diff --git a/docs/README.md b/docs/README.md index 95932edc..0a5bffe1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,15 +1,15 @@
-

Youer 1.21.1

+

Youer 1.21.2

The project is experimental, we are not available, and it is expected that it will not be released stably until after 1.21.2 or 1.22. ### Minecraft NeoForge Hybrid server implementing the Spigot/Bukkit API -[![](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fci.codemc.io%2Fjob%2FMohistMC%2Fjob%2FYouer-1.21.1)](https://ci.codemc.io/job/MohistMC/job/Youer-1.21.1) +[![](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fci.codemc.io%2Fjob%2FMohistMC%2Fjob%2FYouer-1.21.2)](https://ci.codemc.io/job/MohistMC/job/Youer-1.21.2) [![](https://img.shields.io/github/stars/MohistMC/Mohist.svg?label=Stars&logo=github)](https://github.com/MohistMC/Mohist/stargazers) -[![](https://img.shields.io/badge/NeoForge-21.1.4-brightgreen.svg?colorB=26303d)](https://neoforged.net/) +[![](https://img.shields.io/badge/NeoForge-21.2.0-brightgreen.svg?colorB=26303d)](https://neoforged.net/) [![](https://img.shields.io/badge/JDK-21.0.3-brightgreen.svg?colorB=469C00&logo=java)](https://www.azul.com/downloads/?version=java-21-lts#zulu) -[![](https://img.shields.io/badge/Gradle-8.3-brightgreen.svg?colorB=469C00&logo=gradle)](https://docs.gradle.org/8.3/release-notes.html) +[![](https://img.shields.io/badge/Gradle-8.10.2-brightgreen.svg?colorB=469C00&logo=gradle)](https://docs.gradle.org/8.10.2/release-notes.html) [![](https://img.shields.io/bstats/servers/6762?label=bStats)](https://bstats.org/plugin/server-implementation/Mohist/6762) [![](https://badges.crowdin.net/mohist/localized.svg)](https://crowdin.com/project/mohist) [![](https://img.shields.io/discord/311256119005937665.svg?color=%237289da&label=Discord&logo=discord&logoColor=%237289da)](https://discord.gg/mohistmc) @@ -21,7 +21,7 @@ Progress ------ -- [x] Rectify NeoForge([**bdda6d296d**](https://github.com/neoforged/NeoForge/commit/bdda6d296d)) +- [x] Rectify NeoForge([**91303b6970**](https://github.com/neoforged/NeoForge/commit/91303b6970)) - [ ] Start patch * [x] Bukkit([**69fa4695**](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/69fa4695)) * [ ] CraftBukkit([**661afb43c**](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/661afb43c)) diff --git a/gradle.properties b/gradle.properties index dda819ee..79248906 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,15 +9,15 @@ org.gradle.debug=false java_version=21 -minecraft_version=1.21.1 -neoform_version=20240808.144430 +minecraft_version=1.21.2 +neoform_version=20241022.151510 # on snapshot versions, used to prefix the version -neoforge_snapshot_next_stable=22.0 +neoforge_snapshot_next_stable=21.3 mergetool_version=2.0.0 accesstransformers_version=10.0.1 coremods_version=6.0.4 -eventbus_version=8.0.1 +eventbus_version=8.0.2 modlauncher_version=11.0.4 securejarhandler_version=3.0.8 bootstraplauncher_version=2.0.2 @@ -25,13 +25,12 @@ asm_version=9.7 installer_version=2.1.+ mixin_version=0.15.2+mixin.0.8.7 terminalconsoleappender_version=1.3.0 -jline_version=3.12.+ nightconfig_version=3.8.0 jetbrains_annotations_version=24.0.1 slf4j_api_version=2.0.7 apache_maven_artifact_version=3.8.5 jarjar_version=0.4.1 -fancy_mod_loader_version=4.0.24 +fancy_mod_loader_version=4.0.29 mojang_logging_version=1.1.1 log4j_version=2.22.1 guava_version=31.1.2-jre @@ -54,4 +53,5 @@ neogradle.subsystems.conventions.sourcesets.automatic-inclusion=false neogradle.subsystems.conventions.enabled=false neogradle.subsystems.tools.jst=net.neoforged.jst:jst-cli-bundle:1.0.45 + neoforge_version=21.0.52-beta \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0aaefbca..df97d72b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/nms-patches/net/minecraft/CrashReport.patch b/nms-patches/net/minecraft/CrashReport.patch new file mode 100644 index 00000000..0c5cb0b0 --- /dev/null +++ b/nms-patches/net/minecraft/CrashReport.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/CrashReport.java ++++ b/net/minecraft/CrashReport.java +@@ -36,6 +36,7 @@ + public CrashReport(String s, Throwable throwable) { + this.title = s; + this.exception = throwable; ++ this.systemReport.setDetail("CraftBukkit Information", new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit + } + + public String getTitle() { diff --git a/nms-patches/net/minecraft/advancements/AdvancementHolder.patch b/nms-patches/net/minecraft/advancements/AdvancementHolder.patch new file mode 100644 index 00000000..1b57fcdb --- /dev/null +++ b/nms-patches/net/minecraft/advancements/AdvancementHolder.patch @@ -0,0 +1,25 @@ +--- a/net/minecraft/advancements/AdvancementHolder.java ++++ b/net/minecraft/advancements/AdvancementHolder.java +@@ -6,6 +6,11 @@ + import net.minecraft.network.codec.StreamCodec; + import net.minecraft.resources.MinecraftKey; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.advancement.CraftAdvancement; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++// CraftBukkit end ++ + public record AdvancementHolder(MinecraftKey id, Advancement value) { + + public static final StreamCodec STREAM_CODEC = StreamCodec.composite(MinecraftKey.STREAM_CODEC, AdvancementHolder::id, Advancement.STREAM_CODEC, AdvancementHolder::value, AdvancementHolder::new); +@@ -38,4 +43,10 @@ + public String toString() { + return this.id.toString(); + } ++ ++ // CraftBukkit start ++ public final org.bukkit.advancement.Advancement toBukkit() { ++ return new CraftAdvancement(this); ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/net/minecraft/advancements/AdvancementTree.patch b/nms-patches/net/minecraft/advancements/AdvancementTree.patch new file mode 100644 index 00000000..a09551db --- /dev/null +++ b/nms-patches/net/minecraft/advancements/AdvancementTree.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/advancements/AdvancementTree.java ++++ b/net/minecraft/advancements/AdvancementTree.java +@@ -77,7 +77,7 @@ + } + } + +- AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size()); ++ // AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size()); // CraftBukkit - moved to AdvancementDataWorld#reload + } + + private boolean tryInsert(AdvancementHolder advancementholder) { diff --git a/nms-patches/net/minecraft/commands/CommandDispatcher.patch b/nms-patches/net/minecraft/commands/CommandDispatcher.patch index ff91e67a..8f5612fb 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 -@@ -135,6 +135,14 @@ +@@ -139,6 +139,14 @@ import net.minecraft.world.level.GameRules; import org.slf4j.Logger; @@ -15,7 +15,7 @@ public class CommandDispatcher { private static final ThreadLocal> CURRENT_EXECUTION_CONTEXT = new ThreadLocal(); -@@ -147,6 +155,7 @@ +@@ -151,6 +159,7 @@ private final com.mojang.brigadier.CommandDispatcher dispatcher = new com.mojang.brigadier.CommandDispatcher(); public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype, CommandBuildContext commandbuildcontext) { @@ -23,7 +23,7 @@ CommandAdvancement.register(this.dispatcher); CommandAttribute.register(this.dispatcher, commandbuildcontext); CommandExecute.register(this.dispatcher, commandbuildcontext); -@@ -247,6 +256,11 @@ +@@ -252,6 +261,11 @@ CommandPublish.register(this.dispatcher); } @@ -35,7 +35,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -257,18 +271,65 @@ +@@ -262,18 +276,65 @@ return new ParseResults(commandcontextbuilder1, parseresults.getReader(), parseresults.getExceptions()); } @@ -95,7 +95,7 @@ + public void performCommand(ParseResults parseresults, String s, String label) { // CraftBukkit CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) parseresults.getContext().getSource(); - commandlistenerwrapper.getServer().getProfiler().push(() -> { + Profiler.get().push(() -> { return "/" + s; }); - ContextChain contextchain = finishParsing(parseresults, s, commandlistenerwrapper); @@ -103,7 +103,7 @@ try { if (contextchain != null) { -@@ -302,7 +363,7 @@ +@@ -307,7 +368,7 @@ } @Nullable @@ -112,7 +112,7 @@ try { validateParseResults(parseresults); return (ContextChain) ContextChain.tryFlatten(parseresults.getContext().build(s)).orElseThrow(() -> { -@@ -313,7 +374,7 @@ +@@ -318,7 +379,7 @@ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { int i = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> { @@ -121,7 +121,7 @@ }); if (i > 10) { -@@ -363,7 +424,7 @@ +@@ -368,7 +429,7 @@ executioncontext1.close(); } finally { @@ -130,7 +130,7 @@ } } else { consumer.accept(executioncontext); -@@ -372,11 +433,36 @@ +@@ -377,11 +438,36 @@ } public void sendCommands(EntityPlayer entityplayer) { @@ -168,7 +168,7 @@ entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode)); } -@@ -387,7 +473,7 @@ +@@ -392,7 +478,7 @@ CommandNode commandnode2 = (CommandNode) iterator.next(); if (commandnode2.canUse(commandlistenerwrapper)) { @@ -177,7 +177,7 @@ argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -410,7 +496,7 @@ +@@ -415,7 +501,7 @@ argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); } @@ -186,7 +186,7 @@ map.put(commandnode2, commandnode3); commandnode1.addChild(commandnode3); -@@ -471,7 +557,7 @@ +@@ -481,7 +567,7 @@ } private HolderLookup.b.a createLookup(final HolderLookup.b holderlookup_b) { diff --git a/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch b/nms-patches/net/minecraft/commands/CommandListenerWrapper.patch index 092f48ad..940733b4 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 -@@ -44,6 +44,8 @@ +@@ -46,6 +46,8 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -9,7 +9,7 @@ public class CommandListenerWrapper implements ExecutionCommandSource, ICompletionProvider { public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(IChatBaseComponent.translatable("permissions.requires.player")); -@@ -63,6 +65,7 @@ +@@ -65,6 +67,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, CommandResultCallback.EMPTY, ArgumentAnchor.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(minecraftserver)); -@@ -169,9 +172,23 @@ +@@ -171,9 +174,23 @@ @Override public boolean hasPermission(int i) { @@ -41,16 +41,16 @@ public Vec3D getPosition() { return this.worldPosition; } -@@ -300,7 +317,7 @@ +@@ -302,7 +319,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -- if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getGameProfile())) { -+ if (entityplayer != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit +- if (entityplayer.commandSource() != this.source && this.server.getPlayerList().isOp(entityplayer.getGameProfile())) { ++ if (entityplayer.commandSource() != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit entityplayer.sendSystemMessage(ichatmutablecomponent); } } -@@ -393,4 +410,10 @@ +@@ -400,4 +417,10 @@ public boolean isSilent() { return this.silent; } diff --git a/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch b/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch index 4e271a50..d9fb2ed9 100644 --- a/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch +++ b/nms-patches/net/minecraft/core/cauldron/CauldronInteraction.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/cauldron/CauldronInteraction.java +++ b/net/minecraft/core/cauldron/CauldronInteraction.java -@@ -34,9 +34,15 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -36,14 +36,20 @@ import net.minecraft.world.level.gameevent.GameEvent; + import net.minecraft.world.level.material.Fluid; +// CraftBukkit start +import org.bukkit.event.block.CauldronLevelChangeEvent; @@ -11,27 +11,28 @@ public interface CauldronInteraction { Map INTERACTIONS = new Object2ObjectArrayMap(); -+ // CraftBukkit start - decompile error -+ /* - Codec CODEC; - CauldronInteraction.a EMPTY; - CauldronInteraction.a WATER; -@@ -48,6 +54,8 @@ - CauldronInteraction SHULKER_BOX; - CauldronInteraction BANNER; - CauldronInteraction DYED_ITEM; -+ */ +- Codec CODEC; +- CauldronInteraction.a EMPTY; +- CauldronInteraction.a WATER; +- CauldronInteraction.a LAVA; +- CauldronInteraction.a POWDER_SNOW; ++ // CraftBukkit start - decompile errors ++ Codec CODEC = Codec.stringResolver(CauldronInteraction.a::name, CauldronInteraction.INTERACTIONS::get); ++ CauldronInteraction.a EMPTY = newInteractionMap("empty"); ++ CauldronInteraction.a WATER = newInteractionMap("water"); ++ CauldronInteraction.a LAVA = newInteractionMap("lava"); ++ CauldronInteraction.a POWDER_SNOW = newInteractionMap("powder_snow"); + // CraftBukkit end static CauldronInteraction.a newInteractionMap(String s) { Object2ObjectOpenHashMap object2objectopenhashmap = new Object2ObjectOpenHashMap(); -@@ -72,12 +80,17 @@ +@@ -68,12 +74,17 @@ if (potioncontents != null && potioncontents.is(Potions.WATER)) { if (!world.isClientSide) { + // CraftBukkit start + if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { -+ return ItemInteractionResult.SUCCESS; ++ return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end Item item = itemstack.getItem(); @@ -44,13 +45,13 @@ world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition); } -@@ -97,12 +110,17 @@ +@@ -93,12 +104,17 @@ }); map1.put(Items.GLASS_BOTTLE, (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { if (!world.isClientSide) { + // CraftBukkit start + if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) { -+ return ItemInteractionResult.SUCCESS; ++ return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end Item item = itemstack.getItem(); @@ -63,13 +64,13 @@ world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition); } -@@ -117,10 +135,15 @@ +@@ -113,10 +129,15 @@ if (potioncontents != null && potioncontents.is(Potions.WATER)) { if (!world.isClientSide) { + // CraftBukkit start + if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.cycle(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { -+ return ItemInteractionResult.SUCCESS; ++ return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE))); @@ -80,13 +81,13 @@ world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition); } -@@ -198,12 +221,17 @@ - return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; +@@ -194,12 +215,17 @@ + return EnumInteractionResult.TRY_WITH_EMPTY_HAND; } else { if (!world.isClientSide) { + // CraftBukkit start + if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) { -+ return ItemInteractionResult.SUCCESS; ++ return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end Item item = itemstack.getItem(); @@ -99,13 +100,13 @@ world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition); } -@@ -214,12 +242,17 @@ +@@ -210,12 +236,17 @@ - static ItemInteractionResult emptyBucket(World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) { + static EnumInteractionResult emptyBucket(World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) { if (!world.isClientSide) { + // CraftBukkit start + if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) { -+ return ItemInteractionResult.SUCCESS; ++ return EnumInteractionResult.SUCCESS; + } + // CraftBukkit end Item item = itemstack.getItem(); @@ -118,113 +119,74 @@ world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition); } -@@ -227,76 +260,89 @@ - return ItemInteractionResult.sidedSuccess(world.isClientSide); - } - -- static { -- Function function = CauldronInteraction.a::name; -- Map map = CauldronInteraction.INTERACTIONS; -- -- Objects.requireNonNull(map); -- CODEC = Codec.stringResolver(function, map::get); -- EMPTY = newInteractionMap("empty"); -- WATER = newInteractionMap("water"); -- LAVA = newInteractionMap("lava"); -- POWDER_SNOW = newInteractionMap("powder_snow"); -- FILL_WATER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { -+ // CraftBukkit start - decompile errors -+ // static { -+ Codec CODEC = Codec.stringResolver(CauldronInteraction.a::name, CauldronInteraction.INTERACTIONS::get); -+ CauldronInteraction.a EMPTY = newInteractionMap("empty"); -+ CauldronInteraction.a WATER = newInteractionMap("water"); -+ CauldronInteraction.a LAVA = newInteractionMap("lava"); -+ CauldronInteraction.a POWDER_SNOW = newInteractionMap("powder_snow"); -+ CauldronInteraction FILL_WATER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { - return emptyBucket(world, blockposition, entityhuman, enumhand, itemstack, (IBlockData) Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), SoundEffects.BUCKET_EMPTY); - }; -- FILL_LAVA = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { -+ CauldronInteraction FILL_LAVA = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { - return emptyBucket(world, blockposition, entityhuman, enumhand, itemstack, Blocks.LAVA_CAULDRON.defaultBlockState(), SoundEffects.BUCKET_EMPTY_LAVA); - }; -- FILL_POWDER_SNOW = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { -+ CauldronInteraction FILL_POWDER_SNOW = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { - return emptyBucket(world, blockposition, entityhuman, enumhand, itemstack, (IBlockData) Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), SoundEffects.BUCKET_EMPTY_POWDER_SNOW); - }; -- SHULKER_BOX = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { -+ CauldronInteraction SHULKER_BOX = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { -+ // CraftBukkit end - Block block = Block.byItem(itemstack.getItem()); - - if (!(block instanceof BlockShulkerBox)) { - return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; - } else { - if (!world.isClientSide) { -+ // CraftBukkit start -+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) { -+ return ItemInteractionResult.SUCCESS; -+ } -+ // CraftBukkit end - ItemStack itemstack1 = itemstack.transmuteCopy(Blocks.SHULKER_BOX, 1); - - entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false)); - entityhuman.awardStat(StatisticList.CLEAN_SHULKER_BOX); -- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); -+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit - } +@@ -242,11 +273,16 @@ + return EnumInteractionResult.TRY_WITH_EMPTY_HAND; + } else { + if (!world.isClientSide) { ++ // CraftBukkit start ++ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) { ++ return EnumInteractionResult.SUCCESS; ++ } ++ // CraftBukkit end + ItemStack itemstack1 = itemstack.transmuteCopy(Blocks.SHULKER_BOX, 1); - return ItemInteractionResult.sidedSuccess(world.isClientSide); + entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false)); + entityhuman.awardStat(StatisticList.CLEAN_SHULKER_BOX); +- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); ++ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit } - }; -- BANNER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { -+ CauldronInteraction BANNER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { // CraftBukkit - decompile error - BannerPatternLayers bannerpatternlayers = (BannerPatternLayers) itemstack.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY); - - if (bannerpatternlayers.layers().isEmpty()) { - return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; - } else { - if (!world.isClientSide) { -+ // CraftBukkit start -+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) { -+ return ItemInteractionResult.SUCCESS; -+ } -+ // CraftBukkit end - ItemStack itemstack1 = itemstack.copyWithCount(1); - itemstack1.set(DataComponents.BANNER_PATTERNS, bannerpatternlayers.removeLast()); - entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false)); - entityhuman.awardStat(StatisticList.CLEAN_BANNER); -- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); -+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit - } + return EnumInteractionResult.SUCCESS; +@@ -260,12 +296,17 @@ + return EnumInteractionResult.TRY_WITH_EMPTY_HAND; + } else { + if (!world.isClientSide) { ++ // CraftBukkit start ++ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) { ++ return EnumInteractionResult.SUCCESS; ++ } ++ // CraftBukkit end + ItemStack itemstack1 = itemstack.copyWithCount(1); - return ItemInteractionResult.sidedSuccess(world.isClientSide); + itemstack1.set(DataComponents.BANNER_PATTERNS, bannerpatternlayers.removeLast()); + entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false)); + entityhuman.awardStat(StatisticList.CLEAN_BANNER); +- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); ++ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit } - }; -- DYED_ITEM = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { -+ CauldronInteraction DYED_ITEM = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { // CraftBukkit - decompile error - if (!itemstack.is(TagsItem.DYEABLE)) { - return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; - } else if (!itemstack.has(DataComponents.DYED_COLOR)) { - return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; - } else { - if (!world.isClientSide) { -+ // CraftBukkit start -+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) { -+ return ItemInteractionResult.SUCCESS; -+ } -+ // CraftBukkit end - itemstack.remove(DataComponents.DYED_COLOR); - entityhuman.awardStat(StatisticList.CLEAN_ARMOR); -- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); -+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit - } - return ItemInteractionResult.sidedSuccess(world.isClientSide); + return EnumInteractionResult.SUCCESS; +@@ -279,9 +320,14 @@ + return EnumInteractionResult.TRY_WITH_EMPTY_HAND; + } else { + if (!world.isClientSide) { ++ // CraftBukkit start ++ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) { ++ return EnumInteractionResult.SUCCESS; ++ } ++ // CraftBukkit end + itemstack.remove(DataComponents.DYED_COLOR); + entityhuman.awardStat(StatisticList.CLEAN_ARMOR); +- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); ++ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit } - }; -- } -+ // } // CraftBukkit - decompile error + + return EnumInteractionResult.SUCCESS; +@@ -294,6 +340,8 @@ + return fluid.is(TagsFluid.WATER); + } + ++ // CraftBukkit start - decompile errors ++ /* + static { + Function function = CauldronInteraction.a::name; + Map map = CauldronInteraction.INTERACTIONS; +@@ -305,6 +353,8 @@ + LAVA = newInteractionMap("lava"); + POWDER_SNOW = newInteractionMap("powder_snow"); + } ++ */ ++ // CraftBukkit end public static record a(String name, Map map) { diff --git a/nms-patches/net/minecraft/core/component/DataComponentPatch.patch b/nms-patches/net/minecraft/core/component/DataComponentPatch.patch new file mode 100644 index 00000000..5e70217b --- /dev/null +++ b/nms-patches/net/minecraft/core/component/DataComponentPatch.patch @@ -0,0 +1,63 @@ +--- a/net/minecraft/core/component/DataComponentPatch.java ++++ b/net/minecraft/core/component/DataComponentPatch.java +@@ -61,7 +61,7 @@ + } + } + +- return reference2objectmap; ++ return (Reference2ObjectMap) reference2objectmap; // CraftBukkit - decompile error + }); + public static final StreamCodec STREAM_CODEC = new StreamCodec() { + public DataComponentPatch decode(RegistryFriendlyByteBuf registryfriendlybytebuf) { +@@ -144,7 +144,7 @@ + } + + private static void encodeComponent(RegistryFriendlyByteBuf registryfriendlybytebuf, DataComponentType datacomponenttype, Object object) { +- datacomponenttype.streamCodec().encode(registryfriendlybytebuf, object); ++ datacomponenttype.streamCodec().encode(registryfriendlybytebuf, (T) object); // CraftBukkit - decompile error + } + }; + private static final String REMOVED_PREFIX = "!"; +@@ -271,6 +271,42 @@ + + a() {} + ++ // CraftBukkit start ++ public void copy(DataComponentPatch orig) { ++ this.map.putAll(orig.map); ++ } ++ ++ public void clear(DataComponentType type) { ++ this.map.remove(type); ++ } ++ ++ public boolean isSet(DataComponentType type) { ++ return map.containsKey(type); ++ } ++ ++ public boolean isEmpty() { ++ return this.map.isEmpty(); ++ } ++ ++ @Override ++ public boolean equals(Object object) { ++ if (this == object) { ++ return true; ++ } ++ ++ if (object instanceof DataComponentPatch.a patch) { ++ return this.map.equals(patch.map); ++ } ++ ++ return false; ++ } ++ ++ @Override ++ public int hashCode() { ++ return this.map.hashCode(); ++ } ++ // CraftBukkit end ++ + public DataComponentPatch.a set(DataComponentType datacomponenttype, T t0) { + this.map.put(datacomponenttype, Optional.of(t0)); + return this; diff --git a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch index e0360bdb..9bef9068 100644 --- a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch +++ b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/DispenseBehaviorBoat.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorBoat.java -@@ -13,6 +13,12 @@ +@@ -12,6 +12,12 @@ import net.minecraft.world.level.block.BlockDispenser; import net.minecraft.world.phys.Vec3D; @@ -12,13 +12,11 @@ + public class DispenseBehaviorBoat extends DispenseBehaviorItem { - private final DispenseBehaviorItem defaultDispenseItemBehavior; -@@ -51,13 +57,41 @@ + private final DispenseBehaviorItem defaultDispenseItemBehavior = new DispenseBehaviorItem(); +@@ -43,14 +49,40 @@ d4 = 0.0D; } -- Object object = this.isChestBoat ? new ChestBoat(worldserver, d1, d2 + d4, d3) : new EntityBoat(worldserver, d1, d2 + d4, d3); -+ // Object object = this.isChestBoat ? new ChestBoat(worldserver, d1, d2 + d4, d3) : new EntityBoat(worldserver, d1, d2 + d4, d3); + // CraftBukkit start + ItemStack itemstack1 = itemstack.split(1); + org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos()); @@ -44,17 +42,18 @@ + return itemstack; + } + } -+ -+ EntityBoat 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 + AbstractBoat abstractboat = (AbstractBoat) this.type.create(worldserver, EntitySpawnReason.DISPENSER); - EntityTypes.createDefaultStackConfig(worldserver, itemstack, (EntityHuman) null).accept(object); - ((EntityBoat) object).setVariant(this.type); - ((EntityBoat) object).setYRot(enumdirection.toYRot()); -- worldserver.addFreshEntity((Entity) object); -- itemstack.shrink(1); -+ if (!worldserver.addFreshEntity((Entity) object)) itemstack.grow(1); // CraftBukkit -+ // itemstack.shrink(1); // CraftBukkit - handled during event processing - return itemstack; - } + if (abstractboat != null) { +- abstractboat.setInitialPos(d1, d2 + d4, d3); ++ abstractboat.setInitialPos(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); // CraftBukkit + EntityTypes.createDefaultStackConfig(worldserver, itemstack, (EntityHuman) null).accept(abstractboat); + abstractboat.setYRot(enumdirection.toYRot()); +- worldserver.addFreshEntity(abstractboat); +- itemstack.shrink(1); ++ if (!worldserver.addFreshEntity(abstractboat)) itemstack.grow(1); // CraftBukkit ++ // itemstack.shrink(1); // CraftBukkit - handled during event processing + } + return itemstack; diff --git a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch index cad1f786..17073b18 100644 --- a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch +++ b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorProjectile.patch @@ -14,11 +14,12 @@ public class DispenseBehaviorProjectile extends DispenseBehaviorItem { private final ProjectileItem projectileItem; -@@ -32,9 +39,38 @@ +@@ -31,8 +38,37 @@ + EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); IPosition iposition = this.dispenseConfig.positionFunction().getDispensePosition(sourceblock, enumdirection); - IProjectile iprojectile = this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection); -- this.projectileItem.shoot(iprojectile, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); +- IProjectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection), worldserver, itemstack, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); +- itemstack.shrink(1); + // CraftBukkit start + // this.projectileItem.shoot(iprojectile, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); + ItemStack itemstack1 = itemstack.split(1); @@ -46,12 +47,10 @@ + } + } + -+ this.projectileItem.shoot(iprojectile, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); ++ IProjectile iprojectile = IProjectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection), worldserver, itemstack, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); + ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(sourceblock.blockEntity()); -+ // CraftBukkit end - worldserver.addFreshEntity(iprojectile); -- itemstack.shrink(1); + // itemstack.shrink(1); // CraftBukkit - Handled during event processing ++ // CraftBukkit end return itemstack; } diff --git a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch index ff8376c9..6e092687 100644 --- a/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch +++ b/nms-patches/net/minecraft/core/dispenser/DispenseBehaviorShears.patch @@ -45,8 +45,8 @@ if (!worldserver.isClientSide()) { BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); -- this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition)); -+ this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, bukkitBlock, craftItem)); // CraftBukkit +- this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, itemstack)); ++ this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, itemstack, bukkitBlock, craftItem)); // CraftBukkit if (this.isSuccess()) { itemstack.hurtAndBreak(1, worldserver, (EntityPlayer) null, (item) -> { }); @@ -54,8 +54,8 @@ return false; } -- private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition) { -+ private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args +- private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { ++ private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args List list = worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS); Iterator iterator = list.iterator(); @@ -68,6 +68,6 @@ + continue; + } + // CraftBukkit end - ishearable.shear(SoundCategory.BLOCKS); + ishearable.shear(worldserver, SoundCategory.BLOCKS, itemstack); worldserver.gameEvent((Entity) null, (Holder) GameEvent.SHEAR, blockposition); return true; diff --git a/nms-patches/net/minecraft/world/item/ItemArmor.patch b/nms-patches/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.patch similarity index 77% rename from nms-patches/net/minecraft/world/item/ItemArmor.patch rename to nms-patches/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.patch index 1c25dc58..4052a9e3 100644 --- a/nms-patches/net/minecraft/world/item/ItemArmor.patch +++ b/nms-patches/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.patch @@ -1,28 +1,29 @@ ---- a/net/minecraft/world/item/ItemArmor.java -+++ b/net/minecraft/world/item/ItemArmor.java -@@ -29,6 +29,12 @@ +--- a/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java ++++ b/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java +@@ -10,6 +10,13 @@ import net.minecraft.world.level.block.BlockDispenser; import net.minecraft.world.phys.AxisAlignedBB; +// CraftBukkit start ++import net.minecraft.world.level.World; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.block.BlockDispenseArmorEvent; +// CraftBukkit end + - public class ItemArmor extends Item implements Equipable { + public class EquipmentDispenseItemBehavior extends DispenseBehaviorItem { - public static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() { -@@ -51,8 +57,34 @@ - EntityLiving entityliving = (EntityLiving) list.get(0); + public static final EquipmentDispenseItemBehavior INSTANCE = new EquipmentDispenseItemBehavior(); +@@ -34,7 +41,34 @@ EnumItemSlot enumitemslot = entityliving.getEquipmentSlotForItem(itemstack); ItemStack itemstack1 = itemstack.split(1); + +- entityliving.setItemSlot(enumitemslot, itemstack1); + // CraftBukkit start + World world = sourceblock.level(); + org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - -- entityliving.setItemSlot(enumitemslot, itemstack1); ++ + BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity()); + if (!BlockDispenser.eventFired) { + world.getCraftServer().getPluginManager().callEvent(event); @@ -38,7 +39,7 @@ + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) { ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) { + idispensebehavior.dispense(sourceblock, eventStack); + return true; + } @@ -47,5 +48,5 @@ + entityliving.setItemSlot(enumitemslot, CraftItemStack.asNMSCopy(event.getItem())); + // CraftBukkit end if (entityliving instanceof EntityInsentient) { - ((EntityInsentient) entityliving).setDropChance(enumitemslot, 2.0F); - ((EntityInsentient) entityliving).setPersistenceRequired(); + EntityInsentient entityinsentient = (EntityInsentient) entityliving; + diff --git a/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch b/nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch index 054da80d..502a05bc 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 -@@ -67,6 +67,22 @@ +@@ -63,6 +63,22 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import org.slf4j.Logger; @@ -23,7 +23,7 @@ public interface IDispenseBehavior { Logger LOGGER = LogUtils.getLogger(); -@@ -94,14 +110,42 @@ +@@ -90,14 +106,42 @@ EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack); @@ -55,7 +55,7 @@ + } + try { - entitytypes.spawn(sourceblock.level(), itemstack, (EntityHuman) null, sourceblock.pos().relative(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false); + entitytypes.spawn(sourceblock.level(), itemstack, (EntityHuman) null, sourceblock.pos().relative(enumdirection), EntitySpawnReason.DISPENSER, enumdirection != EnumDirection.UP, false); } catch (Exception exception) { - null.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", sourceblock.pos(), exception); + LOGGER.error("Error while dispensing spawn egg from dispenser at {}", sourceblock.pos(), exception); // CraftBukkit - decompile error @@ -68,7 +68,7 @@ sourceblock.level().gameEvent((Entity) null, (Holder) GameEvent.ENTITY_PLACE, sourceblock.pos()); return itemstack; } -@@ -120,13 +164,41 @@ +@@ -116,13 +160,41 @@ EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); BlockPosition blockposition = sourceblock.pos().relative(enumdirection); WorldServer worldserver = sourceblock.level(); @@ -103,7 +103,7 @@ Consumer consumer = EntityTypes.appendDefaultStackConfig((entityarmorstand) -> { entityarmorstand.setYRot(enumdirection.toYRot()); }, worldserver, itemstack, (EntityHuman) null); - EntityArmorStand entityarmorstand = (EntityArmorStand) EntityTypes.ARMOR_STAND.spawn(worldserver, consumer, blockposition, EnumMobSpawn.DISPENSER, false, false); + EntityArmorStand entityarmorstand = (EntityArmorStand) EntityTypes.ARMOR_STAND.spawn(worldserver, consumer, blockposition, EntitySpawnReason.DISPENSER, false, false); if (entityarmorstand != null) { - itemstack.shrink(1); @@ -111,7 +111,7 @@ } return itemstack; -@@ -145,7 +217,34 @@ +@@ -141,7 +213,34 @@ }); if (!list.isEmpty()) { @@ -137,7 +137,7 @@ + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) { ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) { + idispensebehavior.dispense(sourceblock, eventStack); + return itemstack; + } @@ -147,44 +147,7 @@ this.setSuccess(true); return itemstack; } else { -@@ -172,7 +271,35 @@ - entityhorseabstract = (EntityHorseAbstract) iterator1.next(); - } while (!entityhorseabstract.isBodyArmorItem(itemstack) || entityhorseabstract.isWearingBodyArmor() || !entityhorseabstract.isTamed()); - -- entityhorseabstract.setBodyArmorItem(itemstack.split(1)); -+ // CraftBukkit start -+ ItemStack itemstack1 = itemstack.split(1); -+ WorldServer world = sourceblock.level(); -+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); -+ -+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorseabstract.getBukkitEntity()); -+ if (!BlockDispenser.eventFired) { -+ world.getCraftServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ itemstack.grow(1); -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ itemstack.grow(1); -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) { -+ idispensebehavior.dispense(sourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ -+ entityhorseabstract.setBodyArmorItem(CraftItemStack.asNMSCopy(event.getItem())); -+ // CraftBukkit end - this.setSuccess(true); - return itemstack; - } -@@ -215,9 +342,35 @@ +@@ -166,9 +265,35 @@ } entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next(); @@ -210,7 +173,7 @@ + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) { ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) { + idispensebehavior.dispense(sourceblock, eventStack); + return itemstack; + } @@ -222,7 +185,7 @@ this.setSuccess(true); return itemstack; } -@@ -249,6 +402,38 @@ +@@ -202,6 +327,38 @@ BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); WorldServer worldserver = sourceblock.level(); @@ -261,7 +224,7 @@ if (dispensiblecontaineritem.emptyContents((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) { dispensiblecontaineritem.checkExtraContent((EntityHuman) null, worldserver, itemstack, blockposition); return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(Items.BUCKET)); -@@ -276,7 +461,7 @@ +@@ -229,7 +386,7 @@ Block block = iblockdata.getBlock(); if (block instanceof IFluidSource ifluidsource) { @@ -270,7 +233,7 @@ if (itemstack1.isEmpty()) { return super.execute(sourceblock, itemstack); -@@ -284,6 +469,32 @@ +@@ -237,6 +394,32 @@ worldserver.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition); Item item = itemstack1.getItem(); @@ -303,7 +266,7 @@ return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(item)); } } else { -@@ -296,16 +507,44 @@ +@@ -249,16 +432,44 @@ protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) { WorldServer worldserver = sourceblock.level(); @@ -351,7 +314,7 @@ BlockTNT.explode(worldserver, blockposition); worldserver.removeBlock(blockposition, false); } else { -@@ -330,12 +569,62 @@ +@@ -283,12 +494,62 @@ this.setSuccess(true); WorldServer worldserver = sourceblock.level(); BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); @@ -414,7 +377,7 @@ return itemstack; } -@@ -345,12 +634,41 @@ +@@ -298,12 +559,41 @@ protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) { WorldServer worldserver = sourceblock.level(); BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); @@ -458,7 +421,7 @@ return itemstack; } }); -@@ -375,6 +693,30 @@ +@@ -314,6 +604,30 @@ EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); BlockPosition blockposition = sourceblock.pos().relative(enumdirection); @@ -489,7 +452,7 @@ if (worldserver.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(worldserver, blockposition, itemstack)) { worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, RotationSegment.convertToSegment(enumdirection)), 3); worldserver.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_PLACE, blockposition); -@@ -400,6 +742,30 @@ +@@ -339,6 +653,30 @@ BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; @@ -520,7 +483,7 @@ if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) { if (!worldserver.isClientSide) { worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3); -@@ -438,6 +804,30 @@ +@@ -377,6 +715,30 @@ BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); IBlockData iblockdata = worldserver.getBlockState(blockposition); @@ -551,7 +514,7 @@ if (iblockdata.is(TagsBlock.BEEHIVES, (blockbase_blockdata) -> { return blockbase_blockdata.hasProperty(BlockBeehive.HONEY_LEVEL) && blockbase_blockdata.getBlock() instanceof BlockBeehive; }) && (Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL) >= 5) { -@@ -487,6 +877,31 @@ +@@ -426,6 +788,31 @@ this.setSuccess(false); return itemstack; } else { @@ -574,7 +537,7 @@ + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) { ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) { + idispensebehavior.dispense(sourceblock, eventStack); + return itemstack; + } diff --git a/nms-patches/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.patch b/nms-patches/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.patch new file mode 100644 index 00000000..5ea81d2e --- /dev/null +++ b/nms-patches/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.patch @@ -0,0 +1,59 @@ +--- a/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java ++++ b/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java +@@ -16,6 +16,12 @@ + import net.minecraft.world.level.block.state.properties.BlockPropertyTrackPosition; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.event.block.BlockDispenseEvent; ++// CraftBukkit end ++ + public class MinecartDispenseItemBehavior extends DispenseBehaviorItem { + + private final DispenseBehaviorItem defaultDispenseItemBehavior = new DispenseBehaviorItem(); +@@ -62,11 +68,40 @@ + } + + Vec3D vec3d1 = new Vec3D(d0, d1 + d3, d2); +- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, vec3d1.x, vec3d1.y, vec3d1.z, this.entityType, EntitySpawnReason.DISPENSER, itemstack, (EntityHuman) null); ++ // CraftBukkit start ++ // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, vec3d1.x, vec3d1.y, vec3d1.z, this.entityType, EntitySpawnReason.DISPENSER, itemstack, (EntityHuman) null); ++ ItemStack itemstack1 = itemstack.split(1); ++ org.bukkit.block.Block block2 = CraftBlock.at(worldserver, sourceblock.pos()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(vec3d1.x, vec3d1.y, vec3d1.z)); ++ if (!BlockDispenser.eventFired) { ++ worldserver.getCraftServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ itemstack.grow(1); ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ itemstack.grow(1); ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { ++ idispensebehavior.dispense(sourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ ++ itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); ++ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.entityType, EntitySpawnReason.DISPENSER, itemstack1, (EntityHuman) null); + + if (entityminecartabstract != null) { +- worldserver.addFreshEntity(entityminecartabstract); +- itemstack.shrink(1); ++ if (!worldserver.addFreshEntity(entityminecartabstract)) itemstack.grow(1); ++ // itemstack.shrink(1); // CraftBukkit - handled during event processing ++ // CraftBukkit end + } + + return itemstack; diff --git a/nms-patches/net/minecraft/nbt/NBTCompressedStreamTools.patch b/nms-patches/net/minecraft/nbt/NBTCompressedStreamTools.patch new file mode 100644 index 00000000..e7fb3c79 --- /dev/null +++ b/nms-patches/net/minecraft/nbt/NBTCompressedStreamTools.patch @@ -0,0 +1,7 @@ +--- a/net/minecraft/nbt/NBTCompressedStreamTools.java ++++ b/net/minecraft/nbt/NBTCompressedStreamTools.java +@@ -1,3 +1,4 @@ ++// mc-dev import + package net.minecraft.nbt; + + import java.io.BufferedOutputStream; diff --git a/nms-patches/net/minecraft/nbt/NBTTagByteArray.patch b/nms-patches/net/minecraft/nbt/NBTTagByteArray.patch new file mode 100644 index 00000000..1bd3e4da --- /dev/null +++ b/nms-patches/net/minecraft/nbt/NBTTagByteArray.patch @@ -0,0 +1,7 @@ +--- a/net/minecraft/nbt/NBTTagByteArray.java ++++ b/net/minecraft/nbt/NBTTagByteArray.java +@@ -1,3 +1,4 @@ ++// mc-dev import + package net.minecraft.nbt; + + import java.io.DataInput; diff --git a/nms-patches/net/minecraft/nbt/NBTTagIntArray.patch b/nms-patches/net/minecraft/nbt/NBTTagIntArray.patch new file mode 100644 index 00000000..d62cce3d --- /dev/null +++ b/nms-patches/net/minecraft/nbt/NBTTagIntArray.patch @@ -0,0 +1,7 @@ +--- a/net/minecraft/nbt/NBTTagIntArray.java ++++ b/net/minecraft/nbt/NBTTagIntArray.java +@@ -1,3 +1,4 @@ ++// mc-dev import + package net.minecraft.nbt; + + import java.io.DataInput; diff --git a/nms-patches/net/minecraft/network/PacketDataSerializer.patch b/nms-patches/net/minecraft/network/PacketDataSerializer.patch index 37573090..459f0978 100644 --- a/nms-patches/net/minecraft/network/PacketDataSerializer.patch +++ b/nms-patches/net/minecraft/network/PacketDataSerializer.patch @@ -51,7 +51,7 @@ BitSet bitset = this.readFixedBitSet(ae.length); EnumSet enumset = EnumSet.noneOf(oclass); -@@ -482,7 +482,7 @@ +@@ -498,7 +498,7 @@ } public > T readEnum(Class oclass) { @@ -60,7 +60,7 @@ } public PacketDataSerializer writeEnum(Enum oenum) { -@@ -549,7 +549,7 @@ +@@ -565,7 +565,7 @@ try { NBTCompressedStreamTools.writeAnyTag((NBTBase) nbtbase, new ByteBufOutputStream(bytebuf)); diff --git a/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch b/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch index 95c8733e..783abb4d 100644 --- a/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch +++ b/nms-patches/net/minecraft/network/chat/IChatBaseComponent.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/IChatBaseComponent.java +++ b/net/minecraft/network/chat/IChatBaseComponent.java -@@ -36,7 +36,22 @@ +@@ -38,7 +38,22 @@ import net.minecraft.util.FormattedString; import net.minecraft.world.level.ChunkCoordIntPair; diff --git a/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch b/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch index 87812ef5..ef25110a 100644 --- a/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch +++ b/nms-patches/net/minecraft/server/AdvancementDataPlayer.patch @@ -15,4 +15,4 @@ + this.player.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancementholder.toBukkit())); // CraftBukkit advancementholder.value().rewards().grant(this.player); advancementholder.value().display().ifPresent((advancementdisplay) -> { - if (advancementdisplay.shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { + if (advancementdisplay.shouldAnnounceChat() && this.player.serverLevel().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { diff --git a/nms-patches/net/minecraft/server/AdvancementDataWorld.patch b/nms-patches/net/minecraft/server/AdvancementDataWorld.patch index be95a05a..258a729f 100644 --- a/nms-patches/net/minecraft/server/AdvancementDataWorld.patch +++ b/nms-patches/net/minecraft/server/AdvancementDataWorld.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/AdvancementDataWorld.java +++ b/net/minecraft/server/AdvancementDataWorld.java -@@ -27,11 +27,15 @@ +@@ -21,10 +21,14 @@ import net.minecraft.util.profiling.GameProfilerFiller; import org.slf4j.Logger; @@ -8,18 +8,17 @@ +import java.util.HashMap; +// CraftBukkit end + - public class AdvancementDataWorld extends ResourceDataJson { + public class AdvancementDataWorld extends ResourceDataJson { private static final Logger LOGGER = LogUtils.getLogger(); - public static final Gson GSON = (new GsonBuilder()).create(); - public Map advancements = Map.of(); + public Map advancements = new HashMap<>(); // CraftBukkit - SPIGOT-7734: mutable private AdvancementTree tree = new AdvancementTree(); private final HolderLookup.a registries; -@@ -55,7 +59,7 @@ - } - +@@ -40,7 +44,7 @@ + this.validate(minecraftkey, advancement); + builder.put(minecraftkey, new AdvancementHolder(minecraftkey, advancement)); }); - this.advancements = builder.buildOrThrow(); + this.advancements = new HashMap<>(builder.buildOrThrow()); // CraftBukkit - SPIGOT-7734: mutable diff --git a/nms-patches/net/minecraft/server/CustomFunctionData.patch b/nms-patches/net/minecraft/server/CustomFunctionData.patch index 21f7645c..419c9c3e 100644 --- a/nms-patches/net/minecraft/server/CustomFunctionData.patch +++ b/nms-patches/net/minecraft/server/CustomFunctionData.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CustomFunctionData.java +++ b/net/minecraft/server/CustomFunctionData.java -@@ -36,7 +36,7 @@ +@@ -37,7 +37,7 @@ } public CommandDispatcher getDispatcher() { diff --git a/nms-patches/net/minecraft/server/DispenserRegistry.patch b/nms-patches/net/minecraft/server/DispenserRegistry.patch index 723d6d05..5d9a0815 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 -@@ -28,6 +28,12 @@ - import net.minecraft.world.level.block.BlockFire; +@@ -29,6 +29,12 @@ + import net.minecraft.world.level.block.state.BlockBase; import org.slf4j.Logger; +// CraftBukkit start @@ -13,7 +13,7 @@ public class DispenserRegistry { public static final PrintStream STDOUT = System.out; -@@ -39,6 +45,23 @@ +@@ -40,6 +46,23 @@ public static void bootStrap() { if (!DispenserRegistry.isBootstrapped) { @@ -37,7 +37,7 @@ DispenserRegistry.isBootstrapped = true; Instant instant = Instant.now(); -@@ -58,6 +81,69 @@ +@@ -59,6 +82,69 @@ wrapStreams(); DispenserRegistry.bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis()); } diff --git a/nms-patches/net/minecraft/server/Main.patch b/nms-patches/net/minecraft/server/Main.patch index 01bf23ca..43088e1c 100644 --- a/nms-patches/net/minecraft/server/Main.patch +++ b/nms-patches/net/minecraft/server/Main.patch @@ -135,7 +135,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); + IRegistry iregistry = worldloader_a.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM); if (dynamic1 != null) { @@ -199,7 +248,7 @@ @@ -150,7 +150,7 @@ @@ -207,7 +256,7 @@ DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties(); - worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration()); + worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(worldloader_a.dataConfiguration().enabledFeatures()), 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()); @@ -213,5 +213,5 @@ - Main.LOGGER.info("Forcing world upgrade!"); + Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelId()); // CraftBukkit WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, iregistrycustom, flag, flag1); - IChatBaseComponent ichatbasecomponent = null; + try { diff --git a/nms-patches/net/minecraft/server/MinecraftServer.patch b/nms-patches/net/minecraft/server/MinecraftServer.patch index 9aa65086..fd9dbabc 100644 --- a/nms-patches/net/minecraft/server/MinecraftServer.patch +++ b/nms-patches/net/minecraft/server/MinecraftServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -173,13 +173,38 @@ +@@ -180,13 +180,38 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -29,7 +29,7 @@ +import org.bukkit.event.server.ServerLoadEvent; +// CraftBukkit end + - public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements ServerInfo, ChunkIOErrorReporter, ICommandListener, AutoCloseable { + public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements ServerInfo, ChunkIOErrorReporter, ICommandListener { public static final Logger LOGGER = LogUtils.getLogger(); public static final String VANILLA_BRAND = "vanilla"; @@ -40,9 +40,9 @@ private static final int OVERLOADED_TICKS_THRESHOLD = 20; private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeRange.NANOSECONDS_PER_SECOND; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; -@@ -266,6 +291,19 @@ - private volatile boolean isSaving; - private static final AtomicReference fatalException = new AtomicReference(); +@@ -277,6 +302,19 @@ + private final SuppressedExceptionCollector suppressedExceptions; + private final DiscontinuousFrame tickFrame; + // CraftBukkit start + public final WorldLoader.a worldLoader; @@ -60,7 +60,7 @@ public static S spin(Function function) { AtomicReference atomicreference = new AtomicReference(); Thread thread = new Thread(() -> { -@@ -279,14 +317,14 @@ +@@ -290,14 +328,14 @@ thread.setPriority(8); } @@ -76,19 +76,19 @@ + 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(); -@@ -309,7 +347,7 @@ - this.customBossEvents = new BossBattleCustomData(); + this.onMetricsRecordingStopped = (methodprofilerresults) -> { +@@ -321,7 +359,7 @@ + this.suppressedExceptions = new SuppressedExceptionCollector(); this.registries = worldstem.registries(); this.worldData = worldstem.worldData(); -- 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 +- if (!this.registries.compositeAccess().lookupOrThrow(Registries.LEVEL_STEM).containsKey(WorldDimension.OVERWORLD)) { ++ if (false && !this.registries.compositeAccess().lookupOrThrow(Registries.LEVEL_STEM).containsKey(WorldDimension.OVERWORLD)) { // CraftBukkit - initialised later throw new IllegalStateException("Missing Overworld dimension data"); } else { this.proxy = proxy; -@@ -334,6 +372,33 @@ - this.executor = SystemUtils.backgroundExecutor(); - this.potionBrewing = PotionBrewer.bootstrap(this.worldData.enabledFeatures()); +@@ -349,6 +387,33 @@ + this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures()); + this.tickFrame = TracyClient.createDiscontinuousFrame("Server Tick"); } + // CraftBukkit start + this.options = options; @@ -120,7 +120,7 @@ } private void readScoreboard(WorldPersistentData worldpersistentdata) { -@@ -342,7 +407,7 @@ +@@ -357,7 +422,7 @@ protected abstract boolean initServer() throws IOException; @@ -129,7 +129,7 @@ if (!JvmProfiler.INSTANCE.isRunning()) { ; } -@@ -350,12 +415,8 @@ +@@ -365,12 +430,8 @@ boolean flag = false; ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted(); @@ -143,19 +143,19 @@ if (profiledduration != null) { profiledduration.finish(); } -@@ -372,23 +433,217 @@ +@@ -387,23 +448,217 @@ protected void forceDifficulty() {} - protected void createLevels(WorldLoadListener worldloadlistener) { - IWorldDataServer iworlddataserver = this.worldData.overworldData(); - boolean flag = this.worldData.isDebugWorld(); -- IRegistry iregistry = this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM); +- IRegistry iregistry = this.registries.compositeAccess().lookupOrThrow(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); +- WorldDimension worlddimension = (WorldDimension) iregistry.getValue(WorldDimension.OVERWORLD); - WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, worlddimension, worldloadlistener, flag, j, list, true, (RandomSequences) null); + // CraftBukkit start + private void loadWorld0(String s) { @@ -164,7 +164,7 @@ - this.levels.put(World.OVERWORLD, worldserver); - WorldPersistentData worldpersistentdata = worldserver.getDataStorage(); + IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.compositeAccess(); -+ IRegistry dimensions = iregistrycustom_dimension.registryOrThrow(Registries.LEVEL_STEM); ++ IRegistry dimensions = iregistrycustom_dimension.lookupOrThrow(Registries.LEVEL_STEM); + for (WorldDimension worldDimension : dimensions) { + ResourceKey dimensionKey = dimensions.getResourceKey(worldDimension).get(); @@ -276,7 +276,7 @@ + + WorldDataServer worlddata; + WorldLoader.a worldloader_a = this.worldLoader; -+ IRegistry iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM); ++ IRegistry iregistry = worldloader_a.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM); + if (dynamic != null) { + LevelDataAndDimensions leveldataanddimensions = Convertable.getLevelDataAndDimensions(dynamic, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen()); + @@ -293,7 +293,7 @@ + } else { + DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties(); + -+ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration()); ++ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(worldloader_a.dataConfiguration().enabledFeatures()), worldloader_a.dataConfiguration()); + worldoptions = options.has("bonusChest") ? dedicatedserverproperties.worldOptions.withBonusChest(true) : dedicatedserverproperties.worldOptions; + worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen()); + } @@ -316,7 +316,7 @@ + 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) dimensions.get(dimensionKey); ++ WorldDimension worlddimension = (WorldDimension) dimensions.getValue(dimensionKey); + + 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) { @@ -375,7 +375,7 @@ if (!iworlddataserver.isInitialized()) { try { -@@ -412,30 +667,8 @@ +@@ -427,30 +682,8 @@ iworlddataserver.setInitialized(true); } @@ -407,7 +407,7 @@ private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) { if (flag1) { -@@ -443,6 +676,21 @@ +@@ -458,6 +691,21 @@ } else { ChunkProviderServer chunkproviderserver = worldserver.getChunkSource(); ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition()); @@ -428,8 +428,8 @@ + // CraftBukkit end int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver); - if (i < worldserver.getMinBuildHeight()) { -@@ -501,8 +749,11 @@ + if (i < worldserver.getMinY()) { +@@ -516,8 +764,11 @@ iworlddataserver.setGameType(EnumGamemode.SPECTATOR); } @@ -443,7 +443,7 @@ MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location()); BlockPosition blockposition = worldserver.getSharedSpawnPos(); -@@ -512,20 +763,22 @@ +@@ -527,20 +778,22 @@ this.nextTickTimeNanos = SystemUtils.getNanos(); worldserver.setDefaultSpawnPos(blockposition, worldserver.getSharedSpawnAngle()); @@ -474,7 +474,7 @@ ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk.factory(), "chunks"); if (forcedchunk != null) { -@@ -540,10 +793,17 @@ +@@ -555,10 +808,17 @@ } } @@ -488,14 +488,14 @@ - this.updateMobSpawningFlags(); + // CraftBukkit start + // this.updateMobSpawningFlags(); -+ worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals()); ++ worldserver.setSpawnSettings(this.isSpawningMonsters()); + + this.forceTicks = false; + // CraftBukkit end } public EnumGamemode getDefaultGameType() { -@@ -573,12 +833,16 @@ +@@ -588,12 +848,16 @@ worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2); } @@ -512,7 +512,7 @@ if (flag1) { Iterator iterator1 = this.getAllLevels().iterator(); -@@ -613,18 +877,40 @@ +@@ -628,18 +892,40 @@ this.stopServer(); } @@ -553,7 +553,7 @@ } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -712,7 +998,7 @@ +@@ -727,7 +1013,7 @@ } this.nextTickTimeNanos = SystemUtils.getNanos(); @@ -562,7 +562,7 @@ this.status = this.buildServerStatus(); while (this.running) { -@@ -729,6 +1015,7 @@ +@@ -744,6 +1030,7 @@ if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) { long k = j / i; @@ -570,15 +570,15 @@ MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", j / TimeRange.NANOSECONDS_PER_MILLISECOND, k); this.nextTickTimeNanos += k * i; this.lastOverloadWarningNanos = this.nextTickTimeNanos; -@@ -742,6 +1029,7 @@ +@@ -757,6 +1044,7 @@ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount); } + MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit this.nextTickTimeNanos += i; - this.startMetricsRecordingTick(); - this.profiler.push("tick"); -@@ -789,6 +1077,12 @@ + + try { +@@ -830,6 +1118,12 @@ this.services.profileCache().clearExecutor(); } @@ -591,7 +591,7 @@ this.onServerExit(); } -@@ -848,7 +1142,14 @@ +@@ -889,7 +1183,14 @@ } private boolean haveTime() { @@ -607,7 +607,7 @@ } public static boolean throwIfFatalException() { -@@ -862,7 +1163,7 @@ +@@ -903,7 +1204,7 @@ } public static void setFatalException(RuntimeException runtimeexception) { @@ -616,36 +616,49 @@ } @Override -@@ -928,7 +1229,7 @@ +@@ -977,7 +1278,7 @@ } } - protected void doRunTask(TickTask ticktask) { + public void doRunTask(TickTask ticktask) { // CraftBukkit - decompile error - this.getProfiler().incrementCounter("runTask"); + Profiler.get().incrementCounter("runTask"); super.doRunTask(ticktask); } -@@ -987,8 +1288,10 @@ +@@ -1041,6 +1342,7 @@ + this.autoSave(); + } + ++ this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit + this.tickConnection(); + return; + } +@@ -1055,7 +1357,7 @@ } --this.ticksUntilAutosave; - if (this.ticksUntilAutosave <= 0) { -- this.ticksUntilAutosave = this.computeNextAutosaveInterval(); -+ // CraftBukkit start -+ if (this.autosavePeriod > 0 && this.ticksUntilAutosave <= 0) { -+ this.ticksUntilAutosave = this.autosavePeriod; -+ // CraftBukkit end - MinecraftServer.LOGGER.debug("Autosave started"); - this.profiler.push("save"); - this.saveEverything(true, false, false); -@@ -1076,11 +1379,26 @@ ++ if (this.autosavePeriod > 0 && this.ticksUntilAutosave <= 0) { // CraftBukkit + this.autoSave(); + } + +@@ -1074,7 +1376,7 @@ + } + + private void autoSave() { +- this.ticksUntilAutosave = this.computeNextAutosaveInterval(); ++ this.ticksUntilAutosave = this.autosavePeriod; // CraftBukkit + MinecraftServer.LOGGER.debug("Autosave started"); + GameProfilerFiller gameprofilerfiller = Profiler.get(); + +@@ -1154,11 +1456,26 @@ this.getPlayerList().getPlayers().forEach((entityplayer) -> { entityplayer.connection.suspendFlushing(); }); -+ this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit - this.profiler.push("commandFunctions"); ++ this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit + gameprofilerfiller.push("commandFunctions"); this.getFunctions().tick(); - this.profiler.popPush("levels"); + gameprofilerfiller.popPush("levels"); Iterator iterator = this.getAllLevels().iterator(); + // CraftBukkit start @@ -658,28 +671,28 @@ + if (this.tickCount % 20 == 0) { + for (int i = 0; i < this.getPlayerList().players.size(); ++i) { + EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i); -+ entityplayer.connection.send(new PacketPlayOutUpdateTime(entityplayer.level().getGameTime(), entityplayer.getPlayerTime(), entityplayer.level().getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time ++ entityplayer.connection.send(new PacketPlayOutUpdateTime(entityplayer.level().getGameTime(), entityplayer.getPlayerTime(), entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time + } + } + while (iterator.hasNext()) { WorldServer worldserver = (WorldServer) iterator.next(); -@@ -1089,11 +1407,13 @@ +@@ -1167,11 +1484,13 @@ return s + " " + String.valueOf(worldserver.dimension().location()); }); + /* Drop global time updates if (this.tickCount % 20 == 0) { - this.profiler.push("timeSync"); + gameprofilerfiller.push("timeSync"); this.synchronizeTime(worldserver); - this.profiler.pop(); + gameprofilerfiller.pop(); } + // CraftBukkit end */ - this.profiler.push("tick"); + gameprofilerfiller.push("tick"); -@@ -1183,6 +1503,22 @@ +@@ -1267,6 +1586,22 @@ return (WorldServer) this.levels.get(resourcekey); } @@ -702,7 +715,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1212,7 +1548,7 @@ +@@ -1296,7 +1631,7 @@ @DontObfuscate public String getServerModName() { @@ -711,7 +724,7 @@ } public SystemReport fillSystemReport(SystemReport systemreport) { -@@ -1554,11 +1890,11 @@ +@@ -1634,11 +1969,11 @@ public CompletableFuture reloadResources(Collection collection) { CompletableFuture completablefuture = CompletableFuture.supplyAsync(() -> { @@ -724,8 +737,8 @@ + return stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(ResourcePackLoader::open).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error }, this).thenCompose((immutablelist) -> { ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist); - -@@ -1573,6 +1909,7 @@ + List> list = TagDataPack.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess()); +@@ -1654,6 +1989,7 @@ }).thenAcceptAsync((minecraftserver_reloadableresources) -> { this.resources.close(); this.resources = minecraftserver_reloadableresources; @@ -733,16 +746,16 @@ this.packRepository.setSelected(collection); WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures()); -@@ -1873,7 +2210,7 @@ +@@ -1952,7 +2288,7 @@ final List list = Lists.newArrayList(); final GameRules gamerules = this.getGameRules(); -- GameRules.visitGameRuleTypes(new GameRules.GameRuleVisitor(this) { -+ GameRules.visitGameRuleTypes(new GameRules.GameRuleVisitor() { // CraftBukkit - decompile error +- gamerules.visitGameRuleTypes(new GameRules.GameRuleVisitor(this) { ++ gamerules.visitGameRuleTypes(new GameRules.GameRuleVisitor() { // CraftBukkit - decompile error @Override public > void visit(GameRules.GameRuleKey gamerules_gamerulekey, GameRules.GameRuleDefinition gamerules_gameruledefinition) { list.add(String.format(Locale.ROOT, "%s=%s\n", gamerules_gamerulekey.getId(), gamerules.getRule(gamerules_gamerulekey))); -@@ -1979,7 +2316,7 @@ +@@ -2058,7 +2394,7 @@ try { label51: { @@ -751,7 +764,7 @@ try { arraylist = Lists.newArrayList(NativeModuleLister.listModules()); -@@ -2029,6 +2366,22 @@ +@@ -2108,6 +2444,22 @@ } @@ -771,10 +784,10 @@ + } + // CraftBukkit end + - private void startMetricsRecordingTick() { + private GameProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { -@@ -2159,6 +2512,11 @@ +@@ -2235,6 +2587,11 @@ } diff --git a/nms-patches/net/minecraft/server/bossevents/BossBattleCustom.patch b/nms-patches/net/minecraft/server/bossevents/BossBattleCustom.patch new file mode 100644 index 00000000..3dacf956 --- /dev/null +++ b/nms-patches/net/minecraft/server/bossevents/BossBattleCustom.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/server/bossevents/BossBattleCustom.java ++++ b/net/minecraft/server/bossevents/BossBattleCustom.java +@@ -19,12 +19,27 @@ + import net.minecraft.util.MathHelper; + import net.minecraft.world.BossBattle; + ++// CraftBukkit start ++import org.bukkit.boss.KeyedBossBar; ++import org.bukkit.craftbukkit.boss.CraftKeyedBossbar; ++// CraftBukkit end ++ + public class BossBattleCustom extends BossBattleServer { + + private final MinecraftKey id; + private final Set players = Sets.newHashSet(); + private int value; + private int max = 100; ++ // CraftBukkit start ++ private KeyedBossBar bossBar; ++ ++ public KeyedBossBar getBukkitEntity() { ++ if (bossBar == null) { ++ bossBar = new CraftKeyedBossbar(this); ++ } ++ return bossBar; ++ } ++ // CraftBukkit end + + public BossBattleCustom(MinecraftKey minecraftkey, IChatBaseComponent ichatbasecomponent) { + super(ichatbasecomponent, BossBattle.BarColor.WHITE, BossBattle.BarStyle.PROGRESS); diff --git a/nms-patches/net/minecraft/server/commands/CommandGamerule.patch b/nms-patches/net/minecraft/server/commands/CommandGamerule.patch index e9c56cdd..f3107570 100644 --- a/nms-patches/net/minecraft/server/commands/CommandGamerule.patch +++ b/nms-patches/net/minecraft/server/commands/CommandGamerule.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandGamerule.java +++ b/net/minecraft/server/commands/CommandGamerule.java -@@ -31,7 +31,7 @@ +@@ -34,7 +34,7 @@ static > int setRule(CommandContext commandcontext, GameRules.GameRuleKey gamerules_gamerulekey) { CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) commandcontext.getSource(); @@ -9,7 +9,7 @@ t0.setFromArgument(commandcontext, "value"); commandlistenerwrapper.sendSuccess(() -> { -@@ -41,7 +41,7 @@ +@@ -44,7 +44,7 @@ } static > int queryRule(CommandListenerWrapper commandlistenerwrapper, GameRules.GameRuleKey gamerules_gamerulekey) { diff --git a/nms-patches/net/minecraft/server/commands/CommandLoot.patch b/nms-patches/net/minecraft/server/commands/CommandLoot.patch index 8c242917..d68afd40 100644 --- a/nms-patches/net/minecraft/server/commands/CommandLoot.patch +++ b/nms-patches/net/minecraft/server/commands/CommandLoot.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/CommandLoot.java +++ b/net/minecraft/server/commands/CommandLoot.java -@@ -91,7 +91,7 @@ +@@ -95,7 +95,7 @@ } private static > T addTargets(T t0, CommandLoot.c commandloot_c) { @@ -9,7 +9,7 @@ return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), list.size(), list, commandloot_a); }).then(commandloot_c.construct(net.minecraft.commands.CommandDispatcher.argument("count", IntegerArgumentType.integer(0)), (commandcontext, list, commandloot_a) -> { return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), IntegerArgumentType.getInteger(commandcontext, "count"), list, commandloot_a); -@@ -246,6 +246,7 @@ +@@ -250,6 +250,7 @@ private static int dropInWorld(CommandListenerWrapper commandlistenerwrapper, Vec3D vec3d, List list, CommandLoot.a commandloot_a) throws CommandSyntaxException { WorldServer worldserver = commandlistenerwrapper.getLevel(); diff --git a/nms-patches/net/minecraft/server/commands/CommandSchedule.patch b/nms-patches/net/minecraft/server/commands/CommandSchedule.patch index 00b20307..96177b3a 100644 --- a/nms-patches/net/minecraft/server/commands/CommandSchedule.patch +++ b/nms-patches/net/minecraft/server/commands/CommandSchedule.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/commands/CommandSchedule.java +++ b/net/minecraft/server/commands/CommandSchedule.java -@@ -55,7 +55,7 @@ +@@ -58,7 +58,7 @@ } else { long j = commandlistenerwrapper.getLevel().getGameTime() + (long) i; MinecraftKey minecraftkey = (MinecraftKey) pair.getFirst(); - CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue = commandlistenerwrapper.getServer().getWorldData().overworldData().getScheduledEvents(); + CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue = commandlistenerwrapper.getLevel().serverLevelData.overworldData().getScheduledEvents(); // CraftBukkit - SPIGOT-6667: Use world specific function timer + Optional> optional = ((Either) pair.getSecond()).left(); + String s; - ((Either) pair.getSecond()).ifLeft((net_minecraft_commands_functions_commandfunction) -> { - String s = minecraftkey.toString(); diff --git a/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch b/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch index b637188c..67d39d33 100644 --- a/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch +++ b/nms-patches/net/minecraft/server/commands/CommandSpreadPlayers.patch @@ -13,8 +13,8 @@ commandspreadplayers_a = acommandspreadplayers_a[j++]; } -- entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot()); -+ entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - handle teleport reason +- entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot(), true); ++ entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot(), true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - handle teleport reason d1 = Double.MAX_VALUE; CommandSpreadPlayers.a[] acommandspreadplayers_a1 = acommandspreadplayers_a; int k = acommandspreadplayers_a.length; diff --git a/nms-patches/net/minecraft/server/commands/CommandSummon.patch b/nms-patches/net/minecraft/server/commands/CommandSummon.patch index 7cff016f..8e53d336 100644 --- a/nms-patches/net/minecraft/server/commands/CommandSummon.patch +++ b/nms-patches/net/minecraft/server/commands/CommandSummon.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/commands/CommandSummon.java +++ b/net/minecraft/server/commands/CommandSummon.java @@ -67,7 +67,7 @@ - ((EntityInsentient) entity).finalizeSpawn(commandlistenerwrapper.getLevel(), commandlistenerwrapper.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EnumMobSpawn.COMMAND, (GroupDataEntity) null); + ((EntityInsentient) entity).finalizeSpawn(commandlistenerwrapper.getLevel(), commandlistenerwrapper.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.COMMAND, (GroupDataEntity) null); } - if (!worldserver.tryAddFreshEntityWithPassengers(entity)) { diff --git a/nms-patches/net/minecraft/server/commands/CommandTeleport.patch b/nms-patches/net/minecraft/server/commands/CommandTeleport.patch index c96cfba8..01612c03 100644 --- a/nms-patches/net/minecraft/server/commands/CommandTeleport.patch +++ b/nms-patches/net/minecraft/server/commands/CommandTeleport.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/server/commands/CommandTeleport.java +++ b/net/minecraft/server/commands/CommandTeleport.java -@@ -33,6 +33,13 @@ +@@ -31,6 +31,14 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start ++import net.minecraft.server.level.EntityPlayer; +import org.bukkit.Location; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.event.entity.EntityTeleportEvent; @@ -14,35 +15,35 @@ public class CommandTeleport { private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(IChatBaseComponent.translatable("commands.teleport.invalidPosition")); -@@ -155,7 +162,30 @@ - float f2 = MathHelper.wrapDegrees(f); - float f3 = MathHelper.wrapDegrees(f1); +@@ -167,7 +175,30 @@ + float f4 = MathHelper.wrapDegrees(f2); + float f5 = MathHelper.wrapDegrees(f3); -- if (entity.teleportTo(worldserver, d0, d1, d2, set, f2, f3)) { +- if (entity.teleportTo(worldserver, d3, d4, d5, set, f4, f5, true)) { + // CraftBukkit start - Teleport event + boolean result; + if (entity instanceof EntityPlayer player) { -+ result = player.teleportTo(worldserver, d0, d1, d2, set, f2, f3, PlayerTeleportEvent.TeleportCause.COMMAND); ++ result = player.teleportTo(worldserver, d3, d4, d5, set, f4, f5, true, PlayerTeleportEvent.TeleportCause.COMMAND); + } else { -+ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f3); ++ Location to = new Location(worldserver.getWorld(), d3, d4, d5, f4, f5); + EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to); + worldserver.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + -+ d0 = to.getX(); -+ d1 = to.getY(); -+ d2 = to.getZ(); -+ f2 = to.getYaw(); -+ f3 = to.getPitch(); ++ d3 = to.getX(); ++ d4 = to.getY(); ++ d5 = to.getZ(); ++ f4 = to.getYaw(); ++ f5 = to.getPitch(); + worldserver = ((CraftWorld) to.getWorld()).getHandle(); + -+ result = entity.teleportTo(worldserver, d0, d1, d2, set, f2, f3); ++ result = entity.teleportTo(worldserver, d3, d4, d5, set, f4, f5, true); + } + + if (result) { + // CraftBukkit end - if (commandteleport_a != null) { - commandteleport_a.perform(commandlistenerwrapper, entity); + if (lookat != null) { + lookat.perform(commandlistenerwrapper, entity); } diff --git a/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch b/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch index 2113fa76..2b0e2397 100644 --- a/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch +++ b/nms-patches/net/minecraft/server/dedicated/DedicatedServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -60,6 +60,18 @@ +@@ -59,6 +59,18 @@ import net.minecraft.world.level.storage.Convertable; import org.slf4j.Logger; @@ -19,7 +19,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer { static final Logger LOGGER = LogUtils.getLogger(); -@@ -68,7 +80,7 @@ +@@ -67,7 +79,7 @@ private final List consoleInput = Collections.synchronizedList(Lists.newArrayList()); @Nullable private RemoteStatusListener queryThreadGs4; @@ -28,7 +28,7 @@ @Nullable private RemoteControlListener rconThread; public DedicatedServerSettings settings; -@@ -82,10 +94,12 @@ +@@ -81,10 +93,12 @@ private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker; public ServerLinks serverLinks; @@ -41,10 +41,10 @@ this.settings = dedicatedserversettings; - this.rconConsoleSource = new RemoteControlCommandListener(this); + // this.rconConsoleSource = new RemoteControlCommandListener(this); // CraftBukkit - remove field - this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig); + this.serverTextFilter = ServerTextFilter.createFromConfig(dedicatedserversettings.getProperties()); this.serverLinks = createServerLinks(dedicatedserversettings); } -@@ -94,13 +108,44 @@ +@@ -93,13 +107,44 @@ public boolean initServer() throws IOException { Thread thread = new Thread("Server console handler") { public void run() { @@ -92,7 +92,7 @@ } } catch (IOException ioexception) { DedicatedServer.LOGGER.error("Exception handling console input", ioexception); -@@ -109,6 +154,29 @@ +@@ -108,6 +153,29 @@ } }; @@ -122,7 +122,7 @@ thread.setDaemon(true); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER)); thread.start(); -@@ -133,7 +201,7 @@ +@@ -132,7 +200,7 @@ this.setMotd(dedicatedserverproperties.motd); super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get()); this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist); @@ -131,7 +131,7 @@ DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode); InetAddress inetaddress = null; -@@ -157,6 +225,12 @@ +@@ -156,6 +224,12 @@ return false; } @@ -144,7 +144,7 @@ if (!this.usesAuthentication()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); -@@ -171,7 +245,7 @@ +@@ -170,7 +244,7 @@ if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) { return false; } else { @@ -153,7 +153,7 @@ this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList()); this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME); long i = SystemUtils.getNanos(); -@@ -179,13 +253,13 @@ +@@ -178,13 +252,13 @@ TileEntitySkull.setup(this.services, this); UserCache.setUsesAuthentication(this.usesAuthentication()); DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName()); @@ -169,7 +169,7 @@ } if (dedicatedserverproperties.enableQuery) { -@@ -311,6 +385,7 @@ +@@ -293,6 +367,7 @@ this.queryThreadGs4.stop(); } @@ -177,7 +177,7 @@ } @Override -@@ -332,7 +407,15 @@ +@@ -314,7 +389,15 @@ while (!this.consoleInput.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0); @@ -194,7 +194,7 @@ } } -@@ -559,16 +642,52 @@ +@@ -541,16 +624,52 @@ @Override public String getPluginNames() { @@ -251,7 +251,7 @@ } public void storeUsingWhiteList(boolean flag) { -@@ -673,4 +792,15 @@ +@@ -660,4 +779,15 @@ } } } diff --git a/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch b/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch index b14bb65a..f46a8a10 100644 --- a/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch +++ b/nms-patches/net/minecraft/server/dedicated/DedicatedServerProperties.patch @@ -30,7 +30,7 @@ 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"); -@@ -165,13 +172,15 @@ +@@ -167,13 +174,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()))); } @@ -50,7 +50,7 @@ } @Nullable -@@ -252,10 +261,10 @@ +@@ -254,10 +263,10 @@ }).orElseThrow(() -> { return new IllegalStateException("Invalid datapack contents: can't find default preset"); }); @@ -62,11 +62,11 @@ + return Optional.ofNullable(DedicatedServerProperties.WorldDimensionData.LEGACY_PRESET_NAMES.get(this.levelType)); // CraftBukkit - decompile error }); - Objects.requireNonNull(iregistry); -@@ -267,7 +276,7 @@ + Objects.requireNonNull(holderlookup); +@@ -269,7 +278,7 @@ if (holder.is(WorldPresets.FLAT)) { - RegistryOps registryops = iregistrycustom.createSerializationContext(JsonOps.INSTANCE); + RegistryOps registryops = holderlookup_a.createSerializationContext(JsonOps.INSTANCE); - 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/gui/ServerGUI.patch b/nms-patches/net/minecraft/server/gui/ServerGUI.patch new file mode 100644 index 00000000..e99114a8 --- /dev/null +++ b/nms-patches/net/minecraft/server/gui/ServerGUI.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/server/gui/ServerGUI.java ++++ b/net/minecraft/server/gui/ServerGUI.java +@@ -96,7 +96,7 @@ + private JComponent buildInfoPanel() { + JPanel jpanel = new JPanel(new BorderLayout()); + GuiStatsComponent guistatscomponent = new GuiStatsComponent(this.server); +- Collection collection = this.finalizers; ++ Collection collection = this.finalizers; // CraftBukkit - decompile error + + Objects.requireNonNull(guistatscomponent); + collection.add(guistatscomponent::close); +@@ -132,7 +132,7 @@ + + jtextfield.setText(""); + }); +- jtextarea.addFocusListener(new FocusAdapter(this) { ++ jtextarea.addFocusListener(new FocusAdapter() { // CraftBukkit - decompile error + public void focusGained(FocusEvent focusevent) {} + }); + jpanel.add(jscrollpane, "Center"); +@@ -166,6 +166,7 @@ + this.finalizers.forEach(Runnable::run); + } + ++ private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})*)?[m|K]"); // CraftBukkit + public void print(JTextArea jtextarea, JScrollPane jscrollpane, String s) { + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(() -> { +@@ -181,7 +182,7 @@ + } + + try { +- document.insertString(document.getLength(), s, (AttributeSet) null); ++ document.insertString(document.getLength(), ANSI.matcher(s).replaceAll(""), (AttributeSet) null); // CraftBukkit + } catch (BadLocationException badlocationexception) { + ; + } diff --git a/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch b/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch index b88b2aeb..8a42bd4d 100644 --- a/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch +++ b/nms-patches/net/minecraft/server/level/ChunkMapDistance.patch @@ -1,6 +1,22 @@ --- a/net/minecraft/server/level/ChunkMapDistance.java +++ b/net/minecraft/server/level/ChunkMapDistance.java -@@ -163,7 +163,7 @@ +@@ -117,6 +117,15 @@ + + PlayerChunk playerchunk; + ++ // CraftBukkit start - SPIGOT-7780: Call chunk unload events before updateHighestAllowedStatus ++ while (iterator.hasNext()) { ++ playerchunk = (PlayerChunk) iterator.next(); ++ playerchunk.callEventIfUnloading(playerchunkmap); ++ } ++ ++ iterator = this.chunksToUpdateFutures.iterator(); ++ // CraftBukkit end ++ + while (iterator.hasNext()) { + playerchunk = (PlayerChunk) iterator.next(); + playerchunk.updateHighestAllowedStatus(playerchunkmap); +@@ -165,7 +174,7 @@ } } @@ -9,7 +25,7 @@ ArraySetSorted> arraysetsorted = this.getTickets(i); int j = getTicketLevelAt(arraysetsorted); Ticket ticket1 = (Ticket) arraysetsorted.addOrGet(ticket); -@@ -173,13 +173,15 @@ +@@ -175,13 +184,15 @@ this.ticketTracker.update(i, ticket.getTicketLevel(), true); } @@ -27,7 +43,7 @@ } if (arraysetsorted.isEmpty()) { -@@ -187,6 +189,7 @@ +@@ -189,6 +200,7 @@ } this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false); @@ -35,7 +51,7 @@ } public void addTicket(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { -@@ -200,19 +203,33 @@ +@@ -202,19 +214,33 @@ } public void addRegionTicket(TicketType tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { @@ -71,7 +87,7 @@ } private ArraySetSorted> getTickets(long i) { -@@ -251,6 +268,7 @@ +@@ -253,6 +279,7 @@ ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk(); long i = chunkcoordintpair.toLong(); ObjectSet objectset = (ObjectSet) this.playersPerChunk.get(i); @@ -79,7 +95,7 @@ objectset.remove(entityplayer); if (objectset.isEmpty()) { -@@ -380,6 +398,26 @@ +@@ -391,6 +418,26 @@ return !this.tickets.isEmpty(); } diff --git a/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch b/nms-patches/net/minecraft/server/level/ChunkProviderServer.patch index 18aed6e8..6d00dd68 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 -@@ -82,6 +82,16 @@ +@@ -96,6 +96,16 @@ this.clearCache(); } @@ -17,7 +17,7 @@ @Override public LightEngineThreaded getLightEngine() { return this.lightEngine; -@@ -125,7 +135,7 @@ +@@ -139,7 +149,7 @@ if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) { IChunkAccess ichunkaccess = this.lastChunk[l]; @@ -26,7 +26,7 @@ return ichunkaccess; } } -@@ -138,7 +148,7 @@ +@@ -152,7 +162,7 @@ Objects.requireNonNull(completablefuture); chunkproviderserver_b.managedBlock(completablefuture::isDone); ChunkResult chunkresult = (ChunkResult) completablefuture.join(); @@ -35,7 +35,7 @@ if (ichunkaccess1 == null && flag) { throw (IllegalStateException) SystemUtils.pauseInIde(new IllegalStateException("Chunk not there when requested: " + chunkresult.getError())); -@@ -218,7 +228,15 @@ +@@ -232,7 +242,15 @@ int l = ChunkLevel.byStatus(chunkstatus); PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k); @@ -51,8 +51,8 @@ + // CraftBukkit end this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); if (this.chunkAbsent(playerchunk, l)) { - GameProfilerFiller gameprofilerfiller = this.level.getProfiler(); -@@ -237,7 +255,7 @@ + GameProfilerFiller gameprofilerfiller = Profiler.get(); +@@ -251,7 +269,7 @@ } private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) { @@ -61,7 +61,7 @@ } @Override -@@ -292,11 +310,31 @@ +@@ -310,12 +328,34 @@ @Override public void close() throws IOException { @@ -75,40 +75,63 @@ + this.save(true); + } + // CraftBukkit end + this.dataStorage.close(); this.lightEngine.close(); this.chunkMap.close(); } + // CraftBukkit start - modelled on below + public void purgeUnload() { -+ this.level.getProfiler().push("purge"); ++ GameProfilerFiller gameprofilerfiller = Profiler.get(); ++ ++ gameprofilerfiller.push("purge"); + this.distanceManager.purgeStaleTickets(); + this.runDistanceManagerUpdates(); -+ this.level.getProfiler().popPush("unload"); ++ gameprofilerfiller.popPush("unload"); + this.chunkMap.tick(() -> true); -+ this.level.getProfiler().pop(); ++ gameprofilerfiller.pop(); + this.clearCache(); + } + // CraftBukkit end + @Override public void tick(BooleanSupplier booleansupplier, boolean flag) { - this.level.getProfiler().push("purge"); -@@ -346,11 +384,11 @@ + GameProfilerFiller gameprofilerfiller = Profiler.get(); +@@ -402,14 +442,14 @@ + + this.lastSpawnState = spawnercreature_d; + gameprofilerfiller.popPush("spawnAndTick"); +- boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING); ++ boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit + int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); + List list1; - this.lastSpawnState = spawnercreature_d; - gameprofilerfiller.popPush("spawnAndTick"); -- boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING); -+ boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit + if (flag && (this.spawnEnemies || this.spawnFriendlies)) { +- boolean flag1 = this.level.getLevelData().getGameTime() % 400L == 0L; ++ boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit - SystemUtils.shuffle(list, this.level.random); - int l = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); -- boolean flag1 = this.level.getLevelData().getGameTime() % 400L == 0L; -+ boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit - Iterator iterator1 = list.iterator(); +- list1 = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1); ++ list1 = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1, this.level); // CraftBukkit + } else { + list1 = List.of(); + } +@@ -542,8 +582,14 @@ + + @Override + public void setSpawnSettings(boolean flag) { ++ // CraftBukkit start ++ this.setSpawnSettings(flag, this.spawnFriendlies); ++ } ++ ++ public void setSpawnSettings(boolean flag, boolean spawnFriendlies) { + this.spawnEnemies = flag; +- this.spawnFriendlies = this.spawnFriendlies; ++ this.spawnFriendlies = spawnFriendlies; ++ // CraftBukkit end + } - while (iterator1.hasNext()) { -@@ -560,13 +598,19 @@ + public String getChunkDebugData(ChunkCoordIntPair chunkcoordintpair) { +@@ -619,13 +665,19 @@ } @Override diff --git a/nms-patches/net/minecraft/server/level/EntityPlayer.patch b/nms-patches/net/minecraft/server/level/EntityPlayer.patch index f14d7ace..d2126ebd 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 -@@ -166,6 +166,40 @@ +@@ -184,6 +184,41 @@ import net.minecraft.world.scores.criteria.IScoreboardCriteria; import org.slf4j.Logger; @@ -15,6 +15,7 @@ +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.WeatherType; ++import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.CraftWorldBorder; +import org.bukkit.craftbukkit.entity.CraftPlayer; @@ -28,20 +29,20 @@ +import org.bukkit.event.player.PlayerBedLeaveEvent; +import org.bukkit.event.player.PlayerChangedMainHandEvent; +import org.bukkit.event.player.PlayerChangedWorldEvent; ++import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerLocaleChangeEvent; +import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerSpawnChangeEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -+import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.MainHand; +// CraftBukkit end + public class EntityPlayer extends EntityHuman { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -204,7 +238,7 @@ +@@ -227,7 +262,7 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance; @@ -50,7 +51,7 @@ @Nullable private Vec3D startingToFallPosition; @Nullable -@@ -235,6 +269,21 @@ +@@ -261,6 +296,22 @@ private int containerCounter; public boolean wonGame; @@ -58,6 +59,7 @@ + public CraftPlayer.TransferCookieConnection transferCookieConnection; + public String displayName; + public IChatBaseComponent listName; ++ public int listOrder = 0; + public org.bukkit.Location compassTarget; + public int newExp = 0; + public int newLevel = 0; @@ -72,7 +74,21 @@ public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) { super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile); this.chatVisibility = EnumChatVisibility.FULL; -@@ -302,14 +351,67 @@ +@@ -342,6 +393,13 @@ + public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) { + EntityPlayer.this.sendSystemMessage(ichatbasecomponent); + } ++ ++ // CraftBukkit start ++ @Override ++ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) { ++ return getBukkitEntity(); ++ } ++ // CraftBukkit end + }; + this.textFilter = minecraftserver.createTextFilterForPlayer(this); + this.gameMode = minecraftserver.createGameModeForPlayer(this); +@@ -354,14 +412,67 @@ this.moveTo(this.adjustSpawnLocation(worldserver, worldserver.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); this.updateOptions(clientinformation); this.object = null; @@ -81,8 +97,8 @@ + this.displayName = this.getScoreboardName(); + this.bukkitPickUpLoot = true; + this.maxHealthCache = this.getMaxHealth(); - } - ++ } ++ + // Use method to resend items in hands in case of client desync, because the item use got cancelled. + // For example, when cancelling the leash event + public void resendItemInHands() { @@ -128,9 +144,9 @@ + } + + return blockposition; -+ } + } + // CraftBukkit end -+ + @Override public BlockPosition adjustSpawnLocation(WorldServer worldserver, BlockPosition blockposition) { AxisAlignedBB axisalignedbb = this.getDimensions(EntityPose.STANDING).makeBoundingBox(Vec3D.ZERO); @@ -141,7 +157,30 @@ int i = Math.max(0, this.server.getSpawnRadius(worldserver)); int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); -@@ -366,7 +468,7 @@ +@@ -397,14 +508,20 @@ + + Objects.requireNonNull(blockposition); + crashreportsystemdetails.setDetail("Origin", blockposition::toString); ++ // CraftBukkit start - decompile error ++ int finalI = i; + crashreportsystemdetails.setDetail("Radius", () -> { +- return Integer.toString(i); ++ return Integer.toString(finalI); ++ // CraftBukkit end + }); + crashreportsystemdetails.setDetail("Candidate", () -> { + return "[" + l2 + "," + i3 + "]"; + }); ++ // CraftBukkit start - decompile error ++ int finalL1 = l1; + crashreportsystemdetails.setDetail("Progress", () -> { +- return "" + l1 + " out of " + i1; ++ return "" + finalL1 + " out of " + i1; ++ // CraftBukkit end + }); + throw new ReportedException(crashreport); + } +@@ -442,7 +559,7 @@ dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker"))); logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); @@ -150,9 +189,9 @@ this.wardenSpawnTracker = wardenspawntracker; }); } -@@ -381,17 +483,26 @@ - if (nbttagcompound.contains("recipeBook", 10)) { - this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager()); +@@ -459,17 +576,26 @@ + return this.server.getRecipeManager().byKey(resourcekey).isPresent(); + }); } + this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit @@ -178,7 +217,7 @@ Logger logger1 = EntityPlayer.LOGGER; Objects.requireNonNull(logger1); -@@ -406,7 +517,7 @@ +@@ -484,7 +610,7 @@ dataresult = BlockPosition.CODEC.parse(DynamicOpsNBT.INSTANCE, nbtbase); logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); @@ -187,7 +226,7 @@ this.raidOmenPosition = blockposition; }); } -@@ -416,7 +527,7 @@ +@@ -494,7 +620,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); @@ -196,7 +235,15 @@ Logger logger = EntityPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -437,7 +548,20 @@ +@@ -528,6 +654,7 @@ + nbttagcompound.put("SpawnDimension", nbtbase); + }); + } ++ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit + + nbttagcompound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall); + if (this.raidOmenPosition != null) { +@@ -546,7 +673,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -215,18 +262,43 @@ + + if (persistVehicle && entity1 != null && entity != this && entity.hasExactlyOnePlayerPassenger()) { + // CraftBukkit end + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound2 = new NBTTagCompound(); - NBTTagCompound nbttagcompound3 = new NBTTagCompound(); -@@ -462,6 +586,7 @@ - nbttagcompound.put("SpawnDimension", nbtbase); - }); - } -+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit +@@ -600,12 +740,12 @@ - nbttagcompound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall); - if (this.raidOmenPosition != null) { -@@ -475,6 +600,29 @@ + if (!this.isPassenger()) { + EntityPlayer.LOGGER.warn("Couldn't reattach entity to player"); +- entity.discard(); ++ entity.discard(null); // CraftBukkit - add Bukkit remove cause + iterator = entity.getIndirectPassengers().iterator(); + + while (iterator.hasNext()) { + entity1 = (Entity) iterator.next(); +- entity1.discard(); ++ entity1.discard(null); // CraftBukkit - add Bukkit remove cause + } + } + } +@@ -627,7 +767,7 @@ + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + + entityenderpearl.save(nbttagcompound1); +- DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, entityenderpearl.level().dimension().location()); ++ DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, entityenderpearl.level().dimension().location()); // CraftBukkit - decompile error + Logger logger = EntityPlayer.LOGGER; + + Objects.requireNonNull(logger); +@@ -653,7 +793,7 @@ + nbttaglist.forEach((nbtbase1) -> { + if (nbtbase1 instanceof NBTTagCompound nbttagcompound) { + if (nbttagcompound.contains("ender_pearl_dimension")) { +- DataResult dataresult = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("ender_pearl_dimension")); ++ DataResult> dataresult = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("ender_pearl_dimension")); // CraftBukkit - decompile error + Logger logger = EntityPlayer.LOGGER; + + Objects.requireNonNull(logger); +@@ -688,6 +828,29 @@ } @@ -256,7 +328,7 @@ public void setExperiencePoints(int i) { float f = (float) this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -533,6 +681,11 @@ +@@ -746,6 +909,11 @@ @Override public void tick() { @@ -268,7 +340,7 @@ this.gameMode.tick(); this.wardenSpawnTracker.tick(); --this.spawnInvulnerableTime; -@@ -613,7 +766,7 @@ +@@ -822,7 +990,7 @@ } if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -277,7 +349,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -644,6 +797,12 @@ +@@ -853,6 +1021,12 @@ this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience)); } @@ -290,7 +362,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel)); -@@ -658,6 +817,20 @@ +@@ -867,6 +1041,20 @@ CriterionTriggers.LOCATION.trigger(this); } @@ -311,7 +383,16 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked"); -@@ -703,7 +876,8 @@ +@@ -895,7 +1083,7 @@ + if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { + if (this.tickCount % 20 == 0) { + if (this.getHealth() < this.getMaxHealth()) { +- this.heal(1.0F); ++ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit - added regain reason of "REGEN" for filtering purposes. + } + + float f = this.foodData.getSaturationLevel(); +@@ -948,7 +1136,8 @@ } private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) { @@ -321,16 +402,16 @@ scoreaccess.set(i); }); } -@@ -712,9 +886,47 @@ +@@ -957,9 +1146,47 @@ public void die(DamageSource damagesource) { this.gameEvent(GameEvent.ENTITY_DIE); - boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); + boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); + // CraftBukkit start - fire PlayerDeathEvent + if (this.isRemoved()) { + return; + } + java.util.List loot = new java.util.ArrayList<>(this.getInventory().getContainerSize()); -+ boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator(); ++ boolean keepInventory = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator(); - if (flag) { - IChatBaseComponent ichatbasecomponent = this.getCombatTracker().getDeathMessage(); @@ -342,7 +423,7 @@ + } + } + // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) -+ this.dropFromLootTable(damagesource, this.lastHurtByPlayerTime > 0); ++ this.dropFromLootTable(this.serverLevel(), damagesource, this.lastHurtByPlayerTime > 0); + this.dropCustomDeathLoot(this.serverLevel(), damagesource, flag); + + loot.addAll(this.drops); @@ -371,15 +452,15 @@ this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> { boolean flag1 = true; -@@ -745,12 +957,18 @@ - if (this.level().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { +@@ -990,12 +1217,18 @@ + if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { this.tellNeutralMobsThatIDied(); } - - if (!this.isSpectator()) { - this.dropAllDeathLoot(this.serverLevel(), damagesource); + // SPIGOT-5478 must be called manually now -+ this.dropExperience(damagesource.getEntity()); ++ this.dropExperience(this.serverLevel(), damagesource.getEntity()); + // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. + if (!event.getKeepInventory()) { + this.getInventory().clearContent(); @@ -394,7 +475,7 @@ EntityLiving entityliving = this.getKillCredit(); if (entityliving != null) { -@@ -785,10 +1003,12 @@ +@@ -1030,10 +1263,12 @@ if (entity != this) { super.awardKillScore(entity, i, damagesource); this.increaseScore(i); @@ -409,7 +490,7 @@ } else { this.awardStat(StatisticList.MOB_KILLS); } -@@ -806,7 +1026,8 @@ +@@ -1051,7 +1286,8 @@ int i = scoreboardteam.getColor().getId(); if (i >= 0 && i < aiscoreboardcriteria.length) { @@ -419,7 +500,7 @@ } } -@@ -856,10 +1077,16 @@ +@@ -1101,10 +1337,16 @@ } private boolean isPvpAllowed() { @@ -428,53 +509,53 @@ + return this.level().pvpMode; } -- public DimensionTransition findRespawnPositionAndUseSpawnBlock(boolean flag, DimensionTransition.a dimensiontransition_a) { +- public TeleportTransition findRespawnPositionAndUseSpawnBlock(boolean flag, TeleportTransition.a teleporttransition_a) { + // CraftBukkit start -+ public DimensionTransition findRespawnPositionAndUseSpawnBlock(boolean flag, DimensionTransition.a dimensiontransition_a, PlayerRespawnEvent.RespawnReason reason) { -+ DimensionTransition dimensionTransition; ++ public TeleportTransition findRespawnPositionAndUseSpawnBlock(boolean flag, TeleportTransition.a teleporttransition_a, PlayerRespawnEvent.RespawnReason reason) { ++ TeleportTransition teleportTransition; + boolean isBedSpawn = false; + boolean isAnchorSpawn = false; + // CraftBukkit end BlockPosition blockposition = this.getRespawnPosition(); float f = this.getRespawnAngle(); boolean flag1 = this.isRespawnForced(); -@@ -871,13 +1098,32 @@ +@@ -1116,13 +1358,32 @@ if (optional.isPresent()) { EntityPlayer.RespawnPosAngle entityplayer_respawnposangle = (EntityPlayer.RespawnPosAngle) optional.get(); -- return new DimensionTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, dimensiontransition_a); +- return new TeleportTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, teleporttransition_a); + // CraftBukkit start + isBedSpawn = entityplayer_respawnposangle.isBedSpawn(); + isAnchorSpawn = entityplayer_respawnposangle.isAnchorSpawn(); -+ dimensionTransition = new DimensionTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, dimensiontransition_a); ++ teleportTransition = new TeleportTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, teleporttransition_a); + // CraftBukkit end } else { -- return DimensionTransition.missingRespawnBlock(this.server.overworld(), this, dimensiontransition_a); -+ dimensionTransition = DimensionTransition.missingRespawnBlock(this.server.overworld(), this, dimensiontransition_a); // CraftBukkit +- return TeleportTransition.missingRespawnBlock(this.server.overworld(), this, teleporttransition_a); ++ teleportTransition = TeleportTransition.missingRespawnBlock(this.server.overworld(), this, teleporttransition_a); // CraftBukkit } } else { -- return new DimensionTransition(this.server.overworld(), this, dimensiontransition_a); -+ dimensionTransition = new DimensionTransition(this.server.overworld(), this, dimensiontransition_a); // CraftBukkit +- return new TeleportTransition(this.server.overworld(), this, teleporttransition_a); ++ teleportTransition = new TeleportTransition(this.server.overworld(), this, teleporttransition_a); // CraftBukkit } + // CraftBukkit start + if (reason == null) { -+ return dimensionTransition; ++ return teleportTransition; + } + + Player respawnPlayer = this.getBukkitEntity(); -+ Location location = CraftLocation.toBukkit(dimensionTransition.pos(), dimensionTransition.newLevel().getWorld(), dimensionTransition.yRot(), dimensionTransition.xRot()); ++ Location location = CraftLocation.toBukkit(teleportTransition.position(), teleportTransition.newLevel().getWorld(), teleportTransition.yRot(), teleportTransition.xRot()); + + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn, isAnchorSpawn, reason); + this.level().getCraftServer().getPluginManager().callEvent(respawnEvent); + + location = respawnEvent.getRespawnLocation(); + -+ return new DimensionTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), dimensionTransition.speed(), location.getYaw(), location.getPitch(), dimensionTransition.missingRespawnBlock(), dimensionTransition.postDimensionTransition(), dimensionTransition.cause()); ++ return new TeleportTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), teleportTransition.deltaMovement(), location.getYaw(), location.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), teleportTransition.relatives(), teleportTransition.postTeleportTransition(), teleportTransition.cause()); + // CraftBukkit end } public static Optional findRespawnAndUseSpawnBlock(WorldServer worldserver, BlockPosition blockposition, float f, boolean flag, boolean flag1) { -@@ -892,11 +1138,11 @@ +@@ -1137,11 +1398,11 @@ } return optional.map((vec3d) -> { @@ -488,7 +569,7 @@ }); } else if (!flag) { return Optional.empty(); -@@ -905,7 +1151,7 @@ +@@ -1150,7 +1411,7 @@ IBlockData iblockdata1 = worldserver.getBlockState(blockposition.above()); boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1); @@ -497,32 +578,49 @@ } } -@@ -923,6 +1169,7 @@ +@@ -1168,6 +1429,7 @@ @Nullable @Override - public Entity changeDimension(DimensionTransition dimensiontransition) { + public EntityPlayer teleport(TeleportTransition teleporttransition) { + if (this.isSleeping()) return null; // CraftBukkit - SPIGOT-3154 if (this.isRemoved()) { return null; } else { -@@ -932,14 +1179,21 @@ +@@ -1177,18 +1439,38 @@ - WorldServer worldserver = dimensiontransition.newLevel(); + WorldServer worldserver = teleporttransition.newLevel(); WorldServer worldserver1 = this.serverLevel(); - ResourceKey resourcekey = worldserver1.dimension(); + // CraftBukkit start + ResourceKey resourcekey = worldserver1.getTypeKey(); ++ ++ Location enter = this.getBukkitEntity().getLocation(); ++ PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); ++ Location exit = (worldserver == null) ? null : CraftLocation.toBukkit(absolutePosition.position(), worldserver.getWorld(), absolutePosition.yRot(), absolutePosition.xRot()); ++ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, teleporttransition.cause()); ++ Bukkit.getServer().getPluginManager().callEvent(tpEvent); ++ Location newExit = tpEvent.getTo(); ++ if (tpEvent.isCancelled() || newExit == null) { ++ return null; ++ } ++ if (!newExit.equals(exit)) { ++ worldserver = ((CraftWorld) newExit.getWorld()).getHandle(); ++ teleporttransition = new TeleportTransition(worldserver, CraftLocation.toVec3D(newExit), Vec3D.ZERO, newExit.getYaw(), newExit.getPitch(), teleporttransition.missingRespawnBlock(), teleporttransition.asPassenger(), Set.of(), teleporttransition.postTeleportTransition(), teleporttransition.cause()); ++ } ++ // CraftBukkit end + + if (!teleporttransition.asPassenger()) { + this.stopRiding(); + } - if (worldserver.dimension() == resourcekey) { -- this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot()); -+ if (worldserver != null && worldserver.dimension() == worldserver1.dimension()) { // CraftBukkit -+ boolean result = this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot(), dimensiontransition.cause()); -+ if (!result) { -+ return null; -+ } +- this.connection.teleport(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); ++ // CraftBukkit start ++ if (worldserver != null && worldserver.dimension() == worldserver1.dimension()) { ++ this.connection.internalTeleport(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); + // CraftBukkit end this.connection.resetPosition(); - dimensiontransition.postDimensionTransition().onTransition(this); + teleporttransition.postTeleportTransition().onTransition(this); return this; } else { + // CraftBukkit start @@ -530,31 +628,22 @@ this.isChangingDimension = true; WorldData worlddata = worldserver.getLevelData(); -@@ -950,15 +1204,40 @@ +@@ -1199,17 +1481,31 @@ playerlist.sendPlayerPermissionLevel(this); worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); this.unsetRemoved(); + */ + // CraftBukkit end - worldserver1.getProfiler().push("moving"); + GameProfilerFiller gameprofilerfiller = Profiler.get(); + + gameprofilerfiller.push("moving"); - if (resourcekey == World.OVERWORLD && worldserver.dimension() == World.NETHER) { + if (worldserver != null && resourcekey == WorldDimension.OVERWORLD && worldserver.getTypeKey() == WorldDimension.NETHER) { // CraftBukkit - empty to fall through to null to event this.enteredNetherPosition = this.position(); } -+ // CraftBukkit start -+ Location enter = this.getBukkitEntity().getLocation(); -+ Location exit = (worldserver == null) ? null : CraftLocation.toBukkit(dimensiontransition.pos(), worldserver.getWorld(), dimensiontransition.yRot(), dimensiontransition.xRot()); -+ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, dimensiontransition.cause()); -+ Bukkit.getServer().getPluginManager().callEvent(tpEvent); -+ if (tpEvent.isCancelled() || tpEvent.getTo() == null) { -+ return null; -+ } -+ exit = tpEvent.getTo(); -+ worldserver = ((CraftWorld) exit.getWorld()).getHandle(); -+ // CraftBukkit end - worldserver1.getProfiler().pop(); - worldserver1.getProfiler().push("placing"); + gameprofilerfiller.pop(); + gameprofilerfiller.push("placing"); + // CraftBukkit start + this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds + WorldData worlddata = worldserver.getLevelData(); @@ -568,12 +657,12 @@ + this.unsetRemoved(); + // CraftBukkit end this.setServerLevel(worldserver); -- this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot()); -+ this.connection.teleport(exit); // CraftBukkit - use internal teleport without event +- this.connection.teleport(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); ++ this.connection.internalTeleport(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); // CraftBukkit - use internal teleport without event this.connection.resetPosition(); worldserver.addDuringTeleport(this); - worldserver1.getProfiler().pop(); -@@ -971,21 +1250,47 @@ + gameprofilerfiller.pop(); +@@ -1223,11 +1519,29 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -600,6 +689,10 @@ + } + // CraftBukkit end + + @Override + public void forceSetRotation(float f, float f1) { + this.connection.send(new ClientboundPlayerRotationPacket(f, f1)); +@@ -1236,13 +1550,21 @@ public void triggerDimensionChangeTriggers(WorldServer worldserver) { ResourceKey resourcekey = worldserver.dimension(); ResourceKey resourcekey1 = this.level().dimension(); @@ -624,7 +717,7 @@ this.enteredNetherPosition = null; } -@@ -1002,19 +1307,17 @@ +@@ -1259,19 +1581,17 @@ this.containerMenu.broadcastChanges(); } @@ -648,7 +741,7 @@ if (this.level().isDay()) { return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW); } else { -@@ -1031,7 +1334,36 @@ +@@ -1288,7 +1608,36 @@ } } @@ -686,7 +779,7 @@ this.awardStat(StatisticList.SLEEP_IN_BED); CriterionTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1044,9 +1376,8 @@ +@@ -1301,9 +1650,8 @@ return either; } } @@ -697,7 +790,7 @@ } @Override -@@ -1073,13 +1404,31 @@ +@@ -1330,13 +1678,31 @@ @Override public void stopSleepInBed(boolean flag, boolean flag1) { @@ -730,7 +823,7 @@ } } -@@ -1146,8 +1495,9 @@ +@@ -1403,8 +1769,9 @@ this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag)); } @@ -741,7 +834,7 @@ } @Override -@@ -1155,13 +1505,35 @@ +@@ -1412,13 +1779,35 @@ if (itileinventory == null) { return OptionalInt.empty(); } else { @@ -777,7 +870,7 @@ if (container == null) { if (this.isSpectator()) { this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true); -@@ -1169,9 +1541,11 @@ +@@ -1426,9 +1815,11 @@ return OptionalInt.empty(); } else { @@ -791,7 +884,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1184,15 +1558,26 @@ +@@ -1441,15 +1832,26 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -820,7 +913,7 @@ this.initMenu(this.containerMenu); } -@@ -1215,6 +1600,7 @@ +@@ -1472,6 +1874,7 @@ @Override public void closeContainer() { @@ -828,24 +921,7 @@ this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); this.doCloseContainer(); } -@@ -1237,6 +1623,16 @@ - } - - this.jumping = flag; -+ // CraftBukkit start -+ if (flag1 != this.isShiftKeyDown()) { -+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getBukkitEntity(), flag1); -+ this.server.server.getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ return; -+ } -+ } -+ // CraftBukkit end - this.setShiftKeyDown(flag1); - } - -@@ -1270,19 +1666,19 @@ +@@ -1501,19 +1904,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); @@ -868,7 +944,7 @@ } } else if (this.onClimbable()) { if (d1 > 0.0D) { -@@ -1293,13 +1689,13 @@ +@@ -1524,13 +1927,13 @@ if (i > 0) { if (this.isSprinting()) { this.awardStat(StatisticList.SPRINT_ONE_CM, i); @@ -885,7 +961,7 @@ } } } else if (this.isFallFlying()) { -@@ -1342,7 +1738,7 @@ +@@ -1573,7 +1976,7 @@ @Override public void awardStat(Statistic statistic, int i) { this.stats.increment(this, statistic, i); @@ -894,7 +970,7 @@ scoreaccess.add(i); }); } -@@ -1350,7 +1746,7 @@ +@@ -1581,7 +1984,7 @@ @Override public void resetStat(Statistic statistic) { this.stats.setValue(this, statistic, 0); @@ -903,7 +979,19 @@ } @Override -@@ -1398,6 +1794,7 @@ +@@ -1613,9 +2016,9 @@ + super.jumpFromGround(); + this.awardStat(StatisticList.JUMP); + if (this.isSprinting()) { +- this.causeFoodExhaustion(0.2F); ++ this.causeFoodExhaustion(0.2F, EntityExhaustionEvent.ExhaustionReason.JUMP_SPRINT); // CraftBukkit - EntityExhaustionEvent + } else { +- this.causeFoodExhaustion(0.05F); ++ this.causeFoodExhaustion(0.05F, EntityExhaustionEvent.ExhaustionReason.JUMP); // CraftBukkit - EntityExhaustionEvent + } + + } +@@ -1641,6 +2044,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -911,16 +999,7 @@ } @Override -@@ -1433,7 +1830,7 @@ - this.gameMode.setGameModeForPlayer(entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer()); - this.onUpdateAbilities(); - this.getAttributes().assignBaseValues(entityplayer.getAttributes()); -- this.setHealth(this.getMaxHealth()); -+ // this.setHealth(this.getMaxHealth()); // CraftBukkit - if (flag) { - this.getInventory().replaceWith(entityplayer.getInventory()); - this.setHealth(entityplayer.getHealth()); -@@ -1443,7 +1840,7 @@ +@@ -1685,7 +2089,7 @@ while (iterator.hasNext()) { MobEffect mobeffect = (MobEffect) iterator.next(); @@ -928,8 +1007,17 @@ + // this.addEffect(new MobEffect(mobeffect)); // CraftBukkit } - this.experienceLevel = entityplayer.experienceLevel; -@@ -1465,7 +1862,7 @@ + this.getInventory().replaceWith(entityplayer.getInventory()); +@@ -1696,7 +2100,7 @@ + this.portalProcess = entityplayer.portalProcess; + } else { + this.getAttributes().assignBaseValues(entityplayer.getAttributes()); +- this.setHealth(this.getMaxHealth()); ++ // this.setHealth(this.getMaxHealth()); // CraftBukkit + if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || entityplayer.isSpectator()) { + this.getInventory().replaceWith(entityplayer.getInventory()); + this.experienceLevel = entityplayer.experienceLevel; +@@ -1712,7 +2116,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -938,32 +1026,25 @@ this.seenCredits = entityplayer.seenCredits; this.enteredNetherPosition = entityplayer.enteredNetherPosition; this.chunkTrackingView = entityplayer.chunkTrackingView; -@@ -1516,6 +1913,12 @@ +@@ -1768,7 +2172,7 @@ + } @Override - public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1) { -+ // CraftBukkit start -+ return teleportTo(worldserver, d0, d1, d2, set, f, f1, TeleportCause.UNKNOWN); -+ } -+ -+ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, TeleportCause cause) { -+ // CraftBukkit end +- public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, boolean flag) { ++ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, boolean flag, TeleportCause cause) { // CraftBukkit ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2)); worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId()); -@@ -1525,9 +1928,9 @@ +@@ -1780,7 +2184,7 @@ + this.setCamera(this); } - if (worldserver == this.level()) { -- this.connection.teleport(d0, d1, d2, f, f1, set); -+ this.connection.teleport(d0, d1, d2, f, f1, set, cause); // CraftBukkit - } else { -- this.teleportTo(worldserver, d0, d1, d2, f, f1); -+ this.teleportTo(worldserver, d0, d1, d2, f, f1, cause); // CraftBukkit - } +- boolean flag1 = super.teleportTo(worldserver, d0, d1, d2, set, f, f1, flag); ++ boolean flag1 = super.teleportTo(worldserver, d0, d1, d2, set, f, f1, flag, cause); // CraftBukkit - this.setYHeadRot(f); -@@ -1635,6 +2038,16 @@ + if (flag1) { + this.setYHeadRot(set.contains(Relative.Y_ROT) ? this.getYHeadRot() + f : f); +@@ -1897,6 +2301,16 @@ } public void updateOptions(ClientInformation clientinformation) { @@ -980,16 +1061,16 @@ this.language = clientinformation.language(); this.requestedViewDistance = clientinformation.viewDistance(); this.chatVisibility = clientinformation.chatVisibility(); -@@ -1718,7 +2131,7 @@ +@@ -1981,7 +2395,7 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; -- this.teleportTo(worldserver, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot()); -+ this.teleportTo(worldserver, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit +- this.teleportTo(worldserver, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot(), false); ++ this.teleportTo(worldserver, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot(), false, TeleportCause.SPECTATE); // CraftBukkit } if (entity != null) { -@@ -1755,7 +2168,7 @@ +@@ -2018,11 +2432,11 @@ @Nullable public IChatBaseComponent getTabListDisplayName() { @@ -997,33 +1078,13 @@ + return listName; // CraftBukkit } - @Override -@@ -1776,14 +2189,24 @@ - return this.advancements; - } - -+ // CraftBukkit start - public void teleportTo(WorldServer worldserver, double d0, double d1, double d2, float f, float f1) { -+ this.teleportTo(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); -+ } -+ -+ public void teleportTo(WorldServer worldserver, double d0, double d1, double d2, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { -+ // CraftBukkit end - this.setCamera(this); - this.stopRiding(); -+ /* CraftBukkit start - replace with bukkit handling for multi-world - if (worldserver == this.level()) { - this.connection.teleport(d0, d1, d2, f, f1); - } else { - this.changeDimension(new DimensionTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1, DimensionTransition.DO_NOTHING)); - } -+ */ -+ this.getBukkitEntity().teleport(new Location(worldserver.getWorld(), d0, d1, d2, f, f1), cause); -+ // CraftBukkit end - + public int getTabListOrder() { +- return 0; ++ return listOrder; // CraftBukkit } -@@ -1809,6 +2232,32 @@ + @Override +@@ -2065,6 +2479,32 @@ } public void setRespawnPosition(ResourceKey resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) { @@ -1056,24 +1117,48 @@ if (blockposition != null) { boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension); -@@ -1852,7 +2301,14 @@ +@@ -2107,12 +2547,38 @@ + } @Override - public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { -- EntityItem entityitem = super.drop(itemstack, flag, flag1); -+ // CraftBukkit start - SPIGOT-2942: Add boolean to call event -+ return drop(itemstack, flag, flag1, true); -+ } -+ -+ @Override -+ public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) { -+ EntityItem entityitem = super.drop(itemstack, flag, flag1, callEvent); -+ // CraftBukkit end +- public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { ++ public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) { // CraftBukkit - SPIGOT-2942: Add boolean to call event + EntityItem entityitem = this.createItemStackToDrop(itemstack, flag, flag1); if (entityitem == null) { return null; -@@ -2049,10 +2505,12 @@ - this.awardStat(StatisticList.ITEM_BROKEN.get(item)); + } else { ++ // CraftBukkit start - fire PlayerDropItemEvent ++ if (callEvent) { ++ Player player = (Player) this.getBukkitEntity(); ++ org.bukkit.entity.Item drop = (org.bukkit.entity.Item) entityitem.getBukkitEntity(); ++ ++ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); ++ this.level().getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); ++ if (flag1 && (cur == null || cur.getAmount() == 0)) { ++ // The complete stack was dropped ++ player.getInventory().setItemInHand(drop.getItemStack()); ++ } else if (flag1 && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) { ++ // Only one item is dropped ++ cur.setAmount(cur.getAmount() + 1); ++ player.getInventory().setItemInHand(cur); ++ } else { ++ // Fallback ++ player.getInventory().addItem(drop.getItemStack()); ++ } ++ return null; ++ } ++ } ++ // CraftBukkit end ++ + this.level().addFreshEntity(entityitem); + ItemStack itemstack1 = entityitem.getItem(); + +@@ -2394,10 +2860,12 @@ + return TicketType.ENDER_PEARL.timeout(); } - public static record RespawnPosAngle(Vec3D position, float yaw) { @@ -1088,7 +1173,7 @@ } private static float calculateLookAtYaw(Vec3D vec3d, BlockPosition blockposition) { -@@ -2061,4 +2519,147 @@ +@@ -2406,4 +2874,146 @@ return (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); } } @@ -1195,7 +1280,6 @@ + + public void reset() { + float exp = 0; -+ boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY); + + if (this.keepLevel) { // CraftBukkit - SPIGOT-6687: Only use keepLevel (was pre-set with RULE_KEEPINVENTORY value in PlayerDeathEvent) + exp = this.experienceProgress; @@ -1207,7 +1291,7 @@ + this.stopUsingItem(); // CraftBukkit - SPIGOT-6682: Clear active item on reset + this.setRemainingFireTicks(0); + this.fallDistance = 0; -+ this.foodData = new FoodMetaData(this); ++ this.foodData = new FoodMetaData(); + this.experienceLevel = this.newLevel; + this.totalExperience = this.newTotalExp; + this.experienceProgress = 0; diff --git a/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch b/nms-patches/net/minecraft/server/level/EntityTrackerEntry.patch index f8ac888b..1e4584f0 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 -@@ -46,6 +46,12 @@ +@@ -50,6 +50,12 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -13,7 +13,7 @@ public class EntityTrackerEntry { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -70,8 +76,12 @@ +@@ -74,8 +80,12 @@ private boolean wasOnGround; @Nullable private List> trackedDataValues; @@ -27,7 +27,7 @@ this.level = worldserver; this.broadcast = consumer; this.entity = entity; -@@ -90,7 +100,7 @@ +@@ -94,7 +104,7 @@ List list = this.entity.getPassengers(); if (!list.equals(this.lastPassengers)) { @@ -36,7 +36,7 @@ removedPassengers(list, this.lastPassengers).forEach((entity) -> { if (entity instanceof EntityPlayer entityplayer) { entityplayer.connection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot()); -@@ -103,18 +113,18 @@ +@@ -107,18 +117,18 @@ Entity entity = this.entity; if (entity instanceof EntityItemFrame entityitemframe) { @@ -59,7 +59,7 @@ worldmap.tickCarriedBy(entityplayer, itemstack); Packet packet = worldmap.getUpdatePacket(mapid, entityplayer); -@@ -232,6 +242,27 @@ +@@ -248,6 +258,27 @@ ++this.tickCount; if (this.entity.hurtMarked) { @@ -87,7 +87,7 @@ this.entity.hurtMarked = false; this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity)); } -@@ -260,7 +291,10 @@ +@@ -298,7 +329,10 @@ public void sendPairingData(EntityPlayer entityplayer, Consumer> consumer) { if (this.entity.isRemoved()) { @@ -99,7 +99,7 @@ } Packet packet = this.entity.getAddEntityPacket(this); -@@ -275,6 +309,12 @@ +@@ -313,6 +347,12 @@ if (this.entity instanceof EntityLiving) { Collection collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes(); @@ -112,7 +112,7 @@ if (!collection.isEmpty()) { consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection)); } -@@ -305,6 +345,7 @@ +@@ -344,6 +384,7 @@ if (!list.isEmpty()) { consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list)); } @@ -120,7 +120,7 @@ } if (!this.entity.getPassengers().isEmpty()) { -@@ -358,6 +399,11 @@ +@@ -396,6 +437,11 @@ Set set = ((EntityLiving) this.entity).getAttributes().getAttributesToSync(); if (!set.isEmpty()) { diff --git a/nms-patches/net/minecraft/server/level/PlayerChunk.patch b/nms-patches/net/minecraft/server/level/PlayerChunk.patch index 085ee7e4..8cdc5508 100644 --- a/nms-patches/net/minecraft/server/level/PlayerChunk.patch +++ b/nms-patches/net/minecraft/server/level/PlayerChunk.patch @@ -52,15 +52,15 @@ } @Nullable -@@ -134,6 +150,7 @@ - if (chunk != null) { +@@ -138,6 +154,7 @@ + boolean flag = this.hasChangedSections; int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY()); -+ if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 ++ if (i < 0 || i >= this.changedBlocksPerSection.length) return false; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 if (this.changedBlocksPerSection[i] == null) { this.hasChangedSections = true; this.changedBlocksPerSection[i] = new ShortOpenHashSet(); -@@ -208,8 +225,11 @@ +@@ -224,8 +241,11 @@ PacketPlayOutMultiBlockChange packetplayoutmultiblockchange = new PacketPlayOutMultiBlockChange(sectionposition, shortset, chunksection); this.broadcast(list, packetplayoutmultiblockchange); @@ -73,7 +73,7 @@ }); } } -@@ -275,7 +295,7 @@ +@@ -291,7 +311,7 @@ this.pendingFullStateConfirmation = completablefuture1; completablefuture.thenAccept((chunkresult) -> { chunkresult.ifSuccess((chunk) -> { @@ -82,13 +82,19 @@ }); }); } -@@ -290,6 +310,30 @@ - FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel); - boolean flag = fullchunkstatus.isOrAfter(FullChunkStatus.FULL); - boolean flag1 = fullchunkstatus1.isOrAfter(FullChunkStatus.FULL); -+ // CraftBukkit start -+ // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins. -+ if (flag && !flag1) { +@@ -301,6 +321,38 @@ + playerchunkmap.onFullChunkStatusChange(this.pos, fullchunkstatus); + } + ++ // CraftBukkit start ++ // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins. ++ // SPIGOT-7780: Moved out of updateFutures to call all chunk unload events before calling updateHighestAllowedStatus for all chunks ++ protected void callEventIfUnloading(PlayerChunkMap playerchunkmap) { ++ FullChunkStatus oldFullChunkStatus = ChunkLevel.fullStatus(this.oldTicketLevel); ++ FullChunkStatus newFullChunkStatus = ChunkLevel.fullStatus(this.ticketLevel); ++ boolean oldIsFull = oldFullChunkStatus.isOrAfter(FullChunkStatus.FULL); ++ boolean newIsFull = newFullChunkStatus.isOrAfter(FullChunkStatus.FULL); ++ if (oldIsFull && !newIsFull) { + this.getFullChunkFuture().thenAccept((either) -> { + Chunk chunk = (Chunk) either.orElse(null); + if (chunk != null) { @@ -96,7 +102,7 @@ + // Minecraft will apply the chunks tick lists to the world once the chunk got loaded, and then store the tick + // lists again inside the chunk once the chunk becomes inaccessible and set the chunk's needsSaving flag. + // These actions may however happen deferred, so we manually set the needsSaving flag already here. -+ chunk.setUnsaved(true); ++ chunk.markUnsaved(); + chunk.unloadCallback(); + }); + } @@ -109,11 +115,13 @@ + // Run callback right away if the future was already done + playerchunkmap.callbackExecutor.run(); + } -+ // CraftBukkit end - - this.wasAccessibleSinceLastSave |= flag1; - if (!flag && flag1) { -@@ -341,6 +385,26 @@ ++ } ++ // CraftBukkit end ++ + protected void updateFutures(PlayerChunkMap playerchunkmap, Executor executor) { + FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel); + FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel); +@@ -357,6 +409,26 @@ this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel); this.oldTicketLevel = this.ticketLevel; diff --git a/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch b/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch index f6390c0e..91440ae9 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 -@@ -102,6 +102,10 @@ +@@ -104,6 +104,10 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; @@ -11,7 +11,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.b, GeneratingChunkMap { private static final ChunkResult> UNLOADED_CHUNK_LIST_RESULT = ChunkResult.error("Unloaded chunks found in range"); -@@ -145,6 +149,27 @@ +@@ -149,6 +153,27 @@ public int serverViewDistance; private final WorldGenContext worldGenContext; @@ -39,7 +39,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(new RegionStorageInfo(convertable_conversionsession.getLevelId(), worldserver.dimension(), "chunk"), convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag); this.visibleChunkMap = this.updatingChunkMap.clone(); -@@ -164,7 +189,13 @@ +@@ -170,7 +195,13 @@ IRegistryCustom iregistrycustom = worldserver.registryAccess(); long j = worldserver.getSeed(); @@ -54,7 +54,7 @@ this.randomState = RandomState.create((GeneratorSettingBase) chunkgeneratorabstract.generatorSettings().value(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j); } else { this.randomState = RandomState.create(GeneratorSettingBase.dummy(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j); -@@ -318,7 +349,7 @@ +@@ -325,7 +356,7 @@ throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), "n/a"); } @@ -63,7 +63,7 @@ if (ichunkaccess == null) { return PlayerChunkMap.UNLOADED_CHUNK_LIST_RESULT; -@@ -937,7 +968,8 @@ +@@ -977,7 +1008,8 @@ return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); }); @@ -73,7 +73,7 @@ return chunk.getBlockEntities().size(); }).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> { return chunk.getBlockTicks().count(); -@@ -950,7 +982,7 @@ +@@ -990,7 +1022,7 @@ private static String printFuture(CompletableFuture> completablefuture) { try { @@ -82,13 +82,13 @@ return chunkresult != null ? (chunkresult.isSuccess() ? "done" : "unloaded") : "not completed"; } catch (CompletionException completionexception) { -@@ -962,12 +994,14 @@ +@@ -1002,12 +1034,14 @@ private CompletableFuture> readChunk(ChunkCoordIntPair chunkcoordintpair) { return this.read(chunkcoordintpair).thenApplyAsync((optional) -> { - return optional.map(this::upgradeChunkTag); + return optional.map((nbttagcompound) -> upgradeChunkTag(nbttagcompound, chunkcoordintpair)); // CraftBukkit - }, SystemUtils.backgroundExecutor()); + }, SystemUtils.backgroundExecutor().forName("upgradeChunk")); } - private NBTTagCompound upgradeChunkTag(NBTTagCompound nbttagcompound) { @@ -99,8 +99,8 @@ + // CraftBukkit end } - boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) { -@@ -1370,7 +1404,7 @@ + void forEachSpawnCandidateChunk(Consumer consumer) { +@@ -1424,7 +1458,7 @@ public final Set seenBy = Sets.newIdentityHashSet(); public EntityTracker(final Entity entity, final int i, final int j, final boolean flag) { @@ -109,7 +109,7 @@ this.entity = entity; this.range = i; this.lastSectionPos = SectionPosition.of((EntityAccess) entity); -@@ -1430,6 +1464,11 @@ +@@ -1484,6 +1518,11 @@ double d2 = d0 * d0; boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer) && PlayerChunkMap.this.isChunkTracked(entityplayer, this.entity.chunkPosition().x, this.entity.chunkPosition().z); diff --git a/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch b/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch index a82ef80b..5826f84b 100644 --- a/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch +++ b/nms-patches/net/minecraft/server/level/PlayerInteractManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/PlayerInteractManager.java +++ b/net/minecraft/server/level/PlayerInteractManager.java -@@ -28,6 +28,27 @@ +@@ -26,6 +26,27 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -28,7 +28,7 @@ public class PlayerInteractManager { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -58,9 +79,16 @@ +@@ -56,9 +77,16 @@ if (enumgamemode == this.gameModeForPlayer) { return false; } else { @@ -46,7 +46,7 @@ this.level.updateSleepingPlayerList(); if (enumgamemode == EnumGamemode.CREATIVE) { this.player.resetCurrentImpulseContext(); -@@ -94,7 +122,7 @@ +@@ -92,7 +120,7 @@ } public void tick() { @@ -55,7 +55,7 @@ IBlockData iblockdata; if (this.hasDelayedDestroy) { -@@ -148,11 +176,33 @@ +@@ -146,11 +174,33 @@ if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) { if (!this.level.mayInteract(this.player, blockposition)) { @@ -89,7 +89,7 @@ if (this.isCreative()) { this.destroyAndAck(blockposition, j, "creative destroy"); return; -@@ -168,7 +218,19 @@ +@@ -166,7 +216,19 @@ float f = 1.0F; iblockdata = this.level.getBlockState(blockposition); @@ -110,7 +110,7 @@ EnchantmentManager.onHitBlock(this.level, this.player.getMainHandItem(), this.player, this.player, EnumItemSlot.MAINHAND, Vec3D.atCenterOf(blockposition), iblockdata, (item) -> { this.player.onEquippedItemBroken(item, EnumItemSlot.MAINHAND); }); -@@ -176,6 +238,26 @@ +@@ -174,6 +236,26 @@ f = iblockdata.getDestroyProgress(this.player, this.player.level(), blockposition); } @@ -137,7 +137,7 @@ if (!iblockdata.isAir() && f >= 1.0F) { this.destroyAndAck(blockposition, j, "insta mine"); } else { -@@ -220,13 +302,15 @@ +@@ -218,13 +300,15 @@ } else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) { this.isDestroyingBlock = false; if (!Objects.equals(this.destroyPos, blockposition)) { @@ -154,7 +154,7 @@ } } -@@ -244,10 +328,65 @@ +@@ -242,10 +326,65 @@ public boolean destroyBlock(BlockPosition blockposition) { IBlockData iblockdata = this.level.getBlockState(blockposition); @@ -221,7 +221,7 @@ TileEntity tileentity = this.level.getBlockEntity(blockposition); Block block = iblockdata.getBlock(); -@@ -257,6 +396,10 @@ +@@ -255,6 +394,10 @@ } else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) { return false; } else { @@ -232,7 +232,7 @@ IBlockData iblockdata1 = block.playerWillDestroy(this.level, blockposition, iblockdata, this.player); boolean flag = this.level.removeBlock(blockposition, false); -@@ -265,19 +408,32 @@ +@@ -263,19 +406,32 @@ } if (this.isCreative()) { @@ -268,7 +268,7 @@ } } } -@@ -315,14 +471,53 @@ +@@ -321,14 +477,53 @@ } } @@ -290,7 +290,7 @@ + cancelledBlock = !(itileinventory instanceof ITileInventory); + } + -+ if (entityplayer.getCooldowns().isOnCooldown(itemstack.getItem())) { ++ if (entityplayer.getCooldowns().isOnCooldown(itemstack)) { + cancelledBlock = true; + } + @@ -322,11 +322,11 @@ if (itileinventory != null) { entityplayer.openMenu(itileinventory); -@@ -353,7 +548,7 @@ +@@ -359,7 +554,7 @@ } } -- if (!itemstack.isEmpty() && !entityplayer.getCooldowns().isOnCooldown(itemstack.getItem())) { +- if (!itemstack.isEmpty() && !entityplayer.getCooldowns().isOnCooldown(itemstack)) { + if (!itemstack.isEmpty() && !interactResult) { // add !interactResult SPIGOT-764 ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock); diff --git a/nms-patches/net/minecraft/server/level/TicketType.patch b/nms-patches/net/minecraft/server/level/TicketType.patch index a83c57b3..64176430 100644 --- a/nms-patches/net/minecraft/server/level/TicketType.patch +++ b/nms-patches/net/minecraft/server/level/TicketType.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java -@@ -22,6 +22,8 @@ - public static final TicketType PORTAL = create("portal", BaseBlockPosition::compareTo, 300); +@@ -23,6 +23,8 @@ + public static final TicketType ENDER_PEARL = create("ender_pearl", Comparator.comparingLong(ChunkCoordIntPair::toLong), 40); public static final TicketType POST_TELEPORT = create("post_teleport", Integer::compareTo, 5); public static final TicketType UNKNOWN = create("unknown", Comparator.comparingLong(ChunkCoordIntPair::toLong), 1); + public static final TicketType PLUGIN = create("plugin", (a, b) -> 0); // CraftBukkit diff --git a/nms-patches/net/minecraft/server/level/WorldServer.patch b/nms-patches/net/minecraft/server/level/WorldServer.patch index 2327d7de..170108a5 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 -@@ -171,6 +171,23 @@ +@@ -173,6 +173,23 @@ import net.minecraft.world.ticks.TickListServer; import org.slf4j.Logger; @@ -21,31 +21,28 @@ +import org.bukkit.event.world.TimeSkipEvent; +// CraftBukkit end + - public class WorldServer extends World implements GeneratorAccessSeed { + public class WorldServer extends World implements ServerEntityGetter, GeneratorAccessSeed { public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0); -@@ -184,7 +201,7 @@ - final List players; +@@ -186,7 +203,7 @@ + final List players = Lists.newArrayList(); private final ChunkProviderServer chunkSource; private final MinecraftServer server; - public final IWorldDataServer serverLevelData; + public final WorldDataServer serverLevelData; // CraftBukkit - type private int lastSpawnChunkRadius; - final EntityTickList entityTickList; + final EntityTickList entityTickList = new EntityTickList(); public final PersistentEntitySectionManager entityManager; -@@ -211,12 +228,30 @@ +@@ -213,13 +230,47 @@ private final boolean tickTime; private final RandomSequences randomSequences; - 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, @Nullable RandomSequences randomsequences) { -- IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); -- Holder holder = worlddimension.type(); +- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates()); + // CraftBukkit start + public final Convertable.ConversionSession convertable; + public final UUID uuid; - -- Objects.requireNonNull(minecraftserver); -- super(iworlddataserver, resourcekey, iregistrycustom_dimension, holder, minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates()); ++ + public Chunk getChunkIfLoaded(int x, int z) { + return this.chunkSource.getChunk(x, z, false); + } @@ -57,19 +54,13 @@ + + // 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, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { -+ // IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error -+ // Holder holder = worlddimension.type(); // CraftBukkit - decompile error -+ -+ // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error -+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env); ++ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env); + this.pvpMode = minecraftserver.isPvpAllowed(); + convertable = convertable_conversionsession; + uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); + // CraftBukkit end - this.players = Lists.newArrayList(); - this.entityTickList = new EntityTickList(); - this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); -@@ -231,6 +266,22 @@ + this.tickTime = flag1; + this.server = minecraftserver; this.customSpawners = list; this.serverLevelData = iworlddataserver; ChunkGenerator chunkgenerator = worlddimension.generator(); @@ -77,7 +68,7 @@ + serverLevelData.setWorld(this); + + if (biomeProvider != null) { -+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(getWorld(), biomeProvider, server.registryAccess().registryOrThrow(Registries.BIOME)); ++ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(getWorld(), biomeProvider, server.registryAccess().lookupOrThrow(Registries.BIOME)); + if (chunkgenerator instanceof ChunkGeneratorAbstract cga) { + chunkgenerator = new ChunkGeneratorAbstract(worldChunkManager, cga.settings); + } else if (chunkgenerator instanceof ChunkProviderFlat cpf) { @@ -92,7 +83,7 @@ boolean flag2 = minecraftserver.forceSynchronousWrites(); DataFixer datafixer = minecraftserver.getFixerUpper(); EntityPersistentStorage entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver); -@@ -258,9 +309,9 @@ +@@ -247,9 +298,9 @@ long l = minecraftserver.getWorldData().worldGenOptions().seed(); this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer); @@ -105,7 +96,7 @@ } else { this.dragonFight = null; } -@@ -270,6 +321,7 @@ +@@ -259,6 +310,7 @@ this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> { return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.factory(l), "random_sequences"); }); @@ -113,7 +104,7 @@ } /** @deprecated */ -@@ -314,12 +366,20 @@ +@@ -304,12 +356,20 @@ long j; if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { @@ -137,7 +128,7 @@ if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -354,7 +414,7 @@ +@@ -344,7 +404,7 @@ this.handlingTick = false; gameprofilerfiller.pop(); @@ -146,16 +137,7 @@ if (flag1) { this.resetEmptyTime(); -@@ -370,7 +430,7 @@ - - this.entityTickList.forEach((entity) -> { - if (!entity.isRemoved()) { -- if (this.shouldDiscardEntity(entity)) { -+ if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed - entity.discard(); - } else if (!tickratemanager.isEntityFrozen(entity)) { - gameprofilerfiller.push("checkDespawn"); -@@ -442,7 +502,7 @@ +@@ -428,7 +488,7 @@ private void wakeUpAllPlayers() { this.sleepStatus.removeAllSleepers(); @@ -164,7 +146,7 @@ entityplayer.stopSleepInBed(false, false); }); } -@@ -469,7 +529,7 @@ +@@ -455,7 +515,7 @@ entityhorseskeleton.setTrap(true); entityhorseskeleton.setAge(0); entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); @@ -173,7 +155,7 @@ } } -@@ -478,7 +538,7 @@ +@@ -464,7 +524,7 @@ if (entitylightning != null) { entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); entitylightning.setVisualOnly(flag1); @@ -182,7 +164,7 @@ } } } -@@ -534,7 +594,7 @@ +@@ -520,7 +580,7 @@ BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value(); if (biomebase.shouldFreeze(this, blockposition2)) { @@ -191,7 +173,7 @@ } if (this.isRaining()) { -@@ -550,10 +610,10 @@ +@@ -536,10 +596,10 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1); Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1); @@ -204,7 +186,7 @@ } } -@@ -714,6 +774,7 @@ +@@ -700,6 +760,7 @@ this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -212,7 +194,7 @@ if (this.oRainLevel != this.rainLevel) { this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); } -@@ -732,15 +793,48 @@ +@@ -718,15 +779,48 @@ this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -263,15 +245,15 @@ } public void resetEmptyTime() { -@@ -775,6 +869,7 @@ +@@ -762,6 +856,7 @@ }); gameprofilerfiller.incrementCounter("tickNonPassenger"); entity.tick(); + entity.postTick(); // CraftBukkit - this.getProfiler().pop(); + gameprofilerfiller.pop(); Iterator iterator = entity.getPassengers().iterator(); -@@ -798,6 +893,7 @@ +@@ -785,6 +880,7 @@ }); gameprofilerfiller.incrementCounter("tickPassenger"); entity1.rideTick(); @@ -279,7 +261,7 @@ gameprofilerfiller.pop(); Iterator iterator = entity1.getPassengers().iterator(); -@@ -822,6 +918,7 @@ +@@ -809,6 +905,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkSource(); if (!flag1) { @@ -287,7 +269,7 @@ if (iprogressupdate != null) { iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel")); } -@@ -839,11 +936,19 @@ +@@ -826,11 +923,19 @@ } } @@ -301,14 +283,14 @@ + // CraftBukkit end } - private void saveLevelData() { + private void saveLevelData(boolean flag) { if (this.dragonFight != null) { - this.server.getWorldData().setEndDragonFightData(this.dragonFight.saveData()); + this.serverLevelData.setEndDragonFightData(this.dragonFight.saveData()); // CraftBukkit } - this.getChunkSource().getDataStorage().save(); -@@ -908,18 +1013,40 @@ + WorldPersistentData worldpersistentdata = this.getChunkSource().getDataStorage(); +@@ -902,18 +1007,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -352,7 +334,7 @@ } } -@@ -944,24 +1071,37 @@ +@@ -938,24 +1065,37 @@ this.entityManager.addNewEntity(entityplayer); } @@ -394,19 +376,19 @@ return true; } } -@@ -972,13 +1112,35 @@ +@@ -966,13 +1106,35 @@ } public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) { - entityplayer.remove(entity_removalreason); + entityplayer.remove(entity_removalreason, null); // CraftBukkit - add Bukkit remove cause - } - ++ } ++ + // CraftBukkit start + public boolean strikeLightning(Entity entitylightning) { + return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN); -+ } -+ + } + + public boolean strikeLightning(Entity entitylightning, LightningStrikeEvent.Cause cause) { + LightningStrikeEvent lightning = CraftEventFactory.callLightningStrikeEvent((org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause); + @@ -431,7 +413,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -987,6 +1149,12 @@ +@@ -981,6 +1143,12 @@ double d1 = (double) blockposition.getY() - entityplayer.getY(); double d2 = (double) blockposition.getZ() - entityplayer.getZ(); @@ -444,7 +426,7 @@ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); } -@@ -1047,7 +1215,18 @@ +@@ -1059,7 +1227,18 @@ Iterator iterator = this.navigatingMobs.iterator(); while (iterator.hasNext()) { @@ -464,19 +446,52 @@ NavigationAbstract navigationabstract = entityinsentient.getNavigation(); if (navigationabstract.shouldRecomputePath(blockposition)) { -@@ -1109,6 +1288,11 @@ +@@ -1125,6 +1304,12 @@ + @Override - public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a, ParticleParam particleparam, ParticleParam particleparam1, Holder holder) { - Explosion explosion = this.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, false, particleparam, particleparam1, holder); + public void explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a, ParticleParam particleparam, ParticleParam particleparam1, Holder holder) { + // CraftBukkit start -+ if (explosion.wasCanceled) { -+ return explosion; ++ this.explode0(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, particleparam, particleparam1, holder); ++ } ++ ++ public ServerExplosion explode0(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a, ParticleParam particleparam, ParticleParam particleparam1, Holder holder) { ++ // CraftBukkit end + Explosion.Effect explosion_effect; + + switch (world_a) { +@@ -1143,6 +1328,11 @@ + case TRIGGER: + explosion_effect = Explosion.Effect.TRIGGER_BLOCK; + break; ++ // CraftBukkit start - handle custom explosion type ++ case STANDARD: ++ explosion_effect = Explosion.Effect.DESTROY; ++ break; ++ // CraftBukkit end + default: + throw new MatchException((String) null, (Throwable) null); + } +@@ -1152,6 +1342,11 @@ + ServerExplosion serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1); + + serverexplosion.explode(); ++ // CraftBukkit start ++ if (serverexplosion.wasCanceled) { ++ return serverexplosion; + } + // CraftBukkit end + ParticleParam particleparam2 = serverexplosion.isSmall() ? particleparam : particleparam1; + Iterator iterator = this.players.iterator(); + +@@ -1165,6 +1360,7 @@ + } + } + ++ return serverexplosion; // CraftBukkit + } - if (!explosion.interactsWithBlocks()) { - explosion.clearToBlow(); -@@ -1181,13 +1365,20 @@ + private Explosion.Effect getDestroyType(GameRules.GameRuleKey gamerules_gamerulekey) { +@@ -1225,13 +1421,20 @@ } public int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { @@ -499,7 +514,7 @@ ++j; } } -@@ -1238,7 +1429,7 @@ +@@ -1282,7 +1485,7 @@ @Nullable public BlockPosition findNearestMapStructure(TagKey tagkey, BlockPosition blockposition, int i, boolean flag) { @@ -507,8 +522,8 @@ + if (!this.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit return null; } else { - Optional> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey); -@@ -1280,11 +1471,22 @@ + Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(tagkey); +@@ -1324,11 +1527,22 @@ @Nullable @Override public WorldMap getMapData(MapId mapid) { @@ -532,7 +547,7 @@ this.getServer().overworld().getDataStorage().set(mapid.key(), worldmap); } -@@ -1595,6 +1797,11 @@ +@@ -1639,6 +1853,11 @@ @Override public void blockUpdated(BlockPosition blockposition, Block block) { if (!this.isDebug()) { @@ -544,7 +559,7 @@ this.updateNeighborsAt(blockposition, block); } -@@ -1614,12 +1821,12 @@ +@@ -1658,12 +1877,12 @@ } public boolean isFlat() { @@ -559,7 +574,7 @@ } @Nullable -@@ -1642,7 +1849,7 @@ +@@ -1686,7 +1905,7 @@ private static String getTypeCount(Iterable iterable, Function function) { try { Object2IntOpenHashMap object2intopenhashmap = new Object2IntOpenHashMap(); @@ -568,7 +583,7 @@ while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -1651,7 +1858,7 @@ +@@ -1695,7 +1914,7 @@ object2intopenhashmap.addTo(s, 1); } @@ -577,7 +592,7 @@ String s1 = (String) entry.getKey(); return s1 + ":" + entry.getIntValue(); -@@ -1796,6 +2003,8 @@ +@@ -1854,6 +2073,8 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -586,7 +601,7 @@ } public void onTrackingEnd(Entity entity) { -@@ -1827,6 +2036,14 @@ +@@ -1885,6 +2106,14 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); diff --git a/nms-patches/net/minecraft/server/network/PlayerConnection.patch b/nms-patches/net/minecraft/server/network/PlayerConnection.patch index ef370f58..b11116f7 100644 --- a/nms-patches/net/minecraft/server/network/PlayerConnection.patch +++ b/nms-patches/net/minecraft/server/network/PlayerConnection.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/PlayerConnection.java +++ b/net/minecraft/server/network/PlayerConnection.java -@@ -191,6 +191,67 @@ +@@ -196,6 +196,69 @@ import net.minecraft.world.phys.shapes.VoxelShapes; import org.slf4j.Logger; @@ -13,7 +13,7 @@ +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.PacketPlayOutSpawnEntity; ++import net.minecraft.network.protocol.game.PacketPlayOutSetSlot; +import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.entity.animal.Bucketable; +import net.minecraft.world.entity.EntityLiving; @@ -30,7 +30,9 @@ +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.inventory.CraftItemType; ++import org.bukkit.craftbukkit.inventory.CraftRecipe; +import org.bukkit.craftbukkit.util.CraftChatMessage; ++import org.bukkit.craftbukkit.util.CraftLocation; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.craftbukkit.util.LazyPlayerSet; +import org.bukkit.craftbukkit.util.Waitable; @@ -68,18 +70,7 @@ public class PlayerConnection extends ServerCommonPacketListenerImpl implements PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener { static final Logger LOGGER = LogUtils.getLogger(); -@@ -204,7 +265,9 @@ - public final PlayerChunkSender chunkSender; - private int tickCount; - private int ackBlockChangesUpTo = -1; -- private int chatSpamTickCount; -+ // CraftBukkit start - multithreaded fields -+ private final AtomicInteger chatSpamTickCount = new AtomicInteger(); -+ // CraftBukkit end - private int dropSpamTickCount; - private double firstGoodX; - private double firstGoodY; -@@ -239,7 +302,7 @@ +@@ -245,7 +308,7 @@ private boolean waitingForSwitchToConfig; public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) { @@ -88,7 +79,7 @@ this.chunkSender = new PlayerChunkSender(networkmanager.isMemoryConnection()); this.player = entityplayer; entityplayer.connection = this; -@@ -248,9 +311,25 @@ +@@ -254,9 +317,25 @@ Objects.requireNonNull(minecraftserver); this.signedMessageDecoder = SignedMessageChain.b.unsigned(uuid, minecraftserver::enforceSecureProfile); @@ -115,29 +106,15 @@ @Override public void tick() { if (this.ackBlockChangesUpTo > -1) { -@@ -302,15 +381,21 @@ - } - - this.keepConnectionAlive(); -+ // CraftBukkit start -+ for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !chatSpamTickCount.compareAndSet(spam, spam - 1); ) ; -+ /* Use thread-safe field access instead - if (this.chatSpamTickCount > 0) { - --this.chatSpamTickCount; - } -+ */ -+ // CraftBukkit end - - if (this.dropSpamTickCount > 0) { - --this.dropSpamTickCount; - } - +@@ -311,6 +390,7 @@ + this.chatSpamThrottler.tick(); + this.dropSpamThrottler.tick(); if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) { + this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854 this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.idling")); } -@@ -399,6 +484,13 @@ +@@ -399,6 +479,13 @@ if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) { WorldServer worldserver = this.player.serverLevel(); @@ -151,7 +128,7 @@ double d0 = entity.getX(); double d1 = entity.getY(); double d2 = entity.getZ(); -@@ -413,7 +505,33 @@ +@@ -413,7 +500,33 @@ double d9 = entity.getDeltaMovement().lengthSqr(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; @@ -186,7 +163,7 @@ PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); this.send(new PacketPlayOutVehicleMove(entity)); return; -@@ -453,14 +571,76 @@ +@@ -453,14 +566,76 @@ } entity.absMoveTo(d3, d4, d5, f, f1); @@ -261,9 +238,9 @@ + // CraftBukkit end + this.player.serverLevel().getChunkSource().move(this.player); + entity.recordMovementThroughBlocks(new Vec3D(d0, d1, d2), entity.position()); Vec3D vec3d = new Vec3D(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2); - -@@ -497,6 +677,7 @@ +@@ -498,6 +673,7 @@ } this.awaitingPositionFromClient = null; @@ -271,16 +248,7 @@ } } -@@ -504,7 +685,7 @@ - @Override - public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { - PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.serverLevel()); -- Optional optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe()); -+ Optional> optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe()); // CraftBukkit - decompile error - RecipeBookServer recipebookserver = this.player.getRecipeBook(); - - Objects.requireNonNull(recipebookserver); -@@ -514,6 +695,7 @@ +@@ -521,6 +697,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(PacketPlayInRecipeSettings packetplayinrecipesettings) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipesettings, this, this.player.serverLevel()); @@ -288,12 +256,12 @@ this.player.getRecipeBook().setBookSetting(packetplayinrecipesettings.getBookType(), packetplayinrecipesettings.isOpen(), packetplayinrecipesettings.isFiltering()); } -@@ -534,6 +716,12 @@ +@@ -541,6 +718,12 @@ @Override public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel()); + // CraftBukkit start -+ if (chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { ++ if (!this.chatSpamThrottler.isIncrementAndUnderThreshold(1, 500) && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { + this.disconnect(IChatBaseComponent.translatable("disconnect.spam")); + return; + } @@ -301,7 +269,7 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -543,6 +731,7 @@ +@@ -550,6 +733,7 @@ ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { @@ -309,7 +277,7 @@ Suggestions suggestions1 = suggestions.getList().size() <= 1000 ? suggestions : new Suggestions(suggestions.getRange(), suggestions.getList().subList(0, 1000)); this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions1)); -@@ -787,6 +976,13 @@ +@@ -796,6 +980,13 @@ Container container = this.player.containerMenu; if (container instanceof ContainerMerchant containermerchant) { @@ -323,7 +291,7 @@ if (!containermerchant.stillValid(this.player)) { PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant); return; -@@ -800,6 +996,13 @@ +@@ -809,6 +1000,13 @@ @Override public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { @@ -337,16 +305,7 @@ int i = packetplayinbedit.slot(); if (PlayerInventory.isHotbarSlot(i) || i == 40) { -@@ -808,7 +1011,7 @@ - - Objects.requireNonNull(list); - optional.ifPresent(list::add); -- Stream stream = packetplayinbedit.pages().stream().limit(100L); -+ Stream stream = packetplayinbedit.pages().stream().limit(100L); // CraftBukkit - decompile error - - Objects.requireNonNull(list); - stream.forEach(list::add); -@@ -823,12 +1026,16 @@ +@@ -829,12 +1027,16 @@ } private void updateBookContents(List list, int i) { @@ -356,7 +315,7 @@ + ItemStack itemstack = handItem.copy(); + // CraftBukkit end - if (itemstack.is(Items.WRITABLE_BOOK)) { + if (itemstack.has(DataComponents.WRITABLE_BOOK_CONTENT)) { List> list1 = list.stream().map(this::filterableFromOutgoing).toList(); itemstack.set(DataComponents.WRITABLE_BOOK_CONTENT, new WritableBookContent(list1)); @@ -364,7 +323,7 @@ } } -@@ -839,12 +1046,13 @@ +@@ -845,12 +1047,13 @@ ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK); itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT); @@ -380,7 +339,7 @@ } } -@@ -906,7 +1114,7 @@ +@@ -912,7 +1115,7 @@ } else { WorldServer worldserver = this.player.serverLevel(); @@ -389,7 +348,7 @@ if (this.tickCount == 0) { this.resetPosition(); } -@@ -921,7 +1129,15 @@ +@@ -927,7 +1130,15 @@ if (this.player.isPassenger()) { this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); this.player.serverLevel().getChunkSource().move(this.player); @@ -405,7 +364,7 @@ double d3 = this.player.getX(); double d4 = this.player.getY(); double d5 = this.player.getZ(); -@@ -943,15 +1159,33 @@ +@@ -949,15 +1160,33 @@ ++this.receivedMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount; @@ -432,16 +391,16 @@ + speed = player.getAbilities().walkingSpeed * 10f; + } + - if (!this.player.isChangingDimension() && (!this.player.level().getGameRules().getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK) || !flag)) { + if (this.shouldCheckPlayerMovement(flag)) { float f2 = flag ? 300.0F : 100.0F; -- if (d10 - d9 > (double) (f2 * (float) i) && !this.isSingleplayerOwner()) { -+ if (d10 - d9 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { +- if (d10 - d9 > (double) (f2 * (float) i)) { ++ if (d10 - d9 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2))) { + // CraftBukkit end PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8}); this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); return; -@@ -973,6 +1207,7 @@ +@@ -979,6 +1208,7 @@ boolean flag2 = this.player.verticalCollisionBelow; this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8)); @@ -449,12 +408,12 @@ double d11 = d7; d6 = d0 - this.player.getX(); -@@ -991,9 +1226,75 @@ +@@ -997,9 +1227,75 @@ } if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) { - this.teleport(d3, d4, d5, f, f1); -+ this.internalTeleport(d3, d4, d5, f, f1, Collections.emptySet()); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet. ++ this.internalTeleport(d3, d4, d5, f, f1); // 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.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5, packetplayinflying.isOnGround()); } else { + // CraftBukkit start - fire PlayerMoveEvent @@ -526,7 +485,7 @@ this.player.absMoveTo(d0, d1, d2, f, f1); boolean flag4 = this.player.isAutoSpinAttack(); -@@ -1030,6 +1331,7 @@ +@@ -1049,6 +1345,7 @@ this.awaitingTeleportTime = this.tickCount; this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); } @@ -534,38 +493,33 @@ return true; } else { -@@ -1057,11 +1359,68 @@ - return true; +@@ -1077,10 +1374,62 @@ } -+ // CraftBukkit start - Delegate to teleport(Location) public void teleport(double d0, double d1, double d2, float f, float f1) { -- this.teleport(d0, d1, d2, f, f1, Collections.emptySet()); +- this.teleport(new PositionMoveRotation(new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1), Collections.emptySet()); ++ // CraftBukkit start - Delegate to teleport(Location) + this.teleport(d0, d1, d2, f, f1, PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + + public boolean teleport(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { -+ return this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), cause); ++ return this.teleport(new PositionMoveRotation(new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1), Collections.emptySet(), cause); ++ // CraftBukkit end } - public void teleport(double d0, double d1, double d2, float f, float f1, Set set) { -+ this.teleport(d0, d1, d2, f, f1, set, PlayerTeleportEvent.TeleportCause.UNKNOWN); + public void teleport(PositionMoveRotation positionmoverotation, Set set) { ++ // CraftBukkit start ++ this.teleport(positionmoverotation, set, PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + -+ public boolean teleport(double d0, double d1, double d2, float f, float f1, Set set, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status ++ public boolean teleport(PositionMoveRotation positionmoverotation, Set set, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status + Player player = this.getCraftPlayer(); + Location from = player.getLocation(); -+ -+ double x = d0; -+ double y = d1; -+ double z = d2; -+ float yaw = f; -+ float pitch = f1; -+ -+ Location to = new Location(this.getCraftPlayer().getWorld(), x, y, z, yaw, pitch); ++ PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this.player), positionmoverotation, set); ++ Location to = CraftLocation.toBukkit(absolutePosition.position(), this.getCraftPlayer().getWorld(), absolutePosition.yRot(), absolutePosition.xRot()); + // SPIGOT-5171: Triggered on join + if (from.equals(to)) { -+ this.internalTeleport(d0, d1, d2, f, f1, set); ++ this.internalTeleport(positionmoverotation, set); + return true; // CraftBukkit - Return event status + } + @@ -575,51 +529,48 @@ + if (event.isCancelled() || !to.equals(event.getTo())) { + set = Collections.emptySet(); // Can't relative teleport + to = event.isCancelled() ? event.getFrom() : event.getTo(); -+ d0 = to.getX(); -+ d1 = to.getY(); -+ d2 = to.getZ(); -+ f = to.getYaw(); -+ f1 = to.getPitch(); ++ positionmoverotation = new PositionMoveRotation(CraftLocation.toVec3D(to), Vec3D.ZERO, to.getYaw(), to.getPitch()); + } + -+ this.internalTeleport(d0, d1, d2, f, f1, set); ++ this.internalTeleport(positionmoverotation, set); + return !event.isCancelled(); // CraftBukkit - Return event status + } + + public void teleport(Location dest) { -+ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet()); ++ this.internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch()); + } + -+ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set) { -+ // CraftBukkit start -+ if (Float.isNaN(f)) { -+ f = 0; ++ private void internalTeleport(double d0, double d1, double d2, float f, float f1) { ++ this.internalTeleport(new PositionMoveRotation(new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1), Collections.emptySet()); ++ } ++ ++ public void internalTeleport(PositionMoveRotation positionmoverotation, Set set) { ++ if (Float.isNaN(positionmoverotation.yRot())) { ++ positionmoverotation = new PositionMoveRotation(positionmoverotation.position(), positionmoverotation.deltaMovement(), 0, positionmoverotation.xRot()); + } -+ if (Float.isNaN(f1)) { -+ f1 = 0; ++ if (Float.isNaN(positionmoverotation.xRot())) { ++ positionmoverotation = new PositionMoveRotation(positionmoverotation.position(), positionmoverotation.deltaMovement(), positionmoverotation.yRot(), 0); + } + + this.justTeleported = true; + // CraftBukkit end - double d3 = set.contains(RelativeMovement.X) ? this.player.getX() : 0.0D; - double d4 = set.contains(RelativeMovement.Y) ? this.player.getY() : 0.0D; - double d5 = set.contains(RelativeMovement.Z) ? this.player.getZ() : 0.0D; -@@ -1073,6 +1432,14 @@ + this.awaitingTeleportTime = this.tickCount; + if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; - } +@@ -1088,12 +1437,20 @@ + this.player.teleportSetPosition(positionmoverotation, set); + this.awaitingPositionFromClient = this.player.position(); + // CraftBukkit start - update last location + this.lastPosX = this.awaitingPositionFromClient.x; + this.lastPosY = this.awaitingPositionFromClient.y; + this.lastPosZ = this.awaitingPositionFromClient.z; -+ this.lastYaw = f; -+ this.lastPitch = f1; ++ this.lastYaw = this.player.getYRot(); ++ this.lastPitch = this.player.getXRot(); + // CraftBukkit end -+ - 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)); -@@ -1081,6 +1448,7 @@ + this.player.connection.send(PacketPlayOutPosition.of(this.awaitingTeleport, positionmoverotation, set)); + } + @Override public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.serverLevel()); @@ -627,7 +578,7 @@ BlockPosition blockposition = packetplayinblockdig.getPos(); this.player.resetLastActionTime(); -@@ -1091,14 +1459,46 @@ +@@ -1104,14 +1461,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); @@ -676,7 +627,7 @@ this.player.drop(false); } -@@ -1136,6 +1536,7 @@ +@@ -1149,6 +1538,7 @@ @Override public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel()); @@ -684,15 +635,15 @@ this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence()); WorldServer worldserver = this.player.serverLevel(); EnumHand enumhand = packetplayinuseitem.getHand(); -@@ -1158,6 +1559,7 @@ +@@ -1171,6 +1561,7 @@ - if (blockposition.getY() < i) { + if (blockposition.getY() <= i) { if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) { + this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706 EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); if (enuminteractionresult.consumesAction()) { -@@ -1190,6 +1592,7 @@ +@@ -1207,6 +1598,7 @@ @Override public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel()); @@ -700,7 +651,7 @@ this.ackBlockChangesUpTo(packetplayinblockplace.getSequence()); WorldServer worldserver = this.player.serverLevel(); EnumHand enumhand = packetplayinblockplace.getHand(); -@@ -1204,6 +1607,47 @@ +@@ -1221,6 +1613,47 @@ this.player.absRotateTo(f, f1); } @@ -747,17 +698,17 @@ + // CraftBukkit end EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); - if (enuminteractionresult.shouldSwing()) { -@@ -1224,7 +1668,7 @@ + if (enuminteractionresult instanceof EnumInteractionResult.d) { +@@ -1245,7 +1678,7 @@ Entity entity = packetplayinspectate.getEntity(worldserver); if (entity != null) { -- this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); -+ this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit +- this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), Set.of(), entity.getYRot(), entity.getXRot(), true); ++ this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), Set.of(), entity.getYRot(), entity.getXRot(), true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit return; } } -@@ -1245,6 +1689,13 @@ +@@ -1266,6 +1699,13 @@ @Override public void onDisconnect(DisconnectionDetails disconnectiondetails) { @@ -771,7 +722,7 @@ PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), disconnectiondetails.reason().getString()); this.removePlayerFromWorld(); super.onDisconnect(disconnectiondetails); -@@ -1252,10 +1703,18 @@ +@@ -1273,10 +1713,18 @@ private void removePlayerFromWorld() { this.chatMessageChain.close(); @@ -791,7 +742,7 @@ this.player.getTextFilter().leave(); } -@@ -1270,7 +1729,16 @@ +@@ -1291,7 +1739,16 @@ @Override public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel()); @@ -808,7 +759,7 @@ if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { this.player.stopUsingItem(); } -@@ -1279,11 +1747,18 @@ +@@ -1300,11 +1757,18 @@ this.player.resetLastActionTime(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); @@ -827,7 +778,7 @@ Optional optional = this.unpackAndApplyLastSeen(packetplayinchat.lastSeenMessages()); if (!optional.isEmpty()) { -@@ -1297,7 +1772,7 @@ +@@ -1318,7 +1782,7 @@ return; } @@ -836,7 +787,7 @@ IChatBaseComponent ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent()); this.chatMessageChain.append(completablefuture, (filteredtext) -> { -@@ -1305,19 +1780,36 @@ +@@ -1326,19 +1790,36 @@ this.broadcastChatMessage(playerchatmessage1); }); @@ -875,7 +826,7 @@ ParseResults parseresults = this.parseCommand(s); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) { -@@ -1334,19 +1826,37 @@ +@@ -1355,19 +1836,37 @@ if (!optional.isEmpty()) { this.tryHandleChat(serverboundchatcommandsignedpacket.command(), () -> { @@ -916,7 +867,7 @@ } catch (SignedMessageChain.a signedmessagechain_a) { this.handleMessageDecodeFailure(signedmessagechain_a); return; -@@ -1354,10 +1864,10 @@ +@@ -1375,10 +1874,10 @@ CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map); @@ -929,7 +880,7 @@ } private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) { -@@ -1433,14 +1943,20 @@ +@@ -1454,14 +1953,20 @@ return com_mojang_brigadier_commanddispatcher.parse(s, this.player.createCommandSourceStack()); } @@ -953,7 +904,7 @@ } } -@@ -1469,6 +1985,116 @@ +@@ -1490,6 +1995,116 @@ return false; } @@ -1070,7 +1021,7 @@ private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a { SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages); -@@ -1476,13 +2102,33 @@ +@@ -1497,13 +2112,33 @@ } private void broadcastChatMessage(PlayerChatMessage playerchatmessage) { @@ -1098,16 +1049,16 @@ } private void detectRateSpam() { -- this.chatSpamTickCount += 20; -- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { +- this.chatSpamThrottler.increment(); +- if (!this.chatSpamThrottler.isUnderThreshold() && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { + // CraftBukkit start - replaced with thread safe throttle -+ // this.chatSpamTickCount += 20; -+ if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { ++ // this.chatSpamThrottler.increment(); ++ if (!this.chatSpamThrottler.isIncrementAndUnderThreshold() && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { + // CraftBukkit end this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("disconnect.spam")); } -@@ -1504,13 +2150,62 @@ +@@ -1525,13 +2160,62 @@ @Override public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel()); @@ -1170,7 +1121,7 @@ this.player.resetLastActionTime(); Entity entity; -@@ -1587,6 +2282,12 @@ +@@ -1608,6 +2292,12 @@ } public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) { @@ -1183,7 +1134,7 @@ this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a)); this.addPendingMessage(playerchatmessage); } -@@ -1614,6 +2315,7 @@ +@@ -1635,6 +2325,7 @@ @Override public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel()); @@ -1191,9 +1142,9 @@ final WorldServer worldserver = this.player.serverLevel(); final Entity entity = packetplayinuseentity.getTarget(worldserver); -@@ -1628,13 +2330,51 @@ +@@ -1649,13 +2340,51 @@ - if (this.player.canInteractWithEntity(axisalignedbb, 1.0D)) { + if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) { packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { - private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) { + private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit @@ -1241,10 +1192,10 @@ + } + // CraftBukkit end + - if (enuminteractionresult.consumesAction()) { - CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, enuminteractionresult.indicateItemUse() ? itemstack1 : ItemStack.EMPTY, entity); - if (enuminteractionresult.shouldSwing()) { -@@ -1647,19 +2387,20 @@ + if (enuminteractionresult instanceof EnumInteractionResult.d) { + EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult; + ItemStack itemstack2 = enuminteractionresult_d.wasItemInteraction() ? itemstack1 : ItemStack.EMPTY; +@@ -1671,19 +2400,20 @@ @Override public void onInteraction(EnumHand enumhand) { @@ -1268,7 +1219,7 @@ label23: { if (entity instanceof EntityArrow) { -@@ -1677,6 +2418,11 @@ +@@ -1701,6 +2431,11 @@ } PlayerConnection.this.player.attack(entity); @@ -1280,28 +1231,30 @@ return; } } -@@ -1700,17 +2446,17 @@ +@@ -1724,7 +2459,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; - this.player = this.server.getPlayerList().respawn(this.player, true, Entity.RemovalReason.CHANGED_DIMENSION); + this.player = this.server.getPlayerList().respawn(this.player, true, Entity.RemovalReason.CHANGED_DIMENSION, RespawnReason.END_PORTAL); // CraftBukkit + this.resetPosition(); CriterionTriggers.CHANGED_DIMENSION.trigger(this.player, World.END, World.OVERWORLD); } else { - if (this.player.getHealth() > 0.0F) { +@@ -1732,11 +2467,11 @@ return; } - this.player = this.server.getPlayerList().respawn(this.player, false, Entity.RemovalReason.KILLED); + this.player = this.server.getPlayerList().respawn(this.player, false, Entity.RemovalReason.KILLED, RespawnReason.DEATH); // CraftBukkit + this.resetPosition(); if (this.server.isHardcore()) { this.player.setGameMode(EnumGamemode.SPECTATOR); -- ((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server); -+ ((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.player.serverLevel()); // CraftBukkit - per-world +- ((GameRules.GameRuleBoolean) this.player.serverLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server); ++ ((GameRules.GameRuleBoolean) this.player.serverLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.player.serverLevel()); // CraftBukkit - per-world } } break; -@@ -1723,15 +2469,21 @@ +@@ -1749,15 +2484,21 @@ @Override public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel()); @@ -1325,7 +1278,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); -@@ -1744,7 +2496,284 @@ +@@ -1770,7 +2511,284 @@ boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); @@ -1611,28 +1564,30 @@ ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); while (objectiterator.hasNext()) { -@@ -1774,9 +2803,18 @@ - if (!this.player.containerMenu.stillValid(this.player)) { - PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); - } else { -- this.server.getRecipeManager().byKey(packetplayinautorecipe.getRecipe()).ifPresent((recipeholder) -> { -- ((ContainerRecipeBook) this.player.containerMenu).handlePlacement(packetplayinautorecipe.isShiftDown(), recipeholder, this.player); -+ // CraftBukkit start - implement PlayerRecipeBookClickEvent -+ org.bukkit.inventory.Recipe recipe = this.cserver.getRecipe(CraftNamespacedKey.fromMinecraft(packetplayinautorecipe.getRecipe())); -+ if (recipe == null) { -+ return; -+ } -+ org.bukkit.event.player.PlayerRecipeBookClickEvent event = CraftEventFactory.callRecipeBookClickEvent(this.player, recipe, packetplayinautorecipe.isShiftDown()); +@@ -1816,7 +2834,21 @@ + return; + } + +- ContainerRecipeBook.a containerrecipebook_a = containerrecipebook.handlePlacement(packetplayinautorecipe.useMaxItems(), this.player.isCreative(), recipeholder, this.player.serverLevel(), this.player.getInventory()); ++ // CraftBukkit start - implement PlayerRecipeBookClickEvent ++ org.bukkit.inventory.Recipe recipe = recipeholder.toBukkitRecipe(); ++ if (recipe == null) { ++ return; ++ } ++ org.bukkit.event.player.PlayerRecipeBookClickEvent event = CraftEventFactory.callRecipeBookClickEvent(this.player, recipe, packetplayinautorecipe.useMaxItems()); + -+ // Cast to keyed should be safe as the recipe will never be a MerchantRecipe. -+ this.server.getRecipeManager().byKey(CraftNamespacedKey.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey())).ifPresent((recipeholder) -> { -+ ((ContainerRecipeBook) this.player.containerMenu).handlePlacement(event.isShiftClick(), recipeholder, this.player); - }); -+ // CraftBukkit end - } - } - } -@@ -1784,6 +2822,7 @@ ++ // Cast to keyed should be safe as the recipe will never be a MerchantRecipe. ++ recipeholder = this.server.getRecipeManager().byKey(CraftRecipe.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey())).orElse(null); ++ if (recipeholder == null) { ++ return; ++ } ++ ++ ContainerRecipeBook.a containerrecipebook_a = containerrecipebook.handlePlacement(event.isShiftClick(), this.player.isCreative(), recipeholder, this.player.serverLevel(), this.player.getInventory()); ++ // CraftBukkit end + + if (containerrecipebook_a == ContainerRecipeBook.a.PLACE_GHOST_RECIPE) { + this.player.connection.send(new PacketPlayOutAutoRecipe(this.player.containerMenu.containerId, craftingmanager_d.display().display())); +@@ -1832,6 +2864,7 @@ @Override public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel()); @@ -1640,7 +1595,7 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packetplayinenchantitem.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1826,6 +2865,43 @@ +@@ -1875,6 +2908,43 @@ boolean flag1 = packetplayinsetcreativeslot.slotNum() >= 1 && packetplayinsetcreativeslot.slotNum() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize(); @@ -1684,7 +1639,7 @@ if (flag1 && flag2) { this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).setByPlayer(itemstack); -@@ -1848,6 +2924,7 @@ +@@ -1902,6 +2972,7 @@ } private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List list) { @@ -1692,7 +1647,7 @@ this.player.resetLastActionTime(); WorldServer worldserver = this.player.serverLevel(); BlockPosition blockposition = packetplayinupdatesign.getPos(); -@@ -1869,7 +2946,17 @@ +@@ -1923,7 +2994,17 @@ @Override public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel()); @@ -1711,7 +1666,7 @@ } @Override -@@ -1928,7 +3015,7 @@ +@@ -1982,7 +3063,7 @@ if (!this.waitingForSwitchToConfig) { throw new IllegalStateException("Client acknowledged config, but none was requested"); } else { @@ -1720,7 +1675,7 @@ } } -@@ -1953,8 +3040,10 @@ +@@ -2007,8 +3088,10 @@ }); } @@ -1732,4 +1687,4 @@ + // CraftBukkit end @Override - public EntityPlayer getPlayer() { + public void handleClientTickEnd(ServerboundClientTickEndPacket serverboundclienttickendpacket) { diff --git a/nms-patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.patch b/nms-patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.patch index a158caaa..53e150b2 100644 --- a/nms-patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.patch +++ b/nms-patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -28,8 +28,44 @@ +@@ -29,8 +29,44 @@ import net.minecraft.util.thread.IAsyncTaskHandler; import org.slf4j.Logger; @@ -46,7 +46,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final int LATENCY_CHECK_INTERVAL = 15000; private static final int CLOSED_LISTENER_TIMEOUT = 15000; -@@ -46,12 +82,24 @@ +@@ -47,12 +83,24 @@ private int latency; private volatile boolean suspendFlushingOnServerThread = false; @@ -72,7 +72,7 @@ } private void close() { -@@ -73,6 +121,7 @@ +@@ -80,6 +128,7 @@ @Override public void handleKeepAlive(ServerboundKeepAlivePacket serverboundkeepalivepacket) { @@ -80,7 +80,7 @@ if (this.keepAlivePending && serverboundkeepalivepacket.getId() == this.keepAliveChallenge) { int i = (int) (SystemUtils.getMillis() - this.keepAliveTime); -@@ -87,8 +136,56 @@ +@@ -94,8 +143,56 @@ @Override public void handlePong(ServerboundPongPacket serverboundpongpacket) {} @@ -138,7 +138,7 @@ @Override public void handleResourcePackResponse(ServerboundResourcePackPacket serverboundresourcepackpacket) { -@@ -97,11 +194,18 @@ +@@ -104,11 +201,18 @@ ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack {} rejection", this.playerProfile().getName(), serverboundresourcepackpacket.id()); this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect")); } @@ -157,8 +157,8 @@ this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); } -@@ -109,7 +213,7 @@ - this.server.getProfiler().push("keepAlive"); +@@ -116,7 +220,7 @@ + Profiler.get().push("keepAlive"); long i = SystemUtils.getMillis(); - if (!this.isSingleplayerOwner() && i - this.keepAliveTime >= 15000L) { @@ -166,7 +166,7 @@ if (this.keepAlivePending) { this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE); } else if (this.checkIfClosed(i)) { -@@ -149,6 +253,14 @@ +@@ -156,6 +260,14 @@ } public void send(Packet packet, @Nullable PacketSendListener packetsendlistener) { @@ -181,7 +181,7 @@ if (packet.isTerminal()) { this.close(); } -@@ -173,15 +285,61 @@ +@@ -180,15 +292,61 @@ } public void disconnect(DisconnectionDetails disconnectiondetails) { diff --git a/nms-patches/net/minecraft/server/players/PlayerList.patch b/nms-patches/net/minecraft/server/players/PlayerList.patch index da2910eb..f4b02439 100644 --- a/nms-patches/net/minecraft/server/players/PlayerList.patch +++ b/nms-patches/net/minecraft/server/players/PlayerList.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -103,6 +103,27 @@ +@@ -104,6 +104,27 @@ import net.minecraft.world.scores.ScoreboardTeam; import org.slf4j.Logger; @@ -28,7 +28,7 @@ public abstract class PlayerList { public static final File USERBANLIST_FILE = new File("banned-players.json"); -@@ -115,14 +136,16 @@ +@@ -116,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; @@ -48,7 +48,7 @@ public final WorldNBTStorage playerIo; private boolean doWhiteList; private final LayeredRegistryAccess registries; -@@ -133,13 +156,23 @@ +@@ -134,13 +157,23 @@ private static final boolean ALLOW_LOGOUTIVATOR = false; private int sendAllPlayerInfoIn; @@ -74,7 +74,7 @@ this.server = minecraftserver; this.registries = layeredregistryaccess; this.maxPlayers = i; -@@ -149,25 +182,34 @@ +@@ -150,25 +183,34 @@ public void placeNewPlayer(NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) { GameProfile gameprofile = entityplayer.getGameProfile(); UserCache usercache = this.server.getProfileCache(); @@ -114,7 +114,7 @@ WorldServer worldserver = this.server.getLevel(resourcekey); WorldServer worldserver1; -@@ -181,10 +223,11 @@ +@@ -182,10 +224,11 @@ entityplayer.setServerLevel(worldserver1); String s1 = networkmanager.getLoggableAddress(this.server.logIPs()); @@ -128,7 +128,7 @@ PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer, commonlistenercookie); networkmanager.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection); -@@ -194,6 +237,7 @@ +@@ -195,6 +238,7 @@ boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING); playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, flag2, entityplayer.createCommonSpawnInfo(worldserver1), this.server.enforceSecureProfile())); @@ -136,7 +136,7 @@ playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities())); playerconnection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected)); -@@ -210,8 +254,10 @@ +@@ -213,8 +257,10 @@ } else { ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s); } @@ -148,7 +148,7 @@ playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot()); ServerPing serverping = this.server.getStatus(); -@@ -219,18 +265,70 @@ +@@ -222,17 +268,70 @@ entityplayer.sendServerStatus(serverping); } @@ -215,39 +215,15 @@ + worldserver1 = entityplayer.serverLevel(); // CraftBukkit - Update in case join event changed it + // CraftBukkit end this.sendActivePlayerEffects(entityplayer); - if (optional.isPresent() && ((NBTTagCompound) optional.get()).contains("RootVehicle", 10)) { - NBTTagCompound nbttagcompound = ((NBTTagCompound) optional.get()).getCompound("RootVehicle"); -+ WorldServer finalWorldServer = worldserver1; // CraftBukkit - decompile error - Entity entity = EntityTypes.loadEntityRecursive(nbttagcompound.getCompound("Entity"), worldserver1, (entity1) -> { -- return !worldserver1.addWithUUID(entity1) ? null : entity1; -+ return !finalWorldServer.addWithUUID(entity1) ? null : entity1; // CraftBukkit - decompile error - }); - - if (entity != null) { -@@ -261,18 +359,20 @@ - - if (!entityplayer.isPassenger()) { - PlayerList.LOGGER.warn("Couldn't reattach entity to player"); -- entity.discard(); -+ entity.discard(null); // CraftBukkit - add Bukkit remove cause - iterator = entity.getIndirectPassengers().iterator(); - - while (iterator.hasNext()) { - entity1 = (Entity) iterator.next(); -- entity1.discard(); -+ entity1.discard(null); // CraftBukkit - add Bukkit remove cause - } - } - } - } - + entityplayer.loadAndSpawnEnderpearls(optional); + entityplayer.loadAndSpawnParentVehicle(optional); entityplayer.initInventoryMenu(); + // CraftBukkit - Moved from above, added world + PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getName().getString(), s1, entityplayer.getId(), worldserver1.serverLevelData.getLevelName(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()); } public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -309,30 +409,31 @@ +@@ -269,30 +368,31 @@ } public void addWorldborderListener(WorldServer worldserver) { @@ -284,7 +260,7 @@ } @Override -@@ -359,14 +460,15 @@ +@@ -319,14 +419,15 @@ } protected void save(EntityPlayer entityplayer) { @@ -302,7 +278,7 @@ if (advancementdataplayer != null) { advancementdataplayer.save(); -@@ -374,10 +476,24 @@ +@@ -334,10 +435,24 @@ } @@ -328,7 +304,7 @@ this.save(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getRootVehicle(); -@@ -386,7 +502,7 @@ +@@ -346,7 +461,7 @@ PlayerList.LOGGER.debug("Removing player mount"); entityplayer.stopRiding(); entity.getPassengersAndSelf().forEach((entity1) -> { @@ -337,7 +313,16 @@ }); } } -@@ -401,17 +517,66 @@ +@@ -357,7 +472,7 @@ + while (iterator.hasNext()) { + EntityEnderPearl entityenderpearl = (EntityEnderPearl) iterator.next(); + +- entityenderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER); ++ entityenderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, EntityRemoveEvent.Cause.PLAYER_QUIT); // CraftBukkit - add Bukkit remove cause + } + + worldserver.removePlayerImmediately(entityplayer, Entity.RemovalReason.UNLOADED_WITH_PLAYER); +@@ -369,17 +484,66 @@ if (entityplayer1 == entityplayer) { this.playersByUUID.remove(uuid); @@ -409,7 +394,7 @@ if (this.bans.isBanned(gameprofile)) { GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile); -@@ -420,9 +585,11 @@ +@@ -388,9 +552,11 @@ ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires()))); } @@ -423,7 +408,7 @@ } else if (this.ipBans.isBanned(socketaddress)) { IpBanEntry ipbanentry = this.ipBans.get(socketaddress); -@@ -431,17 +598,32 @@ +@@ -399,17 +565,32 @@ ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires()))); } @@ -436,13 +421,13 @@ + if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) { + event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full"); + } -+ } + } + + cserver.getPluginManager().callEvent(event); + if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { + loginlistener.disconnect(event.getKickMessage()); + return null; - } ++ } + return entity; } @@ -461,7 +446,7 @@ UUID uuid = gameprofile.getId(); Set set = Sets.newIdentityHashSet(); Iterator iterator = this.players.iterator(); -@@ -469,22 +651,41 @@ +@@ -437,22 +618,41 @@ } return !set.isEmpty(); @@ -481,8 +466,8 @@ this.players.remove(entityplayer); entityplayer.serverLevel().removePlayerImmediately(entityplayer, entity_removalreason); + /* CraftBukkit start - DimensionTransition dimensiontransition = entityplayer.findRespawnPositionAndUseSpawnBlock(flag, DimensionTransition.DO_NOTHING); - WorldServer worldserver = dimensiontransition.newLevel(); + TeleportTransition teleporttransition = entityplayer.findRespawnPositionAndUseSpawnBlock(!flag, TeleportTransition.DO_NOTHING); + WorldServer worldserver = teleporttransition.newLevel(); EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver, entityplayer.getGameProfile(), entityplayer.clientInformation()); + // */ + EntityPlayer entityplayer1 = entityplayer; @@ -496,7 +481,7 @@ entityplayer1.setMainArm(entityplayer.getMainArm()); + // CraftBukkit - not required, just copies old location into reused entity + /* - if (!dimensiontransition.missingRespawnBlock()) { + if (!teleporttransition.missingRespawnBlock()) { entityplayer1.copyRespawnPosition(entityplayer); } + */ @@ -504,35 +489,35 @@ Iterator iterator = entityplayer.getTags().iterator(); -@@ -494,11 +695,26 @@ +@@ -462,11 +662,26 @@ entityplayer1.addTag(s); } + // CraftBukkit start - fire PlayerRespawnEvent -+ DimensionTransition dimensiontransition; ++ TeleportTransition teleporttransition; + if (location == null) { -+ dimensiontransition = entityplayer.findRespawnPositionAndUseSpawnBlock(flag, DimensionTransition.DO_NOTHING, reason); ++ teleporttransition = entityplayer.findRespawnPositionAndUseSpawnBlock(!flag, TeleportTransition.DO_NOTHING, reason); + + if (!flag) entityplayer.reset(); // SPIGOT-4785 + } else { -+ dimensiontransition = new DimensionTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3D.ZERO, location.getYaw(), location.getPitch(), DimensionTransition.DO_NOTHING); ++ teleporttransition = new TeleportTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3D.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING); + } -+ WorldServer worldserver = dimensiontransition.newLevel(); ++ WorldServer worldserver = teleporttransition.newLevel(); + entityplayer1.spawnIn(worldserver); + entityplayer1.unsetRemoved(); + entityplayer1.setShiftKeyDown(false); - Vec3D vec3d = dimensiontransition.pos(); + Vec3D vec3d = teleporttransition.position(); -- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, dimensiontransition.yRot(), dimensiontransition.xRot()); -+ entityplayer1.forceSetPositionRotation(vec3d.x, vec3d.y, vec3d.z, dimensiontransition.yRot(), dimensiontransition.xRot()); +- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, teleporttransition.yRot(), teleporttransition.xRot()); ++ entityplayer1.forceSetPositionRotation(vec3d.x, vec3d.y, vec3d.z, teleporttransition.yRot(), teleporttransition.xRot()); + // CraftBukkit end - if (dimensiontransition.missingRespawnBlock()) { + if (teleporttransition.missingRespawnBlock()) { entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); + entityplayer1.setRespawnPosition(null, null, 0f, false, false, PlayerSpawnChangeEvent.Cause.RESET); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed } int i = flag ? 1 : 0; -@@ -506,17 +722,19 @@ +@@ -474,17 +689,19 @@ WorldData worlddata = worldserver1.getLevelData(); entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver1), (byte) i)); @@ -555,9 +540,9 @@ + } + // entityplayer1.initInventoryMenu(); entityplayer1.setHealth(entityplayer1.getHealth()); - if (!flag) { - BlockPosition blockposition = BlockPosition.containing(dimensiontransition.pos()); -@@ -526,6 +744,27 @@ + BlockPosition blockposition = entityplayer1.getRespawnPosition(); + WorldServer worldserver2 = this.server.getLevel(entityplayer1.getRespawnDimension()); +@@ -496,6 +713,27 @@ entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver.getRandom().nextLong())); } } @@ -585,7 +570,7 @@ return entityplayer1; } -@@ -554,7 +793,18 @@ +@@ -524,7 +762,18 @@ public void tick() { if (++this.sendAllPlayerInfoIn > 600) { @@ -605,7 +590,7 @@ this.sendAllPlayerInfoIn = 0; } -@@ -571,6 +821,25 @@ +@@ -541,6 +790,25 @@ } @@ -631,7 +616,7 @@ public void broadcastAll(Packet packet, ResourceKey resourcekey) { Iterator iterator = this.players.iterator(); -@@ -649,7 +918,7 @@ +@@ -619,7 +887,7 @@ } public void deop(GameProfile gameprofile) { @@ -640,7 +625,7 @@ EntityPlayer entityplayer = this.getPlayer(gameprofile.getId()); if (entityplayer != null) { -@@ -673,6 +942,7 @@ +@@ -643,6 +911,7 @@ entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0)); } @@ -648,7 +633,7 @@ this.server.getCommands().sendCommands(entityplayer); } -@@ -703,6 +973,12 @@ +@@ -673,6 +942,12 @@ for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); @@ -661,7 +646,7 @@ if (entityplayer != entityhuman && entityplayer.level().dimension() == resourcekey) { double d4 = d0 - entityplayer.getX(); double d5 = d1 - entityplayer.getY(); -@@ -742,15 +1018,19 @@ +@@ -712,15 +987,19 @@ public void reloadWhiteList() {} public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) { @@ -685,7 +670,7 @@ } entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -759,8 +1039,16 @@ +@@ -729,8 +1008,16 @@ public void sendAllPlayerInfo(EntityPlayer entityplayer) { entityplayer.inventoryMenu.sendAllDataToRemote(); @@ -695,15 +680,15 @@ + entityplayer.refreshEntityData(entityplayer); // CraftBukkkit - SPIGOT-7218: sync metadata entityplayer.connection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected)); + // CraftBukkit start - from GameRules -+ int i = entityplayer.level().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; ++ int i = entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; + entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, (byte) i)); -+ float immediateRespawn = entityplayer.level().getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; ++ float immediateRespawn = entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; + entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.IMMEDIATE_RESPAWN, immediateRespawn)); + // CraftBukkit end } public int getPlayerCount() { -@@ -816,12 +1104,22 @@ +@@ -786,12 +1073,22 @@ } public void removeAll() { @@ -728,7 +713,7 @@ public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> { return ichatbasecomponent; -@@ -879,16 +1177,23 @@ +@@ -849,16 +1146,23 @@ return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now()); } @@ -756,7 +741,7 @@ Path path = file2.toPath(); if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { -@@ -897,7 +1202,7 @@ +@@ -867,7 +1171,7 @@ } serverstatisticmanager = new ServerStatisticManager(this.server, file1); @@ -765,7 +750,7 @@ } return serverstatisticmanager; -@@ -905,13 +1210,13 @@ +@@ -875,13 +1179,13 @@ public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) { UUID uuid = entityplayer.getUUID(); @@ -781,7 +766,7 @@ } advancementdataplayer.setPlayer(entityplayer); -@@ -962,13 +1267,20 @@ +@@ -932,13 +1236,20 @@ } public void reloadResources() { @@ -802,4 +787,4 @@ + // CraftBukkit end this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries))); - PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getRecipeManager().getOrderedRecipes()); + CraftingManager craftingmanager = this.server.getRecipeManager(); diff --git a/nms-patches/net/minecraft/stats/RecipeBookServer.patch b/nms-patches/net/minecraft/stats/RecipeBookServer.patch new file mode 100644 index 00000000..38c18d21 --- /dev/null +++ b/nms-patches/net/minecraft/stats/RecipeBookServer.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/stats/RecipeBookServer.java ++++ b/net/minecraft/stats/RecipeBookServer.java +@@ -29,6 +29,8 @@ + import net.minecraft.world.item.crafting.display.RecipeDisplayId; + import org.slf4j.Logger; + ++import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit ++ + public class RecipeBookServer extends RecipeBook { + + public static final String RECIPE_BOOK_TAG = "recipeBook"; +@@ -72,7 +74,7 @@ + RecipeHolder recipeholder = (RecipeHolder) iterator.next(); + ResourceKey> resourcekey = recipeholder.id(); + +- if (!this.known.contains(resourcekey) && !recipeholder.value().isSpecial()) { ++ if (!this.known.contains(resourcekey) && !recipeholder.value().isSpecial() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, resourcekey.location())) { // CraftBukkit + this.add(resourcekey); + this.addHighlight(resourcekey); + this.displayResolver.displaysForRecipe(resourcekey, (recipedisplayentry) -> { +@@ -82,7 +84,7 @@ + } + } + +- if (!list.isEmpty()) { ++ if (!list.isEmpty() && entityplayer.connection != null) { // SPIGOT-4478 during PlayerLoginEvent + entityplayer.connection.send(new ClientboundRecipeBookAddPacket(list, false)); + } + +@@ -105,7 +107,7 @@ + } + } + +- if (!list.isEmpty()) { ++ if (!list.isEmpty() && entityplayer.connection != null) { // SPIGOT-4478 during PlayerLoginEvent + entityplayer.connection.send(new ClientboundRecipeBookRemovePacket(list)); + } + diff --git a/nms-patches/net/minecraft/stats/ServerStatisticManager.patch b/nms-patches/net/minecraft/stats/ServerStatisticManager.patch new file mode 100644 index 00000000..ac3c4fff --- /dev/null +++ b/nms-patches/net/minecraft/stats/ServerStatisticManager.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/stats/ServerStatisticManager.java ++++ b/net/minecraft/stats/ServerStatisticManager.java +@@ -1,3 +1,4 @@ ++// mc-dev import + package net.minecraft.stats; + + import com.google.common.collect.Maps; +@@ -158,13 +159,12 @@ + } + + private Optional> getStat(StatisticWrapper statisticwrapper, String s) { +- Optional optional = Optional.ofNullable(MinecraftKey.tryParse(s)); +- IRegistry iregistry = statisticwrapper.getRegistry(); ++ // CraftBukkit - decompile error start ++ Optional optional = Optional.ofNullable(MinecraftKey.tryParse(s)); ++ IRegistry iregistry = statisticwrapper.getRegistry(); + +- Objects.requireNonNull(iregistry); +- optional = optional.flatMap(iregistry::getOptional); +- Objects.requireNonNull(statisticwrapper); +- return optional.map(statisticwrapper::get); ++ return optional.flatMap(iregistry::getOptional).map(statisticwrapper::get); ++ // CraftBukkit - decompile error end + } + + private static NBTTagCompound fromJson(JsonObject jsonobject) { diff --git a/nms-patches/net/minecraft/stats/StatisticManager.patch b/nms-patches/net/minecraft/stats/StatisticManager.patch new file mode 100644 index 00000000..118075d5 --- /dev/null +++ b/nms-patches/net/minecraft/stats/StatisticManager.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/stats/StatisticManager.java ++++ b/net/minecraft/stats/StatisticManager.java +@@ -16,6 +16,12 @@ + public void increment(EntityHuman entityhuman, Statistic statistic, int i) { + int j = (int) Math.min((long) this.getValue(statistic) + (long) i, 2147483647L); + ++ // CraftBukkit start - fire Statistic events ++ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getValue(statistic), j); ++ if (cancellable != null && cancellable.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + this.setValue(entityhuman, statistic, j); + } + diff --git a/nms-patches/net/minecraft/util/SpawnUtil.patch b/nms-patches/net/minecraft/util/SpawnUtil.patch new file mode 100644 index 00000000..47da6b11 --- /dev/null +++ b/nms-patches/net/minecraft/util/SpawnUtil.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/util/SpawnUtil.java ++++ b/net/minecraft/util/SpawnUtil.java +@@ -21,6 +21,12 @@ + public SpawnUtil() {} + + public static Optional trySpawnMob(EntityTypes entitytypes, EntitySpawnReason entityspawnreason, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a) { ++ // CraftBukkit start ++ return trySpawnMob(entitytypes, entityspawnreason, worldserver, blockposition, i, j, k, spawnutil_a, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ } ++ ++ public static Optional trySpawnMob(EntityTypes entitytypes, EntitySpawnReason entityspawnreason, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ // CraftBukkit end + BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); + + for (int l = 0; l < i; ++l) { +@@ -29,15 +35,15 @@ + + 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, (Consumer) null, blockposition_mutableblockposition, entityspawnreason, false, false); ++ T t0 = entitytypes.create(worldserver, (Consumer) null, blockposition_mutableblockposition, entityspawnreason, false, false); // CraftBukkit - decompile error + + if (t0 != null) { + if (t0.checkSpawnRules(worldserver, entityspawnreason) && t0.checkSpawnObstruction(worldserver)) { +- worldserver.addFreshEntityWithPassengers(t0); ++ worldserver.addFreshEntityWithPassengers(t0, reason); // CraftBukkit + return Optional.of(t0); + } + +- t0.discard(); ++ t0.discard(null); // CraftBukkit - add Bukkit remove cause + } + } + } diff --git a/nms-patches/net/minecraft/util/TickThrottler.patch b/nms-patches/net/minecraft/util/TickThrottler.patch new file mode 100644 index 00000000..38e6ddbc --- /dev/null +++ b/nms-patches/net/minecraft/util/TickThrottler.patch @@ -0,0 +1,53 @@ +--- a/net/minecraft/util/TickThrottler.java ++++ b/net/minecraft/util/TickThrottler.java +@@ -1,10 +1,14 @@ + package net.minecraft.util; + ++// CraftBukkit start ++import java.util.concurrent.atomic.AtomicInteger; ++// CraftBukkit end ++ + public class TickThrottler { + + private final int incrementStep; + private final int threshold; +- private int count; ++ private final AtomicInteger count = new AtomicInteger(); // CraftBukkit - multithreaded field + + public TickThrottler(int i, int j) { + this.incrementStep = i; +@@ -12,17 +16,32 @@ + } + + public void increment() { +- this.count += this.incrementStep; ++ this.count.addAndGet(this.incrementStep); // CraftBukkit - use thread-safe field access instead + } + + public void tick() { ++ // CraftBukkit start ++ for (int val; (val = this.count.get()) > 0 && !count.compareAndSet(val, val - 1); ) ; ++ /* Use thread-safe field access instead + if (this.count > 0) { + --this.count; + } ++ */ ++ // CraftBukkit end + + } + + public boolean isUnderThreshold() { +- return this.count < this.threshold; ++ // CraftBukkit start - use thread-safe field access instead ++ return this.count.get() < this.threshold; ++ } ++ ++ public boolean isIncrementAndUnderThreshold() { ++ return isIncrementAndUnderThreshold(this.incrementStep, this.threshold); ++ } ++ ++ public boolean isIncrementAndUnderThreshold(int incrementStep, int threshold) { ++ return this.count.addAndGet(incrementStep) < threshold; ++ // CraftBukkit end + } + } diff --git a/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch b/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch new file mode 100644 index 00000000..1148881f --- /dev/null +++ b/nms-patches/net/minecraft/util/datafix/DataConverterRegistry.patch @@ -0,0 +1,82 @@ +--- a/net/minecraft/util/datafix/DataConverterRegistry.java ++++ b/net/minecraft/util/datafix/DataConverterRegistry.java +@@ -510,6 +510,18 @@ + datafixerbuilder.addFixer(new DataConverterItemFrame(schema44, false)); + Schema schema45 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED); + ++ // CraftBukkit start ++ datafixerbuilder.addFixer(new com.mojang.datafixers.DataFix(schema45, false) { ++ @Override ++ protected com.mojang.datafixers.TypeRewriteRule makeRule() { ++ return this.fixTypeEverywhereTyped("Player CustomName", this.getInputSchema().getType(DataConverterTypes.PLAYER), (typed) -> { ++ return typed.update(DSL.remainderFinder(), (dynamic) -> { ++ return DataConverterCustomNameEntity.fixTagCustomName(dynamic); ++ }); ++ }); ++ } ++ }); ++ // CraftBukkit end + datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema45, false)); + datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema45, false)); + datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema45, false)); +@@ -768,7 +780,8 @@ + datafixerbuilder.addFixer(new DataConverterAddChoices(schema110, "Added Zoglin", DataConverterTypes.ENTITY)); + Schema schema111 = datafixerbuilder.addSchema(2523, DataConverterRegistry.SAME_NAMESPACED); + +- datafixerbuilder.addFixer(new DataConverterAttributes(schema111, "Attribute renames", createRenamerNoNamespace(ImmutableMap.builder().put("generic.maxHealth", "minecraft:generic.max_health").put("Max Health", "minecraft:generic.max_health").put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements").put("Spawn Reinforcements Chance", "minecraft:zombie.spawn_reinforcements").put("horse.jumpStrength", "minecraft:horse.jump_strength").put("Jump Strength", "minecraft:horse.jump_strength").put("generic.followRange", "minecraft:generic.follow_range").put("Follow Range", "minecraft:generic.follow_range").put("generic.knockbackResistance", "minecraft:generic.knockback_resistance").put("Knockback Resistance", "minecraft:generic.knockback_resistance").put("generic.movementSpeed", "minecraft:generic.movement_speed").put("Movement Speed", "minecraft:generic.movement_speed").put("generic.flyingSpeed", "minecraft:generic.flying_speed").put("Flying Speed", "minecraft:generic.flying_speed").put("generic.attackDamage", "minecraft:generic.attack_damage").put("generic.attackKnockback", "minecraft:generic.attack_knockback").put("generic.attackSpeed", "minecraft:generic.attack_speed").put("generic.armorToughness", "minecraft:generic.armor_toughness").build()))); ++ // CraftBukkit - decompile error ++ datafixerbuilder.addFixer(new DataConverterAttributes(schema111, "Attribute renames", createRenamerNoNamespace(ImmutableMap.builder().put("generic.maxHealth", "minecraft:generic.max_health").put("Max Health", "minecraft:generic.max_health").put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements").put("Spawn Reinforcements Chance", "minecraft:zombie.spawn_reinforcements").put("horse.jumpStrength", "minecraft:horse.jump_strength").put("Jump Strength", "minecraft:horse.jump_strength").put("generic.followRange", "minecraft:generic.follow_range").put("Follow Range", "minecraft:generic.follow_range").put("generic.knockbackResistance", "minecraft:generic.knockback_resistance").put("Knockback Resistance", "minecraft:generic.knockback_resistance").put("generic.movementSpeed", "minecraft:generic.movement_speed").put("Movement Speed", "minecraft:generic.movement_speed").put("generic.flyingSpeed", "minecraft:generic.flying_speed").put("Flying Speed", "minecraft:generic.flying_speed").put("generic.attackDamage", "minecraft:generic.attack_damage").put("generic.attackKnockback", "minecraft:generic.attack_knockback").put("generic.attackSpeed", "minecraft:generic.attack_speed").put("generic.armorToughness", "minecraft:generic.armor_toughness").build()))); + Schema schema112 = datafixerbuilder.addSchema(2527, DataConverterRegistry.SAME_NAMESPACED); + + datafixerbuilder.addFixer(new DataConverterBitStorageAlign(schema112)); +@@ -831,12 +844,14 @@ + datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Squid", DataConverterTypes.ENTITY)); + datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Item Frame", DataConverterTypes.ENTITY)); + Schema schema131 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED); +- ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); ++ // CraftBukkit - decompile error ++ ImmutableMap immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); + + datafixerbuilder.addFixer(DataConverterItemName.create(schema131, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap))); + datafixerbuilder.addFixer(DataConverterBlockRename.create(schema131, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap))); + Schema schema132 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED); +- ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); ++ // CraftBukkit - decompile error ++ ImmutableMap immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); + + datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Rename copper item suffixes", createRenamer(immutablemap1))); + datafixerbuilder.addFixer(DataConverterBlockRename.create(schema132, "Rename copper blocks suffixes", createRenamer(immutablemap1))); +@@ -844,7 +859,8 @@ + + datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema133, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); + Schema schema134 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); +- ImmutableMap immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); ++ // CraftBukkit - decompile error ++ ImmutableMap immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); + + datafixerbuilder.addFixer(DataConverterItemName.create(schema134, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); + datafixerbuilder.addFixer(DataConverterBlockRename.create(schema134, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); +@@ -931,10 +947,11 @@ + datafixerbuilder.addFixer(new DataConverterAddChoices(schema159, "Added Allay", DataConverterTypes.ENTITY)); + Schema schema160 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED); + +- datafixerbuilder.addFixer(new NamespacedTypeRenameFix(schema160, "game_event_renames_3084", DataConverterTypes.GAME_EVENT_NAME, createRenamer(ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build()))); ++ // CraftBukkit - decompile error ++ datafixerbuilder.addFixer(new NamespacedTypeRenameFix(schema160, "game_event_renames_3084", DataConverterTypes.GAME_EVENT_NAME, createRenamer(ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build()))); + Schema schema161 = datafixerbuilder.addSchema(3086, DataConverterRegistry.SAME_NAMESPACED); + TypeReference typereference = DataConverterTypes.ENTITY; +- Int2ObjectOpenHashMap int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> { ++ Int2ObjectOpenHashMap int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> { // CraftBukkit - decompile error + int2objectopenhashmap1.defaultReturnValue("minecraft:tabby"); + int2objectopenhashmap1.put(0, "minecraft:tabby"); + int2objectopenhashmap1.put(1, "minecraft:black"); +@@ -951,7 +968,8 @@ + + Objects.requireNonNull(int2objectopenhashmap); + datafixerbuilder.addFixer(new EntityVariantFix(schema161, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get)); +- ImmutableMap immutablemap3 = ImmutableMap.builder().put("textures/entity/cat/tabby.png", "minecraft:tabby").put("textures/entity/cat/black.png", "minecraft:black").put("textures/entity/cat/red.png", "minecraft:red").put("textures/entity/cat/siamese.png", "minecraft:siamese").put("textures/entity/cat/british_shorthair.png", "minecraft:british").put("textures/entity/cat/calico.png", "minecraft:calico").put("textures/entity/cat/persian.png", "minecraft:persian").put("textures/entity/cat/ragdoll.png", "minecraft:ragdoll").put("textures/entity/cat/white.png", "minecraft:white").put("textures/entity/cat/jellie.png", "minecraft:jellie").put("textures/entity/cat/all_black.png", "minecraft:all_black").build(); ++ // CraftBukkit - decompile error ++ ImmutableMap immutablemap3 = ImmutableMap.builder().put("textures/entity/cat/tabby.png", "minecraft:tabby").put("textures/entity/cat/black.png", "minecraft:black").put("textures/entity/cat/red.png", "minecraft:red").put("textures/entity/cat/siamese.png", "minecraft:siamese").put("textures/entity/cat/british_shorthair.png", "minecraft:british").put("textures/entity/cat/calico.png", "minecraft:calico").put("textures/entity/cat/persian.png", "minecraft:persian").put("textures/entity/cat/ragdoll.png", "minecraft:ragdoll").put("textures/entity/cat/white.png", "minecraft:white").put("textures/entity/cat/jellie.png", "minecraft:jellie").put("textures/entity/cat/all_black.png", "minecraft:all_black").build(); + + datafixerbuilder.addFixer(new CriteriaRenameFix(schema161, "Migrate cat variant advancement", "minecraft:husbandry/complete_catalogue", (s) -> { + return (String) immutablemap3.getOrDefault(s, s); diff --git a/nms-patches/net/minecraft/util/datafix/fixes/DataConverterFlatten.patch b/nms-patches/net/minecraft/util/datafix/fixes/DataConverterFlatten.patch new file mode 100644 index 00000000..6916dff5 --- /dev/null +++ b/nms-patches/net/minecraft/util/datafix/fixes/DataConverterFlatten.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/util/datafix/fixes/DataConverterFlatten.java ++++ b/net/minecraft/util/datafix/fixes/DataConverterFlatten.java +@@ -376,7 +376,7 @@ + Typed typed2 = typed.getOrCreateTyped(opticfinder1); + Dynamic dynamic1 = (Dynamic) typed2.get(DSL.remainderFinder()); + +- dynamic1 = dynamic1.set("Damage", dynamic1.createInt(i)); ++ if (i != 0) dynamic1 = dynamic1.set("Damage", dynamic1.createInt(i)); // CraftBukkit + typed1 = typed1.set(opticfinder1, typed2.set(DSL.remainderFinder(), dynamic1)); + } + diff --git a/nms-patches/net/minecraft/util/datafix/fixes/DataConverterMap.patch b/nms-patches/net/minecraft/util/datafix/fixes/DataConverterMap.patch new file mode 100644 index 00000000..41b8ab11 --- /dev/null +++ b/nms-patches/net/minecraft/util/datafix/fixes/DataConverterMap.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/util/datafix/fixes/DataConverterMap.java ++++ b/net/minecraft/util/datafix/fixes/DataConverterMap.java +@@ -32,7 +32,7 @@ + Typed typed1 = typed.getOrCreateTyped(opticfinder1); + Dynamic dynamic1 = (Dynamic) typed1.get(DSL.remainderFinder()); + +- dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.get("Damage").asInt(0))); ++ if (!dynamic1.getElement("map").result().isPresent()) dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.get("Damage").asInt(0))); // CraftBukkit + return typed.set(opticfinder1, typed1.set(DSL.remainderFinder(), dynamic1)); + } else { + return typed; diff --git a/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch b/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch new file mode 100644 index 00000000..722e0a99 --- /dev/null +++ b/nms-patches/net/minecraft/util/worldupdate/WorldUpgrader.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/util/worldupdate/WorldUpgrader.java ++++ b/net/minecraft/util/worldupdate/WorldUpgrader.java +@@ -80,7 +80,7 @@ + + public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, IRegistryCustom iregistrycustom, boolean flag, boolean flag1) { + this.dimensions = iregistrycustom.lookupOrThrow(Registries.LEVEL_STEM); +- this.levels = (Set) this.dimensions.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); ++ this.levels = (Set) java.util.stream.Stream.of(convertable_conversionsession.dimensionType).map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); // CraftBukkit + this.eraseCache = flag; + this.dataFixer = datafixer; + this.levelStorage = convertable_conversionsession; +@@ -197,9 +197,9 @@ + if (nbttagcompound != null) { + int i = IChunkLoader.getVersion(nbttagcompound); + ChunkGenerator chunkgenerator = ((WorldDimension) WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(resourcekey))).generator(); +- NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(resourcekey, () -> { ++ NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(Registries.levelToLevelStem(resourcekey), () -> { // CraftBukkit + return WorldUpgrader.this.overworldDataStorage; +- }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer()); ++ }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit + ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos")); + + if (!chunkcoordintpair1.equals(chunkcoordintpair)) { +@@ -321,7 +321,7 @@ + WorldUpgrader.c worldupgrader_c = (WorldUpgrader.c) iterator.next(); + ResourceKey resourcekey = worldupgrader_c.dimensionKey; + ListIterator listiterator = worldupgrader_c.files; +- T t0 = (AutoCloseable) worldupgrader_c.storage; ++ T t0 = (T) worldupgrader_c.storage; // CraftBukkit - decompile error + + if (listiterator.hasNext()) { + WorldUpgrader.e worldupgrader_e = (WorldUpgrader.e) listiterator.next(); diff --git a/nms-patches/net/minecraft/world/ChestLock.patch b/nms-patches/net/minecraft/world/ChestLock.patch deleted file mode 100644 index a6fe4a98..00000000 --- a/nms-patches/net/minecraft/world/ChestLock.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/net/minecraft/world/ChestLock.java -+++ b/net/minecraft/world/ChestLock.java -@@ -6,6 +6,11 @@ - import net.minecraft.network.chat.IChatBaseComponent; - import net.minecraft.world.item.ItemStack; - -+// CraftBukkit start -+import org.bukkit.ChatColor; -+import org.bukkit.craftbukkit.util.CraftChatMessage; -+// CraftBukkit end -+ - public record ChestLock(String key) { - - public static final ChestLock NO_LOCK = new ChestLock(""); -@@ -18,7 +23,19 @@ - } else { - IChatBaseComponent ichatbasecomponent = (IChatBaseComponent) itemstack.get(DataComponents.CUSTOM_NAME); - -- return ichatbasecomponent != null && this.key.equals(ichatbasecomponent.getString()); -+ // CraftBukkit start - SPIGOT-6307: Check for color codes if the lock contains color codes -+ if (this.key.isEmpty()) return true; -+ if (ichatbasecomponent != null) { -+ if (this.key.indexOf(ChatColor.COLOR_CHAR) == -1) { -+ // The lock key contains no color codes, so let's ignore colors in the item display name (vanilla Minecraft behavior): -+ return this.key.equals(ichatbasecomponent.getString()); -+ } else { -+ // The lock key contains color codes, so let's take them into account: -+ return this.key.equals(CraftChatMessage.fromComponent(ichatbasecomponent)); -+ } -+ } -+ return false; -+ // CraftBukkit end - } - } - diff --git a/nms-patches/net/minecraft/world/damagesource/DamageSources.patch b/nms-patches/net/minecraft/world/damagesource/DamageSources.patch index 86fc05e2..2397a45a 100644 --- a/nms-patches/net/minecraft/world/damagesource/DamageSources.patch +++ b/nms-patches/net/minecraft/world/damagesource/DamageSources.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/damagesource/DamageSources.java +++ b/net/minecraft/world/damagesource/DamageSources.java -@@ -42,9 +42,15 @@ +@@ -43,9 +43,15 @@ private final DamageSource stalagmite; private final DamageSource outsideBorder; private final DamageSource genericKill; @@ -9,15 +9,15 @@ + private final DamageSource poison; public DamageSources(IRegistryCustom iregistrycustom) { - this.damageTypes = iregistrycustom.registryOrThrow(Registries.DAMAGE_TYPE); + this.damageTypes = iregistrycustom.lookupOrThrow(Registries.DAMAGE_TYPE); + this.melting = this.source(DamageTypes.ON_FIRE).melting(); + this.poison = this.source(DamageTypes.MAGIC).poison(); + // CraftBukkit end this.inFire = this.source(DamageTypes.IN_FIRE); this.campfire = this.source(DamageTypes.CAMPFIRE); this.lightningBolt = this.source(DamageTypes.LIGHTNING_BOLT); -@@ -83,6 +89,16 @@ - return new DamageSource(this.damageTypes.getHolderOrThrow(resourcekey), entity, entity1); +@@ -85,6 +91,16 @@ + return new DamageSource(this.damageTypes.getOrThrow(resourcekey), entity, entity1); } + // CraftBukkit start @@ -33,7 +33,7 @@ public DamageSource inFire() { return this.inFire; } -@@ -248,7 +264,13 @@ +@@ -254,7 +270,13 @@ } public DamageSource explosion(@Nullable Entity entity, @Nullable Entity entity1) { @@ -48,17 +48,17 @@ } public DamageSource sonicBoom(Entity entity) { -@@ -256,7 +278,13 @@ +@@ -262,7 +284,13 @@ } public DamageSource badRespawnPointExplosion(Vec3D vec3d) { -- return new DamageSource(this.damageTypes.getHolderOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d); +- return new DamageSource(this.damageTypes.getOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d); + // CraftBukkit start + return badRespawnPointExplosion(vec3d, null); + } + + public DamageSource badRespawnPointExplosion(Vec3D vec3d, org.bukkit.block.BlockState blockState) { -+ return new DamageSource(this.damageTypes.getHolderOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d).directBlockState(blockState); ++ return new DamageSource(this.damageTypes.getOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d).directBlockState(blockState); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/effect/HealOrHarmMobEffect.patch b/nms-patches/net/minecraft/world/effect/HealOrHarmMobEffect.patch index 539a0856..f6f28110 100644 --- a/nms-patches/net/minecraft/world/effect/HealOrHarmMobEffect.patch +++ b/nms-patches/net/minecraft/world/effect/HealOrHarmMobEffect.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/effect/HealOrHarmMobEffect.java +++ b/net/minecraft/world/effect/HealOrHarmMobEffect.java -@@ -16,7 +16,7 @@ +@@ -17,7 +17,7 @@ @Override - public boolean applyEffectTick(EntityLiving entityliving, int i) { + public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) { if (this.isHarm == entityliving.isInvertedHealAndHarm()) { - entityliving.heal((float) Math.max(4 << i, 0)); + entityliving.heal((float) Math.max(4 << i, 0), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit } else { - entityliving.hurt(entityliving.damageSources().magic(), (float) (6 << i)); + entityliving.hurtServer(worldserver, entityliving.damageSources().magic(), (float) (6 << i)); } -@@ -30,7 +30,7 @@ +@@ -31,7 +31,7 @@ if (this.isHarm == entityliving.isInvertedHealAndHarm()) { j = (int) (d0 * (double) (4 << i) + 0.5D); diff --git a/nms-patches/net/minecraft/world/effect/HungerMobEffect.patch b/nms-patches/net/minecraft/world/effect/HungerMobEffect.patch index 3bfa8f79..f3a3c206 100644 --- a/nms-patches/net/minecraft/world/effect/HungerMobEffect.patch +++ b/nms-patches/net/minecraft/world/effect/HungerMobEffect.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/effect/HungerMobEffect.java +++ b/net/minecraft/world/effect/HungerMobEffect.java -@@ -12,7 +12,7 @@ +@@ -13,7 +13,7 @@ @Override - public boolean applyEffectTick(EntityLiving entityliving, int i) { + public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) { if (entityliving instanceof EntityHuman entityhuman) { - entityhuman.causeFoodExhaustion(0.005F * (float) (i + 1)); + entityhuman.causeFoodExhaustion(0.005F * (float) (i + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent diff --git a/nms-patches/net/minecraft/world/effect/InfestedMobEffect.patch b/nms-patches/net/minecraft/world/effect/InfestedMobEffect.patch index 60861865..ce145e52 100644 --- a/nms-patches/net/minecraft/world/effect/InfestedMobEffect.patch +++ b/nms-patches/net/minecraft/world/effect/InfestedMobEffect.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/effect/InfestedMobEffect.java +++ b/net/minecraft/world/effect/InfestedMobEffect.java -@@ -47,7 +47,11 @@ +@@ -48,7 +48,11 @@ - entitysilverfish.moveTo(d0, d1, d2, world.getRandom().nextFloat() * 360.0F, 0.0F); + entitysilverfish.moveTo(d0, d1, d2, worldserver.getRandom().nextFloat() * 360.0F, 0.0F); entitysilverfish.setDeltaMovement(new Vec3D(vector3f)); -- world.addFreshEntity(entitysilverfish); +- worldserver.addFreshEntity(entitysilverfish); + // CraftBukkit start -+ if (!world.addFreshEntity(entitysilverfish, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT)) { ++ if (!worldserver.addFreshEntity(entitysilverfish, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT)) { + return; + } + // CraftBukkit end diff --git a/nms-patches/net/minecraft/world/effect/OozingMobEffect.patch b/nms-patches/net/minecraft/world/effect/OozingMobEffect.patch index 02adb1c7..1619b976 100644 --- a/nms-patches/net/minecraft/world/effect/OozingMobEffect.patch +++ b/nms-patches/net/minecraft/world/effect/OozingMobEffect.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/OozingMobEffect.java +++ b/net/minecraft/world/effect/OozingMobEffect.java -@@ -51,7 +51,7 @@ +@@ -52,7 +52,7 @@ if (entityslime != null) { entityslime.setSize(2, true); entityslime.moveTo(d0, d1, d2, world.getRandom().nextFloat() * 360.0F, 0.0F); diff --git a/nms-patches/net/minecraft/world/effect/PoisonMobEffect.patch b/nms-patches/net/minecraft/world/effect/PoisonMobEffect.patch index e493de93..14617da0 100644 --- a/nms-patches/net/minecraft/world/effect/PoisonMobEffect.patch +++ b/nms-patches/net/minecraft/world/effect/PoisonMobEffect.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/effect/PoisonMobEffect.java +++ b/net/minecraft/world/effect/PoisonMobEffect.java -@@ -11,7 +11,7 @@ +@@ -12,7 +12,7 @@ @Override - public boolean applyEffectTick(EntityLiving entityliving, int i) { + public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) { if (entityliving.getHealth() > 1.0F) { -- entityliving.hurt(entityliving.damageSources().magic(), 1.0F); -+ entityliving.hurt(entityliving.damageSources().poison(), 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON +- entityliving.hurtServer(worldserver, entityliving.damageSources().magic(), 1.0F); ++ entityliving.hurtServer(worldserver, entityliving.damageSources().poison(), 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON } return true; diff --git a/nms-patches/net/minecraft/world/effect/RegenerationMobEffect.patch b/nms-patches/net/minecraft/world/effect/RegenerationMobEffect.patch index 7ec7c8c0..4ca57f37 100644 --- a/nms-patches/net/minecraft/world/effect/RegenerationMobEffect.patch +++ b/nms-patches/net/minecraft/world/effect/RegenerationMobEffect.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/effect/RegenerationMobEffect.java +++ b/net/minecraft/world/effect/RegenerationMobEffect.java -@@ -11,7 +11,7 @@ +@@ -12,7 +12,7 @@ @Override - public boolean applyEffectTick(EntityLiving entityliving, int i) { + public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) { if (entityliving.getHealth() < entityliving.getMaxHealth()) { - entityliving.heal(1.0F); + entityliving.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC_REGEN); // CraftBukkit diff --git a/nms-patches/net/minecraft/world/effect/SaturationMobEffect.patch b/nms-patches/net/minecraft/world/effect/SaturationMobEffect.patch index 390177b4..ebf1e21e 100644 --- a/nms-patches/net/minecraft/world/effect/SaturationMobEffect.patch +++ b/nms-patches/net/minecraft/world/effect/SaturationMobEffect.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/SaturationMobEffect.java +++ b/net/minecraft/world/effect/SaturationMobEffect.java -@@ -3,6 +3,11 @@ +@@ -4,6 +4,11 @@ import net.minecraft.world.entity.EntityLiving; import net.minecraft.world.entity.player.EntityHuman; @@ -12,10 +12,10 @@ class SaturationMobEffect extends InstantMobEffect { protected SaturationMobEffect(MobEffectInfo mobeffectinfo, int i) { -@@ -12,7 +17,15 @@ +@@ -13,7 +18,15 @@ @Override - public boolean applyEffectTick(EntityLiving entityliving, int i) { - if (!entityliving.level().isClientSide && entityliving instanceof EntityHuman entityhuman) { + public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) { + if (entityliving instanceof EntityHuman entityhuman) { - entityhuman.getFoodData().eat(i + 1, 1.0F); + // CraftBukkit start + int oldFoodLevel = entityhuman.getFoodData().foodLevel; diff --git a/nms-patches/net/minecraft/world/entity/ConversionType.patch b/nms-patches/net/minecraft/world/entity/ConversionType.patch new file mode 100644 index 00000000..4aaf08e2 --- /dev/null +++ b/nms-patches/net/minecraft/world/entity/ConversionType.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/world/entity/ConversionType.java ++++ b/net/minecraft/world/entity/ConversionType.java +@@ -12,6 +12,11 @@ + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.scores.Scoreboard; + ++// CraftBukkit start ++import net.minecraft.core.BlockPosition; ++import org.bukkit.event.entity.EntityRemoveEvent; ++// CraftBukkit end ++ + public enum ConversionType { + + SINGLE(true) { +@@ -31,7 +36,7 @@ + while (iterator.hasNext()) { + entity1 = (Entity) iterator.next(); + entity1.stopRiding(); +- entity1.remove(Entity.RemovalReason.DISCARDED); ++ entity1.remove(Entity.RemovalReason.DISCARDED, EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause + } + + entity.startRiding(entityinsentient1); +@@ -64,7 +69,7 @@ + entityinsentient1.hurtTime = entityinsentient.hurtTime; + entityinsentient1.yBodyRot = entityinsentient.yBodyRot; + entityinsentient1.setOnGround(entityinsentient.onGround()); +- Optional optional = entityinsentient.getSleepingPos(); ++ Optional optional = entityinsentient.getSleepingPos(); // CraftBukkit - decompile error + + Objects.requireNonNull(entityinsentient1); + optional.ifPresent(entityinsentient1::setSleepingPos); +@@ -156,7 +161,7 @@ + entityinsentient1.setNoGravity(entityinsentient.isNoGravity()); + entityinsentient1.setPortalCooldown(entityinsentient.getPortalCooldown()); + entityinsentient1.setSilent(entityinsentient.isSilent()); +- Set set = entityinsentient.getTags(); ++ Set set = entityinsentient.getTags(); // CraftBukkit - decompile error + + Objects.requireNonNull(entityinsentient1); + set.forEach(entityinsentient1::addTag); diff --git a/nms-patches/net/minecraft/world/entity/Entity.patch b/nms-patches/net/minecraft/world/entity/Entity.patch index 86ac3ad8..cf4d28c9 100644 --- a/nms-patches/net/minecraft/world/entity/Entity.patch +++ b/nms-patches/net/minecraft/world/entity/Entity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -131,8 +131,72 @@ +@@ -139,8 +139,67 @@ import net.minecraft.world.scores.ScoreboardTeamBase; import org.slf4j.Logger; @@ -42,7 +42,7 @@ +import org.bukkit.plugin.PluginManager; +// CraftBukkit end + - public abstract class Entity implements SyncedDataHolder, INamableTileEntity, EntityAccess, ICommandListener, ScoreHolder { + public abstract class Entity implements SyncedDataHolder, INamableTileEntity, EntityAccess, ScoreHolder { + // CraftBukkit start + private static final int CURRENT_LEVEL = 2; @@ -59,11 +59,6 @@ + return bukkitEntity; + } + -+ @Override -+ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) { -+ return getBukkitEntity(); -+ } -+ + // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + public int getDefaultMaxAirSupply() { + return TOTAL_AIR_SUPPLY; @@ -73,10 +68,10 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -245,6 +309,30 @@ - public boolean hasVisualFire; - @Nullable - private IBlockData inBlockState; +@@ -253,6 +312,30 @@ + private final List movementThisTick; + private final Set blocksInside; + private final LongSet visitedBlocks; + // CraftBukkit start + public boolean forceDrops; + public boolean persist = true; @@ -104,10 +99,10 @@ public Entity(EntityTypes entitytypes, World world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -351,12 +439,18 @@ +@@ -362,12 +445,18 @@ } - public void kill() { + public void kill(WorldServer worldserver) { - this.remove(Entity.RemovalReason.KILLED); + this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause this.gameEvent(GameEvent.ENTITY_DIE); @@ -125,7 +120,7 @@ } protected abstract void defineSynchedData(DataWatcher.a datawatcher_a); -@@ -365,6 +459,16 @@ +@@ -376,6 +465,16 @@ return this.entityData; } @@ -142,7 +137,7 @@ public boolean equals(Object object) { return object instanceof Entity ? ((Entity) object).id == this.id : false; } -@@ -374,12 +478,24 @@ +@@ -385,7 +484,13 @@ } public void remove(Entity.RemovalReason entity_removalreason) { @@ -157,6 +152,8 @@ } public void onClientRemoval() {} +@@ -393,6 +498,12 @@ + public void onRemoval(Entity.RemovalReason entity_removalreason) {} public void setPose(EntityPose entitypose) { + // CraftBukkit start @@ -168,7 +165,7 @@ this.entityData.set(Entity.DATA_POSE, entitypose); } -@@ -404,6 +520,33 @@ +@@ -417,6 +528,33 @@ } protected void setRot(float f, float f1) { @@ -202,7 +199,7 @@ this.setYRot(f % 360.0F); this.setXRot(f1 % 360.0F); } -@@ -445,6 +588,15 @@ +@@ -458,6 +596,15 @@ this.baseTick(); } @@ -216,18 +213,18 @@ + // CraftBukkit end + public void baseTick() { - this.level().getProfiler().push("entityBaseTick"); - this.inBlockState = null; -@@ -459,7 +611,7 @@ - this.walkDistO = this.walkDist; - this.xRotO = this.getXRot(); - this.yRotO = this.getYRot(); + GameProfilerFiller gameprofilerfiller = Profiler.get(); + +@@ -471,7 +618,7 @@ + --this.boardingCooldown; + } + - this.handlePortal(); + if (this instanceof EntityPlayer) this.handlePortal(); // CraftBukkit - // Moved up to postTick if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -494,6 +646,10 @@ +@@ -510,6 +657,10 @@ if (this.isInLava()) { this.lavaHurt(); this.fallDistance *= 0.5F; @@ -238,21 +235,20 @@ } this.checkBelowWorld(); -@@ -503,7 +659,7 @@ - - this.firstTick = false; - if (!this.level().isClientSide && this instanceof Leashable) { -- Leashable.tickLeash((Entity) ((Leashable) this)); -+ Leashable.tickLeash((Entity & Leashable) this); // CraftBukkit - decompile error +@@ -521,7 +672,7 @@ + world = this.level(); + if (world instanceof WorldServer worldserver) { + if (this instanceof Leashable) { +- Leashable.tickLeash(worldserver, (Entity) ((Leashable) this)); ++ Leashable.tickLeash(worldserver, (Entity & Leashable) this); // CraftBukkit - decompile error + } } - this.level().getProfiler().pop(); -@@ -545,15 +701,47 @@ +@@ -564,15 +715,32 @@ public void lavaHurt() { if (!this.fireImmune()) { - this.igniteForSeconds(15.0F); -- if (this.hurt(this.damageSources().lava(), 4.0F)) { + // CraftBukkit start - Fallen in lava TODO: this event spams! + if (this instanceof EntityLiving && remainingFireTicks <= 0) { + // not on fire yet @@ -268,13 +264,22 @@ + // This will be called every single tick the entity is in lava, so don't throw an event + this.igniteForSeconds(15.0F, false); + } -+ -+ if (this.hurt(this.damageSources().lava().directBlock(level, lastLavaContact), 4.0F)) { - this.playSound(SoundEffects.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F); ++ // CraftBukkit end + World world = this.level(); + + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; + +- if (this.hurtServer(worldserver, this.damageSources().lava(), 4.0F) && this.shouldPlayLavaHurtSound() && !this.isSilent()) { ++ // CraftBukkit start ++ if (this.hurtServer(worldserver, this.damageSources().lava().directBlock(level, lastLavaContact), 4.0F) && this.shouldPlayLavaHurtSound() && !this.isSilent()) { + worldserver.playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.GENERIC_BURN, this.getSoundSource(), 0.4F, 2.0F + this.random.nextFloat() * 0.4F); + } ++ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls } -+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls } +@@ -583,6 +751,22 @@ } public final void igniteForSeconds(float f) { @@ -297,7 +302,7 @@ this.igniteForTicks(MathHelper.floor(f * 20.0F)); } -@@ -577,7 +765,7 @@ +@@ -606,7 +790,7 @@ } protected void onBelowWorld() { @@ -306,8 +311,8 @@ } public boolean isFree(double d0, double d1, double d2) { -@@ -702,6 +890,28 @@ - block.updateEntityAfterFallOn(this.level(), this); +@@ -739,6 +923,28 @@ + } } + // CraftBukkit start @@ -332,10 +337,10 @@ + } + // CraftBukkit end + - if (this.onGround()) { - block.stepOn(this.level(), blockposition, iblockdata, this); - } -@@ -1073,6 +1283,20 @@ + if (!this.level().isClientSide() || this.isControlledByLocalInstance()) { + Entity.MovementEmission entity_movementemission = this.getMovementEmission(); + +@@ -1120,6 +1326,20 @@ return SoundEffects.GENERIC_SPLASH; } @@ -353,10 +358,10 @@ + } + // CraftBukkit end + - protected void checkInsideBlocks() { - AxisAlignedBB axisalignedbb = this.getBoundingBox(); - BlockPosition blockposition = BlockPosition.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D); -@@ -1512,6 +1736,7 @@ + public void recordMovementThroughBlocks(Vec3D vec3d, Vec3D vec3d1) { + this.movementThisTick.add(new Entity.b(vec3d, vec3d1)); + } +@@ -1586,6 +1806,7 @@ this.yo = d1; this.zo = d4; this.setPos(d3, d1, d4); @@ -364,7 +369,7 @@ } public void moveTo(Vec3D vec3d) { -@@ -1718,6 +1943,12 @@ +@@ -1838,6 +2059,12 @@ return false; } @@ -377,7 +382,7 @@ public void awardKillScore(Entity entity, int i, DamageSource damagesource) { if (entity instanceof EntityPlayer) { CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); -@@ -1746,16 +1977,22 @@ +@@ -1866,16 +2093,22 @@ } public boolean saveAsPassenger(NBTTagCompound nbttagcompound) { @@ -402,7 +407,7 @@ return true; } } -@@ -1766,16 +2003,38 @@ +@@ -1886,16 +2119,38 @@ } public NBTTagCompound saveWithoutId(NBTTagCompound nbttagcompound) { @@ -445,7 +450,7 @@ nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); nbttagcompound.putFloat("FallDistance", this.fallDistance); nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); -@@ -1783,7 +2042,28 @@ +@@ -1903,7 +2158,28 @@ nbttagcompound.putBoolean("OnGround", this.onGround()); nbttagcompound.putBoolean("Invulnerable", this.invulnerable); nbttagcompound.putInt("PortalCooldown", this.portalCooldown); @@ -475,7 +480,7 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1832,7 +2112,7 @@ +@@ -1952,7 +2228,7 @@ nbttagcompound.put("Tags", nbttaglist); } @@ -484,7 +489,7 @@ if (this.isVehicle()) { nbttaglist = new NBTTagList(); iterator = this.getPassengers().iterator(); -@@ -1841,7 +2121,7 @@ +@@ -1961,7 +2237,7 @@ Entity entity = (Entity) iterator.next(); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); @@ -493,7 +498,7 @@ nbttaglist.add(nbttagcompound1); } } -@@ -1851,6 +2131,11 @@ +@@ -1971,6 +2247,11 @@ } } @@ -505,7 +510,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -1934,6 +2219,45 @@ +@@ -2055,6 +2336,45 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -551,7 +556,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -1955,6 +2279,12 @@ +@@ -2076,6 +2396,12 @@ return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null; } @@ -564,8 +569,8 @@ protected abstract void readAdditionalSaveData(NBTTagCompound nbttagcompound); protected abstract void addAdditionalSaveData(NBTTagCompound nbttagcompound); -@@ -2009,9 +2339,22 @@ - } else if (this.level().isClientSide) { +@@ -2128,9 +2454,22 @@ + if (itemstack.isEmpty()) { return null; } else { + // CraftBukkit start - Capture drops for death event @@ -574,7 +579,7 @@ + return null; + } + // CraftBukkit end - EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY() + (double) f, this.getZ(), itemstack); + EntityItem entityitem = new EntityItem(worldserver, this.getX(), this.getY() + (double) f, this.getZ(), itemstack); entityitem.setDefaultPickUpDelay(); + // CraftBukkit start @@ -584,10 +589,10 @@ + return null; + } + // CraftBukkit end - this.level().addFreshEntity(entityitem); + worldserver.addFreshEntity(entityitem); return entityitem; } -@@ -2040,6 +2383,12 @@ +@@ -2159,6 +2498,12 @@ if (this.isAlive() && this instanceof Leashable leashable) { if (leashable.getLeashHolder() == entityhuman) { if (!this.level().isClientSide()) { @@ -600,7 +605,7 @@ leashable.dropLeash(true, !entityhuman.hasInfiniteMaterials()); this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman); } -@@ -2051,6 +2400,13 @@ +@@ -2170,6 +2515,13 @@ if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { if (!this.level().isClientSide()) { @@ -614,7 +619,7 @@ leashable.setLeashedTo(entityhuman, true); } -@@ -2134,6 +2490,27 @@ +@@ -2255,6 +2607,27 @@ if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -642,7 +647,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2167,7 +2544,7 @@ +@@ -2288,7 +2661,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -651,7 +656,7 @@ } } -@@ -2198,10 +2575,38 @@ +@@ -2319,10 +2692,38 @@ } } @@ -691,7 +696,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); } else { -@@ -2213,6 +2618,7 @@ +@@ -2334,6 +2735,7 @@ entity.boardingCooldown = 60; this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity); } @@ -699,16 +704,16 @@ } protected boolean canAddPassenger(Entity entity) { -@@ -2307,7 +2713,7 @@ - if (dimensiontransition != null) { - WorldServer worldserver1 = dimensiontransition.newLevel(); +@@ -2434,7 +2836,7 @@ + if (teleporttransition != null) { + WorldServer worldserver1 = teleporttransition.newLevel(); -- if (worldserver.getServer().isLevelEnabled(worldserver1) && (worldserver1.dimension() == worldserver.dimension() || this.canChangeDimensions(worldserver, worldserver1))) { -+ if (this instanceof EntityPlayer || (worldserver1 != null && (worldserver1.dimension() == worldserver.dimension() || this.canChangeDimensions(worldserver, worldserver1)))) { // CraftBukkit - always call event for players - this.changeDimension(dimensiontransition); +- if (worldserver.getServer().isLevelEnabled(worldserver1) && (worldserver1.dimension() == worldserver.dimension() || this.canTeleport(worldserver, worldserver1))) { ++ if (this instanceof EntityPlayer || (worldserver1 != null && (worldserver1.dimension() == worldserver.dimension() || this.canTeleport(worldserver, worldserver1)))) { // CraftBukkit - always call event for players + this.teleport(teleporttransition); } } -@@ -2414,6 +2820,13 @@ +@@ -2541,6 +2943,13 @@ } public void setSwimming(boolean flag) { @@ -722,7 +727,7 @@ this.setSharedFlag(4, flag); } -@@ -2463,8 +2876,12 @@ +@@ -2594,8 +3003,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; } @@ -736,7 +741,7 @@ } public boolean getSharedFlag(int i) { -@@ -2483,7 +2900,7 @@ +@@ -2614,7 +3027,7 @@ } public int getMaxAirSupply() { @@ -745,7 +750,7 @@ } public int getAirSupply() { -@@ -2491,7 +2908,18 @@ +@@ -2622,7 +3035,18 @@ } public void setAirSupply(int i) { @@ -765,7 +770,7 @@ } public int getTicksFrozen() { -@@ -2518,11 +2946,40 @@ +@@ -2649,11 +3073,40 @@ public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -786,7 +791,7 @@ + // CraftBukkit end } -- this.hurt(this.damageSources().lightningBolt(), 5.0F); +- this.hurtServer(worldserver, this.damageSources().lightningBolt(), 5.0F); + // CraftBukkit start + if (thisBukkitEntity instanceof Hanging) { + HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity); @@ -801,47 +806,47 @@ + return; + } + -+ if (!this.hurt(this.damageSources().lightningBolt().customEntityDamager(entitylightning), 5.0F)) { ++ if (!this.hurtServer(worldserver, this.damageSources().lightningBolt().customEntityDamager(entitylightning), 5.0F)) { + return; + } + // CraftBukkit end } public void onAboveBubbleCol(boolean flag) { -@@ -2691,6 +3148,15 @@ +@@ -2822,6 +3275,18 @@ if (world instanceof WorldServer worldserver) { if (!this.isRemoved()) { + // CraftBukkit start -+ Location to = new Location(dimensiontransition.newLevel().getWorld(), dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot()); ++ PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); ++ Location to = CraftLocation.toBukkit(absolutePosition.position(), teleporttransition.newLevel().getWorld(), absolutePosition.yRot(), absolutePosition.xRot()); + EntityTeleportEvent teleEvent = CraftEventFactory.callEntityTeleportEvent(this, to); + if (teleEvent.isCancelled()) { + return null; + } -+ to = teleEvent.getTo(); -+ dimensiontransition = new DimensionTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), dimensiontransition.speed(), to.getYaw(), to.getPitch(), dimensiontransition.missingRespawnBlock(), dimensiontransition.postDimensionTransition(), dimensiontransition.cause()); ++ if (!to.equals(teleEvent.getTo())) { ++ to = teleEvent.getTo(); ++ teleporttransition = new TeleportTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), Vec3D.ZERO, to.getYaw(), to.getPitch(), teleporttransition.missingRespawnBlock(), teleporttransition.asPassenger(), Set.of(), teleporttransition.postTeleportTransition(), teleporttransition.cause()); ++ } + // CraftBukkit end - WorldServer worldserver1 = dimensiontransition.newLevel(); - List list = this.getPassengers(); - -@@ -2716,11 +3182,15 @@ - if (this != entity2) { - entity2.restoreFrom(this); - this.removeAfterChangingDimensions(); -+ // CraftBukkit start - Forward the CraftEntity to the new entity -+ this.getBukkitEntity().setHandle(entity2); -+ entity2.bukkitEntity = this.getBukkitEntity(); -+ // CraftBukkit end - } + WorldServer worldserver1 = teleporttransition.newLevel(); + boolean flag = worldserver1.dimension() != worldserver.dimension(); - entity2.moveTo(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), entity2.getXRot()); - entity2.setDeltaMovement(dimensiontransition.speed()); -- if (this != entity2) { -+ if (this != entity2 && this.inWorld) { // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned - worldserver1.addDuringTeleport(entity2); - } +@@ -2890,8 +3355,12 @@ + } else { + entity.restoreFrom(this); + this.removeAfterChangingDimensions(); ++ // CraftBukkit start - Forward the CraftEntity to the new entity ++ this.getBukkitEntity().setHandle(entity); ++ entity.bukkitEntity = this.getBukkitEntity(); ++ // CraftBukkit end + entity.teleportSetPosition(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); +- worldserver.addDuringTeleport(entity); ++ if (this.inWorld) worldserver.addDuringTeleport(entity); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned + Iterator iterator1 = list1.iterator(); -@@ -2754,8 +3224,9 @@ + while (iterator1.hasNext()) { +@@ -2965,8 +3434,9 @@ } protected void removeAfterChangingDimensions() { @@ -852,7 +857,7 @@ leashable.dropLeash(true, false); } -@@ -2765,6 +3236,20 @@ +@@ -2976,6 +3446,20 @@ return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); } @@ -873,35 +878,25 @@ public boolean canUsePortal(boolean flag) { return (flag || !this.isPassenger()) && this.isAlive(); } -@@ -2877,6 +3362,12 @@ +@@ -3104,9 +3588,15 @@ return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); } +- public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, boolean flag) { + // CraftBukkit start -+ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { -+ return this.teleportTo(worldserver, d0, d1, d2, set, f, f1); ++ public final boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, boolean flag) { ++ return teleportTo(worldserver, d0, d1, d2, set, f, f1, flag, PlayerTeleportEvent.TeleportCause.UNKNOWN); + } -+ // CraftBukkit end + - public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1) { ++ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set set, float f, float f1, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { float f2 = MathHelper.clamp(f1, -90.0F, 90.0F); +- Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f2, set, TeleportTransition.DO_NOTHING)); ++ Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f2, set, TeleportTransition.DO_NOTHING, cause)); ++ // CraftBukkit end -@@ -2895,8 +3386,12 @@ - entity.restoreFrom(this); - entity.moveTo(d0, d1, d2, f, f2); - entity.setYHeadRot(f); -- this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION); -- worldserver.addDuringTeleport(entity); -+ this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION, null); // CraftBukkit - add Bukkit remove cause -+ // CraftBukkit start - Don't spawn the new entity if the current entity isn't spawned -+ if (inWorld) { -+ worldserver.addDuringTeleport(entity); -+ } -+ // CraftBukkit end - } - - return true; -@@ -3023,7 +3518,26 @@ + return entity != null; + } +@@ -3228,7 +3718,26 @@ } public final void setBoundingBox(AxisAlignedBB axisalignedbb) { @@ -929,7 +924,7 @@ } public final float getEyeHeight(EntityPose entitypose) { -@@ -3332,6 +3846,11 @@ +@@ -3525,6 +4034,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } @@ -941,7 +936,7 @@ } } } -@@ -3601,6 +4120,14 @@ +@@ -3792,6 +4306,14 @@ @Override public final void setRemoved(Entity.RemovalReason entity_removalreason) { diff --git a/nms-patches/net/minecraft/world/entity/EntityAgeable.patch b/nms-patches/net/minecraft/world/entity/EntityAgeable.patch index b5e1154c..77d10c6a 100644 --- a/nms-patches/net/minecraft/world/entity/EntityAgeable.patch +++ b/nms-patches/net/minecraft/world/entity/EntityAgeable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityAgeable.java +++ b/net/minecraft/world/entity/EntityAgeable.java -@@ -20,6 +20,7 @@ +@@ -21,6 +21,7 @@ protected int age; protected int forcedAge; protected int forcedAgeTimer; @@ -8,7 +8,7 @@ protected EntityAgeable(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -103,6 +104,7 @@ +@@ -104,6 +105,7 @@ super.addAdditionalSaveData(nbttagcompound); nbttagcompound.putInt("Age", this.getAge()); nbttagcompound.putInt("ForcedAge", this.forcedAge); @@ -16,7 +16,7 @@ } @Override -@@ -110,6 +112,7 @@ +@@ -111,6 +113,7 @@ super.readAdditionalSaveData(nbttagcompound); this.setAge(nbttagcompound.getInt("Age")); this.forcedAge = nbttagcompound.getInt("ForcedAge"); @@ -24,7 +24,7 @@ } @Override -@@ -124,7 +127,7 @@ +@@ -125,7 +128,7 @@ @Override public void aiStep() { super.aiStep(); diff --git a/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch b/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch index ee7c7306..3f2bb941 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 @@ +@@ -33,6 +33,12 @@ import net.minecraft.world.level.material.EnumPistonReaction; import org.slf4j.Logger; @@ -13,81 +13,81 @@ public class EntityAreaEffectCloud extends Entity implements TraceableEntity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -188,7 +194,7 @@ - } - } else { - if (this.tickCount >= this.waitTime + this.duration) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - return; - } +@@ -200,7 +206,7 @@ -@@ -205,7 +211,7 @@ - if (this.radiusPerTick != 0.0F) { - f += this.radiusPerTick; - if (f < 0.5F) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - return; - } + private void serverTick(WorldServer worldserver) { + if (this.tickCount >= this.waitTime + this.duration) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + } else { + boolean flag = this.isWaiting(); + boolean flag1 = this.tickCount < this.waitTime; +@@ -215,7 +221,7 @@ + if (this.radiusPerTick != 0.0F) { + f += this.radiusPerTick; + if (f < 0.5F) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + return; + } -@@ -239,11 +245,12 @@ - if (!list1.isEmpty()) { - Iterator iterator1 = list1.iterator(); +@@ -249,11 +255,12 @@ + if (!list1.isEmpty()) { + Iterator iterator1 = list1.iterator(); -+ List entities = new java.util.ArrayList(); // CraftBukkit - while (iterator1.hasNext()) { - EntityLiving entityliving = (EntityLiving) iterator1.next(); ++ List entities = new java.util.ArrayList(); // CraftBukkit + while (iterator1.hasNext()) { + EntityLiving entityliving = (EntityLiving) iterator1.next(); - if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) { -- Stream stream = list.stream(); -+ Stream stream = list.stream(); // CraftBukkit - decompile error + if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) { +- Stream stream = list.stream(); ++ Stream stream = list.stream(); // CraftBukkit - decompile error - Objects.requireNonNull(entityliving); - if (!stream.noneMatch(entityliving::canBeAffected)) { -@@ -252,6 +259,19 @@ - double d5 = d3 * d3 + d4 * d4; + Objects.requireNonNull(entityliving); + if (!stream.noneMatch(entityliving::canBeAffected)) { +@@ -262,6 +269,19 @@ + double d2 = d0 * d0 + d1 * d1; - if (d5 <= (double) (f * f)) { -+ // CraftBukkit start -+ entities.add((LivingEntity) entityliving.getBukkitEntity()); + if (d2 <= (double) (f * f)) { ++ // CraftBukkit start ++ entities.add((LivingEntity) entityliving.getBukkitEntity()); ++ } + } + } + } -+ } -+ { -+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities); -+ if (!event.isCancelled()) { -+ for (LivingEntity entity : event.getAffectedEntities()) { -+ if (entity instanceof CraftLivingEntity) { -+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); -+ // CraftBukkit end - this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); - Iterator iterator2 = list.iterator(); ++ { ++ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities); ++ if (!event.isCancelled()) { ++ for (LivingEntity entity : event.getAffectedEntities()) { ++ if (entity instanceof CraftLivingEntity) { ++ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); ++ // CraftBukkit end + this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); + Iterator iterator2 = list.iterator(); -@@ -261,14 +281,14 @@ - if (((MobEffectList) mobeffect1.getEffect().value()).isInstantenous()) { - ((MobEffectList) mobeffect1.getEffect().value()).applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D); - } else { -- entityliving.addEffect(new MobEffect(mobeffect1), this); -+ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit +@@ -271,14 +291,14 @@ + if (((MobEffectList) mobeffect1.getEffect().value()).isInstantenous()) { + ((MobEffectList) mobeffect1.getEffect().value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D); + } else { +- entityliving.addEffect(new MobEffect(mobeffect1), this); ++ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit + } } - } - if (this.radiusOnUse != 0.0F) { - f += this.radiusOnUse; - if (f < 0.5F) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - return; - } + if (this.radiusOnUse != 0.0F) { + f += this.radiusOnUse; + if (f < 0.5F) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + return; + } -@@ -278,7 +298,7 @@ - if (this.durationOnUse != 0) { - this.duration += this.durationOnUse; - if (this.duration <= 0) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - return; +@@ -288,7 +308,7 @@ + if (this.durationOnUse != 0) { + this.duration += this.durationOnUse; + if (this.duration <= 0) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + return; + } } - } diff --git a/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch b/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch index 4ada992e..48c47f28 100644 --- a/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch +++ b/nms-patches/net/minecraft/world/entity/EntityExperienceOrb.patch @@ -47,7 +47,7 @@ Vec3D vec3d = new Vec3D(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double) this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ()); double d0 = vec3d.lengthSqr(); -@@ -118,7 +142,7 @@ +@@ -119,7 +143,7 @@ ++this.age; if (this.age >= 6000) { @@ -56,7 +56,7 @@ } } -@@ -187,7 +211,7 @@ +@@ -188,7 +212,7 @@ private void merge(EntityExperienceOrb entityexperienceorb) { this.count += entityexperienceorb.count; this.age = Math.min(this.age, entityexperienceorb.age); @@ -65,7 +65,7 @@ } private void setUnderwaterMovement() { -@@ -209,7 +233,7 @@ +@@ -213,7 +237,7 @@ this.markHurt(); this.health = (int) ((float) this.health - f); if (this.health <= 0) { @@ -74,7 +74,7 @@ } return true; -@@ -236,17 +260,17 @@ +@@ -240,17 +264,17 @@ public void playerTouch(EntityHuman entityhuman) { if (entityhuman instanceof EntityPlayer entityplayer) { if (entityhuman.takeXpDelay == 0) { @@ -95,7 +95,7 @@ } } -@@ -260,12 +284,20 @@ +@@ -264,12 +288,20 @@ ItemStack itemstack = ((EnchantedItemInUse) optional.get()).itemStack(); int j = EnchantmentManager.modifyDurabilityToRepairFromXp(entityplayer.serverLevel(), itemstack, i); int k = Math.min(j, itemstack.getDamageValue()); @@ -116,7 +116,7 @@ return this.repairPlayerItems(entityplayer, l); } } -@@ -285,6 +317,24 @@ +@@ -289,6 +321,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 54e16c0d..a27e3229 100644 --- a/nms-patches/net/minecraft/world/entity/EntityInsentient.patch +++ b/nms-patches/net/minecraft/world/entity/EntityInsentient.patch @@ -1,15 +1,13 @@ --- a/net/minecraft/world/entity/EntityInsentient.java +++ b/net/minecraft/world/entity/EntityInsentient.java -@@ -87,6 +87,20 @@ +@@ -89,6 +89,18 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; import net.minecraft.world.phys.AxisAlignedBB; +// CraftBukkit start -+import net.minecraft.server.level.EntityPlayer; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.event.entity.CreatureSpawnEvent; -+import org.bukkit.event.entity.EntityCombustByEntityEvent; +import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.entity.EntityTargetEvent; @@ -21,7 +19,7 @@ public abstract class EntityInsentient extends EntityLiving implements EquipmentUser, Leashable, Targeting { private static final DataWatcherObject DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE); -@@ -134,6 +148,8 @@ +@@ -136,6 +148,8 @@ private BlockPosition restrictCenter; private float restrictRadius; @@ -30,7 +28,7 @@ protected EntityInsentient(EntityTypes entitytypes, World world) { super(entitytypes, world); this.handItems = NonNullList.withSize(2, ItemStack.EMPTY); -@@ -161,6 +177,12 @@ +@@ -164,6 +178,12 @@ } @@ -43,7 +41,7 @@ protected void registerGoals() {} public static AttributeProvider.Builder createMobAttributes() { -@@ -265,11 +287,42 @@ +@@ -268,11 +288,42 @@ @Nullable protected final EntityLiving getTargetFromBrain() { @@ -87,7 +85,7 @@ } @Override -@@ -405,6 +458,12 @@ +@@ -403,6 +454,12 @@ return null; } @@ -100,7 +98,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); -@@ -478,16 +537,26 @@ +@@ -476,16 +533,26 @@ nbttagcompound.putBoolean("NoAI", this.isNoAi()); } @@ -112,7 +110,7 @@ super.readAdditionalSaveData(nbttagcompound); + + // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it - if (nbttagcompound.contains("CanPickUpLoot", 1)) { + if (nbttagcompound.contains("CanPickUpLoot", 99)) { - this.setCanPickUpLoot(nbttagcompound.getBoolean("CanPickUpLoot")); + boolean data = nbttagcompound.getBoolean("CanPickUpLoot"); + if (isLevelAtLeast(nbttagcompound, 1) || data) { @@ -129,7 +127,7 @@ NBTTagList nbttaglist; NBTTagCompound nbttagcompound1; int i; -@@ -541,6 +610,11 @@ +@@ -539,6 +606,11 @@ } this.setNoAi(nbttagcompound.getBoolean("NoAI")); @@ -141,12 +139,12 @@ } @Override -@@ -615,20 +689,26 @@ +@@ -615,20 +687,26 @@ - protected void pickUpItem(EntityItem entityitem) { + protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); -- ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy()); -+ ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy(), entityitem); // CraftBukkit - add item +- ItemStack itemstack1 = this.equipItemIfPossible(worldserver, itemstack.copy()); ++ ItemStack itemstack1 = this.equipItemIfPossible(worldserver, itemstack.copy(), entityitem); // CraftBukkit - add item if (!itemstack1.isEmpty()) { this.onItemPickup(entityitem); @@ -160,17 +158,17 @@ } - public ItemStack equipItemIfPossible(ItemStack itemstack) { + public ItemStack equipItemIfPossible(WorldServer worldserver, ItemStack itemstack) { + // CraftBukkit start - add item -+ return this.equipItemIfPossible(itemstack, null); ++ return this.equipItemIfPossible(worldserver, itemstack, null); + } + -+ public ItemStack equipItemIfPossible(ItemStack itemstack, EntityItem entityitem) { ++ public ItemStack equipItemIfPossible(WorldServer worldserver, ItemStack itemstack, EntityItem entityitem) { + // CraftBukkit end EnumItemSlot enumitemslot = this.getEquipmentSlotForItem(itemstack); ItemStack itemstack1 = this.getItemBySlot(enumitemslot); - boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1); -@@ -639,11 +719,19 @@ + boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1, enumitemslot); +@@ -639,11 +717,19 @@ flag = itemstack1.isEmpty(); } @@ -186,12 +184,12 @@ if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) { + this.forceDrops = true; // CraftBukkit - this.spawnAtLocation(itemstack1); + this.spawnAtLocation(worldserver, itemstack1); + this.forceDrops = false; // CraftBukkit } ItemStack itemstack2 = enumitemslot.limit(itemstack); -@@ -772,7 +860,7 @@ +@@ -770,7 +856,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { @@ -200,7 +198,7 @@ } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { EntityHuman entityhuman = this.level().getNearestPlayer(this, -1.0D); -@@ -782,14 +870,14 @@ +@@ -780,14 +866,14 @@ int j = i * i; if (d0 > (double) j && this.removeWhenFarAway(d0)) { @@ -217,15 +215,15 @@ } else if (d0 < (double) l) { this.noActionTime = 0; } -@@ -803,6 +891,7 @@ +@@ -801,6 +887,7 @@ @Override protected final void serverAiStep() { ++this.noActionTime; + if (!this.aware) return; // CraftBukkit - GameProfilerFiller gameprofilerfiller = this.level().getProfiler(); + GameProfilerFiller gameprofilerfiller = Profiler.get(); gameprofilerfiller.push("sensing"); -@@ -1354,7 +1443,7 @@ +@@ -1340,7 +1427,7 @@ if (itemstack.getItem() instanceof ItemMonsterEgg) { if (this.level() instanceof WorldServer) { ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); @@ -234,51 +232,71 @@ optional.ifPresent((entityinsentient) -> { this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient); -@@ -1403,12 +1492,19 @@ +@@ -1391,12 +1478,19 @@ return this.restrictRadius != -1.0F; } + // CraftBukkit start @Nullable - public T convertTo(EntityTypes entitytypes, boolean flag) { -+ return this.convertTo(entitytypes, flag, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + public T convertTo(EntityTypes entitytypes, ConversionParams conversionparams, EntitySpawnReason entityspawnreason, ConversionParams.a conversionparams_a) { ++ return this.convertTo(entitytypes, conversionparams, entityspawnreason, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + + @Nullable -+ public T convertTo(EntityTypes entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { ++ public T convertTo(EntityTypes entitytypes, ConversionParams conversionparams, EntitySpawnReason entityspawnreason, ConversionParams.a conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end if (this.isRemoved()) { return null; } else { -- T t0 = (EntityInsentient) entitytypes.create(this.level()); -+ T t0 = entitytypes.create(this.level()); // CraftBukkit - decompile error +- T t0 = (EntityInsentient) entitytypes.create(this.level(), entityspawnreason); ++ T t0 = entitytypes.create(this.level(), EntitySpawnReason.CONVERSION); // CraftBukkit - decompile error if (t0 == null) { return null; -@@ -1442,7 +1538,12 @@ - } - } +@@ -1405,14 +1499,24 @@ + conversionparams_a.finalizeConversion(t0); + World world = this.level(); -- this.level().addFreshEntity(t0); + // CraftBukkit start ++ if (transformReason == null) { ++ // Special handling for slime split and pig lightning ++ return t0; ++ } ++ + if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) { + return null; + } -+ this.level().addFreshEntity(t0, spawnReason); + // CraftBukkit end - if (this.isPassenger()) { - Entity entity = this.getVehicle(); + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; + +- worldserver.addFreshEntity(t0); ++ worldserver.addFreshEntity(t0, spawnReason); // CraftBukkit + } -@@ -1450,7 +1551,7 @@ - t0.startRiding(entity, true); + if (conversionparams.type().shouldDiscardAfterConversion()) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause } -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause return t0; - } - } -@@ -1492,6 +1593,7 @@ +@@ -1422,7 +1526,14 @@ + + @Nullable + public T convertTo(EntityTypes entitytypes, ConversionParams conversionparams, ConversionParams.a conversionparams_a) { +- return this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a); ++ // CraftBukkit start ++ return this.convertTo(entitytypes, conversionparams, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); ++ } ++ ++ @Nullable ++ public T convertTo(EntityTypes entitytypes, ConversionParams conversionparams, ConversionParams.a conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { ++ return this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a, transformReason, spawnReason); ++ // CraftBukkit end + } + + @Nullable +@@ -1461,6 +1572,7 @@ boolean flag1 = super.startRiding(entity, flag); if (flag1 && this.isLeashed()) { @@ -286,10 +304,10 @@ this.dropLeash(true, true); } -@@ -1578,7 +1680,7 @@ - if (f1 > 0.0F && entity instanceof EntityLiving) { - EntityLiving entityliving = (EntityLiving) entity; +@@ -1545,7 +1657,7 @@ + if (f1 > 0.0F && entity instanceof EntityLiving) { + entityliving = (EntityLiving) entity; - entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F))); + entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); diff --git a/nms-patches/net/minecraft/world/entity/EntityLightning.patch b/nms-patches/net/minecraft/world/entity/EntityLightning.patch index 84f36215..04073819 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 -@@ -30,6 +30,11 @@ +@@ -31,6 +31,11 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -12,7 +12,7 @@ public class EntityLightning extends Entity { private static final int START_LIFE = 2; -@@ -121,7 +126,7 @@ +@@ -120,7 +125,7 @@ } } @@ -21,7 +21,7 @@ } else if (this.life < -this.random.nextInt(10)) { --this.flashes; this.life = 1; -@@ -130,7 +135,7 @@ +@@ -129,7 +134,7 @@ } } @@ -30,37 +30,37 @@ if (!(this.level() instanceof WorldServer)) { this.level().setSkyFlashTime(2); } else if (!this.visualOnly) { -@@ -164,8 +169,12 @@ - IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition); +@@ -169,8 +174,12 @@ + IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition); - if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { -- this.level().setBlockAndUpdate(blockposition, iblockdata); -- ++this.blocksSetOnFire; -+ // CraftBukkit start - add "!visualOnly" -+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition, this).isCancelled()) { -+ this.level().setBlockAndUpdate(blockposition, iblockdata); -+ ++this.blocksSetOnFire; -+ } -+ // CraftBukkit end - } + if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { +- this.level().setBlockAndUpdate(blockposition, iblockdata); +- ++this.blocksSetOnFire; ++ // CraftBukkit start - add "!visualOnly" ++ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition, this).isCancelled()) { ++ this.level().setBlockAndUpdate(blockposition, iblockdata); ++ ++this.blocksSetOnFire; ++ } ++ // CraftBukkit end + } - for (int j = 0; j < i; ++j) { -@@ -173,8 +182,12 @@ + for (int j = 0; j < i; ++j) { +@@ -178,8 +187,12 @@ - iblockdata = BlockFireAbstract.getState(this.level(), blockposition1); - if (this.level().getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level(), blockposition1)) { -- this.level().setBlockAndUpdate(blockposition1, iblockdata); -- ++this.blocksSetOnFire; -+ // CraftBukkit start - add "!visualOnly" -+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition1, this).isCancelled()) { -+ this.level().setBlockAndUpdate(blockposition1, iblockdata); -+ ++this.blocksSetOnFire; -+ } -+ // CraftBukkit end - } - } + iblockdata = BlockFireAbstract.getState(this.level(), blockposition1); + if (this.level().getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level(), blockposition1)) { +- this.level().setBlockAndUpdate(blockposition1, iblockdata); +- ++this.blocksSetOnFire; ++ // CraftBukkit start - add "!visualOnly" ++ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition1, this).isCancelled()) { ++ this.level().setBlockAndUpdate(blockposition1, iblockdata); ++ ++this.blocksSetOnFire; ++ } ++ // CraftBukkit end + } + } -@@ -238,8 +251,9 @@ +@@ -247,8 +260,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 1db9c0fb..730ea72b 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 -@@ -132,6 +132,32 @@ +@@ -137,6 +137,33 @@ import net.minecraft.world.scores.ScoreboardTeam; import org.slf4j.Logger; @@ -8,10 +8,11 @@ +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; -+import com.google.common.base.Function; ++import java.util.LinkedList; +import java.util.UUID; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagInt; ++import net.minecraft.world.item.component.Consumable; +import org.bukkit.Location; +import org.bukkit.craftbukkit.attribute.CraftAttributeMap; +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -33,18 +34,9 @@ public abstract class EntityLiving extends Entity implements Attackable { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -157,7 +183,7 @@ - private static final double MAX_LINE_OF_SIGHT_TEST_RANGE = 128.0D; - protected static final int LIVING_ENTITY_FLAG_IS_USING = 1; - protected static final int LIVING_ENTITY_FLAG_OFF_HAND = 2; -- protected static final int LIVING_ENTITY_FLAG_SPIN_ATTACK = 4; -+ public static final int LIVING_ENTITY_FLAG_SPIN_ATTACK = 4; - protected static final DataWatcherObject DATA_LIVING_ENTITY_FLAGS = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.BYTE); - public static final DataWatcherObject DATA_HEALTH_ID = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.FLOAT); - private static final DataWatcherObject> DATA_EFFECT_PARTICLES = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.PARTICLES); -@@ -249,6 +275,19 @@ +@@ -262,6 +289,19 @@ protected boolean skipDropExperience; - private final Reference2ObjectMap> activeLocationDependentEnchantments; + private final EnumMap>> activeLocationDependentEnchantments; protected float appliedScale; + // CraftBukkit start + public int expToDrop; @@ -62,8 +54,8 @@ protected EntityLiving(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -264,7 +303,9 @@ - this.activeLocationDependentEnchantments = new Reference2ObjectArrayMap(); +@@ -278,7 +318,9 @@ + this.activeLocationDependentEnchantments = new EnumMap(EnumItemSlot.class); this.appliedScale = 1.0F; this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes)); - this.setHealth(this.getMaxHealth()); @@ -73,22 +65,22 @@ this.blocksBuilding = true; this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.reapplyPosition(); -@@ -344,7 +385,13 @@ +@@ -358,7 +400,13 @@ double d8 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d8); -- ((WorldServer) this.level()).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); +- worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + // CraftBukkit start - visiblity api + if (this instanceof EntityPlayer) { -+ ((WorldServer) this.level()).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); ++ worldserver.sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); + } else { -+ ((WorldServer) this.level()).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); ++ worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + } + // CraftBukkit end } } } -@@ -555,7 +602,7 @@ +@@ -573,7 +621,7 @@ ++this.deathTime; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, (byte) 60); @@ -97,7 +89,7 @@ } } -@@ -661,13 +708,19 @@ +@@ -679,13 +727,19 @@ } public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1) { @@ -107,18 +99,18 @@ + + public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1, boolean silent) { + // CraftBukkit end - boolean flag = itemstack1.isEmpty() && itemstack.isEmpty(); + if (!this.level().isClientSide() && !this.isSpectator()) { + boolean flag = itemstack1.isEmpty() && itemstack.isEmpty(); - if (!flag && !ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) { - Equipable equipable = Equipable.get(itemstack1); + if (!flag && !ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) { + Equippable equippable = (Equippable) itemstack1.get(DataComponents.EQUIPPABLE); - if (!this.level().isClientSide() && !this.isSpectator()) { -- if (!this.isSilent() && equipable != null && equipable.getEquipmentSlot() == enumitemslot) { -+ if (!this.isSilent() && equipable != null && equipable.getEquipmentSlot() == enumitemslot && !silent) { // CraftBukkit - this.level().playSeededSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equipable.getEquipSound(), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong()); +- if (!this.isSilent() && equippable != null && enumitemslot == equippable.slot()) { ++ if (!this.isSilent() && equippable != null && enumitemslot == equippable.slot() && !silent) { // CraftBukkit + this.level().playSeededSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equippable.equipSound(), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong()); } -@@ -681,11 +734,18 @@ +@@ -699,6 +753,13 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -130,7 +122,10 @@ + public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) { + // CraftBukkit end if (entity_removalreason == Entity.RemovalReason.KILLED || entity_removalreason == Entity.RemovalReason.DISCARDED) { - this.triggerOnDeathMobEffects(entity_removalreason); + World world = this.level(); + +@@ -709,7 +770,7 @@ + } } - super.remove(entity_removalreason); @@ -138,15 +133,15 @@ this.brain.clearMemories(); } -@@ -698,6 +758,7 @@ - mobeffect.onMobRemoved(this, entity_removalreason); +@@ -722,6 +783,7 @@ + mobeffect.onMobRemoved(worldserver, this, entity_removalreason); } + this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DEATH); // CraftBukkit this.activeEffects.clear(); } -@@ -757,6 +818,17 @@ +@@ -781,6 +843,17 @@ } } @@ -164,7 +159,7 @@ if (nbttagcompound.contains("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -795,9 +867,32 @@ +@@ -819,9 +892,32 @@ } @@ -197,7 +192,7 @@ try { while (iterator.hasNext()) { Holder holder = (Holder) iterator.next(); -@@ -807,6 +902,12 @@ +@@ -831,6 +927,12 @@ this.onEffectUpdated(mobeffect, true, (Entity) null); })) { if (!this.level().isClientSide) { @@ -208,9 +203,9 @@ + } + // CraftBukkit end iterator.remove(); - this.onEffectRemoved(mobeffect); + this.onEffectsRemoved(List.of(mobeffect)); } -@@ -817,6 +918,17 @@ +@@ -841,6 +943,17 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { ; } @@ -228,7 +223,7 @@ if (this.effectsDirty) { if (!this.level().isClientSide) { -@@ -932,7 +1044,13 @@ +@@ -952,17 +1065,36 @@ this.entityData.set(EntityLiving.DATA_EFFECT_PARTICLES, List.of()); } @@ -241,24 +236,35 @@ + // CraftBukkit end if (this.level().isClientSide) { return false; + } else if (this.activeEffects.isEmpty()) { + return false; } else { -@@ -941,7 +1059,14 @@ - boolean flag; +- Map, MobEffect> map = Maps.newHashMap(this.activeEffects); ++ // CraftBukkit start ++ List toRemove = new LinkedList<>(); ++ Iterator iterator = this.activeEffects.values().iterator(); - for (flag = false; iterator.hasNext(); flag = true) { -- this.onEffectRemoved((MobEffect) iterator.next()); -+ // CraftBukkit start -+ MobEffect effect = (MobEffect) iterator.next(); +- this.activeEffects.clear(); +- this.onEffectsRemoved(map.values()); +- return true; ++ while (iterator.hasNext()) { ++ MobEffect effect = iterator.next(); + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED); + if (event.isCancelled()) { + continue; + } -+ this.onEffectRemoved(effect); -+ // CraftBukkit end - iterator.remove(); - } ++ ++ iterator.remove(); ++ toRemove.add(effect); ++ } ++ ++ this.onEffectsRemoved(toRemove); ++ return !toRemove.isEmpty(); ++ // CraftBukkit end + } + } -@@ -970,20 +1095,50 @@ +@@ -987,20 +1119,50 @@ return this.addEffect(mobeffect, (Entity) null); } @@ -310,7 +316,7 @@ flag = true; } -@@ -1014,13 +1169,39 @@ +@@ -1031,13 +1193,39 @@ return this.getType().is(TagsEntity.INVERTED_HEALING_AND_HARM); } @@ -350,8 +356,8 @@ + // CraftBukkit end if (mobeffect != null) { - this.onEffectRemoved(mobeffect); -@@ -1118,20 +1299,55 @@ + this.onEffectsRemoved(List.of(mobeffect)); +@@ -1142,20 +1330,55 @@ } @@ -408,18 +414,18 @@ this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth())); } -@@ -1145,7 +1361,7 @@ - return false; - } else if (this.level().isClientSide) { +@@ -1167,7 +1390,7 @@ + public boolean hurtServer(WorldServer worldserver, DamageSource damagesource, float f) { + if (this.isInvulnerableTo(worldserver, damagesource)) { return false; - } else if (this.isDeadOrDying()) { + } else if (this.isRemoved() || this.dead || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die return false; } else if (damagesource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1156,10 +1372,11 @@ +@@ -1182,10 +1405,11 @@ + } - this.noActionTime = 0; float f1 = f; - boolean flag = false; + boolean flag = f > 0.0F && this.isDamageSourceBlocked(damagesource); // Copied from below @@ -431,7 +437,7 @@ this.hurtCurrentlyUsedShield(f); f2 = f; f = 0.0F; -@@ -1176,30 +1393,50 @@ +@@ -1202,15 +1426,26 @@ flag = true; } @@ -458,6 +464,10 @@ + // CraftBukkit end + this.walkAnimation.setSpeed(1.5F); + if (Float.isNaN(f) || Float.isInfinite(f)) { + f = Float.MAX_VALUE; +@@ -1218,18 +1453,27 @@ + boolean flag1 = true; - if ((float) this.invulnerableTime > 10.0F && !damagesource.is(DamageTypeTags.BYPASSES_COOLDOWN)) { @@ -466,9 +476,9 @@ return false; } -- this.actuallyHurt(damagesource, f - this.lastHurt); +- this.actuallyHurt(worldserver, damagesource, f - this.lastHurt); + // CraftBukkit start -+ if (!this.actuallyHurt(damagesource, (float) event.getFinalDamage() - this.lastHurt, event)) { ++ if (!this.actuallyHurt(worldserver, damagesource, (float) event.getFinalDamage() - this.lastHurt, event)) { + return false; + } + // CraftBukkit end @@ -476,20 +486,20 @@ flag1 = false; } else { + // CraftBukkit start -+ if (!this.actuallyHurt(damagesource, (float) event.getFinalDamage(), event)) { ++ if (!this.actuallyHurt(worldserver, damagesource, (float) event.getFinalDamage(), event)) { + return false; + } this.lastHurt = f; - this.invulnerableTime = 20; -- this.actuallyHurt(damagesource, f); +- this.actuallyHurt(worldserver, damagesource, f); + this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks -+ // this.actuallyHurt(damagesource, f); ++ // this.actuallyHurt(worldserver, damagesource, f); + // CraftBukkit end this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1245,7 +1482,7 @@ - this.level().broadcastDamageEvent(this, damagesource); +@@ -1275,7 +1519,7 @@ + worldserver.broadcastDamageEvent(this, damagesource); } - if (!damagesource.is(DamageTypeTags.NO_IMPACT) && (!flag || f > 0.0F)) { @@ -497,7 +507,7 @@ this.markHurt(); } -@@ -1265,7 +1502,7 @@ +@@ -1295,7 +1539,7 @@ d1 = damagesource.getSourcePosition().z() - this.getZ(); } @@ -506,7 +516,7 @@ if (!flag) { this.indicateDamage(d0, d1); } -@@ -1284,7 +1521,7 @@ +@@ -1314,7 +1558,7 @@ this.playHurtSound(damagesource); } @@ -515,7 +525,7 @@ if (flag2) { this.lastDamageSource = damagesource; -@@ -1318,7 +1555,7 @@ +@@ -1352,7 +1596,7 @@ } protected void blockedByShield(EntityLiving entityliving) { @@ -524,7 +534,7 @@ } private boolean checkTotemDeathProtection(DamageSource damagesource) { -@@ -1329,19 +1566,32 @@ +@@ -1364,20 +1608,33 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; @@ -536,7 +546,8 @@ - ItemStack itemstack1 = this.getItemInHand(enumhand); + itemstack1 = this.getItemInHand(enumhand); - if (itemstack1.is(Items.TOTEM_OF_UNDYING)) { + deathprotection = (DeathProtection) itemstack1.get(DataComponents.DEATH_PROTECTION); + if (deathprotection != null) { + hand = enumhand; // CraftBukkit itemstack = itemstack1.copy(); - itemstack1.shrink(1); @@ -560,30 +571,8 @@ + // CraftBukkit end EntityPlayer entityplayer = (EntityPlayer) this; - entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING)); -@@ -1350,14 +1600,16 @@ - } - - this.setHealth(1.0F); -- this.removeAllEffects(); -- this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1)); -- this.addEffect(new MobEffect(MobEffects.ABSORPTION, 100, 1)); -- this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0)); -+ // CraftBukkit start -+ this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); -+ this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); -+ this.addEffect(new MobEffect(MobEffects.ABSORPTION, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); -+ this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); -+ // CraftBukkit end - this.level().broadcastEntityEvent(this, (byte) 35); - } - -- return itemstack != null; -+ return !event.isCancelled(); - } - } - -@@ -1464,14 +1716,22 @@ + entityplayer.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem())); +@@ -1501,14 +1758,22 @@ IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { @@ -608,13 +597,13 @@ this.level().addFreshEntity(entityitem); } } -@@ -1482,26 +1742,41 @@ +@@ -1519,22 +1784,37 @@ protected void dropAllDeathLoot(WorldServer worldserver, DamageSource damagesource) { boolean flag = this.lastHurtByPlayerTime > 0; -+ this.dropEquipment(); // CraftBukkit - from below ++ this.dropEquipment(worldserver); // CraftBukkit - from below if (this.shouldDropLoot() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - this.dropFromLootTable(damagesource, flag); + this.dropFromLootTable(worldserver, damagesource, flag); this.dropCustomDeathLoot(worldserver, damagesource, flag); } + // CraftBukkit start - Call death event @@ -622,38 +611,34 @@ + this.drops = new ArrayList<>(); + // CraftBukkit end -- this.dropEquipment(); -+ // this.dropEquipment();// CraftBukkit - moved up - this.dropExperience(damagesource.getEntity()); +- this.dropEquipment(worldserver); ++ // this.dropEquipment(worldserver);// CraftBukkit - moved up + this.dropExperience(worldserver, damagesource.getEntity()); } - protected void dropEquipment() {} + protected void dropEquipment(WorldServer worldserver) {} -- protected void dropExperience(@Nullable Entity entity) { -+ public int getExpReward(@Nullable Entity entity) { // CraftBukkit - World world = this.level(); - - if (world instanceof WorldServer worldserver) { - if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { -- EntityExperienceOrb.award(worldserver, this.position(), this.getExperienceReward(worldserver, entity)); -+ return this.getExperienceReward(worldserver, entity); // CraftBukkit - } +- protected void dropExperience(WorldServer worldserver, @Nullable Entity entity) { ++ public int getExpReward(WorldServer worldserver, @Nullable Entity entity) { // CraftBukkit + if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { +- EntityExperienceOrb.award(worldserver, this.position(), this.getExperienceReward(worldserver, entity)); ++ return this.getExperienceReward(worldserver, entity); // CraftBukkit } } + return 0; // CraftBukkit + } + -+ protected void dropExperience(@Nullable Entity entity) { ++ protected void dropExperience(WorldServer worldserver, @Nullable Entity entity) { + // CraftBukkit start - Update getExpReward() above if the removed if() changes! + if (!(this instanceof net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time -+ EntityExperienceOrb.award((WorldServer) this.level(), this.position(), this.expToDrop); ++ EntityExperienceOrb.award(worldserver, this.position(), this.expToDrop); + this.expToDrop = 0; + } + // CraftBukkit end } protected void dropCustomDeathLoot(WorldServer worldserver, DamageSource damagesource, boolean flag) {} -@@ -1540,9 +1815,14 @@ +@@ -1601,9 +1881,14 @@ } public void knockback(double d0, double d1, double d2) { @@ -670,7 +655,7 @@ Vec3D vec3d; -@@ -1552,7 +1832,14 @@ +@@ -1613,7 +1898,14 @@ Vec3D vec3d1 = (new Vec3D(d1, 0.0D, d2)).normalize().scale(d0); @@ -686,8 +671,8 @@ } } -@@ -1613,6 +1900,28 @@ - return itemstack.getEatingSound(); +@@ -1668,6 +1960,20 @@ + return new EntityLiving.a(SoundEffects.GENERIC_SMALL_FALL, SoundEffects.GENERIC_BIG_FALL); } + // CraftBukkit start - Add delegate methods @@ -702,25 +687,17 @@ + public SoundEffect getFallDamageSound0(int fallHeight) { + return getFallDamageSound(fallHeight); + } -+ -+ public SoundEffect getDrinkingSound0(ItemStack itemstack) { -+ return getDrinkingSound(itemstack); -+ } -+ -+ public SoundEffect getEatingSound0(ItemStack itemstack) { -+ return getEatingSound(itemstack); -+ } + // CraftBukkit end + public Optional getLastClimbablePos() { return this.lastClimbablePos; } -@@ -1666,9 +1975,14 @@ +@@ -1746,9 +2052,14 @@ int i = this.calculateFallDamage(f, f1); if (i > 0) { + // CraftBukkit start -+ if (!this.hurt(damagesource, (float) i)) { ++ if (!this.hurtServer((WorldServer) this.level(), damagesource, (float) i)) { + return true; + } + // CraftBukkit end @@ -731,7 +708,7 @@ return true; } else { return flag; -@@ -1738,7 +2052,7 @@ +@@ -1819,7 +2130,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) { if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -740,7 +717,7 @@ f = CombatMath.getDamageAfterAbsorb(this, f, damagesource, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1749,7 +2063,8 @@ +@@ -1830,7 +2141,8 @@ if (damagesource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return f; } else { @@ -750,16 +727,16 @@ int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1792,15 +2107,140 @@ +@@ -1873,15 +2185,140 @@ } } -- protected void actuallyHurt(DamageSource damagesource, float f) { +- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) { + // CraftBukkit start + private EntityDamageEvent handleEntityDamage(final DamageSource damagesource, float f) { + float originalDamage = f; + -+ Function freezing = new Function() { ++ com.google.common.base.Function freezing = new com.google.common.base.Function() { + @Override + public Double apply(Double f) { + if (damagesource.is(DamageTypeTags.IS_FREEZING) && EntityLiving.this.getType().is(TagsEntity.FREEZE_HURTS_EXTRA_TYPES)) { @@ -771,7 +748,7 @@ + float freezingModifier = freezing.apply((double) f).floatValue(); + f += freezingModifier; + -+ Function hardHat = new Function() { ++ com.google.common.base.Function hardHat = new com.google.common.base.Function() { + @Override + public Double apply(Double f) { + if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !EntityLiving.this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { @@ -783,7 +760,7 @@ + float hardHatModifier = hardHat.apply((double) f).floatValue(); + f += hardHatModifier; + -+ Function blocking = new Function() { ++ com.google.common.base.Function blocking = new com.google.common.base.Function() { + @Override + public Double apply(Double f) { + return -((EntityLiving.this.isDamageSourceBlocked(damagesource)) ? f : 0.0); @@ -792,7 +769,7 @@ + float blockingModifier = blocking.apply((double) f).floatValue(); + f += blockingModifier; + -+ Function armor = new Function() { ++ com.google.common.base.Function armor = new com.google.common.base.Function() { + @Override + public Double apply(Double f) { + return -(f - EntityLiving.this.getDamageAfterArmorAbsorb(damagesource, f.floatValue())); @@ -801,7 +778,7 @@ + float armorModifier = armor.apply((double) f).floatValue(); + f += armorModifier; + -+ Function resistance = new Function() { ++ com.google.common.base.Function resistance = new com.google.common.base.Function() { + @Override + public Double apply(Double f) { + if (!damagesource.is(DamageTypeTags.BYPASSES_EFFECTS) && EntityLiving.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { @@ -816,7 +793,7 @@ + float resistanceModifier = resistance.apply((double) f).floatValue(); + f += resistanceModifier; + -+ Function magic = new Function() { ++ com.google.common.base.Function magic = new com.google.common.base.Function() { + @Override + public Double apply(Double f) { + return -(f - EntityLiving.this.getDamageAfterMagicAbsorb(damagesource, f.floatValue())); @@ -825,7 +802,7 @@ + float magicModifier = magic.apply((double) f).floatValue(); + f += magicModifier; + -+ Function absorption = new Function() { ++ com.google.common.base.Function absorption = new com.google.common.base.Function() { + @Override + public Double apply(Double f) { + return -(Math.max(f - Math.max(f - EntityLiving.this.getAbsorptionAmount(), 0.0F), 0.0F)); @@ -836,8 +813,8 @@ + return CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, freezingModifier, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, freezing, hardHat, blocking, armor, resistance, magic, absorption); + } + -+ protected boolean actuallyHurt(final DamageSource damagesource, float f, final EntityDamageEvent event) { // void -> boolean, add final - if (!this.isInvulnerableTo(damagesource)) { ++ protected boolean actuallyHurt(WorldServer worldserver, final DamageSource damagesource, float f, final EntityDamageEvent event) { // void -> boolean, add final + if (!this.isInvulnerableTo(worldserver, damagesource)) { - f = this.getDamageAfterArmorAbsorb(damagesource, f); - f = this.getDamageAfterMagicAbsorb(damagesource, f); - float f1 = f; @@ -898,7 +875,7 @@ if (f2 > 0.0F && f2 < 3.4028235E37F) { Entity entity = damagesource.getEntity(); -@@ -1812,13 +2252,48 @@ +@@ -1893,13 +2330,48 @@ } } @@ -949,7 +926,7 @@ } public CombatTracker getCombatTracker() { -@@ -1843,9 +2318,19 @@ +@@ -1924,9 +2396,19 @@ } public final void setArrowCount(int i) { @@ -970,7 +947,7 @@ public final int getStingerCount() { return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID); } -@@ -2086,6 +2571,12 @@ +@@ -2171,6 +2653,12 @@ public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot); @@ -983,15 +960,7 @@ public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack); public Iterable getHandSlots() { -@@ -2336,6 +2827,7 @@ - } - - if (this.onGround() && !this.level().isClientSide) { -+ if (getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit - this.setSharedFlag(7, false); - } - } else { -@@ -2506,7 +2998,7 @@ +@@ -2623,7 +3111,7 @@ } } @@ -1000,8 +969,8 @@ if (this.tickCount % 20 == 0) { this.getCombatTracker().recheckStatus(); } -@@ -2610,7 +3102,7 @@ - +@@ -2730,7 +3218,7 @@ + this.elytraAnimationState.tick(); } - public void detectEquipmentUpdates() { @@ -1009,15 +978,15 @@ Map map = this.collectEquipmentChanges(); if (map != null) { -@@ -2949,6 +3441,7 @@ - } - +@@ -3052,6 +3540,7 @@ + this.checkSlowFallDistance(); if (!this.level().isClientSide) { -+ if (flag != this.getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit - this.setSharedFlag(7, flag); - } - -@@ -3141,13 +3634,20 @@ + if (!this.canGlide()) { ++ if (this.getSharedFlag(7) != false && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit + this.setSharedFlag(7, false); + return; + } +@@ -3298,14 +3787,21 @@ @Override public boolean isPickable() { @@ -1029,30 +998,22 @@ public boolean isPushable() { - return this.isAlive() && !this.isSpectator() && !this.onClimbable(); + return this.isAlive() && !this.isSpectator() && !this.onClimbable() && this.collides; // CraftBukkit -+ } -+ + } + + // CraftBukkit start - collidable API + @Override + public boolean canCollideWithBukkit(Entity entity) { + return isPushable() && this.collides != this.collidableExemptions.contains(entity.getUUID()); - } ++ } + // CraftBukkit end - ++ @Override public float getYHeadRot() { -@@ -3245,7 +3745,7 @@ - - } - -- protected void setLivingEntityFlag(int i, boolean flag) { -+ public void setLivingEntityFlag(int i, boolean flag) { - int j = (Byte) this.entityData.get(EntityLiving.DATA_LIVING_ENTITY_FLAGS); - - if (flag) { -@@ -3346,7 +3846,29 @@ + return this.yHeadRot; +@@ -3476,7 +3972,30 @@ + this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { - this.triggerItemUseEffects(this.useItem, 16); - ItemStack itemstack = this.useItem.finishUsingItem(this.level(), this); + // CraftBukkit start - fire PlayerItemConsumeEvent + ItemStack itemstack; @@ -1064,8 +1025,9 @@ + + if (event.isCancelled()) { + // Update client -+ if (this.useItem.getItem() instanceof net.minecraft.world.item.ItemSuspiciousStew itemSuspiciousStew) { -+ itemSuspiciousStew.cancelUsingItem(entityPlayer, this.useItem); ++ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE); ++ if (consumable != null) { ++ consumable.cancelUsingItem(entityPlayer, this.useItem); + } + entityPlayer.getBukkitEntity().updateInventory(); + entityPlayer.getBukkitEntity().updateScaledHealth(); @@ -1080,7 +1042,7 @@ if (itemstack != this.useItem) { this.setItemInHand(enumhand, itemstack); -@@ -3424,6 +3946,12 @@ +@@ -3561,6 +4080,12 @@ } public boolean randomTeleport(double d0, double d1, double d2, boolean flag) { @@ -1093,7 +1055,7 @@ double d3 = this.getX(); double d4 = this.getY(); double d5 = this.getZ(); -@@ -3448,16 +3976,41 @@ +@@ -3585,16 +4110,41 @@ } if (flag2) { @@ -1121,7 +1083,7 @@ + } + } else { + // player teleport event is called in the underlining code -+ if (!((EntityPlayer) this).connection.teleport(d0, d6, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), cause)) { ++ if (!((EntityPlayer) this).connection.teleport(d0, d6, d2, this.getYRot(), this.getXRot(), cause)) { + return Optional.empty(); + } + } @@ -1138,7 +1100,7 @@ } else { if (flag) { world.broadcastEntityEvent(this, (byte) 46); -@@ -3469,7 +4022,7 @@ +@@ -3606,7 +4156,7 @@ entitycreature.getNavigation().stop(); } @@ -1147,7 +1109,7 @@ } } -@@ -3562,7 +4115,7 @@ +@@ -3699,7 +4249,7 @@ } public void stopSleeping() { @@ -1156,7 +1118,7 @@ World world = this.level(); java.util.Objects.requireNonNull(world); -@@ -3596,7 +4149,7 @@ +@@ -3733,7 +4283,7 @@ @Nullable public EnumDirection getBedOrientation() { @@ -1165,12 +1127,3 @@ return blockposition != null ? BlockBed.getBedOrientation(this.level(), blockposition) : null; } -@@ -3633,7 +4186,7 @@ - FoodInfo.b foodinfo_b = (FoodInfo.b) iterator.next(); - - if (this.random.nextFloat() < foodinfo_b.probability()) { -- this.addEffect(foodinfo_b.effect()); -+ this.addEffect(foodinfo_b.effect(), EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit - } - } - diff --git a/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch b/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch index cd568c29..c7f83229 100644 --- a/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch +++ b/nms-patches/net/minecraft/world/entity/EntityTameableAnimal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityTameableAnimal.java +++ b/net/minecraft/world/entity/EntityTameableAnimal.java -@@ -27,6 +27,12 @@ +@@ -28,6 +28,12 @@ import net.minecraft.world.level.pathfinder.PathfinderNormal; import net.minecraft.world.scores.ScoreboardTeam; @@ -13,7 +13,7 @@ public abstract class EntityTameableAnimal extends EntityAnimal implements OwnableEntity { public static final int TELEPORT_WHEN_DISTANCE_IS_SQ = 144; -@@ -281,7 +287,14 @@ +@@ -292,7 +298,14 @@ if (!this.canTeleportTo(new BlockPosition(i, j, k))) { return false; } else { diff --git a/nms-patches/net/minecraft/world/entity/EntityTypes.patch b/nms-patches/net/minecraft/world/entity/EntityTypes.patch index fc45d0b2..a57f473f 100644 --- a/nms-patches/net/minecraft/world/entity/EntityTypes.patch +++ b/nms-patches/net/minecraft/world/entity/EntityTypes.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityTypes.java +++ b/net/minecraft/world/entity/EntityTypes.java -@@ -168,6 +168,7 @@ +@@ -176,6 +176,7 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -8,83 +8,81 @@ import org.slf4j.Logger; public class EntityTypes implements FeatureElement, EntityTypeTest { -@@ -177,7 +178,7 @@ - private static final float MAGIC_HORSE_WIDTH = 1.3964844F; - private static final int DISPLAY_TRACKING_RANGE = 10; +@@ -191,7 +192,7 @@ + return Items.ACACIA_CHEST_BOAT; + }), EnumCreatureType.MISC).noLootTable().sized(1.375F, 0.5625F).eyeHeight(0.5625F).clientTrackingRange(10)); public static final EntityTypes ALLAY = register("allay", EntityTypes.Builder.of(Allay::new, EnumCreatureType.CREATURE).sized(0.35F, 0.6F).eyeHeight(0.36F).ridingOffset(0.04F).clientTrackingRange(8).updateInterval(2)); -- public static final EntityTypes AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE)); -+ public static final EntityTypes AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds +- public static final EntityTypes AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).noLootTable().fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE)); ++ public static final EntityTypes AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).noLootTable().fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds public static final EntityTypes ARMADILLO = register("armadillo", EntityTypes.Builder.of(Armadillo::new, EnumCreatureType.CREATURE).sized(0.7F, 0.65F).eyeHeight(0.26F).clientTrackingRange(10)); public static final EntityTypes ARMOR_STAND = register("armor_stand", EntityTypes.Builder.of(EntityArmorStand::new, EnumCreatureType.MISC).sized(0.5F, 1.975F).eyeHeight(1.7775F).clientTrackingRange(10)); - public static final EntityTypes ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).sized(0.5F, 0.5F).eyeHeight(0.13F).clientTrackingRange(4).updateInterval(20)); -@@ -325,8 +326,8 @@ - private final float spawnDimensionsScale; - private final FeatureFlagSet requiredFeatures; + public static final EntityTypes ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).noLootTable().sized(0.5F, 0.5F).eyeHeight(0.13F).clientTrackingRange(4).updateInterval(20)); +@@ -399,7 +400,7 @@ + return ResourceKey.create(Registries.ENTITY_TYPE, MinecraftKey.withDefaultNamespace(s)); + } - private static EntityTypes register(String s, EntityTypes.Builder entitytypes_builder) { -- 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(BuiltInRegistries.ENTITY_TYPE, s, (EntityTypes) entitytypes_builder.build(s)); // CraftBukkit - decompile error + return register(vanillaEntityId(s), entitytypes_builder); } - public static MinecraftKey getKey(EntityTypes entitytypes) { -@@ -355,7 +356,14 @@ +@@ -431,7 +432,14 @@ @Nullable - public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { + public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1) { - Consumer consumer; + // CraftBukkit start -+ return this.spawn(worldserver, itemstack, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); ++ return this.spawn(worldserver, itemstack, entityhuman, blockposition, entityspawnreason, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); + } + + @Nullable -+ 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) { ++ public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end + Consumer consumer; // CraftBukkit - decompile error if (itemstack != null) { consumer = createDefaultStackConfig(worldserver, itemstack, entityhuman); -@@ -364,7 +372,7 @@ +@@ -440,7 +448,7 @@ }; } -- return this.spawn(worldserver, consumer, blockposition, enummobspawn, flag, flag1); -+ return this.spawn(worldserver, consumer, blockposition, enummobspawn, flag, flag1, spawnReason); // CraftBukkit +- return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1); ++ return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1, spawnReason); // CraftBukkit } - public static Consumer createDefaultStackConfig(WorldServer worldserver, ItemStack itemstack, @Nullable EntityHuman entityhuman) { -@@ -388,21 +396,37 @@ + public static Consumer createDefaultStackConfig(World world, ItemStack itemstack, @Nullable EntityHuman entityhuman) { +@@ -464,21 +472,37 @@ CustomData customdata = (CustomData) itemstack.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY); return !customdata.isEmpty() ? consumer.andThen((entity) -> { -- updateCustomEntityTag(worldserver, entityhuman, entity, customdata); -+ try { updateCustomEntityTag(worldserver, entityhuman, entity, customdata); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665 +- updateCustomEntityTag(world, entityhuman, entity, customdata); ++ try { updateCustomEntityTag(world, entityhuman, entity, customdata); } 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, (Consumer) null, blockposition, enummobspawn, false, false); + public T spawn(WorldServer worldserver, BlockPosition blockposition, EntitySpawnReason entityspawnreason) { +- return this.spawn(worldserver, (Consumer) null, blockposition, entityspawnreason, false, false); + // CraftBukkit start -+ return this.spawn(worldserver, blockposition, enummobspawn, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return this.spawn(worldserver, blockposition, entityspawnreason, 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, (Consumer) null, blockposition, enummobspawn, false, false, spawnReason); // CraftBukkit - decompile error ++ public T spawn(WorldServer worldserver, BlockPosition blockposition, EntitySpawnReason entityspawnreason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { ++ return this.spawn(worldserver, (Consumer) null, blockposition, entityspawnreason, false, false, spawnReason); // CraftBukkit - decompile error + // CraftBukkit end } @Nullable - public T spawn(WorldServer worldserver, @Nullable Consumer consumer, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { + public T spawn(WorldServer worldserver, @Nullable Consumer consumer, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1) { + // CraftBukkit start -+ return this.spawn(worldserver, consumer, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + + @Nullable -+ public T spawn(WorldServer worldserver, @Nullable Consumer consumer, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { ++ public T spawn(WorldServer worldserver, @Nullable Consumer consumer, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end - T t0 = this.create(worldserver, consumer, blockposition, enummobspawn, flag, flag1); + T t0 = this.create(worldserver, consumer, blockposition, entityspawnreason, flag, flag1); if (t0 != null) { - worldserver.addFreshEntityWithPassengers(t0); @@ -94,7 +92,7 @@ } return t0; -@@ -583,7 +607,7 @@ +@@ -649,7 +673,7 @@ } return entity; @@ -102,8 +100,8 @@ + }).orElse(null); // CraftBukkit - decompile error } - public static Stream loadEntitiesRecursive(final List list, final World world) { -@@ -644,7 +668,7 @@ + public static Stream loadEntitiesRecursive(final List list, final World world, final EntitySpawnReason entityspawnreason) { +@@ -710,7 +734,7 @@ @Nullable public T tryCast(Entity entity) { @@ -112,7 +110,7 @@ } @Override -@@ -681,7 +705,7 @@ +@@ -779,7 +803,7 @@ this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; } diff --git a/nms-patches/net/minecraft/world/entity/IEntitySelector.patch b/nms-patches/net/minecraft/world/entity/IEntitySelector.patch index 625f1d6c..35099c5a 100644 --- a/nms-patches/net/minecraft/world/entity/IEntitySelector.patch +++ b/nms-patches/net/minecraft/world/entity/IEntitySelector.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/IEntitySelector.java +++ b/net/minecraft/world/entity/IEntitySelector.java -@@ -44,7 +44,7 @@ +@@ -43,7 +43,7 @@ ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteam == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteam.getCollisionRule(); return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.NO_SPECTATORS.and((entity1) -> { diff --git a/nms-patches/net/minecraft/world/entity/Interaction.patch b/nms-patches/net/minecraft/world/entity/Interaction.patch index 230f95fb..69b475e8 100644 --- a/nms-patches/net/minecraft/world/entity/Interaction.patch +++ b/nms-patches/net/minecraft/world/entity/Interaction.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Interaction.java +++ b/net/minecraft/world/entity/Interaction.java -@@ -24,6 +24,12 @@ +@@ -26,6 +26,12 @@ import net.minecraft.world.phys.AxisAlignedBB; import org.slf4j.Logger; @@ -13,7 +13,7 @@ public class Interaction extends Entity implements Attackable, Targeting { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -62,7 +68,7 @@ +@@ -64,7 +70,7 @@ this.setHeight(nbttagcompound.getFloat("height")); } @@ -22,7 +22,7 @@ Logger logger; if (nbttagcompound.contains("attack")) { -@@ -142,9 +148,16 @@ +@@ -144,9 +150,16 @@ @Override public boolean skipAttackInteraction(Entity entity) { if (entity instanceof EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/entity/Leashable.patch b/nms-patches/net/minecraft/world/entity/Leashable.patch index 16295d0a..770872a7 100644 --- a/nms-patches/net/minecraft/world/entity/Leashable.patch +++ b/nms-patches/net/minecraft/world/entity/Leashable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Leashable.java +++ b/net/minecraft/world/entity/Leashable.java -@@ -15,6 +15,11 @@ +@@ -16,6 +16,11 @@ import net.minecraft.world.level.IMaterial; import net.minecraft.world.level.World; @@ -12,7 +12,7 @@ public interface Leashable { String LEASH_TAG = "leash"; -@@ -44,7 +49,7 @@ +@@ -45,7 +50,7 @@ default void setDelayedLeashHolderId(int i) { this.setLeashData(new Leashable.a(i)); @@ -21,7 +21,7 @@ } @Nullable -@@ -53,7 +58,7 @@ +@@ -54,7 +59,7 @@ return new Leashable.a(Either.left(nbttagcompound.getCompound("leash").getUUID("UUID"))); } else { if (nbttagcompound.contains("leash", 11)) { @@ -30,7 +30,7 @@ if (either != null) { return new Leashable.a(either); -@@ -68,6 +73,11 @@ +@@ -69,6 +74,11 @@ if (leashable_a != null) { Either either = leashable_a.delayedLeashInfo; Entity entity = leashable_a.leashHolder; @@ -42,17 +42,17 @@ if (entity instanceof EntityLeash) { EntityLeash entityleash = (EntityLeash) entity; -@@ -110,7 +120,9 @@ +@@ -111,7 +121,9 @@ } if (e0.tickCount > 100) { + e0.forceDrops = true; // CraftBukkit - e0.spawnAtLocation((IMaterial) Items.LEAD); + e0.spawnAtLocation(worldserver, (IMaterial) Items.LEAD); + e0.forceDrops = false; // CraftBukkit ((Leashable) e0).setLeashData((Leashable.a) null); } } -@@ -119,7 +131,7 @@ +@@ -120,7 +132,7 @@ } default void dropLeash(boolean flag, boolean flag1) { @@ -61,27 +61,27 @@ } private static void dropLeash(E e0, boolean flag, boolean flag1) { -@@ -128,7 +140,9 @@ - if (leashable_a != null && leashable_a.leashHolder != null) { - ((Leashable) e0).setLeashData((Leashable.a) null); - if (!e0.level().isClientSide && flag1) { -+ e0.forceDrops = true; // CraftBukkit - e0.spawnAtLocation((IMaterial) Items.LEAD); -+ e0.forceDrops = false; // CraftBukkit - } +@@ -134,7 +146,9 @@ + WorldServer worldserver = (WorldServer) world; + + if (flag1) { ++ e0.forceDrops = true; // CraftBukkit + e0.spawnAtLocation(worldserver, (IMaterial) Items.LEAD); ++ e0.forceDrops = false; // CraftBukkit + } - if (flag) { -@@ -153,7 +167,8 @@ + if (flag) { +@@ -154,7 +168,8 @@ if (leashable_a != null && leashable_a.leashHolder != null) { if (!e0.isAlive() || !leashable_a.leashHolder.isAlive()) { -- dropLeash(e0, true, true); -+ e0.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(e0.getBukkitEntity(), (!e0.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit -+ dropLeash(e0, true, !e0.pluginRemoved); // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin +- dropLeash(e0, true, worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)); ++ worldserver.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(e0.getBukkitEntity(), (!e0.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit ++ dropLeash(e0, true, worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !e0.pluginRemoved); // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin } Entity entity = ((Leashable) e0).getLeashHolder(); -@@ -183,13 +198,18 @@ +@@ -184,13 +199,18 @@ } default void leashTooFarBehaviour() { @@ -101,7 +101,7 @@ } private static void legacyElasticRangeLeashBehaviour(E e0, Entity entity, float f) { -@@ -201,7 +221,7 @@ +@@ -202,7 +222,7 @@ } default void setLeashedTo(Entity entity, boolean flag) { @@ -110,7 +110,7 @@ } private static void setLeashedTo(E e0, Entity entity, boolean flag) { -@@ -232,7 +252,7 @@ +@@ -233,7 +253,7 @@ @Nullable default Entity getLeashHolder() { 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 68f2b43b..7952cb5e 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.java -@@ -8,6 +8,12 @@ +@@ -7,6 +7,12 @@ import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder; import net.minecraft.world.entity.ai.memory.MemoryModuleType; @@ -13,8 +13,8 @@ public class BehaviorAttackTargetForget { private static final int TIMEOUT_TO_GET_WITHIN_ATTACK_RANGE = 200; -@@ -41,6 +47,17 @@ - if (entityinsentient.canAttack(entityliving) && (!flag || !isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) && entityliving.isAlive() && entityliving.level() == entityinsentient.level() && !predicate.test(entityliving)) { +@@ -40,6 +46,17 @@ + if (entityinsentient.canAttack(entityliving) && (!flag || !isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) && entityliving.isAlive() && entityliving.level() == entityinsentient.level() && !behaviorattacktargetforget_a.test(worldserver, entityliving)) { return true; } else { + // CraftBukkit start @@ -28,6 +28,6 @@ + return true; + } + // CraftBukkit end - biconsumer.accept(entityinsentient, entityliving); + behaviorattacktargetforget_b.accept(worldserver, 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 774133bc..51929e40 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.java -@@ -8,6 +8,13 @@ +@@ -7,6 +7,13 @@ import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder; import net.minecraft.world.entity.ai.memory.MemoryModuleType; @@ -14,7 +14,7 @@ public class BehaviorAttackTargetSet { public BehaviorAttackTargetSet() {} -@@ -35,6 +42,17 @@ +@@ -34,6 +41,17 @@ if (!entityinsentient.canAttack(entityliving)) { return false; } else { 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 de85cbfe..bc34f917 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFindAdmirableItem.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/BehaviorFindAdmirableItem.patch @@ -3,7 +3,7 @@ @@ -28,6 +28,20 @@ EntityItem entityitem = (EntityItem) behaviorbuilder_b.get(memoryaccessor2); - if (behaviorbuilder_b.tryGet(memoryaccessor3).isEmpty() && predicate.test(entityliving) && entityitem.closerThan(entityliving, (double) i) && entityliving.level().getWorldBorder().isWithinBounds(entityitem.blockPosition())) { + if (behaviorbuilder_b.tryGet(memoryaccessor3).isEmpty() && predicate.test(entityliving) && entityitem.closerThan(entityliving, (double) i) && entityliving.level().getWorldBorder().isWithinBounds(entityitem.blockPosition()) && entityliving.canPickUpLoot()) { + // 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); 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 822fafa2..eed68fa4 100644 --- a/nms-patches/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.patch @@ -15,7 +15,7 @@ public static final int TIME_OUT_DURATION = 160; @@ -63,6 +70,13 @@ - return this.ramTargeting.test(entitycreature, entityliving); + return this.ramTargeting.test(worldserver, entitycreature, entityliving); }); }).ifPresent((entityliving) -> { + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch index 2a6ba8eb..c4a2f98f 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java -@@ -71,6 +71,12 @@ +@@ -72,6 +72,12 @@ } if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level().getDifficulty())) { diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch index 169dd130..34b12bbc 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.patch @@ -15,8 +15,8 @@ BlockPosition blockposition = this.mob.blockPosition(); if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) { -- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit +- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit this.level.destroyBlock(blockposition, false); } @@ -24,8 +24,8 @@ BlockPosition blockposition1 = blockposition.below(); if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) { -- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit +- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit this.level.levelEvent(2001, blockposition1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); this.level.setBlock(blockposition1, Blocks.DIRT.defaultBlockState(), 2); } diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch index 060e8905..b0ee5531 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.java -@@ -21,6 +21,11 @@ +@@ -22,6 +22,11 @@ import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraft.world.phys.Vec3D; @@ -12,7 +12,7 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget { private final Block blockToRemove; -@@ -96,6 +101,11 @@ +@@ -97,6 +102,11 @@ } if (this.ticksSinceReachedGoal > 60) { diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch index f47a666e..bff667ef 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java -@@ -10,6 +10,13 @@ +@@ -11,6 +11,13 @@ import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; @@ -13,8 +13,8 @@ + public class PathfinderGoalTempt extends PathfinderGoal { - private static final PathfinderTargetCondition TEMP_TARGETING = PathfinderTargetCondition.forNonCombat().range(10.0D).ignoreLineOfSight(); -@@ -22,7 +29,7 @@ + private static final PathfinderTargetCondition TEMPT_TARGETING = PathfinderTargetCondition.forNonCombat().ignoreLineOfSight(); +@@ -23,7 +30,7 @@ private double pRotX; private double pRotY; @Nullable @@ -23,10 +23,10 @@ private int calmDown; private boolean isRunning; private final Predicate items; -@@ -44,6 +51,15 @@ +@@ -47,6 +54,15 @@ return false; } else { - this.player = this.mob.level().getNearestPlayer(this.targetingConditions, this.mob); + this.player = getServerLevel((Entity) this.mob).getNearestPlayer(this.targetingConditions.range(this.mob.getAttributeValue(GenericAttributes.TEMPT_RANGE)), this.mob); + // CraftBukkit start + if (this.player != null) { + EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.mob, this.player, EntityTargetEvent.TargetReason.TEMPT); diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch index 8e8bf5a0..e5894e99 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java -@@ -58,7 +58,7 @@ +@@ -61,7 +61,7 @@ @Override public void start() { diff --git a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.patch b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.patch index bc347873..61d5a08f 100644 --- a/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.patch +++ b/nms-patches/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java -@@ -67,7 +67,7 @@ +@@ -70,7 +70,7 @@ @Override public void start() { 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 2301d3e9..0781087a 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 -@@ -18,6 +18,14 @@ +@@ -19,6 +19,14 @@ import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; @@ -14,17 +14,17 @@ + public class TemptingSensor extends Sensor { - public static final int TEMPTATION_RANGE = 10; -@@ -30,7 +38,7 @@ - + private static final PathfinderTargetCondition TEMPT_TARGETING = PathfinderTargetCondition.forNonCombat().ignoreLineOfSight(); +@@ -31,7 +39,7 @@ protected void doTick(WorldServer worldserver, EntityCreature entitycreature) { BehaviorController behaviorcontroller = entitycreature.getBrain(); + PathfinderTargetCondition pathfindertargetcondition = TemptingSensor.TEMPT_TARGETING.copy().range((double) ((float) entitycreature.getAttributeValue(GenericAttributes.TEMPT_RANGE))); - Stream stream = worldserver.players().stream().filter(IEntitySelector.NO_SPECTATORS).filter((entityplayer) -> { + Stream stream = worldserver.players().stream().filter(IEntitySelector.NO_SPECTATORS).filter((entityplayer) -> { // CraftBukkit - decompile error - return TemptingSensor.TEMPT_TARGETING.test(entitycreature, entityplayer); - }).filter((entityplayer) -> { - return entitycreature.closerThan(entityplayer, 10.0D); -@@ -44,7 +52,17 @@ + return pathfindertargetcondition.test(worldserver, entitycreature, entityplayer); + }).filter(this::playerHoldingTemptation).filter((entityplayer) -> { + return !entitycreature.hasPassenger((Entity) entityplayer); +@@ -43,7 +51,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 3f575b8b..fbac4f60 100644 --- a/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch +++ b/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/ambient/EntityBat.java +++ b/net/minecraft/world/entity/ambient/EntityBat.java -@@ -27,6 +27,10 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -30,6 +30,10 @@ + import net.minecraft.world.level.levelgen.HeightMap; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -11,37 +11,37 @@ public class EntityBat extends EntityAmbient { public static final float FLAP_LENGTH_SECONDS = 0.5F; -@@ -141,13 +145,13 @@ +@@ -144,13 +148,13 @@ this.yHeadRot = (float) this.random.nextInt(360); } -- if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) { -+ if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent +- if (worldserver.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) { ++ if (worldserver.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent this.setResting(false); if (!flag) { - this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0); + worldserver.levelEvent((EntityHuman) null, 1025, blockposition, 0); } } - } else { + } else if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent this.setResting(false); if (!flag) { - this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0); -@@ -174,7 +178,7 @@ + worldserver.levelEvent((EntityHuman) null, 1025, blockposition, 0); +@@ -177,7 +181,7 @@ this.zza = 0.5F; this.setYRot(this.getYRot() + f1); -- if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1)) { -+ if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1) && CraftEventFactory.handleBatToggleSleepEvent(this, false)) { // CraftBukkit - Call BatToggleSleepEvent +- if (this.random.nextInt(100) == 0 && worldserver.getBlockState(blockposition1).isRedstoneConductor(worldserver, blockposition1)) { ++ if (this.random.nextInt(100) == 0 && worldserver.getBlockState(blockposition1).isRedstoneConductor(worldserver, blockposition1) && CraftEventFactory.handleBatToggleSleepEvent(this, false)) { // CraftBukkit - Call BatToggleSleepEvent this.setResting(true); } } -@@ -199,7 +203,7 @@ - if (this.isInvulnerableTo(damagesource)) { +@@ -202,7 +206,7 @@ + if (this.isInvulnerableTo(worldserver, damagesource)) { return false; } else { -- if (!this.level().isClientSide && this.isResting()) { -+ if (!this.level().isClientSide && this.isResting() && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent +- if (this.isResting()) { ++ if (this.isResting() && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent this.setResting(false); } diff --git a/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch b/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch index 77ebdc3f..1476f050 100644 --- a/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch +++ b/nms-patches/net/minecraft/world/entity/animal/Bucketable.patch @@ -45,6 +45,6 @@ - t0.discard(); + t0.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause - return Optional.of(EnumInteractionResult.sidedSuccess(world.isClientSide)); + return Optional.of(EnumInteractionResult.SUCCESS); } else { return Optional.empty(); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch b/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch index 1c9add4d..2a29f15f 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityAnimal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityAnimal.java +++ b/net/minecraft/world/entity/animal/EntityAnimal.java -@@ -29,12 +29,20 @@ +@@ -35,12 +35,20 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.pathfinder.PathType; @@ -21,25 +21,25 @@ protected EntityAnimal(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -72,9 +80,15 @@ +@@ -82,9 +90,15 @@ } @Override -- protected void actuallyHurt(DamageSource damagesource, float f) { +- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) { + // CraftBukkit start - void -> boolean -+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) { -+ boolean damageResult = super.actuallyHurt(damagesource, f, event); ++ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { ++ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event); + if (!damageResult) { + return false; + } this.resetLove(); -- super.actuallyHurt(damagesource, f); +- super.actuallyHurt(worldserver, damagesource, f); + return true; + // CraftBukkit end } @Override -@@ -162,10 +176,17 @@ +@@ -188,10 +202,17 @@ } public void setInLove(@Nullable EntityHuman entityhuman) { @@ -58,7 +58,7 @@ this.level().broadcastEntityEvent(this, (byte) 18); } -@@ -207,12 +228,29 @@ +@@ -233,12 +254,29 @@ if (entityageable != null) { entityageable.setBaby(true); entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); @@ -90,7 +90,7 @@ Optional.ofNullable(this.getLoveCause()).or(() -> { return Optional.ofNullable(entityanimal.getLoveCause()); }).ifPresent((entityplayer) -> { -@@ -225,7 +263,11 @@ +@@ -251,7 +289,11 @@ entityanimal.resetLove(); worldserver.broadcastEntityEvent(this, (byte) 18); if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch b/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch index b3940b51..7ed8bcd2 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityBee.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityBee.java +++ b/net/minecraft/world/entity/animal/EntityBee.java -@@ -87,6 +87,12 @@ +@@ -89,6 +89,12 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; @@ -13,7 +13,7 @@ public class EntityBee extends EntityAnimal implements IEntityAngerable, EntityBird { public static final float FLAP_DEGREES_PER_TICK = 120.32113F; -@@ -186,12 +192,19 @@ +@@ -194,12 +200,19 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { @@ -35,18 +35,18 @@ nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.getSavedFlowerPos())); } -@@ -205,8 +218,8 @@ - - @Override - public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { +@@ -219,8 +232,8 @@ + this.ticksWithoutNectarSinceExitingHive = nbttagcompound.getInt("TicksSincePollination"); + this.stayOutOfHiveCountdown = nbttagcompound.getInt("CannotEnterHiveTicks"); + this.numCropsGrownSincePollination = nbttagcompound.getInt("CropsGrownSincePollination"); - this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse((Object) null); - this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse((Object) null); + this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse(null); // CraftBukkit - decompile error + this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse(null); // CraftBukkit - decompile error - super.readAdditionalSaveData(nbttagcompound); - this.setHasNectar(nbttagcompound.getBoolean("HasNectar")); - this.setHasStung(nbttagcompound.getBoolean("HasStung")); -@@ -243,7 +256,7 @@ + this.readPersistentAngerSaveData(this.level(), nbttagcompound); + } + +@@ -244,7 +257,7 @@ } if (b0 > 0) { @@ -55,24 +55,32 @@ } } -@@ -636,11 +649,14 @@ - if (this.isInvulnerableTo(damagesource)) { +@@ -502,7 +515,7 @@ + + @Nullable + TileEntityBeehive getBeehiveBlockEntity() { +- return this.hivePos == null ? null : (this.isTooFarAway(this.hivePos) ? null : (TileEntityBeehive) this.level().getBlockEntity(this.hivePos, TileEntityTypes.BEEHIVE).orElse((Object) null)); ++ return this.hivePos == null ? null : (this.isTooFarAway(this.hivePos) ? null : (TileEntityBeehive) this.level().getBlockEntity(this.hivePos, TileEntityTypes.BEEHIVE).orElse(null)); // CraftBukkit - decompile error + } + + boolean isHiveValid() { +@@ -638,8 +651,14 @@ + if (this.isInvulnerableTo(worldserver, damagesource)) { return false; } else { -- if (!this.level().isClientSide) { + // CraftBukkit start - Only stop pollinating if entity was damaged -+ boolean result = super.hurt(damagesource, f); -+ if (result && !this.level().isClientSide) { ++ boolean result = super.hurtServer(worldserver, damagesource, f); ++ if (!result) { ++ return result; ++ } + // CraftBukkit end - this.beePollinateGoal.stopPollinating(); - } - -- return super.hurt(damagesource, f); + this.beePollinateGoal.stopPollinating(); +- return super.hurtServer(worldserver, damagesource, f); + return result; // CraftBukkit } } -@@ -992,7 +1008,7 @@ +@@ -1048,7 +1067,7 @@ e() { super(); @@ -81,7 +89,7 @@ this.blacklistedTargets = Lists.newArrayList(); this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -1109,7 +1125,7 @@ +@@ -1162,7 +1181,7 @@ f() { super(); @@ -90,7 +98,7 @@ this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -1209,7 +1225,7 @@ +@@ -1267,7 +1286,7 @@ } } @@ -99,7 +107,7 @@ EntityBee.this.level().levelEvent(2011, blockposition, 15); EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1); EntityBee.this.incrementNumCropsGrownSincePollination(); -@@ -1282,7 +1298,7 @@ +@@ -1344,7 +1363,7 @@ @Override protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) { @@ -108,7 +116,7 @@ } } -@@ -1291,7 +1307,7 @@ +@@ -1353,7 +1372,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 334d99b6..c8275b2f 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 -@@ -181,10 +181,10 @@ +@@ -174,10 +174,10 @@ @Override public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); @@ -12,8 +12,8 @@ + IRegistry iregistry = BuiltInRegistries.CAT_VARIANT; // CraftBukkit - decompile error Objects.requireNonNull(iregistry); - optional.flatMap(iregistry::getHolder).ifPresent(this::setVariant); -@@ -452,7 +452,7 @@ + optional.flatMap(iregistry::get).ifPresent(this::setVariant); +@@ -463,7 +463,7 @@ } private void tryToTame(EntityHuman entityhuman) { @@ -22,7 +22,7 @@ this.tame(entityhuman); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, (byte) 7); -@@ -470,7 +470,7 @@ +@@ -481,7 +481,7 @@ private static class PathfinderGoalTemptChance extends PathfinderGoalTempt { @Nullable @@ -31,24 +31,24 @@ private final EntityCat cat; public PathfinderGoalTemptChance(EntityCat entitycat, double d0, Predicate predicate, boolean flag) { -@@ -611,7 +611,15 @@ - while (iterator.hasNext()) { - ItemStack itemstack = (ItemStack) iterator.next(); - -- this.cat.level().addFreshEntity(new EntityItem(this.cat.level(), (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack)); +@@ -615,7 +615,15 @@ + this.cat.randomTeleport((double) (blockposition_mutableblockposition.getX() + randomsource.nextInt(11) - 5), (double) (blockposition_mutableblockposition.getY() + randomsource.nextInt(5) - 2), (double) (blockposition_mutableblockposition.getZ() + randomsource.nextInt(11) - 5), false); + blockposition_mutableblockposition.set(this.cat.blockPosition()); + this.cat.dropFromGiftLootTable(getServerLevel((Entity) this.cat), LootTables.CAT_MORNING_GIFT, (worldserver, itemstack) -> { +- worldserver.addFreshEntity(new EntityItem(worldserver, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack)); + // CraftBukkit start -+ EntityItem entityitem = new EntityItem(this.cat.level(), (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack); ++ EntityItem entityitem = new EntityItem(worldserver, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack); + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.cat.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); + entityitem.level().getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ continue; ++ return; + } -+ this.cat.level().addFreshEntity(entityitem); ++ worldserver.addFreshEntity(entityitem); + // CraftBukkit end - } - + }); } -@@ -643,10 +651,10 @@ + +@@ -646,10 +654,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 33194151..11e71cc9 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityChicken.patch @@ -1,12 +1,15 @@ --- a/net/minecraft/world/entity/animal/EntityChicken.java +++ b/net/minecraft/world/entity/animal/EntityChicken.java -@@ -98,7 +98,9 @@ - this.flap += this.flapping * 2.0F; - if (!this.level().isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) { - this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); -+ this.forceDrops = true; // CraftBukkit - this.spawnAtLocation((IMaterial) Items.EGG); -+ this.forceDrops = false; // CraftBukkit - this.gameEvent(GameEvent.ENTITY_PLACE); - this.eggTime = this.random.nextInt(6000) + 6000; - } +@@ -99,10 +99,12 @@ + + if (world instanceof WorldServer worldserver) { + if (this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) { ++ this.forceDrops = true; // CraftBukkit + if (this.dropFromGiftLootTable(worldserver, LootTables.CHICKEN_LAY, this::spawnAtLocation)) { + this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.gameEvent(GameEvent.ENTITY_PLACE); + } ++ this.forceDrops = false; // CraftBukkit + + this.eggTime = this.random.nextInt(6000) + 6000; + } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch b/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch index 40f3a47c..35abe25c 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch @@ -30,4 +30,4 @@ + ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit entityhuman.setItemInHand(enumhand, itemstack1); - return EnumInteractionResult.sidedSuccess(this.level().isClientSide); + return EnumInteractionResult.SUCCESS; diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch b/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch index 932c266e..27264dec 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityDolphin.java +++ b/net/minecraft/world/entity/animal/EntityDolphin.java -@@ -59,8 +59,20 @@ +@@ -62,8 +62,20 @@ import net.minecraft.world.level.pathfinder.PathMode; import net.minecraft.world.phys.Vec3D; @@ -10,7 +10,7 @@ +import org.bukkit.event.entity.EntityRemoveEvent; +// CraftBukkit end + - public class EntityDolphin extends EntityWaterAnimal { + public class EntityDolphin extends AgeableWaterCreature { + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + @Override @@ -21,7 +21,7 @@ private static final DataWatcherObject TREASURE_POS = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BLOCK_POS); private static final DataWatcherObject GOT_FISH = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BOOLEAN); private static final DataWatcherObject MOISTNESS_LEVEL = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.INT); -@@ -176,7 +188,7 @@ +@@ -200,7 +212,7 @@ @Override public int getMaxAirSupply() { @@ -30,7 +30,7 @@ } @Override -@@ -212,11 +224,17 @@ +@@ -234,11 +246,17 @@ ItemStack itemstack = entityitem.getItem(); if (this.canHoldItem(itemstack)) { @@ -49,7 +49,7 @@ } } -@@ -467,7 +485,7 @@ +@@ -495,7 +513,7 @@ @Override public void start() { @@ -58,7 +58,7 @@ } @Override -@@ -486,7 +504,7 @@ +@@ -514,7 +532,7 @@ } if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch b/nms-patches/net/minecraft/world/entity/animal/EntityFox.patch index ef52d3da..2c4b0856 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 -@@ -93,6 +93,10 @@ +@@ -91,6 +91,10 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; @@ -11,8 +11,8 @@ public class EntityFox extends EntityAnimal implements VariantHolder { private static final DataWatcherObject DATA_TYPE_ID = DataWatcher.defineId(EntityFox.class, DataWatcherRegistry.INT); -@@ -518,7 +522,8 @@ - protected void pickUpItem(EntityItem entityitem) { +@@ -503,7 +507,8 @@ + protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); - if (this.canHoldItem(itemstack)) { @@ -21,7 +21,7 @@ int i = itemstack.getCount(); if (i > 1) { -@@ -530,7 +535,7 @@ +@@ -515,7 +520,7 @@ this.setItemSlot(EnumItemSlot.MAINHAND, itemstack.split(1)); this.setGuaranteedDrop(EnumItemSlot.MAINHAND); this.take(entityitem, itemstack.getCount()); @@ -30,7 +30,7 @@ this.ticksSinceEaten = 0; } -@@ -868,6 +873,16 @@ +@@ -853,6 +858,16 @@ if (entityplayer1 != null && entityplayer != entityplayer1) { entityfox.addTrustedUUID(entityplayer1.getUUID()); } @@ -47,7 +47,7 @@ if (entityplayer2 != null) { entityplayer2.awardStat(StatisticList.ANIMALS_BRED); -@@ -878,12 +893,14 @@ +@@ -863,12 +878,14 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); @@ -56,7 +56,7 @@ - worldserver.addFreshEntityWithPassengers(entityfox); + worldserver.addFreshEntityWithPassengers(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason this.level.broadcastEntityEvent(this.animal, (byte) 18); - if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - this.level.addFreshEntity(new EntityExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1)); + // CraftBukkit start - use event experience + if (experience > 0) { @@ -66,7 +66,7 @@ } } -@@ -1279,6 +1296,11 @@ +@@ -1264,6 +1281,11 @@ int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE); iblockdata.setValue(BlockSweetBerryBush.AGE, 1); @@ -78,12 +78,12 @@ int j = 1 + EntityFox.this.level().random.nextInt(2) + (i == 3 ? 1 : 0); ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND); -@@ -1436,7 +1458,7 @@ - private EntityLiving trustedLastHurt; - private int timestamp; +@@ -1494,7 +1516,7 @@ + } -- public a(final Class oclass, final boolean flag, final boolean flag1, @Nullable final Predicate predicate) { -+ public a(final Class oclass, final boolean flag, final boolean flag1, @Nullable final Predicate predicate) { // CraftBukkit - decompile error - super(EntityFox.this, oclass, 10, flag, flag1, predicate); + public static EntityFox.Type byName(String s) { +- return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, (Enum) EntityFox.Type.RED); ++ return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, EntityFox.Type.RED); // CraftBukkit - decompile error } + public static EntityFox.Type byId(int i) { diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch b/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch index 5eb23724..25e301c4 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityMushroomCow.patch @@ -1,66 +1,59 @@ --- a/net/minecraft/world/entity/animal/EntityMushroomCow.java +++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java -@@ -42,6 +42,14 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -44,6 +44,13 @@ import net.minecraft.world.level.gameevent.GameEvent; + import net.minecraft.world.level.storage.loot.LootTables; +// CraftBukkit start +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityDropItemEvent; -+import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.entity.EntityTransformEvent; +// CraftBukkit end + public class EntityMushroomCow extends EntityCow implements IShearable, VariantHolder { private static final DataWatcherObject DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING); -@@ -114,6 +122,11 @@ - this.playSound(soundeffect, 1.0F, 1.0F); - return EnumInteractionResult.sidedSuccess(this.level().isClientSide); - } else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { -+ // CraftBukkit start -+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { -+ return EnumInteractionResult.PASS; -+ } -+ // CraftBukkit end - this.shear(SoundCategory.PLAYERS); - this.gameEvent(GameEvent.SHEAR, entityhuman); - if (!this.level().isClientSide) { -@@ -157,7 +170,7 @@ +@@ -121,6 +128,11 @@ + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; - 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; -@@ -171,10 +184,25 @@ - } - - entitycow.setInvulnerable(this.isInvulnerable()); -- this.level().addFreshEntity(entitycow); + // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { -+ return; ++ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { ++ return EnumInteractionResult.PASS; + } -+ this.level().addFreshEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); -+ -+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - from above and add Bukkit remove cause + // 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()))); + this.shear(worldserver, SoundCategory.PLAYERS, itemstack); + this.gameEvent(GameEvent.SHEAR, entityhuman); + itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); +@@ -162,11 +174,19 @@ + worldserver.sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D); + this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_MOOSHROOM, itemstack, (worldserver1, itemstack1) -> { + for (int i = 0; i < itemstack1.getCount(); ++i) { +- worldserver1.addFreshEntity(new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), itemstack1.copyWithCount(1))); + // CraftBukkit start -+ EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock())); ++ EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), itemstack1.copyWithCount(1)); + EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); + Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + continue; + } -+ this.level().addFreshEntity(entityitem); ++ worldserver1.addFreshEntity(entityitem); + // CraftBukkit end } - } + + }); +- }); ++ }, EntityTransformEvent.TransformReason.SHEARED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); // CraftBukkit + } + + @Override +@@ -262,7 +282,7 @@ + } + + static EntityMushroomCow.Type byName(String s) { +- return (EntityMushroomCow.Type) EntityMushroomCow.Type.CODEC.byName(s, (Enum) EntityMushroomCow.Type.RED); ++ return (EntityMushroomCow.Type) EntityMushroomCow.Type.CODEC.byName(s, EntityMushroomCow.Type.RED); // CraftBukkit - decompile error } + } + } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch b/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch index adaf9451..9c76590e 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityOcelot.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityOcelot.java +++ b/net/minecraft/world/entity/animal/EntityOcelot.java -@@ -168,7 +168,7 @@ +@@ -167,7 +167,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && entityhuman.distanceToSqr((Entity) this) < 9.0D) { this.usePlayerItem(entityhuman, enumhand, itemstack); if (!this.level().isClientSide) { @@ -9,7 +9,7 @@ this.setTrusting(true); this.spawnTrustingParticles(true); this.level().broadcastEntityEvent(this, (byte) 41); -@@ -299,10 +299,10 @@ +@@ -298,10 +298,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 fc566a83..6dbcfc20 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityPanda.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/EntityPanda.java +++ b/net/minecraft/world/entity/animal/EntityPanda.java -@@ -73,6 +73,12 @@ - import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; +@@ -69,6 +69,12 @@ + import net.minecraft.world.level.storage.loot.LootTables; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start; @@ -13,12 +13,12 @@ public class EntityPanda extends EntityAnimal { private static final DataWatcherObject UNHAPPY_COUNTER = DataWatcher.defineId(EntityPanda.class, DataWatcherRegistry.INT); -@@ -558,14 +564,14 @@ +@@ -541,14 +547,14 @@ @Override - protected void pickUpItem(EntityItem entityitem) { -- if (this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem)) { -+ if (!CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem))).isCancelled()) { // CraftBukkit + protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) { +- if (this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && canPickUpAndEat(entityitem)) { ++ if (!CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && canPickUpAndEat(entityitem))).isCancelled()) { // CraftBukkit this.onItemPickup(entityitem); ItemStack itemstack = entityitem.getItem(); @@ -30,7 +30,16 @@ } } -@@ -889,10 +895,10 @@ +@@ -772,7 +778,7 @@ + } + + public static EntityPanda.Gene byName(String s) { +- return (EntityPanda.Gene) EntityPanda.Gene.CODEC.byName(s, (Enum) EntityPanda.Gene.NORMAL); ++ return (EntityPanda.Gene) EntityPanda.Gene.CODEC.byName(s, EntityPanda.Gene.NORMAL); // CraftBukkit - decompile error + } + + public static EntityPanda.Gene getRandom(RandomSource randomsource) { +@@ -876,10 +882,10 @@ private final EntityPanda panda; public c(EntityPanda entitypanda, Class oclass, float f, double d0, double d1) { @@ -44,7 +53,7 @@ this.panda = entitypanda; } -@@ -1131,7 +1137,7 @@ +@@ -1116,7 +1122,7 @@ @Override protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof 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 6087b83e..5cdb3fbc 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 -@@ -248,7 +248,7 @@ +@@ -250,7 +250,7 @@ } if (!this.level().isClientSide) { @@ -9,16 +9,16 @@ this.tame(entityhuman); this.level().broadcastEntityEvent(this, (byte) 7); } else { -@@ -269,7 +269,7 @@ +@@ -271,7 +271,7 @@ } } else { - itemstack.consume(1, entityhuman); + this.usePlayerItem(entityhuman, enumhand, itemstack); - this.addEffect(new MobEffect(MobEffects.POISON, 900)); + this.addEffect(new MobEffect(MobEffects.POISON, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit if (entityhuman.isCreative() || !this.isInvulnerable()) { this.hurt(this.damageSources().playerAttack(entityhuman), Float.MAX_VALUE); } -@@ -363,7 +363,7 @@ +@@ -365,7 +365,7 @@ @Override public boolean isPushable() { @@ -27,19 +27,18 @@ } @Override -@@ -378,11 +378,14 @@ - if (this.isInvulnerableTo(damagesource)) { +@@ -380,8 +380,14 @@ + if (this.isInvulnerableTo(worldserver, damagesource)) { return false; } else { -- if (!this.level().isClientSide) { + // CraftBukkit start -+ boolean result = super.hurt(damagesource, f); -+ if (!this.level().isClientSide && result) { -+ // CraftBukkit end - this.setOrderedToSit(false); - } - -- return super.hurt(damagesource, f); ++ boolean result = super.hurtServer(worldserver, damagesource, f); ++ if (!result) { ++ return result; ++ } ++ // CraftBukkit end + this.setOrderedToSit(false); +- return super.hurtServer(worldserver, damagesource, f); + return result; // CraftBukkit } } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch b/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch index aefc4f57..0f44b395 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityPig.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityPig.java +++ b/net/minecraft/world/entity/animal/EntityPig.java -@@ -49,6 +49,11 @@ +@@ -50,6 +50,11 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -12,20 +12,19 @@ public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable { private static final DataWatcherObject DATA_SADDLE_ID = DataWatcher.defineId(EntityPig.class, DataWatcherRegistry.BOOLEAN); -@@ -253,8 +258,14 @@ +@@ -247,7 +252,14 @@ } - entitypigzombie.setPersistenceRequired(); -- worldserver.addFreshEntity(entitypigzombie); -- this.discard(); -+ // 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(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause - } else { + entitypigzombie1.setPersistenceRequired(); +- }); ++ // CraftBukkit start ++ }, null, null); ++ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { ++ return; ++ } ++ worldserver.addFreshEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause ++ // CraftBukkit end + + if (entitypigzombie == null) { super.thunderHit(worldserver, entitylightning); - } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch b/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch index e896b2ba..10104083 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityPufferFish.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/animal/EntityPufferFish.java +++ b/net/minecraft/world/entity/animal/EntityPufferFish.java -@@ -150,7 +150,7 @@ +@@ -155,7 +155,7 @@ int i = this.getPuffState(); - if (entityinsentient.hurt(this.damageSources().mobAttack(this), (float) (1 + i))) { + if (entityinsentient.hurtServer(worldserver, this.damageSources().mobAttack(this), (float) (1 + i))) { - entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this); + entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit this.playSound(SoundEffects.PUFFER_FISH_STING, 1.0F, 1.0F); } -@@ -165,7 +165,7 @@ - ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F)); - } +@@ -171,7 +171,7 @@ + entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F)); + } -- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this); -+ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this); ++ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + } } - } diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch b/nms-patches/net/minecraft/world/entity/animal/EntityRabbit.patch index 242b724f..60b150a8 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 -@@ -67,6 +67,10 @@ +@@ -66,6 +66,10 @@ import net.minecraft.world.level.pathfinder.PathEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityRabbit extends EntityAnimal implements VariantHolder { public static final double STROLL_SPEED_MOD = 0.6D; -@@ -91,7 +95,6 @@ +@@ -90,7 +94,6 @@ super(entitytypes, world); this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this); this.moveControl = new EntityRabbit.ControllerMoveRabbit(this); @@ -19,7 +19,7 @@ } @Override -@@ -578,9 +581,19 @@ +@@ -577,9 +580,19 @@ 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 8bc4c6ce..b5351cb7 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/EntitySheep.java +++ b/net/minecraft/world/entity/animal/EntitySheep.java -@@ -63,6 +63,12 @@ - import net.minecraft.world.level.storage.loot.LootTable; +@@ -57,6 +57,12 @@ + import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.storage.loot.LootTables; +// CraftBukkit start @@ -13,29 +13,29 @@ public class EntitySheep extends EntityAnimal implements IShearable { private static final int EAT_ANIMATION_TICKS = 40; -@@ -250,6 +256,11 @@ +@@ -167,6 +173,11 @@ + WorldServer worldserver = (WorldServer) world; - if (itemstack.is(Items.SHEARS)) { - if (!this.level().isClientSide && this.readyForShearing()) { -+ // CraftBukkit start -+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { -+ return EnumInteractionResult.PASS; -+ } -+ // CraftBukkit end - this.shear(SoundCategory.PLAYERS); - this.gameEvent(GameEvent.SHEAR, entityhuman); - itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); -@@ -269,7 +280,9 @@ - int i = 1 + this.random.nextInt(3); + if (this.readyForShearing()) { ++ // CraftBukkit start ++ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + this.shear(worldserver, SoundCategory.PLAYERS, itemstack); + this.gameEvent(GameEvent.SHEAR, entityhuman); + itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); +@@ -185,7 +196,9 @@ + worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SHEEP_SHEAR, soundcategory, 1.0F, 1.0F); + this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SHEEP, itemstack, (worldserver1, itemstack1) -> { + for (int i = 0; i < itemstack1.getCount(); ++i) { ++ this.forceDrops = true; // CraftBukkit + EntityItem entityitem = this.spawnAtLocation(worldserver1, itemstack1.copyWithCount(1), 1.0F); ++ this.forceDrops = false; // CraftBukkit - for (int j = 0; j < i; ++j) { -+ this.forceDrops = true; // CraftBukkit - EntityItem entityitem = this.spawnAtLocation((IMaterial) EntitySheep.ITEM_BY_DYE.get(this.getColor()), 1); -+ this.forceDrops = false; // CraftBukkit - - 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))); -@@ -362,6 +375,12 @@ + if (entityitem != null) { + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F))); +@@ -280,6 +293,12 @@ @Override public void ate() { @@ -48,12 +48,12 @@ super.ate(); this.setSheared(false); if (this.isBaby()) { -@@ -381,7 +400,7 @@ - EnumColor enumcolor = ((EntitySheep) entityanimal).getColor(); - EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor(); +@@ -299,7 +318,7 @@ + EnumColor enumcolor = entitysheep.getColor(); + EnumColor enumcolor1 = entitysheep1.getColor(); CraftingInput craftinginput = makeCraftInput(enumcolor, enumcolor1); -- Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> { -+ Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error - return ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, this.level().registryAccess()); +- Optional optional = worldserver.recipeAccess().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver).map((recipeholder) -> { ++ Optional optional = worldserver.recipeAccess().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver).map((recipeholder) -> { // CraftBukkit - decompile error + return ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, worldserver.registryAccess()); }).map(ItemStack::getItem); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch b/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch index 2c4f535b..f662758d 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntitySnowman.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/animal/EntitySnowman.java +++ b/net/minecraft/world/entity/animal/EntitySnowman.java -@@ -40,6 +40,10 @@ - import net.minecraft.world.level.gameevent.GameEvent; +@@ -43,6 +43,10 @@ + import net.minecraft.world.level.storage.loot.LootTables; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -11,16 +11,16 @@ public class EntitySnowman extends EntityGolem implements IShearable, IRangedEntity { private static final DataWatcherObject DATA_PUMPKIN_ID = DataWatcher.defineId(EntitySnowman.class, DataWatcherRegistry.BYTE); -@@ -95,7 +99,7 @@ - super.aiStep(); - if (!this.level().isClientSide) { +@@ -100,7 +104,7 @@ + + if (world instanceof WorldServer worldserver) { if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) { -- this.hurt(this.damageSources().onFire(), 1.0F); -+ this.hurt(this.damageSources().melting(), 1.0F); // CraftBukkit - DamageSources.ON_FIRE -> CraftEventFactory.MELTING +- this.hurtServer(worldserver, this.damageSources().onFire(), 1.0F); ++ this.hurtServer(worldserver, this.damageSources().melting(), 1.0F); // CraftBukkit - DamageSources.ON_FIRE -> CraftEventFactory.MELTING } - if (!this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -@@ -111,7 +115,11 @@ + if (!worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +@@ -116,7 +120,11 @@ BlockPosition blockposition = new BlockPosition(j, k, l); if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { @@ -33,25 +33,25 @@ this.level().gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this, iblockdata)); } } -@@ -138,6 +146,11 @@ - ItemStack itemstack = entityhuman.getItemInHand(enumhand); +@@ -153,6 +161,11 @@ + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; - if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { -+ // CraftBukkit start -+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { -+ return EnumInteractionResult.PASS; -+ } -+ // CraftBukkit end - this.shear(SoundCategory.PLAYERS); - this.gameEvent(GameEvent.SHEAR, entityhuman); - if (!this.level().isClientSide) { -@@ -155,7 +168,9 @@ - this.level().playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F); - if (!this.level().isClientSide()) { - this.setPumpkin(false); ++ // CraftBukkit start ++ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + this.shear(worldserver, SoundCategory.PLAYERS, itemstack); + this.gameEvent(GameEvent.SHEAR, entityhuman); + itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); +@@ -169,7 +182,9 @@ + worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F); + this.setPumpkin(false); + this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SNOW_GOLEM, itemstack, (worldserver1, itemstack1) -> { + this.forceDrops = true; // CraftBukkit - this.spawnAtLocation(new ItemStack(Items.CARVED_PUMPKIN), this.getEyeHeight()); + this.spawnAtLocation(worldserver1, itemstack1, this.getEyeHeight()); + this.forceDrops = false; // CraftBukkit - } - + }); } + diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch b/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch index 379fe48a..5484958b 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityTurtle.patch @@ -1,25 +1,25 @@ --- a/net/minecraft/world/entity/animal/EntityTurtle.java +++ b/net/minecraft/world/entity/animal/EntityTurtle.java -@@ -305,7 +305,9 @@ - protected void ageBoundaryReached() { - super.ageBoundaryReached(); - if (!this.isBaby() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { -+ this.forceDrops = true; // CraftBukkit - this.spawnAtLocation(Items.TURTLE_SCUTE, 1); -+ this.forceDrops = false; // CraftBukkit - } +@@ -310,7 +310,9 @@ + WorldServer worldserver = (WorldServer) world; - } -@@ -332,7 +334,7 @@ + if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { ++ this.forceDrops = true; // CraftBukkit + this.spawnAtLocation(worldserver, Items.TURTLE_SCUTE, 1); ++ this.forceDrops = false; // CraftBukkit + } + } + } +@@ -339,7 +341,7 @@ @Override public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { -- this.hurt(this.damageSources().lightningBolt(), Float.MAX_VALUE); -+ this.hurt(this.damageSources().lightningBolt().customEntityDamager(entitylightning), Float.MAX_VALUE); // CraftBukkit +- this.hurtServer(worldserver, this.damageSources().lightningBolt(), Float.MAX_VALUE); ++ this.hurtServer(worldserver, this.damageSources().lightningBolt().customEntityDamager(entitylightning), Float.MAX_VALUE); // CraftBukkit } @Override -@@ -489,12 +491,14 @@ +@@ -496,12 +498,14 @@ } else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) { World world = this.turtle.level(); diff --git a/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch b/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch index 62bec789..e29a99b4 100644 --- a/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch +++ b/nms-patches/net/minecraft/world/entity/animal/EntityWolf.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/EntityWolf.java +++ b/net/minecraft/world/entity/animal/EntityWolf.java -@@ -90,6 +90,13 @@ +@@ -86,6 +86,13 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; @@ -14,32 +14,31 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable, VariantHolder> { private static final DataWatcherObject DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN); -@@ -360,11 +367,14 @@ - if (this.isInvulnerableTo(damagesource)) { +@@ -345,8 +352,14 @@ + if (this.isInvulnerableTo(worldserver, damagesource)) { return false; } else { -- if (!this.level().isClientSide) { + // CraftBukkit start -+ boolean result = super.hurt(damagesource, f); -+ if (!this.level().isClientSide && result) { -+ // CraftBukkit end - this.setOrderedToSit(false); - } - -- return super.hurt(damagesource, f); ++ boolean result = super.hurtServer(worldserver, damagesource, f); ++ if (!result) { ++ return result; ++ } ++ // CraftBukkit end + this.setOrderedToSit(false); +- return super.hurtServer(worldserver, damagesource, f); + return result; // CraftBukkit } } -@@ -374,10 +384,15 @@ +@@ -356,10 +369,15 @@ } @Override -- protected void actuallyHurt(DamageSource damagesource, float f) { -+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) { // CraftBukkit - void -> boolean +- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) { ++ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { // CraftBukkit - void -> boolean if (!this.canArmorAbsorb(damagesource)) { -- super.actuallyHurt(damagesource, f); -+ return super.actuallyHurt(damagesource, f, event); // CraftBukkit +- super.actuallyHurt(worldserver, damagesource, f); ++ return super.actuallyHurt(worldserver, damagesource, f, event); // CraftBukkit } else { + // CraftBukkit start - SPIGOT-7815: if the damage was cancelled, no need to run the wolf armor behaviour + if (event.isCancelled()) { @@ -49,7 +48,7 @@ ItemStack itemstack = this.getBodyArmorItem(); int i = itemstack.getDamageValue(); int j = itemstack.getMaxDamage(); -@@ -395,6 +410,7 @@ +@@ -371,6 +389,7 @@ } } @@ -57,7 +56,7 @@ } private boolean canArmorAbsorb(DamageSource damagesource) { -@@ -405,7 +421,7 @@ +@@ -381,7 +400,7 @@ protected void applyTamingSideEffects() { if (this.isTame()) { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(40.0D); @@ -66,35 +65,35 @@ } else { this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D); } -@@ -432,7 +448,7 @@ +@@ -404,7 +423,7 @@ FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD); float f = foodinfo != null ? (float) foodinfo.nutrition() : 1.0F; - this.heal(2.0F * f); + this.heal(2.0F * f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit - return EnumInteractionResult.sidedSuccess(this.level().isClientSide()); + return EnumInteractionResult.SUCCESS; } else { if (item instanceof ItemDye) { -@@ -463,7 +479,9 @@ - this.playSound(SoundEffects.ARMOR_UNEQUIP_WOLF); - itemstack1 = this.getBodyArmorItem(); - this.setBodyArmorItem(ItemStack.EMPTY); -+ this.forceDrops = true; // CraftBukkit - this.spawnAtLocation(itemstack1); -+ this.forceDrops = false; // CraftBukkit +@@ -440,7 +459,9 @@ + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; + ++ this.forceDrops = true; // CraftBukkit + this.spawnAtLocation(worldserver, itemstack1); ++ this.forceDrops = false; // CraftBukkit + } + return EnumInteractionResult.SUCCESS; - } else if (((RecipeItemStack) ((ArmorMaterial) EnumArmorMaterial.ARMADILLO.value()).repairIngredient().get()).test(itemstack) && this.isInSittingPose() && this.hasArmor() && this.isOwnedBy(entityhuman) && this.getBodyArmorItem().isDamaged()) { - itemstack.shrink(1); -@@ -480,7 +498,7 @@ +@@ -459,7 +480,7 @@ this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); - this.setTarget((EntityLiving) null); + this.setTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason - return EnumInteractionResult.SUCCESS_NO_ITEM_USED; + return EnumInteractionResult.SUCCESS.withoutItem(); } else { return enuminteractionresult; -@@ -498,7 +516,8 @@ +@@ -477,7 +498,8 @@ } private void tryToTame(EntityHuman entityhuman) { 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 5ffafed7..bb113dd9 100644 --- a/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch +++ b/nms-patches/net/minecraft/world/entity/animal/allay/Allay.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -101,6 +101,7 @@ +@@ -103,6 +103,7 @@ private float dancingAnimationTicks; private float spinningAnimationTicks; private float spinningAnimationTicks0; @@ -8,7 +8,7 @@ public Allay(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -112,6 +113,12 @@ +@@ -114,6 +115,12 @@ this.dynamicJukeboxListener = new DynamicGameEventListener<>(new Allay.a(this.vibrationUser.getPositionSource(), ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius())); } @@ -21,7 +21,7 @@ @Override protected BehaviorController.b brainProvider() { return BehaviorController.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES); -@@ -124,7 +131,7 @@ +@@ -126,7 +133,7 @@ @Override public BehaviorController getBrain() { @@ -30,7 +30,7 @@ } public static AttributeProvider.Builder createAttributes() { -@@ -225,7 +232,7 @@ +@@ -229,7 +236,7 @@ public void aiStep() { super.aiStep(); if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) { @@ -39,10 +39,10 @@ } if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) { -@@ -295,7 +302,12 @@ +@@ -299,7 +306,12 @@ ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND); - if (this.isDancing() && this.isDuplicationItem(itemstack) && this.canDuplicate()) { + if (this.isDancing() && itemstack.is(TagsItem.DUPLICATES_ALLAYS) && this.canDuplicate()) { - this.duplicateAllay(); + // CraftBukkit start - handle cancel duplication + Allay allay = this.duplicateAllay(); @@ -53,7 +53,7 @@ this.level().broadcastEntityEvent(this, (byte) 18); this.level().playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F); this.removeInteractionItem(entityhuman, itemstack); -@@ -306,7 +318,7 @@ +@@ -310,7 +322,7 @@ this.setItemInHand(EnumHand.MAIN_HAND, itemstack2); this.removeInteractionItem(entityhuman, itemstack); this.level().playSound(entityhuman, (Entity) this, SoundEffects.ALLAY_ITEM_GIVEN, SoundCategory.NEUTRAL, 2.0F, 1.0F); @@ -62,7 +62,7 @@ return EnumInteractionResult.SUCCESS; } else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) { this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY); -@@ -407,6 +419,7 @@ +@@ -411,6 +423,7 @@ } private boolean shouldStopDancing() { @@ -70,16 +70,16 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); } -@@ -500,7 +513,7 @@ - return Allay.DUPLICATION_ITEM.test(itemstack); +@@ -502,7 +515,7 @@ + } - public void duplicateAllay() { + public Allay duplicateAllay() { // CraftBukkit - return allay - Allay allay = (Allay) EntityTypes.ALLAY.create(this.level()); + Allay allay = (Allay) EntityTypes.ALLAY.create(this.level(), EntitySpawnReason.BREEDING); if (allay != null) { -@@ -508,9 +521,9 @@ +@@ -510,9 +523,9 @@ allay.setPersistenceRequired(); allay.resetDuplicationCooldown(); this.resetDuplicationCooldown(); diff --git a/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch b/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch index 905cd0dc..8187e9f1 100644 --- a/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch +++ b/nms-patches/net/minecraft/world/entity/animal/armadillo/Armadillo.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -47,6 +47,10 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -48,6 +48,10 @@ import net.minecraft.world.level.gameevent.GameEvent; + import net.minecraft.world.level.storage.loot.LootTables; +// CraftBukkit start +import org.bukkit.event.entity.EntityDamageEvent; @@ -11,33 +11,35 @@ public class Armadillo extends EntityAnimal { public static final float BABY_SCALE = 0.6F; -@@ -132,14 +136,16 @@ - @Override - protected void customServerAiStep() { - this.level().getProfiler().push("armadilloBrain"); -- this.brain.tick((WorldServer) this.level(), this); -+ ((BehaviorController) this.brain).tick((WorldServer) this.level(), this); // CraftBukkit - decompile error - this.level().getProfiler().pop(); - this.level().getProfiler().push("armadilloActivityUpdate"); +@@ -135,16 +139,18 @@ + GameProfilerFiller gameprofilerfiller = Profiler.get(); + + gameprofilerfiller.push("armadilloBrain"); +- this.brain.tick(worldserver, this); ++ ((BehaviorController) this.brain).tick(worldserver, this); // CraftBukkit - decompile error + gameprofilerfiller.pop(); + gameprofilerfiller.push("armadilloActivityUpdate"); ArmadilloAi.updateActivity(this); - this.level().getProfiler().pop(); + gameprofilerfiller.pop(); if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) { - this.playSound(SoundEffects.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.forceDrops = true; // CraftBukkit - this.spawnAtLocation((IMaterial) Items.ARMADILLO_SCUTE); + if (this.dropFromGiftLootTable(worldserver, LootTables.ARMADILLO_SHED, this::spawnAtLocation)) { + this.playSound(SoundEffects.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.gameEvent(GameEvent.ENTITY_PLACE); + } + this.forceDrops = false; // CraftBukkit - this.gameEvent(GameEvent.ENTITY_PLACE); + this.scuteTime = this.pickNextScuteDropTime(); } -@@ -286,8 +292,13 @@ +@@ -291,8 +297,13 @@ } @Override -- protected void actuallyHurt(DamageSource damagesource, float f) { -- super.actuallyHurt(damagesource, f); +- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) { +- super.actuallyHurt(worldserver, damagesource, f); + // CraftBukkit start - void -> boolean -+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) { -+ boolean damageResult = super.actuallyHurt(damagesource, f, event); ++ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { ++ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event); + if (!damageResult) { + return false; + } @@ -45,7 +47,7 @@ if (!this.isNoAi() && !this.isDeadOrDying()) { if (damagesource.getEntity() instanceof EntityLiving) { this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L); -@@ -299,6 +310,7 @@ +@@ -304,6 +315,7 @@ } } @@ -53,13 +55,22 @@ } @Override -@@ -326,7 +338,9 @@ - if (this.isBaby()) { - return false; - } else { -+ this.forceDrops = true; // CraftBukkit - this.spawnAtLocation(new ItemStack(Items.ARMADILLO_SCUTE)); -+ this.forceDrops = false; // CraftBukkit - this.gameEvent(GameEvent.ENTITY_INTERACT); - this.playSound(SoundEffects.ARMADILLO_BRUSH); - return true; +@@ -327,7 +339,9 @@ + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; + ++ this.forceDrops = true; // CraftBukkit + this.spawnAtLocation(worldserver, new ItemStack(Items.ARMADILLO_SCUTE)); ++ this.forceDrops = false; // CraftBukkit + this.gameEvent(GameEvent.ENTITY_INTERACT); + this.playSound(SoundEffects.ARMADILLO_BRUSH); + } +@@ -431,7 +445,7 @@ + } + + public static Armadillo.a fromName(String s) { +- return (Armadillo.a) Armadillo.a.CODEC.byName(s, (Enum) Armadillo.a.IDLE); ++ return (Armadillo.a) Armadillo.a.CODEC.byName(s, Armadillo.a.IDLE); // CraftBukkit - decompile error + } + + @Override 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 f8aec072..b9752285 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 -@@ -68,9 +68,16 @@ +@@ -67,10 +67,17 @@ - public class Axolotl extends EntityAnimal implements LerpingModel, VariantHolder, Bucketable { + public class Axolotl extends EntityAnimal implements VariantHolder, Bucketable { + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + @Override @@ -11,6 +11,7 @@ + } + // CraftBukkit end public static final int TOTAL_PLAYDEAD_TIME = 200; + private static final int POSE_ANIMATION_TICKS = 10; 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}); + // CraftBukkit - decompile error @@ -18,7 +19,7 @@ private static final DataWatcherObject DATA_VARIANT = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.INT); private static final DataWatcherObject DATA_PLAYING_DEAD = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); private static final DataWatcherObject FROM_BUCKET = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN); -@@ -187,7 +194,7 @@ +@@ -210,7 +217,7 @@ @Override public int getMaxAirSupply() { @@ -27,7 +28,7 @@ } @Override -@@ -391,7 +398,7 @@ +@@ -414,7 +421,7 @@ int i = mobeffect != null ? mobeffect.getDuration() : 0; int j = Math.min(2400, 100 + i); @@ -36,7 +37,7 @@ } entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN); -@@ -441,7 +448,7 @@ +@@ -464,7 +471,7 @@ @Override public BehaviorController getBrain() { diff --git a/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch b/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch index 7d3e9bba..1c78bcdb 100644 --- a/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch +++ b/nms-patches/net/minecraft/world/entity/animal/camel/Camel.patch @@ -8,32 +8,32 @@ +import org.bukkit.event.entity.EntityDamageEvent; +// CraftBukkit end + - public class Camel extends EntityHorseAbstract implements IJumpable, ISaddleable { + public class Camel extends EntityHorseAbstract { public static final float BABY_SCALE = 0.45F; -@@ -141,7 +145,7 @@ - @Override - protected void customServerAiStep() { - this.level().getProfiler().push("camelBrain"); +@@ -143,7 +147,7 @@ + GameProfilerFiller gameprofilerfiller = Profiler.get(); + + gameprofilerfiller.push("camelBrain"); - BehaviorController behaviorcontroller = this.getBrain(); + BehaviorController behaviorcontroller = (BehaviorController) this.getBrain(); // CraftBukkit - decompile error - behaviorcontroller.tick((WorldServer) this.level(), this); - this.level().getProfiler().pop(); -@@ -452,9 +456,15 @@ + behaviorcontroller.tick(worldserver, this); + gameprofilerfiller.pop(); +@@ -454,9 +458,15 @@ } @Override -- protected void actuallyHurt(DamageSource damagesource, float f) { +- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) { + // CraftBukkit start - void -> boolean -+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) { -+ boolean damageResult = super.actuallyHurt(damagesource, f, event); ++ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { ++ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event); + if (!damageResult) { + return false; + } + // CraftBukkit end this.standUpInstantly(); -- super.actuallyHurt(damagesource, f); +- super.actuallyHurt(worldserver, damagesource, f); + return true; // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/entity/animal/frog/ShootTongue.patch b/nms-patches/net/minecraft/world/entity/animal/frog/ShootTongue.patch index bbd20a83..00ad10cb 100644 --- a/nms-patches/net/minecraft/world/entity/animal/frog/ShootTongue.patch +++ b/nms-patches/net/minecraft/world/entity/animal/frog/ShootTongue.patch @@ -22,7 +22,7 @@ } @@ -85,7 +89,7 @@ if (entity.isAlive()) { - frog.doHurtTarget(entity); + frog.doHurtTarget(worldserver, entity); if (!entity.isAlive()) { - entity.remove(Entity.RemovalReason.KILLED); + entity.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause 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 0903590a..d8295126 100644 --- a/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch +++ b/nms-patches/net/minecraft/world/entity/animal/frog/Tadpole.patch @@ -1,17 +1,6 @@ --- a/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -38,6 +38,10 @@ - import net.minecraft.world.item.component.CustomData; - import net.minecraft.world.level.World; - -+// CraftBukkit start -+import org.bukkit.event.entity.EntityRemoveEvent; -+// CraftBukkit end -+ - public class Tadpole extends EntityFish { - - @VisibleForTesting -@@ -71,7 +75,7 @@ +@@ -74,7 +74,7 @@ @Override public BehaviorController getBrain() { @@ -20,22 +9,23 @@ } @Override -@@ -232,10 +236,16 @@ - } +@@ -225,12 +225,17 @@ + World world = this.level(); + if (world instanceof WorldServer worldserver) { +- this.convertTo(EntityTypes.FROG, ConversionParams.single(this, false, false), (frog) -> { ++ Frog converted = this.convertTo(EntityTypes.FROG, ConversionParams.single(this, false, false), (frog) -> { // CraftBukkit + frog.finalizeSpawn(worldserver, this.level().getCurrentDifficultyAt(frog.blockPosition()), EntitySpawnReason.CONVERSION, (GroupDataEntity) null); 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 frog.fudgePositionAfterSizeChange(this.getDimensions(this.getPose())); this.playSound(SoundEffects.TADPOLE_GROW_UP, 0.15F, 1.0F); -- worldserver.addFreshEntityWithPassengers(frog); -- this.discard(); -+ worldserver.addFreshEntityWithPassengers(frog, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.METAMORPHOSIS); // CraftBukkit - add SpawnReason -+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause - } +- }); ++ // CraftBukkit start ++ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.METAMORPHOSIS, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.METAMORPHOSIS); ++ if (converted == null) { ++ this.setAge(0); // Sets the age to 0 for avoid a loop if the event is canceled ++ } ++ // CraftBukkit end } + } 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 dc79b95d..fa246c2f 100644 --- a/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch +++ b/nms-patches/net/minecraft/world/entity/animal/goat/Goat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/goat/Goat.java +++ b/net/minecraft/world/entity/animal/goat/Goat.java -@@ -55,6 +55,12 @@ +@@ -54,6 +54,12 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3D; @@ -13,7 +13,7 @@ public class Goat extends EntityAnimal { public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.scalable(0.9F, 1.3F).scale(0.7F); -@@ -182,7 +188,7 @@ +@@ -184,7 +190,7 @@ @Override public BehaviorController getBrain() { @@ -22,7 +22,7 @@ } @Override -@@ -225,8 +231,15 @@ +@@ -229,8 +235,15 @@ ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.is(Items.BUCKET) && !this.isBaby()) { @@ -38,4 +38,4 @@ + ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit entityhuman.setItemInHand(enumhand, itemstack1); - return EnumInteractionResult.sidedSuccess(this.level().isClientSide); + return EnumInteractionResult.SUCCESS; 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 cf381401..68577274 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 -@@ -81,6 +81,18 @@ +@@ -79,6 +79,18 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.ticks.ContainerSingleItem; @@ -19,7 +19,7 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, HasCustomInventoryScreen, OwnableEntity, IJumpable, ISaddleable { public static final int EQUIPMENT_SLOT_OFFSET = 400; -@@ -158,7 +170,53 @@ +@@ -167,7 +179,53 @@ public boolean stillValid(EntityHuman entityhuman) { return entityhuman.getVehicle() == EntityHorseAbstract.this || entityhuman.canInteractWithEntity((Entity) EntityHorseAbstract.this, 4.0D); } @@ -73,7 +73,7 @@ protected EntityHorseAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -353,7 +411,7 @@ +@@ -366,7 +424,7 @@ public void createInventory() { InventorySubcontainer inventorysubcontainer = this.inventory; @@ -82,7 +82,7 @@ if (inventorysubcontainer != null) { inventorysubcontainer.removeListener(this); int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize()); -@@ -457,7 +515,7 @@ +@@ -470,7 +528,7 @@ } public int getMaxTemper() { @@ -91,7 +91,7 @@ } @Override -@@ -528,7 +586,7 @@ +@@ -541,7 +599,7 @@ } if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { @@ -100,16 +100,16 @@ flag = true; } -@@ -602,7 +660,7 @@ - super.aiStep(); - if (!this.level().isClientSide && this.isAlive()) { - if (this.random.nextInt(900) == 0 && this.deathTime == 0) { -- this.heal(1.0F); -+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit - } +@@ -618,7 +676,7 @@ + if (world instanceof WorldServer worldserver) { + if (this.isAlive()) { + if (this.random.nextInt(900) == 0 && this.deathTime == 0) { +- this.heal(1.0F); ++ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit + } - if (this.canEatGrass()) { -@@ -864,6 +922,7 @@ + if (this.canEatGrass()) { +@@ -883,6 +941,7 @@ if (this.getOwnerUUID() != null) { nbttagcompound.putUUID("Owner", this.getOwnerUUID()); } @@ -117,7 +117,7 @@ if (!this.inventory.getItem(0).isEmpty()) { nbttagcompound.put("SaddleItem", this.inventory.getItem(0).save(this.registryAccess())); -@@ -891,6 +950,11 @@ +@@ -910,6 +969,11 @@ if (uuid != null) { this.setOwnerUUID(uuid); } @@ -129,7 +129,7 @@ if (nbttagcompound.contains("SaddleItem", 10)) { ItemStack itemstack = (ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("SaddleItem")).orElse(ItemStack.EMPTY); -@@ -993,6 +1057,17 @@ +@@ -1012,6 +1076,17 @@ @Override public void handleStartJump(int i) { 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 865898ee..edd02d7a 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 -@@ -84,6 +84,11 @@ +@@ -82,6 +82,11 @@ 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 1c56c4bd..d43f6038 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 -@@ -19,6 +19,10 @@ +@@ -22,6 +22,10 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.WorldAccess; @@ -11,7 +11,7 @@ public class EntityLlamaTrader extends EntityLlama { private int despawnDelay = 47999; -@@ -87,7 +91,7 @@ +@@ -94,7 +98,7 @@ this.despawnDelay = this.isLeashedToWanderingTrader() ? ((EntityVillagerTrader) this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1; if (this.despawnDelay <= 0) { this.dropLeash(true, false); @@ -20,7 +20,7 @@ } } -@@ -153,7 +157,7 @@ +@@ -160,7 +164,7 @@ @Override public void start() { diff --git a/nms-patches/net/minecraft/world/entity/animal/sniffer/Sniffer.patch b/nms-patches/net/minecraft/world/entity/animal/sniffer/Sniffer.patch index 37f01acf..a100d9df 100644 --- a/nms-patches/net/minecraft/world/entity/animal/sniffer/Sniffer.patch +++ b/nms-patches/net/minecraft/world/entity/animal/sniffer/Sniffer.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -274,6 +274,13 @@ - ItemStack itemstack = (ItemStack) iterator.next(); - EntityItem entityitem = new EntityItem(worldserver, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack); +@@ -267,6 +267,13 @@ + this.dropFromGiftLootTable(worldserver, LootTables.SNIFFER_DIGGING, (worldserver1, itemstack) -> { + EntityItem entityitem = new EntityItem(this.level(), (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack); -+ // CraftBukkit start - handle EntityDropItemEvent -+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); -+ org.bukkit.Bukkit.getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ continue; -+ } -+ // CraftBukkit end - entityitem.setDefaultPickUpDelay(); - worldserver.addFreshEntity(entityitem); - } -@@ -313,7 +320,7 @@ ++ // CraftBukkit start - handle EntityDropItemEvent ++ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + entityitem.setDefaultPickUpDelay(); + worldserver1.addFreshEntity(entityitem); + }); +@@ -308,7 +315,7 @@ List list = (List) this.getExploredPositions().limit(20L).collect(Collectors.toList()); list.add(0, GlobalPos.of(this.level().dimension(), blockposition)); @@ -23,7 +23,7 @@ return this; } -@@ -454,7 +461,7 @@ +@@ -444,7 +451,7 @@ @Override public BehaviorController getBrain() { 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 19695c44..1bc0b773 100644 --- a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch +++ b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.patch @@ -26,10 +26,10 @@ } } -@@ -94,12 +104,26 @@ +@@ -99,12 +109,26 @@ return false; } else { - if (!this.isRemoved() && !this.level().isClientSide) { + if (!this.isRemoved()) { - this.remove(Entity.RemovalReason.KILLED); + // CraftBukkit start - All non-living entities need this + if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) { @@ -39,7 +39,7 @@ if (!damagesource.is(DamageTypeTags.IS_EXPLOSION)) { DamageSource damagesource1 = damagesource.getEntity() != null ? this.damageSources().explosion(this, damagesource.getEntity()) : null; -- this.level().explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), 6.0F, false, World.a.BLOCK); +- worldserver.explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), 6.0F, false, World.a.BLOCK); + // CraftBukkit start + ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent(this, 6.0F, false); + if (event.isCancelled()) { @@ -47,11 +47,11 @@ + } + + this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause -+ this.level().explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.BLOCK); ++ worldserver.explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.BLOCK); + } else { + this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause } + // CraftBukkit end - this.onDestroyedBy(damagesource); + this.onDestroyedBy(worldserver, damagesource); } diff --git a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch index 2d60d6a8..6b683c7a 100644 --- a/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch +++ b/nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java -@@ -52,6 +52,21 @@ +@@ -52,6 +52,22 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Explosion; ++import net.minecraft.world.level.ServerExplosion; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.TileEntity; +import net.minecraft.world.level.storage.loot.LootParams; @@ -22,7 +23,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -89,6 +104,7 @@ +@@ -88,6 +104,7 @@ private final PathPoint[] nodes; private final int[] nodeAdjacency; private final Path openSet; @@ -30,15 +31,15 @@ public EntityEnderDragon(EntityTypes entitytypes, World world) { super(EntityTypes.ENDER_DRAGON, world); -@@ -110,6 +126,7 @@ +@@ -108,6 +125,7 @@ + this.setHealth(this.getMaxHealth()); this.noPhysics = true; - this.noCulling = true; this.phaseManager = new DragonControllerManager(this); -+ this.explosionSource = new Explosion(world, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Effect.DESTROY, Particles.EXPLOSION, Particles.EXPLOSION_EMITTER, SoundEffects.GENERIC_EXPLODE); // CraftBukkit ++ this.explosionSource = new ServerExplosion(world.getMinecraftWorld(), this, null, null, new Vec3D(Double.NaN, Double.NaN, Double.NaN), Float.NaN, true, Explosion.Effect.DESTROY); // CraftBukkit } public void setDragonFight(EnderDragonBattle enderdragonbattle) { -@@ -257,7 +274,7 @@ +@@ -218,7 +236,7 @@ Vec3D vec3d1 = idragoncontroller.getFlyTargetLocation(); @@ -47,7 +48,7 @@ double d0 = vec3d1.x - this.getX(); double d1 = vec3d1.y - this.getY(); double d2 = vec3d1.z - this.getZ(); -@@ -404,7 +421,14 @@ +@@ -379,7 +397,14 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -63,7 +64,7 @@ } } -@@ -489,6 +513,9 @@ +@@ -458,6 +483,9 @@ int j1 = MathHelper.floor(axisalignedbb.maxZ); boolean flag = false; boolean flag1 = false; @@ -73,20 +74,20 @@ for (int k1 = i; k1 <= l; ++k1) { for (int l1 = j; l1 <= i1; ++l1) { -@@ -498,7 +525,11 @@ +@@ -467,7 +495,11 @@ if (!iblockdata.isAir() && !iblockdata.is(TagsBlock.DRAGON_TRANSPARENT)) { - if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(TagsBlock.DRAGON_IMMUNE)) { -- flag1 = this.level().removeBlock(blockposition, false) || flag1; + if (worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(TagsBlock.DRAGON_IMMUNE)) { +- flag1 = worldserver.removeBlock(blockposition, false) || flag1; + // CraftBukkit start - Add blocks to list rather than destroying them -+ // flag1 = this.level().removeBlock(blockposition, false) || flag1; ++ // flag1 = worldserver.removeBlock(blockposition, false) || flag1; + flag1 = true; -+ destroyedBlocks.add(CraftBlock.at(this.level(), blockposition)); ++ destroyedBlocks.add(CraftBlock.at(worldserver, blockposition)); + // CraftBukkit end } else { flag = true; } -@@ -507,6 +538,49 @@ +@@ -476,6 +508,49 @@ } } @@ -126,7 +127,7 @@ + }); + craftBlock.getNMS().spawnAfterBreak((WorldServer) this.level(), blockposition, ItemStack.EMPTY, false); + } -+ nmsBlock.wasExploded(this.level(), blockposition, explosionSource); ++ nmsBlock.wasExploded((WorldServer) this.level(), blockposition, explosionSource); + + this.level().removeBlock(blockposition, false); + } @@ -136,24 +137,24 @@ if (flag1) { BlockPosition blockposition1 = new BlockPosition(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1)); -@@ -562,7 +636,7 @@ +@@ -531,7 +606,7 @@ @Override - public void kill() { + public void kill(WorldServer worldserver) { - this.remove(Entity.RemovalReason.KILLED); + this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause this.gameEvent(GameEvent.ENTITY_DIE); if (this.dragonFight != null) { this.dragonFight.updateDragon(this); -@@ -571,6 +645,21 @@ +@@ -540,6 +615,21 @@ } + // CraftBukkit start - SPIGOT-2420: Special case, the ender dragon drops 12000 xp for the first kill and 500 xp for every other kill and this over time. + @Override -+ public int getExpReward(Entity entity) { ++ public int getExpReward(WorldServer worldserver, Entity entity) { + // CraftBukkit - Moved from #tickDeath method -+ boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); ++ boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); + short short0 = 500; + + if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) { @@ -167,13 +168,12 @@ @Override protected void tickDeath() { if (this.dragonFight != null) { -@@ -586,15 +675,20 @@ +@@ -555,16 +645,21 @@ this.level().addParticle(Particles.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D); } + // CraftBukkit start - SPIGOT-2420: Moved up to #getExpReward method + /* - boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); short short0 = 500; if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) { @@ -183,31 +183,35 @@ + int short0 = expToDrop; + // CraftBukkit end - if (this.level() instanceof WorldServer) { -- if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && flag) { -+ if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp - EntityExperienceOrb.award((WorldServer) this.level(), this.position(), MathHelper.floor((float) short0 * 0.08F)); - } - -@@ -605,7 +699,7 @@ + World world = this.level(); - this.move(EnumMoveType.SELF, new Vec3D(0.0D, 0.10000000149011612D, 0.0D)); - if (this.dragonDeathTime == 200 && this.level() instanceof WorldServer) { -- if (flag) { -+ if (true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp - EntityExperienceOrb.award((WorldServer) this.level(), this.position(), MathHelper.floor((float) short0 * 0.2F)); + if (world instanceof WorldServer worldserver) { +- if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { ++ if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp + EntityExperienceOrb.award(worldserver, this.position(), MathHelper.floor((float) short0 * 0.08F)); } -@@ -613,7 +707,7 @@ - this.dragonFight.setDragonKilled(this); +@@ -577,8 +672,8 @@ + if (this.dragonDeathTime == 200) { + world = this.level(); + if (world instanceof WorldServer) { +- worldserver = (WorldServer) world; +- if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { ++ WorldServer worldserver = (WorldServer) world; // CraftBukkit - decompile error ++ if (true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp + EntityExperienceOrb.award(worldserver, this.position(), MathHelper.floor((float) short0 * 0.2F)); + } + +@@ -586,7 +681,7 @@ + this.dragonFight.setDragonKilled(this); + } + +- this.remove(Entity.RemovalReason.KILLED); ++ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause + this.gameEvent(GameEvent.ENTITY_DIE); } - -- this.remove(Entity.RemovalReason.KILLED); -+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause - this.gameEvent(GameEvent.ENTITY_DIE); } - -@@ -826,6 +920,7 @@ +@@ -800,6 +895,7 @@ super.addAdditionalSaveData(nbttagcompound); nbttagcompound.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); nbttagcompound.putInt("DragonDeathTime", this.dragonDeathTime); @@ -215,7 +219,7 @@ } @Override -@@ -839,6 +934,11 @@ +@@ -813,6 +909,11 @@ this.dragonDeathTime = nbttagcompound.getInt("DragonDeathTime"); } diff --git a/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.patch b/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.patch index 8718435f..b38a3a09 100644 --- a/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.patch +++ b/nms-patches/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.java -@@ -10,6 +10,10 @@ +@@ -11,6 +11,10 @@ import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class DragonControllerLandedFlame extends AbstractDragonControllerLanded { private static final int FLAME_DURATION = 200; -@@ -99,7 +103,7 @@ +@@ -100,7 +104,7 @@ @Override public void end() { if (this.flame != null) { 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 e27efc7a..27bbc62a 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 -@@ -59,6 +59,18 @@ +@@ -57,6 +57,18 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -16,29 +16,29 @@ +import org.bukkit.event.entity.ExplosionPrimeEvent; +// CraftBukkit end + - public class EntityWither extends EntityMonster implements PowerableMob, IRangedEntity { + public class EntityWither extends EntityMonster implements IRangedEntity { private static final DataWatcherObject DATA_TARGET_A = DataWatcher.defineId(EntityWither.class, DataWatcherRegistry.INT); -@@ -255,15 +267,40 @@ +@@ -253,15 +265,40 @@ i = this.getInvulnerableTicks() - 1; this.bossEvent.setProgress(1.0F - (float) i / 220.0F); if (i <= 0) { -- this.level().explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, World.a.MOB); +- worldserver.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, World.a.MOB); ++ // worldserver.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); ++ worldserver.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.level().explode(this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); ++ worldserver.explode(this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); + } + // CraftBukkit end + if (!this.isSilent()) { -- this.level().globalLevelEvent(1023, this.blockPosition(), 0); +- worldserver.globalLevelEvent(1023, this.blockPosition(), 0); + // CraftBukkit start - Use relative location for far away sounds -+ // this.level().globalLevelEvent(1023, new BlockPosition(this), 0); -+ int viewDistance = ((WorldServer) this.level()).getCraftServer().getViewDistance() * 16; ++ // worldserver.globalLevelEvent(1023, new BlockPosition(this), 0); ++ int viewDistance = worldserver.getCraftServer().getViewDistance() * 16; + for (EntityPlayer player : (List) MinecraftServer.getServer().getPlayerList().players) { + double deltaX = this.getX() - player.getX(); + double deltaZ = this.getZ() - player.getZ(); @@ -63,7 +63,7 @@ } } else { -@@ -308,6 +345,7 @@ +@@ -306,6 +343,7 @@ if (!list.isEmpty()) { EntityLiving entityliving1 = (EntityLiving) list.get(this.random.nextInt(list.size())); @@ -71,8 +71,8 @@ this.setAlternativeTarget(i, entityliving1.getId()); } } -@@ -334,6 +372,11 @@ - IBlockData iblockdata = this.level().getBlockState(blockposition); +@@ -332,6 +370,11 @@ + IBlockData iblockdata = worldserver.getBlockState(blockposition); if (canDestroy(iblockdata)) { + // CraftBukkit start @@ -80,10 +80,10 @@ + continue; + } + // CraftBukkit end - flag = this.level().destroyBlock(blockposition, true, this) || flag; + flag = worldserver.destroyBlock(blockposition, true, this) || flag; } } -@@ -345,7 +388,7 @@ +@@ -343,7 +386,7 @@ } if (this.tickCount % 20 == 0) { @@ -92,7 +92,7 @@ } this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); -@@ -502,7 +545,7 @@ +@@ -500,7 +543,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { diff --git a/nms-patches/net/minecraft/world/entity/decoration/BlockAttachedEntity.patch b/nms-patches/net/minecraft/world/entity/decoration/BlockAttachedEntity.patch index 5a159a32..27d3b35b 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/BlockAttachedEntity.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/BlockAttachedEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/BlockAttachedEntity.java +++ b/net/minecraft/world/entity/decoration/BlockAttachedEntity.java -@@ -15,6 +15,15 @@ +@@ -18,6 +18,15 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -16,7 +16,7 @@ public abstract class BlockAttachedEntity extends Entity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -39,7 +48,25 @@ +@@ -44,7 +53,25 @@ if (this.checkInterval++ == 100) { this.checkInterval = 0; if (!this.isRemoved() && !this.survives()) { @@ -40,13 +40,13 @@ + } + // CraftBukkit end + this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause - this.dropItem((Entity) null); + this.dropItem(worldserver, (Entity) null); } } -@@ -69,6 +96,22 @@ +@@ -81,6 +108,22 @@ return false; } else { - if (!this.isRemoved() && !this.level().isClientSide) { + if (!this.isRemoved()) { + // CraftBukkit start - fire break events + Entity damager = (damagesource.isDirect()) ? damagesource.getDirectEntity() : damagesource.getEntity(); + HangingBreakEvent event; @@ -63,37 +63,36 @@ + } + // CraftBukkit end + - this.kill(); + this.kill(worldserver); this.markHurt(); - this.dropItem(damagesource.getEntity()); -@@ -81,6 +124,18 @@ - @Override - public void move(EnumMoveType enummovetype, Vec3D vec3d) { - if (!this.level().isClientSide && !this.isRemoved() && vec3d.lengthSqr() > 0.0D) { -+ if (this.isRemoved()) return; // CraftBukkit -+ -+ // CraftBukkit start - fire break events -+ // TODO - Does this need its own cause? Seems to only be triggered by pistons -+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS); -+ this.level().getCraftServer().getPluginManager().callEvent(event); + this.dropItem(worldserver, damagesource.getEntity()); +@@ -101,6 +144,16 @@ + + if (world instanceof WorldServer worldserver) { + if (!this.isRemoved() && vec3d.lengthSqr() > 0.0D) { ++ // CraftBukkit start - fire break events ++ // TODO - Does this need its own cause? Seems to only be triggered by pistons ++ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS); ++ this.level().getCraftServer().getPluginManager().callEvent(event); + -+ if (this.isRemoved() || event.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end ++ if (this.isRemoved() || event.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + - this.kill(); - this.dropItem((Entity) null); - } -@@ -89,13 +144,22 @@ + this.kill(worldserver); + this.dropItem(worldserver, (Entity) null); + } +@@ -113,7 +166,7 @@ + World world = this.level(); - @Override - public void push(double d0, double d1, double d2) { -- if (!this.level().isClientSide && !this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { -+ if (false && !this.level().isClientSide && !this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed - this.kill(); - this.dropItem((Entity) null); - } + if (world instanceof WorldServer worldserver) { +- if (!this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { ++ if (false && !this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed + this.kill(worldserver); + this.dropItem(worldserver, (Entity) null); + } +@@ -121,6 +174,15 @@ } diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch index 7770160f..15945470 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityArmorStand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/EntityArmorStand.java +++ b/net/minecraft/world/entity/decoration/EntityArmorStand.java -@@ -46,6 +46,16 @@ +@@ -48,6 +48,16 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -17,7 +17,7 @@ public class EntityArmorStand extends EntityLiving { public static final int WOBBLE_TIME = 5; -@@ -111,6 +121,13 @@ +@@ -123,6 +133,13 @@ return createLivingAttributes().add(GenericAttributes.STEP_HEIGHT, 0.0D); } @@ -31,7 +31,7 @@ @Override public void refreshDimensions() { double d0 = this.getX(); -@@ -171,13 +188,20 @@ +@@ -183,13 +200,20 @@ @Override public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -54,9 +54,9 @@ } } -@@ -407,7 +431,25 @@ +@@ -412,7 +436,25 @@ return false; - } else if (itemstack1.isEmpty() && (this.disabledSlots & 1 << enumitemslot.getFilterFlag() + 16) != 0) { + } else if (itemstack1.isEmpty() && (this.disabledSlots & 1 << enumitemslot.getFilterBit(16)) != 0) { return false; - } else if (entityhuman.hasInfiniteMaterials() && itemstack1.isEmpty() && !itemstack.isEmpty()) { + // CraftBukkit start @@ -81,7 +81,7 @@ this.setItemSlot(enumitemslot, itemstack.copyWithCount(1)); return true; } else if (!itemstack.isEmpty() && itemstack.getCount() > 1) { -@@ -422,6 +464,7 @@ +@@ -427,6 +469,7 @@ entityhuman.setItemInHand(enumhand, itemstack1); return true; } @@ -89,60 +89,60 @@ } @Override -@@ -435,12 +478,22 @@ - WorldServer worldserver = (WorldServer) world; - - if (damagesource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { -- this.kill(); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { -+ return false; -+ } -+ this.kill(damagesource); // CraftBukkit -+ // CraftBukkit end - return false; -- } else if (!this.isInvulnerableTo(damagesource) && !this.invisible && !this.isMarker()) { -+ } else if (!this.isInvulnerableTo(damagesource) && (true || !this.invisible) && !this.isMarker()) { // CraftBukkit -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, true, this.invisible)) { -+ return false; -+ } -+ // CraftBukkit end - if (damagesource.is(DamageTypeTags.IS_EXPLOSION)) { - this.brokenByAnything(worldserver, damagesource); -- this.kill(); -+ this.kill(damagesource); // CraftBukkit - return false; - } else if (damagesource.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { - if (this.isOnFire()) { -@@ -473,7 +526,7 @@ - if (damagesource.isCreativePlayer()) { - this.playBrokenSound(); - this.showBreakingParticles(); -- this.kill(); -+ this.kill(damagesource); // CraftBukkit - return true; - } else { - long i = worldserver.getGameTime(); -@@ -485,7 +538,7 @@ - } else { - this.brokenByPlayer(worldserver, damagesource); - this.showBreakingParticles(); -- this.kill(); -+ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event - } +@@ -436,12 +479,22 @@ + } else if (!worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && damagesource.getEntity() instanceof EntityInsentient) { + return false; + } else if (damagesource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { +- this.kill(worldserver); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { ++ return false; ++ } ++ this.kill(worldserver, damagesource); // CraftBukkit ++ // CraftBukkit end + return false; +- } else if (!this.isInvulnerableTo(worldserver, damagesource) && !this.invisible && !this.isMarker()) { ++ } else if (!this.isInvulnerableTo(worldserver, damagesource) && (true || !this.invisible) && !this.isMarker()) { // CraftBukkit ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, true, this.invisible)) { ++ return false; ++ } ++ // CraftBukkit end + if (damagesource.is(DamageTypeTags.IS_EXPLOSION)) { + this.brokenByAnything(worldserver, damagesource); +- this.kill(worldserver); ++ this.kill(worldserver, damagesource); // CraftBukkit + return false; + } else if (damagesource.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { + if (this.isOnFire()) { +@@ -474,7 +527,7 @@ + if (damagesource.isCreativePlayer()) { + this.playBrokenSound(); + this.showBreakingParticles(); +- this.kill(worldserver); ++ this.kill(worldserver, damagesource); // CraftBukkit + return true; + } else { + long i = worldserver.getGameTime(); +@@ -486,7 +539,7 @@ + } else { + this.brokenByPlayer(worldserver, damagesource); + this.showBreakingParticles(); +- this.kill(worldserver); ++ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event + } - return true; -@@ -539,7 +592,7 @@ + return true; +@@ -536,7 +589,7 @@ f1 -= f; if (f1 <= 0.5F) { this.brokenByAnything(worldserver, damagesource); -- this.kill(); -+ this.kill(damagesource); // CraftBukkit +- this.kill(worldserver); ++ this.kill(worldserver, damagesource); // CraftBukkit } else { this.setHealth(f1); this.gameEvent(GameEvent.ENTITY_DAMAGE, damagesource.getEntity()); -@@ -551,13 +604,13 @@ +@@ -548,13 +601,13 @@ ItemStack itemstack = new ItemStack(Items.ARMOR_STAND); itemstack.set(DataComponents.CUSTOM_NAME, this.getCustomName()); @@ -158,7 +158,7 @@ ItemStack itemstack; int i; -@@ -565,7 +618,7 @@ +@@ -562,7 +615,7 @@ for (i = 0; i < this.handItems.size(); ++i) { itemstack = (ItemStack) this.handItems.get(i); if (!itemstack.isEmpty()) { @@ -167,7 +167,7 @@ this.handItems.set(i, ItemStack.EMPTY); } } -@@ -573,10 +626,11 @@ +@@ -570,10 +623,11 @@ for (i = 0; i < this.armorItems.size(); ++i) { itemstack = (ItemStack) this.armorItems.get(i); if (!itemstack.isEmpty()) { @@ -180,7 +180,7 @@ } -@@ -667,9 +721,23 @@ +@@ -664,9 +718,23 @@ return this.isSmall(); } @@ -192,13 +192,13 @@ + // CraftBukkit end + @Override - public void kill() { + public void kill(WorldServer worldserver) { - this.remove(Entity.RemovalReason.KILLED); + // CraftBukkit start - pass DamageSource for kill -+ this.kill(null); ++ this.kill(worldserver, null); + } + -+ public void kill(DamageSource damageSource) { ++ public void kill(WorldServer worldserver, DamageSource damageSource) { + org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, (damageSource == null ? this.damageSources().genericKill() : damageSource), drops); // CraftBukkit - call event + this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause + // CraftBukkit end diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityItemFrame.patch index 1be425e0..26a8dd92 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 -@@ -90,6 +90,12 @@ +@@ -91,6 +91,12 @@ @Override protected AxisAlignedBB calculateBoundingBox(BlockPosition blockposition, EnumDirection enumdirection) { @@ -13,19 +13,19 @@ float f = 0.46875F; Vec3D vec3d = Vec3D.atCenterOf(blockposition).relative(enumdirection, -0.46875D); EnumDirection.EnumAxis enumdirection_enumaxis = enumdirection.getAxis(); -@@ -143,6 +149,11 @@ - return false; - } else if (!damagesource.is(DamageTypeTags.IS_EXPLOSION) && !this.getItem().isEmpty()) { - if (!this.level().isClientSide) { +@@ -155,6 +161,11 @@ + if (this.isInvulnerableToBase(damagesource)) { + return false; + } else if (this.shouldDamageDropItem(damagesource)) { + // CraftBukkit start - fire EntityDamageEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.isRemoved()) { + return true; + } + // CraftBukkit end - this.dropItem(damagesource.getEntity(), false); + this.dropItem(worldserver, damagesource.getEntity(), false); this.gameEvent(GameEvent.BLOCK_CHANGE, damagesource.getEntity()); this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); -@@ -255,13 +266,19 @@ +@@ -267,13 +278,19 @@ } public void setItem(ItemStack itemstack, boolean flag) { diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityLeash.patch index 2b0db10d..db338150 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 -@@ -26,6 +26,13 @@ +@@ -27,6 +27,13 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -14,7 +14,7 @@ public class EntityLeash extends BlockAttachedEntity { public static final double OFFSET_Y = 0.375D; -@@ -84,6 +91,15 @@ +@@ -85,6 +92,15 @@ Leashable leashable = (Leashable) iterator.next(); if (leashable.getLeashHolder() == entityhuman) { @@ -30,7 +30,7 @@ leashable.setLeashedTo(this, true); flag = true; } -@@ -92,18 +108,34 @@ +@@ -93,18 +109,34 @@ boolean flag1 = false; if (!flag) { diff --git a/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch b/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch index bfdd9a17..ac5b3f26 100644 --- a/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch +++ b/nms-patches/net/minecraft/world/entity/decoration/EntityPainting.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/decoration/EntityPainting.java +++ b/net/minecraft/world/entity/decoration/EntityPainting.java -@@ -71,7 +71,7 @@ +@@ -72,7 +72,7 @@ public static Optional create(World world, BlockPosition blockposition, EnumDirection enumdirection) { EntityPainting entitypainting = new EntityPainting(world, blockposition); List> list = new ArrayList(); -- Iterable iterable = world.registryAccess().registryOrThrow(Registries.PAINTING_VARIANT).getTagOrEmpty(PaintingVariantTags.PLACEABLE); -+ Iterable> iterable = world.registryAccess().registryOrThrow(Registries.PAINTING_VARIANT).getTagOrEmpty(PaintingVariantTags.PLACEABLE); // CraftBukkit - decompile error +- Iterable iterable = world.registryAccess().lookupOrThrow(Registries.PAINTING_VARIANT).getTagOrEmpty(PaintingVariantTags.PLACEABLE); ++ Iterable> iterable = world.registryAccess().lookupOrThrow(Registries.PAINTING_VARIANT).getTagOrEmpty(PaintingVariantTags.PLACEABLE); // CraftBukkit - decompile error Objects.requireNonNull(list); iterable.forEach(list::add); -@@ -137,22 +137,32 @@ +@@ -138,22 +138,32 @@ @Override protected AxisAlignedBB calculateBoundingBox(BlockPosition blockposition, EnumDirection enumdirection) { diff --git a/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch b/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch index 1c8bbcb5..183c3b95 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch @@ -31,7 +31,7 @@ return entityfallingblock; } -@@ -130,7 +142,7 @@ +@@ -139,7 +151,7 @@ @Override public void tick() { if (this.blockState.isAir()) { @@ -40,52 +40,52 @@ } else { Block block = this.blockState.getBlock(); -@@ -159,7 +171,7 @@ - this.spawnAtLocation((IMaterial) block); - } - -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause - } - } else { - IBlockData iblockdata = this.level().getBlockState(blockposition); -@@ -176,9 +188,15 @@ - this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true); - } +@@ -174,7 +186,7 @@ + this.spawnAtLocation(worldserver, (IMaterial) block); + } -+ // CraftBukkit start -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState)) { -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // SPIGOT-6586 called before the event in previous versions -+ return; -+ } -+ // CraftBukkit end - if (this.level().setBlock(blockposition, this.blockState, 3)) { - ((WorldServer) this.level()).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level().getBlockState(blockposition))); -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); - if (block instanceof Fallable) { - ((Fallable) block).onLand(this.level(), blockposition, this.blockState, iblockdata, this); +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause + } + } else { + IBlockData iblockdata = this.level().getBlockState(blockposition); +@@ -191,9 +203,15 @@ + this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true); } -@@ -206,19 +224,19 @@ + ++ // CraftBukkit start ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState)) { ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // SPIGOT-6586 called before the event in previous versions ++ return; ++ } ++ // CraftBukkit end + if (this.level().setBlock(blockposition, this.blockState, 3)) { + ((WorldServer) this.level()).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level().getBlockState(blockposition))); +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + if (block instanceof Fallable) { + ((Fallable) block).onLand(this.level(), blockposition, this.blockState, iblockdata, this); + } +@@ -221,19 +239,19 @@ + } } + } else if (this.dropItem && worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause + this.callOnBrokenAfterFall(block, blockposition); + this.spawnAtLocation(worldserver, (IMaterial) block); } - } else if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + } else { - this.discard(); + this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause - this.callOnBrokenAfterFall(block, blockposition); - this.spawnAtLocation((IMaterial) block); + if (this.dropItem && worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + this.callOnBrokenAfterFall(block, blockposition); + this.spawnAtLocation(worldserver, (IMaterial) block); + } } } else { - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause - if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { - this.callOnBrokenAfterFall(block, blockposition); - this.spawnAtLocation((IMaterial) block); - } ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + this.callOnBrokenAfterFall(block, blockposition); } - } else { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - this.callOnBrokenAfterFall(block, blockposition); } - } diff --git a/nms-patches/net/minecraft/world/entity/item/EntityItem.patch b/nms-patches/net/minecraft/world/entity/item/EntityItem.patch index 1613016c..7dac6e9b 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityItem.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityItem.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/item/EntityItem.java +++ b/net/minecraft/world/entity/item/EntityItem.java @@ -34,6 +34,15 @@ - import net.minecraft.world.level.portal.DimensionTransition; + import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -44,7 +44,7 @@ this.xo = this.getX(); this.yo = this.getY(); -@@ -187,9 +200,11 @@ +@@ -188,9 +201,11 @@ this.mergeWithNeighbours(); } @@ -56,7 +56,7 @@ this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing(); if (!this.level().isClientSide) { -@@ -201,7 +216,13 @@ +@@ -202,7 +217,13 @@ } if (!this.level().isClientSide && this.age >= 6000) { @@ -71,7 +71,7 @@ } } -@@ -284,11 +305,16 @@ +@@ -287,11 +308,16 @@ } private static void merge(EntityItem entityitem, ItemStack itemstack, EntityItem entityitem1, ItemStack itemstack1) { @@ -89,9 +89,9 @@ } } -@@ -309,12 +335,17 @@ - } else if (this.level().isClientSide) { - return true; +@@ -320,12 +346,17 @@ + } else if (!this.getItem().canBeHurtBy(damagesource)) { + return false; } else { + // CraftBukkit start + if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { @@ -108,7 +108,7 @@ } return true; -@@ -366,7 +397,7 @@ +@@ -382,7 +413,7 @@ } if (this.getItem().isEmpty()) { @@ -117,7 +117,7 @@ } } -@@ -378,10 +409,50 @@ +@@ -394,10 +425,50 @@ Item item = itemstack.getItem(); int i = itemstack.getCount(); diff --git a/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch b/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch index 75d24428..d4ea5a67 100644 --- a/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch +++ b/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/item/EntityTNTPrimed.java +++ b/net/minecraft/world/entity/item/EntityTNTPrimed.java -@@ -24,6 +24,12 @@ +@@ -27,6 +27,12 @@ import net.minecraft.world.level.material.Fluid; - import net.minecraft.world.level.portal.DimensionTransition; + import net.minecraft.world.level.portal.TeleportTransition; +// CraftBukkit start; +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -13,16 +13,15 @@ public class EntityTNTPrimed extends Entity implements TraceableEntity { private static final DataWatcherObject DATA_FUSE_ID = DataWatcher.defineId(EntityTNTPrimed.class, DataWatcherRegistry.INT); -@@ -45,6 +51,8 @@ - @Nullable +@@ -51,6 +57,7 @@ public EntityLiving owner; private boolean usedPortal; -+ public float yield = 4; // CraftBukkit - add field + public float explosionPower; + public boolean isIncendiary = false; // CraftBukkit - add field public EntityTNTPrimed(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -99,10 +107,13 @@ +@@ -107,10 +114,13 @@ this.setFuse(i); if (i <= 0) { @@ -37,19 +36,17 @@ } else { this.updateInWaterStateAndDoFluidPushing(); if (this.level().isClientSide) { -@@ -113,9 +124,14 @@ +@@ -121,7 +131,13 @@ } private void explode() { -- float f = 4.0F; +- this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), this.explosionPower, false, World.a.TNT); + // CraftBukkit start -+ // float f = 4.0F; -+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive)this.getBukkitEntity()); - -- this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, false, World.a.TNT); -+ if (!event.isCancelled()) { -+ this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT); ++ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); ++ if (event.isCancelled()) { ++ return; + } ++ this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, 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/Bogged.patch b/nms-patches/net/minecraft/world/entity/monster/Bogged.patch index 05fc9bf8..8a45b0e8 100644 --- a/nms-patches/net/minecraft/world/entity/monster/Bogged.patch +++ b/nms-patches/net/minecraft/world/entity/monster/Bogged.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/monster/Bogged.java +++ b/net/minecraft/world/entity/monster/Bogged.java @@ -79,6 +79,12 @@ - ItemStack itemstack = entityhuman.getItemInHand(enumhand); + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; - if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { -+ this.getEntityData().markDirty(Bogged.DATA_SHEARED); // CraftBukkit - mark dirty to restore sheared state to clients -+ return EnumInteractionResult.PASS; -+ } -+ // CraftBukkit end - this.shear(SoundCategory.PLAYERS); - this.gameEvent(GameEvent.SHEAR, entityhuman); - if (!this.level().isClientSide) { ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { ++ this.getEntityData().markDirty(Bogged.DATA_SHEARED); // CraftBukkit - mark dirty to restore sheared state to clients ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + this.shear(worldserver, SoundCategory.PLAYERS, itemstack); + this.gameEvent(GameEvent.SHEAR, entityhuman); + itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch b/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch index 98548119..f70d92bc 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityCaveSpider.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityCaveSpider.java +++ b/net/minecraft/world/entity/monster/EntityCaveSpider.java -@@ -39,7 +39,7 @@ +@@ -40,7 +40,7 @@ } if (b0 > 0) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch b/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch index a0cc7042..158cbcb1 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 -@@ -43,6 +43,13 @@ +@@ -42,6 +42,13 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; @@ -11,10 +11,10 @@ +import org.bukkit.event.entity.ExplosionPrimeEvent; +// CraftBukkit end + - public class EntityCreeper extends EntityMonster implements PowerableMob { + public class EntityCreeper extends EntityMonster { private static final DataWatcherObject DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT); -@@ -53,6 +60,7 @@ +@@ -52,6 +59,7 @@ public int maxSwell = 30; public int explosionRadius = 3; private int droppedSkulls; @@ -22,7 +22,7 @@ public EntityCreeper(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -216,9 +224,20 @@ +@@ -214,9 +222,20 @@ @Override public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { super.thunderHit(worldserver, entitylightning); @@ -43,7 +43,7 @@ @Override protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); -@@ -228,8 +247,9 @@ +@@ -226,8 +245,9 @@ this.level().playSound(entityhuman, this.getX(), this.getY(), this.getZ(), soundeffect, this.getSoundSource(), 1.0F, this.random.nextFloat() * 0.4F + 0.8F); if (!this.level().isClientSide) { @@ -55,7 +55,7 @@ } else { itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); @@ -246,11 +266,20 @@ - if (!this.level().isClientSide) { + if (world instanceof WorldServer worldserver) { float f = this.isPowered() ? 2.0F : 1.0F; + // CraftBukkit start @@ -63,10 +63,10 @@ + if (!event.isCancelled()) { + // CraftBukkit end this.dead = true; -- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB); -+ this.level().explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customCausingEntityDamager(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit +- worldserver.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB); ++ worldserver.explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customCausingEntityDamager(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit this.spawnLingeringCloud(); - this.triggerOnDeathMobEffects(Entity.RemovalReason.KILLED); + this.triggerOnDeathMobEffects(worldserver, Entity.RemovalReason.KILLED); - this.discard(); + this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityDrowned.patch b/nms-patches/net/minecraft/world/entity/monster/EntityDrowned.patch deleted file mode 100644 index 80279ce7..00000000 --- a/nms-patches/net/minecraft/world/entity/monster/EntityDrowned.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/monster/EntityDrowned.java -+++ b/net/minecraft/world/entity/monster/EntityDrowned.java -@@ -247,7 +247,7 @@ - - @Override - public void performRangedAttack(EntityLiving entityliving, float f) { -- EntityThrownTrident entitythrowntrident = new EntityThrownTrident(this.level(), this, new ItemStack(Items.TRIDENT)); -+ EntityThrownTrident entitythrowntrident = new EntityThrownTrident(this.level(), this, this.getItemInHand(net.minecraft.world.entity.projectile.ProjectileHelper.getWeaponHoldingHand(this, Items.TRIDENT))); // CraftBukkit - Use Trident in hand like skeletons (SPIGOT-7025) - double d0 = entityliving.getX() - this.getX(); - double d1 = entityliving.getY(0.3333333333333333D) - entitythrowntrident.getY(); - double d2 = entityliving.getZ() - this.getZ(); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch b/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch index b210296b..4f24f259 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch @@ -39,7 +39,7 @@ } -@@ -479,9 +495,11 @@ +@@ -466,9 +482,11 @@ if (iblockdata2 != null) { iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level(), blockposition); if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { @@ -51,7 +51,7 @@ } } -@@ -520,9 +538,11 @@ +@@ -507,9 +525,11 @@ 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 e49d29c8..5a033402 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityEvoker.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityEvoker.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityEvoker.java +++ b/net/minecraft/world/entity/monster/EntityEvoker.java -@@ -213,7 +213,7 @@ +@@ -212,7 +212,7 @@ worldserver.getScoreboard().addPlayerToTeam(entityvex.getScoreboardName(), scoreboardteam); } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch b/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch index 9fde3255..69f630ae 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityGhast.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityGhast.java +++ b/net/minecraft/world/entity/monster/EntityGhast.java -@@ -332,6 +332,8 @@ +@@ -333,6 +333,8 @@ EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, vec3d1.normalize(), this.ghast.getExplosionPower()); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityGuardian.patch b/nms-patches/net/minecraft/world/entity/monster/EntityGuardian.patch index b36812b7..9090b0c4 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityGuardian.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityGuardian.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityGuardian.java +++ b/net/minecraft/world/entity/monster/EntityGuardian.java -@@ -59,6 +59,7 @@ +@@ -60,6 +60,7 @@ private boolean clientSideTouchedGround; @Nullable public PathfinderGoalRandomStroll randomStrollGoal; @@ -8,7 +8,7 @@ public EntityGuardian(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -74,7 +75,7 @@ +@@ -75,7 +76,7 @@ PathfinderGoalMoveTowardsRestriction pathfindergoalmovetowardsrestriction = new PathfinderGoalMoveTowardsRestriction(this, 1.0D); this.randomStrollGoal = new PathfinderGoalRandomStroll(this, 1.0D, 80); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch b/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch index c708cf10..a3cce2e7 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityGuardianElder.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/EntityGuardianElder.java +++ b/net/minecraft/world/entity/monster/EntityGuardianElder.java @@ -67,7 +67,7 @@ - super.customServerAiStep(); + super.customServerAiStep(worldserver); if ((this.tickCount + this.getId()) % 1200 == 0) { MobEffect mobeffect = new MobEffect(MobEffects.DIG_SLOWDOWN, 6000, 2); -- List list = MobEffectUtil.addEffectToPlayersAround((WorldServer) this.level(), this, this.position(), 50.0D, mobeffect, 1200); -+ List list = MobEffectUtil.addEffectToPlayersAround((WorldServer) this.level(), this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- List list = MobEffectUtil.addEffectToPlayersAround(worldserver, this, this.position(), 50.0D, mobeffect, 1200); ++ List list = MobEffectUtil.addEffectToPlayersAround(worldserver, this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit list.forEach((entityplayer) -> { entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F)); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch index e16a1cf3..6bcb758d 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerIllusioner.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java +++ b/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java -@@ -217,7 +217,7 @@ +@@ -218,7 +218,7 @@ @Override protected void performSpellCasting() { @@ -9,7 +9,7 @@ } @Nullable -@@ -268,7 +268,7 @@ +@@ -269,7 +269,7 @@ @Override protected void performSpellCasting() { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch b/nms-patches/net/minecraft/world/entity/monster/EntityIllagerWizard.patch index 2ec51fd6..0b26a806 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 -@@ -17,6 +17,10 @@ +@@ -18,6 +18,10 @@ import net.minecraft.world.entity.ai.goal.PathfinderGoal; import net.minecraft.world.level.World; @@ -11,7 +11,7 @@ public abstract class EntityIllagerWizard extends EntityIllagerAbstract { private static final DataWatcherObject DATA_SPELL_CASTING_ID = DataWatcher.defineId(EntityIllagerWizard.class, DataWatcherRegistry.BYTE); -@@ -158,6 +162,11 @@ +@@ -159,6 +163,11 @@ public void tick() { --this.attackWarmupDelay; if (this.attackWarmupDelay == 0) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch b/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch index 2889edc2..94a1d848 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityPhantom.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/monster/EntityPhantom.java +++ b/net/minecraft/world/entity/monster/EntityPhantom.java -@@ -521,14 +521,14 @@ - List list = EntityPhantom.this.level().getNearbyPlayers(this.attackTargeting, EntityPhantom.this, EntityPhantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D)); +@@ -522,14 +522,14 @@ + List list = worldserver.getNearbyPlayers(this.attackTargeting, EntityPhantom.this, EntityPhantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D)); if (!list.isEmpty()) { - list.sort(Comparator.comparing(Entity::getY).reversed()); @@ -11,7 +11,7 @@ while (iterator.hasNext()) { EntityHuman entityhuman = (EntityHuman) iterator.next(); - if (EntityPhantom.this.canAttack(entityhuman, PathfinderTargetCondition.DEFAULT)) { + if (EntityPhantom.this.canAttack(worldserver, entityhuman, PathfinderTargetCondition.DEFAULT)) { - EntityPhantom.this.setTarget(entityhuman); + EntityPhantom.this.setTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason return true; diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch b/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch index 6f3cac8b..f0a0fd53 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityPigZombie.patch @@ -41,4 +41,4 @@ + // CraftBukkit end } - public static boolean checkZombifiedPiglinSpawnRules(EntityTypes entitytypes, GeneratorAccess generatoraccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, RandomSource randomsource) { + public static boolean checkZombifiedPiglinSpawnRules(EntityTypes entitytypes, GeneratorAccess generatoraccess, EntitySpawnReason entityspawnreason, BlockPosition blockposition, RandomSource randomsource) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch b/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch index 5697e18b..45b728cf 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityPillager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityPillager.java +++ b/net/minecraft/world/entity/monster/EntityPillager.java -@@ -48,6 +48,10 @@ +@@ -50,6 +50,10 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.WorldAccess; @@ -11,7 +11,7 @@ public class EntityPillager extends EntityIllagerAbstract implements ICrossbow, InventoryCarrier { private static final DataWatcherObject IS_CHARGING_CROSSBOW = DataWatcher.defineId(EntityPillager.class, DataWatcherRegistry.BOOLEAN); -@@ -195,7 +199,7 @@ +@@ -198,7 +202,7 @@ ItemStack itemstack1 = this.inventory.addItem(itemstack); if (itemstack1.isEmpty()) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch b/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch index a9687a15..ac3d0c85 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityRavager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityRavager.java +++ b/net/minecraft/world/entity/monster/EntityRavager.java -@@ -43,6 +43,10 @@ +@@ -45,6 +45,10 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -10,16 +10,16 @@ + public class EntityRavager extends EntityRaider { - private static final Predicate NO_RAVAGER_AND_ALIVE = (entity) -> { -@@ -147,6 +151,11 @@ - Block block = iblockdata.getBlock(); + private static final Predicate ROAR_TARGET_WITH_GRIEFING = (entity) -> { +@@ -161,6 +165,11 @@ + Block block = iblockdata.getBlock(); - if (block instanceof BlockLeaves) { -+ // CraftBukkit start -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) { -+ continue; -+ } -+ // CraftBukkit end - flag = this.level().destroyBlock(blockposition, true, this) || flag; + if (block instanceof BlockLeaves) { ++ // CraftBukkit start ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) { ++ continue; ++ } ++ // CraftBukkit end + flag = worldserver.destroyBlock(blockposition, true, this) || flag; + } } - } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch b/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch index 14e78b06..611d16c8 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityShulker.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityShulker.java +++ b/net/minecraft/world/entity/monster/EntityShulker.java -@@ -58,6 +58,12 @@ +@@ -59,6 +59,12 @@ import net.minecraft.world.phys.Vec3D; import org.joml.Vector3f; @@ -13,7 +13,7 @@ public class EntityShulker extends EntityGolem implements VariantHolder>, IMonster { private static final MinecraftKey COVERED_ARMOR_MODIFIER_ID = MinecraftKey.withDefaultNamespace("covered"); -@@ -401,6 +407,14 @@ +@@ -402,6 +408,14 @@ EnumDirection enumdirection = this.findAttachableSurface(blockposition1); if (enumdirection != null) { @@ -28,7 +28,7 @@ this.unRide(); this.setAttachFace(enumdirection); this.playSound(SoundEffects.SHULKER_TELEPORT, 1.0F, 1.0F); -@@ -471,7 +485,7 @@ +@@ -472,7 +486,7 @@ if (entityshulker != null) { entityshulker.setVariant(this.getVariant()); entityshulker.moveTo(vec3d); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch index e1f17591..e2516bea 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySilverfish.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntitySilverfish.java +++ b/net/minecraft/world/entity/monster/EntitySilverfish.java -@@ -30,6 +30,11 @@ +@@ -31,6 +31,11 @@ import net.minecraft.world.level.block.BlockMonsterEggs; import net.minecraft.world.level.block.state.IBlockData; @@ -12,7 +12,7 @@ public class EntitySilverfish extends EntityMonster { @Nullable -@@ -157,6 +162,11 @@ +@@ -160,6 +165,11 @@ Block block = iblockdata.getBlock(); if (block instanceof BlockMonsterEggs) { @@ -21,10 +21,10 @@ + continue; + } + // CraftBukkit end - if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (getServerLevel(world).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { world.destroyBlock(blockposition1, true, this.silverfish); } else { -@@ -226,9 +236,14 @@ +@@ -229,9 +239,14 @@ IBlockData iblockdata = world.getBlockState(blockposition); if (BlockMonsterEggs.isCompatibleHostBlock(iblockdata)) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch index 73a2ea06..ddc3ae31 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySkeleton.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/EntitySkeleton.java +++ b/net/minecraft/world/entity/monster/EntitySkeleton.java -@@ -91,7 +91,7 @@ +@@ -99,7 +99,7 @@ + this.level().levelEvent((EntityHuman) null, 1048, this.blockPosition(), 0); + } + +- }); ++ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons } - protected void doFreezeConversion() { -- this.convertTo(EntityTypes.STRAY, true); -+ this.convertTo(EntityTypes.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons - if (!this.isSilent()) { - this.level().levelEvent((EntityHuman) null, 1048, this.blockPosition(), 0); - } + @Override diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch index ba4d0f47..4fceb68c 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySkeletonAbstract.patch @@ -1,23 +1,21 @@ --- a/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java +++ b/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java -@@ -204,8 +204,19 @@ - double d3 = Math.sqrt(d0 * d0 + d2 * d2); +@@ -207,7 +207,17 @@ + World world = this.level(); - entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level().getDifficulty().getId() * 4)); -+ // CraftBukkit start -+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), null, entityarrow, net.minecraft.world.EnumHand.MAIN_HAND, 0.8F, true); -+ if (event.isCancelled()) { -+ event.getProjectile().remove(); -+ return; -+ } + if (world instanceof WorldServer worldserver) { +- IProjectile.spawnProjectileUsingShoot(entityarrow, worldserver, itemstack1, d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - worldserver.getDifficulty().getId() * 4)); ++ // CraftBukkit start ++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), null, entityarrow, net.minecraft.world.EnumHand.MAIN_HAND, 0.8F, true); ++ if (event.isCancelled()) { ++ event.getProjectile().remove(); ++ return; ++ } + -+ if (event.getProjectile() == entityarrow.getBukkitEntity()) { -+ this.level().addFreshEntity(entityarrow); -+ } -+ // CraftBukkit end - this.playSound(SoundEffects.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -- this.level().addFreshEntity(entityarrow); -+ // this.level().addFreshEntity(entityarrow); // CraftBukkit - moved up - } ++ if (event.getProjectile() == entityarrow.getBukkitEntity()) { ++ IProjectile.spawnProjectileUsingShoot(entityarrow, worldserver, itemstack1, d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - worldserver.getDifficulty().getId() * 4)); ++ } ++ // CraftBukkit end + } - protected EntityArrow getArrow(ItemStack itemstack, float f, @Nullable ItemStack itemstack1) { + this.playSound(SoundEffects.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch b/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch index 5d98d3ae..73994c5c 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntitySlime.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/EntitySlime.java +++ b/net/minecraft/world/entity/monster/EntitySlime.java -@@ -45,6 +45,15 @@ - import net.minecraft.world.level.levelgen.SeededRandom; +@@ -47,6 +47,15 @@ import net.minecraft.world.phys.Vec3D; + import net.minecraft.world.scores.ScoreboardTeam; +// CraftBukkit start +import java.util.ArrayList; @@ -16,7 +16,7 @@ public class EntitySlime extends EntityInsentient implements IMonster { private static final DataWatcherObject ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT); -@@ -195,11 +204,18 @@ +@@ -197,11 +206,18 @@ @Override public EntityTypes getType() { @@ -36,9 +36,9 @@ int i = this.getSize(); if (!this.level().isClientSide && i > 1 && this.isDeadOrDying()) { -@@ -210,6 +226,19 @@ - int j = i / 2; +@@ -211,18 +227,45 @@ int k = 2 + this.random.nextInt(3); + ScoreboardTeam scoreboardteam = this.getTeam(); + // CraftBukkit start + SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), k); @@ -56,19 +56,24 @@ for (int l = 0; l < k; ++l) { float f2 = ((float) (l % 2) - 0.5F) * f1; float f3 = ((float) (l / 2) - 0.5F) * f1; -@@ -225,12 +254,21 @@ - entityslime.setInvulnerable(this.isInvulnerable()); + +- this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, scoreboardteam), EntitySpawnReason.TRIGGERED, (entityslime) -> { ++ EntitySlime converted = this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, scoreboardteam), EntitySpawnReason.TRIGGERED, (entityslime) -> { // CraftBukkit entityslime.setSize(j, true); entityslime.moveTo(this.getX() + (double) f2, this.getY() + 0.5D, this.getZ() + (double) f3, this.random.nextFloat() * 360.0F, 0.0F); -- this.level().addFreshEntity(entityslime); -+ slimes.add(entityslime); // CraftBukkit - } - } +- }); ++ // CraftBukkit start ++ }, null, null); ++ if (converted != null) { ++ slimes.add(converted); ++ } ++ // CraftBukkit end ++ } + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) { + super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause + return; -+ } + } + for (EntityLiving living : slimes) { + this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason + } diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch b/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch index 53c7c308..a17b5b26 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityStrider.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityStrider.java +++ b/net/minecraft/world/entity/monster/EntityStrider.java -@@ -351,7 +351,14 @@ +@@ -350,7 +350,14 @@ boolean flag2 = flag1; diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch b/nms-patches/net/minecraft/world/entity/monster/EntityVex.patch index 79cc944e..4f8bf90a 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 -@@ -383,7 +383,7 @@ +@@ -381,7 +381,7 @@ @Override public void start() { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch b/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch index 85c27b27..d0b562f1 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityWitch.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityWitch.java +++ b/net/minecraft/world/entity/monster/EntityWitch.java -@@ -125,7 +125,7 @@ +@@ -126,7 +126,7 @@ PotionContents potioncontents = (PotionContents) itemstack.get(DataComponents.POTION_CONTENTS); if (itemstack.is(Items.POTION) && potioncontents != null) { diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch b/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch index e447f1d8..1eed7427 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityZombie.java +++ b/net/minecraft/world/entity/monster/EntityZombie.java -@@ -65,6 +65,15 @@ +@@ -67,6 +67,15 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -16,7 +16,7 @@ public class EntityZombie extends EntityMonster { private static final MinecraftKey SPEED_MODIFIER_BABY_ID = MinecraftKey.withDefaultNamespace("baby"); -@@ -89,6 +98,7 @@ +@@ -91,6 +100,7 @@ private boolean canBreakDoors; private int inWaterTime; public int conversionTime; @@ -24,7 +24,7 @@ public EntityZombie(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -205,7 +215,10 @@ +@@ -203,7 +213,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(); } -@@ -222,6 +235,7 @@ +@@ -220,6 +233,7 @@ } super.tick(); @@ -44,7 +44,7 @@ } @Override -@@ -256,6 +270,7 @@ +@@ -254,6 +268,7 @@ } public void startUnderWaterConversion(int i) { @@ -52,36 +52,65 @@ this.conversionTime = i; this.getEntityData().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true); } -@@ -269,11 +284,15 @@ +@@ -267,26 +282,39 @@ } protected void convertToZombieType(EntityTypes entitytypes) { -- EntityZombie entityzombie = (EntityZombie) this.convertTo(entitytypes, true); -+ EntityZombie entityzombie = (EntityZombie) this.convertTo(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED); - - if (entityzombie != null) { +- this.convertTo(entitytypes, ConversionParams.single(this, true, true), (entityzombie) -> { ++ EntityZombie converted = this.convertTo(entitytypes, ConversionParams.single(this, true, true), (entityzombie) -> { // CraftBukkit entityzombie.handleAttributes(entityzombie.level().getCurrentDifficultyAt(entityzombie.blockPosition()).getSpecialMultiplier()); - entityzombie.setCanBreakDoors(entityzombie.supportsBreakDoorGoal() && this.canBreakDoors()); -+ // CraftBukkit start - SPIGOT-5208: End conversion to stop event spam -+ } else { -+ ((Zombie) getBukkitEntity()).setConversionTime(-1); -+ // CraftBukkit end - } +- }); ++ // CraftBukkit start ++ }, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED); ++ if (converted == null) { ++ ((Zombie) getBukkitEntity()).setConversionTime(-1); // CraftBukkit - SPIGOT-5208: End conversion to stop event spam ++ } ++ // CraftBukkit end + } + @VisibleForTesting + public boolean convertVillagerToZombieVillager(WorldServer worldserver, EntityVillager entityvillager) { ++ // CraftBukkit start ++ return convertVillagerToZombieVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION) != null; ++ } ++ ++ public static EntityZombieVillager convertVillagerToZombieVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { ++ // CraftBukkit end + EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, ConversionParams.single(entityvillager, true, true), (entityzombievillager1) -> { + entityzombievillager1.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager1.blockPosition()), EntitySpawnReason.CONVERSION, new EntityZombie.GroupDataZombie(false, true)); + entityzombievillager1.setVillagerData(entityvillager.getVillagerData()); + entityzombievillager1.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE)); + entityzombievillager1.setTradeOffers(entityvillager.getOffers().copy()); + entityzombievillager1.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); + } + +- }); ++ }, transformReason, spawnReason); + +- return entityzombievillager != null; ++ return entityzombievillager; ++ // CraftBukkit end } -@@ -312,9 +331,9 @@ - if (EntityPositionTypes.isSpawnPositionOk(entitytypes, this.level(), blockposition) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level().random)) { + + protected boolean isSunSensitive() { +@@ -324,9 +352,9 @@ + if (EntityPositionTypes.isSpawnPositionOk(entitytypes, worldserver, blockposition) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EntitySpawnReason.REINFORCEMENT, blockposition, worldserver.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())) { + if (!worldserver.hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && worldserver.isUnobstructed(entityzombie) && worldserver.noCollision((Entity) entityzombie) && (entityzombie.canSpawnInLiquids() || !worldserver.containsAnyLiquid(entityzombie.getBoundingBox()))) { - entityzombie.setTarget(entityliving); + entityzombie.setTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit - entityzombie.finalizeSpawn(worldserver, this.level().getCurrentDifficultyAt(entityzombie.blockPosition()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null); + entityzombie.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombie.blockPosition()), EntitySpawnReason.REINFORCEMENT, (GroupDataEntity) null); - worldserver.addFreshEntityWithPassengers(entityzombie); + worldserver.addFreshEntityWithPassengers(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE); AttributeModifier attributemodifier = attributemodifiable.getModifier(EntityZombie.REINFORCEMENT_CALLER_CHARGE_ID); double d0 = attributemodifier != null ? attributemodifier.amount() : 0.0D; -@@ -340,7 +359,14 @@ +@@ -352,7 +380,14 @@ float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) { @@ -97,50 +126,17 @@ } } -@@ -415,8 +441,17 @@ - if (worldserver.getDifficulty() != EnumDifficulty.HARD && this.random.nextBoolean()) { - return flag; - } -+ // 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); -+ // CraftBukkit end - - if (entityzombievillager != null) { - entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true)); -@@ -424,15 +459,17 @@ - entityzombievillager.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE)); - entityzombievillager.setTradeOffers(entityvillager.getOffers().copy()); - 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; - } -- } +@@ -385,7 +420,7 @@ -- return flag; -+ return entityzombievillager; -+ } -+ // CraftBukkit end + @Override + public EntityTypes getType() { +- return super.getType(); ++ return (EntityTypes) super.getType(); // CraftBukkit - decompile error } - @Override -@@ -483,7 +520,7 @@ - entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null); + protected boolean canSpawnInLiquids() { +@@ -496,7 +531,7 @@ + entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EntitySpawnReason.JOCKEY, (GroupDataEntity) null); entitychicken1.setChickenJockey(true); this.startRiding(entitychicken1); - worldaccess.addFreshEntity(entitychicken1); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch b/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch index dab22fcd..ae2ac43b 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityZombieHusk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EntityZombieHusk.java +++ b/net/minecraft/world/entity/monster/EntityZombieHusk.java -@@ -58,7 +58,7 @@ +@@ -59,7 +59,7 @@ if (flag && this.getMainHandItem().isEmpty() && entity instanceof EntityLiving) { float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); diff --git a/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch b/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch index bf1c47db..96e3b9c0 100644 --- a/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch +++ b/nms-patches/net/minecraft/world/entity/monster/EntityZombieVillager.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/world/entity/monster/EntityZombieVillager.java +++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java -@@ -51,6 +51,13 @@ +@@ -52,6 +52,14 @@ import net.minecraft.world.level.block.state.IBlockData; import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.server.MinecraftServer; ++import net.minecraft.world.entity.npc.EntityVillager; +import org.bukkit.entity.ZombieVillager; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityTransformEvent; @@ -14,7 +15,7 @@ public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -68,6 +75,7 @@ +@@ -69,6 +77,7 @@ @Nullable private MerchantRecipeList tradeOffers; private int villagerXp; @@ -22,7 +23,7 @@ public EntityZombieVillager(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -86,7 +94,7 @@ +@@ -87,7 +96,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); @@ -31,7 +32,7 @@ Logger logger = EntityZombieVillager.LOGGER; Objects.requireNonNull(logger); -@@ -121,7 +129,7 @@ +@@ -122,7 +131,7 @@ } if (nbttagcompound.contains("Offers")) { @@ -40,7 +41,7 @@ Logger logger1 = EntityZombieVillager.LOGGER; Objects.requireNonNull(logger1); -@@ -148,6 +156,10 @@ +@@ -149,6 +158,10 @@ public void tick() { if (!this.level().isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); @@ -51,7 +52,7 @@ this.villagerConversionTime -= i; if (this.villagerConversionTime <= 0) { -@@ -156,6 +168,7 @@ +@@ -157,6 +170,7 @@ } super.tick(); @@ -59,7 +60,7 @@ } @Override -@@ -196,8 +209,10 @@ +@@ -197,8 +211,10 @@ this.conversionStarter = uuid; this.villagerConversionTime = i; this.getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, true); @@ -72,29 +73,20 @@ this.level().broadcastEntityEvent(this, (byte) 16); } -@@ -214,12 +229,20 @@ +@@ -215,10 +231,11 @@ } private void finishConversion(WorldServer worldserver) { -- EntityVillager entityvillager = (EntityVillager) this.convertTo(EntityTypes.VILLAGER, false); -+ // CraftBukkit start -+ EntityVillager entityvillager = (EntityVillager) this.convertTo(EntityTypes.VILLAGER, false, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED); -+ if (entityvillager == null) { -+ ((ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam -+ return; -+ } -+ // CraftBukkit end - - if (entityvillager != null) { -+ this.forceDrops = true; // CraftBukkit - Iterator iterator = this.dropPreservedEquipment((itemstack) -> { +- this.convertTo(EntityTypes.VILLAGER, ConversionParams.single(this, false, false), (entityvillager) -> { ++ EntityVillager converted = this.convertTo(EntityTypes.VILLAGER, ConversionParams.single(this, false, false), (entityvillager) -> { // CraftBukkit + Iterator iterator = this.dropPreservedEquipment(worldserver, (itemstack) -> { return !EnchantmentManager.has(itemstack, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE); }).iterator(); + this.forceDrops = false; // CraftBukkit while (iterator.hasNext()) { EnumItemSlot enumitemslot = (EnumItemSlot) iterator.next(); -@@ -249,7 +272,7 @@ +@@ -248,12 +265,16 @@ } } @@ -103,3 +95,14 @@ if (!this.isSilent()) { worldserver.levelEvent((EntityHuman) null, 1027, this.blockPosition(), 0); } +- +- }); ++ // CraftBukkit start ++ }, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED); ++ if (converted == null) { ++ ((ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam ++ } ++ // CraftBukkit end + } + + @VisibleForTesting diff --git a/nms-patches/net/minecraft/world/entity/monster/creaking/CreakingTransient.patch b/nms-patches/net/minecraft/world/entity/monster/creaking/CreakingTransient.patch new file mode 100644 index 00000000..bbce5b44 --- /dev/null +++ b/nms-patches/net/minecraft/world/entity/monster/creaking/CreakingTransient.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/entity/monster/creaking/CreakingTransient.java ++++ b/net/minecraft/world/entity/monster/creaking/CreakingTransient.java +@@ -97,7 +97,7 @@ + } + } + +- this.setRemoved(Entity.RemovalReason.DISCARDED); ++ this.setRemoved(Entity.RemovalReason.DISCARDED, null); // CraftBukkit - add Bukkit remove cause + return; + } + } +@@ -149,7 +149,7 @@ + } + } + +- this.remove(Entity.RemovalReason.DISCARDED); ++ this.remove(Entity.RemovalReason.DISCARDED, null); // CraftBukkit - add Bukkit remove cause + } + + @Override diff --git a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglin.patch index 74c59c42..a18f0f58 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 @@ +@@ -57,6 +57,18 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -19,7 +19,7 @@ public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow, InventoryCarrier { private static final DataWatcherObject DATA_BABY_ID = DataWatcher.defineId(EntityPiglin.class, DataWatcherRegistry.BOOLEAN); -@@ -73,6 +85,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.ITEM_PICKUP_COOLDOWN_TICKS, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, new MemoryModuleType[]{MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT}); @@ -30,7 +30,7 @@ public EntityPiglin(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -91,6 +107,14 @@ +@@ -94,6 +110,14 @@ } this.writeInventoryToTag(nbttagcompound, this.registryAccess()); @@ -45,18 +45,18 @@ } @Override -@@ -99,6 +123,10 @@ +@@ -102,6 +126,10 @@ this.setBaby(nbttagcompound.getBoolean("IsBaby")); this.setCannotHunt(nbttagcompound.getBoolean("CannotHunt")); this.readInventoryFromTag(nbttagcompound, this.registryAccess()); + // CraftBukkit start -+ 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)); ++ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new)); ++ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new)); + // CraftBukkit end } @VisibleForDebug -@@ -216,7 +244,7 @@ +@@ -221,7 +249,7 @@ @Override public BehaviorController getBrain() { @@ -65,7 +65,7 @@ } @Override -@@ -349,7 +377,7 @@ +@@ -366,7 +394,7 @@ } protected void holdInOffHand(ItemStack itemstack) { @@ -74,7 +74,7 @@ this.setItemSlot(EnumItemSlot.OFFHAND, itemstack); this.setGuaranteedDrop(EnumItemSlot.OFFHAND); } else { -@@ -375,8 +403,8 @@ +@@ -392,8 +420,8 @@ if (EnchantmentManager.has(itemstack1, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE)) { return false; } else { @@ -83,9 +83,9 @@ + boolean flag = PiglinAI.isLovedItem(itemstack, this) || itemstack.is(Items.CROSSBOW); // CraftBukkit + boolean flag1 = PiglinAI.isLovedItem(itemstack1, this) || itemstack1.is(Items.CROSSBOW); // CraftBukkit - return flag && !flag1 ? true : (!flag && flag1 ? false : (this.isAdult() && !itemstack.is(Items.CROSSBOW) && itemstack1.is(Items.CROSSBOW) ? false : super.canReplaceCurrentItem(itemstack, itemstack1))); + return flag && !flag1 ? true : (!flag && flag1 ? false : (this.isAdult() && !itemstack.is(Items.CROSSBOW) && itemstack1.is(Items.CROSSBOW) ? false : super.canReplaceCurrentItem(itemstack, itemstack1, enumitemslot))); } -@@ -405,7 +433,7 @@ +@@ -422,7 +450,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 0df483cf..85d6ba91 100644 --- a/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch +++ b/nms-patches/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java +++ b/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java -@@ -94,7 +94,7 @@ - } - +@@ -102,7 +102,7 @@ protected void finishConversion(WorldServer worldserver) { -- EntityPigZombie entitypigzombie = (EntityPigZombie) this.convertTo(EntityTypes.ZOMBIFIED_PIGLIN, true); -+ EntityPigZombie entitypigzombie = (EntityPigZombie) this.convertTo(EntityTypes.ZOMBIFIED_PIGLIN, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons - - if (entitypigzombie != null) { + this.convertTo(EntityTypes.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), (entitypigzombie) -> { entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); +- }); ++ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons + } + + public boolean isAdult() { 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 3150aa5f..26aa7784 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 -@@ -74,6 +74,14 @@ +@@ -72,6 +72,14 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParameters; import net.minecraft.world.phys.Vec3D; @@ -15,7 +15,7 @@ public class PiglinAI { public static final int REPELLENT_DETECTION_RANGE_HORIZONTAL = 8; -@@ -164,7 +172,8 @@ +@@ -166,7 +174,8 @@ } private static void initRideHoglinActivity(BehaviorController behaviorcontroller) { @@ -25,7 +25,7 @@ return true; }), 1)).build())), BehaviorStopRiding.create(8, PiglinAI::wantsToStopRiding)), MemoryModuleType.RIDE_TARGET); } -@@ -174,7 +183,7 @@ +@@ -176,7 +185,7 @@ } private static BehaviorGateSingle createIdleLookBehaviors() { @@ -34,7 +34,7 @@ } private static BehaviorGateSingle createIdleMovementBehaviors() { -@@ -195,13 +204,13 @@ +@@ -197,13 +206,13 @@ protected static void updateActivity(EntityPiglin entitypiglin) { BehaviorController behaviorcontroller = entitypiglin.getBrain(); @@ -51,7 +51,7 @@ Objects.requireNonNull(entitypiglin); optional.ifPresent(entitypiglin::makeSound); -@@ -233,23 +242,27 @@ +@@ -235,23 +244,27 @@ stopWalking(entitypiglin); ItemStack itemstack; @@ -74,17 +74,17 @@ - if (isLovedItem(itemstack)) { + if (isLovedItem(itemstack, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering entitypiglin.getBrain().eraseMemory(MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM); - holdInOffhand(entitypiglin, itemstack); + holdInOffhand(worldserver, entitypiglin, itemstack); admireGoldItem(entitypiglin); } else if (isFood(itemstack) && !hasEatenRecently(entitypiglin)) { eat(entitypiglin); } else { -- boolean flag = !entitypiglin.equipItemIfPossible(itemstack).equals(ItemStack.EMPTY); -+ boolean flag = !entitypiglin.equipItemIfPossible(itemstack, entityitem).equals(ItemStack.EMPTY); // CraftBukkit +- boolean flag = !entitypiglin.equipItemIfPossible(worldserver, itemstack).equals(ItemStack.EMPTY); ++ boolean flag = !entitypiglin.equipItemIfPossible(worldserver, itemstack, entityitem).equals(ItemStack.EMPTY); // CraftBukkit if (!flag) { putInInventory(entitypiglin, itemstack); -@@ -270,7 +283,7 @@ +@@ -272,7 +285,7 @@ ItemStack itemstack1 = itemstack.split(1); if (itemstack.isEmpty()) { @@ -93,7 +93,7 @@ } else { entityitem.setItem(itemstack); } -@@ -285,9 +298,14 @@ +@@ -287,9 +300,14 @@ boolean flag1; if (entitypiglin.isAdult()) { @@ -108,9 +108,9 @@ + } + // CraftBukkit end } else if (!flag1) { - boolean flag2 = !entitypiglin.equipItemIfPossible(itemstack).isEmpty(); + boolean flag2 = !entitypiglin.equipItemIfPossible(worldserver, itemstack).isEmpty(); -@@ -300,7 +318,7 @@ +@@ -302,7 +320,7 @@ if (!flag1) { ItemStack itemstack1 = entitypiglin.getMainHandItem(); @@ -119,7 +119,7 @@ putInInventory(entitypiglin, itemstack1); } else { throwItems(entitypiglin, Collections.singletonList(itemstack1)); -@@ -377,7 +395,7 @@ +@@ -379,7 +397,7 @@ return false; } else if (isAdmiringDisabled(entitypiglin) && entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; @@ -128,7 +128,7 @@ return isNotHoldingLovedItemInOffHand(entitypiglin); } else { boolean flag = entitypiglin.canAddToInventory(itemstack); -@@ -386,6 +404,12 @@ +@@ -388,6 +406,12 @@ } } @@ -141,7 +141,7 @@ protected static boolean isLovedItem(ItemStack itemstack) { return itemstack.is(TagsItem.PIGLIN_LOVED); } -@@ -479,7 +503,7 @@ +@@ -481,7 +505,7 @@ } protected static boolean canAdmire(EntityPiglin entitypiglin, ItemStack itemstack) { @@ -149,8 +149,8 @@ + return !isAdmiringDisabled(entitypiglin) && !isAdmiringItem(entitypiglin) && entitypiglin.isAdult() && isBarterCurrency(itemstack, entitypiglin); // CraftBukkit } - protected static void wasHurtBy(EntityPiglin entitypiglin, EntityLiving entityliving) { -@@ -736,6 +760,12 @@ + protected static void wasHurtBy(WorldServer worldserver, EntityPiglin entitypiglin, EntityLiving entityliving) { +@@ -735,6 +759,12 @@ return entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM); } @@ -163,7 +163,7 @@ private static boolean isBarterCurrency(ItemStack itemstack) { return itemstack.is(PiglinAI.BARTERING_ITEM); } -@@ -773,7 +803,7 @@ +@@ -772,7 +802,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 385070ba..45b48aff 100644 --- a/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch +++ b/nms-patches/net/minecraft/world/entity/monster/warden/Warden.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/warden/Warden.java +++ b/net/minecraft/world/entity/monster/warden/Warden.java -@@ -372,7 +372,7 @@ +@@ -375,7 +375,7 @@ @Override public BehaviorController getBrain() { @@ -9,7 +9,7 @@ } @Override -@@ -409,7 +409,7 @@ +@@ -412,7 +412,7 @@ public static void applyDarknessAround(WorldServer worldserver, Vec3D vec3d, @Nullable Entity entity, int i) { MobEffect mobeffect = new MobEffect(MobEffects.DARKNESS, 260, 0, false, false); @@ -18,7 +18,7 @@ } @Override -@@ -544,7 +544,7 @@ +@@ -547,7 +547,7 @@ public void setAttackTarget(EntityLiving entityliving) { this.getBrain().eraseMemory(MemoryModuleType.ROAR_TARGET); @@ -27,7 +27,7 @@ this.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); SonicBoom.setCooldown(this, 200); } -@@ -579,12 +579,12 @@ +@@ -582,12 +582,12 @@ @Override protected NavigationAbstract createNavigation(World world) { diff --git a/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch b/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch index a10feb4f..0f03f2ba 100644 --- a/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch +++ b/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/EntityVillager.java +++ b/net/minecraft/world/entity/npc/EntityVillager.java -@@ -92,6 +92,15 @@ +@@ -93,6 +93,15 @@ import net.minecraft.world.phys.AxisAlignedBB; import org.slf4j.Logger; @@ -25,7 +25,7 @@ } @Override -@@ -233,7 +242,7 @@ +@@ -235,7 +244,7 @@ this.increaseProfessionLevelOnUpdate = false; } @@ -34,7 +34,7 @@ } } -@@ -363,7 +372,13 @@ +@@ -360,7 +369,13 @@ while (iterator.hasNext()) { MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); @@ -49,7 +49,7 @@ } this.resendOffersToTradingPlayer(); -@@ -432,7 +447,13 @@ +@@ -429,7 +444,13 @@ while (iterator.hasNext()) { MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); @@ -64,7 +64,7 @@ } } -@@ -492,7 +513,7 @@ +@@ -489,7 +510,7 @@ @Override public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(nbttagcompound); @@ -73,7 +73,7 @@ Logger logger = EntityVillager.LOGGER; Objects.requireNonNull(logger); -@@ -515,7 +536,7 @@ +@@ -512,7 +533,7 @@ public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); if (nbttagcompound.contains("VillagerData", 10)) { @@ -82,33 +82,25 @@ Logger logger = EntityVillager.LOGGER; Objects.requireNonNull(logger); -@@ -828,9 +849,14 @@ - } - - 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 +@@ -808,7 +829,7 @@ + entitywitch1.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entitywitch1.blockPosition()), EntitySpawnReason.CONVERSION, (GroupDataEntity) null); + entitywitch1.setPersistenceRequired(); this.releaseAllPois(); -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause - } else { +- }); ++ }, EntityTransformEvent.TransformReason.LIGHTNING, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit + + if (entitywitch == null) { super.thunderHit(worldserver, entitylightning); - } -@@ -927,7 +953,7 @@ - }).limit(5L).collect(Collectors.toList()); +@@ -906,7 +927,7 @@ + }).limit(5L).toList(); if (list1.size() >= j) { -- if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EnumMobSpawn.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM).isEmpty()) { -+ if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EnumMobSpawn.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isEmpty()) { // CraftBukkit +- if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM).isEmpty()) { ++ if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isEmpty()) { // CraftBukkit list.forEach(SensorGolemLastSeen::golemDetected); } } -@@ -984,7 +1010,7 @@ +@@ -963,7 +984,7 @@ @Override public void startSleeping(BlockPosition blockposition) { super.startSleeping(blockposition); @@ -117,7 +109,7 @@ this.brain.eraseMemory(MemoryModuleType.WALK_TARGET); this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); } -@@ -992,7 +1018,7 @@ +@@ -971,7 +992,7 @@ @Override public void stopSleeping() { super.stopSleeping(); diff --git a/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch b/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch index 0c1a8c80..24ade5e5 100644 --- a/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch +++ b/nms-patches/net/minecraft/world/entity/npc/EntityVillagerTrader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/EntityVillagerTrader.java +++ b/net/minecraft/world/entity/npc/EntityVillagerTrader.java -@@ -47,6 +47,14 @@ +@@ -48,6 +48,14 @@ import net.minecraft.world.phys.Vec3D; import org.apache.commons.lang3.tuple.Pair; @@ -12,10 +12,10 @@ +import org.bukkit.event.entity.VillagerAcquireTradeEvent; +// CraftBukkit end + - public class EntityVillagerTrader extends EntityVillagerAbstract { + public class EntityVillagerTrader extends EntityVillagerAbstract implements Consumable.b { private static final int NUMBER_OF_TRADE_OFFERS = 5; -@@ -56,6 +64,7 @@ +@@ -57,6 +65,7 @@ public EntityVillagerTrader(EntityTypes entitytypes, World world) { super(entitytypes, world); @@ -23,7 +23,7 @@ } @Override -@@ -136,7 +145,16 @@ +@@ -137,7 +146,16 @@ MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(this, this.random); if (merchantrecipe != null) { @@ -41,7 +41,7 @@ } } -@@ -243,7 +261,7 @@ +@@ -244,7 +262,7 @@ private void maybeDespawn() { if (this.despawnDelay > 0 && !this.isTrading() && --this.despawnDelay == 0) { diff --git a/nms-patches/net/minecraft/world/entity/npc/InventoryCarrier.patch b/nms-patches/net/minecraft/world/entity/npc/InventoryCarrier.patch index 3f06982a..fb8c4975 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 -@@ -7,6 +7,10 @@ +@@ -8,6 +8,10 @@ import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.item.ItemStack; @@ -11,7 +11,7 @@ public interface InventoryCarrier { String TAG_INVENTORY = "Inventory"; -@@ -24,13 +28,20 @@ +@@ -25,13 +29,20 @@ return; } diff --git a/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch b/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch index c19f83c2..e4987a51 100644 --- a/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch +++ b/nms-patches/net/minecraft/world/entity/npc/MobSpawnerTrader.patch @@ -4,8 +4,8 @@ return false; } -- 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 +- EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, blockposition2, EntitySpawnReason.EVENT); ++ EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, blockposition2, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit if (entityvillagertrader != null) { for (int i = 0; i < 2; ++i) { @@ -22,8 +22,8 @@ BlockPosition blockposition = this.findSpawnPositionNear(worldserver, entityvillagertrader.blockPosition(), i); if (blockposition != null) { -- 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 +- EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, blockposition, EntitySpawnReason.EVENT); ++ EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, blockposition, EntitySpawnReason.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 b2a5adce..a09799fd 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 -@@ -115,6 +115,23 @@ +@@ -119,6 +119,19 @@ import net.minecraft.world.scores.ScoreboardTeam; import org.slf4j.Logger; @@ -9,22 +9,18 @@ +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.util.CraftVector; -+import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.CreatureSpawnEvent; -+import org.bukkit.event.entity.EntityCombustByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityExhaustionEvent; -+import org.bukkit.event.entity.EntityKnockbackEvent; +import org.bukkit.event.entity.EntityRemoveEvent; -+import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerVelocityEvent; +// CraftBukkit end + public abstract class EntityHuman extends EntityLiving { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -135,7 +152,8 @@ +@@ -139,7 +152,8 @@ private static final int CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME_TICKS = 40; public static final Vec3D DEFAULT_VEHICLE_ATTACHMENT = new Vec3D(0.0D, 0.6D, 0.0D); public static final EntitySize STANDING_DIMENSIONS = EntitySize.scalable(0.6F, 1.8F).withEyeHeight(1.62F).withAttachments(EntityAttachments.builder().attach(EntityAttachment.VEHICLE, EntityHuman.DEFAULT_VEHICLE_ATTACHMENT)); @@ -34,7 +30,7 @@ private static final DataWatcherObject DATA_PLAYER_ABSORPTION_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.FLOAT); private static final DataWatcherObject DATA_SCORE_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.INT); protected static final DataWatcherObject DATA_PLAYER_MODE_CUSTOMISATION = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.BYTE); -@@ -144,10 +162,10 @@ +@@ -148,7 +162,7 @@ protected static final DataWatcherObject DATA_SHOULDER_RIGHT = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG); private long timeEntitySatOnShoulder; final PlayerInventory inventory = new PlayerInventory(this); @@ -42,12 +38,8 @@ + protected InventoryEnderChest enderChestInventory = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor public final ContainerPlayer inventoryMenu; public Container containerMenu; -- protected FoodMetaData foodData = new FoodMetaData(); -+ protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor - protected int jumpTriggerTime; - public float oBob; - public float bob; -@@ -182,6 +200,16 @@ + protected FoodMetaData foodData = new FoodMetaData(); +@@ -186,6 +200,16 @@ private boolean ignoreFallDamageFromCurrentImpulse; private int currentImpulseContextResetGraceTime; @@ -64,16 +56,16 @@ public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); this.lastItemInMainHand = ItemStack.EMPTY; -@@ -330,7 +358,7 @@ - ItemStack itemstack = this.getItemBySlot(EnumItemSlot.HEAD); - - if (itemstack.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(TagsFluid.WATER)) { -- this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true)); -+ this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit - } +@@ -350,7 +374,7 @@ + } + private void turtleHelmetTick() { +- this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true)); ++ this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit } -@@ -482,8 +510,14 @@ + + private boolean isEquipped(Item item) { +@@ -520,8 +544,14 @@ public void rideTick() { if (!this.level().isClientSide && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -90,17 +82,7 @@ super.rideTick(); this.oBob = this.bob; this.bob = 0.0F; -@@ -505,7 +539,8 @@ - - if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { - if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) { -- this.heal(1.0F); -+ // CraftBukkit - added regain reason of "REGEN" for filtering purposes. -+ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); - } - - if (this.foodData.getSaturationLevel() < 20.0F && this.tickCount % 20 == 0) { -@@ -683,6 +718,13 @@ +@@ -716,6 +746,13 @@ @Nullable public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { @@ -111,44 +93,10 @@ + @Nullable + public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) { + // CraftBukkit end - if (itemstack.isEmpty()) { - return null; - } else { -@@ -717,6 +759,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); - } - -+ // CraftBukkit start - fire PlayerDropItemEvent -+ if (!callEvent) { // SPIGOT-2942: Add boolean to call event -+ return entityitem; -+ } -+ Player player = (Player) this.getBukkitEntity(); -+ Item drop = (Item) entityitem.getBukkitEntity(); -+ -+ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); -+ if (flag1 && (cur == null || cur.getAmount() == 0)) { -+ // The complete stack was dropped -+ player.getInventory().setItemInHand(drop.getItemStack()); -+ } else if (flag1 && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) { -+ // Only one item is dropped -+ cur.setAmount(cur.getAmount() + 1); -+ player.getInventory().setItemInHand(cur); -+ } else { -+ // Fallback -+ player.getInventory().addItem(drop.getItemStack()); -+ } -+ return null; -+ } -+ // CraftBukkit end -+ - return entityitem; + if (!itemstack.isEmpty() && this.level().isClientSide) { + this.swing(EnumHand.MAIN_HAND); } - } -@@ -803,7 +872,7 @@ +@@ -806,7 +843,7 @@ } if (nbttagcompound.contains("LastDeathLocation", 10)) { @@ -157,7 +105,7 @@ Logger logger = EntityHuman.LOGGER; Objects.requireNonNull(logger); -@@ -811,7 +880,7 @@ +@@ -814,7 +851,7 @@ } if (nbttagcompound.contains("current_explosion_impact_pos", 9)) { @@ -166,7 +114,7 @@ Logger logger1 = EntityHuman.LOGGER; Objects.requireNonNull(logger1); -@@ -848,7 +917,7 @@ +@@ -851,7 +888,7 @@ } this.getLastDeathLocation().flatMap((globalpos) -> { @@ -175,28 +123,26 @@ Logger logger = EntityHuman.LOGGER; Objects.requireNonNull(logger); -@@ -881,12 +950,12 @@ +@@ -883,10 +920,10 @@ + if (this.isDeadOrDying()) { return false; } else { - if (!this.level().isClientSide) { -- this.removeEntitiesOnShoulder(); -+ // this.removeEntitiesOnShoulder(); // CraftBukkit - moved down - } - +- this.removeEntitiesOnShoulder(); ++ // this.removeEntitiesOnShoulder(); // CraftBukkit - moved down if (damagesource.scalesWithDifficulty()) { - if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL) { + if (worldserver.getDifficulty() == EnumDifficulty.PEACEFUL) { - f = 0.0F; + return false; // CraftBukkit - f = 0.0f -> return false } - if (this.level().getDifficulty() == EnumDifficulty.EASY) { -@@ -898,7 +967,13 @@ + if (worldserver.getDifficulty() == EnumDifficulty.EASY) { +@@ -898,7 +935,13 @@ } } -- return f == 0.0F ? false : super.hurt(damagesource, f); +- return f == 0.0F ? false : super.hurtServer(worldserver, damagesource, f); + // CraftBukkit start - Don't filter out 0 damage -+ boolean damaged = super.hurt(damagesource, f); ++ boolean damaged = super.hurtServer(worldserver, damagesource, f); + if (damaged) { + this.removeEntitiesOnShoulder(); + } @@ -205,7 +151,7 @@ } } } -@@ -918,10 +993,29 @@ +@@ -920,10 +963,29 @@ } public boolean canHarmPlayer(EntityHuman entityhuman) { @@ -238,22 +184,22 @@ } @Override -@@ -961,8 +1055,13 @@ +@@ -963,8 +1025,13 @@ } } + // CraftBukkit start @Override -- protected void actuallyHurt(DamageSource damagesource, float f) { -+ protected boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) { // void -> boolean +- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) { ++ protected boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { // void -> boolean + if (true) { -+ return super.actuallyHurt(damagesource, f, event); ++ return super.actuallyHurt(worldserver, damagesource, f, event); + } + // CraftBukkit end - if (!this.isInvulnerableTo(damagesource)) { + if (!this.isInvulnerableTo(worldserver, damagesource)) { f = this.getDamageAfterArmorAbsorb(damagesource, f); f = this.getDamageAfterMagicAbsorb(damagesource, f); -@@ -977,7 +1076,7 @@ +@@ -979,7 +1046,7 @@ } if (f != 0.0F) { @@ -262,7 +208,7 @@ this.getCombatTracker().recordDamage(damagesource, f); this.setHealth(this.getHealth() - f); if (f < 3.4028235E37F) { -@@ -987,6 +1086,7 @@ +@@ -989,6 +1056,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -270,7 +216,7 @@ } public boolean isTextFilteringEnabled() { -@@ -1139,10 +1239,15 @@ +@@ -1141,10 +1209,15 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -287,12 +233,12 @@ if (iprojectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, this, true)) { this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource()); return; -@@ -1218,8 +1323,13 @@ +@@ -1220,8 +1293,13 @@ if (entityliving2 != this && entityliving2 != entity && !this.isAlliedTo((Entity) entityliving2) && (!(entityliving2 instanceof EntityArmorStand) || !((EntityArmorStand) entityliving2).isMarker()) && this.distanceToSqr((Entity) entityliving2) < 9.0D) { float f7 = this.getEnchantedDamage(entityliving2, f6, damagesource) * f2; + // CraftBukkit start - Only apply knockback if the damage hits -+ if (!entityliving2.hurt(this.damageSources().playerAttack(this).sweep(), f7)) { ++ if (!entityliving2.hurtServer((WorldServer) this.level(), this.damageSources().playerAttack(this).sweep(), f7)) { + continue; + } + // CraftBukkit end @@ -302,7 +248,7 @@ World world = this.level(); if (world instanceof WorldServer) { -@@ -1235,9 +1345,26 @@ +@@ -1237,9 +1315,26 @@ } if (entity instanceof EntityPlayer && entity.hurtMarked) { @@ -329,7 +275,7 @@ } if (flag2) { -@@ -1303,9 +1430,14 @@ +@@ -1305,9 +1400,14 @@ } } @@ -345,7 +291,7 @@ } } -@@ -1346,7 +1478,14 @@ +@@ -1348,7 +1448,14 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -361,7 +307,7 @@ this.inventoryMenu.removed(this); if (this.containerMenu != null && this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1382,6 +1521,12 @@ +@@ -1388,6 +1495,12 @@ } public Either startSleepInBed(BlockPosition blockposition) { @@ -374,32 +320,7 @@ this.startSleeping(blockposition); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1444,9 +1589,9 @@ - super.jumpFromGround(); - this.awardStat(StatisticList.JUMP); - if (this.isSprinting()) { -- this.causeFoodExhaustion(0.2F); -+ this.causeFoodExhaustion(0.2F, EntityExhaustionEvent.ExhaustionReason.JUMP_SPRINT); // CraftBukkit - EntityExhaustionEvent - } else { -- this.causeFoodExhaustion(0.05F); -+ this.causeFoodExhaustion(0.05F, EntityExhaustionEvent.ExhaustionReason.JUMP); // CraftBukkit - EntityExhaustionEvent - } - - } -@@ -1473,7 +1618,11 @@ - - this.setDeltaMovement(vec3d2.x, d0 * 0.6D, vec3d2.z); - this.resetFallDistance(); -- this.setSharedFlag(7, false); -+ // CraftBukkit start -+ if (getSharedFlag(7) && !org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { -+ this.setSharedFlag(7, false); -+ } -+ // CraftBukkit end - } else { - super.travel(vec3d); - } -@@ -1547,12 +1696,24 @@ +@@ -1542,12 +1655,24 @@ } public void startFallFlying() { @@ -425,7 +346,7 @@ } @Override -@@ -1667,10 +1828,21 @@ +@@ -1662,10 +1787,21 @@ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); } @@ -448,7 +369,7 @@ } } -@@ -1756,13 +1928,20 @@ +@@ -1745,13 +1881,20 @@ @Override public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -472,7 +393,7 @@ } } -@@ -1806,26 +1985,31 @@ +@@ -1795,26 +1938,31 @@ protected void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -495,8 +416,8 @@ - private void respawnEntityOnShoulder(NBTTagCompound nbttagcompound) { + private boolean respawnEntityOnShoulder(NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean if (!this.level().isClientSide && !nbttagcompound.isEmpty()) { -- EntityTypes.create(nbttagcompound, this.level()).ifPresent((entity) -> { -+ return EntityTypes.create(nbttagcompound, this.level()).map((entity) -> { // CraftBukkit +- EntityTypes.create(nbttagcompound, this.level(), EntitySpawnReason.LOAD).ifPresent((entity) -> { ++ return EntityTypes.create(nbttagcompound, this.level(), EntitySpawnReason.LOAD).map((entity) -> { // CraftBukkit if (entity instanceof EntityTameableAnimal) { ((EntityTameableAnimal) entity).setOwnerUUID(this.uuid); } @@ -512,12 +433,3 @@ } @Override -@@ -2040,7 +2224,7 @@ - - @Override - public ItemStack eat(World world, ItemStack itemstack, FoodInfo foodinfo) { -- this.getFoodData().eat(foodinfo); -+ this.getFoodData().eat(itemstack, foodinfo); // CraftBukkit - this.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem())); - world.playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); - if (this instanceof EntityPlayer) { diff --git a/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch b/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch index b790523b..1746368e 100644 --- a/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch +++ b/nms-patches/net/minecraft/world/entity/player/PlayerInventory.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/PlayerInventory.java +++ b/net/minecraft/world/entity/player/PlayerInventory.java -@@ -23,6 +23,13 @@ +@@ -24,6 +24,13 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.IBlockData; @@ -14,7 +14,7 @@ public class PlayerInventory implements IInventory, INamableTileEntity { public static final int POP_TIME_DURATION = 5; -@@ -40,6 +47,54 @@ +@@ -39,6 +46,54 @@ public final EntityHuman player; private int timesChanged; @@ -69,7 +69,7 @@ public PlayerInventory(EntityHuman entityhuman) { this.items = NonNullList.withSize(36, ItemStack.EMPTY); this.armor = NonNullList.withSize(4, ItemStack.EMPTY); -@@ -60,6 +115,28 @@ +@@ -59,6 +114,28 @@ return !itemstack.isEmpty() && ItemStack.isSameItemSameComponents(itemstack, itemstack1) && itemstack.isStackable() && itemstack.getCount() < this.getMaxStackSize(itemstack); } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch index 7788760b..b822c097 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 -@@ -52,6 +52,13 @@ +@@ -51,6 +51,13 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.shapes.VoxelShape; @@ -29,7 +29,7 @@ this.pickupItemStack = itemstack.copy(); this.setCustomName((IChatBaseComponent) itemstack.get(DataComponents.CUSTOM_NAME)); Unit unit = (Unit) itemstack.remove(DataComponents.INTANGIBLE_PROJECTILE); -@@ -116,8 +130,8 @@ +@@ -112,8 +126,8 @@ } protected EntityArrow(EntityTypes entitytypes, EntityLiving entityliving, World world, ItemStack itemstack, @Nullable ItemStack itemstack1) { @@ -40,16 +40,16 @@ } public void setSoundEvent(SoundEffect soundeffect) { -@@ -242,7 +256,7 @@ - } - - if (object != null && !flag) { -- ProjectileDeflection projectiledeflection = this.hitTargetOrDeflectSelf((MovingObjectPosition) object); -+ ProjectileDeflection projectiledeflection = this.preHitTargetOrDeflectSelf((MovingObjectPosition) object); // CraftBukkit - projectile hit event +@@ -276,7 +290,7 @@ - this.hasImpulse = true; - if (projectiledeflection != ProjectileDeflection.NONE) { -@@ -333,7 +347,7 @@ + if (movingobjectpositionentity == null) { + if (this.isAlive() && movingobjectpositionblock.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { +- this.hitTargetOrDeflectSelf(movingobjectpositionblock); ++ this.preHitTargetOrDeflectSelf(movingobjectpositionblock); // CraftBukkit - projectile hit event + this.hasImpulse = true; + } + } else { +@@ -356,7 +370,7 @@ protected void tickDespawn() { ++this.life; if (this.life >= 1200) { @@ -58,7 +58,7 @@ } } -@@ -380,7 +394,7 @@ +@@ -408,7 +422,7 @@ } if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) { @@ -67,7 +67,7 @@ return; } -@@ -401,7 +415,13 @@ +@@ -429,7 +443,13 @@ int k = entity.getRemainingFireTicks(); if (this.isOnFire() && !flag) { @@ -81,8 +81,8 @@ + // CraftBukkit end } - if (entity.hurt(damagesource, (float) i)) { -@@ -447,7 +467,7 @@ + if (entity.hurtOrSimulate(damagesource, (float) i)) { +@@ -475,7 +495,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -91,16 +91,16 @@ } } else { entity.setRemainingFireTicks(k); -@@ -458,7 +478,7 @@ - this.spawnAtLocation(this.getPickupItem(), 0.1F); - } +@@ -491,7 +511,7 @@ + this.spawnAtLocation(worldserver2, this.getPickupItem(), 0.1F); + } -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause + } } } - -@@ -614,7 +634,7 @@ +@@ -660,7 +680,7 @@ } if (nbttagcompound.contains("weapon", 10)) { @@ -109,7 +109,7 @@ } else { this.firedFromWeapon = null; } -@@ -627,34 +647,31 @@ +@@ -673,34 +693,31 @@ Entity entity1 = entity; byte b0 = 0; @@ -156,10 +156,10 @@ } this.pickup = entityarrow_pickupstatus; -@@ -663,9 +680,24 @@ +@@ -709,9 +726,24 @@ @Override public void playerTouch(EntityHuman entityhuman) { - if (!this.level().isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) { + if (!this.level().isClientSide && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { - if (this.tryPickup(entityhuman)) { + // CraftBukkit start + ItemStack itemstack = this.getPickupItem(); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch index ea87f55e..806f5d1e 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityDragonFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityDragonFireball.java +++ b/net/minecraft/world/entity/projectile/EntityDragonFireball.java -@@ -16,6 +16,10 @@ +@@ -15,6 +15,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public class EntityDragonFireball extends EntityFireball { public static final float SPLASH_RANGE = 4.0F; -@@ -62,7 +66,7 @@ +@@ -61,7 +65,7 @@ this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1); this.level().addFreshEntity(entityareaeffectcloud); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch index 0bc36534..025e842e 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEgg.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEgg.java +++ b/net/minecraft/world/entity/projectile/EntityEgg.java -@@ -12,6 +12,16 @@ +@@ -14,6 +14,16 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -17,7 +17,7 @@ public class EntityEgg extends EntityProjectileThrowable { private static final EntitySize ZERO_SIZED_DIMENSIONS = EntitySize.fixed(0.0F, 0.0F); -@@ -50,30 +60,58 @@ +@@ -52,30 +62,58 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level().isClientSide) { @@ -54,7 +54,7 @@ + // CraftBukkit end + for (int i = 0; i < b0; ++i) { -- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level()); +- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level(), EntitySpawnReason.TRIGGERED); + Entity entitychicken = this.level().getWorld().makeEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); // CraftBukkit if (entitychicken != null) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch index 102abdc3..cebde2d2 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderPearl.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityEnderPearl.java +++ b/net/minecraft/world/entity/projectile/EntityEnderPearl.java -@@ -21,6 +21,13 @@ +@@ -29,6 +29,13 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -13,20 +13,20 @@ + public class EntityEnderPearl extends EntityProjectileThrowable { - public EntityEnderPearl(EntityTypes entitytypes, World world) { -@@ -65,19 +72,26 @@ + private long ticketTimer = 0L; +@@ -140,12 +147,19 @@ EntityPlayer entityplayer = (EntityPlayer) entity; if (entityplayer.connection.isAcceptingMessages()) { + // CraftBukkit start -+ Entity tp = entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING, PlayerTeleportEvent.TeleportCause.ENDER_PEARL)); -+ if (tp == null) { ++ EntityPlayer entityplayer1 = entityplayer.teleport(new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING, PlayerTeleportEvent.TeleportCause.ENDER_PEARL)); ++ if (entityplayer1 == null) { + this.discard(EntityRemoveEvent.Cause.HIT); + return; + } + // CraftBukkit end if (this.random.nextFloat() < 0.05F && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { - EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(worldserver); + EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(worldserver, EntitySpawnReason.TRIGGERED); if (entityendermite != null) { entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); @@ -35,17 +35,23 @@ } } -- entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING)); -+ // entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING)); // CraftBukkit - moved up - entity.resetFallDistance(); - entityplayer.resetCurrentImpulseContext(); -- entity.hurt(this.damageSources().fall(), 5.0F); -+ entity.hurt(this.damageSources().fall().customEntityDamager(this), 5.0F); // CraftBukkit - this.playSound(worldserver, this.position()); - } - } else { -@@ -86,11 +100,11 @@ - this.playSound(worldserver, this.position()); +@@ -153,12 +167,12 @@ + entity.setPortalCooldown(); + } + +- EntityPlayer entityplayer1 = entityplayer.teleport(new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING)); ++ // EntityPlayer entityplayer1 = entityplayer.teleport(new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING)); // CraftBukkit - moved up + + if (entityplayer1 != null) { + entityplayer1.resetFallDistance(); + entityplayer1.resetCurrentImpulseContext(); +- entityplayer1.hurtServer(entityplayer.serverLevel(), this.damageSources().enderPearl(), 5.0F); ++ entityplayer1.hurtServer(entityplayer.serverLevel(), this.damageSources().enderPearl().customEntityDamager(this), 5.0F); // CraftBukkit + } + + this.playSound(worldserver, vec3d); +@@ -173,11 +187,11 @@ + this.playSound(worldserver, vec3d); } - this.discard(); @@ -58,21 +64,21 @@ return; } } -@@ -116,7 +130,7 @@ - Entity entity = this.getOwner(); - - if (entity instanceof EntityPlayer && !entity.isAlive() && this.level().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - } else { - super.tick(); - } -@@ -129,7 +143,7 @@ +@@ -210,7 +224,7 @@ + entity = this.getOwner(); + if (entity instanceof EntityPlayer entityplayer) { + if (!entity.isAlive() && entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + break label30; + } + } +@@ -248,7 +262,7 @@ @Override - public boolean canChangeDimensions(World world, World world1) { -- if (world.dimension() == World.END) { -+ if (world.getTypeKey() == WorldDimension.END) { // CraftBukkit + public boolean canTeleport(World world, World world1) { +- if (world.dimension() == World.END && world1.dimension() == World.OVERWORLD) { ++ if (world.getTypeKey() == WorldDimension.END && world1.getTypeKey() == WorldDimension.OVERWORLD) { // CraftBukkit Entity entity = this.getOwner(); if (entity instanceof EntityPlayer) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityEnderSignal.patch index 9cd57aaf..04ffd2f1 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 -@@ -16,6 +16,10 @@ +@@ -18,6 +18,10 @@ import net.minecraft.world.level.World; import net.minecraft.world.phys.Vec3D; @@ -10,8 +10,8 @@ + public class EntityEnderSignal extends Entity implements ItemSupplier { - private static final DataWatcherObject DATA_ITEM_STACK = DataWatcher.defineId(EntityEnderSignal.class, DataWatcherRegistry.ITEM_STACK); -@@ -146,7 +150,7 @@ + private static final float MIN_CAMERA_DISTANCE_SQUARED = 12.25F; +@@ -153,7 +157,7 @@ ++this.life; if (this.life > 80 && !this.level().isClientSide) { this.playSound(SoundEffects.ENDER_EYE_DEATH, 1.0F, 1.0F); @@ -20,7 +20,7 @@ if (this.surviveAfterDeath) { this.level().addFreshEntity(new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), this.getItem())); } else { -@@ -167,7 +171,12 @@ +@@ -174,7 +178,12 @@ @Override public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { if (nbttagcompound.contains("Item", 10)) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch index 30b743bb..45aaffc6 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 -@@ -18,11 +18,17 @@ +@@ -19,11 +19,17 @@ import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.Vec3D; @@ -18,21 +18,21 @@ protected EntityFireball(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -71,7 +77,7 @@ - Entity entity = this.getOwner(); +@@ -73,7 +79,7 @@ + this.applyInertia(); if (!this.level().isClientSide && (entity != null && entity.isRemoved() || !this.level().hasChunkAt(this.blockPosition()))) { - this.discard(); + this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { - super.tick(); - if (this.shouldBurn()) { -@@ -81,7 +87,7 @@ MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType()); + Vec3D vec3d; +@@ -93,7 +99,7 @@ + } - if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { + if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && this.isAlive()) { - this.hitTargetOrDeflectSelf(movingobjectposition); + this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event } - this.checkInsideBlocks(); + this.createParticleTrail(); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch index 4330cea2..0c681a09 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityFireballFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityFireballFireball.java +++ b/net/minecraft/world/entity/projectile/EntityFireballFireball.java -@@ -58,7 +58,12 @@ +@@ -61,7 +61,12 @@ public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); if (nbttagcompound.contains("Item", 10)) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch index 894649a2..82af90e2 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 -@@ -32,6 +32,10 @@ +@@ -33,6 +33,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,59 +11,60 @@ public class EntityFireworks extends IProjectile implements ItemSupplier { public static final DataWatcherObject DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK); -@@ -148,7 +152,7 @@ - MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity); +@@ -152,7 +156,7 @@ + } - if (!this.noPhysics) { + if (!this.noPhysics && this.isAlive() && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { - this.hitTargetOrDeflectSelf(movingobjectposition); + this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event this.hasImpulse = true; } -@@ -163,7 +167,11 @@ - } +@@ -172,7 +176,11 @@ + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; - if (!this.level().isClientSide && this.life > this.lifetime) { -- this.explode(); -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { -+ this.explode(); -+ } -+ // CraftBukkit end +- this.explode(worldserver); ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { ++ this.explode(worldserver); ++ } ++ // CraftBukkit end + } } - } -@@ -172,14 +180,18 @@ - this.level().broadcastEntityEvent(this, (byte) 17); +@@ -182,7 +190,7 @@ + worldserver.broadcastEntityEvent(this, (byte) 17); this.gameEvent(GameEvent.EXPLODE, this.getOwner()); - this.dealExplosionDamage(); + this.dealExplosionDamage(worldserver); - this.discard(); + this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause } @Override - protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) { - super.onHitEntity(movingobjectpositionentity); - if (!this.level().isClientSide) { -- this.explode(); +@@ -191,7 +199,11 @@ + World world = this.level(); + + if (world instanceof WorldServer worldserver) { +- this.explode(worldserver); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { -+ this.explode(); ++ this.explode(worldserver); + } + // CraftBukkit end } - } -@@ -189,7 +201,11 @@ + } +@@ -205,7 +217,11 @@ - this.level().getBlockState(blockposition).entityInside(this.level(), blockposition, this); - if (!this.level().isClientSide() && this.hasExplosion()) { -- this.explode(); -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { -+ this.explode(); -+ } -+ // CraftBukkit end + if (world instanceof WorldServer worldserver) { + if (this.hasExplosion()) { +- this.explode(worldserver); ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { ++ this.explode(worldserver); ++ } ++ // CraftBukkit end + } } - super.onHitBlock(movingobjectpositionblock); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch index 9bba8000..48be1a5e 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch @@ -33,7 +33,7 @@ private EntityFishingHook(EntityTypes entitytypes, World world, int i, int j) { super(entitytypes, world); this.syncronizedRandom = RandomSource.create(); -@@ -148,12 +167,12 @@ +@@ -152,12 +171,12 @@ EntityHuman entityhuman = this.getPlayerOwner(); if (entityhuman == null) { @@ -48,7 +48,7 @@ return; } } else { -@@ -254,7 +273,7 @@ +@@ -259,7 +278,7 @@ if (!entityhuman.isRemoved() && entityhuman.isAlive() && (flag || flag1) && this.distanceToSqr((Entity) entityhuman) <= 1024.0D) { return false; } else { @@ -57,7 +57,7 @@ return true; } } -@@ -262,7 +281,7 @@ +@@ -267,7 +286,7 @@ private void checkCollision() { MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity); @@ -66,7 +66,7 @@ } @Override -@@ -295,11 +314,11 @@ +@@ -300,11 +319,11 @@ int i = 1; BlockPosition blockposition1 = blockposition.above(); @@ -80,7 +80,7 @@ --i; } -@@ -309,6 +328,10 @@ +@@ -314,6 +333,10 @@ this.timeUntilLured = 0; this.timeUntilHooked = 0; this.getEntityData().set(EntityFishingHook.DATA_BITING, false); @@ -91,7 +91,7 @@ } } else { float f; -@@ -342,6 +365,13 @@ +@@ -347,6 +370,13 @@ worldserver.sendParticles(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D); } } else { @@ -105,7 +105,7 @@ this.playSound(SoundEffects.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); double d3 = this.getY() + 0.5D; -@@ -374,12 +404,16 @@ +@@ -379,12 +409,16 @@ } if (this.timeUntilLured <= 0) { @@ -126,7 +126,7 @@ } } -@@ -447,6 +481,14 @@ +@@ -452,6 +486,14 @@ int i = 0; if (this.hookedIn != null) { @@ -141,7 +141,7 @@ this.pullEntity(this.hookedIn); CriterionTriggers.FISHING_ROD_HOOKED.trigger((EntityPlayer) entityhuman, itemstack, this, Collections.emptyList()); this.level().broadcastEntityEvent(this, (byte) 31); -@@ -462,6 +504,15 @@ +@@ -467,6 +509,15 @@ while (iterator.hasNext()) { ItemStack itemstack1 = (ItemStack) iterator.next(); EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), itemstack1); @@ -157,7 +157,7 @@ double d0 = entityhuman.getX() - this.getX(); double d1 = entityhuman.getY() - this.getY(); double d2 = entityhuman.getZ() - this.getZ(); -@@ -469,7 +520,11 @@ +@@ -474,7 +525,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); @@ -170,7 +170,7 @@ if (itemstack1.is(TagsItem.FISHES)) { entityhuman.awardStat(StatisticList.FISH_CAUGHT, 1); } -@@ -479,10 +534,27 @@ +@@ -484,10 +539,27 @@ } if (this.onGround()) { @@ -199,7 +199,7 @@ return i; } else { return 0; -@@ -515,8 +587,15 @@ +@@ -520,8 +592,15 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -216,3 +216,12 @@ } @Override +@@ -575,7 +654,7 @@ + int i = packetplayoutspawnentity.getData(); + + EntityFishingHook.LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(i), i); +- this.discard(); ++ this.discard(null); // CraftBukkit - add Bukkit remove cause + } + + } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch index fe986897..abd100da 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch @@ -15,19 +15,19 @@ public EntityLargeFireball(EntityTypes entitytypes, World world) { super(entitytypes, world); -+ isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit ++ isIncendiary = (world instanceof WorldServer worldserver) && worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit } public EntityLargeFireball(World world, EntityLiving entityliving, Vec3D vec3d, int i) { super(EntityTypes.FIREBALL, entityliving, vec3d, world); this.explosionPower = i; -+ isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit ++ isIncendiary = (world instanceof WorldServer worldserver) && worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit } @Override -@@ -32,8 +39,16 @@ - if (!this.level().isClientSide) { - boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); +@@ -34,8 +41,16 @@ + if (world instanceof WorldServer worldserver) { + boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); - this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionPower, flag, World.a.MOB); - this.discard(); @@ -44,7 +44,7 @@ } } -@@ -63,7 +78,8 @@ +@@ -65,7 +80,8 @@ public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { super.readAdditionalSaveData(nbttagcompound); if (nbttagcompound.contains("ExplosionPower", 99)) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch index 7569e95b..17a9a265 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch @@ -32,7 +32,7 @@ } else { this.setDeltaMovement(vec3d.scale(0.9900000095367432D)); this.applyGravity(); -@@ -86,7 +90,7 @@ +@@ -83,7 +87,7 @@ protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) { super.onHitBlock(movingobjectpositionblock); if (!this.level().isClientSide) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch index 5045121a..fce143ac 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityPotion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityPotion.java +++ b/net/minecraft/world/entity/projectile/EntityPotion.java -@@ -34,6 +34,18 @@ +@@ -35,6 +35,18 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.MovingObjectPositionEntity; @@ -16,45 +16,45 @@ +import org.bukkit.event.entity.EntityRemoveEvent; +// CraftBukkit end + - public class EntityPotion extends EntityProjectileThrowable implements ItemSupplier { + public class EntityPotion extends EntityProjectileThrowable { public static final double SPLASH_RANGE = 4.0D; -@@ -98,18 +110,18 @@ +@@ -101,18 +113,18 @@ if (potioncontents.is(Potions.WATER)) { - this.applyWater(); + this.applyWater(worldserver); - } else if (potioncontents.hasEffects()) { + } else if (true || potioncontents.hasEffects()) { // CraftBukkit - Call event even if no effects to apply if (this.isLingering()) { - this.makeAreaOfEffectCloud(potioncontents); + this.makeAreaOfEffectCloud(potioncontents, movingobjectposition); // CraftBukkit - Pass MovingObjectPosition } else { -- this.applySplash(potioncontents.getAllEffects(), movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null); -+ this.applySplash(potioncontents.getAllEffects(), movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null, movingobjectposition); // CraftBukkit - Pass MovingObjectPosition +- this.applySplash(worldserver, potioncontents.getAllEffects(), movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null); ++ this.applySplash(worldserver, potioncontents.getAllEffects(), movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null, movingobjectposition); // CraftBukkit - Pass MovingObjectPosition } } int i = potioncontents.potion().isPresent() && ((PotionRegistry) ((Holder) potioncontents.potion().get()).value()).hasInstantEffects() ? 2007 : 2002; - this.level().levelEvent(i, this.blockPosition(), potioncontents.getColor()); + worldserver.levelEvent(i, this.blockPosition(), potioncontents.getColor()); - this.discard(); + this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause } } -@@ -144,9 +156,10 @@ +@@ -147,9 +159,10 @@ } -- private void applySplash(Iterable iterable, @Nullable Entity entity) { -+ private void applySplash(Iterable iterable, @Nullable Entity entity, MovingObjectPosition position) { // CraftBukkit - Pass MovingObjectPosition +- private void applySplash(WorldServer worldserver, Iterable iterable, @Nullable Entity entity) { ++ private void applySplash(WorldServer worldserver, Iterable iterable, @Nullable Entity entity, MovingObjectPosition position) { // CraftBukkit - Pass MovingObjectPosition AxisAlignedBB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D); - List list = this.level().getEntitiesOfClass(EntityLiving.class, axisalignedbb); + List list = worldserver.getEntitiesOfClass(EntityLiving.class, axisalignedbb); + Map affected = new HashMap(); // CraftBukkit if (!list.isEmpty()) { Entity entity1 = this.getEffectSource(); -@@ -167,24 +180,50 @@ +@@ -170,24 +183,50 @@ d1 = 1.0D - Math.sqrt(d0) / 4.0D; } @@ -78,7 +78,7 @@ + } - if (((MobEffectList) holder.value()).isInstantenous()) { -- ((MobEffectList) holder.value()).applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1); +- ((MobEffectList) holder.value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1); - } else { - int i = mobeffect.mapDuration((j) -> { - return (int) (d1 * (double) j + 0.5D); @@ -108,7 +108,7 @@ + // CraftBukkit end + + if (((MobEffectList) holder.value()).isInstantenous()) { -+ ((MobEffectList) holder.value()).applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1); ++ ((MobEffectList) holder.value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1); + } else { + int i = mobeffect.mapDuration((j) -> { + return (int) (d1 * (double) j + 0.5D); @@ -120,7 +120,7 @@ } } } -@@ -193,7 +232,7 @@ +@@ -196,7 +235,7 @@ } @@ -129,7 +129,7 @@ EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); Entity entity = this.getOwner(); -@@ -206,7 +245,14 @@ +@@ -209,7 +248,14 @@ entityareaeffectcloud.setWaitTime(10); entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float) entityareaeffectcloud.getDuration()); entityareaeffectcloud.setPotionContents(potioncontents); @@ -145,7 +145,7 @@ } public boolean isLingering() { -@@ -217,13 +263,25 @@ +@@ -220,13 +266,25 @@ IBlockData iblockdata = this.level().getBlockState(blockposition); if (iblockdata.is(TagsBlock.FIRE)) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch index 5943756d..d6b202b2 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/EntityProjectile.java +++ b/net/minecraft/world/entity/projectile/EntityProjectile.java -@@ -46,7 +46,7 @@ - MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity); - - if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { +@@ -63,7 +63,7 @@ + this.applyEffectsFromBlocks(); + super.tick(); + if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && this.isAlive()) { - this.hitTargetOrDeflectSelf(movingobjectposition); + this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event } - this.checkInsideBlocks(); + } diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch index 58fe9d52..8ddb29fd 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityProjectileThrowable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityProjectileThrowable.java +++ b/net/minecraft/world/entity/projectile/EntityProjectileThrowable.java -@@ -32,6 +32,12 @@ +@@ -34,6 +34,12 @@ protected abstract Item getDefaultItem(); diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch index 28584287..a42348ea 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch @@ -42,16 +42,16 @@ } } -@@ -230,7 +247,7 @@ - MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity); +@@ -239,7 +256,7 @@ + } - if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { -- this.hitTargetOrDeflectSelf(movingobjectposition); -+ this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event - } + if (movingobjectposition != null && this.isAlive() && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { +- this.hitTargetOrDeflectSelf(movingobjectposition); ++ this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event } -@@ -307,7 +324,7 @@ + ProjectileHelper.rotateTowardsMovement(this, 0.5F); +@@ -312,7 +329,7 @@ if (entity instanceof EntityLiving) { EntityLiving entityliving1 = (EntityLiving) entity; @@ -60,7 +60,7 @@ } } -@@ -321,14 +338,20 @@ +@@ -326,14 +343,20 @@ } private void destroy() { @@ -83,20 +83,19 @@ } @Override -@@ -338,10 +361,15 @@ +@@ -348,9 +371,14 @@ @Override - public boolean hurt(DamageSource damagesource, float f) { + public boolean hurtServer(WorldServer worldserver, DamageSource damagesource, float f) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) { + return false; + } + // CraftBukkit end - if (!this.level().isClientSide) { - this.playSound(SoundEffects.SHULKER_BULLET_HURT, 1.0F, 1.0F); - ((WorldServer) this.level()).sendParticles(Particles.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D); -- this.destroy(); -+ this.destroy(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause - } - + this.playSound(SoundEffects.SHULKER_BULLET_HURT, 1.0F, 1.0F); + worldserver.sendParticles(Particles.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D); +- this.destroy(); ++ this.destroy(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause return true; + } + diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch b/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch index ccb76785..a9757221 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntitySmallFireball.patch @@ -18,7 +18,7 @@ super(EntityTypes.SMALL_FIREBALL, entityliving, vec3d, world); + // CraftBukkit start + if (this.getOwner() != null && this.getOwner() instanceof EntityInsentient) { -+ isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); ++ isIncendiary = (world instanceof WorldServer worldserver) && worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + } + // CraftBukkit end } @@ -39,12 +39,12 @@ + // CraftBukkit end DamageSource damagesource = this.damageSources().fireball(this, entity1); - if (!entity.hurt(damagesource, 5.0F)) { -@@ -58,10 +75,10 @@ - if (!this.level().isClientSide) { + if (!entity.hurtServer(worldserver, damagesource, 5.0F)) { +@@ -60,10 +77,10 @@ + if (world instanceof WorldServer worldserver) { Entity entity = this.getOwner(); -- if (!(entity instanceof EntityInsentient) || this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- if (!(entity instanceof EntityInsentient) || worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (isIncendiary) { // CraftBukkit BlockPosition blockposition = movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()); @@ -53,7 +53,7 @@ this.level().setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level(), blockposition)); } } -@@ -73,7 +90,7 @@ +@@ -75,7 +92,7 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level().isClientSide) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch index 2323bc5b..ab6f2fdb 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownExpBottle.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EntityThrownExpBottle.java +++ b/net/minecraft/world/entity/projectile/EntityThrownExpBottle.java -@@ -11,6 +11,10 @@ +@@ -12,6 +12,10 @@ import net.minecraft.world.level.World; import net.minecraft.world.phys.MovingObjectPosition; @@ -11,7 +11,7 @@ public class EntityThrownExpBottle extends EntityProjectileThrowable { public EntityThrownExpBottle(EntityTypes entitytypes, World world) { -@@ -39,11 +43,20 @@ +@@ -40,11 +44,20 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (this.level() instanceof WorldServer) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch index 477f3622..a4d00d7b 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/EntityThrownTrident.patch @@ -11,21 +11,25 @@ public class EntityThrownTrident extends EntityArrow { private static final DataWatcherObject ID_LOYALTY = DataWatcher.defineId(EntityThrownTrident.class, DataWatcherRegistry.BYTE); -@@ -69,7 +73,7 @@ - this.spawnAtLocation(this.getPickupItem(), 0.1F); +@@ -75,10 +79,10 @@ + } } - this.discard(); + this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause } else { - this.setNoPhysics(true); - Vec3D vec3d = entity.getEyePosition().subtract(this.position()); -@@ -129,7 +133,7 @@ + if (!(entity instanceof EntityHuman) && this.position().distanceTo(entity.getEyePosition()) < (double) entity.getBbWidth() + 1.0D) { +- this.discard(); ++ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + return; + } + +@@ -136,7 +140,7 @@ world = this.level(); if (world instanceof WorldServer) { - worldserver = (WorldServer) world; + WorldServer worldserver = (WorldServer) world; // CraftBukkit - decompile error - EnchantmentManager.doPostAttackEffectsWithItemSource(worldserver, entity, damagesource, this.getWeaponItem()); - } - + EnchantmentManager.doPostAttackEffectsWithItemSourceOnBreak(worldserver, entity, damagesource, this.getWeaponItem(), (item) -> { + this.kill(worldserver); + }); diff --git a/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch b/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch index 8e05cbf0..b4c0be0b 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 -@@ -30,6 +30,10 @@ +@@ -36,6 +36,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,7 @@ public abstract class IProjectile extends Entity implements TraceableEntity { @Nullable -@@ -41,6 +45,10 @@ +@@ -47,6 +51,10 @@ @Nullable private Entity lastDeflectedBy; @@ -22,7 +22,7 @@ IProjectile(EntityTypes entitytypes, World world) { super(entitytypes, world); } -@@ -50,6 +58,7 @@ +@@ -56,6 +64,7 @@ this.ownerUUID = entity.getUUID(); this.cachedOwner = entity; } @@ -30,8 +30,17 @@ } -@@ -177,6 +186,17 @@ - this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, entity.onGround() ? 0.0D : vec3d.y, vec3d.z)); +@@ -213,7 +222,7 @@ + + public static T spawnProjectile(T t0, WorldServer worldserver, ItemStack itemstack, Consumer consumer) { + consumer.accept(t0); +- worldserver.addFreshEntity(t0); ++ if (worldserver.addFreshEntity(t0)) // CraftBukkit + t0.applyOnProjectileSpawned(worldserver, itemstack); + return t0; + } +@@ -232,6 +241,17 @@ + } + // CraftBukkit start - call projectile hit event @@ -48,7 +57,7 @@ protected ProjectileDeflection hitTargetOrDeflectSelf(MovingObjectPosition movingobjectposition) { if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) { MovingObjectPositionEntity movingobjectpositionentity = (MovingObjectPositionEntity) movingobjectposition; -@@ -237,6 +257,11 @@ +@@ -309,6 +329,11 @@ protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {} protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) { diff --git a/nms-patches/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.patch b/nms-patches/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.patch index b8cf1783..1a127fc3 100644 --- a/nms-patches/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.patch +++ b/nms-patches/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.patch @@ -10,8 +10,8 @@ + public abstract class AbstractWindCharge extends EntityFireball implements ItemSupplier { - public static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new SimpleExplosionDamageCalculator(true, false, Optional.empty(), BuiltInRegistries.BLOCK.getTag(TagsBlock.BLOCKS_WIND_CHARGE_EXPLOSIONS).map(Function.identity())); -@@ -113,7 +117,7 @@ + public static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new SimpleExplosionDamageCalculator(true, false, Optional.empty(), BuiltInRegistries.BLOCK.get(TagsBlock.BLOCKS_WIND_CHARGE_EXPLOSIONS).map(Function.identity())); +@@ -111,7 +115,7 @@ Vec3D vec3d1 = movingobjectpositionblock.getLocation().add(vec3d); this.explode(vec3d1); @@ -20,7 +20,7 @@ } } -@@ -122,7 +126,7 @@ +@@ -120,7 +124,7 @@ protected void onHit(MovingObjectPosition movingobjectposition) { super.onHit(movingobjectposition); if (!this.level().isClientSide) { @@ -29,9 +29,9 @@ } } -@@ -157,7 +161,7 @@ +@@ -155,7 +159,7 @@ public void tick() { - if (!this.level().isClientSide && this.getBlockY() > this.level().getMaxBuildHeight() + 30) { + if (!this.level().isClientSide && this.getBlockY() > this.level().getMaxY() + 30) { this.explode(this.position()); - this.discard(); + this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD); // CraftBukkit - add Bukkit remove cause diff --git a/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch b/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch index a2c11f8b..40e734c4 100644 --- a/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch +++ b/nms-patches/net/minecraft/world/entity/raid/EntityRaider.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/raid/EntityRaider.java +++ b/net/minecraft/world/entity/raid/EntityRaider.java -@@ -38,6 +38,10 @@ - import net.minecraft.world.level.WorldAccess; +@@ -41,6 +41,10 @@ + import net.minecraft.world.level.pathfinder.PathEntity; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -11,7 +11,7 @@ public abstract class EntityRaider extends EntityMonsterPatrolling { protected static final DataWatcherObject IS_CELEBRATING = DataWatcher.defineId(EntityRaider.class, DataWatcherRegistry.BOOLEAN); -@@ -233,7 +237,7 @@ +@@ -236,7 +240,7 @@ this.onItemPickup(entityitem); this.setItemSlot(enumitemslot, itemstack); this.take(entityitem, itemstack.getCount()); @@ -20,16 +20,16 @@ this.getCurrentRaid().setLeader(this.getWave(), this); this.setPatrolLeader(true); } else { -@@ -282,7 +286,7 @@ +@@ -290,7 +294,7 @@ + @Nullable + private EntityItem pursuedBannerItemEntity; - private final T mob; - -- public b(final EntityRaider entityraider, final EntityRaider entityraider1) { -+ public b(final EntityRaider entityraider, final T entityraider1) { // CraftBukkit - decompile error - this.mob = entityraider1; +- public b(final EntityRaider entityraider) { ++ public b(final T entityraider) { // CraftBukkit - decompile error + this.mob = entityraider; this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -475,7 +479,7 @@ +@@ -524,7 +528,7 @@ private final float hostileRadiusSqr; public final PathfinderTargetCondition shoutTargeting = PathfinderTargetCondition.forNonCombat().range(8.0D).ignoreLineOfSight().ignoreInvisibilityTesting(); @@ -38,7 +38,7 @@ this.mob = entityillagerabstract; this.hostileRadiusSqr = f * f; this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK)); -@@ -498,7 +502,7 @@ +@@ -547,7 +551,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); @@ -47,7 +47,7 @@ } } -@@ -515,7 +519,7 @@ +@@ -564,7 +568,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); diff --git a/nms-patches/net/minecraft/world/entity/raid/Raid.patch b/nms-patches/net/minecraft/world/entity/raid/Raid.patch index 25ced268..cff0acd8 100644 --- a/nms-patches/net/minecraft/world/entity/raid/Raid.patch +++ b/nms-patches/net/minecraft/world/entity/raid/Raid.patch @@ -38,15 +38,15 @@ this.stop(); return; } -@@ -380,6 +390,7 @@ +@@ -374,6 +384,7 @@ } - if (j > 3) { + if (j > 5) { + org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit this.stop(); break; } -@@ -392,6 +403,7 @@ +@@ -386,6 +397,7 @@ this.status = Raid.Status.VICTORY; Iterator iterator = this.heroesOfTheVillage.iterator(); @@ -54,7 +54,7 @@ while (iterator.hasNext()) { UUID uuid = (UUID) iterator.next(); Entity entity = this.level.getEntity(uuid); -@@ -406,10 +418,12 @@ +@@ -400,10 +412,12 @@ entityplayer.awardStat(StatisticList.RAID_WIN); CriterionTriggers.RAID_WIN.trigger(entityplayer); @@ -67,7 +67,7 @@ } } -@@ -417,6 +431,7 @@ +@@ -411,6 +425,7 @@ } else if (this.isOver()) { ++this.celebrationTicks; if (this.celebrationTicks >= 600) { @@ -75,7 +75,7 @@ this.stop(); return; } -@@ -553,6 +568,10 @@ +@@ -544,6 +559,10 @@ int j = araid_wave.length; int k = 0; @@ -86,7 +86,7 @@ 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); -@@ -568,9 +587,11 @@ +@@ -559,9 +578,11 @@ entityraider.setPatrolLeader(true); this.setLeader(i, entityraider); flag = true; @@ -98,7 +98,7 @@ if (raid_wave.entityType == EntityTypes.RAVAGER) { EntityRaider entityraider1 = null; -@@ -589,6 +610,7 @@ +@@ -580,6 +601,7 @@ this.joinRaid(i, entityraider1, blockposition, false); entityraider1.moveTo(blockposition, 0.0F, 0.0F); entityraider1.startRiding(entityraider); @@ -106,7 +106,7 @@ } } -@@ -606,6 +628,7 @@ +@@ -597,6 +619,7 @@ ++this.groupsSpawned; this.updateBossbar(); this.setDirty(); @@ -114,8 +114,8 @@ } public void joinRaid(int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) { -@@ -621,7 +644,7 @@ - entityraider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null); +@@ -612,7 +635,7 @@ + entityraider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(blockposition), EntitySpawnReason.EVENT, (GroupDataEntity) null); entityraider.applyRaidBuffs(this.level, i, false); entityraider.setOnGround(true); - this.level.addFreshEntityWithPassengers(entityraider); @@ -123,7 +123,7 @@ } } -@@ -870,6 +893,12 @@ +@@ -865,6 +888,12 @@ this.heroesOfTheVillage.add(entity.getUUID()); } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch b/nms-patches/net/minecraft/world/entity/vehicle/AbstractBoat.patch similarity index 68% rename from nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch rename to nms-patches/net/minecraft/world/entity/vehicle/AbstractBoat.patch index 44bbb9f2..f6c41ac0 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityBoat.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/AbstractBoat.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/vehicle/EntityBoat.java -+++ b/net/minecraft/world/entity/vehicle/EntityBoat.java -@@ -55,6 +55,16 @@ +--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java ++++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java +@@ -48,6 +48,15 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -9,17 +9,16 @@ +import org.bukkit.craftbukkit.util.CraftLocation; +import org.bukkit.entity.Vehicle; +import org.bukkit.event.entity.EntityRemoveEvent; -+import org.bukkit.event.vehicle.VehicleDestroyEvent; +import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; +import org.bukkit.event.vehicle.VehicleMoveEvent; +// CraftBukkit end + - public class EntityBoat extends VehicleEntity implements Leashable, VariantHolder { + public abstract class AbstractBoat extends VehicleEntity implements Leashable { - private static final DataWatcherObject DATA_ID_TYPE = DataWatcher.defineId(EntityBoat.class, DataWatcherRegistry.INT); -@@ -94,6 +104,14 @@ - @Nullable + private static final DataWatcherObject DATA_ID_PADDLE_LEFT = DataWatcher.defineId(AbstractBoat.class, DataWatcherRegistry.BOOLEAN); +@@ -87,6 +96,14 @@ private Leashable.a leashData; + private final Supplier dropItem; + // CraftBukkit start + // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable. @@ -29,12 +28,12 @@ + public boolean landBoats = false; + // CraftBukkit end + - public EntityBoat(EntityTypes entitytypes, World world) { + public AbstractBoat(EntityTypes entitytypes, World world, Supplier supplier) { super(entitytypes, world); - this.paddlePositions = new float[2]; -@@ -189,9 +207,29 @@ + this.dropItem = supplier; +@@ -182,9 +199,29 @@ public void push(Entity entity) { - if (entity instanceof EntityBoat) { + if (entity instanceof AbstractBoat) { if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { + // CraftBukkit start + if (!this.isPassengerOfSameVehicle(entity)) { @@ -62,7 +61,7 @@ super.push(entity); } -@@ -285,6 +323,7 @@ +@@ -247,6 +284,7 @@ return this.getDirection().getClockWise(); } @@ -70,7 +69,7 @@ @Override public void tick() { this.oldStatus = this.status; -@@ -325,6 +364,22 @@ +@@ -287,6 +325,21 @@ this.setDeltaMovement(Vec3D.ZERO); } @@ -89,11 +88,10 @@ + } + lastLocation = vehicle.getLocation(); + // CraftBukkit end -+ + this.applyEffectsFromBlocks(); + this.applyEffectsFromBlocks(); this.tickBubbleColumn(); - - for (int i = 0; i <= 1; ++i) { -@@ -837,11 +892,18 @@ +@@ -790,11 +843,18 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -113,23 +111,3 @@ } @Override -@@ -857,6 +919,11 @@ - - this.causeFallDamage(this.fallDistance, 1.0F, this.damageSources().fall()); - if (!this.level().isClientSide && !this.isRemoved()) { -+ // CraftBukkit start -+ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); -+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null); -+ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent); -+ if (!destroyEvent.isCancelled()) { - this.kill(); - if (this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { - int i; -@@ -870,6 +937,7 @@ - } - } - } -+ } // CraftBukkit end - } - - this.resetFallDistance(); diff --git a/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch b/nms-patches/net/minecraft/world/entity/vehicle/AbstractChestBoat.patch similarity index 88% rename from nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch rename to nms-patches/net/minecraft/world/entity/vehicle/AbstractChestBoat.patch index 1e7f11f7..5b6e2c7a 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/ChestBoat.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/AbstractChestBoat.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/vehicle/ChestBoat.java -+++ b/net/minecraft/world/entity/vehicle/ChestBoat.java -@@ -26,6 +26,15 @@ +--- a/net/minecraft/world/entity/vehicle/AbstractChestBoat.java ++++ b/net/minecraft/world/entity/vehicle/AbstractChestBoat.java +@@ -27,6 +27,15 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.storage.loot.LootTable; @@ -13,10 +13,10 @@ +import org.bukkit.inventory.InventoryHolder; +// CraftBukkit end + - public class ChestBoat extends EntityBoat implements HasCustomInventoryScreen, ContainerEntity { + public abstract class AbstractChestBoat extends AbstractBoat implements HasCustomInventoryScreen, ContainerEntity { private static final int CONTAINER_SIZE = 27; -@@ -78,11 +87,18 @@ +@@ -70,11 +79,18 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { @@ -36,7 +36,7 @@ } @Override -@@ -248,4 +264,51 @@ +@@ -212,4 +228,51 @@ public void stopOpen(EntityHuman entityhuman) { this.level().gameEvent((Holder) GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.a.of((Entity) entityhuman)); } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.patch index cdcc7248..55678f52 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 -@@ -47,6 +47,14 @@ +@@ -43,6 +43,14 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; @@ -15,7 +15,7 @@ public abstract class EntityMinecartAbstract extends VehicleEntity { private static final Vec3D LOWERED_PASSENGER_ATTACHMENT = new Vec3D(0.0D, 0.0D, 0.0D); -@@ -86,6 +94,17 @@ +@@ -76,6 +84,17 @@ enummap.put(BlockPropertyTrackPosition.NORTH_EAST, Pair.of(baseblockposition2, baseblockposition1)); }); @@ -32,17 +32,17 @@ + protected EntityMinecartAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.targetDeltaMovement = Vec3D.ZERO; -@@ -126,7 +145,7 @@ - object = new EntityMinecartRideable(worldserver, d0, d1, d2); - } + this.blocksBuilding = true; +@@ -101,7 +120,7 @@ -- Object object1 = object; -+ EntityMinecartAbstract object1 = (EntityMinecartAbstract) object; // CraftBukkit- decompile error + @Nullable + public static T createMinecart(World world, double d0, double d1, double d2, EntityTypes entitytypes, EntitySpawnReason entityspawnreason, ItemStack itemstack, @Nullable EntityHuman entityhuman) { +- T t0 = (EntityMinecartAbstract) entitytypes.create(world, entityspawnreason); ++ T t0 = (T) entitytypes.create(world, entityspawnreason); // CraftBukkit - decompile error - EntityTypes.createDefaultStackConfig(worldserver, itemstack, entityhuman).accept(object1); - return (EntityMinecartAbstract) object1; -@@ -270,6 +289,14 @@ + if (t0 != null) { + t0.setInitialPos(d0, d1, d2); +@@ -262,6 +281,14 @@ @Override public void tick() { @@ -57,86 +57,29 @@ if (this.getHurtTime() > 0) { this.setHurtTime(this.getHurtTime() - 1); } -@@ -279,7 +306,7 @@ +@@ -271,8 +298,20 @@ } this.checkBelowWorld(); - this.handlePortal(); + // this.handlePortal(); // CraftBukkit - handled in postTick - if (this.level().isClientSide) { - if (this.lerpSteps > 0) { - this.lerpPositionAndRotationStep(this.lerpSteps, this.lerpX, this.lerpY, this.lerpZ, this.lerpYRot, this.lerpXRot); -@@ -332,6 +359,18 @@ - } - - this.setRot(this.getYRot(), this.getXRot()); -+ // CraftBukkit start -+ org.bukkit.World bworld = this.level().getWorld(); -+ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch); -+ Location to = CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot()); -+ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); -+ -+ this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); -+ -+ if (!from.equals(to)) { -+ this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); -+ } -+ // CraftBukkit end - 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)); - -@@ -342,8 +381,26 @@ - Entity entity = (Entity) iterator.next(); - - if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) { -+ // CraftBukkit start -+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity()); -+ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); -+ -+ if (collisionEvent.isCancelled()) { -+ continue; -+ } -+ // CraftBukkit end - entity.startRiding(this); - } else { -+ // CraftBukkit start -+ if (!this.isPassengerOfSameVehicle(entity)) { -+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity()); -+ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); + this.behavior.tick(); ++ // CraftBukkit start ++ org.bukkit.World bworld = this.level().getWorld(); ++ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch); ++ Location to = CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot()); ++ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + -+ if (collisionEvent.isCancelled()) { -+ continue; -+ } -+ } -+ // CraftBukkit end - entity.push((Entity) this); - } - } -@@ -355,6 +412,14 @@ - Entity entity1 = (Entity) iterator1.next(); - - if (!this.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) { -+ // CraftBukkit start -+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity1.getBukkitEntity()); -+ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); ++ this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); + -+ if (collisionEvent.isCancelled()) { -+ continue; -+ } -+ // CraftBukkit end - entity1.push((Entity) this); - } - } -@@ -371,7 +436,7 @@ - } - - protected double getMaxSpeed() { -- return (this.isInWater() ? 4.0D : 8.0D) / 20.0D; -+ return (this.isInWater() ? this.maxSpeed / 2.0D: this.maxSpeed); // CraftBukkit - } - - public void activateMinecart(int i, int j, int k, boolean flag) {} -@@ -382,16 +447,30 @@ ++ if (!from.equals(to)) { ++ this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); ++ } ++ // CraftBukkit end + this.updateInWaterStateAndDoFluidPushing(); + if (this.isInLava()) { + this.lavaHurt(); +@@ -385,12 +424,16 @@ this.setDeltaMovement(MathHelper.clamp(vec3d.x, -d0, d0), vec3d.y, MathHelper.clamp(vec3d.z, -d0, d0)); if (this.onGround()) { @@ -155,30 +98,7 @@ } } - -+ // CraftBukkit start -+ @Override -+ public Vec3D getKnownMovement() { -+ double d0 = this.getMaxSpeed(); -+ Vec3D vec3d = super.getKnownMovement(); -+ -+ return new Vec3D(MathHelper.clamp(vec3d.x, -d0, d0), vec3d.y, MathHelper.clamp(vec3d.z, -d0, d0)); -+ } -+ // CraftBukkit end -+ - protected void moveAlongTrack(BlockPosition blockposition, IBlockData iblockdata) { - this.resetFallDistance(); - double d0 = this.getX(); -@@ -583,7 +662,7 @@ - } - - protected void applyNaturalSlowdown() { -- double d0 = this.isVehicle() ? 0.997D : 0.96D; -+ double d0 = this.isVehicle() || !this.slowWhenEmpty ? 0.997D : 0.96D; // CraftBukkit - add !this.slowWhenEmpty - Vec3D vec3d = this.getDeltaMovement(); - - vec3d = vec3d.multiply(d0, 0.0D, d0); -@@ -722,6 +801,14 @@ +@@ -521,6 +564,14 @@ if (!this.level().isClientSide) { if (!entity.noPhysics && !this.noPhysics) { if (!this.hasPassenger(entity)) { @@ -193,9 +113,9 @@ double d0 = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double d2 = d0 * d0 + d1 * d1; -@@ -896,4 +983,26 @@ - - private EnumMinecartType() {} +@@ -645,4 +696,26 @@ + public boolean isFurnace() { + return false; } + + // CraftBukkit start - Methods for getting and setting flying and derailed velocity modifiers diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch index fc124c7e..19b0628e 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.java -@@ -143,5 +143,12 @@ +@@ -140,5 +140,12 @@ public boolean isValid() { return !EntityMinecartCommandBlock.this.isRemoved(); } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch index 46407b55..4966dee1 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java +++ b/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java -@@ -19,6 +19,15 @@ - import net.minecraft.world.level.World; +@@ -21,6 +21,15 @@ import net.minecraft.world.level.storage.loot.LootTable; + import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import java.util.List; @@ -16,7 +16,7 @@ public abstract class EntityMinecartContainer extends EntityMinecartAbstract implements ContainerEntity { private NonNullList itemStacks; -@@ -26,14 +35,55 @@ +@@ -28,9 +37,50 @@ public ResourceKey lootTable; public long lootTableSeed; @@ -67,14 +67,8 @@ + this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 } - protected EntityMinecartContainer(EntityTypes entitytypes, double d0, double d1, double d2, World world) { - super(entitytypes, world, d0, d1, d2); -- this.itemStacks = NonNullList.withSize(36, ItemStack.EMPTY); -+ this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 - } - @Override -@@ -77,11 +127,18 @@ +@@ -74,11 +124,18 @@ @Override public void remove(Entity.RemovalReason entity_removalreason) { diff --git a/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch b/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartTNT.patch index 8072b608..c43684fd 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 -@@ -23,6 +23,11 @@ +@@ -26,6 +26,11 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.material.Fluid; @@ -12,20 +12,28 @@ public class EntityMinecartTNT extends EntityMinecartAbstract { private static final byte EVENT_PRIME = 10; -@@ -113,8 +118,16 @@ - d1 = 5.0D; - } +@@ -33,6 +38,7 @@ + private static final float DEFAULT_EXPLOSION_POWER_BASE = 4.0F; + public int fuse = -1; + public float explosionPowerBase = 4.0F; ++ public boolean isIncendiary = false; // CraftBukkit - add field -- 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); + public EntityMinecartTNT(EntityTypes entitytypes, World world) { + super(entitytypes, world); +@@ -113,8 +119,16 @@ + if (world instanceof WorldServer worldserver) { + double d1 = Math.min(Math.sqrt(d0), 5.0D); + +- worldserver.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), (float) ((double) this.explosionPowerBase + this.random.nextDouble() * 1.5D * d1), false, World.a.TNT); - this.discard(); + // CraftBukkit start -+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), (float) (4.0D + this.random.nextDouble() * 1.5D * d1), false); -+ this.level().getCraftServer().getPluginManager().callEvent(event); ++ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), (float) ((double) this.explosionPowerBase + this.random.nextDouble() * 1.5D * d1), this.isIncendiary); ++ worldserver.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + fuse = -1; + return; + } -+ this.level().explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT); ++ worldserver.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT); + // CraftBukkit end + this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.patch b/nms-patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.patch new file mode 100644 index 00000000..ef0b9564 --- /dev/null +++ b/nms-patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.patch @@ -0,0 +1,70 @@ +--- a/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java +@@ -28,6 +28,11 @@ + import net.minecraft.world.phys.AxisAlignedBB; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import org.bukkit.entity.Vehicle; ++import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; ++// CraftBukkit end ++ + public class NewMinecartBehavior extends MinecartBehavior { + + public static final int POS_ROT_LERP_TICKS = 3; +@@ -544,7 +549,7 @@ + + @Override + public double getSlowdownFactor() { +- return this.minecart.isVehicle() ? 0.997D : 0.975D; ++ return this.minecart.isVehicle() || !this.minecart.slowWhenEmpty ? 0.997D : 0.975D; // CraftBukkit - add !this.slowWhenEmpty + } + + @Override +@@ -571,6 +576,14 @@ + Entity entity = (Entity) iterator.next(); + + if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.minecart.isVehicle() && !entity.isPassenger()) { ++ // CraftBukkit start ++ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); ++ ++ if (collisionEvent.isCancelled()) { ++ continue; ++ } ++ // CraftBukkit end + boolean flag = entity.startRiding(this.minecart); + + if (flag) { +@@ -597,6 +610,16 @@ + Entity entity = (Entity) iterator.next(); + + if (entity instanceof EntityHuman || entity instanceof EntityIronGolem || entity instanceof EntityMinecartAbstract || this.minecart.isVehicle() || entity.isPassenger()) { ++ // CraftBukkit start ++ if (!this.minecart.isPassengerOfSameVehicle(entity)) { ++ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); ++ ++ if (collisionEvent.isCancelled()) { ++ continue; ++ } ++ } ++ // CraftBukkit end + entity.push((Entity) this.minecart); + flag = true; + } +@@ -609,6 +632,14 @@ + Entity entity1 = (Entity) iterator1.next(); + + if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) { ++ // CraftBukkit start ++ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity1.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); ++ ++ if (collisionEvent.isCancelled()) { ++ continue; ++ } ++ // CraftBukkit end + entity1.push((Entity) this.minecart); + flag = true; + } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.patch b/nms-patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.patch new file mode 100644 index 00000000..3b43b93d --- /dev/null +++ b/nms-patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.patch @@ -0,0 +1,70 @@ +--- a/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java +@@ -25,6 +25,11 @@ + import net.minecraft.world.phys.AxisAlignedBB; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import org.bukkit.entity.Vehicle; ++import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; ++// CraftBukkit end ++ + public class OldMinecartBehavior extends MinecartBehavior { + + private static final double MINECART_RIDABLE_THRESHOLD = 0.01D; +@@ -454,8 +459,26 @@ + Entity entity = (Entity) iterator.next(); + + if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.minecart.isVehicle() && !entity.isPassenger()) { ++ // CraftBukkit start ++ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); ++ ++ if (collisionEvent.isCancelled()) { ++ continue; ++ } ++ // CraftBukkit end + entity.startRiding(this.minecart); + } else { ++ // CraftBukkit start ++ if (!this.minecart.isPassengerOfSameVehicle(entity)) { ++ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); ++ ++ if (collisionEvent.isCancelled()) { ++ continue; ++ } ++ } ++ // CraftBukkit end + entity.push((Entity) this.minecart); + } + } +@@ -467,6 +490,14 @@ + Entity entity1 = (Entity) iterator1.next(); + + if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) { ++ // CraftBukkit start ++ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity1.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); ++ ++ if (collisionEvent.isCancelled()) { ++ continue; ++ } ++ // CraftBukkit end + entity1.push((Entity) this.minecart); + } + } +@@ -487,11 +518,11 @@ + + @Override + public double getMaxSpeed(WorldServer worldserver) { +- return this.minecart.isInWater() ? 0.2D : 0.4D; ++ return (this.minecart.isInWater() ? this.minecart.maxSpeed / 2.0D: this.minecart.maxSpeed); // CraftBukkit + } + + @Override + public double getSlowdownFactor() { +- return this.minecart.isVehicle() ? 0.997D : 0.96D; ++ return this.minecart.isVehicle() || !this.minecart.slowWhenEmpty ? 0.997D : 0.96D; // CraftBukkit - add !this.slowWhenEmpty + } + } diff --git a/nms-patches/net/minecraft/world/entity/vehicle/VehicleEntity.patch b/nms-patches/net/minecraft/world/entity/vehicle/VehicleEntity.patch index 69de92da..7f20fdff 100644 --- a/nms-patches/net/minecraft/world/entity/vehicle/VehicleEntity.patch +++ b/nms-patches/net/minecraft/world/entity/vehicle/VehicleEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/VehicleEntity.java +++ b/net/minecraft/world/entity/vehicle/VehicleEntity.java -@@ -14,6 +14,13 @@ +@@ -17,6 +17,13 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; @@ -14,42 +14,30 @@ public abstract class VehicleEntity extends Entity { protected static final DataWatcherObject DATA_ID_HURT = DataWatcher.defineId(VehicleEntity.class, DataWatcherRegistry.INT); -@@ -30,6 +37,18 @@ - if (this.isInvulnerableTo(damagesource)) { - return false; - } else { -+ // CraftBukkit start -+ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); -+ org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); +@@ -40,6 +47,18 @@ + return false; + } else { + boolean flag; ++ // CraftBukkit start ++ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); ++ org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); + -+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f); -+ this.level().getCraftServer().getPluginManager().callEvent(event); ++ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f); ++ this.level().getCraftServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ return false; -+ } -+ f = (float) event.getDamage(); -+ // CraftBukkit end ++ if (event.isCancelled()) { ++ return false; ++ } ++ f = (float) event.getDamage(); ++ // CraftBukkit end + label32: + { this.setHurtDir(-this.getHurtDir()); - this.setHurtTime(10); - this.markHurt(); -@@ -39,9 +58,27 @@ +@@ -65,9 +84,27 @@ - if ((flag || this.getDamage() <= 40.0F) && !this.shouldSourceDestroy(damagesource)) { - if (flag) { -- this.discard(); -+ // CraftBukkit start -+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); -+ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent); -+ -+ if (destroyEvent.isCancelled()) { -+ this.setDamage(40.0F); // Maximize damage so this doesn't get triggered again right away -+ return true; -+ } -+ // CraftBukkit end -+ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause - } - } else { + if ((flag1 || this.getDamage() <= 40.0F) && !this.shouldSourceDestroy(damagesource)) { + if (flag1) { +- this.discard(); + // CraftBukkit start + VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); + this.level().getCraftServer().getPluginManager().callEvent(destroyEvent); @@ -59,6 +47,18 @@ + return true; + } + // CraftBukkit end - this.destroy(damagesource); ++ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause } + } else { ++ // CraftBukkit start ++ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); ++ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent); ++ ++ if (destroyEvent.isCancelled()) { ++ this.setDamage(40.0F); // Maximize damage so this doesn't get triggered again right away ++ return true; ++ } ++ // CraftBukkit end + this.destroy(worldserver, damagesource); + } diff --git a/nms-patches/net/minecraft/world/food/FoodInfo.patch b/nms-patches/net/minecraft/world/food/FoodInfo.patch new file mode 100644 index 00000000..294900c9 --- /dev/null +++ b/nms-patches/net/minecraft/world/food/FoodInfo.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/world/food/FoodInfo.java ++++ b/net/minecraft/world/food/FoodInfo.java +@@ -18,6 +18,10 @@ + import net.minecraft.world.item.component.ConsumableListener; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import net.minecraft.server.level.EntityPlayer; ++// CraftBukkit end ++ + public record FoodInfo(int nutrition, float saturation, boolean canAlwaysEat) implements ConsumableListener { + + public static final Codec DIRECT_CODEC = RecordCodecBuilder.create((instance) -> { +@@ -31,7 +35,7 @@ + + world.playSound((EntityHuman) null, entityliving.getX(), entityliving.getY(), entityliving.getZ(), (SoundEffect) consumable.sound().value(), SoundCategory.NEUTRAL, 1.0F, randomsource.triangle(1.0F, 0.4F)); + if (entityliving instanceof EntityHuman entityhuman) { +- entityhuman.getFoodData().eat(this); ++ entityhuman.getFoodData().eat(this, itemstack, (EntityPlayer) entityhuman); // CraftBukkit + world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, MathHelper.randomBetween(randomsource, 0.9F, 1.0F)); + } + diff --git a/nms-patches/net/minecraft/world/food/FoodMetaData.patch b/nms-patches/net/minecraft/world/food/FoodMetaData.patch index a697f51d..dc73325e 100644 --- a/nms-patches/net/minecraft/world/food/FoodMetaData.patch +++ b/nms-patches/net/minecraft/world/food/FoodMetaData.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/world/food/FoodMetaData.java +++ b/net/minecraft/world/food/FoodMetaData.java -@@ -6,15 +6,34 @@ - import net.minecraft.world.entity.player.EntityHuman; +@@ -7,12 +7,22 @@ + import net.minecraft.world.EnumDifficulty; import net.minecraft.world.level.GameRules; +// CraftBukkit start +import net.minecraft.network.protocol.game.PacketPlayOutUpdateHealth; -+import net.minecraft.server.level.EntityPlayer; +import net.minecraft.world.item.ItemStack; +// CraftBukkit end + @@ -17,93 +16,81 @@ public float exhaustionLevel; private int tickTimer; + // CraftBukkit start -+ private EntityHuman entityhuman; + public int saturatedRegenRate = 10; + public int unsaturatedRegenRate = 80; + public int starvationRate = 80; + // CraftBukkit end - private int lastFoodLevel = 20; -- public FoodMetaData() {} -+ public FoodMetaData() { throw new AssertionError("Whoopsie, we missed the bukkit."); } // CraftBukkit start - throw an error -+ -+ // CraftBukkit start - added EntityHuman constructor -+ public FoodMetaData(EntityHuman entityhuman) { -+ org.apache.commons.lang.Validate.notNull(entityhuman); -+ this.entityhuman = entityhuman; -+ } -+ // CraftBukkit end + public FoodMetaData() {} - private void add(int i, float f) { - this.foodLevel = MathHelper.clamp(i + this.foodLevel, 0, 20); -@@ -29,6 +48,20 @@ +@@ -29,6 +39,20 @@ this.add(foodinfo.nutrition(), foodinfo.saturation()); } + // CraftBukkit start -+ public void eat(ItemStack itemstack, FoodInfo foodinfo) { ++ public void eat(FoodInfo foodinfo, ItemStack itemstack, EntityPlayer entityplayer) { + int oldFoodLevel = foodLevel; + -+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodinfo.nutrition() + oldFoodLevel, itemstack); ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityplayer, foodinfo.nutrition() + oldFoodLevel, itemstack); + + if (!event.isCancelled()) { + this.add(event.getFoodLevel() - oldFoodLevel, foodinfo.saturation()); + } + -+ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); ++ entityplayer.getBukkitEntity().sendHealthUpdate(); + } + // CraftBukkit end + - public void tick(EntityHuman entityhuman) { - EnumDifficulty enumdifficulty = entityhuman.level().getDifficulty(); - -@@ -38,7 +71,15 @@ + public void tick(EntityPlayer entityplayer) { + WorldServer worldserver = entityplayer.serverLevel(); + EnumDifficulty enumdifficulty = worldserver.getDifficulty(); +@@ -38,7 +62,15 @@ if (this.saturationLevel > 0.0F) { this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F); } else if (enumdifficulty != EnumDifficulty.PEACEFUL) { - this.foodLevel = Math.max(this.foodLevel - 1, 0); + // CraftBukkit start -+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, Math.max(this.foodLevel - 1, 0)); ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityplayer, Math.max(this.foodLevel - 1, 0)); + + if (!event.isCancelled()) { + this.foodLevel = event.getFoodLevel(); + } + -+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), this.foodLevel, this.saturationLevel)); ++ entityplayer.connection.send(new PacketPlayOutUpdateHealth(entityplayer.getBukkitEntity().getScaledHealth(), this.foodLevel, this.saturationLevel)); + // CraftBukkit end } } -@@ -46,23 +87,25 @@ +@@ -46,23 +78,25 @@ - if (flag && this.saturationLevel > 0.0F && entityhuman.isHurt() && this.foodLevel >= 20) { + if (flag && this.saturationLevel > 0.0F && entityplayer.isHurt() && this.foodLevel >= 20) { ++this.tickTimer; - if (this.tickTimer >= 10) { + if (this.tickTimer >= this.saturatedRegenRate) { // CraftBukkit float f = Math.min(this.saturationLevel, 6.0F); -- entityhuman.heal(f / 6.0F); +- entityplayer.heal(f / 6.0F); - this.addExhaustion(f); -+ entityhuman.heal(f / 6.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason ++ entityplayer.heal(f / 6.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason + // this.addExhaustion(f); CraftBukkit - EntityExhaustionEvent -+ entityhuman.causeFoodExhaustion(f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent ++ entityplayer.causeFoodExhaustion(f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent this.tickTimer = 0; } - } else if (flag && this.foodLevel >= 18 && entityhuman.isHurt()) { + } else if (flag && this.foodLevel >= 18 && entityplayer.isHurt()) { ++this.tickTimer; - if (this.tickTimer >= 80) { -- entityhuman.heal(1.0F); +- entityplayer.heal(1.0F); - this.addExhaustion(6.0F); + if (this.tickTimer >= this.unsaturatedRegenRate) { // CraftBukkit - add regen rate manipulation -+ entityhuman.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason -+ // this.a(6.0F); CraftBukkit - EntityExhaustionEvent -+ entityhuman.causeFoodExhaustion(6.0f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent ++ entityplayer.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason ++ // this.addExhaustion(6.0F); CraftBukkit - EntityExhaustionEvent ++ entityplayer.causeFoodExhaustion(6.0f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent this.tickTimer = 0; } } else if (this.foodLevel <= 0) { ++this.tickTimer; - if (this.tickTimer >= 80) { + if (this.tickTimer >= this.starvationRate) { // CraftBukkit - add regen rate manipulation - if (entityhuman.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || entityhuman.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL) { - entityhuman.hurt(entityhuman.damageSources().starve(), 1.0F); + if (entityplayer.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || entityplayer.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL) { + entityplayer.hurtServer(worldserver, entityplayer.damageSources().starve(), 1.0F); } diff --git a/nms-patches/net/minecraft/world/inventory/AbstractCraftingMenu.patch b/nms-patches/net/minecraft/world/inventory/AbstractCraftingMenu.patch new file mode 100644 index 00000000..d0ab6955 --- /dev/null +++ b/nms-patches/net/minecraft/world/inventory/AbstractCraftingMenu.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/world/inventory/AbstractCraftingMenu.java ++++ b/net/minecraft/world/inventory/AbstractCraftingMenu.java +@@ -13,14 +13,17 @@ + + private final int width; + private final int height; +- public final InventoryCrafting craftSlots; ++ public final TransientCraftingContainer craftSlots; // CraftBukkit + public final InventoryCraftResult resultSlots = new InventoryCraftResult(); + +- public AbstractCraftingMenu(Containers containers, int i, int j, int k) { ++ public AbstractCraftingMenu(Containers containers, int i, int j, int k, PlayerInventory playerInventory) { // CraftBukkit + super(containers, i); + this.width = j; + this.height = k; +- this.craftSlots = new TransientCraftingContainer(this, j, k); ++ // CraftBukkit start ++ this.craftSlots = new TransientCraftingContainer(this, j, k, playerInventory.player); // CraftBukkit - pass player ++ this.craftSlots.resultInventory = this.resultSlots; // CraftBukkit - let InventoryCrafting know about its result slot ++ // CraftBukkit end + } + + protected Slot addResultSlot(EntityHuman entityhuman, int i, int j) { +@@ -38,7 +41,7 @@ + + @Override + public ContainerRecipeBook.a handlePlacement(boolean flag, boolean flag1, RecipeHolder recipeholder, WorldServer worldserver, PlayerInventory playerinventory) { +- RecipeHolder recipeholder1 = recipeholder; ++ RecipeHolder recipeholder1 = (RecipeHolder) recipeholder; // CraftBukkit - decompile error + + this.beginPlacingRecipe(); + +@@ -65,7 +68,7 @@ + } + }, this.width, this.height, list, list, playerinventory, recipeholder1, flag, flag1); + } finally { +- this.finishPlacingRecipe(worldserver, recipeholder); ++ this.finishPlacingRecipe(worldserver, recipeholder1); // CraftBukkit - decompile error + } + + return containerrecipebook_a; diff --git a/nms-patches/net/minecraft/world/inventory/Container.patch b/nms-patches/net/minecraft/world/inventory/Container.patch index 9e3afe1d..89229c65 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 -@@ -33,6 +33,20 @@ +@@ -35,6 +35,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(); -@@ -63,6 +77,27 @@ +@@ -67,6 +81,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(); -@@ -164,6 +199,15 @@ +@@ -192,6 +227,15 @@ } @@ -65,7 +65,7 @@ public void removeSlotListener(ICrafting icrafting) { this.containerListeners.remove(icrafting); } -@@ -380,7 +424,7 @@ +@@ -417,7 +461,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); -@@ -396,6 +440,7 @@ +@@ -433,6 +477,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 @@ +@@ -443,12 +488,48 @@ int l1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1); l -= l1 - j1; @@ -134,7 +134,7 @@ } this.resetQuickCraft(); -@@ -429,8 +510,11 @@ +@@ -466,8 +547,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 @@ +@@ -530,6 +614,15 @@ } slot.setChanged(); @@ -163,23 +163,18 @@ } } else { int j2; -@@ -609,13 +702,14 @@ +@@ -662,8 +755,9 @@ ItemStack itemstack = this.getCarried(); if (!itemstack.isEmpty()) { + this.setCarried(ItemStack.EMPTY); // CraftBukkit - SPIGOT-4556 - from below - if (entityhuman.isAlive() && !((EntityPlayer) entityhuman).hasDisconnected()) { - entityhuman.getInventory().placeItemBackInInventory(itemstack); - } else { - entityhuman.drop(itemstack, false); - } - + dropOrPlaceInInventory(entityhuman, itemstack); - this.setCarried(ItemStack.EMPTY); + // this.setCarried(ItemStack.EMPTY); // CraftBukkit - moved up } - } -@@ -830,6 +924,11 @@ + } +@@ -893,6 +987,11 @@ } public ItemStack getCarried() { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch b/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch index 7cf49410..74393b2c 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerAnvil.patch @@ -11,7 +11,7 @@ public class ContainerAnvil extends ContainerAnvilAbstract { public static final int INPUT_SLOT = 0; -@@ -44,6 +48,11 @@ +@@ -45,6 +49,11 @@ private static final int ADDITIONAL_SLOT_X_PLACEMENT = 76; private static final int RESULT_SLOT_X_PLACEMENT = 134; private static final int SLOT_Y_PLACEMENT = 47; @@ -23,7 +23,7 @@ public ContainerAnvil(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -71,7 +80,7 @@ +@@ -72,7 +81,7 @@ @Override protected boolean mayPickup(EntityHuman entityhuman, boolean flag) { @@ -38,11 +38,11 @@ - this.cost.set(0); + this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item + this.inputSlots.setItem(0, ItemStack.EMPTY); this.access.execute((world, blockposition) -> { IBlockData iblockdata = world.getBlockState(blockposition); - -@@ -141,8 +150,8 @@ - if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) { +@@ -143,8 +152,8 @@ + if (itemstack1.isDamageableItem() && itemstack.isValidRepairItem(itemstack2)) { k = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); if (k <= 0) { - this.resultSlots.setItem(0, ItemStack.EMPTY); @@ -52,7 +52,7 @@ return; } -@@ -156,8 +165,8 @@ +@@ -158,8 +167,8 @@ this.repairItemCountCost = i1; } else { if (!flag && (!itemstack1.is(itemstack2.getItem()) || !itemstack1.isDamageableItem())) { @@ -63,7 +63,7 @@ return; } -@@ -231,8 +240,8 @@ +@@ -233,8 +242,8 @@ } if (flag2 && !flag1) { @@ -74,14 +74,17 @@ return; } } -@@ -257,11 +266,11 @@ - itemstack1 = ItemStack.EMPTY; +@@ -260,14 +269,14 @@ } -- if (b0 == i && b0 > 0 && this.cost.get() >= 40) { -- this.cost.set(39); -+ if (b0 == i && b0 > 0 && this.cost.get() >= maximumRepairCost) { // CraftBukkit -+ this.cost.set(maximumRepairCost - 1); // CraftBukkit + if (b0 == i && b0 > 0) { +- if (this.cost.get() >= 40) { +- this.cost.set(39); ++ if (this.cost.get() >= maximumRepairCost) { // CraftBukkit ++ this.cost.set(maximumRepairCost - 1); // CraftBukkit + } + + this.onlyRenaming = true; } - if (this.cost.get() >= 40 && !this.player.getAbilities().instabuild) { @@ -89,7 +92,7 @@ itemstack1 = ItemStack.EMPTY; } -@@ -279,11 +288,12 @@ +@@ -285,11 +294,12 @@ EnchantmentManager.setEnchantments(itemstack1, itemenchantments_a.toImmutable()); } @@ -105,7 +108,7 @@ } } -@@ -323,4 +333,19 @@ +@@ -329,4 +339,19 @@ public int getCost() { return this.cost.get(); } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch b/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch index 4c76c0b1..204c7d1c 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerAnvilAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerAnvilAbstract.java +++ b/net/minecraft/world/inventory/ContainerAnvilAbstract.java -@@ -47,7 +47,7 @@ +@@ -50,7 +50,7 @@ while (iterator.hasNext()) { final ItemCombinerMenuSlotDefinition.b itemcombinermenuslotdefinition_b = (ItemCombinerMenuSlotDefinition.b) iterator.next(); @@ -9,7 +9,7 @@ @Override public boolean mayPlace(ItemStack itemstack) { return itemcombinermenuslotdefinition_b.mayPlace().test(itemstack); -@@ -124,6 +124,7 @@ +@@ -110,6 +110,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch b/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch index 33ba78a9..b1549438 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch @@ -33,7 +33,7 @@ @Override public boolean canPlaceItem(int j, ItemStack itemstack) { return itemstack.is(TagsItem.BEACON_PAYMENT_ITEMS); -@@ -83,6 +93,7 @@ +@@ -69,6 +79,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -41,7 +41,7 @@ return stillValid(this.access, entityhuman, Blocks.BEACON); } -@@ -164,8 +175,8 @@ +@@ -150,8 +161,8 @@ public void updateEffects(Optional> optional, Optional> optional1) { if (this.paymentSlot.hasItem()) { @@ -52,7 +52,7 @@ this.paymentSlot.remove(1); this.access.execute(World::blockEntityChanged); } -@@ -192,4 +203,17 @@ +@@ -178,4 +189,17 @@ return 1; } } @@ -64,7 +64,7 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon(this.beacon); ++ org.bukkit.craftbukkit.inventory.CraftInventoryBeacon inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon(this.beacon); + bukkitEntity = new CraftBeaconView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch b/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch index 0c45c771..ea84f452 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerBrewingStand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerBrewingStand.java +++ b/net/minecraft/world/inventory/ContainerBrewingStand.java -@@ -15,6 +15,11 @@ +@@ -16,6 +16,11 @@ import net.minecraft.world.item.alchemy.PotionContents; import net.minecraft.world.item.alchemy.PotionRegistry; @@ -12,7 +12,7 @@ public class ContainerBrewingStand extends Container { private static final int BOTTLE_SLOT_START = 0; -@@ -31,12 +36,18 @@ +@@ -32,12 +37,18 @@ private final IContainerProperties brewingStandData; private final Slot ingredientSlot; @@ -31,7 +31,7 @@ checkContainerSize(iinventory, 5); checkContainerDataCount(icontainerproperties, 2); this.brewingStand = iinventory; -@@ -66,6 +77,7 @@ +@@ -55,6 +66,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -39,8 +39,8 @@ return this.brewingStand.stillValid(entityhuman); } -@@ -196,4 +208,17 @@ - return itemstack.is(Items.BLAZE_POWDER); +@@ -185,4 +197,17 @@ + return itemstack.is(TagsItem.BREWING_FUEL); } } + diff --git a/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch b/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch index fce0e967..3872eb8c 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerCartography.patch @@ -62,7 +62,7 @@ + this.addSlot(new Slot(this.container, 0, 15, 15) { // CraftBukkit - decompile error @Override public boolean mayPlace(ItemStack itemstack) { - return itemstack.is(Items.FILLED_MAP); + return itemstack.has(DataComponents.MAP_ID); } }); - this.addSlot(new Slot(this, this.container, 1, 15, 52) { @@ -70,10 +70,10 @@ @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.is(Items.PAPER) || itemstack.is(Items.MAP) || itemstack.is(Items.GLASS_PANE); -@@ -97,10 +133,12 @@ - this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142)); - } - +@@ -85,10 +121,12 @@ + } + }); + this.addStandardInventorySlots(playerinventory, 8, 84); + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerChest.patch b/nms-patches/net/minecraft/world/inventory/ContainerChest.patch index e955215f..cdc889f1 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerChest.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerChest.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerChest.java +++ b/net/minecraft/world/inventory/ContainerChest.java -@@ -6,11 +6,40 @@ +@@ -6,10 +6,39 @@ import net.minecraft.world.entity.player.PlayerInventory; import net.minecraft.world.item.ItemStack; @@ -12,7 +12,6 @@ + public class ContainerChest extends Container { - private static final int SLOTS_PER_ROW = 9; private final IInventory container; private final int containerRows; + // CraftBukkit start @@ -41,18 +40,17 @@ private ContainerChest(Containers containers, int i, PlayerInventory playerinventory, int j) { this(containers, i, playerinventory, new InventorySubcontainer(9 * j), j); -@@ -56,6 +85,10 @@ +@@ -53,6 +82,9 @@ + this.container = iinventory; + this.containerRows = j; iinventory.startOpen(playerinventory.player); - int k = (this.containerRows - 4) * 18; - + // CraftBukkit start - Save player + this.player = playerinventory; + // CraftBukkit end -+ - int l; - int i1; + boolean flag = true; -@@ -79,6 +112,7 @@ + this.addChestGrid(iinventory, 8, 18); +@@ -72,6 +104,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch b/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch index a678f092..682cb82e 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch @@ -34,7 +34,7 @@ checkContainerSize(iinventory, 9); this.dispenser = iinventory; iinventory.startOpen(playerinventory.player); -@@ -48,6 +61,7 @@ +@@ -41,6 +54,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -42,7 +42,7 @@ return this.dispenser.stillValid(entityhuman); } -@@ -89,4 +103,17 @@ +@@ -82,4 +96,17 @@ super.removed(entityhuman); this.dispenser.stopOpen(entityhuman); } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch b/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch index 6b02e272..b30ed5ec 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch @@ -61,7 +61,7 @@ @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.is(Items.LAPIS_LAZULI); -@@ -101,6 +125,9 @@ +@@ -89,6 +113,9 @@ this.addDataSlot(ContainerProperty.shared(this.levelClue, 0)); this.addDataSlot(ContainerProperty.shared(this.levelClue, 1)); this.addDataSlot(ContainerProperty.shared(this.levelClue, 2)); @@ -71,16 +71,16 @@ } @Override -@@ -108,7 +135,7 @@ +@@ -96,7 +123,7 @@ if (iinventory == this.enchantSlots) { ItemStack itemstack = iinventory.getItem(0); - if (!itemstack.isEmpty() && itemstack.isEnchantable()) { + if (!itemstack.isEmpty()) { // CraftBukkit - relax condition this.access.execute((world, blockposition) -> { - Registry> registry = world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); + Registry> registry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); int i = 0; -@@ -148,6 +175,41 @@ +@@ -136,6 +163,41 @@ } } @@ -122,14 +122,14 @@ this.broadcastChanges(); }); } else { -@@ -175,21 +237,46 @@ +@@ -163,21 +225,46 @@ ItemStack itemstack2 = itemstack; List list = this.getEnchantmentList(world.registryAccess(), itemstack, i, this.costs[i]); - if (!list.isEmpty()) { - entityhuman.onEnchantmentPerformed(itemstack, j); + // CraftBukkit start -+ Registry> registry = world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); ++ Registry> registry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); + if (true || !list.isEmpty()) { + // entityhuman.onEnchantmentPerformed(itemstack, j); // Moved down + Map enchants = new java.util.HashMap(); @@ -175,7 +175,7 @@ itemstack1.consume(j, entityhuman); if (itemstack1.isEmpty()) { this.enchantSlots.setItem(1, ItemStack.EMPTY); -@@ -256,6 +343,7 @@ +@@ -244,6 +331,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -183,7 +183,7 @@ return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE); } -@@ -306,4 +394,17 @@ +@@ -294,4 +382,17 @@ return itemstack; } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch b/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch index 2bffe3f9..9720bf6a 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerFurnace.patch @@ -1,19 +1,20 @@ --- a/net/minecraft/world/inventory/ContainerFurnace.java +++ b/net/minecraft/world/inventory/ContainerFurnace.java -@@ -14,6 +14,11 @@ +@@ -18,6 +18,12 @@ + import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.level.World; - import net.minecraft.world.level.block.entity.TileEntityFurnace; +// CraftBukkit start ++import net.minecraft.world.level.block.entity.TileEntityFurnace; +import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace; +import org.bukkit.craftbukkit.inventory.view.CraftFurnaceView; +// CraftBukkit end + - public abstract class ContainerFurnace extends ContainerRecipeBook { + public abstract class ContainerFurnace extends ContainerRecipeBook { public static final int INGREDIENT_SLOT = 0; -@@ -31,6 +36,22 @@ - private final Recipes recipeType; +@@ -36,6 +42,22 @@ + private final RecipePropertySet acceptedInputs; private final RecipeBookType recipeBookType; + // CraftBukkit start @@ -32,18 +33,18 @@ + } + // CraftBukkit end + - protected ContainerFurnace(Containers containers, Recipes recipes, RecipeBookType recipebooktype, int i, PlayerInventory playerinventory) { - this(containers, recipes, recipebooktype, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4)); + protected ContainerFurnace(Containers containers, Recipes recipes, ResourceKey resourcekey, RecipeBookType recipebooktype, int i, PlayerInventory playerinventory) { + this(containers, recipes, resourcekey, recipebooktype, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4)); } -@@ -47,6 +68,7 @@ +@@ -53,6 +75,7 @@ this.addSlot(new Slot(iinventory, 0, 56, 17)); this.addSlot(new SlotFurnaceFuel(this, iinventory, 1, 56, 53)); this.addSlot(new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35)); + this.player = playerinventory; // CraftBukkit - save player - - int j; - -@@ -104,6 +126,7 @@ + this.addStandardInventorySlots(playerinventory, 8, 84); + this.addDataSlots(icontainerproperties); + } +@@ -71,6 +94,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -51,3 +52,11 @@ return this.container.stillValid(entityhuman); } +@@ -180,6 +204,6 @@ + public boolean recipeMatches(RecipeHolder recipeholder1) { + return ((RecipeCooking) recipeholder1.value()).matches(new SingleRecipeInput(ContainerFurnace.this.container.getItem(0)), worldserver); + } +- }, 1, 1, List.of(this.getSlot(0)), list, playerinventory, recipeholder, flag, flag1); ++ }, 1, 1, List.of(this.getSlot(0)), list, playerinventory, (RecipeHolder) recipeholder, flag, flag1); // CraftBukkit - decompile error + } + } diff --git a/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch b/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch index e35e128c..2ad13b21 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerGrindstone.patch @@ -56,15 +56,15 @@ @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.isDamageableItem() || EnchantmentManager.hasAnyEnchantments(itemstack); -@@ -125,6 +154,7 @@ - this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142)); - } - +@@ -113,6 +142,7 @@ + } + }); + this.addStandardInventorySlots(playerinventory, 8, 84); + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } @Override -@@ -137,7 +167,8 @@ +@@ -125,7 +155,8 @@ } private void createResult() { @@ -74,7 +74,7 @@ this.broadcastChanges(); } -@@ -239,6 +270,7 @@ +@@ -227,6 +258,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch b/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch index 1a6a5505..4f0fd9ab 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch @@ -40,8 +40,8 @@ + this.player = playerinventory; // CraftBukkit - save player checkContainerSize(iinventory, 5); iinventory.startOpen(playerinventory.player); - boolean flag = true; -@@ -42,6 +64,7 @@ + +@@ -30,6 +52,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch b/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch index 88d6bafd..ef136c31 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerHorse.patch @@ -12,7 +12,7 @@ public class ContainerHorse extends Container { private final IInventory horseContainer; -@@ -18,8 +23,23 @@ +@@ -18,13 +23,28 @@ private static final int SLOT_BODY_ARMOR = 1; private static final int SLOT_HORSE_INVENTORY_START = 2; @@ -36,16 +36,13 @@ this.horseContainer = iinventory; this.armorContainer = entityhorseabstract.getBodyArmorAccess(); this.horse = entityhorseabstract; -@@ -28,7 +48,7 @@ iinventory.startOpen(playerinventory.player); - boolean flag1 = true; - - this.addSlot(new Slot(this, iinventory, 0, 8, 18) { + this.addSlot(new Slot(iinventory, 0, 8, 18) { // CraftBukkit - decompile error @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.is(Items.SADDLE) && !this.hasItem() && entityhorseabstract.isSaddleable(); -@@ -39,7 +59,7 @@ +@@ -35,7 +55,7 @@ return entityhorseabstract.isSaddleable(); } }); @@ -53,4 +50,4 @@ + this.addSlot(new ArmorSlot(this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, (MinecraftKey) null) { // CraftBukkit - decompile error @Override public boolean mayPlace(ItemStack itemstack) { - return entityhorseabstract.isBodyArmorItem(itemstack); + return entityhorseabstract.isEquippableInSlot(itemstack, EnumItemSlot.BODY); diff --git a/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch b/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch index 002f671a..ff61f6da 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerLoom.patch @@ -77,8 +77,8 @@ @Override public boolean mayPlace(ItemStack itemstack) { return itemstack.getItem() instanceof ItemBannerPattern; -@@ -128,10 +164,12 @@ - +@@ -116,10 +152,12 @@ + this.addStandardInventorySlots(playerinventory, 8, 84); this.addDataSlot(this.selectedBannerPatternIndex); this.patternGetter = playerinventory.player.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN); + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit @@ -90,7 +90,7 @@ return stillValid(this.access, entityhuman, Blocks.LOOM); } -@@ -306,6 +344,11 @@ +@@ -294,6 +332,11 @@ EnumColor enumcolor = ((ItemDye) itemstack1.getItem()).getDyeColor(); itemstack2.update(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY, (bannerpatternlayers) -> { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch b/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch index c7e8e5cd..6f8db52e 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch @@ -34,10 +34,10 @@ this.addSlot(new Slot(this.tradeContainer, 1, 162, 37)); this.addSlot(new SlotMerchantResult(playerinventory.player, imerchant, this.tradeContainer, 2, 220, 37)); + this.player = playerinventory; // CraftBukkit - save player + this.addStandardInventorySlots(playerinventory, 108, 84); + } - int j; - -@@ -155,7 +171,7 @@ +@@ -143,7 +159,7 @@ } private void playTradeSound() { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch b/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch index 0c5eaf1b..f66a82c7 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerPlayer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/inventory/ContainerPlayer.java +++ b/net/minecraft/world/inventory/ContainerPlayer.java @@ -13,6 +13,12 @@ - import net.minecraft.world.item.crafting.RecipeCrafting; import net.minecraft.world.item.crafting.RecipeHolder; + import net.minecraft.world.level.World; +// CraftBukkit start +import net.minecraft.network.chat.IChatBaseComponent; @@ -10,52 +10,38 @@ +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + - public class ContainerPlayer extends ContainerRecipeBook { + public class ContainerPlayer extends AbstractCraftingMenu { public static final int CONTAINER_ID = 0; -@@ -36,15 +42,28 @@ - public static final MinecraftKey EMPTY_ARMOR_SLOT_SHIELD = MinecraftKey.withDefaultNamespace("item/empty_armor_slot_shield"); - private static final Map TEXTURE_EMPTY_SLOTS = Map.of(EnumItemSlot.FEET, ContainerPlayer.EMPTY_ARMOR_SLOT_BOOTS, EnumItemSlot.LEGS, ContainerPlayer.EMPTY_ARMOR_SLOT_LEGGINGS, EnumItemSlot.CHEST, ContainerPlayer.EMPTY_ARMOR_SLOT_CHESTPLATE, EnumItemSlot.HEAD, ContainerPlayer.EMPTY_ARMOR_SLOT_HELMET); +@@ -40,9 +46,15 @@ private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET}; -- private final InventoryCrafting craftSlots = new TransientCraftingContainer(this, 2, 2); -- private final InventoryCraftResult resultSlots = new InventoryCraftResult(); -+ // CraftBukkit start -+ private final TransientCraftingContainer craftSlots; -+ private final InventoryCraftResult resultSlots; -+ // CraftBukkit end public final boolean active; private final EntityHuman owner; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; -+ private PlayerInventory player; + // CraftBukkit end public ContainerPlayer(PlayerInventory playerinventory, boolean flag, final EntityHuman entityhuman) { - super((Containers) null, 0); - this.active = flag; - this.owner = entityhuman; +- super((Containers) null, 0, 2, 2); + // CraftBukkit start -+ this.resultSlots = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction -+ this.craftSlots = new TransientCraftingContainer(this, 2, 2, playerinventory.player); // CraftBukkit - pass player -+ this.craftSlots.resultInventory = this.resultSlots; // CraftBukkit - let InventoryCrafting know about its result slot -+ this.player = playerinventory; // CraftBukkit - save player ++ super((Containers) null, 0, 2, 2, playerinventory); // CraftBukkit - save player + setTitle(IChatBaseComponent.translatable("container.crafting")); // SPIGOT-4722: Allocate title for player inventory + // CraftBukkit end - this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28)); - - int i; -@@ -73,7 +92,7 @@ - this.addSlot(new Slot(playerinventory, i, 8 + i * 18, 142)); + this.active = flag; + this.owner = entityhuman; + this.addResultSlot(entityhuman, 154, 28); +@@ -56,7 +68,7 @@ } + this.addStandardInventorySlots(playerinventory, 8, 84); - this.addSlot(new Slot(this, playerinventory, 40, 77, 62) { + this.addSlot(new Slot(playerinventory, 40, 77, 62) { // CraftBukkit - decompile error @Override public void setByPlayer(ItemStack itemstack, ItemStack itemstack1) { entityhuman.onEquipItem(EnumItemSlot.OFFHAND, itemstack1, itemstack); -@@ -230,4 +249,17 @@ - public boolean shouldMoveToInventory(int i) { - return i != this.getResultSlotIndex(); +@@ -192,4 +204,17 @@ + protected EntityHuman owner() { + return this.owner; } + + // CraftBukkit start @@ -66,7 +52,7 @@ + } + + CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots); -+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); ++ bukkitEntity = new CraftInventoryView(this.owner.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end diff --git a/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch b/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch index 19429ef3..5109b7b8 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch @@ -38,7 +38,7 @@ iinventory.startOpen(playerinventory.player); boolean flag = true; boolean flag1 = true; -@@ -46,6 +66,7 @@ +@@ -34,6 +54,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch b/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch index 5d29097d..39be79fc 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerSmithing.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ContainerSmithing.java +++ b/net/minecraft/world/inventory/ContainerSmithing.java -@@ -14,6 +14,8 @@ +@@ -18,6 +18,8 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; @@ -9,39 +9,39 @@ public class ContainerSmithing extends ContainerAnvilAbstract { public static final int TEMPLATE_SLOT = 0; -@@ -29,6 +31,9 @@ - @Nullable - private RecipeHolder selectedRecipe; - private final List> recipes; +@@ -34,6 +36,9 @@ + private final RecipePropertySet templateItemTest; + private final RecipePropertySet additionItemTest; + private final ContainerProperty hasRecipeError; + // CraftBukkit start + private CraftInventoryView bukkitEntity; + // CraftBukkit end public ContainerSmithing(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -103,7 +108,7 @@ - List> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, smithingrecipeinput, this.level); +@@ -117,7 +122,7 @@ + public void createResult() { + SmithingRecipeInput smithingrecipeinput = this.createRecipeInput(); + World world = this.level; +- Optional optional; ++ Optional> optional; // CraftBukkit - decompile error - if (list.isEmpty()) { -- this.resultSlots.setItem(0, ItemStack.EMPTY); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit - } else { - RecipeHolder recipeholder = (RecipeHolder) list.get(0); + if (world instanceof WorldServer worldserver) { + optional = worldserver.recipeAccess().getRecipeFor(Recipes.SMITHING, smithingrecipeinput, worldserver); +@@ -129,7 +134,9 @@ ItemStack itemstack = ((SmithingRecipe) recipeholder.value()).assemble(smithingrecipeinput, this.level.registryAccess()); -@@ -111,7 +116,9 @@ - if (itemstack.isItemEnabled(this.level.enabledFeatures())) { - this.selectedRecipe = recipeholder; - this.resultSlots.setRecipeUsed(recipeholder); -- this.resultSlots.setItem(0, itemstack); -+ // CraftBukkit start -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); -+ // CraftBukkit end - } - } -@@ -143,4 +150,18 @@ - return !this.getSlot(i).hasItem(); - }).findFirst(); + this.resultSlots.setRecipeUsed(recipeholder); +- this.resultSlots.setItem(0, itemstack); ++ // CraftBukkit start ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); ++ // CraftBukkit end + }, () -> { + this.resultSlots.setRecipeUsed((RecipeHolder) null); + this.resultSlots.setItem(0, ItemStack.EMPTY); +@@ -149,4 +156,18 @@ + public boolean hasRecipeError() { + return this.hasRecipeError.get() > 0; } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch b/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch index ac843b87..e3c0b04a 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerStonecutter.patch @@ -50,15 +50,15 @@ }; this.resultContainer = new InventoryCraftResult(); this.access = containeraccess; -@@ -106,6 +135,7 @@ - } - +@@ -94,6 +123,7 @@ + }); + this.addStandardInventorySlots(playerinventory, 8, 84); this.addDataSlot(this.selectedRecipeIndex); + player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit } public int getSelectedRecipeIndex() { -@@ -126,6 +156,7 @@ +@@ -114,6 +144,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -66,3 +66,12 @@ return stillValid(this.access, entityhuman, Blocks.STONECUTTER); } +@@ -154,7 +185,7 @@ + } + + void setupResultSlot(int i) { +- Optional optional; ++ Optional> optional; // CraftBukkit - decompile error + + if (!this.recipesForInput.isEmpty() && this.isValidRecipeIndex(i)) { + SelectableRecipe.a selectablerecipe_a = (SelectableRecipe.a) this.recipesForInput.entries().get(i); diff --git a/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch b/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch index a3acf03d..4e456f85 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerWorkbench.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/inventory/ContainerWorkbench.java +++ b/net/minecraft/world/inventory/ContainerWorkbench.java @@ -16,6 +16,12 @@ - import net.minecraft.world.level.World; + import net.minecraft.world.item.crafting.Recipes; import net.minecraft.world.level.block.Blocks; +// CraftBukkit start @@ -10,16 +10,10 @@ +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + - public class ContainerWorkbench extends ContainerRecipeBook { + public class ContainerWorkbench extends AbstractCraftingMenu { - public static final int RESULT_SLOT = 0; -@@ -25,11 +31,14 @@ - private static final int INV_SLOT_END = 37; - private static final int USE_ROW_SLOT_START = 37; - private static final int USE_ROW_SLOT_END = 46; -- public final InventoryCrafting craftSlots; -+ public final TransientCraftingContainer craftSlots; // CraftBukkit - public final InventoryCraftResult resultSlots; + private static final int CRAFTING_GRID_WIDTH = 3; +@@ -31,13 +37,16 @@ public final ContainerAccess access; private final EntityHuman player; private boolean placingRecipe; @@ -29,36 +23,31 @@ public ContainerWorkbench(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.NULL); -@@ -37,8 +46,11 @@ + } public ContainerWorkbench(int i, PlayerInventory playerinventory, ContainerAccess containeraccess) { - super(Containers.CRAFTING, i); -- this.craftSlots = new TransientCraftingContainer(this, 3, 3); -+ // CraftBukkit start - Switched order of IInventory construction and stored player - this.resultSlots = new InventoryCraftResult(); -+ this.craftSlots = new TransientCraftingContainer(this, 3, 3, playerinventory.player); // CraftBukkit - pass player -+ this.craftSlots.resultInventory = this.resultSlots; -+ // CraftBukkit end +- super(Containers.CRAFTING, i, 3, 3); ++ super(Containers.CRAFTING, i, 3, 3, playerinventory); // CraftBukkit - pass player this.access = containeraccess; this.player = playerinventory.player; - this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35)); -@@ -70,6 +82,7 @@ - EntityPlayer entityplayer = (EntityPlayer) entityhuman; - ItemStack itemstack = ItemStack.EMPTY; - Optional> optional = world.getServer().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, world, recipeholder); -+ inventorycrafting.setCurrentRecipe(optional.orElse(null)); // CraftBukkit + this.addResultSlot(this.player, 124, 35); +@@ -50,6 +59,7 @@ + EntityPlayer entityplayer = (EntityPlayer) entityhuman; + ItemStack itemstack = ItemStack.EMPTY; + Optional> optional = worldserver.getServer().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver, recipeholder); ++ inventorycrafting.setCurrentRecipe(optional.orElse(null)); // CraftBukkit - if (optional.isPresent()) { - RecipeHolder recipeholder1 = (RecipeHolder) optional.get(); -@@ -83,6 +96,7 @@ - } + if (optional.isPresent()) { + RecipeHolder recipeholder1 = (RecipeHolder) optional.get(); +@@ -63,6 +73,7 @@ } } -+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), optional.map(RecipeHolder::value).orElse(null) instanceof RecipeRepair); // CraftBukkit + } ++ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), optional.map(RecipeHolder::value).orElse(null) instanceof RecipeRepair); // CraftBukkit - inventorycraftresult.setItem(0, itemstack); - container.setRemoteSlot(0, itemstack); -@@ -139,6 +153,7 @@ + inventorycraftresult.setItem(0, itemstack); + container.setRemoteSlot(0, itemstack); +@@ -103,6 +114,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -66,9 +55,9 @@ return stillValid(this.access, entityhuman, Blocks.CRAFTING_TABLE); } -@@ -227,4 +242,17 @@ - public boolean shouldMoveToInventory(int i) { - return i != this.getResultSlotIndex(); +@@ -181,4 +193,17 @@ + protected EntityHuman owner() { + return this.player; } + + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/inventory/CrafterMenu.patch b/nms-patches/net/minecraft/world/inventory/CrafterMenu.patch index 2340a444..0f552aba 100644 --- a/nms-patches/net/minecraft/world/inventory/CrafterMenu.patch +++ b/nms-patches/net/minecraft/world/inventory/CrafterMenu.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/inventory/CrafterMenu.java +++ b/net/minecraft/world/inventory/CrafterMenu.java @@ -10,8 +10,27 @@ - import net.minecraft.world.level.World; + import net.minecraft.world.item.crafting.RecipeCrafting; import net.minecraft.world.level.block.CrafterBlock; +// CraftBukkit start @@ -28,7 +28,7 @@ protected static final int SLOT_COUNT = 9; private static final int INV_SLOT_START = 9; private static final int INV_SLOT_END = 36; -@@ -118,6 +137,7 @@ +@@ -106,6 +125,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/inventory/TransientCraftingContainer.patch b/nms-patches/net/minecraft/world/inventory/TransientCraftingContainer.patch index 87f4eec5..7c539ac5 100644 --- a/nms-patches/net/minecraft/world/inventory/TransientCraftingContainer.patch +++ b/nms-patches/net/minecraft/world/inventory/TransientCraftingContainer.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/inventory/TransientCraftingContainer.java +++ b/net/minecraft/world/inventory/TransientCraftingContainer.java @@ -8,6 +8,16 @@ - import net.minecraft.world.entity.player.EntityHuman; + import net.minecraft.world.entity.player.StackedItemContents; import net.minecraft.world.item.ItemStack; +// CraftBukkit start diff --git a/nms-patches/net/minecraft/world/item/ItemBlock.patch b/nms-patches/net/minecraft/world/item/ItemBlock.patch index 1234a88a..96695239 100644 --- a/nms-patches/net/minecraft/world/item/ItemBlock.patch +++ b/nms-patches/net/minecraft/world/item/ItemBlock.patch @@ -14,7 +14,7 @@ public class ItemBlock extends Item { /** @deprecated */ -@@ -68,6 +75,12 @@ +@@ -62,6 +69,12 @@ return EnumInteractionResult.FAIL; } else { IBlockData iblockdata = this.getPlacementState(blockactioncontext1); @@ -27,7 +27,7 @@ if (iblockdata == null) { return EnumInteractionResult.FAIL; -@@ -85,6 +98,19 @@ +@@ -79,6 +92,19 @@ this.updateCustomBlockEntityTag(blockposition, world, entityhuman, itemstack, iblockdata1); updateBlockEntityComponents(world, blockposition, itemstack); 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,7 +118,7 @@ +@@ -86,7 +112,7 @@ SoundEffectType soundeffecttype = iblockdata1.getSoundType(); @@ -55,8 +55,8 @@ + // world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); world.gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(entityhuman, iblockdata1)); itemstack.consume(1, entityhuman); - return EnumInteractionResult.sidedSuccess(world.isClientSide); -@@ -150,8 +176,15 @@ + return EnumInteractionResult.SUCCESS; +@@ -144,8 +170,15 @@ protected boolean canPlace(BlockActionContext blockactioncontext, IBlockData iblockdata) { EntityHuman entityhuman = blockactioncontext.getPlayer(); VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.empty() : VoxelShapeCollision.of(entityhuman); diff --git a/nms-patches/net/minecraft/world/item/ItemBoat.patch b/nms-patches/net/minecraft/world/item/ItemBoat.patch index dc6429b0..5ab0387a 100644 --- a/nms-patches/net/minecraft/world/item/ItemBoat.patch +++ b/nms-patches/net/minecraft/world/item/ItemBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemBoat.java +++ b/net/minecraft/world/item/ItemBoat.java -@@ -61,6 +61,13 @@ +@@ -58,6 +58,13 @@ } if (movingobjectpositionblock.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) { @@ -8,35 +8,26 @@ + org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, false, enumhand, movingobjectpositionblock.getLocation()); + + if (event.isCancelled()) { -+ return InteractionResultWrapper.pass(itemstack); ++ return EnumInteractionResult.PASS; + } + // CraftBukkit end - EntityBoat entityboat = this.getBoat(world, movingobjectpositionblock, itemstack, entityhuman); + AbstractBoat abstractboat = this.getBoat(world, movingobjectpositionblock, itemstack, entityhuman); - entityboat.setVariant(this.type); -@@ -69,7 +76,15 @@ - return InteractionResultWrapper.fail(itemstack); - } else { - if (!world.isClientSide) { -- world.addFreshEntity(entityboat); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), entityhuman, entityboat, enumhand).isCancelled()) { -+ return InteractionResultWrapper.fail(itemstack); -+ } + if (abstractboat == null) { +@@ -68,7 +75,15 @@ + return EnumInteractionResult.FAIL; + } else { + if (!world.isClientSide) { +- world.addFreshEntity(abstractboat); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), entityhuman, abstractboat, enumhand).isCancelled()) { ++ return EnumInteractionResult.FAIL; ++ } + -+ if (!world.addFreshEntity(entityboat)) { -+ return InteractionResultWrapper.pass(itemstack); -+ } -+ // CraftBukkit end - world.gameEvent((Entity) entityhuman, (Holder) GameEvent.ENTITY_PLACE, movingobjectpositionblock.getLocation()); - itemstack.consume(1, entityhuman); - } -@@ -85,7 +100,7 @@ - - private EntityBoat getBoat(World world, MovingObjectPosition movingobjectposition, ItemStack itemstack, EntityHuman entityhuman) { - Vec3D vec3d = movingobjectposition.getLocation(); -- Object object = this.hasChest ? new ChestBoat(world, vec3d.x, vec3d.y, vec3d.z) : new EntityBoat(world, vec3d.x, vec3d.y, vec3d.z); -+ EntityBoat object = this.hasChest ? new ChestBoat(world, vec3d.x, vec3d.y, vec3d.z) : new EntityBoat(world, vec3d.x, vec3d.y, vec3d.z); // CraftBukkit - decompile error - - if (world instanceof WorldServer worldserver) { - EntityTypes.createDefaultStackConfig(worldserver, itemstack, entityhuman).accept(object); ++ if (!world.addFreshEntity(abstractboat)) { ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + world.gameEvent((Entity) entityhuman, (Holder) GameEvent.ENTITY_PLACE, movingobjectpositionblock.getLocation()); + itemstack.consume(1, entityhuman); + } diff --git a/nms-patches/net/minecraft/world/item/ItemBucket.patch b/nms-patches/net/minecraft/world/item/ItemBucket.patch index 418749bd..63994725 100644 --- a/nms-patches/net/minecraft/world/item/ItemBucket.patch +++ b/nms-patches/net/minecraft/world/item/ItemBucket.patch @@ -23,13 +23,13 @@ IFluidSource ifluidsource = (IFluidSource) block; + // CraftBukkit start + ItemStack dummyFluid = ifluidsource.pickupBlock(entityhuman, DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); -+ if (dummyFluid.isEmpty()) return InteractionResultWrapper.fail(itemstack); // Don't fire event if the bucket won't be filled. ++ if (dummyFluid.isEmpty()) return EnumInteractionResult.FAIL; // Don't fire event if the bucket won't be filled. + PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.getItem(), enumhand); + + if (event.isCancelled()) { + ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager) + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541 -+ return InteractionResultWrapper.fail(itemstack); ++ return EnumInteractionResult.FAIL; + } + // CraftBukkit end diff --git a/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch b/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch deleted file mode 100644 index c0127695..00000000 --- a/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/world/item/ItemChorusFruit.java -+++ b/net/minecraft/world/item/ItemChorusFruit.java -@@ -36,7 +36,16 @@ - - Vec3D vec3d = entityliving.position(); - -- if (entityliving.randomTeleport(d0, d1, d2, true)) { -+ // CraftBukkit start - handle canceled status of teleport event -+ java.util.Optional status = entityliving.randomTeleport(d0, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT); -+ -+ if (!status.isPresent()) { -+ // teleport event was canceled, no more tries -+ break; -+ } -+ -+ if (status.get()) { -+ // CraftBukkit end - world.gameEvent((Holder) GameEvent.TELEPORT, vec3d, GameEvent.a.of((Entity) entityliving)); - SoundEffect soundeffect; - SoundCategory soundcategory; diff --git a/nms-patches/net/minecraft/world/item/ItemEgg.patch b/nms-patches/net/minecraft/world/item/ItemEgg.patch index 363eb916..185fb658 100644 --- a/nms-patches/net/minecraft/world/item/ItemEgg.patch +++ b/nms-patches/net/minecraft/world/item/ItemEgg.patch @@ -1,23 +1,19 @@ --- a/net/minecraft/world/item/ItemEgg.java +++ b/net/minecraft/world/item/ItemEgg.java -@@ -22,14 +22,22 @@ - public InteractionResultWrapper use(World world, EntityHuman entityhuman, EnumHand enumhand) { +@@ -23,10 +23,18 @@ + public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); - world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); + // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down - if (!world.isClientSide) { - EntityEgg entityegg = new EntityEgg(world, entityhuman); - - entityegg.setItem(itemstack); - entityegg.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); -- world.addFreshEntity(entityegg); + if (world instanceof WorldServer worldserver) { +- IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F); + // CraftBukkit start -+ if (!world.addFreshEntity(entityegg)) { ++ if (IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isRemoved()) { + if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } -+ return InteractionResultWrapper.fail(itemstack); ++ return EnumInteractionResult.FAIL; + } + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/item/ItemEnderEye.patch b/nms-patches/net/minecraft/world/item/ItemEnderEye.patch index 9050013b..7549f817 100644 --- a/nms-patches/net/minecraft/world/item/ItemEnderEye.patch +++ b/nms-patches/net/minecraft/world/item/ItemEnderEye.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/ItemEnderEye.java +++ b/net/minecraft/world/item/ItemEnderEye.java -@@ -97,7 +97,11 @@ - entityendersignal.setItem(itemstack); - entityendersignal.signalTo(blockposition); - world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.a.of((Entity) entityhuman)); -- world.addFreshEntity(entityendersignal); -+ // CraftBukkit start -+ if (!world.addFreshEntity(entityendersignal)) { -+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); -+ } -+ // CraftBukkit end - if (entityhuman instanceof EntityPlayer) { - EntityPlayer entityplayer = (EntityPlayer) entityhuman; +@@ -99,7 +99,11 @@ + entityendersignal.setItem(itemstack); + entityendersignal.signalTo(blockposition); + world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.a.of((Entity) entityhuman)); +- world.addFreshEntity(entityendersignal); ++ // CraftBukkit start ++ if (!world.addFreshEntity(entityendersignal)) { ++ return EnumInteractionResult.FAIL; ++ } ++ // CraftBukkit end + if (entityhuman instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) entityhuman; diff --git a/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch b/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch index 21f3d927..fc2a6207 100644 --- a/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch +++ b/nms-patches/net/minecraft/world/item/ItemEnderPearl.patch @@ -1,30 +1,22 @@ --- a/net/minecraft/world/item/ItemEnderPearl.java +++ b/net/minecraft/world/item/ItemEnderPearl.java -@@ -19,16 +19,24 @@ - public InteractionResultWrapper use(World world, EntityHuman entityhuman, EnumHand enumhand) { +@@ -21,10 +21,17 @@ + public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); - world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -- entityhuman.getCooldowns().addCooldown(this, 20); -+ // CraftBukkit start - change order - if (!world.isClientSide) { - EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman); - - entityenderpearl.setItem(itemstack); - entityenderpearl.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); -- world.addFreshEntity(entityenderpearl); -+ if (!world.addFreshEntity(entityenderpearl)) { + if (world instanceof WorldServer worldserver) { +- IProjectile.spawnProjectileFromRotation(EntityEnderPearl::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F); ++ // CraftBukkit start ++ if (IProjectile.spawnProjectileFromRotation(EntityEnderPearl::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isRemoved()) { + if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } -+ return InteractionResultWrapper.fail(itemstack); ++ return EnumInteractionResult.FAIL; + } } - + world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -+ entityhuman.getCooldowns().addCooldown(this, 20); + // CraftBukkit end -+ + entityhuman.awardStat(StatisticList.ITEM_USED.get(this)); itemstack.consume(1, entityhuman); - return InteractionResultWrapper.sidedSuccess(itemstack, world.isClientSide()); diff --git a/nms-patches/net/minecraft/world/item/ItemFishingRod.patch b/nms-patches/net/minecraft/world/item/ItemFishingRod.patch index 0977a96c..80a8d1b9 100644 --- a/nms-patches/net/minecraft/world/item/ItemFishingRod.patch +++ b/nms-patches/net/minecraft/world/item/ItemFishingRod.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemFishingRod.java +++ b/net/minecraft/world/item/ItemFishingRod.java -@@ -13,6 +13,11 @@ +@@ -14,6 +14,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; @@ -12,7 +12,7 @@ public class ItemFishingRod extends Item { public ItemFishingRod(Item.Info item_info) { -@@ -33,13 +38,24 @@ +@@ -34,13 +39,24 @@ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); entityhuman.gameEvent(GameEvent.ITEM_INTERACT_FINISH); } else { @@ -23,18 +23,18 @@ int j = (int) (EnchantmentManager.getFishingTimeReduction(worldserver, itemstack, entityhuman) * 20.0F); int k = EnchantmentManager.getFishingLuckBonus(worldserver, itemstack, entityhuman); -- world.addFreshEntity(new EntityFishingHook(entityhuman, world, k, j)); +- IProjectile.spawnProjectile(new EntityFishingHook(entityhuman, world, k, j, itemstack), worldserver, itemstack); + // CraftBukkit start -+ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, k, j); ++ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, k, j, itemstack); + PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand), PlayerFishEvent.State.FISHING); + world.getCraftServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { + entityhuman.fishing = null; -+ return InteractionResultWrapper.pass(itemstack); ++ return EnumInteractionResult.PASS; + } + world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -+ world.addFreshEntity(entityfishinghook); ++ IProjectile.spawnProjectile(entityfishinghook, worldserver, itemstack); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/item/ItemHanging.patch b/nms-patches/net/minecraft/world/item/ItemHanging.patch index 4c64f39f..5dcb4a28 100644 --- a/nms-patches/net/minecraft/world/item/ItemHanging.patch +++ b/nms-patches/net/minecraft/world/item/ItemHanging.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemHanging.java +++ b/net/minecraft/world/item/ItemHanging.java -@@ -24,6 +24,11 @@ +@@ -25,6 +25,11 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; @@ -12,7 +12,7 @@ public class ItemHanging extends Item { private static final IChatBaseComponent TOOLTIP_RANDOM_VARIANT = IChatBaseComponent.translatable("painting.random").withStyle(EnumChatFormat.GRAY); -@@ -74,6 +79,19 @@ +@@ -75,6 +80,19 @@ if (((EntityHanging) object).survives()) { if (!world.isClientSide) { @@ -32,3 +32,12 @@ ((EntityHanging) object).playPlacementSound(); world.gameEvent((Entity) entityhuman, (Holder) GameEvent.ENTITY_PLACE, ((EntityHanging) object).position()); world.addFreshEntity((Entity) object); +@@ -102,7 +120,7 @@ + + if (!customdata.isEmpty()) { + customdata.read(holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE), EntityPainting.VARIANT_MAP_CODEC).result().ifPresentOrElse((holder) -> { +- Optional optional = ((PaintingVariant) holder.value()).title(); ++ Optional optional = ((PaintingVariant) holder.value()).title(); // CraftBukkit - decompile error + + Objects.requireNonNull(list); + optional.ifPresent(list::add); diff --git a/nms-patches/net/minecraft/world/item/ItemLeash.patch b/nms-patches/net/minecraft/world/item/ItemLeash.patch index d26c8aac..38caf51b 100644 --- a/nms-patches/net/minecraft/world/item/ItemLeash.patch +++ b/nms-patches/net/minecraft/world/item/ItemLeash.patch @@ -13,17 +13,16 @@ public class ItemLeash extends Item { public ItemLeash(Item.Info item_info) { -@@ -35,7 +41,7 @@ +@@ -35,14 +41,14 @@ EntityHuman entityhuman = itemactioncontext.getPlayer(); if (!world.isClientSide && entityhuman != null) { -- bindPlayerMobs(entityhuman, world, blockposition); -+ bindPlayerMobs(entityhuman, world, blockposition, itemactioncontext.getHand()); // CraftBukkit - Pass hand +- return bindPlayerMobs(entityhuman, world, blockposition); ++ return bindPlayerMobs(entityhuman, world, blockposition, itemactioncontext.getHand()); // CraftBukkit - Pass hand } - - return EnumInteractionResult.sidedSuccess(world.isClientSide); -@@ -44,7 +50,7 @@ } + + return EnumInteractionResult.PASS; } - public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition) { @@ -31,7 +30,7 @@ EntityLeash entityleash = null; List list = leashableInArea(world, blockposition, (leashable) -> { return leashable.getLeashHolder() == entityhuman; -@@ -52,22 +58,55 @@ +@@ -50,22 +56,55 @@ Leashable leashable; @@ -68,7 +67,7 @@ if (!list.isEmpty()) { world.gameEvent((Holder) GameEvent.BLOCK_ATTACH, blockposition, GameEvent.a.of((Entity) entityhuman)); - return EnumInteractionResult.SUCCESS; + return EnumInteractionResult.SUCCESS_SERVER; } else { + // CraftBukkit start- remove leash if we do not leash any entity because of the cancelled event + if (entityleash != null) { diff --git a/nms-patches/net/minecraft/world/item/ItemMilkBucket.patch b/nms-patches/net/minecraft/world/item/ItemMilkBucket.patch deleted file mode 100644 index 57a4d364..00000000 --- a/nms-patches/net/minecraft/world/item/ItemMilkBucket.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/ItemMilkBucket.java -+++ b/net/minecraft/world/item/ItemMilkBucket.java -@@ -25,7 +25,7 @@ - } - - if (!world.isClientSide) { -- entityliving.removeAllEffects(); -+ entityliving.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.MILK); // CraftBukkit - } - - if (entityliving instanceof EntityHuman entityhuman) { diff --git a/nms-patches/net/minecraft/world/item/ItemMinecart.patch b/nms-patches/net/minecraft/world/item/ItemMinecart.patch index 856e6f41..f5a66c7a 100644 --- a/nms-patches/net/minecraft/world/item/ItemMinecart.patch +++ b/nms-patches/net/minecraft/world/item/ItemMinecart.patch @@ -1,72 +1,16 @@ --- a/net/minecraft/world/item/ItemMinecart.java +++ b/net/minecraft/world/item/ItemMinecart.java -@@ -20,6 +20,12 @@ - import net.minecraft.world.level.gameevent.GameEvent; - import net.minecraft.world.phys.Vec3D; - -+// CraftBukkit start -+import org.bukkit.craftbukkit.block.CraftBlock; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.event.block.BlockDispenseEvent; -+// CraftBukkit end -+ - public class ItemMinecart extends Item { - - private static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() { -@@ -59,10 +65,39 @@ +@@ -67,7 +67,12 @@ + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; + +- worldserver.addFreshEntity(entityminecartabstract); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityminecartabstract).isCancelled()) { ++ return EnumInteractionResult.FAIL; ++ } ++ // CraftBukkit end ++ if (!worldserver.addFreshEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit + worldserver.gameEvent((Holder) GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of(itemactioncontext.getPlayer(), worldserver.getBlockState(blockposition.below()))); } - } - -- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type, itemstack, (EntityHuman) null); -+ // CraftBukkit start -+ // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type); -+ ItemStack itemstack1 = itemstack.split(1); -+ org.bukkit.block.Block block2 = CraftBlock.at(worldserver, sourceblock.pos()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - -- worldserver.addFreshEntity(entityminecartabstract); -- itemstack.shrink(1); -+ BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2)); -+ if (!BlockDispenser.eventFired) { -+ worldserver.getCraftServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ itemstack.grow(1); -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ itemstack.grow(1); -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) { -+ idispensebehavior.dispense(sourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ -+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); -+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).type, itemstack1, (EntityHuman) null); -+ -+ if (!worldserver.addFreshEntity(entityminecartabstract)) itemstack.grow(1); -+ // itemstack.shrink(1); // CraftBukkit - handled during event processing -+ // CraftBukkit end - return itemstack; - } - -@@ -101,7 +136,12 @@ - - EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.0625D + d0, (double) blockposition.getZ() + 0.5D, this.type, itemstack, itemactioncontext.getPlayer()); - -- worldserver.addFreshEntity(entityminecartabstract); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityminecartabstract).isCancelled()) { -+ return EnumInteractionResult.FAIL; -+ } -+ // CraftBukkit end -+ if (!worldserver.addFreshEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit - worldserver.gameEvent((Holder) GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of(itemactioncontext.getPlayer(), worldserver.getBlockState(blockposition.below()))); - } diff --git a/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch b/nms-patches/net/minecraft/world/item/ItemMonsterEgg.patch index a56361ee..c76355cf 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 -@@ -177,10 +177,10 @@ +@@ -176,10 +176,10 @@ return Optional.empty(); } else { ((EntityInsentient) object).moveTo(vec3d.x(), vec3d.y(), vec3d.z(), 0.0F, 0.0F); diff --git a/nms-patches/net/minecraft/world/item/ItemPotion.patch b/nms-patches/net/minecraft/world/item/ItemPotion.patch deleted file mode 100644 index cfbb4bb5..00000000 --- a/nms-patches/net/minecraft/world/item/ItemPotion.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/ItemPotion.java -+++ b/net/minecraft/world/item/ItemPotion.java -@@ -62,7 +62,7 @@ - if (((MobEffectList) mobeffect.getEffect().value()).isInstantenous()) { - ((MobEffectList) mobeffect.getEffect().value()).applyInstantenousEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D); - } else { -- entityliving.addEffect(mobeffect); -+ entityliving.addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit - } - - }); diff --git a/nms-patches/net/minecraft/world/item/ItemProjectileWeapon.patch b/nms-patches/net/minecraft/world/item/ItemProjectileWeapon.patch index a3aaf32f..8b560696 100644 --- a/nms-patches/net/minecraft/world/item/ItemProjectileWeapon.patch +++ b/nms-patches/net/minecraft/world/item/ItemProjectileWeapon.patch @@ -1,11 +1,16 @@ --- a/net/minecraft/world/item/ItemProjectileWeapon.java +++ b/net/minecraft/world/item/ItemProjectileWeapon.java -@@ -62,7 +62,22 @@ - IProjectile iprojectile = this.createProjectile(worldserver, entityliving, itemstack, itemstack1, flag); +@@ -54,9 +54,25 @@ + float f6 = f4 + f5 * (float) ((i + 1) / 2) * f3; - this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1); -- worldserver.addFreshEntity(iprojectile); + f5 = -f5; +- IProjectile.spawnProjectile(this.createProjectile(worldserver, entityliving, itemstack, itemstack1, flag), worldserver, itemstack1, (iprojectile) -> { +- this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1); +- }); + // CraftBukkit start ++ IProjectile iprojectile = this.createProjectile(worldserver, entityliving, itemstack, itemstack1, flag); ++ this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1); ++ + org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, iprojectile, enumhand, f, true); + if (event.isCancelled()) { + event.getProjectile().remove(); @@ -13,7 +18,7 @@ + } + + if (event.getProjectile() == iprojectile.getBukkitEntity()) { -+ if (!worldserver.addFreshEntity(iprojectile)) { ++ if (IProjectile.spawnProjectile(iprojectile, worldserver, itemstack1).isRemoved()) { + if (entityliving instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityliving).getBukkitEntity().updateInventory(); + } diff --git a/nms-patches/net/minecraft/world/item/ItemSign.patch b/nms-patches/net/minecraft/world/item/ItemSign.patch index 2b304e15..a9723327 100644 --- a/nms-patches/net/minecraft/world/item/ItemSign.patch +++ b/nms-patches/net/minecraft/world/item/ItemSign.patch @@ -6,8 +6,8 @@ + public static BlockPosition openSign; // CraftBukkit + - public ItemSign(Item.Info item_info, Block block, Block block1) { - super(block, block1, item_info, EnumDirection.DOWN); + public ItemSign(Block block, Block block1, Item.Info item_info) { + super(block, block1, EnumDirection.DOWN, item_info); } @@ -35,7 +37,10 @@ if (block instanceof BlockSign) { diff --git a/nms-patches/net/minecraft/world/item/ItemSnowball.patch b/nms-patches/net/minecraft/world/item/ItemSnowball.patch index d8cb71ef..b670cf0f 100644 --- a/nms-patches/net/minecraft/world/item/ItemSnowball.patch +++ b/nms-patches/net/minecraft/world/item/ItemSnowball.patch @@ -1,31 +1,27 @@ --- a/net/minecraft/world/item/ItemSnowball.java +++ b/net/minecraft/world/item/ItemSnowball.java -@@ -22,17 +22,25 @@ - public InteractionResultWrapper use(World world, EntityHuman entityhuman, EnumHand enumhand) { +@@ -23,13 +23,21 @@ + public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.getItemInHand(enumhand); - world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -+ // CraftBukkit - moved down ++ // CraftBukkit start - moved down + // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); - if (!world.isClientSide) { - EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman); - - entitysnowball.setItem(itemstack); - entitysnowball.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F); -- world.addFreshEntity(entitysnowball); -+ if (world.addFreshEntity(entitysnowball)) { + if (world instanceof WorldServer worldserver) { +- IProjectile.spawnProjectileFromRotation(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F); ++ if (IProjectile.spawnProjectileFromRotation(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isAlive()) { + itemstack.consume(1, entityhuman); + + world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); + } else if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { + ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } ++ // CraftBukkit end } -+ // CraftBukkit end entityhuman.awardStat(StatisticList.ITEM_USED.get(this)); - itemstack.consume(1, entityhuman); + // itemstack.consume(1, entityhuman); // CraftBukkit - moved up - return InteractionResultWrapper.sidedSuccess(itemstack, world.isClientSide()); + return EnumInteractionResult.SUCCESS; } diff --git a/nms-patches/net/minecraft/world/item/ItemStack.patch b/nms-patches/net/minecraft/world/item/ItemStack.patch index 1ea1ce3e..bf9aba51 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 -@@ -91,6 +91,40 @@ +@@ -96,17 +96,51 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; @@ -40,14 +40,10 @@ + public final class ItemStack implements DataComponentHolder { - public static final Codec> ITEM_NON_AIR_CODEC = BuiltInRegistries.ITEM.holderByNameCodec().validate((holder) -> { -@@ -99,14 +133,14 @@ - }) : DataResult.success(holder); - }); public static final Codec CODEC = Codec.lazyInitialized(() -> { - return RecordCodecBuilder.create((instance) -> { + return RecordCodecBuilder.create((instance) -> { // CraftBukkit - decompile error - return instance.group(ItemStack.ITEM_NON_AIR_CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), ExtraCodecs.intRange(1, 99).fieldOf("count").orElse(1).forGetter(ItemStack::getCount), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> { + return instance.group(Item.CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), ExtraCodecs.intRange(1, 99).fieldOf("count").orElse(1).forGetter(ItemStack::getCount), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> { return itemstack.components.asPatch(); })).apply(instance, ItemStack::new); }); @@ -55,7 +51,7 @@ public static final Codec SINGLE_ITEM_CODEC = Codec.lazyInitialized(() -> { - return RecordCodecBuilder.create((instance) -> { + return RecordCodecBuilder.create((instance) -> { // CraftBukkit - decompile error - return instance.group(ItemStack.ITEM_NON_AIR_CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> { + return instance.group(Item.CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> { return itemstack.components.asPatch(); })).apply(instance, (holder, datacomponentpatch) -> { @@ -131,19 +165,25 @@ @@ -88,7 +84,7 @@ DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch()); } } -@@ -187,7 +227,7 @@ +@@ -186,7 +226,7 @@ return dataresult.isError() ? dataresult.map((unit) -> { return itemstack; @@ -97,7 +93,7 @@ int i = itemstack.getCount(); return "Item stack with stack size of " + i + " was larger than maximum: " + itemstack.getMaxStackSize(); -@@ -286,8 +326,9 @@ +@@ -289,8 +329,9 @@ j = itemstack.getMaxStackSize(); } while (i <= j); @@ -108,7 +104,7 @@ }); } } -@@ -369,11 +410,169 @@ +@@ -372,15 +413,173 @@ return EnumInteractionResult.PASS; } else { Item item = this.getItem(); @@ -171,108 +167,112 @@ + } + world.captureTreeGeneration = false; - if (entityhuman != null && enuminteractionresult.indicateItemUse()) { -- entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); -+ EnumHand enumhand = itemactioncontext.getHand(); -+ org.bukkit.event.block.BlockPlaceEvent placeEvent = null; -+ List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); -+ world.capturedBlockStates.clear(); -+ if (blocks.size() > 1) { -+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, enumhand, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ } else if (blocks.size() == 1) { -+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blocks.get(0), blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ } -+ -+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { -+ enuminteractionresult = EnumInteractionResult.FAIL; // cancel placement -+ // PAIL: Remove this when MC-99075 fixed -+ placeEvent.getPlayer().updateInventory(); -+ // revert back all captured blocks -+ world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710 -+ for (BlockState blockstate : blocks) { -+ blockstate.update(true, false); -+ } -+ world.preventPoiUpdated = false; -+ -+ // Brute force all possible updates -+ BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition(); -+ for (EnumDirection dir : EnumDirection.values()) { -+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, placedPos.relative(dir))); -+ } -+ ItemSign.openSign = null; // SPIGOT-6758 - Reset on early return -+ } else { -+ // Change the stack to its new contents if it hasn't been tampered with. -+ if (this.getCount() == oldCount && Objects.equals(this.components.asPatch(), oldData)) { -+ this.restorePatch(newData); -+ this.setCount(newCount); + if (entityhuman != null && enuminteractionresult instanceof EnumInteractionResult.d) { + EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult; + + if (enuminteractionresult_d.wasItemInteraction()) { +- entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); ++ EnumHand enumhand = itemactioncontext.getHand(); ++ org.bukkit.event.block.BlockPlaceEvent placeEvent = null; ++ List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); ++ world.capturedBlockStates.clear(); ++ if (blocks.size() > 1) { ++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, enumhand, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ } else if (blocks.size() == 1) { ++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blocks.get(0), blockposition.getX(), blockposition.getY(), blockposition.getZ()); + } + -+ for (Map.Entry e : world.capturedTileEntities.entrySet()) { -+ world.setBlockEntity(e.getValue()); -+ } ++ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { ++ enuminteractionresult = EnumInteractionResult.FAIL; // cancel placement ++ // PAIL: Remove this when MC-99075 fixed ++ placeEvent.getPlayer().updateInventory(); ++ // revert back all captured blocks ++ world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710 ++ for (BlockState blockstate : blocks) { ++ blockstate.update(true, false); ++ } ++ world.preventPoiUpdated = false; + -+ for (BlockState blockstate : blocks) { -+ int updateFlag = ((CraftBlockState) blockstate).getFlag(); -+ IBlockData oldBlock = ((CraftBlockState) blockstate).getHandle(); -+ BlockPosition newblockposition = ((CraftBlockState) blockstate).getPosition(); -+ IBlockData block = world.getBlockState(newblockposition); ++ // Brute force all possible updates ++ BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition(); ++ for (EnumDirection dir : EnumDirection.values()) { ++ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, placedPos.relative(dir))); ++ } ++ ItemSign.openSign = null; // SPIGOT-6758 - Reset on early return ++ } else { ++ // Change the stack to its new contents if it hasn't been tampered with. ++ if (this.getCount() == oldCount && Objects.equals(this.components.asPatch(), oldData)) { ++ this.restorePatch(newData); ++ this.setCount(newCount); ++ } + -+ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically -+ block.onPlace(world, newblockposition, oldBlock, true, itemactioncontext); ++ for (Map.Entry e : world.capturedTileEntities.entrySet()) { ++ world.setBlockEntity(e.getValue()); + } + -+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point -+ } ++ for (BlockState blockstate : blocks) { ++ int updateFlag = ((CraftBlockState) blockstate).getFlag(); ++ IBlockData oldBlock = ((CraftBlockState) blockstate).getHandle(); ++ BlockPosition newblockposition = ((CraftBlockState) blockstate).getPosition(); ++ IBlockData block = world.getBlockState(newblockposition); + -+ if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled -+ BlockPosition bp = blockposition; -+ if (!world.getBlockState(blockposition).canBeReplaced()) { -+ if (!world.getBlockState(blockposition).isSolid()) { -+ bp = null; -+ } else { -+ bp = bp.relative(itemactioncontext.getClickedFace()); ++ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically ++ block.onPlace(world, newblockposition, oldBlock, true, itemactioncontext); + } ++ ++ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point + } -+ if (bp != null) { -+ TileEntity te = world.getBlockEntity(bp); -+ if (te instanceof TileEntitySkull) { -+ BlockWitherSkull.checkSpawn(world, bp, (TileEntitySkull) te); ++ ++ if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled ++ BlockPosition bp = blockposition; ++ if (!world.getBlockState(blockposition).canBeReplaced()) { ++ if (!world.getBlockState(blockposition).isSolid()) { ++ bp = null; ++ } else { ++ bp = bp.relative(itemactioncontext.getClickedFace()); ++ } ++ } ++ if (bp != null) { ++ TileEntity te = world.getBlockEntity(bp); ++ if (te instanceof TileEntitySkull) { ++ BlockWitherSkull.checkSpawn(world, bp, (TileEntitySkull) te); ++ } + } + } -+ } + -+ // SPIGOT-4678 -+ if (this.item instanceof ItemSign && ItemSign.openSign != null) { -+ try { -+ if (world.getBlockEntity(ItemSign.openSign) instanceof TileEntitySign tileentitysign) { -+ if (world.getBlockState(ItemSign.openSign).getBlock() instanceof BlockSign blocksign) { -+ blocksign.openTextEdit(entityhuman, tileentitysign, true, org.bukkit.event.player.PlayerSignOpenEvent.Cause.PLACE); // Craftbukkit ++ // SPIGOT-4678 ++ if (this.item instanceof ItemSign && ItemSign.openSign != null) { ++ try { ++ if (world.getBlockEntity(ItemSign.openSign) instanceof TileEntitySign tileentitysign) { ++ if (world.getBlockState(ItemSign.openSign).getBlock() instanceof BlockSign blocksign) { ++ blocksign.openTextEdit(entityhuman, tileentitysign, true, org.bukkit.event.player.PlayerSignOpenEvent.Cause.PLACE); // Craftbukkit ++ } + } ++ } finally { ++ ItemSign.openSign = null; + } -+ } finally { -+ ItemSign.openSign = null; + } -+ } + -+ // SPIGOT-7315: Moved from BlockBed#setPlacedBy -+ if (placeEvent != null && this.item instanceof ItemBed) { -+ BlockPosition position = ((CraftBlock) placeEvent.getBlock()).getPosition(); -+ IBlockData blockData = world.getBlockState(position); ++ // SPIGOT-7315: Moved from BlockBed#setPlacedBy ++ if (placeEvent != null && this.item instanceof ItemBed) { ++ BlockPosition position = ((CraftBlock) placeEvent.getBlock()).getPosition(); ++ IBlockData blockData = world.getBlockState(position); + -+ if (blockData.getBlock() instanceof BlockBed) { -+ world.blockUpdated(position, Blocks.AIR); -+ blockData.updateNeighbourShapes(world, position, 3); ++ if (blockData.getBlock() instanceof BlockBed) { ++ world.blockUpdated(position, Blocks.AIR); ++ blockData.updateNeighbourShapes(world, position, 3); ++ } + } -+ } + -+ // SPIGOT-1288 - play sound stripped from ItemBlock -+ if (this.item instanceof ItemBlock) { -+ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().defaultBlockState().getSoundType(); // TODO: not strictly correct, however currently only affects decorated pots -+ world.playSound(entityhuman, blockposition, soundeffecttype.getPlaceSound(), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); -+ } ++ // SPIGOT-1288 - play sound stripped from ItemBlock ++ if (this.item instanceof ItemBlock) { ++ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().defaultBlockState().getSoundType(); // TODO: not strictly correct, however currently only affects decorated pots ++ world.playSound(entityhuman, blockposition, soundeffecttype.getPlaceSound(), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); ++ } + -+ entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); -+ } ++ entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); ++ } + } } + world.capturedTileEntities.clear(); + world.capturedBlockStates.clear(); @@ -280,41 +280,41 @@ return enuminteractionresult; } -@@ -444,6 +643,21 @@ - if (entityplayer == null || !entityplayer.hasInfiniteMaterials()) { - if (i > 0) { - i = EnchantmentManager.processDurabilityChange(worldserver, this, i); -+ // CraftBukkit start -+ if (entityplayer != null) { -+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(entityplayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), i); -+ event.getPlayer().getServer().getPluginManager().callEvent(event); +@@ -487,6 +686,21 @@ + + public void hurtAndBreak(int i, WorldServer worldserver, @Nullable EntityPlayer entityplayer, Consumer consumer) { + int j = this.processDurabilityChange(i, worldserver, entityplayer); ++ // CraftBukkit start ++ if (entityplayer != null) { ++ PlayerItemDamageEvent event = new PlayerItemDamageEvent(entityplayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j); ++ event.getPlayer().getServer().getPluginManager().callEvent(event); + -+ if (i != event.getDamage() || event.isCancelled()) { -+ event.getPlayer().updateInventory(); -+ } -+ if (event.isCancelled()) { -+ return; -+ } ++ if (j != event.getDamage() || event.isCancelled()) { ++ event.getPlayer().updateInventory(); ++ } ++ if (event.isCancelled()) { ++ return; ++ } + -+ i = event.getDamage(); -+ } -+ // CraftBukkit end - if (i <= 0) { - return; - } -@@ -458,6 +672,11 @@ - this.setDamageValue(j); - if (j >= this.getMaxDamage()) { - Item item = this.getItem(); -+ // CraftBukkit start - Check for item breaking -+ if (this.count == 1 && entityplayer != null) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(entityplayer, this); -+ } -+ // CraftBukkit end ++ j = event.getDamage(); ++ } ++ // CraftBukkit end + + if (j != 0) { + this.applyDamage(this.getDamageValue() + j, entityplayer, consumer); +@@ -506,6 +720,11 @@ + this.setDamageValue(i); + if (this.isBroken()) { + Item item = this.getItem(); ++ // CraftBukkit start - Check for item breaking ++ if (this.count == 1 && entityplayer != null) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(entityplayer, this); ++ } ++ // CraftBukkit end - this.shrink(1); - consumer.accept(item); -@@ -693,6 +912,12 @@ + this.shrink(1); + consumer.accept(item); +@@ -765,6 +984,12 @@ return this.getItem().useOnRelease(this); } @@ -327,7 +327,7 @@ @Nullable public T set(DataComponentType datacomponenttype, @Nullable T t0) { return this.components.set(datacomponenttype, t0); -@@ -752,7 +977,7 @@ +@@ -846,7 +1071,7 @@ } private void addToTooltip(DataComponentType datacomponenttype, Item.b item_b, Consumer consumer, TooltipFlag tooltipflag) { @@ -336,7 +336,7 @@ if (t0 != null) { t0.addToTooltip(item_b, consumer, tooltipflag); -@@ -992,6 +1217,13 @@ +@@ -1073,6 +1298,13 @@ EnchantmentManager.forEachModifier(this, enumitemslot, biconsumer); } @@ -350,7 +350,7 @@ public IChatBaseComponent getDisplayName() { IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().append(this.getHoverName()); -@@ -1054,7 +1286,7 @@ +@@ -1135,7 +1367,7 @@ } public void consume(int i, @Nullable EntityLiving entityliving) { diff --git a/nms-patches/net/minecraft/world/item/ItemSuspiciousStew.patch b/nms-patches/net/minecraft/world/item/ItemSuspiciousStew.patch deleted file mode 100644 index 9cf5dbbb..00000000 --- a/nms-patches/net/minecraft/world/item/ItemSuspiciousStew.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/world/item/ItemSuspiciousStew.java -+++ b/net/minecraft/world/item/ItemSuspiciousStew.java -@@ -53,4 +53,15 @@ - - return super.finishUsingItem(itemstack, world, entityliving); - } -+ -+ // CraftBukkit start -+ public void cancelUsingItem(net.minecraft.server.level.EntityPlayer entityplayer, ItemStack itemstack) { -+ SuspiciousStewEffects suspicioussteweffects = (SuspiciousStewEffects) itemstack.getOrDefault(DataComponents.SUSPICIOUS_STEW_EFFECTS, SuspiciousStewEffects.EMPTY); -+ -+ for (SuspiciousStewEffects.a suspicioussteweffects_a : suspicioussteweffects.effects()) { -+ entityplayer.connection.send(new net.minecraft.network.protocol.game.PacketPlayOutRemoveEntityEffect(entityplayer.getId(), suspicioussteweffects_a.effect())); -+ } -+ entityplayer.server.getPlayerList().sendActivePlayerEffects(entityplayer); -+ } -+ // CraftBukkit end - } diff --git a/nms-patches/net/minecraft/world/item/ItemTrident.patch b/nms-patches/net/minecraft/world/item/ItemTrident.patch index f645aecb..dcc3a868 100644 --- a/nms-patches/net/minecraft/world/item/ItemTrident.patch +++ b/nms-patches/net/minecraft/world/item/ItemTrident.patch @@ -1,47 +1,42 @@ --- a/net/minecraft/world/item/ItemTrident.java +++ b/net/minecraft/world/item/ItemTrident.java -@@ -77,7 +77,7 @@ - Holder holder = (Holder) EnchantmentManager.pickHighestLevel(itemstack, EnchantmentEffectComponents.TRIDENT_SOUND).orElse(SoundEffects.TRIDENT_THROW); +@@ -85,9 +85,19 @@ + if (world instanceof WorldServer) { + WorldServer worldserver = (WorldServer) world; - if (!world.isClientSide) { -- itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); -+ // itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); // CraftBukkit - moved down - if (f == 0.0F) { - EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack); +- itemstack.hurtWithoutBreaking(1, entityhuman); ++ // itemstack.hurtWithoutBreaking(1, entityhuman); // CraftBukkit - moved down + if (f == 0.0F) { + EntityThrownTrident entitythrowntrident = (EntityThrownTrident) IProjectile.spawnProjectileFromRotation(EntityThrownTrident::new, worldserver, itemstack, entityhuman, 0.0F, 2.5F, 1.0F); ++ // CraftBukkit start ++ if (entitythrowntrident.isRemoved()) { ++ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { ++ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); ++ } ++ return false; ++ } ++ itemstack.hurtWithoutBreaking(1, entityhuman); ++ entitythrowntrident.pickupItemStack = itemstack.copy(); // SPIGOT-4511 update since damage call moved ++ // CraftBukkit end -@@ -86,11 +86,26 @@ - entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY; - } + if (entityhuman.hasInfiniteMaterials()) { + entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY; +@@ -97,6 +107,10 @@ -- world.addFreshEntity(entitythrowntrident); -+ // CraftBukkit start -+ if (!world.addFreshEntity(entitythrowntrident)) { -+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { -+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); -+ } -+ return; -+ } -+ -+ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); -+ entitythrowntrident.pickupItemStack = itemstack.copy(); // SPIGOT-4511 update since damage call moved -+ // CraftBukkit end -+ - world.playSound((EntityHuman) null, (Entity) entitythrowntrident, (SoundEffect) holder.value(), SoundCategory.PLAYERS, 1.0F, 1.0F); - if (!entityhuman.hasInfiniteMaterials()) { - entityhuman.getInventory().removeItem(itemstack); - } -+ // CraftBukkit start - SPIGOT-5458 also need in this branch :( -+ } else { -+ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); -+ // CraftBukkkit end - } + world.playSound((EntityHuman) null, (Entity) entitythrowntrident, (SoundEffect) holder.value(), SoundCategory.PLAYERS, 1.0F, 1.0F); + return true; ++ // CraftBukkit start - SPIGOT-5458 also need in this branch :( ++ } else { ++ itemstack.hurtWithoutBreaking(1, entityhuman); ++ // CraftBukkkit end } + } -@@ -106,6 +121,7 @@ - f3 *= f / f6; - f4 *= f / f6; - f5 *= f / f6; -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(entityhuman, itemstack, f3, f4, f5); // CraftBukkit - entityhuman.push((double) f3, (double) f4, (double) f5); - entityhuman.startAutoSpinAttack(20, 8.0F, itemstack); - if (entityhuman.onGround()) { +@@ -112,6 +126,7 @@ + f3 *= f / f6; + f4 *= f / f6; + f5 *= f / f6; ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(entityhuman, itemstack, f3, f4, f5); // CraftBukkit + entityhuman.push((double) f3, (double) f4, (double) f5); + entityhuman.startAutoSpinAttack(20, 8.0F, itemstack); + if (entityhuman.onGround()) { diff --git a/nms-patches/net/minecraft/world/item/alchemy/PotionContents.patch b/nms-patches/net/minecraft/world/item/alchemy/PotionContents.patch new file mode 100644 index 00000000..a6181a2c --- /dev/null +++ b/nms-patches/net/minecraft/world/item/alchemy/PotionContents.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/item/alchemy/PotionContents.java ++++ b/net/minecraft/world/item/alchemy/PotionContents.java +@@ -93,7 +93,7 @@ + } + + public PotionContents withEffectAdded(MobEffect mobeffect) { +- return new PotionContents(this.potion, this.customColor, SystemUtils.copyAndAdd(this.customEffects, (Object) mobeffect), this.customName); ++ return new PotionContents(this.potion, this.customColor, SystemUtils.copyAndAdd(this.customEffects, mobeffect), this.customName); // CraftBukkit - decompile error + } + + public int getColor() { +@@ -176,7 +176,7 @@ + if (((MobEffectList) mobeffect.getEffect().value()).isInstantenous()) { + ((MobEffectList) mobeffect.getEffect().value()).applyInstantenousEffect(worldserver, entityhuman2, entityhuman2, entityliving, mobeffect.getAmplifier(), 1.0D); + } else { +- entityliving.addEffect(mobeffect); ++ entityliving.addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit + } + + }); diff --git a/nms-patches/net/minecraft/world/item/component/Consumable.patch b/nms-patches/net/minecraft/world/item/component/Consumable.patch new file mode 100644 index 00000000..67770c32 --- /dev/null +++ b/nms-patches/net/minecraft/world/item/component/Consumable.patch @@ -0,0 +1,51 @@ +--- a/net/minecraft/world/item/component/Consumable.java ++++ b/net/minecraft/world/item/component/Consumable.java +@@ -29,6 +29,11 @@ + import net.minecraft.world.level.World; + import net.minecraft.world.level.gameevent.GameEvent; + ++// CraftBukkit start ++import net.minecraft.world.item.Items; ++import org.bukkit.event.entity.EntityPotionEffectEvent; ++// CraftBukkit end ++ + public record Consumable(float consumeSeconds, ItemUseAnimation animation, Holder sound, boolean hasConsumeParticles, List onConsumeEffects) { + + public static final float DEFAULT_CONSUME_SECONDS = 1.6F; +@@ -69,8 +74,19 @@ + consumablelistener.onConsume(world, entityliving, itemstack, this); + }); + if (!world.isClientSide) { ++ // CraftBukkit start ++ EntityPotionEffectEvent.Cause cause; ++ if (itemstack.is(Items.MILK_BUCKET)) { ++ cause = EntityPotionEffectEvent.Cause.MILK; ++ } else if (itemstack.is(Items.POTION)) { ++ cause = EntityPotionEffectEvent.Cause.POTION_DRINK; ++ } else { ++ cause = EntityPotionEffectEvent.Cause.FOOD; ++ } ++ + this.onConsumeEffects.forEach((consumeeffect) -> { +- consumeeffect.apply(world, itemstack, entityliving); ++ consumeeffect.apply(world, itemstack, entityliving, cause); ++ // CraftBukkit end + }); + } + +@@ -79,6 +95,15 @@ + return itemstack; + } + ++ // CraftBukkit start ++ public void cancelUsingItem(net.minecraft.server.level.EntityPlayer entityplayer, ItemStack itemstack) { ++ itemstack.getAllOfType(ConsumableListener.class).forEach((consumablelistener) -> { ++ consumablelistener.cancelUsingItem(entityplayer, itemstack); ++ }); ++ entityplayer.server.getPlayerList().sendActivePlayerEffects(entityplayer); ++ } ++ // CraftBukkit end ++ + public boolean canConsume(EntityLiving entityliving, ItemStack itemstack) { + FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD); + diff --git a/nms-patches/net/minecraft/world/item/component/ConsumableListener.patch b/nms-patches/net/minecraft/world/item/component/ConsumableListener.patch new file mode 100644 index 00000000..d3e222f4 --- /dev/null +++ b/nms-patches/net/minecraft/world/item/component/ConsumableListener.patch @@ -0,0 +1,9 @@ +--- a/net/minecraft/world/item/component/ConsumableListener.java ++++ b/net/minecraft/world/item/component/ConsumableListener.java +@@ -7,4 +7,6 @@ + public interface ConsumableListener { + + void onConsume(World world, EntityLiving entityliving, ItemStack itemstack, Consumable consumable); ++ ++ default void cancelUsingItem(net.minecraft.server.level.EntityPlayer entityplayer, ItemStack itemstack) {} // CraftBukkit + } diff --git a/nms-patches/net/minecraft/world/item/component/DeathProtection.patch b/nms-patches/net/minecraft/world/item/component/DeathProtection.patch new file mode 100644 index 00000000..14197c4b --- /dev/null +++ b/nms-patches/net/minecraft/world/item/component/DeathProtection.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/world/item/component/DeathProtection.java ++++ b/net/minecraft/world/item/component/DeathProtection.java +@@ -15,6 +15,10 @@ + import net.minecraft.world.item.consume_effects.ClearAllStatusEffectsConsumeEffect; + import net.minecraft.world.item.consume_effects.ConsumeEffect; + ++// CraftBukkit start ++import org.bukkit.event.entity.EntityPotionEffectEvent; ++// CraftBukkit end ++ + public record DeathProtection(List deathEffects) { + + public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { +@@ -29,7 +33,7 @@ + while (iterator.hasNext()) { + ConsumeEffect consumeeffect = (ConsumeEffect) iterator.next(); + +- consumeeffect.apply(entityliving.level(), itemstack, entityliving); ++ consumeeffect.apply(entityliving.level(), itemstack, entityliving, EntityPotionEffectEvent.Cause.TOTEM); // CraftBukkit + } + + } diff --git a/nms-patches/net/minecraft/world/item/component/SuspiciousStewEffects.patch b/nms-patches/net/minecraft/world/item/component/SuspiciousStewEffects.patch new file mode 100644 index 00000000..b8ba7b7f --- /dev/null +++ b/nms-patches/net/minecraft/world/item/component/SuspiciousStewEffects.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/world/item/component/SuspiciousStewEffects.java ++++ b/net/minecraft/world/item/component/SuspiciousStewEffects.java +@@ -29,7 +29,7 @@ + public static final StreamCodec STREAM_CODEC = SuspiciousStewEffects.a.STREAM_CODEC.apply(ByteBufCodecs.list()).map(SuspiciousStewEffects::new, SuspiciousStewEffects::effects); + + public SuspiciousStewEffects withEffectAdded(SuspiciousStewEffects.a suspicioussteweffects_a) { +- return new SuspiciousStewEffects(SystemUtils.copyAndAdd(this.effects, (Object) suspicioussteweffects_a)); ++ return new SuspiciousStewEffects(SystemUtils.copyAndAdd(this.effects, suspicioussteweffects_a)); // CraftBukkit - decompile error + } + + @Override +@@ -44,6 +44,15 @@ + + } + ++ // CraftBukkit start ++ @Override ++ public void cancelUsingItem(net.minecraft.server.level.EntityPlayer entityplayer, ItemStack itemstack) { ++ for (SuspiciousStewEffects.a suspicioussteweffects_a : this.effects) { ++ entityplayer.connection.send(new net.minecraft.network.protocol.game.PacketPlayOutRemoveEntityEffect(entityplayer.getId(), suspicioussteweffects_a.effect())); ++ } ++ } ++ // CraftBukkit end ++ + @Override + public void addToTooltip(Item.b item_b, Consumer consumer, TooltipFlag tooltipflag) { + if (tooltipflag.isCreative()) { diff --git a/nms-patches/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.patch b/nms-patches/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.patch new file mode 100644 index 00000000..2b3e1447 --- /dev/null +++ b/nms-patches/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java +@@ -13,6 +13,10 @@ + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import org.bukkit.event.entity.EntityPotionEffectEvent; ++// CraftBukkit end ++ + public record ApplyStatusEffectsConsumeEffect(List effects, float probability) implements ConsumeEffect { + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { +@@ -38,7 +42,7 @@ + } + + @Override +- public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) { ++ public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) { // CraftBukkit + if (entityliving.getRandom().nextFloat() >= this.probability) { + return false; + } else { +@@ -48,7 +52,7 @@ + while (iterator.hasNext()) { + MobEffect mobeffect = (MobEffect) iterator.next(); + +- if (entityliving.addEffect(new MobEffect(mobeffect))) { ++ if (entityliving.addEffect(new MobEffect(mobeffect), cause)) { // CraftBukkit + flag = true; + } + } diff --git a/nms-patches/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.patch b/nms-patches/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.patch new file mode 100644 index 00000000..50d8037b --- /dev/null +++ b/nms-patches/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.patch @@ -0,0 +1,25 @@ +--- a/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java +@@ -7,6 +7,10 @@ + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import org.bukkit.event.entity.EntityPotionEffectEvent; ++// CraftBukkit end ++ + public record ClearAllStatusEffectsConsumeEffect() implements ConsumeEffect { + + public static final ClearAllStatusEffectsConsumeEffect INSTANCE = new ClearAllStatusEffectsConsumeEffect(); +@@ -19,7 +23,9 @@ + } + + @Override +- public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) { +- return entityliving.removeAllEffects(); ++ // CraftBukkit start ++ public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) { ++ return entityliving.removeAllEffects(cause); ++ // CraftBukkit end + } + } diff --git a/nms-patches/net/minecraft/world/item/consume_effects/ConsumeEffect.patch b/nms-patches/net/minecraft/world/item/consume_effects/ConsumeEffect.patch new file mode 100644 index 00000000..d85f9105 --- /dev/null +++ b/nms-patches/net/minecraft/world/item/consume_effects/ConsumeEffect.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/item/consume_effects/ConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/ConsumeEffect.java +@@ -12,6 +12,10 @@ + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import org.bukkit.event.entity.EntityPotionEffectEvent; ++// CraftBukkit end ++ + public interface ConsumeEffect { + + Codec CODEC = BuiltInRegistries.CONSUME_EFFECT_TYPE.byNameCodec().dispatch(ConsumeEffect::getType, ConsumeEffect.a::codec); +@@ -19,7 +23,15 @@ + + ConsumeEffect.a getType(); + +- boolean apply(World world, ItemStack itemstack, EntityLiving entityliving); ++ // CraftBukkit start ++ default boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) { ++ return this.apply(world, itemstack, entityliving, EntityPotionEffectEvent.Cause.UNKNOWN); ++ } ++ ++ default boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) { ++ return this.apply(world, itemstack, entityliving); ++ } ++ // CraftBukkit end + + public static record a(MapCodec codec, StreamCodec streamCodec) { + diff --git a/nms-patches/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.patch b/nms-patches/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.patch new file mode 100644 index 00000000..4e7586f7 --- /dev/null +++ b/nms-patches/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java +@@ -15,6 +15,10 @@ + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import org.bukkit.event.entity.EntityPotionEffectEvent; ++// CraftBukkit end ++ + public record RemoveStatusEffectsConsumeEffect(HolderSet effects) implements ConsumeEffect { + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { +@@ -32,14 +36,14 @@ + } + + @Override +- public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) { ++ public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) { // CraftBukkit + boolean flag = false; + Iterator iterator = this.effects.iterator(); + + while (iterator.hasNext()) { + Holder holder = (Holder) iterator.next(); + +- if (entityliving.removeEffect(holder)) { ++ if (entityliving.removeEffect(holder, cause)) { // CraftBukkit + flag = true; + } + } diff --git a/nms-patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.patch b/nms-patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.patch new file mode 100644 index 00000000..b8af6a41 --- /dev/null +++ b/nms-patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java +@@ -53,7 +53,16 @@ + + Vec3D vec3d = entityliving.position(); + +- if (entityliving.randomTeleport(d0, d1, d2, true)) { ++ // CraftBukkit start - handle canceled status of teleport event ++ java.util.Optional status = entityliving.randomTeleport(d0, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT); ++ ++ if (!status.isPresent()) { ++ // teleport event was canceled, no more tries ++ break; ++ } ++ ++ if (status.get()) { ++ // CraftBukkit end + world.gameEvent((Holder) GameEvent.TELEPORT, vec3d, GameEvent.a.of((Entity) entityliving)); + SoundEffect soundeffect; + SoundCategory soundcategory; diff --git a/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch b/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch index 17bd7807..3653f81f 100644 --- a/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch +++ b/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch @@ -1,108 +1,87 @@ --- a/net/minecraft/world/item/crafting/CraftingManager.java +++ b/net/minecraft/world/item/crafting/CraftingManager.java -@@ -34,6 +34,11 @@ +@@ -38,6 +38,10 @@ import net.minecraft.world.level.World; import org.slf4j.Logger; +// CraftBukkit start -+import com.google.common.collect.LinkedHashMultimap; -+import com.google.common.collect.Maps; ++import java.util.Collections; +// CraftBukkit end + - public class CraftingManager extends ResourceDataJson { + public class CraftingManager extends ResourceDataAbstract implements RecipeAccess { - private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create(); -@@ -70,11 +75,26 @@ - } - } - -- this.byType = builder.build(); -- this.byName = com_google_common_collect_immutablemap_builder.build(); -+ // CraftBukkit start - mutable -+ this.byType = LinkedHashMultimap.create(builder.build()); -+ this.byName = Maps.newHashMap(com_google_common_collect_immutablemap_builder.build()); -+ // CraftBukkit end - CraftingManager.LOGGER.info("Loaded {} recipes", this.byType.size()); + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -109,7 +113,23 @@ + CraftingManager.LOGGER.info("Loaded {} recipes", recipemap.values().size()); } + // CraftBukkit start + public void addRecipe(RecipeHolder irecipe) { -+ Collection> map = this.byType.get(irecipe.value().getType()); // CraftBukkit ++ this.recipes.addRecipe(irecipe); ++ finalizeRecipeLoading(); ++ } + -+ if (byName.containsKey(irecipe.id())) { -+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.id()); -+ } else { -+ map.add(irecipe); -+ byName.put(irecipe.id(), irecipe); ++ private FeatureFlagSet featureflagset; ++ ++ public void finalizeRecipeLoading() { ++ if (featureflagset != null) { ++ finalizeRecipeLoading(featureflagset); + } + } -+ // CraftBukkit end + - public boolean hadErrorsLoading() { - return this.hasErrors; - } -@@ -90,9 +110,13 @@ - } - - public > Optional> getRecipeFor(Recipes recipes, I i0, World world, @Nullable RecipeHolder recipeholder) { -- return i0.isEmpty() ? Optional.empty() : (recipeholder != null && recipeholder.value().matches(i0, world) ? Optional.of(recipeholder) : this.byType(recipes).stream().filter((recipeholder1) -> { -+ // CraftBukkit start -+ List> list = this.byType(recipes).stream().filter((recipeholder1) -> { - return recipeholder1.value().matches(i0, world); -- }).findFirst()); -+ }).toList(); -+ Optional> recipe = (list.isEmpty() || i0.isEmpty()) ? Optional.empty() : (recipeholder != null && recipeholder.value().matches(i0, world) ? Optional.of(recipeholder) : Optional.of(list.getLast())); // CraftBukkit - SPIGOT-4638: last recipe gets priority -+ return recipe; + public void finalizeRecipeLoading(FeatureFlagSet featureflagset) { ++ this.featureflagset = featureflagset; + // CraftBukkit end - } + List> list = new ArrayList(); + List list1 = CraftingManager.RECIPE_PROPERTY_SETS.entrySet().stream().map((entry) -> { + return new CraftingManager.b((ResourceKey) entry.getKey(), (CraftingManager.c) entry.getValue()); +@@ -128,7 +148,7 @@ + RecipeStonecutting recipestonecutting = (RecipeStonecutting) irecipe; + + if (isIngredientEnabled(featureflagset, recipestonecutting.input()) && recipestonecutting.resultDisplay().isEnabled(featureflagset)) { +- list.add(new SelectableRecipe.a<>(recipestonecutting.input(), new SelectableRecipe<>(recipestonecutting.resultDisplay(), Optional.of(recipeholder)))); ++ list.add(new SelectableRecipe.a(recipestonecutting.input(), new SelectableRecipe<>(recipestonecutting.resultDisplay(), Optional.of((RecipeHolder) recipeholder)))); // CraftBukkit - decompile error + } + } - public > List> getAllRecipesFor(Recipes recipes) { -@@ -108,7 +132,7 @@ +@@ -170,7 +190,10 @@ } - private > Collection> byType(Recipes recipes) { -- return this.byType.get(recipes); -+ return (Collection) this.byType.get(recipes); // CraftBukkit - decompile error + public > Optional> getRecipeFor(Recipes recipes, I i0, World world) { +- return this.recipes.getRecipesFor(recipes, i0, world).findFirst(); ++ // CraftBukkit start ++ List> list = this.recipes.getRecipesFor(recipes, i0, world).toList(); ++ return (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority ++ // CraftBukkit end } - public > NonNullList getRemainingItemsFor(Recipes recipes, I i0, World world) { -@@ -135,7 +159,7 @@ - private > RecipeHolder byKeyTyped(Recipes recipes, MinecraftKey minecraftkey) { - RecipeHolder recipeholder = (RecipeHolder) this.byName.get(minecraftkey); + public Optional> byKey(ResourceKey> resourcekey) { +@@ -181,7 +204,7 @@ + private > RecipeHolder byKeyTyped(Recipes recipes, ResourceKey> resourcekey) { + RecipeHolder recipeholder = this.recipes.byKey(resourcekey); - return recipeholder != null && recipeholder.value().getType().equals(recipes) ? recipeholder : null; + return recipeholder != null && recipeholder.value().getType().equals(recipes) ? (RecipeHolder) recipeholder : null; // CraftBukkit - decompile error } - public Collection> getOrderedRecipes() { -@@ -171,10 +195,31 @@ - com_google_common_collect_immutablemap_builder.put(recipeholder.id(), recipeholder); - } + public Map, RecipePropertySet> getSynchronizedItemProperties() { +@@ -229,6 +252,22 @@ + return new RecipeHolder<>(resourcekey, irecipe); + } -- this.byType = builder.build(); -- this.byName = com_google_common_collect_immutablemap_builder.build(); -+ // CraftBukkit start - mutable -+ this.byType = LinkedHashMultimap.create(builder.build()); -+ this.byName = Maps.newHashMap(com_google_common_collect_immutablemap_builder.build()); -+ // CraftBukkit end -+ } -+ + // CraftBukkit start -+ public boolean removeRecipe(MinecraftKey mcKey) { -+ Iterator> iter = byType.values().iterator(); -+ while (iter.hasNext()) { -+ RecipeHolder recipe = iter.next(); -+ if (recipe.id().equals(mcKey)) { -+ iter.remove(); -+ } ++ public boolean removeRecipe(ResourceKey> mcKey) { ++ boolean removed = this.recipes.removeRecipe(mcKey); ++ if (removed) { ++ finalizeRecipeLoading(); + } + -+ return byName.remove(mcKey) != null; - } - ++ return removed; ++ } ++ + public void clearRecipes() { -+ this.byType = LinkedHashMultimap.create(); -+ this.byName = Maps.newHashMap(); ++ this.recipes = RecipeMap.create(Collections.emptyList()); ++ finalizeRecipeLoading(); + } + // CraftBukkit end + diff --git a/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch index 30ac7e91..d69f2a7b 100644 --- a/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch +++ b/nms-patches/net/minecraft/world/item/crafting/FurnaceRecipe.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/FurnaceRecipe.java +++ b/net/minecraft/world/item/crafting/FurnaceRecipe.java -@@ -3,6 +3,14 @@ +@@ -4,6 +4,14 @@ import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.item.Items; +// CraftBukkit start +import org.bukkit.NamespacedKey; @@ -15,18 +15,18 @@ public class FurnaceRecipe extends RecipeCooking { public FurnaceRecipe(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -18,4 +26,17 @@ - public RecipeSerializer getSerializer() { - return RecipeSerializer.SMELTING_RECIPE; +@@ -45,4 +53,17 @@ + + return recipebookcategory; } + + // CraftBukkit start + @Override + public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result()); + -+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); -+ recipe.setGroup(this.group); ++ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(id, result, CraftRecipe.toBukkit(this.input()), 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/IRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch index 85949adc..4d92b706 100644 --- a/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch +++ b/nms-patches/net/minecraft/world/item/crafting/IRecipe.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/crafting/IRecipe.java +++ b/net/minecraft/world/item/crafting/IRecipe.java -@@ -71,4 +71,6 @@ - return recipeitemstack.getItems().length == 0; - }); +@@ -44,4 +44,6 @@ } + + RecipeBookCategory recipeBookCategory(); + + org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id); // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch b/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch index 4087f9dd..911c0790 100644 --- a/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch +++ b/nms-patches/net/minecraft/world/item/crafting/IRecipeComplex.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/item/crafting/IRecipeComplex.java +++ b/net/minecraft/world/item/crafting/IRecipeComplex.java -@@ -3,6 +3,15 @@ - import net.minecraft.core.HolderLookup; - import net.minecraft.world.item.ItemStack; +@@ -8,6 +8,15 @@ + import net.minecraft.network.RegistryFriendlyByteBuf; + import net.minecraft.network.codec.StreamCodec; +// CraftBukkit start -+import net.minecraft.core.IRegistryCustom; ++import net.minecraft.world.item.ItemStack; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.inventory.CraftComplexRecipe; +import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -16,21 +16,39 @@ public abstract class IRecipeComplex implements RecipeCrafting { private final CraftingBookCategory category; -@@ -25,4 +34,17 @@ - public CraftingBookCategory category() { - return this.category; - } -+ +@@ -34,6 +43,19 @@ + @Override + public abstract RecipeSerializer getSerializer(); + + // CraftBukkit start + @Override + public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(getResultItem(IRegistryCustom.EMPTY)); ++ CraftItemStack result = CraftItemStack.asCraftMirror(ItemStack.EMPTY); + + CraftComplexRecipe recipe = new CraftComplexRecipe(id, result, this); -+ recipe.setGroup(this.getGroup()); ++ recipe.setGroup(this.group()); + recipe.setCategory(CraftRecipe.getCategory(this.category())); + + return recipe; + } + // CraftBukkit end - } ++ + public static class Serializer implements RecipeSerializer { + + private final MapCodec codec; +@@ -41,13 +63,13 @@ + + public Serializer(IRecipeComplex.Serializer.Factory irecipecomplex_serializer_factory) { + this.codec = RecordCodecBuilder.mapCodec((instance) -> { +- P1 p1 = instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(RecipeCrafting::category)); ++ P1, CraftingBookCategory> p1 = instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(RecipeCrafting::category)); // CraftBukkit - decompile error + + Objects.requireNonNull(irecipecomplex_serializer_factory); + return p1.apply(instance, irecipecomplex_serializer_factory::create); + }); + StreamCodec streamcodec = CraftingBookCategory.STREAM_CODEC; +- Function function = RecipeCrafting::category; ++ Function function = RecipeCrafting::category; // CraftBukkit - decompile error + + Objects.requireNonNull(irecipecomplex_serializer_factory); + this.streamCodec = StreamCodec.composite(streamcodec, function, irecipecomplex_serializer_factory::create); diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch index daa0c936..3adff4ba 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeBlasting.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/RecipeBlasting.java +++ b/net/minecraft/world/item/crafting/RecipeBlasting.java -@@ -3,6 +3,14 @@ +@@ -4,6 +4,14 @@ import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.item.Items; +// CraftBukkit start +import org.bukkit.NamespacedKey; @@ -15,18 +15,18 @@ public class RecipeBlasting extends RecipeCooking { public RecipeBlasting(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -18,4 +26,17 @@ - public RecipeSerializer getSerializer() { - return RecipeSerializer.BLASTING_RECIPE; +@@ -43,4 +51,17 @@ + + return recipebookcategory; } + + // CraftBukkit start + @Override + public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result()); + -+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); -+ recipe.setGroup(this.group); ++ CraftBlastingRecipe recipe = new CraftBlastingRecipe(id, result, CraftRecipe.toBukkit(this.input()), 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 fa7909db..17887eef 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeCampfire.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/RecipeCampfire.java +++ b/net/minecraft/world/item/crafting/RecipeCampfire.java -@@ -3,6 +3,14 @@ +@@ -4,6 +4,14 @@ import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.item.Items; +// CraftBukkit start +import org.bukkit.NamespacedKey; @@ -15,18 +15,18 @@ public class RecipeCampfire extends RecipeCooking { public RecipeCampfire(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -18,4 +26,17 @@ - public RecipeSerializer getSerializer() { - return RecipeSerializer.CAMPFIRE_COOKING_RECIPE; +@@ -29,4 +37,17 @@ + public RecipeBookCategory recipeBookCategory() { + return RecipeBookCategories.CAMPFIRE; } + + // CraftBukkit start + @Override + public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result()); + -+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); -+ recipe.setGroup(this.group); ++ CraftCampfireRecipe recipe = new CraftCampfireRecipe(id, result, CraftRecipe.toBukkit(this.input()), 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/RecipeHolder.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeHolder.patch index 6ded93bb..e6d62f70 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeHolder.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeHolder.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/item/crafting/RecipeHolder.java +++ b/net/minecraft/world/item/crafting/RecipeHolder.java -@@ -4,8 +4,19 @@ +@@ -5,8 +5,19 @@ import net.minecraft.network.codec.StreamCodec; - import net.minecraft.resources.MinecraftKey; + import net.minecraft.resources.ResourceKey; +// CraftBukkit start +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.Recipe; +// CraftBukkit end + - public record RecipeHolder>(MinecraftKey id, T value) { + public record RecipeHolder>(ResourceKey> id, T value) { + // CraftBukkit start + public final Recipe toBukkitRecipe() { -+ return this.value.toBukkitRecipe(CraftNamespacedKey.fromMinecraft(this.id)); ++ return this.value.toBukkitRecipe(CraftNamespacedKey.fromMinecraft(this.id.location())); + } + // CraftBukkit end + - public static final StreamCodec> STREAM_CODEC = StreamCodec.composite(MinecraftKey.STREAM_CODEC, RecipeHolder::id, IRecipe.STREAM_CODEC, RecipeHolder::value, RecipeHolder::new); + public static final StreamCodec> STREAM_CODEC = StreamCodec.composite(ResourceKey.streamCodec(Registries.RECIPE), RecipeHolder::id, IRecipe.STREAM_CODEC, RecipeHolder::value, RecipeHolder::new); public boolean equals(Object object) { diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch index 3141f273..0d36ff3d 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch @@ -1,26 +1,52 @@ --- a/net/minecraft/world/item/crafting/RecipeItemStack.java +++ b/net/minecraft/world/item/crafting/RecipeItemStack.java -@@ -40,6 +40,7 @@ - public ItemStack[] itemStacks; +@@ -42,6 +42,24 @@ + private final HolderSet values; @Nullable - private IntList stackingIds; -+ public boolean exact; // CraftBukkit - public static final Codec CODEC = codec(true); - public static final Codec CODEC_NONEMPTY = codec(false); + private List> items; ++ // CraftBukkit start ++ @Nullable ++ private List itemStacks; ++ ++ public boolean isExact() { ++ return this.itemStacks != null; ++ } ++ ++ public List itemStacks() { ++ return this.itemStacks; ++ } ++ ++ public static RecipeItemStack ofStacks(Stream stacks) { ++ RecipeItemStack recipe = RecipeItemStack.of(stacks.map(ItemStack::getItem)); ++ recipe.itemStacks = stacks.toList(); ++ return recipe; ++ } ++ // CraftBukkit end -@@ -77,6 +78,15 @@ - for (int j = 0; j < i; ++j) { - ItemStack itemstack1 = aitemstack[j]; + private RecipeItemStack(HolderSet holderset) { + holderset.unwrap().ifRight((list) -> { +@@ -72,6 +90,15 @@ + } -+ // CraftBukkit start -+ if (exact) { -+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.isSameItemSameComponents(itemstack, itemstack1)) { -+ return true; -+ } -+ -+ continue; + public boolean test(ItemStack itemstack) { ++ // CraftBukkit start ++ if (this.isExact()) { ++ for (ItemStack itemstack1 : this.itemStacks()) { ++ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.isSameItemSameComponents(itemstack, itemstack1)) { ++ return true; + } -+ // CraftBukkit end - if (itemstack1.is(itemstack.getItem())) { - return true; - } ++ } ++ } ++ // CraftBukkit end + List> list = this.items(); + + for (int i = 0; i < list.size(); ++i) { +@@ -85,7 +112,7 @@ + + public boolean equals(Object object) { + if (object instanceof RecipeItemStack recipeitemstack) { +- return Objects.equals(this.values, recipeitemstack.values); ++ return Objects.equals(this.values, recipeitemstack.values) && Objects.equals(this.itemStacks, recipeitemstack.itemStacks); // CraftBukkit + } else { + return false; + } diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeMap.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeMap.patch new file mode 100644 index 00000000..7a21b05a --- /dev/null +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeMap.patch @@ -0,0 +1,56 @@ +--- a/net/minecraft/world/item/crafting/RecipeMap.java ++++ b/net/minecraft/world/item/crafting/RecipeMap.java +@@ -12,6 +12,11 @@ + import net.minecraft.resources.ResourceKey; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import com.google.common.collect.LinkedHashMultimap; ++import com.google.common.collect.Maps; ++// CraftBukkit end ++ + public class RecipeMap { + + public static final RecipeMap EMPTY = new RecipeMap(ImmutableMultimap.of(), Map.of()); +@@ -35,11 +40,39 @@ + com_google_common_collect_immutablemap_builder.put(recipeholder.id(), recipeholder); + } + +- return new RecipeMap(builder.build(), com_google_common_collect_immutablemap_builder.build()); ++ // CraftBukkit start - mutable ++ return new RecipeMap(LinkedHashMultimap.create(builder.build()), Maps.newHashMap(com_google_common_collect_immutablemap_builder.build())); ++ } ++ ++ public void addRecipe(RecipeHolder irecipe) { ++ Collection> map = this.byType.get(irecipe.value().getType()); ++ ++ if (byKey.containsKey(irecipe.id())) { ++ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.id()); ++ } else { ++ map.add(irecipe); ++ byKey.put(irecipe.id(), irecipe); ++ } + } + ++ public boolean removeRecipe(ResourceKey> mcKey) { ++ boolean removed = false; ++ Iterator> iter = byType.values().iterator(); ++ while (iter.hasNext()) { ++ RecipeHolder recipe = iter.next(); ++ if (recipe.id().equals(mcKey)) { ++ iter.remove(); ++ removed = true; ++ } ++ } ++ removed |= byKey.remove(mcKey) != null; ++ ++ return removed; ++ } ++ // CraftBukkit end ++ + public > Collection> byType(Recipes recipes) { +- return this.byType.get(recipes); ++ return (Collection) this.byType.get(recipes); // CraftBukkit - decompile error + } + + public Collection> values() { diff --git a/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch index 2fe09912..d168b475 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeSmoking.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/RecipeSmoking.java +++ b/net/minecraft/world/item/crafting/RecipeSmoking.java -@@ -3,6 +3,14 @@ +@@ -4,6 +4,14 @@ import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.item.Items; +// CraftBukkit start +import org.bukkit.NamespacedKey; @@ -15,18 +15,18 @@ public class RecipeSmoking extends RecipeCooking { public RecipeSmoking(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { -@@ -18,4 +26,17 @@ - public RecipeSerializer getSerializer() { - return RecipeSerializer.SMOKING_RECIPE; +@@ -29,4 +37,17 @@ + public RecipeBookCategory recipeBookCategory() { + return RecipeBookCategories.SMOKER_FOOD; } + + // CraftBukkit start + @Override + public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result()); + -+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); -+ recipe.setGroup(this.group); ++ CraftSmokingRecipe recipe = new CraftSmokingRecipe(id, result, CraftRecipe.toBukkit(this.input()), 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/RecipeStonecutting.patch b/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch index 21b2a7fe..41726d8c 100644 --- a/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch +++ b/nms-patches/net/minecraft/world/item/crafting/RecipeStonecutting.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/RecipeStonecutting.java +++ b/net/minecraft/world/item/crafting/RecipeStonecutting.java -@@ -4,6 +4,14 @@ - import net.minecraft.world.level.World; - import net.minecraft.world.level.block.Blocks; +@@ -7,6 +7,14 @@ + import net.minecraft.world.item.crafting.display.SlotDisplay; + import net.minecraft.world.item.crafting.display.StonecutterRecipeDisplay; +// CraftBukkit start +import org.bukkit.NamespacedKey; @@ -15,18 +15,18 @@ public class RecipeStonecutting extends RecipeSingleItem { public RecipeStonecutting(String s, RecipeItemStack recipeitemstack, ItemStack itemstack) { -@@ -18,4 +26,16 @@ - public ItemStack getToastSymbol() { - return new ItemStack(Blocks.STONECUTTER); +@@ -36,4 +44,16 @@ + public RecipeBookCategory recipeBookCategory() { + return RecipeBookCategories.STONECUTTER; } + + // CraftBukkit start + @Override + public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result()); + -+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(id, result, CraftRecipe.toBukkit(this.ingredient)); -+ recipe.setGroup(this.group); ++ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(id, result, CraftRecipe.toBukkit(this.input())); ++ recipe.setGroup(this.group()); + + return recipe; + } diff --git a/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch b/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch index a9a8c24a..26816fcf 100644 --- a/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch +++ b/nms-patches/net/minecraft/world/item/crafting/ShapedRecipes.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipes.java +++ b/net/minecraft/world/item/crafting/ShapedRecipes.java -@@ -10,6 +10,14 @@ - import net.minecraft.world.item.ItemStack; +@@ -17,6 +17,14 @@ + import net.minecraft.world.item.crafting.display.SlotDisplay; import net.minecraft.world.level.World; +// CraftBukkit start @@ -15,7 +15,7 @@ public class ShapedRecipes implements RecipeCrafting { final ShapedRecipePattern pattern; -@@ -30,6 +38,68 @@ +@@ -39,6 +47,68 @@ this(s, craftingbookcategory, shapedrecipepattern, itemstack, true); } @@ -69,7 +69,7 @@ + break; + } + char c = 'a'; -+ for (RecipeItemStack list : this.pattern.ingredients()) { ++ for (Optional list : this.pattern.ingredients()) { + RecipeChoice choice = CraftRecipe.toBukkit(list); + if (choice != null) { + recipe.setIngredient(c, choice); @@ -82,5 +82,5 @@ + // CraftBukkit end + @Override - public RecipeSerializer getSerializer() { + public RecipeSerializer getSerializer() { return RecipeSerializer.SHAPED_RECIPE; diff --git a/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch b/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch index 68bf0e1e..1045293a 100644 --- a/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch +++ b/nms-patches/net/minecraft/world/item/crafting/ShapelessRecipes.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipes.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipes.java -@@ -13,6 +13,13 @@ - import net.minecraft.world.item.ItemStack; +@@ -17,6 +17,13 @@ + import net.minecraft.world.item.crafting.display.SlotDisplay; import net.minecraft.world.level.World; +// CraftBukkit start @@ -14,8 +14,8 @@ public class ShapelessRecipes implements RecipeCrafting { final String group; -@@ -27,6 +34,22 @@ - this.ingredients = nonnulllist; +@@ -33,6 +40,22 @@ + this.ingredients = list; } + // CraftBukkit start @@ -35,5 +35,5 @@ + // CraftBukkit end + @Override - public RecipeSerializer getSerializer() { + public RecipeSerializer getSerializer() { return RecipeSerializer.SHAPELESS_RECIPE; diff --git a/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch index 30f56c61..5594867e 100644 --- a/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch +++ b/nms-patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -@@ -9,6 +9,14 @@ - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.World; +@@ -14,6 +14,14 @@ + import net.minecraft.world.item.crafting.display.SlotDisplay; + import net.minecraft.world.item.crafting.display.SmithingRecipeDisplay; +// CraftBukkit start +import org.bukkit.NamespacedKey; @@ -14,9 +14,9 @@ + public class SmithingTransformRecipe implements SmithingRecipe { - final RecipeItemStack template; -@@ -64,6 +72,17 @@ - return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty); + final Optional template; +@@ -71,6 +79,17 @@ + return List.of(new SmithingRecipeDisplay(RecipeItemStack.optionalIngredientToDisplay(this.template), RecipeItemStack.optionalIngredientToDisplay(this.base), RecipeItemStack.optionalIngredientToDisplay(this.addition), new SlotDisplay.f(this.result), new SlotDisplay.d(Items.SMITHING_TABLE))); } + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch index 3cf83034..3b2a1c61 100644 --- a/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch +++ b/nms-patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -19,6 +19,13 @@ - import net.minecraft.world.item.armortrim.TrimPatterns; - import net.minecraft.world.level.World; +@@ -21,6 +21,13 @@ + import net.minecraft.world.item.equipment.trim.TrimPattern; + import net.minecraft.world.item.equipment.trim.TrimPatterns; +// CraftBukkit start +import org.bukkit.NamespacedKey; @@ -13,9 +13,9 @@ + public class SmithingTrimRecipe implements SmithingRecipe { - final RecipeItemStack template; + final Optional template; @@ -97,6 +104,13 @@ - return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty); + return List.of(new SmithingRecipeDisplay(slotdisplay2, slotdisplay, slotdisplay1, new SlotDisplay.g(slotdisplay, slotdisplay1, slotdisplay2), new SlotDisplay.d(Items.SMITHING_TABLE))); } + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/item/crafting/TransmuteRecipe.patch b/nms-patches/net/minecraft/world/item/crafting/TransmuteRecipe.patch new file mode 100644 index 00000000..b650fe61 --- /dev/null +++ b/nms-patches/net/minecraft/world/item/crafting/TransmuteRecipe.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/world/item/crafting/TransmuteRecipe.java ++++ b/net/minecraft/world/item/crafting/TransmuteRecipe.java +@@ -20,6 +20,14 @@ + import net.minecraft.world.level.IMaterial; + import net.minecraft.world.level.World; + ++// CraftBukkit start ++import org.bukkit.NamespacedKey; ++import org.bukkit.craftbukkit.inventory.CraftItemType; ++import org.bukkit.craftbukkit.inventory.CraftRecipe; ++import org.bukkit.craftbukkit.inventory.CraftTransmuteRecipe; ++import org.bukkit.inventory.Recipe; ++// CraftBukkit end ++ + public class TransmuteRecipe implements RecipeCrafting { + + final String group; +@@ -84,6 +92,13 @@ + return List.of(new ShapelessCraftingRecipeDisplay(List.of(this.input.display(), this.material.display()), new SlotDisplay.d(this.result), new SlotDisplay.d(Items.CRAFTING_TABLE))); + } + ++ // CraftBukkit start ++ @Override ++ public Recipe toBukkitRecipe(NamespacedKey id) { ++ return new CraftTransmuteRecipe(id, CraftItemType.minecraftToBukkit(this.result.value()), CraftRecipe.toBukkit(this.input), CraftRecipe.toBukkit(this.material)); ++ } ++ // CraftBukkit end ++ + @Override + public RecipeSerializer getSerializer() { + return RecipeSerializer.TRANSMUTE; diff --git a/nms-patches/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.patch b/nms-patches/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.patch index b95be72a..60e640d2 100644 --- a/nms-patches/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.patch +++ b/nms-patches/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.patch @@ -17,8 +17,8 @@ Optional>> optional = this.entityTypes().getRandomElement(worldserver.getRandom()); if (!optional.isEmpty()) { -- Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).spawn(worldserver, blockposition, EnumMobSpawn.TRIGGERED); -+ Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).create(worldserver, null, blockposition, EnumMobSpawn.TRIGGERED, false, false); // CraftBukkit +- Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).spawn(worldserver, blockposition, EntitySpawnReason.TRIGGERED); ++ Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).create(worldserver, null, blockposition, EntitySpawnReason.TRIGGERED, false, false); // CraftBukkit if (entity1 != null) { if (entity1 instanceof EntityLightning) { diff --git a/nms-patches/net/minecraft/world/level/Explosion.patch b/nms-patches/net/minecraft/world/level/Explosion.patch deleted file mode 100644 index 76c609ba..00000000 --- a/nms-patches/net/minecraft/world/level/Explosion.patch +++ /dev/null @@ -1,198 +0,0 @@ ---- a/net/minecraft/world/level/Explosion.java -+++ b/net/minecraft/world/level/Explosion.java -@@ -41,6 +41,16 @@ - import net.minecraft.world.phys.MovingObjectPosition; - import net.minecraft.world.phys.Vec3D; - -+// CraftBukkit start -+import net.minecraft.world.entity.boss.EntityComplexPart; -+import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon; -+import net.minecraft.world.level.block.Blocks; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.event.entity.EntityExplodeEvent; -+import org.bukkit.Location; -+import org.bukkit.event.block.BlockExplodeEvent; -+// CraftBukkit end -+ - public class Explosion { - - private static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new ExplosionDamageCalculator(); -@@ -62,6 +72,10 @@ - private final Holder explosionSound; - private final ObjectArrayList toBlow; - private final Map hitPlayers; -+ // CraftBukkit - add field -+ public boolean wasCanceled = false; -+ public float yield; -+ // CraftBukkit end - - public static DamageSource getDefaultDamageSource(World world, @Nullable Entity entity) { - return world.damageSources().explosion(entity, getIndirectSourceEntityInternal(entity)); -@@ -87,7 +101,7 @@ - this.hitPlayers = Maps.newHashMap(); - this.level = world; - this.source = entity; -- this.radius = f; -+ this.radius = (float) Math.max(f, 0.0); // CraftBukkit - clamp bad values - this.x = d0; - this.y = d1; - this.z = d2; -@@ -98,6 +112,7 @@ - this.smallExplosionParticles = particleparam; - this.largeExplosionParticles = particleparam1; - this.explosionSound = holder; -+ this.yield = this.blockInteraction == Explosion.Effect.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit - } - - private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { -@@ -148,6 +163,11 @@ - } - - public void explode() { -+ // CraftBukkit start -+ if (this.radius < 0.1F) { -+ return; -+ } -+ // CraftBukkit end - this.level.gameEvent(this.source, (Holder) GameEvent.EXPLODE, new Vec3D(this.x, this.y, this.z)); - Set set = Sets.newHashSet(); - boolean flag = true; -@@ -230,7 +250,35 @@ - d9 /= d11; - d10 /= d11; - if (this.damageCalculator.shouldDamageEntity(this, entity)) { -- entity.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity)); -+ // CraftBukkit start -+ -+ // Special case ender dragon only give knockback if no damage is cancelled -+ // Thinks to note: -+ // - Setting a velocity to a ComplexEntityPart is ignored (and therefore not needed) -+ // - Damaging ComplexEntityPart while forward the damage to EntityEnderDragon -+ // - Damaging EntityEnderDragon does nothing -+ // - EntityEnderDragon hitbock always covers the other parts and is therefore always present -+ if (entity instanceof EntityComplexPart) { -+ continue; -+ } -+ -+ entity.lastDamageCancelled = false; -+ -+ if (entity instanceof EntityEnderDragon) { -+ for (EntityComplexPart entityComplexPart : ((EntityEnderDragon) entity).subEntities) { -+ // Calculate damage separately for each EntityComplexPart -+ if (list.contains(entityComplexPart)) { -+ entityComplexPart.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity)); -+ } -+ } -+ } else { -+ entity.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity)); -+ } -+ -+ if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled -+ continue; -+ } -+ // CraftBukkit end - } - - double d12 = (1.0D - d7) * (double) getSeenPercent(vec3d, entity) * (double) this.damageCalculator.getKnockbackMultiplier(entity); -@@ -249,6 +297,17 @@ - d10 *= d13; - Vec3D vec3d1 = new Vec3D(d8, d9, d10); - -+ // CraftBukkit start - Call EntityKnockbackEvent -+ if (entity instanceof EntityLiving) { -+ Vec3D result = entity.getDeltaMovement().add(vec3d1); -+ org.bukkit.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), source, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.EXPLOSION, d13, vec3d1, result.x, result.y, result.z); -+ -+ // SPIGOT-7640: Need to subtract entity movement from the event result, -+ // since the code below (the setDeltaMovement call as well as the hitPlayers map) -+ // want the vector to be the relative velocity will the event provides the absolute velocity -+ vec3d1 = (event.isCancelled()) ? Vec3D.ZERO : new Vec3D(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ()).subtract(entity.getDeltaMovement()); -+ } -+ // CraftBukkit end - entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1)); - if (entity instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) entity; -@@ -291,9 +350,62 @@ - - SystemUtils.shuffle(this.toBlow, this.level.random); - ObjectListIterator objectlistiterator = this.toBlow.iterator(); -+ // CraftBukkit start -+ org.bukkit.World bworld = this.level.getWorld(); -+ Location location = new Location(bworld, this.x, this.y, this.z); -+ -+ List blockList = new ObjectArrayList<>(); -+ for (int i1 = this.toBlow.size() - 1; i1 >= 0; i1--) { -+ BlockPosition cpos = this.toBlow.get(i1); -+ org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ()); -+ if (!bblock.getType().isAir()) { -+ blockList.add(bblock); -+ } -+ } -+ -+ List bukkitBlocks; -+ -+ if (this.source != null) { -+ EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent(this.source, blockList, this.yield, getBlockInteraction()); -+ this.wasCanceled = event.isCancelled(); -+ bukkitBlocks = event.blockList(); -+ this.yield = event.getYield(); -+ } else { -+ org.bukkit.block.Block block = location.getBlock(); -+ org.bukkit.block.BlockState blockState = (damageSource.getDirectBlockState() != null) ? damageSource.getDirectBlockState() : block.getState(); -+ BlockExplodeEvent event = CraftEventFactory.callBlockExplodeEvent(block, blockState, blockList, this.yield, getBlockInteraction()); -+ this.wasCanceled = event.isCancelled(); -+ bukkitBlocks = event.blockList(); -+ this.yield = event.getYield(); -+ } -+ -+ this.toBlow.clear(); -+ -+ for (org.bukkit.block.Block bblock : bukkitBlocks) { -+ BlockPosition coords = new BlockPosition(bblock.getX(), bblock.getY(), bblock.getZ()); -+ toBlow.add(coords); -+ } -+ -+ if (this.wasCanceled) { -+ return; -+ } -+ // CraftBukkit end -+ objectlistiterator = this.toBlow.iterator(); - - while (objectlistiterator.hasNext()) { - BlockPosition blockposition = (BlockPosition) objectlistiterator.next(); -+ // CraftBukkit start - TNTPrimeEvent -+ IBlockData iblockdata = this.level.getBlockState(blockposition); -+ Block block = iblockdata.getBlock(); -+ if (block instanceof net.minecraft.world.level.block.BlockTNT) { -+ Entity sourceEntity = source == null ? null : source; -+ BlockPosition sourceBlock = sourceEntity == null ? BlockPosition.containing(this.x, this.y, this.z) : null; -+ if (!CraftEventFactory.callTNTPrimeEvent(this.level, blockposition, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.EXPLOSION, sourceEntity, sourceBlock)) { -+ this.level.sendBlockUpdated(blockposition, Blocks.AIR.defaultBlockState(), iblockdata, 3); // Update the block on the client -+ continue; -+ } -+ } -+ // CraftBukkit end - - this.level.getBlockState(blockposition).onExplosionHit(this.level, blockposition, this, (itemstack, blockposition1) -> { - addOrAppendStack(list, itemstack, blockposition1); -@@ -318,7 +430,11 @@ - BlockPosition blockposition1 = (BlockPosition) objectlistiterator1.next(); - - if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockposition1).isAir() && this.level.getBlockState(blockposition1.below()).isSolidRender(this.level, blockposition1.below())) { -- this.level.setBlockAndUpdate(blockposition1, BlockFireAbstract.getState(this.level, blockposition1)); -+ // CraftBukkit start - Ignition by explosion -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level, blockposition1, this).isCancelled()) { -+ this.level.setBlockAndUpdate(blockposition1, BlockFireAbstract.getState(this.level, blockposition1)); -+ } -+ // CraftBukkit end - } - } - } -@@ -326,6 +442,7 @@ - } - - private static void addOrAppendStack(List> list, ItemStack itemstack, BlockPosition blockposition) { -+ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-5425 - for (int i = 0; i < list.size(); ++i) { - Pair pair = (Pair) list.get(i); - ItemStack itemstack1 = (ItemStack) pair.getFirst(); diff --git a/nms-patches/net/minecraft/world/level/GameRules.patch b/nms-patches/net/minecraft/world/level/GameRules.patch index c67fbace..c2398839 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 -@@ -55,7 +55,7 @@ +@@ -58,7 +58,7 @@ public static final GameRules.GameRuleKey RULE_SENDCOMMANDFEEDBACK = register("sendCommandFeedback", GameRules.GameRuleCategory.CHAT, GameRules.GameRuleBoolean.create(true)); public static final GameRules.GameRuleKey RULE_REDUCEDDEBUGINFO = register("reducedDebugInfo", GameRules.GameRuleCategory.MISC, GameRules.GameRuleBoolean.create(false, (minecraftserver, gamerules_gameruleboolean) -> { int i = gamerules_gameruleboolean.get() ? 22 : 23; @@ -9,7 +9,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -70,7 +70,7 @@ +@@ -74,7 +74,7 @@ public static final GameRules.GameRuleKey RULE_MAX_ENTITY_CRAMMING = register("maxEntityCramming", GameRules.GameRuleCategory.MOBS, GameRules.GameRuleInt.create(24)); public static final GameRules.GameRuleKey RULE_WEATHER_CYCLE = register("doWeatherCycle", GameRules.GameRuleCategory.UPDATES, GameRules.GameRuleBoolean.create(true)); public static final GameRules.GameRuleKey RULE_LIMITED_CRAFTING = register("doLimitedCrafting", GameRules.GameRuleCategory.PLAYER, GameRules.GameRuleBoolean.create(false, (minecraftserver, gamerules_gameruleboolean) -> { @@ -18,7 +18,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -86,7 +86,7 @@ +@@ -90,7 +90,7 @@ public static final GameRules.GameRuleKey RULE_DISABLE_RAIDS = register("disableRaids", GameRules.GameRuleCategory.MOBS, GameRules.GameRuleBoolean.create(false)); public static final GameRules.GameRuleKey RULE_DOINSOMNIA = register("doInsomnia", GameRules.GameRuleCategory.SPAWNING, GameRules.GameRuleBoolean.create(true)); public static final GameRules.GameRuleKey RULE_DO_IMMEDIATE_RESPAWN = register("doImmediateRespawn", GameRules.GameRuleCategory.PLAYER, GameRules.GameRuleBoolean.create(false, (minecraftserver, gamerules_gameruleboolean) -> { @@ -27,25 +27,25 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -117,7 +117,7 @@ - public static final GameRules.GameRuleKey RULE_DO_VINES_SPREAD = register("doVinesSpread", GameRules.GameRuleCategory.UPDATES, GameRules.GameRuleBoolean.create(true)); - public static final GameRules.GameRuleKey RULE_ENDER_PEARLS_VANISH_ON_DEATH = register("enderPearlsVanishOnDeath", GameRules.GameRuleCategory.PLAYER, GameRules.GameRuleBoolean.create(true)); - public static final GameRules.GameRuleKey RULE_SPAWN_CHUNK_RADIUS = register("spawnChunkRadius", GameRules.GameRuleCategory.MISC, GameRules.GameRuleInt.create(2, 0, 32, (minecraftserver, gamerules_gameruleint) -> { +@@ -123,7 +123,7 @@ + public static final GameRules.GameRuleKey RULE_MINECART_MAX_SPEED = register("minecartMaxSpeed", GameRules.GameRuleCategory.MISC, GameRules.GameRuleInt.create(8, 1, 1000, FeatureFlagSet.of(FeatureFlags.MINECART_IMPROVEMENTS), (minecraftserver, gamerules_gameruleint) -> { + })); + public static final GameRules.GameRuleKey RULE_SPAWN_CHUNK_RADIUS = register("spawnChunkRadius", GameRules.GameRuleCategory.MISC, GameRules.GameRuleInt.create(2, 0, 32, FeatureFlagSet.of(), (minecraftserver, gamerules_gameruleint) -> { - WorldServer worldserver = minecraftserver.overworld(); + WorldServer worldserver = minecraftserver; // CraftBukkit - per-world worldserver.setDefaultSpawnPos(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle()); })); -@@ -150,7 +150,7 @@ +@@ -164,7 +164,7 @@ } public > T getRule(GameRules.GameRuleKey gamerules_gamerulekey) { -- return (GameRules.GameRuleValue) this.rules.get(gamerules_gamerulekey); -+ return (T) this.rules.get(gamerules_gamerulekey); // CraftBukkit - decompile error - } +- T t0 = (GameRules.GameRuleValue) this.rules.get(gamerules_gamerulekey); ++ T t0 = (T) this.rules.get(gamerules_gamerulekey); // CraftBukkit - decompile error - public NBTTagCompound createTag() { -@@ -164,7 +164,7 @@ + if (t0 == null) { + throw new IllegalArgumentException("Tried to access invalid game rule"); +@@ -184,7 +184,7 @@ private void loadFromTag(DynamicLike dynamiclike) { this.rules.forEach((gamerules_gamerulekey, gamerules_gamerulevalue) -> { @@ -54,14 +54,16 @@ Objects.requireNonNull(gamerules_gamerulevalue); dataresult.ifSuccess(gamerules_gamerulevalue::deserialize); -@@ -184,17 +184,17 @@ - } +@@ -205,19 +205,19 @@ + + private > void callVisitorCap(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey, GameRules.GameRuleDefinition gamerules_gameruledefinition) { + if (gamerules_gameruledefinition.requiredFeatures.isSubsetOf(this.enabledFeatures)) { +- gamerules_gamerulevisitor.visit(gamerules_gamerulekey, gamerules_gameruledefinition); +- gamerules_gameruledefinition.callVisitor(gamerules_gamerulevisitor, gamerules_gamerulekey); ++ gamerules_gamerulevisitor.visit((GameRules.GameRuleKey) gamerules_gamerulekey, (GameRules.GameRuleDefinition) gamerules_gameruledefinition); // CraftBukkit - decompile error ++ ((GameRules.GameRuleDefinition) gamerules_gameruledefinition).callVisitor(gamerules_gamerulevisitor, (GameRules.GameRuleKey) gamerules_gamerulekey); // CraftBukkit - decompile error + } - private static > void callVisitorCap(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey, GameRules.GameRuleDefinition gamerules_gameruledefinition) { -- gamerules_gamerulevisitor.visit(gamerules_gamerulekey, gamerules_gameruledefinition); -- gamerules_gameruledefinition.callVisitor(gamerules_gamerulevisitor, gamerules_gamerulekey); -+ gamerules_gamerulevisitor.visit((GameRules.GameRuleKey) gamerules_gamerulekey, (GameRules.GameRuleDefinition) gamerules_gameruledefinition); // CraftBukkit - decompile error -+ ((GameRules.GameRuleDefinition) gamerules_gameruledefinition).callVisitor(gamerules_gamerulevisitor, (GameRules.GameRuleKey) gamerules_gamerulekey); // CraftBukkit - decompile error } - public void assignFrom(GameRules gamerules, @Nullable MinecraftServer minecraftserver) { @@ -76,20 +78,21 @@ T t0 = gamerules.getRule(gamerules_gamerulekey); this.getRule(gamerules_gamerulekey).setFrom(t0, minecraftserver); -@@ -262,10 +262,10 @@ +@@ -285,11 +285,11 @@ final Supplier> argument; private final Function, T> constructor; - final BiConsumer callback; + final BiConsumer callback; // CraftBukkit - per-world private final GameRules.h visitorCaller; + final FeatureFlagSet requiredFeatures; -- GameRuleDefinition(Supplier> supplier, Function, T> function, BiConsumer biconsumer, GameRules.h gamerules_h) { -+ GameRuleDefinition(Supplier> supplier, Function, T> function, BiConsumer biconsumer, GameRules.h gamerules_h) { // CraftBukkit - per-world +- GameRuleDefinition(Supplier> supplier, Function, T> function, BiConsumer biconsumer, GameRules.h gamerules_h, FeatureFlagSet featureflagset) { ++ GameRuleDefinition(Supplier> supplier, Function, T> function, BiConsumer biconsumer, GameRules.h gamerules_h, FeatureFlagSet featureflagset) { // CraftBukkit - per-world this.argument = supplier; this.constructor = function; this.callback = biconsumer; -@@ -277,7 +277,7 @@ +@@ -302,7 +302,7 @@ } public T createRule() { @@ -98,7 +101,7 @@ } public void callVisitor(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey) { -@@ -297,17 +297,17 @@ +@@ -326,17 +326,17 @@ public void setFromArgument(CommandContext commandcontext, String s) { this.updateFromArgument(commandcontext, s); @@ -119,7 +122,7 @@ public abstract String serialize(); -@@ -321,7 +321,7 @@ +@@ -350,7 +350,7 @@ protected abstract T copy(); @@ -128,7 +131,7 @@ } public interface GameRuleVisitor { -@@ -337,7 +337,7 @@ +@@ -366,7 +366,7 @@ private boolean value; @@ -136,8 +139,8 @@ + static GameRules.GameRuleDefinition create(boolean flag, BiConsumer biconsumer) { // CraftBukkit - per-world return new GameRules.GameRuleDefinition<>(BoolArgumentType::bool, (gamerules_gameruledefinition) -> { return new GameRules.GameRuleBoolean(gamerules_gameruledefinition, flag); - }, biconsumer, GameRules.GameRuleVisitor::visitBoolean); -@@ -362,7 +362,7 @@ + }, biconsumer, GameRules.GameRuleVisitor::visitBoolean, FeatureFlagSet.of()); +@@ -391,7 +391,7 @@ return this.value; } @@ -146,7 +149,7 @@ this.value = flag; this.onChanged(minecraftserver); } -@@ -373,7 +373,7 @@ +@@ -402,7 +402,7 @@ } @Override @@ -155,7 +158,7 @@ this.value = Boolean.parseBoolean(s); } -@@ -392,7 +392,7 @@ +@@ -421,7 +421,7 @@ return new GameRules.GameRuleBoolean(this.type, this.value); } @@ -164,7 +167,7 @@ this.value = gamerules_gameruleboolean.value; this.onChanged(minecraftserver); } -@@ -402,13 +402,13 @@ +@@ -431,13 +431,13 @@ private int value; @@ -172,15 +175,15 @@ + private static GameRules.GameRuleDefinition create(int i, BiConsumer biconsumer) { // CraftBukkit - per-world return new GameRules.GameRuleDefinition<>(IntegerArgumentType::integer, (gamerules_gameruledefinition) -> { return new GameRules.GameRuleInt(gamerules_gameruledefinition, i); - }, biconsumer, GameRules.GameRuleVisitor::visitInteger); + }, biconsumer, GameRules.GameRuleVisitor::visitInteger, FeatureFlagSet.of()); } -- static GameRules.GameRuleDefinition create(int i, int j, int k, BiConsumer biconsumer) { -+ static GameRules.GameRuleDefinition create(int i, int j, int k, BiConsumer biconsumer) { // CraftBukkit - per-world +- static GameRules.GameRuleDefinition create(int i, int j, int k, FeatureFlagSet featureflagset, BiConsumer biconsumer) { ++ static GameRules.GameRuleDefinition create(int i, int j, int k, FeatureFlagSet featureflagset, BiConsumer biconsumer) { // CraftBukkit - per-world return new GameRules.GameRuleDefinition<>(() -> { return IntegerArgumentType.integer(j, k); }, (gamerules_gameruledefinition) -> { -@@ -435,7 +435,7 @@ +@@ -464,7 +464,7 @@ return this.value; } @@ -189,7 +192,7 @@ this.value = i; this.onChanged(minecraftserver); } -@@ -446,7 +446,7 @@ +@@ -475,7 +475,7 @@ } @Override @@ -198,7 +201,7 @@ this.value = safeParse(s); } -@@ -488,7 +488,7 @@ +@@ -517,7 +517,7 @@ return new GameRules.GameRuleInt(this.type, this.value); } diff --git a/nms-patches/net/minecraft/world/level/GeneratorAccess.patch b/nms-patches/net/minecraft/world/level/GeneratorAccess.patch index 5df5b1c2..ff57d08f 100644 --- a/nms-patches/net/minecraft/world/level/GeneratorAccess.patch +++ b/nms-patches/net/minecraft/world/level/GeneratorAccess.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/GeneratorAccess.java +++ b/net/minecraft/world/level/GeneratorAccess.java -@@ -121,4 +121,6 @@ +@@ -101,4 +101,6 @@ default void gameEvent(ResourceKey resourcekey, BlockPosition blockposition, GameEvent.a gameevent_a) { - this.gameEvent((Holder) this.registryAccess().registryOrThrow(Registries.GAME_EVENT).getHolderOrThrow(resourcekey), blockposition, gameevent_a); + this.gameEvent((Holder) this.registryAccess().lookupOrThrow(Registries.GAME_EVENT).getOrThrow(resourcekey), blockposition, gameevent_a); } + + net.minecraft.server.level.WorldServer getMinecraftWorld(); // CraftBukkit diff --git a/nms-patches/net/minecraft/world/level/IBlockAccess.patch b/nms-patches/net/minecraft/world/level/IBlockAccess.patch index 15e1b1d7..0e30f8b4 100644 --- a/nms-patches/net/minecraft/world/level/IBlockAccess.patch +++ b/nms-patches/net/minecraft/world/level/IBlockAccess.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/IBlockAccess.java +++ b/net/minecraft/world/level/IBlockAccess.java -@@ -26,7 +26,7 @@ +@@ -31,7 +31,7 @@ default Optional getBlockEntity(BlockPosition blockposition, TileEntityTypes tileentitytypes) { TileEntity tileentity = this.getBlockEntity(blockposition); @@ -9,7 +9,7 @@ } IBlockData getBlockState(BlockPosition blockposition); -@@ -58,8 +58,8 @@ +@@ -59,8 +59,8 @@ }); } @@ -20,7 +20,7 @@ IBlockData iblockdata = this.getBlockState(blockposition); Fluid fluid = this.getFluidState(blockposition); Vec3D vec3d = raytrace1.getFrom(); -@@ -72,6 +72,12 @@ +@@ -73,6 +73,12 @@ double d1 = movingobjectpositionblock1 == null ? Double.MAX_VALUE : raytrace1.getFrom().distanceToSqr(movingobjectpositionblock1.getLocation()); return d0 <= d1 ? movingobjectpositionblock : movingobjectpositionblock1; @@ -33,7 +33,7 @@ }, (raytrace1) -> { Vec3D vec3d = raytrace1.getFrom().subtract(raytrace1.getTo()); -@@ -144,7 +150,7 @@ +@@ -145,7 +151,7 @@ double d13 = d10 * (i1 > 0 ? 1.0D - MathHelper.frac(d4) : MathHelper.frac(d4)); double d14 = d11 * (j1 > 0 ? 1.0D - MathHelper.frac(d5) : MathHelper.frac(d5)); diff --git a/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch b/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch index 45bf2cf9..7e6badc7 100644 --- a/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch +++ b/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch @@ -9,7 +9,7 @@ private boolean isNearPlayer(World world, BlockPosition blockposition) { @@ -157,13 +158,18 @@ - ((EntityInsentient) entity).finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entity.blockPosition()), EnumMobSpawn.SPAWNER, (GroupDataEntity) null); + ((EntityInsentient) entity).finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, (GroupDataEntity) null); } - Optional optional1 = mobspawnerdata.getEquipment(); diff --git a/nms-patches/net/minecraft/world/level/ServerExplosion.patch b/nms-patches/net/minecraft/world/level/ServerExplosion.patch new file mode 100644 index 00000000..e2c17adb --- /dev/null +++ b/nms-patches/net/minecraft/world/level/ServerExplosion.patch @@ -0,0 +1,193 @@ +--- a/net/minecraft/world/level/ServerExplosion.java ++++ b/net/minecraft/world/level/ServerExplosion.java +@@ -35,6 +35,17 @@ + import net.minecraft.world.phys.MovingObjectPosition; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import net.minecraft.world.entity.boss.EntityComplexPart; ++import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon; ++import net.minecraft.world.level.block.Blocks; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.craftbukkit.util.CraftLocation; ++import org.bukkit.event.entity.EntityExplodeEvent; ++import org.bukkit.Location; ++import org.bukkit.event.block.BlockExplodeEvent; ++// CraftBukkit end ++ + public class ServerExplosion implements Explosion { + + private static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new ExplosionDamageCalculator(); +@@ -50,16 +61,21 @@ + private final DamageSource damageSource; + private final ExplosionDamageCalculator damageCalculator; + private final Map hitPlayers = new HashMap(); ++ // CraftBukkit - add field ++ public boolean wasCanceled = false; ++ public float yield; ++ // CraftBukkit end + + public ServerExplosion(WorldServer worldserver, @Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, Vec3D vec3d, float f, boolean flag, Explosion.Effect explosion_effect) { + this.level = worldserver; + this.source = entity; +- this.radius = f; ++ this.radius = (float) Math.max(f, 0.0); // CraftBukkit - clamp bad values + this.center = vec3d; + this.fire = flag; + this.blockInteraction = explosion_effect; + this.damageSource = damagesource == null ? worldserver.damageSources().explosion(this) : damagesource; + this.damageCalculator = explosiondamagecalculator == null ? this.makeDamageCalculator(entity) : explosiondamagecalculator; ++ this.yield = this.blockInteraction == Explosion.Effect.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit + } + + private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { +@@ -195,7 +211,35 @@ + float f2 = !flag && f1 == 0.0F ? 0.0F : getSeenPercent(this.center, entity); + + if (flag) { +- entity.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f2)); ++ // CraftBukkit start ++ ++ // Special case ender dragon only give knockback if no damage is cancelled ++ // Thinks to note: ++ // - Setting a velocity to a ComplexEntityPart is ignored (and therefore not needed) ++ // - Damaging ComplexEntityPart while forward the damage to EntityEnderDragon ++ // - Damaging EntityEnderDragon does nothing ++ // - EntityEnderDragon hitbock always covers the other parts and is therefore always present ++ if (entity instanceof EntityComplexPart) { ++ continue; ++ } ++ ++ entity.lastDamageCancelled = false; ++ ++ if (entity instanceof EntityEnderDragon) { ++ for (EntityComplexPart entityComplexPart : ((EntityEnderDragon) entity).subEntities) { ++ // Calculate damage separately for each EntityComplexPart ++ if (list.contains(entityComplexPart)) { ++ entityComplexPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f2)); ++ } ++ } ++ } else { ++ entity.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f2)); ++ } ++ ++ if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled ++ continue; ++ } ++ // CraftBukkit end + } + + double d5 = (1.0D - d0) * (double) f2 * (double) f1; +@@ -214,6 +258,17 @@ + d3 *= d6; + Vec3D vec3d = new Vec3D(d1, d2, d3); + ++ // CraftBukkit start - Call EntityKnockbackEvent ++ if (entity instanceof EntityLiving) { ++ Vec3D result = entity.getDeltaMovement().add(vec3d); ++ org.bukkit.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), source, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.EXPLOSION, d6, vec3d, result.x, result.y, result.z); ++ ++ // SPIGOT-7640: Need to subtract entity movement from the event result, ++ // since the code below (the setDeltaMovement call as well as the hitPlayers map) ++ // want the vector to be the relative velocity will the event provides the absolute velocity ++ vec3d = (event.isCancelled()) ? Vec3D.ZERO : new Vec3D(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ()).subtract(entity.getDeltaMovement()); ++ } ++ // CraftBukkit end + entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d)); + if (entity instanceof EntityHuman) { + EntityHuman entityhuman = (EntityHuman) entity; +@@ -235,10 +290,62 @@ + List list1 = new ArrayList(); + + SystemUtils.shuffle(list, this.level.random); ++ // CraftBukkit start ++ org.bukkit.World bworld = this.level.getWorld(); ++ Location location = CraftLocation.toBukkit(this.center, bworld); ++ ++ List blockList = new ObjectArrayList<>(); ++ for (int i1 = list.size() - 1; i1 >= 0; i1--) { ++ BlockPosition cpos = list.get(i1); ++ org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ()); ++ if (!bblock.getType().isAir()) { ++ blockList.add(bblock); ++ } ++ } ++ ++ List bukkitBlocks; ++ ++ if (this.source != null) { ++ EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent(this.source, blockList, this.yield, getBlockInteraction()); ++ this.wasCanceled = event.isCancelled(); ++ bukkitBlocks = event.blockList(); ++ this.yield = event.getYield(); ++ } else { ++ org.bukkit.block.Block block = location.getBlock(); ++ org.bukkit.block.BlockState blockState = (damageSource.getDirectBlockState() != null) ? damageSource.getDirectBlockState() : block.getState(); ++ BlockExplodeEvent event = CraftEventFactory.callBlockExplodeEvent(block, blockState, blockList, this.yield, getBlockInteraction()); ++ this.wasCanceled = event.isCancelled(); ++ bukkitBlocks = event.blockList(); ++ this.yield = event.getYield(); ++ } ++ ++ list.clear(); ++ ++ for (org.bukkit.block.Block bblock : bukkitBlocks) { ++ BlockPosition coords = new BlockPosition(bblock.getX(), bblock.getY(), bblock.getZ()); ++ list.add(coords); ++ } ++ ++ if (this.wasCanceled) { ++ return; ++ } ++ // CraftBukkit end + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { + BlockPosition blockposition = (BlockPosition) iterator.next(); ++ // CraftBukkit start - TNTPrimeEvent ++ IBlockData iblockdata = this.level.getBlockState(blockposition); ++ Block block = iblockdata.getBlock(); ++ if (block instanceof net.minecraft.world.level.block.BlockTNT) { ++ Entity sourceEntity = source == null ? null : source; ++ BlockPosition sourceBlock = sourceEntity == null ? BlockPosition.containing(this.center) : null; ++ if (!CraftEventFactory.callTNTPrimeEvent(this.level, blockposition, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.EXPLOSION, sourceEntity, sourceBlock)) { ++ this.level.sendBlockUpdated(blockposition, Blocks.AIR.defaultBlockState(), iblockdata, 3); // Update the block on the client ++ continue; ++ } ++ } ++ // CraftBukkit end + + this.level.getBlockState(blockposition).onExplosionHit(this.level, blockposition, this, (itemstack, blockposition1) -> { + addOrAppendStack(list1, itemstack, blockposition1); +@@ -262,13 +369,22 @@ + BlockPosition blockposition = (BlockPosition) iterator.next(); + + if (this.level.random.nextInt(3) == 0 && this.level.getBlockState(blockposition).isAir() && this.level.getBlockState(blockposition.below()).isSolidRender()) { +- this.level.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level, blockposition)); ++ // CraftBukkit start - Ignition by explosion ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level, blockposition, this).isCancelled()) { ++ this.level.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level, blockposition)); ++ } ++ // CraftBukkit end + } + } + + } + + public void explode() { ++ // CraftBukkit start ++ if (this.radius < 0.1F) { ++ return; ++ } ++ // CraftBukkit end + this.level.gameEvent(this.source, (Holder) GameEvent.EXPLODE, this.center); + List list = this.calculateExplodedPositions(); + +@@ -288,6 +404,7 @@ + } + + private static void addOrAppendStack(List list, ItemStack itemstack, BlockPosition blockposition) { ++ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-5425 + Iterator iterator = list.iterator(); + + do { diff --git a/nms-patches/net/minecraft/world/level/SpawnerCreature.patch b/nms-patches/net/minecraft/world/level/SpawnerCreature.patch index 36cf6bf5..d2b2e265 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 -@@ -46,6 +46,13 @@ +@@ -50,6 +50,13 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -14,12 +14,19 @@ public final class SpawnerCreature { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -108,10 +115,25 @@ +@@ -107,15 +114,31 @@ + return (BiomeBase) ichunkaccess.getNoiseBiome(QuartPos.fromBlock(blockposition.getX()), QuartPos.fromBlock(blockposition.getY()), QuartPos.fromBlock(blockposition.getZ())).value(); + } + +- public static List getFilteredSpawningCategories(SpawnerCreature.d spawnercreature_d, boolean flag, boolean flag1, boolean flag2) { ++ // CraftBukkit start - add server ++ public static List getFilteredSpawningCategories(SpawnerCreature.d spawnercreature_d, boolean flag, boolean flag1, boolean flag2, WorldServer worldserver) { ++ WorldData worlddata = worldserver.getLevelData(); // CraftBukkit - Other mob type spawn tick rate ++ // CraftBukkit end + List list = new ArrayList(SpawnerCreature.SPAWNING_CATEGORIES.length); EnumCreatureType[] aenumcreaturetype = SpawnerCreature.SPAWNING_CATEGORIES; int i = aenumcreaturetype.length; -+ WorldData worlddata = worldserver.getLevelData(); // CraftBukkit - Other mob type spawn tick rate -+ for (int j = 0; j < i; ++j) { EnumCreatureType enumcreaturetype = aenumcreaturetype[j]; + // CraftBukkit start - Use per-world spawn limits @@ -31,20 +38,20 @@ + limit = worldserver.getWorld().getSpawnLimit(spawnCategory); + } -- if ((flag || !enumcreaturetype.isFriendly()) && (flag1 || enumcreaturetype.isFriendly()) && (flag2 || !enumcreaturetype.isPersistent()) && spawnercreature_d.canSpawnForCategory(enumcreaturetype, chunk.getPos())) { +- if ((flag || !enumcreaturetype.isFriendly()) && (flag1 || enumcreaturetype.isFriendly()) && (flag2 || !enumcreaturetype.isPersistent()) && spawnercreature_d.canSpawnForCategoryGlobal(enumcreaturetype)) { + if (!spawnThisTick || limit == 0) { + continue; + } + -+ if ((flag || !enumcreaturetype.isFriendly()) && (flag1 || enumcreaturetype.isFriendly()) && (flag2 || !enumcreaturetype.isPersistent()) && spawnercreature_d.canSpawnForCategory(enumcreaturetype, chunk.getPos(), limit)) { ++ if ((flag || !enumcreaturetype.isFriendly()) && (flag1 || enumcreaturetype.isFriendly()) && (flag2 || !enumcreaturetype.isPersistent()) && spawnercreature_d.canSpawnForCategoryGlobal(enumcreaturetype, limit)) { + // CraftBukkit end - Objects.requireNonNull(spawnercreature_d); - SpawnerCreature.c spawnercreature_c = spawnercreature_d::canSpawn; - -@@ -196,10 +218,15 @@ + list.add(enumcreaturetype); + } + } +@@ -217,10 +240,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); + groupdataentity = entityinsentient.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityinsentient.blockPosition()), EntitySpawnReason.NATURAL, groupdataentity); - ++j; - ++k1; - worldserver.addFreshEntityWithPassengers(entityinsentient); @@ -61,25 +68,25 @@ if (j >= entityinsentient.getMaxSpawnClusterSize()) { return; } -@@ -348,7 +375,7 @@ +@@ -369,7 +397,7 @@ - if (entityinsentient.checkSpawnRules(worldaccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.checkSpawnObstruction(worldaccess)) { - groupdataentity = entityinsentient.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(entityinsentient.blockPosition()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity); + if (entityinsentient.checkSpawnRules(worldaccess, EntitySpawnReason.CHUNK_GENERATION) && entityinsentient.checkSpawnObstruction(worldaccess)) { + groupdataentity = entityinsentient.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(entityinsentient.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, groupdataentity); - worldaccess.addFreshEntityWithPassengers(entityinsentient); + worldaccess.addFreshEntityWithPassengers(entityinsentient, SpawnReason.CHUNK_GEN); // CraftBukkit flag = true; } } -@@ -461,8 +488,10 @@ +@@ -482,8 +510,10 @@ return this.unmodifiableMobCategoryCounts; } -- boolean canSpawnForCategory(EnumCreatureType enumcreaturetype, ChunkCoordIntPair chunkcoordintpair) { +- boolean canSpawnForCategoryGlobal(EnumCreatureType enumcreaturetype) { - int i = enumcreaturetype.getMaxInstancesPerChunk() * this.spawnableChunkCount / SpawnerCreature.MAGIC_NUMBER; + // CraftBukkit start -+ boolean canSpawnForCategory(EnumCreatureType enumcreaturetype, ChunkCoordIntPair chunkcoordintpair, int limit) { ++ boolean canSpawnForCategoryGlobal(EnumCreatureType enumcreaturetype, int limit) { + int i = limit * this.spawnableChunkCount / SpawnerCreature.MAGIC_NUMBER; + // CraftBukkit end - return this.mobCategoryCounts.getInt(enumcreaturetype) >= i ? false : this.localMobCapCalculator.canSpawn(enumcreaturetype, chunkcoordintpair); + return this.mobCategoryCounts.getInt(enumcreaturetype) < i; } diff --git a/nms-patches/net/minecraft/world/level/World.patch b/nms-patches/net/minecraft/world/level/World.patch index 80116f14..1fdff914 100644 --- a/nms-patches/net/minecraft/world/level/World.patch +++ b/nms-patches/net/minecraft/world/level/World.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/World.java +++ b/net/minecraft/world/level/World.java -@@ -78,6 +78,28 @@ +@@ -80,6 +80,28 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.scores.Scoreboard; @@ -29,11 +29,11 @@ public abstract class World implements GeneratorAccess, AutoCloseable { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); -@@ -119,7 +141,42 @@ +@@ -120,7 +142,42 @@ private final DamageSources damageSources; private long subTickCount; -- protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, IRegistryCustom iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j) { +- protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, IRegistryCustom iregistrycustom, Holder holder, boolean flag, boolean flag1, long i, int j) { + // CraftBukkit start Added the following + private final CraftWorld world; + public boolean pvpMode; @@ -58,7 +58,7 @@ + + public abstract ResourceKey getTypeKey(); + -+ protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, IRegistryCustom iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env) { ++ protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, IRegistryCustom iregistrycustom, Holder holder, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env) { + this.generator = gen; + this.world = new CraftWorld((WorldServer) this, gen, biomeProvider, env); + @@ -70,9 +70,9 @@ + } + + // CraftBukkit end - this.profiler = supplier; this.levelData = worlddatamutable; this.dimensionTypeRegistration = holder; + final DimensionManager dimensionmanager = (DimensionManager) holder.value(); @@ -128,15 +185,15 @@ this.dimension = resourcekey; this.isClientSide = flag; @@ -255,7 +255,7 @@ public void onBlockStateChange(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} @Override -@@ -337,6 +515,14 @@ +@@ -339,6 +517,14 @@ @Override public IBlockData getBlockState(BlockPosition blockposition) { @@ -270,19 +270,7 @@ if (this.isOutsideBuildHeight(blockposition)) { return Blocks.VOID_AIR.defaultBlockState(); } else { -@@ -523,6 +709,11 @@ - case 4: - explosion_effect = Explosion.Effect.TRIGGER_BLOCK; - break; -+ // CraftBukkit start - handle custom explosion type -+ case 5: -+ explosion_effect = Explosion.Effect.DESTROY; -+ break; -+ // CraftBukkit end - default: - throw new MatchException((String) null, (Throwable) null); - } -@@ -544,6 +735,16 @@ +@@ -509,6 +695,16 @@ @Nullable @Override public TileEntity getBlockEntity(BlockPosition blockposition) { @@ -299,7 +287,7 @@ return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, Chunk.EnumTileEntityState.IMMEDIATE)); } -@@ -551,6 +752,12 @@ +@@ -516,6 +712,12 @@ BlockPosition blockposition = tileentity.getBlockPos(); if (!this.isOutsideBuildHeight(blockposition)) { @@ -312,7 +300,7 @@ this.getChunkAt(blockposition).addAndRegisterBlockEntity(tileentity); } } -@@ -680,7 +887,7 @@ +@@ -645,7 +847,7 @@ for (int k = 0; k < j; ++k) { EntityComplexPart entitycomplexpart = aentitycomplexpart[k]; @@ -321,7 +309,7 @@ if (t0 != null && predicate.test(t0)) { list.add(t0); -@@ -958,7 +1165,7 @@ +@@ -912,7 +1114,7 @@ public static enum a implements INamable { diff --git a/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch b/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch index 4bcfac09..a11c361b 100644 --- a/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/AbstractCandleBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/AbstractCandleBlock.java +++ b/net/minecraft/world/level/block/AbstractCandleBlock.java -@@ -46,6 +46,11 @@ +@@ -47,6 +47,11 @@ @Override protected void onProjectileHit(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, IProjectile iprojectile) { if (!world.isClientSide && iprojectile.isOnFire() && this.canBeLit(iblockdata)) { diff --git a/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch b/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch index 901605a2..791bcfe2 100644 --- a/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/BigDripleafBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BigDripleafBlock.java +++ b/net/minecraft/world/level/block/BigDripleafBlock.java -@@ -43,6 +43,11 @@ +@@ -45,6 +45,11 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -12,7 +12,7 @@ public class BigDripleafBlock extends BlockFacingHorizontal implements IBlockFragilePlantElement, IBlockWaterlogged { public static final MapCodec CODEC = simpleCodec(BigDripleafBlock::new); -@@ -117,7 +122,7 @@ +@@ -119,7 +124,7 @@ @Override protected void onProjectileHit(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, IProjectile iprojectile) { @@ -21,7 +21,7 @@ } @Override -@@ -176,7 +181,20 @@ +@@ -178,7 +183,20 @@ protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { if (!world.isClientSide) { if (iblockdata.getValue(BigDripleafBlock.TILT) == Tilt.NONE && canEntityTilt(blockposition, entity) && !world.hasNeighborSignal(blockposition)) { @@ -43,7 +43,7 @@ } } -@@ -190,9 +208,9 @@ +@@ -192,9 +210,9 @@ Tilt tilt = (Tilt) iblockdata.getValue(BigDripleafBlock.TILT); if (tilt == Tilt.UNSTABLE) { @@ -55,7 +55,7 @@ } else if (tilt == Tilt.FULL) { resetTilt(iblockdata, worldserver, blockposition); } -@@ -218,8 +236,10 @@ +@@ -220,8 +238,10 @@ return entity.onGround() && entity.position().y > (double) ((float) blockposition.getY() + 0.6875F); } @@ -68,7 +68,7 @@ if (soundeffect != null) { playTiltSound(world, blockposition, soundeffect); } -@@ -233,14 +253,21 @@ +@@ -235,14 +255,21 @@ } private static void resetTilt(IBlockData iblockdata, World world, BlockPosition blockposition) { @@ -92,7 +92,7 @@ Tilt tilt1 = (Tilt) iblockdata.getValue(BigDripleafBlock.TILT); world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BigDripleafBlock.TILT, tilt), 2); -@@ -248,6 +275,7 @@ +@@ -250,6 +277,7 @@ world.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_CHANGE, blockposition); } diff --git a/nms-patches/net/minecraft/world/level/block/Block.patch b/nms-patches/net/minecraft/world/level/block/Block.patch index 5bb1b617..fe2c7229 100644 --- a/nms-patches/net/minecraft/world/level/block/Block.patch +++ b/nms-patches/net/minecraft/world/level/block/Block.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java @@ -340,7 +340,13 @@ - EntityItem entityitem = (EntityItem) supplier.get(); - - entityitem.setDefaultPickUpDelay(); -- world.addFreshEntity(entityitem); -+ // CraftBukkit start -+ if (world.captureDrops != null) { -+ world.captureDrops.add(entityitem); -+ } else { -+ world.addFreshEntity(entityitem); -+ } -+ // CraftBukkit end + EntityItem entityitem = (EntityItem) supplier.get(); + + entityitem.setDefaultPickUpDelay(); +- world.addFreshEntity(entityitem); ++ // CraftBukkit start ++ if (world.captureDrops != null) { ++ world.captureDrops.add(entityitem); ++ } else { ++ world.addFreshEntity(entityitem); ++ } ++ // CraftBukkit end + return; + } } - } - -@@ -366,7 +372,7 @@ +@@ -369,7 +375,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); } -@@ -499,15 +505,23 @@ +@@ -494,15 +500,23 @@ return this.builtInRegistryHolder; } @@ -47,6 +47,6 @@ + } + // CraftBukkit end + - public static final class a { + private static record a(VoxelShape first, VoxelShape second) { - private final IBlockData first; + public boolean equals(Object object) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch b/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch index 4d6cca39..b18e8d37 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBamboo.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBamboo.java +++ b/net/minecraft/world/level/block/BlockBamboo.java -@@ -187,7 +187,7 @@ +@@ -183,7 +183,7 @@ BlockPosition blockposition1 = blockposition.above(i); IBlockData iblockdata1 = worldserver.getBlockState(blockposition1); @@ -9,7 +9,7 @@ return; } -@@ -208,14 +208,18 @@ +@@ -204,14 +204,18 @@ BlockPosition blockposition1 = blockposition.below(2); IBlockData iblockdata2 = world.getBlockState(blockposition1); BlockPropertyBambooSize blockpropertybamboosize = BlockPropertyBambooSize.NONE; @@ -30,7 +30,7 @@ } } } else { -@@ -226,7 +230,14 @@ +@@ -222,7 +226,14 @@ int j = (Integer) iblockdata.getValue(BlockBamboo.AGE) != 1 && !iblockdata2.is(Blocks.BAMBOO) ? 0 : 1; int k = (i < 11 || randomsource.nextFloat() >= 0.25F) && i != 15 ? 0 : 1; diff --git a/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch b/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch index e734aac6..9bfc7a5c 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBambooSapling.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBambooSapling.java +++ b/net/minecraft/world/level/block/BlockBambooSapling.java -@@ -95,6 +95,6 @@ +@@ -87,6 +87,6 @@ } protected void growBamboo(World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockBed.patch b/nms-patches/net/minecraft/world/level/block/BlockBed.patch index 9f9c5700..87549359 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 -@@ -93,7 +93,8 @@ +@@ -95,7 +95,8 @@ } } @@ -10,9 +10,9 @@ world.removeBlock(blockposition, false); BlockPosition blockposition1 = blockposition.relative(((EnumDirection) iblockdata.getValue(BlockBed.FACING)).getOpposite()); -@@ -112,7 +113,16 @@ +@@ -114,7 +115,16 @@ - return EnumInteractionResult.SUCCESS; + return EnumInteractionResult.SUCCESS_SERVER; } else { + // CraftBukkit start + IBlockData finaliblockdata = iblockdata; @@ -27,7 +27,7 @@ if (entityhuman_enumbedresult.getMessage() != null) { entityhuman.displayClientMessage(entityhuman_enumbedresult.getMessage(), true); } -@@ -123,8 +133,30 @@ +@@ -125,8 +135,30 @@ } } @@ -59,7 +59,7 @@ } private boolean kickVillagerOutOfBed(World world, BlockPosition blockposition) { -@@ -323,6 +355,11 @@ +@@ -325,6 +357,11 @@ BlockPosition blockposition1 = blockposition.relative((EnumDirection) iblockdata.getValue(BlockBed.FACING)); world.setBlock(blockposition1, (IBlockData) iblockdata.setValue(BlockBed.PART, BlockPropertyBedPart.HEAD), 3); diff --git a/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch b/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch index fb022452..7ad5aa98 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBeehive.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBeehive.java +++ b/net/minecraft/world/level/block/BlockBeehive.java -@@ -119,7 +119,7 @@ +@@ -133,7 +133,7 @@ if (entitybee.getTarget() == null) { EntityHuman entityhuman = (EntityHuman) SystemUtils.getRandom(list1, world.random); @@ -9,12 +9,12 @@ } } } -@@ -287,7 +287,7 @@ - ItemStack itemstack = new ItemStack(this); +@@ -302,7 +302,7 @@ + ItemStack itemstack = new ItemStack(this); - itemstack.applyComponents(tileentitybeehive.collectComponents()); -- itemstack.set(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY.with(BlockBeehive.HONEY_LEVEL, (Comparable) i)); -+ itemstack.set(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY.with(BlockBeehive.HONEY_LEVEL, i)); // CraftBukkit - decompile error - EntityItem entityitem = new EntityItem(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack); + itemstack.applyComponents(tileentitybeehive.collectComponents()); +- itemstack.set(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY.with(BlockBeehive.HONEY_LEVEL, (Comparable) i)); ++ itemstack.set(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY.with(BlockBeehive.HONEY_LEVEL, i)); // CraftBukkit - decompile error + EntityItem entityitem = new EntityItem(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack); - entityitem.setDefaultPickUpDelay(); + entityitem.setDefaultPickUpDelay(); diff --git a/nms-patches/net/minecraft/world/level/block/BlockBell.patch b/nms-patches/net/minecraft/world/level/block/BlockBell.patch index 76a04850..cdf7e1e8 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockBell.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockBell.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockBell.java +++ b/net/minecraft/world/level/block/BlockBell.java -@@ -146,6 +146,11 @@ +@@ -148,6 +148,11 @@ if (enumdirection == null) { enumdirection = (EnumDirection) world.getBlockState(blockposition).getValue(BlockBell.FACING); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockButtonAbstract.patch index ebc661f7..5000b862 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 -@@ -33,6 +33,11 @@ +@@ -35,6 +35,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -12,7 +12,7 @@ public class BlockButtonAbstract extends BlockAttachable { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -124,6 +129,19 @@ +@@ -126,6 +131,19 @@ if ((Boolean) iblockdata.getValue(BlockButtonAbstract.POWERED)) { return EnumInteractionResult.CONSUME; } else { @@ -30,9 +30,9 @@ + } + // CraftBukkit end this.press(iblockdata, world, blockposition, entityhuman); - return EnumInteractionResult.sidedSuccess(world.isClientSide); + return EnumInteractionResult.SUCCESS; } -@@ -195,11 +213,36 @@ +@@ -197,11 +215,36 @@ } protected void checkPressed(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCactus.patch b/nms-patches/net/minecraft/world/level/block/BlockCactus.patch index 586d2923..b7357ae0 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCactus.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCactus.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCactus.java +++ b/net/minecraft/world/level/block/BlockCactus.java -@@ -22,6 +22,8 @@ +@@ -23,6 +23,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public class BlockCactus extends Block { public static final MapCodec CODEC = simpleCodec(BlockCactus::new); -@@ -64,7 +66,7 @@ +@@ -65,7 +67,7 @@ int j = (Integer) iblockdata.getValue(BlockCactus.AGE); if (j == 15) { @@ -18,7 +18,7 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockCactus.AGE, 0); worldserver.setBlock(blockposition, iblockdata1, 4); -@@ -119,7 +121,7 @@ +@@ -120,7 +122,7 @@ @Override protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCake.patch b/nms-patches/net/minecraft/world/level/block/BlockCake.patch index f7dbcd4f..85c05115 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCake.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCake.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCake.java +++ b/net/minecraft/world/level/block/BlockCake.java -@@ -97,7 +97,18 @@ +@@ -98,7 +98,18 @@ return EnumInteractionResult.PASS; } else { entityhuman.awardStat(StatisticList.EAT_CAKE_SLICE); diff --git a/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch b/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch index 434f5451..dcc6445b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCampfire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCampfire.java +++ b/net/minecraft/world/level/block/BlockCampfire.java -@@ -105,7 +105,7 @@ +@@ -113,7 +113,7 @@ @Override protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { if ((Boolean) iblockdata.getValue(BlockCampfire.LIT) && entity instanceof EntityLiving) { @@ -9,15 +9,15 @@ } super.entityInside(iblockdata, world, blockposition, entity); -@@ -215,6 +215,11 @@ - BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); +@@ -224,6 +224,11 @@ - if (!world.isClientSide && iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition) && !(Boolean) iblockdata.getValue(BlockCampfire.LIT) && !(Boolean) iblockdata.getValue(BlockCampfire.WATERLOGGED)) { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, iprojectile).isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockProperties.LIT, true), 11); + if (world instanceof WorldServer worldserver) { + if (iprojectile.isOnFire() && iprojectile.mayInteract(worldserver, blockposition) && !(Boolean) iblockdata.getValue(BlockCampfire.LIT) && !(Boolean) iblockdata.getValue(BlockCampfire.WATERLOGGED)) { ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, iprojectile).isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockProperties.LIT, true), 11); + } } - diff --git a/nms-patches/net/minecraft/world/level/block/BlockChest.patch b/nms-patches/net/minecraft/world/level/block/BlockChest.patch index f3931bf5..4f8016bc 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockChest.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockChest.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockChest.java +++ b/net/minecraft/world/level/block/BlockChest.java -@@ -90,24 +90,7 @@ +@@ -91,24 +91,7 @@ public Optional acceptDouble(final TileEntityChest tileentitychest, final TileEntityChest tileentitychest1) { final InventoryLargeChest inventorylargechest = new InventoryLargeChest(tileentitychest, tileentitychest1); @@ -26,7 +26,7 @@ } public Optional acceptSingle(TileEntityChest tileentitychest) { -@@ -120,6 +103,38 @@ +@@ -121,6 +104,38 @@ } }; @@ -65,7 +65,7 @@ @Override public MapCodec codec() { return BlockChest.CODEC; -@@ -263,7 +278,7 @@ +@@ -262,7 +277,7 @@ @Override public DoubleBlockFinder.Result combine(IBlockData iblockdata, World world, BlockPosition blockposition, boolean flag) { @@ -74,7 +74,7 @@ if (flag) { bipredicate = (generatoraccess, blockposition1) -> { -@@ -279,7 +294,14 @@ +@@ -278,7 +293,14 @@ @Nullable @Override protected ITileInventory getMenuProvider(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch b/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch index 69451ae1..04cac1d3 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockChorusFlower.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockChorusFlower.java +++ b/net/minecraft/world/level/block/BlockChorusFlower.java -@@ -22,6 +22,8 @@ +@@ -23,6 +23,8 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,7 @@ public class BlockChorusFlower extends Block { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -102,8 +104,12 @@ +@@ -103,8 +105,12 @@ } if (flag && allNeighborsEmpty(worldserver, blockposition1, (EnumDirection) null) && worldserver.isEmptyBlock(blockposition.above(2))) { @@ -24,7 +24,7 @@ } else if (i < 4) { j = randomsource.nextInt(4); if (flag1) { -@@ -117,18 +123,30 @@ +@@ -118,18 +124,30 @@ BlockPosition blockposition2 = blockposition.relative(enumdirection); if (worldserver.isEmptyBlock(blockposition2) && worldserver.isEmptyBlock(blockposition2.below()) && allNeighborsEmpty(worldserver, blockposition2, enumdirection.getOpposite())) { @@ -59,15 +59,15 @@ } } -@@ -265,6 +283,11 @@ - BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); +@@ -267,6 +285,11 @@ - if (!world.isClientSide && iprojectile.mayInteract(world, blockposition) && iprojectile.mayBreak(world)) { -+ // CraftBukkit -+ if (!CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState())) { -+ return; -+ } -+ // CraftBukkit end - world.destroyBlock(blockposition, true, iprojectile); + if (world instanceof WorldServer worldserver) { + if (iprojectile.mayInteract(worldserver, blockposition) && iprojectile.mayBreak(worldserver)) { ++ // CraftBukkit ++ if (!CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState())) { ++ return; ++ } ++ // CraftBukkit end + world.destroyBlock(blockposition, true, iprojectile); + } } - diff --git a/nms-patches/net/minecraft/world/level/block/BlockCommand.patch b/nms-patches/net/minecraft/world/level/block/BlockCommand.patch index f931c492..3984b69d 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCommand.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCommand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCommand.java +++ b/net/minecraft/world/level/block/BlockCommand.java -@@ -29,6 +29,8 @@ +@@ -31,6 +31,8 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import org.slf4j.Logger; @@ -9,19 +9,19 @@ public class BlockCommand extends BlockTileEntity implements GameMasterBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -69,6 +71,15 @@ - TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity; - boolean flag1 = world.hasNeighborSignal(blockposition); - boolean flag2 = tileentitycommand.isPowered(); -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ int old = flag2 ? 15 : 0; -+ int current = flag1 ? 15 : 0; +@@ -78,6 +80,15 @@ + + private void setPoweredAndUpdate(World world, BlockPosition blockposition, TileEntityCommand tileentitycommand, boolean flag) { + boolean flag1 = tileentitycommand.isPowered(); ++ // CraftBukkit start ++ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ int old = flag1 ? 15 : 0; ++ int current = flag ? 15 : 0; + -+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current); -+ world.getCraftServer().getPluginManager().callEvent(eventRedstone); -+ flag1 = eventRedstone.getNewCurrent() > 0; -+ // CraftBukkit end ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current); ++ world.getCraftServer().getPluginManager().callEvent(eventRedstone); ++ flag = eventRedstone.getNewCurrent() > 0; ++ // CraftBukkit end - tileentitycommand.setPowered(flag1); - if (!flag2 && !tileentitycommand.isAutomatic() && tileentitycommand.getMode() != TileEntityCommand.Type.SEQUENCE) { + if (flag != flag1) { + tileentitycommand.setPowered(flag); diff --git a/nms-patches/net/minecraft/world/level/block/BlockComposter.patch b/nms-patches/net/minecraft/world/level/block/BlockComposter.patch index a53c6442..e858180c 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockComposter.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockComposter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockComposter.java +++ b/net/minecraft/world/level/block/BlockComposter.java -@@ -43,6 +43,11 @@ +@@ -42,6 +42,11 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -12,7 +12,7 @@ public class BlockComposter extends Block implements IInventoryHolder { public static final MapCodec CODEC = simpleCodec(BlockComposter::new); -@@ -263,7 +268,14 @@ +@@ -267,7 +272,14 @@ int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) { @@ -28,7 +28,7 @@ itemstack.shrink(1); return iblockdata1; -@@ -273,6 +285,14 @@ +@@ -277,6 +289,14 @@ } public static IBlockData extractProduce(Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { @@ -43,7 +43,7 @@ if (!world.isClientSide) { Vec3D vec3d = Vec3D.atLowerCornerWithOffset(blockposition, 0.5D, 1.01D, 0.5D).offsetRandom(world.random, 0.7F); EntityItem entityitem = new EntityItem(world, vec3d.x(), vec3d.y(), vec3d.z(), new ItemStack(Items.BONE_MEAL)); -@@ -296,10 +316,16 @@ +@@ -300,10 +320,16 @@ } static IBlockData addItem(@Nullable Entity entity, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) { @@ -61,7 +61,7 @@ return iblockdata; } else { int j = i + 1; -@@ -348,7 +374,8 @@ +@@ -352,7 +378,8 @@ public IWorldInventory getContainer(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); @@ -71,7 +71,7 @@ } public static class ContainerOutput extends InventorySubcontainer implements IWorldInventory { -@@ -363,6 +390,7 @@ +@@ -367,6 +394,7 @@ this.state = iblockdata; this.level = generatoraccess; this.pos = blockposition; @@ -79,7 +79,7 @@ } @Override -@@ -387,8 +415,15 @@ +@@ -391,8 +419,15 @@ @Override public void setChanged() { @@ -95,7 +95,7 @@ } } -@@ -401,6 +436,7 @@ +@@ -405,6 +440,7 @@ public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { super(1); @@ -103,7 +103,7 @@ this.state = iblockdata; this.level = generatoraccess; this.pos = blockposition; -@@ -443,8 +479,9 @@ +@@ -447,8 +483,9 @@ public static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory { diff --git a/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch b/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch index ba1b0d0e..f828b830 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockConcretePowder.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockConcretePowder.java +++ b/net/minecraft/world/level/block/BlockConcretePowder.java -@@ -14,6 +14,12 @@ +@@ -16,6 +16,12 @@ import net.minecraft.world.level.block.state.BlockBase; import net.minecraft.world.level.block.state.IBlockData; @@ -13,7 +13,7 @@ public class BlockConcretePowder extends BlockFalling { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -36,7 +42,7 @@ +@@ -38,7 +44,7 @@ @Override public void onLand(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) { if (shouldSolidify(world, blockposition, iblockdata1)) { @@ -22,7 +22,7 @@ } } -@@ -47,7 +53,24 @@ +@@ -49,7 +55,24 @@ BlockPosition blockposition = blockactioncontext.getClickedPos(); IBlockData iblockdata = world.getBlockState(blockposition); @@ -48,29 +48,29 @@ } private static boolean shouldSolidify(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) { -@@ -83,7 +106,25 @@ +@@ -85,7 +108,25 @@ @Override - protected IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { -- return touchesLiquid(generatoraccess, blockposition) ? this.concrete.defaultBlockState() : super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + protected IBlockData updateShape(IBlockData iblockdata, IWorldReader iworldreader, ScheduledTickAccess scheduledtickaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition blockposition1, IBlockData iblockdata1, RandomSource randomsource) { +- return touchesLiquid(iworldreader, blockposition) ? this.concrete.defaultBlockState() : super.updateShape(iblockdata, iworldreader, scheduledtickaccess, blockposition, enumdirection, blockposition1, iblockdata1, randomsource); + // CraftBukkit start -+ if (touchesLiquid(generatoraccess, blockposition)) { ++ if (touchesLiquid(iworldreader, blockposition)) { + // Suppress during worldgen -+ if (!(generatoraccess instanceof World)) { ++ if (!(iworldreader instanceof World world)) { + return this.concrete.defaultBlockState(); + } -+ CraftBlockState blockState = CraftBlockStates.getBlockState(generatoraccess, blockposition); ++ CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockposition); + blockState.setData(this.concrete.defaultBlockState()); + + BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState); -+ ((World) generatoraccess).getCraftServer().getPluginManager().callEvent(event); ++ world.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + return blockState.getHandle(); + } + } + -+ return super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); ++ return super.updateShape(iblockdata, iworldreader, scheduledtickaccess, blockposition, enumdirection, blockposition1, iblockdata1, randomsource); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/level/block/BlockCoral.patch b/nms-patches/net/minecraft/world/level/block/BlockCoral.patch index c42075fa..17128dac 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCoral.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCoral.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCoral.java +++ b/net/minecraft/world/level/block/BlockCoral.java -@@ -39,6 +39,11 @@ +@@ -40,6 +40,11 @@ @Override protected void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if (!this.scanForWater(worldserver, blockposition)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch b/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch index 7651d1e6..d885679e 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCoralFan.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCoralFan.java +++ b/net/minecraft/world/level/block/BlockCoralFan.java -@@ -40,6 +40,11 @@ +@@ -41,6 +41,11 @@ @Override protected void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if (!scanForWater(iblockdata, worldserver, blockposition)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch b/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch index bff8af0a..304e1b53 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCoralFanWall.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCoralFanWall.java +++ b/net/minecraft/world/level/block/BlockCoralFanWall.java -@@ -40,6 +40,11 @@ +@@ -41,6 +41,11 @@ @Override protected void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if (!scanForWater(iblockdata, worldserver, blockposition)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch b/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch index 3eedfdef..44e06a24 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCoralPlant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockCoralPlant.java +++ b/net/minecraft/world/level/block/BlockCoralPlant.java -@@ -45,6 +45,11 @@ +@@ -46,6 +46,11 @@ @Override protected void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if (!scanForWater(iblockdata, worldserver, blockposition)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockCrops.patch b/nms-patches/net/minecraft/world/level/block/BlockCrops.patch index 92dfca5b..bf16556b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockCrops.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockCrops.patch @@ -27,12 +27,12 @@ } protected int getBonemealAgeIncrease(World world) { -@@ -160,7 +162,7 @@ - +@@ -161,7 +163,7 @@ @Override protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { -- if (entity instanceof EntityRavager && world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (entity instanceof EntityRavager && CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit - world.destroyBlock(blockposition, true, entity); + if (world instanceof WorldServer worldserver) { +- if (entity instanceof EntityRavager && worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (entity instanceof EntityRavager && CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit + worldserver.destroyBlock(blockposition, true, entity); + } } - diff --git a/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch index 6f3a7b99..1b54785c 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDiodeAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockDiodeAbstract.java +++ b/net/minecraft/world/level/block/BlockDiodeAbstract.java -@@ -21,6 +21,8 @@ +@@ -24,6 +24,8 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.ticks.TickListPriority; @@ -9,7 +9,7 @@ public abstract class BlockDiodeAbstract extends BlockFacingHorizontal { protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D); -@@ -56,8 +58,18 @@ +@@ -59,8 +61,18 @@ boolean flag1 = this.shouldTurnOn(worldserver, blockposition, iblockdata); if (flag && !flag1) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch b/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch index 6d78a69b..8b0139e0 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockDispenser.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BlockDispenser.java +++ b/net/minecraft/world/level/block/BlockDispenser.java -@@ -51,6 +51,7 @@ - object2objectopenhashmap.defaultReturnValue(BlockDispenser.DEFAULT_BEHAVIOR); - }); +@@ -52,6 +52,7 @@ + private static final DispenseBehaviorItem DEFAULT_BEHAVIOR = new DispenseBehaviorItem(); + public static final Map DISPENSER_REGISTRY = new IdentityHashMap(); private static final int TRIGGER_DURATION = 4; + public static boolean eventFired = false; // CraftBukkit @Override public MapCodec codec() { -@@ -91,7 +92,7 @@ +@@ -88,7 +89,7 @@ } public void dispenseFrom(WorldServer worldserver, IBlockData iblockdata, BlockPosition blockposition) { @@ -17,7 +17,7 @@ if (tileentitydispenser == null) { BlockDispenser.LOGGER.warn("Ignoring dispensing attempt for Dispenser without matching block entity at {}", blockposition); -@@ -107,6 +108,7 @@ +@@ -104,6 +105,7 @@ IDispenseBehavior idispensebehavior = this.getDispenseMethod(worldserver, itemstack); if (idispensebehavior != IDispenseBehavior.NOOP) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockDoor.patch b/nms-patches/net/minecraft/world/level/block/BlockDoor.patch index a6c3d841..d62163d0 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 -@@ -37,6 +37,8 @@ +@@ -39,6 +39,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,10 +9,10 @@ public class BlockDoor extends Block { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -220,9 +222,24 @@ +@@ -222,9 +224,24 @@ @Override - protected void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { + protected void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, @Nullable Orientation orientation, boolean flag) { - boolean flag1 = world.hasNeighborSignal(blockposition) || world.hasNeighborSignal(blockposition.relative(iblockdata.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN)); + // CraftBukkit start + BlockPosition otherHalf = blockposition.relative(iblockdata.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN); diff --git a/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch b/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch index 97412076..d4318f23 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockEndGateway.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/BlockEndGateway.java +++ b/net/minecraft/world/level/block/BlockEndGateway.java -@@ -21,6 +21,10 @@ - import net.minecraft.world.level.portal.DimensionTransition; +@@ -23,6 +23,10 @@ + import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start @@ -11,12 +11,12 @@ public class BlockEndGateway extends BlockTileEntity implements Portal { public static final MapCodec CODEC = simpleCodec(BlockEndGateway::new); -@@ -110,7 +114,7 @@ +@@ -112,7 +116,7 @@ if (tileentity instanceof TileEntityEndGateway tileentityendgateway) { Vec3D vec3d = tileentityendgateway.getPortalPosition(worldserver, blockposition); -- return vec3d != null ? new DimensionTransition(worldserver, vec3d, calculateExitMovement(entity), entity.getYRot(), entity.getXRot(), DimensionTransition.PLACE_PORTAL_TICKET) : null; -+ return vec3d != null ? new DimensionTransition(worldserver, vec3d, calculateExitMovement(entity), entity.getYRot(), entity.getXRot(), DimensionTransition.PLACE_PORTAL_TICKET, PlayerTeleportEvent.TeleportCause.END_GATEWAY) : null; // CraftBukkit +- return vec3d == null ? null : (entity instanceof EntityEnderPearl ? new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Set.of(), TeleportTransition.PLACE_PORTAL_TICKET) : new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Relative.union(Relative.DELTA, Relative.ROTATION), TeleportTransition.PLACE_PORTAL_TICKET)); ++ return vec3d == null ? null : (entity instanceof EntityEnderPearl ? new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Set.of(), TeleportTransition.PLACE_PORTAL_TICKET, PlayerTeleportEvent.TeleportCause.END_GATEWAY) : new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Relative.union(Relative.DELTA, Relative.ROTATION), TeleportTransition.PLACE_PORTAL_TICKET, PlayerTeleportEvent.TeleportCause.END_GATEWAY)); // CraftBukkit } else { return null; } diff --git a/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch b/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch index efe0c008..85f651ff 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockEnderPortal.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/BlockEnderPortal.java +++ b/net/minecraft/world/level/block/BlockEnderPortal.java @@ -26,6 +26,19 @@ + import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; - import net.minecraft.world.phys.shapes.VoxelShapes; +// CraftBukkit start +import java.util.List; @@ -20,10 +20,10 @@ public class BlockEnderPortal extends BlockTileEntity implements Portal { public static final MapCodec CODEC = simpleCodec(BlockEnderPortal::new); -@@ -53,6 +66,10 @@ +@@ -58,6 +71,10 @@ @Override protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (entity.canUsePortal(false) && VoxelShapes.joinIsNotEmpty(VoxelShapes.create(entity.getBoundingBox().move((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) { + if (entity.canUsePortal(false)) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getCraftServer().getPluginManager().callEvent(event); @@ -31,41 +31,41 @@ if (!world.isClientSide && world.dimension() == World.END && entity instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) entity; -@@ -69,11 +86,11 @@ +@@ -74,11 +91,11 @@ @Override - public DimensionTransition getPortalDestination(WorldServer worldserver, Entity entity, BlockPosition blockposition) { + public TeleportTransition getPortalDestination(WorldServer worldserver, Entity entity, BlockPosition blockposition) { - ResourceKey resourcekey = worldserver.dimension() == World.END ? World.OVERWORLD : World.END; + ResourceKey resourcekey = worldserver.getTypeKey() == WorldDimension.END ? World.OVERWORLD : World.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends WorldServer worldserver1 = worldserver.getServer().getLevel(resourcekey); if (worldserver1 == null) { - return null; -+ return new DimensionTransition(PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit- always fire event in case plugins wish to change it ++ return new TeleportTransition(PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit- always fire event in case plugins wish to change it } else { boolean flag = resourcekey == World.END; BlockPosition blockposition1 = flag ? WorldServer.END_SPAWN_POINT : worldserver1.getSharedSpawnPos(); -@@ -81,7 +98,7 @@ - float f = entity.getYRot(); +@@ -87,7 +104,7 @@ + Set set; if (flag) { - EndPlatformFeature.createEndPlatform(worldserver1, BlockPosition.containing(vec3d).below(), true); + EndPlatformFeature.createEndPlatform(worldserver1, BlockPosition.containing(vec3d).below(), true, entity); // CraftBukkit f = EnumDirection.WEST.toYRot(); + set = Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)); if (entity instanceof EntityPlayer) { - vec3d = vec3d.subtract(0.0D, 1.0D, 0.0D); -@@ -90,13 +107,21 @@ +@@ -99,13 +116,21 @@ if (entity instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) entity; -- return entityplayer.findRespawnPositionAndUseSpawnBlock(false, DimensionTransition.DO_NOTHING); -+ return entityplayer.findRespawnPositionAndUseSpawnBlock(false, DimensionTransition.DO_NOTHING, PlayerRespawnEvent.RespawnReason.END_PORTAL); // CraftBukkit +- return entityplayer.findRespawnPositionAndUseSpawnBlock(false, TeleportTransition.DO_NOTHING); ++ return entityplayer.findRespawnPositionAndUseSpawnBlock(false, TeleportTransition.DO_NOTHING, PlayerRespawnEvent.RespawnReason.END_PORTAL); // CraftBukkit } vec3d = entity.adjustSpawnLocation(worldserver1, blockposition1).getBottomCenter(); } -- return new DimensionTransition(worldserver1, vec3d, entity.getDeltaMovement(), f, entity.getXRot(), DimensionTransition.PLAY_PORTAL_SOUND.then(DimensionTransition.PLACE_PORTAL_TICKET)); +- return new TeleportTransition(worldserver1, vec3d, Vec3D.ZERO, f, 0.0F, set, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET)); + // CraftBukkit start + CraftPortalEvent event = entity.callPortalEvent(entity, CraftLocation.toBukkit(vec3d, worldserver1.getWorld(), f, entity.getXRot()), PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0); + if (event == null) { @@ -73,7 +73,7 @@ + } + Location to = event.getTo(); + -+ return new DimensionTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), entity.getDeltaMovement(), to.getYaw(), to.getPitch(), DimensionTransition.PLAY_PORTAL_SOUND.then(DimensionTransition.PLACE_PORTAL_TICKET), PlayerTeleportEvent.TeleportCause.END_PORTAL); ++ return new TeleportTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), entity.getDeltaMovement(), to.getYaw(), to.getPitch(), set, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET), PlayerTeleportEvent.TeleportCause.END_PORTAL); + // CraftBukkit end } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch b/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch index 9cedb877..9665e2b1 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFenceGate.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/BlockFenceGate.java +++ b/net/minecraft/world/level/block/BlockFenceGate.java -@@ -168,6 +168,17 @@ - protected void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { +@@ -173,6 +173,17 @@ + protected void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, @Nullable Orientation orientation, boolean flag) { if (!world.isClientSide) { boolean flag1 = world.hasNeighborSignal(blockposition); + // CraftBukkit start diff --git a/nms-patches/net/minecraft/world/level/block/BlockFire.patch b/nms-patches/net/minecraft/world/level/block/BlockFire.patch index a783ad8d..beab20b9 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFire.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFire.patch @@ -19,25 +19,25 @@ @@ -100,7 +109,24 @@ @Override - protected IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { -- return this.canSurvive(iblockdata, generatoraccess, blockposition) ? this.getStateWithAge(generatoraccess, blockposition, (Integer) iblockdata.getValue(BlockFire.AGE)) : Blocks.AIR.defaultBlockState(); + protected IBlockData updateShape(IBlockData iblockdata, IWorldReader iworldreader, ScheduledTickAccess scheduledtickaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition blockposition1, IBlockData iblockdata1, RandomSource randomsource) { +- return this.canSurvive(iblockdata, iworldreader, blockposition) ? this.getStateWithAge(iworldreader, blockposition, (Integer) iblockdata.getValue(BlockFire.AGE)) : Blocks.AIR.defaultBlockState(); + // CraftBukkit start -+ if (!this.canSurvive(iblockdata, generatoraccess, blockposition)) { ++ if (!this.canSurvive(iblockdata, iworldreader, blockposition)) { + // Suppress during worldgen -+ if (!(generatoraccess instanceof World)) { ++ if (!(iworldreader instanceof World world)) { + return Blocks.AIR.defaultBlockState(); + } -+ CraftBlockState blockState = CraftBlockStates.getBlockState(generatoraccess, blockposition); ++ CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockposition); + blockState.setData(Blocks.AIR.defaultBlockState()); + + BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState); -+ ((World) generatoraccess).getCraftServer().getPluginManager().callEvent(event); ++ world.getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + return blockState.getHandle(); + } + } -+ return this.getStateWithAge(generatoraccess, blockposition, (Integer) iblockdata.getValue(BlockFire.AGE)); ++ return this.getStateWithAge(iworldreader, blockposition, (Integer) iblockdata.getValue(BlockFire.AGE)); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch b/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch index 7e7020ba..639176c4 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFireAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFireAbstract.java +++ b/net/minecraft/world/level/block/BlockFireAbstract.java -@@ -19,6 +19,10 @@ +@@ -20,6 +20,10 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -11,10 +11,10 @@ public abstract class BlockFireAbstract extends Block { private static final int SECONDS_ON_FIRE = 8; -@@ -127,7 +131,14 @@ - if (!entity.fireImmune()) { - entity.setRemainingFireTicks(entity.getRemainingFireTicks() + 1); - if (entity.getRemainingFireTicks() == 0) { +@@ -137,7 +141,14 @@ + } + + if (entity.getRemainingFireTicks() >= 0) { - entity.igniteForSeconds(8.0F); + // CraftBukkit start + org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition), entity.getBukkitEntity(), 8.0F); @@ -27,7 +27,7 @@ } } -@@ -136,26 +147,26 @@ +@@ -146,26 +157,26 @@ } @Override @@ -38,8 +38,8 @@ Optional optional = BlockPortalShape.findEmptyPortalShape(world, blockposition, EnumDirection.EnumAxis.X); if (optional.isPresent()) { -- ((BlockPortalShape) optional.get()).createPortalBlocks(); -+ ((BlockPortalShape) optional.get()).createPortalBlocks((context == null) ? null : context.getPlayer()); // CraftBukkit - player +- ((BlockPortalShape) optional.get()).createPortalBlocks(world); ++ ((BlockPortalShape) optional.get()).createPortalBlocks(world, (context == null) ? null : context.getPlayer()); // CraftBukkit - player return; } } @@ -58,7 +58,7 @@ } @Override -@@ -203,4 +214,12 @@ +@@ -213,4 +224,12 @@ } } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockFluids.patch b/nms-patches/net/minecraft/world/level/block/BlockFluids.patch index addd5dfa..db927b8c 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockFluids.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockFluids.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockFluids.java +++ b/net/minecraft/world/level/block/BlockFluids.java -@@ -39,7 +39,7 @@ +@@ -42,7 +42,7 @@ public class BlockFluids extends Block implements IFluidSource { private static final Codec FLOWING_FLUID = BuiltInRegistries.FLUID.byNameCodec().comapFlatMap((fluidtype) -> { @@ -9,7 +9,7 @@ if (fluidtype instanceof FluidTypeFlowing fluidtypeflowing) { dataresult = DataResult.success(fluidtypeflowing); -@@ -172,14 +172,20 @@ +@@ -175,14 +175,20 @@ if (world.getFluidState(blockposition1).is(TagsFluid.WATER)) { Block block = world.getFluidState(blockposition).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; diff --git a/nms-patches/net/minecraft/world/level/block/BlockIce.patch b/nms-patches/net/minecraft/world/level/block/BlockIce.patch index 7164cce2..4c22d943 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockIce.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockIce.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockIce.java +++ b/net/minecraft/world/level/block/BlockIce.java -@@ -59,6 +59,11 @@ +@@ -60,6 +60,11 @@ } protected void melt(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch b/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch index c3ca72ab..31ae1d48 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLeaves.java +++ b/net/minecraft/world/level/block/BlockLeaves.java -@@ -25,6 +25,8 @@ +@@ -27,6 +27,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -9,7 +9,7 @@ public class BlockLeaves extends Block implements IBlockWaterlogged { public static final MapCodec CODEC = simpleCodec(BlockLeaves::new); -@@ -57,6 +59,14 @@ +@@ -59,6 +61,14 @@ @Override protected void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if (this.decaying(iblockdata)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockLectern.patch b/nms-patches/net/minecraft/world/level/block/BlockLectern.patch index 645c4d73..2e2f29d8 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockLectern.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLectern.java +++ b/net/minecraft/world/level/block/BlockLectern.java -@@ -208,11 +208,12 @@ +@@ -211,11 +211,12 @@ } private void popBook(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockLever.patch b/nms-patches/net/minecraft/world/level/block/BlockLever.patch index 19b55014..32219f93 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockLever.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockLever.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockLever.java +++ b/net/minecraft/world/level/block/BlockLever.java -@@ -29,6 +29,8 @@ +@@ -32,6 +32,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,9 +9,9 @@ public class BlockLever extends BlockAttachable { public static final MapCodec CODEC = simpleCodec(BlockLever::new); -@@ -101,6 +103,20 @@ - - return EnumInteractionResult.SUCCESS; +@@ -102,6 +104,20 @@ + makeParticle(iblockdata1, world, blockposition, 1.0F); + } } else { + // CraftBukkit start - Interact Lever + boolean powered = iblockdata.getValue(BlockLever.POWERED); // Old powered state @@ -28,5 +28,5 @@ + // CraftBukkit end + this.pull(iblockdata, world, blockposition, (EntityHuman) null); - return EnumInteractionResult.CONSUME; } + diff --git a/nms-patches/net/minecraft/world/level/block/BlockMagma.patch b/nms-patches/net/minecraft/world/level/block/BlockMagma.patch index 708bbfa8..8c863e49 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMagma.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMagma.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockMagma.java +++ b/net/minecraft/world/level/block/BlockMagma.java -@@ -29,7 +29,7 @@ +@@ -30,7 +30,7 @@ @Override public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { if (!entity.isSteppingCarefully() && entity instanceof EntityLiving) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch b/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch index 0abacadd..0029fbfc 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMinecartDetector.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/BlockMinecartDetector.java +++ b/net/minecraft/world/level/block/BlockMinecartDetector.java -@@ -26,6 +26,8 @@ - import net.minecraft.world.level.block.state.properties.IBlockState; +@@ -27,6 +27,8 @@ + import net.minecraft.world.level.redstone.Orientation; import net.minecraft.world.phys.AxisAlignedBB; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit @@ -9,7 +9,7 @@ public class BlockMinecartDetector extends BlockMinecartTrackAbstract { public static final MapCodec CODEC = simpleCodec(BlockMinecartDetector::new); -@@ -87,6 +89,16 @@ +@@ -88,6 +90,16 @@ } IBlockData iblockdata1; diff --git a/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch b/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch index d77107fa..894857de 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockMonsterEggs.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockMonsterEggs.java +++ b/net/minecraft/world/level/block/BlockMonsterEggs.java -@@ -19,6 +19,8 @@ +@@ -20,6 +20,8 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.block.state.properties.IBlockState; @@ -9,7 +9,7 @@ public class BlockMonsterEggs extends Block { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -53,7 +55,7 @@ +@@ -54,7 +56,7 @@ if (entitysilverfish != null) { entitysilverfish.moveTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); diff --git a/nms-patches/net/minecraft/world/level/block/BlockNote.patch b/nms-patches/net/minecraft/world/level/block/BlockNote.patch index 6fa81248..74c8339f 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockNote.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockNote.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockNote.java +++ b/net/minecraft/world/level/block/BlockNote.java -@@ -83,6 +83,7 @@ +@@ -85,6 +85,7 @@ if (flag1 != (Boolean) iblockdata.getValue(BlockNote.POWERED)) { if (flag1) { this.playNote((Entity) null, iblockdata, world, blockposition); @@ -8,7 +8,7 @@ } world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockNote.POWERED, flag1), 3); -@@ -92,6 +93,12 @@ +@@ -94,6 +95,12 @@ private void playNote(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { if (((BlockPropertyInstrument) iblockdata.getValue(BlockNote.INSTRUMENT)).worksAboveNoteBlock() || world.getBlockState(blockposition.above()).isAir()) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockObserver.patch b/nms-patches/net/minecraft/world/level/block/BlockObserver.patch index 3db9cb18..b76c2f04 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockObserver.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockObserver.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockObserver.java +++ b/net/minecraft/world/level/block/BlockObserver.java -@@ -15,6 +15,8 @@ - import net.minecraft.world.level.block.state.properties.BlockProperties; - import net.minecraft.world.level.block.state.properties.BlockStateBoolean; +@@ -18,6 +18,8 @@ + import net.minecraft.world.level.redstone.ExperimentalRedstoneUtils; + import net.minecraft.world.level.redstone.Orientation; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockObserver extends BlockDirectional { public static final MapCodec CODEC = simpleCodec(BlockObserver::new); -@@ -48,8 +50,18 @@ +@@ -51,8 +53,18 @@ @Override protected void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if ((Boolean) iblockdata.getValue(BlockObserver.POWERED)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockPlant.patch b/nms-patches/net/minecraft/world/level/block/BlockPlant.patch index c7ded855..274403a3 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPlant.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPlant.patch @@ -1,17 +1,29 @@ --- a/net/minecraft/world/level/block/BlockPlant.java +++ b/net/minecraft/world/level/block/BlockPlant.java -@@ -26,7 +26,14 @@ +@@ -12,6 +12,10 @@ + import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.pathfinder.PathMode; + ++// CraftBukkit start ++import net.minecraft.world.level.World; ++// CraftBukkit end ++ + public abstract class BlockPlant extends Block { + + protected BlockPlant(BlockBase.Info blockbase_info) { +@@ -27,7 +31,15 @@ @Override - protected IBlockData updateShape(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { -- return !iblockdata.canSurvive(generatoraccess, blockposition) ? Blocks.AIR.defaultBlockState() : super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + protected IBlockData updateShape(IBlockData iblockdata, IWorldReader iworldreader, ScheduledTickAccess scheduledtickaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition blockposition1, IBlockData iblockdata1, RandomSource randomsource) { +- return !iblockdata.canSurvive(iworldreader, blockposition) ? Blocks.AIR.defaultBlockState() : super.updateShape(iblockdata, iworldreader, scheduledtickaccess, blockposition, enumdirection, blockposition1, iblockdata1, randomsource); + // CraftBukkit start -+ if (!iblockdata.canSurvive(generatoraccess, blockposition)) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(generatoraccess, blockposition).isCancelled()) { ++ if (!iblockdata.canSurvive(iworldreader, blockposition)) { ++ // Suppress during worldgen ++ if (!(iworldreader instanceof World world) || !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) { + return Blocks.AIR.defaultBlockState(); + } + } -+ return super.updateShape(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); ++ return super.updateShape(iblockdata, iworldreader, scheduledtickaccess, blockposition, enumdirection, blockposition1, iblockdata1, randomsource); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/level/block/BlockPortal.patch b/nms-patches/net/minecraft/world/level/block/BlockPortal.patch index 0c279c6e..70f5f61d 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 -@@ -38,6 +38,15 @@ +@@ -39,6 +39,15 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import org.slf4j.Logger; @@ -16,17 +16,17 @@ public class BlockPortal extends Block implements Portal { public static final MapCodec CODEC = simpleCodec(BlockPortal::new); -@@ -76,7 +85,8 @@ +@@ -77,7 +86,8 @@ } if (worldserver.getBlockState(blockposition).isValidSpawn(worldserver, blockposition, EntityTypes.ZOMBIFIED_PIGLIN)) { -- Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(worldserver, blockposition.above(), EnumMobSpawn.STRUCTURE); +- Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(worldserver, blockposition.above(), EntitySpawnReason.STRUCTURE); + // CraftBukkit - set spawn reason to NETHER_PORTAL -+ Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(worldserver, blockposition.above(), EnumMobSpawn.STRUCTURE, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); ++ Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawn(worldserver, blockposition.above(), EntitySpawnReason.STRUCTURE, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); if (entity != null) { entity.setPortalCooldown(); -@@ -98,6 +108,10 @@ +@@ -104,6 +114,10 @@ @Override protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { if (entity.canUsePortal(false)) { @@ -37,10 +37,10 @@ entity.setAsInsidePortal(this, blockposition); } -@@ -115,24 +129,34 @@ +@@ -121,24 +135,34 @@ @Nullable @Override - public DimensionTransition getPortalDestination(WorldServer worldserver, Entity entity, BlockPosition blockposition) { + public TeleportTransition getPortalDestination(WorldServer worldserver, Entity entity, BlockPosition blockposition) { - ResourceKey resourcekey = worldserver.dimension() == World.NETHER ? World.OVERWORLD : World.NETHER; + // CraftBukkit start + ResourceKey resourcekey = worldserver.getTypeKey() == WorldDimension.NETHER ? World.OVERWORLD : World.NETHER; @@ -48,7 +48,7 @@ if (worldserver1 == null) { - return null; -+ return new DimensionTransition(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); // always fire event in case plugins wish to change it ++ return new TeleportTransition(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); // always fire event in case plugins wish to change it } else { - boolean flag = worldserver1.dimension() == World.NETHER; + boolean flag = worldserver1.getTypeKey() == WorldDimension.NETHER; @@ -71,15 +71,15 @@ } @Nullable -- private DimensionTransition getExitPortal(WorldServer worldserver, Entity entity, BlockPosition blockposition, BlockPosition blockposition1, boolean flag, WorldBorder worldborder) { +- private TeleportTransition getExitPortal(WorldServer worldserver, Entity entity, BlockPosition blockposition, BlockPosition blockposition1, boolean flag, WorldBorder worldborder) { - Optional optional = worldserver.getPortalForcer().findClosestPortalPosition(blockposition1, flag, worldborder); -+ private DimensionTransition getExitPortal(WorldServer worldserver, Entity entity, BlockPosition blockposition, BlockPosition blockposition1, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { ++ private TeleportTransition getExitPortal(WorldServer worldserver, Entity entity, BlockPosition blockposition, BlockPosition blockposition1, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { + Optional optional = worldserver.getPortalForcer().findClosestPortalPosition(blockposition1, worldborder, searchRadius); BlockUtil.Rectangle blockutil_rectangle; - DimensionTransition.a dimensiontransition_a; + TeleportTransition.a teleporttransition_a; -@@ -146,17 +170,22 @@ - dimensiontransition_a = DimensionTransition.PLAY_PORTAL_SOUND.then((entity1) -> { +@@ -152,17 +176,22 @@ + teleporttransition_a = TeleportTransition.PLAY_PORTAL_SOUND.then((entity1) -> { entity1.placePortalTicket(blockposition2); }); - } else { @@ -96,20 +96,20 @@ } blockutil_rectangle = (BlockUtil.Rectangle) optional1.get(); - dimensiontransition_a = DimensionTransition.PLAY_PORTAL_SOUND.then(DimensionTransition.PLACE_PORTAL_TICKET); + teleporttransition_a = TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET); + // CraftBukkit start + } else { + return null; + // CraftBukkit end } - return getDimensionTransitionFromExit(entity, blockposition, blockutil_rectangle, worldserver, dimensiontransition_a); -@@ -198,7 +227,7 @@ - Vec3D vec3d3 = new Vec3D((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2)); - Vec3D vec3d4 = BlockPortalShape.findCollisionFreePosition(vec3d3, worldserver, entity, entitysize); + return getDimensionTransitionFromExit(entity, blockposition, blockutil_rectangle, worldserver, teleporttransition_a); +@@ -203,7 +232,7 @@ + Vec3D vec3d1 = new Vec3D((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2)); + Vec3D vec3d2 = BlockPortalShape.findCollisionFreePosition(vec3d1, worldserver, entity, entitysize); -- return new DimensionTransition(worldserver, vec3d4, vec3d2, f + (float) i, f1, dimensiontransition_a); -+ return new DimensionTransition(worldserver, vec3d4, vec3d2, f + (float) i, f1, dimensiontransition_a, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); // CraftBukkit +- return new TeleportTransition(worldserver, vec3d2, Vec3D.ZERO, (float) i, 0.0F, Relative.union(Relative.DELTA, Relative.ROTATION), teleporttransition_a); ++ return new TeleportTransition(worldserver, vec3d2, Vec3D.ZERO, (float) i, 0.0F, Relative.union(Relative.DELTA, Relative.ROTATION), teleporttransition_a, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); // CraftBukkit } @Override diff --git a/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch b/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch index 96b33886..2870194e 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPoweredRail.patch @@ -22,4 +22,4 @@ + // CraftBukkit end world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockPoweredRail.POWERED, flag1), 3); world.updateNeighborsAt(blockposition.below(), this); - if (((BlockPropertyTrackPosition) iblockdata.getValue(BlockPoweredRail.SHAPE)).isAscending()) { + if (((BlockPropertyTrackPosition) iblockdata.getValue(BlockPoweredRail.SHAPE)).isSlope()) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch b/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch index 82f7a792..c7033e7a 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockPumpkinCarved.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/BlockPumpkinCarved.java +++ b/net/minecraft/world/level/block/BlockPumpkinCarved.java -@@ -24,6 +24,10 @@ +@@ -25,6 +25,10 @@ import net.minecraft.world.level.block.state.predicate.BlockStatePredicate; - import net.minecraft.world.level.block.state.properties.BlockStateDirection; + import net.minecraft.world.level.block.state.properties.BlockStateEnum; +// CraftBukkit start +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; @@ -11,7 +11,7 @@ public class BlockPumpkinCarved extends BlockFacingHorizontal { public static final MapCodec CODEC = simpleCodec(BlockPumpkinCarved::new); -@@ -86,9 +90,14 @@ +@@ -87,9 +91,14 @@ } private static void spawnGolemInWorld(World world, ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection, Entity entity, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch index 79f53d0f..dc9826b6 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRedstoneComparator.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockRedstoneComparator.java +++ b/net/minecraft/world/level/block/BlockRedstoneComparator.java -@@ -27,6 +27,8 @@ +@@ -28,6 +28,8 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.ticks.TickListPriority; @@ -9,7 +9,7 @@ public class BlockRedstoneComparator extends BlockDiodeAbstract implements ITileEntity { public static final MapCodec CODEC = simpleCodec(BlockRedstoneComparator::new); -@@ -109,7 +111,8 @@ +@@ -110,7 +112,8 @@ @Nullable private EntityItemFrame getItemFrame(World world, EnumDirection enumdirection, BlockPosition blockposition) { @@ -19,7 +19,7 @@ return entityitemframe != null && entityitemframe.getDirection() == enumdirection; }); -@@ -162,8 +165,18 @@ +@@ -163,8 +166,18 @@ boolean flag1 = (Boolean) iblockdata.getValue(BlockRedstoneComparator.POWERED); if (flag1 && !flag) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch index dce344c8..c90e0052 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRedstoneLamp.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockRedstoneLamp.java +++ b/net/minecraft/world/level/block/BlockRedstoneLamp.java -@@ -12,6 +12,8 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -13,6 +13,8 @@ import net.minecraft.world.level.block.state.properties.BlockStateBoolean; + import net.minecraft.world.level.redstone.Orientation; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockRedstoneLamp extends Block { public static final MapCodec CODEC = simpleCodec(BlockRedstoneLamp::new); -@@ -42,6 +44,11 @@ +@@ -43,6 +45,11 @@ if (flag1) { world.scheduleTick(blockposition, (Block) this, 4); } else { @@ -21,7 +21,7 @@ world.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockRedstoneLamp.LIT), 2); } } -@@ -52,6 +59,11 @@ +@@ -53,6 +60,11 @@ @Override protected void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) { if ((Boolean) iblockdata.getValue(BlockRedstoneLamp.LIT) && !worldserver.hasNeighborSignal(blockposition)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch index cb76dcb3..1bd1a91b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRedstoneOre.patch @@ -50,7 +50,7 @@ + interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman } - return itemstack.getItem() instanceof ItemBlock && (new BlockActionContext(entityhuman, enumhand, itemstack, movingobjectpositionblock)).canPlace() ? ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION : ItemInteractionResult.SUCCESS; + return (EnumInteractionResult) (itemstack.getItem() instanceof ItemBlock && (new BlockActionContext(entityhuman, enumhand, itemstack, movingobjectpositionblock)).canPlace() ? EnumInteractionResult.PASS : EnumInteractionResult.SUCCESS); } - private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch index e6c3fb38..8d82d103 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRedstoneTorch.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/BlockRedstoneTorch.java +++ b/net/minecraft/world/level/block/BlockRedstoneTorch.java -@@ -19,6 +19,8 @@ - import net.minecraft.world.level.block.state.properties.BlockProperties; - import net.minecraft.world.level.block.state.properties.BlockStateBoolean; +@@ -22,6 +22,8 @@ + import net.minecraft.world.level.redstone.ExperimentalRedstoneUtils; + import net.minecraft.world.level.redstone.Orientation; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + diff --git a/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch b/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch deleted file mode 100644 index 40407a28..00000000 --- a/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/minecraft/world/level/block/BlockRedstoneWire.java -+++ b/net/minecraft/world/level/block/BlockRedstoneWire.java -@@ -36,6 +36,8 @@ - import net.minecraft.world.phys.shapes.VoxelShapeCollision; - import net.minecraft.world.phys.shapes.VoxelShapes; - -+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit -+ - public class BlockRedstoneWire extends Block { - - public static final MapCodec CODEC = simpleCodec(BlockRedstoneWire::new); -@@ -260,7 +262,16 @@ - private void updatePowerStrength(World world, BlockPosition blockposition, IBlockData iblockdata) { - int i = this.calculateTargetStrength(world, blockposition); - -- if ((Integer) iblockdata.getValue(BlockRedstoneWire.POWER) != i) { -+ // CraftBukkit start -+ int oldPower = (Integer) iblockdata.getValue(BlockRedstoneWire.POWER); -+ if (oldPower != i) { -+ BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), oldPower, i); -+ world.getCraftServer().getPluginManager().callEvent(event); -+ -+ i = event.getNewCurrent(); -+ } -+ if (oldPower != i) { -+ // CraftBukkit end - if (world.getBlockState(blockposition) == iblockdata) { - world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneWire.POWER, i), 2); - } diff --git a/nms-patches/net/minecraft/world/level/block/BlockRespawnAnchor.patch b/nms-patches/net/minecraft/world/level/block/BlockRespawnAnchor.patch index 30a49ff4..3dc1bbb4 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockRespawnAnchor.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockRespawnAnchor.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockRespawnAnchor.java +++ b/net/minecraft/world/level/block/BlockRespawnAnchor.java -@@ -89,7 +89,7 @@ +@@ -88,7 +88,7 @@ EntityPlayer entityplayer = (EntityPlayer) entityhuman; if (entityplayer.getRespawnDimension() != world.dimension() || !blockposition.equals(entityplayer.getRespawnPosition())) { - entityplayer.setRespawnPosition(world.dimension(), blockposition, 0.0F, false, true); + entityplayer.setRespawnPosition(world.dimension(), blockposition, 0.0F, false, true, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.RESPAWN_ANCHOR); // CraftBukkit world.playSound((EntityHuman) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, SoundEffects.RESPAWN_ANCHOR_SET_SPAWN, SoundCategory.BLOCKS, 1.0F, 1.0F); - return EnumInteractionResult.SUCCESS; + return EnumInteractionResult.SUCCESS_SERVER; } -@@ -128,15 +128,16 @@ +@@ -127,15 +127,16 @@ } private void explode(IBlockData iblockdata, World world, final BlockPosition blockposition) { @@ -28,7 +28,7 @@ @Override public Optional getBlockExplosionResistance(Explosion explosion, IBlockAccess iblockaccess, BlockPosition blockposition1, IBlockData iblockdata1, Fluid fluid) { return blockposition1.equals(blockposition) && flag1 ? Optional.of(Blocks.WATER.getExplosionResistance()) : super.getBlockExplosionResistance(explosion, iblockaccess, blockposition1, iblockdata1, fluid); -@@ -144,7 +145,7 @@ +@@ -143,7 +144,7 @@ }; Vec3D vec3d = blockposition.getCenter(); diff --git a/nms-patches/net/minecraft/world/level/block/BlockSign.patch b/nms-patches/net/minecraft/world/level/block/BlockSign.patch index bd27f5de..677b87be 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSign.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSign.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BlockSign.java +++ b/net/minecraft/world/level/block/BlockSign.java -@@ -139,7 +139,7 @@ +@@ -140,7 +140,7 @@ } else if (flag1) { - return EnumInteractionResult.SUCCESS; + return EnumInteractionResult.SUCCESS_SERVER; } else if (!this.otherPlayerIsEditingSign(entityhuman, tileentitysign) && entityhuman.mayBuild() && this.hasEditableText(entityhuman, tileentitysign, flag)) { - this.openTextEdit(entityhuman, tileentitysign, flag); + this.openTextEdit(entityhuman, tileentitysign, flag, org.bukkit.event.player.PlayerSignOpenEvent.Cause.INTERACT); // CraftBukkit - return EnumInteractionResult.SUCCESS; + return EnumInteractionResult.SUCCESS_SERVER; } else { return EnumInteractionResult.PASS; -@@ -185,6 +185,15 @@ +@@ -186,6 +186,15 @@ } public void openTextEdit(EntityHuman entityhuman, TileEntitySign tileentitysign, boolean flag) { @@ -25,7 +25,7 @@ tileentitysign.setAllowedPlayerEditor(entityhuman.getUUID()); entityhuman.openTextEdit(tileentitysign, flag); } -@@ -198,6 +207,6 @@ +@@ -199,6 +208,6 @@ @Nullable @Override public BlockEntityTicker getTicker(World world, IBlockData iblockdata, TileEntityTypes tileentitytypes) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockSoil.patch b/nms-patches/net/minecraft/world/level/block/BlockSoil.patch index fb1d9e8f..4f6c91e2 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSoil.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSoil.patch @@ -12,7 +12,7 @@ public class BlockSoil extends Block { public static final MapCodec CODEC = simpleCodec(BlockSoil::new); -@@ -92,26 +97,49 @@ +@@ -92,28 +97,51 @@ if (!isNearWater(worldserver, blockposition) && !worldserver.isRainingAt(blockposition.above())) { if (i > 0) { @@ -31,25 +31,27 @@ @Override public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) { + super.fallOn(world, iblockdata, blockposition, entity, f); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage. - if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) { -+ // CraftBukkit start - Interact soil -+ org.bukkit.event.Cancellable cancellable; -+ if (entity instanceof EntityHuman) { -+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null); -+ } else { -+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); -+ world.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); -+ } + if (world instanceof WorldServer worldserver) { + if (world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) { ++ // CraftBukkit start - Interact soil ++ org.bukkit.event.Cancellable cancellable; ++ if (entity instanceof EntityHuman) { ++ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null); ++ } else { ++ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); ++ world.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); ++ } + -+ if (cancellable.isCancelled()) { -+ return; -+ } ++ if (cancellable.isCancelled()) { ++ return; ++ } + -+ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.defaultBlockState())) { -+ return; -+ } -+ // CraftBukkit end - turnToDirt(entity, iblockdata, world, blockposition); ++ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.defaultBlockState())) { ++ return; ++ } ++ // CraftBukkit end + turnToDirt(entity, iblockdata, world, blockposition); + } } - super.fallOn(world, iblockdata, blockposition, entity, f); diff --git a/nms-patches/net/minecraft/world/level/block/BlockSponge.patch b/nms-patches/net/minecraft/world/level/block/BlockSponge.patch index ae282d29..cb7d20fd 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockSponge.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockSponge.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/BlockSponge.java +++ b/net/minecraft/world/level/block/BlockSponge.java -@@ -13,6 +13,13 @@ - import net.minecraft.world.level.block.state.IBlockData; +@@ -15,6 +15,13 @@ import net.minecraft.world.level.material.Fluid; + import net.minecraft.world.level.redstone.Orientation; +// CraftBukkit start +import java.util.List; @@ -14,7 +14,7 @@ public class BlockSponge extends Block { public static final MapCodec CODEC = simpleCodec(BlockSponge::new); -@@ -51,7 +58,8 @@ +@@ -53,7 +60,8 @@ } private boolean removeWaterBreadthFirstSearch(World world, BlockPosition blockposition) { @@ -24,7 +24,7 @@ EnumDirection[] aenumdirection = BlockSponge.ALL_DIRECTIONS; int i = aenumdirection.length; -@@ -65,8 +73,10 @@ +@@ -67,8 +75,10 @@ if (blockposition1.equals(blockposition)) { return true; } else { @@ -37,7 +37,7 @@ if (!fluid.is(TagsFluid.WATER)) { return false; -@@ -76,27 +86,64 @@ +@@ -78,27 +88,64 @@ if (block instanceof IFluidSource) { IFluidSource ifluidsource = (IFluidSource) block; diff --git a/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch b/nms-patches/net/minecraft/world/level/block/BlockSweetBerryBush.patch index e3d7501e..a2a2f314 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 -@@ -30,6 +30,13 @@ +@@ -29,6 +29,13 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -14,7 +14,7 @@ public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement { public static final MapCodec CODEC = simpleCodec(BlockSweetBerryBush::new); -@@ -71,7 +78,7 @@ +@@ -70,7 +77,7 @@ if (i < 3 && randomsource.nextInt(5) == 0 && worldserver.getRawBrightness(blockposition.above(), 0) >= 9) { IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, i + 1); @@ -23,16 +23,16 @@ worldserver.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); } -@@ -86,7 +93,7 @@ - double d1 = Math.abs(entity.getZ() - entity.zOld); +@@ -91,7 +98,7 @@ + double d1 = Math.abs(vec3d.z()); - if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { -- entity.hurt(world.damageSources().sweetBerryBush(), 1.0F); -+ entity.hurt(world.damageSources().sweetBerryBush().directBlock(world, blockposition), 1.0F); // CraftBukkit - } - } + if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { +- entity.hurtServer(worldserver, world.damageSources().sweetBerryBush(), 1.0F); ++ entity.hurtServer(worldserver, world.damageSources().sweetBerryBush().directBlock(world, blockposition), 1.0F); // CraftBukkit + } + } -@@ -109,7 +116,15 @@ +@@ -118,7 +125,15 @@ if (i > 1) { int j = 1 + world.random.nextInt(2); diff --git a/nms-patches/net/minecraft/world/level/block/BlockTNT.patch b/nms-patches/net/minecraft/world/level/block/BlockTNT.patch index a01659be..9c744572 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTNT.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTNT.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/BlockTNT.java +++ b/net/minecraft/world/level/block/BlockTNT.java -@@ -27,6 +27,11 @@ - import net.minecraft.world.level.gameevent.GameEvent; +@@ -29,6 +29,11 @@ + import net.minecraft.world.level.redstone.Orientation; import net.minecraft.world.phys.MovingObjectPositionBlock; +// CraftBukkit start @@ -12,7 +12,7 @@ public class BlockTNT extends Block { public static final MapCodec CODEC = simpleCodec(BlockTNT::new); -@@ -45,7 +50,7 @@ +@@ -47,7 +52,7 @@ @Override protected void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) { if (!iblockdata1.is(iblockdata.getBlock())) { @@ -21,16 +21,16 @@ explode(world, blockposition); world.removeBlock(blockposition, false); } -@@ -55,7 +60,7 @@ +@@ -57,7 +62,7 @@ @Override - protected void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { + protected void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, @Nullable Orientation orientation, boolean flag) { - if (world.hasNeighborSignal(blockposition)) { -+ if (world.hasNeighborSignal(blockposition) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.REDSTONE, null, blockposition1)) { // CraftBukkit - TNTPrimeEvent ++ if (world.hasNeighborSignal(blockposition) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent explode(world, blockposition); world.removeBlock(blockposition, false); } -@@ -64,7 +69,7 @@ +@@ -66,7 +71,7 @@ @Override public IBlockData playerWillDestroy(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { @@ -45,7 +45,7 @@ } else { + // CraftBukkit start - TNTPrimeEvent + if (!CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PLAYER, entityhuman, null)) { -+ return ItemInteractionResult.CONSUME; ++ return EnumInteractionResult.CONSUME; + } + // CraftBukkit end explode(world, blockposition, entityhuman); @@ -54,7 +54,7 @@ @@ -123,6 +133,11 @@ Entity entity = iprojectile.getOwner(); - if (iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition)) { + if (iprojectile.isOnFire() && iprojectile.mayInteract(worldserver, blockposition)) { + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState()) || !CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PROJECTILE, iprojectile, null)) { + return; diff --git a/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch b/nms-patches/net/minecraft/world/level/block/BlockTallPlant.patch index 975c3049..af55991d 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 -@@ -101,6 +101,11 @@ +@@ -103,6 +103,11 @@ } protected static void preventDropFromBottomPart(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 fb5c64d9..f9c7facd 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 -@@ -34,6 +34,8 @@ +@@ -38,6 +38,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 MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -139,6 +141,19 @@ +@@ -143,6 +145,19 @@ boolean flag1 = world.hasNeighborSignal(blockposition); if (flag1 != (Boolean) iblockdata.getValue(BlockTrapdoor.POWERED)) { diff --git a/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch b/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch index c611141f..bc230018 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTripwire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTripwire.java +++ b/net/minecraft/world/level/block/BlockTripwire.java -@@ -28,6 +28,8 @@ +@@ -29,6 +29,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -9,7 +9,7 @@ public class BlockTripwire extends Block { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -167,6 +169,40 @@ +@@ -179,6 +181,40 @@ } } diff --git a/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch b/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch index a05ad280..01475895 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTripwireHook.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTripwireHook.java +++ b/net/minecraft/world/level/block/BlockTripwireHook.java -@@ -30,6 +30,11 @@ +@@ -32,6 +32,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -12,7 +12,7 @@ public class BlockTripwireHook extends Block { public static final MapCodec CODEC = simpleCodec(BlockTripwireHook::new); -@@ -174,6 +179,15 @@ +@@ -176,6 +181,15 @@ emitState(world, blockposition1, flag4, flag5, flag2, flag3); } diff --git a/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch b/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch index 7b3381fc..f9aedfa8 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockTurtleEgg.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockTurtleEgg.java +++ b/net/minecraft/world/level/block/BlockTurtleEgg.java -@@ -31,6 +31,12 @@ +@@ -32,6 +32,12 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; @@ -13,27 +13,27 @@ public class BlockTurtleEgg extends Block { public static final MapCodec CODEC = simpleCodec(BlockTurtleEgg::new); -@@ -73,6 +79,19 @@ +@@ -74,6 +80,19 @@ private void destroyEgg(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, int i) { - if (this.canDestroyEgg(world, entity)) { - if (!world.isClientSide && world.random.nextInt(i) == 0 && iblockdata.is(Blocks.TURTLE_EGG)) { + if (iblockdata.is(Blocks.TURTLE_EGG) && world instanceof WorldServer worldserver) { + if (this.canDestroyEgg(worldserver, entity) && world.random.nextInt(i) == 0) { + // CraftBukkit start - Step on eggs + org.bukkit.event.Cancellable cancellable; + if (entity instanceof EntityHuman) { + cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null); + } else { -+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), CraftBlock.at(world, blockposition)); -+ world.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); ++ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), CraftBlock.at(worldserver, blockposition)); ++ worldserver.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); + } + + if (cancellable.isCancelled()) { + return; + } + // CraftBukkit end - this.decreaseEggs(world, blockposition, iblockdata); + this.decreaseEggs(worldserver, blockposition, iblockdata); } - -@@ -99,10 +118,20 @@ + } +@@ -100,10 +119,20 @@ int i = (Integer) iblockdata.getValue(BlockTurtleEgg.HATCH); if (i < 2) { @@ -55,7 +55,7 @@ worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + randomsource.nextFloat() * 0.2F); worldserver.removeBlock(blockposition, false); worldserver.gameEvent((Holder) GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(iblockdata)); -@@ -115,7 +144,7 @@ +@@ -116,7 +145,7 @@ entityturtle.setAge(-24000); entityturtle.setHomePos(blockposition); entityturtle.moveTo((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F); diff --git a/nms-patches/net/minecraft/world/level/block/BlockVine.patch b/nms-patches/net/minecraft/world/level/block/BlockVine.patch index 907a641f..7ebaef3b 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockVine.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockVine.patch @@ -44,7 +44,7 @@ } } else { - if (enumdirection == EnumDirection.UP && blockposition.getY() < worldserver.getMaxBuildHeight() - 1) { + if (enumdirection == EnumDirection.UP && blockposition.getY() < worldserver.getMaxY()) { if (this.canSupportAtFace(worldserver, blockposition, enumdirection)) { - worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockVine.UP, true), 2); + CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(BlockVine.UP, true), 2); // CraftBukkit diff --git a/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch b/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch index 9251f6af..6423b8bb 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch @@ -14,7 +14,7 @@ @@ -32,6 +36,11 @@ protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { super.entityInside(iblockdata, world, blockposition, entity); - if (world instanceof WorldServer && entity instanceof EntityBoat) { + if (world instanceof WorldServer && entity instanceof AbstractBoat) { + // CraftBukkit start + if (!CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState())) { + return; diff --git a/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch b/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch index e3999a62..355fb68c 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/BlockWitherRose.java +++ b/net/minecraft/world/level/block/BlockWitherRose.java -@@ -67,7 +67,7 @@ - EntityLiving entityliving = (EntityLiving) entity; - - if (!entityliving.isInvulnerableTo(world.damageSources().wither())) { +@@ -66,7 +66,7 @@ + if (world instanceof WorldServer worldserver) { + if (world.getDifficulty() != EnumDifficulty.PEACEFUL && entity instanceof EntityLiving entityliving) { + if (!entityliving.isInvulnerableTo(worldserver, world.damageSources().wither())) { - entityliving.addEffect(new MobEffect(MobEffects.WITHER, 40)); + entityliving.addEffect(new MobEffect(MobEffects.WITHER, 40), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.WITHER_ROSE); // CraftBukkit } } - + } diff --git a/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch b/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch index 780efc1b..099a259f 100644 --- a/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch +++ b/nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BlockWitherSkull.java +++ b/net/minecraft/world/level/block/BlockWitherSkull.java -@@ -25,6 +25,10 @@ +@@ -26,6 +26,10 @@ import net.minecraft.world.level.block.state.pattern.ShapeDetectorBuilder; import net.minecraft.world.level.block.state.predicate.BlockStatePredicate; @@ -11,7 +11,7 @@ public class BlockWitherSkull extends BlockSkull { public static final MapCodec CODEC = simpleCodec(BlockWitherSkull::new); -@@ -57,6 +61,7 @@ +@@ -58,6 +62,7 @@ } public static void checkSpawn(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { @@ -19,8 +19,8 @@ if (!world.isClientSide) { IBlockData iblockdata = tileentityskull.getBlockState(); boolean flag = iblockdata.is(Blocks.WITHER_SKELETON_SKULL) || iblockdata.is(Blocks.WITHER_SKELETON_WALL_SKULL); -@@ -68,12 +73,18 @@ - EntityWither entitywither = (EntityWither) EntityTypes.WITHER.create(world); +@@ -69,12 +74,18 @@ + EntityWither entitywither = (EntityWither) EntityTypes.WITHER.create(world, EntitySpawnReason.TRIGGERED); if (entitywither != null) { - BlockPumpkinCarved.clearPatternBlocks(world, shapedetector_shapedetectorcollection); @@ -39,7 +39,7 @@ Iterator iterator = world.getEntitiesOfClass(EntityPlayer.class, entitywither.getBoundingBox().inflate(50.0D)).iterator(); while (iterator.hasNext()) { -@@ -82,7 +93,7 @@ +@@ -83,7 +94,7 @@ CriterionTriggers.SUMMONED_ENTITY.trigger(entityplayer, (Entity) entitywither); } diff --git a/nms-patches/net/minecraft/world/level/block/CeilingHangingSignBlock.patch b/nms-patches/net/minecraft/world/level/block/CeilingHangingSignBlock.patch index 99ec4d13..66912c1a 100644 --- a/nms-patches/net/minecraft/world/level/block/CeilingHangingSignBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/CeilingHangingSignBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CeilingHangingSignBlock.java +++ b/net/minecraft/world/level/block/CeilingHangingSignBlock.java -@@ -158,6 +158,6 @@ +@@ -159,6 +159,6 @@ @Nullable @Override public BlockEntityTicker getTicker(World world, IBlockData iblockdata, TileEntityTypes tileentitytypes) { diff --git a/nms-patches/net/minecraft/world/level/block/CrafterBlock.patch b/nms-patches/net/minecraft/world/level/block/CrafterBlock.patch index d0ada720..fb402f84 100644 --- a/nms-patches/net/minecraft/world/level/block/CrafterBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/CrafterBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java -@@ -39,6 +39,15 @@ +@@ -40,6 +40,15 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.Vec3D; @@ -16,7 +16,7 @@ public class CrafterBlock extends BlockTileEntity { public static final MapCodec CODEC = simpleCodec(CrafterBlock::new); -@@ -188,6 +197,13 @@ +@@ -189,6 +198,13 @@ RecipeHolder recipeholder = (RecipeHolder) optional.get(); ItemStack itemstack = ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, worldserver.registryAccess()); @@ -30,7 +30,7 @@ if (itemstack.isEmpty()) { worldserver.levelEvent(1050, blockposition, 0); } else { -@@ -226,7 +242,25 @@ +@@ -227,7 +243,25 @@ ItemStack itemstack1 = itemstack.copy(); if (iinventory != null && (iinventory instanceof CrafterBlockEntity || itemstack.getCount() > iinventory.getMaxStackSize(itemstack))) { @@ -56,7 +56,7 @@ ItemStack itemstack2 = itemstack1.copyWithCount(1); ItemStack itemstack3 = TileEntityHopper.addItem(crafterblockentity, iinventory, itemstack2, enumdirection.getOpposite()); -@@ -237,7 +271,25 @@ +@@ -238,7 +272,25 @@ itemstack1.shrink(1); } } else if (iinventory != null) { diff --git a/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch b/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch index 4d646728..a10aad16 100644 --- a/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/DecoratedPotBlock.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/DecoratedPotBlock.java +++ b/net/minecraft/world/level/block/DecoratedPotBlock.java -@@ -239,6 +239,11 @@ - BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); +@@ -240,6 +240,11 @@ - if (!world.isClientSide && iprojectile.mayInteract(world, blockposition) && iprojectile.mayBreak(world)) { -+ // CraftBukkit start - call EntityChangeBlockEvent -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, this.getFluidState(iblockdata).createLegacyBlock())) { -+ return; -+ } -+ // CraftBukkit end - world.setBlock(blockposition, (IBlockData) iblockdata.setValue(DecoratedPotBlock.CRACKED, true), 4); - world.destroyBlock(blockposition, true, iprojectile); - } + if (world instanceof WorldServer worldserver) { + if (iprojectile.mayInteract(worldserver, blockposition) && iprojectile.mayBreak(worldserver)) { ++ // CraftBukkit start - call EntityChangeBlockEvent ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, this.getFluidState(iblockdata).createLegacyBlock())) { ++ return; ++ } ++ // CraftBukkit end + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(DecoratedPotBlock.CRACKED, true), 4); + world.destroyBlock(blockposition, true, iprojectile); + } diff --git a/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch b/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch index 9c5e2bf8..f2eebd06 100644 --- a/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/LayeredCauldronBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LayeredCauldronBlock.java +++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java -@@ -17,6 +17,12 @@ +@@ -18,6 +18,12 @@ import net.minecraft.world.level.material.FluidType; import net.minecraft.world.level.material.FluidTypes; @@ -13,24 +13,37 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -62,10 +68,14 @@ - @Override +@@ -64,39 +70,67 @@ protected void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (!world.isClientSide && entity.isOnFire() && this.isEntityInsideContent(iblockdata, blockposition, entity)) { -- entity.clearFire(); -+ // CraftBukkit start - if (entity.mayInteract(world, blockposition)) { -- this.handleEntityOnFireInside(iblockdata, world, blockposition); -+ if (!lowerFillLevel(iblockdata, world, blockposition, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) { -+ return; -+ } + if (world instanceof WorldServer worldserver) { + if (entity.isOnFire() && this.isEntityInsideContent(iblockdata, blockposition, entity)) { +- entity.clearFire(); ++ // CraftBukkit start - moved down ++ // entity.clearFire(); + if (entity.mayInteract(worldserver, blockposition)) { +- this.handleEntityOnFireInside(iblockdata, world, blockposition); ++ if (this.handleEntityOnFireInside(iblockdata, world, blockposition, entity)) { ++ entity.clearFire(); ++ } ++ // CraftBukkit end + } } -+ entity.clearFire(); -+ // CraftBukkit end } } -@@ -80,20 +90,42 @@ + +- private void handleEntityOnFireInside(IBlockData iblockdata, World world, BlockPosition blockposition) { ++ // CraftBukkit start ++ private boolean handleEntityOnFireInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + if (this.precipitationType == BiomeBase.Precipitation.SNOW) { +- lowerFillLevel((IBlockData) Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL)), world, blockposition); ++ return lowerFillLevel((IBlockData) Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL)), world, blockposition, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH); + } else { +- lowerFillLevel(iblockdata, world, blockposition); ++ return lowerFillLevel(iblockdata, world, blockposition, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH); ++ // CraftBukkit end + } + } public static void lowerFillLevel(IBlockData iblockdata, World world, BlockPosition blockposition) { @@ -77,7 +90,7 @@ } } -@@ -112,8 +144,11 @@ +@@ -115,8 +149,11 @@ if (!this.isFull(iblockdata)) { IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) + 1); diff --git a/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch b/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch index f0665b99..8a36902c 100644 --- a/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/LightningRodBlock.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/LightningRodBlock.java +++ b/net/minecraft/world/level/block/LightningRodBlock.java -@@ -22,6 +22,11 @@ - import net.minecraft.world.level.material.FluidType; +@@ -24,6 +24,11 @@ import net.minecraft.world.level.material.FluidTypes; + import net.minecraft.world.level.redstone.ExperimentalRedstoneUtils; +// CraftBukkit start +import org.bukkit.craftbukkit.block.CraftBlock; @@ -12,7 +12,7 @@ public class LightningRodBlock extends RodBlock implements IBlockWaterlogged { public static final MapCodec CODEC = simpleCodec(LightningRodBlock::new); -@@ -74,6 +79,18 @@ +@@ -76,6 +81,18 @@ } public void onLightningStrike(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch b/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch index a90a954a..0ce0a173 100644 --- a/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/PointedDripstoneBlock.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java -@@ -133,6 +133,11 @@ - BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); +@@ -136,6 +136,11 @@ + WorldServer worldserver = (WorldServer) world; - if (iprojectile.mayInteract(world, blockposition) && iprojectile.mayBreak(world) && iprojectile instanceof EntityThrownTrident && iprojectile.getDeltaMovement().length() > 0.6D) { -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState())) { -+ return; -+ } -+ // CraftBukkit end - world.destroyBlock(blockposition, true); + if (iprojectile.mayInteract(worldserver, blockposition) && iprojectile.mayBreak(worldserver) && iprojectile instanceof EntityThrownTrident && iprojectile.getDeltaMovement().length() > 0.6D) { ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState())) { ++ return; ++ } ++ // CraftBukkit end + world.destroyBlock(blockposition, true); + } } - -@@ -142,7 +147,7 @@ +@@ -146,7 +151,7 @@ @Override public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) { if (iblockdata.getValue(PointedDripstoneBlock.TIP_DIRECTION) == EnumDirection.UP && iblockdata.getValue(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) { @@ -21,7 +21,7 @@ } else { super.fallOn(world, iblockdata, blockposition, entity, f); } -@@ -387,15 +392,15 @@ +@@ -391,15 +396,15 @@ if (isUnmergedTipWithDirection(iblockdata, enumdirection.getOpposite())) { createMergedTips(iblockdata, worldserver, blockposition1); } else if (iblockdata.isAir() || iblockdata.is(Blocks.WATER)) { @@ -40,7 +40,7 @@ } private static void createMergedTips(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { -@@ -410,8 +415,8 @@ +@@ -414,8 +419,8 @@ blockposition1 = blockposition.below(); } @@ -51,7 +51,7 @@ } public static void spawnDripParticle(World world, BlockPosition blockposition, IBlockData iblockdata) { -@@ -444,7 +449,7 @@ +@@ -448,7 +453,7 @@ return (BlockPosition) findBlockVertical(generatoraccess, blockposition, enumdirection.getAxisDirection(), bipredicate, (iblockdata1) -> { return isTip(iblockdata1, flag); @@ -60,7 +60,7 @@ } } -@@ -560,7 +565,7 @@ +@@ -564,7 +569,7 @@ return canDripThrough(world, blockposition1, iblockdata); }; @@ -69,7 +69,7 @@ } @Nullable -@@ -569,7 +574,7 @@ +@@ -573,7 +578,7 @@ return canDripThrough(world, blockposition1, iblockdata); }; diff --git a/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch b/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch index 3897c740..54416b36 100644 --- a/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/PowderSnowBlock.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/level/block/PowderSnowBlock.java +++ b/net/minecraft/world/level/block/PowderSnowBlock.java -@@ -77,7 +77,12 @@ +@@ -73,7 +73,12 @@ entity.setIsInPowderSnow(true); - if (!world.isClientSide) { -- if (entity.isOnFire() && (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman) && entity.mayInteract(world, blockposition)) { + if (world instanceof WorldServer worldserver) { +- if (entity.isOnFire() && (worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman) && entity.mayInteract(worldserver, blockposition)) { + // CraftBukkit start -+ if (entity.isOnFire() && entity.mayInteract(world, blockposition)) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !(world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman))) { ++ if (entity.isOnFire() && entity.mayInteract(worldserver, blockposition)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !(worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman))) { + return; + } + // CraftBukkit end diff --git a/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch b/nms-patches/net/minecraft/world/level/block/SculkSensorBlock.patch index 98237a7c..d66c4e3e 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 -@@ -43,6 +43,11 @@ +@@ -44,6 +44,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 MapCodec CODEC = simpleCodec(SculkSensorBlock::new); -@@ -103,6 +108,18 @@ +@@ -104,6 +109,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) { -@@ -206,6 +223,15 @@ +@@ -207,6 +224,15 @@ } public static void deactivate(World world, BlockPosition blockposition, IBlockData iblockdata) { @@ -47,7 +47,7 @@ world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.COOLDOWN)).setValue(SculkSensorBlock.POWER, 0), 3); world.scheduleTick(blockposition, iblockdata.getBlock(), 10); updateNeighbours(world, blockposition, iblockdata); -@@ -217,6 +243,15 @@ +@@ -218,6 +244,15 @@ } public void activate(@Nullable Entity entity, World world, BlockPosition blockposition, IBlockData iblockdata, int i, int j) { @@ -63,7 +63,7 @@ world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.ACTIVE)).setValue(SculkSensorBlock.POWER, i), 3); world.scheduleTick(blockposition, iblockdata.getBlock(), this.getActiveTicks()); updateNeighbours(world, blockposition, iblockdata); -@@ -297,9 +332,16 @@ +@@ -298,9 +333,16 @@ @Override protected void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); diff --git a/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch b/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch index 02dbc894..41ec5aee 100644 --- a/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/SculkShriekerBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkShriekerBlock.java +++ b/net/minecraft/world/level/block/SculkShriekerBlock.java -@@ -62,6 +62,7 @@ +@@ -63,6 +63,7 @@ EntityPlayer entityplayer = SculkShriekerBlockEntity.tryGetPlayer(entity); if (entityplayer != null) { @@ -8,7 +8,7 @@ worldserver.getBlockEntity(blockposition, TileEntityTypes.SCULK_SHRIEKER).ifPresent((sculkshriekerblockentity) -> { sculkshriekerblockentity.tryShriek(worldserver, entityplayer); }); -@@ -144,10 +145,17 @@ +@@ -145,10 +146,17 @@ @Override protected void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); diff --git a/nms-patches/net/minecraft/world/level/block/SculkSpreader.patch b/nms-patches/net/minecraft/world/level/block/SculkSpreader.patch index f7fdd0b5..0a02154d 100644 --- a/nms-patches/net/minecraft/world/level/block/SculkSpreader.patch +++ b/nms-patches/net/minecraft/world/level/block/SculkSpreader.patch @@ -15,7 +15,7 @@ public class SculkSpreader { public static final int MAX_GROWTH_RATE_RADIUS = 24; -@@ -56,6 +64,7 @@ +@@ -57,6 +65,7 @@ private final int additionalDecayRate; private List cursors = new ArrayList(); private static final Logger LOGGER = LogUtils.getLogger(); @@ -23,7 +23,7 @@ public SculkSpreader(boolean flag, TagKey tagkey, int i, int j, int k, int l) { this.isWorldGeneration = flag; -@@ -110,7 +119,7 @@ +@@ -111,7 +120,7 @@ public void load(NBTTagCompound nbttagcompound) { if (nbttagcompound.contains("cursors", 9)) { this.cursors.clear(); @@ -32,7 +32,7 @@ Logger logger = SculkSpreader.LOGGER; Objects.requireNonNull(logger); -@@ -125,7 +134,7 @@ +@@ -126,7 +135,7 @@ } public void save(NBTTagCompound nbttagcompound) { @@ -41,7 +41,7 @@ Logger logger = SculkSpreader.LOGGER; Objects.requireNonNull(logger); -@@ -146,6 +155,19 @@ +@@ -147,6 +156,19 @@ private void addCursor(SculkSpreader.a sculkspreader_a) { if (this.cursors.size() < 32) { @@ -61,7 +61,7 @@ this.cursors.add(sculkspreader_a); } } -@@ -241,7 +263,7 @@ +@@ -244,7 +266,7 @@ this.charge = i; this.decayDelay = j; this.updateDelay = k; diff --git a/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch b/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch index 73b70169..f9aa1f54 100644 --- a/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkVeinBlock.java +++ b/net/minecraft/world/level/block/SculkVeinBlock.java -@@ -108,10 +108,11 @@ +@@ -110,10 +110,11 @@ @Override public int attemptUseCharge(SculkSpreader.a sculkspreader_a, GeneratorAccess generatoraccess, BlockPosition blockposition, RandomSource randomsource, SculkSpreader sculkspreader, boolean flag) { @@ -14,7 +14,7 @@ IBlockData iblockdata = generatoraccess.getBlockState(blockposition); TagKey tagkey = sculkspreader.replaceableBlocks(); Iterator iterator = EnumDirection.allShuffled(randomsource).iterator(); -@@ -126,7 +127,11 @@ +@@ -128,7 +129,11 @@ if (iblockdata1.is(tagkey)) { IBlockData iblockdata2 = Blocks.SCULK.defaultBlockState(); diff --git a/nms-patches/net/minecraft/world/level/block/WallHangingSignBlock.patch b/nms-patches/net/minecraft/world/level/block/WallHangingSignBlock.patch index 7e884406..4fad718c 100644 --- a/nms-patches/net/minecraft/world/level/block/WallHangingSignBlock.patch +++ b/nms-patches/net/minecraft/world/level/block/WallHangingSignBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/WallHangingSignBlock.java +++ b/net/minecraft/world/level/block/WallHangingSignBlock.java -@@ -183,6 +183,6 @@ +@@ -179,6 +179,6 @@ @Nullable @Override public BlockEntityTicker getTicker(World world, IBlockData iblockdata, TileEntityTypes tileentitytypes) { diff --git a/nms-patches/net/minecraft/world/level/block/entity/BrushableBlockEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/BrushableBlockEntity.patch index 95cc62d7..3b5b8926 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/BrushableBlockEntity.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/BrushableBlockEntity.patch @@ -13,15 +13,15 @@ public class BrushableBlockEntity extends TileEntity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -156,7 +162,10 @@ - EntityItem entityitem = new EntityItem(this.level, d3, d4, d5, this.item.split(this.level.random.nextInt(21) + 10)); +@@ -151,7 +157,10 @@ + EntityItem entityitem = new EntityItem(worldserver, d3, d4, d5, this.item.split(worldserver.random.nextInt(21) + 10)); - entityitem.setDeltaMovement(Vec3D.ZERO); -- this.level.addFreshEntity(entityitem); -+ // CraftBukkit start -+ org.bukkit.block.Block bblock = CraftBlock.at(this.level, this.worldPosition); -+ CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), (EntityPlayer) entityhuman, Arrays.asList(entityitem)); -+ // CraftBukkit end - this.item = ItemStack.EMPTY; - } + entityitem.setDeltaMovement(Vec3D.ZERO); +- worldserver.addFreshEntity(entityitem); ++ // CraftBukkit start ++ org.bukkit.block.Block bblock = CraftBlock.at(this.level, this.worldPosition); ++ CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), (EntityPlayer) entityhuman, Arrays.asList(entityitem)); ++ // CraftBukkit end + this.item = ItemStack.EMPTY; + } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch index d1005ab8..28bcd242 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntity.patch @@ -49,7 +49,7 @@ return nbttagcompound; } -@@ -276,12 +300,18 @@ +@@ -277,12 +301,18 @@ } public final void applyComponents(DataComponentMap datacomponentmap, DataComponentPatch datacomponentpatch) { @@ -69,7 +69,7 @@ @Nullable @Override public T get(DataComponentType datacomponenttype) { -@@ -299,6 +329,10 @@ +@@ -300,6 +330,10 @@ DataComponentPatch datacomponentpatch1 = datacomponentpatch.forget(set::contains); this.components = datacomponentpatch1.split().added(); @@ -80,7 +80,7 @@ } protected void collectImplicitComponents(DataComponentMap.a datacomponentmap_a) {} -@@ -333,6 +367,15 @@ +@@ -334,6 +368,15 @@ } } 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 2ffc59b3..fa7669c3 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeacon.patch @@ -120,8 +120,8 @@ if (nbttagcompound.contains(s, 8)) { MinecraftKey minecraftkey = MinecraftKey.tryParse(nbttagcompound.getString(s)); -- return minecraftkey == null ? null : (Holder) BuiltInRegistries.MOB_EFFECT.getHolder(minecraftkey).map(TileEntityBeacon::filterEffect).orElse((Object) null); -+ return minecraftkey == null ? null : (Holder) BuiltInRegistries.MOB_EFFECT.getHolder(minecraftkey).orElse(null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598) +- return minecraftkey == null ? null : (Holder) BuiltInRegistries.MOB_EFFECT.get(minecraftkey).map(TileEntityBeacon::filterEffect).orElse((Object) null); ++ return minecraftkey == null ? null : (Holder) BuiltInRegistries.MOB_EFFECT.get(minecraftkey).orElse(null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598) } else { return null; } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch index ca50649d..8874e644 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBeehive.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBeehive.java +++ b/net/minecraft/world/level/block/entity/TileEntityBeehive.java -@@ -42,6 +42,10 @@ +@@ -43,6 +43,10 @@ import net.minecraft.world.level.gameevent.GameEvent; import org.slf4j.Logger; @@ -11,7 +11,7 @@ public class TileEntityBeehive extends TileEntity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -55,6 +59,7 @@ +@@ -56,6 +60,7 @@ private List stored = Lists.newArrayList(); @Nullable public BlockPosition savedFlowerPos; @@ -19,7 +19,7 @@ public TileEntityBeehive(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.BEEHIVE, blockposition, iblockdata); -@@ -94,7 +99,7 @@ +@@ -95,7 +100,7 @@ } public boolean isFull() { @@ -28,7 +28,7 @@ } public void emptyAllLivingFromHive(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { -@@ -111,7 +116,7 @@ +@@ -112,7 +117,7 @@ if (entityhuman.position().distanceToSqr(entity.position()) <= 16.0D) { if (!this.isSedated()) { @@ -37,7 +37,7 @@ } else { entitybee.setStayOutOfHiveCountdown(400); } -@@ -123,10 +128,16 @@ +@@ -124,10 +129,16 @@ } private List releaseAllOccupants(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { @@ -55,7 +55,7 @@ }); if (!list.isEmpty()) { super.setChanged(); -@@ -150,7 +161,19 @@ +@@ -151,7 +162,19 @@ } public void addOccupant(Entity entity) { @@ -76,7 +76,7 @@ entity.stopRiding(); entity.ejectPassengers(); this.storeBee(TileEntityBeehive.c.of(entity)); -@@ -169,7 +192,7 @@ +@@ -170,7 +193,7 @@ this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, this.getBlockState())); } @@ -85,22 +85,22 @@ super.setChanged(); } } -@@ -179,7 +202,13 @@ +@@ -180,7 +203,13 @@ } private static boolean releaseOccupant(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.c tileentitybeehive_c, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1) { -- if ((world.isNight() || world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) { +- if (EntityBee.isNightOrRaining(world) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) { + // CraftBukkit start - This allows us to bypass the night/rain/emergency check + return releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_c, list, tileentitybeehive_releasestatus, blockposition1, false); + } + + private static boolean releaseOccupant(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.c tileentitybeehive_c, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1, boolean force) { -+ if (!force && (world.isNight() || world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) { ++ if (!force && EntityBee.isNightOrRaining(world) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) { + // CraftBukkit end return false; } else { EnumDirection enumdirection = (EnumDirection) iblockdata.getValue(BlockBeehive.FACING); -@@ -192,6 +221,18 @@ +@@ -193,6 +222,18 @@ Entity entity = tileentitybeehive_c.createEntity(world, blockposition); if (entity != null) { @@ -119,7 +119,7 @@ if (entity instanceof EntityBee) { EntityBee entitybee = (EntityBee) entity; -@@ -222,6 +263,7 @@ +@@ -223,6 +264,7 @@ list.add(entitybee); } @@ -127,7 +127,7 @@ float f = entity.getBbWidth(); double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F); double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getStepX(); -@@ -229,11 +271,12 @@ +@@ -230,11 +272,12 @@ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ(); entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); @@ -141,7 +141,7 @@ } else { return false; } -@@ -258,6 +301,10 @@ +@@ -259,6 +302,10 @@ if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee.toOccupant(), (List) null, tileentitybeehive_releasestatus, blockposition1)) { flag = true; iterator.remove(); @@ -152,7 +152,7 @@ } } } -@@ -284,7 +331,7 @@ +@@ -285,7 +332,7 @@ @Override protected void loadAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { super.loadAdditional(nbttagcompound, holderlookup_a); @@ -161,7 +161,7 @@ if (nbttagcompound.contains("bees")) { TileEntityBeehive.c.LIST_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("bees")).resultOrPartial((s) -> { TileEntityBeehive.LOGGER.error("Failed to parse bees: '{}'", s); -@@ -293,7 +340,12 @@ +@@ -294,7 +341,12 @@ }); } @@ -175,7 +175,7 @@ } @Override -@@ -303,13 +355,14 @@ +@@ -304,13 +356,14 @@ if (this.hasSavedFlowerPos()) { nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos)); } @@ -191,7 +191,7 @@ List list = (List) tileentity_b.getOrDefault(DataComponents.BEES, List.of()); list.forEach(this::storeBee); -@@ -350,7 +403,7 @@ +@@ -351,7 +404,7 @@ NBTTagCompound nbttagcompound = new NBTTagCompound(); entity.save(nbttagcompound); @@ -200,7 +200,7 @@ Objects.requireNonNull(nbttagcompound); list.forEach(nbttagcompound::remove); -@@ -369,7 +422,7 @@ +@@ -370,7 +423,7 @@ @Nullable public Entity createEntity(World world, BlockPosition blockposition) { NBTTagCompound nbttagcompound = this.entityData.copyTag(); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch index 6a15e045..002abf34 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityBrewingStand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java +++ b/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java -@@ -23,6 +23,20 @@ +@@ -24,6 +24,20 @@ import net.minecraft.world.level.block.BlockBrewingStand; import net.minecraft.world.level.block.state.IBlockData; @@ -21,7 +21,7 @@ public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory { private static final int INGREDIENT_SLOT = 3; -@@ -40,6 +54,36 @@ +@@ -41,6 +55,36 @@ private Item ingredient; public int fuel; protected final IContainerProperties dataAccess; @@ -58,10 +58,10 @@ public TileEntityBrewingStand(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.BREWING_STAND, blockposition, iblockdata); -@@ -106,8 +150,19 @@ +@@ -107,8 +151,19 @@ ItemStack itemstack = (ItemStack) tileentitybrewingstand.items.get(4); - if (tileentitybrewingstand.fuel <= 0 && itemstack.is(Items.BLAZE_POWDER)) { + if (tileentitybrewingstand.fuel <= 0 && itemstack.is(TagsItem.BREWING_FUEL)) { - tileentitybrewingstand.fuel = 20; - itemstack.shrink(1); + // CraftBukkit start @@ -80,7 +80,7 @@ setChanged(world, blockposition, iblockdata); } -@@ -115,12 +170,17 @@ +@@ -116,12 +171,17 @@ boolean flag1 = tileentitybrewingstand.brewTime > 0; ItemStack itemstack1 = (ItemStack) tileentitybrewingstand.items.get(3); @@ -101,7 +101,7 @@ } else if (!flag || !itemstack1.is(tileentitybrewingstand.ingredient)) { tileentitybrewingstand.brewTime = 0; } -@@ -128,7 +188,11 @@ +@@ -129,7 +189,11 @@ setChanged(world, blockposition, iblockdata); } else if (flag && tileentitybrewingstand.fuel > 0) { --tileentitybrewingstand.fuel; @@ -114,7 +114,7 @@ tileentitybrewingstand.ingredient = itemstack1.getItem(); setChanged(world, blockposition, iblockdata); } -@@ -184,12 +248,34 @@ +@@ -185,12 +249,34 @@ } } 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 5fe4b5dc..ec68f7a9 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityCampfire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityCampfire.java +++ b/net/minecraft/world/level/block/entity/TileEntityCampfire.java -@@ -30,6 +30,14 @@ +@@ -31,6 +31,14 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.gameevent.GameEvent; @@ -15,16 +15,16 @@ public class TileEntityCampfire extends TileEntity implements Clearable { private static final int BURN_COOL_SPEED = 2; -@@ -64,6 +72,20 @@ +@@ -63,6 +71,20 @@ }).orElse(itemstack); - if (itemstack1.isItemEnabled(world.enabledFeatures())) { + if (itemstack1.isItemEnabled(worldserver.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(worldserver, blockposition), source, result); ++ worldserver.getCraftServer().getPluginManager().callEvent(blockCookEvent); + + if (blockCookEvent.isCancelled()) { + return; @@ -33,19 +33,19 @@ + result = blockCookEvent.getResult(); + itemstack1 = CraftItemStack.asNMSCopy(result); + // CraftBukkit end - InventoryUtils.dropItemStack(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); + InventoryUtils.dropItemStack(worldserver, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); tileentitycampfire.items.set(i, ItemStack.EMPTY); - world.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); -@@ -176,7 +198,11 @@ - ItemStack itemstack1 = (ItemStack) this.items.get(j); + worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); +@@ -177,7 +199,11 @@ + return false; + } - if (itemstack1.isEmpty()) { -- this.cookingTime[j] = i; +- this.cookingTime[i] = ((RecipeCampfire) ((RecipeHolder) optional.get()).value()).cookingTime(); + // CraftBukkit start -+ CampfireStartEvent event = new CampfireStartEvent(CraftBlock.at(this.level,this.worldPosition), CraftItemStack.asCraftMirror(itemstack), (CampfireRecipe) getCookableRecipe(itemstack).get().toBukkitRecipe()); ++ CampfireStartEvent event = new CampfireStartEvent(CraftBlock.at(this.level,this.worldPosition), CraftItemStack.asCraftMirror(itemstack), (CampfireRecipe) optional.get().toBukkitRecipe()); + this.level.getCraftServer().getPluginManager().callEvent(event); -+ this.cookingTime[j] = event.getTotalCookTime(); // i -> event.getTotalCookTime() ++ this.cookingTime[i] = event.getTotalCookTime(); // i -> event.getTotalCookTime() + // CraftBukkit end - this.cookingProgress[j] = 0; - this.items.set(j, itemstack.consumeAndReturn(1, entityliving)); - this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, this.getBlockPos(), GameEvent.a.of(entityliving, this.getBlockState())); + this.cookingProgress[i] = 0; + this.items.set(i, itemstack.consumeAndReturn(1, entityliving)); + worldserver.gameEvent((Holder) GameEvent.BLOCK_CHANGE, this.getBlockPos(), GameEvent.a.of(entityliving, this.getBlockState())); diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch index 775a4466..033b3ba2 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch @@ -1,6 +1,17 @@ --- a/net/minecraft/world/level/block/entity/TileEntityConduit.java +++ b/net/minecraft/world/level/block/entity/TileEntityConduit.java -@@ -187,8 +187,20 @@ +@@ -28,6 +28,10 @@ + import net.minecraft.world.phys.AxisAlignedBB; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import net.minecraft.server.level.WorldServer; ++// CraftBukkit end ++ + public class TileEntityConduit extends TileEntity { + + private static final int BLOCK_REFRESH_RATE = 2; +@@ -187,8 +191,20 @@ } private static void applyEffects(World world, BlockPosition blockposition, List list) { @@ -21,7 +32,7 @@ int k = blockposition.getX(); int l = blockposition.getY(); int i1 = blockposition.getZ(); -@@ -202,7 +214,7 @@ +@@ -202,7 +218,7 @@ EntityHuman entityhuman = (EntityHuman) iterator.next(); if (blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) { @@ -30,7 +41,7 @@ } } -@@ -210,6 +222,12 @@ +@@ -210,6 +226,12 @@ } private static void updateDestroyTarget(World world, BlockPosition blockposition, IBlockData iblockdata, List list, TileEntityConduit tileentityconduit) { @@ -43,7 +54,7 @@ EntityLiving entityliving = tileentityconduit.destroyTarget; int i = list.size(); -@@ -230,9 +248,12 @@ +@@ -230,9 +252,12 @@ tileentityconduit.destroyTarget = null; } @@ -52,7 +63,7 @@ - tileentityconduit.destroyTarget.hurt(world.damageSources().magic(), 4.0F); + // CraftBukkit start + if (damageTarget && tileentityconduit.destroyTarget != null) { -+ if (tileentityconduit.destroyTarget.hurt(world.damageSources().magic().directBlock(world, blockposition), 4.0F)) { ++ if (tileentityconduit.destroyTarget.hurtServer((WorldServer) world, world.damageSources().magic().directBlock(world, blockposition), 4.0F)) { + world.playSound(null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); + } + // CraftBukkit end 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 0d23226a..cf27b353 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityContainer.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/entity/TileEntityContainer.java +++ b/net/minecraft/world/level/block/entity/TileEntityContainer.java @@ -178,4 +178,12 @@ - nbttagcompound.remove("Lock"); + nbttagcompound.remove("lock"); nbttagcompound.remove("Items"); } + 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 fd6b054c..be3111dc 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityFurnace.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityFurnace.java +++ b/net/minecraft/world/level/block/entity/TileEntityFurnace.java -@@ -48,6 +48,21 @@ +@@ -42,6 +42,21 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.Vec3D; @@ -22,19 +22,14 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeCraftingHolder, AutoRecipeOutput { protected static final int SLOT_INPUT = 0; -@@ -118,7 +133,7 @@ +@@ -112,9 +127,39 @@ } }; - this.recipesUsed = new Object2IntOpenHashMap(); + this.recipesUsed = new Reference2IntOpenHashMap(); - this.quickCheck = CraftingManager.createCheck(recipes); + this.quickCheck = CraftingManager.createCheck((Recipes) recipes); // CraftBukkit - decompile error // Eclipse fail - } - - public static void invalidateCache() { -@@ -197,6 +212,40 @@ - } - } - ++ } ++ + // CraftBukkit start - add fields and methods + private int maxStack = MAX_STACK; + public List transaction = new java.util.ArrayList(); @@ -53,8 +48,8 @@ + + public List getViewers() { + return transaction; -+ } -+ + } + + @Override + public int getMaxStackSize() { + return maxStack; @@ -63,34 +58,30 @@ + public void setMaxStackSize(int size) { + maxStack = size; + } -+ -+ public Object2IntOpenHashMap getRecipesUsed() { -+ return this.recipesUsed; // PAIL private -> public -+ } + // CraftBukkit end + - private static boolean isNeverAFurnaceFuel(Item item) { - return item.builtInRegistryHolder().is(TagsItem.NON_FLAMMABLE_WOOD); + private boolean isLit() { + return this.litTime > 0; } -@@ -286,7 +335,7 @@ +@@ -180,7 +225,7 @@ RecipeHolder recipeholder; if (flag2) { -- recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(new SingleRecipeInput(itemstack1), world).orElse((Object) null); -+ recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(new SingleRecipeInput(itemstack1), world).orElse(null); // CraftBukkit - decompile error +- recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, worldserver).orElse((Object) null); ++ recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, worldserver).orElse(null); // CraftBukkit - decompile error } else { recipeholder = null; } -@@ -294,9 +343,20 @@ +@@ -188,9 +233,20 @@ int i = tileentityfurnace.getMaxStackSize(); - if (!tileentityfurnace.isLit() && canBurn(world.registryAccess(), recipeholder, tileentityfurnace.items, i)) { -- tileentityfurnace.litTime = tileentityfurnace.getBurnDuration(itemstack); + if (!tileentityfurnace.isLit() && canBurn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) { +- tileentityfurnace.litTime = tileentityfurnace.getBurnDuration(worldserver.fuelValues(), itemstack); + // CraftBukkit start + CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack); + -+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(world, blockposition), fuel, tileentityfurnace.getBurnDuration(itemstack)); -+ world.getCraftServer().getPluginManager().callEvent(furnaceBurnEvent); ++ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(worldserver, blockposition), fuel, tileentityfurnace.getBurnDuration(worldserver.fuelValues(), itemstack)); ++ worldserver.getCraftServer().getPluginManager().callEvent(furnaceBurnEvent); + + if (furnaceBurnEvent.isCancelled()) { + return; @@ -104,17 +95,17 @@ flag1 = true; if (flag3) { Item item = itemstack.getItem(); -@@ -312,11 +372,23 @@ +@@ -204,11 +260,23 @@ } - if (tileentityfurnace.isLit() && canBurn(world.registryAccess(), recipeholder, tileentityfurnace.items, i)) { + if (tileentityfurnace.isLit() && canBurn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) { + // CraftBukkit start + if (recipeholder != null && tileentityfurnace.cookingProgress == 0) { + CraftItemStack source = CraftItemStack.asCraftMirror(tileentityfurnace.items.get(0)); + CookingRecipe recipe = (CookingRecipe) recipeholder.toBukkitRecipe(); + -+ FurnaceStartSmeltEvent event = new FurnaceStartSmeltEvent(CraftBlock.at(world, blockposition), source, recipe); -+ world.getCraftServer().getPluginManager().callEvent(event); ++ FurnaceStartSmeltEvent event = new FurnaceStartSmeltEvent(CraftBlock.at(worldserver, blockposition), source, recipe); ++ worldserver.getCraftServer().getPluginManager().callEvent(event); + + tileentityfurnace.cookingTotalTime = event.getTotalCookTime(); + } @@ -123,21 +114,21 @@ ++tileentityfurnace.cookingProgress; if (tileentityfurnace.cookingProgress == tileentityfurnace.cookingTotalTime) { tileentityfurnace.cookingProgress = 0; - tileentityfurnace.cookingTotalTime = getTotalCookTime(world, tileentityfurnace); -- if (burn(world.registryAccess(), recipeholder, tileentityfurnace.items, i)) { -+ if (burn(tileentityfurnace.level, tileentityfurnace.worldPosition, world.registryAccess(), recipeholder, tileentityfurnace.items, i)) { // CraftBukkit + tileentityfurnace.cookingTotalTime = getTotalCookTime(worldserver, tileentityfurnace); +- if (burn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) { ++ if (burn(tileentityfurnace.level, tileentityfurnace.worldPosition, worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) { // CraftBukkit tileentityfurnace.setRecipeUsed(recipeholder); } -@@ -355,17 +427,44 @@ +@@ -247,17 +315,44 @@ } } -- private static boolean burn(IRegistryCustom iregistrycustom, @Nullable RecipeHolder recipeholder, NonNullList nonnulllist, int i) { -+ private static boolean burn(World world, BlockPosition blockposition, IRegistryCustom iregistrycustom, @Nullable RecipeHolder recipeholder, NonNullList nonnulllist, int i) { // CraftBukkit - if (recipeholder != null && canBurn(iregistrycustom, recipeholder, nonnulllist, i)) { +- private static boolean burn(IRegistryCustom iregistrycustom, @Nullable RecipeHolder recipeholder, SingleRecipeInput singlerecipeinput, NonNullList nonnulllist, int i) { ++ private static boolean burn(World world, BlockPosition blockposition, IRegistryCustom iregistrycustom, @Nullable RecipeHolder recipeholder, SingleRecipeInput singlerecipeinput, NonNullList nonnulllist, int i) { // CraftBukkit + if (recipeholder != null && canBurn(iregistrycustom, recipeholder, singlerecipeinput, nonnulllist, i)) { ItemStack itemstack = (ItemStack) nonnulllist.get(0); - ItemStack itemstack1 = recipeholder.value().getResultItem(iregistrycustom); + ItemStack itemstack1 = ((RecipeCooking) recipeholder.value()).assemble(singlerecipeinput, iregistrycustom); ItemStack itemstack2 = (ItemStack) nonnulllist.get(2); + // CraftBukkit start - fire FurnaceSmeltEvent @@ -175,15 +166,15 @@ 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)); -@@ -389,6 +488,7 @@ +@@ -275,6 +370,7 @@ } - private static int getTotalCookTime(World world, TileEntityFurnace tileentityfurnace) { -+ if (world == null) return 200; // CraftBukkit - SPIGOT-4302 + private static int getTotalCookTime(WorldServer worldserver, TileEntityFurnace tileentityfurnace) { ++ if (worldserver == null) return 200; // CraftBukkit - SPIGOT-4302 SingleRecipeInput singlerecipeinput = new SingleRecipeInput(tileentityfurnace.getItem(0)); - return (Integer) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, world).map((recipeholder) -> { -@@ -477,8 +577,8 @@ + return (Integer) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, worldserver).map((recipeholder) -> { +@@ -365,8 +461,8 @@ @Override public void awardUsedRecipes(EntityHuman entityhuman, List list) {} @@ -194,7 +185,7 @@ entityplayer.awardRecipes(list); Iterator iterator = list.iterator(); -@@ -495,6 +595,12 @@ +@@ -383,22 +479,28 @@ } public List> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d) { @@ -205,14 +196,16 @@ + public List> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d, BlockPosition blockposition, EntityPlayer entityplayer, ItemStack itemstack, int amount) { + // CraftBukkit end List> list = Lists.newArrayList(); - ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator(); + ObjectIterator objectiterator = this.recipesUsed.reference2IntEntrySet().iterator(); -@@ -503,14 +609,14 @@ + while (objectiterator.hasNext()) { + Entry>> entry = (Entry) objectiterator.next(); - worldserver.getRecipeManager().byKey((MinecraftKey) entry.getKey()).ifPresent((recipeholder) -> { +- worldserver.recipeAccess().byKey((ResourceKey) entry.getKey()).ifPresent((recipeholder) -> { ++ worldserver.recipeAccess().byKey(entry.getKey()).ifPresent((recipeholder) -> { // CraftBukkit - decompile error list.add(recipeholder); -- createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) recipeholder.value()).getExperience()); -+ createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) recipeholder.value()).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit +- createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) recipeholder.value()).experience()); ++ createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) recipeholder.value()).experience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit }); } @@ -224,7 +217,7 @@ int j = MathHelper.floor((float) i * f); float f1 = MathHelper.frac((float) i * f); -@@ -518,6 +624,17 @@ +@@ -406,6 +508,17 @@ ++j; } diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch index b3d264bf..cd407858 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityJukeBox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityJukeBox.java +++ b/net/minecraft/world/level/block/entity/TileEntityJukeBox.java -@@ -20,12 +20,56 @@ +@@ -19,12 +19,56 @@ import net.minecraft.world.phys.Vec3D; import net.minecraft.world.ticks.ContainerSingleItem; @@ -12,7 +12,7 @@ +import org.bukkit.entity.HumanEntity; +// CraftBukkit end + - public class TileEntityJukeBox extends TileEntity implements Clearable, ContainerSingleItem.a { + public class TileEntityJukeBox extends TileEntity implements ContainerSingleItem.a { public static final String SONG_ITEM_TAG_ID = "RecordItem"; public static final String TICKS_SINCE_SONG_STARTED_TAG_ID = "ticks_since_song_started"; @@ -57,7 +57,7 @@ public TileEntityJukeBox(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.JUKEBOX, blockposition, iblockdata); -@@ -134,7 +178,7 @@ +@@ -133,7 +177,7 @@ @Override public int getMaxStackSize() { @@ -66,7 +66,7 @@ } @Override -@@ -153,12 +197,17 @@ +@@ -152,12 +196,17 @@ } @VisibleForTesting diff --git a/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch b/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch index de231eff..9ac9529f 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch @@ -4,7 +4,6 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; --public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory { +// CraftBukkit start +import java.util.ArrayList; +import java.util.Arrays; @@ -17,7 +16,7 @@ +import org.bukkit.inventory.InventoryHolder; +// CraftBukkit end + -+public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory, ICommandListener { // CraftBukkit - ICommandListener + public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory { public static final int DATA_PAGE = 0; public static final int NUM_DATA = 1; @@ -107,50 +106,53 @@ } } -@@ -187,6 +255,32 @@ +@@ -189,6 +257,35 @@ return itemstack; } + // CraftBukkit start -+ @Override -+ public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) { -+ } -+ -+ @Override -+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { -+ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this); -+ } -+ -+ @Override -+ public boolean acceptsSuccess() { -+ return false; -+ } -+ -+ @Override -+ public boolean acceptsFailure() { -+ return false; -+ } -+ -+ @Override -+ public boolean shouldInformAdmins() { -+ return false; -+ } ++ private final ICommandListener commandSource = new ICommandListener() { + ++ @Override ++ public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) { ++ } ++ ++ @Override ++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { ++ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitEntity() : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, TileEntityLectern.this); ++ } ++ ++ @Override ++ public boolean acceptsSuccess() { ++ return false; ++ } ++ ++ @Override ++ public boolean acceptsFailure() { ++ return false; ++ } ++ ++ @Override ++ public boolean shouldInformAdmins() { ++ return false; ++ } ++ }; + // CraftBukkit end - private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman) { ++ + private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman, WorldServer worldserver) { String s; Object object; -@@ -201,7 +295,8 @@ +@@ -203,7 +300,8 @@ Vec3D vec3d = Vec3D.atCenterOf(this.worldPosition); -- return new CommandListenerWrapper(ICommandListener.NULL, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityhuman); -+ // CraftBukkit - this -+ return new CommandListenerWrapper(this, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityhuman); +- return new CommandListenerWrapper(ICommandListener.NULL, vec3d, Vec2F.ZERO, worldserver, 2, s, (IChatBaseComponent) object, worldserver.getServer(), entityhuman); ++ // CraftBukkit - commandSource ++ return new CommandListenerWrapper(commandSource, vec3d, Vec2F.ZERO, worldserver, 2, s, (IChatBaseComponent) object, worldserver.getServer(), entityhuman); } @Override -@@ -239,7 +334,7 @@ +@@ -241,7 +339,7 @@ @Override public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { 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 933fece8..4c2e6b73 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/TileEntitySign.patch @@ -1,10 +1,9 @@ --- a/net/minecraft/world/level/block/entity/TileEntitySign.java +++ b/net/minecraft/world/level/block/entity/TileEntitySign.java -@@ -36,7 +36,17 @@ +@@ -36,6 +36,16 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; --public class TileEntitySign extends TileEntity { +// CraftBukkit start +import net.minecraft.nbt.NBTBase; +import net.minecraft.server.level.EntityPlayer; @@ -15,10 +14,9 @@ +import org.bukkit.event.block.SignChangeEvent; +// CraftBukkit end + -+public class TileEntitySign extends TileEntity implements ICommandListener { // CraftBukkit - implements + public class TileEntitySign extends TileEntity { private static final Logger LOGGER = LogUtils.getLogger(); - private static final int MAX_TEXT_LINE_WIDTH = 90; @@ -101,7 +111,7 @@ protected void saveAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { super.saveAdditional(nbttagcompound, holderlookup_a); @@ -92,34 +90,37 @@ return signtext; } -@@ -250,11 +285,37 @@ +@@ -250,11 +285,40 @@ return flag1; } - private static CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition) { + // CraftBukkit start -+ @Override -+ public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {} ++ private final ICommandListener commandSource = new ICommandListener() { + -+ @Override -+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { -+ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this); -+ } ++ @Override ++ public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {} + -+ @Override -+ public boolean acceptsSuccess() { -+ return false; -+ } ++ @Override ++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { ++ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitEntity() : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, TileEntitySign.this); ++ } + -+ @Override -+ public boolean acceptsFailure() { -+ return false; -+ } ++ @Override ++ public boolean acceptsSuccess() { ++ return false; ++ } + -+ @Override -+ public boolean shouldInformAdmins() { -+ return false; -+ } ++ @Override ++ public boolean acceptsFailure() { ++ return false; ++ } ++ ++ @Override ++ public boolean shouldInformAdmins() { ++ return false; ++ } ++ }; + + private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition) { + // CraftBukkit end @@ -127,12 +128,12 @@ Object object = entityhuman == null ? IChatBaseComponent.literal("Sign") : entityhuman.getDisplayName(); - return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, (IChatBaseComponent) object, world.getServer(), entityhuman); -+ // CraftBukkit - this -+ return new CommandListenerWrapper(this, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, (IChatBaseComponent) object, world.getServer(), entityhuman); ++ // CraftBukkit - commandSource ++ return new CommandListenerWrapper(commandSource, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, (IChatBaseComponent) object, world.getServer(), entityhuman); } @Override -@@ -278,12 +339,17 @@ +@@ -278,12 +342,17 @@ @Nullable public UUID getPlayerWhoMayEdit() { diff --git a/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch b/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch index 51824432..d9d12313 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java -@@ -206,7 +206,7 @@ +@@ -211,7 +211,7 @@ } public void resetAfterBecomingOminous(TrialSpawner trialspawner, WorldServer worldserver) { @@ -9,8 +9,8 @@ Objects.requireNonNull(worldserver); stream.map(worldserver::getEntity).forEach((entity) -> { -@@ -218,7 +218,7 @@ - entityinsentient.dropPreservedEquipment(); +@@ -223,7 +223,7 @@ + entityinsentient.dropPreservedEquipment(worldserver); } - entity.remove(Entity.RemovalReason.DISCARDED); diff --git a/nms-patches/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.patch b/nms-patches/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.patch index 8cf5a218..a44d02ca 100644 --- a/nms-patches/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.patch +++ b/nms-patches/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java +++ b/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java -@@ -47,6 +47,13 @@ +@@ -46,6 +46,13 @@ import net.minecraft.world.phys.Vec3D; import org.slf4j.Logger; @@ -14,7 +14,7 @@ public class VaultBlockEntity extends TileEntity { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -97,18 +104,18 @@ +@@ -96,18 +103,18 @@ dataresult = VaultServerData.CODEC.parse(dynamicops, nbttagcompound.get("server_data")); logger = VaultBlockEntity.LOGGER; Objects.requireNonNull(logger); @@ -36,7 +36,7 @@ this.config = vaultconfig; }); } -@@ -117,11 +124,11 @@ +@@ -116,11 +123,11 @@ dataresult = VaultSharedData.CODEC.parse(dynamicops, nbttagcompound.get("shared_data")); logger = VaultBlockEntity.LOGGER; Objects.requireNonNull(logger); @@ -50,7 +50,7 @@ } } -@@ -321,6 +328,14 @@ +@@ -320,6 +327,14 @@ if (!list.isEmpty()) { entityhuman.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem())); itemstack.consume(vaultconfig.keyItem().getCount(), entityhuman); @@ -65,7 +65,7 @@ unlock(worldserver, iblockdata, blockposition, vaultconfig, vaultserverdata, vaultshareddata, list); vaultserverdata.addToRewardedPlayers(entityhuman); vaultshareddata.updateConnectedPlayersWithinRange(worldserver, blockposition, vaultserverdata, vaultconfig, vaultconfig.deactivationRange()); -@@ -342,6 +357,14 @@ +@@ -341,6 +356,14 @@ vaultshareddata.setDisplayItem(ItemStack.EMPTY); } else { ItemStack itemstack = getRandomDisplayItemFromLootTable(worldserver, blockposition, (ResourceKey) vaultconfig.overrideLootTableToDisplay().orElse(vaultconfig.lootTable())); 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 61f547d2..0a014858 100644 --- a/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch +++ b/nms-patches/net/minecraft/world/level/block/grower/WorldGenTreeProvider.patch @@ -13,7 +13,7 @@ public final class WorldGenTreeProvider { private static final Map GROWERS = new Object2ObjectArrayMap(); -@@ -74,21 +80,22 @@ +@@ -75,21 +81,22 @@ } } @@ -31,20 +31,20 @@ ResourceKey> resourcekey = this.getConfiguredMegaFeature(randomsource); if (resourcekey != null) { -- 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 +- Holder> holder = (Holder) worldserver.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey).orElse((Object) null); ++ Holder> holder = (Holder) worldserver.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey).orElse(null); // CraftBukkit - decompile error if (holder != null) { + setTreeType(holder); // CraftBukkit for (int i = 0; i >= -1; --i) { for (int j = 0; j >= -1; --j) { if (isTwoByTwoSapling(iblockdata, worldserver, blockposition, i, j)) { -@@ -119,11 +126,12 @@ +@@ -120,11 +127,12 @@ if (resourcekey1 == null) { return false; } else { -- Holder> holder1 = (Holder) worldserver.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(resourcekey1).orElse((Object) null); -+ Holder> holder1 = (Holder) worldserver.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(resourcekey1).orElse(null); // CraftBukkit - decompile error +- Holder> holder1 = (Holder) worldserver.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey1).orElse((Object) null); ++ Holder> holder1 = (Holder) worldserver.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey1).orElse(null); // CraftBukkit - decompile error if (holder1 == null) { return false; @@ -53,7 +53,7 @@ WorldGenFeatureConfigured worldgenfeatureconfigured1 = (WorldGenFeatureConfigured) holder1.value(); IBlockData iblockdata2 = worldserver.getFluidState(blockposition).createLegacyBlock(); -@@ -164,11 +172,62 @@ +@@ -165,11 +173,62 @@ return true; } diff --git a/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch b/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch index ca610a7b..7b2160e5 100644 --- a/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch +++ b/nms-patches/net/minecraft/world/level/block/piston/BlockPiston.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/BlockPiston.java +++ b/net/minecraft/world/level/block/piston/BlockPiston.java -@@ -42,6 +42,14 @@ +@@ -45,6 +45,14 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; @@ -15,7 +15,7 @@ public class BlockPiston extends BlockDirectional { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { -@@ -152,6 +160,18 @@ +@@ -155,6 +163,18 @@ } } @@ -34,7 +34,7 @@ world.blockEvent(blockposition, this, b0, enumdirection.get3DDataValue()); } -@@ -332,6 +352,48 @@ +@@ -335,6 +355,48 @@ IBlockData[] aiblockdata = new IBlockData[list.size() + list2.size()]; EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.getOpposite(); int i = 0; diff --git a/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch b/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch index 9b91c972..bc6135f2 100644 --- a/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch +++ b/nms-patches/net/minecraft/world/level/block/state/BlockBase.patch @@ -1,17 +1,18 @@ --- a/net/minecraft/world/level/block/state/BlockBase.java +++ b/net/minecraft/world/level/block/state/BlockBase.java -@@ -81,6 +81,10 @@ +@@ -84,6 +84,11 @@ import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapes; +// CraftBukkit start +import net.minecraft.world.item.context.ItemActionContext; ++import net.minecraft.world.level.ServerExplosion; +// CraftBukkit end + public abstract class BlockBase implements FeatureElement { protected static final EnumDirection[] UPDATE_SHAPE_ORDER = new EnumDirection[]{EnumDirection.WEST, EnumDirection.EAST, EnumDirection.NORTH, EnumDirection.SOUTH, EnumDirection.DOWN, EnumDirection.UP}; -@@ -156,6 +160,12 @@ +@@ -158,6 +163,12 @@ protected void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) {} @@ -24,20 +25,20 @@ protected void onRemove(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) { if (iblockdata.hasBlockEntity() && !iblockdata.is(iblockdata1.getBlock())) { world.removeBlockEntity(blockposition); -@@ -173,8 +183,10 @@ - TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition) : null; +@@ -174,8 +185,10 @@ + TileEntity tileentity = iblockdata.hasBlockEntity() ? worldserver.getBlockEntity(blockposition) : null; LootParams.a lootparams_a = (new LootParams.a(worldserver)).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity).withOptionalParameter(LootContextParameters.THIS_ENTITY, explosion.getDirectSourceEntity()); - if (explosion.getBlockInteraction() == Explosion.Effect.DESTROY_WITH_DECAY) { - lootparams_a.withParameter(LootContextParameters.EXPLOSION_RADIUS, explosion.radius()); + // CraftBukkit start - add yield -+ if (explosion.yield < 1.0F) { -+ lootparams_a.withParameter(LootContextParameters.EXPLOSION_RADIUS, 1.0F / explosion.yield); ++ if (explosion instanceof ServerExplosion serverExplosion && serverExplosion.yield < 1.0F) { ++ lootparams_a.withParameter(LootContextParameters.EXPLOSION_RADIUS, 1.0F / serverExplosion.yield); + // CraftBukkit end } iblockdata.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY, flag); -@@ -1066,7 +1078,13 @@ +@@ -1121,7 +1134,13 @@ } public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata, boolean flag) { diff --git a/nms-patches/net/minecraft/world/level/border/WorldBorder.patch b/nms-patches/net/minecraft/world/level/border/WorldBorder.patch index e3d8ca0c..732d68c4 100644 --- a/nms-patches/net/minecraft/world/level/border/WorldBorder.patch +++ b/nms-patches/net/minecraft/world/level/border/WorldBorder.patch @@ -8,7 +8,7 @@ public WorldBorder() {} -@@ -181,6 +182,7 @@ +@@ -189,6 +190,7 @@ } public void addListener(IWorldBorderListener iworldborderlistener) { diff --git a/nms-patches/net/minecraft/world/level/chunk/Chunk.patch b/nms-patches/net/minecraft/world/level/chunk/Chunk.patch index 4df6567e..245064ce 100644 --- a/nms-patches/net/minecraft/world/level/chunk/Chunk.patch +++ b/nms-patches/net/minecraft/world/level/chunk/Chunk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/Chunk.java +++ b/net/minecraft/world/level/chunk/Chunk.java -@@ -77,7 +77,7 @@ +@@ -78,7 +78,7 @@ }; private final Map tickersInLevel; public boolean loaded; @@ -9,16 +9,16 @@ @Nullable private Supplier fullStatus; @Nullable -@@ -93,7 +93,7 @@ - public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, ChunkConverter chunkconverter, LevelChunkTicks levelchunkticks, LevelChunkTicks levelchunkticks1, long i, @Nullable ChunkSection[] achunksection, @Nullable Chunk.c chunk_c, @Nullable BlendingData blendingdata) { - super(chunkcoordintpair, chunkconverter, world, world.registryAccess().registryOrThrow(Registries.BIOME), i, achunksection, blendingdata); +@@ -97,7 +97,7 @@ this.tickersInLevel = Maps.newHashMap(); + this.unsavedListener = (chunkcoordintpair1) -> { + }; - this.level = world; + this.level = (WorldServer) world; // CraftBukkit - type this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap(); HeightMap.Type[] aheightmap_type = HeightMap.Type.values(); int j = aheightmap_type.length; -@@ -111,6 +111,11 @@ +@@ -115,6 +115,11 @@ this.fluidTicks = levelchunkticks1; } @@ -30,18 +30,18 @@ public Chunk(WorldServer worldserver, ProtoChunk protochunk, @Nullable Chunk.c chunk_c) { this(worldserver, protochunk.getPos(), protochunk.getUpgradeData(), protochunk.unpackBlockTicks(), protochunk.unpackFluidTicks(), protochunk.getInhabitedTime(), protochunk.getSections(), chunk_c, protochunk.getBlendingData()); Iterator iterator = protochunk.getBlockEntities().values().iterator(); -@@ -142,6 +147,10 @@ +@@ -146,6 +151,10 @@ this.skyLightSources = protochunk.skyLightSources; this.setLightCorrect(protochunk.isLightCorrect()); - this.unsaved = true; + this.markUnsaved(); + this.needsDecoration = true; // CraftBukkit + // CraftBukkit start + this.persistentDataContainer = protochunk.persistentDataContainer; // SPIGOT-6814: copy PDC to account for 1.17 to 1.18 chunk upgrading. + // CraftBukkit end } - @Override -@@ -244,9 +253,16 @@ + public void setUnsavedListener(Chunk.e chunk_e) { +@@ -267,9 +276,16 @@ } } @@ -58,7 +58,7 @@ int i = blockposition.getY(); ChunkSection chunksection = this.getSection(this.getSectionIndex(i)); boolean flag1 = chunksection.hasOnlyAir(); -@@ -295,7 +311,8 @@ +@@ -319,7 +335,8 @@ if (!chunksection.getBlockState(j, k, l).is(block)) { return null; } else { @@ -68,7 +68,7 @@ iblockdata.onPlace(this.level, blockposition, iblockdata1, flag); } -@@ -345,7 +362,12 @@ +@@ -370,7 +387,12 @@ @Nullable public TileEntity getBlockEntity(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { @@ -82,7 +82,7 @@ if (tileentity == null) { NBTTagCompound nbttagcompound = (NBTTagCompound) this.pendingBlockEntities.remove(blockposition); -@@ -417,6 +439,7 @@ +@@ -442,6 +464,7 @@ if (!iblockdata.hasBlockEntity()) { Chunk.LOGGER.warn("Trying to set block entity {} at position {}, but state {} does not allow it", new Object[]{tileentity, blockposition, iblockdata}); @@ -90,7 +90,7 @@ } else { IBlockData iblockdata1 = tileentity.getBlockState(); -@@ -470,6 +493,12 @@ +@@ -495,6 +518,12 @@ if (this.isInLevel()) { TileEntity tileentity = (TileEntity) this.blockEntities.remove(blockposition); @@ -103,7 +103,7 @@ if (tileentity != null) { World world = this.level; -@@ -523,6 +552,57 @@ +@@ -548,6 +577,57 @@ } @@ -161,7 +161,7 @@ public boolean isEmpty() { return false; } -@@ -718,7 +798,7 @@ +@@ -745,7 +825,7 @@ private void updateBlockEntityTicker(T t0) { IBlockData iblockdata = t0.getBlockState(); @@ -170,7 +170,7 @@ if (blockentityticker == null) { this.removeBlockEntityTicker(t0.getBlockPos()); -@@ -803,7 +883,7 @@ +@@ -836,7 +916,7 @@ private boolean loggedInvalidBlockState; a(final TileEntity tileentity, final BlockEntityTicker blockentityticker) { diff --git a/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch b/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch index 2978daa4..72784c4b 100644 --- a/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch +++ b/nms-patches/net/minecraft/world/level/chunk/ChunkSection.patch @@ -1,20 +1,24 @@ --- a/net/minecraft/world/level/chunk/ChunkSection.java +++ b/net/minecraft/world/level/chunk/ChunkSection.java -@@ -23,9 +23,11 @@ +@@ -23,7 +23,7 @@ private short tickingBlockCount; private short tickingFluidCount; private final DataPaletteBlock states; - private PalettedContainerRO> biomes; -+ // CraftBukkit start - read/write -+ private DataPaletteBlock> biomes; ++ private DataPaletteBlock> biomes; // CraftBukkit - read/write + + private ChunkSection(ChunkSection chunksection) { + this.nonEmptyBlockCount = chunksection.nonEmptyBlockCount; +@@ -33,7 +33,7 @@ + this.biomes = chunksection.biomes.copy(); + } - public ChunkSection(DataPaletteBlock datapaletteblock, PalettedContainerRO> palettedcontainerro) { -+ public ChunkSection(DataPaletteBlock datapaletteblock, DataPaletteBlock> palettedcontainerro) { -+ // CraftBukkit end ++ public ChunkSection(DataPaletteBlock datapaletteblock, DataPaletteBlock> palettedcontainerro) { // CraftBukkit - read/write this.states = datapaletteblock; this.biomes = palettedcontainerro; this.recalcBlockCounts(); -@@ -188,6 +190,12 @@ +@@ -196,6 +196,12 @@ return (Holder) this.biomes.get(i, j, k); } diff --git a/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch b/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch index 715e6fbb..b8d23e44 100644 --- a/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch +++ b/nms-patches/net/minecraft/world/level/chunk/IChunkAccess.patch @@ -24,11 +24,15 @@ private static void replaceMissingSections(IRegistry iregistry, ChunkSection[] achunksection) { for (int i = 0; i < achunksection.length; ++i) { -@@ -270,10 +279,11 @@ - - public void setUnsaved(boolean flag) { - this.unsaved = flag; -+ if (!flag) this.persistentDataContainer.dirty(false); // CraftBukkit - SPIGOT-6814: chunk was saved, pdc is no longer dirty +@@ -275,6 +284,7 @@ + public boolean tryMarkSaved() { + if (this.unsaved) { + this.unsaved = false; ++ this.persistentDataContainer.dirty(false); // CraftBukkit - SPIGOT-6814: chunk was saved, pdc is no longer dirty + return true; + } else { + return false; +@@ -282,7 +292,7 @@ } public boolean isUnsaved() { @@ -37,14 +41,14 @@ } public abstract ChunkStatus getPersistedStatus(); -@@ -449,6 +459,27 @@ +@@ -458,6 +468,27 @@ } } + // CraftBukkit start + public void setBiome(int i, int j, int k, Holder biome) { + try { -+ int l = QuartPos.fromBlock(this.getMinBuildHeight()); ++ int l = QuartPos.fromBlock(this.getMinY()); + int i1 = l + QuartPos.fromBlock(this.getHeight()) - 1; + int j1 = MathHelper.clamp(j, l, i1); + int k1 = this.getSectionIndex(QuartPos.toBlock(j1)); diff --git a/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch b/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch index e8d99c2b..520b5c69 100644 --- a/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch +++ b/nms-patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java -@@ -38,7 +38,7 @@ +@@ -36,7 +36,7 @@ static CompletableFuture generateStructureStarts(WorldGenContext worldgencontext, ChunkStep chunkstep, StaticCache2D staticcache2d, IChunkAccess ichunkaccess) { WorldServer worldserver = worldgencontext.level(); @@ -9,20 +9,16 @@ worldgencontext.generator().createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), ichunkaccess, worldgencontext.structureManager()); } -@@ -177,7 +177,21 @@ +@@ -170,7 +170,17 @@ private static void postLoadProtoChunk(WorldServer worldserver, List list) { if (!list.isEmpty()) { -- worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver)); +- worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver, EntitySpawnReason.LOAD)); + // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities -+ worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver).filter((entity) -> { ++ worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver, EntitySpawnReason.LOAD).filter((entity) -> { + boolean needsRemoval = false; + net.minecraft.server.dedicated.DedicatedServer server = worldserver.getCraftServer().getServer(); -+ if (!server.areNpcsEnabled() && entity instanceof net.minecraft.world.entity.npc.NPC) { -+ entity.discard(null); // CraftBukkit - add Bukkit remove cause -+ needsRemoval = true; -+ } -+ if (!server.isSpawningAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) { ++ if (!worldserver.getChunkSource().spawnFriendlies && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) { + entity.discard(null); // CraftBukkit - add Bukkit remove cause + needsRemoval = true; + } diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch b/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch deleted file mode 100644 index f8b2d183..00000000 --- a/nms-patches/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.patch +++ /dev/null @@ -1,111 +0,0 @@ ---- a/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java -+++ b/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java -@@ -105,7 +105,7 @@ - ChunkProviderServer chunkproviderserver = worldserver.getChunkSource(); - LevelLightEngine levellightengine = chunkproviderserver.getLightEngine(); - IRegistry iregistry = worldserver.registryAccess().registryOrThrow(Registries.BIOME); -- Codec>> codec = makeBiomeCodec(iregistry); -+ Codec>> codec = makeBiomeCodecRW(iregistry); // CraftBukkit - read/write - boolean flag2 = false; - - for (int j = 0; j < nbttaglist.size(); ++j) { -@@ -124,17 +124,17 @@ - datapaletteblock = new DataPaletteBlock<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.d.SECTION_STATES); - } - -- Object object; -+ DataPaletteBlock object; // CraftBukkit - read/write - - if (nbttagcompound1.contains("biomes", 10)) { -- object = (PalettedContainerRO) codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound1.getCompound("biomes")).promotePartial((s) -> { -+ object = codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound1.getCompound("biomes")).promotePartial((s) -> { // CraftBukkit - decompile error - logErrors(chunkcoordintpair, b0, s); - }).getOrThrow(ChunkRegionLoader.a::new); - } else { - object = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), DataPaletteBlock.d.SECTION_BIOMES); - } - -- ChunkSection chunksection = new ChunkSection(datapaletteblock, (PalettedContainerRO) object); -+ ChunkSection chunksection = new ChunkSection(datapaletteblock, (DataPaletteBlock) object); // CraftBukkit - read/write - - achunksection[k] = chunksection; - SectionPosition sectionposition = SectionPosition.of(chunkcoordintpair, b0); -@@ -171,7 +171,7 @@ - dataresult = BlendingData.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("blending_data"))); - logger = ChunkRegionLoader.LOGGER; - Objects.requireNonNull(logger); -- blendingdata = (BlendingData) dataresult.resultOrPartial(logger::error).orElse((Object) null); -+ blendingdata = (BlendingData) ((DataResult) dataresult).resultOrPartial(logger::error).orElse(null); // CraftBukkit - decompile error - } else { - blendingdata = null; - } -@@ -202,7 +202,7 @@ - dataresult = BelowZeroRetrogen.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen"))); - logger = ChunkRegionLoader.LOGGER; - Objects.requireNonNull(logger); -- Optional optional = dataresult.resultOrPartial(logger::error); -+ Optional optional = ((DataResult) dataresult).resultOrPartial(logger::error); // CraftBukkit - decompile error - - Objects.requireNonNull(protochunk); - optional.ifPresent(protochunk::setBelowZeroRetrogen); -@@ -216,6 +216,13 @@ - } - } - -+ // CraftBukkit start - load chunk persistent data from nbt - SPIGOT-6814: Already load PDC here to account for 1.17 to 1.18 chunk upgrading. -+ net.minecraft.nbt.NBTBase persistentBase = nbttagcompound.get("ChunkBukkitValues"); -+ if (persistentBase instanceof NBTTagCompound) { -+ ((IChunkAccess) object1).persistentDataContainer.putAll((NBTTagCompound) persistentBase); -+ } -+ // CraftBukkit end -+ - ((IChunkAccess) object1).setLightCorrect(flag); - NBTTagCompound nbttagcompound2 = nbttagcompound.getCompound("Heightmaps"); - EnumSet enumset = EnumSet.noneOf(HeightMap.Type.class); -@@ -295,6 +302,12 @@ - return DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS)); - } - -+ // CraftBukkit start - read/write -+ private static Codec>> makeBiomeCodecRW(IRegistry iregistry) { -+ return DataPaletteBlock.codecRW(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS)); -+ } -+ // CraftBukkit end -+ - public static NBTTagCompound write(WorldServer worldserver, IChunkAccess ichunkaccess) { - ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); - NBTTagCompound nbttagcompound = GameProfileSerializer.addCurrentDataVersion(new NBTTagCompound()); -@@ -306,7 +319,7 @@ - nbttagcompound.putLong("InhabitedTime", ichunkaccess.getInhabitedTime()); - nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(ichunkaccess.getPersistedStatus()).toString()); - BlendingData blendingdata = ichunkaccess.getBlendingData(); -- DataResult dataresult; -+ DataResult dataresult; // CraftBukkit - decompile error - Logger logger; - - if (blendingdata != null) { -@@ -430,6 +443,11 @@ - - nbttagcompound.put("Heightmaps", nbttagcompound3); - nbttagcompound.put("structures", packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences())); -+ // CraftBukkit start - store chunk persistent data in nbt -+ if (!ichunkaccess.persistentDataContainer.isEmpty()) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading. -+ nbttagcompound.put("ChunkBukkitValues", ichunkaccess.persistentDataContainer.toTagCompound()); -+ } -+ // CraftBukkit end - return nbttagcompound; - } - -@@ -534,6 +552,12 @@ - StructureStart structurestart = StructureStart.loadStaticStart(structurepieceserializationcontext, nbttagcompound1.getCompound(s), i); - - if (structurestart != null) { -+ // CraftBukkit start - load persistent data for structure start -+ net.minecraft.nbt.NBTBase persistentBase = nbttagcompound1.getCompound(s).get("StructureBukkitValues"); -+ if (persistentBase instanceof NBTTagCompound) { -+ structurestart.persistentDataContainer.putAll((NBTTagCompound) persistentBase); -+ } -+ // CraftBukkit end - map.put(structure, structurestart); - } - } diff --git a/nms-patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.patch b/nms-patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.patch new file mode 100644 index 00000000..ccd848a8 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.patch @@ -0,0 +1,146 @@ +--- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java ++++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +@@ -76,7 +76,8 @@ + import net.minecraft.world.ticks.TickListChunk; + import org.slf4j.Logger; + +-public record SerializableChunkData(IRegistry biomeRegistry, ChunkCoordIntPair chunkPos, int minSectionY, long lastUpdateTime, long inhabitedTime, ChunkStatus chunkStatus, @Nullable BlendingData.d blendingData, @Nullable BelowZeroRetrogen belowZeroRetrogen, ChunkConverter upgradeData, @Nullable long[] carvingMask, Map heightmaps, IChunkAccess.a packedTicks, ShortList[] postProcessingSections, boolean lightCorrect, List sectionData, List entities, List blockEntities, NBTTagCompound structureData) { ++// CraftBukkit - persistentDataContainer ++public record SerializableChunkData(IRegistry biomeRegistry, ChunkCoordIntPair chunkPos, int minSectionY, long lastUpdateTime, long inhabitedTime, ChunkStatus chunkStatus, @Nullable BlendingData.d blendingData, @Nullable BelowZeroRetrogen belowZeroRetrogen, ChunkConverter upgradeData, @Nullable long[] carvingMask, Map heightmaps, IChunkAccess.a packedTicks, ShortList[] postProcessingSections, boolean lightCorrect, List sectionData, List entities, List blockEntities, NBTTagCompound structureData, @Nullable NBTBase persistentDataContainer) { + + public static final Codec> BLOCK_STATE_CODEC = DataPaletteBlock.codecRW(Block.BLOCK_STATE_REGISTRY, IBlockData.CODEC, DataPaletteBlock.d.SECTION_STATES, Blocks.AIR.defaultBlockState()); + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -110,7 +111,7 @@ + dataresult = BlendingData.d.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("blending_data")); + logger = SerializableChunkData.LOGGER; + Objects.requireNonNull(logger); +- blendingdata_d = (BlendingData.d) dataresult.resultOrPartial(logger::error).orElse((Object) null); ++ blendingdata_d = (BlendingData.d) ((DataResult) dataresult).resultOrPartial(logger::error).orElse(null); // CraftBukkit - decompile error + } else { + blendingdata_d = null; + } +@@ -121,7 +122,7 @@ + dataresult = BelowZeroRetrogen.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen")); + logger = SerializableChunkData.LOGGER; + Objects.requireNonNull(logger); +- belowzeroretrogen = (BelowZeroRetrogen) dataresult.resultOrPartial(logger::error).orElse((Object) null); ++ belowzeroretrogen = (BelowZeroRetrogen) ((DataResult) dataresult).resultOrPartial(logger::error).orElse(null); // CraftBukkit - decompile error + } else { + belowzeroretrogen = null; + } +@@ -178,7 +179,7 @@ + NBTTagList nbttaglist2 = nbttagcompound.getList("sections", 10); + List list4 = new ArrayList(nbttaglist2.size()); + IRegistry iregistry = iregistrycustom.lookupOrThrow(Registries.BIOME); +- Codec>> codec = makeBiomeCodec(iregistry); ++ Codec>> codec = makeBiomeCodecRW(iregistry); // CraftBukkit - read/write + + for (int i1 = 0; i1 < nbttaglist2.size(); ++i1) { + NBTTagCompound nbttagcompound3 = nbttaglist2.getCompound(i1); +@@ -196,17 +197,17 @@ + datapaletteblock = new DataPaletteBlock<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.d.SECTION_STATES); + } + +- Object object; ++ DataPaletteBlock object; // CraftBukkit - read/write + + if (nbttagcompound3.contains("biomes", 10)) { +- object = (PalettedContainerRO) codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound3.getCompound("biomes")).promotePartial((s1) -> { ++ object = codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound3.getCompound("biomes")).promotePartial((s1) -> { // CraftBukkit - read/write + logErrors(chunkcoordintpair, b0, s1); + }).getOrThrow(SerializableChunkData.a::new); + } else { + object = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getOrThrow(Biomes.PLAINS), DataPaletteBlock.d.SECTION_BIOMES); + } + +- chunksection = new ChunkSection(datapaletteblock, (PalettedContainerRO) object); ++ chunksection = new ChunkSection(datapaletteblock, (DataPaletteBlock) object); // CraftBukkit - read/write + } else { + chunksection = null; + } +@@ -217,7 +218,8 @@ + list4.add(new SerializableChunkData.b(b0, chunksection, nibblearray, nibblearray1)); + } + +- return new SerializableChunkData(iregistry, chunkcoordintpair, levelheightaccessor.getMinSectionY(), i, j, chunkstatus, blendingdata_d, belowzeroretrogen, chunkconverter, along, map, ichunkaccess_a, ashortlist, flag, list4, list2, list3, nbttagcompound2); ++ // CraftBukkit - ChunkBukkitValues ++ return new SerializableChunkData(iregistry, chunkcoordintpair, levelheightaccessor.getMinSectionY(), i, j, chunkstatus, blendingdata_d, belowzeroretrogen, chunkconverter, along, map, ichunkaccess_a, ashortlist, flag, list4, list2, list3, nbttagcompound2, nbttagcompound.get("ChunkBukkitValues")); + } + } + +@@ -289,6 +291,12 @@ + } + } + ++ // CraftBukkit start - load chunk persistent data from nbt - SPIGOT-6814: Already load PDC here to account for 1.17 to 1.18 chunk upgrading. ++ if (persistentDataContainer instanceof NBTTagCompound) { ++ ((IChunkAccess) object).persistentDataContainer.putAll((NBTTagCompound) persistentDataContainer); ++ } ++ // CraftBukkit end ++ + ((IChunkAccess) object).setLightCorrect(this.lightCorrect); + EnumSet enumset = EnumSet.noneOf(HeightMap.Type.class); + Iterator iterator1 = ((IChunkAccess) object).getPersistedStatus().heightmapsAfter().iterator(); +@@ -348,6 +356,12 @@ + return DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getOrThrow(Biomes.PLAINS)); + } + ++ // CraftBukkit start - read/write ++ private static Codec>> makeBiomeCodecRW(IRegistry iregistry) { ++ return DataPaletteBlock.codecRW(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getOrThrow(Biomes.PLAINS)); ++ } ++ // CraftBukkit end ++ + public static SerializableChunkData copyOf(WorldServer worldserver, IChunkAccess ichunkaccess) { + if (!ichunkaccess.canBeSerialized()) { + throw new IllegalArgumentException("Chunk can't be serialized: " + String.valueOf(ichunkaccess)); +@@ -419,7 +433,14 @@ + }); + NBTTagCompound nbttagcompound1 = packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences()); + +- return new SerializableChunkData(worldserver.registryAccess().lookupOrThrow(Registries.BIOME), chunkcoordintpair, ichunkaccess.getMinSectionY(), worldserver.getGameTime(), ichunkaccess.getInhabitedTime(), ichunkaccess.getPersistedStatus(), (BlendingData.d) Optionull.map(ichunkaccess.getBlendingData(), BlendingData::pack), ichunkaccess.getBelowZeroRetrogen(), ichunkaccess.getUpgradeData().copy(), along, map, ichunkaccess_a, ashortlist, ichunkaccess.isLightCorrect(), list, list2, list1, nbttagcompound1); ++ // CraftBukkit start - store chunk persistent data in nbt ++ NBTTagCompound persistentDataContainer = null; ++ if (!ichunkaccess.persistentDataContainer.isEmpty()) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading. ++ persistentDataContainer = ichunkaccess.persistentDataContainer.toTagCompound(); ++ } ++ ++ return new SerializableChunkData(worldserver.registryAccess().lookupOrThrow(Registries.BIOME), chunkcoordintpair, ichunkaccess.getMinSectionY(), worldserver.getGameTime(), ichunkaccess.getInhabitedTime(), ichunkaccess.getPersistedStatus(), (BlendingData.d) Optionull.map(ichunkaccess.getBlendingData(), BlendingData::pack), ichunkaccess.getBelowZeroRetrogen(), ichunkaccess.getUpgradeData().copy(), along, map, ichunkaccess_a, ashortlist, ichunkaccess.isLightCorrect(), list, list2, list1, nbttagcompound1, persistentDataContainer); ++ // CraftBukkit end + } + } + +@@ -432,7 +453,7 @@ + nbttagcompound.putLong("LastUpdate", this.lastUpdateTime); + nbttagcompound.putLong("InhabitedTime", this.inhabitedTime); + nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(this.chunkStatus).toString()); +- DataResult dataresult; ++ DataResult dataresult; // CraftBukkit - decompile error + Logger logger; + + if (this.blendingData != null) { +@@ -513,6 +534,11 @@ + }); + nbttagcompound.put("Heightmaps", nbttagcompound2); + nbttagcompound.put("structures", this.structureData); ++ // CraftBukkit start - store chunk persistent data in nbt ++ if (persistentDataContainer != null) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading. ++ nbttagcompound.put("ChunkBukkitValues", persistentDataContainer); ++ } ++ // CraftBukkit end + return nbttagcompound; + } + +@@ -623,6 +649,12 @@ + StructureStart structurestart = StructureStart.loadStaticStart(structurepieceserializationcontext, nbttagcompound1.getCompound(s), i); + + if (structurestart != null) { ++ // CraftBukkit start - load persistent data for structure start ++ net.minecraft.nbt.NBTBase persistentBase = nbttagcompound1.getCompound(s).get("StructureBukkitValues"); ++ if (persistentBase instanceof NBTTagCompound) { ++ structurestart.persistentDataContainer.putAll((NBTTagCompound) persistentBase); ++ } ++ // CraftBukkit end + map.put(structure, structurestart); + } + } diff --git a/nms-patches/net/minecraft/world/level/dimension/end/EnderDragonBattle.patch b/nms-patches/net/minecraft/world/level/dimension/end/EnderDragonBattle.patch index 86ffe4ac..ad62a4bf 100644 --- a/nms-patches/net/minecraft/world/level/dimension/end/EnderDragonBattle.patch +++ b/nms-patches/net/minecraft/world/level/dimension/end/EnderDragonBattle.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/dimension/end/EnderDragonBattle.java +++ b/net/minecraft/world/level/dimension/end/EnderDragonBattle.java -@@ -110,14 +110,14 @@ +@@ -111,14 +111,14 @@ this.origin = blockposition; this.validPlayer = IEntitySelector.ENTITY_STILL_ALIVE.and(IEntitySelector.withinDistance((double) blockposition.getX(), (double) (128 + blockposition.getY()), (double) blockposition.getZ(), 192.0D)); this.needsStateScanning = enderdragonbattle_a.needsStateScanning; @@ -17,7 +17,7 @@ this.gateways.addAll((Collection) enderdragonbattle_a.gateways.orElseGet(() -> { ObjectArrayList objectarraylist = new ObjectArrayList(ContiguousSet.create(Range.closedOpen(0, 20), DiscreteDomain.integers())); -@@ -207,7 +207,7 @@ +@@ -208,7 +208,7 @@ this.dragonKilled = false; if (!flag) { EnderDragonBattle.LOGGER.info("But we didn't have a portal, let's remove it."); @@ -26,7 +26,7 @@ this.dragonUUID = null; } } -@@ -510,7 +510,7 @@ +@@ -513,7 +513,7 @@ return this.previouslyKilled; } @@ -35,7 +35,7 @@ if (this.dragonKilled && this.respawnStage == null) { BlockPosition blockposition = this.portalLocation; -@@ -537,19 +537,19 @@ +@@ -540,19 +540,19 @@ List list1 = this.level.getEntitiesOfClass(EntityEnderCrystal.class, new AxisAlignedBB(blockposition1.relative(enumdirection, 2))); if (list1.isEmpty()) { @@ -59,7 +59,7 @@ if (this.dragonKilled && this.respawnStage == null) { for (ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = this.findExitPortal(); shapedetector_shapedetectorcollection != null; shapedetector_shapedetectorcollection = this.findExitPortal()) { for (int i = 0; i < this.exitPortalPattern.getWidth(); ++i) { -@@ -569,8 +569,9 @@ +@@ -572,8 +572,9 @@ this.respawnTime = 0; this.spawnExitPortal(false); this.respawnCrystals = list; diff --git a/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch index 6d10880d..c2787a53 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPatrol.patch @@ -3,7 +3,7 @@ @@ -116,7 +116,7 @@ entitymonsterpatrolling.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); - entitymonsterpatrolling.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(blockposition), EnumMobSpawn.PATROL, (GroupDataEntity) null); + entitymonsterpatrolling.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(blockposition), EntitySpawnReason.PATROL, (GroupDataEntity) null); - worldserver.addFreshEntityWithPassengers(entitymonsterpatrolling); + worldserver.addFreshEntityWithPassengers(entitymonsterpatrolling, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); // CraftBukkit return true; diff --git a/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch index ac5104bf..35c075ea 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/MobSpawnerPhantom.patch @@ -3,7 +3,7 @@ @@ -74,7 +74,7 @@ if (entityphantom != null) { entityphantom.moveTo(blockposition1, 0.0F, 0.0F); - groupdataentity = entityphantom.finalizeSpawn(worldserver, difficultydamagescaler, EnumMobSpawn.NATURAL, groupdataentity); + groupdataentity = entityphantom.finalizeSpawn(worldserver, difficultydamagescaler, EntitySpawnReason.NATURAL, groupdataentity); - worldserver.addFreshEntityWithPassengers(entityphantom); + worldserver.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit ++i; diff --git a/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch b/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch index 125efd65..f8a04e34 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.patch @@ -27,7 +27,7 @@ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); for (int i = -2; i <= 2; ++i) { -@@ -29,16 +42,33 @@ +@@ -29,16 +42,36 @@ BlockPosition.MutableBlockPosition blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(blockposition).move(j, k, i); Block block = k == -1 ? Blocks.OBSIDIAN : Blocks.AIR; @@ -47,19 +47,22 @@ } } + // CraftBukkit start -+ if (entity == null) { -+ // SPIGOT-7746: Entity will only be null during world generation, which is async, so just generate without event -+ blockList.updateList(); -+ return; -+ } ++ // SPIGOT-7746: Entity will only be null during world generation, which is async, so just generate without event ++ if (entity != null) { ++ org.bukkit.World bworld = worldaccess.getLevel().getWorld(); ++ PortalCreateEvent portalEvent = new PortalCreateEvent((List) (List) blockList.getList(), bworld, entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); + -+ org.bukkit.World bworld = worldaccess.getLevel().getWorld(); -+ PortalCreateEvent portalEvent = new PortalCreateEvent((List) (List) blockList.getList(), bworld, entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); ++ worldaccess.getLevel().getCraftServer().getPluginManager().callEvent(portalEvent); ++ if (portalEvent.isCancelled()) { ++ return; ++ } ++ } + -+ worldaccess.getLevel().getCraftServer().getPluginManager().callEvent(portalEvent); -+ if (!portalEvent.isCancelled()) { -+ blockList.updateList(); ++ // SPIGOT-7856: End platform not dropping items after replacing blocks ++ if (flag) { ++ blockList.getList().forEach((state) -> worldaccess.destroyBlock(state.getPosition(), true, null)); + } ++ blockList.updateList(); + // CraftBukkit end } diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch index 1c6fcf59..a8d3bc86 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.patch @@ -11,7 +11,7 @@ public class PersistentStructureLegacy { private static final Map CURRENT_TO_LEGACY_MAP = (Map) SystemUtils.make(Maps.newHashMap(), (hashmap) -> { -@@ -236,16 +240,16 @@ +@@ -233,16 +237,16 @@ } } diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch index d4be33f9..e9a12400 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/StructurePiece.patch @@ -4,8 +4,8 @@ private EnumBlockRotation rotation; protected int genDepth; private final WorldGenFeatureStructurePieceType type; -- private static final Set SHAPE_CHECK_BLOCKS = ImmutableSet.builder().add(Blocks.NETHER_BRICK_FENCE).add(Blocks.TORCH).add(Blocks.WALL_TORCH).add(Blocks.OAK_FENCE).add(Blocks.SPRUCE_FENCE).add(Blocks.DARK_OAK_FENCE).add(Blocks.ACACIA_FENCE).add(Blocks.BIRCH_FENCE).add(Blocks.JUNGLE_FENCE).add(Blocks.LADDER).add(Blocks.IRON_BARS).build(); -+ public static final Set SHAPE_CHECK_BLOCKS = ImmutableSet.builder().add(Blocks.NETHER_BRICK_FENCE).add(Blocks.TORCH).add(Blocks.WALL_TORCH).add(Blocks.OAK_FENCE).add(Blocks.SPRUCE_FENCE).add(Blocks.DARK_OAK_FENCE).add(Blocks.ACACIA_FENCE).add(Blocks.BIRCH_FENCE).add(Blocks.JUNGLE_FENCE).add(Blocks.LADDER).add(Blocks.IRON_BARS).build(); // CraftBukkit - decompile error / PAIL private -> public +- private static final Set SHAPE_CHECK_BLOCKS = ImmutableSet.builder().add(Blocks.NETHER_BRICK_FENCE).add(Blocks.TORCH).add(Blocks.WALL_TORCH).add(Blocks.OAK_FENCE).add(Blocks.SPRUCE_FENCE).add(Blocks.DARK_OAK_FENCE).add(Blocks.PALE_OAK_FENCE).add(Blocks.ACACIA_FENCE).add(Blocks.BIRCH_FENCE).add(Blocks.JUNGLE_FENCE).add(Blocks.LADDER).add(Blocks.IRON_BARS).build(); ++ public static final Set SHAPE_CHECK_BLOCKS = ImmutableSet.builder().add(Blocks.NETHER_BRICK_FENCE).add(Blocks.TORCH).add(Blocks.WALL_TORCH).add(Blocks.OAK_FENCE).add(Blocks.SPRUCE_FENCE).add(Blocks.DARK_OAK_FENCE).add(Blocks.PALE_OAK_FENCE).add(Blocks.ACACIA_FENCE).add(Blocks.BIRCH_FENCE).add(Blocks.JUNGLE_FENCE).add(Blocks.LADDER).add(Blocks.IRON_BARS).build(); // CraftBukkit - decompile error / PAIL private -> public protected StructurePiece(WorldGenFeatureStructurePieceType worldgenfeaturestructurepiecetype, int i, StructureBoundingBox structureboundingbox) { this.type = worldgenfeaturestructurepiecetype; diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/StructureStart.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/StructureStart.patch index d951f977..cf6f6199 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/StructureStart.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/StructureStart.patch @@ -52,4 +52,4 @@ + // CraftBukkit end if (this.isValid()) { - nbttagcompound.putString("id", structurepieceserializationcontext.registryAccess().registryOrThrow(Registries.STRUCTURE).getKey(this.structure).toString()); + nbttagcompound.putString("id", structurepieceserializationcontext.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(this.structure).toString()); diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.patch index de8fd65a..9aea5241 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java -@@ -284,7 +284,12 @@ +@@ -285,7 +285,12 @@ BlockPosition blockposition1 = blockposition.below(); if (structureboundingbox.isInside(blockposition1)) { diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.patch index ed2f4037..086c189c 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java -@@ -43,6 +43,10 @@ +@@ -44,6 +44,10 @@ import net.minecraft.world.level.storage.loot.LootTables; import org.slf4j.Logger; @@ -11,7 +11,7 @@ public class MineshaftPieces { static final Logger LOGGER = LogUtils.getLogger(); -@@ -515,6 +519,8 @@ +@@ -520,6 +524,8 @@ if (structureboundingbox.isInside(blockposition_mutableblockposition) && this.isInterior(generatoraccessseed, 1, 0, l, structureboundingbox)) { this.hasPlacedSpider = true; @@ -20,7 +20,7 @@ generatoraccessseed.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2); TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition); -@@ -523,6 +529,9 @@ +@@ -528,6 +534,9 @@ tileentitymobspawner.setEntityId(EntityTypes.CAVE_SPIDER, randomsource); } @@ -30,7 +30,7 @@ } } } -@@ -814,11 +823,11 @@ +@@ -819,11 +828,11 @@ public d(NBTTagCompound nbttagcompound) { super(WorldGenFeatureStructurePieceType.MINE_SHAFT_ROOM, nbttagcompound); @@ -44,7 +44,7 @@ List list = this.childEntranceBoxes; Objects.requireNonNull(this.childEntranceBoxes); -@@ -924,7 +933,7 @@ +@@ -929,7 +938,7 @@ @Override protected void addAdditionalSaveData(StructurePieceSerializationContext structurepieceserializationcontext, NBTTagCompound nbttagcompound) { super.addAdditionalSaveData(structurepieceserializationcontext, nbttagcompound); diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.patch index e8ae59be..bfb61781 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.patch @@ -19,5 +19,5 @@ + placeCraftBlockEntity(worldaccess, blockposition, craftChest, 2); + // CraftBukkit end } else if ("drowned".equals(s)) { - EntityDrowned entitydrowned = (EntityDrowned) EntityTypes.DROWNED.create(worldaccess.getLevel()); + EntityDrowned entitydrowned = (EntityDrowned) EntityTypes.DROWNED.create(worldaccess.getLevel(), EntitySpawnReason.STRUCTURE); 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 9767269c..d46ee757 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 @@ -3,7 +3,7 @@ @@ -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); + entitywitch.finalizeSpawn(generatoraccessseed, generatoraccessseed.getCurrentDifficultyAt(blockposition_mutableblockposition), EntitySpawnReason.STRUCTURE, (GroupDataEntity) null); - generatoraccessseed.addFreshEntityWithPassengers(entitywitch); + generatoraccessseed.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } @@ -12,7 +12,7 @@ @@ -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); + entitycat.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(blockposition_mutableblockposition), EntitySpawnReason.STRUCTURE, (GroupDataEntity) 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 3525993f..f8027cf9 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 -@@ -52,6 +52,12 @@ +@@ -56,6 +56,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 @@ +@@ -74,6 +80,11 @@ private BaseBlockPosition size; private String author; @@ -25,7 +25,7 @@ public DefinedStructure() { this.size = BaseBlockPosition.ZERO; this.author = "?"; -@@ -143,7 +154,7 @@ +@@ -147,7 +158,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(); -@@ -229,6 +240,19 @@ +@@ -253,6 +264,19 @@ if (this.palettes.isEmpty()) { return false; } else { @@ -54,7 +54,7 @@ List list = definedstructureinfo.getRandomPalette(this.palettes, blockposition).blocks(); if ((!list.isEmpty() || !definedstructureinfo.isIgnoreEntities() && !this.entityInfoList.isEmpty()) && this.size.getX() >= 1 && this.size.getY() >= 1 && this.size.getZ() >= 1) { -@@ -260,6 +284,20 @@ +@@ -284,6 +308,20 @@ Clearable.tryClear(tileentity); worldaccess.setBlock(blockposition2, Blocks.BARRIER.defaultBlockState(), 20); } @@ -75,7 +75,7 @@ if (worldaccess.setBlock(blockposition2, iblockdata, i)) { j = Math.min(j, blockposition2.getX()); -@@ -272,7 +310,7 @@ +@@ -296,7 +334,7 @@ if (definedstructure_blockinfo.nbt != null) { tileentity = worldaccess.getBlockEntity(blockposition2); if (tileentity != null) { @@ -84,7 +84,7 @@ definedstructure_blockinfo.nbt.putLong("LootTableSeed", randomsource.nextLong()); } -@@ -377,7 +415,7 @@ +@@ -401,7 +439,7 @@ } if (!definedstructureinfo.isIgnoreEntities()) { @@ -93,14 +93,14 @@ } return true; -@@ -479,11 +517,13 @@ +@@ -503,11 +541,13 @@ } private static Optional createEntityIgnoreException(WorldAccess worldaccess, NBTTagCompound nbttagcompound) { - try { + // CraftBukkit start + // try { - return EntityTypes.create(nbttagcompound, worldaccess.getLevel()); + return EntityTypes.create(nbttagcompound, worldaccess.getLevel(), EntitySpawnReason.STRUCTURE); - } catch (Exception exception) { - return Optional.empty(); - } @@ -111,7 +111,7 @@ } public BaseBlockPosition getSize(EnumBlockRotation enumblockrotation) { -@@ -697,6 +737,11 @@ +@@ -721,6 +761,11 @@ nbttagcompound.put("entities", nbttaglist3); nbttagcompound.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ())); @@ -123,7 +123,7 @@ return GameProfileSerializer.addCurrentDataVersion(nbttagcompound); } -@@ -736,6 +781,12 @@ +@@ -760,6 +805,12 @@ } } @@ -136,11 +136,11 @@ } private void loadPalette(HolderGetter holdergetter, NBTTagList nbttaglist, NBTTagList nbttaglist1) { -@@ -865,7 +916,7 @@ +@@ -924,7 +975,7 @@ public IBlockData stateFor(int i) { IBlockData iblockdata = (IBlockData) this.ids.byId(i); -- return iblockdata == null ? DefinedStructure.b.DEFAULT_BLOCK_STATE : iblockdata; +- return iblockdata == null ? DefinedStructure.c.DEFAULT_BLOCK_STATE : iblockdata; + return iblockdata == null ? DEFAULT_BLOCK_STATE : iblockdata; // CraftBukkit - decompile error } diff --git a/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch b/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch index 08f32d6b..4eee99d5 100644 --- a/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch +++ b/nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.patch @@ -21,5 +21,5 @@ + return list.get(this.palette); + // CraftBukkit end } else { - return (DefinedStructure.a) list.get(this.getRandom(blockposition).nextInt(i)); + return (DefinedStructure.b) list.get(this.getRandom(blockposition).nextInt(i)); } diff --git a/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch b/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch index 753e886f..0cff368d 100644 --- a/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch +++ b/nms-patches/net/minecraft/world/level/material/FluidTypeFlowing.patch @@ -16,62 +16,60 @@ public abstract class FluidTypeFlowing extends FluidType { public static final BlockStateBoolean FALLING = BlockProperties.FALLING; -@@ -132,6 +141,15 @@ - Fluid fluid1 = this.getNewLiquid(world, blockposition1, iblockdata1); +@@ -135,6 +144,15 @@ + FluidType fluidtype = fluid2.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(world, blockposition); -+ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN); -+ world.getCraftServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - this.spreadTo(world, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1); - if (this.sourceNeighborCount(world, blockposition) >= 3) { - this.spreadToSides(world, blockposition, fluid, iblockdata); -@@ -162,6 +180,15 @@ - IBlockData iblockdata1 = world.getBlockState(blockposition1); - - if (this.canSpreadTo(world, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) { + if (fluid1.canBeReplacedWith(worldserver, blockposition1, fluidtype, EnumDirection.DOWN) && canHoldSpecificFluid(worldserver, blockposition1, iblockdata1, fluidtype)) { + // CraftBukkit start -+ org.bukkit.block.Block source = CraftBlock.at(world, blockposition); -+ BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection)); -+ world.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.block.Block source = CraftBlock.at(worldserver, blockposition); ++ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN); ++ worldserver.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ continue; ++ return; + } + // CraftBukkit end - this.spreadTo(world, blockposition1, iblockdata1, enumdirection, fluid1); - } + this.spreadTo(worldserver, blockposition1, iblockdata1, EnumDirection.DOWN, fluid2); + if (this.sourceNeighborCount(worldserver, blockposition) >= 3) { + this.spreadToSides(worldserver, blockposition, fluid, iblockdata); +@@ -168,6 +186,15 @@ + Fluid fluid1 = (Fluid) entry.getValue(); + BlockPosition blockposition1 = blockposition.relative(enumdirection); + ++ // CraftBukkit start ++ org.bukkit.block.Block source = CraftBlock.at(worldserver, blockposition); ++ BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection)); ++ worldserver.getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ continue; ++ } ++ // CraftBukkit end + this.spreadTo(worldserver, blockposition1, worldserver.getBlockState(blockposition1), enumdirection, fluid1); } -@@ -436,12 +463,23 @@ +@@ -444,10 +471,24 @@ if (fluid1.isEmpty()) { fluid = fluid1; -- world.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 3); + iblockdata = Blocks.AIR.defaultBlockState(); + // CraftBukkit start -+ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(world, blockposition, Blocks.AIR.defaultBlockState()); ++ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(worldserver, blockposition, iblockdata); + if (event.isCancelled()) { + return; + } -+ world.setBlock(blockposition, ((CraftBlockData) event.getNewData()).getState(), 3); ++ iblockdata = ((CraftBlockData) event.getNewData()).getState(); + // CraftBukkit end + worldserver.setBlock(blockposition, iblockdata, 3); } else if (!fluid1.equals(fluid)) { fluid = fluid1; - IBlockData iblockdata = fluid1.createLegacyBlock(); -- -- world.setBlock(blockposition, iblockdata, 2); + iblockdata = fluid1.createLegacyBlock(); + // CraftBukkit start -+ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(world, blockposition, iblockdata); ++ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(worldserver, blockposition, iblockdata); + if (event.isCancelled()) { + return; + } -+ world.setBlock(blockposition, ((CraftBlockData) event.getNewData()).getState(), 2); ++ iblockdata = ((CraftBlockData) event.getNewData()).getState(); + // CraftBukkit end - world.scheduleTick(blockposition, fluid1.getType(), i); - world.updateNeighborsAt(blockposition, iblockdata.getBlock()); + worldserver.setBlock(blockposition, iblockdata, 3); + worldserver.scheduleTick(blockposition, fluid1.getType(), i); } diff --git a/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch b/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch index d6968185..b77cab1d 100644 --- a/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch +++ b/nms-patches/net/minecraft/world/level/material/FluidTypeLava.patch @@ -1,35 +1,35 @@ --- a/net/minecraft/world/level/material/FluidTypeLava.java +++ b/net/minecraft/world/level/material/FluidTypeLava.java -@@ -84,6 +84,13 @@ +@@ -85,6 +85,13 @@ if (iblockdata.isAir()) { - if (this.hasFlammableNeighbours(world, blockposition1)) { + if (this.hasFlammableNeighbours(worldserver, blockposition1)) { + // CraftBukkit start - Prevent lava putting something on fire -+ if (world.getBlockState(blockposition1).getBlock() != Blocks.FIRE) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, blockposition).isCancelled()) { ++ if (worldserver.getBlockState(blockposition1).getBlock() != Blocks.FIRE) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition1, blockposition).isCancelled()) { + continue; + } + } + // CraftBukkit end - world.setBlockAndUpdate(blockposition1, BlockFireAbstract.getState(world, blockposition1)); + worldserver.setBlockAndUpdate(blockposition1, BlockFireAbstract.getState(worldserver, blockposition1)); return; } -@@ -100,6 +107,14 @@ +@@ -101,6 +108,14 @@ } - if (world.isEmptyBlock(blockposition2.above()) && this.isFlammable(world, blockposition2)) { + if (worldserver.isEmptyBlock(blockposition2.above()) && this.isFlammable(worldserver, blockposition2)) { + // CraftBukkit start - Prevent lava putting something on fire + BlockPosition up = blockposition2.above(); -+ if (world.getBlockState(up).getBlock() != Blocks.FIRE) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, up, blockposition).isCancelled()) { ++ if (worldserver.getBlockState(up).getBlock() != Blocks.FIRE) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, up, blockposition).isCancelled()) { + continue; + } + } + // CraftBukkit end - world.setBlockAndUpdate(blockposition2.above(), BlockFireAbstract.getState(world, blockposition2)); + worldserver.setBlockAndUpdate(blockposition2.above(), BlockFireAbstract.getState(worldserver, blockposition2)); } } -@@ -195,7 +210,11 @@ +@@ -196,7 +211,11 @@ if (this.is(TagsFluid.LAVA) && fluid1.is(TagsFluid.WATER)) { if (iblockdata.getBlock() instanceof BlockFluids) { diff --git a/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch b/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch index 0a345134..903517a8 100644 --- a/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch +++ b/nms-patches/net/minecraft/world/level/portal/BlockPortalShape.patch @@ -1,75 +1,154 @@ --- a/net/minecraft/world/level/portal/BlockPortalShape.java +++ b/net/minecraft/world/level/portal/BlockPortalShape.java -@@ -21,6 +21,10 @@ - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -23,6 +23,11 @@ import net.minecraft.world.phys.shapes.VoxelShapes; + import org.apache.commons.lang3.mutable.MutableInt; +// CraftBukkit start ++import org.bukkit.craftbukkit.util.BlockStateListPopulator; +import org.bukkit.event.world.PortalCreateEvent; +// CraftBukkit end + public class BlockPortalShape { private static final int MIN_WIDTH = 2; -@@ -40,6 +44,7 @@ - private BlockPosition bottomLeft; - private int height; +@@ -40,8 +45,12 @@ + private final BlockPosition bottomLeft; + private final int height; private final int width; -+ org.bukkit.craftbukkit.util.BlockStateListPopulator blocks; // CraftBukkit - add field ++ // CraftBukkit start - add field ++ private final BlockStateListPopulator blocks; - public static Optional findEmptyPortalShape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { - return findPortalShape(generatoraccess, blockposition, (blockportalshape) -> { -@@ -60,6 +65,7 @@ +- private BlockPortalShape(EnumDirection.EnumAxis enumdirection_enumaxis, int i, EnumDirection enumdirection, BlockPosition blockposition, int j, int k) { ++ private BlockPortalShape(EnumDirection.EnumAxis enumdirection_enumaxis, int i, EnumDirection enumdirection, BlockPosition blockposition, int j, int k, BlockStateListPopulator blocks) { ++ this.blocks = blocks; ++ // CraftBukkit end + this.axis = enumdirection_enumaxis; + this.numPortalBlocks = i; + this.rightDir = enumdirection; +@@ -69,44 +78,45 @@ } - public BlockPortalShape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { -+ blocks = new org.bukkit.craftbukkit.util.BlockStateListPopulator(generatoraccess.getMinecraftWorld()); // CraftBukkit - this.level = generatoraccess; - this.axis = enumdirection_enumaxis; - this.rightDir = enumdirection_enumaxis == EnumDirection.EnumAxis.X ? EnumDirection.WEST : EnumDirection.SOUTH; -@@ -104,6 +110,7 @@ + public static BlockPortalShape findAnyShape(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { ++ BlockStateListPopulator blocks = new BlockStateListPopulator(((GeneratorAccess) iblockaccess).getMinecraftWorld()); // CraftBukkit + EnumDirection enumdirection = enumdirection_enumaxis == EnumDirection.EnumAxis.X ? EnumDirection.WEST : EnumDirection.SOUTH; +- BlockPosition blockposition1 = calculateBottomLeft(iblockaccess, enumdirection, blockposition); ++ BlockPosition blockposition1 = calculateBottomLeft(iblockaccess, enumdirection, blockposition, blocks); // CraftBukkit + + if (blockposition1 == null) { +- return new BlockPortalShape(enumdirection_enumaxis, 0, enumdirection, blockposition, 0, 0); ++ return new BlockPortalShape(enumdirection_enumaxis, 0, enumdirection, blockposition, 0, 0, blocks); // CraftBukkit + } else { +- int i = calculateWidth(iblockaccess, blockposition1, enumdirection); ++ int i = calculateWidth(iblockaccess, blockposition1, enumdirection, blocks); // CraftBukkit + + if (i == 0) { +- return new BlockPortalShape(enumdirection_enumaxis, 0, enumdirection, blockposition1, 0, 0); ++ return new BlockPortalShape(enumdirection_enumaxis, 0, enumdirection, blockposition1, 0, 0, blocks); // CraftBukkit + } else { + MutableInt mutableint = new MutableInt(); +- int j = calculateHeight(iblockaccess, blockposition1, enumdirection, i, mutableint); ++ int j = calculateHeight(iblockaccess, blockposition1, enumdirection, i, mutableint, blocks); // CraftBukkit + +- return new BlockPortalShape(enumdirection_enumaxis, mutableint.getValue(), enumdirection, blockposition1, i, j); ++ return new BlockPortalShape(enumdirection_enumaxis, mutableint.getValue(), enumdirection, blockposition1, i, j, blocks); // CraftBukkit + } + } + } + + @Nullable +- private static BlockPosition calculateBottomLeft(IBlockAccess iblockaccess, EnumDirection enumdirection, BlockPosition blockposition) { ++ private static BlockPosition calculateBottomLeft(IBlockAccess iblockaccess, EnumDirection enumdirection, BlockPosition blockposition, BlockStateListPopulator blocks) { // CraftBukkit + for (int i = Math.max(iblockaccess.getMinY(), blockposition.getY() - 21); blockposition.getY() > i && isEmpty(iblockaccess.getBlockState(blockposition.below())); blockposition = blockposition.below()) { + ; + } + + EnumDirection enumdirection1 = enumdirection.getOpposite(); +- int j = getDistanceUntilEdgeAboveFrame(iblockaccess, blockposition, enumdirection1) - 1; ++ int j = getDistanceUntilEdgeAboveFrame(iblockaccess, blockposition, enumdirection1, blocks) - 1; // CraftBukkit + + return j < 0 ? null : blockposition.relative(enumdirection1, j); + } + +- private static int calculateWidth(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection) { +- int i = getDistanceUntilEdgeAboveFrame(iblockaccess, blockposition, enumdirection); ++ private static int calculateWidth(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockStateListPopulator blocks) { // CraftBukkit ++ int i = getDistanceUntilEdgeAboveFrame(iblockaccess, blockposition, enumdirection, blocks); // CraftBukkit + + return i >= 2 && i <= 21 ? i : 0; + } + +- private static int getDistanceUntilEdgeAboveFrame(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection) { ++ private static int getDistanceUntilEdgeAboveFrame(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockStateListPopulator blocks) { // CraftBukkit + BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); + + for (int i = 0; i <= 21; ++i) { +@@ -115,6 +125,7 @@ if (!isEmpty(iblockdata)) { - if (BlockPortalShape.FRAME.test(iblockdata, this.level, blockposition_mutableblockposition)) { + if (BlockPortalShape.FRAME.test(iblockdata, iblockaccess, blockposition_mutableblockposition)) { + blocks.setBlock(blockposition_mutableblockposition, iblockdata, 18); // CraftBukkit - lower left / right return i; } break; -@@ -114,6 +121,7 @@ - if (!BlockPortalShape.FRAME.test(iblockdata1, this.level, blockposition_mutableblockposition)) { +@@ -125,31 +136,33 @@ + if (!BlockPortalShape.FRAME.test(iblockdata1, iblockaccess, blockposition_mutableblockposition)) { break; } + blocks.setBlock(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit - bottom row } return 0; -@@ -133,6 +141,7 @@ - if (!BlockPortalShape.FRAME.test(this.level.getBlockState(blockposition_mutableblockposition1), this.level, blockposition_mutableblockposition1)) { + } + +- private static int calculateHeight(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection, int i, MutableInt mutableint) { ++ private static int calculateHeight(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection, int i, MutableInt mutableint, BlockStateListPopulator blocks) { // CraftBukkit + BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); +- int j = getDistanceUntilTop(iblockaccess, blockposition, enumdirection, blockposition_mutableblockposition, i, mutableint); ++ int j = getDistanceUntilTop(iblockaccess, blockposition, enumdirection, blockposition_mutableblockposition, i, mutableint, blocks); // CraftBukkit + +- return j >= 3 && j <= 21 && hasTopFrame(iblockaccess, blockposition, enumdirection, blockposition_mutableblockposition, i, j) ? j : 0; ++ return j >= 3 && j <= 21 && hasTopFrame(iblockaccess, blockposition, enumdirection, blockposition_mutableblockposition, i, j, blocks) ? j : 0; // CraftBukkit + } + +- private static boolean hasTopFrame(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition.MutableBlockPosition blockposition_mutableblockposition, int i, int j) { ++ private static boolean hasTopFrame(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition.MutableBlockPosition blockposition_mutableblockposition, int i, int j, BlockStateListPopulator blocks) { // CraftBukkit + for (int k = 0; k < i; ++k) { + BlockPosition.MutableBlockPosition blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(blockposition).move(EnumDirection.UP, j).move(enumdirection, k); + + if (!BlockPortalShape.FRAME.test(iblockaccess.getBlockState(blockposition_mutableblockposition1), iblockaccess, blockposition_mutableblockposition1)) { return false; } -+ blocks.setBlock(blockposition_mutableblockposition1, this.level.getBlockState(blockposition_mutableblockposition1), 18); // CraftBukkit - upper row ++ blocks.setBlock(blockposition_mutableblockposition1, iblockaccess.getBlockState(blockposition_mutableblockposition1), 18); // CraftBukkit - upper row } return true; -@@ -162,6 +171,10 @@ - ++this.numPortalBlocks; + } + +- private static int getDistanceUntilTop(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition.MutableBlockPosition blockposition_mutableblockposition, int i, MutableInt mutableint) { ++ private static int getDistanceUntilTop(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition.MutableBlockPosition blockposition_mutableblockposition, int i, MutableInt mutableint, BlockStateListPopulator blocks) { // CraftBukkit + for (int j = 0; j < 21; ++j) { + blockposition_mutableblockposition.set(blockposition).move(EnumDirection.UP, j).move(enumdirection, -1); + if (!BlockPortalShape.FRAME.test(iblockaccess.getBlockState(blockposition_mutableblockposition), iblockaccess, blockposition_mutableblockposition)) { +@@ -173,6 +186,10 @@ + mutableint.increment(); } } + // CraftBukkit start - left and right -+ blocks.setBlock(blockposition_mutableblockposition.set(this.bottomLeft).move(EnumDirection.UP, i).move(this.rightDir, -1), this.level.getBlockState(blockposition_mutableblockposition), 18); -+ blocks.setBlock(blockposition_mutableblockposition.set(this.bottomLeft).move(EnumDirection.UP, i).move(this.rightDir, this.width), this.level.getBlockState(blockposition_mutableblockposition), 18); ++ blocks.setBlock(blockposition_mutableblockposition.set(blockposition).move(EnumDirection.UP, j).move(enumdirection, -1), iblockaccess.getBlockState(blockposition_mutableblockposition), 18); ++ blocks.setBlock(blockposition_mutableblockposition.set(blockposition).move(EnumDirection.UP, j).move(enumdirection, i), iblockaccess.getBlockState(blockposition_mutableblockposition), 18); + // CraftBukkit end } return 21; -@@ -175,12 +188,28 @@ - return this.bottomLeft != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; +@@ -186,12 +203,28 @@ + return this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } -- public void createPortalBlocks() { +- public void createPortalBlocks(GeneratorAccess generatoraccess) { + // CraftBukkit start - return boolean, add entity -+ public boolean createPortalBlocks(Entity entity) { -+ org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld(); ++ public boolean createPortalBlocks(GeneratorAccess generatoraccess, Entity entity) { ++ org.bukkit.World bworld = generatoraccess.getMinecraftWorld().getWorld(); + + // Copy below for loop IBlockData iblockdata = (IBlockData) Blocks.NETHER_PORTAL.defaultBlockState().setValue(BlockPortal.AXIS, this.axis); @@ -79,14 +158,14 @@ + }); + + PortalCreateEvent event = new PortalCreateEvent((java.util.List) (java.util.List) blocks.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), PortalCreateEvent.CreateReason.FIRE); -+ this.level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event); ++ generatoraccess.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; + } + // CraftBukkit end + BlockPosition.betweenClosed(this.bottomLeft, this.bottomLeft.relative(EnumDirection.UP, this.height - 1).relative(this.rightDir, this.width - 1)).forEach((blockposition) -> { - this.level.setBlock(blockposition, iblockdata, 18); + generatoraccess.setBlock(blockposition, iblockdata, 18); }); + return true; // CraftBukkit } diff --git a/nms-patches/net/minecraft/world/level/portal/DimensionTransition.patch b/nms-patches/net/minecraft/world/level/portal/DimensionTransition.patch deleted file mode 100644 index 2b377bae..00000000 --- a/nms-patches/net/minecraft/world/level/portal/DimensionTransition.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/net/minecraft/world/level/portal/DimensionTransition.java -+++ b/net/minecraft/world/level/portal/DimensionTransition.java -@@ -7,7 +7,19 @@ - import net.minecraft.world.entity.Entity; - import net.minecraft.world.phys.Vec3D; - --public record DimensionTransition(WorldServer newLevel, Vec3D pos, Vec3D speed, float yRot, float xRot, boolean missingRespawnBlock, DimensionTransition.a postDimensionTransition) { -+// CraftBukkit start -+import org.bukkit.event.player.PlayerTeleportEvent; -+ -+public record DimensionTransition(WorldServer newLevel, Vec3D pos, Vec3D speed, float yRot, float xRot, boolean missingRespawnBlock, DimensionTransition.a postDimensionTransition, PlayerTeleportEvent.TeleportCause cause) { -+ -+ public DimensionTransition(WorldServer newLevel, Vec3D pos, Vec3D speed, float yRot, float xRot, boolean missingRespawnBlock, DimensionTransition.a postDimensionTransition) { -+ this(newLevel, pos, speed, yRot, xRot, missingRespawnBlock, postDimensionTransition, PlayerTeleportEvent.TeleportCause.UNKNOWN); -+ } -+ -+ public DimensionTransition(PlayerTeleportEvent.TeleportCause cause) { -+ this(null, Vec3D.ZERO, Vec3D.ZERO, 0.0F, 0.0F, false, DO_NOTHING, cause); -+ } -+ // CraftBukkit end - - public static final DimensionTransition.a DO_NOTHING = (entity) -> { - }; -@@ -15,11 +27,21 @@ - public static final DimensionTransition.a PLACE_PORTAL_TICKET = DimensionTransition::placePortalTicket; - - public DimensionTransition(WorldServer worldserver, Vec3D vec3d, Vec3D vec3d1, float f, float f1, DimensionTransition.a dimensiontransition_a) { -- this(worldserver, vec3d, vec3d1, f, f1, false, dimensiontransition_a); -+ // CraftBukkit start -+ this(worldserver, vec3d, vec3d1, f, f1, dimensiontransition_a, PlayerTeleportEvent.TeleportCause.UNKNOWN); -+ } -+ -+ public DimensionTransition(WorldServer worldserver, Vec3D vec3d, Vec3D vec3d1, float f, float f1, DimensionTransition.a dimensiontransition_a, PlayerTeleportEvent.TeleportCause cause) { -+ this(worldserver, vec3d, vec3d1, f, f1, false, dimensiontransition_a, cause); - } - - public DimensionTransition(WorldServer worldserver, Entity entity, DimensionTransition.a dimensiontransition_a) { -- this(worldserver, findAdjustedSharedSpawnPos(worldserver, entity), Vec3D.ZERO, 0.0F, 0.0F, false, dimensiontransition_a); -+ this(worldserver, entity, dimensiontransition_a, PlayerTeleportEvent.TeleportCause.UNKNOWN); -+ } -+ -+ public DimensionTransition(WorldServer worldserver, Entity entity, DimensionTransition.a dimensiontransition_a, PlayerTeleportEvent.TeleportCause cause) { -+ this(worldserver, findAdjustedSharedSpawnPos(worldserver, entity), Vec3D.ZERO, 0.0F, 0.0F, false, dimensiontransition_a, cause); -+ // CraftBukkit end - } - - private static void playPortalSound(Entity entity) { diff --git a/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch b/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch index 43293e13..0f5b050a 100644 --- a/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch +++ b/nms-patches/net/minecraft/world/level/portal/PortalTravelAgent.patch @@ -40,7 +40,7 @@ double d0 = -1.0D; BlockPosition blockposition1 = null; @@ -69,7 +81,7 @@ - int i = Math.min(this.level.getMaxBuildHeight(), this.level.getMinBuildHeight() + this.level.getLogicalHeight()) - 1; + int i = Math.min(this.level.getMaxY(), this.level.getMinY() + this.level.getLogicalHeight() - 1); boolean flag = true; BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); - Iterator iterator = BlockPosition.spiralAround(blockposition, 16, EnumDirection.EAST, EnumDirection.SOUTH).iterator(); @@ -54,7 +54,7 @@ + org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(this.level); // CraftBukkit - Use BlockStateListPopulator if (d0 == -1.0D) { - j1 = Math.max(this.level.getMinBuildHeight() - -1, 70); + j1 = Math.max(this.level.getMinY() - -1, 70); k1 = i - 9; @@ -139,7 +152,7 @@ IBlockData iblockdata = i1 < 0 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); diff --git a/nms-patches/net/minecraft/world/level/portal/TeleportTransition.patch b/nms-patches/net/minecraft/world/level/portal/TeleportTransition.patch new file mode 100644 index 00000000..26b74234 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/portal/TeleportTransition.patch @@ -0,0 +1,60 @@ +--- a/net/minecraft/world/level/portal/TeleportTransition.java ++++ b/net/minecraft/world/level/portal/TeleportTransition.java +@@ -9,7 +9,19 @@ + import net.minecraft.world.entity.Relative; + import net.minecraft.world.phys.Vec3D; + +-public record TeleportTransition(WorldServer newLevel, Vec3D position, Vec3D deltaMovement, float yRot, float xRot, boolean missingRespawnBlock, boolean asPassenger, Set relatives, TeleportTransition.a postTeleportTransition) { ++// CraftBukkit start ++import org.bukkit.event.player.PlayerTeleportEvent; ++ ++public record TeleportTransition(WorldServer newLevel, Vec3D position, Vec3D deltaMovement, float yRot, float xRot, boolean missingRespawnBlock, boolean asPassenger, Set relatives, TeleportTransition.a postTeleportTransition, PlayerTeleportEvent.TeleportCause cause) { ++ ++ public TeleportTransition(WorldServer newLevel, Vec3D position, Vec3D deltaMovement, float yRot, float xRot, boolean missingRespawnBlock, boolean asPassenger, Set relatives, TeleportTransition.a postTeleportTransition) { ++ this(newLevel, position, deltaMovement, yRot, xRot, missingRespawnBlock, asPassenger, relatives, postTeleportTransition, PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ ++ public TeleportTransition(PlayerTeleportEvent.TeleportCause cause) { ++ this(null, Vec3D.ZERO, Vec3D.ZERO, 0.0F, 0.0F, false, false, Set.of(), DO_NOTHING, cause); ++ } ++ // CraftBukkit end + + public static final TeleportTransition.a DO_NOTHING = (entity) -> { + }; +@@ -17,15 +29,33 @@ + public static final TeleportTransition.a PLACE_PORTAL_TICKET = TeleportTransition::placePortalTicket; + + public TeleportTransition(WorldServer worldserver, Vec3D vec3d, Vec3D vec3d1, float f, float f1, TeleportTransition.a teleporttransition_a) { +- this(worldserver, vec3d, vec3d1, f, f1, Set.of(), teleporttransition_a); ++ // CraftBukkit start ++ this(worldserver, vec3d, vec3d1, f, f1, teleporttransition_a, PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ ++ public TeleportTransition(WorldServer worldserver, Vec3D vec3d, Vec3D vec3d1, float f, float f1, TeleportTransition.a teleporttransition_a, PlayerTeleportEvent.TeleportCause cause) { ++ this(worldserver, vec3d, vec3d1, f, f1, Set.of(), teleporttransition_a, cause); ++ // CraftBukkit end + } + + public TeleportTransition(WorldServer worldserver, Vec3D vec3d, Vec3D vec3d1, float f, float f1, Set set, TeleportTransition.a teleporttransition_a) { +- this(worldserver, vec3d, vec3d1, f, f1, false, false, set, teleporttransition_a); ++ // CraftBukkit start ++ this(worldserver, vec3d, vec3d1, f, f1, set, teleporttransition_a, PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ ++ public TeleportTransition(WorldServer worldserver, Vec3D vec3d, Vec3D vec3d1, float f, float f1, Set set, TeleportTransition.a teleporttransition_a, PlayerTeleportEvent.TeleportCause cause) { ++ this(worldserver, vec3d, vec3d1, f, f1, false, false, set, teleporttransition_a, cause); ++ // CraftBukkit end + } + + public TeleportTransition(WorldServer worldserver, Entity entity, TeleportTransition.a teleporttransition_a) { +- this(worldserver, findAdjustedSharedSpawnPos(worldserver, entity), Vec3D.ZERO, 0.0F, 0.0F, false, false, Set.of(), teleporttransition_a); ++ // CraftBukkit start ++ this(worldserver, entity, teleporttransition_a, PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ ++ public TeleportTransition(WorldServer worldserver, Entity entity, TeleportTransition.a teleporttransition_a, PlayerTeleportEvent.TeleportCause cause) { ++ this(worldserver, findAdjustedSharedSpawnPos(worldserver, entity), Vec3D.ZERO, 0.0F, 0.0F, false, false, Set.of(), teleporttransition_a, cause); ++ // CraftBukkit end + } + + private static void playPortalSound(Entity entity) { diff --git a/nms-patches/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.patch b/nms-patches/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.patch new file mode 100644 index 00000000..c98450b0 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java ++++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java +@@ -10,6 +10,11 @@ + import net.minecraft.world.level.block.BlockRedstoneWire; + import net.minecraft.world.level.block.state.IBlockData; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.event.block.BlockRedstoneEvent; ++// CraftBukkit end ++ + public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator { + + public DefaultRedstoneWireEvaluator(BlockRedstoneWire blockredstonewire) { +@@ -20,7 +25,16 @@ + public void updatePowerStrength(World world, BlockPosition blockposition, IBlockData iblockdata, @Nullable Orientation orientation, boolean flag) { + int i = this.calculateTargetStrength(world, blockposition); + +- if ((Integer) iblockdata.getValue(BlockRedstoneWire.POWER) != i) { ++ // CraftBukkit start ++ int oldPower = iblockdata.getValue(BlockRedstoneWire.POWER); ++ if (oldPower != i) { ++ BlockRedstoneEvent event = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), oldPower, i); ++ world.getCraftServer().getPluginManager().callEvent(event); ++ ++ i = event.getNewCurrent(); ++ } ++ if (oldPower != i) { ++ // CraftBukkit end + if (world.getBlockState(blockposition) == iblockdata) { + world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneWire.POWER, i), 2); + } diff --git a/nms-patches/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.patch b/nms-patches/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.patch new file mode 100644 index 00000000..16399707 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java ++++ b/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java +@@ -17,6 +17,11 @@ + import net.minecraft.world.level.block.state.properties.BlockPropertyRedstoneSide; + import net.minecraft.world.level.block.state.properties.BlockStateEnum; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.event.block.BlockRedstoneEvent; ++// CraftBukkit end ++ + public class ExperimentalRedstoneWireEvaluator extends RedstoneWireEvaluator { + + private final Deque wiresToTurnOff = new ArrayDeque(); +@@ -41,7 +46,16 @@ + int j = unpackPower(i); + IBlockData iblockdata1 = world.getBlockState(blockposition1); + +- if (iblockdata1.is((Block) this.wireBlock) && !((Integer) iblockdata1.getValue(BlockRedstoneWire.POWER)).equals(j)) { ++ // CraftBukkit start ++ int oldPower = iblockdata.getValue(BlockRedstoneWire.POWER); ++ if (oldPower != j) { ++ BlockRedstoneEvent event = new BlockRedstoneEvent(CraftBlock.at(world, blockposition1), oldPower, j); ++ world.getCraftServer().getPluginManager().callEvent(event); ++ ++ j = event.getNewCurrent(); ++ } ++ if (iblockdata1.is((Block) this.wireBlock) && oldPower != j) { ++ // CraftBukkit end + int k = 2; + + if (!flag || !flag1) { diff --git a/nms-patches/net/minecraft/world/level/redstone/NeighborUpdater.patch b/nms-patches/net/minecraft/world/level/redstone/NeighborUpdater.patch index ad8bebcf..3d8cac6f 100644 --- a/nms-patches/net/minecraft/world/level/redstone/NeighborUpdater.patch +++ b/nms-patches/net/minecraft/world/level/redstone/NeighborUpdater.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/redstone/NeighborUpdater.java +++ b/net/minecraft/world/level/redstone/NeighborUpdater.java -@@ -12,6 +12,13 @@ - import net.minecraft.world.level.World; +@@ -13,6 +13,13 @@ import net.minecraft.world.level.block.Block; + import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.IBlockData; +// CraftBukkit start +import net.minecraft.server.level.WorldServer; @@ -14,14 +14,14 @@ public interface NeighborUpdater { -@@ -46,6 +53,17 @@ +@@ -50,6 +57,17 @@ - static void executeUpdate(World world, IBlockData iblockdata, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { + static void executeUpdate(World world, IBlockData iblockdata, BlockPosition blockposition, Block block, @Nullable Orientation orientation, boolean flag) { try { + // CraftBukkit start + CraftWorld cworld = ((WorldServer) world).getWorld(); + if (cworld != null) { -+ BlockPhysicsEvent event = new BlockPhysicsEvent(CraftBlock.at(world, blockposition), CraftBlockData.fromData(iblockdata), CraftBlock.at(world, blockposition1)); ++ BlockPhysicsEvent event = new BlockPhysicsEvent(CraftBlock.at(world, blockposition), CraftBlockData.fromData(iblockdata)); + ((WorldServer) world).getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { @@ -29,6 +29,6 @@ + } + } + // CraftBukkit end - iblockdata.handleNeighborChanged(world, blockposition, block, blockposition1, flag); + iblockdata.handleNeighborChanged(world, blockposition, block, orientation, flag); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception while updating neighbours"); 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 9aa14f1c..88ce770f 100644 --- a/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch +++ b/nms-patches/net/minecraft/world/level/saveddata/maps/WorldMap.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/saveddata/maps/WorldMap.java +++ b/net/minecraft/world/level/saveddata/maps/WorldMap.java -@@ -44,6 +44,17 @@ +@@ -47,6 +47,17 @@ import net.minecraft.world.level.saveddata.PersistentBase; import org.slf4j.Logger; @@ -18,7 +18,7 @@ public class WorldMap extends PersistentBase { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -67,6 +78,13 @@ +@@ -70,6 +81,13 @@ private final Map frameMarkers = Maps.newHashMap(); private int trackedDecorationCount; @@ -32,10 +32,10 @@ public static PersistentBase.a factory() { return new PersistentBase.a<>(() -> { throw new IllegalStateException("Should never create an empty map saved data"); -@@ -82,6 +100,10 @@ +@@ -84,6 +102,10 @@ + this.trackingPosition = flag; this.unlimitedTracking = flag1; this.locked = flag2; - this.setDirty(); + // CraftBukkit start + mapView = new CraftMapView(this); + server = (CraftServer) org.bukkit.Bukkit.getServer(); @@ -43,7 +43,7 @@ } public static WorldMap createFresh(double d0, double d1, byte b0, boolean flag, boolean flag1, ResourceKey resourcekey) { -@@ -99,12 +121,30 @@ +@@ -101,12 +123,30 @@ } public static WorldMap load(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { @@ -77,7 +77,7 @@ }); int i = nbttagcompound.getInt("xCenter"); int j = nbttagcompound.getInt("zCenter"); -@@ -129,7 +169,8 @@ +@@ -131,7 +171,8 @@ MapIconBanner mapiconbanner = (MapIconBanner) iterator.next(); worldmap.bannerMarkers.put(mapiconbanner.getId(), mapiconbanner); @@ -87,7 +87,7 @@ } NBTTagList nbttaglist = nbttagcompound.getList("frames", 10); -@@ -148,13 +189,32 @@ +@@ -150,13 +191,32 @@ @Override public NBTTagCompound save(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) { @@ -121,7 +121,7 @@ nbttagcompound.putInt("xCenter", this.centerX); nbttagcompound.putInt("zCenter", this.centerZ); nbttagcompound.putByte("scale", this.scale); -@@ -409,7 +469,7 @@ +@@ -443,7 +503,7 @@ if (!this.isTrackedCountOverLimit(256)) { this.bannerMarkers.put(mapiconbanner.getId(), mapiconbanner); @@ -130,16 +130,16 @@ return true; } } -@@ -519,7 +579,7 @@ +@@ -554,7 +614,7 @@ this.player = entityhuman; } -- private WorldMap.b createPatch() { -+ private WorldMap.b createPatch(byte[] buffer) { // CraftBukkit +- private WorldMap.c createPatch() { ++ private WorldMap.c createPatch(byte[] buffer) { // CraftBukkit int i = this.minDirtyX; int j = this.minDirtyY; int k = this.maxDirtyX + 1 - this.minDirtyX; -@@ -528,7 +588,7 @@ +@@ -563,7 +623,7 @@ for (int i1 = 0; i1 < k; ++i1) { for (int j1 = 0; j1 < l; ++j1) { @@ -148,18 +148,18 @@ } } -@@ -538,19 +598,29 @@ +@@ -573,19 +633,29 @@ @Nullable Packet nextUpdatePacket(MapId mapid) { - WorldMap.b worldmap_b; + WorldMap.c worldmap_c; + org.bukkit.craftbukkit.map.RenderData render = WorldMap.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.player.getBukkitEntity()); // CraftBukkit if (this.dirtyData) { this.dirtyData = false; -- worldmap_b = this.createPatch(); -+ worldmap_b = this.createPatch(render.buffer); // CraftBukkit +- worldmap_c = this.createPatch(); ++ worldmap_c = this.createPatch(render.buffer); // CraftBukkit } else { - worldmap_b = null; + worldmap_c = null; } Collection collection; diff --git a/nms-patches/net/minecraft/world/level/storage/Convertable.patch b/nms-patches/net/minecraft/world/level/storage/Convertable.patch index da71086f..c2b81314 100644 --- a/nms-patches/net/minecraft/world/level/storage/Convertable.patch +++ b/nms-patches/net/minecraft/world/level/storage/Convertable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/Convertable.java +++ b/net/minecraft/world/level/storage/Convertable.java -@@ -77,6 +77,10 @@ +@@ -78,6 +78,10 @@ import net.minecraft.world.level.validation.PathAllowList; import org.slf4j.Logger; @@ -11,7 +11,7 @@ public class Convertable { static final Logger LOGGER = LogUtils.getLogger(); -@@ -148,7 +152,7 @@ +@@ -149,7 +153,7 @@ } public static WorldDataConfiguration readDataConfig(Dynamic dynamic) { @@ -20,9 +20,9 @@ Logger logger = Convertable.LOGGER; Objects.requireNonNull(logger); -@@ -167,6 +171,7 @@ +@@ -168,6 +172,7 @@ WorldDimensions.b worlddimensions_b = generatorsettings.dimensions().bake(iregistry); - Lifecycle lifecycle = worlddimensions_b.lifecycle().add(iregistrycustom_dimension.allRegistriesLifecycle()); + Lifecycle lifecycle = worlddimensions_b.lifecycle().add(holderlookup_a.allRegistriesLifecycle()); WorldDataServer worlddataserver = WorldDataServer.parse(dynamic1, worldsettings, worlddimensions_b.specialWorldProperty(), generatorsettings.options(), lifecycle); + worlddataserver.pdc = ((Dynamic) dynamic1).getElement("BukkitValues", null); // CraftBukkit - Add PDC to world diff --git a/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch b/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch index 12b90220..cf2dffac 100644 --- a/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch +++ b/nms-patches/net/minecraft/world/level/storage/WorldDataServer.patch @@ -73,7 +73,7 @@ GameProfileSerializer.addCurrentDataVersion(nbttagcompound); DynamicOps dynamicops = iregistrycustom.createSerializationContext(DynamicOpsNBT.INSTANCE); - DataResult dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, iregistrycustom); -+ DataResult dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, new WorldDimensions(this.customDimensions != null ? this.customDimensions : iregistrycustom.registryOrThrow(Registries.LEVEL_STEM))); // CraftBukkit ++ DataResult dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, new WorldDimensions(this.customDimensions != null ? this.customDimensions : iregistrycustom.lookupOrThrow(Registries.LEVEL_STEM))); // CraftBukkit Logger logger = WorldDataServer.LOGGER; Objects.requireNonNull(logger); diff --git a/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch b/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch index 56748563..86e7c6ff 100644 --- a/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch +++ b/nms-patches/net/minecraft/world/level/storage/loot/LootDataType.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/storage/loot/LootDataType.java +++ b/net/minecraft/world/level/storage/loot/LootDataType.java -@@ -15,6 +15,11 @@ +@@ -9,6 +9,11 @@ + import net.minecraft.world.level.storage.loot.functions.LootItemFunctions; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; - import org.slf4j.Logger; +// CraftBukkit start +import org.bukkit.craftbukkit.CraftLootTable; @@ -11,11 +11,11 @@ + public record LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.a validator) { - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -48,6 +53,7 @@ + public static final LootDataType PREDICATE = new LootDataType<>(Registries.PREDICATE, LootItemCondition.DIRECT_CODEC, createSimpleValidator()); +@@ -32,6 +37,7 @@ private static LootDataType.a createLootTableValidator() { return (lootcollector, resourcekey, loottable) -> { - loottable.validate(lootcollector.setParams(loottable.getParamSet()).enterElement("{" + String.valueOf(resourcekey.registry()) + "/" + String.valueOf(resourcekey.location()) + "}", resourcekey)); + loottable.validate(lootcollector.setContextKeySet(loottable.getParamSet()).enterElement("{" + String.valueOf(resourcekey.registry()) + "/" + String.valueOf(resourcekey.location()) + "}", resourcekey)); + loottable.craftLootTable = new CraftLootTable(CraftNamespacedKey.fromMinecraft(resourcekey.location()), loottable); // CraftBukkit }; } 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 3b5177ef..827b4ca4 100644 --- a/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch +++ b/nms-patches/net/minecraft/world/level/storage/loot/LootTable.patch @@ -20,8 +20,8 @@ private final BiFunction compositeFunction; + public CraftLootTable craftLootTable; // CraftBukkit - LootTable(LootContextParameterSet lootcontextparameterset, Optional optional, List list, List list1) { - this.paramSet = lootcontextparameterset; + LootTable(ContextKeySet contextkeyset, Optional optional, List list, List list1) { + this.paramSet = contextkeyset; @@ -157,9 +165,22 @@ } diff --git a/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.patch b/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.patch index d0a4a03d..48c4a881 100644 --- a/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.patch +++ b/nms-patches/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.java +++ b/net/minecraft/world/level/storage/loot/predicates/LootItemConditionSurvivesExplosion.java -@@ -32,7 +32,8 @@ +@@ -31,7 +31,8 @@ RandomSource randomsource = loottableinfo.getRandom(); float f = 1.0F / ofloat; diff --git a/patches/com/mojang/blaze3d/pipeline/RenderTarget.java.patch b/patches/com/mojang/blaze3d/pipeline/RenderTarget.java.patch deleted file mode 100644 index da006f8e..00000000 --- a/patches/com/mojang/blaze3d/pipeline/RenderTarget.java.patch +++ /dev/null @@ -1,57 +0,0 @@ ---- a/com/mojang/blaze3d/pipeline/RenderTarget.java -+++ b/com/mojang/blaze3d/pipeline/RenderTarget.java -@@ -104,7 +_,10 @@ - GlStateManager._texParameter(3553, 34892, 0); - GlStateManager._texParameter(3553, 10242, 33071); - GlStateManager._texParameter(3553, 10243, 33071); -+ if (!stencilEnabled) - GlStateManager._texImage2D(3553, 0, 6402, this.width, this.height, 0, 6402, 5126, null); -+ else -+ GlStateManager._texImage2D(3553, 0, org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8, this.width, this.height, 0, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL, org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV, null); - } - - this.setFilterMode(9728, true); -@@ -115,7 +_,14 @@ - GlStateManager._glBindFramebuffer(36160, this.frameBufferId); - GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, this.colorTextureId, 0); - if (this.useDepth) { -+ if(!stencilEnabled) - GlStateManager._glFramebufferTexture2D(36160, 36096, 3553, this.depthBufferId, 0); -+ else if(net.neoforged.neoforge.common.NeoForgeConfig.CLIENT.useCombinedDepthStencilAttachment.get()) { -+ GlStateManager._glFramebufferTexture2D(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL_ATTACHMENT, 3553, this.depthBufferId, 0); -+ } else { -+ GlStateManager._glFramebufferTexture2D(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_DEPTH_ATTACHMENT, 3553, this.depthBufferId, 0); -+ GlStateManager._glFramebufferTexture2D(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_STENCIL_ATTACHMENT, 3553, this.depthBufferId, 0); -+ } - } - - this.checkStatus(); -@@ -257,5 +_,28 @@ - - public int getDepthTextureId() { - return this.depthBufferId; -+ } -+ -+ // Neo: Injected stencil control -+ private boolean stencilEnabled = false; -+ -+ /** -+ * Attempts to enable 8 bits of stencil buffer on this FrameBuffer. -+ * Modders must call this directly to set things up. -+ * This is to prevent the default cause where graphics cards do not support stencil bits. -+ * Make sure to call this on the main render thread! -+ */ -+ public void enableStencil() { -+ if(stencilEnabled) return; -+ stencilEnabled = true; -+ this.resize(viewWidth, viewHeight, net.minecraft.client.Minecraft.ON_OSX); -+ } -+ -+ /** -+ * Returns whether this FBO has been successfully initialized with stencil bits. -+ * If not, and a modder wishes it to be, they must call enableStencil. -+ */ -+ public boolean isStencilEnabled() { -+ return this.stencilEnabled; - } - } diff --git a/patches/com/mojang/blaze3d/platform/GlStateManager.java.patch b/patches/com/mojang/blaze3d/platform/GlStateManager.java.patch index 4eb7c902..88bb5116 100644 --- a/patches/com/mojang/blaze3d/platform/GlStateManager.java.patch +++ b/patches/com/mojang/blaze3d/platform/GlStateManager.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/platform/GlStateManager.java +++ b/com/mojang/blaze3d/platform/GlStateManager.java -@@ -945,4 +_,53 @@ +@@ -1009,4 +_,53 @@ return INSTANCE.height; } } diff --git a/patches/com/mojang/blaze3d/platform/Window.java.patch b/patches/com/mojang/blaze3d/platform/Window.java.patch index edf8e769..f211b35f 100644 --- a/patches/com/mojang/blaze3d/platform/Window.java.patch +++ b/patches/com/mojang/blaze3d/platform/Window.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/platform/Window.java +++ b/com/mojang/blaze3d/platform/Window.java -@@ -86,7 +_,8 @@ +@@ -90,7 +_,8 @@ GLFW.glfwWindowHint(139267, 2); GLFW.glfwWindowHint(139272, 204801); GLFW.glfwWindowHint(139270, 1); @@ -10,7 +10,7 @@ if (monitor != null) { VideoMode videomode = monitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty()); this.windowedX = this.x = monitor.getX() + videomode.getWidth() / 2 - this.width / 2; -@@ -98,6 +_,7 @@ +@@ -102,6 +_,7 @@ this.windowedX = this.x = aint1[0]; this.windowedY = this.y = aint[0]; } @@ -18,7 +18,7 @@ GLFW.glfwMakeContextCurrent(this.window); GL.createCapabilities(); -@@ -256,6 +_,7 @@ +@@ -269,6 +_,7 @@ GLFW.glfwGetFramebufferSize(this.window, aint, aint1); this.framebufferWidth = aint[0] > 0 ? aint[0] : 1; this.framebufferHeight = aint1[0] > 0 ? aint1[0] : 1; diff --git a/patches/com/mojang/blaze3d/systems/RenderSystem.java.patch b/patches/com/mojang/blaze3d/systems/RenderSystem.java.patch index 3a0ac77e..756e40c7 100644 --- a/patches/com/mojang/blaze3d/systems/RenderSystem.java.patch +++ b/patches/com/mojang/blaze3d/systems/RenderSystem.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/systems/RenderSystem.java +++ b/com/mojang/blaze3d/systems/RenderSystem.java -@@ -932,4 +_,14 @@ +@@ -822,4 +_,14 @@ void accept(it.unimi.dsi.fastutil.ints.IntConsumer p_157488_, int p_157489_); } } diff --git a/patches/com/mojang/blaze3d/vertex/PoseStack.java.patch b/patches/com/mojang/blaze3d/vertex/PoseStack.java.patch index a21f52da..c3b47049 100644 --- a/patches/com/mojang/blaze3d/vertex/PoseStack.java.patch +++ b/patches/com/mojang/blaze3d/vertex/PoseStack.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/vertex/PoseStack.java +++ b/com/mojang/blaze3d/vertex/PoseStack.java -@@ -13,7 +_,7 @@ +@@ -14,7 +_,7 @@ import org.joml.Vector3f; @OnlyIn(Dist.CLIENT) diff --git a/patches/com/mojang/blaze3d/vertex/VertexConsumer.java.patch b/patches/com/mojang/blaze3d/vertex/VertexConsumer.java.patch index 7648e309..30c19c43 100644 --- a/patches/com/mojang/blaze3d/vertex/VertexConsumer.java.patch +++ b/patches/com/mojang/blaze3d/vertex/VertexConsumer.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/vertex/VertexConsumer.java +++ b/com/mojang/blaze3d/vertex/VertexConsumer.java -@@ -12,7 +_,7 @@ +@@ -13,7 +_,7 @@ import org.lwjgl.system.MemoryStack; @OnlyIn(Dist.CLIENT) @@ -10,19 +10,19 @@ VertexConsumer setColor(int p_350535_, int p_350875_, int p_350886_, int p_350775_); @@ -131,11 +_,14 @@ - f5 = p_331397_[l] * p_85992_ * 255.0F; + f5 = p_331397_[i1] * p_85992_ * 255.0F; } -- int i1 = FastColor.ARGB32.color(k, (int)f3, (int)f4, (int)f5); -- int j1 = p_331378_[l]; +- int j1 = ARGB.color(k, (int)f3, (int)f4, (int)f5); +- int k1 = LightTexture.lightCoordsWithEmission(p_331378_[i1], l); + // Neo: also apply alpha that's coming from the baked quad + int vertexAlpha = p_331268_ ? (int)((p_331416_ * (float) (bytebuffer.get(15) & 255) / 255.0F) * 255) : k; -+ int i1 = FastColor.ARGB32.color(vertexAlpha, (int)f3, (int)f4, (int)f5); -+ int j1 = applyBakedLighting(p_331378_[l], bytebuffer); ++ int j1 = ARGB.color(vertexAlpha, (int)f3, (int)f4, (int)f5); ++ int k1 = applyBakedLighting(LightTexture.lightCoordsWithEmission(p_331378_[i1], l), bytebuffer); float f10 = bytebuffer.getFloat(16); float f9 = bytebuffer.getFloat(20); Vector3f vector3f1 = matrix4f.transformPosition(f, f1, f2, new Vector3f()); + applyBakedNormals(vector3f, bytebuffer, p_85988_.normal()); - this.addVertex(vector3f1.x(), vector3f1.y(), vector3f1.z(), i1, f10, f9, p_85993_, j1, vector3f.x(), vector3f.y(), vector3f.z()); + this.addVertex(vector3f1.x(), vector3f1.y(), vector3f1.z(), j1, f10, f9, p_85993_, k1, vector3f.x(), vector3f.y(), vector3f.z()); } } diff --git a/patches/com/mojang/blaze3d/vertex/VertexFormat.java.patch b/patches/com/mojang/blaze3d/vertex/VertexFormat.java.patch index a6debaff..792970ee 100644 --- a/patches/com/mojang/blaze3d/vertex/VertexFormat.java.patch +++ b/patches/com/mojang/blaze3d/vertex/VertexFormat.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/vertex/VertexFormat.java +++ b/com/mojang/blaze3d/vertex/VertexFormat.java -@@ -237,4 +_,28 @@ +@@ -220,4 +_,28 @@ }; } } diff --git a/patches/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java.patch b/patches/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java.patch index 0757213a..b9cb377a 100644 --- a/patches/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java.patch +++ b/patches/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java +++ b/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java -@@ -127,7 +_,7 @@ +@@ -128,7 +_,7 @@ private void drawIcons(GuiGraphics p_282966_) { int i = this.numberOfPendingInvites; int j = 24; diff --git a/patches/net/minecraft/CrashReport.java.patch b/patches/net/minecraft/CrashReport.java.patch index 3d7f107a..05a189e6 100644 --- a/patches/net/minecraft/CrashReport.java.patch +++ b/patches/net/minecraft/CrashReport.java.patch @@ -1,13 +1,5 @@ --- a/net/minecraft/CrashReport.java +++ b/net/minecraft/CrashReport.java -@@ -34,6 +_,7 @@ - public CrashReport(String p_127509_, Throwable p_127510_) { - this.title = p_127509_; - this.exception = p_127510_; -+ this.systemReport.setDetail("CraftBukkit Information", new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit - } - - public String getTitle() { @@ -58,14 +_,8 @@ if (this.uncategorizedStackTrace != null && this.uncategorizedStackTrace.length > 0) { p_127520_.append("-- Head --\n"); diff --git a/patches/net/minecraft/SharedConstants.java.patch b/patches/net/minecraft/SharedConstants.java.patch index c0e578e4..d36ef831 100644 --- a/patches/net/minecraft/SharedConstants.java.patch +++ b/patches/net/minecraft/SharedConstants.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java -@@ -118,7 +_,8 @@ +@@ -117,7 +_,8 @@ public static final boolean USE_WORKFLOWS_HOOKS = false; public static final boolean USE_DEVONLY = false; public static boolean CHECK_DATA_FIXER_SCHEMA = true; @@ -10,7 +10,7 @@ public static final int WORLD_RESOLUTION = 16; public static final int MAX_CHAT_LENGTH = 256; public static final int MAX_USER_INPUT_COMMAND_LENGTH = 32500; -@@ -171,6 +_,7 @@ +@@ -170,6 +_,7 @@ } static { diff --git a/patches/net/minecraft/Util.java.patch b/patches/net/minecraft/Util.java.patch index e74d0222..06262a76 100644 --- a/patches/net/minecraft/Util.java.patch +++ b/patches/net/minecraft/Util.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java -@@ -267,8 +_,8 @@ +@@ -264,8 +_,8 @@ .getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().getDataVersion().getVersion())) .getChoiceType(p_137552_, p_137553_); } catch (IllegalArgumentException illegalargumentexception) { @@ -11,7 +11,7 @@ throw illegalargumentexception; } } -@@ -526,20 +_,20 @@ +@@ -630,20 +_,20 @@ public static void logAndPauseIfInIde(String p_143786_) { LOGGER.error(p_143786_); diff --git a/patches/net/minecraft/advancements/AdvancementHolder.java.patch b/patches/net/minecraft/advancements/AdvancementHolder.java.patch deleted file mode 100644 index e30a0ed1..00000000 --- a/patches/net/minecraft/advancements/AdvancementHolder.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/advancements/AdvancementHolder.java -+++ b/net/minecraft/advancements/AdvancementHolder.java -@@ -5,6 +_,7 @@ - import net.minecraft.network.codec.ByteBufCodecs; - import net.minecraft.network.codec.StreamCodec; - import net.minecraft.resources.ResourceLocation; -+import org.bukkit.craftbukkit.advancement.CraftAdvancement; - - public record AdvancementHolder(ResourceLocation id, Advancement value) { - public static final StreamCodec STREAM_CODEC = StreamCodec.composite( -@@ -33,5 +_,9 @@ - @Override - public String toString() { - return this.id.toString(); -+ } -+ -+ public final org.bukkit.advancement.Advancement toBukkit() { -+ return new CraftAdvancement(this); - } - } diff --git a/patches/net/minecraft/advancements/AdvancementRewards.java.patch b/patches/net/minecraft/advancements/AdvancementRewards.java.patch index 2b4fd0ad..34bfaa4c 100644 --- a/patches/net/minecraft/advancements/AdvancementRewards.java.patch +++ b/patches/net/minecraft/advancements/AdvancementRewards.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/AdvancementRewards.java +++ b/net/minecraft/advancements/AdvancementRewards.java -@@ -40,6 +_,7 @@ +@@ -41,6 +_,7 @@ LootParams lootparams = new LootParams.Builder(p_9990_.serverLevel()) .withParameter(LootContextParams.THIS_ENTITY, p_9990_) .withParameter(LootContextParams.ORIGIN, p_9990_.position()) diff --git a/patches/net/minecraft/client/Camera.java.patch b/patches/net/minecraft/client/Camera.java.patch index 5af6f8da..df738842 100644 --- a/patches/net/minecraft/client/Camera.java.patch +++ b/patches/net/minecraft/client/Camera.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Camera.java +++ b/net/minecraft/client/Camera.java -@@ -42,6 +_,7 @@ +@@ -44,6 +_,7 @@ private float eyeHeightOld; private float partialTickTime; public static final float FOG_DISTANCE_SCALE = 0.083333336F; @@ -8,20 +8,20 @@ public void setup(BlockGetter p_90576_, Entity p_90577_, boolean p_90578_, boolean p_90579_, float p_90580_) { this.initialized = true; -@@ -49,7 +_,10 @@ - this.entity = p_90577_; - this.detached = p_90578_; - this.partialTickTime = p_90580_; -- this.setRotation(p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_)); -+ var cameraSetup = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.ViewportEvent.ComputeCameraAngles( -+ this, p_90580_, p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_), 0) -+ ); -+ this.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll()); - this.setPosition( - Mth.lerp((double)p_90580_, p_90577_.xo, p_90577_.getX()), - Mth.lerp((double)p_90580_, p_90577_.yo, p_90577_.getY()) + (double)Mth.lerp(p_90580_, this.eyeHeightOld, this.eyeHeight), -@@ -57,11 +_,11 @@ - ); +@@ -62,7 +_,10 @@ + this.setRotation(p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_)); + this.setPosition(newminecartbehavior.getCartLerpPosition(p_90580_).add(vec3)); + } else { +- this.setRotation(p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_)); ++ var cameraSetup = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.ViewportEvent.ComputeCameraAngles( ++ this, p_90580_, p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_), 0) ++ ); ++ this.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll()); + this.setPosition( + Mth.lerp((double)p_90580_, p_90577_.xo, p_90577_.getX()), + Mth.lerp((double)p_90580_, p_90577_.yo, p_90577_.getY()) + (double)Mth.lerp(p_90580_, this.eyeHeightOld, this.eyeHeight), +@@ -72,11 +_,11 @@ + if (p_90578_) { if (p_90579_) { - this.setRotation(this.yRot + 180.0F, -this.xRot); @@ -34,7 +34,7 @@ } else if (p_90577_ instanceof LivingEntity && ((LivingEntity)p_90577_).isSleeping()) { Direction direction = ((LivingEntity)p_90577_).getBedOrientation(); this.setRotation(direction != null ? direction.toYRot() - 180.0F : 0.0F, 0.0F); -@@ -102,10 +_,17 @@ +@@ -117,10 +_,17 @@ this.setPosition(new Vec3(this.position.x + (double)vector3f.x, this.position.y + (double)vector3f.y, this.position.z + (double)vector3f.z)); } @@ -53,7 +53,7 @@ FORWARDS.rotate(this.rotation, this.forwards); UP.rotate(this.rotation, this.up); LEFT.rotate(this.rotation, this.left); -@@ -221,6 +_,17 @@ +@@ -236,6 +_,17 @@ public float getPartialTickTime() { return this.partialTickTime; diff --git a/patches/net/minecraft/client/ClientRecipeBook.java.patch b/patches/net/minecraft/client/ClientRecipeBook.java.patch index 774d2198..8d6b3ae4 100644 --- a/patches/net/minecraft/client/ClientRecipeBook.java.patch +++ b/patches/net/minecraft/client/ClientRecipeBook.java.patch @@ -1,20 +1,19 @@ --- a/net/minecraft/client/ClientRecipeBook.java +++ b/net/minecraft/client/ClientRecipeBook.java -@@ -65,7 +_,7 @@ - Recipe recipe = recipeholder.value(); - if (!recipe.isSpecial() && !recipe.isIncomplete()) { - RecipeBookCategories recipebookcategories = getCategory(recipeholder); -- String s = recipe.getGroup(); -+ String s = recipe.getGroup().isEmpty() ? recipeholder.id().toString() : recipe.getGroup(); // FORGE: Group value defaults to the recipe's ID if the recipe's explicit group is empty. - if (s.isEmpty()) { - map.computeIfAbsent(recipebookcategories, p_90645_ -> Lists.newArrayList()).add(ImmutableList.of(recipeholder)); - } else { -@@ -125,6 +_,8 @@ - } else if (recipetype == RecipeType.SMITHING) { - return RecipeBookCategories.SMITHING; - } else { -+ RecipeBookCategories categories = net.neoforged.neoforge.client.RecipeBookManager.findCategories((RecipeType) recipetype, p_301136_); -+ if (categories != null) return categories; - LOGGER.warn( - "Unknown recipe category: {}/{}", - LogUtils.defer(() -> BuiltInRegistries.RECIPE_TYPE.getKey(recipe.getType())), +@@ -74,6 +_,16 @@ + .collect(ImmutableList.toImmutableList()) + ); + } ++ // Neo: Do the same for modded search categories. ++ for (var entry : net.neoforged.neoforge.client.RecipeBookManager.getSearchCategories().entrySet()) { ++ map1.put( ++ entry.getKey(), ++ entry.getValue() ++ .stream() ++ .flatMap(category -> map1.getOrDefault(category, List.of()).stream()) ++ .collect(ImmutableList.toImmutableList()) ++ ); ++ } + + this.collectionsByTab = Map.copyOf(map1); + this.allCollections = builder.build(); diff --git a/patches/net/minecraft/client/KeyboardHandler.java.patch b/patches/net/minecraft/client/KeyboardHandler.java.patch index 2c5ce4a4..2470d92b 100644 --- a/patches/net/minecraft/client/KeyboardHandler.java.patch +++ b/patches/net/minecraft/client/KeyboardHandler.java.patch @@ -1,53 +1,49 @@ --- a/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java -@@ -407,9 +_,13 @@ - Screen.wrapScreenError(() -> { - if (p_90897_ == 1 || p_90897_ == 2) { +@@ -426,12 +_,20 @@ + if (screen != null) { + try { + if (p_90897_ != 1 && p_90897_ != 2) { +- if (p_90897_ == 0 && screen.keyReleased(p_90895_, p_90896_, p_90898_)) { ++ if (p_90897_ == 0 && ( ++ net.neoforged.neoforge.client.ClientHooks.onScreenKeyReleasedPre(screen, p_90895_, p_90896_, p_90898_) || ++ screen.keyReleased(p_90895_, p_90896_, p_90898_) || ++ net.neoforged.neoforge.client.ClientHooks.onScreenKeyReleasedPost(screen, p_90895_, p_90896_, p_90898_)) ++ ) { + return; + } + } else { screen.afterKeyboardAction(); -- aboolean[0] = screen.keyPressed(p_90895_, p_90896_, p_90898_); -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenKeyPressedPre(screen, p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = screen.keyPressed(p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenKeyPressedPost(screen, p_90895_, p_90896_, p_90898_); - } else if (p_90897_ == 0) { -- aboolean[0] = screen.keyReleased(p_90895_, p_90896_, p_90898_); -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenKeyReleasedPre(screen, p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = screen.keyReleased(p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenKeyReleasedPost(screen, p_90895_, p_90896_, p_90898_); +- if (screen.keyPressed(p_90895_, p_90896_, p_90898_)) { ++ if ( ++ net.neoforged.neoforge.client.ClientHooks.onScreenKeyPressedPre(screen, p_90895_, p_90896_, p_90898_) || ++ screen.keyPressed(p_90895_, p_90896_, p_90898_) || ++ net.neoforged.neoforge.client.ClientHooks.onScreenKeyPressedPost(screen, p_90895_, p_90896_, p_90898_) ++ ) { + return; + } } - }, "keyPressed event handler", screen.getClass().getCanonicalName()); - if (aboolean[0]) { -@@ -478,22 +_,27 @@ +@@ -516,10 +_,20 @@ + if (screen != null && this.minecraft.getOverlay() == null) { + try { + if (Character.isBmpCodePoint(p_90891_)) { +- screen.charTyped((char)p_90891_, p_90892_); ++ if (net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPre(screen, (char)p_90891_, p_90892_)) return; ++ if (screen.charTyped((char)p_90891_, p_90892_)) return; ++ net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPost(screen, (char)p_90891_, p_90892_); + } else if (Character.isValidCodePoint(p_90891_)) { +- screen.charTyped(Character.highSurrogate(p_90891_), p_90892_); +- screen.charTyped(Character.lowSurrogate(p_90891_), p_90892_); ++ if (!net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPre(screen, Character.highSurrogate(p_90891_), p_90892_)) { ++ if (!screen.charTyped(Character.highSurrogate(p_90891_), p_90892_)) { ++ net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPost(screen, Character.highSurrogate(p_90891_), p_90892_); ++ } ++ } ++ if (!net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPre(screen, Character.lowSurrogate(p_90891_), p_90892_)) { ++ if (!screen.charTyped(Character.lowSurrogate(p_90891_), p_90892_)) { ++ net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPost(screen, Character.lowSurrogate(p_90891_), p_90892_); ++ } ++ } } - } - } -+ net.neoforged.neoforge.client.ClientHooks.onKeyInput(p_90895_, p_90896_, p_90897_, p_90898_); - } - } - - private void charTyped(long p_90890_, int p_90891_, int p_90892_) { - if (p_90890_ == this.minecraft.getWindow().getWindow()) { -- GuiEventListener guieventlistener = this.minecraft.screen; -+ Screen guieventlistener = this.minecraft.screen; - if (guieventlistener != null && this.minecraft.getOverlay() == null) { - if (Character.charCount(p_90891_) == 1) { -- Screen.wrapScreenError( -- () -> guieventlistener.charTyped((char)p_90891_, p_90892_), "charTyped event handler", guieventlistener.getClass().getCanonicalName() -- ); -+ Screen.wrapScreenError(() -> { -+ if (net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPre(guieventlistener, (char)p_90891_, p_90892_)) return; -+ if (guieventlistener.charTyped((char)p_90891_, p_90892_)) return; -+ net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPost(guieventlistener, (char)p_90891_, p_90892_); -+ }, "charTyped event handler", guieventlistener.getClass().getCanonicalName()); - } else { - for (char c0 : Character.toChars(p_90891_)) { -- Screen.wrapScreenError( -- () -> guieventlistener.charTyped(c0, p_90892_), "charTyped event handler", guieventlistener.getClass().getCanonicalName() -- ); -+ Screen.wrapScreenError(() -> { -+ if (net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPre(guieventlistener, c0, p_90892_)) return; -+ if (guieventlistener.charTyped(c0, p_90892_)) return; -+ net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPost(guieventlistener, c0, p_90892_); -+ }, "charTyped event handler", guieventlistener.getClass().getCanonicalName()); - } - } - } + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.forThrowable(throwable, "charTyped event handler"); diff --git a/patches/net/minecraft/client/Minecraft.java.patch b/patches/net/minecraft/client/Minecraft.java.patch index 13ff259e..d73618ac 100644 --- a/patches/net/minecraft/client/Minecraft.java.patch +++ b/patches/net/minecraft/client/Minecraft.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java -@@ -254,7 +_,7 @@ +@@ -253,7 +_,7 @@ import org.slf4j.Logger; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ static Minecraft instance; private static final Logger LOGGER = LogUtils.getLogger(); public static final boolean ON_OSX = Util.getPlatform() == Util.OS.OSX; -@@ -435,7 +_,6 @@ +@@ -437,7 +_,6 @@ } }, Util.nonCriticalIoPool()); LOGGER.info("Setting user: {}", this.user.getName()); @@ -17,10 +17,10 @@ this.demo = p_91084_.game.demo; this.allowsMultiplayer = !p_91084_.game.disableMultiplayer; this.allowsChat = !p_91084_.game.disableChat; -@@ -476,15 +_,15 @@ +@@ -488,15 +_,15 @@ + LOGGER.error("Couldn't set icon", (Throwable)ioexception); } - this.window.setFramerateLimit(this.options.framerateLimit().get()); + // FORGE: Move mouse and keyboard handler setup further below this.mouseHandler = new MouseHandler(this); - this.mouseHandler.setup(this.window.getWindow()); @@ -29,13 +29,13 @@ RenderSystem.initRenderer(this.options.glDebugVerbosity, false); this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight()); this.mainRenderTarget.setClearColor(0.0F, 0.0F, 0.0F, 0.0F); - this.mainRenderTarget.clear(ON_OSX); + this.mainRenderTarget.clear(); this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); + net.neoforged.neoforge.client.loading.ClientModLoader.begin(this, this.resourcePackRepository, this.resourceManager); this.resourcePackRepository.reload(); this.options.loadSelectedResourcePacks(this.resourcePackRepository); this.languageManager = new LanguageManager(this.options.languageCode, p_344151_ -> { -@@ -554,6 +_,7 @@ +@@ -582,6 +_,7 @@ ); this.resourceManager.registerReloadListener(this.entityRenderDispatcher); this.particleEngine = new ParticleEngine(this.level, this.textureManager); @@ -43,12 +43,13 @@ this.resourceManager.registerReloadListener(this.particleEngine); this.paintingTextures = new PaintingTextureManager(this.textureManager); this.resourceManager.registerReloadListener(this.paintingTextures); -@@ -566,10 +_,14 @@ +@@ -591,11 +_,15 @@ + this.resourceManager.registerReloadListener(this.guiSprites); this.gameRenderer = new GameRenderer(this, this.entityRenderDispatcher.getItemInHandRenderer(), this.resourceManager, this.renderBuffers); - this.resourceManager.registerReloadListener(this.gameRenderer.createReloadListener()); this.levelRenderer = new LevelRenderer(this, this.entityRenderDispatcher, this.blockEntityRenderDispatcher, this.renderBuffers); + net.neoforged.fml.ModLoader.postEvent(new net.neoforged.neoforge.client.event.RenderLevelStageEvent.RegisterStageEvent()); this.resourceManager.registerReloadListener(this.levelRenderer); + this.resourceManager.registerReloadListener(this.levelRenderer.getCloudRenderer()); this.gpuWarnlistManager = new GpuWarnlistManager(); this.resourceManager.registerReloadListener(this.gpuWarnlistManager); this.resourceManager.registerReloadListener(this.regionalCompliancies); @@ -58,7 +59,7 @@ this.gui = new Gui(this); this.debugRenderer = new DebugRenderer(this); RealmsClient realmsclient = RealmsClient.create(this); -@@ -594,6 +_,7 @@ +@@ -620,6 +_,7 @@ this.options.fullscreen().set(this.window.isFullscreen()); } @@ -66,7 +67,7 @@ this.window.updateVsync(this.options.enableVsync().get()); this.window.updateRawMouseInput(this.options.rawMouseInput().get()); this.window.setDefaultErrorCallback(); -@@ -614,16 +_,18 @@ +@@ -641,16 +_,18 @@ GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS); Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay); this.setOverlay( @@ -88,8 +89,8 @@ + ).get() ); this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.path()); - } -@@ -663,6 +_,8 @@ + this.framerateLimitTracker = new FramerateLimitTracker(this.options, this); +@@ -696,6 +_,8 @@ runnable = () -> this.setScreen(screen); } @@ -98,7 +99,7 @@ return runnable; } -@@ -711,7 +_,7 @@ +@@ -744,7 +_,7 @@ private String createTitle() { StringBuilder stringbuilder = new StringBuilder("Minecraft"); if (checkModStatus().shouldReportAsModified()) { @@ -107,7 +108,7 @@ } stringbuilder.append(" "); -@@ -743,7 +_,7 @@ +@@ -776,7 +_,7 @@ } private void rollbackResourcePacks(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299846_) { @@ -116,24 +117,16 @@ this.clearResourcePacksOnError(p_91240_, null, p_299846_); } else { Util.throwAsRuntime(p_91240_); -@@ -871,13 +_,13 @@ - - if (p_91333_.getSaveFile() != null) { - Bootstrap.realStdoutPrintln("#@!@# Game crashed! Crash report saved to: #@!@# " + p_91333_.getSaveFile().toAbsolutePath()); -- System.exit(-1); -+ net.neoforged.neoforge.server.ServerLifecycleHooks.handleExit(-1); - } else if (p_91333_.saveToFile(path1, ReportType.CRASH)) { - Bootstrap.realStdoutPrintln("#@!@# Game crashed! Crash report saved to: #@!@# " + path1.toAbsolutePath()); -- System.exit(-1); -+ net.neoforged.neoforge.server.ServerLifecycleHooks.handleExit(-1); - } else { - Bootstrap.realStdoutPrintln("#@?@# Game crashed! Crash report could not be saved. #@?@#"); -- System.exit(-2); -+ net.neoforged.neoforge.server.ServerLifecycleHooks.handleExit(-2); +@@ -935,7 +_,7 @@ + p_307414_.soundManager.emergencyShutdown(); } + +- System.exit(i); ++ net.neoforged.neoforge.server.ServerLifecycleHooks.handleExit(i); } -@@ -1006,9 +_,7 @@ + public boolean isEnforceUnicode() { +@@ -1062,9 +_,7 @@ LOGGER.error("setScreen called from non-game thread"); } @@ -144,7 +137,7 @@ this.setLastInputType(InputType.NONE); } -@@ -1025,6 +_,19 @@ +@@ -1081,6 +_,19 @@ } } @@ -164,20 +157,20 @@ this.screen = p_91153_; if (this.screen != null) { this.screen.added(); -@@ -1170,9 +_,11 @@ +@@ -1234,9 +_,11 @@ this.mouseHandler.handleAccumulatedMovement(); - this.profiler.pop(); + profilerfiller.pop(); if (!this.noRender) { -+ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePre(this.timer); - this.profiler.popPush("gameRenderer"); - this.gameRenderer.render(this.timer, p_91384_); - this.profiler.pop(); -+ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePost(this.timer); ++ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePre(this.deltaTracker); + profilerfiller.popPush("gameRenderer"); + this.gameRenderer.render(this.deltaTracker, p_91384_); + profilerfiller.pop(); ++ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePost(this.deltaTracker); } - if (this.fpsPieResults != null) { -@@ -1203,9 +_,13 @@ - this.profiler.pop(); + profilerfiller.push("blit"); +@@ -1264,9 +_,13 @@ + profilerfiller.pop(); this.window.setErrorSection("Post render"); this.frames++; - this.pause = this.hasSingleplayerServer() @@ -188,10 +181,10 @@ + this.pause = pause; + net.neoforged.neoforge.client.ClientHooks.onClientPauseChangePost(pause); + } - this.timer.updatePauseState(this.pause); - this.timer.updateFrozenState(!this.isLevelRunningNormally()); - long k = Util.getNanos(); -@@ -1298,10 +_,12 @@ + this.deltaTracker.updatePauseState(this.pause); + this.deltaTracker.updateFrozenState(!this.isLevelRunningNormally()); + long l = Util.getNanos(); +@@ -1358,10 +_,12 @@ this.window.setGuiScale((double)i); if (this.screen != null) { this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); @@ -199,12 +192,12 @@ } RenderTarget rendertarget = this.getMainRenderTarget(); - rendertarget.resize(this.window.getWidth(), this.window.getHeight(), ON_OSX); + rendertarget.resize(this.window.getWidth(), this.window.getHeight()); + if (this.gameRenderer != null) this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight()); this.mouseHandler.setIgnoreFirstMove(); } -@@ -1569,6 +_,7 @@ +@@ -1502,6 +_,7 @@ } public void stop() { @@ -212,7 +205,7 @@ this.running = false; } -@@ -1598,9 +_,17 @@ +@@ -1531,9 +_,17 @@ BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockPos blockpos = blockhitresult.getBlockPos(); if (!this.level.getBlockState(blockpos).isAir()) { @@ -232,7 +225,7 @@ this.player.swing(InteractionHand.MAIN_HAND); } } -@@ -1628,6 +_,8 @@ +@@ -1561,6 +_,8 @@ return false; } else { boolean flag = false; @@ -241,7 +234,7 @@ switch (this.hitResult.getType()) { case ENTITY: this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity()); -@@ -1648,8 +_,10 @@ +@@ -1581,8 +_,10 @@ } this.player.resetAttackStrengthTicker(); @@ -252,7 +245,7 @@ this.player.swing(InteractionHand.MAIN_HAND); return flag; } -@@ -1665,6 +_,11 @@ +@@ -1598,6 +_,11 @@ } for (InteractionHand interactionhand : InteractionHand.values()) { @@ -264,35 +257,35 @@ ItemStack itemstack = this.player.getItemInHand(interactionhand); if (!itemstack.isItemEnabled(this.level.enabledFeatures())) { return; -@@ -1685,7 +_,7 @@ +@@ -1618,7 +_,7 @@ } - if (interactionresult.consumesAction()) { -- if (interactionresult.shouldSwing()) { -+ if (interactionresult.shouldSwing() && inputEvent.shouldSwingHand()) { + if (interactionresult instanceof InteractionResult.Success interactionresult$success2) { +- if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT) { ++ if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { this.player.swing(interactionhand); } -@@ -1697,7 +_,7 @@ +@@ -1630,7 +_,7 @@ int i = itemstack.getCount(); InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult); - if (interactionresult1.consumesAction()) { -- if (interactionresult1.shouldSwing()) { -+ if (interactionresult1.shouldSwing() && inputEvent.shouldSwingHand()) { + if (interactionresult1 instanceof InteractionResult.Success interactionresult$success) { +- if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT) { ++ if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { this.player.swing(interactionhand); if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.gameMode.hasInfiniteItems())) { this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand); -@@ -1713,6 +_,9 @@ +@@ -1646,6 +_,9 @@ } } + if (itemstack.isEmpty() && (this.hitResult == null || this.hitResult.getType() == HitResult.Type.MISS)) + net.neoforged.neoforge.common.CommonHooks.onEmptyClick(this.player, interactionhand); + - if (!itemstack.isEmpty()) { - InteractionResult interactionresult2 = this.gameMode.useItem(this.player, interactionhand); - if (interactionresult2.consumesAction()) { -@@ -1735,6 +_,8 @@ + if (!itemstack.isEmpty() + && this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) { + if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) { +@@ -1666,6 +_,8 @@ public void tick() { this.clientTickCount++; @@ -301,32 +294,32 @@ if (this.level != null && !this.pause) { this.level.tickRateManager().tick(); } -@@ -1826,6 +_,7 @@ +@@ -1764,6 +_,7 @@ this.tutorial.tick(); + net.neoforged.neoforge.event.EventHooks.fireLevelTickPre(this.level, () -> true); try { this.level.tick(() -> true); - } catch (Throwable throwable) { -@@ -1839,6 +_,7 @@ + } catch (Throwable throwable1) { +@@ -1777,6 +_,7 @@ - throw new ReportedException(crashreport); + throw new ReportedException(crashreport1); } + net.neoforged.neoforge.event.EventHooks.fireLevelTickPost(this.level, () -> true); } - this.profiler.popPush("animateTick"); -@@ -1858,6 +_,8 @@ - this.profiler.popPush("keyboard"); + profilerfiller.popPush("animateTick"); +@@ -1801,6 +_,8 @@ + profilerfiller.popPush("keyboard"); this.keyboardHandler.tick(); - this.profiler.pop(); + profilerfiller.pop(); + + net.neoforged.neoforge.client.ClientHooks.fireClientTickPost(); } private boolean isLevelRunningNormally() { -@@ -2056,7 +_,8 @@ +@@ -2000,7 +_,8 @@ } public void setLevel(ClientLevel p_91157_, ReceivingLevelScreen.Reason p_341652_) { @@ -336,7 +329,7 @@ this.level = p_91157_; this.updateLevelInEngines(p_91157_); if (!this.isLocalServer) { -@@ -2093,6 +_,7 @@ +@@ -2037,6 +_,7 @@ IntegratedServer integratedserver = this.singleplayerServer; this.singleplayerServer = null; this.gameRenderer.resetData(); @@ -344,15 +337,15 @@ this.gameMode = null; this.narrator.clear(); this.clientLevelTeardownInProgress = true; -@@ -2100,6 +_,7 @@ +@@ -2044,6 +_,7 @@ try { this.updateScreenAndTick(p_320248_); if (this.level != null) { + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.LevelEvent.Unload(this.level)); if (integratedserver != null) { - this.profiler.push("waitForServer"); - -@@ -2258,6 +_,7 @@ + ProfilerFiller profilerfiller = Profiler.get(); + profilerfiller.push("waitForServer"); +@@ -2204,6 +_,7 @@ private void pickBlock() { if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { @@ -360,7 +353,7 @@ boolean flag = this.player.getAbilities().instabuild; BlockEntity blockentity = null; HitResult.Type hitresult$type = this.hitResult.getType(); -@@ -2270,7 +_,7 @@ +@@ -2216,7 +_,7 @@ } Block block = blockstate.getBlock(); @@ -369,7 +362,7 @@ if (itemstack.isEmpty()) { return; } -@@ -2284,7 +_,7 @@ +@@ -2230,7 +_,7 @@ } Entity entity = ((EntityHitResult)this.hitResult).getEntity(); @@ -378,7 +371,7 @@ if (itemstack == null) { return; } -@@ -2794,6 +_,10 @@ +@@ -2757,6 +_,10 @@ public void updateMaxMipLevel(int p_91313_) { this.modelManager.updateMaxMipLevel(p_91313_); diff --git a/patches/net/minecraft/client/MouseHandler.java.patch b/patches/net/minecraft/client/MouseHandler.java.patch index 01b53bd4..48d9f7cb 100644 --- a/patches/net/minecraft/client/MouseHandler.java.patch +++ b/patches/net/minecraft/client/MouseHandler.java.patch @@ -1,42 +1,42 @@ --- a/net/minecraft/client/MouseHandler.java +++ b/net/minecraft/client/MouseHandler.java -@@ -79,6 +_,7 @@ +@@ -85,6 +_,7 @@ this.activeButton = -1; } + if (net.neoforged.neoforge.client.ClientHooks.onMouseButtonPre(p_91532_, p_91533_, p_91534_)) return; - boolean[] aboolean = new boolean[]{false}; if (this.minecraft.getOverlay() == null) { if (this.minecraft.screen == null) { -@@ -91,13 +_,21 @@ - Screen screen = this.minecraft.screen; - if (flag) { + if (!this.mouseGrabbed && flag) { +@@ -98,7 +_,12 @@ screen.afterMouseAction(); -- Screen.wrapScreenError( -- () -> aboolean[0] = screen.mouseClicked(d0, d1, i), "mouseClicked event handler", screen.getClass().getCanonicalName() -- ); -+ Screen.wrapScreenError(() -> { -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenMouseClickedPre(screen, d0, d1, i); -+ if (!aboolean[0]) { -+ aboolean[0] = screen.mouseClicked(d0, d1, i); -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenMouseClickedPost(screen, d0, d1, i, aboolean[0]); -+ } -+ }, "mouseClicked event handler", screen.getClass().getCanonicalName()); + + try { +- if (screen.mouseClicked(d0, d1, i)) { ++ boolean flag2; ++ if ( ++ net.neoforged.neoforge.client.ClientHooks.onScreenMouseClickedPre(screen, d0, d1, i) || ++ (flag2 = screen.mouseClicked(d0, d1, i)) | ++ net.neoforged.neoforge.client.ClientHooks.onScreenMouseClickedPost(screen, d0, d1, i, flag2) ++ ) { + return; + } + } catch (Throwable throwable1) { +@@ -112,7 +_,12 @@ + } } else { -- Screen.wrapScreenError( -- () -> aboolean[0] = screen.mouseReleased(d0, d1, i), "mouseReleased event handler", screen.getClass().getCanonicalName() -- ); -+ Screen.wrapScreenError(() -> { -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenMouseReleasedPre(screen, d0, d1, i); -+ if (!aboolean[0]) { -+ aboolean[0] = screen.mouseReleased(d0, d1, i); -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenMouseReleasedPost(screen, d0, d1, i, aboolean[0]); -+ } -+ }, "mouseReleased event handler", screen.getClass().getCanonicalName()); - } - } - } -@@ -120,6 +_,7 @@ + try { +- if (screen.mouseReleased(d0, d1, i)) { ++ boolean flag2; ++ if ( ++ net.neoforged.neoforge.client.ClientHooks.onScreenMouseReleasedPre(screen, d0, d1, i) || ++ (flag2 = screen.mouseReleased(d0, d1, i)) | ++ net.neoforged.neoforge.client.ClientHooks.onScreenMouseReleasedPost(screen, d0, d1, i, flag2) ++ ) { + return; + } + } catch (Throwable throwable) { +@@ -146,6 +_,7 @@ } } } @@ -44,7 +44,7 @@ } } -@@ -133,7 +_,11 @@ +@@ -160,7 +_,11 @@ if (this.minecraft.screen != null) { double d3 = this.xpos * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth(); double d4 = this.ypos * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getScreenHeight(); @@ -56,31 +56,29 @@ + } this.minecraft.screen.afterMouseAction(); } else if (this.minecraft.player != null) { - if (this.accumulatedScrollX != 0.0 && Math.signum(d1) != Math.signum(this.accumulatedScrollX)) { -@@ -155,6 +_,7 @@ - this.accumulatedScrollX -= (double)j; - this.accumulatedScrollY -= (double)i; - int k = i == 0 ? -j : i; + Vector2i vector2i = this.scrollWheelHandler.onMouseScroll(d1, d2); +@@ -169,6 +_,7 @@ + } + + int i = vector2i.y == 0 ? -vector2i.x : vector2i.y; + if (net.neoforged.neoforge.client.ClientHooks.onMouseScroll(this, d1, d2)) return; if (this.minecraft.player.isSpectator()) { if (this.minecraft.gui.getSpectatorGui().isMenuActive()) { - this.minecraft.gui.getSpectatorGui().onMouseScrolled(-k); -@@ -244,9 +_,11 @@ - double d5 = this.accumulatedDY - * (double)this.minecraft.getWindow().getGuiScaledHeight() + this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i); +@@ -280,7 +_,11 @@ / (double)this.minecraft.getWindow().getScreenHeight(); -- Screen.wrapScreenError( -- () -> screen.mouseDragged(d2, d3, this.activeButton, d4, d5), "mouseDragged event handler", screen.getClass().getCanonicalName() -- ); -+ Screen.wrapScreenError(() -> { -+ if (net.neoforged.neoforge.client.ClientHooks.onScreenMouseDragPre(screen, d2, d3, this.activeButton, d4, d5)) return; -+ if (screen.mouseDragged(d2, d3, this.activeButton, d4, d5)) return; -+ net.neoforged.neoforge.client.ClientHooks.onScreenMouseDragPost(screen, d2, d3, this.activeButton, d4, d5); -+ }, "mouseDragged event handler", screen.getClass().getCanonicalName()); - } - screen.afterMouseMove(); -@@ -262,12 +_,13 @@ + try { +- screen.mouseDragged(d2, d3, this.activeButton, d4, d5); ++ if (!net.neoforged.neoforge.client.ClientHooks.onScreenMouseDragPre(screen, d2, d3, this.activeButton, d4, d5)) { ++ if (!screen.mouseDragged(d2, d3, this.activeButton, d4, d5)) { ++ net.neoforged.neoforge.client.ClientHooks.onScreenMouseDragPost(screen, d2, d3, this.activeButton, d4, d5); ++ } ++ } + } catch (Throwable throwable) { + CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler"); + screen.fillCrashDetails(crashreport1); +@@ -304,12 +_,13 @@ } private void turnPlayer(double p_316356_) { @@ -96,7 +94,7 @@ double d5 = this.smoothTurnX.getNewDeltaValue(this.accumulatedDX * d4, p_316356_ * d4); double d6 = this.smoothTurnY.getNewDeltaValue(this.accumulatedDY * d4, p_316356_ * d4); d0 = d5; -@@ -313,6 +_,14 @@ +@@ -355,6 +_,14 @@ public double ypos() { return this.ypos; diff --git a/patches/net/minecraft/client/Options.java.patch b/patches/net/minecraft/client/Options.java.patch index 63cda73a..ba0680da 100644 --- a/patches/net/minecraft/client/Options.java.patch +++ b/patches/net/minecraft/client/Options.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java -@@ -727,9 +_,10 @@ +@@ -746,9 +_,10 @@ } }, new OptionInstance.LazyEnum<>( @@ -12,7 +12,7 @@ && !Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().contains(p_232011_) ? Optional.empty() : Optional.of(p_232011_), -@@ -799,7 +_,7 @@ +@@ -822,7 +_,7 @@ this.incompatibleResourcePacks.clear(); for (Pack pack : p_275268_.getSelectedPacks()) { @@ -21,7 +21,7 @@ this.resourcePacks.add(pack.getId()); if (!pack.getCompatibility().isCompatible()) { this.incompatibleResourcePacks.add(pack.getId()); -@@ -1099,6 +_,7 @@ +@@ -1130,6 +_,7 @@ } public Options(Minecraft p_92138_, File p_92139_) { @@ -29,7 +29,7 @@ this.minecraft = p_92138_; this.optionsFile = new File(p_92139_, "options.txt"); boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L; -@@ -1236,11 +_,21 @@ +@@ -1264,11 +_,21 @@ this.onboardAccessibility = p_168428_.process("onboardAccessibility", this.onboardAccessibility); p_168428_.process("menuBackgroundBlurriness", this.menuBackgroundBlurriness); @@ -53,7 +53,7 @@ } } -@@ -1258,6 +_,9 @@ +@@ -1286,6 +_,9 @@ } public void load() { @@ -63,7 +63,7 @@ try { if (!this.optionsFile.exists()) { return; -@@ -1285,7 +_,8 @@ +@@ -1313,7 +_,8 @@ } } @@ -73,7 +73,7 @@ new Options.FieldAccess() { @Nullable private String getValueOrNull(String p_168459_) { -@@ -1460,6 +_,7 @@ +@@ -1484,6 +_,7 @@ } public ClientInformation buildPlayerInformation() { @@ -81,7 +81,7 @@ int i = 0; for (PlayerModelPart playermodelpart : this.modelParts) { -@@ -1535,6 +_,23 @@ +@@ -1555,6 +_,23 @@ } p_92146_.setSelected(set); diff --git a/patches/net/minecraft/client/RecipeBookCategories.java.patch b/patches/net/minecraft/client/RecipeBookCategories.java.patch deleted file mode 100644 index 71ddc27b..00000000 --- a/patches/net/minecraft/client/RecipeBookCategories.java.patch +++ /dev/null @@ -1,59 +0,0 @@ ---- a/net/minecraft/client/RecipeBookCategories.java -+++ b/net/minecraft/client/RecipeBookCategories.java -@@ -12,7 +_,7 @@ - import net.neoforged.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public enum RecipeBookCategories { -+public enum RecipeBookCategories implements net.neoforged.fml.common.asm.enumextension.IExtensibleEnum { - CRAFTING_SEARCH(new ItemStack(Items.COMPASS)), - CRAFTING_BUILDING_BLOCKS(new ItemStack(Blocks.BRICKS)), - CRAFTING_REDSTONE(new ItemStack(Items.REDSTONE)), -@@ -38,20 +_,20 @@ - public static final List CRAFTING_CATEGORIES = ImmutableList.of( - CRAFTING_SEARCH, CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE - ); -- public static final Map> AGGREGATE_CATEGORIES = ImmutableMap.of( -- CRAFTING_SEARCH, -- ImmutableList.of(CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE), -- FURNACE_SEARCH, -- ImmutableList.of(FURNACE_FOOD, FURNACE_BLOCKS, FURNACE_MISC), -- BLAST_FURNACE_SEARCH, -- ImmutableList.of(BLAST_FURNACE_BLOCKS, BLAST_FURNACE_MISC), -- SMOKER_SEARCH, -- ImmutableList.of(SMOKER_FOOD) -- ); -+ public static final Map> AGGREGATE_CATEGORIES = net.neoforged.neoforge.client.RecipeBookManager.getAggregateCategories(); -+ @Deprecated // Neo: Empty for custom categories. Use the getter. - private final List itemIcons; -+ private final java.util.function.Supplier> itemIconsSupplier; - -+ @net.neoforged.fml.common.asm.enumextension.ReservedConstructor - private RecipeBookCategories(ItemStack... p_92267_) { - this.itemIcons = ImmutableList.copyOf(p_92267_); -+ this.itemIconsSupplier = () -> this.itemIcons; -+ } -+ -+ private RecipeBookCategories(java.util.function.Supplier> itemIconsSupplier) { -+ this.itemIcons = List.of(); -+ this.itemIconsSupplier = net.neoforged.neoforge.common.util.Lazy.of(itemIconsSupplier); - } - - public static List getCategories(RecipeBookType p_92270_) { -@@ -60,10 +_,15 @@ - case FURNACE -> FURNACE_CATEGORIES; - case BLAST_FURNACE -> BLAST_FURNACE_CATEGORIES; - case SMOKER -> SMOKER_CATEGORIES; -+ default -> net.neoforged.neoforge.client.RecipeBookManager.getCustomCategoriesOrEmpty(p_92270_); - }; - } - - public List getIconItems() { -- return this.itemIcons; -+ return this.itemIconsSupplier.get(); -+ } -+ -+ public static net.neoforged.fml.common.asm.enumextension.ExtensionInfo getExtensionInfo() { -+ return net.neoforged.fml.common.asm.enumextension.ExtensionInfo.nonExtended(RecipeBookCategories.class); - } - } diff --git a/patches/net/minecraft/client/color/item/ItemColors.java.patch b/patches/net/minecraft/client/color/item/ItemColors.java.patch index 49188648..afe4aac3 100644 --- a/patches/net/minecraft/client/color/item/ItemColors.java.patch +++ b/patches/net/minecraft/client/color/item/ItemColors.java.patch @@ -10,8 +10,8 @@ public static ItemColors createDefault(BlockColors p_92684_) { ItemColors itemcolors = new ItemColors(); -@@ -105,17 +_,20 @@ - : FastColor.ARGB32.opaque(p_329710_.getOrDefault(DataComponents.MAP_COLOR, MapItemColor.DEFAULT).rgb()), +@@ -101,17 +_,20 @@ + (p_359075_, p_359076_) -> p_359076_ == 0 ? -1 : ARGB.opaque(p_359075_.getOrDefault(DataComponents.MAP_COLOR, MapItemColor.DEFAULT).rgb()), Items.FILLED_MAP ); + net.neoforged.neoforge.client.ClientHooks.onItemColorsInit(itemcolors, p_92684_); diff --git a/patches/net/minecraft/client/gui/Font.java.patch b/patches/net/minecraft/client/gui/Font.java.patch index 57718aa4..92bc34f8 100644 --- a/patches/net/minecraft/client/gui/Font.java.patch +++ b/patches/net/minecraft/client/gui/Font.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/Font.java +++ b/net/minecraft/client/gui/Font.java -@@ -31,7 +_,7 @@ +@@ -33,7 +_,7 @@ import org.joml.Vector3f; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ private static final float EFFECT_DEPTH = 0.01F; private static final Vector3f SHADOW_OFFSET = new Vector3f(0.0F, 0.0F, 0.03F); public static final int ALPHA_CUTOFF = 8; -@@ -326,6 +_,8 @@ +@@ -309,6 +_,8 @@ public StringSplitter getSplitter() { return this.splitter; } diff --git a/patches/net/minecraft/client/gui/Gui.java.patch b/patches/net/minecraft/client/gui/Gui.java.patch index dc1055a5..57ea3460 100644 --- a/patches/net/minecraft/client/gui/Gui.java.patch +++ b/patches/net/minecraft/client/gui/Gui.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/Gui.java +++ b/net/minecraft/client/gui/Gui.java -@@ -69,6 +_,9 @@ +@@ -71,6 +_,9 @@ import net.neoforged.api.distmarker.OnlyIn; import org.joml.Matrix4fStack; @@ -10,8 +10,8 @@ @OnlyIn(Dist.CLIENT) public class Gui { private static final ResourceLocation CROSSHAIR_SPRITE = ResourceLocation.withDefaultNamespace("hud/crosshair"); -@@ -158,9 +_,21 @@ - private long healthBlinkTime; +@@ -175,9 +_,21 @@ + private int lastBubblePopSoundPlayed; private float autosaveIndicatorValue; private float lastAutosaveIndicatorValue; + /** Neo: This is empty and unused, rendering goes through {@link #layerManager} instead. */ @@ -32,7 +32,7 @@ public Gui(Minecraft p_232355_) { this.minecraft = p_232355_; this.debugOverlay = new DebugScreenOverlay(p_232355_); -@@ -170,27 +_,40 @@ +@@ -187,27 +_,40 @@ this.bossOverlay = new BossHealthOverlay(p_232355_); this.subtitleOverlay = new SubtitleOverlay(p_232355_); this.resetTitleTimes(); @@ -90,18 +90,18 @@ } public void resetTitleTimes() { -@@ -201,7 +_,9 @@ +@@ -217,7 +_,9 @@ + } public void render(GuiGraphics p_282884_, DeltaTracker p_348630_) { - RenderSystem.enableDepthTest(); - this.layers.render(p_282884_, p_348630_); + leftHeight = 39; + rightHeight = 39; + this.layerManager.render(p_282884_, p_348630_); - RenderSystem.disableDepthTest(); } -@@ -262,8 +_,12 @@ + private void renderCameraOverlays(GuiGraphics p_316735_, DeltaTracker p_348538_) { +@@ -289,8 +_,12 @@ } if (i > 8) { @@ -115,7 +115,7 @@ int j; if (this.animateOverlayMessageColor) { j = Mth.hsvToArgb(f / 50.0F, 0.7F, 0.6F, i); -@@ -323,9 +_,19 @@ +@@ -350,9 +_,19 @@ private void renderChat(GuiGraphics p_316307_, DeltaTracker p_348631_) { if (!this.chat.isChatFocused()) { Window window = this.minecraft.getWindow(); @@ -135,7 +135,7 @@ } } -@@ -441,6 +_,8 @@ +@@ -449,6 +_,8 @@ List list = Lists.newArrayListWithExpectedSize(collection.size()); for (MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { @@ -143,16 +143,16 @@ + if (!renderer.isVisibleInGui(mobeffectinstance)) continue; Holder holder = mobeffectinstance.getEffect(); if (mobeffectinstance.showIcon()) { - int i = p_282812_.guiWidth(); -@@ -471,6 +_,7 @@ + int k = p_282812_.guiWidth(); +@@ -480,6 +_,7 @@ } } -+ if (renderer.renderGuiIcon(mobeffectinstance, this, p_282812_, i, j, 0, f)) continue; ++ if (renderer.renderGuiIcon(mobeffectinstance, this, p_282812_, k, l, 0, f)) continue; TextureAtlasSprite textureatlassprite = mobeffecttexturemanager.get(holder); - int l1 = i; - int i1 = j; -@@ -488,29 +_,59 @@ + int l1 = k; + int k1 = l; +@@ -495,29 +_,59 @@ } } @@ -215,7 +215,7 @@ this.spectatorGui.renderTooltip(p_316628_); } } -@@ -633,18 +_,23 @@ +@@ -632,18 +_,23 @@ } private void renderSelectedItemName(GuiGraphics p_283501_) { @@ -223,7 +223,7 @@ + } + + public void renderSelectedItemName(GuiGraphics p_283501_, int yShift) { - this.minecraft.getProfiler().push("selectedItemName"); + Profiler.get().push("selectedItemName"); if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) { MutableComponent mutablecomponent = Component.empty() .append(this.lastToolHighlight.getHoverName()) @@ -242,31 +242,31 @@ if (!this.minecraft.gameMode.canHurtPlayer()) { k += 14; } -@@ -655,7 +_,13 @@ +@@ -654,7 +_,13 @@ } if (l > 0) { -- p_283501_.drawStringWithBackdrop(this.getFont(), mutablecomponent, j, k, i, FastColor.ARGB32.color(l, -1)); +- p_283501_.drawStringWithBackdrop(this.getFont(), mutablecomponent, j, k, i, ARGB.color(l, -1)); + Font font = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(lastToolHighlight).getFont(lastToolHighlight, net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.FontContext.SELECTED_ITEM_NAME); + if (font == null) { -+ p_283501_.drawStringWithBackdrop(this.getFont(), highlightTip, j, k, i, FastColor.ARGB32.color(l, -1)); ++ p_283501_.drawStringWithBackdrop(this.getFont(), highlightTip, j, k, i, ARGB.color(l, -1)); + } else { + j = (p_283501_.guiWidth() - font.width(highlightTip)) / 2; -+ p_283501_.drawStringWithBackdrop(font, highlightTip, j, k, i, FastColor.ARGB32.color(l, -1)); ++ p_283501_.drawStringWithBackdrop(font, highlightTip, j, k, i, ARGB.color(l, -1)); + } } } -@@ -663,7 +_,7 @@ +@@ -662,7 +_,7 @@ } private void renderDemoOverlay(GuiGraphics p_281825_, DeltaTracker p_348679_) { - if (this.minecraft.isDemo()) { + if (this.minecraft.isDemo() && !this.getDebugOverlay().showDebugScreen()) { // Neo: Hide demo timer when F3 debug overlay is open; fixes MC-271166 - this.minecraft.getProfiler().push("demo"); + Profiler.get().push("demo"); Component component; if (this.minecraft.level.getGameTime() >= 120500L) { -@@ -778,7 +_,15 @@ +@@ -774,7 +_,15 @@ return (int)Math.ceil((double)p_93013_ / 10.0); } @@ -282,7 +282,7 @@ Player player = this.getCameraPlayer(); if (player != null) { int i = Mth.ceil(player.getHealth()); -@@ -803,35 +_,62 @@ +@@ -798,31 +_,59 @@ this.random.setSeed((long)(this.tickCount * 312871)); int l = p_283143_.guiWidth() / 2 - 91; int i1 = p_283143_.guiWidth() / 2 + 91; @@ -299,12 +299,12 @@ k2 = this.tickCount % Mth.ceil(f + 5.0F); } - -- this.minecraft.getProfiler().push("armor"); +- Profiler.get().push("armor"); - renderArmor(p_283143_, player, j1, l1, i2, l); -- this.minecraft.getProfiler().popPush("health"); -+ this.minecraft.getProfiler().push("health"); +- Profiler.get().popPush("health"); ++ Profiler.get().push("health"); this.renderHearts(p_283143_, player, l, j1, i2, k2, f, i, k, k1, flag); -+ this.minecraft.getProfiler().pop(); ++ Profiler.get().pop(); + } + } + @@ -312,9 +312,9 @@ + Player player = this.getCameraPlayer(); + if (player != null) { + int l = p_283143_.guiWidth() / 2 - 91; -+ this.minecraft.getProfiler().push("armor"); ++ Profiler.get().push("armor"); + renderArmor(p_283143_, player, p_283143_.guiHeight() - leftHeight + 10, 1, 0, l); -+ this.minecraft.getProfiler().pop(); ++ Profiler.get().pop(); + if (player.getArmorValue() > 0) { + leftHeight += 10; + } @@ -327,61 +327,57 @@ LivingEntity livingentity = this.getPlayerVehicleWithHealth(); int l2 = this.getVehicleMaxHearts(livingentity); if (l2 == 0) { -- this.minecraft.getProfiler().popPush("food"); -+ this.minecraft.getProfiler().push("food"); +- Profiler.get().popPush("food"); ++ Profiler.get().push("food"); + int i1 = p_283143_.guiWidth() / 2 + 91; + int j1 = p_283143_.guiHeight() - rightHeight; this.renderFood(p_283143_, player, j1, i1); - j2 -= 10; + rightHeight += 10; -+ this.minecraft.getProfiler().pop(); ++ Profiler.get().pop(); } -- -- this.minecraft.getProfiler().popPush("air"); + } + } -+ + +- Profiler.get().popPush("air"); +- this.renderAirBubbles(p_283143_, player, l2, j2, i1); + private void renderAirLevel(GuiGraphics p_283143_) { + Player player = this.getCameraPlayer(); + if (player != null) { + int i1 = p_283143_.guiWidth() / 2 + 91; -+ -+ this.minecraft.getProfiler().push("air"); - int i3 = player.getMaxAirSupply(); - int j3 = Math.min(player.getAirSupply(), i3); - if (player.isEyeInFluid(FluidTags.WATER) || j3 < i3) { -- int k3 = this.getVisibleVehicleHeartRows(l2) - 1; -- j2 -= k3 * 10; -+ int j2 = p_283143_.guiHeight() - rightHeight; - int l3 = Mth.ceil((double)(j3 - 2) * 10.0 / (double)i3); - int i4 = Mth.ceil((double)j3 * 10.0 / (double)i3) - l3; - RenderSystem.enableBlend(); -@@ -845,6 +_,7 @@ ++ int j2 = p_283143_.guiHeight() - rightHeight; ++ Profiler.get().push("air"); ++ this.renderAirBubbles(p_283143_, player, 10, j2, i1); + Profiler.get().pop(); + } + } +@@ -936,6 +_,8 @@ + p_381066_.blitSprite(RenderType::guiTextured, AIR_EMPTY_SPRITE, k1, p_381100_ + l1, 9, 9); } - - RenderSystem.disableBlend(); -+ rightHeight += 10; } ++ ++ rightHeight += 10; + } + } - this.minecraft.getProfiler().pop(); -@@ -984,7 +_,7 @@ +@@ -1003,7 +_,7 @@ if (i != 0) { int j = (int)Math.ceil((double)livingentity.getHealth()); - this.minecraft.getProfiler().popPush("mountHealth"); + Profiler.get().popPush("mountHealth"); - int k = p_283368_.guiHeight() - 39; + int k = p_283368_.guiHeight() - rightHeight; int l = p_283368_.guiWidth() / 2 + 91; int i1 = k; - int j1 = 0; -@@ -1007,6 +_,7 @@ + +@@ -1024,6 +_,7 @@ } i1 -= 10; + rightHeight += 10; - j1 += 20; } - -@@ -1163,7 +_,7 @@ + } + } +@@ -1190,7 +_,7 @@ this.toolHighlightTimer = 0; } else if (this.lastToolHighlight.isEmpty() || !itemstack.is(this.lastToolHighlight.getItem()) @@ -390,7 +386,7 @@ this.toolHighlightTimer = (int)(40.0 * this.minecraft.options.notificationDisplayTime().get()); } else if (this.toolHighlightTimer > 0) { this.toolHighlightTimer--; -@@ -1292,8 +_,17 @@ +@@ -1319,8 +_,17 @@ } } @@ -409,7 +405,7 @@ CONTAINER( ResourceLocation.withDefaultNamespace("hud/heart/container"), ResourceLocation.withDefaultNamespace("hud/heart/container_blinking"), -@@ -1409,8 +_,13 @@ +@@ -1436,8 +_,13 @@ } else { gui$hearttype = NORMAL; } diff --git a/patches/net/minecraft/client/gui/GuiGraphics.java.patch b/patches/net/minecraft/client/gui/GuiGraphics.java.patch index 9ce42c48..caca78e3 100644 --- a/patches/net/minecraft/client/gui/GuiGraphics.java.patch +++ b/patches/net/minecraft/client/gui/GuiGraphics.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/GuiGraphics.java +++ b/net/minecraft/client/gui/GuiGraphics.java -@@ -56,7 +_,7 @@ +@@ -53,7 +_,7 @@ import org.joml.Vector2ic; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ public static final float MAX_GUI_Z = 10000.0F; public static final float MIN_GUI_Z = -10000.0F; private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2; -@@ -268,6 +_,11 @@ +@@ -227,6 +_,11 @@ } public int drawString(Font p_283343_, @Nullable String p_281896_, int p_283569_, int p_283418_, int p_281560_, boolean p_282130_) { @@ -18,10 +18,10 @@ + + // Forge: Add float variant for x,y coordinates, with a string as input + public int drawString(Font p_283343_, @Nullable String p_281896_, float p_283569_, float p_283418_, int p_281560_, boolean p_282130_) { - if (p_281896_ == null) { - return 0; - } else { -@@ -294,6 +_,11 @@ + return p_281896_ == null + ? 0 + : p_283343_.drawInBatch( +@@ -248,6 +_,11 @@ } public int drawString(Font p_282636_, FormattedCharSequence p_281596_, int p_281586_, int p_282816_, int p_281743_, boolean p_282394_) { @@ -30,13 +30,14 @@ + + // Forge: Add float variant for x,y coordinates, with a formatted char sequence as input + public int drawString(Font p_282636_, FormattedCharSequence p_281596_, float p_281586_, float p_282816_, int p_281743_, boolean p_282394_) { - int i = p_282636_.drawInBatch( + return p_282636_.drawInBatch( p_281596_, (float)p_281586_, -@@ -873,19 +_,26 @@ - } - +@@ -870,10 +_,15 @@ + this.renderItemCount(p_282005_, p_283349_, p_282641_, p_282146_, p_282803_); + this.renderItemCooldown(p_283349_, p_282641_, p_282146_); this.pose.popPose(); ++ // TODO 1.21.2: This probably belongs in one of the sub-methods. + net.neoforged.neoforge.client.ItemDecoratorHandler.of(p_283349_).render(this, p_282005_, p_283349_, p_282641_, p_282146_); } } @@ -45,56 +46,93 @@ public void renderTooltip(Font p_282308_, ItemStack p_282781_, int p_282687_, int p_282292_) { + this.tooltipStack = p_282781_; - this.renderTooltip(p_282308_, Screen.getTooltipFromItem(this.minecraft, p_282781_), p_282781_.getTooltipImage(), p_282687_, p_282292_); + this.renderTooltip( + p_282308_, + Screen.getTooltipFromItem(this.minecraft, p_282781_), +@@ -882,6 +_,17 @@ + p_282292_, + p_282781_.get(DataComponents.TOOLTIP_STYLE) + ); + this.tooltipStack = ItemStack.EMPTY; + } + + public void renderTooltip(Font font, List textComponents, Optional tooltipComponent, ItemStack stack, int mouseX, int mouseY) { ++ renderTooltip(font, textComponents, tooltipComponent, stack, mouseX, mouseY, null); ++ } ++ ++ public void renderTooltip(Font font, List textComponents, Optional tooltipComponent, ItemStack stack, int mouseX, int mouseY, @Nullable ResourceLocation backgroundTexture) { + this.tooltipStack = stack; -+ this.renderTooltip(font, textComponents, tooltipComponent, mouseX, mouseY); ++ this.renderTooltip(font, textComponents, tooltipComponent, mouseX, mouseY, backgroundTexture); + this.tooltipStack = ItemStack.EMPTY; } public void renderTooltip(Font p_283128_, List p_282716_, Optional p_281682_, int p_283678_, int p_281696_) { -- List list = p_282716_.stream() +@@ -891,11 +_,7 @@ + public void renderTooltip( + Font p_371715_, List p_371741_, Optional p_371604_, int p_371500_, int p_371755_, @Nullable ResourceLocation p_371766_ + ) { +- List list = p_371741_.stream() - .map(Component::getVisualOrderText) - .map(ClientTooltipComponent::create) - .collect(Util.toMutableList()); -- p_281682_.ifPresent(p_337410_ -> list.add(list.isEmpty() ? 0 : 1, ClientTooltipComponent.create(p_337410_))); -+ List list = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponents(this.tooltipStack, p_282716_, p_281682_, p_283678_, guiWidth(), guiHeight(), p_283128_); - this.renderTooltipInternal(p_283128_, list, p_283678_, p_281696_, DefaultTooltipPositioner.INSTANCE); +- p_371604_.ifPresent(p_337410_ -> list.add(list.isEmpty() ? 0 : 1, ClientTooltipComponent.create(p_337410_))); ++ List list = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponents(this.tooltipStack, p_371741_, p_371604_, p_371500_, guiWidth(), guiHeight(), p_371715_); + this.renderTooltipInternal(p_371715_, list, p_371500_, p_371755_, DefaultTooltipPositioner.INSTANCE, p_371766_); } -@@ -894,7 +_,22 @@ +@@ -908,13 +_,14 @@ } public void renderComponentTooltip(Font p_282739_, List p_281832_, int p_282191_, int p_282446_) { -- this.renderTooltip(p_282739_, Lists.transform(p_281832_, Component::getVisualOrderText), p_282191_, p_282446_); -+ List components = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponents(this.tooltipStack, p_281832_, p_282191_, guiWidth(), guiHeight(), p_282739_); -+ this.renderTooltipInternal(p_282739_, components, p_282191_, p_282446_, DefaultTooltipPositioner.INSTANCE); +- this.renderComponentTooltip(p_282739_, p_281832_, p_282191_, p_282446_, null); ++ this.renderComponentTooltip(p_282739_, p_281832_, p_282191_, p_282446_, (ResourceLocation) null); + } + + public void renderComponentTooltip(Font p_371677_, List p_371519_, int p_371314_, int p_371389_, @Nullable ResourceLocation p_371458_) { ++ List components = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponents(this.tooltipStack, p_371519_, p_371314_, guiWidth(), guiHeight(), p_371677_); + this.renderTooltipInternal( + p_371677_, +- p_371519_.stream().map(Component::getVisualOrderText).map(ClientTooltipComponent::create).toList(), ++ components, + p_371314_, + p_371389_, + DefaultTooltipPositioner.INSTANCE, +@@ -922,6 +_,28 @@ + ); + } + ++ public void renderComponentTooltip(Font font, List tooltips, int mouseX, int mouseY, ItemStack stack) { ++ renderComponentTooltip(font, tooltips, mouseX, mouseY, stack, null); + } + -+ public void renderComponentTooltip(Font font, List tooltips, int mouseX, int mouseY, ItemStack stack) { ++ public void renderComponentTooltip(Font font, List tooltips, int mouseX, int mouseY, ItemStack stack, @Nullable ResourceLocation backgroundTexture) { + this.tooltipStack = stack; + List components = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponents(stack, tooltips, mouseX, guiWidth(), guiHeight(), font); -+ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE); ++ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, backgroundTexture); + this.tooltipStack = ItemStack.EMPTY; + } + + public void renderComponentTooltipFromElements(Font font, List> elements, int mouseX, int mouseY, ItemStack stack) { ++ renderComponentTooltipFromElements(font, elements, mouseX, mouseY, stack, null); ++ } ++ ++ public void renderComponentTooltipFromElements(Font font, List> elements, int mouseX, int mouseY, ItemStack stack, @Nullable ResourceLocation backgroundTexture) { + this.tooltipStack = stack; + List components = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponentsFromElements(stack, elements, mouseX, guiWidth(), guiHeight(), font); -+ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE); ++ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, backgroundTexture); + this.tooltipStack = ItemStack.EMPTY; - } - ++ } ++ public void renderTooltip(Font p_282192_, List p_282297_, int p_281680_, int p_283325_) { -@@ -915,11 +_,13 @@ - - private void renderTooltipInternal(Font p_282675_, List p_282615_, int p_283230_, int p_283417_, ClientTooltipPositioner p_282442_) { + this.renderTooltip(p_282192_, p_282297_, p_281680_, p_283325_, null); + } +@@ -954,41 +_,45 @@ + @Nullable ResourceLocation p_371327_ + ) { if (!p_282615_.isEmpty()) { + net.neoforged.neoforge.client.event.RenderTooltipEvent.Pre preEvent = net.neoforged.neoforge.client.ClientHooks.onRenderTooltipPre(this.tooltipStack, this, p_283230_, p_283417_, guiWidth(), guiHeight(), p_282615_, p_282675_, p_282442_); + if (preEvent.isCanceled()) return; ++ int i = 0; int j = p_282615_.size() == 1 ? -2 : 0; @@ -104,35 +142,41 @@ if (k > i) { i = k; } -@@ -929,18 +_,19 @@ + +- j += clienttooltipcomponent.getHeight(p_282675_); ++ j += clienttooltipcomponent.getHeight(preEvent.getFont()); + } int i2 = i; int j2 = j; -- Vector2ic vector2ic = p_282442_.positionTooltip(this.guiWidth(), this.guiHeight(), p_283230_, p_283417_, i2, j2); +- Vector2ic vector2ic = p_282442_.positionTooltip(this.guiWidth(), this.guiHeight(), p_283230_, p_283417_, i, j); + Vector2ic vector2ic = p_282442_.positionTooltip(this.guiWidth(), this.guiHeight(), preEvent.getX(), preEvent.getY(), i2, j2); int l = vector2ic.x(); int i1 = vector2ic.y(); this.pose.pushPose(); int j1 = 400; -- this.drawManaged(() -> TooltipRenderUtil.renderTooltipBackground(this, l, i1, i2, j2, 400)); -+ net.neoforged.neoforge.client.event.RenderTooltipEvent.Color colorEvent = net.neoforged.neoforge.client.ClientHooks.onRenderTooltipColor(this.tooltipStack, this, l, i1, preEvent.getFont(), p_282615_); -+ this.drawManaged(() -> TooltipRenderUtil.renderTooltipBackground(this, l, i1, i2, j2, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd(), colorEvent.getBorderStart(), colorEvent.getBorderEnd())); +- TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, 400, p_371327_); ++ var textureEvent = net.neoforged.neoforge.client.ClientHooks.onRenderTooltipTexture(this.tooltipStack, this, l, i1, preEvent.getFont(), p_282615_, p_371327_); ++ TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, 400, textureEvent.getTexture()); this.pose.translate(0.0F, 0.0F, 400.0F); int k1 = i1; for (int l1 = 0; l1 < p_282615_.size(); l1++) { ClientTooltipComponent clienttooltipcomponent1 = p_282615_.get(l1); - clienttooltipcomponent1.renderText(p_282675_, l, k1, this.pose.last().pose(), this.bufferSource); +- k1 += clienttooltipcomponent1.getHeight(p_282675_) + (l1 == 0 ? 2 : 0); + clienttooltipcomponent1.renderText(preEvent.getFont(), l, k1, this.pose.last().pose(), this.bufferSource); - k1 += clienttooltipcomponent1.getHeight() + (l1 == 0 ? 2 : 0); ++ k1 += clienttooltipcomponent1.getHeight(preEvent.getFont()) + (l1 == 0 ? 2 : 0); } -@@ -948,7 +_,7 @@ + k1 = i1; for (int k2 = 0; k2 < p_282615_.size(); k2++) { ClientTooltipComponent clienttooltipcomponent2 = p_282615_.get(k2); -- clienttooltipcomponent2.renderImage(p_282675_, l, k1, this); -+ clienttooltipcomponent2.renderImage(preEvent.getFont(), l, k1, this); - k1 += clienttooltipcomponent2.getHeight() + (k2 == 0 ? 2 : 0); +- clienttooltipcomponent2.renderImage(p_282675_, l, k1, i2, j2, this); +- k1 += clienttooltipcomponent2.getHeight(p_282675_) + (k2 == 0 ? 2 : 0); ++ clienttooltipcomponent2.renderImage(preEvent.getFont(), l, k1, i2, j2, this); ++ k1 += clienttooltipcomponent2.getHeight(preEvent.getFont()) + (k2 == 0 ? 2 : 0); } + this.pose.popPose(); diff --git a/patches/net/minecraft/client/gui/MapRenderer.java.patch b/patches/net/minecraft/client/gui/MapRenderer.java.patch deleted file mode 100644 index 756bcda9..00000000 --- a/patches/net/minecraft/client/gui/MapRenderer.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/client/gui/MapRenderer.java -+++ b/net/minecraft/client/gui/MapRenderer.java -@@ -122,6 +_,10 @@ - - for (MapDecoration mapdecoration : this.data.getDecorations()) { - if (!p_93294_ || mapdecoration.renderOnFrame()) { -+ if (net.neoforged.neoforge.client.gui.map.MapDecorationRendererManager.render(mapdecoration, p_93292_, p_93293_, data, MapRenderer.this.decorationTextures, p_93294_, p_93295_, k)) { -+ k++; -+ continue; -+ } - p_93292_.pushPose(); - p_93292_.translate(0.0F + (float)mapdecoration.x() / 2.0F + 64.0F, 0.0F + (float)mapdecoration.y() / 2.0F + 64.0F, -0.02F); - p_93292_.mulPose(Axis.ZP.rotationDegrees((float)(mapdecoration.rot() * 360) / 16.0F)); diff --git a/patches/net/minecraft/client/gui/components/AbstractButton.java.patch b/patches/net/minecraft/client/gui/components/AbstractButton.java.patch index 5d141a2e..56d0a21b 100644 --- a/patches/net/minecraft/client/gui/components/AbstractButton.java.patch +++ b/patches/net/minecraft/client/gui/components/AbstractButton.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/gui/components/AbstractButton.java +++ b/net/minecraft/client/gui/components/AbstractButton.java -@@ -34,7 +_,7 @@ - RenderSystem.enableDepthTest(); - p_281670_.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); - p_281670_.setColor(1.0F, 1.0F, 1.0F, 1.0F); +@@ -39,7 +_,7 @@ + this.getHeight(), + ARGB.white(this.alpha) + ); - int i = this.active ? 16777215 : 10526880; + int i = getFGColor(); this.renderString(p_281670_, minecraft.font, i | Mth.ceil(this.alpha * 255.0F) << 24); diff --git a/patches/net/minecraft/client/gui/components/AbstractWidget.java.patch b/patches/net/minecraft/client/gui/components/AbstractWidget.java.patch index 0f5ac718..256cef46 100644 --- a/patches/net/minecraft/client/gui/components/AbstractWidget.java.patch +++ b/patches/net/minecraft/client/gui/components/AbstractWidget.java.patch @@ -27,7 +27,7 @@ return true; } } -@@ -253,6 +_,19 @@ +@@ -257,6 +_,19 @@ @Override public void setFocused(boolean p_93693_) { this.focused = p_93693_; diff --git a/patches/net/minecraft/client/gui/components/BossHealthOverlay.java.patch b/patches/net/minecraft/client/gui/components/BossHealthOverlay.java.patch index 4bc398ff..2e911a86 100644 --- a/patches/net/minecraft/client/gui/components/BossHealthOverlay.java.patch +++ b/patches/net/minecraft/client/gui/components/BossHealthOverlay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/BossHealthOverlay.java +++ b/net/minecraft/client/gui/components/BossHealthOverlay.java -@@ -63,13 +_,16 @@ +@@ -66,13 +_,16 @@ for (LerpingBossEvent lerpingbossevent : this.events.values()) { int k = i / 2 - 91; diff --git a/patches/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch b/patches/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch index d47bc314..3b4f7e32 100644 --- a/patches/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch +++ b/patches/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch @@ -1,25 +1,24 @@ --- a/net/minecraft/client/gui/components/DebugScreenOverlay.java +++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java -@@ -135,8 +_,15 @@ +@@ -141,8 +_,14 @@ + Entity entity = this.minecraft.getCameraEntity(); this.block = entity.pick(20.0, 0.0F, false); this.liquid = entity.pick(20.0, 0.0F, true); - p_281427_.drawManaged(() -> { -- this.drawGameInformation(p_281427_); -- this.drawSystemInformation(p_281427_); -+ final List gameInformation = this.collectGameInformationText(); -+ final List systemInformation = this.collectSystemInformationText(); +- this.drawGameInformation(p_281427_); +- this.drawSystemInformation(p_281427_); + -+ var event = new net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent.DebugText(minecraft.getWindow(), p_281427_, minecraft.getTimer(), gameInformation, systemInformation); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event); ++ final List gameInformation = this.collectGameInformationText(); ++ final List systemInformation = this.collectSystemInformationText(); ++ var event = new net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent.DebugText(minecraft.getWindow(), p_281427_, minecraft.getDeltaTracker(), gameInformation, systemInformation); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event); ++ this.renderLines(p_281427_, gameInformation, true); ++ this.renderLines(p_281427_, systemInformation, false); + -+ this.renderLines(p_281427_, gameInformation, true); -+ this.renderLines(p_281427_, systemInformation, false); -+ - if (this.renderFpsCharts) { - int i = p_281427_.guiWidth(); - int j = i / 2; -@@ -161,7 +_,11 @@ - this.minecraft.getProfiler().pop(); + this.profilerPieChart.setBottomOffset(10); + if (this.renderFpsCharts) { + int i = p_281427_.guiWidth(); +@@ -175,7 +_,11 @@ + profilerfiller.pop(); } - protected void drawGameInformation(GuiGraphics p_281525_) { @@ -31,7 +30,7 @@ List list = this.getGameInformation(); list.add(""); boolean flag = this.minecraft.getSingleplayerServer() != null; -@@ -176,11 +_,25 @@ +@@ -190,11 +_,25 @@ + (this.renderNetworkCharts ? " visible" : " hidden") ); list.add("For help: press F3 + Q"); @@ -58,7 +57,7 @@ this.renderLines(p_281261_, list, false); } -@@ -509,6 +_,13 @@ +@@ -523,6 +_,13 @@ GlUtil.getRenderer(), GlUtil.getOpenGLVersion() ); @@ -72,7 +71,7 @@ if (this.minecraft.showOnlyReducedInfo()) { return list; } else { -@@ -545,6 +_,7 @@ +@@ -559,6 +_,7 @@ list.add(""); list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()))); diff --git a/patches/net/minecraft/client/gui/components/toasts/ToastComponent.java.patch b/patches/net/minecraft/client/gui/components/toasts/ToastComponent.java.patch deleted file mode 100644 index 7c7e69a6..00000000 --- a/patches/net/minecraft/client/gui/components/toasts/ToastComponent.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/gui/components/toasts/ToastComponent.java -+++ b/net/minecraft/client/gui/components/toasts/ToastComponent.java -@@ -99,6 +_,7 @@ - } - - public void addToast(Toast p_94923_) { -+ if (net.neoforged.neoforge.client.ClientHooks.onToastAdd(p_94923_)) return; - this.queued.add(p_94923_); - } - diff --git a/patches/net/minecraft/client/gui/components/toasts/ToastManager.java.patch b/patches/net/minecraft/client/gui/components/toasts/ToastManager.java.patch new file mode 100644 index 00000000..f5bd0bff --- /dev/null +++ b/patches/net/minecraft/client/gui/components/toasts/ToastManager.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/gui/components/toasts/ToastManager.java ++++ b/net/minecraft/client/gui/components/toasts/ToastManager.java +@@ -107,6 +_,7 @@ + } + + public void addToast(Toast p_362712_) { ++ if (net.neoforged.neoforge.client.ClientHooks.onToastAdd(p_362712_)) return; + this.queued.add(p_362712_); + } + diff --git a/patches/net/minecraft/client/gui/screens/LoadingOverlay.java.patch b/patches/net/minecraft/client/gui/screens/LoadingOverlay.java.patch index 3729b1ae..b607643c 100644 --- a/patches/net/minecraft/client/gui/screens/LoadingOverlay.java.patch +++ b/patches/net/minecraft/client/gui/screens/LoadingOverlay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/LoadingOverlay.java +++ b/net/minecraft/client/gui/screens/LoadingOverlay.java -@@ -133,6 +_,7 @@ +@@ -123,6 +_,7 @@ } if (this.fadeOutStart == -1L && this.reload.isDone() && (!this.fadeIn || f1 >= 2.0F)) { @@ -8,7 +8,7 @@ try { this.reload.checkExceptions(); this.onFinish.accept(Optional.empty()); -@@ -140,7 +_,6 @@ +@@ -130,7 +_,6 @@ this.onFinish.accept(Optional.of(throwable)); } diff --git a/patches/net/minecraft/client/gui/screens/PauseScreen.java.patch b/patches/net/minecraft/client/gui/screens/PauseScreen.java.patch index 7016a271..b8a1613d 100644 --- a/patches/net/minecraft/client/gui/screens/PauseScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/PauseScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/PauseScreen.java +++ b/net/minecraft/client/gui/screens/PauseScreen.java -@@ -96,6 +_,7 @@ +@@ -97,6 +_,7 @@ } else { gridlayout$rowhelper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this))); } diff --git a/patches/net/minecraft/client/gui/screens/Screen.java.patch b/patches/net/minecraft/client/gui/screens/Screen.java.patch index cc93b39e..e7d7751d 100644 --- a/patches/net/minecraft/client/gui/screens/Screen.java.patch +++ b/patches/net/minecraft/client/gui/screens/Screen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/Screen.java +++ b/net/minecraft/client/gui/screens/Screen.java -@@ -116,6 +_,7 @@ +@@ -115,6 +_,7 @@ } } @@ -8,7 +8,7 @@ @Override public void render(GuiGraphics p_281549_, int p_281550_, int p_282878_, float p_282465_) { this.renderBackground(p_281549_, p_281550_, p_282878_, p_282465_); -@@ -201,7 +_,7 @@ +@@ -200,7 +_,7 @@ } public void onClose() { @@ -17,7 +17,7 @@ } protected T addRenderableWidget(T p_169406_) { -@@ -242,7 +_,7 @@ +@@ -241,7 +_,7 @@ return p_282833_.getTooltipLines( Item.TooltipContext.of(p_281881_.level), p_281881_.player, @@ -26,7 +26,7 @@ ); } -@@ -312,8 +_,11 @@ +@@ -311,8 +_,11 @@ this.width = p_96608_; this.height = p_96609_; if (!this.initialized) { @@ -38,7 +38,7 @@ } else { this.repositionElements(); } -@@ -326,8 +_,11 @@ +@@ -325,8 +_,11 @@ protected void rebuildWidgets() { this.clearWidgets(); this.clearFocus(); @@ -50,15 +50,15 @@ } @Override -@@ -354,6 +_,7 @@ +@@ -353,6 +_,7 @@ - this.renderBlurredBackground(p_294317_); + this.renderBlurredBackground(); this.renderMenuBackground(p_283688_); + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.ScreenEvent.BackgroundRendered(this, p_283688_)); } - protected void renderBlurredBackground(float p_330683_) { -@@ -467,6 +_,10 @@ + protected void renderBlurredBackground() { +@@ -458,6 +_,10 @@ public void onFilesDrop(List p_96591_) { } @@ -69,7 +69,7 @@ private void scheduleNarration(long p_169381_, boolean p_169382_) { this.nextNarrationTime = Util.getMillis() + p_169381_; if (p_169382_) { -@@ -643,5 +_,13 @@ +@@ -642,5 +_,13 @@ this.index = p_169425_; this.priority = p_169426_; } diff --git a/patches/net/minecraft/client/gui/screens/TitleScreen.java.patch b/patches/net/minecraft/client/gui/screens/TitleScreen.java.patch index b4069b56..2038b236 100644 --- a/patches/net/minecraft/client/gui/screens/TitleScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/TitleScreen.java.patch @@ -1,22 +1,34 @@ --- a/net/minecraft/client/gui/screens/TitleScreen.java +++ b/net/minecraft/client/gui/screens/TitleScreen.java -@@ -114,11 +_,14 @@ +@@ -114,11 +_,17 @@ int i = this.font.width(COPYRIGHT_TEXT); int j = this.width - i - 2; int k = 24; - int l = this.height / 4 + 48; + int l = this.height / 4 + 32; if (this.minecraft.isDemo()) { - this.createDemoMenuOptions(l, 24); + l = this.createDemoMenuOptions(l, 24); } else { - this.createNormalMenuOptions(l, 24); + l = this.createNormalMenuOptions(l, 24); ++ int modsOffset = SharedConstants.IS_RUNNING_IN_IDE ? 2 : -100; ++ int modsWidth = SharedConstants.IS_RUNNING_IN_IDE ? 98 : 200; + this.addRenderableWidget(new net.neoforged.neoforge.client.gui.widget.ModsButton(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.neoforged.neoforge.client.gui.ModListScreen(this))) -+ .pos(this.width / 2 - 100, l + 24 * 3).size(200, 20))); -+ l += 22; // Move down Options, Quit, Language, and Accessibility buttons to make room for mods button ++ .pos(this.width / 2 + modsOffset, l + 24).size(modsWidth, 20))); ++ if (!SharedConstants.IS_RUNNING_IN_IDE) ++ l += 24; // Move down Options, Quit, Language, and Accessibility buttons to make room for mods button (in-dev the test world button "handles" this) } - SpriteIconButton spriteiconbutton = this.addRenderableWidget( -@@ -285,6 +_,7 @@ + l = this.createTestWorldButton(l, 24); +@@ -160,7 +_,7 @@ + if (SharedConstants.IS_RUNNING_IN_IDE) { + this.addRenderableWidget( + Button.builder(Component.literal("Create Test World"), p_372504_ -> CreateWorldScreen.testWorld(this.minecraft, this)) +- .bounds(this.width / 2 - 100, p_373114_ += p_372852_, 200, 20) ++ .bounds(this.width / 2 - 100, p_373114_ += p_372852_, 98, 20) // Neo: reduce button width to fit the mods button next to it + .build() + ); + } +@@ -304,6 +_,7 @@ if ((i & -67108864) != 0) { super.render(p_282860_, p_281753_, p_283539_, p_282628_); this.logoRenderer.renderLogo(p_282860_, this.width, f); @@ -24,7 +36,7 @@ if (this.splash != null && !this.minecraft.options.hideSplashTexts().get()) { this.splash.render(p_282860_, this.width, this.font, i); } -@@ -300,7 +_,13 @@ +@@ -319,7 +_,13 @@ s = s + I18n.get("menu.modded"); } @@ -37,5 +49,5 @@ + p_282860_.drawString(this.font, brd, this.width - font.width(brd), this.height - (10 + (brdline + 1) * (this.font.lineHeight + 1)), 16777215 | i) + ); if (this.realmsNotificationsEnabled() && f >= 1.0F) { - RenderSystem.enableDepthTest(); this.realmsNotificationsScreen.render(p_282860_, p_281753_, p_283539_, p_282628_); + } diff --git a/patches/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch b/patches/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch index 01da559b..f74b6000 100644 --- a/patches/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch +++ b/patches/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java -@@ -37,6 +_,7 @@ +@@ -38,6 +_,7 @@ private int maxY = Integer.MIN_VALUE; private float fade; private boolean centered; @@ -8,7 +8,7 @@ public AdvancementTab( Minecraft p_97145_, AdvancementsScreen p_97146_, AdvancementTabType p_97147_, int p_97148_, AdvancementNode p_300867_, DisplayInfo p_97150_ -@@ -53,6 +_,15 @@ +@@ -54,6 +_,15 @@ this.addWidget(this.root, p_300867_.holder()); } @@ -24,7 +24,7 @@ public AdvancementTabType getType() { return this.type; } -@@ -146,8 +_,8 @@ +@@ -147,8 +_,8 @@ return null; } else { for (AdvancementTabType advancementtabtype : AdvancementTabType.values()) { diff --git a/patches/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch b/patches/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch index 62e72245..fbce35ac 100644 --- a/patches/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch +++ b/patches/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java -@@ -71,6 +_,7 @@ +@@ -72,6 +_,7 @@ private final AdvancementTabType.Sprites selectedSprites; private final AdvancementTabType.Sprites unselectedSprites; diff --git a/patches/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch b/patches/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch index 3e9f5ae7..30052bef 100644 --- a/patches/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java -@@ -49,6 +_,7 @@ +@@ -51,6 +_,7 @@ @Nullable private AdvancementTab selectedTab; private boolean isScrolling; @@ -8,7 +8,7 @@ public AdvancementsScreen(ClientAdvancements p_97340_) { this(p_97340_, null); -@@ -73,6 +_,16 @@ +@@ -75,6 +_,16 @@ this.advancements.setSelectedTab(this.selectedTab == null ? null : this.selectedTab.getRootNode().holder(), true); } @@ -25,7 +25,7 @@ this.layout.addToFooter(Button.builder(CommonComponents.GUI_DONE, p_331557_ -> this.onClose()).width(200).build()); this.layout.visitWidgets(p_332019_ -> { AbstractWidget abstractwidget = this.addRenderableWidget(p_332019_); -@@ -106,7 +_,7 @@ +@@ -108,7 +_,7 @@ int j = (this.height - 140) / 2; for (AdvancementTab advancementtab : this.tabs.values()) { @@ -34,7 +34,7 @@ this.advancements.setSelectedTab(advancementtab.getRootNode().holder(), true); break; } -@@ -132,6 +_,11 @@ +@@ -134,6 +_,11 @@ super.render(p_282589_, p_282255_, p_283354_, p_283123_); int i = (this.width - 252) / 2; int j = (this.height - 140) / 2; @@ -46,8 +46,8 @@ this.renderInside(p_282589_, p_282255_, p_283354_, i, j); this.renderWindow(p_282589_, i, j); this.renderTooltips(p_282589_, p_282255_, p_283354_, i, j); -@@ -180,10 +_,12 @@ - p_283395_.blit(WINDOW_LOCATION, p_281890_, p_282532_, 0, 0, 252, 140); +@@ -181,10 +_,12 @@ + p_283395_.blit(RenderType::guiTextured, WINDOW_LOCATION, p_281890_, p_282532_, 0.0F, 0.0F, 252, 140, 256, 256); if (this.tabs.size() > 1) { for (AdvancementTab advancementtab : this.tabs.values()) { + if (advancementtab.getPage() == tabPage) @@ -59,7 +59,7 @@ advancementtab1.drawIcon(p_283395_, p_281890_, p_282532_); } } -@@ -203,7 +_,7 @@ +@@ -202,7 +_,7 @@ if (this.tabs.size() > 1) { for (AdvancementTab advancementtab : this.tabs.values()) { diff --git a/patches/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch index d00c918a..be4ec4ba 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java +++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java -@@ -91,7 +_,12 @@ +@@ -107,7 +_,12 @@ public void render(GuiGraphics p_283479_, int p_283661_, int p_281248_, float p_281886_) { int i = this.leftPos; int j = this.topPos; @@ -11,56 +11,26 @@ + for (net.minecraft.client.gui.components.Renderable renderable : this.renderables) { + renderable.render(p_283479_, p_283661_, p_281248_, p_281886_); + } - RenderSystem.disableDepthTest(); p_283479_.pose().pushPose(); p_283479_.pose().translate((float)i, (float)j, 0.0F); -@@ -105,15 +_,12 @@ - - if (this.isHovering(slot, (double)p_283661_, (double)p_281248_) && slot.isActive()) { - this.hoveredSlot = slot; -- int l = slot.x; -- int i1 = slot.y; -- if (this.hoveredSlot.isHighlightable()) { -- renderSlotHighlight(p_283479_, l, i1, 0); -- } -+ this.renderSlotHighlight(p_283479_, slot, p_283661_, p_281248_, p_281886_); - } + Slot slot = this.hoveredSlot; +@@ -120,6 +_,7 @@ } this.renderLabels(p_283479_, p_283661_, p_281248_); + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.ContainerScreenEvent.Render.Foreground(this, p_283479_, p_283661_, p_281248_)); ItemStack itemstack = this.draggingItem.isEmpty() ? this.menu.getCarried() : this.draggingItem; if (!itemstack.isEmpty()) { - int l1 = 8; -@@ -156,13 +_,25 @@ - } - - public static void renderSlotHighlight(GuiGraphics p_283692_, int p_281453_, int p_281915_, int p_283504_) { -- p_283692_.fillGradient(RenderType.guiOverlay(), p_281453_, p_281915_, p_281453_ + 16, p_281915_ + 16, -2130706433, -2130706433, p_283504_); -+ renderSlotHighlight(p_283692_, p_281453_, p_281915_, p_283504_, -2130706433); -+ } -+ public static void renderSlotHighlight(GuiGraphics p_283692_, int p_281453_, int p_281915_, int p_283504_, int color) { -+ p_283692_.fillGradient(RenderType.guiOverlay(), p_281453_, p_281915_, p_281453_ + 16, p_281915_ + 16, color, color, p_283504_); -+ } -+ -+ /** -+ * Renders a highlight for the given slot to indicate the mouse is currently hovering over it. -+ */ -+ protected void renderSlotHighlight(GuiGraphics guiGraphics, Slot slot, int mouseX, int mouseY, float partialTick) { -+ if (slot.isHighlightable()) { -+ renderSlotHighlight(guiGraphics, slot.x, slot.y, 0, getSlotColor(slot.index)); -+ } - } - - protected void renderTooltip(GuiGraphics p_283594_, int p_282171_, int p_281909_) { - if (this.menu.getCarried().isEmpty() && this.hoveredSlot != null && this.hoveredSlot.hasItem()) { - ItemStack itemstack = this.hoveredSlot.getItem(); -- p_283594_.renderTooltip(this.font, this.getTooltipFromContainerItem(itemstack), itemstack.getTooltipImage(), p_282171_, p_281909_); -+ p_283594_.renderTooltip(this.font, this.getTooltipFromContainerItem(itemstack), itemstack.getTooltipImage(), itemstack, p_282171_, p_281909_); - } - } - -@@ -174,7 +_,8 @@ + int k = 8; +@@ -202,6 +_,7 @@ + this.font, + this.getTooltipFromContainerItem(itemstack), + itemstack.getTooltipImage(), ++ itemstack, + p_282171_, + p_281909_, + itemstack.get(DataComponents.TOOLTIP_STYLE) +@@ -222,7 +_,8 @@ p_282567_.pose().pushPose(); p_282567_.pose().translate(0.0F, 0.0F, 232.0F); p_282567_.renderItem(p_281330_, p_281772_, p_281689_); @@ -70,7 +40,7 @@ p_282567_.pose().popPose(); } -@@ -233,6 +_,14 @@ +@@ -281,6 +_,14 @@ p_281607_.fill(i, j, i + 16, j + 16, -2130706433); } @@ -85,7 +55,7 @@ int j1 = p_282613_.x + p_282613_.y * this.imageWidth; if (p_282613_.isFake()) { p_281607_.renderFakeItem(itemstack, i, j, j1); -@@ -241,9 +_,6 @@ +@@ -289,9 +_,6 @@ } p_281607_.renderItemDecorations(this.font, itemstack, i, j, s); @@ -95,17 +65,17 @@ } private void recalculateQuickCraftRemaining() { -@@ -282,7 +_,8 @@ +@@ -329,7 +_,8 @@ if (super.mouseClicked(p_97748_, p_97749_, p_97750_)) { return true; } else { - boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_97750_) && this.minecraft.gameMode.hasInfiniteItems(); + InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97750_); + boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey); - Slot slot = this.findSlot(p_97748_, p_97749_); + Slot slot = this.getHoveredSlot(p_97748_, p_97749_); long i = Util.getMillis(); this.doubleclick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == p_97750_; -@@ -293,6 +_,7 @@ +@@ -340,6 +_,7 @@ int j = this.leftPos; int k = this.topPos; boolean flag1 = this.hasClickedOutside(p_97748_, p_97749_, j, k, p_97750_); @@ -113,7 +83,7 @@ int l = -1; if (slot != null) { l = slot.index; -@@ -318,7 +_,7 @@ +@@ -365,7 +_,7 @@ } } else if (!this.isQuickCrafting) { if (this.menu.getCarried().isEmpty()) { @@ -122,7 +92,7 @@ this.slotClicked(slot, l, p_97750_, ClickType.CLONE); } else { boolean flag2 = l != -999 -@@ -346,7 +_,7 @@ +@@ -393,7 +_,7 @@ this.quickCraftingType = 0; } else if (p_97750_ == 1) { this.quickCraftingType = 1; @@ -131,12 +101,12 @@ this.quickCraftingType = 2; } } -@@ -425,10 +_,13 @@ +@@ -472,10 +_,13 @@ @Override public boolean mouseReleased(double p_97812_, double p_97813_, int p_97814_) { + super.mouseReleased(p_97812_, p_97813_, p_97814_); //Forge, Call parent to release buttons - Slot slot = this.findSlot(p_97812_, p_97813_); + Slot slot = this.getHoveredSlot(p_97812_, p_97813_); int i = this.leftPos; int j = this.topPos; boolean flag = this.hasClickedOutside(p_97812_, p_97813_, i, j, p_97814_); @@ -145,7 +115,7 @@ int k = -1; if (slot != null) { k = slot.index; -@@ -445,7 +_,7 @@ +@@ -492,7 +_,7 @@ if (slot2 != null && slot2.mayPickup(this.minecraft.player) && slot2.hasItem() @@ -154,7 +124,7 @@ && AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) { this.slotClicked(slot2, slot2.index, p_97814_, ClickType.QUICK_MOVE); } -@@ -509,7 +_,7 @@ +@@ -556,7 +_,7 @@ this.slotClicked(null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT); } else if (!this.menu.getCarried().isEmpty()) { @@ -163,7 +133,7 @@ this.slotClicked(slot, k, p_97814_, ClickType.CLONE); } else { boolean flag1 = k != -999 -@@ -568,34 +_,39 @@ +@@ -636,34 +_,39 @@ @Override public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) { @@ -210,7 +180,7 @@ this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, i, ClickType.SWAP); return true; } -@@ -633,6 +_,18 @@ +@@ -701,6 +_,18 @@ @Override public T getMenu() { return this.menu; diff --git a/patches/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch index 67ef56ca..37ccae88 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java -@@ -112,6 +_,8 @@ - private boolean hasClickedOutside; +@@ -115,6 +_,8 @@ private final Set> visibleTags = new HashSet<>(); private final boolean displayOperatorCreativeTab; + private final EffectsInInventory effects; + private final List pages = new java.util.ArrayList<>(); + private net.neoforged.neoforge.client.gui.CreativeTabsScreenPage currentPage = new net.neoforged.neoforge.client.gui.CreativeTabsScreenPage(new java.util.ArrayList<>()); public CreativeModeInventoryScreen(LocalPlayer p_346290_, FeatureFlagSet p_260074_, boolean p_259569_) { super(new CreativeModeInventoryScreen.ItemPickerMenu(p_346290_), p_346290_.getInventory(), CommonComponents.EMPTY); -@@ -147,9 +_,11 @@ +@@ -151,9 +_,11 @@ return false; } else { if (p_345591_ != null) { @@ -24,7 +24,7 @@ } return true; -@@ -159,7 +_,7 @@ +@@ -163,7 +_,7 @@ private void refreshCurrentTabContents(Collection p_261591_) { int i = this.menu.getRowIndexForScroll(this.scrollOffs); this.menu.items.clear(); @@ -33,7 +33,7 @@ this.refreshSearchResults(); } else { this.menu.items.addAll(p_261591_); -@@ -326,6 +_,34 @@ +@@ -337,6 +_,34 @@ protected void init() { if (this.minecraft.gameMode.hasInfiniteItems()) { super.init(); @@ -68,7 +68,7 @@ this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, Component.translatable("itemGroup.search")); this.searchBox.setMaxLength(50); this.searchBox.setBordered(false); -@@ -372,7 +_,7 @@ +@@ -383,7 +_,7 @@ public boolean charTyped(char p_98521_, int p_98522_) { if (this.ignoreTextInput) { return false; @@ -77,7 +77,7 @@ return false; } else { String s = this.searchBox.getValue(); -@@ -391,7 +_,7 @@ +@@ -402,7 +_,7 @@ @Override public boolean keyPressed(int p_98547_, int p_98548_, int p_98549_) { this.ignoreTextInput = false; @@ -86,7 +86,7 @@ if (this.minecraft.options.keyChat.matches(p_98547_, p_98548_)) { this.ignoreTextInput = true; this.selectTab(CreativeModeTabs.searchTab()); -@@ -427,6 +_,7 @@ +@@ -438,6 +_,7 @@ } private void refreshSearchResults() { @@ -94,7 +94,7 @@ this.menu.items.clear(); this.visibleTags.clear(); String s = this.searchBox.getValue(); -@@ -439,10 +_,10 @@ +@@ -450,10 +_,10 @@ SearchTree searchtree; if (s.startsWith("#")) { s = s.substring(1); @@ -107,7 +107,7 @@ } this.menu.items.addAll(searchtree.search(s.toLowerCase(Locale.ROOT))); -@@ -470,7 +_,8 @@ +@@ -481,7 +_,8 @@ @Override protected void renderLabels(GuiGraphics p_283168_, int p_281774_, int p_281466_) { if (selectedTab.showTitle()) { @@ -117,7 +117,7 @@ } } -@@ -480,7 +_,7 @@ +@@ -491,7 +_,7 @@ double d0 = p_98531_ - (double)this.leftPos; double d1 = p_98532_ - (double)this.topPos; @@ -126,7 +126,7 @@ if (this.checkTabClicked(creativemodetab, d0, d1)) { return true; } -@@ -502,7 +_,7 @@ +@@ -513,7 +_,7 @@ double d1 = p_98623_ - (double)this.topPos; this.scrolling = false; @@ -135,7 +135,7 @@ if (this.checkTabClicked(creativemodetab, d0, d1)) { this.selectTab(creativemodetab); return true; -@@ -520,6 +_,7 @@ +@@ -531,6 +_,7 @@ private void selectTab(CreativeModeTab p_98561_) { CreativeModeTab creativemodetab = selectedTab; selectedTab = p_98561_; @@ -143,7 +143,7 @@ this.quickCraftSlots.clear(); this.menu.items.clear(); this.clearDraggingState(); -@@ -596,13 +_,15 @@ +@@ -607,13 +_,15 @@ this.originalSlots = null; } @@ -160,16 +160,19 @@ this.refreshSearchResults(); } else { -@@ -665,7 +_,7 @@ - public void render(GuiGraphics p_283000_, int p_281317_, int p_282770_, float p_281295_) { +@@ -679,18 +_,27 @@ super.render(p_283000_, p_281317_, p_282770_, p_281295_); + this.effects.render(p_283000_, p_281317_, p_282770_, p_281295_); - for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { -+ for(CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { - if (this.checkTabHovering(p_283000_, creativemodetab, p_281317_, p_282770_)) { - break; - } -@@ -677,6 +_,15 @@ +- if (this.checkTabHovering(p_283000_, creativemodetab, p_281317_, p_282770_)) { +- break; +- } +- } +- + if (this.destroyItemSlot != null + && selectedTab.getType() == CreativeModeTab.Type.INVENTORY + && this.isHovering(this.destroyItemSlot.x, this.destroyItemSlot.y, 16, 16, (double)p_281317_, (double)p_282770_)) { p_283000_.renderTooltip(this.font, TRASH_SLOT_TOOLTIP, p_281317_, p_282770_); } @@ -181,11 +184,17 @@ + p_283000_.pose().popPose(); + } + ++ for (CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { ++ if (this.checkTabHovering(p_283000_, creativemodetab, p_281317_, p_282770_)) { ++ break; ++ } ++ } ++ + com.mojang.blaze3d.systems.RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); this.renderTooltip(p_283000_, p_281317_, p_282770_); } -@@ -684,10 +_,10 @@ +@@ -703,10 +_,10 @@ public List getTooltipFromContainerItem(ItemStack p_281769_) { boolean flag = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot; boolean flag1 = selectedTab.getType() == CreativeModeTab.Type.CATEGORY; @@ -198,7 +207,7 @@ if (flag1 && flag) { return list; } else { -@@ -703,7 +_,7 @@ +@@ -722,7 +_,7 @@ int i = 1; for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { @@ -207,7 +216,7 @@ list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE)); } } -@@ -714,7 +_,7 @@ +@@ -733,7 +_,7 @@ @Override protected void renderBg(GuiGraphics p_282663_, float p_282504_, int p_282089_, int p_282249_) { @@ -216,20 +225,20 @@ if (creativemodetab != selectedTab) { this.renderTabButton(p_282663_, creativemodetab); } -@@ -726,10 +_,11 @@ +@@ -747,10 +_,11 @@ int k = this.topPos + 18; int i = k + 112; if (selectedTab.canScroll()) { - ResourceLocation resourcelocation = this.canScroll() ? SCROLLER_SPRITE : SCROLLER_DISABLED_SPRITE; + ResourceLocation resourcelocation = selectedTab.getScrollerSprite(); // this.canScroll() ? SCROLLER_SPRITE : SCROLLER_DISABLED_SPRITE; - p_282663_.blitSprite(resourcelocation, j, k + (int)((float)(i - k - 17) * this.scrollOffs), 12, 15); + p_282663_.blitSprite(RenderType::guiTextured, resourcelocation, j, k + (int)((float)(i - k - 17) * this.scrollOffs), 12, 15); } + if (currentPage.getVisibleTabs().contains(selectedTab)) //Forge: only display tab selection when the selected tab is on the current page this.renderTabButton(p_282663_, selectedTab); if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) { InventoryScreen.renderEntityInInventoryFollowsMouse( -@@ -748,7 +_,7 @@ +@@ -769,7 +_,7 @@ } private int getTabX(CreativeModeTab p_260136_) { @@ -238,7 +247,7 @@ int j = 27; int k = 27 * i; if (p_260136_.isAlignedRight()) { -@@ -760,7 +_,7 @@ +@@ -781,7 +_,7 @@ private int getTabY(CreativeModeTab p_260181_) { int i = 0; @@ -247,7 +256,7 @@ i -= 32; } else { i += this.imageHeight; -@@ -788,8 +_,8 @@ +@@ -809,8 +_,8 @@ protected void renderTabButton(GuiGraphics p_283590_, CreativeModeTab p_283489_) { boolean flag = p_283489_ == selectedTab; @@ -258,15 +267,15 @@ int j = this.leftPos + this.getTabX(p_283489_); int k = this.topPos - (flag1 ? 28 : -(this.imageHeight - 4)); ResourceLocation[] aresourcelocation; -@@ -799,6 +_,7 @@ +@@ -820,6 +_,7 @@ aresourcelocation = flag ? SELECTED_BOTTOM_TABS : UNSELECTED_BOTTOM_TABS; } + //PATCH 1.20.2: Deal with custom tab backgrounds, and deal with transparency. - p_283590_.blitSprite(aresourcelocation[Mth.clamp(i, 0, aresourcelocation.length)], j, k, 26, 32); + p_283590_.blitSprite(RenderType::guiTextured, aresourcelocation[Mth.clamp(i, 0, aresourcelocation.length)], j, k, 26, 32); p_283590_.pose().pushPose(); p_283590_.pose().translate(0.0F, 0.0F, 100.0F); -@@ -840,6 +_,14 @@ +@@ -861,6 +_,14 @@ } } @@ -281,7 +290,7 @@ @OnlyIn(Dist.CLIENT) static class CustomCreativeSlot extends Slot { public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) { -@@ -1024,6 +_,22 @@ +@@ -1042,6 +_,22 @@ @Override public boolean mayPickup(Player p_98665_) { return this.target.mayPickup(p_98665_); diff --git a/patches/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch similarity index 64% rename from patches/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch rename to patches/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch index e194f8c3..c3288a43 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch @@ -1,10 +1,10 @@ ---- a/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java -+++ b/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java -@@ -47,12 +_,17 @@ +--- a/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java ++++ b/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java +@@ -48,12 +_,16 @@ Collection collection = this.minecraft.player.getActiveEffects(); if (!collection.isEmpty() && j >= 32) { boolean flag = j >= 120; -+ var event = net.neoforged.neoforge.client.ClientHooks.onScreenPotionSize(this, j, !flag, i); ++ var event = net.neoforged.neoforge.client.ClientHooks.onScreenPotionSize(screen, j, !flag, i); + if (event.isCanceled()) return; + flag = !event.isCompact(); + i = event.getHorizontalOffset(); @@ -14,41 +14,40 @@ } - Iterable iterable = Ordering.natural().sortedCopy(collection); -+ + Iterable iterable = collection.stream().filter(net.neoforged.neoforge.client.ClientHooks::shouldRenderEffect).sorted().collect(java.util.stream.Collectors.toList()); - this.renderBackgrounds(p_281945_, i, k, iterable, flag); - this.renderIcons(p_281945_, i, k, iterable, flag); + this.renderBackgrounds(p_376884_, i, k, iterable, flag); + this.renderIcons(p_376884_, i, k, iterable, flag); if (flag) { -@@ -74,6 +_,8 @@ +@@ -75,6 +_,8 @@ this.getEffectName(mobeffectinstance), MobEffectUtil.formatDuration(mobeffectinstance, 1.0F, this.minecraft.level.tickRateManager().tickrate()) ); + // Neo: Allow mods to adjust the tooltip shown when hovering a mob effect. -+ list = net.neoforged.neoforge.client.ClientHooks.getEffectTooltip(this, mobeffectinstance, list); - p_281945_.renderTooltip(this.font, list, Optional.empty(), p_282601_, p_282335_); ++ list = net.neoforged.neoforge.client.ClientHooks.getEffectTooltip(screen, mobeffectinstance, list); + p_376884_.renderTooltip(this.screen.getFont(), list, Optional.empty(), p_376869_, p_376740_); } } -@@ -99,6 +_,11 @@ - int i = this.topPos; +@@ -100,6 +_,11 @@ + int i = this.screen.topPos; - for (MobEffectInstance mobeffectinstance : p_282642_) { + for (MobEffectInstance mobeffectinstance : p_376215_) { + var renderer = net.neoforged.neoforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance); -+ if (renderer.renderInventoryIcon(mobeffectinstance, this, p_282745_, p_282521_ + (p_281536_ ? 6 : 7), i, 0)) { -+ i += p_282291_; ++ if (renderer.renderInventoryIcon(mobeffectinstance, screen, p_376734_, p_376350_ + (p_376312_ ? 6 : 7), i, 0)) { ++ i += p_376678_; + continue; + } Holder holder = mobeffectinstance.getEffect(); TextureAtlasSprite textureatlassprite = mobeffecttexturemanager.get(holder); - p_282745_.blit(p_282521_ + (p_281536_ ? 6 : 7), i + 7, 0, 18, 18, textureatlassprite); -@@ -110,6 +_,11 @@ - int i = this.topPos; + p_376734_.blitSprite(RenderType::guiTextured, textureatlassprite, p_376350_ + (p_376312_ ? 6 : 7), i + 7, 18, 18); +@@ -111,6 +_,11 @@ + int i = this.screen.topPos; - for (MobEffectInstance mobeffectinstance : p_281986_) { + for (MobEffectInstance mobeffectinstance : p_376910_) { + var renderer = net.neoforged.neoforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance); -+ if (renderer.renderInventoryText(mobeffectinstance, this, p_281462_, p_283484_, i, 0)) { -+ i += p_282057_; ++ if (renderer.renderInventoryText(mobeffectinstance, screen, p_376227_, p_376372_, i, 0)) { ++ i += p_376395_; + continue; + } Component component = this.getEffectName(mobeffectinstance); - p_281462_.drawString(this.font, component, p_283484_ + 10 + 18, i + 6, 16777215); + p_376227_.drawString(this.screen.getFont(), component, p_376372_ + 10 + 18, i + 6, 16777215); Component component1 = MobEffectUtil.formatDuration(mobeffectinstance, 1.0F, this.minecraft.level.tickRateManager().tickrate()); diff --git a/patches/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch index 9e0e4bfe..66f9e706 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java +++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java -@@ -115,7 +_,7 @@ +@@ -113,7 +_,7 @@ int l1 = 86 - this.font.width(s); FormattedText formattedtext = EnchantmentNames.getInstance().getRandomName(this.font, l1); int i2 = 6839882; - if ((k < l + 1 || this.minecraft.player.experienceLevel < k1) && !this.minecraft.player.getAbilities().instabuild) { + if (((k < l + 1 || this.minecraft.player.experienceLevel < k1) && !this.minecraft.player.getAbilities().instabuild) || this.menu.enchantClue[l] == -1) { // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels - RenderSystem.enableBlend(); - p_282430_.blitSprite(ENCHANTMENT_SLOT_DISABLED_SPRITE, i1, j + 14 + 19 * l, 108, 19); - p_282430_.blitSprite(DISABLED_LEVEL_SPRITES[l], i1 + 1, j + 15 + 19 * l, 16, 16); -@@ -181,13 +_,16 @@ + p_282430_.blitSprite(RenderType::guiTextured, ENCHANTMENT_SLOT_DISABLED_SPRITE, i1, j + 14 + 19 * l, 108, 19); + p_282430_.blitSprite(RenderType::guiTextured, DISABLED_LEVEL_SPRITES[l], i1 + 1, j + 15 + 19 * l, 16, 16); + p_282430_.drawWordWrap(this.font, formattedtext, j1, j + 16 + 19 * l, l1, (i2 & 16711422) >> 1); +@@ -179,13 +_,16 @@ .registryAccess() - .registryOrThrow(Registries.ENCHANTMENT) - .getHolder(this.menu.enchantClue[j]); + .lookupOrThrow(Registries.ENCHANTMENT) + .get(this.menu.enchantClue[j]); - if (!optional.isEmpty()) { + if (true) { int l = this.menu.levelClue[j]; diff --git a/patches/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch index 74155da1..0b4bbf6b 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java +++ b/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java -@@ -15,7 +_,7 @@ +@@ -16,7 +_,7 @@ private static final Vector3f TEXT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F); private static final int TEXTURE_WIDTH = 16; private static final int TEXTURE_HEIGHT = 16; diff --git a/patches/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch index bca6c088..75ffaa27 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/MerchantScreen.java +++ b/net/minecraft/client/gui/screens/inventory/MerchantScreen.java -@@ -236,7 +_,12 @@ +@@ -233,7 +_,12 @@ p_281357_.renderItemDecorations(this.font, p_283466_, p_282403_, p_283601_); } else { p_281357_.renderItemDecorations(this.font, p_282046_, p_282403_, p_283601_, p_282046_.getCount() == 1 ? "1" : null); @@ -9,8 +9,8 @@ + p_281357_.pose().pushPose(); + p_281357_.pose().translate(0.0F, 0.0F, 200.0F); + String count = p_283466_.getCount() == 1 ? "1" : String.valueOf(p_283466_.getCount()); -+ font.drawInBatch(count, (float) (p_282403_ + 14) + 19 - 2 - font.width(count), (float)p_283601_ + 6 + 3, 0xFFFFFF, true, p_281357_.pose().last().pose(), p_281357_.bufferSource(), net.minecraft.client.gui.Font.DisplayMode.NORMAL, 0, 15728880, false); ++ p_281357_.drawString(font, count, (float) (p_282403_ + 14) + 19 - 2 - font.width(count), (float)p_283601_ + 6 + 3, 0xFFFFFF, true); + p_281357_.pose().popPose(); p_281357_.pose().pushPose(); p_281357_.pose().translate(0.0F, 0.0F, 300.0F); - p_281357_.blitSprite(DISCOUNT_STRIKETHRUOGH_SPRITE, p_282403_ + 7, p_283601_ + 12, 0, 9, 2); + p_281357_.blitSprite(RenderType::guiTextured, DISCOUNT_STRIKETHRUOGH_SPRITE, p_282403_ + 7, p_283601_ + 12, 9, 2); diff --git a/patches/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch b/patches/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch index 65910b0a..fd3626d8 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch @@ -1,11 +1,15 @@ --- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java +++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java -@@ -22,6 +_,8 @@ - } else if (p_169951_ instanceof ClientActivePlayersTooltip.ActivePlayersTooltip clientactiveplayerstooltip$activeplayerstooltip) { - return new ClientActivePlayersTooltip(clientactiveplayerstooltip$activeplayerstooltip); - } else { -+ ClientTooltipComponent result = net.neoforged.neoforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(p_169951_); -+ if (result != null) return result; - throw new IllegalArgumentException("Unknown TooltipComponent"); - } +@@ -25,7 +_,11 @@ + case ClientActivePlayersTooltip.ActivePlayersTooltip clientactiveplayerstooltip$activeplayerstooltip -> new ClientActivePlayersTooltip( + clientactiveplayerstooltip$activeplayerstooltip + ); +- default -> throw new IllegalArgumentException("Unknown TooltipComponent"); ++ default -> { ++ ClientTooltipComponent result = net.neoforged.neoforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(p_169951_); ++ if (result != null) yield result; ++ throw new IllegalArgumentException("Unknown TooltipComponent"); ++ } + }); } + diff --git a/patches/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java.patch b/patches/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java.patch deleted file mode 100644 index 2a218d1f..00000000 --- a/patches/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- a/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java -+++ b/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java -@@ -17,16 +_,22 @@ - private static final int BORDER_COLOR_BOTTOM = 1344798847; - - public static void renderTooltipBackground(GuiGraphics p_282666_, int p_281901_, int p_281846_, int p_281559_, int p_283336_, int p_283422_) { -+ renderTooltipBackground(p_282666_, p_281901_, p_281846_, p_281559_, p_283336_, p_283422_, BACKGROUND_COLOR, BACKGROUND_COLOR, BORDER_COLOR_TOP, BORDER_COLOR_BOTTOM); -+ } -+ -+ // Forge: Allow specifying colors for the inner border gradient and a gradient instead of a single color for the background and outer border -+ public static void renderTooltipBackground(GuiGraphics p_282666_, int p_281901_, int p_281846_, int p_281559_, int p_283336_, int p_283422_, int backgroundTop, int backgroundBottom, int borderTop, int borderBottom) -+ { - int i = p_281901_ - 3; - int j = p_281846_ - 3; - int k = p_281559_ + 3 + 3; - int l = p_283336_ + 3 + 3; -- renderHorizontalLine(p_282666_, i, j - 1, k, p_283422_, -267386864); -- renderHorizontalLine(p_282666_, i, j + l, k, p_283422_, -267386864); -- renderRectangle(p_282666_, i, j, k, l, p_283422_, -267386864); -- renderVerticalLine(p_282666_, i - 1, j, l, p_283422_, -267386864); -- renderVerticalLine(p_282666_, i + k, j, l, p_283422_, -267386864); -- renderFrameGradient(p_282666_, i, j + 1, k, l, p_283422_, 1347420415, 1344798847); -+ renderHorizontalLine(p_282666_, i, j - 1, k, p_283422_, backgroundTop); -+ renderHorizontalLine(p_282666_, i, j + l, k, p_283422_, backgroundBottom); -+ renderRectangle(p_282666_, i, j, k, l, p_283422_, backgroundTop, backgroundBottom); -+ renderVerticalLineGradient(p_282666_, i - 1, j, l, p_283422_, backgroundTop, backgroundBottom); -+ renderVerticalLineGradient(p_282666_, i + k, j, l, p_283422_, backgroundTop, backgroundBottom); -+ renderFrameGradient(p_282666_, i, j + 1, k, l, p_283422_, borderTop, borderBottom); - } - - private static void renderFrameGradient( -@@ -52,7 +_,16 @@ - p_282981_.fill(p_282028_, p_282141_, p_282028_ + p_281771_, p_282141_ + 1, p_282734_, p_281979_); - } - -+ /** -+ * @deprecated Forge: Use gradient overload instead -+ */ -+ @Deprecated - private static void renderRectangle(GuiGraphics p_281392_, int p_282294_, int p_283353_, int p_282640_, int p_281964_, int p_283211_, int p_282349_) { -- p_281392_.fill(p_282294_, p_283353_, p_282294_ + p_282640_, p_283353_ + p_281964_, p_283211_, p_282349_); -+ renderRectangle(p_281392_, p_282294_, p_283353_, p_282640_, p_281964_, p_283211_, p_282349_, p_282349_); -+ } -+ -+ // Forge: Allow specifying a gradient instead of a single color for the background -+ private static void renderRectangle(GuiGraphics p_281392_, int p_282294_, int p_283353_, int p_282640_, int p_281964_, int p_283211_, int p_282349_, int colorTo) { -+ p_281392_.fillGradient(p_282294_, p_283353_, p_282294_ + p_282640_, p_283353_ + p_281964_, p_283211_, p_282349_, colorTo); - } - } diff --git a/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch b/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch index d0f6315f..789a7732 100644 --- a/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch +++ b/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch @@ -3,9 +3,9 @@ @@ -158,6 +_,7 @@ ) .build(); - this.resetButton = Button.builder(RESET_BUTTON_TITLE, p_346334_ -> { + this.resetButton = Button.builder(RESET_BUTTON_TITLE, p_359096_ -> { + this.key.setToDefault(); - KeyBindsList.this.minecraft.options.setKey(p_345998_, p_345998_.getDefaultKey()); + p_345998_.setKey(p_345998_.getDefaultKey()); KeyBindsList.this.resetMappingAndUpdateButtons(); }).bounds(0, 0, 50, 20).createNarration(p_344899_ -> Component.translatable("narrator.controls.reset", p_345196_)).build(); @@ -210,7 +_,7 @@ diff --git a/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch b/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch index 99b5c71d..26986803 100644 --- a/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch @@ -46,13 +46,13 @@ + if (this.selectedKey != null) { + if (p_94715_ == 256) { + this.selectedKey.setKeyModifierAndCode(net.neoforged.neoforge.client.settings.KeyModifier.NONE, InputConstants.UNKNOWN); - this.options.setKey(this.selectedKey, InputConstants.UNKNOWN); + this.selectedKey.setKey(InputConstants.UNKNOWN); + lastPressedKey = InputConstants.UNKNOWN; + lastPressedModifier = InputConstants.UNKNOWN; + isLastKeyHeldDown = false; + isLastModifierHeldDown = false; } else { -- this.options.setKey(this.selectedKey, InputConstants.getKey(p_345810_, p_345447_)); +- this.selectedKey.setKey(InputConstants.getKey(p_345810_, p_345447_)); - } + var key = InputConstants.getKey(p_94715_, p_94716_); + if (lastPressedKey.equals(key)) { @@ -67,13 +67,13 @@ + net.neoforged.neoforge.client.settings.KeyModifier.getKeyModifier(lastPressedModifier), + lastPressedKey + ); -+ this.options.setKey(this.selectedKey, lastPressedKey); ++ this.selectedKey.setKey(lastPressedKey); + } else { + this.selectedKey.setKeyModifierAndCode( + net.neoforged.neoforge.client.settings.KeyModifier.NONE, + lastPressedModifier + ); -+ this.options.setKey(this.selectedKey, lastPressedModifier); ++ this.selectedKey.setKey(lastPressedModifier); + } + lastPressedKey = InputConstants.UNKNOWN; + lastPressedModifier = InputConstants.UNKNOWN; diff --git a/patches/net/minecraft/client/gui/screens/recipebook/GhostSlots.java.patch b/patches/net/minecraft/client/gui/screens/recipebook/GhostSlots.java.patch new file mode 100644 index 00000000..126f6d61 --- /dev/null +++ b/patches/net/minecraft/client/gui/screens/recipebook/GhostSlots.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/gui/screens/recipebook/GhostSlots.java ++++ b/net/minecraft/client/gui/screens/recipebook/GhostSlots.java +@@ -69,7 +_,7 @@ + if (ghostslots$ghostslot != null) { + ItemStack itemstack = ghostslots$ghostslot.getItem(this.slotSelectTime.currentIndex()); + p_363721_.renderComponentTooltip( +- p_365392_.font, Screen.getTooltipFromItem(p_365392_, itemstack), p_363797_, p_363310_, itemstack.get(DataComponents.TOOLTIP_STYLE) ++ p_365392_.font, Screen.getTooltipFromItem(p_365392_, itemstack), p_363797_, p_363310_, itemstack, itemstack.get(DataComponents.TOOLTIP_STYLE) + ); + } + } diff --git a/patches/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch b/patches/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch index 0eb3a5d0..46ae50aa 100644 --- a/patches/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch +++ b/patches/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch @@ -1,20 +1,12 @@ --- a/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java +++ b/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java -@@ -115,7 +_,7 @@ - this.initFilterButtonTextures(); - this.tabButtons.clear(); - -- for (RecipeBookCategories recipebookcategories : RecipeBookCategories.getCategories(this.menu.getRecipeBookType())) { -+ for(RecipeBookCategories recipebookcategories : this.menu.getRecipeBookCategories()) { - this.tabButtons.add(new RecipeBookTabButton(recipebookcategories)); - } - -@@ -297,7 +_,7 @@ - } - - if (itemstack != null && this.minecraft.screen != null) { -- p_282776_.renderComponentTooltip(this.minecraft.font, Screen.getTooltipFromItem(this.minecraft, itemstack), p_282948_, p_283050_); -+ p_282776_.renderComponentTooltip(this.minecraft.font, Screen.getTooltipFromItem(this.minecraft, itemstack), p_282948_, p_283050_, itemstack); - } - } - +@@ -268,7 +_,8 @@ + + for (RecipeBookTabButton recipebooktabbutton : this.tabButtons) { + ExtendedRecipeBookCategory extendedrecipebookcategory = recipebooktabbutton.getCategory(); +- if (extendedrecipebookcategory instanceof SearchRecipeBookCategory) { ++ // Neo: Add support for modded search categories. ++ if (extendedrecipebookcategory instanceof SearchRecipeBookCategory || net.neoforged.neoforge.client.RecipeBookManager.getSearchCategories().containsKey(extendedrecipebookcategory)) { + recipebooktabbutton.visible = true; + recipebooktabbutton.setPosition(i, j + 27 * l++); + } else if (recipebooktabbutton.updateVisibility(this.book)) { diff --git a/patches/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch b/patches/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch index 1c369de9..55fa7396 100644 --- a/patches/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch @@ -1,25 +1,25 @@ --- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java +++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java -@@ -118,6 +_,7 @@ - public static void openFresh(Minecraft p_232897_, @Nullable Screen p_232898_) { - queueLoadScreen(p_232897_, PREPARING_WORLD_DATA); - PackRepository packrepository = new PackRepository(new ServerPacksSource(p_232897_.directoryValidator())); +@@ -169,6 +_,7 @@ + ) { + queueLoadScreen(p_372818_, PREPARING_WORLD_DATA); + PackRepository packrepository = new PackRepository(new ServerPacksSource(p_372818_.directoryValidator())); + net.neoforged.neoforge.resource.ResourcePackLoader.populatePackRepository(packrepository, net.minecraft.server.packs.PackType.SERVER_DATA, false); WorldLoader.InitConfig worldloader$initconfig = createDefaultLoadConfig(packrepository, WorldDataConfiguration.DEFAULT); CompletableFuture completablefuture = WorldLoader.load( worldloader$initconfig, -@@ -243,6 +_,10 @@ - WorldCreationContext worldcreationcontext = this.uiState.getSettings(); - LevelSettings levelsettings = this.createLevelSettings(flag); - WorldData worlddata = new PrimaryLevelData(levelsettings, worldcreationcontext.options(), p_250577_, p_249994_); -+ if(worlddata.worldGenSettingsLifecycle() != Lifecycle.stable()) { +@@ -307,6 +_,10 @@ + SystemToast.onPackCopyFailure(this.minecraft, s); + return false; + } else { ++ if (p_374211_.worldGenSettingsLifecycle() != Lifecycle.stable()) { + // Neo: set experimental settings confirmation flag so user is not shown warning on next open -+ ((PrimaryLevelData)worlddata).withConfirmedWarning(true); ++ ((PrimaryLevelData)p_374211_).withConfirmedWarning(true); + } this.minecraft .createWorldOpenFlows() - .createLevelFromExistingSettings(optional.get(), worldcreationcontext.dataPackResources(), p_249152_, worlddata); -@@ -428,7 +_,7 @@ + .createLevelFromExistingSettings(optional.get(), worldcreationcontext.dataPackResources(), p_249152_, p_374211_); +@@ -491,7 +_,7 @@ if (p_269627_) { p_270552_.accept(this.uiState.getSettings().dataConfiguration()); } else { @@ -28,7 +28,7 @@ } }, Component.translatable("dataPack.validation.failed"), -@@ -547,6 +_,7 @@ +@@ -605,6 +_,7 @@ if (path != null) { if (this.tempDataPackRepository == null) { this.tempDataPackRepository = ServerPacksSource.createPackRepository(path, this.packValidator); diff --git a/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch b/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch index d7e34577..deb2ee60 100644 --- a/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch +++ b/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java -@@ -74,6 +_,10 @@ +@@ -95,6 +_,10 @@ ); } + public WorldCreationContext withDataConfiguration(WorldDataConfiguration dataConfiguration) { -+ return new WorldCreationContext(this.options, this.datapackDimensions, this.selectedDimensions, this.worldgenRegistries, this.dataPackResources, dataConfiguration); ++ return new WorldCreationContext(this.options, this.datapackDimensions, this.selectedDimensions, this.worldgenRegistries, this.dataPackResources, dataConfiguration, this.initialWorldCreationOptions); + } + public RegistryAccess.Frozen worldgenLoadContext() { diff --git a/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch b/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch index b1747f20..c362174f 100644 --- a/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch +++ b/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java -@@ -225,7 +_,7 @@ +@@ -236,7 +_,7 @@ @Nullable public PresetEditor getPresetEditor() { Holder holder = this.getWorldType().preset(); diff --git a/patches/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch b/patches/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch index 9dc24fd5..37bde45b 100644 --- a/patches/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch +++ b/patches/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java -@@ -65,7 +_,7 @@ +@@ -66,7 +_,7 @@ import org.slf4j.Logger; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final UUID WORLD_PACK_ID = UUID.fromString("640a6a92-b6cb-48a0-b391-831586500359"); private final Minecraft minecraft; -@@ -210,7 +_,10 @@ +@@ -215,7 +_,10 @@ component1 = Component.translatable("selectWorld.backupWarning.customized"); } else { component = Component.translatable("selectWorld.backupQuestion.experimental"); @@ -21,7 +21,7 @@ } this.minecraft.setScreen(new BackupConfirmScreen(p_307323_, (p_307085_, p_307086_) -> { -@@ -377,10 +_,19 @@ +@@ -381,10 +_,19 @@ WorldData worlddata = p_330774_.worldData(); boolean flag = worlddata.worldGenOptions().isOldCustomizedWorld(); boolean flag1 = worlddata.worldGenSettingsLifecycle() != Lifecycle.stable(); diff --git a/patches/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch b/patches/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch index 93857dce..bd2c7fd8 100644 --- a/patches/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch +++ b/patches/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch @@ -8,15 +8,15 @@ static final Logger LOGGER = LogUtils.getLogger(); static final Component FROM_NEWER_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.fromNewerVersion1").withStyle(ChatFormatting.RED); static final Component FROM_NEWER_TOOLTIP_2 = Component.translatable("selectWorld.tooltip.fromNewerVersion2").withStyle(ChatFormatting.RED); -@@ -405,6 +_,7 @@ - RenderSystem.enableBlend(); - p_281612_.blit(this.icon.textureLocation(), p_282820_, p_283181_, 0.0F, 0.0F, 32, 32, 32, 32); - RenderSystem.disableBlend(); +@@ -403,6 +_,7 @@ + p_281612_.drawString(this.minecraft.font, s1, p_282820_ + 32 + 3, p_283181_ + 9 + 3, -8355712, false); + p_281612_.drawString(this.minecraft.font, component, p_282820_ + 32 + 3, p_283181_ + 9 + 9 + 3, -8355712, false); + p_281612_.blit(RenderType::guiTextured, this.icon.textureLocation(), p_282820_, p_283181_, 0.0F, 0.0F, 32, 32, 32, 32); + renderExperimentalWarning(p_281612_, p_283204_, p_283025_, p_283181_, p_282820_); if (this.minecraft.options.touchscreen().get() || p_283396_) { p_281612_.fill(p_282820_, p_283181_, p_282820_ + 32, p_283181_ + 32, -1601138544); int j = p_283204_ - p_282820_; -@@ -511,6 +_,7 @@ +@@ -509,6 +_,7 @@ this.doDeleteWorld(); } @@ -24,7 +24,7 @@ this.minecraft.setScreen(this.screen); }, Component.translatable("selectWorld.deleteQuestion"), -@@ -647,6 +_,19 @@ +@@ -645,6 +_,19 @@ public String getLevelName() { return this.summary.getLevelName(); @@ -34,7 +34,7 @@ + private void renderExperimentalWarning(GuiGraphics guiGraphics, int mouseX, int mouseY, int top, int left) { + if (this.summary.getSettings() != null && this.summary.getSettings().getLifecycle().equals(com.mojang.serialization.Lifecycle.experimental())) { + int leftStart = left + WorldSelectionList.this.getRowWidth(); -+ guiGraphics.blit(WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32); ++ guiGraphics.blit(RenderType::guiTextured, WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32); + if (WorldSelectionList.this.getEntryAtPosition(mouseX, mouseY) == this && mouseX > leftStart - 36 && mouseX < leftStart) { + var font = Minecraft.getInstance().font; + List tooltip = font.split(Component.translatable("neoforge.experimentalsettings.tooltip"), 200); diff --git a/patches/net/minecraft/client/main/Main.java.patch b/patches/net/minecraft/client/main/Main.java.patch index 4f5d0f09..c66fe4ba 100644 --- a/patches/net/minecraft/client/main/Main.java.patch +++ b/patches/net/minecraft/client/main/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/main/Main.java +++ b/net/minecraft/client/main/Main.java -@@ -111,7 +_,7 @@ +@@ -120,7 +_,7 @@ CrashReport.preload(); logger = LogUtils.getLogger(); s1 = "Bootstrap"; diff --git a/patches/net/minecraft/client/model/HumanoidModel.java.patch b/patches/net/minecraft/client/model/HumanoidModel.java.patch index b067ead7..5d2e521e 100644 --- a/patches/net/minecraft/client/model/HumanoidModel.java.patch +++ b/patches/net/minecraft/client/model/HumanoidModel.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/client/model/HumanoidModel.java +++ b/net/minecraft/client/model/HumanoidModel.java -@@ -306,6 +_,8 @@ +@@ -257,6 +_,8 @@ case BRUSH: this.rightArm.xRot = this.rightArm.xRot * 0.5F - (float) (Math.PI / 5); this.rightArm.yRot = 0.0F; + default: -+ this.rightArmPose.applyTransform(this, p_102876_, net.minecraft.world.entity.HumanoidArm.RIGHT); ++ p_362238_.applyTransform(this, p_364666_, net.minecraft.world.entity.HumanoidArm.RIGHT); } } -@@ -348,6 +_,8 @@ +@@ -299,6 +_,8 @@ case BRUSH: this.leftArm.xRot = this.leftArm.xRot * 0.5F - (float) (Math.PI / 5); this.leftArm.yRot = 0.0F; + default: -+ this.leftArmPose.applyTransform(this, p_102879_, net.minecraft.world.entity.HumanoidArm.LEFT); ++ p_361463_.applyTransform(this, p_361741_, net.minecraft.world.entity.HumanoidArm.LEFT); } } -@@ -446,7 +_,7 @@ +@@ -376,7 +_,7 @@ } @OnlyIn(Dist.CLIENT) @@ -27,7 +27,7 @@ EMPTY(false), ITEM(false), BLOCK(false), -@@ -459,13 +_,31 @@ +@@ -389,13 +_,31 @@ BRUSH(false); private final boolean twoHanded; @@ -50,7 +50,7 @@ return this.twoHanded; + } + -+ public void applyTransform(HumanoidModel model, T entity, net.minecraft.world.entity.HumanoidArm arm) { ++ public void applyTransform(HumanoidModel model, T entity, net.minecraft.world.entity.HumanoidArm arm) { + if (this.forgeArmPose != null) this.forgeArmPose.applyTransform(model, entity, arm); + } + diff --git a/patches/net/minecraft/client/model/HierarchicalModel.java.patch b/patches/net/minecraft/client/model/Model.java.patch similarity index 52% rename from patches/net/minecraft/client/model/HierarchicalModel.java.patch rename to patches/net/minecraft/client/model/Model.java.patch index b9e5a58f..8dfabd26 100644 --- a/patches/net/minecraft/client/model/HierarchicalModel.java.patch +++ b/patches/net/minecraft/client/model/Model.java.patch @@ -1,48 +1,51 @@ ---- a/net/minecraft/client/model/HierarchicalModel.java -+++ b/net/minecraft/client/model/HierarchicalModel.java -@@ -27,6 +_,10 @@ - super(p_170623_); +--- a/net/minecraft/client/model/Model.java ++++ b/net/minecraft/client/model/Model.java +@@ -28,6 +_,10 @@ + this.allParts = p_368583_.getAllParts().toList(); } + protected static net.neoforged.neoforge.client.entity.animation.json.AnimationHolder getAnimation(ResourceLocation key) { + return net.neoforged.neoforge.client.entity.animation.json.AnimationLoader.INSTANCE.getAnimationHolder(key); + } + - @Override - public void renderToBuffer(PoseStack p_170625_, VertexConsumer p_170626_, int p_170627_, int p_170628_, int p_350603_) { - this.root().render(p_170625_, p_170626_, p_170627_, p_170628_, p_350603_); -@@ -44,18 +_,34 @@ - this.animate(p_233382_, p_233383_, p_233384_, 1.0F); + public final RenderType renderType(ResourceLocation p_103120_) { + return this.renderType.apply(p_103120_); + } +@@ -64,12 +_,20 @@ + this.animate(p_364820_, p_361968_, p_362503_, 1.0F); } + protected void animate(AnimationState animationState, net.neoforged.neoforge.client.entity.animation.json.AnimationHolder animation, float ageInTicks) { + this.animate(animationState, animation.get(), ageInTicks); + } + - protected void animateWalk(AnimationDefinition p_268159_, float p_268057_, float p_268347_, float p_268138_, float p_268165_) { - long i = (long)(p_268057_ * 50.0F * p_268138_); - float f = Math.min(p_268347_ * p_268165_, 1.0F); - KeyframeAnimations.animate(this, p_268159_, i, f, ANIMATION_VECTOR_CACHE); + protected void animateWalk(AnimationDefinition p_362453_, float p_365353_, float p_364840_, float p_362983_, float p_361956_) { + long i = (long)(p_365353_ * 50.0F * p_362983_); + float f = Math.min(p_364840_ * p_361956_, 1.0F); + KeyframeAnimations.animate(this, p_362453_, i, f, ANIMATION_VECTOR_CACHE); } + protected void animateWalk(net.neoforged.neoforge.client.entity.animation.json.AnimationHolder animation, float limbSwing, float limbSwingAmount, float maxAnimationSpeed, float animationScaleFactor) { + this.animateWalk(animation.get(), limbSwing, limbSwingAmount, maxAnimationSpeed, animationScaleFactor); + } + - protected void animate(AnimationState p_233386_, AnimationDefinition p_233387_, float p_233388_, float p_233389_) { - p_233386_.updateTime(p_233388_, p_233389_); - p_233386_.ifStarted(p_233392_ -> KeyframeAnimations.animate(this, p_233387_, p_233392_.getAccumulatedTime(), 1.0F, ANIMATION_VECTOR_CACHE)); + protected void animate(AnimationState p_364413_, AnimationDefinition p_361459_, float p_361947_, float p_362164_) { + p_364413_.ifStarted( + p_361743_ -> KeyframeAnimations.animate( +@@ -78,8 +_,16 @@ + ); } + protected void animate(AnimationState animationState, net.neoforged.neoforge.client.entity.animation.json.AnimationHolder animation, float ageInTicks, float speed) { + this.animate(animationState, animation.get(), ageInTicks, speed); + } + - protected void applyStatic(AnimationDefinition p_288996_) { - KeyframeAnimations.animate(this, p_288996_, 0L, 1.0F, ANIMATION_VECTOR_CACHE); + protected void applyStatic(AnimationDefinition p_362055_) { + KeyframeAnimations.animate(this, p_362055_, 0L, 1.0F, ANIMATION_VECTOR_CACHE); + } + + protected void applyStatic(net.neoforged.neoforge.client.entity.animation.json.AnimationHolder animation) { + this.applyStatic(animation.get()); } - } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/net/minecraft/client/model/geom/LayerDefinitions.java.patch b/patches/net/minecraft/client/model/geom/LayerDefinitions.java.patch index 2bb68d95..de5171ae 100644 --- a/patches/net/minecraft/client/model/geom/LayerDefinitions.java.patch +++ b/patches/net/minecraft/client/model/geom/LayerDefinitions.java.patch @@ -1,18 +1,9 @@ --- a/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java -@@ -316,7 +_,7 @@ - LayerDefinition layerdefinition22 = ChestRaftModel.createBodyModel(); - - for (Boat.Type boat$type : Boat.Type.values()) { -- if (boat$type == Boat.Type.BAMBOO) { -+ if (boat$type.isRaft()) { - builder.put(ModelLayers.createBoatModelName(boat$type), layerdefinition21); - builder.put(ModelLayers.createChestBoatModelName(boat$type), layerdefinition22); - } else { -@@ -329,6 +_,7 @@ - WoodType.values().forEach(p_171114_ -> builder.put(ModelLayers.createSignModelName(p_171114_), layerdefinition23)); - LayerDefinition layerdefinition24 = HangingSignRenderer.createHangingSignLayer(); - WoodType.values().forEach(p_247864_ -> builder.put(ModelLayers.createHangingSignModelName(p_247864_), layerdefinition24)); +@@ -454,6 +_,7 @@ + builder.put(ModelLayers.createWallSignModelName(p_359128_), layerdefinition54); + builder.put(ModelLayers.createHangingSignModelName(p_359128_), layerdefinition55); + }); + net.neoforged.neoforge.client.ClientHooks.loadLayerDefinitions(builder); ImmutableMap immutablemap = builder.build(); List list = ModelLayers.getKnownLocations().filter(p_171117_ -> !immutablemap.containsKey(p_171117_)).collect(Collectors.toList()); diff --git a/patches/net/minecraft/client/model/geom/ModelLayers.java.patch b/patches/net/minecraft/client/model/geom/ModelLayers.java.patch index cbb66bf8..9b969107 100644 --- a/patches/net/minecraft/client/model/geom/ModelLayers.java.patch +++ b/patches/net/minecraft/client/model/geom/ModelLayers.java.patch @@ -1,36 +1,18 @@ --- a/net/minecraft/client/model/geom/ModelLayers.java +++ b/net/minecraft/client/model/geom/ModelLayers.java -@@ -213,27 +_,33 @@ +@@ -301,15 +_,18 @@ } - public static ModelLayerLocation createRaftModelName(Boat.Type p_252002_) { -- return createLocation("raft/" + p_252002_.getName(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_252002_.getName()); -+ return new ModelLayerLocation(location.withPrefix("raft/"), "main"); - } - - public static ModelLayerLocation createChestRaftModelName(Boat.Type p_248520_) { -- return createLocation("chest_raft/" + p_248520_.getName(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_248520_.getName()); -+ return new ModelLayerLocation(location.withPrefix("chest_raft/"), "main"); - } - - public static ModelLayerLocation createBoatModelName(Boat.Type p_171290_) { -- return createLocation("boat/" + p_171290_.getName(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_171290_.getName()); -+ return new ModelLayerLocation(location.withPrefix("boat/"), "main"); - } - - public static ModelLayerLocation createChestBoatModelName(Boat.Type p_233551_) { -- return createLocation("chest_boat/" + p_233551_.getName(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_233551_.getName()); -+ return new ModelLayerLocation(location.withPrefix("chest_boat/"), "main"); + public static ModelLayerLocation createStandingSignModelName(WoodType p_171292_) { +- return createLocation("sign/standing/" + p_171292_.name(), "main"); ++ ResourceLocation location = ResourceLocation.parse(p_171292_.name()); ++ return new ModelLayerLocation(location.withPrefix("sign/standing/"), "main"); } - public static ModelLayerLocation createSignModelName(WoodType p_171292_) { -- return createLocation("sign/" + p_171292_.name(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_171292_.name()); -+ return new ModelLayerLocation(location.withPrefix("sign/"), "main"); + public static ModelLayerLocation createWallSignModelName(WoodType p_360963_) { +- return createLocation("sign/wall/" + p_360963_.name(), "main"); ++ ResourceLocation location = ResourceLocation.parse(p_360963_.name()); ++ return new ModelLayerLocation(location.withPrefix("sign/wall/"), "main"); } public static ModelLayerLocation createHangingSignModelName(WoodType p_252225_) { diff --git a/patches/net/minecraft/client/multiplayer/ClientChunkCache.java.patch b/patches/net/minecraft/client/multiplayer/ClientChunkCache.java.patch index 8729039c..768dd4d9 100644 --- a/patches/net/minecraft/client/multiplayer/ClientChunkCache.java.patch +++ b/patches/net/minecraft/client/multiplayer/ClientChunkCache.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/multiplayer/ClientChunkCache.java +++ b/net/minecraft/client/multiplayer/ClientChunkCache.java -@@ -63,6 +_,7 @@ +@@ -65,6 +_,7 @@ int i = this.storage.getIndex(p_295783_.x, p_295783_.z); LevelChunk levelchunk = this.storage.getChunk(i); if (isValidChunk(levelchunk, p_295783_.x, p_295783_.z)) { + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkEvent.Unload(levelchunk)); - this.storage.replace(i, levelchunk, null); + this.storage.drop(i, levelchunk); } } -@@ -123,6 +_,7 @@ +@@ -125,6 +_,7 @@ } this.level.onChunkLoaded(chunkpos); diff --git a/patches/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch b/patches/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch index 8bc8fe4f..0cafb8a7 100644 --- a/patches/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch +++ b/patches/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java -@@ -88,6 +_,10 @@ +@@ -84,6 +_,10 @@ protected final Map serverCookies; protected Map customReportDetails; protected ServerLinks serverLinks; @@ -11,8 +11,8 @@ protected ClientCommonPacketListenerImpl(Minecraft p_295454_, Connection p_294773_, CommonListenerCookie p_294647_) { this.minecraft = p_295454_; -@@ -100,6 +_,8 @@ - this.strictErrorHandling = p_294647_.strictErrorHandling(); +@@ -95,6 +_,8 @@ + this.serverCookies = p_294647_.serverCookies(); this.customReportDetails = p_294647_.customReportDetails(); this.serverLinks = p_294647_.serverLinks(); + // Neo: Set the connection type based on the cookie from the previous phase. @@ -20,7 +20,7 @@ } @Override -@@ -149,6 +_,33 @@ +@@ -142,6 +_,33 @@ @Override public void handleCustomPayload(ClientboundCustomPayloadPacket p_295727_) { @@ -54,7 +54,7 @@ CustomPacketPayload custompacketpayload = p_295727_.payload(); if (!(custompacketpayload instanceof DiscardedPayload)) { PacketUtils.ensureRunningOnSameThread(p_295727_, this, this.minecraft); -@@ -285,6 +_,8 @@ +@@ -278,6 +_,8 @@ } public void send(Packet p_295097_) { @@ -63,7 +63,7 @@ this.connection.send(p_295097_); } -@@ -292,6 +_,9 @@ +@@ -285,6 +_,9 @@ public void onDisconnect(DisconnectionDetails p_350760_) { this.telemetryManager.onDisconnect(); this.minecraft.disconnect(this.createDisconnectScreen(p_350760_), this.isTransferring); @@ -73,7 +73,7 @@ LOGGER.warn("Client disconnected with reason: {}", p_350760_.reason().getString()); } -@@ -415,5 +_,10 @@ +@@ -409,5 +_,10 @@ @OnlyIn(Dist.CLIENT) static record PendingRequest(UUID id, URL url, String hash) { } diff --git a/patches/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch b/patches/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch index 5f8469c3..d26216aa 100644 --- a/patches/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch +++ b/patches/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch @@ -31,9 +31,9 @@ new ClientPacketListener( this.minecraft, this.connection, -@@ -137,12 +_,19 @@ +@@ -136,12 +_,19 @@ + this.serverCookies, this.chatState, - this.strictErrorHandling, this.customReportDetails, - this.serverLinks + this.serverLinks, @@ -53,7 +53,7 @@ } @Override -@@ -154,5 +_,51 @@ +@@ -153,5 +_,51 @@ public void onDisconnect(DisconnectionDetails p_351005_) { super.onDisconnect(p_351005_); this.minecraft.clearDownloadedResourcePacks(); diff --git a/patches/net/minecraft/client/multiplayer/ClientLevel.java.patch b/patches/net/minecraft/client/multiplayer/ClientLevel.java.patch index d7f42b23..a1d3332b 100644 --- a/patches/net/minecraft/client/multiplayer/ClientLevel.java.patch +++ b/patches/net/minecraft/client/multiplayer/ClientLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientLevel.java +++ b/net/minecraft/client/multiplayer/ClientLevel.java -@@ -121,6 +_,7 @@ +@@ -126,6 +_,7 @@ p_194170_.put( BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(p_194168_ -> this.calculateBlockTint(p_194168_, BiomeColors.WATER_COLOR_RESOLVER)) ); @@ -8,16 +8,16 @@ } ); private final ClientChunkCache chunkSource; -@@ -128,6 +_,8 @@ - private int serverSimulationDistance; - private final BlockStatePredictionHandler blockStatePredictionHandler = new BlockStatePredictionHandler(); +@@ -135,6 +_,8 @@ + private final int seaLevel; + private boolean tickDayTime; private static final Set MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT); + private final it.unimi.dsi.fastutil.ints.Int2ObjectMap> partEntities = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>(); + private final net.neoforged.neoforge.client.model.data.ModelDataManager modelDataManager = new net.neoforged.neoforge.client.model.data.ModelDataManager(this); public void handleBlockChangedAck(int p_233652_) { this.blockStatePredictionHandler.endPredictionsUpTo(p_233652_, this); -@@ -157,10 +_,15 @@ +@@ -164,10 +_,15 @@ @Override public boolean setBlock(BlockPos p_233643_, BlockState p_233644_, int p_233645_, int p_233646_) { if (this.blockStatePredictionHandler.isPredicting()) { @@ -33,37 +33,37 @@ } return flag; -@@ -192,6 +_,7 @@ - this.serverSimulationDistance = p_205510_; +@@ -201,6 +_,7 @@ + this.serverSimulationDistance = p_363776_; this.updateSkyBrightness(); this.prepareWeather(); + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.LevelEvent.Load(this)); } public void queueLightUpdate(Runnable p_194172_) { -@@ -238,7 +_,7 @@ +@@ -244,7 +_,7 @@ private void tickTime() { - this.setGameTime(this.levelData.getGameTime() + 1L); - if (this.levelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { -- this.setDayTime(this.levelData.getDayTime() + 1L); -+ this.setDayTime(this.levelData.getDayTime() + advanceDaytime()); + this.clientLevelData.setGameTime(this.clientLevelData.getGameTime() + 1L); + if (this.tickDayTime) { +- this.clientLevelData.setDayTime(this.clientLevelData.getDayTime() + 1L); ++ this.clientLevelData.setDayTime(this.clientLevelData.getDayTime() + advanceDaytime()); } } -@@ -282,7 +_,11 @@ +@@ -283,7 +_,11 @@ p_104640_.setOldPosAndRot(); p_104640_.tickCount++; - this.getProfiler().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString()); + Profiler.get().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString()); - p_104640_.tick(); + // Neo: Permit cancellation of Entity#tick via EntityTickEvent.Pre + if (!net.neoforged.neoforge.event.EventHooks.fireEntityTickPre(p_104640_).isCanceled()) { + p_104640_.tick(); + net.neoforged.neoforge.event.EventHooks.fireEntityTickPost(p_104640_); + } - this.getProfiler().pop(); + Profiler.get().pop(); for (Entity entity : p_104640_.getPassengers()) { -@@ -330,8 +_,10 @@ +@@ -335,8 +_,10 @@ } public void addEntity(Entity p_104741_) { @@ -74,7 +74,7 @@ } public void removeEntity(int p_171643_, Entity.RemovalReason p_171644_) { -@@ -502,6 +_,13 @@ +@@ -507,6 +_,13 @@ float p_263349_, long p_263408_ ) { @@ -88,7 +88,7 @@ if (p_263381_ == this.minecraft.player) { this.playSound(p_263372_, p_263404_, p_263365_, p_263335_.value(), p_263417_, p_263416_, p_263349_, false, p_263408_); } -@@ -511,6 +_,12 @@ +@@ -516,6 +_,12 @@ public void playSeededSound( @Nullable Player p_263514_, Entity p_263536_, Holder p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_ ) { @@ -101,16 +101,7 @@ if (p_263514_ == this.minecraft.player) { this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_263518_.value(), p_263487_, p_263538_, p_263524_, p_263536_, p_263509_)); } -@@ -906,7 +_,7 @@ - } - - @Override -- public LevelEntityGetter getEntities() { -+ protected LevelEntityGetter getEntities() { - return this.entityStorage.getEntityGetter(); - } - -@@ -1033,6 +_,7 @@ +@@ -1045,6 +_,7 @@ } public void setDifficulty(Difficulty p_104852_) { @@ -118,7 +109,7 @@ this.difficulty = p_104852_; } -@@ -1069,14 +_,75 @@ +@@ -1081,14 +_,75 @@ if (p_171712_ instanceof AbstractClientPlayer) { ClientLevel.this.players.add((AbstractClientPlayer)p_171712_); } diff --git a/patches/net/minecraft/client/multiplayer/ClientPacketListener.java.patch b/patches/net/minecraft/client/multiplayer/ClientPacketListener.java.patch index ba17981a..a1ad4df3 100644 --- a/patches/net/minecraft/client/multiplayer/ClientPacketListener.java.patch +++ b/patches/net/minecraft/client/multiplayer/ClientPacketListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientPacketListener.java +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java -@@ -344,6 +_,7 @@ +@@ -367,6 +_,7 @@ private final ChunkBatchSizeCalculator chunkBatchSizeCalculator = new ChunkBatchSizeCalculator(); private final PingDebugMonitor pingDebugMonitor; private final DebugSampleSubscriber debugSampleSubscriber; @@ -8,15 +8,17 @@ @Nullable private LevelLoadStatusManager levelLoadStatusManager; private boolean serverEnforcesSecureChat; -@@ -366,6 +_,7 @@ +@@ -388,7 +_,8 @@ p_253924_.gui.getChat().restoreState(p_295121_.chatState()); } +- this.potionBrewing = PotionBrewing.bootstrap(this.enabledFeatures); + this.connectionType = p_295121_.connectionType(); - this.potionBrewing = PotionBrewing.bootstrap(this.enabledFeatures); ++ this.potionBrewing = PotionBrewing.bootstrap(this.enabledFeatures, this.registryAccess); + this.fuelValues = FuelValues.vanillaBurnTimes(p_295121_.receivedRegistries(), this.enabledFeatures); } -@@ -427,12 +_,13 @@ +@@ -451,12 +_,13 @@ this.minecraft.debugRenderer.clear(); this.minecraft.player.resetPos(); @@ -31,9 +33,9 @@ this.minecraft.player.setReducedDebugInfo(p_105030_.reducedDebugInfo()); this.minecraft.player.setShowDeathScreen(p_105030_.showDeathScreen()); this.minecraft.player.setDoLimitedCrafting(p_105030_.doLimitedCrafting()); -@@ -828,7 +_,8 @@ +@@ -900,7 +_,8 @@ + this.serverCookies, chatcomponent$state, - this.strictErrorHandling, this.customReportDetails, - this.serverLinks + this.serverLinks, @@ -41,7 +43,7 @@ ) ) ); -@@ -1142,7 +_,7 @@ +@@ -1217,7 +_,7 @@ localplayer1 = this.minecraft.gameMode.createPlayer(this.level, localplayer.getStats(), localplayer.getRecipeBook()); } @@ -50,15 +52,15 @@ localplayer1.setId(localplayer.getId()); this.minecraft.player = localplayer1; if (flag) { -@@ -1164,6 +_,7 @@ +@@ -1245,6 +_,7 @@ + localplayer1.getAttributes().assignBaseValues(localplayer.getAttributes()); } - localplayer1.resetPos(); + net.neoforged.neoforge.client.ClientHooks.firePlayerRespawn(this.minecraft.gameMode, localplayer, localplayer1, localplayer1.connection.connection); this.level.addEntity(localplayer1); - localplayer1.setYRot(-180.0F); localplayer1.input = new KeyboardInput(this.minecraft.options); -@@ -1306,10 +_,7 @@ + this.minecraft.gameMode.adjustPlayer(localplayer1); +@@ -1391,10 +_,7 @@ PacketUtils.ensureRunningOnSameThread(p_104976_, this, this.minecraft); BlockPos blockpos = p_104976_.getPos(); this.minecraft.level.getBlockEntity(blockpos, p_104976_.getType()).ifPresent(p_337415_ -> { @@ -70,7 +72,7 @@ if (p_337415_ instanceof CommandBlockEntity && this.minecraft.screen instanceof CommandBlockEditScreen) { ((CommandBlockEditScreen)this.minecraft.screen).updateGui(); -@@ -1420,9 +_,15 @@ +@@ -1505,9 +_,15 @@ } } @@ -87,7 +89,7 @@ } @Override -@@ -1471,7 +_,9 @@ +@@ -1555,7 +_,9 @@ @Override public void handleCommands(ClientboundCommandsPacket p_104990_) { PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft); @@ -98,28 +100,33 @@ } @Override -@@ -1493,6 +_,7 @@ - ClientRecipeBook clientrecipebook = this.minecraft.player.getRecipeBook(); - clientrecipebook.setupCollections(this.recipeManager.getOrderedRecipes(), this.minecraft.level.registryAccess()); - this.searchTrees.updateRecipes(clientrecipebook, this.registryAccess); -+ net.neoforged.neoforge.client.ClientHooks.onRecipesUpdated(this.recipeManager); +@@ -1574,6 +_,11 @@ + public void handleUpdateRecipes(ClientboundUpdateRecipesPacket p_105132_) { + PacketUtils.ensureRunningOnSameThread(p_105132_, this, this.minecraft); + this.recipes = new ClientRecipeContainer(p_105132_.itemSets(), p_105132_.stonecutterRecipes()); ++ ++ // Neo: abuse recipe sync to overwrite fuel values with datamap values after their sync (tag update doesn't fire on initial sync and the constructor is too early) ++ if (this.connectionType.isNeoForge()) { ++ this.fuelValues = net.neoforged.neoforge.common.DataMapHooks.populateFuelValues(this.registryAccess, this.enabledFeatures); ++ } } @Override -@@ -1595,8 +_,10 @@ - TagCollector tagcollector = new TagCollector(); - p_294888_.getTags().forEach(tagcollector::append); - tagcollector.updateTags(this.registryAccess, this.connection.isMemoryConnection()); -- List list = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); -- this.searchTrees.updateCreativeTags(list); +@@ -1698,8 +_,11 @@ + }); + list.forEach(Registry.PendingTags::apply); + this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures); +- List list1 = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); +- this.searchTrees.updateCreativeTags(list1); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.TagsUpdatedEvent(this.registryAccess, true, flag)); + CreativeModeTabs.allTabs().stream().filter(net.minecraft.world.item.CreativeModeTab::hasSearchBar).forEach(tab -> { -+ List list = List.copyOf(tab.getDisplayItems()); -+ this.searchTrees.updateCreativeTags(list, net.neoforged.neoforge.client.CreativeModeTabSearchRegistry.getTagSearchKey(tab)); ++ List stacks = List.copyOf(tab.getDisplayItems()); ++ this.searchTrees.updateCreativeTags(stacks, net.neoforged.neoforge.client.CreativeModeTabSearchRegistry.getTagSearchKey(tab)); + }); } @Override -@@ -2407,6 +_,8 @@ +@@ -2526,6 +_,8 @@ } public void sendChat(String p_249888_) { @@ -128,7 +135,7 @@ Instant instant = Instant.now(); long i = Crypt.SaltSupplier.getLong(); LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.lastSeenMessages.generateAndApplyUpdate(); -@@ -2416,6 +_,7 @@ +@@ -2535,6 +_,7 @@ } public void sendCommand(String p_250092_) { @@ -136,7 +143,7 @@ SignableCommand signablecommand = SignableCommand.of(this.parseCommand(p_250092_)); if (signablecommand.arguments().isEmpty()) { this.send(new ServerboundChatCommandPacket(p_250092_)); -@@ -2490,6 +_,10 @@ +@@ -2622,6 +_,10 @@ public Scoreboard scoreboard() { return this.scoreboard; diff --git a/patches/net/minecraft/client/multiplayer/CommonListenerCookie.java.patch b/patches/net/minecraft/client/multiplayer/CommonListenerCookie.java.patch index 40db5789..da0f788e 100644 --- a/patches/net/minecraft/client/multiplayer/CommonListenerCookie.java.patch +++ b/patches/net/minecraft/client/multiplayer/CommonListenerCookie.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/multiplayer/CommonListenerCookie.java +++ b/net/minecraft/client/multiplayer/CommonListenerCookie.java -@@ -26,6 +_,28 @@ +@@ -25,6 +_,27 @@ + Map serverCookies, @Nullable ChatComponent.State chatState, - @Deprecated(forRemoval = true) boolean strictErrorHandling, Map customReportDetails, - ServerLinks serverLinks + ServerLinks serverLinks, + net.neoforged.neoforge.network.connection.ConnectionType connectionType ) { + /** -+ * @deprecated Use {@link #CommonListenerCookie(GameProfile, WorldSessionTelemetryManager, RegistryAccess.Frozen, FeatureFlagSet, String, ServerData, Screen, Map, ChatComponent.State, boolean, Map, ServerLinks, net.neoforged.neoforge.network.connection.ConnectionType)} ++ * @deprecated Use {@link #CommonListenerCookie(GameProfile, WorldSessionTelemetryManager, RegistryAccess.Frozen, FeatureFlagSet, String, ServerData, Screen, Map, ChatComponent.State, Map, ServerLinks, net.neoforged.neoforge.network.connection.ConnectionType)} + * instead,to indicate whether the connection is modded. + */ + @Deprecated @@ -23,10 +23,9 @@ + @Nullable Screen postDisconnectScreen, + Map serverCookies, + @Nullable ChatComponent.State chatState, -+ @Deprecated(forRemoval = true) boolean strictErrorHandling, + Map customReportDetails, + ServerLinks serverLinks + ) { -+ this(localGameProfile, telemetryManager, receivedRegistries, enabledFeatures, serverBrand, serverData, postDisconnectScreen, serverCookies, chatState, strictErrorHandling, customReportDetails, serverLinks, net.neoforged.neoforge.network.connection.ConnectionType.OTHER); ++ this(localGameProfile, telemetryManager, receivedRegistries, enabledFeatures, serverBrand, serverData, postDisconnectScreen, serverCookies, chatState, customReportDetails, serverLinks, net.neoforged.neoforge.network.connection.ConnectionType.OTHER); + } } diff --git a/patches/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch b/patches/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch index 40bda764..4a88a77d 100644 --- a/patches/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch +++ b/patches/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java +++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java -@@ -119,11 +_,12 @@ +@@ -120,11 +_,12 @@ } else if (blockstate.isAir()) { return false; } else { @@ -15,7 +15,7 @@ } return flag; -@@ -142,6 +_,7 @@ +@@ -143,6 +_,7 @@ BlockState blockstate = this.minecraft.level.getBlockState(p_105270_); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate, 1.0F); this.startPrediction(this.minecraft.level, p_233757_ -> { @@ -23,7 +23,7 @@ this.destroyBlock(p_105270_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233757_); }); -@@ -151,15 +_,19 @@ +@@ -152,15 +_,19 @@ this.connection .send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, p_105271_)); } @@ -43,7 +43,7 @@ if (flag && blockstate1.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105270_) >= 1.0F) { this.destroyBlock(p_105270_); } else { -@@ -171,7 +_,7 @@ +@@ -172,7 +_,7 @@ this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage()); } @@ -52,7 +52,7 @@ }); } -@@ -202,6 +_,7 @@ +@@ -203,6 +_,7 @@ BlockState blockstate1 = this.minecraft.level.getBlockState(p_105284_); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate1, 1.0F); this.startPrediction(this.minecraft.level, p_233753_ -> { @@ -60,7 +60,7 @@ this.destroyBlock(p_105284_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_, p_233753_); }); -@@ -214,7 +_,7 @@ +@@ -215,7 +_,7 @@ } else { this.destroyProgress = this.destroyProgress + blockstate.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105284_); if (this.destroyTicks % 4.0F == 0.0F) { @@ -69,7 +69,7 @@ this.minecraft .getSoundManager() .play( -@@ -231,6 +_,7 @@ +@@ -232,6 +_,7 @@ this.destroyTicks++; this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate, Mth.clamp(this.destroyProgress, 0.0F, 1.0F)); @@ -77,7 +77,7 @@ if (this.destroyProgress >= 1.0F) { this.isDestroying = false; this.startPrediction(this.minecraft.level, p_233739_ -> { -@@ -269,7 +_,7 @@ +@@ -270,7 +_,7 @@ private boolean sameDestroyTarget(BlockPos p_105282_) { ItemStack itemstack = this.minecraft.player.getMainHandItem(); @@ -86,7 +86,7 @@ } private void ensureHasSentCarriedItem() { -@@ -297,12 +_,23 @@ +@@ -298,12 +_,23 @@ private InteractionResult performUseItemOn(LocalPlayer p_233747_, InteractionHand p_233748_, BlockHitResult p_233749_) { BlockPos blockpos = p_233749_.getBlockPos(); ItemStack itemstack = p_233747_.getItemInHand(p_233748_); @@ -95,7 +95,7 @@ + return event.getCancellationResult(); + } if (this.localPlayerMode == GameType.SPECTATOR) { - return InteractionResult.SUCCESS; + return InteractionResult.CONSUME; } else { - boolean flag = !p_233747_.getMainHandItem().isEmpty() || !p_233747_.getOffhandItem().isEmpty(); + UseOnContext useoncontext = new UseOnContext(p_233747_, p_233748_, p_233749_); @@ -112,20 +112,20 @@ BlockState blockstate = this.minecraft.level.getBlockState(blockpos); if (!this.connection.isFeatureEnabled(blockstate.getBlock().requiredFeatures())) { return InteractionResult.FAIL; -@@ -323,8 +_,10 @@ +@@ -324,8 +_,10 @@ } } -- if (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack.getItem())) { +- if (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack)) { - UseOnContext useoncontext = new UseOnContext(p_233747_, p_233748_, p_233749_); + if (event.getUseItem().isFalse()) { + return InteractionResult.PASS; + } -+ if (event.getUseItem().isTrue() || (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack.getItem()))) { - InteractionResult interactionresult1; ++ if (event.getUseItem().isTrue() || (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack))) { + InteractionResult interactionresult2; if (this.localPlayerMode.isCreative()) { int i = itemstack.getCount(); -@@ -358,10 +_,17 @@ +@@ -359,6 +_,11 @@ mutableobject.setValue(InteractionResult.PASS); return serverbounduseitempacket; } else { @@ -134,22 +134,25 @@ + mutableobject.setValue(cancelResult); + return serverbounduseitempacket; + } - InteractionResultHolder interactionresultholder = itemstack.use(this.minecraft.level, p_233722_, p_233723_); - ItemStack itemstack1 = interactionresultholder.getObject(); + InteractionResult interactionresult = itemstack.use(this.minecraft.level, p_233722_, p_233723_); + ItemStack itemstack1; + if (interactionresult instanceof InteractionResult.Success interactionresult$success) { +@@ -371,6 +_,8 @@ + if (itemstack1 != itemstack) { p_233722_.setItemInHand(p_233723_, itemstack1); + if (itemstack1.isEmpty()) + net.neoforged.neoforge.event.EventHooks.onPlayerDestroyItem(p_233722_, itemstack, p_233723_); } - mutableobject.setValue(interactionresultholder.getResult()); -@@ -400,6 +_,9 @@ + mutableobject.setValue(interactionresult); +@@ -409,6 +_,9 @@ this.ensureHasSentCarriedItem(); Vec3 vec3 = p_105233_.getLocation().subtract(p_105232_.getX(), p_105232_.getY(), p_105232_.getZ()); this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105232_, p_105231_.isShiftKeyDown(), p_105234_, vec3)); + if (this.localPlayerMode == GameType.SPECTATOR) return InteractionResult.PASS; // don't fire for spectators to match non-specific EntityInteract + InteractionResult cancelResult = net.neoforged.neoforge.common.CommonHooks.onInteractEntityAt(p_105231_, p_105232_, p_105233_, p_105234_); + if(cancelResult != null) return cancelResult; - return this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105232_.interactAt(p_105231_, vec3, p_105234_); + return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105232_.interactAt(p_105231_, vec3, p_105234_)); } diff --git a/patches/net/minecraft/client/multiplayer/PlayerInfo.java.patch b/patches/net/minecraft/client/multiplayer/PlayerInfo.java.patch index 1609a2b5..27972460 100644 --- a/patches/net/minecraft/client/multiplayer/PlayerInfo.java.patch +++ b/patches/net/minecraft/client/multiplayer/PlayerInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/PlayerInfo.java +++ b/net/minecraft/client/multiplayer/PlayerInfo.java -@@ -85,6 +_,7 @@ +@@ -86,6 +_,7 @@ } protected void setGameMode(GameType p_105318_) { diff --git a/patches/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch b/patches/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch index 70a7eabf..1010c8ad 100644 --- a/patches/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch +++ b/patches/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/multiplayer/SessionSearchTrees.java +++ b/net/minecraft/client/multiplayer/SessionSearchTrees.java -@@ -60,7 +_,7 @@ - List list = p_346233_.getCollections(); - Registry registry = p_345600_.registryOrThrow(Registries.ITEM); - Item.TooltipContext item$tooltipcontext = Item.TooltipContext.of(p_345600_); +@@ -65,7 +_,7 @@ + Registry registry = registryaccess.lookupOrThrow(Registries.ITEM); + Item.TooltipContext item$tooltipcontext = Item.TooltipContext.of(registryaccess); + ContextMap contextmap = SlotDisplayContext.fromLevel(p_379752_); - TooltipFlag tooltipflag = TooltipFlag.Default.NORMAL; + TooltipFlag tooltipflag = net.neoforged.neoforge.client.ClientTooltipFlag.of(TooltipFlag.Default.NORMAL); CompletableFuture completablefuture = this.recipeSearch; this.recipeSearch = CompletableFuture.supplyAsync( () -> new FullTextSearchTree<>( -@@ -86,44 +_,60 @@ +@@ -92,44 +_,60 @@ } public void updateCreativeTags(List p_346121_) { diff --git a/patches/net/minecraft/client/multiplayer/TagCollector.java.patch b/patches/net/minecraft/client/multiplayer/TagCollector.java.patch deleted file mode 100644 index db75c16b..00000000 --- a/patches/net/minecraft/client/multiplayer/TagCollector.java.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- a/net/minecraft/client/multiplayer/TagCollector.java -+++ b/net/minecraft/client/multiplayer/TagCollector.java -@@ -44,5 +_,6 @@ - this.applyTags(p_326147_, p_326446_ -> true); - refreshBuiltInTagDependentData(); - } -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.TagsUpdatedEvent(p_326147_, true, p_326486_)); - } - } diff --git a/patches/net/minecraft/client/particle/AttackSweepParticle.java.patch b/patches/net/minecraft/client/particle/AttackSweepParticle.java.patch deleted file mode 100644 index 68182108..00000000 --- a/patches/net/minecraft/client/particle/AttackSweepParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/AttackSweepParticle.java -+++ b/net/minecraft/client/particle/AttackSweepParticle.java -@@ -9,7 +_,7 @@ - public class AttackSweepParticle extends TextureSheetParticle { - private final SpriteSet sprites; - -- AttackSweepParticle(ClientLevel p_105546_, double p_105547_, double p_105548_, double p_105549_, double p_105550_, SpriteSet p_105551_) { -+ protected AttackSweepParticle(ClientLevel p_105546_, double p_105547_, double p_105548_, double p_105549_, double p_105550_, SpriteSet p_105551_) { - super(p_105546_, p_105547_, p_105548_, p_105549_, 0.0, 0.0, 0.0); - this.sprites = p_105551_; - this.lifetime = 4; diff --git a/patches/net/minecraft/client/particle/BlockMarker.java.patch b/patches/net/minecraft/client/particle/BlockMarker.java.patch deleted file mode 100644 index dfaf8e63..00000000 --- a/patches/net/minecraft/client/particle/BlockMarker.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/BlockMarker.java -+++ b/net/minecraft/client/particle/BlockMarker.java -@@ -9,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class BlockMarker extends TextureSheetParticle { -- BlockMarker(ClientLevel p_194267_, double p_194268_, double p_194269_, double p_194270_, BlockState p_194271_) { -+ protected BlockMarker(ClientLevel p_194267_, double p_194268_, double p_194269_, double p_194270_, BlockState p_194271_) { - super(p_194267_, p_194268_, p_194269_, p_194270_); - this.setSprite(Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getParticleIcon(p_194271_)); - this.gravity = 0.0F; diff --git a/patches/net/minecraft/client/particle/BreakingItemParticle.java.patch b/patches/net/minecraft/client/particle/BreakingItemParticle.java.patch index 021bbf32..3d9b3236 100644 --- a/patches/net/minecraft/client/particle/BreakingItemParticle.java.patch +++ b/patches/net/minecraft/client/particle/BreakingItemParticle.java.patch @@ -1,21 +1,11 @@ --- a/net/minecraft/client/particle/BreakingItemParticle.java +++ b/net/minecraft/client/particle/BreakingItemParticle.java -@@ -14,7 +_,7 @@ - private final float uo; - private final float vo; - -- BreakingItemParticle( -+ protected BreakingItemParticle( - ClientLevel p_105646_, double p_105647_, double p_105648_, double p_105649_, double p_105650_, double p_105651_, double p_105652_, ItemStack p_105653_ - ) { - this(p_105646_, p_105647_, p_105648_, p_105649_, p_105653_); -@@ -33,7 +_,8 @@ +@@ -33,7 +_,7 @@ protected BreakingItemParticle(ClientLevel p_105665_, double p_105666_, double p_105667_, double p_105668_, ItemStack p_105669_) { super(p_105665_, p_105666_, p_105667_, p_105668_, 0.0, 0.0, 0.0); - this.setSprite(Minecraft.getInstance().getItemRenderer().getModel(p_105669_, p_105665_, null, 0).getParticleIcon()); -+ var model = Minecraft.getInstance().getItemRenderer().getModel(p_105669_, p_105665_, null, 0); -+ this.setSprite(model.getOverrides().resolve(model, p_105669_, p_105665_, null, 0).getParticleIcon(net.neoforged.neoforge.client.model.data.ModelData.EMPTY)); ++ this.setSprite(Minecraft.getInstance().getItemRenderer().getModel(p_105669_, p_105665_, null, 0).getParticleIcon(net.neoforged.neoforge.client.model.data.ModelData.EMPTY)); this.gravity = 1.0F; this.quadSize /= 2.0F; this.uo = this.random.nextFloat() * 3.0F; diff --git a/patches/net/minecraft/client/particle/BubbleColumnUpParticle.java.patch b/patches/net/minecraft/client/particle/BubbleColumnUpParticle.java.patch deleted file mode 100644 index dafcdba3..00000000 --- a/patches/net/minecraft/client/particle/BubbleColumnUpParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/BubbleColumnUpParticle.java -+++ b/net/minecraft/client/particle/BubbleColumnUpParticle.java -@@ -9,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class BubbleColumnUpParticle extends TextureSheetParticle { -- BubbleColumnUpParticle(ClientLevel p_105733_, double p_105734_, double p_105735_, double p_105736_, double p_105737_, double p_105738_, double p_105739_) { -+ protected BubbleColumnUpParticle(ClientLevel p_105733_, double p_105734_, double p_105735_, double p_105736_, double p_105737_, double p_105738_, double p_105739_) { - super(p_105733_, p_105734_, p_105735_, p_105736_); - this.gravity = -0.125F; - this.friction = 0.85F; diff --git a/patches/net/minecraft/client/particle/BubbleParticle.java.patch b/patches/net/minecraft/client/particle/BubbleParticle.java.patch deleted file mode 100644 index ec5402ed..00000000 --- a/patches/net/minecraft/client/particle/BubbleParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/BubbleParticle.java -+++ b/net/minecraft/client/particle/BubbleParticle.java -@@ -9,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class BubbleParticle extends TextureSheetParticle { -- BubbleParticle(ClientLevel p_105773_, double p_105774_, double p_105775_, double p_105776_, double p_105777_, double p_105778_, double p_105779_) { -+ protected BubbleParticle(ClientLevel p_105773_, double p_105774_, double p_105775_, double p_105776_, double p_105777_, double p_105778_, double p_105779_) { - super(p_105773_, p_105774_, p_105775_, p_105776_); - this.setSize(0.02F, 0.02F); - this.quadSize = this.quadSize * (this.random.nextFloat() * 0.6F + 0.2F); diff --git a/patches/net/minecraft/client/particle/BubblePopParticle.java.patch b/patches/net/minecraft/client/particle/BubblePopParticle.java.patch deleted file mode 100644 index e47c9f2a..00000000 --- a/patches/net/minecraft/client/particle/BubblePopParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/BubblePopParticle.java -+++ b/net/minecraft/client/particle/BubblePopParticle.java -@@ -9,7 +_,7 @@ - public class BubblePopParticle extends TextureSheetParticle { - private final SpriteSet sprites; - -- BubblePopParticle( -+ protected BubblePopParticle( - ClientLevel p_105814_, double p_105815_, double p_105816_, double p_105817_, double p_105818_, double p_105819_, double p_105820_, SpriteSet p_105821_ - ) { - super(p_105814_, p_105815_, p_105816_, p_105817_); diff --git a/patches/net/minecraft/client/particle/CampfireSmokeParticle.java.patch b/patches/net/minecraft/client/particle/CampfireSmokeParticle.java.patch deleted file mode 100644 index ce9b04f1..00000000 --- a/patches/net/minecraft/client/particle/CampfireSmokeParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/CampfireSmokeParticle.java -+++ b/net/minecraft/client/particle/CampfireSmokeParticle.java -@@ -7,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class CampfireSmokeParticle extends TextureSheetParticle { -- CampfireSmokeParticle( -+ protected CampfireSmokeParticle( - ClientLevel p_105856_, double p_105857_, double p_105858_, double p_105859_, double p_105860_, double p_105861_, double p_105862_, boolean p_105863_ - ) { - super(p_105856_, p_105857_, p_105858_, p_105859_); diff --git a/patches/net/minecraft/client/particle/CritParticle.java.patch b/patches/net/minecraft/client/particle/CritParticle.java.patch deleted file mode 100644 index be8f0636..00000000 --- a/patches/net/minecraft/client/particle/CritParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/CritParticle.java -+++ b/net/minecraft/client/particle/CritParticle.java -@@ -8,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class CritParticle extends TextureSheetParticle { -- CritParticle(ClientLevel p_105919_, double p_105920_, double p_105921_, double p_105922_, double p_105923_, double p_105924_, double p_105925_) { -+ protected CritParticle(ClientLevel p_105919_, double p_105920_, double p_105921_, double p_105922_, double p_105923_, double p_105924_, double p_105925_) { - super(p_105919_, p_105920_, p_105921_, p_105922_, 0.0, 0.0, 0.0); - this.friction = 0.7F; - this.gravity = 0.5F; diff --git a/patches/net/minecraft/client/particle/DragonBreathParticle.java.patch b/patches/net/minecraft/client/particle/DragonBreathParticle.java.patch deleted file mode 100644 index 1551156a..00000000 --- a/patches/net/minecraft/client/particle/DragonBreathParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/DragonBreathParticle.java -+++ b/net/minecraft/client/particle/DragonBreathParticle.java -@@ -19,7 +_,7 @@ - private boolean hasHitGround; - private final SpriteSet sprites; - -- DragonBreathParticle( -+ protected DragonBreathParticle( - ClientLevel p_106005_, double p_106006_, double p_106007_, double p_106008_, double p_106009_, double p_106010_, double p_106011_, SpriteSet p_106012_ - ) { - super(p_106005_, p_106006_, p_106007_, p_106008_); diff --git a/patches/net/minecraft/client/particle/DripParticle.java.patch b/patches/net/minecraft/client/particle/DripParticle.java.patch deleted file mode 100644 index ff566b5e..00000000 --- a/patches/net/minecraft/client/particle/DripParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/DripParticle.java -+++ b/net/minecraft/client/particle/DripParticle.java -@@ -20,7 +_,7 @@ - private final Fluid type; - protected boolean isGlowing; - -- DripParticle(ClientLevel p_106051_, double p_106052_, double p_106053_, double p_106054_, Fluid p_106055_) { -+ protected DripParticle(ClientLevel p_106051_, double p_106052_, double p_106053_, double p_106054_, Fluid p_106055_) { - super(p_106051_, p_106052_, p_106053_, p_106054_); - this.setSize(0.01F, 0.01F); - this.gravity = 0.06F; diff --git a/patches/net/minecraft/client/particle/EndRodParticle.java.patch b/patches/net/minecraft/client/particle/EndRodParticle.java.patch deleted file mode 100644 index edcac260..00000000 --- a/patches/net/minecraft/client/particle/EndRodParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/EndRodParticle.java -+++ b/net/minecraft/client/particle/EndRodParticle.java -@@ -7,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class EndRodParticle extends SimpleAnimatedParticle { -- EndRodParticle( -+ protected EndRodParticle( - ClientLevel p_106531_, double p_106532_, double p_106533_, double p_106534_, double p_106535_, double p_106536_, double p_106537_, SpriteSet p_106538_ - ) { - super(p_106531_, p_106532_, p_106533_, p_106534_, p_106538_, 0.0125F); diff --git a/patches/net/minecraft/client/particle/FallingDustParticle.java.patch b/patches/net/minecraft/client/particle/FallingDustParticle.java.patch deleted file mode 100644 index 42bd8450..00000000 --- a/patches/net/minecraft/client/particle/FallingDustParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/FallingDustParticle.java -+++ b/net/minecraft/client/particle/FallingDustParticle.java -@@ -17,7 +_,7 @@ - private final float rotSpeed; - private final SpriteSet sprites; - -- FallingDustParticle( -+ protected FallingDustParticle( - ClientLevel p_106610_, double p_106611_, double p_106612_, double p_106613_, float p_106614_, float p_106615_, float p_106616_, SpriteSet p_106617_ - ) { - super(p_106610_, p_106611_, p_106612_, p_106613_); diff --git a/patches/net/minecraft/client/particle/FireworkParticles.java.patch b/patches/net/minecraft/client/particle/FireworkParticles.java.patch index c40fed37..709c4d39 100644 --- a/patches/net/minecraft/client/particle/FireworkParticles.java.patch +++ b/patches/net/minecraft/client/particle/FireworkParticles.java.patch @@ -1,23 +1,5 @@ --- a/net/minecraft/client/particle/FireworkParticles.java +++ b/net/minecraft/client/particle/FireworkParticles.java -@@ -49,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public static class OverlayParticle extends TextureSheetParticle { -- OverlayParticle(ClientLevel p_106677_, double p_106678_, double p_106679_, double p_106680_) { -+ protected OverlayParticle(ClientLevel p_106677_, double p_106678_, double p_106679_, double p_106680_) { - super(p_106677_, p_106678_, p_106679_, p_106680_); - this.lifetime = 4; - } -@@ -81,7 +_,7 @@ - private float fadeB; - private boolean hasFade; - -- SparkParticle( -+ protected SparkParticle( - ClientLevel p_106702_, - double p_106703_, - double p_106704_, @@ -253,6 +_,10 @@ intlist = IntList.of(DyeColor.BLACK.getFireworkColor()); } diff --git a/patches/net/minecraft/client/particle/FlameParticle.java.patch b/patches/net/minecraft/client/particle/FlameParticle.java.patch deleted file mode 100644 index 0e4be06b..00000000 --- a/patches/net/minecraft/client/particle/FlameParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/FlameParticle.java -+++ b/net/minecraft/client/particle/FlameParticle.java -@@ -8,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class FlameParticle extends RisingParticle { -- FlameParticle(ClientLevel p_106800_, double p_106801_, double p_106802_, double p_106803_, double p_106804_, double p_106805_, double p_106806_) { -+ protected FlameParticle(ClientLevel p_106800_, double p_106801_, double p_106802_, double p_106803_, double p_106804_, double p_106805_, double p_106806_) { - super(p_106800_, p_106801_, p_106802_, p_106803_, p_106804_, p_106805_, p_106806_); - } - diff --git a/patches/net/minecraft/client/particle/FlyStraightTowardsParticle.java.patch b/patches/net/minecraft/client/particle/FlyStraightTowardsParticle.java.patch deleted file mode 100644 index e4fae4f0..00000000 --- a/patches/net/minecraft/client/particle/FlyStraightTowardsParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/FlyStraightTowardsParticle.java -+++ b/net/minecraft/client/particle/FlyStraightTowardsParticle.java -@@ -15,7 +_,7 @@ - private final int startColor; - private final int endColor; - -- FlyStraightTowardsParticle( -+ protected FlyStraightTowardsParticle( - ClientLevel p_338359_, - double p_338512_, - double p_338787_, diff --git a/patches/net/minecraft/client/particle/FlyTowardsPositionParticle.java.patch b/patches/net/minecraft/client/particle/FlyTowardsPositionParticle.java.patch deleted file mode 100644 index af5db3e4..00000000 --- a/patches/net/minecraft/client/particle/FlyTowardsPositionParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/FlyTowardsPositionParticle.java -+++ b/net/minecraft/client/particle/FlyTowardsPositionParticle.java -@@ -15,7 +_,7 @@ - private final boolean isGlowing; - private final Particle.LifetimeAlpha lifetimeAlpha; - -- FlyTowardsPositionParticle( -+ protected FlyTowardsPositionParticle( - ClientLevel p_323658_, double p_324523_, double p_324079_, double p_324377_, double p_324144_, double p_324286_, double p_323511_ - ) { - this(p_323658_, p_324523_, p_324079_, p_324377_, p_324144_, p_324286_, p_323511_, false, Particle.LifetimeAlpha.ALWAYS_OPAQUE); diff --git a/patches/net/minecraft/client/particle/GlowParticle.java.patch b/patches/net/minecraft/client/particle/GlowParticle.java.patch deleted file mode 100644 index f51e0b22..00000000 --- a/patches/net/minecraft/client/particle/GlowParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/GlowParticle.java -+++ b/net/minecraft/client/particle/GlowParticle.java -@@ -12,7 +_,7 @@ - static final RandomSource RANDOM = RandomSource.create(); - private final SpriteSet sprites; - -- GlowParticle( -+ protected GlowParticle( - ClientLevel p_172136_, double p_172137_, double p_172138_, double p_172139_, double p_172140_, double p_172141_, double p_172142_, SpriteSet p_172143_ - ) { - super(p_172136_, p_172137_, p_172138_, p_172139_, p_172140_, p_172141_, p_172142_); diff --git a/patches/net/minecraft/client/particle/GustSeedParticle.java.patch b/patches/net/minecraft/client/particle/GustSeedParticle.java.patch deleted file mode 100644 index 02dae0d1..00000000 --- a/patches/net/minecraft/client/particle/GustSeedParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/GustSeedParticle.java -+++ b/net/minecraft/client/particle/GustSeedParticle.java -@@ -11,7 +_,7 @@ - private final double scale; - private final int tickDelayInBetween; - -- GustSeedParticle(ClientLevel p_311842_, double p_312103_, double p_312358_, double p_312614_, double p_326153_, int p_326148_, int p_326155_) { -+ protected GustSeedParticle(ClientLevel p_311842_, double p_312103_, double p_312358_, double p_312614_, double p_326153_, int p_326148_, int p_326155_) { - super(p_311842_, p_312103_, p_312358_, p_312614_, 0.0, 0.0, 0.0); - this.scale = p_326153_; - this.lifetime = p_326148_; diff --git a/patches/net/minecraft/client/particle/HeartParticle.java.patch b/patches/net/minecraft/client/particle/HeartParticle.java.patch deleted file mode 100644 index 3cbd8fdd..00000000 --- a/patches/net/minecraft/client/particle/HeartParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/HeartParticle.java -+++ b/net/minecraft/client/particle/HeartParticle.java -@@ -8,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class HeartParticle extends TextureSheetParticle { -- HeartParticle(ClientLevel p_106847_, double p_106848_, double p_106849_, double p_106850_) { -+ protected HeartParticle(ClientLevel p_106847_, double p_106848_, double p_106849_, double p_106850_) { - super(p_106847_, p_106848_, p_106849_, p_106850_, 0.0, 0.0, 0.0); - this.speedUpWhenYMotionIsBlocked = true; - this.friction = 0.86F; diff --git a/patches/net/minecraft/client/particle/HugeExplosionSeedParticle.java.patch b/patches/net/minecraft/client/particle/HugeExplosionSeedParticle.java.patch deleted file mode 100644 index b002e941..00000000 --- a/patches/net/minecraft/client/particle/HugeExplosionSeedParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/HugeExplosionSeedParticle.java -+++ b/net/minecraft/client/particle/HugeExplosionSeedParticle.java -@@ -8,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class HugeExplosionSeedParticle extends NoRenderParticle { -- HugeExplosionSeedParticle(ClientLevel p_106947_, double p_106948_, double p_106949_, double p_106950_) { -+ protected HugeExplosionSeedParticle(ClientLevel p_106947_, double p_106948_, double p_106949_, double p_106950_) { - super(p_106947_, p_106948_, p_106949_, p_106950_, 0.0, 0.0, 0.0); - this.lifetime = 8; - } diff --git a/patches/net/minecraft/client/particle/ItemPickupParticle.java.patch b/patches/net/minecraft/client/particle/ItemPickupParticle.java.patch index b0309a1a..fbf0a1e7 100644 --- a/patches/net/minecraft/client/particle/ItemPickupParticle.java.patch +++ b/patches/net/minecraft/client/particle/ItemPickupParticle.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/particle/ItemPickupParticle.java +++ b/net/minecraft/client/particle/ItemPickupParticle.java -@@ -103,4 +_,11 @@ +@@ -102,4 +_,11 @@ this.targetYOld = this.targetY; this.targetZOld = this.targetZ; } diff --git a/patches/net/minecraft/client/particle/LavaParticle.java.patch b/patches/net/minecraft/client/particle/LavaParticle.java.patch deleted file mode 100644 index 201fe2c1..00000000 --- a/patches/net/minecraft/client/particle/LavaParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/LavaParticle.java -+++ b/net/minecraft/client/particle/LavaParticle.java -@@ -8,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class LavaParticle extends TextureSheetParticle { -- LavaParticle(ClientLevel p_107074_, double p_107075_, double p_107076_, double p_107077_) { -+ protected LavaParticle(ClientLevel p_107074_, double p_107075_, double p_107076_, double p_107077_) { - super(p_107074_, p_107075_, p_107076_, p_107077_, 0.0, 0.0, 0.0); - this.gravity = 0.75F; - this.friction = 0.999F; diff --git a/patches/net/minecraft/client/particle/MobAppearanceParticle.java.patch b/patches/net/minecraft/client/particle/MobAppearanceParticle.java.patch deleted file mode 100644 index 7c3dcd6d..00000000 --- a/patches/net/minecraft/client/particle/MobAppearanceParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/MobAppearanceParticle.java -+++ b/net/minecraft/client/particle/MobAppearanceParticle.java -@@ -24,7 +_,7 @@ - private final Model model; - private final RenderType renderType = RenderType.entityTranslucent(ElderGuardianRenderer.GUARDIAN_ELDER_LOCATION); - -- MobAppearanceParticle(ClientLevel p_107114_, double p_107115_, double p_107116_, double p_107117_) { -+ protected MobAppearanceParticle(ClientLevel p_107114_, double p_107115_, double p_107116_, double p_107117_) { - super(p_107114_, p_107115_, p_107116_, p_107117_); - this.model = new GuardianModel(Minecraft.getInstance().getEntityModels().bakeLayer(ModelLayers.ELDER_GUARDIAN)); - this.gravity = 0.0F; diff --git a/patches/net/minecraft/client/particle/NoteParticle.java.patch b/patches/net/minecraft/client/particle/NoteParticle.java.patch deleted file mode 100644 index d1c81e55..00000000 --- a/patches/net/minecraft/client/particle/NoteParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/NoteParticle.java -+++ b/net/minecraft/client/particle/NoteParticle.java -@@ -8,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class NoteParticle extends TextureSheetParticle { -- NoteParticle(ClientLevel p_107167_, double p_107168_, double p_107169_, double p_107170_, double p_107171_) { -+ protected NoteParticle(ClientLevel p_107167_, double p_107168_, double p_107169_, double p_107170_, double p_107171_) { - super(p_107167_, p_107168_, p_107169_, p_107170_, 0.0, 0.0, 0.0); - this.friction = 0.66F; - this.speedUpWhenYMotionIsBlocked = true; diff --git a/patches/net/minecraft/client/particle/ParticleEngine.java.patch b/patches/net/minecraft/client/particle/ParticleEngine.java.patch index ffbb1d28..de43669f 100644 --- a/patches/net/minecraft/client/particle/ParticleEngine.java.patch +++ b/patches/net/minecraft/client/particle/ParticleEngine.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/particle/ParticleEngine.java +++ b/net/minecraft/client/particle/ParticleEngine.java -@@ -81,11 +_,11 @@ - ParticleRenderType.CUSTOM +@@ -77,11 +_,11 @@ + ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT, ParticleRenderType.CUSTOM ); protected ClientLevel level; - private final Map> particles = Maps.newIdentityHashMap(); @@ -14,8 +14,8 @@ private final Queue particlesToAdd = Queues.newArrayDeque(); private final Map spriteSets = Maps.newHashMap(); private final TextureAtlas textureAtlas; -@@ -216,10 +_,14 @@ - this.register(ParticleTypes.OMINOUS_SPAWNING, FlyStraightTowardsParticle.OminousSpawnProvider::new); +@@ -214,10 +_,14 @@ + this.register(ParticleTypes.BLOCK_CRUMBLE, new TerrainParticle.CrumblingProvider()); } + /** @deprecated Register via {@link net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent} */ @@ -30,7 +30,7 @@ public void register(ParticleType p_273423_, ParticleProvider.Sprite p_273134_) { this.register( p_273423_, -@@ -236,10 +_,12 @@ +@@ -234,10 +_,12 @@ ); } @@ -44,7 +44,7 @@ } @Override -@@ -365,7 +_,7 @@ +@@ -357,7 +_,7 @@ private Particle makeParticle( T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_ ) { @@ -53,7 +53,7 @@ return particleprovider == null ? null : particleprovider.createParticle(p_107396_, this.level, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_); -@@ -441,11 +_,20 @@ +@@ -433,17 +_,27 @@ } } @@ -74,8 +74,7 @@ + if (particlerendertype == ParticleRenderType.NO_RENDER || !renderTypePredicate.test(particlerendertype)) continue; Queue queue = this.particles.get(particlerendertype); if (queue != null && !queue.isEmpty()) { - RenderSystem.setShader(GameRenderer::getParticleShader); -@@ -453,6 +_,7 @@ + Tesselator tesselator = Tesselator.getInstance(); BufferBuilder bufferbuilder = particlerendertype.begin(tesselator, this.textureManager); if (bufferbuilder != null) { for (Particle particle : queue) { @@ -83,7 +82,7 @@ try { particle.render(bufferbuilder, p_107340_, p_107341_); } catch (Throwable throwable) { -@@ -484,7 +_,7 @@ +@@ -475,7 +_,7 @@ } public void destroy(BlockPos p_107356_, BlockState p_107357_) { @@ -92,7 +91,7 @@ VoxelShape voxelshape = p_107357_.getShape(this.level, p_107356_); double d0 = 0.25; voxelshape.forAllBoxes( -@@ -516,7 +_,7 @@ +@@ -507,7 +_,7 @@ d6 - 0.5, p_107357_, p_107356_ @@ -101,7 +100,7 @@ ); } } -@@ -561,12 +_,28 @@ +@@ -552,12 +_,28 @@ d0 = (double)i + aabb.maxX + 0.1F; } diff --git a/patches/net/minecraft/client/particle/ParticleRenderType.java.patch b/patches/net/minecraft/client/particle/ParticleRenderType.java.patch index 4a648c99..e3d114e5 100644 --- a/patches/net/minecraft/client/particle/ParticleRenderType.java.patch +++ b/patches/net/minecraft/client/particle/ParticleRenderType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/particle/ParticleRenderType.java +++ b/net/minecraft/client/particle/ParticleRenderType.java -@@ -43,6 +_,11 @@ +@@ -44,6 +_,11 @@ public String toString() { return "PARTICLE_SHEET_OPAQUE"; } @@ -12,19 +12,7 @@ }; ParticleRenderType PARTICLE_SHEET_TRANSLUCENT = new ParticleRenderType() { @Override -@@ -72,6 +_,11 @@ - public String toString() { - return "PARTICLE_SHEET_LIT"; - } -+ -+ @Override -+ public boolean isTranslucent() { -+ return false; -+ } - }; - ParticleRenderType CUSTOM = new ParticleRenderType() { - @Override -@@ -101,4 +_,9 @@ +@@ -89,4 +_,9 @@ @Nullable BufferBuilder begin(Tesselator p_350949_, TextureManager p_107437_); diff --git a/patches/net/minecraft/client/particle/PlayerCloudParticle.java.patch b/patches/net/minecraft/client/particle/PlayerCloudParticle.java.patch deleted file mode 100644 index 3a49c31e..00000000 --- a/patches/net/minecraft/client/particle/PlayerCloudParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/PlayerCloudParticle.java -+++ b/net/minecraft/client/particle/PlayerCloudParticle.java -@@ -11,7 +_,7 @@ - public class PlayerCloudParticle extends TextureSheetParticle { - private final SpriteSet sprites; - -- PlayerCloudParticle( -+ protected PlayerCloudParticle( - ClientLevel p_107483_, double p_107484_, double p_107485_, double p_107486_, double p_107487_, double p_107488_, double p_107489_, SpriteSet p_107490_ - ) { - super(p_107483_, p_107484_, p_107485_, p_107486_, 0.0, 0.0, 0.0); diff --git a/patches/net/minecraft/client/particle/ReversePortalParticle.java.patch b/patches/net/minecraft/client/particle/ReversePortalParticle.java.patch index 28ca9c44..cfae8e80 100644 --- a/patches/net/minecraft/client/particle/ReversePortalParticle.java.patch +++ b/patches/net/minecraft/client/particle/ReversePortalParticle.java.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/client/particle/ReversePortalParticle.java +++ b/net/minecraft/client/particle/ReversePortalParticle.java -@@ -7,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class ReversePortalParticle extends PortalParticle { -- ReversePortalParticle(ClientLevel p_107590_, double p_107591_, double p_107592_, double p_107593_, double p_107594_, double p_107595_, double p_107596_) { -+ protected ReversePortalParticle(ClientLevel p_107590_, double p_107591_, double p_107592_, double p_107593_, double p_107594_, double p_107595_, double p_107596_) { - super(p_107590_, p_107591_, p_107592_, p_107593_, p_107594_, p_107595_, p_107596_); - this.quadSize *= 1.5F; - this.lifetime = (int)(Math.random() * 2.0) + 60; @@ -31,6 +_,7 @@ this.x = this.x + this.xd * (double)f; this.y = this.y + this.yd * (double)f; diff --git a/patches/net/minecraft/client/particle/SculkChargeParticle.java.patch b/patches/net/minecraft/client/particle/SculkChargeParticle.java.patch deleted file mode 100644 index 2b153db4..00000000 --- a/patches/net/minecraft/client/particle/SculkChargeParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/SculkChargeParticle.java -+++ b/net/minecraft/client/particle/SculkChargeParticle.java -@@ -9,7 +_,7 @@ - public class SculkChargeParticle extends TextureSheetParticle { - private final SpriteSet sprites; - -- SculkChargeParticle( -+ protected SculkChargeParticle( - ClientLevel p_233892_, double p_233893_, double p_233894_, double p_233895_, double p_233896_, double p_233897_, double p_233898_, SpriteSet p_233899_ - ) { - super(p_233892_, p_233893_, p_233894_, p_233895_, p_233896_, p_233897_, p_233898_); diff --git a/patches/net/minecraft/client/particle/SculkChargePopParticle.java.patch b/patches/net/minecraft/client/particle/SculkChargePopParticle.java.patch deleted file mode 100644 index 8d38eaa6..00000000 --- a/patches/net/minecraft/client/particle/SculkChargePopParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/SculkChargePopParticle.java -+++ b/net/minecraft/client/particle/SculkChargePopParticle.java -@@ -9,7 +_,7 @@ - public class SculkChargePopParticle extends TextureSheetParticle { - private final SpriteSet sprites; - -- SculkChargePopParticle( -+ protected SculkChargePopParticle( - ClientLevel p_233932_, double p_233933_, double p_233934_, double p_233935_, double p_233936_, double p_233937_, double p_233938_, SpriteSet p_233939_ - ) { - super(p_233932_, p_233933_, p_233934_, p_233935_, p_233936_, p_233937_, p_233938_); diff --git a/patches/net/minecraft/client/particle/ShriekParticle.java.patch b/patches/net/minecraft/client/particle/ShriekParticle.java.patch deleted file mode 100644 index 12c81175..00000000 --- a/patches/net/minecraft/client/particle/ShriekParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/ShriekParticle.java -+++ b/net/minecraft/client/particle/ShriekParticle.java -@@ -14,7 +_,7 @@ - private static final float MAGICAL_X_ROT = 1.0472F; - private int delay; - -- ShriekParticle(ClientLevel p_233976_, double p_233977_, double p_233978_, double p_233979_, int p_233980_) { -+ protected ShriekParticle(ClientLevel p_233976_, double p_233977_, double p_233978_, double p_233979_, int p_233980_) { - super(p_233976_, p_233977_, p_233978_, p_233979_, 0.0, 0.0, 0.0); - this.quadSize = 0.85F; - this.delay = p_233980_; diff --git a/patches/net/minecraft/client/particle/SoulParticle.java.patch b/patches/net/minecraft/client/particle/SoulParticle.java.patch deleted file mode 100644 index d03d965e..00000000 --- a/patches/net/minecraft/client/particle/SoulParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/SoulParticle.java -+++ b/net/minecraft/client/particle/SoulParticle.java -@@ -10,7 +_,7 @@ - private final SpriteSet sprites; - protected boolean isGlowing; - -- SoulParticle( -+ protected SoulParticle( - ClientLevel p_107717_, double p_107718_, double p_107719_, double p_107720_, double p_107721_, double p_107722_, double p_107723_, SpriteSet p_107724_ - ) { - super(p_107717_, p_107718_, p_107719_, p_107720_, p_107721_, p_107722_, p_107723_); diff --git a/patches/net/minecraft/client/particle/SpellParticle.java.patch b/patches/net/minecraft/client/particle/SpellParticle.java.patch deleted file mode 100644 index 8dd0e6bd..00000000 --- a/patches/net/minecraft/client/particle/SpellParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/SpellParticle.java -+++ b/net/minecraft/client/particle/SpellParticle.java -@@ -16,7 +_,7 @@ - private final SpriteSet sprites; - private float originalAlpha = 1.0F; - -- SpellParticle( -+ protected SpellParticle( - ClientLevel p_107762_, double p_107763_, double p_107764_, double p_107765_, double p_107766_, double p_107767_, double p_107768_, SpriteSet p_107769_ - ) { - super(p_107762_, p_107763_, p_107764_, p_107765_, 0.5 - RANDOM.nextDouble(), p_107767_, 0.5 - RANDOM.nextDouble()); diff --git a/patches/net/minecraft/client/particle/SpitParticle.java.patch b/patches/net/minecraft/client/particle/SpitParticle.java.patch deleted file mode 100644 index b6906be2..00000000 --- a/patches/net/minecraft/client/particle/SpitParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/SpitParticle.java -+++ b/net/minecraft/client/particle/SpitParticle.java -@@ -7,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class SpitParticle extends ExplodeParticle { -- SpitParticle( -+ protected SpitParticle( - ClientLevel p_107888_, double p_107889_, double p_107890_, double p_107891_, double p_107892_, double p_107893_, double p_107894_, SpriteSet p_107895_ - ) { - super(p_107888_, p_107889_, p_107890_, p_107891_, p_107892_, p_107893_, p_107894_, p_107895_); diff --git a/patches/net/minecraft/client/particle/SplashParticle.java.patch b/patches/net/minecraft/client/particle/SplashParticle.java.patch deleted file mode 100644 index adea6e75..00000000 --- a/patches/net/minecraft/client/particle/SplashParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/SplashParticle.java -+++ b/net/minecraft/client/particle/SplashParticle.java -@@ -7,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class SplashParticle extends WaterDropParticle { -- SplashParticle(ClientLevel p_107929_, double p_107930_, double p_107931_, double p_107932_, double p_107933_, double p_107934_, double p_107935_) { -+ protected SplashParticle(ClientLevel p_107929_, double p_107930_, double p_107931_, double p_107932_, double p_107933_, double p_107934_, double p_107935_) { - super(p_107929_, p_107930_, p_107931_, p_107932_); - this.gravity = 0.04F; - if (p_107934_ == 0.0 && (p_107933_ != 0.0 || p_107935_ != 0.0)) { diff --git a/patches/net/minecraft/client/particle/SquidInkParticle.java.patch b/patches/net/minecraft/client/particle/SquidInkParticle.java.patch deleted file mode 100644 index 048714e7..00000000 --- a/patches/net/minecraft/client/particle/SquidInkParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/SquidInkParticle.java -+++ b/net/minecraft/client/particle/SquidInkParticle.java -@@ -9,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class SquidInkParticle extends SimpleAnimatedParticle { -- SquidInkParticle( -+ protected SquidInkParticle( - ClientLevel p_172325_, - double p_172326_, - double p_172327_, diff --git a/patches/net/minecraft/client/particle/SuspendedParticle.java.patch b/patches/net/minecraft/client/particle/SuspendedParticle.java.patch deleted file mode 100644 index 40dbb2ea..00000000 --- a/patches/net/minecraft/client/particle/SuspendedParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/SuspendedParticle.java -+++ b/net/minecraft/client/particle/SuspendedParticle.java -@@ -11,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class SuspendedParticle extends TextureSheetParticle { -- SuspendedParticle(ClientLevel p_172403_, SpriteSet p_172404_, double p_172405_, double p_172406_, double p_172407_) { -+ protected SuspendedParticle(ClientLevel p_172403_, SpriteSet p_172404_, double p_172405_, double p_172406_, double p_172407_) { - super(p_172403_, p_172405_, p_172406_ - 0.125, p_172407_); - this.setSize(0.01F, 0.01F); - this.pickSprite(p_172404_); diff --git a/patches/net/minecraft/client/particle/SuspendedTownParticle.java.patch b/patches/net/minecraft/client/particle/SuspendedTownParticle.java.patch deleted file mode 100644 index 6d11e27b..00000000 --- a/patches/net/minecraft/client/particle/SuspendedTownParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/SuspendedTownParticle.java -+++ b/net/minecraft/client/particle/SuspendedTownParticle.java -@@ -7,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class SuspendedTownParticle extends TextureSheetParticle { -- SuspendedTownParticle(ClientLevel p_108104_, double p_108105_, double p_108106_, double p_108107_, double p_108108_, double p_108109_, double p_108110_) { -+ protected SuspendedTownParticle(ClientLevel p_108104_, double p_108105_, double p_108106_, double p_108107_, double p_108108_, double p_108109_, double p_108110_) { - super(p_108104_, p_108105_, p_108106_, p_108107_, p_108108_, p_108109_, p_108110_); - float f = this.random.nextFloat() * 0.1F + 0.2F; - this.rCol = f; diff --git a/patches/net/minecraft/client/particle/TotemParticle.java.patch b/patches/net/minecraft/client/particle/TotemParticle.java.patch deleted file mode 100644 index f0579cba..00000000 --- a/patches/net/minecraft/client/particle/TotemParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/TotemParticle.java -+++ b/net/minecraft/client/particle/TotemParticle.java -@@ -7,7 +_,7 @@ - - @OnlyIn(Dist.CLIENT) - public class TotemParticle extends SimpleAnimatedParticle { -- TotemParticle( -+ protected TotemParticle( - ClientLevel p_108346_, double p_108347_, double p_108348_, double p_108349_, double p_108350_, double p_108351_, double p_108352_, SpriteSet p_108353_ - ) { - super(p_108346_, p_108347_, p_108348_, p_108349_, p_108353_, 1.25F); diff --git a/patches/net/minecraft/client/particle/VibrationSignalParticle.java.patch b/patches/net/minecraft/client/particle/VibrationSignalParticle.java.patch index 8a8ddc04..05b6502a 100644 --- a/patches/net/minecraft/client/particle/VibrationSignalParticle.java.patch +++ b/patches/net/minecraft/client/particle/VibrationSignalParticle.java.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/client/particle/VibrationSignalParticle.java +++ b/net/minecraft/client/particle/VibrationSignalParticle.java -@@ -20,7 +_,7 @@ - private float pitch; - private float pitchO; - -- VibrationSignalParticle(ClientLevel p_234105_, double p_234106_, double p_234107_, double p_234108_, PositionSource p_234109_, int p_234110_) { -+ protected VibrationSignalParticle(ClientLevel p_234105_, double p_234106_, double p_234107_, double p_234108_, PositionSource p_234109_, int p_234110_) { - super(p_234105_, p_234106_, p_234107_, p_234108_, 0.0, 0.0, 0.0); - this.quadSize = 0.3F; - this.target = p_234109_; @@ -76,6 +_,7 @@ this.x = Mth.lerp(d0, this.x, vec3.x()); this.y = Mth.lerp(d0, this.y, vec3.y()); diff --git a/patches/net/minecraft/client/particle/WakeParticle.java.patch b/patches/net/minecraft/client/particle/WakeParticle.java.patch deleted file mode 100644 index d7c90c86..00000000 --- a/patches/net/minecraft/client/particle/WakeParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/WakeParticle.java -+++ b/net/minecraft/client/particle/WakeParticle.java -@@ -9,7 +_,7 @@ - public class WakeParticle extends TextureSheetParticle { - private final SpriteSet sprites; - -- WakeParticle( -+ protected WakeParticle( - ClientLevel p_108407_, double p_108408_, double p_108409_, double p_108410_, double p_108411_, double p_108412_, double p_108413_, SpriteSet p_108414_ - ) { - super(p_108407_, p_108408_, p_108409_, p_108410_, 0.0, 0.0, 0.0); diff --git a/patches/net/minecraft/client/particle/WaterCurrentDownParticle.java.patch b/patches/net/minecraft/client/particle/WaterCurrentDownParticle.java.patch deleted file mode 100644 index 649df2ff..00000000 --- a/patches/net/minecraft/client/particle/WaterCurrentDownParticle.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/particle/WaterCurrentDownParticle.java -+++ b/net/minecraft/client/particle/WaterCurrentDownParticle.java -@@ -12,7 +_,7 @@ - public class WaterCurrentDownParticle extends TextureSheetParticle { - private float angle; - -- WaterCurrentDownParticle(ClientLevel p_108450_, double p_108451_, double p_108452_, double p_108453_) { -+ protected WaterCurrentDownParticle(ClientLevel p_108450_, double p_108451_, double p_108452_, double p_108453_) { - super(p_108450_, p_108451_, p_108452_, p_108453_); - this.lifetime = (int)(Math.random() * 60.0) + 30; - this.hasPhysics = false; diff --git a/patches/net/minecraft/client/player/AbstractClientPlayer.java.patch b/patches/net/minecraft/client/player/AbstractClientPlayer.java.patch index 48705c04..6e8a8c55 100644 --- a/patches/net/minecraft/client/player/AbstractClientPlayer.java.patch +++ b/patches/net/minecraft/client/player/AbstractClientPlayer.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/player/AbstractClientPlayer.java +++ b/net/minecraft/client/player/AbstractClientPlayer.java -@@ -96,6 +_,6 @@ +@@ -91,6 +_,6 @@ } } -- return Mth.lerp(Minecraft.getInstance().options.fovEffectScale().get().floatValue(), 1.0F, f); -+ return net.neoforged.neoforge.client.ClientHooks.getFieldOfViewModifier(this, f); +- return Mth.lerp(p_366686_, 1.0F, f); ++ return net.neoforged.neoforge.client.ClientHooks.getFieldOfViewModifier(this, f, p_366686_); } } diff --git a/patches/net/minecraft/client/player/LocalPlayer.java.patch b/patches/net/minecraft/client/player/LocalPlayer.java.patch index 632b558e..d7721816 100644 --- a/patches/net/minecraft/client/player/LocalPlayer.java.patch +++ b/patches/net/minecraft/client/player/LocalPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/LocalPlayer.java +++ b/net/minecraft/client/player/LocalPlayer.java -@@ -297,6 +_,7 @@ +@@ -302,6 +_,7 @@ ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_108701_ ? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS : ServerboundPlayerActionPacket.Action.DROP_ITEM; @@ -8,7 +8,7 @@ ItemStack itemstack = this.getInventory().removeFromSelected(p_108701_); this.connection.send(new ServerboundPlayerActionPacket(serverboundplayeractionpacket$action, BlockPos.ZERO, Direction.DOWN)); return !itemstack.isEmpty(); -@@ -489,7 +_,14 @@ +@@ -482,7 +_,14 @@ @Override public void playSound(SoundEvent p_108651_, float p_108652_, float p_108653_) { @@ -24,7 +24,7 @@ } @Override -@@ -682,6 +_,7 @@ +@@ -676,6 +_,7 @@ && (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING)); float f = (float)this.getAttributeValue(Attributes.SNEAKING_SPEED); this.input.tick(this.isMovingSlowly(), f); @@ -32,7 +32,7 @@ this.minecraft.getTutorial().onInput(this.input); if (this.isUsingItem() && !this.isPassenger()) { this.input.leftImpulse *= 0.2F; -@@ -710,7 +_,7 @@ +@@ -704,7 +_,7 @@ boolean flag4 = this.canStartSprinting(); boolean flag5 = this.isPassenger() ? this.getVehicle().onGround() : this.onGround(); boolean flag6 = !flag1 && !flag2; @@ -41,7 +41,7 @@ if (this.sprintTriggerTime <= 0 && !this.minecraft.options.keySprint.isDown()) { this.sprintTriggerTime = 7; } else { -@@ -718,15 +_,15 @@ +@@ -712,15 +_,15 @@ } } @@ -55,12 +55,12 @@ - boolean flag8 = flag7 || this.horizontalCollision && !this.minorHorizontalCollision || this.isInWater() && !this.isUnderWater(); + boolean flag8 = flag7 || this.horizontalCollision && !this.minorHorizontalCollision || this.isInWater() && !this.isUnderWater() || (this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)) && !this.canStartSwimming()); if (this.isSwimming()) { -- if (!this.onGround() && !this.input.shiftKeyDown && flag7 || !this.isInWater()) { -+ if (!this.onGround() && !this.input.shiftKeyDown && flag7 || !(this.isInWater() || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)))) { +- if (!this.onGround() && !this.input.keyPresses.shift() && flag7 || !this.isInWater()) { ++ if (!this.onGround() && !this.input.keyPresses.shift() && flag7 || !(this.isInWater() || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)))) { this.setSprinting(false); } } else if (flag8) { -@@ -735,7 +_,7 @@ +@@ -729,7 +_,7 @@ } boolean flag9 = false; @@ -69,34 +69,18 @@ if (this.minecraft.gameMode.isAlwaysFlying()) { if (!abilities.flying) { abilities.flying = true; -@@ -760,14 +_,15 @@ - - if (this.input.jumping && !flag9 && !flag && !abilities.flying && !this.isPassenger() && !this.onClimbable()) { - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.CHEST); -- if (itemstack.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(itemstack) && this.tryToStartFallFlying()) { -+ if (itemstack.canElytraFly(this) && this.tryToStartFallFlying()) { - this.connection.send(new ServerboundPlayerCommandPacket(this, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING)); - } - } - - this.wasFallFlying = this.isFallFlying(); -- if (this.isInWater() && this.input.shiftKeyDown && this.isAffectedByFluids()) { -- this.goDownInWater(); -+ net.neoforged.neoforge.fluids.FluidType fluidType = this.getMaxHeightFluidType(); -+ if ((this.isInWater() || (!fluidType.isAir() && this.canSwimInFluidType(fluidType))) && this.input.shiftKeyDown && this.isAffectedByFluids()) { -+ this.sinkInFluid(this.isInWater() ? net.neoforged.neoforge.common.NeoForgeMod.WATER_TYPE.value() : fluidType); - } - - if (this.isEyeInFluid(FluidTags.WATER)) { -@@ -875,6 +_,7 @@ +@@ -866,6 +_,10 @@ @Override public void rideTick() { super.rideTick(); -+ if (this.wantsToStopRiding() && this.isPassenger()) this.input.shiftKeyDown = false; ++ if (this.wantsToStopRiding() && this.isPassenger()) { ++ Input input = this.input.keyPresses; ++ this.input.keyPresses = new Input(input.forward(), input.backward(), input.left(), input.right(), input.jump(), false, input.sprint()); ++ } this.handsBusy = false; - if (this.getControlledVehicle() instanceof Boat boat) { - boat.setInput(this.input.left, this.input.right, this.input.up, this.input.down); -@@ -1061,7 +_,7 @@ + if (this.getControlledVehicle() instanceof AbstractBoat abstractboat) { + abstractboat.setInput( +@@ -1063,7 +_,7 @@ } private boolean hasEnoughFoodToStartSprinting() { diff --git a/patches/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch b/patches/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch index 641642c1..285c14a5 100644 --- a/patches/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch +++ b/patches/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch @@ -9,7 +9,7 @@ private static final Object2ObjectMap EFFECTS = Util.make(new Object2ObjectArrayMap<>(), p_108881_ -> { DimensionSpecialEffects.OverworldEffects dimensionspecialeffects$overworldeffects = new DimensionSpecialEffects.OverworldEffects(); p_108881_.defaultReturnValue(dimensionspecialeffects$overworldeffects); -@@ -37,7 +_,7 @@ +@@ -36,7 +_,7 @@ } public static DimensionSpecialEffects forType(DimensionType p_108877_) { @@ -17,4 +17,4 @@ + return net.neoforged.neoforge.client.DimensionSpecialEffectsManager.getForType(p_108877_.effectsLocation()); } - @Nullable + public boolean isSunriseOrSunset(float p_365312_) { diff --git a/patches/net/minecraft/client/renderer/EffectInstance.java.patch b/patches/net/minecraft/client/renderer/EffectInstance.java.patch deleted file mode 100644 index 8ceff68f..00000000 --- a/patches/net/minecraft/client/renderer/EffectInstance.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/client/renderer/EffectInstance.java -+++ b/net/minecraft/client/renderer/EffectInstance.java -@@ -58,7 +_,8 @@ - private final EffectProgram fragmentProgram; - - public EffectInstance(ResourceProvider p_331011_, String p_108942_) throws IOException { -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("shaders/program/" + p_108942_ + ".json"); -+ ResourceLocation rl = ResourceLocation.tryParse(p_108942_); -+ ResourceLocation resourcelocation = ResourceLocation.fromNamespaceAndPath(rl.getNamespace(), "shaders/program/" + rl.getPath() + ".json"); - this.name = p_108942_; - Resource resource = p_331011_.getResourceOrThrow(resourcelocation); - -@@ -150,7 +_,8 @@ - } else { - EffectProgram effectprogram; - if (program == null) { -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("shaders/program/" + p_172569_ + p_172568_.getExtension()); -+ ResourceLocation rl = ResourceLocation.tryParse(p_172569_); -+ ResourceLocation resourcelocation = ResourceLocation.fromNamespaceAndPath(rl.getNamespace(), "shaders/program/" + rl.getPath() + p_172568_.getExtension()); - Resource resource = p_330579_.getResourceOrThrow(resourcelocation); - - try (InputStream inputstream = resource.open()) { diff --git a/patches/net/minecraft/client/renderer/FogRenderer.java.patch b/patches/net/minecraft/client/renderer/FogRenderer.java.patch index 25aa2799..f2443a83 100644 --- a/patches/net/minecraft/client/renderer/FogRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/FogRenderer.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/client/renderer/FogRenderer.java +++ b/net/minecraft/client/renderer/FogRenderer.java -@@ -197,6 +_,12 @@ - fogBlue = fogBlue * (1.0F - f7) + fogBlue * f9 * f7; +@@ -196,7 +_,7 @@ + f2 = f2 * (1.0F - f10) + f2 * f12 * f10; } -+ Vector3f fogColor = net.neoforged.neoforge.client.ClientHooks.getFogColor(p_109019_, p_109020_, p_109021_, p_109022_, p_109023_, fogRed, fogGreen, fogBlue); -+ -+ fogRed = fogColor.x(); -+ fogGreen = fogColor.y(); -+ fogBlue = fogColor.z(); -+ - RenderSystem.clearColor(fogRed, fogGreen, fogBlue, 0.0F); +- return new Vector4f(f, f1, f2, 1.0F); ++ return net.neoforged.neoforge.client.ClientHooks.getFogColor(p_363451_, p_364931_, p_363033_, p_363851_, p_363957_, f, f1, f2); } -@@ -273,6 +_,7 @@ - RenderSystem.setShaderFogStart(fogrenderer$fogdata.start); - RenderSystem.setShaderFogEnd(fogrenderer$fogdata.end); - RenderSystem.setShaderFogShape(fogrenderer$fogdata.shape); -+ net.neoforged.neoforge.client.ClientHooks.onFogRender(p_234174_, fogtype, p_234173_, p_234177_, p_234175_, fogrenderer$fogdata.start, fogrenderer$fogdata.end, fogrenderer$fogdata.shape); + public static boolean toggleFog() { +@@ -274,9 +_,9 @@ + fogrenderer$fogdata.shape = FogShape.CYLINDER; + } + +- return new FogParameters( ++ return net.neoforged.neoforge.client.ClientHooks.onFogRender(p_234174_, fogtype, p_234173_, p_234177_, p_234175_, new FogParameters( + fogrenderer$fogdata.start, fogrenderer$fogdata.end, fogrenderer$fogdata.shape, p_365467_.x, p_365467_.y, p_365467_.z, p_365467_.w +- ); ++ )); + } } - public static void levelFogColor() { diff --git a/patches/net/minecraft/client/renderer/GameRenderer.java.patch b/patches/net/minecraft/client/renderer/GameRenderer.java.patch index 7d1c353a..db82c7ec 100644 --- a/patches/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/GameRenderer.java.patch @@ -1,32 +1,24 @@ --- a/net/minecraft/client/renderer/GameRenderer.java +++ b/net/minecraft/client/renderer/GameRenderer.java -@@ -311,6 +_,8 @@ - this.loadEffect(ResourceLocation.withDefaultNamespace("shaders/post/spider.json")); +@@ -158,6 +_,8 @@ + this.setPostEffect(ResourceLocation.withDefaultNamespace("spider")); } else if (p_109107_ instanceof EnderMan) { - this.loadEffect(ResourceLocation.withDefaultNamespace("shaders/post/invert.json")); + this.setPostEffect(ResourceLocation.withDefaultNamespace("invert")); + } else { + net.neoforged.neoforge.client.ClientHooks.loadEntityShader(p_109107_, this); } } -@@ -714,6 +_,7 @@ - ) - ); - this.loadBlurEffect(p_250719_); -+ net.neoforged.fml.ModLoader.postEvent(new net.neoforged.neoforge.client.event.RegisterShadersEvent(p_250719_, list1)); - } catch (IOException ioexception) { - list1.forEach(p_172729_ -> p_172729_.getFirst().close()); - throw new RuntimeException("could not reload shaders", ioexception); -@@ -872,7 +_,7 @@ - d0 *= Mth.lerp(this.minecraft.options.fovEffectScale().get(), 1.0, 0.85714287F); +@@ -312,7 +_,7 @@ + f *= Mth.lerp(f2, 1.0F, 0.85714287F); } -- return d0; -+ return net.neoforged.neoforge.client.ClientHooks.getFieldOfView(this, p_109142_, p_109143_, d0, p_109144_); +- return f; ++ return net.neoforged.neoforge.client.ClientHooks.getFieldOfView(this, p_109142_, p_109143_, f, p_109144_); } } -@@ -888,6 +_,10 @@ +@@ -328,6 +_,10 @@ return; } @@ -37,48 +29,37 @@ f2 /= (float)livingentity.hurtDuration; f2 = Mth.sin(f2 * f2 * f2 * f2 * (float) Math.PI); float f3 = livingentity.getHurtDir(); -@@ -1036,12 +_,12 @@ +@@ -474,12 +_,12 @@ (float)((double)window.getHeight() / window.getGuiScale()), 0.0F, 1000.0F, - 21000.0F + net.neoforged.neoforge.client.ClientHooks.getGuiFarPlane() ); - RenderSystem.setProjectionMatrix(matrix4f, VertexSorting.ORTHOGRAPHIC_Z); + RenderSystem.setProjectionMatrix(matrix4f, ProjectionType.ORTHOGRAPHIC); Matrix4fStack matrix4fstack = RenderSystem.getModelViewStack(); matrix4fstack.pushMatrix(); - matrix4fstack.translation(0.0F, 0.0F, -11000.0F); + matrix4fstack.translation(0.0F, 0.0F, 10000F - net.neoforged.neoforge.client.ClientHooks.getGuiFarPlane()); - RenderSystem.applyModelViewMatrix(); Lighting.setupFor3DItems(); GuiGraphics guigraphics = new GuiGraphics(this.minecraft, this.renderBuffers.bufferSource()); -@@ -1070,7 +_,8 @@ - - if (this.minecraft.getOverlay() != null) { - try { -- this.minecraft.getOverlay().render(guigraphics, i, j, p_348648_.getRealtimeDeltaTicks()); -+ // Neo: Fix https://bugs.mojang.com/browse/MC-273464 -+ this.minecraft.getOverlay().render(guigraphics, i, j, p_348648_.getGameTimeDeltaPartialTick(false)); - } catch (Throwable throwable2) { - CrashReport crashreport = CrashReport.forThrowable(throwable2, "Rendering overlay"); - CrashReportCategory crashreportcategory = crashreport.addCategory("Overlay render details"); -@@ -1079,7 +_,9 @@ + if (flag && p_109096_ && this.minecraft.level != null) { +@@ -505,7 +_,8 @@ } } else if (flag && this.minecraft.screen != null) { try { -- this.minecraft.screen.renderWithTooltip(guigraphics, i, j, p_348648_.getRealtimeDeltaTicks()); +- this.minecraft.screen.renderWithTooltip(guigraphics, i, j, p_348648_.getGameTimeDeltaTicks()); + // Neo: Wrap Screen#render to allow for GUI Layers and ScreenEvent.Render.[Pre/Post] -+ // Also fixes https://bugs.mojang.com/browse/MC-273464 -+ net.neoforged.neoforge.client.ClientHooks.drawScreen(this.minecraft.screen, guigraphics, i, j, p_348648_.getGameTimeDeltaPartialTick(false)); ++ net.neoforged.neoforge.client.ClientHooks.drawScreen(this.minecraft.screen, guigraphics, i, j, p_348648_.getGameTimeDeltaTicks()); } catch (Throwable throwable1) { CrashReport crashreport1 = CrashReport.forThrowable(throwable1, "Rendering screen"); CrashReportCategory crashreportcategory1 = crashreport1.addCategory("Screen render details"); -@@ -1259,6 +_,8 @@ - .levelRenderer - .prepareCullFrustum(camera.getPosition(), matrix4f1, this.getProjectionMatrix(Math.max(d0, (double)this.minecraft.options.fov().get().intValue()))); - this.minecraft.levelRenderer.renderLevel(p_348589_, flag, camera, this, this.lightTexture, matrix4f1, matrix4f); -+ this.minecraft.getProfiler().popPush("neoforge_render_last"); +@@ -687,6 +_,8 @@ + this.minecraft.levelRenderer.prepareCullFrustum(camera.getPosition(), matrix4f2, matrix4f1); + this.minecraft.getMainRenderTarget().bindWrite(true); + this.minecraft.levelRenderer.renderLevel(this.resourcePool, p_348589_, flag, camera, this, this.lightTexture, matrix4f2, matrix4f); ++ profilerfiller.popPush("neoforge_render_last"); + net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_LEVEL, this.minecraft.levelRenderer, null, matrix4f1, matrix4f, this.minecraft.levelRenderer.getTicks(), camera, this.minecraft.levelRenderer.getFrustum()); - this.minecraft.getProfiler().popPush("hand"); + profilerfiller.popPush("hand"); if (this.renderHand) { - RenderSystem.clear(256, Minecraft.ON_OSX); + RenderSystem.clear(256); diff --git a/patches/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch b/patches/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch index d66d2a4c..1bf5aead 100644 --- a/patches/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch +++ b/patches/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/client/renderer/ItemBlockRenderTypes.java +++ b/net/minecraft/client/renderer/ItemBlockRenderTypes.java -@@ -20,6 +_,7 @@ +@@ -18,6 +_,7 @@ @OnlyIn(Dist.CLIENT) public class ItemBlockRenderTypes { + @Deprecated - private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_353020_ -> { + private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_378824_ -> { RenderType rendertype = RenderType.tripwire(); - p_353020_.put(Blocks.TRIPWIRE, rendertype); -@@ -335,6 +_,7 @@ - p_353020_.put(Blocks.BUBBLE_COLUMN, rendertype3); - p_353020_.put(Blocks.TINTED_GLASS, rendertype3); + p_378824_.put(Blocks.TRIPWIRE, rendertype); +@@ -340,6 +_,7 @@ + p_378824_.put(Blocks.BUBBLE_COLUMN, rendertype3); + p_378824_.put(Blocks.TINTED_GLASS, rendertype3); }); + @Deprecated private static final Map TYPE_BY_FLUID = Util.make(Maps.newHashMap(), p_109290_ -> { RenderType rendertype = RenderType.translucent(); p_109290_.put(Fluids.FLOWING_WATER, rendertype); -@@ -342,6 +_,8 @@ +@@ -347,6 +_,8 @@ }); private static boolean renderCutout; @@ -25,7 +25,7 @@ public static RenderType getChunkRenderType(BlockState p_109283_) { Block block = p_109283_.getBlock(); if (block instanceof LeavesBlock) { -@@ -352,6 +_,8 @@ +@@ -357,6 +_,8 @@ } } @@ -34,25 +34,23 @@ public static RenderType getMovingBlockRenderType(BlockState p_109294_) { Block block = p_109294_.getBlock(); if (block instanceof LeavesBlock) { -@@ -366,6 +_,8 @@ +@@ -371,11 +_,15 @@ } } -+ /** @deprecated Forge: Use {@link net.neoforged.neoforge.client.RenderTypeHelper#getEntityRenderType(RenderType, boolean)} while iterating through {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.neoforged.neoforge.client.model.data.ModelData)}. */ ++ /** @deprecated Forge: Use {@link net.neoforged.neoforge.client.RenderTypeHelper#getEntityRenderType(RenderType)} while iterating through {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.neoforged.neoforge.client.model.data.ModelData)}. */ + @Deprecated // Note: this method does NOT support model-based render types - public static RenderType getRenderType(BlockState p_109285_, boolean p_109286_) { - RenderType rendertype = getChunkRenderType(p_109285_); - if (rendertype == RenderType.translucent()) { -@@ -379,6 +_,8 @@ - } + public static RenderType getRenderType(BlockState p_366653_) { + RenderType rendertype = getChunkRenderType(p_366653_); + return rendertype == RenderType.translucent() ? Sheets.translucentItemSheet() : Sheets.cutoutBlockSheet(); } -+ /** @deprecated Forge: Use {@link net.minecraft.client.resources.model.BakedModel#getRenderPasses(ItemStack, boolean)} and {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(ItemStack, boolean)}. */ ++ /** @deprecated Forge: Use {@link net.minecraft.client.resources.model.BakedModel#getRenderPasses(ItemStack)} and {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(ItemStack)}. */ + @Deprecated // Note: this method does NOT support model-based render types - public static RenderType getRenderType(ItemStack p_109280_, boolean p_109281_) { - Item item = p_109280_.getItem(); - if (item instanceof BlockItem) { -@@ -396,5 +_,78 @@ + public static RenderType getRenderType(ItemStack p_366701_) { + if (p_366701_.getItem() instanceof BlockItem blockitem) { + Block block = blockitem.getBlock(); +@@ -392,5 +_,78 @@ public static void setFancy(boolean p_109292_) { renderCutout = p_109292_; diff --git a/patches/net/minecraft/client/renderer/ItemInHandRenderer.java.patch b/patches/net/minecraft/client/renderer/ItemInHandRenderer.java.patch index 8497dbd1..50e02aa5 100644 --- a/patches/net/minecraft/client/renderer/ItemInHandRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/ItemInHandRenderer.java.patch @@ -1,6 +1,20 @@ --- a/net/minecraft/client/renderer/ItemInHandRenderer.java +++ b/net/minecraft/client/renderer/ItemInHandRenderer.java -@@ -226,7 +_,7 @@ +@@ -168,11 +_,11 @@ + ResourceLocation resourcelocation = this.minecraft.player.getSkin().texture(); + if (p_109365_ == HumanoidArm.RIGHT) { + playerrenderer.renderRightHand( +- p_109362_, p_109363_, p_109364_, resourcelocation, this.minecraft.player.isModelPartShown(PlayerModelPart.RIGHT_SLEEVE) ++ p_109362_, p_109363_, p_109364_, resourcelocation, this.minecraft.player.isModelPartShown(PlayerModelPart.RIGHT_SLEEVE), this.minecraft.player + ); + } else { + playerrenderer.renderLeftHand( +- p_109362_, p_109363_, p_109364_, resourcelocation, this.minecraft.player.isModelPartShown(PlayerModelPart.LEFT_SLEEVE) ++ p_109362_, p_109363_, p_109364_, resourcelocation, this.minecraft.player.isModelPartShown(PlayerModelPart.LEFT_SLEEVE), this.minecraft.player + ); + } + +@@ -234,7 +_,7 @@ p_109367_.translate(-0.5F, -0.5F, 0.0F); p_109367_.scale(0.0078125F, 0.0078125F, 0.0078125F); MapId mapid = p_109370_.get(DataComponents.MAP_ID); @@ -9,7 +23,20 @@ VertexConsumer vertexconsumer = p_109368_.getBuffer(mapitemsaveddata == null ? MAP_BACKGROUND : MAP_BACKGROUND_CHECKERBOARD); Matrix4f matrix4f = p_109367_.last().pose(); vertexconsumer.addVertex(matrix4f, -7.0F, 135.0F, 0.0F).setColor(-1).setUv(0.0F, 1.0F).setLight(p_109369_); -@@ -334,12 +_,14 @@ +@@ -271,10 +_,10 @@ + ResourceLocation resourcelocation = abstractclientplayer.getSkin().texture(); + if (flag) { + playerrenderer.renderRightHand( +- p_109347_, p_109348_, p_109349_, resourcelocation, abstractclientplayer.isModelPartShown(PlayerModelPart.RIGHT_SLEEVE) ++ p_109347_, p_109348_, p_109349_, resourcelocation, abstractclientplayer.isModelPartShown(PlayerModelPart.RIGHT_SLEEVE), abstractclientplayer + ); + } else { +- playerrenderer.renderLeftHand(p_109347_, p_109348_, p_109349_, resourcelocation, abstractclientplayer.isModelPartShown(PlayerModelPart.LEFT_SLEEVE)); ++ playerrenderer.renderLeftHand(p_109347_, p_109348_, p_109349_, resourcelocation, abstractclientplayer.isModelPartShown(PlayerModelPart.LEFT_SLEEVE), abstractclientplayer); + } + } + +@@ -347,12 +_,14 @@ if (iteminhandrenderer$handrenderselection.renderMainHand) { float f4 = interactionhand == InteractionHand.MAIN_HAND ? f : 0.0F; float f5 = 1.0F - Mth.lerp(p_109315_, this.oMainHandHeight, this.mainHandHeight); @@ -24,11 +51,11 @@ this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.offHandItem, f7, p_109316_, p_109317_, p_109319_); } -@@ -399,13 +_,13 @@ +@@ -412,13 +_,13 @@ if (flag && !p_109372_.isInvisible()) { this.renderPlayerArm(p_109379_, p_109380_, p_109381_, p_109378_, p_109376_, humanoidarm); } -- } else if (p_109377_.is(Items.FILLED_MAP)) { +- } else if (p_109377_.has(DataComponents.MAP_ID)) { + } else if (p_109377_.getItem() instanceof MapItem) { if (flag && this.offHandItem.isEmpty()) { this.renderTwoHandedMap(p_109379_, p_109380_, p_109381_, p_109374_, p_109378_, p_109376_); @@ -40,7 +67,7 @@ boolean flag1 = CrossbowItem.isCharged(p_109377_); boolean flag2 = humanoidarm == HumanoidArm.RIGHT; int i = flag2 ? 1 : -1; -@@ -455,6 +_,7 @@ +@@ -468,6 +_,7 @@ ); } else { boolean flag3 = humanoidarm == HumanoidArm.RIGHT; @@ -48,7 +75,7 @@ if (p_109372_.isUsingItem() && p_109372_.getUseItemRemainingTicks() > 0 && p_109372_.getUsedItemHand() == p_109375_) { int k = flag3 ? 1 : -1; switch (p_109377_.getUseAnimation()) { -@@ -569,8 +_,16 @@ +@@ -582,8 +_,16 @@ this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F); } else { float f = localplayer.getAttackStrengthScale(1.0F); diff --git a/patches/net/minecraft/client/renderer/LevelEventHandler.java.patch b/patches/net/minecraft/client/renderer/LevelEventHandler.java.patch new file mode 100644 index 00000000..9babaa65 --- /dev/null +++ b/patches/net/minecraft/client/renderer/LevelEventHandler.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/client/renderer/LevelEventHandler.java ++++ b/net/minecraft/client/renderer/LevelEventHandler.java +@@ -435,8 +_,8 @@ + break; + case 2001: + BlockState blockstate1 = Block.stateById(p_360434_); +- if (!blockstate1.isAir()) { +- SoundType soundtype = blockstate1.getSoundType(); ++ if (!blockstate1.isAir() && !net.neoforged.neoforge.client.extensions.common.IClientBlockExtensions.of(blockstate1).playBreakSound(blockstate1, this.level, p_362181_)) { ++ SoundType soundtype = blockstate1.getSoundType(this.level, p_362181_, null); + this.level + .playLocalSound( + p_362181_, soundtype.getBreakSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F, false diff --git a/patches/net/minecraft/client/renderer/LevelRenderer.java.patch b/patches/net/minecraft/client/renderer/LevelRenderer.java.patch index 82e084e8..f5f9a14c 100644 --- a/patches/net/minecraft/client/renderer/LevelRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -1,229 +1,241 @@ --- a/net/minecraft/client/renderer/LevelRenderer.java +++ b/net/minecraft/client/renderer/LevelRenderer.java -@@ -233,6 +_,10 @@ - private int rainSoundTime; - private final float[] rainSizeX = new float[1024]; - private final float[] rainSizeZ = new float[1024]; +@@ -485,7 +_,7 @@ + RenderSystem.clear(16640); + }); + if (!flag1) { +- this.addSkyPass(framegraphbuilder, p_109604_, f, fogparameters1); ++ this.addSkyPass(framegraphbuilder, p_109604_, f, fogparameters1, p_254120_, p_323920_); + } + + this.addMainPass(framegraphbuilder, frustum, p_109604_, p_254120_, p_323920_, fogparameters, p_109603_, flag2, p_348530_, profilerfiller); +@@ -494,7 +_,7 @@ + postchain1.addToFrame(framegraphbuilder, i, j, this.targets); + } + +- this.addParticlesPass(framegraphbuilder, p_109604_, p_109606_, f, fogparameters); ++ this.addParticlesPass(framegraphbuilder, p_109604_, p_109606_, f, fogparameters, frustum, p_254120_, p_323920_); + CloudStatus cloudstatus = this.minecraft.options.getCloudsType(); + if (cloudstatus != CloudStatus.OFF) { + float f2 = this.level.effects().getCloudHeight(); +@@ -505,7 +_,7 @@ + } + } + +- this.addWeatherPass(framegraphbuilder, p_109606_, p_109604_.getPosition(), f, fogparameters); ++ this.addWeatherPass(framegraphbuilder, p_109606_, p_109604_.getPosition(), f, fogparameters, p_254120_, p_323920_, p_109604_); + if (postchain != null) { + postchain.addToFrame(framegraphbuilder, i, j, this.targets); + } +@@ -576,7 +_,9 @@ + double d2 = vec3.z(); + p_362234_.push("terrain"); + this.renderSectionLayer(RenderType.solid(), d0, d1, d2, p_362420_, p_361272_); ++ this.minecraft.getModelManager().getAtlas(net.minecraft.client.renderer.texture.TextureAtlas.LOCATION_BLOCKS).setBlurMipmap(false, this.minecraft.options.mipmapLevels().get() > 0); // Neo: fix flickering leaves when mods mess up the blurMipmap settings + this.renderSectionLayer(RenderType.cutoutMipped(), d0, d1, d2, p_362420_, p_361272_); ++ this.minecraft.getModelManager().getAtlas(net.minecraft.client.renderer.texture.TextureAtlas.LOCATION_BLOCKS).restoreLastBlurMipmap(); + this.renderSectionLayer(RenderType.cutout(), d0, d1, d2, p_362420_, p_361272_); + if (this.level.effects().constantAmbientLight()) { + Lighting.setupNetherLevel(); +@@ -608,6 +_,7 @@ + p_362234_.popPush("entities"); + this.renderEntities(posestack, multibuffersource$buffersource, p_363453_, p_360931_, this.visibleEntities); + multibuffersource$buffersource.endLastBatch(); ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_ENTITIES, this, posestack, p_362420_, p_361272_, this.ticks, p_363453_, p_366590_); + this.checkPoseStack(posestack); + p_362234_.popPush("blockentities"); + this.renderBlockEntities(posestack, multibuffersource$buffersource, multibuffersource$buffersource1, p_363453_, f); +@@ -624,6 +_,7 @@ + multibuffersource$buffersource.endBatch(Sheets.hangingSignSheet()); + multibuffersource$buffersource.endBatch(Sheets.chestSheet()); + this.renderBuffers.outlineBufferSource().endOutlineBatch(); ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_BLOCK_ENTITIES, this, posestack, p_362420_, p_361272_, this.ticks, p_363453_, p_366590_); + if (p_363964_) { + this.renderBlockOutline(p_363453_, multibuffersource$buffersource, posestack, false); + } +@@ -644,6 +_,11 @@ + multibuffersource$buffersource1.endBatch(); + this.checkPoseStack(posestack); + multibuffersource$buffersource.endBatch(RenderType.waterMask()); ++ // Neo: in Fast/Fancy, render solid particles before translucent geometry so they don't disappear underwater (MC-161917) ++ if (this.targets.particles == null) { ++ p_362234_.popPush("solid_particles"); ++ this.minecraft.particleEngine.render(this.minecraft.gameRenderer.lightTexture(), p_363453_, f, p_366590_, type -> !type.isTranslucent()); ++ } + multibuffersource$buffersource.endBatch(); + if (resourcehandle1 != null) { + resourcehandle1.get().setClearColor(0.0F, 0.0F, 0.0F, 0.0F); +@@ -664,7 +_,15 @@ + }); + } + + /** -+ * Neo: Indicates whether outline effect post-processing was requested for the current frame outside of vanilla codepaths ++ * @deprecated Neo: use {@link #addParticlesPass(FrameGraphBuilder, Camera, LightTexture, float, FogParameters, Frustum, Matrix4f, Matrix4f)} instead + */ -+ private boolean outlineEffectRequested = false; ++ @Deprecated + private void addParticlesPass(FrameGraphBuilder p_363357_, Camera p_365299_, LightTexture p_364308_, float p_364282_, FogParameters p_362149_) { ++ addParticlesPass(p_363357_, p_365299_, p_364308_, p_364282_, p_362149_, this.capturedFrustum != null ? this.capturedFrustum : this.cullingFrustum, RenderSystem.getModelViewMatrix(), RenderSystem.getProjectionMatrix()); ++ } ++ ++ private void addParticlesPass(FrameGraphBuilder p_363357_, Camera p_365299_, LightTexture p_364308_, float p_364282_, FogParameters p_362149_, Frustum frustum, Matrix4f modelViewMatrix, Matrix4f projectionMatrix) { + FramePass framepass = p_363357_.addPass("particles"); + if (this.targets.particles != null) { + this.targets.particles = framepass.readsAndWrites(this.targets.particles); +@@ -684,7 +_,8 @@ + } - public LevelRenderer(Minecraft p_234245_, EntityRenderDispatcher p_234246_, BlockEntityRenderDispatcher p_234247_, RenderBuffers p_234248_) { - this.minecraft = p_234245_; -@@ -256,6 +_,8 @@ + RenderStateShard.PARTICLES_TARGET.setupRenderState(); +- this.minecraft.particleEngine.render(p_364308_, p_365299_, p_364282_); ++ this.minecraft.particleEngine.render(p_364308_, p_365299_, p_364282_, frustum, resourcehandle1 == null ? type -> type.isTranslucent() : type -> true); // Neo: only render translucent particles here in Fast/Fancy ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, null, modelViewMatrix, projectionMatrix, this.ticks, p_365299_, getFrustum()); + RenderStateShard.PARTICLES_TARGET.clearRenderState(); + }); } +@@ -713,11 +_,20 @@ + resourcehandle.get().clear(); + } - private void renderSnowAndRain(LightTexture p_109704_, float p_109705_, double p_109706_, double p_109707_, double p_109708_) { -+ if (level.effects().renderSnowAndRain(level, ticks, p_109705_, p_109704_, p_109706_, p_109707_, p_109708_)) -+ return; - float f = this.minecraft.level.getRainLevel(p_109705_); - if (!(f <= 0.0F)) { - p_109704_.turnOnLightLayer(); -@@ -418,6 +_,8 @@ ++ if (!level.effects().renderClouds(level, ticks, p_365209_, p_362985_.x, p_362985_.y, p_362985_.z, p_362864_, p_360602_)) + this.cloudRenderer.render(p_362342_, p_364196_, p_362337_, p_362864_, p_360602_, p_362985_, p_365209_); + }); } - public void tickRain(Camera p_109694_) { -+ if (level.effects().tickRain(level, ticks, p_109694_)) -+ return; - float f = this.minecraft.level.getRainLevel(1.0F) / (Minecraft.useFancyGraphics() ? 1.0F : 2.0F); - if (!(f <= 0.0F)) { - RandomSource randomsource = RandomSource.create((long)this.ticks * 312987231L); -@@ -942,9 +_,11 @@ - RenderSystem.clear(16640, Minecraft.ON_OSX); - float f1 = p_109605_.getRenderDistance(); - boolean flag1 = this.minecraft.level.effects().isFoggyAt(Mth.floor(d0), Mth.floor(d1)) || this.minecraft.gui.getBossOverlay().shouldCreateWorldFog(); -+ FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f1, flag1, f); - profilerfiller.popPush("sky"); - RenderSystem.setShader(GameRenderer::getPositionShader); - this.renderSky(p_254120_, p_323920_, f, p_109604_, flag1, () -> FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f1, flag1, f)); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY, this, null, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - profilerfiller.popPush("fog"); - FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f1, 32.0F), flag1, f); - profilerfiller.popPush("terrain_setup"); -@@ -953,7 +_,9 @@ - this.compileSections(p_109604_); - profilerfiller.popPush("terrain"); - this.renderSectionLayer(RenderType.solid(), d0, d1, d2, p_254120_, p_323920_); -+ this.minecraft.getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).setBlurMipmap(false, this.minecraft.options.mipmapLevels().get() > 0); // Neo: fix flickering leaves when mods mess up the blurMipmap settings - this.renderSectionLayer(RenderType.cutoutMipped(), d0, d1, d2, p_254120_, p_323920_); -+ this.minecraft.getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).restoreLastBlurMipmap(); - this.renderSectionLayer(RenderType.cutout(), d0, d1, d2, p_254120_, p_323920_); - if (this.level.effects().constantAmbientLight()) { - Lighting.setupNetherLevel(); -@@ -996,7 +_,7 @@ - || p_109604_.isDetached() - || p_109604_.getEntity() instanceof LivingEntity && ((LivingEntity)p_109604_.getEntity()).isSleeping() ++ /** ++ * @deprecated Neo: use {@link #addWeatherPass(FrameGraphBuilder, LightTexture, Vec3, float, FogParameters, Matrix4f, Matrix4f, Camera)} instead ++ */ ++ @Deprecated + private void addWeatherPass(FrameGraphBuilder p_364025_, LightTexture p_361536_, Vec3 p_360771_, float p_362434_, FogParameters p_360974_) { ++ addWeatherPass(p_364025_, p_361536_, p_360771_, p_362434_, p_360974_, RenderSystem.getModelViewMatrix(), RenderSystem.getProjectionMatrix(), this.minecraft.gameRenderer.getMainCamera()); ++ } ++ ++ private void addWeatherPass(FrameGraphBuilder p_364025_, LightTexture p_361536_, Vec3 p_360771_, float p_362434_, FogParameters p_360974_, Matrix4f modelViewMatrix, Matrix4f projectionMatrix, Camera camera) { + int i = this.minecraft.options.getEffectiveRenderDistance() * 16; + float f = this.minecraft.gameRenderer.getDepthFar(); + FramePass framepass = p_364025_.addPass("weather"); +@@ -731,6 +_,7 @@ + RenderSystem.setShaderFog(p_360974_); + RenderStateShard.WEATHER_TARGET.setupRenderState(); + this.weatherEffectRenderer.render(this.minecraft.level, p_361536_, this.ticks, p_362434_, p_360771_); ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, null, modelViewMatrix, projectionMatrix, this.ticks, camera, getFrustum()); + this.worldBorderRenderer.render(this.level.getWorldBorder(), p_360771_, (double)i, (double)f); + RenderStateShard.WEATHER_TARGET.clearRenderState(); + }); +@@ -775,11 +_,14 @@ + || p_363510_.isDetached() + || p_363510_.getEntity() instanceof LivingEntity && ((LivingEntity)p_363510_.getEntity()).isSleeping() ) -- && (!(entity instanceof LocalPlayer) || p_109604_.getEntity() == entity)) { -+ && (!(entity instanceof LocalPlayer) || p_109604_.getEntity() == entity || (entity == minecraft.player && !minecraft.player.isSpectator()))) { // Neo: render local player entity when it is not the camera entity - this.renderedEntities++; - if (entity.tickCount == 0) { - entity.xOld = entity.getX(); -@@ -1012,6 +_,9 @@ - int i = entity.getTeamColor(); - outlinebuffersource.setColor(FastColor.ARGB32.red(i), FastColor.ARGB32.green(i), FastColor.ARGB32.blue(i), 255); - } else { -+ if (this.shouldShowEntityOutlines() && entity.hasCustomOutlineRendering(this.minecraft.player)) { // FORGE: allow custom outline rendering -+ flag2 = true; -+ } - multibuffersource = multibuffersource$buffersource; +- && (!(entity instanceof LocalPlayer) || p_363510_.getEntity() == entity)) { ++ && (!(entity instanceof LocalPlayer) || p_363510_.getEntity() == entity || (entity == minecraft.player && !minecraft.player.isSpectator()))) { // Neo: render local player entity when it is not the camera entity + p_363380_.add(entity); + if (flag1 && this.minecraft.shouldEntityAppearGlowing(entity)) { + flag = true; } ++ else if (flag1 && entity.hasCustomOutlineRendering(this.minecraft.player)) { // FORGE: allow custom outline rendering ++ flag = true; ++ } + } + } + } +@@ -825,10 +_,12 @@ + double d1 = vec3.y(); + double d2 = vec3.z(); -@@ -1027,12 +_,14 @@ - multibuffersource$buffersource.endBatch(RenderType.entityCutout(TextureAtlas.LOCATION_BLOCKS)); - multibuffersource$buffersource.endBatch(RenderType.entityCutoutNoCull(TextureAtlas.LOCATION_BLOCKS)); - multibuffersource$buffersource.endBatch(RenderType.entitySmoothCutout(TextureAtlas.LOCATION_BLOCKS)); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_ENTITIES, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - profilerfiller.popPush("blockentities"); - ++ Frustum frustum = getFrustum(); for (SectionRenderDispatcher.RenderSection sectionrenderdispatcher$rendersection : this.visibleSections) { List list = sectionrenderdispatcher$rendersection.getCompiled().getRenderableBlockEntities(); if (!list.isEmpty()) { - for (BlockEntity blockentity1 : list) { -+ if (!net.neoforged.neoforge.client.ClientHooks.isBlockEntityRendererVisible(blockEntityRenderDispatcher, blockentity1, frustum)) continue; - BlockPos blockpos4 = blockentity1.getBlockPos(); - MultiBufferSource multibuffersource1 = multibuffersource$buffersource; - posestack.pushPose(); -@@ -1051,6 +_,9 @@ - }; - } - } -+ if (this.shouldShowEntityOutlines() && blockentity1.hasCustomOutlineRendering(this.minecraft.player)) { // Neo: allow custom outline rendering -+ flag2 = true; -+ } - - this.blockEntityRenderDispatcher.render(blockentity1, f, posestack, multibuffersource1); - posestack.popPose(); -@@ -1060,9 +_,13 @@ + for (BlockEntity blockentity : list) { ++ if (!net.neoforged.neoforge.client.ClientHooks.isBlockEntityRendererVisible(blockEntityRenderDispatcher, blockentity, frustum)) continue; + BlockPos blockpos = blockentity.getBlockPos(); + MultiBufferSource multibuffersource = p_363819_; + p_362832_.pushPose(); +@@ -856,6 +_,7 @@ synchronized (this.globalBlockEntities) { - for (BlockEntity blockentity : this.globalBlockEntities) { -+ if (!net.neoforged.neoforge.client.ClientHooks.isBlockEntityRendererVisible(blockEntityRenderDispatcher, blockentity, frustum)) continue; - BlockPos blockpos3 = blockentity.getBlockPos(); - posestack.pushPose(); - posestack.translate((double)blockpos3.getX() - d0, (double)blockpos3.getY() - d1, (double)blockpos3.getZ() - d2); -+ if (this.shouldShowEntityOutlines() && blockentity.hasCustomOutlineRendering(this.minecraft.player)) { // Neo: allow custom outline rendering -+ flag2 = true; -+ } - this.blockEntityRenderDispatcher.render(blockentity, f, posestack, multibuffersource$buffersource); - posestack.popPose(); - } -@@ -1080,11 +_,17 @@ - multibuffersource$buffersource.endBatch(Sheets.hangingSignSheet()); - multibuffersource$buffersource.endBatch(Sheets.chestSheet()); - this.renderBuffers.outlineBufferSource().endOutlineBatch(); -+ // Neo: handle outline effect requests outside glowing entities -+ if (this.outlineEffectRequested) { -+ flag2 |= this.shouldShowEntityOutlines(); -+ this.outlineEffectRequested = false; -+ } - if (flag2) { - this.entityEffect.process(p_348530_.getGameTimeDeltaTicks()); - this.minecraft.getMainRenderTarget().bindWrite(false); - } - -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_BLOCK_ENTITIES, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - profilerfiller.popPush("destroyProgress"); - - for (Entry> entry : this.destructionProgress.long2ObjectEntrySet()) { -@@ -1102,9 +_,10 @@ - VertexConsumer vertexconsumer1 = new SheetedDecalTextureGenerator( - this.renderBuffers.crumblingBufferSource().getBuffer(ModelBakery.DESTROY_TYPES.get(k)), posestack$pose1, 1.0F + for (BlockEntity blockentity1 : this.globalBlockEntities) { ++ if (!net.neoforged.neoforge.client.ClientHooks.isBlockEntityRendererVisible(blockEntityRenderDispatcher, blockentity1, frustum)) continue; + BlockPos blockpos1 = blockentity1.getBlockPos(); + p_362832_.pushPose(); + p_362832_.translate((double)blockpos1.getX() - d0, (double)blockpos1.getY() - d1, (double)blockpos1.getZ() - d2); +@@ -883,9 +_,10 @@ + VertexConsumer vertexconsumer = new SheetedDecalTextureGenerator( + p_365216_.getBuffer(ModelBakery.DESTROY_TYPES.get(i)), posestack$pose, 1.0F ); -+ net.neoforged.neoforge.client.model.data.ModelData modelData = level.getModelData(blockpos2); ++ net.neoforged.neoforge.client.model.data.ModelData modelData = level.getModelData(blockpos); this.minecraft .getBlockRenderer() -- .renderBreakingTexture(this.level.getBlockState(blockpos2), blockpos2, this.level, posestack, vertexconsumer1); -+ .renderBreakingTexture(this.level.getBlockState(blockpos2), blockpos2, this.level, posestack, vertexconsumer1, modelData); - posestack.popPose(); +- .renderBreakingTexture(this.level.getBlockState(blockpos), blockpos, this.level, p_363901_, vertexconsumer); ++ .renderBreakingTexture(this.level.getBlockState(blockpos), blockpos, this.level, p_363901_, vertexconsumer, modelData); + p_363901_.popPose(); } } -@@ -1116,10 +_,13 @@ - profilerfiller.popPush("outline"); - BlockPos blockpos1 = ((BlockHitResult)hitresult).getBlockPos(); - BlockState blockstate = this.level.getBlockState(blockpos1); -+ if (!net.neoforged.neoforge.client.ClientHooks.onDrawHighlight(this, p_109604_, hitresult, p_348530_, posestack, multibuffersource$buffersource)) - if (!blockstate.isAir() && this.level.getWorldBorder().isWithinBounds(blockpos1)) { - VertexConsumer vertexconsumer2 = multibuffersource$buffersource.getBuffer(RenderType.lines()); - this.renderHitOutline(posestack, vertexconsumer2, p_109604_.getEntity(), d0, d1, d2, blockpos1, blockstate); - } -+ } else if (hitresult != null && hitresult.getType() == HitResult.Type.ENTITY) { -+ net.neoforged.neoforge.client.ClientHooks.onDrawHighlight(this, p_109604_, hitresult, p_348530_, posestack, multibuffersource$buffersource); - } - - this.minecraft.debugRenderer.render(posestack, multibuffersource$buffersource, d0, d1, d2); -@@ -1147,9 +_,13 @@ - this.particlesTarget.copyDepthFrom(this.minecraft.getMainRenderTarget()); - RenderStateShard.PARTICLES_TARGET.setupRenderState(); - profilerfiller.popPush("particles"); -- this.minecraft.particleEngine.render(p_109606_, p_109604_, f); -+ this.minecraft.particleEngine.render(p_109606_, p_109604_, f, frustum, type -> true); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - RenderStateShard.PARTICLES_TARGET.clearRenderState(); - } else { -+ // Neo: render solid particles before translucent geometry to match order of chunk render types, fixes solid particles disappearing underwater in Fast/Fancy (MC-161917) -+ profilerfiller.popPush("solid_particles"); -+ this.minecraft.particleEngine.render(p_109606_, p_109604_, f, frustum, type -> !type.isTranslucent()); - profilerfiller.popPush("translucent"); - if (this.translucentTarget != null) { - this.translucentTarget.clear(Minecraft.ON_OSX); -@@ -1161,7 +_,8 @@ - profilerfiller.popPush("string"); - this.renderSectionLayer(RenderType.tripwire(), d0, d1, d2, p_254120_, p_323920_); - profilerfiller.popPush("particles"); -- this.minecraft.particleEngine.render(p_109606_, p_109604_, f); -+ this.minecraft.particleEngine.render(p_109606_, p_109604_, f, frustum, type -> type.isTranslucent()); // Neo: only render translucent particles at this stage -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - } - - if (this.minecraft.options.getCloudsType() != CloudStatus.OFF) { -@@ -1177,6 +_,7 @@ - RenderStateShard.WEATHER_TARGET.setupRenderState(); - profilerfiller.popPush("weather"); - this.renderSnowAndRain(p_109606_, f, d0, d1, d2); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - this.renderWorldBorder(p_109604_); - RenderStateShard.WEATHER_TARGET.clearRenderState(); - this.transparencyChain.process(p_348530_.getGameTimeDeltaTicks()); -@@ -1185,6 +_,7 @@ - RenderSystem.depthMask(false); - profilerfiller.popPush("weather"); - this.renderSnowAndRain(p_109606_, f, d0, d1, d2); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - this.renderWorldBorder(p_109604_); - RenderSystem.depthMask(true); +@@ -897,8 +_,9 @@ + if (blockhitresult.getType() != HitResult.Type.MISS) { + BlockPos blockpos = blockhitresult.getBlockPos(); + BlockState blockstate = this.level.getBlockState(blockpos); ++ if (!net.neoforged.neoforge.client.ClientHooks.onDrawHighlight(this, p_363911_, blockhitresult, this.minecraft.getDeltaTracker(), p_361893_, p_362782_, p_361698_)) + if (!blockstate.isAir() && this.level.getWorldBorder().isWithinBounds(blockpos)) { +- boolean flag = ItemBlockRenderTypes.getChunkRenderType(blockstate).sortOnUpload(); ++ boolean flag = net.neoforged.neoforge.client.ClientHooks.isInTranslucentBlockOutlinePass(this.level, blockpos, blockstate); + if (flag != p_361698_) { + return; + } +@@ -1026,6 +_,7 @@ + compiledshaderprogram.clear(); + VertexBuffer.unbind(); + zone.close(); ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(p_294513_, this, p_294782_, p_324517_, this.ticks, this.minecraft.gameRenderer.getMainCamera(), this.getFrustum()); + p_294513_.clearRenderState(); } -@@ -1293,6 +_,7 @@ - shaderinstance.clear(); - VertexBuffer.unbind(); - this.minecraft.getProfiler().pop(); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(p_294513_, this, p_294782_, p_324517_, this.ticks, this.minecraft.gameRenderer.getMainCamera(), this.getFrustum()); - p_294513_.clearRenderState(); - } - -@@ -1543,6 +_,8 @@ } - - public void renderSky(Matrix4f p_254034_, Matrix4f p_324386_, float p_202426_, Camera p_202427_, boolean p_202428_, Runnable p_202429_) { -+ if (level.effects().renderSky(level, ticks, p_202426_, p_254034_, p_202427_, p_324386_, p_202428_, p_202429_)) -+ return; - p_202429_.run(); - if (!p_202428_) { - FogType fogtype = p_202427_.getFluidInCamera(); -@@ -1666,6 +_,8 @@ +@@ -1066,7 +_,15 @@ + } } - public void renderClouds(PoseStack p_254145_, Matrix4f p_254537_, Matrix4f p_324366_, float p_254364_, double p_253843_, double p_253663_, double p_253795_) { -+ if (level.effects().renderClouds(level, ticks, p_254364_, p_254145_, p_253843_, p_253663_, p_253795_, p_254537_, p_324366_)) -+ return; - float f = this.level.effects().getCloudHeight(); - if (!Float.isNaN(f)) { - float f1 = 12.0F; -@@ -2488,6 +_,31 @@ - this.viewArea.setDirty(p_109502_, p_109503_, p_109504_, p_109505_); - } ++ /** ++ * @deprecated Neo: use {@link #addSkyPass(FrameGraphBuilder, Camera, float, FogParameters, Matrix4f, Matrix4f)} instead ++ */ ++ @Deprecated + private void addSkyPass(FrameGraphBuilder p_362870_, Camera p_362177_, float p_363799_, FogParameters p_364999_) { ++ addSkyPass(p_362870_, p_362177_, p_363799_, p_364999_, RenderSystem.getModelViewMatrix(), RenderSystem.getProjectionMatrix()); ++ } ++ ++ private void addSkyPass(FrameGraphBuilder p_362870_, Camera p_362177_, float p_363799_, FogParameters p_364999_, Matrix4f modelViewMatrix, Matrix4f projectionMatrix) { + FogType fogtype = p_362177_.getFluidInCamera(); + if (fogtype != FogType.POWDER_SNOW && fogtype != FogType.LAVA && !this.doesMobEffectBlockSky(p_362177_)) { + DimensionSpecialEffects dimensionspecialeffects = this.level.effects(); +@@ -1075,6 +_,7 @@ + FramePass framepass = p_362870_.addPass("sky"); + this.targets.main = framepass.readsAndWrites(this.targets.main); + framepass.executes(() -> { ++ if (!level.effects().renderSky(level, ticks, p_363799_, modelViewMatrix, p_362177_, projectionMatrix, () -> RenderSystem.setShaderFog(p_364999_))) { + RenderSystem.setShaderFog(p_364999_); + RenderStateShard.MAIN_TARGET.setupRenderState(); + PoseStack posestack = new PoseStack(); +@@ -1102,6 +_,8 @@ + this.skyRenderer.renderDarkDisc(posestack); + } + } ++ } ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY, this, null, modelViewMatrix, projectionMatrix, this.ticks, p_362177_, getFrustum()); + }); + } + } +@@ -1413,7 +_,7 @@ + } else { + int i = p_109538_.getBrightness(LightLayer.SKY, p_109540_); + int j = p_109538_.getBrightness(LightLayer.BLOCK, p_109540_); +- int k = p_109539_.getLightEmission(); ++ int k = p_109539_.getLightEmission(p_109538_, p_109540_); + if (j < k) { + j = k; + } +@@ -1475,5 +_,22 @@ + public CloudRenderer getCloudRenderer() { + return this.cloudRenderer; ++ } ++ + public Frustum getFrustum() { + return this.capturedFrustum != null ? this.capturedFrustum : this.cullingFrustum; + } @@ -239,36 +251,5 @@ + synchronized (this.globalBlockEntities) { + this.globalBlockEntities.forEach(blockEntityConsumer); + } -+ } -+ -+ /** -+ * Neo: Request outline effect post-processing to be enabled for the current frame. Must be called before block -+ * entities are done rendering, ideally early during the frame -+ */ -+ public void requestOutlineEffect() { -+ this.outlineEffectRequested = true; -+ } -+ - public void playJukeboxSong(Holder p_350918_, BlockPos p_350830_) { - if (this.level != null) { - this.stopJukeboxSong(p_350830_); -@@ -3008,8 +_,8 @@ - break; - case 2001: - BlockState blockstate1 = Block.stateById(p_234307_); -- if (!blockstate1.isAir()) { -- SoundType soundtype = blockstate1.getSoundType(); -+ if (!blockstate1.isAir() && !net.neoforged.neoforge.client.extensions.common.IClientBlockExtensions.of(blockstate1).playBreakSound(blockstate1, this.level, p_234306_)) { -+ SoundType soundtype = blockstate1.getSoundType(this.level, p_234306_, null); - this.level - .playLocalSound( - p_234306_, soundtype.getBreakSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F, false -@@ -3495,7 +_,7 @@ - } else { - int i = p_109538_.getBrightness(LightLayer.SKY, p_109540_); - int j = p_109538_.getBrightness(LightLayer.BLOCK, p_109540_); -- int k = p_109539_.getLightEmission(); -+ int k = p_109539_.getLightEmission(p_109538_, p_109540_); - if (j < k) { - j = k; - } + } + } diff --git a/patches/net/minecraft/client/renderer/LightTexture.java.patch b/patches/net/minecraft/client/renderer/LightTexture.java.patch index 72db3bdf..da6b2dc0 100644 --- a/patches/net/minecraft/client/renderer/LightTexture.java.patch +++ b/patches/net/minecraft/client/renderer/LightTexture.java.patch @@ -1,19 +1,10 @@ --- a/net/minecraft/client/renderer/LightTexture.java +++ b/net/minecraft/client/renderer/LightTexture.java -@@ -129,6 +_,8 @@ - } - } - -+ clientlevel.effects().adjustLightmapColors(clientlevel, p_109882_, f, f7, f8, j, i, vector3f1); -+ - if (f5 > 0.0F) { - float f13 = Math.max(vector3f1.x(), Math.max(vector3f1.y(), vector3f1.z())); - if (f13 < 1.0F) { -@@ -186,7 +_,7 @@ +@@ -141,7 +_,7 @@ } public static int block(int p_109884_) { -- return p_109884_ >> 4 & 65535; +- return p_109884_ >>> 4 & 15; + return (p_109884_ & 0xFFFF) >> 4; // Forge: Fix fullbright quads showing dark artifacts. Reported as MC-169806 } diff --git a/patches/net/minecraft/client/renderer/MapRenderer.java.patch b/patches/net/minecraft/client/renderer/MapRenderer.java.patch new file mode 100644 index 00000000..8d0c9606 --- /dev/null +++ b/patches/net/minecraft/client/renderer/MapRenderer.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/client/renderer/MapRenderer.java ++++ b/net/minecraft/client/renderer/MapRenderer.java +@@ -42,6 +_,10 @@ + + for (MapRenderState.MapDecorationRenderState maprenderstate$mapdecorationrenderstate : p_360365_.decorations) { + if (!p_362262_ || maprenderstate$mapdecorationrenderstate.renderOnFrame) { ++ if (net.neoforged.neoforge.client.gui.map.MapDecorationRendererManager.render(maprenderstate$mapdecorationrenderstate, p_362483_, p_363581_, p_360365_, MapRenderer.this.decorationTextures, p_362262_, p_364872_, i)) { ++ i++; ++ continue; ++ } + p_362483_.pushPose(); + p_362483_.translate( + (float)maprenderstate$mapdecorationrenderstate.x / 2.0F + 64.0F, (float)maprenderstate$mapdecorationrenderstate.y / 2.0F + 64.0F, -0.02F +@@ -116,6 +_,7 @@ + + private MapRenderState.MapDecorationRenderState extractDecorationRenderState(MapDecoration p_364175_) { + MapRenderState.MapDecorationRenderState maprenderstate$mapdecorationrenderstate = new MapRenderState.MapDecorationRenderState(); ++ maprenderstate$mapdecorationrenderstate.type = p_364175_.type(); + maprenderstate$mapdecorationrenderstate.atlasSprite = this.decorationTextures.get(p_364175_); + maprenderstate$mapdecorationrenderstate.x = p_364175_.x(); + maprenderstate$mapdecorationrenderstate.y = p_364175_.y(); diff --git a/patches/net/minecraft/client/renderer/PanoramaRenderer.java.patch b/patches/net/minecraft/client/renderer/PanoramaRenderer.java.patch deleted file mode 100644 index 4111b68d..00000000 --- a/patches/net/minecraft/client/renderer/PanoramaRenderer.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/renderer/PanoramaRenderer.java -+++ b/net/minecraft/client/renderer/PanoramaRenderer.java -@@ -30,6 +_,8 @@ - p_334063_.blit(PANORAMA_OVERLAY, 0, 0, p_333839_, p_333923_, 0.0F, 0.0F, 16, 128, 16, 128); - p_334063_.setColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.disableBlend(); -+ // Neo: disable depth test again to prevent issues with extended far plane values for screen layers and HUD layers -+ RenderSystem.disableDepthTest(); - } - - private static float wrap(float p_249058_, float p_249548_) { diff --git a/patches/net/minecraft/client/renderer/PostChain.java.patch b/patches/net/minecraft/client/renderer/PostChain.java.patch deleted file mode 100644 index 7dbfffbb..00000000 --- a/patches/net/minecraft/client/renderer/PostChain.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/client/renderer/PostChain.java -+++ b/net/minecraft/client/renderer/PostChain.java -@@ -156,7 +_,8 @@ - throw new ChainedJsonException("Render target '" + s4 + "' can't be used as depth buffer"); - } - -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("textures/effect/" + s4 + ".png"); -+ ResourceLocation rl = ResourceLocation.tryParse(s4); -+ ResourceLocation resourcelocation = ResourceLocation.fromNamespaceAndPath(rl.getNamespace(), "textures/effect/" + rl.getPath() + ".png"); - this.resourceProvider - .getResource(resourcelocation) - .orElseThrow(() -> new ChainedJsonException("Render target or texture '" + s4 + "' does not exist")); -@@ -257,6 +_,7 @@ - public void addTempTarget(String p_110039_, int p_110040_, int p_110041_) { - RenderTarget rendertarget = new TextureTarget(p_110040_, p_110041_, true, Minecraft.ON_OSX); - rendertarget.setClearColor(0.0F, 0.0F, 0.0F, 0.0F); -+ if (screenTarget.isStencilEnabled()) { rendertarget.enableStencil(); } - this.customRenderTargets.put(p_110039_, rendertarget); - if (p_110040_ == this.screenWidth && p_110041_ == this.screenHeight) { - this.fullSizedTargets.add(rendertarget); diff --git a/patches/net/minecraft/client/renderer/RenderBuffers.java.patch b/patches/net/minecraft/client/renderer/RenderBuffers.java.patch index 97da5ee8..ad6b76cc 100644 --- a/patches/net/minecraft/client/renderer/RenderBuffers.java.patch +++ b/patches/net/minecraft/client/renderer/RenderBuffers.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/renderer/RenderBuffers.java +++ b/net/minecraft/client/renderer/RenderBuffers.java -@@ -37,6 +_,7 @@ - put((Object2ObjectLinkedOpenHashMap)p_349871_, RenderType.waterMask()); - ModelBakery.DESTROY_TYPES.forEach(p_173062_ -> put(p_349871_, p_173062_)); +@@ -35,6 +_,7 @@ + put((Object2ObjectLinkedOpenHashMap)p_366352_, RenderType.entityGlint()); + put((Object2ObjectLinkedOpenHashMap)p_366352_, RenderType.waterMask()); }); + net.neoforged.fml.ModLoader.postEvent(new net.neoforged.neoforge.client.event.RegisterRenderBuffersEvent(sequencedmap)); - this.crumblingBufferSource = MultiBufferSource.immediate(new ByteBufferBuilder(1536)); this.bufferSource = MultiBufferSource.immediateWithBuffers(sequencedmap, new ByteBufferBuilder(786432)); this.outlineBufferSource = new OutlineBufferSource(this.bufferSource); + SequencedMap sequencedmap1 = Util.make( diff --git a/patches/net/minecraft/client/renderer/RenderType.java.patch b/patches/net/minecraft/client/renderer/RenderType.java.patch index 568f0746..3186edd2 100644 --- a/patches/net/minecraft/client/renderer/RenderType.java.patch +++ b/patches/net/minecraft/client/renderer/RenderType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/RenderType.java +++ b/net/minecraft/client/renderer/RenderType.java -@@ -968,7 +_,7 @@ +@@ -1098,7 +_,7 @@ } public static RenderType text(ResourceLocation p_110498_) { @@ -9,7 +9,7 @@ } public static RenderType textBackground() { -@@ -976,19 +_,19 @@ +@@ -1106,19 +_,19 @@ } public static RenderType textIntensity(ResourceLocation p_173238_) { @@ -33,7 +33,7 @@ } public static RenderType textBackgroundSeeThrough() { -@@ -996,7 +_,7 @@ +@@ -1126,7 +_,7 @@ } public static RenderType textIntensitySeeThrough(ResourceLocation p_173241_) { @@ -42,7 +42,7 @@ } public static RenderType lightning() { -@@ -1453,5 +_,17 @@ +@@ -1622,5 +_,17 @@ public String toString() { return this.name; } diff --git a/patches/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch b/patches/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch index ca33ed78..901854e3 100644 --- a/patches/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch @@ -55,7 +55,7 @@ + } + + public static void renderFluid(Minecraft p_110726_, PoseStack p_110727_, ResourceLocation texture) { - RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShader(CoreShaders.POSITION_TEX); - RenderSystem.setShaderTexture(0, UNDERWATER_LOCATION); + RenderSystem.setShaderTexture(0, texture); BlockPos blockpos = BlockPos.containing(p_110726_.player.getX(), p_110726_.player.getEyeY(), p_110726_.player.getZ()); diff --git a/patches/net/minecraft/client/renderer/ShaderInstance.java.patch b/patches/net/minecraft/client/renderer/ShaderInstance.java.patch deleted file mode 100644 index 2192fa09..00000000 --- a/patches/net/minecraft/client/renderer/ShaderInstance.java.patch +++ /dev/null @@ -1,57 +0,0 @@ ---- a/net/minecraft/client/renderer/ShaderInstance.java -+++ b/net/minecraft/client/renderer/ShaderInstance.java -@@ -94,10 +_,14 @@ - @Nullable - public final Uniform CHUNK_OFFSET; - -+ @Deprecated // FORGE: Use the ResourceLocation variant below - public ShaderInstance(ResourceProvider p_173336_, String p_173337_, VertexFormat p_173338_) throws IOException { -- this.name = p_173337_; -+ this(p_173336_, ResourceLocation.parse(p_173337_), p_173338_); -+ } -+ public ShaderInstance(ResourceProvider p_173336_, ResourceLocation shaderLocation, VertexFormat p_173338_) throws IOException { -+ this.name = shaderLocation.getNamespace().equals("minecraft") ? shaderLocation.getPath() : shaderLocation.toString(); - this.vertexFormat = p_173338_; -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("shaders/core/" + p_173337_ + ".json"); -+ ResourceLocation resourcelocation = ResourceLocation.fromNamespaceAndPath(shaderLocation.getNamespace(), "shaders/core/" + shaderLocation.getPath() + ".json"); - - try (Reader reader = p_173336_.openAsReader(resourcelocation)) { - JsonObject jsonobject = GsonHelper.parse(reader); -@@ -177,8 +_,10 @@ - Program program1 = p_173342_.getPrograms().get(p_173343_); - Program program; - if (program1 == null) { -- String s = "shaders/core/" + p_173343_ + p_173342_.getExtension(); -- Resource resource = p_173341_.getResourceOrThrow(ResourceLocation.withDefaultNamespace(s)); -+ ResourceLocation loc = ResourceLocation.parse(p_173343_); -+ String s = "shaders/core/" + loc.getPath() + p_173342_.getExtension(); -+ ResourceLocation resourcelocation = ResourceLocation.fromNamespaceAndPath(loc.getNamespace(), s); -+ Resource resource = p_173341_.getResourceOrThrow(resourcelocation); - - try (InputStream inputstream = resource.open()) { - final String s1 = FileUtil.getFullResourcePath(s); -@@ -187,11 +_,11 @@ - - @Override - public String applyImport(boolean p_173374_, String p_173375_) { -- p_173375_ = FileUtil.normalizeResourcePath((p_173374_ ? s1 : "shaders/include/") + p_173375_); -- if (!this.importedPaths.add(p_173375_)) { -+ // FORGE: use the mod's namespace to look up resources if specified -+ ResourceLocation resourcelocation = net.neoforged.neoforge.client.ClientHooks.getShaderImportLocation(s1, p_173374_, p_173375_); -+ if (!this.importedPaths.add(resourcelocation.toString())) { - return null; - } else { -- ResourceLocation resourcelocation = ResourceLocation.parse(p_173375_); - - try { - String s2; -@@ -201,7 +_,8 @@ - - return s2; - } catch (IOException ioexception) { -- ShaderInstance.LOGGER.error("Could not open GLSL import {}: {}", p_173375_, ioexception.getMessage()); -+ // FORGE: specify the namespace of the failed import in case of duplicates from multiple mods -+ ShaderInstance.LOGGER.error("Could not open GLSL import {}: {}", resourcelocation, ioexception.getMessage()); - return "#error " + ioexception.getMessage(); - } - } diff --git a/patches/net/minecraft/client/renderer/ShaderManager.java.patch b/patches/net/minecraft/client/renderer/ShaderManager.java.patch new file mode 100644 index 00000000..4e634d23 --- /dev/null +++ b/patches/net/minecraft/client/renderer/ShaderManager.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/renderer/ShaderManager.java ++++ b/net/minecraft/client/renderer/ShaderManager.java +@@ -169,7 +_,7 @@ + ShaderManager.CompilationCache shadermanager$compilationcache = new ShaderManager.CompilationCache(p_366597_); + Map map = new HashMap<>(); + +- for (ShaderProgram shaderprogram : CoreShaders.getProgramsToPreload()) { ++ for (ShaderProgram shaderprogram : net.neoforged.neoforge.client.CoreShaderManager.getProgramsToPreload()) { + try { + shadermanager$compilationcache.programs.put(shaderprogram, Optional.of(shadermanager$compilationcache.compileProgram(shaderprogram))); + } catch (ShaderManager.CompilationException shadermanager$compilationexception) { diff --git a/patches/net/minecraft/client/renderer/Sheets.java.patch b/patches/net/minecraft/client/renderer/Sheets.java.patch index b2ff568d..cb01eb86 100644 --- a/patches/net/minecraft/client/renderer/Sheets.java.patch +++ b/patches/net/minecraft/client/renderer/Sheets.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/Sheets.java +++ b/net/minecraft/client/renderer/Sheets.java -@@ -146,11 +_,13 @@ +@@ -141,11 +_,13 @@ } private static Material createSignMaterial(WoodType p_173386_) { @@ -16,7 +16,7 @@ } public static Material getSignMaterial(WoodType p_173382_) { -@@ -209,6 +_,23 @@ +@@ -204,6 +_,23 @@ case SINGLE: default: return p_110773_; diff --git a/patches/net/minecraft/client/renderer/WeatherEffectRenderer.java.patch b/patches/net/minecraft/client/renderer/WeatherEffectRenderer.java.patch new file mode 100644 index 00000000..180f2825 --- /dev/null +++ b/patches/net/minecraft/client/renderer/WeatherEffectRenderer.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/client/renderer/WeatherEffectRenderer.java ++++ b/net/minecraft/client/renderer/WeatherEffectRenderer.java +@@ -61,6 +_,8 @@ + } + + public void render(Level p_364994_, LightTexture p_363130_, int p_363664_, float p_361655_, Vec3 p_363375_) { ++ if (((ClientLevel) p_364994_).effects().renderSnowAndRain((ClientLevel) p_364994_, p_363664_, p_361655_, p_363130_, p_363375_.x, p_363375_.y, p_363375_.z)) ++ return; + float f = p_364994_.getRainLevel(p_361655_); + if (!(f <= 0.0F)) { + int i = Minecraft.useFancyGraphics() ? 10 : 5; +@@ -201,6 +_,8 @@ + } + + public void tickRainParticles(ClientLevel p_361823_, Camera p_364990_, int p_361788_, ParticleStatus p_363302_) { ++ if (p_361823_.effects().tickRain(p_361823_, p_361788_, p_364990_)) ++ return; + float f = p_361823_.getRainLevel(1.0F) / (Minecraft.useFancyGraphics() ? 1.0F : 2.0F); + if (!(f <= 0.0F)) { + RandomSource randomsource = RandomSource.create((long)p_361788_ * 312987231L); diff --git a/patches/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch b/patches/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch index b3930065..5ee7f472 100644 --- a/patches/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch +++ b/patches/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch @@ -91,8 +91,8 @@ this.modelRenderer .renderModel( p_110914_.last(), -- p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_, false)), -+ p_110915_.getBuffer(renderType != null ? renderType : net.neoforged.neoforge.client.RenderTypeHelper.getEntityRenderType(rt, false)), +- p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_)), ++ p_110915_.getBuffer(renderType != null ? renderType : net.neoforged.neoforge.client.RenderTypeHelper.getEntityRenderType(rt)), p_110913_, bakedmodel, f, diff --git a/patches/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch b/patches/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch index 5eab04bb..f2ca146f 100644 --- a/patches/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/LiquidBlockRenderer.java +++ b/net/minecraft/client/renderer/block/LiquidBlockRenderer.java -@@ -38,6 +_,7 @@ +@@ -37,6 +_,7 @@ this.waterIcons[0] = Minecraft.getInstance().getModelManager().getBlockModelShaper().getBlockModel(Blocks.WATER.defaultBlockState()).getParticleIcon(); this.waterIcons[1] = ModelBakery.WATER_FLOW.sprite(); this.waterOverlay = ModelBakery.WATER_OVERLAY.sprite(); @@ -20,7 +20,7 @@ float f = (float)(i >> 16 & 0xFF) / 255.0F; float f1 = (float)(i >> 8 & 0xFF) / 255.0F; float f2 = (float)(i & 0xFF) / 255.0F; -@@ -181,15 +_,15 @@ +@@ -180,15 +_,15 @@ float f57 = f4 * f; float f29 = f4 * f1; float f30 = f4 * f2; @@ -44,7 +44,7 @@ } } -@@ -202,10 +_,10 @@ +@@ -201,10 +_,10 @@ float f46 = f3 * f; float f48 = f3 * f1; float f50 = f3 * f2; @@ -59,8 +59,8 @@ } int j = this.getLightColor(p_234370_, p_234371_); -@@ -260,10 +_,9 @@ - && !isFaceOccludedByNeighbor(p_234370_, p_234371_, direction, Math.max(f44, f45), p_234370_.getBlockState(p_234371_.relative(direction)))) { +@@ -258,10 +_,9 @@ + if (flag7 && !isFaceOccludedByNeighbor(direction, Math.max(f44, f45), p_234370_.getBlockState(p_234371_.relative(direction)))) { BlockPos blockpos = p_234371_.relative(direction); TextureAtlasSprite textureatlassprite2 = atextureatlassprite[1]; - if (!flag) { @@ -73,7 +73,7 @@ } } -@@ -276,15 +_,15 @@ +@@ -274,15 +_,15 @@ float f33 = f4 * f32 * f; float f34 = f4 * f32 * f1; float f35 = f4 * f32 * f2; @@ -98,7 +98,7 @@ } } } -@@ -325,6 +_,26 @@ +@@ -323,6 +_,26 @@ private float getHeight(BlockAndTintGetter p_203157_, Fluid p_203158_, BlockPos p_203159_) { BlockState blockstate = p_203157_.getBlockState(p_203159_); return this.getHeight(p_203157_, p_203158_, p_203159_, blockstate, blockstate.getFluidState()); diff --git a/patches/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch b/patches/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch index 94bd0b01..49d5af1f 100644 --- a/patches/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/ModelBlockRenderer.java +++ b/net/minecraft/client/renderer/block/ModelBlockRenderer.java -@@ -40,6 +_,7 @@ +@@ -39,6 +_,7 @@ this.blockColors = p_110999_; } @@ -8,34 +8,34 @@ public void tesselateBlock( BlockAndTintGetter p_234380_, BakedModel p_234381_, -@@ -52,15 +_,35 @@ +@@ -51,14 +_,35 @@ long p_234388_, int p_234389_ ) { - boolean flag = Minecraft.useAmbientOcclusion() && p_234382_.getLightEmission() == 0 && p_234381_.useAmbientOcclusion(); + tesselateBlock(p_234380_, p_234381_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234387_, p_234388_, p_234389_, net.neoforged.neoforge.client.model.data.ModelData.EMPTY, null); + } ++ + public void tesselateBlock( -+ BlockAndTintGetter p_234380_, -+ BakedModel p_234381_, -+ BlockState p_234382_, -+ BlockPos p_234383_, -+ PoseStack p_234384_, -+ VertexConsumer p_234385_, -+ boolean p_234386_, -+ RandomSource p_234387_, -+ long p_234388_, -+ int p_234389_, -+ net.neoforged.neoforge.client.model.data.ModelData modelData, -+ net.minecraft.client.renderer.RenderType renderType ++ BlockAndTintGetter p_234380_, ++ BakedModel p_234381_, ++ BlockState p_234382_, ++ BlockPos p_234383_, ++ PoseStack p_234384_, ++ VertexConsumer p_234385_, ++ boolean p_234386_, ++ RandomSource p_234387_, ++ long p_234388_, ++ int p_234389_, ++ net.neoforged.neoforge.client.model.data.ModelData modelData, ++ net.minecraft.client.renderer.RenderType renderType + ) { + boolean flag = Minecraft.useAmbientOcclusion() && switch(p_234381_.useAmbientOcclusion(p_234382_, modelData, renderType)) { + case TRUE -> true; + case DEFAULT -> p_234382_.getLightEmission(p_234380_, p_234383_) == 0; + case FALSE -> false; + }; - Vec3 vec3 = p_234382_.getOffset(p_234380_, p_234383_); - p_234384_.translate(vec3.x, vec3.y, vec3.z); + p_234384_.translate(p_234382_.getOffset(p_234383_)); try { if (flag) { @@ -47,7 +47,7 @@ } } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating block model"); -@@ -71,6 +_,7 @@ +@@ -69,6 +_,7 @@ } } @@ -55,12 +55,13 @@ public void tesselateWithAO( BlockAndTintGetter p_234391_, BakedModel p_234392_, -@@ -83,6 +_,22 @@ +@@ -81,6 +_,23 @@ long p_234399_, int p_234400_ ) { + tesselateWithAO(p_234391_, p_234392_, p_234393_, p_234394_, p_234395_, p_234396_, p_234397_, p_234398_, p_234399_, p_234400_, net.neoforged.neoforge.client.model.data.ModelData.EMPTY, null); + } ++ + public void tesselateWithAO( + BlockAndTintGetter p_234391_, + BakedModel p_234392_, @@ -78,7 +79,7 @@ float[] afloat = new float[DIRECTIONS.length * 2]; BitSet bitset = new BitSet(3); ModelBlockRenderer.AmbientOcclusionFace modelblockrenderer$ambientocclusionface = new ModelBlockRenderer.AmbientOcclusionFace(); -@@ -90,7 +_,7 @@ +@@ -88,10 +_,10 @@ for (Direction direction : DIRECTIONS) { p_234398_.setSeed(p_234399_); @@ -86,8 +87,12 @@ + List list = p_234392_.getQuads(p_234393_, direction, p_234398_, modelData, renderType); if (!list.isEmpty()) { blockpos$mutableblockpos.setWithOffset(p_234394_, direction); - if (!p_234397_ || Block.shouldRenderFace(p_234393_, p_234391_, p_234394_, direction, blockpos$mutableblockpos)) { -@@ -102,7 +_,7 @@ +- if (!p_234397_ || Block.shouldRenderFace(p_234393_, p_234391_.getBlockState(blockpos$mutableblockpos), direction)) { ++ if (!p_234397_ || Block.shouldRenderFace(p_234391_, p_234394_, p_234393_, p_234391_.getBlockState(blockpos$mutableblockpos), direction)) { + this.renderModelFaceAO( + p_234391_, p_234393_, p_234394_, p_234395_, p_234396_, list, afloat, bitset, modelblockrenderer$ambientocclusionface, p_234400_ + ); +@@ -100,7 +_,7 @@ } p_234398_.setSeed(p_234399_); @@ -96,7 +101,7 @@ if (!list1.isEmpty()) { this.renderModelFaceAO( p_234391_, p_234393_, p_234394_, p_234395_, p_234396_, list1, afloat, bitset, modelblockrenderer$ambientocclusionface, p_234400_ -@@ -110,6 +_,7 @@ +@@ -108,6 +_,7 @@ } } @@ -104,12 +109,13 @@ public void tesselateWithoutAO( BlockAndTintGetter p_234402_, BakedModel p_234403_, -@@ -122,12 +_,28 @@ +@@ -120,15 +_,32 @@ long p_234410_, int p_234411_ ) { + tesselateWithoutAO(p_234402_, p_234403_, p_234404_, p_234405_, p_234406_, p_234407_, p_234408_, p_234409_, p_234410_, p_234411_, net.neoforged.neoforge.client.model.data.ModelData.EMPTY, null); + } ++ + public void tesselateWithoutAO( + BlockAndTintGetter p_234402_, + BakedModel p_234403_, @@ -133,8 +139,12 @@ + List list = p_234403_.getQuads(p_234404_, direction, p_234409_, modelData, renderType); if (!list.isEmpty()) { blockpos$mutableblockpos.setWithOffset(p_234405_, direction); - if (!p_234408_ || Block.shouldRenderFace(p_234404_, p_234402_, p_234405_, direction, blockpos$mutableblockpos)) { -@@ -138,7 +_,7 @@ +- if (!p_234408_ || Block.shouldRenderFace(p_234404_, p_234402_.getBlockState(blockpos$mutableblockpos), direction)) { ++ if (!p_234408_ || Block.shouldRenderFace(p_234402_, p_234405_, p_234404_, p_234402_.getBlockState(blockpos$mutableblockpos), direction)) { + int i = LevelRenderer.getLightColor(p_234402_, p_234404_, blockpos$mutableblockpos); + this.renderModelFaceFlat(p_234402_, p_234404_, p_234405_, i, p_234411_, false, p_234406_, p_234407_, list, bitset); + } +@@ -136,7 +_,7 @@ } p_234409_.setSeed(p_234410_); @@ -143,7 +153,7 @@ if (!list1.isEmpty()) { this.renderModelFaceFlat(p_234402_, p_234404_, p_234405_, -1, p_234411_, true, p_234406_, p_234407_, list1, bitset); } -@@ -158,6 +_,7 @@ +@@ -156,6 +_,7 @@ ) { for (BakedQuad bakedquad : p_111018_) { this.calculateShape(p_111013_, p_111014_, p_111015_, bakedquad.getVertices(), bakedquad.getDirection(), p_111019_, p_111020_); @@ -151,7 +161,7 @@ p_111021_.calculate(p_111013_, p_111014_, p_111015_, bakedquad.getDirection(), p_111019_, p_111020_, bakedquad.isShade()); this.putQuadData( p_111013_, -@@ -323,6 +_,7 @@ +@@ -321,6 +_,7 @@ } } @@ -159,7 +169,7 @@ public void renderModel( PoseStack.Pose p_111068_, VertexConsumer p_111069_, -@@ -334,16 +_,32 @@ +@@ -332,16 +_,32 @@ int p_111075_, int p_111076_ ) { @@ -194,30 +204,27 @@ } private static void renderQuadList( -@@ -724,22 +_,22 @@ +@@ -722,19 +_,19 @@ int l = modelblockrenderer$cache.getLightColor(blockstate3, p_111168_, blockpos$mutableblockpos); float f3 = modelblockrenderer$cache.getShadeBrightness(blockstate3, p_111168_, blockpos$mutableblockpos); BlockState blockstate4 = p_111168_.getBlockState( -- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[0]).move(p_111171_) +- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[0]).move(p_366875_) + blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[0]) // Neo: remove move() to avoid oversampling (MC-43968) ); - boolean flag = !blockstate4.isViewBlocking(p_111168_, blockpos$mutableblockpos) - || blockstate4.getLightBlock(p_111168_, blockpos$mutableblockpos) == 0; + boolean flag = !blockstate4.isViewBlocking(p_111168_, blockpos$mutableblockpos) || blockstate4.getLightBlock() == 0; BlockState blockstate5 = p_111168_.getBlockState( -- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[1]).move(p_111171_) +- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[1]).move(p_366875_) + blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[1]) // Neo: remove move() to avoid oversampling (MC-43968) ); - boolean flag1 = !blockstate5.isViewBlocking(p_111168_, blockpos$mutableblockpos) - || blockstate5.getLightBlock(p_111168_, blockpos$mutableblockpos) == 0; + boolean flag1 = !blockstate5.isViewBlocking(p_111168_, blockpos$mutableblockpos) || blockstate5.getLightBlock() == 0; BlockState blockstate6 = p_111168_.getBlockState( -- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[2]).move(p_111171_) +- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[2]).move(p_366875_) + blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[2]) // Neo: remove move() to avoid oversampling (MC-43968) ); - boolean flag2 = !blockstate6.isViewBlocking(p_111168_, blockpos$mutableblockpos) - || blockstate6.getLightBlock(p_111168_, blockpos$mutableblockpos) == 0; + boolean flag2 = !blockstate6.isViewBlocking(p_111168_, blockpos$mutableblockpos) || blockstate6.getLightBlock() == 0; BlockState blockstate7 = p_111168_.getBlockState( -- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[3]).move(p_111171_) +- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[3]).move(p_366875_) + blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[3]) // Neo: remove move() to avoid oversampling (MC-43968) ); - boolean flag3 = !blockstate7.isViewBlocking(p_111168_, blockpos$mutableblockpos) - || blockstate7.getLightBlock(p_111168_, blockpos$mutableblockpos) == 0; + boolean flag3 = !blockstate7.isViewBlocking(p_111168_, blockpos$mutableblockpos) || blockstate7.getLightBlock() == 0; + float f4; diff --git a/patches/net/minecraft/client/renderer/block/model/BakedOverrides.java.patch b/patches/net/minecraft/client/renderer/block/model/BakedOverrides.java.patch new file mode 100644 index 00000000..60cb1a71 --- /dev/null +++ b/patches/net/minecraft/client/renderer/block/model/BakedOverrides.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/client/renderer/block/model/BakedOverrides.java ++++ b/net/minecraft/client/renderer/block/model/BakedOverrides.java +@@ -29,7 +_,15 @@ + this.properties = new ResourceLocation[0]; + } + ++ /** ++ * @deprecated Neo: Use {@link #BakedOverrides(ModelBaker, List, java.util.function.Function)} ++ */ ++ @Deprecated + public BakedOverrides(ModelBaker p_371950_, List p_371198_) { ++ this(p_371950_, p_371198_, p_371950_.getModelTextureGetter()); ++ } ++ ++ public BakedOverrides(ModelBaker p_371950_, List p_371198_, java.util.function.Function spriteGetter) { + this.properties = p_371198_.stream() + .flatMap(p_371945_ -> p_371945_.predicates().stream()) + .map(ItemOverride.Predicate::property) +@@ -45,7 +_,7 @@ + + for (int j = p_371198_.size() - 1; j >= 0; j--) { + ItemOverride itemoverride = p_371198_.get(j); +- BakedModel bakedmodel = p_371950_.bake(itemoverride.model(), BlockModelRotation.X0_Y0); ++ BakedModel bakedmodel = p_371950_.bake(itemoverride.model(), BlockModelRotation.X0_Y0, spriteGetter); + BakedOverrides.PropertyMatcher[] abakedoverrides$propertymatcher = itemoverride.predicates().stream().map(p_371644_ -> { + int k = object2intmap.getInt(p_371644_.property()); + return new BakedOverrides.PropertyMatcher(k, p_371644_.value()); +@@ -80,6 +_,10 @@ + } + + return null; ++ } ++ ++ public com.google.common.collect.ImmutableList getOverrides() { ++ return com.google.common.collect.ImmutableList.copyOf(overrides); + } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/net/minecraft/client/renderer/block/model/BakedQuad.java.patch b/patches/net/minecraft/client/renderer/block/model/BakedQuad.java.patch index fb47f0c8..4c6541f5 100644 --- a/patches/net/minecraft/client/renderer/block/model/BakedQuad.java.patch +++ b/patches/net/minecraft/client/renderer/block/model/BakedQuad.java.patch @@ -1,29 +1,30 @@ --- a/net/minecraft/client/renderer/block/model/BakedQuad.java +++ b/net/minecraft/client/renderer/block/model/BakedQuad.java -@@ -12,13 +_,19 @@ - protected final Direction direction; +@@ -13,14 +_,20 @@ protected final TextureAtlasSprite sprite; private final boolean shade; + private final int lightEmission; + private final boolean hasAmbientOcclusion; - public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_) { -+ this(p_111298_, p_111299_, p_111300_, p_111301_, p_111302_, true); + public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, int p_361140_) { ++ this(p_111298_, p_111299_, p_111300_, p_111301_, p_111302_, p_361140_, true); + } + -+ public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, boolean hasAmbientOcclusion) { ++ public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, int p_361140_, boolean hasAmbientOcclusion) { this.vertices = p_111298_; this.tintIndex = p_111299_; this.direction = p_111300_; this.sprite = p_111301_; this.shade = p_111302_; + this.lightEmission = p_361140_; + this.hasAmbientOcclusion = hasAmbientOcclusion; } public TextureAtlasSprite getSprite() { -@@ -43,5 +_,13 @@ +@@ -49,5 +_,13 @@ - public boolean isShade() { - return this.shade; + public int getLightEmission() { + return this.lightEmission; + } + + /** diff --git a/patches/net/minecraft/client/renderer/block/model/BlockElement.java.patch b/patches/net/minecraft/client/renderer/block/model/BlockElement.java.patch index eb9ddf91..c19fb03a 100644 --- a/patches/net/minecraft/client/renderer/block/model/BlockElement.java.patch +++ b/patches/net/minecraft/client/renderer/block/model/BlockElement.java.patch @@ -1,41 +1,44 @@ --- a/net/minecraft/client/renderer/block/model/BlockElement.java +++ b/net/minecraft/client/renderer/block/model/BlockElement.java -@@ -29,16 +_,23 @@ - public final Map faces; +@@ -30,6 +_,7 @@ public final BlockElementRotation rotation; public final boolean shade; + public final int lightEmission; + private net.neoforged.neoforge.client.model.ExtraFaceData faceData; - public BlockElement( - Vector3f p_253626_, Vector3f p_254426_, Map p_254454_, @Nullable BlockElementRotation p_254229_, boolean p_253661_ + public BlockElement(Vector3f p_253626_, Vector3f p_254426_, Map p_254454_) { + this(p_253626_, p_254426_, p_254454_, null, true, 0); +@@ -43,6 +_,10 @@ + boolean p_361372_, + int p_361908_ ) { -+ this(p_253626_, p_254426_, p_254454_, p_254229_, p_253661_, net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT); ++ this(p_361324_, p_363867_, p_362722_, p_360926_, p_361372_, p_361908_, net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT); + } + -+ public BlockElement(Vector3f p_253626_, Vector3f p_254426_, Map p_254454_, @Nullable BlockElementRotation p_254229_, boolean p_253661_, net.neoforged.neoforge.client.model.ExtraFaceData faceData) { - this.from = p_253626_; - this.to = p_254426_; - this.faces = p_254454_; - this.rotation = p_254229_; - this.shade = p_253661_; ++ public BlockElement(Vector3f p_361324_, Vector3f p_363867_, Map p_362722_, @Nullable BlockElementRotation p_360926_, boolean p_361372_, int p_361908_, net.neoforged.neoforge.client.model.ExtraFaceData faceData) { + this.from = p_361324_; + this.to = p_363867_; + this.faces = p_362722_; +@@ -50,6 +_,8 @@ + this.shade = p_361372_; + this.lightEmission = p_361908_; this.fillUvs(); + this.setFaceData(faceData); + this.faces.values().forEach(face -> face.parent().setValue(this)); } private void fillUvs() { -@@ -80,7 +_,9 @@ - throw new JsonParseException("Expected shade to be a Boolean"); - } else { - boolean flag = GsonHelper.getAsBoolean(jsonobject, "shade", true); -- return new BlockElement(vector3f, vector3f1, map, blockelementrotation, flag); -+ if (jsonobject.has("forge_data")) throw new JsonParseException("forge_data should be replaced by neoforge_data"); // TODO 1.22: Remove +@@ -104,7 +_,8 @@ + } + } + +- return new BlockElement(vector3f, vector3f1, map, blockelementrotation, flag, i); + var faceData = net.neoforged.neoforge.client.model.ExtraFaceData.read(jsonobject.get("neoforge_data"), net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT); -+ return new BlockElement(vector3f, vector3f1, map, blockelementrotation, flag, faceData); ++ return new BlockElement(vector3f, vector3f1, map, blockelementrotation, flag, i, faceData); } } -@@ -191,5 +_,13 @@ +@@ -215,5 +_,13 @@ return new Vector3f(afloat[0], afloat[1], afloat[2]); } } diff --git a/patches/net/minecraft/client/renderer/block/model/BlockModel.java.patch b/patches/net/minecraft/client/renderer/block/model/BlockModel.java.patch index b587befb..767bdb36 100644 --- a/patches/net/minecraft/client/renderer/block/model/BlockModel.java.patch +++ b/patches/net/minecraft/client/renderer/block/model/BlockModel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/model/BlockModel.java +++ b/net/minecraft/client/renderer/block/model/BlockModel.java -@@ -77,9 +_,10 @@ +@@ -72,9 +_,10 @@ public BlockModel parent; @Nullable protected ResourceLocation parentLocation; @@ -11,8 +11,8 @@ + return GsonHelper.fromJson(net.neoforged.neoforge.client.model.ExtendedBlockModelDeserializer.INSTANCE, p_111462_, BlockModel.class); } - public static BlockModel fromString(String p_111464_) { -@@ -104,10 +_,15 @@ + public BlockModel( +@@ -95,10 +_,15 @@ this.overrides = p_273099_; } @@ -28,42 +28,50 @@ public boolean hasAmbientOcclusion() { if (this.hasAmbientOcclusion != null) { return this.hasAmbientOcclusion; -@@ -136,6 +_,10 @@ - return this.overrides.isEmpty() ? ItemOverrides.EMPTY : new ItemOverrides(p_250138_, p_251800_, this.overrides); - } +@@ -132,10 +_,18 @@ -+ public ItemOverrides getOverrides(ModelBaker p_250138_, BlockModel p_251800_, Function spriteGetter) { -+ return this.overrides.isEmpty() ? ItemOverrides.EMPTY : new ItemOverrides(p_250138_, p_251800_, this.overrides, spriteGetter); -+ } -+ - @Override - public Collection getDependencies() { - Set set = Sets.newHashSet(); -@@ -184,6 +_,10 @@ - blockmodel.parent = (BlockModel)unbakedmodel; + this.parent = blockmodel; } - ++ + if (customData.hasCustomGeometry()) { -+ customData.getCustomGeometry().resolveParents(p_249059_, customData); ++ customData.getCustomGeometry().resolveDependencies(p_361203_, customData); + } -+ - this.overrides.forEach(p_247932_ -> { - UnbakedModel unbakedmodel1 = p_249059_.apply(p_247932_.getModel()); - if (!Objects.equals(unbakedmodel1, this)) { -@@ -198,6 +_,12 @@ } - public BakedModel bake( -+ ModelBaker p_249720_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, boolean p_111455_ -+ ) { -+ return net.neoforged.neoforge.client.model.geometry.UnbakedGeometryHelper.bake(this, p_249720_, p_111451_, p_111452_, p_111453_, p_111455_); -+ } + @Override + public BakedModel bake(ModelBaker p_252120_, Function p_250023_, ModelState p_251130_) { ++ var customGeometry = this.customData.getCustomGeometry(); ++ if (customGeometry != null) { ++ return customGeometry.bake(this.customData, p_252120_, p_250023_, p_251130_, this.overrides); ++ } + return this.bake(p_250023_, p_251130_, true); + } + +@@ -146,6 +_,10 @@ + } else { + SimpleBakedModel.Builder simplebakedmodel$builder = new SimpleBakedModel.Builder(this, p_111455_).particle(textureatlassprite); + ++ if (!this.customData.getRootTransform().isIdentity()) { ++ p_111453_ = net.neoforged.neoforge.client.model.geometry.UnbakedGeometryHelper.composeRootTransformIntoModelState(p_111453_, this.customData.getRootTransform()); ++ } + -+ public BakedModel bakeVanilla( - ModelBaker p_249720_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, boolean p_111455_ - ) { - TextureAtlasSprite textureatlassprite = p_111452_.apply(this.getMaterial("particle")); -@@ -288,7 +_,18 @@ + for (BlockElement blockelement : this.getElements()) { + for (Direction direction : blockelement.faces.keySet()) { + BlockElementFace blockelementface = blockelement.faces.get(direction); +@@ -161,7 +_,11 @@ + } + } + +- return simplebakedmodel$builder.build(); ++ var renderTypes = net.neoforged.neoforge.client.RenderTypeGroup.EMPTY; ++ if (this.customData.getRenderTypeHint() != null) { ++ renderTypes = this.customData.getRenderType(this.customData.getRenderTypeHint()); ++ } ++ return simplebakedmodel$builder.build(renderTypes); + } + } + +@@ -229,7 +_,18 @@ ItemTransform itemtransform5 = this.getTransform(ItemDisplayContext.GUI); ItemTransform itemtransform6 = this.getTransform(ItemDisplayContext.GROUND); ItemTransform itemtransform7 = this.getTransform(ItemDisplayContext.FIXED); @@ -83,12 +91,14 @@ } private ItemTransform getTransform(ItemDisplayContext p_270662_) { -@@ -407,6 +_,8 @@ +@@ -347,6 +_,10 @@ + public boolean lightLikeBlock() { return this == SIDE; - } ++ } + -+ public String getSerializedName() { return name; } ++ public String getSerializedName() { ++ return name; + } } - - @OnlyIn(Dist.CLIENT) + } diff --git a/patches/net/minecraft/client/renderer/block/model/FaceBakery.java.patch b/patches/net/minecraft/client/renderer/block/model/FaceBakery.java.patch index e24c7072..71b9c994 100644 --- a/patches/net/minecraft/client/renderer/block/model/FaceBakery.java.patch +++ b/patches/net/minecraft/client/renderer/block/model/FaceBakery.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/client/renderer/block/model/FaceBakery.java +++ b/net/minecraft/client/renderer/block/model/FaceBakery.java -@@ -57,7 +_,14 @@ +@@ -58,7 +_,14 @@ this.recalculateWinding(aint, direction); } -- return new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_); +- return new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, p_364857_); + net.neoforged.neoforge.client.ClientHooks.fillNormal(aint, direction); + var data = p_111603_.faceData(); -+ var quad = new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, data.ambientOcclusion()); ++ var quad = new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, p_364857_, data.ambientOcclusion()); + if (!net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT.equals(data)) { + net.neoforged.neoforge.client.model.QuadTransformers.applyingLightmap(data.blockLight(), data.skyLight()).processInPlace(quad); + net.neoforged.neoforge.client.model.QuadTransformers.applyingColor(data.color()).processInPlace(quad); diff --git a/patches/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch b/patches/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch deleted file mode 100644 index 13a802c1..00000000 --- a/patches/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/net/minecraft/client/renderer/block/model/ItemOverrides.java -+++ b/net/minecraft/client/renderer/block/model/ItemOverrides.java -@@ -31,7 +_,15 @@ - this.properties = new ResourceLocation[0]; - } - -+ /** -+ * @deprecated Forge: Use {@link #ItemOverrides(ModelBaker, UnbakedModel, List, java.util.function.Function)} -+ */ -+ @Deprecated - public ItemOverrides(ModelBaker p_251211_, BlockModel p_111741_, List p_111743_) { -+ this(p_251211_, p_111741_, p_111743_, p_251211_.getModelTextureGetter()); -+ } -+ -+ public ItemOverrides(ModelBaker p_251211_, UnbakedModel p_111741_, List p_111743_, java.util.function.Function spriteGetter) { - this.properties = p_111743_.stream() - .flatMap(ItemOverride::getPredicates) - .map(ItemOverride.Predicate::getProperty) -@@ -47,7 +_,7 @@ - - for (int j = p_111743_.size() - 1; j >= 0; j--) { - ItemOverride itemoverride = p_111743_.get(j); -- BakedModel bakedmodel = this.bakeModel(p_251211_, p_111741_, itemoverride); -+ BakedModel bakedmodel = this.bakeModel(p_251211_, p_111741_, itemoverride, spriteGetter); - ItemOverrides.PropertyMatcher[] aitemoverrides$propertymatcher = itemoverride.getPredicates().map(p_173477_ -> { - int k = object2intmap.getInt(p_173477_.getProperty()); - return new ItemOverrides.PropertyMatcher(k, p_173477_.getValue()); -@@ -59,9 +_,9 @@ - } - - @Nullable -- private BakedModel bakeModel(ModelBaker p_249483_, BlockModel p_251965_, ItemOverride p_250816_) { -+ private BakedModel bakeModel(ModelBaker p_249483_, UnbakedModel p_251965_, ItemOverride p_250816_, java.util.function.Function spriteGetter) { - UnbakedModel unbakedmodel = p_249483_.getModel(p_250816_.getModel()); -- return Objects.equals(unbakedmodel, p_251965_) ? null : p_249483_.bake(p_250816_.getModel(), BlockModelRotation.X0_Y0); -+ return Objects.equals(unbakedmodel, p_251965_) ? null : p_249483_.bake(p_250816_.getModel(), BlockModelRotation.X0_Y0, spriteGetter); - } - - @Nullable -@@ -93,6 +_,10 @@ - } - - return p_173465_; -+ } -+ -+ public com.google.common.collect.ImmutableList getOverrides() { -+ return com.google.common.collect.ImmutableList.copyOf(overrides); - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/net/minecraft/client/renderer/block/model/MultiVariant.java.patch b/patches/net/minecraft/client/renderer/block/model/MultiVariant.java.patch index 438e6177..bd74eaf2 100644 --- a/patches/net/minecraft/client/renderer/block/model/MultiVariant.java.patch +++ b/patches/net/minecraft/client/renderer/block/model/MultiVariant.java.patch @@ -1,11 +1,17 @@ --- a/net/minecraft/client/renderer/block/model/MultiVariant.java +++ b/net/minecraft/client/renderer/block/model/MultiVariant.java -@@ -68,7 +_,7 @@ - WeightedBakedModel.Builder weightedbakedmodel$builder = new WeightedBakedModel.Builder(); +@@ -45,12 +_,12 @@ + public BakedModel bake(ModelBaker p_249016_, Function p_111851_, ModelState p_111852_) { + if (this.variants.size() == 1) { + Variant variant1 = this.variants.getFirst(); +- return p_249016_.bake(variant1.getModelLocation(), variant1); ++ return p_249016_.bake(variant1.getModelLocation(), variant1, p_111851_); + } else { + SimpleWeightedRandomList.Builder builder = SimpleWeightedRandomList.builder(); - for (Variant variant : this.getVariants()) { + for (Variant variant : this.variants) { - BakedModel bakedmodel = p_249016_.bake(variant.getModelLocation(), variant); + BakedModel bakedmodel = p_249016_.bake(variant.getModelLocation(), variant, p_111851_); - weightedbakedmodel$builder.add(bakedmodel, variant.getWeight()); + builder.add(bakedmodel, variant.getWeight()); } diff --git a/patches/net/minecraft/client/renderer/blockentity/BannerRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/BannerRenderer.java.patch index c526f187..81cc3164 100644 --- a/patches/net/minecraft/client/renderer/blockentity/BannerRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/BannerRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/blockentity/BannerRenderer.java +++ b/net/minecraft/client/renderer/blockentity/BannerRenderer.java -@@ -139,4 +_,11 @@ +@@ -141,4 +_,11 @@ int i = p_332728_.getTextureDiffuseColor(); p_332732_.render(p_332737_, p_332704_.buffer(p_332758_, RenderType::entityNoOutline), p_332821_, p_332828_, i); } diff --git a/patches/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch index a79e2703..dc78f074 100644 --- a/patches/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/blockentity/ChestRenderer.java +++ b/net/minecraft/client/renderer/blockentity/ChestRenderer.java -@@ -128,7 +_,7 @@ +@@ -66,7 +_,7 @@ f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; int i = neighborcombineresult.apply(new BrightnessCombiner<>()).applyAsInt(p_112367_); @@ -9,10 +9,10 @@ VertexConsumer vertexconsumer = material.buffer(p_112366_, RenderType::entityCutout); if (flag1) { if (chesttype == ChestType.LEFT) { -@@ -159,5 +_,15 @@ - p_112372_.render(p_112370_, p_112371_, p_112376_, p_112377_); - p_112373_.render(p_112370_, p_112371_, p_112376_, p_112377_); - p_112374_.render(p_112370_, p_112371_, p_112376_, p_112377_); +@@ -85,5 +_,15 @@ + private void render(PoseStack p_112370_, VertexConsumer p_112371_, ChestModel p_364178_, float p_112375_, int p_112376_, int p_112377_) { + p_364178_.setupAnim(p_112375_); + p_364178_.renderToBuffer(p_112370_, p_112371_, p_112376_, p_112377_); + } + + protected Material getMaterial(T blockEntity, ChestType chestType) { diff --git a/patches/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java.patch index 35f7d562..90b0eb6a 100644 --- a/patches/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java +++ b/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java @@ -53,4 +_,10 @@ - this.bookModel.render(p_112420_, vertexconsumer, p_112422_, p_112423_, -1); + this.bookModel.renderToBuffer(p_112420_, vertexconsumer, p_112422_, p_112423_); p_112420_.popPose(); } + diff --git a/patches/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java.patch index 4bd58550..b1bd51f9 100644 --- a/patches/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java.patch @@ -1,13 +1,15 @@ --- a/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java +++ b/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java -@@ -56,4 +_,10 @@ - this.model.renderToBuffer(p_112480_, vertexconsumer, p_112482_, p_112483_); +@@ -55,6 +_,12 @@ p_112480_.popPose(); } -+ + + @Override + public net.minecraft.world.phys.AABB getRenderBoundingBox(ShulkerBoxBlockEntity blockEntity) { + net.minecraft.core.BlockPos pos = blockEntity.getBlockPos(); + return new net.minecraft.world.phys.AABB(pos.getX() - 0.5, pos.getY() - 0.5, pos.getZ() - 0.5, pos.getX() + 1.5, pos.getY() + 1.5, pos.getZ() + 1.5); + } - } ++ + @OnlyIn(Dist.CLIENT) + static class ShulkerBoxModel extends Model { + private final ModelPart lid; diff --git a/patches/net/minecraft/client/renderer/blockentity/SignRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/SignRenderer.java.patch index e4756dda..23ffcf89 100644 --- a/patches/net/minecraft/client/renderer/blockentity/SignRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/SignRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/blockentity/SignRenderer.java +++ b/net/minecraft/client/renderer/blockentity/SignRenderer.java -@@ -250,6 +_,15 @@ +@@ -251,6 +_,15 @@ return LayerDefinition.create(meshdefinition, 64, 32); } @@ -14,5 +14,5 @@ + } + @OnlyIn(Dist.CLIENT) - public static final class SignModel extends Model { - public final ModelPart root; + static record Models(Model standing, Model wall) { + } diff --git a/patches/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java.patch index 351d861b..7a43c83c 100644 --- a/patches/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java +++ b/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java @@ -57,4 +_,10 @@ - p_312703_.render(p_312223_, 0.0, 0.0, 0.0, 0.0F, p_311943_, p_312805_, p_312394_, p_311996_); + p_312703_.render(p_312223_, 0.0, 0.0, 0.0, p_311943_, p_312805_, p_312394_, p_311996_); p_312805_.popPose(); } + diff --git a/patches/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java.patch b/patches/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java.patch index 33e437bf..83ea06ba 100644 --- a/patches/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java.patch +++ b/patches/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java.patch @@ -1,47 +1,42 @@ --- a/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java +++ b/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java -@@ -441,14 +_,15 @@ +@@ -393,9 +_,10 @@ public SectionRenderDispatcher.RenderSection.CompileTask createCompileTask(RenderRegionCache p_295324_) { - boolean flag = this.cancelTasks(); -- RenderChunkRegion renderchunkregion = p_295324_.createRegion(SectionRenderDispatcher.this.level, SectionPos.of(this.origin)); + this.cancelTasks(); +- RenderChunkRegion renderchunkregion = p_295324_.createRegion(SectionRenderDispatcher.this.level, SectionPos.of(this.sectionNode)); + var additionalRenderers = net.neoforged.neoforge.client.ClientHooks.gatherAdditionalRenderers(this.origin, SectionRenderDispatcher.this.level); -+ RenderChunkRegion renderchunkregion = p_295324_.createRegion(SectionRenderDispatcher.this.level, SectionPos.of(this.origin), additionalRenderers.isEmpty()); - boolean flag1 = this.compiled.get() == SectionRenderDispatcher.CompiledSection.UNCOMPILED; - if (flag1 && flag) { - this.initialCompilationCancelCount.incrementAndGet(); - } - - this.lastRebuildTask = new SectionRenderDispatcher.RenderSection.RebuildTask( -- this.getDistToPlayerSqr(), renderchunkregion, !flag1 || this.initialCompilationCancelCount.get() > 2 -+ this.getDistToPlayerSqr(), renderchunkregion, !flag1 || this.initialCompilationCancelCount.get() > 2, additionalRenderers - ); ++ RenderChunkRegion renderchunkregion = p_295324_.createRegion(SectionRenderDispatcher.this.level, SectionPos.of(this.sectionNode), additionalRenderers.isEmpty()); + boolean flag = this.compiled.get() != SectionRenderDispatcher.CompiledSection.UNCOMPILED; +- this.lastRebuildTask = new SectionRenderDispatcher.RenderSection.RebuildTask(renderchunkregion, flag); ++ this.lastRebuildTask = new SectionRenderDispatcher.RenderSection.RebuildTask(renderchunkregion, flag, additionalRenderers); return this.lastRebuildTask; } -@@ -523,10 +_,17 @@ + +@@ -464,10 +_,17 @@ class RebuildTask extends SectionRenderDispatcher.RenderSection.CompileTask { @Nullable - protected RenderChunkRegion region; + protected volatile RenderChunkRegion region; + private final List additionalRenderers; + @Deprecated - public RebuildTask(double p_294400_, @Nullable RenderChunkRegion p_294382_, boolean p_295207_) { -+ this(p_294400_, p_294382_, p_295207_, List.of()); + public RebuildTask(@Nullable RenderChunkRegion p_294382_, boolean p_295207_) { ++ this(p_294382_, p_295207_, List.of()); + } + -+ public RebuildTask(double p_294400_, @Nullable RenderChunkRegion p_294382_, boolean p_295207_, List additionalRenderers) { - super(p_294400_, p_295207_); ++ public RebuildTask(@Nullable RenderChunkRegion p_294382_, boolean p_295207_, List additionalRenderers) { + super(p_295207_); this.region = p_294382_; + this.additionalRenderers = additionalRenderers; } @Override -@@ -552,7 +_,7 @@ - } else { - SectionPos sectionpos = SectionPos.of(RenderSection.this.origin); - SectionCompiler.Results sectioncompiler$results = SectionRenderDispatcher.this.sectionCompiler -- .compile(sectionpos, renderchunkregion, RenderSection.this.createVertexSorting(), p_296138_); -+ .compile(sectionpos, renderchunkregion, RenderSection.this.createVertexSorting(), p_296138_, this.additionalRenderers); - RenderSection.this.updateGlobalBlockEntities(sectioncompiler$results.globalBlockEntities); - if (this.isCancelled.get()) { - sectioncompiler$results.release(); +@@ -498,7 +_,7 @@ + SectionCompiler.Results sectioncompiler$results; + try (Zone zone = Profiler.get().zone("Compile Section")) { + sectioncompiler$results = SectionRenderDispatcher.this.sectionCompiler +- .compile(sectionpos, renderchunkregion, RenderSection.this.createVertexSorting(), p_296138_); ++ .compile(sectionpos, renderchunkregion, RenderSection.this.createVertexSorting(), p_296138_, this.additionalRenderers); + } + + SectionRenderDispatcher.TranslucencyPointOfView sectionrenderdispatcher$translucencypointofview = SectionRenderDispatcher.TranslucencyPointOfView.of( diff --git a/patches/net/minecraft/client/renderer/culling/Frustum.java.patch b/patches/net/minecraft/client/renderer/culling/Frustum.java.patch index 92a6b521..9dc2e4ad 100644 --- a/patches/net/minecraft/client/renderer/culling/Frustum.java.patch +++ b/patches/net/minecraft/client/renderer/culling/Frustum.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/renderer/culling/Frustum.java +++ b/net/minecraft/client/renderer/culling/Frustum.java -@@ -70,6 +_,8 @@ +@@ -71,6 +_,8 @@ } public boolean isVisible(AABB p_113030_) { + // FORGE: exit early for infinite bounds, these would otherwise fail in the intersection test at certain camera angles (GH-9321) + if (p_113030_.isInfinite()) return true; - return this.cubeInFrustum(p_113030_.minX, p_113030_.minY, p_113030_.minZ, p_113030_.maxX, p_113030_.maxY, p_113030_.maxZ); + int i = this.cubeInFrustum(p_113030_.minX, p_113030_.minY, p_113030_.minZ, p_113030_.maxX, p_113030_.maxY, p_113030_.maxZ); + return i == -2 || i == -1; } - diff --git a/patches/net/minecraft/client/renderer/entity/BoatRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/BoatRenderer.java.patch deleted file mode 100644 index efa87185..00000000 --- a/patches/net/minecraft/client/renderer/entity/BoatRenderer.java.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/BoatRenderer.java -+++ b/net/minecraft/client/renderer/entity/BoatRenderer.java -@@ -45,7 +_,7 @@ - private ListModel createBoatModel(EntityRendererProvider.Context p_248834_, Boat.Type p_249317_, boolean p_250093_) { - ModelLayerLocation modellayerlocation = p_250093_ ? ModelLayers.createChestBoatModelName(p_249317_) : ModelLayers.createBoatModelName(p_249317_); - ModelPart modelpart = p_248834_.bakeLayer(modellayerlocation); -- if (p_249317_ == Boat.Type.BAMBOO) { -+ if (p_249317_.isRaft()) { - return (ListModel)(p_250093_ ? new ChestRaftModel(modelpart) : new RaftModel(modelpart)); - } else { - return (ListModel)(p_250093_ ? new ChestBoatModel(modelpart) : new BoatModel(modelpart)); -@@ -54,8 +_,8 @@ - - private static ResourceLocation getTextureLocation(Boat.Type p_234566_, boolean p_234567_) { - return p_234567_ -- ? ResourceLocation.withDefaultNamespace("textures/entity/chest_boat/" + p_234566_.getName() + ".png") -- : ResourceLocation.withDefaultNamespace("textures/entity/boat/" + p_234566_.getName() + ".png"); -+ ? ResourceLocation.parse(p_234566_.getName()).withPrefix("textures/entity/chest_boat/").withSuffix(".png") -+ : ResourceLocation.parse(p_234566_.getName()).withPrefix("textures/entity/boat/").withSuffix(".png"); - } - - public void render(Boat p_113929_, float p_113930_, float p_113931_, PoseStack p_113932_, MultiBufferSource p_113933_, int p_113934_) { -@@ -77,7 +_,7 @@ - p_113932_.mulPose(new Quaternionf().setAngleAxis(p_113929_.getBubbleAngle(p_113931_) * (float) (Math.PI / 180.0), 1.0F, 0.0F, 1.0F)); - } - -- Pair> pair = this.boatResources.get(p_113929_.getVariant()); -+ Pair> pair = getModelWithLocation(p_113929_); - ResourceLocation resourcelocation = pair.getFirst(); - ListModel listmodel = pair.getSecond(); - p_113932_.scale(-1.0F, -1.0F, 1.0F); -@@ -96,7 +_,12 @@ - super.render(p_113929_, p_113930_, p_113931_, p_113932_, p_113933_, p_113934_); - } - -+ @Deprecated // forge: override getModelWithLocation to change the texture / model - public ResourceLocation getTextureLocation(Boat p_113927_) { -- return this.boatResources.get(p_113927_.getVariant()).getFirst(); -+ return getModelWithLocation(p_113927_).getFirst(); -+ } -+ -+ public Pair> getModelWithLocation(Boat boat) { -+ return this.boatResources.get(boat.getVariant()); - } - } diff --git a/patches/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch b/patches/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch index d1dd832f..49c59060 100644 --- a/patches/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch +++ b/patches/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java +++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java -@@ -222,12 +_,12 @@ +@@ -243,12 +_,12 @@ ) { AABB aabb = p_114444_.getBoundingBox().move(-p_114444_.getX(), -p_114444_.getY(), -p_114444_.getZ()); - LevelRenderer.renderLineBox(p_114442_, p_114443_, aabb, p_353064_, p_353059_, p_353042_, 1.0F); + ShapeRenderer.renderLineBox(p_114442_, p_114443_, aabb, p_353064_, p_353059_, p_353042_, 1.0F); - if (p_114444_ instanceof EnderDragon) { + if (p_114444_.isMultipartEntity()) { double d0 = -Mth.lerp((double)p_114445_, p_114444_.xOld, p_114444_.getX()); @@ -15,18 +15,18 @@ p_114442_.pushPose(); double d3 = d0 + Mth.lerp((double)p_114445_, enderdragonpart.xOld, enderdragonpart.getX()); double d4 = d1 + Mth.lerp((double)p_114445_, enderdragonpart.yOld, enderdragonpart.getY()); -@@ -467,6 +_,10 @@ +@@ -474,6 +_,10 @@ return this.itemInHandRenderer; } -+ public Map> getSkinMap() { ++ public Map> getSkinMap() { + return java.util.Collections.unmodifiableMap(playerRenderers); + } + @Override public void onResourceManagerReload(ResourceManager p_174004_) { EntityRendererProvider.Context entityrendererprovider$context = new EntityRendererProvider.Context( -@@ -474,5 +_,6 @@ +@@ -481,5 +_,6 @@ ); this.renderers = EntityRenderers.createEntityRenderers(entityrendererprovider$context); this.playerRenderers = EntityRenderers.createPlayerRenderers(entityrendererprovider$context); diff --git a/patches/net/minecraft/client/renderer/entity/EntityRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/EntityRenderer.java.patch index 86142b36..2e7b86b2 100644 --- a/patches/net/minecraft/client/renderer/entity/EntityRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/EntityRenderer.java.patch @@ -1,25 +1,33 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderer.java +++ b/net/minecraft/client/renderer/entity/EntityRenderer.java -@@ -94,8 +_,11 @@ - } +@@ -105,6 +_,8 @@ } -- if (this.shouldShowName(p_114485_)) { -- this.renderNameTag(p_114485_, p_114485_.getDisplayName(), p_114488_, p_114489_, p_114490_, p_114487_); -+ // Neo: Post the RenderNameTagEvent and conditionally wrap #renderNameTag based on the result. -+ var event = new net.neoforged.neoforge.client.event.RenderNameTagEvent(p_114485_, p_114485_.getDisplayName(), this, p_114488_, p_114489_, p_114490_, p_114487_); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event); -+ if (event.canRender().isTrue() || event.canRender().isDefault() && this.shouldShowName(p_114485_)) { -+ this.renderNameTag(p_114485_, event.getContent(), p_114488_, p_114489_, p_114490_, p_114487_); + if (p_364816_.nameTag != null) { ++ var event = new net.neoforged.neoforge.client.event.RenderNameTagEvent.DoRender(p_364816_, p_364816_.nameTag, this, p_114488_, p_114489_, p_114490_, p_364816_.partialTick); ++ if (!net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event).isCanceled()) + this.renderNameTag(p_364816_, p_364816_.nameTag, p_114488_, p_114489_, p_114490_); } } +@@ -270,7 +_,12 @@ + } -@@ -181,7 +_,7 @@ + p_361028_.distanceToCameraSq = this.entityRenderDispatcher.distanceToSqr(p_362104_); +- boolean flag = p_361028_.distanceToCameraSq < 4096.0 && this.shouldShowName(p_362104_, p_361028_.distanceToCameraSq); ++ boolean flag = p_361028_.distanceToCameraSq < 4096.0; ++ if (flag) { ++ var event = new net.neoforged.neoforge.client.event.RenderNameTagEvent.CanRender(p_362104_, p_361028_, p_362104_.getDisplayName(), this, p_362204_); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event); ++ flag = event.canRender().isTrue() || (event.canRender().isDefault() && this.shouldShowName(p_362104_, p_361028_.distanceToCameraSq)); ++ } + if (flag) { + p_361028_.nameTag = this.getNameTag(p_362104_); + p_361028_.nameTagAttachment = p_362104_.getAttachments().getNullable(EntityAttachment.NAME_TAG, 0, p_362104_.getYRot(p_362204_)); +@@ -302,5 +_,7 @@ + } - protected void renderNameTag(T p_114498_, Component p_114499_, PoseStack p_114500_, MultiBufferSource p_114501_, int p_114502_, float p_316698_) { - double d0 = this.entityRenderDispatcher.distanceToSqr(p_114498_); -- if (!(d0 > 4096.0)) { -+ if (net.neoforged.neoforge.client.ClientHooks.isNameplateInRenderDistance(p_114498_, d0)) { - Vec3 vec3 = p_114498_.getAttachments().getNullable(EntityAttachment.NAME_TAG, 0, p_114498_.getViewYRot(p_316698_)); - if (vec3 != null) { - boolean flag = !p_114498_.isDiscrete(); + p_361028_.displayFireAnimation = p_362104_.displayFireAnimation(); ++ ++ p_361028_.partialTick = p_362204_; + } + } diff --git a/patches/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch index 836cad28..0e7a50f6 100644 --- a/patches/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/client/renderer/entity/FallingBlockRenderer.java +++ b/net/minecraft/client/renderer/entity/FallingBlockRenderer.java -@@ -34,6 +_,8 @@ - p_114637_.pushPose(); - BlockPos blockpos = BlockPos.containing(p_114634_.getX(), p_114634_.getBoundingBox().maxY, p_114634_.getZ()); - p_114637_.translate(-0.5, 0.0, -0.5); -+ var model = this.dispatcher.getBlockModel(blockstate); -+ for (var renderType : model.getRenderTypes(blockstate, RandomSource.create(blockstate.getSeed(p_114634_.getStartPos())), net.neoforged.neoforge.client.model.data.ModelData.EMPTY)) - this.dispatcher - .getModelRenderer() - .tesselateBlock( -@@ -42,11 +_,13 @@ - blockstate, - blockpos, - p_114637_, -- p_114638_.getBuffer(ItemBlockRenderTypes.getMovingBlockRenderType(blockstate)), -+ p_114638_.getBuffer(net.neoforged.neoforge.client.RenderTypeHelper.getMovingBlockRenderType(renderType)), - false, - RandomSource.create(), - blockstate.getSeed(p_114634_.getStartPos()), -- OverlayTexture.NO_OVERLAY -+ OverlayTexture.NO_OVERLAY, -+ net.neoforged.neoforge.client.model.data.ModelData.EMPTY, -+ renderType - ); - p_114637_.popPose(); - super.render(p_114634_, p_114635_, p_114636_, p_114637_, p_114638_, p_114639_); +@@ -36,6 +_,8 @@ + if (blockstate.getRenderShape() == RenderShape.MODEL) { + p_114637_.pushPose(); + p_114637_.translate(-0.5, 0.0, -0.5); ++ var model = this.dispatcher.getBlockModel(blockstate); ++ for (var renderType : model.getRenderTypes(blockstate, RandomSource.create(blockstate.getSeed(p_361300_.startBlockPos)), net.neoforged.neoforge.client.model.data.ModelData.EMPTY)) + this.dispatcher + .getModelRenderer() + .tesselateBlock( +@@ -44,11 +_,13 @@ + blockstate, + p_361300_.blockPos, + p_114637_, +- p_114638_.getBuffer(ItemBlockRenderTypes.getMovingBlockRenderType(blockstate)), ++ p_114638_.getBuffer(net.neoforged.neoforge.client.RenderTypeHelper.getMovingBlockRenderType(renderType)), + false, + RandomSource.create(), + blockstate.getSeed(p_361300_.startBlockPos), +- OverlayTexture.NO_OVERLAY ++ OverlayTexture.NO_OVERLAY, ++ net.neoforged.neoforge.client.model.data.ModelData.EMPTY, ++ renderType + ); + p_114637_.popPose(); + super.render(p_361300_, p_114637_, p_114638_, p_114639_); diff --git a/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch index 77ce7e70..6747d9fd 100644 --- a/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/FishingHookRenderer.java +++ b/net/minecraft/client/renderer/entity/FishingHookRenderer.java -@@ -64,7 +_,7 @@ +@@ -63,7 +_,7 @@ private Vec3 getPlayerHandPos(Player p_340935_, float p_340872_, float p_341261_) { int i = p_340935_.getMainArm() == HumanoidArm.RIGHT ? 1 : -1; ItemStack itemstack = p_340935_.getMainHandItem(); diff --git a/patches/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch new file mode 100644 index 00000000..fa562476 --- /dev/null +++ b/patches/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java ++++ b/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java +@@ -40,7 +_,7 @@ + p_362998_.isCrouching = p_365104_.isCrouching(); + p_362998_.isFallFlying = p_365104_.isFallFlying(); + p_362998_.isVisuallySwimming = p_365104_.isVisuallySwimming(); +- p_362998_.isPassenger = p_365104_.isPassenger(); ++ p_362998_.isPassenger = p_365104_.isPassenger() && (p_365104_.getVehicle() != null && p_365104_.getVehicle().shouldRiderSit()); + p_362998_.speedValue = 1.0F; + if (p_362998_.isFallFlying) { + p_362998_.speedValue = (float)p_365104_.getDeltaMovement().lengthSqr(); diff --git a/patches/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch index 7412c8c3..52951841 100644 --- a/patches/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/client/renderer/entity/ItemEntityRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemEntityRenderer.java -@@ -45,7 +_,8 @@ - BakedModel bakedmodel = this.itemRenderer.getModel(itemstack, p_115036_.level(), null, p_115036_.getId()); - boolean flag = bakedmodel.isGui3d(); - float f = 0.25F; -- float f1 = Mth.sin(((float)p_115036_.getAge() + p_115038_) / 10.0F + p_115036_.bobOffs) * 0.1F + 0.1F; -+ boolean shouldBob = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).shouldBobAsEntity(itemstack); -+ float f1 = shouldBob ? Mth.sin(((float)p_115036_.getAge() + p_115038_) / 10.0F + p_115036_.bobOffs) * 0.1F + 0.1F : 0; - float f2 = bakedmodel.getTransforms().getTransform(ItemDisplayContext.GROUND).scale.y(); - p_115039_.translate(0.0F, f1 + 0.25F * f2, 0.0F); - float f3 = p_115036_.getSpin(p_115038_); -@@ -100,9 +_,10 @@ +@@ -54,7 +_,8 @@ + this.random.setSeed((long)getSeedForItemStack(itemstack)); + boolean flag = bakedmodel.isGui3d(); + float f = 0.25F; +- float f1 = Mth.sin(p_362172_.ageInTicks / 10.0F + p_362172_.bobOffset) * 0.1F + 0.1F; ++ boolean shouldBob = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).shouldBobAsEntity(itemstack); ++ float f1 = shouldBob ? Mth.sin(p_362172_.ageInTicks / 10.0F + p_362172_.bobOffset) * 0.1F + 0.1F : 0; + float f2 = bakedmodel.getTransforms().getTransform(ItemDisplayContext.GROUND).scale.y(); + p_115030_.translate(0.0F, f1 + 0.25F * f2, 0.0F); + float f3 = ItemEntity.getSpin(p_362172_.ageInTicks, p_362172_.bobOffset); +@@ -110,9 +_,10 @@ p_323733_.translate(f3, f4, f5); } diff --git a/patches/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch index d2db3be4..7fe0bf49 100644 --- a/patches/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch @@ -1,50 +1,27 @@ --- a/net/minecraft/client/renderer/entity/ItemFrameRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemFrameRenderer.java -@@ -84,25 +_,25 @@ - } - - if (!itemstack.isEmpty()) { -- MapId mapid = p_115076_.getFramedMapId(itemstack); -+ MapItemSavedData mapitemsaveddata = MapItem.getSavedData(itemstack, p_115076_.level()); - if (flag) { - p_115079_.translate(0.0F, 0.0F, 0.5F); - } else { - p_115079_.translate(0.0F, 0.0F, 0.4375F); - } +@@ -100,6 +_,7 @@ -- int j = mapid != null ? p_115076_.getRotation() % 4 * 2 : p_115076_.getRotation(); -+ int j = mapitemsaveddata != null ? p_115076_.getRotation() % 4 * 2 : p_115076_.getRotation(); + int j = mapid != null ? p_364723_.rotation % 4 * 2 : p_364723_.rotation; p_115079_.mulPose(Axis.ZP.rotationDegrees((float)j * 360.0F / 8.0F)); -- if (mapid != null) { -+ if (!net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderItemInFrameEvent(p_115076_, this, p_115079_, p_115080_, p_115081_)).isCanceled()) { -+ if (mapitemsaveddata != null) { ++ if (!net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderItemInFrameEvent(p_364723_, this, p_115079_, p_115080_, p_115081_)).isCanceled()) { + if (mapid != null) { p_115079_.mulPose(Axis.ZP.rotationDegrees(180.0F)); - float f = 0.0078125F; - p_115079_.scale(0.0078125F, 0.0078125F, 0.0078125F); - p_115079_.translate(-64.0F, -64.0F, 0.0F); -- MapItemSavedData mapitemsaveddata = MapItem.getSavedData(mapid, p_115076_.level()); - p_115079_.translate(0.0F, 0.0F, -1.0F); - if (mapitemsaveddata != null) { - int i = this.getLightVal(p_115076_, 15728850, p_115081_); -- Minecraft.getInstance().gameRenderer.getMapRenderer().render(p_115079_, p_115080_, mapid, mapitemsaveddata, true, i); -+ Minecraft.getInstance().gameRenderer.getMapRenderer().render(p_115079_, p_115080_, p_115076_.getFramedMapId(itemstack), mapitemsaveddata, true, i); - } - } else { - int k = this.getLightVal(p_115076_, 15728880, p_115081_); -@@ -110,6 +_,7 @@ - this.itemRenderer - .renderStatic(itemstack, ItemDisplayContext.FIXED, k, OverlayTexture.NO_OVERLAY, p_115079_, p_115080_, p_115076_.level(), p_115076_.getId()); + float f2 = 0.0078125F; +@@ -113,6 +_,7 @@ + p_115079_.scale(0.5F, 0.5F, 0.5F); + this.itemRenderer.render(itemstack, ItemDisplayContext.FIXED, false, p_115079_, p_115080_, k, OverlayTexture.NO_OVERLAY, p_364723_.itemModel); } + } } p_115079_.popPose(); -@@ -121,7 +_,7 @@ - - private ModelResourceLocation getFrameModelResourceLoc(T p_174213_, ItemStack p_174214_) { - boolean flag = p_174213_.getType() == EntityType.GLOW_ITEM_FRAME; -- if (p_174214_.is(Items.FILLED_MAP)) { -+ if (p_174214_.getItem() instanceof MapItem) { - return flag ? GLOW_MAP_FRAME_LOCATION : MAP_FRAME_LOCATION; - } else { - return flag ? GLOW_FRAME_LOCATION : FRAME_LOCATION; +@@ -161,7 +_,7 @@ + if (!p_362907_.itemStack.isEmpty()) { + MapId mapid = p_363125_.getFramedMapId(itemstack); + if (mapid != null) { +- MapItemSavedData mapitemsaveddata = p_363125_.level().getMapData(mapid); ++ MapItemSavedData mapitemsaveddata = net.minecraft.world.item.MapItem.getSavedData(itemstack, p_363125_.level()); + if (mapitemsaveddata != null) { + this.mapRenderer.extractRenderState(mapid, mapitemsaveddata, p_362907_.mapRenderState); + p_362907_.mapId = mapid; diff --git a/patches/net/minecraft/client/renderer/entity/ItemRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/ItemRenderer.java.patch index 67b1f7c5..a53ce7e0 100644 --- a/patches/net/minecraft/client/renderer/entity/ItemRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/ItemRenderer.java.patch @@ -1,63 +1,54 @@ --- a/net/minecraft/client/renderer/entity/ItemRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemRenderer.java -@@ -70,7 +_,7 @@ - public ItemRenderer(Minecraft p_266926_, TextureManager p_266774_, ModelManager p_266850_, ItemColors p_267016_, BlockEntityWithoutLevelRenderer p_267049_) { - this.minecraft = p_266926_; - this.textureManager = p_266774_; -- this.itemModelShaper = new ItemModelShaper(p_266850_); -+ this.itemModelShaper = new net.neoforged.neoforge.client.model.RegistryAwareItemModelShaper(p_266850_); - this.blockEntityRenderer = p_267049_; - - for (Item item : BuiltInRegistries.ITEM) { -@@ -120,7 +_,7 @@ - } +@@ -156,7 +_,7 @@ + float p_371782_ + ) { + p_371635_.pushPose(); +- p_371384_.getTransforms().getTransform(p_371250_).apply(p_371248_, p_371635_); ++ p_371384_ = net.neoforged.neoforge.client.ClientHooks.handleCameraTransforms(p_371635_, p_371384_, p_371250_, p_371248_); + p_371635_.translate(-0.5F, -0.5F, p_371782_); + this.renderItem(p_371318_, p_371250_, p_371635_, p_371946_, p_371752_, p_371508_, p_371384_, p_371718_); + p_371635_.popPose(); +@@ -173,7 +_,8 @@ + boolean p_364829_ + ) { + if (!p_363970_.isCustomRenderer() && (!p_361397_.is(Items.TRIDENT) || p_364829_)) { +- RenderType rendertype = ItemBlockRenderTypes.getRenderType(p_361397_); ++ for (var model : p_363970_.getRenderPasses(p_361397_)) { ++ for (var rendertype : model.getRenderTypes(p_361397_)) { + VertexConsumer vertexconsumer; + if (hasAnimatedTexture(p_361397_) && p_361397_.hasFoil()) { + PoseStack.Pose posestack$pose = p_360423_.last().copy(); +@@ -188,9 +_,11 @@ + vertexconsumer = getFoilBuffer(p_360415_, rendertype, true, p_361397_.hasFoil()); } -- p_115151_.getTransforms().getTransform(p_270188_).apply(p_115146_, p_115147_); -+ p_115151_ = net.neoforged.neoforge.client.ClientHooks.handleCameraTransforms(p_115147_, p_115151_, p_270188_, p_115146_); - p_115147_.translate(-0.5F, -0.5F, -0.5F); - if (!p_115151_.isCustomRenderer() && (!p_115144_.is(Items.TRIDENT) || flag)) { - boolean flag1; -@@ -131,7 +_,8 @@ - flag1 = true; - } - -- RenderType rendertype = ItemBlockRenderTypes.getRenderType(p_115144_, flag1); -+ for (var model : p_115151_.getRenderPasses(p_115144_, flag1)) { -+ for (var rendertype : model.getRenderTypes(p_115144_, flag1)) { - VertexConsumer vertexconsumer; - if (hasAnimatedTexture(p_115144_) && p_115144_.hasFoil()) { - PoseStack.Pose posestack$pose = p_115147_.last().copy(); -@@ -148,9 +_,11 @@ - vertexconsumer = getFoilBuffer(p_115148_, rendertype, true, p_115144_.hasFoil()); - } - -- this.renderModelLists(p_115151_, p_115144_, p_115149_, p_115150_, p_115147_, vertexconsumer); -+ this.renderModelLists(model, p_115144_, p_115149_, p_115150_, p_115147_, vertexconsumer); -+ } -+ } - } else { -- this.blockEntityRenderer.renderByItem(p_115144_, p_270188_, p_115147_, p_115148_, p_115149_, p_115150_); -+ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(p_115144_).getCustomRenderer().renderByItem(p_115144_, p_270188_, p_115147_, p_115148_, p_115149_, p_115150_); - } +- this.renderModelLists(p_363970_, p_361397_, p_361265_, p_364771_, p_360423_, vertexconsumer); ++ this.renderModelLists(model, p_361397_, p_361265_, p_364771_, p_360423_, vertexconsumer); ++ } ++ } + } else { +- this.blockEntityRenderer.renderByItem(p_361397_, p_361627_, p_360423_, p_360415_, p_361265_, p_364771_); ++ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(p_361397_).getCustomRenderer().renderByItem(p_361397_, p_361627_, p_360423_, p_360415_, p_361265_, p_364771_); + } + } - p_115147_.popPose(); -@@ -203,7 +_,7 @@ - float f1 = (float)FastColor.ARGB32.red(i) / 255.0F; - float f2 = (float)FastColor.ARGB32.green(i) / 255.0F; - float f3 = (float)FastColor.ARGB32.blue(i) / 255.0F; +@@ -238,7 +_,7 @@ + float f1 = (float)ARGB.red(i) / 255.0F; + float f2 = (float)ARGB.green(i) / 255.0F; + float f3 = (float)ARGB.blue(i) / 255.0F; - p_115164_.putBulkData(posestack$pose, bakedquad, f1, f2, f3, f, p_115167_, p_115168_); + p_115164_.putBulkData(posestack$pose, bakedquad, f1, f2, f3, f, p_115167_, p_115168_, true); // Neo: pass readExistingColor=true } } -@@ -256,5 +_,9 @@ - @Override - public void onResourceManagerReload(ResourceManager p_115105_) { - this.itemModelShaper.rebuildCache(); +@@ -294,5 +_,9 @@ + ClientLevel clientlevel = p_372942_ instanceof ClientLevel ? (ClientLevel)p_372942_ : null; + BakedModel bakedmodel = p_373094_.overrides().findOverride(p_372923_, clientlevel, p_373099_, p_372933_); + return bakedmodel == null ? p_373094_ : bakedmodel; + } + + public BlockEntityWithoutLevelRenderer getBlockEntityRenderer() { -+ return blockEntityRenderer; ++ return blockEntityRenderer; } } diff --git a/patches/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch index 77ec1121..8322d59b 100644 --- a/patches/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch @@ -1,38 +1,36 @@ --- a/net/minecraft/client/renderer/entity/LivingEntityRenderer.java +++ b/net/minecraft/client/renderer/entity/LivingEntityRenderer.java -@@ -50,14 +_,16 @@ +@@ -69,6 +_,7 @@ } - public void render(T p_115308_, float p_115309_, float p_115310_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { -+ if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderLivingEvent.Pre(p_115308_, this, p_115310_, p_115311_, p_115312_, p_115313_)).isCanceled()) return; + public void render(S p_361886_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { ++ if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderLivingEvent.Pre(p_361886_, this, p_361886_.partialTick, p_115311_, p_115312_, p_115313_)).isCanceled()) return; p_115311_.pushPose(); - this.model.attackTime = this.getAttackAnim(p_115308_, p_115310_); -- this.model.riding = p_115308_.isPassenger(); -+ boolean shouldSit = p_115308_.isPassenger() && (p_115308_.getVehicle() != null && p_115308_.getVehicle().shouldRiderSit()); -+ this.model.riding = shouldSit; - this.model.young = p_115308_.isBaby(); - float f = Mth.rotLerp(p_115310_, p_115308_.yBodyRotO, p_115308_.yBodyRot); - float f1 = Mth.rotLerp(p_115310_, p_115308_.yHeadRotO, p_115308_.yHeadRot); - float f2 = f1 - f; -- if (p_115308_.isPassenger() && p_115308_.getVehicle() instanceof LivingEntity livingentity) { -+ if (shouldSit && p_115308_.getVehicle() instanceof LivingEntity livingentity) { - f = Mth.rotLerp(p_115310_, livingentity.yBodyRotO, livingentity.yBodyRot); - f2 = f1 - f; - float f7 = Mth.wrapDegrees(f2); -@@ -101,7 +_,7 @@ - p_115311_.translate(0.0F, -1.501F, 0.0F); - float f4 = 0.0F; - float f5 = 0.0F; -- if (!p_115308_.isPassenger() && p_115308_.isAlive()) { -+ if (!shouldSit && p_115308_.isAlive()) { - f4 = p_115308_.walkAnimation.speed(p_115310_); - f5 = p_115308_.walkAnimation.position(p_115310_); - if (p_115308_.isBaby()) { -@@ -134,6 +_,7 @@ + if (p_361886_.hasPose(Pose.SLEEPING)) { + Direction direction = p_361886_.bedOrientation; +@@ -104,6 +_,7 @@ p_115311_.popPose(); - super.render(p_115308_, p_115309_, p_115310_, p_115311_, p_115312_, p_115313_); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderLivingEvent.Post(p_115308_, this, p_115310_, p_115311_, p_115312_, p_115313_)); + super.render(p_361886_, p_115311_, p_115312_, p_115313_); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderLivingEvent.Post(p_361886_, this, p_361886_.partialTick, p_115311_, p_115312_, p_115313_)); } - @Nullable + protected boolean shouldRenderLayers(S p_364697_) { +@@ -201,7 +_,7 @@ + protected boolean shouldShowName(T p_363517_, double p_365448_) { + if (p_363517_.isDiscrete()) { + float f = 32.0F; +- if (p_365448_ >= 1024.0) { ++ if (!net.neoforged.neoforge.client.ClientHooks.isNameplateInRenderDistance(p_363517_, p_365448_)) { + return false; + } + } +@@ -284,7 +_,7 @@ + + p_360515_.isFullyFrozen = p_362733_.isFullyFrozen(); + p_360515_.isBaby = p_362733_.isBaby(); +- p_360515_.isInWater = p_362733_.isInWater(); ++ p_360515_.isInWater = p_362733_.isInWater() || p_362733_.isInFluidType((fluidType, height) -> p_362733_.canSwimInFluidType(fluidType)); + p_360515_.isAutoSpinAttack = p_362733_.isAutoSpinAttack(); + p_360515_.hasRedOverlay = p_362733_.hurtTime > 0 || p_362733_.deathTime > 0; + ItemStack itemstack1 = p_362733_.getItemBySlot(EquipmentSlot.HEAD); diff --git a/patches/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch b/patches/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch deleted file mode 100644 index d64f1997..00000000 --- a/patches/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/layers/ElytraLayer.java -+++ b/net/minecraft/client/renderer/entity/layers/ElytraLayer.java -@@ -45,7 +_,7 @@ - float p_116960_ - ) { - ItemStack itemstack = p_116954_.getItemBySlot(EquipmentSlot.CHEST); -- if (itemstack.is(Items.ELYTRA)) { -+ if (shouldRender(itemstack, p_116954_)) { - ResourceLocation resourcelocation; - if (p_116954_ instanceof AbstractClientPlayer abstractclientplayer) { - PlayerSkin playerskin = abstractclientplayer.getSkin(); -@@ -54,10 +_,10 @@ - } else if (playerskin.capeTexture() != null && abstractclientplayer.isModelPartShown(PlayerModelPart.CAPE)) { - resourcelocation = playerskin.capeTexture(); - } else { -- resourcelocation = WINGS_LOCATION; -+ resourcelocation = getElytraTexture(itemstack, p_116954_); - } - } else { -- resourcelocation = WINGS_LOCATION; -+ resourcelocation = getElytraTexture(itemstack, p_116954_); - } - - p_116951_.pushPose(); -@@ -68,5 +_,30 @@ - this.elytraModel.renderToBuffer(p_116951_, vertexconsumer, p_116953_, OverlayTexture.NO_OVERLAY); - p_116951_.popPose(); - } -+ } -+ -+ /** -+ * Determines if the ElytraLayer should render. -+ * ItemStack and Entity are provided for modder convenience, -+ * For example, using the same ElytraLayer for multiple custom Elytra. -+ * -+ * @param stack The Elytra ItemStack -+ * @param entity The entity being rendered. -+ * @return If the ElytraLayer should render. -+ */ -+ public boolean shouldRender(ItemStack stack, T entity) { -+ return stack.getItem() == Items.ELYTRA; -+ } -+ -+ /** -+ * Gets the texture to use with this ElytraLayer. -+ * This assumes the vanilla Elytra model. -+ * -+ * @param stack The Elytra ItemStack. -+ * @param entity The entity being rendered. -+ * @return The texture. -+ */ -+ public ResourceLocation getElytraTexture(ItemStack stack, T entity) { -+ return WINGS_LOCATION; - } - } diff --git a/patches/net/minecraft/client/renderer/entity/layers/EquipmentLayerRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/layers/EquipmentLayerRenderer.java.patch new file mode 100644 index 00000000..d9bc5030 --- /dev/null +++ b/patches/net/minecraft/client/renderer/entity/layers/EquipmentLayerRenderer.java.patch @@ -0,0 +1,45 @@ +--- a/net/minecraft/client/renderer/entity/layers/EquipmentLayerRenderer.java ++++ b/net/minecraft/client/renderer/entity/layers/EquipmentLayerRenderer.java +@@ -65,21 +_,26 @@ + int p_371309_, + @Nullable ResourceLocation p_371587_ + ) { ++ p_371731_ = getArmorModelHook(p_371670_, p_371854_, p_371731_); + List list = this.equipmentModels.get(p_371639_).getLayers(p_371854_); + if (!list.isEmpty()) { +- int i = p_371670_.is(ItemTags.DYEABLE) ? DyedItemColor.getOrDefault(p_371670_, 0) : 0; ++ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions extensions = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(p_371670_); ++ int i = extensions.getDefaultDyeColor(p_371670_); + boolean flag = p_371670_.hasFoil(); + ++ int idx = 0; + for (EquipmentModel.Layer equipmentmodel$layer : list) { +- int j = getColorForLayer(equipmentmodel$layer, i); ++ int j = extensions.getArmorLayerTintColor(p_371670_, equipmentmodel$layer, idx, i); + if (j != 0) { + ResourceLocation resourcelocation = equipmentmodel$layer.usePlayerTexture() && p_371587_ != null + ? p_371587_ + : this.layerTextureLookup.apply(new EquipmentLayerRenderer.LayerTextureKey(p_371854_, equipmentmodel$layer)); ++ resourcelocation = net.neoforged.neoforge.client.ClientHooks.getArmorTexture(p_371670_, p_371854_, equipmentmodel$layer, resourcelocation); + VertexConsumer vertexconsumer = ItemRenderer.getArmorFoilBuffer(p_371286_, RenderType.armorCutoutNoCull(resourcelocation), flag); + p_371731_.renderToBuffer(p_371767_, vertexconsumer, p_371309_, OverlayTexture.NO_OVERLAY, j); + flag = false; + } ++ idx++; + } + + ArmorTrim armortrim = p_371670_.get(DataComponents.TRIM); +@@ -99,6 +_,13 @@ + } else { + return -1; + } ++ } ++ ++ /** ++ * Hook to allow item-sensitive armor model. for HumanoidArmorLayer. ++ */ ++ protected net.minecraft.client.model.Model getArmorModelHook(ItemStack itemStack, EquipmentModel.LayerType layerType, Model model) { ++ return net.neoforged.neoforge.client.ClientHooks.getArmorModel(itemStack, layerType, model); + } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch b/patches/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch deleted file mode 100644 index 545f030b..00000000 --- a/patches/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch +++ /dev/null @@ -1,82 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java -+++ b/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java -@@ -66,22 +_,28 @@ - if (armoritem.getEquipmentSlot() == p_117122_) { - this.getParentModel().copyPropertiesTo(p_117124_); - this.setPartVisibility(p_117124_, p_117122_); -+ net.minecraft.client.model.Model model = getArmorModelHook(p_117121_, itemstack, p_117122_, p_117124_); - boolean flag = this.usesInnerModel(p_117122_); - ArmorMaterial armormaterial = armoritem.getMaterial().value(); -- int i = itemstack.is(ItemTags.DYEABLE) ? FastColor.ARGB32.opaque(DyedItemColor.getOrDefault(itemstack, -6265536)) : -1; - -- for (ArmorMaterial.Layer armormaterial$layer : armormaterial.layers()) { -- int j = armormaterial$layer.dyeable() ? i : -1; -- this.renderModel(p_117119_, p_117120_, p_117123_, p_117124_, j, armormaterial$layer.texture(flag)); -+ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions extensions = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack); -+ int fallbackColor = extensions.getDefaultDyeColor(itemstack); -+ for (int layerIdx = 0; layerIdx < armormaterial.layers().size(); layerIdx++) { -+ ArmorMaterial.Layer armormaterial$layer = armormaterial.layers().get(layerIdx); -+ int j = extensions.getArmorLayerTintColor(itemstack, p_117121_, armormaterial$layer, layerIdx, fallbackColor); -+ if (j != 0) { -+ var texture = net.neoforged.neoforge.client.ClientHooks.getArmorTexture(p_117121_, itemstack, armormaterial$layer, flag, p_117122_); -+ this.renderModel(p_117119_, p_117120_, p_117123_, model, j, texture); -+ } - } - - ArmorTrim armortrim = itemstack.get(DataComponents.TRIM); - if (armortrim != null) { -- this.renderTrim(armoritem.getMaterial(), p_117119_, p_117120_, p_117123_, armortrim, p_117124_, flag); -+ this.renderTrim(armoritem.getMaterial(), p_117119_, p_117120_, p_117123_, armortrim, model, flag); - } - - if (itemstack.hasFoil()) { -- this.renderGlint(p_117119_, p_117120_, p_117123_, p_117124_); -+ this.renderGlint(p_117119_, p_117120_, p_117123_, model); - } - } - } -@@ -111,6 +_,9 @@ - } - - private void renderModel(PoseStack p_289664_, MultiBufferSource p_289689_, int p_289681_, A p_289658_, int p_350798_, ResourceLocation p_324344_) { -+ renderModel(p_289664_, p_289689_, p_289681_, (net.minecraft.client.model.Model) p_289658_, p_350798_, p_324344_); -+ } -+ private void renderModel(PoseStack p_289664_, MultiBufferSource p_289689_, int p_289681_, net.minecraft.client.model.Model p_289658_, int p_350798_, ResourceLocation p_324344_) { - VertexConsumer vertexconsumer = p_289689_.getBuffer(RenderType.armorCutoutNoCull(p_324344_)); - p_289658_.renderToBuffer(p_289664_, vertexconsumer, p_289681_, OverlayTexture.NO_OVERLAY, p_350798_); - } -@@ -118,6 +_,11 @@ - private void renderTrim( - Holder p_323506_, PoseStack p_289687_, MultiBufferSource p_289643_, int p_289683_, ArmorTrim p_289692_, A p_289663_, boolean p_289651_ - ) { -+ renderTrim(p_323506_, p_289687_, p_289643_, p_289683_, p_289692_, (net.minecraft.client.model.Model) p_289663_, p_289651_); -+ } -+ private void renderTrim( -+ Holder p_323506_, PoseStack p_289687_, MultiBufferSource p_289643_, int p_289683_, ArmorTrim p_289692_, net.minecraft.client.model.Model p_289663_, boolean p_289651_ -+ ) { - TextureAtlasSprite textureatlassprite = this.armorTrimAtlas - .getSprite(p_289651_ ? p_289692_.innerTexture(p_323506_) : p_289692_.outerTexture(p_323506_)); - VertexConsumer vertexconsumer = textureatlassprite.wrap(p_289643_.getBuffer(Sheets.armorTrimsSheet(p_289692_.pattern().value().decal()))); -@@ -125,6 +_,9 @@ - } - - private void renderGlint(PoseStack p_289673_, MultiBufferSource p_289654_, int p_289649_, A p_289659_) { -+ renderGlint(p_289673_, p_289654_, p_289649_, (net.minecraft.client.model.Model) p_289659_); -+ } -+ private void renderGlint(PoseStack p_289673_, MultiBufferSource p_289654_, int p_289649_, net.minecraft.client.model.Model p_289659_) { - p_289659_.renderToBuffer(p_289673_, p_289654_.getBuffer(RenderType.armorEntityGlint()), p_289649_, OverlayTexture.NO_OVERLAY); - } - -@@ -134,5 +_,12 @@ - - private boolean usesInnerModel(EquipmentSlot p_117129_) { - return p_117129_ == EquipmentSlot.LEGS; -+ } -+ -+ /** -+ * Hook to allow item-sensitive armor model. for HumanoidArmorLayer. -+ */ -+ protected net.minecraft.client.model.Model getArmorModelHook(T entity, ItemStack itemStack, EquipmentSlot slot, A model) { -+ return net.neoforged.neoforge.client.ClientHooks.getArmorModel(entity, itemStack, slot, model); - } - } diff --git a/patches/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch index 7f808403..d2fb4f49 100644 --- a/patches/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch @@ -1,47 +1,66 @@ --- a/net/minecraft/client/renderer/entity/player/PlayerRenderer.java +++ b/net/minecraft/client/renderer/entity/player/PlayerRenderer.java -@@ -68,7 +_,9 @@ - - public void render(AbstractClientPlayer p_117788_, float p_117789_, float p_117790_, PoseStack p_117791_, MultiBufferSource p_117792_, int p_117793_) { - this.setModelProperties(p_117788_); -+ if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderPlayerEvent.Pre(p_117788_, this, p_117790_, p_117791_, p_117792_, p_117793_)).isCanceled()) return; - super.render(p_117788_, p_117789_, p_117790_, p_117791_, p_117792_, p_117793_); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderPlayerEvent.Post(p_117788_, this, p_117790_, p_117791_, p_117792_, p_117793_)); - } - - public Vec3 getRenderOffset(AbstractClientPlayer p_117785_, float p_117786_) { -@@ -140,9 +_,11 @@ - if (useanim == UseAnim.BRUSH) { - return HumanoidModel.ArmPose.BRUSH; - } -- } else if (!p_117795_.swinging && itemstack.is(Items.CROSSBOW) && CrossbowItem.isCharged(itemstack)) { -+ } else if (!p_117795_.swinging && itemstack.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(itemstack)) { +@@ -127,6 +_,9 @@ + } else if (!p_363098_.swinging && p_364742_.holdsChargedCrossbow) { return HumanoidModel.ArmPose.CROSSBOW_HOLD; } -+ HumanoidModel.ArmPose forgeArmPose = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).getArmPose(p_117795_, p_117796_, itemstack); -+ if (forgeArmPose != null) return forgeArmPose; ++ if (p_364742_.customArmPose != null) { ++ return p_364742_.customArmPose; ++ } return HumanoidModel.ArmPose.ITEM; } -@@ -185,10 +_,12 @@ +@@ -141,6 +_,13 @@ + p_117799_.scale(0.9375F, 0.9375F, 0.9375F); } - public void renderRightHand(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, AbstractClientPlayer p_117774_) { -+ if(!net.neoforged.neoforge.client.ClientHooks.renderSpecificFirstPersonArm(p_117771_, p_117772_, p_117773_, p_117774_, HumanoidArm.RIGHT)) - this.renderHand(p_117771_, p_117772_, p_117773_, p_117774_, this.model.rightArm, this.model.rightSleeve); ++ @Override ++ public void render(PlayerRenderState p_361886_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { ++ if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderPlayerEvent.Pre(p_361886_, this, p_361886_.partialTick, p_115311_, p_115312_, p_115313_)).isCanceled()) return; ++ super.render(p_361886_, p_115311_, p_115312_, p_115313_); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderPlayerEvent.Post(p_361886_, this, p_361886_.partialTick, p_115311_, p_115312_, p_115313_)); ++ } ++ + protected void renderNameTag(PlayerRenderState p_363185_, Component p_117809_, PoseStack p_117810_, MultiBufferSource p_117811_, int p_117812_) { + p_117810_.pushPose(); + if (p_363185_.scoreText != null) { +@@ -217,7 +_,8 @@ + ItemStack itemstack = p_364516_.getItemInHand(p_364304_); + p_360817_.isEmpty = itemstack.isEmpty(); + p_360817_.useAnimation = !itemstack.isEmpty() ? itemstack.getUseAnimation() : null; +- p_360817_.holdsChargedCrossbow = itemstack.is(Items.CROSSBOW) && CrossbowItem.isCharged(itemstack); ++ p_360817_.holdsChargedCrossbow = itemstack.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(itemstack); ++ p_360817_.customArmPose = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).getArmPose(p_364516_, p_364304_, itemstack); } - public void renderLeftHand(PoseStack p_117814_, MultiBufferSource p_117815_, int p_117816_, AbstractClientPlayer p_117817_) { -+ if(!net.neoforged.neoforge.client.ClientHooks.renderSpecificFirstPersonArm(p_117814_, p_117815_, p_117816_, p_117817_, HumanoidArm.LEFT)) - this.renderHand(p_117814_, p_117815_, p_117816_, p_117817_, this.model.leftArm, this.model.leftSleeve); + private static void extractCapeState(AbstractClientPlayer p_364691_, PlayerRenderState p_360814_, float p_364460_) { +@@ -247,11 +_,29 @@ + : null; + } + ++ /** ++ * @deprecated Neo: use {@link #renderRightHand(PoseStack, MultiBufferSource, int, ResourceLocation, boolean, AbstractClientPlayer)} instead ++ */ ++ @Deprecated + public void renderRightHand(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, ResourceLocation p_363694_, boolean p_366898_) { ++ this.renderRightHand(p_117771_, p_117772_, p_117773_, p_363694_, p_366898_, net.minecraft.client.Minecraft.getInstance().player); ++ } ++ ++ public void renderRightHand(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, ResourceLocation p_363694_, boolean p_366898_, AbstractClientPlayer player) { ++ if(!net.neoforged.neoforge.client.ClientHooks.renderSpecificFirstPersonArm(p_117771_, p_117772_, p_117773_, player, HumanoidArm.RIGHT)) + this.renderHand(p_117771_, p_117772_, p_117773_, p_363694_, this.model.rightArm, p_366898_); + } + ++ /** ++ * @deprecated Neo: use {@link #renderLeftHand(PoseStack, MultiBufferSource, int, ResourceLocation, boolean, AbstractClientPlayer)} instead ++ */ ++ @Deprecated + public void renderLeftHand(PoseStack p_117814_, MultiBufferSource p_117815_, int p_117816_, ResourceLocation p_361745_, boolean p_366730_) { ++ this.renderLeftHand(p_117814_, p_117815_, p_117816_, p_361745_, p_366730_, net.minecraft.client.Minecraft.getInstance().player); ++ } ++ ++ public void renderLeftHand(PoseStack p_117814_, MultiBufferSource p_117815_, int p_117816_, ResourceLocation p_361745_, boolean p_366730_, AbstractClientPlayer player) { ++ if(!net.neoforged.neoforge.client.ClientHooks.renderSpecificFirstPersonArm(p_117814_, p_117815_, p_117816_, player, HumanoidArm.LEFT)) + this.renderHand(p_117814_, p_117815_, p_117816_, p_361745_, this.model.leftArm, p_366730_); } -@@ -230,7 +_,7 @@ - } - } else if (f > 0.0F) { - super.setupRotations(p_117802_, p_117803_, p_117804_, p_117805_, p_117806_, p_320048_); -- float f4 = p_117802_.isInWater() ? -90.0F - f1 : -90.0F; -+ float f4 = p_117802_.isInWater() || p_117802_.isInFluidType((fluidType, height) -> p_117802_.canSwimInFluidType(fluidType)) ? -90.0F - p_117802_.getXRot() : -90.0F; - float f5 = Mth.lerp(f, 0.0F, f4); - p_117803_.mulPose(Axis.XP.rotationDegrees(f5)); - if (p_117802_.isVisuallySwimming()) { diff --git a/patches/net/minecraft/client/renderer/entity/state/EntityRenderState.java.patch b/patches/net/minecraft/client/renderer/entity/state/EntityRenderState.java.patch new file mode 100644 index 00000000..a9fd8070 --- /dev/null +++ b/patches/net/minecraft/client/renderer/entity/state/EntityRenderState.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/renderer/entity/state/EntityRenderState.java ++++ b/net/minecraft/client/renderer/entity/state/EntityRenderState.java +@@ -27,6 +_,7 @@ + public Vec3 nameTagAttachment; + @Nullable + public EntityRenderState.LeashState leashState; ++ public float partialTick; + + @OnlyIn(Dist.CLIENT) + public static class LeashState { diff --git a/patches/net/minecraft/client/renderer/entity/state/PlayerRenderState.java.patch b/patches/net/minecraft/client/renderer/entity/state/PlayerRenderState.java.patch new file mode 100644 index 00000000..870f5bd8 --- /dev/null +++ b/patches/net/minecraft/client/renderer/entity/state/PlayerRenderState.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/renderer/entity/state/PlayerRenderState.java ++++ b/net/minecraft/client/renderer/entity/state/PlayerRenderState.java +@@ -52,5 +_,7 @@ + @Nullable + public ItemUseAnimation useAnimation; + public boolean holdsChargedCrossbow; ++ @Nullable ++ public net.minecraft.client.model.HumanoidModel.ArmPose customArmPose; + } + } diff --git a/patches/net/minecraft/client/renderer/state/MapRenderState.java.patch b/patches/net/minecraft/client/renderer/state/MapRenderState.java.patch new file mode 100644 index 00000000..2ac034ae --- /dev/null +++ b/patches/net/minecraft/client/renderer/state/MapRenderState.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/renderer/state/MapRenderState.java ++++ b/net/minecraft/client/renderer/state/MapRenderState.java +@@ -17,6 +_,7 @@ + + @OnlyIn(Dist.CLIENT) + public static class MapDecorationRenderState { ++ public net.minecraft.core.Holder type; + @Nullable + public TextureAtlasSprite atlasSprite; + public byte x; diff --git a/patches/net/minecraft/client/renderer/texture/AbstractTexture.java.patch b/patches/net/minecraft/client/renderer/texture/AbstractTexture.java.patch index 8990e16b..ce14e13d 100644 --- a/patches/net/minecraft/client/renderer/texture/AbstractTexture.java.patch +++ b/patches/net/minecraft/client/renderer/texture/AbstractTexture.java.patch @@ -1,9 +1,25 @@ --- a/net/minecraft/client/renderer/texture/AbstractTexture.java +++ b/net/minecraft/client/renderer/texture/AbstractTexture.java -@@ -36,6 +_,20 @@ - GlStateManager._texParameter(3553, 10240, j); - } +@@ -15,9 +_,13 @@ + public static final int NOT_ASSIGNED = -1; + protected int id = -1; + protected boolean defaultBlur; ++ protected boolean blur; ++ protected boolean mipmap; + public void setFilter(boolean p_117961_, boolean p_117962_) { + RenderSystem.assertOnRenderThreadOrInit(); ++ this.blur = p_117961_; ++ this.mipmap = p_117962_; + int i; + int j; + if (p_117961_) { +@@ -31,6 +_,20 @@ + this.bind(); + GlStateManager._texParameter(3553, 10241, i); + GlStateManager._texParameter(3553, 10240, j); ++ } ++ + // FORGE: This seems to have been stripped out, but we need it + private boolean lastBlur; + private boolean lastMipmap; @@ -16,8 +32,6 @@ + + public void restoreLastBlurMipmap() { + setFilter(this.lastBlur, this.lastMipmap); -+ } -+ + } + public int getId() { - RenderSystem.assertOnRenderThreadOrInit(); - if (this.id == -1) { diff --git a/patches/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch b/patches/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch index 5835dfec..c6a51c60 100644 --- a/patches/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch +++ b/patches/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/texture/MipmapGenerator.java +++ b/net/minecraft/client/renderer/texture/MipmapGenerator.java -@@ -25,12 +_,15 @@ +@@ -26,12 +_,15 @@ anativeimage[0] = p_251300_[0]; boolean flag = hasTransparentPixel(anativeimage[0]); @@ -17,7 +17,7 @@ int j = nativeimage1.getWidth(); int k = nativeimage1.getHeight(); -@@ -48,6 +_,7 @@ +@@ -49,6 +_,7 @@ ) ); } diff --git a/patches/net/minecraft/client/renderer/texture/TextureAtlas.java.patch b/patches/net/minecraft/client/renderer/texture/TextureAtlas.java.patch index 6fe9f37f..ffc654c2 100644 --- a/patches/net/minecraft/client/renderer/texture/TextureAtlas.java.patch +++ b/patches/net/minecraft/client/renderer/texture/TextureAtlas.java.patch @@ -9,7 +9,7 @@ } @Override -@@ -172,5 +_,9 @@ +@@ -168,5 +_,9 @@ public void updateFilter(SpriteLoader.Preparations p_251993_) { this.setFilter(false, p_251993_.mipLevel() > 0); diff --git a/patches/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch b/patches/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch index 3c47d4cc..3dbb3049 100644 --- a/patches/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch +++ b/patches/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch @@ -12,6 +12,6 @@ + y += this.contents.animatedTexture.getFrameY(frameIndex) * this.contents.height; + } + -+ return this.contents.getOriginalImage().getPixelRGBA(x, y); ++ return this.contents.getOriginalImage().getPixel(x, y); + } } diff --git a/patches/net/minecraft/client/resources/language/ClientLanguage.java.patch b/patches/net/minecraft/client/resources/language/ClientLanguage.java.patch index 86f9a1da..22eb7edb 100644 --- a/patches/net/minecraft/client/resources/language/ClientLanguage.java.patch +++ b/patches/net/minecraft/client/resources/language/ClientLanguage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/language/ClientLanguage.java +++ b/net/minecraft/client/resources/language/ClientLanguage.java -@@ -22,36 +_,50 @@ +@@ -22,23 +_,32 @@ public class ClientLanguage extends Language { private static final Logger LOGGER = LogUtils.getLogger(); private final Map storage; @@ -19,8 +19,8 @@ } public static ClientLanguage loadFrom(ResourceManager p_265765_, List p_265743_, boolean p_265470_) { - Map map = Maps.newHashMap(); -+ Map componentMap = Maps.newHashMap(); + Map map = new HashMap<>(); ++ Map componentMap = new HashMap<>(); for (String s : p_265743_) { String s1 = String.format(Locale.ROOT, "lang/%s.json", s); @@ -34,11 +34,12 @@ } catch (Exception exception) { LOGGER.warn("Skipped language file: {}:{} ({})", s2, s1, exception.toString()); } - } +@@ -46,13 +_,18 @@ } -- return new ClientLanguage(ImmutableMap.copyOf(map), p_265470_); -+ return new ClientLanguage(ImmutableMap.copyOf(map), p_265470_, ImmutableMap.copyOf(componentMap)); + DeprecatedTranslationsInfo.loadFromDefaultResource().applyToMap(map); +- return new ClientLanguage(Map.copyOf(map), p_265470_); ++ return new ClientLanguage(Map.copyOf(map), p_265470_, Map.copyOf(componentMap)); } + @Deprecated @@ -54,7 +55,7 @@ } catch (IOException ioexception) { LOGGER.warn("Failed to load translations for {} from pack {}", p_235036_, resource.sourcePackId(), ioexception); } -@@ -76,5 +_,15 @@ +@@ -77,5 +_,15 @@ @Override public FormattedCharSequence getVisualOrder(FormattedText p_118925_) { return FormattedBidiReorder.reorder(p_118925_, this.defaultRightToLeft); diff --git a/patches/net/minecraft/client/resources/model/BakedModel.java.patch b/patches/net/minecraft/client/resources/model/BakedModel.java.patch index 6f162f22..15490942 100644 --- a/patches/net/minecraft/client/resources/model/BakedModel.java.patch +++ b/patches/net/minecraft/client/resources/model/BakedModel.java.patch @@ -24,5 +24,5 @@ + @Deprecated + default ItemTransforms getTransforms() { return ItemTransforms.NO_TRANSFORMS; } - ItemOverrides getOverrides(); - } + default BakedOverrides overrides() { + return BakedOverrides.EMPTY; diff --git a/patches/net/minecraft/client/resources/model/DelegateBakedModel.java.patch b/patches/net/minecraft/client/resources/model/DelegateBakedModel.java.patch new file mode 100644 index 00000000..5c8eacbb --- /dev/null +++ b/patches/net/minecraft/client/resources/model/DelegateBakedModel.java.patch @@ -0,0 +1,75 @@ +--- a/net/minecraft/client/resources/model/DelegateBakedModel.java ++++ b/net/minecraft/client/resources/model/DelegateBakedModel.java +@@ -20,16 +_,27 @@ + } + + @Override ++ @Deprecated + public List getQuads(@Nullable BlockState p_371320_, @Nullable Direction p_371369_, RandomSource p_371947_) { + return this.parent.getQuads(p_371320_, p_371369_, p_371947_); + } + + @Override ++ public List getQuads(@Nullable BlockState p_371320_, @Nullable Direction p_371369_, RandomSource p_371947_, net.neoforged.neoforge.client.model.data.ModelData modelData, @org.jetbrains.annotations.Nullable net.minecraft.client.renderer.RenderType renderType) { ++ return this.parent.getQuads(p_371320_, p_371369_, p_371947_, modelData, renderType); ++ } ++ ++ @Override + public boolean useAmbientOcclusion() { + return this.parent.useAmbientOcclusion(); + } + + @Override ++ public net.neoforged.neoforge.common.util.TriState useAmbientOcclusion(BlockState state, net.neoforged.neoforge.client.model.data.ModelData modelData, net.minecraft.client.renderer.RenderType renderType) { ++ return this.parent.useAmbientOcclusion(state, modelData, renderType); ++ } ++ ++ @Override + public boolean isGui3d() { + return this.parent.isGui3d(); + } +@@ -45,12 +_,44 @@ + } + + @Override ++ @Deprecated + public TextureAtlasSprite getParticleIcon() { + return this.parent.getParticleIcon(); + } + + @Override ++ public TextureAtlasSprite getParticleIcon(net.neoforged.neoforge.client.model.data.ModelData modelData) { ++ return this.parent.getParticleIcon(modelData); ++ } ++ ++ @Override ++ @Deprecated + public ItemTransforms getTransforms() { + return this.parent.getTransforms(); ++ } ++ ++ @Override ++ public BakedModel applyTransform(net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack poseStack, boolean applyLeftHandTransform) { ++ return this.parent.applyTransform(transformType, poseStack, applyLeftHandTransform); ++ } ++ ++ @Override ++ public net.neoforged.neoforge.client.model.data.ModelData getModelData(net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, BlockState state, net.neoforged.neoforge.client.model.data.ModelData modelData) { ++ return this.parent.getModelData(level, pos, state, modelData); ++ } ++ ++ @Override ++ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, net.neoforged.neoforge.client.model.data.ModelData data) { ++ return this.parent.getRenderTypes(state, rand, data); ++ } ++ ++ @Override ++ public List getRenderTypes(net.minecraft.world.item.ItemStack itemStack) { ++ return this.parent.getRenderTypes(itemStack); ++ } ++ ++ @Override ++ public List getRenderPasses(net.minecraft.world.item.ItemStack itemStack) { ++ return this.parent.getRenderPasses(itemStack); + } + } diff --git a/patches/net/minecraft/client/resources/model/ItemModel.java.patch b/patches/net/minecraft/client/resources/model/ItemModel.java.patch new file mode 100644 index 00000000..10d96b4e --- /dev/null +++ b/patches/net/minecraft/client/resources/model/ItemModel.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/client/resources/model/ItemModel.java ++++ b/net/minecraft/client/resources/model/ItemModel.java +@@ -29,11 +_,11 @@ + + @Override + public BakedModel bake(ModelBaker p_371426_, Function p_371750_, ModelState p_371674_) { +- BakedModel bakedmodel = p_371426_.bake(this.id, p_371674_); ++ BakedModel bakedmodel = p_371426_.bake(this.id, p_371674_, p_371750_); + if (this.overrides.isEmpty()) { + return bakedmodel; + } else { +- BakedOverrides bakedoverrides = new BakedOverrides(p_371426_, this.overrides); ++ BakedOverrides bakedoverrides = new BakedOverrides(p_371426_, this.overrides, p_371750_); + return new ItemModel.BakedModelWithOverrides(bakedmodel, bakedoverrides); + } + } diff --git a/patches/net/minecraft/client/resources/model/ModelBaker.java.patch b/patches/net/minecraft/client/resources/model/ModelBaker.java.patch index 7535b116..36016793 100644 --- a/patches/net/minecraft/client/resources/model/ModelBaker.java.patch +++ b/patches/net/minecraft/client/resources/model/ModelBaker.java.patch @@ -1,17 +1,14 @@ --- a/net/minecraft/client/resources/model/ModelBaker.java +++ b/net/minecraft/client/resources/model/ModelBaker.java -@@ -6,9 +_,13 @@ +@@ -5,6 +_,10 @@ import net.neoforged.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -public interface ModelBaker { +public interface ModelBaker extends net.neoforged.neoforge.client.extensions.IModelBakerExtension { - UnbakedModel getModel(ResourceLocation p_252194_); - + /** + * @deprecated Forge: Use {@link #bake(ResourceLocation, ModelState, java.util.function.Function)} instead. + */ + @Deprecated - @Nullable BakedModel bake(ResourceLocation p_250776_, ModelState p_251280_); } diff --git a/patches/net/minecraft/client/resources/model/ModelBakery.java.patch b/patches/net/minecraft/client/resources/model/ModelBakery.java.patch index cf11be47..ed116d3f 100644 --- a/patches/net/minecraft/client/resources/model/ModelBakery.java.patch +++ b/patches/net/minecraft/client/resources/model/ModelBakery.java.patch @@ -1,25 +1,12 @@ --- a/net/minecraft/client/resources/model/ModelBakery.java +++ b/net/minecraft/client/resources/model/ModelBakery.java -@@ -117,6 +_,12 @@ - p_252014_.popPush("special"); - this.loadSpecialItemModelAndDependencies(ItemRenderer.TRIDENT_IN_HAND_MODEL); - this.loadSpecialItemModelAndDependencies(ItemRenderer.SPYGLASS_IN_HAND_MODEL); -+ Set additionalModels = new HashSet<>(); -+ net.neoforged.neoforge.client.ClientHooks.onRegisterAdditionalModels(additionalModels); -+ for (ModelResourceLocation rl : additionalModels) { -+ UnbakedModel unbakedmodel = this.getModel(rl.id()); -+ this.registerModelAndLoadDependencies(rl, unbakedmodel); -+ } - this.topLevelModels.values().forEach(p_247954_ -> p_247954_.resolveParents(this::getModel)); - p_252014_.pop(); - } -@@ -246,14 +_,30 @@ +@@ -94,25 +_,46 @@ } @Override -+ @Nullable ++ @org.jetbrains.annotations.Nullable + public UnbakedModel getTopLevelModel(ModelResourceLocation location) { -+ return topLevelModels.get(location); ++ return topModels.get(location); + } + + @Override @@ -45,22 +32,17 @@ ModelBakery.this.bakedCache.put(modelbakery$bakedcachekey, bakedmodel1); return bakedmodel1; } -@@ -261,13 +_,19 @@ + } - @Nullable BakedModel bakeUncached(UnbakedModel p_352386_, ModelState p_352194_) { + return bakeUncached(p_352386_, p_352194_, this.modelTextureGetter); + } + + @Override -+ @Nullable + public BakedModel bakeUncached(UnbakedModel p_352386_, ModelState p_352194_, Function sprites) { - if (p_352386_ instanceof BlockModel blockmodel && blockmodel.getRootModel() == ModelBakery.GENERATION_MARKER) { - return ModelBakery.ITEM_MODEL_GENERATOR -- .generateBlockModel(this.modelTextureGetter, blockmodel) -- .bake(this, blockmodel, this.modelTextureGetter, p_352194_, false); -+ .generateBlockModel(sprites, blockmodel) -+ .bake(this, blockmodel, sprites, p_352194_, false); + if (p_352386_ instanceof BlockModel blockmodel && blockmodel.getRootModel() == SpecialModels.GENERATED_MARKER) { +- return ModelBakery.ITEM_MODEL_GENERATOR.generateBlockModel(this.modelTextureGetter, blockmodel).bake(this.modelTextureGetter, p_352194_, false); ++ return ModelBakery.ITEM_MODEL_GENERATOR.generateBlockModel(sprites, blockmodel).bake(sprites, p_352194_, false); } - return p_352386_.bake(this, this.modelTextureGetter, p_352194_); diff --git a/patches/net/minecraft/client/resources/model/ModelDiscovery.java.patch b/patches/net/minecraft/client/resources/model/ModelDiscovery.java.patch new file mode 100644 index 00000000..7c9de848 --- /dev/null +++ b/patches/net/minecraft/client/resources/model/ModelDiscovery.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/client/resources/model/ModelDiscovery.java ++++ b/net/minecraft/client/resources/model/ModelDiscovery.java +@@ -49,6 +_,7 @@ + }); + set.add(ItemRenderer.TRIDENT_MODEL); + set.add(ItemRenderer.SPYGLASS_MODEL); ++ net.neoforged.neoforge.client.ClientHooks.onRegisterAdditionalModels(set); + return set; + } + +@@ -77,6 +_,15 @@ + } + } + ); ++ // Neo: ensure standalone models registered in ModelEvent.RegisterAdditional are loaded ++ var it = set.iterator(); ++ while (it.hasNext()) { ++ ModelResourceLocation mrl = it.next(); ++ if (mrl.getVariant().equals(ModelResourceLocation.STANDALONE_VARIANT)) { ++ registerTopModel(mrl, getBlockModel(mrl.id())); ++ it.remove(); ++ } ++ } + if (!set.isEmpty()) { + LOGGER.warn("Missing mandatory models: {}", set.stream().map(p_370354_ -> "\n\t" + p_370354_).collect(Collectors.joining())); + } diff --git a/patches/net/minecraft/client/resources/model/ModelManager.java.patch b/patches/net/minecraft/client/resources/model/ModelManager.java.patch index dd6edb65..2795dad2 100644 --- a/patches/net/minecraft/client/resources/model/ModelManager.java.patch +++ b/patches/net/minecraft/client/resources/model/ModelManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/model/ModelManager.java +++ b/net/minecraft/client/resources/model/ModelManager.java -@@ -63,13 +_,14 @@ +@@ -71,13 +_,14 @@ TextureAtlas.LOCATION_BLOCKS, ResourceLocation.withDefaultNamespace("blocks") ); @@ -16,15 +16,15 @@ public ModelManager(TextureManager p_119406_, BlockColors p_119407_, int p_119408_) { this.blockColors = p_119407_; -@@ -100,6 +_,7 @@ - Executor p_249221_ +@@ -102,6 +_,7 @@ + public final CompletableFuture reload( + PreparableReloadListener.PreparationBarrier p_249079_, ResourceManager p_251134_, Executor p_250550_, Executor p_249221_ ) { - p_250336_.startTick(); + net.neoforged.neoforge.client.model.geometry.GeometryLoaderManager.init(); - CompletableFuture> completablefuture = loadBlockModels(p_251134_, p_250550_); - CompletableFuture>> completablefuture1 = loadBlockStates(p_251134_, p_250550_); - CompletableFuture completablefuture2 = completablefuture.thenCombineAsync( -@@ -218,6 +_,8 @@ + UnbakedModel unbakedmodel = MissingBlockModel.missingModel(); + BlockStateModelLoader blockstatemodelloader = new BlockStateModelLoader(unbakedmodel); + CompletableFuture> completablefuture = loadBlockModels(p_251134_, p_250550_); +@@ -258,6 +_,8 @@ .collect(Collectors.joining("\n")) ) ); @@ -32,17 +32,17 @@ + net.neoforged.neoforge.client.ClientHooks.onModifyBakingResult(p_248945_.getBakedTopLevelModels(), p_250646_, p_248945_); p_252136_.popPush("dispatch"); Map map = p_248945_.getBakedTopLevelModels(); - BakedModel bakedmodel = map.get(ModelBakery.MISSING_MODEL_VARIANT); -@@ -247,6 +_,8 @@ + BakedModel bakedmodel = map.get(MissingBlockModel.VARIANT); +@@ -289,6 +_,8 @@ this.bakedRegistry = modelbakery.getBakedTopLevelModels(); - this.modelGroups = modelbakery.getModelGroups(); + this.modelGroups = p_248996_.modelGroups; this.missingModel = p_248996_.missingModel; + this.modelBakery = modelbakery; + net.neoforged.neoforge.client.ClientHooks.onModelBake(this, this.bakedRegistry, modelbakery); p_251960_.popPush("cache"); this.blockModelShaper.replaceCache(p_248996_.modelCache); p_251960_.pop(); -@@ -272,6 +_,7 @@ +@@ -313,6 +_,7 @@ } public TextureAtlas getAtlas(ResourceLocation p_119429_) { @@ -50,7 +50,7 @@ return this.atlases.getAtlas(p_119429_); } -@@ -282,6 +_,10 @@ +@@ -323,6 +_,10 @@ public void updateMaxMipLevel(int p_119411_) { this.maxMipmapLevels = p_119411_; diff --git a/patches/net/minecraft/client/resources/model/ModelResourceLocation.java.patch b/patches/net/minecraft/client/resources/model/ModelResourceLocation.java.patch index ff24a3ea..85d4fc00 100644 --- a/patches/net/minecraft/client/resources/model/ModelResourceLocation.java.patch +++ b/patches/net/minecraft/client/resources/model/ModelResourceLocation.java.patch @@ -8,7 +8,7 @@ public ModelResourceLocation(ResourceLocation id, String variant) { variant = lowercaseVariant(variant); -@@ -21,6 +_,14 @@ +@@ -17,6 +_,14 @@ public static ModelResourceLocation inventory(ResourceLocation p_352141_) { return new ModelResourceLocation(p_352141_, "inventory"); diff --git a/patches/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch b/patches/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch index 8404abbe..012bbbff 100644 --- a/patches/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch +++ b/patches/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch @@ -1,29 +1,16 @@ --- a/net/minecraft/client/resources/model/MultiPartBakedModel.java +++ b/net/minecraft/client/resources/model/MultiPartBakedModel.java -@@ -20,7 +_,7 @@ - import org.apache.commons.lang3.tuple.Pair; +@@ -16,7 +_,7 @@ + import net.neoforged.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) --public class MultiPartBakedModel implements BakedModel { -+public class MultiPartBakedModel implements BakedModel, net.neoforged.neoforge.client.model.IDynamicBakedModel { - private final List, BakedModel>> selectors; - protected final boolean hasAmbientOcclusion; - protected final boolean isGui3d; -@@ -29,10 +_,12 @@ - protected final ItemTransforms transforms; - protected final ItemOverrides overrides; +-public class MultiPartBakedModel extends DelegateBakedModel { ++public class MultiPartBakedModel extends DelegateBakedModel implements net.neoforged.neoforge.client.model.IDynamicBakedModel { + private final List selectors; private final Map selectorCache = new Reference2ObjectOpenHashMap<>(); -+ private final BakedModel defaultModel; - public MultiPartBakedModel(List, BakedModel>> p_119462_) { +@@ -33,11 +_,7 @@ this.selectors = p_119462_; - BakedModel bakedmodel = p_119462_.iterator().next().getRight(); -+ this.defaultModel = bakedmodel; - this.hasAmbientOcclusion = bakedmodel.useAmbientOcclusion(); - this.isGui3d = bakedmodel.isGui3d(); - this.usesBlockLight = bakedmodel.usesBlockLight(); -@@ -41,11 +_,7 @@ - this.overrides = bakedmodel.getOverrides(); } - @Override @@ -35,14 +22,14 @@ BitSet bitset = this.selectorCache.get(p_235050_); if (bitset == null) { bitset = new BitSet(); -@@ -59,17 +_,28 @@ +@@ -50,19 +_,47 @@ this.selectorCache.put(p_235050_, bitset); } + return bitset; + } -- List list = Lists.newArrayList(); +- List list = new ArrayList<>(); + // FORGE: Implement our overloads (here and below) so child models can have custom logic + @Override + public List getQuads(@Nullable BlockState p_235050_, @Nullable Direction p_235051_, RandomSource p_235052_, net.neoforged.neoforge.client.model.data.ModelData modelData, @org.jetbrains.annotations.Nullable net.minecraft.client.renderer.RenderType renderType) { @@ -50,29 +37,25 @@ + return Collections.emptyList(); + } else { + BitSet bitset = getSelectors(p_235050_); -+ List> list = Lists.newArrayList(); - long k = p_235052_.nextLong(); ++ List> list = new ArrayList<>(); + long j = p_235052_.nextLong(); - for (int j = 0; j < bitset.length(); j++) { - if (bitset.get(j)) { -- list.addAll(this.selectors.get(j).getRight().getQuads(p_235050_, p_235051_, RandomSource.create(k))); -+ var model = this.selectors.get(j).getRight(); -+ if (renderType == null || model.getRenderTypes(p_235050_, p_235052_, modelData).contains(renderType)) // FORGE: Only put quad data if the model is using the render type passed -+ list.add(model.getQuads(p_235050_, p_235051_, RandomSource.create(k), net.neoforged.neoforge.client.model.data.MultipartModelData.resolve(modelData, model), renderType)); + for (int k = 0; k < bitset.length(); k++) { + if (bitset.get(k)) { +- p_235052_.setSeed(j); +- list.addAll(this.selectors.get(k).model.getQuads(p_235050_, p_235051_, p_235052_)); ++ ++ var model = this.selectors.get(k).model; ++ if (renderType == null || model.getRenderTypes(p_235050_, p_235052_, modelData).contains(renderType)) { // FORGE: Only put quad data if the model is using the render type passed ++ p_235052_.setSeed(j); ++ list.add(model.getQuads(p_235050_, p_235051_, p_235052_, net.neoforged.neoforge.client.model.data.MultipartModelData.resolve(modelData, model), renderType)); ++ } } } - return list; + return net.neoforged.neoforge.common.util.ConcatenatedListView.of(list); } - } - -@@ -79,6 +_,16 @@ - } - - @Override -+ public net.neoforged.neoforge.common.util.TriState useAmbientOcclusion(BlockState state, net.neoforged.neoforge.client.model.data.ModelData modelData, net.minecraft.client.renderer.RenderType renderType) { -+ return this.defaultModel.useAmbientOcclusion(state, modelData, renderType); + } + + @Override @@ -80,43 +63,14 @@ + return net.neoforged.neoforge.client.model.data.MultipartModelData.create(selectors, getSelectors(state), level, pos, state, modelData); + } + -+ @Override - public boolean isGui3d() { - return this.isGui3d; - } -@@ -94,13 +_,35 @@ - } - - @Override -+ @Deprecated - public TextureAtlasSprite getParticleIcon() { - return this.particleIcon; - } - - @Override -+ public TextureAtlasSprite getParticleIcon(net.neoforged.neoforge.client.model.data.ModelData modelData) { -+ return this.defaultModel.getParticleIcon(modelData); -+ } -+ -+ @Deprecated -+ @Override - public ItemTransforms getTransforms() { - return this.transforms; -+ } -+ -+ @Override -+ public BakedModel applyTransform(net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack poseStack, boolean applyLeftHandTransform) { -+ return this.defaultModel.applyTransform(transformType, poseStack, applyLeftHandTransform); -+ } -+ + @Override // FORGE: Get render types based on the selectors matched by the given block state + public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(@org.jetbrains.annotations.NotNull BlockState state, @org.jetbrains.annotations.NotNull RandomSource rand, @org.jetbrains.annotations.NotNull net.neoforged.neoforge.client.model.data.ModelData data) { + var renderTypeSets = new java.util.LinkedList(); + var selectors = getSelectors(state); + for (int i = 0; i < selectors.length(); i++) + if (selectors.get(i)) -+ renderTypeSets.add(this.selectors.get(i).getRight().getRenderTypes(state, rand, data)); ++ renderTypeSets.add(this.selectors.get(i).model.getRenderTypes(state, rand, data)); + return net.neoforged.neoforge.client.ChunkRenderTypeSet.union(renderTypeSets); } - @Override + @OnlyIn(Dist.CLIENT) diff --git a/patches/net/minecraft/client/resources/model/SimpleBakedModel.java.patch b/patches/net/minecraft/client/resources/model/SimpleBakedModel.java.patch index b477646b..41044226 100644 --- a/patches/net/minecraft/client/resources/model/SimpleBakedModel.java.patch +++ b/patches/net/minecraft/client/resources/model/SimpleBakedModel.java.patch @@ -1,76 +1,68 @@ --- a/net/minecraft/client/resources/model/SimpleBakedModel.java +++ b/net/minecraft/client/resources/model/SimpleBakedModel.java -@@ -26,7 +_,12 @@ +@@ -25,7 +_,11 @@ + protected final boolean usesBlockLight; protected final TextureAtlasSprite particleIcon; protected final ItemTransforms transforms; - protected final ItemOverrides overrides; -+ protected final net.neoforged.neoforge.client.ChunkRenderTypeSet blockRenderTypes; -+ protected final List itemRenderTypes; -+ protected final List fabulousItemRenderTypes; ++ @Nullable protected final net.neoforged.neoforge.client.ChunkRenderTypeSet blockRenderTypes; ++ @Nullable protected final List itemRenderTypes; -+ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, ItemOverrides, net.neoforged.neoforge.client.RenderTypeGroup) variant with RenderTypeGroup} **/ ++ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, net.neoforged.neoforge.client.RenderTypeGroup) variant with RenderTypeGroup} **/ + @Deprecated public SimpleBakedModel( List p_119489_, Map> p_119490_, -@@ -37,6 +_,20 @@ - ItemTransforms p_119495_, - ItemOverrides p_119496_ +@@ -35,6 +_,19 @@ + TextureAtlasSprite p_119494_, + ItemTransforms p_119495_ ) { -+ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, p_119496_, net.neoforged.neoforge.client.RenderTypeGroup.EMPTY); ++ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, net.neoforged.neoforge.client.RenderTypeGroup.EMPTY); + } + + public SimpleBakedModel( -+ List p_119489_, -+ Map> p_119490_, -+ boolean p_119491_, -+ boolean p_119492_, -+ boolean p_119493_, -+ TextureAtlasSprite p_119494_, -+ ItemTransforms p_119495_, -+ ItemOverrides p_119496_, -+ net.neoforged.neoforge.client.RenderTypeGroup renderTypes ++ List p_119489_, ++ Map> p_119490_, ++ boolean p_119491_, ++ boolean p_119492_, ++ boolean p_119493_, ++ TextureAtlasSprite p_119494_, ++ ItemTransforms p_119495_, ++ net.neoforged.neoforge.client.RenderTypeGroup renderTypes + ) { this.unculledFaces = p_119489_; this.culledFaces = p_119490_; this.hasAmbientOcclusion = p_119491_; -@@ -45,6 +_,9 @@ +@@ -42,6 +_,8 @@ + this.usesBlockLight = p_119492_; this.particleIcon = p_119494_; this.transforms = p_119495_; - this.overrides = p_119496_; + this.blockRenderTypes = !renderTypes.isEmpty() ? net.neoforged.neoforge.client.ChunkRenderTypeSet.of(renderTypes.block()) : null; + this.itemRenderTypes = !renderTypes.isEmpty() ? List.of(renderTypes.entity()) : null; -+ this.fabulousItemRenderTypes = !renderTypes.isEmpty() ? List.of(renderTypes.entityFabulous()) : null; } @Override -@@ -87,6 +_,25 @@ - return this.overrides; +@@ -79,6 +_,20 @@ + return this.transforms; } + @Override -+ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(@org.jetbrains.annotations.NotNull BlockState state, @org.jetbrains.annotations.NotNull RandomSource rand, @org.jetbrains.annotations.NotNull net.neoforged.neoforge.client.model.data.ModelData data) { ++ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, net.neoforged.neoforge.client.model.data.ModelData data) { + if (blockRenderTypes != null) + return blockRenderTypes; + return BakedModel.super.getRenderTypes(state, rand, data); + } + + @Override -+ public List getRenderTypes(net.minecraft.world.item.ItemStack itemStack, boolean fabulous) { -+ if (!fabulous) { -+ if (itemRenderTypes != null) -+ return itemRenderTypes; -+ } else { -+ if (fabulousItemRenderTypes != null) -+ return fabulousItemRenderTypes; -+ } -+ return BakedModel.super.getRenderTypes(itemStack, fabulous); ++ public List getRenderTypes(net.minecraft.world.item.ItemStack itemStack) { ++ if (itemRenderTypes != null) ++ return itemRenderTypes; ++ return BakedModel.super.getRenderTypes(itemStack); + } + @OnlyIn(Dist.CLIENT) public static class Builder { - private final List unculledFaces = Lists.newArrayList(); -@@ -133,7 +_,13 @@ + private final ImmutableList.Builder unculledFaces = ImmutableList.builder(); +@@ -124,7 +_,13 @@ return this; } @@ -84,12 +76,12 @@ if (this.particleIcon == null) { throw new RuntimeException("Missing particle!"); } else { -@@ -145,7 +_,8 @@ +@@ -136,7 +_,8 @@ + this.usesBlockLight, this.isGui3d, this.particleIcon, - this.transforms, -- this.overrides -+ this.overrides, +- this.transforms ++ this.transforms, + renderTypes ); } diff --git a/patches/net/minecraft/client/resources/model/WeightedBakedModel.java.patch b/patches/net/minecraft/client/resources/model/WeightedBakedModel.java.patch index f96aeedb..ecca5f27 100644 --- a/patches/net/minecraft/client/resources/model/WeightedBakedModel.java.patch +++ b/patches/net/minecraft/client/resources/model/WeightedBakedModel.java.patch @@ -1,62 +1,30 @@ --- a/net/minecraft/client/resources/model/WeightedBakedModel.java +++ b/net/minecraft/client/resources/model/WeightedBakedModel.java -@@ -17,7 +_,7 @@ +@@ -12,7 +_,7 @@ import net.neoforged.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) --public class WeightedBakedModel implements BakedModel { -+public class WeightedBakedModel implements BakedModel, net.neoforged.neoforge.client.model.IDynamicBakedModel { - private final int totalWeight; - private final List> list; - private final BakedModel wrapped; -@@ -29,9 +_,10 @@ +-public class WeightedBakedModel extends DelegateBakedModel { ++public class WeightedBakedModel extends DelegateBakedModel implements net.neoforged.neoforge.client.model.IDynamicBakedModel { + private final SimpleWeightedRandomList list; + + public WeightedBakedModel(SimpleWeightedRandomList p_371780_) { +@@ -20,8 +_,15 @@ + this.list = p_371780_; } - @Override +- @Override - public List getQuads(@Nullable BlockState p_235058_, @Nullable Direction p_235059_, RandomSource p_235060_) { -+ // FORGE: Implement our overloads (here and below) so child models can have custom logic +- return this.list.getRandomValue(p_235060_).map(p_370367_ -> p_370367_.getQuads(p_235058_, p_235059_, p_235060_)).orElse(Collections.emptyList()); ++ @Override // FORGE: Implement our overload so child models can have custom logic + public List getQuads(@Nullable BlockState p_235058_, @Nullable Direction p_235059_, RandomSource p_235060_, net.neoforged.neoforge.client.model.data.ModelData modelData, @org.jetbrains.annotations.Nullable net.minecraft.client.renderer.RenderType renderType) { - return WeightedRandom.getWeightedItem(this.list, Math.abs((int)p_235060_.nextLong()) % this.totalWeight) -- .map(p_337442_ -> p_337442_.data().getQuads(p_235058_, p_235059_, p_235060_)) -+ .map(p_235065_ -> p_235065_.data().getQuads(p_235058_, p_235059_, p_235060_, modelData, renderType)) - .orElse(Collections.emptyList()); - } - -@@ -41,6 +_,11 @@ - } - - @Override -+ public net.neoforged.neoforge.common.util.TriState useAmbientOcclusion(BlockState state, net.neoforged.neoforge.client.model.data.ModelData modelData, net.minecraft.client.renderer.RenderType renderType) { -+ return this.wrapped.useAmbientOcclusion(state, modelData, renderType); -+ } -+ -+ @Override - public boolean isGui3d() { - return this.wrapped.isGui3d(); - } -@@ -61,8 +_,25 @@ - } - - @Override -+ public TextureAtlasSprite getParticleIcon(net.neoforged.neoforge.client.model.data.ModelData modelData) { -+ return this.wrapped.getParticleIcon(modelData); -+ } -+ -+ @Override - public ItemTransforms getTransforms() { - return this.wrapped.getTransforms(); -+ } -+ -+ @Override -+ public BakedModel applyTransform(net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack poseStack, boolean applyLeftHandTransform) { -+ return this.wrapped.applyTransform(transformType, poseStack, applyLeftHandTransform); ++ return this.list.getRandomValue(p_235060_).map(p_370367_ -> p_370367_.getQuads(p_235058_, p_235059_, p_235060_, modelData, renderType)).orElse(Collections.emptyList()); + } + + @Override // FORGE: Get render types based on the active weighted model -+ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(@org.jetbrains.annotations.NotNull BlockState state, @org.jetbrains.annotations.NotNull RandomSource rand, @org.jetbrains.annotations.NotNull net.neoforged.neoforge.client.model.data.ModelData data) { -+ return WeightedRandom.getWeightedItem(this.list, Math.abs((int)rand.nextLong()) % this.totalWeight) -+ .map((p_235065_) -> p_235065_.data().getRenderTypes(state, rand, data)) -+ .orElse(net.neoforged.neoforge.client.ChunkRenderTypeSet.none()); ++ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, net.neoforged.neoforge.client.model.data.ModelData data) { ++ return list.getRandomValue(rand) ++ .map(model -> model.getRenderTypes(state, rand, data)) ++ .orElse(net.neoforged.neoforge.client.ChunkRenderTypeSet.none()); } - - @Override + } diff --git a/patches/net/minecraft/client/server/IntegratedServer.java.patch b/patches/net/minecraft/client/server/IntegratedServer.java.patch index 2c8e4f62..8d9e76bd 100644 --- a/patches/net/minecraft/client/server/IntegratedServer.java.patch +++ b/patches/net/minecraft/client/server/IntegratedServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/server/IntegratedServer.java +++ b/net/minecraft/client/server/IntegratedServer.java -@@ -73,10 +_,12 @@ +@@ -71,10 +_,12 @@ this.setPvpAllowed(true); this.setFlightAllowed(true); this.initializeKeyPair(); @@ -13,7 +13,7 @@ return true; } -@@ -225,6 +_,7 @@ +@@ -218,6 +_,7 @@ @Override public void halt(boolean p_120053_) { diff --git a/patches/net/minecraft/client/sounds/MusicManager.java.patch b/patches/net/minecraft/client/sounds/MusicManager.java.patch index 9772e14a..578bcd60 100644 --- a/patches/net/minecraft/client/sounds/MusicManager.java.patch +++ b/patches/net/minecraft/client/sounds/MusicManager.java.patch @@ -15,5 +15,5 @@ + } + if (this.currentMusic != null) { - if (!music.getEvent().value().getLocation().equals(this.currentMusic.getLocation()) && music.replaceCurrentMusic()) { + if (!music.getEvent().value().location().equals(this.currentMusic.getLocation()) && music.replaceCurrentMusic()) { this.minecraft.getSoundManager().stop(this.currentMusic); diff --git a/patches/net/minecraft/commands/CommandSource.java.patch b/patches/net/minecraft/commands/CommandSource.java.patch deleted file mode 100644 index 7dece7e4..00000000 --- a/patches/net/minecraft/commands/CommandSource.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/commands/CommandSource.java -+++ b/net/minecraft/commands/CommandSource.java -@@ -22,6 +_,11 @@ - public boolean shouldInformAdmins() { - return false; - } -+ -+ @Override -+ public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { -+ throw new UnsupportedOperationException("Not supported yet."); -+ } - }; - - void sendSystemMessage(Component p_230797_); -@@ -35,4 +_,6 @@ - default boolean alwaysAccepts() { - return false; - } -+ -+ org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper); // CraftBukkit - } diff --git a/patches/net/minecraft/commands/CommandSourceStack.java.patch b/patches/net/minecraft/commands/CommandSourceStack.java.patch index edd7fedd..09ebb7cb 100644 --- a/patches/net/minecraft/commands/CommandSourceStack.java.patch +++ b/patches/net/minecraft/commands/CommandSourceStack.java.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/commands/CommandSourceStack.java +++ b/net/minecraft/commands/CommandSourceStack.java -@@ -17,6 +_,8 @@ - import java.util.function.Supplier; - import java.util.stream.Stream; - import javax.annotation.Nullable; -+ -+import com.mojang.brigadier.tree.CommandNode; - import net.minecraft.ChatFormatting; - import net.minecraft.commands.arguments.EntityAnchorArgument; - import net.minecraft.commands.execution.TraceCallbacks; -@@ -43,7 +_,7 @@ +@@ -46,7 +_,7 @@ import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; @@ -18,26 +9,3 @@ public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player")); public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity")); public final CommandSource source; -@@ -61,6 +_,7 @@ - private final Vec2 rotation; - private final CommandSigningContext signingContext; - private final TaskChainer chatMessageChainer; -+ public volatile CommandNode currentCommand; // CraftBukkit - - public CommandSourceStack( - CommandSource p_81302_, -@@ -389,6 +_,14 @@ - @Override - public boolean hasPermission(int p_81370_) { - return this.permissionLevel >= p_81370_; -+ } -+ -+ public boolean hasPermission(int i, String bukkitPermission) { -+ return false; -+ } -+ -+ public org.bukkit.command.CommandSender getBukkitSender() { -+ return source.getBukkitSender(this); - } - - public Vec3 getPosition() { diff --git a/patches/net/minecraft/commands/Commands.java.patch b/patches/net/minecraft/commands/Commands.java.patch index 3b84b282..17ef4a84 100644 --- a/patches/net/minecraft/commands/Commands.java.patch +++ b/patches/net/minecraft/commands/Commands.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -214,7 +_,7 @@ +@@ -219,7 +_,7 @@ JfrCommand.register(this.dispatcher); } @@ -9,7 +9,7 @@ TestCommand.register(this.dispatcher); RaidCommand.register(this.dispatcher, p_230944_); DebugPathCommand.register(this.dispatcher); -@@ -248,6 +_,7 @@ +@@ -253,6 +_,7 @@ if (p_230943_.includeIntegrated) { PublishCommand.register(this.dispatcher); } @@ -17,29 +17,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -258,6 +_,21 @@ - return new ParseResults<>(commandcontextbuilder1, p_242928_.getReader(), p_242928_.getExceptions()); - } - -+ public void dispatchServerCommand(CommandSourceStack sender, String command) { -+ -+ } -+ -+ public void performPrefixedCommand(CommandSourceStack commandlistenerwrapper, String s, String label) { -+ -+ } -+ -+ public void performCommand(ParseResults parseresults, String s, String label) { // CraftBukkit -+ } -+ -+ private static ContextChain finishParsing(ParseResults parseresults, String s, CommandSourceStack commandlistenerwrapper, String label) { -+ return null; -+ } -+ - public void performPrefixedCommand(CommandSourceStack p_230958_, String p_230959_) { - p_230959_ = p_230959_.startsWith("/") ? p_230959_.substring(1) : p_230959_; - this.performCommand(this.dispatcher.parse(p_230959_, p_230958_), p_230959_); -@@ -265,6 +_,16 @@ +@@ -270,6 +_,16 @@ public void performCommand(ParseResults p_242844_, String p_242841_) { CommandSourceStack commandsourcestack = p_242844_.getContext().getSource(); @@ -53,10 +31,10 @@ + } + p_242844_ = event.getParseResults(); + - commandsourcestack.getServer().getProfiler().push(() -> "/" + p_242841_); + Profiler.get().push(() -> "/" + p_242841_); ContextChain contextchain = finishParsing(p_242844_, p_242841_, commandsourcestack); -@@ -362,7 +_,8 @@ +@@ -367,7 +_,8 @@ Map, CommandNode> map = Maps.newHashMap(); RootCommandNode rootcommandnode = new RootCommandNode<>(); map.put(this.dispatcher.getRoot(), rootcommandnode); diff --git a/patches/net/minecraft/commands/arguments/ResourceKeyArgument.java.patch b/patches/net/minecraft/commands/arguments/ResourceKeyArgument.java.patch new file mode 100644 index 00000000..6fa16e9d --- /dev/null +++ b/patches/net/minecraft/commands/arguments/ResourceKeyArgument.java.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/commands/arguments/ResourceKeyArgument.java ++++ b/net/minecraft/commands/arguments/ResourceKeyArgument.java +@@ -49,6 +_,9 @@ + private static final DynamicCommandExceptionType ERROR_INVALID_ADVANCEMENT = new DynamicCommandExceptionType( + p_378835_ -> Component.translatableEscape("advancement.advancementNotFound", p_378835_) + ); ++ private static final com.mojang.brigadier.exceptions.SimpleCommandExceptionType ERROR_NO_RECIPES_ON_CLIENT = new com.mojang.brigadier.exceptions.SimpleCommandExceptionType( ++ Component.translatable("commands.neoforge.vanilla.resource_key.no_recipes_on_client") ++ ); + final ResourceKey> registryKey; + + public ResourceKeyArgument(ResourceKey> p_212367_) { +@@ -91,6 +_,9 @@ + } + + public static RecipeHolder getRecipe(CommandContext p_380134_, String p_379840_) throws CommandSyntaxException { ++ if (p_380134_.getSource().getUnsidedLevel().isClientSide()) { ++ throw ERROR_NO_RECIPES_ON_CLIENT.create(); ++ } + RecipeManager recipemanager = p_380134_.getSource().getServer().getRecipeManager(); + ResourceKey> resourcekey = getRegistryKey(p_380134_, p_379840_, Registries.RECIPE, ERROR_INVALID_RECIPE); + return recipemanager.byKey(resourcekey).orElseThrow(() -> ERROR_INVALID_RECIPE.create(resourcekey.location())); +@@ -98,7 +_,7 @@ + + public static AdvancementHolder getAdvancement(CommandContext p_379729_, String p_379326_) throws CommandSyntaxException { + ResourceKey resourcekey = getRegistryKey(p_379729_, p_379326_, Registries.ADVANCEMENT, ERROR_INVALID_ADVANCEMENT); +- AdvancementHolder advancementholder = p_379729_.getSource().getServer().getAdvancements().get(resourcekey.location()); ++ AdvancementHolder advancementholder = p_379729_.getSource().getAdvancement(resourcekey.location()); + if (advancementholder == null) { + throw ERROR_INVALID_ADVANCEMENT.create(resourcekey.location()); + } else { diff --git a/patches/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch b/patches/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch deleted file mode 100644 index 67679581..00000000 --- a/patches/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/commands/arguments/ResourceLocationArgument.java -+++ b/net/minecraft/commands/arguments/ResourceLocationArgument.java -@@ -29,7 +_,7 @@ - - public static AdvancementHolder getAdvancement(CommandContext p_106988_, String p_106989_) throws CommandSyntaxException { - ResourceLocation resourcelocation = getId(p_106988_, p_106989_); -- AdvancementHolder advancementholder = p_106988_.getSource().getServer().getAdvancements().get(resourcelocation); -+ AdvancementHolder advancementholder = p_106988_.getSource().getAdvancement(resourcelocation); - if (advancementholder == null) { - throw ERROR_UNKNOWN_ADVANCEMENT.create(resourcelocation); - } else { -@@ -38,7 +_,7 @@ - } - - public static RecipeHolder getRecipe(CommandContext p_106995_, String p_106996_) throws CommandSyntaxException { -- RecipeManager recipemanager = p_106995_.getSource().getServer().getRecipeManager(); -+ RecipeManager recipemanager = p_106995_.getSource().getRecipeManager(); - ResourceLocation resourcelocation = getId(p_106995_, p_106996_); - return recipemanager.byKey(resourcelocation).orElseThrow(() -> ERROR_UNKNOWN_RECIPE.create(resourcelocation)); - } diff --git a/patches/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch b/patches/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch index b72f6ed2..1f0e8a3e 100644 --- a/patches/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch +++ b/patches/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch @@ -1,28 +1,5 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelectorParser.java +++ b/net/minecraft/commands/arguments/selector/EntitySelectorParser.java -@@ -21,7 +_,6 @@ - import javax.annotation.Nullable; - import net.minecraft.advancements.critereon.MinMaxBounds; - import net.minecraft.advancements.critereon.WrappedMinMaxBounds; --import net.minecraft.commands.SharedSuggestionProvider; - import net.minecraft.commands.arguments.selector.options.EntitySelectorOptions; - import net.minecraft.network.chat.Component; - import net.minecraft.server.level.ServerPlayer; -@@ -204,6 +_,14 @@ - }; - } - -+ protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException { -+ throw new RuntimeException("Not Implemented"); -+ } -+ -+ public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException { -+ throw new RuntimeException("Not Implemented"); -+ } -+ - protected void parseSelector() throws CommandSyntaxException { - this.usesSelectors = true; - this.suggestions = this::suggestSelector; @@ -481,6 +_,9 @@ } diff --git a/patches/net/minecraft/core/Holder.java.patch b/patches/net/minecraft/core/Holder.java.patch index f4b396b6..4cb8ce7c 100644 --- a/patches/net/minecraft/core/Holder.java.patch +++ b/patches/net/minecraft/core/Holder.java.patch @@ -9,7 +9,7 @@ T value(); boolean isBound(); -@@ -220,6 +_,14 @@ +@@ -229,6 +_,14 @@ } } @@ -24,7 +24,7 @@ void bindTags(Collection> p_205770_) { this.tags = Set.copyOf(p_205770_); } -@@ -232,6 +_,33 @@ +@@ -241,6 +_,33 @@ @Override public String toString() { return "Reference{" + this.key + "=" + this.value + "}"; diff --git a/patches/net/minecraft/core/HolderLookup.java.patch b/patches/net/minecraft/core/HolderLookup.java.patch index d9548171..aa44414f 100644 --- a/patches/net/minecraft/core/HolderLookup.java.patch +++ b/patches/net/minecraft/core/HolderLookup.java.patch @@ -4,17 +4,24 @@ return this.listTags().map(HolderSet.Named::key); } -- public interface Provider { -+ public interface Provider extends net.neoforged.neoforge.common.extensions.IHolderLookupProviderExtension { - Stream>> listRegistries(); +- public interface Provider extends HolderGetter.Provider { ++ public interface Provider extends HolderGetter.Provider, net.neoforged.neoforge.common.extensions.IHolderLookupProviderExtension { + Stream>> listRegistryKeys(); - Optional> lookup(ResourceKey> p_256285_); -@@ -96,6 +_,11 @@ + default Stream> listRegistries() { +@@ -96,6 +_,18 @@ }; } ++ /** ++ * {@return the data map value attached with the object with the key, or {@code null} if there's no attached value} ++ * ++ * @param type the type of the data map ++ * @param key the object to get the value for ++ * @param the data type ++ */ + @org.jetbrains.annotations.Nullable -+ default A getData(net.neoforged.neoforge.registries.datamaps.DataMapType attachment, ResourceKey key) { ++ default A getData(net.neoforged.neoforge.registries.datamaps.DataMapType type, ResourceKey key) { + return null; + } + diff --git a/patches/net/minecraft/core/HolderSet.java.patch b/patches/net/minecraft/core/HolderSet.java.patch index a557fdb2..6c2a44d7 100644 --- a/patches/net/minecraft/core/HolderSet.java.patch +++ b/patches/net/minecraft/core/HolderSet.java.patch @@ -9,7 +9,7 @@ Stream> stream(); int size(); -@@ -174,6 +_,9 @@ +@@ -182,6 +_,9 @@ void bind(List> p_205836_) { this.contents = List.copyOf(p_205836_); @@ -19,7 +19,7 @@ } public TagKey key() { -@@ -208,6 +_,11 @@ +@@ -225,6 +_,11 @@ @Override public boolean canSerializeIn(HolderOwner p_256542_) { return this.owner.canSerializeIn(p_256542_); diff --git a/patches/net/minecraft/core/MappedRegistry.java.patch b/patches/net/minecraft/core/MappedRegistry.java.patch index e7f390bb..08874566 100644 --- a/patches/net/minecraft/core/MappedRegistry.java.patch +++ b/patches/net/minecraft/core/MappedRegistry.java.patch @@ -1,28 +1,15 @@ --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -31,7 +_,7 @@ +@@ -30,7 +_,7 @@ + import net.minecraft.tags.TagLoader; import net.minecraft.util.RandomSource; - import org.slf4j.Logger; -public class MappedRegistry implements WritableRegistry { +public class MappedRegistry extends net.neoforged.neoforge.registries.BaseMappedRegistry implements WritableRegistry { - private static final Logger LOGGER = LogUtils.getLogger(); - final ResourceKey> key; + private final ResourceKey> key; private final ObjectList> byId = new ObjectArrayList<>(256); -@@ -75,6 +_,12 @@ - public Stream> listTags() { - return MappedRegistry.this.getTags().map(Pair::getSecond); - } -+ -+ @Override -+ @org.jetbrains.annotations.Nullable -+ public A getData(net.neoforged.neoforge.registries.datamaps.DataMapType type, ResourceKey key) { -+ return MappedRegistry.this.getData(type, key); -+ } - }; - private final Object tagAdditionLock = new Object(); - -@@ -114,9 +_,17 @@ + private final Reference2IntMap toId = Util.make(new Reference2IntOpenHashMap<>(), p_304142_ -> p_304142_.defaultReturnValue(-1)); +@@ -86,9 +_,17 @@ @Override public Holder.Reference register(ResourceKey p_256252_, T p_256591_, RegistrationInfo p_326235_) { @@ -38,77 +25,89 @@ + throw new IllegalStateException(String.format(java.util.Locale.ENGLISH, "Invalid id %d - maximum id range of %d exceeded.", i, this.getMaxId())); + if (this.byLocation.containsKey(p_256252_.location())) { - Util.pauseInIde(new IllegalStateException("Adding duplicate key '" + p_256252_ + "' to registry")); - } -@@ -135,16 +_,18 @@ - reference.bindKey(p_256252_); - } else { - reference = this.byKey.computeIfAbsent(p_256252_, p_258168_ -> Holder.Reference.createStandAlone(this.holderOwner(), (ResourceKey)p_258168_)); -+ // Forge: Bind the value immediately so it can be queried while the registry is not frozen -+ reference.bindValue(p_256591_); - } + throw (IllegalStateException)Util.pauseInIde(new IllegalStateException("Adding duplicate key '" + p_256252_ + "' to registry")); + } else if (this.byValue.containsKey(p_256591_)) { +@@ -104,16 +_,18 @@ + reference.bindKey(p_256252_); + } else { + reference = this.byKey.computeIfAbsent(p_256252_, p_367800_ -> Holder.Reference.createStandAlone(this, (ResourceKey)p_367800_)); ++ // Forge: Bind the value immediately so it can be queried while the registry is not frozen ++ reference.bindValue(p_256591_); + } - this.byKey.put(p_256252_, reference); - this.byLocation.put(p_256252_.location(), reference); - this.byValue.put(p_256591_, reference); -- int i = this.byId.size(); - this.byId.add(reference); - this.toId.put(p_256591_, i); - this.registrationInfos.put(p_256252_, p_326235_); - this.registryLifecycle = this.registryLifecycle.add(p_326235_.lifecycle()); -+ this.addCallbacks.forEach(addCallback -> addCallback.onAdd(this, i, p_256252_, p_256591_)); - return reference; + this.byKey.put(p_256252_, reference); + this.byLocation.put(p_256252_.location(), reference); + this.byValue.put(p_256591_, reference); +- int i = this.byId.size(); + this.byId.add(reference); + this.toId.put(p_256591_, i); + this.registrationInfos.put(p_256252_, p_326235_); + this.registryLifecycle = this.registryLifecycle.add(p_326235_.lifecycle()); ++ this.addCallbacks.forEach(addCallback -> addCallback.onAdd(this, i, p_256252_, p_256591_)); + return reference; + } } - -@@ -168,7 +_,7 @@ +@@ -138,7 +_,7 @@ @Nullable @Override - public T get(@Nullable ResourceKey p_122714_) { + public T getValue(@Nullable ResourceKey p_122714_) { - return getValueFromNullable(this.byKey.get(p_122714_)); + return getValueFromNullable(this.byKey.get(resolve(p_122714_))); } @Nullable -@@ -184,12 +_,12 @@ +@@ -154,12 +_,12 @@ @Override - public Optional> getHolder(ResourceLocation p_316743_) { + public Optional> get(ResourceLocation p_316743_) { - return Optional.ofNullable(this.byLocation.get(p_316743_)); + return Optional.ofNullable(this.byLocation.get(resolve(p_316743_))); } @Override - public Optional> getHolder(ResourceKey p_205905_) { + public Optional> get(ResourceKey p_205905_) { - return Optional.ofNullable(this.byKey.get(p_205905_)); + return Optional.ofNullable(this.byKey.get(resolve(p_205905_))); } @Override -@@ -204,7 +_,7 @@ +@@ -174,12 +_,12 @@ } Holder.Reference getOrCreateHolderOrThrow(ResourceKey p_248831_) { -- return this.byKey.computeIfAbsent(p_248831_, p_258169_ -> { +- return this.byKey.computeIfAbsent(p_248831_, p_367801_ -> { + return this.byKey.computeIfAbsent(resolve(p_248831_), p_258169_ -> { if (this.unregisteredIntrusiveHolders != null) { throw new IllegalStateException("This registry can't create new holders without value"); } else { -@@ -237,7 +_,7 @@ +- this.validateWrite((ResourceKey)p_367801_); +- return Holder.Reference.createStandAlone(this, (ResourceKey)p_367801_); ++ this.validateWrite((ResourceKey)p_258169_); ++ return Holder.Reference.createStandAlone(this, (ResourceKey)p_258169_); + } + }); + } +@@ -207,7 +_,7 @@ @Nullable @Override - public T get(@Nullable ResourceLocation p_122739_) { + public T getValue(@Nullable ResourceLocation p_122739_) { - Holder.Reference reference = this.byLocation.get(p_122739_); + Holder.Reference reference = this.byLocation.get(p_122739_ != null ? resolve(p_122739_) : null); return getValueFromNullable(reference); } -@@ -321,13 +_,18 @@ +@@ -269,13 +_,23 @@ return this.byKey.containsKey(p_175392_); } + /** @deprecated Forge: For internal use only. Use the Register events when registering values. */ + @Deprecated -+ public void unfreeze() { ++ @Override ++ public void unfreeze(boolean clearTags) { ++ if (clearTags) { ++ // unbind tags which were bound by the previous freeze ++ this.allTags = MappedRegistry.TagSet.unbound(); ++ } + this.frozen = false; + } + @@ -122,7 +121,7 @@ List list = this.byKey .entrySet() .stream() -@@ -343,8 +_,10 @@ +@@ -291,11 +_,15 @@ throw new IllegalStateException("Some intrusive holders were not registered: " + this.unregisteredIntrusiveHolders.values()); } @@ -132,12 +131,18 @@ } + this.bakeCallbacks.forEach(bakeCallback -> bakeCallback.onBake(this)); - return this; - } -@@ -440,5 +_,53 @@ - @Override - public HolderLookup.RegistryLookup asLookup() { - return this.lookup; + if (this.allTags.isBound()) { +- throw new IllegalStateException("Tags already present before freezing"); ++ // Neo: we freeze/unfreeze the registry to apply snapshots and tags need to be preserved in those cases ++ //throw new IllegalStateException("Tags already present before freezing"); ++ return this; + } else { + List list1 = this.frozenTags + .entrySet() +@@ -450,6 +_,54 @@ + } + }; + } + } + + @Override @@ -151,7 +156,7 @@ + this.byLocation.clear(); + this.byKey.clear(); + this.byValue.clear(); -+ this.tags.clear(); ++ this.allTags = MappedRegistry.TagSet.unbound(); + if (unregisteredIntrusiveHolders != null) { + unregisteredIntrusiveHolders.clear(); + unregisteredIntrusiveHolders = null; @@ -175,16 +180,17 @@ + + @Override + public int getId(ResourceLocation name) { -+ return getId(get(name)); ++ return getId(getValue(name)); + } + + @Override + public int getId(ResourceKey key) { -+ return getId(get(key)); ++ return getId(getValue(key)); + } + + @Override + public boolean containsValue(T value) { + return byValue.containsKey(value); } - } + + interface TagSet { diff --git a/patches/net/minecraft/core/Registry.java.patch b/patches/net/minecraft/core/Registry.java.patch index 7276d4d6..b12790d2 100644 --- a/patches/net/minecraft/core/Registry.java.patch +++ b/patches/net/minecraft/core/Registry.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/core/Registry.java +++ b/net/minecraft/core/Registry.java -@@ -22,7 +_,7 @@ +@@ -21,7 +_,7 @@ import net.minecraft.util.ExtraCodecs; import net.minecraft.util.RandomSource; --public interface Registry extends Keyable, IdMap { -+public interface Registry extends Keyable, IdMap, net.neoforged.neoforge.registries.IRegistryExtension { +-public interface Registry extends Keyable, HolderLookup.RegistryLookup, IdMap { ++public interface Registry extends Keyable, HolderLookup.RegistryLookup, IdMap, net.neoforged.neoforge.registries.IRegistryExtension { + @Override ResourceKey> key(); - default Codec byNameCodec() { @@ -48,7 +_,7 @@ } diff --git a/patches/net/minecraft/core/RegistrySetBuilder.java.patch b/patches/net/minecraft/core/RegistrySetBuilder.java.patch index 163a1531..0acf4974 100644 --- a/patches/net/minecraft/core/RegistrySetBuilder.java.patch +++ b/patches/net/minecraft/core/RegistrySetBuilder.java.patch @@ -22,7 +22,7 @@ - RegistrySetBuilder.LazyHolder lazyholder = new RegistrySetBuilder.LazyHolder<>(p_312323_, resourcekey); - lazyholder.supplier = () -> cloner.clone((T)p_311506_.value(), p_312725_, p_311797_.getValue()); - return lazyholder; -+ Optional> lookup = p_312725_.lookup(p_311836_); ++ Optional> lookup = p_312725_.lookup(p_311836_); + Lifecycle lifecycle; + if (lookup.isPresent()) { + HolderLookup.RegistryLookup registrylookup1 = lookup.get(); @@ -43,16 +43,16 @@ return lookupFromMap(p_311836_, lifecycle, p_312323_, map); } } -@@ -236,7 +_,7 @@ +@@ -235,7 +_,7 @@ + List list = new ArrayList<>(); RegistrySetBuilder.UniversalLookup registrysetbuilder$universallookup = new RegistrySetBuilder.UniversalLookup(registrysetbuilder$universalowner); Builder> builder = ImmutableMap.builder(); - p_255995_.registries() -- .forEach(p_258197_ -> builder.put(p_258197_.key().location(), RegistrySetBuilder.wrapContextLookup(p_258197_.value().asLookup()))); -+ .forEach(p_258197_ -> builder.put(p_258197_.key().location(), net.neoforged.neoforge.common.CommonHooks.wrapRegistryLookup(p_258197_.value().asLookup()))); +- p_255995_.registries().forEach(p_367807_ -> builder.put(p_367807_.key().location(), RegistrySetBuilder.wrapContextLookup(p_367807_.value()))); ++ p_255995_.registries().forEach(p_367807_ -> builder.put(p_367807_.key().location(), net.neoforged.neoforge.common.CommonHooks.wrapRegistryLookup(p_367807_.value()))); p_256495_.forEach(p_256603_ -> builder.put(p_256603_.location(), registrysetbuilder$universallookup)); return new RegistrySetBuilder.BuildState( registrysetbuilder$universalowner, registrysetbuilder$universallookup, builder.build(), new HashMap<>(), list -@@ -260,6 +_,11 @@ +@@ -259,6 +_,11 @@ @Override public HolderGetter lookup(ResourceKey> p_255961_) { return (HolderGetter)BuildState.this.registries.getOrDefault(p_255961_.location(), BuildState.this.lookup); diff --git a/patches/net/minecraft/core/component/DataComponentHolder.java.patch b/patches/net/minecraft/core/component/DataComponentHolder.java.patch index c1264738..d8a88115 100644 --- a/patches/net/minecraft/core/component/DataComponentHolder.java.patch +++ b/patches/net/minecraft/core/component/DataComponentHolder.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/core/component/DataComponentHolder.java +++ b/net/minecraft/core/component/DataComponentHolder.java -@@ -2,7 +_,7 @@ - +@@ -3,7 +_,7 @@ + import java.util.stream.Stream; import javax.annotation.Nullable; -public interface DataComponentHolder { diff --git a/patches/net/minecraft/core/component/DataComponentPatch.java.patch b/patches/net/minecraft/core/component/DataComponentPatch.java.patch index d755bbe0..b42716d7 100644 --- a/patches/net/minecraft/core/component/DataComponentPatch.java.patch +++ b/patches/net/minecraft/core/component/DataComponentPatch.java.patch @@ -1,45 +1,8 @@ --- a/net/minecraft/core/component/DataComponentPatch.java +++ b/net/minecraft/core/component/DataComponentPatch.java -@@ -238,7 +_,44 @@ - Builder() { +@@ -239,6 +_,7 @@ } -+ // CraftBukkit start -+ public void copy(DataComponentPatch orig) { -+ this.map.putAll(orig.map); -+ } -+ -+ public void clear(DataComponentType type) { -+ this.map.remove(type); -+ } -+ -+ public boolean isSet(DataComponentType type) { -+ return map.containsKey(type); -+ } -+ -+ public boolean isEmpty() { -+ return this.map.isEmpty(); -+ } -+ -+ @Override -+ public boolean equals(Object object) { -+ if (this == object) { -+ return true; -+ } -+ -+ if (object instanceof DataComponentPatch.Builder patch) { -+ return this.map.equals(patch.map); -+ } -+ -+ return false; -+ } -+ -+ @Override -+ public int hashCode() { -+ return this.map.hashCode(); -+ } -+ // CraftBukkit end -+ public DataComponentPatch.Builder set(DataComponentType p_332004_, T p_331566_) { + net.neoforged.neoforge.common.CommonHooks.validateComponent(p_331566_); this.map.put(p_332004_, Optional.of(p_331566_)); diff --git a/patches/net/minecraft/core/component/PatchedDataComponentMap.java.patch b/patches/net/minecraft/core/component/PatchedDataComponentMap.java.patch index 041019dd..dfea9ede 100644 --- a/patches/net/minecraft/core/component/PatchedDataComponentMap.java.patch +++ b/patches/net/minecraft/core/component/PatchedDataComponentMap.java.patch @@ -8,7 +8,7 @@ this.ensureMapOwnership(); T t = this.prototype.get((DataComponentType)p_330791_); Optional optional; -@@ -192,6 +_,10 @@ +@@ -197,6 +_,10 @@ } return i; diff --git a/patches/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch b/patches/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch index f2a00c2a..df2a666f 100644 --- a/patches/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch +++ b/patches/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch @@ -1,31 +1,42 @@ --- a/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java -@@ -35,21 +_,22 @@ +@@ -29,27 +_,33 @@ double d2 = vec3.y() + (double)((float)direction.getStepY() * 1.125F); double d3 = vec3.z() + (double)direction.getStepZ() * d0; BlockPos blockpos = p_302460_.pos().relative(direction); -+ Boat boat = (Boat)(this.isChestBoat ? new ChestBoat(serverlevel, d1, d2, d3) : new Boat(serverlevel, d1, d2, d3)); -+ EntityType.createDefaultStackConfig(serverlevel, p_123376_, null).accept(boat); -+ boat.setVariant(this.type); -+ boat.setYRot(direction.toYRot()); ++ AbstractBoat abstractboat = this.type.create(serverlevel, EntitySpawnReason.DISPENSER); ++ if (abstractboat != null) { ++ EntityType.createDefaultStackConfig(serverlevel, p_123376_, null).accept(abstractboat); ++ abstractboat.setYRot(direction.toYRot()); ++ serverlevel.addFreshEntity(abstractboat); ++ } double d4; - if (serverlevel.getFluidState(blockpos).is(FluidTags.WATER)) { -+ if (boat.canBoatInFluid(serverlevel.getFluidState(blockpos))) { ++ if (canBoatInFluid(abstractboat, serverlevel.getFluidState(blockpos))) { d4 = 1.0; } else { - if (!serverlevel.getBlockState(blockpos).isAir() || !serverlevel.getFluidState(blockpos.below()).is(FluidTags.WATER)) { -+ if (!serverlevel.getBlockState(blockpos).isAir() || !boat.canBoatInFluid(serverlevel.getFluidState(blockpos.below()))) { ++ if (!serverlevel.getBlockState(blockpos).isAir() || !canBoatInFluid(abstractboat, serverlevel.getFluidState(blockpos.below()))) { return this.defaultDispenseItemBehavior.dispense(p_302460_, p_123376_); } d4 = 0.0; } -- Boat boat = (Boat)(this.isChestBoat ? new ChestBoat(serverlevel, d1, d2 + d4, d3) : new Boat(serverlevel, d1, d2 + d4, d3)); -- EntityType.createDefaultStackConfig(serverlevel, p_123376_, null).accept(boat); -- boat.setVariant(this.type); -- boat.setYRot(direction.toYRot()); -+ boat.setPos(d1, d2 + d4, d3); - serverlevel.addFreshEntity(boat); - p_123376_.shrink(1); +- AbstractBoat abstractboat = this.type.create(serverlevel, EntitySpawnReason.DISPENSER); + if (abstractboat != null) { + abstractboat.setInitialPos(d1, d2 + d4, d3); +- EntityType.createDefaultStackConfig(serverlevel, p_123376_, null).accept(abstractboat); +- abstractboat.setYRot(direction.toYRot()); +- serverlevel.addFreshEntity(abstractboat); + p_123376_.shrink(1); + } + return p_123376_; ++ } ++ ++ private static boolean canBoatInFluid(@org.jetbrains.annotations.Nullable AbstractBoat boat, net.minecraft.world.level.material.FluidState fluid) { ++ return boat != null ? boat.canBoatInFluid(fluid) : fluid.is(FluidTags.WATER); + } + + @Override diff --git a/patches/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/patches/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index 9f0b115a..e65ba524 100644 --- a/patches/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/patches/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,28 +1,28 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -231,7 +_,7 @@ - DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_338251_.getItem(); - BlockPos blockpos = p_338850_.pos().relative(p_338850_.state().getValue(DispenserBlock.FACING)); - Level level = p_338850_.level(); +@@ -192,7 +_,7 @@ + DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_338735_.getItem(); + BlockPos blockpos = p_338297_.pos().relative(p_338297_.state().getValue(DispenserBlock.FACING)); + Level level = p_338297_.level(); - if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null)) { -+ if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null, p_338251_)) { - dispensiblecontaineritem.checkExtraContent(null, level, p_338251_, blockpos); - return this.consumeWithRemainder(p_338850_, p_338251_, new ItemStack(Items.BUCKET)); ++ if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null, p_338735_)) { + dispensiblecontaineritem.checkExtraContent(null, level, p_338735_, blockpos); + return this.consumeWithRemainder(p_338297_, p_338735_, new ItemStack(Items.BUCKET)); } else { -@@ -279,12 +_,13 @@ +@@ -240,12 +_,13 @@ if (BaseFireBlock.canBePlacedAt(serverlevel, blockpos, direction)) { serverlevel.setBlockAndUpdate(blockpos, BaseFireBlock.getState(serverlevel, blockpos)); serverlevel.gameEvent(null, GameEvent.BLOCK_PLACE, blockpos); - } else if (CampfireBlock.canLight(blockstate) || CandleBlock.canLight(blockstate) || CandleCakeBlock.canLight(blockstate)) { - serverlevel.setBlockAndUpdate(blockpos, blockstate.setValue(BlockStateProperties.LIT, Boolean.valueOf(true))); -+ } else if (blockstate.getToolModifiedState(new net.minecraft.world.item.context.UseOnContext(p_338494_.level(), null, net.minecraft.world.InteractionHand.MAIN_HAND, p_338444_, new net.minecraft.world.phys.BlockHitResult(blockpos.getCenter(), direction.getOpposite(), blockpos, false)), net.neoforged.neoforge.common.ItemAbilities.FIRESTARTER_LIGHT, false) instanceof BlockState blockstate2) { ++ } else if (blockstate.getToolModifiedState(new net.minecraft.world.item.context.UseOnContext(serverlevel, null, net.minecraft.world.InteractionHand.MAIN_HAND, p_338526_, new net.minecraft.world.phys.BlockHitResult(blockpos.getCenter(), direction.getOpposite(), blockpos, false)), net.neoforged.neoforge.common.ItemAbilities.FIRESTARTER_LIGHT, false) instanceof BlockState blockstate2) { + serverlevel.setBlockAndUpdate(blockpos, blockstate2); serverlevel.gameEvent(null, GameEvent.BLOCK_CHANGE, blockpos); - } else if (blockstate.getBlock() instanceof TntBlock) { - TntBlock.explode(serverlevel, blockpos); - serverlevel.removeBlock(blockpos, false); -+ } else if (blockstate.isFlammable(serverlevel, blockpos, p_338494_.state().getValue(DispenserBlock.FACING).getOpposite())) { -+ blockstate.onCaughtFire(serverlevel, blockpos, p_338494_.state().getValue(DispenserBlock.FACING).getOpposite(), null); ++ } else if (blockstate.isFlammable(serverlevel, blockpos, p_338386_.state().getValue(DispenserBlock.FACING).getOpposite())) { ++ blockstate.onCaughtFire(serverlevel, blockpos, p_338386_.state().getValue(DispenserBlock.FACING).getOpposite(), null); + if (blockstate.getBlock() instanceof TntBlock) + serverlevel.removeBlock(blockpos, false); } else { diff --git a/patches/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch b/patches/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch new file mode 100644 index 00000000..0959113d --- /dev/null +++ b/patches/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java ++++ b/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java +@@ -26,6 +_,8 @@ + } else { + LivingEntity livingentity = list.getFirst(); + EquipmentSlot equipmentslot = livingentity.getEquipmentSlotForItem(p_371227_); ++ // Neo: Respect IItemExtension#canEquip in dispenseArmor ++ if (!p_371227_.canEquip(equipmentslot, livingentity)) return false; + ItemStack itemstack = p_371227_.split(1); + livingentity.setItemSlot(equipmentslot, itemstack); + if (livingentity instanceof Mob mob) { diff --git a/patches/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch b/patches/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch new file mode 100644 index 00000000..866bbb82 --- /dev/null +++ b/patches/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java ++++ b/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java +@@ -34,7 +_,7 @@ + BlockState blockstate = serverlevel.getBlockState(blockpos); + double d3; + if (blockstate.is(BlockTags.RAILS)) { +- if (getRailShape(blockstate).isSlope()) { ++ if (getRailShape(blockstate, serverlevel, blockpos).isSlope()) { + d3 = 0.6; + } else { + d3 = 0.1; +@@ -49,7 +_,7 @@ + return this.defaultDispenseItemBehavior.dispense(p_374045_, p_374580_); + } + +- if (direction != Direction.DOWN && getRailShape(blockstate1).isSlope()) { ++ if (direction != Direction.DOWN && getRailShape(blockstate1, serverlevel, blockpos.below()).isSlope()) { + d3 = -0.4; + } else { + d3 = -0.9; +@@ -68,8 +_,8 @@ + return p_374580_; + } + +- private static RailShape getRailShape(BlockState p_374571_) { +- return p_374571_.getBlock() instanceof BaseRailBlock baserailblock ? p_374571_.getValue(baserailblock.getShapeProperty()) : RailShape.NORTH_SOUTH; ++ private static RailShape getRailShape(BlockState p_374571_, ServerLevel level, BlockPos pos) { ++ return p_374571_.getBlock() instanceof BaseRailBlock baserailblock ? baserailblock.getRailDirection(p_374571_, level, pos, null) : RailShape.NORTH_SOUTH; + } + + @Override diff --git a/patches/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch b/patches/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch index 0ab82269..1e9b2b01 100644 --- a/patches/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch +++ b/patches/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch @@ -4,22 +4,19 @@ ServerLevel serverlevel = p_302443_.level(); if (!serverlevel.isClientSide()) { BlockPos blockpos = p_302443_.pos().relative(p_302443_.state().getValue(DispenserBlock.FACING)); -- this.setSuccess(tryShearBeehive(serverlevel, blockpos) || tryShearLivingEntity(serverlevel, blockpos)); +- this.setSuccess(tryShearBeehive(serverlevel, blockpos) || tryShearLivingEntity(serverlevel, blockpos, p_123581_)); + this.setSuccess(net.neoforged.neoforge.common.CommonHooks.tryDispenseShearsHarvestBlock(p_302443_, p_123581_, serverlevel, blockpos) || tryShearBeehive(serverlevel, blockpos) || tryShearLivingEntity(serverlevel, blockpos, p_123581_)); if (this.isSuccess()) { p_123581_.hurtAndBreak(1, serverlevel, null, p_348118_ -> { }); -@@ -51,10 +_,11 @@ - return false; - } +@@ -53,8 +_,9 @@ -- private static boolean tryShearLivingEntity(ServerLevel p_123583_, BlockPos p_123584_) { -+ private static boolean tryShearLivingEntity(ServerLevel p_123583_, BlockPos p_123584_, ItemStack stack) { + private static boolean tryShearLivingEntity(ServerLevel p_123583_, BlockPos p_123584_, ItemStack p_372883_) { for (LivingEntity livingentity : p_123583_.getEntitiesOfClass(LivingEntity.class, new AABB(p_123584_), EntitySelector.NO_SPECTATORS)) { - if (livingentity instanceof Shearable shearable && shearable.readyForShearing()) { -- shearable.shear(SoundSource.BLOCKS); -+ if (livingentity instanceof net.neoforged.neoforge.common.IShearable shearable && shearable.isShearable(null, stack, p_123583_, p_123584_)) { -+ shearable.onSheared(null, stack, p_123583_, p_123584_) +- shearable.shear(p_123583_, SoundSource.BLOCKS, p_372883_); ++ if (livingentity instanceof net.neoforged.neoforge.common.IShearable shearable && shearable.isShearable(null, p_372883_, p_123583_, p_123584_)) { ++ shearable.onSheared(null, p_372883_, p_123583_, p_123584_) + .forEach(drop -> shearable.spawnShearedDrop(p_123583_, p_123584_, drop)); p_123583_.gameEvent(null, GameEvent.SHEAR, p_123584_); return true; diff --git a/patches/net/minecraft/core/particles/ItemParticleOption.java.patch b/patches/net/minecraft/core/particles/ItemParticleOption.java.patch index ba30506c..33a8473c 100644 --- a/patches/net/minecraft/core/particles/ItemParticleOption.java.patch +++ b/patches/net/minecraft/core/particles/ItemParticleOption.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/particles/ItemParticleOption.java +++ b/net/minecraft/core/particles/ItemParticleOption.java -@@ -24,7 +_,7 @@ +@@ -25,7 +_,7 @@ throw new IllegalArgumentException("Empty stacks are not allowed"); } else { this.type = p_123705_; diff --git a/patches/net/minecraft/core/registries/BuiltInRegistries.java.patch b/patches/net/minecraft/core/registries/BuiltInRegistries.java.patch index e693d8f2..d6ad5ccf 100644 --- a/patches/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/patches/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -356,6 +_,10 @@ - }); +@@ -373,6 +_,10 @@ + ((MappedRegistry)p_365443_).bindAllTagsToEmpty(); } + public static java.util.Set getVanillaRegistrationOrder() { diff --git a/patches/net/minecraft/core/registries/Registries.java.patch b/patches/net/minecraft/core/registries/Registries.java.patch index 1d5ce376..6e968254 100644 --- a/patches/net/minecraft/core/registries/Registries.java.patch +++ b/patches/net/minecraft/core/registries/Registries.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/registries/Registries.java +++ b/net/minecraft/core/registries/Registries.java -@@ -249,10 +_,10 @@ +@@ -257,10 +_,10 @@ } public static String elementsDirPath(ResourceKey> p_350960_) { diff --git a/patches/net/minecraft/data/DataProvider.java.patch b/patches/net/minecraft/data/DataProvider.java.patch index 24c97360..07f5c148 100644 --- a/patches/net/minecraft/data/DataProvider.java.patch +++ b/patches/net/minecraft/data/DataProvider.java.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/data/DataProvider.java +++ b/net/minecraft/data/DataProvider.java -@@ -24,6 +_,8 @@ +@@ -28,6 +_,9 @@ public interface DataProvider { ToIntFunction FIXED_ORDER_FIELDS = Util.make(new Object2IntOpenHashMap<>(), p_236070_ -> { + // Neo: conditions go first + p_236070_.put("neoforge:conditions", -1); ++ p_236070_.put("neoforge:ingredient_type", 0); p_236070_.put("type", 0); p_236070_.put("parent", 1); p_236070_.defaultReturnValue(2); diff --git a/patches/net/minecraft/data/Main.java.patch b/patches/net/minecraft/data/Main.java.patch index 4f188c8e..4e6c37a6 100644 --- a/patches/net/minecraft/data/Main.java.patch +++ b/patches/net/minecraft/data/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/Main.java +++ b/net/minecraft/data/Main.java -@@ -77,8 +_,15 @@ +@@ -86,8 +_,15 @@ OptionSpec optionspec6 = optionparser.accepts("all", "Include all generators"); OptionSpec optionspec7 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated"); OptionSpec optionspec8 = optionparser.accepts("input", "Input folder").withRequiredArg(); @@ -17,7 +17,7 @@ Path path = Paths.get(optionspec7.value(optionset)); boolean flag = optionset.has(optionspec6); boolean flag1 = flag || optionset.has(optionspec2); -@@ -86,9 +_,16 @@ +@@ -95,9 +_,16 @@ boolean flag3 = flag || optionset.has(optionspec3); boolean flag4 = flag || optionset.has(optionspec4); boolean flag5 = flag || optionset.has(optionspec5); @@ -36,7 +36,7 @@ flag1, flag2, flag3, -@@ -98,6 +_,7 @@ +@@ -107,6 +_,7 @@ true ); datagenerator.run(); diff --git a/patches/net/minecraft/data/loot/BlockLootSubProvider.java.patch b/patches/net/minecraft/data/loot/BlockLootSubProvider.java.patch index 95cf157b..2bd05fb5 100644 --- a/patches/net/minecraft/data/loot/BlockLootSubProvider.java.patch +++ b/patches/net/minecraft/data/loot/BlockLootSubProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/BlockLootSubProvider.java +++ b/net/minecraft/data/loot/BlockLootSubProvider.java -@@ -655,12 +_,16 @@ +@@ -684,12 +_,16 @@ protected abstract void generate(); @@ -14,7 +14,7 @@ Set> set = new HashSet<>(); - for (Block block : BuiltInRegistries.BLOCK) { -+ for(Block block : getKnownBlocks()) { ++ for (Block block : getKnownBlocks()) { if (block.isEnabled(this.enabledFeatures)) { - ResourceKey resourcekey = block.getLootTable(); - if (resourcekey != BuiltInLootTables.EMPTY && set.add(resourcekey)) { + block.getLootTable() + .ifPresent( diff --git a/patches/net/minecraft/data/loot/EntityLootSubProvider.java.patch b/patches/net/minecraft/data/loot/EntityLootSubProvider.java.patch index 05135934..6ec12bde 100644 --- a/patches/net/minecraft/data/loot/EntityLootSubProvider.java.patch +++ b/patches/net/minecraft/data/loot/EntityLootSubProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/EntityLootSubProvider.java +++ b/net/minecraft/data/loot/EntityLootSubProvider.java -@@ -96,12 +_,16 @@ +@@ -104,12 +_,16 @@ public abstract void generate(); @@ -13,18 +13,9 @@ this.generate(); Set> set = new HashSet<>(); - BuiltInRegistries.ENTITY_TYPE -- .holders() +- .listElements() + this.getKnownEntityTypes() + .map(EntityType::builtInRegistryHolder) .forEach( - p_266624_ -> { - EntityType entitytype = p_266624_.value(); -@@ -151,7 +_,7 @@ - } - } - -- protected static boolean canHaveLootTable(EntityType p_249029_) { -+ protected boolean canHaveLootTable(EntityType p_249029_) { - return SPECIAL_LOOT_TABLE_TYPES.contains(p_249029_) || p_249029_.getCategory() != MobCategory.MISC; - } - + p_367828_ -> { + EntityType entitytype = p_367828_.value(); diff --git a/patches/net/minecraft/data/loot/LootTableProvider.java.patch b/patches/net/minecraft/data/loot/LootTableProvider.java.patch index 8a8f1bc2..d68c2594 100644 --- a/patches/net/minecraft/data/loot/LootTableProvider.java.patch +++ b/patches/net/minecraft/data/loot/LootTableProvider.java.patch @@ -1,29 +1,29 @@ --- a/net/minecraft/data/loot/LootTableProvider.java +++ b/net/minecraft/data/loot/LootTableProvider.java -@@ -62,33 +_,24 @@ +@@ -62,34 +_,24 @@ private CompletableFuture run(CachedOutput p_324447_, HolderLookup.Provider p_323978_) { WritableRegistry writableregistry = new MappedRegistry<>(Registries.LOOT_TABLE, Lifecycle.experimental()); Map map = new Object2ObjectOpenHashMap<>(); -- this.subProviders.forEach(p_344197_ -> p_344197_.provider().apply(p_323978_).generate((p_339366_, p_339367_) -> { -- ResourceLocation resourcelocation = sequenceIdForLootTable(p_339366_); +- this.subProviders.forEach(p_344197_ -> p_344197_.provider().apply(p_323978_).generate((p_380827_, p_380828_) -> { +- ResourceLocation resourcelocation = sequenceIdForLootTable(p_380827_); + getTables().forEach(p_329847_ -> p_329847_.provider().apply(p_323978_).generate((p_335199_, p_335200_) -> { + ResourceLocation resourcelocation = sequenceIdForLootTable(p_335199_); ResourceLocation resourcelocation1 = map.put(RandomSequence.seedForKey(resourcelocation), resourcelocation); if (resourcelocation1 != null) { -- Util.logAndPauseIfInIde("Loot table random sequence seed collision on " + resourcelocation1 + " and " + p_339366_.location()); +- Util.logAndPauseIfInIde("Loot table random sequence seed collision on " + resourcelocation1 + " and " + p_380827_.location()); + Util.logAndPauseIfInIde("Loot table random sequence seed collision on " + resourcelocation1 + " and " + p_335199_.location()); } -- p_339367_.setRandomSequence(resourcelocation); -- LootTable loottable = p_339367_.setParamSet(p_344197_.paramSet).build(); -- writableregistry.register(p_339366_, loottable, RegistrationInfo.BUILT_IN); +- p_380828_.setRandomSequence(resourcelocation); +- LootTable loottable = p_380828_.setParamSet(p_344197_.paramSet).build(); +- writableregistry.register(p_380827_, loottable, RegistrationInfo.BUILT_IN); + p_335200_.setRandomSequence(resourcelocation); + LootTable loottable = p_335200_.setParamSet(p_329847_.paramSet).build(); + writableregistry.register(p_335199_, loottable, RegistrationInfo.BUILT_IN); })); writableregistry.freeze(); ProblemReporter.Collector problemreporter$collector = new ProblemReporter.Collector(); - HolderGetter.Provider holdergetter$provider = new RegistryAccess.ImmutableRegistryAccess(List.of(writableregistry)).freeze().asGetterLookup(); + HolderGetter.Provider holdergetter$provider = new RegistryAccess.ImmutableRegistryAccess(List.of(writableregistry)).freeze(); ValidationContext validationcontext = new ValidationContext(problemreporter$collector, LootContextParamSets.ALL_PARAMS, holdergetter$provider); - for (ResourceKey resourcekey : Sets.difference(this.requiredTables, writableregistry.registryKeySet())) { @@ -31,17 +31,18 @@ - } + validate(writableregistry, validationcontext, problemreporter$collector); -- writableregistry.holders() +- writableregistry.listElements() - .forEach( -- p_339369_ -> p_339369_.value() +- p_380823_ -> p_380823_.value() - .validate( -- validationcontext.setParams(p_339369_.value().getParamSet()).enterElement("{" + p_339369_.key().location() + "}", p_339369_.key()) +- validationcontext.setContextKeySet(p_380823_.value().getParamSet()) +- .enterElement("{" + p_380823_.key().location() + "}", p_380823_.key()) - ) - ); Multimap multimap = problemreporter$collector.get(); if (!multimap.isEmpty()) { multimap.forEach((p_124446_, p_124447_) -> LOGGER.warn("Found validation problem in {}: {}", p_124446_, p_124447_)); -@@ -101,6 +_,20 @@ +@@ -102,6 +_,20 @@ return DataProvider.saveStable(p_324447_, p_323978_, LootTable.DIRECT_CODEC, loottable, path); }).toArray(CompletableFuture[]::new)); } @@ -56,8 +57,8 @@ + problemreporter$collector.report("Missing built-in table: " + resourcekey.location()); + } + -+ writableregistry.holders().forEach(p_335195_ -> { -+ p_335195_.value().validate(validationcontext.setParams(p_335195_.value().getParamSet()).enterElement("{" + p_335195_.key().location() + "}", p_335195_.key())); ++ writableregistry.listElements().forEach(p_335195_ -> { ++ p_335195_.value().validate(validationcontext.setContextKeySet(p_335195_.value().getParamSet()).enterElement("{" + p_335195_.key().location() + "}", p_335195_.key())); + }); } diff --git a/patches/net/minecraft/data/recipes/RecipeOutput.java.patch b/patches/net/minecraft/data/recipes/RecipeOutput.java.patch index 17b3c42d..18206b33 100644 --- a/patches/net/minecraft/data/recipes/RecipeOutput.java.patch +++ b/patches/net/minecraft/data/recipes/RecipeOutput.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/data/recipes/RecipeOutput.java +++ b/net/minecraft/data/recipes/RecipeOutput.java @@ -6,8 +_,10 @@ - import net.minecraft.resources.ResourceLocation; + import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.crafting.Recipe; -public interface RecipeOutput { -- void accept(ResourceLocation p_312249_, Recipe p_312328_, @Nullable AdvancementHolder p_312176_); +- void accept(ResourceKey> p_380042_, Recipe p_312328_, @Nullable AdvancementHolder p_312176_); +public interface RecipeOutput extends net.neoforged.neoforge.common.extensions.IRecipeOutputExtension { -+ default void accept(ResourceLocation p_312249_, Recipe p_312328_, @Nullable AdvancementHolder p_312176_) { ++ default void accept(ResourceKey> p_312249_, Recipe p_312328_, @Nullable AdvancementHolder p_312176_) { + accept(p_312249_, p_312328_, p_312176_, new net.neoforged.neoforge.common.conditions.ICondition[0]); + } Advancement.Builder advancement(); - } + diff --git a/patches/net/minecraft/data/recipes/RecipeProvider.java.patch b/patches/net/minecraft/data/recipes/RecipeProvider.java.patch index ec1d44e0..27eb2f31 100644 --- a/patches/net/minecraft/data/recipes/RecipeProvider.java.patch +++ b/patches/net/minecraft/data/recipes/RecipeProvider.java.patch @@ -1,69 +1,53 @@ --- a/net/minecraft/data/recipes/RecipeProvider.java +++ b/net/minecraft/data/recipes/RecipeProvider.java -@@ -84,18 +_,18 @@ - this.buildRecipes( - new RecipeOutput() { - @Override -- public void accept(ResourceLocation p_312039_, Recipe p_312254_, @Nullable AdvancementHolder p_311794_) { -+ public void accept(ResourceLocation p_312039_, Recipe p_312254_, @Nullable AdvancementHolder p_311794_, net.neoforged.neoforge.common.conditions.ICondition... conditions) { - if (!set.add(p_312039_)) { - throw new IllegalStateException("Duplicate recipe " + p_312039_); - } else { -- list.add(DataProvider.saveStable(p_324494_, p_324248_, Recipe.CODEC, p_312254_, RecipeProvider.this.recipePathProvider.json(p_312039_))); -+ list.add(DataProvider.saveStable(p_324494_, p_324248_, Recipe.CONDITIONAL_CODEC, Optional.of(new net.neoforged.neoforge.common.conditions.WithConditions<>(p_312254_, conditions)), RecipeProvider.this.recipePathProvider.json(p_312039_))); - if (p_311794_ != null) { - list.add( - DataProvider.saveStable( - p_324494_, - p_324248_, -- Advancement.CODEC, -- p_311794_.value(), -+ Advancement.CONDITIONAL_CODEC, -+ Optional.of(new net.neoforged.neoforge.common.conditions.WithConditions<>(p_311794_.value(), conditions)), - RecipeProvider.this.advancementPathProvider.json(p_311794_.id()) - ) - ); -@@ -107,18 +_,26 @@ - public Advancement.Builder advancement() { - return Advancement.Builder.recipeAdvancement().parent(RecipeBuilder.ROOT_RECIPE_ADVANCEMENT); - } -- } -+ }, p_324248_ - ); - return CompletableFuture.allOf(list.toArray(CompletableFuture[]::new)); +@@ -566,8 +_,7 @@ } - protected CompletableFuture buildAdvancement(CachedOutput p_253674_, HolderLookup.Provider p_323646_, AdvancementHolder p_301116_) { -- return DataProvider.saveStable(p_253674_, p_323646_, Advancement.CODEC, p_301116_.value(), this.advancementPathProvider.json(p_301116_.id())); -- } -- -- protected abstract void buildRecipes(RecipeOutput p_301172_); -- -- protected static void generateForEnabledBlockFamilies(RecipeOutput p_301146_, FeatureFlagSet p_251836_) { -+ return buildAdvancement(p_253674_, p_323646_, p_301116_, new net.neoforged.neoforge.common.conditions.ICondition[0]); -+ } -+ -+ protected CompletableFuture buildAdvancement(CachedOutput p_253674_, HolderLookup.Provider p_323646_, AdvancementHolder p_301116_, net.neoforged.neoforge.common.conditions.ICondition... conditions) { -+ return DataProvider.saveStable(p_253674_, p_323646_, Advancement.CONDITIONAL_CODEC, Optional.of(new net.neoforged.neoforge.common.conditions.WithConditions<>(p_301116_.value(), conditions)), this.advancementPathProvider.json(p_301116_.id())); -+ } -+ -+ protected void buildRecipes(RecipeOutput recipeOutput, HolderLookup.Provider holderLookup) { -+ buildRecipes(recipeOutput); -+ } -+ -+ protected void buildRecipes(RecipeOutput p_301172_) {} -+ -+ protected void generateForEnabledBlockFamilies(RecipeOutput p_301146_, FeatureFlagSet p_251836_) { - BlockFamilies.getAllFamilies().filter(BlockFamily::shouldGenerateRecipe).forEach(p_313461_ -> generateRecipes(p_301146_, p_313461_, p_251836_)); - } - -@@ -611,8 +_,7 @@ - } - - protected static void waxRecipes(RecipeOutput p_301254_, FeatureFlagSet p_313879_) { + protected void waxRecipes(FeatureFlagSet p_313879_) { - HoneycombItem.WAXABLES - .get() + net.neoforged.neoforge.common.DataMapHooks.INVERSE_WAXABLES_DATAMAP .forEach( - (p_337490_, p_337491_) -> { - if (p_337491_.requiredFeatures().isSubsetOf(p_313879_)) { + (p_359424_, p_359425_) -> { + if (p_359425_.requiredFeatures().isSubsetOf(p_313879_)) { +@@ -756,13 +_,13 @@ + final List> list = new ArrayList<>(); + RecipeOutput recipeoutput = new RecipeOutput() { + @Override +- public void accept(ResourceKey> p_380360_, Recipe p_362882_, @Nullable AdvancementHolder p_364507_) { ++ public void accept(ResourceKey> p_380360_, Recipe p_362882_, @Nullable AdvancementHolder p_364507_, net.neoforged.neoforge.common.conditions.ICondition... conditions) { + if (!set.add(p_380360_)) { + throw new IllegalStateException("Duplicate recipe " + p_380360_.location()); + } else { +- this.saveRecipe(p_380360_, p_362882_); ++ this.saveRecipe(p_380360_, p_362882_, conditions); + if (p_364507_ != null) { +- this.saveAdvancement(p_364507_); ++ this.saveAdvancement(p_364507_, conditions); + } + } + } +@@ -781,15 +_,21 @@ + } + + private void saveRecipe(ResourceKey> p_380099_, Recipe p_364792_) { ++ saveRecipe(p_380099_, p_364792_, new net.neoforged.neoforge.common.conditions.ICondition[0]); ++ } ++ private void saveRecipe(ResourceKey> p_380099_, Recipe p_364792_, net.neoforged.neoforge.common.conditions.ICondition... conditions) { + list.add( +- DataProvider.saveStable(p_364823_, p_364211_, Recipe.CODEC, p_364792_, packoutput$pathprovider.json(p_380099_.location())) ++ DataProvider.saveStable(p_364823_, p_364211_, Recipe.CONDITIONAL_CODEC, Optional.of(new net.neoforged.neoforge.common.conditions.WithConditions<>(p_364792_, conditions)), packoutput$pathprovider.json(p_380099_.location())) + ); + } + + private void saveAdvancement(AdvancementHolder p_363148_) { ++ saveAdvancement(p_363148_, new net.neoforged.neoforge.common.conditions.ICondition[0]); ++ } ++ private void saveAdvancement(AdvancementHolder p_363148_, net.neoforged.neoforge.common.conditions.ICondition... conditions) { + list.add( + DataProvider.saveStable( +- p_364823_, p_364211_, Advancement.CODEC, p_363148_.value(), packoutput$pathprovider1.json(p_363148_.id()) ++ p_364823_, p_364211_, Advancement.CONDITIONAL_CODEC, Optional.of(new net.neoforged.neoforge.common.conditions.WithConditions<>(p_363148_.value(), conditions)), packoutput$pathprovider1.json(p_363148_.id()) + ) + ); + } diff --git a/patches/net/minecraft/data/recipes/ShapedRecipeBuilder.java.patch b/patches/net/minecraft/data/recipes/ShapedRecipeBuilder.java.patch index 2d994e43..e14eb541 100644 --- a/patches/net/minecraft/data/recipes/ShapedRecipeBuilder.java.patch +++ b/patches/net/minecraft/data/recipes/ShapedRecipeBuilder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/recipes/ShapedRecipeBuilder.java +++ b/net/minecraft/data/recipes/ShapedRecipeBuilder.java -@@ -25,6 +_,7 @@ +@@ -28,6 +_,7 @@ private final RecipeCategory category; private final Item result; private final int count; @@ -8,14 +8,15 @@ private final List rows = Lists.newArrayList(); private final Map key = Maps.newLinkedHashMap(); private final Map> criteria = new LinkedHashMap<>(); -@@ -33,9 +_,14 @@ +@@ -36,10 +_,15 @@ private boolean showNotification = true; - public ShapedRecipeBuilder(RecipeCategory p_249996_, ItemLike p_251475_, int p_248948_) { -+ this(p_249996_, new ItemStack(p_251475_, p_248948_)); + private ShapedRecipeBuilder(HolderGetter p_365072_, RecipeCategory p_249996_, ItemLike p_251475_, int p_248948_) { ++ this(p_365072_, p_249996_, new ItemStack(p_251475_, p_248948_)); + } + -+ public ShapedRecipeBuilder(RecipeCategory p_249996_, ItemStack result) { ++ private ShapedRecipeBuilder(HolderGetter p_365072_, RecipeCategory p_249996_, ItemStack result) { + this.items = p_365072_; this.category = p_249996_; - this.result = p_251475_.asItem(); - this.count = p_248948_; @@ -24,19 +25,19 @@ + this.resultStack = result; } - public static ShapedRecipeBuilder shaped(RecipeCategory p_250853_, ItemLike p_249747_) { -@@ -46,6 +_,10 @@ - return new ShapedRecipeBuilder(p_251325_, p_250636_, p_249081_); + public static ShapedRecipeBuilder shaped(HolderGetter p_364036_, RecipeCategory p_250853_, ItemLike p_249747_) { +@@ -50,6 +_,10 @@ + return new ShapedRecipeBuilder(p_365019_, p_251325_, p_250636_, p_249081_); } -+ public static ShapedRecipeBuilder shaped(RecipeCategory p_251325_, ItemStack result) { -+ return new ShapedRecipeBuilder(p_251325_, result); ++ public static ShapedRecipeBuilder shaped(HolderGetter p_365019_, RecipeCategory p_251325_, ItemStack result) { ++ return new ShapedRecipeBuilder(p_365019_, p_251325_, result); + } + public ShapedRecipeBuilder define(Character p_206417_, TagKey p_206418_) { - return this.define(p_206417_, Ingredient.of(p_206418_)); + return this.define(p_206417_, Ingredient.of(this.items.getOrThrow(p_206418_))); } -@@ -106,7 +_,7 @@ +@@ -110,7 +_,7 @@ Objects.requireNonNullElse(this.group, ""), RecipeBuilder.determineBookCategory(this.category), shapedrecipepattern, @@ -44,4 +45,4 @@ + this.resultStack, this.showNotification ); - p_301098_.accept(p_126142_, shapedrecipe, advancement$builder.build(p_126142_.withPrefix("recipes/" + this.category.getFolderName() + "/"))); + p_301098_.accept(p_380072_, shapedrecipe, advancement$builder.build(p_380072_.location().withPrefix("recipes/" + this.category.getFolderName() + "/"))); diff --git a/patches/net/minecraft/data/recipes/ShapelessRecipeBuilder.java.patch b/patches/net/minecraft/data/recipes/ShapelessRecipeBuilder.java.patch deleted file mode 100644 index 27ab5b58..00000000 --- a/patches/net/minecraft/data/recipes/ShapelessRecipeBuilder.java.patch +++ /dev/null @@ -1,46 +0,0 @@ ---- a/net/minecraft/data/recipes/ShapelessRecipeBuilder.java -+++ b/net/minecraft/data/recipes/ShapelessRecipeBuilder.java -@@ -22,15 +_,21 @@ - private final RecipeCategory category; - private final Item result; - private final int count; -+ private final ItemStack resultStack; // Neo: add stack result support - private final NonNullList ingredients = NonNullList.create(); - private final Map> criteria = new LinkedHashMap<>(); - @Nullable - private String group; - - public ShapelessRecipeBuilder(RecipeCategory p_250837_, ItemLike p_251897_, int p_252227_) { -+ this(p_250837_, new ItemStack(p_251897_, p_252227_)); -+ } -+ -+ public ShapelessRecipeBuilder(RecipeCategory p_250837_, ItemStack result) { - this.category = p_250837_; -- this.result = p_251897_.asItem(); -- this.count = p_252227_; -+ this.result = result.getItem(); -+ this.count = result.getCount(); -+ this.resultStack = result; - } - - public static ShapelessRecipeBuilder shapeless(RecipeCategory p_250714_, ItemLike p_249659_) { -@@ -41,6 +_,10 @@ - return new ShapelessRecipeBuilder(p_252339_, p_250836_, p_249928_); - } - -+ public static ShapelessRecipeBuilder shapeless(RecipeCategory p_252339_, ItemStack result) { -+ return new ShapelessRecipeBuilder(p_252339_, result); -+ } -+ - public ShapelessRecipeBuilder requires(TagKey p_206420_) { - return this.requires(Ingredient.of(p_206420_)); - } -@@ -95,7 +_,7 @@ - ShapelessRecipe shapelessrecipe = new ShapelessRecipe( - Objects.requireNonNullElse(this.group, ""), - RecipeBuilder.determineBookCategory(this.category), -- new ItemStack(this.result, this.count), -+ this.resultStack, - this.ingredients - ); - p_301215_.accept(p_126206_, shapelessrecipe, advancement$builder.build(p_126206_.withPrefix("recipes/" + this.category.getFolderName() + "/"))); diff --git a/patches/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java.patch b/patches/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java.patch index fb0bc660..38432d61 100644 --- a/patches/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java.patch +++ b/patches/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java +++ b/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java -@@ -28,6 +_,7 @@ +@@ -29,6 +_,7 @@ private final RecipeCategory category; private final CookingBookCategory bookCategory; private final Item result; @@ -8,7 +8,7 @@ private final Ingredient ingredient; private final float experience; private final int cookingTime; -@@ -45,9 +_,22 @@ +@@ -46,9 +_,22 @@ int p_250189_, AbstractCookingRecipe.Factory p_311960_ ) { @@ -32,7 +32,7 @@ this.ingredient = p_250362_; this.experience = p_251204_; this.cookingTime = p_250189_; -@@ -86,6 +_,38 @@ +@@ -87,6 +_,38 @@ return new SimpleCookingRecipeBuilder(p_250319_, CookingBookCategory.FOOD, p_250377_, p_248930_, p_252329_, p_250482_, SmokingRecipe::new); } @@ -71,12 +71,12 @@ public SimpleCookingRecipeBuilder unlockedBy(String p_176792_, Criterion p_300970_) { this.criteria.put(p_176792_, p_300970_); return this; -@@ -111,7 +_,7 @@ +@@ -112,7 +_,7 @@ this.criteria.forEach(advancement$builder::addCriterion); AbstractCookingRecipe abstractcookingrecipe = this.factory .create( - Objects.requireNonNullElse(this.group, ""), this.bookCategory, this.ingredient, new ItemStack(this.result), this.experience, this.cookingTime + Objects.requireNonNullElse(this.group, ""), this.bookCategory, this.ingredient, this.stackResult, this.experience, this.cookingTime ); - p_301266_.accept(p_126264_, abstractcookingrecipe, advancement$builder.build(p_126264_.withPrefix("recipes/" + this.category.getFolderName() + "/"))); - } + p_301266_.accept( + p_380371_, abstractcookingrecipe, advancement$builder.build(p_380371_.location().withPrefix("recipes/" + this.category.getFolderName() + "/")) diff --git a/patches/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch b/patches/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch index 53007c8f..6619051d 100644 --- a/patches/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch +++ b/patches/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch @@ -48,10 +48,10 @@ + var conditionalCodec = net.neoforged.neoforge.common.conditions.ConditionalOps.createConditionalCodecWithConditions(p_256449_.elementCodec()); return p_256492_.lookup(resourcekey) .map( - p_349921_ -> { + p_367836_ -> { PackOutput.PathProvider packoutput$pathprovider = this.output.createRegistryElementsPathProvider(resourcekey); return CompletableFuture.allOf( - p_349921_.listElements() + p_367836_.listElements() + .filter(holder -> this.namespacePredicate.test(holder.key().location().getNamespace())) .map( p_256105_ -> dumpValue( diff --git a/patches/net/minecraft/data/registries/RegistryPatchGenerator.java.patch b/patches/net/minecraft/data/registries/RegistryPatchGenerator.java.patch index 29eceb38..d7b34a0c 100644 --- a/patches/net/minecraft/data/registries/RegistryPatchGenerator.java.patch +++ b/patches/net/minecraft/data/registries/RegistryPatchGenerator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/registries/RegistryPatchGenerator.java +++ b/net/minecraft/data/registries/RegistryPatchGenerator.java -@@ -20,7 +_,7 @@ +@@ -21,7 +_,7 @@ p_311522_ -> { RegistryAccess.Frozen registryaccess$frozen = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); Cloner.Factory cloner$factory = new Cloner.Factory(); diff --git a/patches/net/minecraft/data/registries/VanillaRegistries.java.patch b/patches/net/minecraft/data/registries/VanillaRegistries.java.patch index 94e1887d..2831c7f2 100644 --- a/patches/net/minecraft/data/registries/VanillaRegistries.java.patch +++ b/patches/net/minecraft/data/registries/VanillaRegistries.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/data/registries/VanillaRegistries.java +++ b/net/minecraft/data/registries/VanillaRegistries.java -@@ -68,6 +_,7 @@ - .add(Registries.ENCHANTMENT, Enchantments::bootstrap) +@@ -72,6 +_,7 @@ .add(Registries.ENCHANTMENT_PROVIDER, VanillaEnchantmentProviders::bootstrap) - .add(Registries.JUKEBOX_SONG, JukeboxSongs::bootstrap); + .add(Registries.JUKEBOX_SONG, JukeboxSongs::bootstrap) + .add(Registries.INSTRUMENT, Instruments::bootstrap); + public static final List>> DATAPACK_REGISTRY_KEYS = BUILDER.getEntryKeys(); private static void validateThatAllBiomeFeaturesHaveBiomeFilter(HolderLookup.Provider p_256242_) { diff --git a/patches/net/minecraft/gametest/framework/GameTestInfo.java.patch b/patches/net/minecraft/gametest/framework/GameTestInfo.java.patch index 6d77cc9d..2081e074 100644 --- a/patches/net/minecraft/gametest/framework/GameTestInfo.java.patch +++ b/patches/net/minecraft/gametest/framework/GameTestInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestInfo.java +++ b/net/minecraft/gametest/framework/GameTestInfo.java -@@ -264,6 +_,7 @@ +@@ -268,6 +_,7 @@ BlockPos blockpos = this.getOrCalculateNorthwestCorner(); this.structureBlockEntity = StructureUtils.prepareTestStructure(this, blockpos, this.getRotation(), this.level); this.structureBlockPos = this.structureBlockEntity.getBlockPos(); diff --git a/patches/net/minecraft/gametest/framework/GameTestServer.java.patch b/patches/net/minecraft/gametest/framework/GameTestServer.java.patch index 162c3537..e648ea2a 100644 --- a/patches/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/patches/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -151,6 +_,7 @@ +@@ -155,6 +_,7 @@ public boolean initServer() { this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, 1) { }); @@ -8,7 +8,7 @@ this.loadLevel(); ServerLevel serverlevel = this.overworld(); this.testBatches = Lists.newArrayList(GameTestBatchFactory.fromTestFunction(this.testFunctions, serverlevel)); -@@ -158,6 +_,7 @@ +@@ -162,6 +_,7 @@ int i = 20000000; serverlevel.setWeatherParameters(20000000, 20000000, false, false); LOGGER.info("Started game test server"); diff --git a/patches/net/minecraft/gametest/framework/TestCommand.java.patch b/patches/net/minecraft/gametest/framework/TestCommand.java.patch index 9bfb27ea..7bc73f3e 100644 --- a/patches/net/minecraft/gametest/framework/TestCommand.java.patch +++ b/patches/net/minecraft/gametest/framework/TestCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/TestCommand.java +++ b/net/minecraft/gametest/framework/TestCommand.java -@@ -361,7 +_,7 @@ +@@ -363,7 +_,7 @@ } else { BlockPos blockpos1 = blockpos.subtract(optional.get()); String s = blockpos1.getX() + ", " + blockpos1.getY() + ", " + blockpos1.getZ(); diff --git a/patches/net/minecraft/locale/Language.java.patch b/patches/net/minecraft/locale/Language.java.patch index 9f3cb451..6ca12f12 100644 --- a/patches/net/minecraft/locale/Language.java.patch +++ b/patches/net/minecraft/locale/Language.java.patch @@ -1,19 +1,20 @@ --- a/net/minecraft/locale/Language.java +++ b/net/minecraft/locale/Language.java -@@ -36,8 +_,10 @@ - private static Language loadDefault() { - Builder builder = ImmutableMap.builder(); - BiConsumer biconsumer = builder::put; +@@ -36,9 +_,11 @@ + DeprecatedTranslationsInfo deprecatedtranslationsinfo = DeprecatedTranslationsInfo.loadFromDefaultResource(); + Map map = new HashMap<>(); + BiConsumer biconsumer = map::put; - parseTranslations(biconsumer, "/assets/minecraft/lang/en_us.json"); -- final Map map = builder.build(); + Map componentMap = new java.util.HashMap<>(); + parseTranslations(biconsumer, componentMap::put, "/assets/minecraft/lang/en_us.json"); -+ final Map map = new java.util.HashMap<>(builder.build()); + deprecatedtranslationsinfo.applyToMap(map); +- final Map map1 = Map.copyOf(map); ++ final Map map1 = map; // Neo keep the map mutable to make LanguageHook work + net.neoforged.neoforge.server.LanguageHook.captureLanguageMap(map, componentMap); return new Language() { @Override public String getOrDefault(String p_128127_, String p_265421_) { -@@ -64,21 +_,51 @@ +@@ -65,21 +_,51 @@ ) .isPresent(); } @@ -66,14 +67,14 @@ String s = UNSUPPORTED_FORMAT_PATTERN.matcher(GsonHelper.convertToString(entry.getValue(), entry.getKey())).replaceAll("%$1s"); p_128110_.accept(entry.getKey(), s); } -@@ -90,6 +_,13 @@ +@@ -91,6 +_,13 @@ public static void inject(Language p_128115_) { instance = p_128115_; + } + + // Neo: All helpers methods below are injected by Neo to ease modder's usage of Language -+ public Map getLanguageData() { return ImmutableMap.of(); } ++ public Map getLanguageData() { return com.google.common.collect.ImmutableMap.of(); } + + public @org.jetbrains.annotations.Nullable net.minecraft.network.chat.Component getComponent(String key) { + return null; diff --git a/patches/net/minecraft/network/Connection.java.patch b/patches/net/minecraft/network/Connection.java.patch index c9a92575..49877aef 100644 --- a/patches/net/minecraft/network/Connection.java.patch +++ b/patches/net/minecraft/network/Connection.java.patch @@ -1,10 +1,9 @@ --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -107,6 +_,9 @@ +@@ -107,6 +_,8 @@ private volatile DisconnectionDetails delayedDisconnect; @Nullable BandwidthDebugMonitor bandwidthDebugMonitor; -+ public String hostname = ""; // CraftBukkit - add field + @Nullable + private ProtocolInfo inboundProtocol; diff --git a/patches/net/minecraft/network/FriendlyByteBuf.java.patch b/patches/net/minecraft/network/FriendlyByteBuf.java.patch index 5f72bfa0..b6e2de94 100644 --- a/patches/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/patches/net/minecraft/network/FriendlyByteBuf.java.patch @@ -9,7 +9,7 @@ public static final int DEFAULT_NBT_QUOTA = 2097152; private final ByteBuf source; public static final short MAX_STRING_LENGTH = 32767; -@@ -1588,5 +_,10 @@ +@@ -1623,5 +_,10 @@ @Override public boolean release(int p_130347_) { return this.source.release(p_130347_); diff --git a/patches/net/minecraft/network/chat/Component.java.patch b/patches/net/minecraft/network/chat/Component.java.patch deleted file mode 100644 index 8370e022..00000000 --- a/patches/net/minecraft/network/chat/Component.java.patch +++ /dev/null @@ -1,44 +0,0 @@ ---- a/net/minecraft/network/chat/Component.java -+++ b/net/minecraft/network/chat/Component.java -@@ -16,12 +_,8 @@ - import java.io.StringReader; - import java.lang.reflect.Type; - import java.net.URI; --import java.util.ArrayList; --import java.util.Collections; --import java.util.Date; --import java.util.List; --import java.util.Optional; --import java.util.UUID; -+import java.util.*; -+import java.util.stream.Stream; - import javax.annotation.Nullable; - import net.minecraft.core.HolderLookup; - import net.minecraft.network.chat.contents.DataSource; -@@ -35,7 +_,7 @@ - import net.minecraft.util.FormattedCharSequence; - import net.minecraft.world.level.ChunkPos; - --public interface Component extends Message, FormattedText { -+public interface Component extends Message, FormattedText, Iterable { // CraftBukkit - Style getStyle(); - - ComponentContents getContents(); -@@ -69,6 +_,17 @@ - - return null; - } -+ -+ // CraftBukkit start -+ default Stream stream() { -+ return com.google.common.collect.Streams.concat(new Stream[]{Stream.of(this), this.getSiblings().stream().flatMap(Component::stream)}); -+ } -+ -+ @Override -+ default Iterator iterator() { -+ return this.stream().iterator(); -+ } -+ // CraftBukkit end - - default MutableComponent plainCopy() { - return MutableComponent.create(this.getContents()); diff --git a/patches/net/minecraft/network/chat/TextColor.java.patch b/patches/net/minecraft/network/chat/TextColor.java.patch deleted file mode 100644 index 60ee0c1f..00000000 --- a/patches/net/minecraft/network/chat/TextColor.java.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/net/minecraft/network/chat/TextColor.java -+++ b/net/minecraft/network/chat/TextColor.java -@@ -17,22 +_,32 @@ - public static final Codec CODEC = Codec.STRING.comapFlatMap(TextColor::parseColor, TextColor::serialize); - private static final Map LEGACY_FORMAT_TO_COLOR = Stream.of(ChatFormatting.values()) - .filter(ChatFormatting::isColor) -- .collect(ImmutableMap.toImmutableMap(Function.identity(), p_237301_ -> new TextColor(p_237301_.getColor(), p_237301_.getName()))); -+ .collect(ImmutableMap.toImmutableMap(Function.identity(), p_237301_ -> new TextColor(p_237301_.getColor(), p_237301_.getName(), p_237301_))); - private static final Map NAMED_COLORS = LEGACY_FORMAT_TO_COLOR.values() - .stream() - .collect(ImmutableMap.toImmutableMap(p_237297_ -> p_237297_.name, Function.identity())); - private final int value; - @Nullable - public final String name; -+ @Nullable -+ public final ChatFormatting format; -+ -+ private TextColor(int p_131263_, String p_131264_, ChatFormatting format) { -+ this.value = p_131263_ & 16777215; -+ this.name = p_131264_; -+ this.format = format; -+ } - - private TextColor(int p_131263_, String p_131264_) { - this.value = p_131263_ & 16777215; - this.name = p_131264_; -+ this.format = null; - } - - private TextColor(int p_131261_) { - this.value = p_131261_ & 16777215; - this.name = null; -+ this.format = null; - } - - public int getValue() { diff --git a/patches/net/minecraft/network/codec/ByteBufCodecs.java.patch b/patches/net/minecraft/network/codec/ByteBufCodecs.java.patch index b05fe14e..ac8e4a27 100644 --- a/patches/net/minecraft/network/codec/ByteBufCodecs.java.patch +++ b/patches/net/minecraft/network/codec/ByteBufCodecs.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/network/codec/ByteBufCodecs.java +++ b/net/minecraft/network/codec/ByteBufCodecs.java -@@ -463,7 +_,11 @@ +@@ -487,7 +_,11 @@ ) { return new StreamCodec() { - private IdMap getRegistryOrThrow(RegistryFriendlyByteBuf p_330361_) { -- return p_320353_.apply(p_330361_.registryAccess().registryOrThrow(p_319942_)); -+ var registry = p_330361_.registryAccess().registryOrThrow(p_319942_); + private IdMap getRegistryOrThrow(RegistryFriendlyByteBuf p_362297_) { +- return p_320353_.apply(p_362297_.registryAccess().lookupOrThrow(p_319942_)); ++ var registry = p_362297_.registryAccess().lookupOrThrow(p_319942_); + if (net.neoforged.neoforge.registries.RegistryManager.isNonSyncedBuiltInRegistry(registry)) { + throw new IllegalStateException("Cannot use ID syncing for non-synced built-in registry: " + registry.key()); + } + return p_320353_.apply(registry); } - public R decode(RegistryFriendlyByteBuf p_331253_) { -@@ -520,8 +_,25 @@ + public R decode(RegistryFriendlyByteBuf p_340887_) { +@@ -544,8 +_,25 @@ private static final int NAMED_SET = -1; private final StreamCodec> holderCodec = ByteBufCodecs.holderRegistry(p_332137_); @@ -27,31 +27,31 @@ + return (H) holderSet; + } + - public HolderSet decode(RegistryFriendlyByteBuf p_340887_) { - int i = VarInt.read(p_340887_) - 1; + public HolderSet decode(RegistryFriendlyByteBuf p_376912_) { + int i = VarInt.read(p_376912_) - 1; + // Neo: Co-opt negative VarInt values within the HolderSet codec as an HolderSetType id. + // Vanilla uses 0 for tag and [1, Integer.MAX_VALUE] for list size [0, Integer.MAX_VALUE - 1]. + // So we may encode the registry id for custom holder set types in [Integer.MIN_VALUE + 1, -1] (local variable i must not be underflow). + // The registry id for custom holder set types is (-1 - network id), while local variable i is (network id - 1), so the registry id would be (-2 - i). + if (i < -1) { -+ return this.holderSetCodec(net.neoforged.neoforge.registries.NeoForgeRegistries.HOLDER_SET_TYPES.byIdOrThrow(-2 - i)).decode(p_340887_); ++ return this.holderSetCodec(net.neoforged.neoforge.registries.NeoForgeRegistries.HOLDER_SET_TYPES.byIdOrThrow(-2 - i)).decode(p_376912_); + } if (i == -1) { - Registry registry = p_340887_.registryAccess().registryOrThrow(p_332137_); - return registry.getTag(TagKey.create(p_332137_, ResourceLocation.STREAM_CODEC.decode(p_340887_))).orElseThrow(); -@@ -537,6 +_,15 @@ + Registry registry = p_376912_.registryAccess().lookupOrThrow(p_332137_); + return registry.get(TagKey.create(p_332137_, ResourceLocation.STREAM_CODEC.decode(p_376912_))).orElseThrow(); +@@ -561,6 +_,15 @@ } - public void encode(RegistryFriendlyByteBuf p_341009_, HolderSet p_340834_) { + public void encode(RegistryFriendlyByteBuf p_376382_, HolderSet p_376430_) { + // Neo: Co-opt negative VarInt values within the HolderSet codec as an HolderSetType id. + // Vanilla uses 0 for tag and [1, Integer.MAX_VALUE] for list size [0, Integer.MAX_VALUE - 1] (local variable i in decode() must not be underflow). + // So we may encode the registry id for custom holder set types in [Integer.MIN_VALUE + 1, -1]. + // The network id for custom holder set types is (-1 - registry id) -+ if (p_341009_.getConnectionType().isNeoForge() && p_340834_ instanceof net.neoforged.neoforge.registries.holdersets.ICustomHolderSet customHolderSet) { -+ VarInt.write(p_341009_, -1 - net.neoforged.neoforge.registries.NeoForgeRegistries.HOLDER_SET_TYPES.getId(customHolderSet.type())); -+ this.holderSetCodec(customHolderSet.type()).encode(p_341009_, cast(customHolderSet)); ++ if (p_376382_.getConnectionType().isNeoForge() && p_376430_ instanceof net.neoforged.neoforge.registries.holdersets.ICustomHolderSet customHolderSet) { ++ VarInt.write(p_376382_, -1 - net.neoforged.neoforge.registries.NeoForgeRegistries.HOLDER_SET_TYPES.getId(customHolderSet.type())); ++ this.holderSetCodec(customHolderSet.type()).encode(p_376382_, cast(customHolderSet)); + return; + } - Optional> optional = p_340834_.unwrapKey(); + Optional> optional = p_376430_.unwrapKey(); if (optional.isPresent()) { - VarInt.write(p_341009_, 0); + VarInt.write(p_376382_, 0); diff --git a/patches/net/minecraft/network/protocol/common/ClientCommonPacketListener.java.patch b/patches/net/minecraft/network/protocol/common/ClientCommonPacketListener.java.patch index f9a18764..1b6b85fc 100644 --- a/patches/net/minecraft/network/protocol/common/ClientCommonPacketListener.java.patch +++ b/patches/net/minecraft/network/protocol/common/ClientCommonPacketListener.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/network/protocol/common/ClientCommonPacketListener.java +++ b/net/minecraft/network/protocol/common/ClientCommonPacketListener.java -@@ -3,7 +_,7 @@ - import net.minecraft.network.ClientboundPacketListener; +@@ -2,7 +_,7 @@ + import net.minecraft.network.protocol.cookie.ClientCookiePacketListener; --public interface ClientCommonPacketListener extends ClientCookiePacketListener, ClientboundPacketListener { -+public interface ClientCommonPacketListener extends ClientCookiePacketListener, ClientboundPacketListener, net.neoforged.neoforge.common.extensions.IClientCommonPacketListenerExtension { +-public interface ClientCommonPacketListener extends ClientCookiePacketListener { ++public interface ClientCommonPacketListener extends ClientCookiePacketListener, net.neoforged.neoforge.common.extensions.IClientCommonPacketListenerExtension { void handleKeepAlive(ClientboundKeepAlivePacket p_295236_); void handlePing(ClientboundPingPacket p_296451_); diff --git a/patches/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch b/patches/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch index f17a187e..f36844e8 100644 --- a/patches/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch +++ b/patches/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java +++ b/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java -@@ -60,12 +_,16 @@ +@@ -62,12 +_,16 @@ ), p_333492_ -> { } diff --git a/patches/net/minecraft/network/protocol/common/ServerCommonPacketListener.java.patch b/patches/net/minecraft/network/protocol/common/ServerCommonPacketListener.java.patch index bb57676d..c503189b 100644 --- a/patches/net/minecraft/network/protocol/common/ServerCommonPacketListener.java.patch +++ b/patches/net/minecraft/network/protocol/common/ServerCommonPacketListener.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/network/protocol/common/ServerCommonPacketListener.java +++ b/net/minecraft/network/protocol/common/ServerCommonPacketListener.java -@@ -3,7 +_,7 @@ +@@ -2,7 +_,7 @@ + import net.minecraft.network.protocol.cookie.ServerCookiePacketListener; - import net.minecraft.network.protocol.game.ServerPacketListener; --public interface ServerCommonPacketListener extends ServerCookiePacketListener, ServerPacketListener { -+public interface ServerCommonPacketListener extends ServerCookiePacketListener, ServerPacketListener, net.neoforged.neoforge.common.extensions.IServerCommonPacketListenerExtension { +-public interface ServerCommonPacketListener extends ServerCookiePacketListener { ++public interface ServerCommonPacketListener extends ServerCookiePacketListener, net.neoforged.neoforge.common.extensions.IServerCommonPacketListenerExtension { void handleKeepAlive(ServerboundKeepAlivePacket p_296457_); void handlePong(ServerboundPongPacket p_294309_); diff --git a/patches/net/minecraft/network/protocol/game/ServerGamePacketListener.java.patch b/patches/net/minecraft/network/protocol/game/ServerGamePacketListener.java.patch index 141ddf71..f24f3d2b 100644 --- a/patches/net/minecraft/network/protocol/game/ServerGamePacketListener.java.patch +++ b/patches/net/minecraft/network/protocol/game/ServerGamePacketListener.java.patch @@ -4,8 +4,8 @@ import net.minecraft.network.protocol.common.ServerCommonPacketListener; import net.minecraft.network.protocol.ping.ServerPingPacketListener; --public interface ServerGamePacketListener extends ServerPingPacketListener, ServerCommonPacketListener { -+public interface ServerGamePacketListener extends ServerPingPacketListener, ServerCommonPacketListener, net.neoforged.neoforge.common.extensions.IServerGamePacketListenerExtension { +-public interface ServerGamePacketListener extends ServerCommonPacketListener, ServerPingPacketListener { ++public interface ServerGamePacketListener extends ServerCommonPacketListener, ServerPingPacketListener, net.neoforged.neoforge.common.extensions.IServerGamePacketListenerExtension { @Override default ConnectionProtocol protocol() { return ConnectionProtocol.PLAY; diff --git a/patches/net/minecraft/network/syncher/SynchedEntityData.java.patch b/patches/net/minecraft/network/syncher/SynchedEntityData.java.patch index a43c0474..2e15f885 100644 --- a/patches/net/minecraft/network/syncher/SynchedEntityData.java.patch +++ b/patches/net/minecraft/network/syncher/SynchedEntityData.java.patch @@ -16,17 +16,3 @@ } } catch (ClassNotFoundException classnotfoundexception) { } -@@ -66,6 +_,13 @@ - this.isDirty = true; - } - } -+ -+ // CraftBukkit start - add method from above -+ public void markDirty(EntityDataAccessor datawatcherobject) { -+ this.getItem(datawatcherobject).setDirty(true); -+ this.isDirty = true; -+ } -+ // CraftBukkit end - - public boolean isDirty() { - return this.isDirty; diff --git a/patches/net/minecraft/resources/RegistryDataLoader.java.patch b/patches/net/minecraft/resources/RegistryDataLoader.java.patch index 0453b559..4a24d6d0 100644 --- a/patches/net/minecraft/resources/RegistryDataLoader.java.patch +++ b/patches/net/minecraft/resources/RegistryDataLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/RegistryDataLoader.java +++ b/net/minecraft/resources/RegistryDataLoader.java -@@ -100,7 +_,7 @@ +@@ -112,7 +_,7 @@ public static final List> DIMENSION_REGISTRIES = List.of( new RegistryDataLoader.RegistryData<>(Registries.LEVEL_STEM, LevelStem.CODEC) ); @@ -9,16 +9,16 @@ new RegistryDataLoader.RegistryData<>(Registries.BIOME, Biome.NETWORK_CODEC), new RegistryDataLoader.RegistryData<>(Registries.CHAT_TYPE, ChatType.DIRECT_CODEC), new RegistryDataLoader.RegistryData<>(Registries.TRIM_PATTERN, TrimPattern.DIRECT_CODEC), -@@ -112,7 +_,7 @@ - new RegistryDataLoader.RegistryData<>(Registries.BANNER_PATTERN, BannerPattern.DIRECT_CODEC), +@@ -125,7 +_,7 @@ new RegistryDataLoader.RegistryData<>(Registries.ENCHANTMENT, Enchantment.DIRECT_CODEC), - new RegistryDataLoader.RegistryData<>(Registries.JUKEBOX_SONG, JukeboxSong.DIRECT_CODEC) + new RegistryDataLoader.RegistryData<>(Registries.JUKEBOX_SONG, JukeboxSong.DIRECT_CODEC), + new RegistryDataLoader.RegistryData<>(Registries.INSTRUMENT, Instrument.DIRECT_CODEC) - ); + )); // Neo: Keep the list so custom registries can be added later - public static RegistryAccess.Frozen load(ResourceManager p_252046_, RegistryAccess p_249916_, List> p_250344_) { - return load((p_321412_, p_321413_) -> p_321412_.loadFromResources(p_252046_, p_321413_), p_249916_, p_250344_); -@@ -204,11 +_,16 @@ + public static RegistryAccess.Frozen load( + ResourceManager p_364116_, List> p_321716_, List> p_365382_ +@@ -247,11 +_,16 @@ Resource p_326141_, RegistrationInfo p_326033_ ) throws IOException { @@ -37,7 +37,7 @@ } } -@@ -221,7 +_,7 @@ +@@ -264,7 +_,7 @@ ) { String s = Registries.elementsDirPath(p_321557_.key()); FileToIdConverter filetoidconverter = FileToIdConverter.json(s); @@ -46,3 +46,26 @@ for (Entry entry : filetoidconverter.listMatchingResources(p_321535_).entrySet()) { ResourceLocation resourcelocation = entry.getKey(); +@@ -354,13 +_,20 @@ + public static record NetworkedRegistryData(List elements, TagNetworkSerialization.NetworkPayload tags) { + } + +- public static record RegistryData(ResourceKey> key, Codec elementCodec, boolean requiredNonEmpty) { ++ public static record RegistryData(ResourceKey> key, Codec elementCodec, boolean requiredNonEmpty, java.util.function.Consumer> registryBuilderConsumer) { ++ public RegistryData(ResourceKey> key, Codec elementCodec, boolean requiredNonEmpty) { ++ this(key, elementCodec, requiredNonEmpty, registryBuilder -> {}); ++ } ++ + RegistryData(ResourceKey> p_251360_, Codec p_248976_) { + this(p_251360_, p_248976_, false); + } + + RegistryDataLoader.Loader create(Lifecycle p_251662_, Map, Exception> p_251565_) { +- WritableRegistry writableregistry = new MappedRegistry<>(this.key, p_251662_); ++ net.neoforged.neoforge.registries.RegistryBuilder registryBuilder = new net.neoforged.neoforge.registries.RegistryBuilder<>(key); ++ registryBuilderConsumer.accept(registryBuilder); ++ ++ WritableRegistry writableregistry = (WritableRegistry) registryBuilder.disableRegistrationCheck().create(); + return new RegistryDataLoader.Loader<>(this, writableregistry, p_251565_); + } + diff --git a/patches/net/minecraft/server/Bootstrap.java.patch b/patches/net/minecraft/server/Bootstrap.java.patch index 1aaee96a..e775eb5e 100644 --- a/patches/net/minecraft/server/Bootstrap.java.patch +++ b/patches/net/minecraft/server/Bootstrap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Bootstrap.java +++ b/net/minecraft/server/Bootstrap.java -@@ -52,6 +_,8 @@ +@@ -53,6 +_,8 @@ CauldronInteraction.bootStrap(); BuiltInRegistries.bootStrap(); CreativeModeTabs.validate(); @@ -9,7 +9,7 @@ wrapStreams(); bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis()); } -@@ -117,7 +_,6 @@ +@@ -119,7 +_,6 @@ Commands.validate(); } diff --git a/patches/net/minecraft/server/Main.java.patch b/patches/net/minecraft/server/Main.java.patch index 786a375e..e32cfe17 100644 --- a/patches/net/minecraft/server/Main.java.patch +++ b/patches/net/minecraft/server/Main.java.patch @@ -86,14 +86,14 @@ LOGGER.error("Failed to load world data from {}", levelstoragesource$leveldirectory.oldDataFile(), ioexception); LOGGER.error( @@ -214,6 +_,9 @@ - worlddimensions = dedicatedserverproperties.createDimensions(p_307161_.datapackWorldgen()); + worlddimensions = dedicatedserverproperties.createDimensions(p_359487_.datapackWorldgen()); } + // Neo: Do a write-read-cycle to inject modded dimensions on first start of a dedicated server into its generated world dimensions list. -+ var registryOps = net.minecraft.resources.RegistryOps.create(net.minecraft.nbt.NbtOps.INSTANCE, p_307161_.datapackWorldgen()); ++ var registryOps = net.minecraft.resources.RegistryOps.create(net.minecraft.nbt.NbtOps.INSTANCE, p_359487_.datapackWorldgen()); + worlddimensions = WorldDimensions.CODEC.encoder().encodeStart(registryOps, worlddimensions).flatMap((writtenPayloadWithModdedDimensions) -> WorldDimensions.CODEC.decoder().parse(registryOps, writtenPayloadWithModdedDimensions)).resultOrPartial(LOGGER::error).orElse(worlddimensions); WorldDimensions.Complete worlddimensions$complete = worlddimensions.bake(registry); - Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_307161_.datapackWorldgen().allRegistriesLifecycle()); + Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_359487_.datapackWorldgen().allRegistriesLifecycle()); return new WorldLoader.DataLoadOutput<>( @@ -246,24 +_,22 @@ diff --git a/patches/net/minecraft/server/MinecraftServer.java.patch b/patches/net/minecraft/server/MinecraftServer.java.patch index 9cf25ce9..f6874df7 100644 --- a/patches/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/net/minecraft/server/MinecraftServer.java.patch @@ -1,41 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -48,6 +_,9 @@ - import java.util.stream.Collectors; - import javax.annotation.Nullable; - import javax.imageio.ImageIO; -+ -+import jline.console.ConsoleReader; -+import joptsimple.OptionSet; - import net.minecraft.CrashReport; - import net.minecraft.CrashReportCategory; - import net.minecraft.FileUtil; -@@ -165,6 +_,9 @@ - import net.minecraft.world.level.storage.WorldData; - import net.minecraft.world.phys.Vec2; - import net.minecraft.world.phys.Vec3; -+import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.CraftRegistry; -+import org.bukkit.craftbukkit.CraftServer; - import org.slf4j.Logger; - - public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, ChunkIOErrorReporter, CommandSource, AutoCloseable { -@@ -261,10 +_,22 @@ - private final PotionBrewing potionBrewing; - private volatile boolean isSaving; - private static final AtomicReference fatalException = new AtomicReference<>(); -+ // CraftBukkit start -+ public WorldLoader.DataLoadContext worldLoader; -+ public org.bukkit.craftbukkit.CraftServer server; -+ public OptionSet options; -+ public org.bukkit.command.ConsoleCommandSender console; -+ public ConsoleReader reader; -+ public static int currentTick = (int) (System.currentTimeMillis() / 50); -+ public java.util.Queue processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); -+ public int autosavePeriod; -+ public Commands vanillaCommandDispatcher; -+ private boolean forceTicks; -+ // CraftBukkit end +@@ -275,7 +_,7 @@ public static S spin(Function p_129873_) { AtomicReference atomicreference = new AtomicReference<>(); @@ -44,69 +9,19 @@ thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> LOGGER.error("Uncaught exception in server thread", p_177910_)); if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); -@@ -325,6 +_,61 @@ - - protected abstract boolean initServer() throws IOException; - -+ protected void loadLevel(String s) { // CraftBukkit -+ } -+ -+ private void loadWorld0(String s) { -+ } -+ -+ public void initWorld(ServerLevel worldserver, ServerLevelData iworlddataserver, LevelData saveData, WorldOptions worldoptions) { -+ -+ } -+ -+ public void prepareLevels(ChunkProgressListener worldloadlistener, ServerLevel worldserver) { -+ -+ } -+ -+ private boolean hasStopped = false; -+ private final Object stopLock = new Object(); -+ public final boolean hasStopped() { -+ synchronized (stopLock) { -+ return hasStopped; -+ } -+ } -+ -+ private void executeModerately() { -+ this.runAllTasks(); -+ java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L); -+ // CraftBukkit end -+ } -+ -+ public void addLevel(ServerLevel level) { -+ -+ } -+ -+ public void removeLevel(ServerLevel level) { -+ -+ } -+ -+ public boolean isDebugging() { -+ return false; -+ } -+ -+ @Deprecated -+ public static MinecraftServer getServer() { -+ return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null; -+ } -+ -+ @Deprecated -+ public static RegistryAccess getDefaultRegistryAccess() { -+ return CraftRegistry.getMinecraftRegistry(); -+ } -+ -+ // CraftBukkit start -+ public final java.util.concurrent.ExecutorService chatExecutor = java.util.concurrent.Executors.newCachedThreadPool( -+ new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").build()); -+ // CraftBukkit end -+ - protected void loadLevel() { - if (!JvmProfiler.INSTANCE.isRunning()) { +@@ -325,9 +_,9 @@ + this.structureTemplateManager = new StructureTemplateManager(p_236726_.resourceManager(), p_236724_, p_236728_, holdergetter); + this.serverThread = p_236723_; + this.executor = Util.backgroundExecutor(); +- this.potionBrewing = PotionBrewing.bootstrap(this.worldData.enabledFeatures()); ++ this.potionBrewing = PotionBrewing.bootstrap(this.worldData.enabledFeatures(), this.registryAccess()); + this.resources.managers.getRecipeManager().finalizeRecipeLoading(this.worldData.enabledFeatures()); +- this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures()); ++ this.fuelValues = net.neoforged.neoforge.common.DataMapHooks.populateFuelValues(this.registries.compositeAccess(), this.worldData.enabledFeatures()); + this.tickFrame = TracyClient.createDiscontinuousFrame("Server Tick"); } -@@ -372,6 +_,7 @@ + } +@@ -385,6 +_,7 @@ this.readScoreboard(dimensiondatastorage); this.commandStorage = new CommandStorage(dimensiondatastorage); WorldBorder worldborder = serverlevel.getWorldBorder(); @@ -114,7 +29,7 @@ if (!serverleveldata.isInitialized()) { try { setInitialSpawn(serverlevel, serverleveldata, worldoptions.generateBonusChest(), flag); -@@ -421,6 +_,7 @@ +@@ -434,6 +_,7 @@ ); worldborder.addListener(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.getWorldBorder())); this.levels.put(resourcekey1, serverlevel1); @@ -122,15 +37,15 @@ } } -@@ -432,6 +_,7 @@ +@@ -445,6 +_,7 @@ p_177898_.setSpawn(BlockPos.ZERO.above(80), 0.0F); } else { ServerChunkCache serverchunkcache = p_177897_.getChunkSource(); + if (net.neoforged.neoforge.event.EventHooks.onCreateWorldSpawn(p_177897_, p_177898_)) return; ChunkPos chunkpos = new ChunkPos(serverchunkcache.randomState().sampler().findSpawnPosition()); int i = serverchunkcache.getGenerator().getSpawnHeight(p_177897_); - if (i < p_177897_.getMinBuildHeight()) { -@@ -513,6 +_,7 @@ + if (i < p_177897_.getMinY()) { +@@ -526,6 +_,7 @@ ChunkPos chunkpos = new ChunkPos(k); serverlevel1.getChunkSource().updateChunkForced(chunkpos, true); } @@ -138,7 +53,7 @@ } } -@@ -620,6 +_,7 @@ +@@ -633,6 +_,7 @@ for (ServerLevel serverlevel2 : this.getAllLevels()) { if (serverlevel2 != null) { try { @@ -146,7 +61,7 @@ serverlevel2.close(); } catch (IOException ioexception1) { LOGGER.error("Exception closing the level", (Throwable)ioexception1); -@@ -666,9 +_,11 @@ +@@ -679,9 +_,11 @@ throw new IllegalStateException("Failed to initialize server"); } @@ -158,16 +73,16 @@ while (this.running) { long i; -@@ -714,6 +_,8 @@ +@@ -734,6 +_,8 @@ this.isReady = true; JvmProfiler.INSTANCE.onServerTick(this.smoothedTickTimeMillis); } + net.neoforged.neoforge.server.ServerLifecycleHooks.handleServerStopping(this); + net.neoforged.neoforge.server.ServerLifecycleHooks.expectServerStopped(); // Forge: Has to come before MinecraftServer#onServerCrash to avoid race conditions - } catch (Throwable throwable1) { - LOGGER.error("Encountered an unexpected exception", throwable1); - CrashReport crashreport = constructOrExtractCrashReport(throwable1); -@@ -725,6 +_,7 @@ + } catch (Throwable throwable2) { + LOGGER.error("Encountered an unexpected exception", throwable2); + CrashReport crashreport = constructOrExtractCrashReport(throwable2); +@@ -745,6 +_,7 @@ LOGGER.error("We were unable to save this crash report to disk."); } @@ -175,7 +90,7 @@ this.onServerCrash(crashreport); } finally { try { -@@ -737,6 +_,7 @@ +@@ -757,6 +_,7 @@ this.services.profileCache().clearExecutor(); } @@ -183,9 +98,9 @@ this.onServerExit(); } } -@@ -901,11 +_,13 @@ - public void tickServer(BooleanSupplier p_129871_) { - long i = Util.getNanos(); +@@ -947,11 +_,13 @@ + } + this.tickCount++; + net.neoforged.neoforge.event.EventHooks.fireServerTickPre(p_129871_, this); this.tickRateManager.tick(); @@ -197,15 +112,15 @@ } this.ticksUntilAutosave--; -@@ -927,6 +_,7 @@ - this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float)j / (float)TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F; +@@ -969,6 +_,7 @@ + this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float)k / (float)TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F; this.logTickMethodTime(i); - this.profiler.pop(); + profilerfiller.pop(); + net.neoforged.neoforge.event.EventHooks.fireServerTickPost(p_129871_, this); } - private void logTickMethodTime(long p_321837_) { -@@ -935,6 +_,16 @@ + private void autoSave() { +@@ -987,6 +_,16 @@ } } @@ -222,7 +137,7 @@ private int computeNextAutosaveInterval() { float f; if (this.tickRateManager.isSprinting()) { -@@ -966,7 +_,8 @@ +@@ -1018,7 +_,8 @@ Optional.of(serverstatus$players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), @@ -232,45 +147,45 @@ ); } -@@ -996,7 +_,8 @@ +@@ -1049,7 +_,8 @@ this.getFunctions().tick(); - this.profiler.popPush("levels"); + profilerfiller.popPush("levels"); - for (ServerLevel serverlevel : this.getAllLevels()) { -+ for(ServerLevel serverlevel : this.getWorldArray()) { ++ for (ServerLevel serverlevel : this.getWorldArray()) { + long tickStart = Util.getNanos(); - this.profiler.push(() -> serverlevel + " " + serverlevel.dimension().location()); + profilerfiller.push(() -> serverlevel + " " + serverlevel.dimension().location()); if (this.tickCount % 20 == 0) { - this.profiler.push("timeSync"); -@@ -1005,6 +_,7 @@ + profilerfiller.push("timeSync"); +@@ -1058,6 +_,7 @@ } - this.profiler.push("tick"); + profilerfiller.push("tick"); + net.neoforged.neoforge.event.EventHooks.fireLevelTickPre(serverlevel, p_129954_); try { serverlevel.tick(p_129954_); -@@ -1013,16 +_,18 @@ +@@ -1066,16 +_,18 @@ serverlevel.fillReportDetails(crashreport); throw new ReportedException(crashreport); } + net.neoforged.neoforge.event.EventHooks.fireLevelTickPost(serverlevel, p_129954_); - this.profiler.pop(); - this.profiler.pop(); + profilerfiller.pop(); + profilerfiller.pop(); + perWorldTickTimes.computeIfAbsent(serverlevel.dimension(), k -> new long[100])[this.tickCount % 100] = Util.getNanos() - tickStart; } - this.profiler.popPush("connection"); - this.getConnection().tick(); - this.profiler.popPush("players"); + profilerfiller.popPush("connection"); + this.tickConnection(); + profilerfiller.popPush("players"); this.playerList.tick(); - if (SharedConstants.IS_RUNNING_IN_IDE && this.tickRateManager.runsNormally()) { + if (net.neoforged.neoforge.gametest.GameTestHooks.isGametestEnabled() && this.tickRateManager.runsNormally()) { GameTestTicker.SINGLETON.tick(); } -@@ -1043,11 +_,17 @@ +@@ -1100,11 +_,17 @@ } private void synchronizeTime(ServerLevel p_276371_) { @@ -293,7 +208,7 @@ } public void forceTimeSynchronization() { -@@ -1118,7 +_,7 @@ +@@ -1176,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -302,7 +217,7 @@ } public SystemReport fillSystemReport(SystemReport p_177936_) { -@@ -1441,7 +_,7 @@ +@@ -1492,7 +_,7 @@ public CompletableFuture reloadResources(Collection p_129862_) { CompletableFuture completablefuture = CompletableFuture.supplyAsync( @@ -311,15 +226,17 @@ this ) .thenCompose( -@@ -1478,6 +_,7 @@ +@@ -1532,7 +_,8 @@ this.getPlayerList().reloadResources(); this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary()); this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager); +- this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures()); ++ this.fuelValues = net.neoforged.neoforge.common.DataMapHooks.populateFuelValues(this.registries.compositeAccess(), this.worldData.enabledFeatures()); + this.getPlayerList().getPlayers().forEach(this.getPlayerList()::sendPlayerPermissionLevel); //Forge: Fix newly added/modified commands not being sent to the client when commands reload. }, this ); -@@ -1495,8 +_,10 @@ +@@ -1550,8 +_,10 @@ FeatureFlagSet featureflagset = p_249869_ ? FeatureFlagSet.of() : p_341632_.enabledFeatures(); FeatureFlagSet featureflagset1 = p_249869_ ? FeatureFlags.REGISTRY.allFlags() : p_341632_.enabledFeatures(); p_248681_.reload(); @@ -331,7 +248,7 @@ } else { Set set = Sets.newLinkedHashSet(); -@@ -1542,6 +_,8 @@ +@@ -1597,6 +_,8 @@ set.add("vanilla"); } @@ -340,7 +257,7 @@ return configureRepositoryWithSelection(p_248681_, set, featureflagset, true); } } -@@ -1712,6 +_,31 @@ +@@ -1763,6 +_,31 @@ public abstract boolean isSingleplayerOwner(GameProfile p_129840_); @@ -372,7 +289,7 @@ public void dumpServerProperties(Path p_177911_) throws IOException { } -@@ -1873,6 +_,10 @@ +@@ -1921,6 +_,10 @@ public WorldData getWorldData() { return this.worldData; diff --git a/patches/net/minecraft/server/PlayerAdvancements.java.patch b/patches/net/minecraft/server/PlayerAdvancements.java.patch index c1dd7151..75e25718 100644 --- a/patches/net/minecraft/server/PlayerAdvancements.java.patch +++ b/patches/net/minecraft/server/PlayerAdvancements.java.patch @@ -16,9 +16,9 @@ + net.neoforged.neoforge.event.EventHooks.onAdvancementProgressedEvent(this.player, p_300979_, advancementprogress, p_135990_, net.neoforged.neoforge.event.entity.player.AdvancementEvent.AdvancementProgressEvent.ProgressType.GRANT); if (!flag1 && advancementprogress.isDone()) { p_300979_.value().rewards().grant(this.player); - p_300979_.value().display().ifPresent(p_352686_ -> { - if (p_352686_.shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { - this.playerList.broadcastSystemMessage(p_352686_.getType().createAnnouncement(p_300979_, this.player), false); + p_300979_.value().display().ifPresent(p_375474_ -> { + if (p_375474_.shouldAnnounceChat() && this.player.serverLevel().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { + this.playerList.broadcastSystemMessage(p_375474_.getType().createAnnouncement(p_300979_, this.player), false); } + net.neoforged.neoforge.event.EventHooks.onAdvancementEarnedEvent(this.player, p_300979_); }); diff --git a/patches/net/minecraft/server/ReloadableServerRegistries.java.patch b/patches/net/minecraft/server/ReloadableServerRegistries.java.patch new file mode 100644 index 00000000..ff31d3b5 --- /dev/null +++ b/patches/net/minecraft/server/ReloadableServerRegistries.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/ReloadableServerRegistries.java ++++ b/net/minecraft/server/ReloadableServerRegistries.java +@@ -61,8 +_,16 @@ + () -> { + WritableRegistry writableregistry = new MappedRegistry<>(p_335741_.registryKey(), Lifecycle.experimental()); + Map map = new HashMap<>(); ++ Map> optionalMap = new HashMap<>(); + String s = Registries.elementsDirPath(p_335741_.registryKey()); +- SimpleJsonResourceReloadListener.scanDirectory(p_335893_, s, p_336173_, p_335741_.codec(), map); ++ SimpleJsonResourceReloadListener.scanDirectory(p_335893_, s, p_336173_, p_335741_.conditionalCodec(), optionalMap); ++ optionalMap.forEach((rl, optionalEntry) -> { ++ optionalEntry.ifPresent(entry -> p_335741_.idSetter().accept(entry, rl)); ++ T value = optionalEntry.orElse(p_335741_.defaultValue()); ++ if (value instanceof LootTable lootTable) value = (T) net.neoforged.neoforge.event.EventHooks.loadLootTable(rl, lootTable); ++ if (value != null) ++ map.put(rl, value); ++ }); + map.forEach( + (p_335721_, p_335683_) -> writableregistry.register( + ResourceKey.create(p_335741_.registryKey(), p_335721_), (T)p_335683_, DEFAULT_REGISTRATION_INFO diff --git a/patches/net/minecraft/server/ReloadableServerResources.java.patch b/patches/net/minecraft/server/ReloadableServerResources.java.patch index cf23f14f..4af3bf71 100644 --- a/patches/net/minecraft/server/ReloadableServerResources.java.patch +++ b/patches/net/minecraft/server/ReloadableServerResources.java.patch @@ -1,19 +1,21 @@ --- a/net/minecraft/server/ReloadableServerResources.java +++ b/net/minecraft/server/ReloadableServerResources.java -@@ -49,6 +_,8 @@ - this.commands = new Commands(p_206858_, CommandBuildContext.simple(this.registryLookup, p_250695_)); - this.advancements = new ServerAdvancementManager(this.registryLookup); +@@ -41,6 +_,9 @@ + this.commands = new Commands(p_206858_, CommandBuildContext.simple(p_361583_, p_250695_)); + this.advancements = new ServerAdvancementManager(p_361583_); this.functionLibrary = new ServerFunctionLibrary(p_206859_, this.commands.getDispatcher()); -+ // Neo: Create context object -+ this.context = new net.neoforged.neoforge.common.conditions.ConditionContext(this.tagManager); ++ // Neo: Store registries and create context object ++ this.registryLookup = p_361583_; ++ this.context = new net.neoforged.neoforge.common.conditions.ConditionContext(this.postponedTags); } public ServerFunctionLibrary getFunctionLibrary() { -@@ -75,6 +_,24 @@ - return List.of(this.tagManager, this.recipes, this.functionLibrary, this.advancements); +@@ -67,6 +_,25 @@ + return List.of(this.recipes, this.functionLibrary, this.advancements); } -+ private final net.neoforged.neoforge.common.conditions.ICondition.IContext context; ++ private final HolderLookup.Provider registryLookup; ++ private final net.neoforged.neoforge.common.conditions.ConditionContext context; + + /** + * Exposes the current condition context for usage in other reload listeners.
@@ -34,12 +36,12 @@ public static CompletableFuture loadResources( ResourceManager p_248588_, LayeredRegistryAccess p_335667_, -@@ -90,14 +_,27 @@ +@@ -83,10 +_,24 @@ ReloadableServerResources reloadableserverresources = new ReloadableServerResources( - p_335211_.compositeAccess(), p_250212_, p_249301_, p_251126_ + p_359514_.layers(), p_359514_.lookupWithUpdatedTags(), p_250212_, p_249301_, p_363739_, p_251126_ ); + List listeners = new java.util.ArrayList<>(reloadableserverresources.listeners()); -+ listeners.addAll(net.neoforged.neoforge.event.EventHooks.onResourceReload(reloadableserverresources, p_335211_.compositeAccess())); ++ listeners.addAll(net.neoforged.neoforge.event.EventHooks.onResourceReload(reloadableserverresources, p_359514_.layers().compositeAccess())); + listeners.forEach(rl -> { + if (rl instanceof net.neoforged.neoforge.resource.ContextAwareReloadListener srl) srl.injectContext(reloadableserverresources.context, reloadableserverresources.registryLookup); + }); @@ -48,26 +50,22 @@ + p_248588_, listeners, p_249136_, p_249601_, DATA_RELOAD_INITIAL_TASK, LOGGER.isDebugEnabled() ) .done() - .whenComplete( - (p_323178_, p_323179_) -> reloadableserverresources.registryLookup - .missingTagAccessPolicy(ReloadableServerResources.MissingTagAccessPolicy.FAIL) - ) + .thenRun(() -> { + // Clear context after reload completes ++ reloadableserverresources.context.clear(); + listeners.forEach(rl -> { + if (rl instanceof net.neoforged.neoforge.resource.ContextAwareReloadListener srl) { -+ srl.injectContext(net.neoforged.neoforge.common.conditions.ICondition.IContext.EMPTY, RegistryAccess.EMPTY); ++ srl.injectContext(net.neoforged.neoforge.common.conditions.ICondition.IContext.EMPTY, net.minecraft.core.RegistryAccess.EMPTY); + } + }); + }) .thenApply(p_214306_ -> reloadableserverresources); } ); -@@ -107,6 +_,7 @@ - this.tagManager.getResult().forEach(p_335204_ -> updateRegistryTags(this.fullRegistryHolder.get(), (TagManager.LoadResult)p_335204_)); - AbstractFurnaceBlockEntity.invalidateCache(); - Blocks.rebuildCache(); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.TagsUpdatedEvent(this.fullRegistryHolder.get(), false, false)); - } +@@ -94,5 +_,6 @@ - private static void updateRegistryTags(RegistryAccess p_206871_, TagManager.LoadResult p_206872_) { + public void updateStaticRegistryTags() { + this.postponedTags.forEach(Registry.PendingTags::apply); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.TagsUpdatedEvent(registryLookup, false, false)); + } + } diff --git a/patches/net/minecraft/server/ServerAdvancementManager.java.patch b/patches/net/minecraft/server/ServerAdvancementManager.java.patch deleted file mode 100644 index 2448b6d2..00000000 --- a/patches/net/minecraft/server/ServerAdvancementManager.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/server/ServerAdvancementManager.java -+++ b/net/minecraft/server/ServerAdvancementManager.java -@@ -39,11 +_,15 @@ - } - - protected void apply(Map p_136034_, ResourceManager p_136035_, ProfilerFiller p_136036_) { -- RegistryOps registryops = this.registries.createSerializationContext(JsonOps.INSTANCE); -+ RegistryOps registryops = this.makeConditionalOps(); // Neo: add condition context - Builder builder = ImmutableMap.builder(); - p_136034_.forEach((p_337529_, p_337530_) -> { - try { -- Advancement advancement = Advancement.CODEC.parse(registryops, p_337530_).getOrThrow(JsonParseException::new); -+ Advancement advancement = net.neoforged.neoforge.common.conditions.ICondition.getWithWithConditionsCodec(Advancement.CONDITIONAL_CODEC, registryops, p_337530_).orElse(null); -+ if (advancement == null) { -+ LOGGER.debug("Skipping loading advancement {} as its conditions were not met", p_337529_); -+ return; -+ } - this.validate(p_337529_, advancement); - builder.put(p_337529_, new AdvancementHolder(p_337529_, advancement)); - } catch (Exception exception) { diff --git a/patches/net/minecraft/server/ServerScoreboard.java.patch b/patches/net/minecraft/server/ServerScoreboard.java.patch deleted file mode 100644 index 69f9f015..00000000 --- a/patches/net/minecraft/server/ServerScoreboard.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/ServerScoreboard.java -+++ b/net/minecraft/server/ServerScoreboard.java -@@ -272,4 +_,8 @@ - CHANGE, - REMOVE; - } -+ -+ private void broadcastAll(Packet packet) { -+ -+ } - } diff --git a/patches/net/minecraft/server/WorldLoader.java.patch b/patches/net/minecraft/server/WorldLoader.java.patch index 67180986..807b3897 100644 --- a/patches/net/minecraft/server/WorldLoader.java.patch +++ b/patches/net/minecraft/server/WorldLoader.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/WorldLoader.java +++ b/net/minecraft/server/WorldLoader.java -@@ -33,7 +_,7 @@ - CloseableResourceManager closeableresourcemanager = pair.getSecond(); - LayeredRegistryAccess layeredregistryaccess = RegistryLayer.createRegistryAccess(); - LayeredRegistryAccess layeredregistryaccess1 = loadAndReplaceLayer( -- closeableresourcemanager, layeredregistryaccess, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES -+ closeableresourcemanager, layeredregistryaccess, RegistryLayer.WORLDGEN, net.neoforged.neoforge.registries.DataPackRegistriesHooks.getDataPackRegistries() +@@ -41,7 +_,7 @@ ); - RegistryAccess.Frozen registryaccess$frozen = layeredregistryaccess1.getAccessForLoading(RegistryLayer.DIMENSIONS); - RegistryAccess.Frozen registryaccess$frozen1 = RegistryDataLoader.load( + RegistryAccess.Frozen registryaccess$frozen = layeredregistryaccess.getAccessForLoading(RegistryLayer.WORLDGEN); + List> list1 = TagLoader.buildUpdatedLookups(registryaccess$frozen, list); +- RegistryAccess.Frozen registryaccess$frozen1 = RegistryDataLoader.load(closeableresourcemanager, list1, RegistryDataLoader.WORLDGEN_REGISTRIES); ++ RegistryAccess.Frozen registryaccess$frozen1 = RegistryDataLoader.load(closeableresourcemanager, list1, net.neoforged.neoforge.registries.DataPackRegistriesHooks.getDataPackRegistries()); + List> list2 = Stream.concat(list1.stream(), registryaccess$frozen1.listRegistries()).toList(); + RegistryAccess.Frozen registryaccess$frozen2 = RegistryDataLoader.load(closeableresourcemanager, list2, RegistryDataLoader.DIMENSION_REGISTRIES); + WorldDataConfiguration worlddataconfiguration = pair.getFirst(); diff --git a/patches/net/minecraft/server/bossevents/CustomBossEvent.java.patch b/patches/net/minecraft/server/bossevents/CustomBossEvent.java.patch deleted file mode 100644 index f767b34d..00000000 --- a/patches/net/minecraft/server/bossevents/CustomBossEvent.java.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/minecraft/server/bossevents/CustomBossEvent.java -+++ b/net/minecraft/server/bossevents/CustomBossEvent.java -@@ -18,12 +_,24 @@ - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.util.Mth; - import net.minecraft.world.BossEvent; -+import org.bukkit.boss.KeyedBossBar; -+import org.bukkit.craftbukkit.boss.CraftKeyedBossbar; - - public class CustomBossEvent extends ServerBossEvent { - private final ResourceLocation id; - private final Set players = Sets.newHashSet(); - private int value; - private int max = 100; -+ // CraftBukkit start -+ private KeyedBossBar bossBar; -+ -+ public KeyedBossBar getBukkitEntity() { -+ if (bossBar == null) { -+ bossBar = new CraftKeyedBossbar(this); -+ } -+ return bossBar; -+ } -+ // CraftBukkit end - - public CustomBossEvent(ResourceLocation p_136261_, Component p_136262_) { - super(p_136262_, BossEvent.BossBarColor.WHITE, BossEvent.BossBarOverlay.PROGRESS); diff --git a/patches/net/minecraft/server/commands/SpreadPlayersCommand.java.patch b/patches/net/minecraft/server/commands/SpreadPlayersCommand.java.patch index 9f297b76..f61c49d3 100644 --- a/patches/net/minecraft/server/commands/SpreadPlayersCommand.java.patch +++ b/patches/net/minecraft/server/commands/SpreadPlayersCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/SpreadPlayersCommand.java +++ b/net/minecraft/server/commands/SpreadPlayersCommand.java -@@ -259,15 +_,22 @@ +@@ -259,16 +_,23 @@ spreadplayerscommand$position = p_138732_[i++]; } @@ -11,7 +11,8 @@ - (double)Mth.floor(spreadplayerscommand$position.z) + 0.5, - Set.of(), - entity.getYRot(), -- entity.getXRot() +- entity.getXRot(), +- true + net.neoforged.neoforge.event.entity.EntityTeleportEvent.SpreadPlayersCommand event = net.neoforged.neoforge.event.EventHooks.onEntityTeleportSpreadPlayersCommand(entity, + (double)Mth.floor(spreadplayerscommand$position.x) + 0.5, + spreadplayerscommand$position.getSpawnY(p_138731_, p_138733_), @@ -25,7 +26,8 @@ + event.getTargetZ(), + Set.of(), + entity.getYRot(), -+ entity.getXRot() ++ entity.getXRot(), ++ true + ); + } double d2 = Double.MAX_VALUE; diff --git a/patches/net/minecraft/server/commands/TeleportCommand.java.patch b/patches/net/minecraft/server/commands/TeleportCommand.java.patch index 2fe8f7c3..70d1b71c 100644 --- a/patches/net/minecraft/server/commands/TeleportCommand.java.patch +++ b/patches/net/minecraft/server/commands/TeleportCommand.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/commands/TeleportCommand.java +++ b/net/minecraft/server/commands/TeleportCommand.java -@@ -270,6 +_,14 @@ +@@ -278,6 +_,14 @@ float p_139023_, - @Nullable TeleportCommand.LookAt p_139024_ + @Nullable LookAt p_380216_ ) throws CommandSyntaxException { + net.neoforged.neoforge.event.entity.EntityTeleportEvent.TeleportCommand event = net.neoforged.neoforge.event.EventHooks.onEntityTeleportCommand(p_139016_, p_139018_, p_139019_, p_139020_); + if (event.isCanceled()) { diff --git a/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch index 953cb8d8..1085bf08 100644 --- a/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,24 +1,15 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -58,6 +_,8 @@ - import net.minecraft.world.level.Level; - import net.minecraft.world.level.block.entity.SkullBlockEntity; - import net.minecraft.world.level.storage.LevelStorageSource; -+import org.bukkit.command.CommandSender; -+import org.bukkit.command.RemoteConsoleCommandSender; - import org.slf4j.Logger; - - public class DedicatedServer extends MinecraftServer implements ServerInterface { -@@ -80,6 +_,8 @@ +@@ -79,6 +_,8 @@ @Nullable private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker; - public ServerLinks serverLinks; + private final ServerLinks serverLinks; + @Nullable + private net.minecraft.client.server.LanServerPinger dediLanPinger; public DedicatedServer( Thread p_214789_, -@@ -103,6 +_,7 @@ +@@ -102,6 +_,7 @@ Thread thread = new Thread("Server console handler") { @Override public void run() { @@ -26,7 +17,7 @@ BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); String s1; -@@ -185,11 +_,13 @@ +@@ -184,11 +_,13 @@ long i = Util.getNanos(); SkullBlockEntity.setup(this.services, this); GameProfileCache.setUsesAuthentication(this.usesAuthentication()); @@ -40,7 +31,7 @@ if (dedicatedserverproperties.announcePlayerAchievements != null) { this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(dedicatedserverproperties.announcePlayerAchievements, this); } -@@ -217,6 +_,12 @@ +@@ -216,6 +_,12 @@ LOGGER.info("JMX monitoring enabled"); } @@ -53,7 +44,7 @@ return true; } } -@@ -295,6 +_,10 @@ +@@ -277,6 +_,10 @@ if (this.queryThreadGs4 != null) { this.queryThreadGs4.stop(); } @@ -64,17 +55,7 @@ } @Override -@@ -542,13 +_,22 @@ - return this.rconConsoleSource.getCommandResponse(); - } - -+ public String runCommand(RconConsoleSource rconConsoleSource, String s) { -+ return s; -+ } -+ - public void storeUsingWhiteList(boolean p_139689_) { - this.settings.update(p_349962_ -> p_349962_.whiteList.update(this.registryAccess(), p_139689_)); - } +@@ -530,7 +_,12 @@ @Override public void stopServer() { @@ -87,19 +68,3 @@ Util.shutdownExecutors(); SkullBlockEntity.clear(); } -@@ -638,5 +_,15 @@ - return Optional.empty(); - } - } -+ } -+ -+ @Override -+ public boolean isDebugging() { -+ return this.getProperties().debug; -+ } -+ -+ @Override -+ public CommandSender getBukkitSender(CommandSourceStack wrapper) { -+ return console; - } - } diff --git a/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch b/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch index dace3c03..b9a564b4 100644 --- a/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch +++ b/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java -@@ -18,6 +_,8 @@ - import java.util.concurrent.TimeUnit; - import java.util.regex.Pattern; - import javax.annotation.Nullable; -+ -+import joptsimple.OptionSet; - import net.minecraft.core.Holder; - import net.minecraft.core.Registry; - import net.minecraft.core.RegistryAccess; @@ -45,7 +_,7 @@ static final Logger LOGGER = LogUtils.getLogger(); private static final Pattern SHA1 = Pattern.compile("^[a-fA-F0-9]{40}$"); @@ -17,33 +8,4 @@ + public final boolean onlineMode = this.get("online-mode", !net.minecraft.SharedConstants.IS_RUNNING_IN_IDE); public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false); public final String serverIp = this.get("server-ip", ""); - public final boolean spawnAnimals = this.get("spawn-animals", true); -@@ -103,6 +_,7 @@ - private final DedicatedServerProperties.WorldDimensionData worldDimensionData; - public final WorldOptions worldOptions; - public boolean acceptsTransfers = this.get("accepts-transfers", false); -+ public final boolean debug = this.get("debug", false); // CraftBukkit - - public DedicatedServerProperties(Properties p_180926_) { - super(p_180926_); -@@ -128,8 +_,20 @@ - ); - } - -+ public DedicatedServerProperties(Properties properties, OptionSet optionset) { -+ this(properties); -+ } -+ - public static DedicatedServerProperties fromFile(Path p_180930_) { - return new DedicatedServerProperties(loadFromFile(p_180930_)); -+ } -+ -+ public static DedicatedServerProperties fromFile(Path path, OptionSet optionset) { -+ return new DedicatedServerProperties(loadFromFile(path), optionset); -+ } -+ -+ protected DedicatedServerProperties reload(RegistryAccess iregistrycustom, Properties properties, OptionSet optionset) { -+ return new DedicatedServerProperties(properties, optionset); - } - - protected DedicatedServerProperties reload(RegistryAccess p_139761_, Properties p_139762_) { + public final boolean pvp = this.get("pvp", true); diff --git a/patches/net/minecraft/server/dedicated/ServerWatchdog.java.patch b/patches/net/minecraft/server/dedicated/ServerWatchdog.java.patch index 0068d126..4045f347 100644 --- a/patches/net/minecraft/server/dedicated/ServerWatchdog.java.patch +++ b/patches/net/minecraft/server/dedicated/ServerWatchdog.java.patch @@ -1,19 +1,41 @@ --- a/net/minecraft/server/dedicated/ServerWatchdog.java +++ b/net/minecraft/server/dedicated/ServerWatchdog.java -@@ -49,14 +_,14 @@ - ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean(); - ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true); - StringBuilder stringbuilder = new StringBuilder(); -- Error error = new Error("Watchdog"); -+ Error error = new Error(String.format(java.util.Locale.ENGLISH, "ServerHangWatchdog detected that a single server tick took %.2f seconds (should be max 0.05)", k / 1000F)); // Forge: don't just make a crash report with a seemingly-inexplicable Error +@@ -46,7 +_,13 @@ + String.format(Locale.ROOT, "%.2f", this.server.tickRateManager().millisecondsPerTick() / (float)TimeUtil.MILLISECONDS_PER_SECOND) + ); + LOGGER.error(LogUtils.FATAL_MARKER, "Considering it to be crashed, server will forcibly shutdown."); +- CrashReport crashreport = createWatchdogCrashReport("Watching Server", this.server.getRunningThread().threadId()); ++ // Neo: don't just make a crash report with a seemingly-inexplicable Error ++ String message = String.format( ++ Locale.ROOT, ++ "ServerWatchdog detected that a single server tick took %.2f seconds (should be max %.2f)", ++ (float)k / (float)TimeUtil.NANOSECONDS_PER_SECOND, ++ this.server.tickRateManager().millisecondsPerTick() / (float)TimeUtil.MILLISECONDS_PER_SECOND); ++ CrashReport crashreport = createWatchdogCrashReport("Watching Server", this.server.getRunningThread().threadId(), message); + this.server.fillSystemReport(crashreport.getSystemReport()); + CrashReportCategory crashreportcategory = crashreport.addCategory("Performance stats"); + crashreportcategory.setDetail( +@@ -77,17 +_,21 @@ + } - for (ThreadInfo threadinfo : athreadinfo) { - if (threadinfo.getThreadId() == this.server.getRunningThread().getId()) { - error.setStackTrace(threadinfo.getStackTrace()); - } + public static CrashReport createWatchdogCrashReport(String p_363165_, long p_364052_) { ++ return createWatchdogCrashReport(p_363165_, p_364052_, "Watchdog"); ++ } ++ ++ public static CrashReport createWatchdogCrashReport(String p_363165_, long p_364052_, String message) { + ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean(); + ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true); + StringBuilder stringbuilder = new StringBuilder(); +- Error error = new Error("Watchdog"); ++ Error error = new Error(message); -- stringbuilder.append(threadinfo); -+ stringbuilder.append(net.neoforged.neoforge.logging.ThreadInfoUtil.getEntireStacktrace(threadinfo)); - stringbuilder.append("\n"); - } + for (ThreadInfo threadinfo : athreadinfo) { + if (threadinfo.getThreadId() == p_364052_) { + error.setStackTrace(threadinfo.getStackTrace()); + } + +- stringbuilder.append(threadinfo); ++ stringbuilder.append(net.neoforged.neoforge.logging.ThreadInfoUtil.getEntireStacktrace(threadinfo)); + stringbuilder.append("\n"); + } diff --git a/patches/net/minecraft/server/dedicated/Settings.java.patch b/patches/net/minecraft/server/dedicated/Settings.java.patch index 0afe52cc..0d12bbd4 100644 --- a/patches/net/minecraft/server/dedicated/Settings.java.patch +++ b/patches/net/minecraft/server/dedicated/Settings.java.patch @@ -1,39 +1,5 @@ --- a/net/minecraft/server/dedicated/Settings.java +++ b/net/minecraft/server/dedicated/Settings.java -@@ -20,17 +_,33 @@ - import java.util.function.Supplier; - import java.util.function.UnaryOperator; - import javax.annotation.Nullable; -+ -+import joptsimple.OptionSet; - import net.minecraft.core.RegistryAccess; - import org.slf4j.Logger; - - public abstract class Settings> { - private static final Logger LOGGER = LogUtils.getLogger(); - public final Properties properties; -+ private OptionSet options = null; - - public Settings(Properties p_139801_) { - this.properties = p_139801_; - } - -+ public Settings(Properties p_139801_, final OptionSet options) { -+ this(p_139801_); -+ this.options = options; -+ } -+ -+ private String getOverride(String name, String value) { -+ if ((this.options != null) && (this.options.has(name))) { -+ return String.valueOf(this.options.valueOf(name)); -+ } -+ -+ return value; -+ } -+ - public static Properties loadFromFile(Path p_139840_) { - try { - try { @@ -66,7 +_,7 @@ public void store(Path p_139877_) { diff --git a/patches/net/minecraft/server/level/ChunkMap.java.patch b/patches/net/minecraft/server/level/ChunkMap.java.patch index 947e62b3..d6dcc919 100644 --- a/patches/net/minecraft/server/level/ChunkMap.java.patch +++ b/patches/net/minecraft/server/level/ChunkMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -395,6 +_,7 @@ +@@ -400,6 +_,7 @@ this.modified = true; } @@ -8,7 +8,7 @@ return p_140179_; } } -@@ -508,8 +_,11 @@ +@@ -529,8 +_,11 @@ } else { ChunkAccess chunkaccess = p_140183_.getLatestChunk(); if (this.pendingUnloads.remove(p_140182_, p_140183_) && chunkaccess != null) { @@ -20,15 +20,23 @@ } this.save(chunkaccess); -@@ -756,6 +_,7 @@ - - this.level.getProfiler().incrementCounter("chunkSave"); - CompoundTag compoundtag = ChunkSerializer.write(this.level, p_140259_); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkDataEvent.Save(p_140259_, p_140259_.getLevel() != null ? p_140259_.getLevel() : this.level, compoundtag)); - this.write(chunkpos, compoundtag).exceptionally(p_351776_ -> { - this.level.getServer().reportChunkSaveFailure(p_351776_, this.storageInfo(), chunkpos); - return null; -@@ -817,9 +_,11 @@ +@@ -579,6 +_,7 @@ + Profiler.get().incrementCounter("chunkLoad"); + if (p_372662_.isPresent()) { + ChunkAccess chunkaccess = p_372662_.get().read(this.level, this.poiManager, this.storageInfo(), p_140418_); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkDataEvent.Load(chunkaccess, p_372662_.get())); + this.markPosition(p_140418_, chunkaccess.getPersistedStatus().getChunkType()); + return chunkaccess; + } else { +@@ -780,6 +_,7 @@ + Profiler.get().incrementCounter("chunkSave"); + this.activeChunkWrites.incrementAndGet(); + SerializableChunkData serializablechunkdata = SerializableChunkData.copyOf(this.level, p_140259_); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkDataEvent.Save(p_140259_, this.level, serializablechunkdata)); + CompletableFuture completablefuture = CompletableFuture.supplyAsync(serializablechunkdata::write, Util.backgroundExecutor()); + this.write(chunkpos, completablefuture::join).handle((p_381690_, p_381691_) -> { + if (p_381691_ != null) { +@@ -846,9 +_,11 @@ private static void markChunkPendingToSend(ServerPlayer p_295834_, LevelChunk p_296281_) { p_295834_.connection.chunkSender.markChunkPendingToSend(p_296281_); @@ -40,7 +48,7 @@ p_294215_.connection.chunkSender.dropChunk(p_294215_, p_294758_); } -@@ -1018,6 +_,7 @@ +@@ -1059,6 +_,7 @@ this.playerMap.unIgnorePlayer(p_140185_); } @@ -48,7 +56,7 @@ this.updateChunkTracking(p_140185_); } } -@@ -1069,7 +_,7 @@ +@@ -1110,7 +_,7 @@ } protected void addEntity(Entity p_140200_) { @@ -57,7 +65,7 @@ EntityType entitytype = p_140200_.getType(); int i = entitytype.clientTrackingRange() * 16; if (i != 0) { -@@ -1313,5 +_,20 @@ +@@ -1354,5 +_,20 @@ this.updatePlayer(serverplayer); } } @@ -74,7 +82,7 @@ + * Use this method to schedule tasks for loading chunks in your whenCompleteAsync method call so the tasks gets processed properly over time and not leak. + * See {@link net.neoforged.neoforge.server.command.generation.GenerationTask#enqueueChunks} as an example usage of this method. + */ -+ public void scheduleOnMainThreadMailbox(ChunkTaskPriorityQueueSorter.Message msg) { -+ mainThreadMailbox.tell(msg); ++ public void scheduleOnMainThreadMailbox(Runnable runnable) { ++ mainThreadExecutor.schedule(runnable); } } diff --git a/patches/net/minecraft/server/level/DistanceManager.java.patch b/patches/net/minecraft/server/level/DistanceManager.java.patch index b0f8aec6..fb0d0488 100644 --- a/patches/net/minecraft/server/level/DistanceManager.java.patch +++ b/patches/net/minecraft/server/level/DistanceManager.java.patch @@ -1,15 +1,14 @@ --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -54,6 +_,8 @@ +@@ -50,6 +_,7 @@ + final Executor mainThreadExecutor; private long ticketTickCounter; - public int simulationDistance = 10; - + private int simulationDistance = 10; + private final Long2ObjectOpenHashMap>> forcedTickets = new Long2ObjectOpenHashMap<>(); -+ + protected DistanceManager(Executor p_140774_, Executor p_140775_) { - ProcessorHandle processorhandle = ProcessorHandle.of("player ticket throttler", p_140775_::execute); - ChunkTaskPriorityQueueSorter chunktaskpriorityqueuesorter = new ChunkTaskPriorityQueueSorter(ImmutableList.of(processorhandle), p_140774_, 4); -@@ -152,6 +_,10 @@ + TaskScheduler taskscheduler = TaskScheduler.wrapExecutor("player ticket throttler", p_140775_); +@@ -150,6 +_,10 @@ if (p_140786_.getTicketLevel() < i) { this.ticketTracker.update(p_140785_, p_140786_.getTicketLevel(), true); } @@ -20,7 +19,7 @@ } void removeTicket(long p_140819_, Ticket p_140820_) { -@@ -164,6 +_,13 @@ +@@ -162,6 +_,13 @@ } this.ticketTracker.update(p_140819_, getTicketLevelAt(sortedarrayset), false); @@ -34,7 +33,7 @@ } public void addTicket(TicketType p_140793_, ChunkPos p_140794_, int p_140795_, T p_140796_) { -@@ -176,14 +_,20 @@ +@@ -174,14 +_,20 @@ } public void addRegionTicket(TicketType p_140841_, ChunkPos p_140842_, int p_140843_, T p_140844_) { @@ -57,10 +56,10 @@ long i = p_140851_.toLong(); this.removeTicket(i, ticket); this.tickingTicketsTracker.removeTicket(i, ticket); -@@ -267,6 +_,11 @@ +@@ -270,6 +_,11 @@ public String getDebugStatus() { - return this.ticketThrottler.getDebugStatus(); + return this.ticketDispatcher.getDebugStatus(); + } + + public boolean shouldForceTicks(long chunkPos) { diff --git a/patches/net/minecraft/server/level/GenerationChunkHolder.java.patch b/patches/net/minecraft/server/level/GenerationChunkHolder.java.patch index cf83f0dc..e34a1b6f 100644 --- a/patches/net/minecraft/server/level/GenerationChunkHolder.java.patch +++ b/patches/net/minecraft/server/level/GenerationChunkHolder.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/level/GenerationChunkHolder.java +++ b/net/minecraft/server/level/GenerationChunkHolder.java -@@ -33,6 +_,7 @@ - private final AtomicReferenceArray>> futures = new AtomicReferenceArray<>(CHUNK_STATUSES.size()); +@@ -34,6 +_,7 @@ private final AtomicReference task = new AtomicReference<>(); private final AtomicInteger generationRefCount = new AtomicInteger(); + private volatile CompletableFuture generationSaveSyncFuture = CompletableFuture.completedFuture(null); + public net.minecraft.world.level.chunk.LevelChunk currentlyLoading; // Forge: Used to bypass future chain when loading chunks. public GenerationChunkHolder(ChunkPos p_347689_) { diff --git a/patches/net/minecraft/server/level/ServerChunkCache.java.patch b/patches/net/minecraft/server/level/ServerChunkCache.java.patch index a52a220b..d56419a0 100644 --- a/patches/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/patches/net/minecraft/server/level/ServerChunkCache.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -45,7 +_,7 @@ - import net.minecraft.world.level.storage.DimensionDataStorage; +@@ -52,7 +_,7 @@ import net.minecraft.world.level.storage.LevelStorageSource; + import org.slf4j.Logger; -public class ServerChunkCache extends ChunkSource { +public class ServerChunkCache extends ChunkSource implements net.neoforged.neoforge.common.extensions.IServerChunkCacheExtension { - private static final List CHUNK_STATUSES = ChunkStatus.getStatusList(); + private static final Logger LOGGER = LogUtils.getLogger(); private final DistanceManager distanceManager; public final ServerLevel level; -@@ -150,6 +_,10 @@ +@@ -165,6 +_,10 @@ } } @@ -20,7 +20,7 @@ profilerfiller.incrementCounter("getChunkCacheMiss"); CompletableFuture> completablefuture = this.getChunkFutureMainThread(p_8360_, p_8361_, p_330876_, p_8363_); this.mainThreadProcessor.managedBlock(completablefuture::isDone); -@@ -184,6 +_,7 @@ +@@ -199,6 +_,7 @@ if (chunkholder == null) { return null; } else { @@ -28,16 +28,16 @@ ChunkAccess chunkaccess1 = chunkholder.getChunkIfPresent(ChunkStatus.FULL); if (chunkaccess1 != null) { this.storeInCache(i, chunkaccess1, ChunkStatus.FULL); -@@ -356,7 +_,7 @@ - for (ServerChunkCache.ChunkAndHolder serverchunkcache$chunkandholder : list) { - LevelChunk levelchunk1 = serverchunkcache$chunkandholder.chunk; - ChunkPos chunkpos = levelchunk1.getPos(); -- if (this.level.isNaturalSpawningAllowed(chunkpos) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkpos)) { -+ if ((this.level.isNaturalSpawningAllowed(chunkpos) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkpos)) || this.distanceManager.shouldForceTicks(chunkpos.toLong())) { - levelchunk1.incrementInhabitedTime(j); - if (flag1 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkpos)) { - NaturalSpawner.spawnForChunk(this.level, levelchunk1, naturalspawner$spawnstate, this.spawnFriendlies, this.spawnEnemies, flag); -@@ -435,11 +_,17 @@ +@@ -384,7 +_,7 @@ + private void collectTickingChunks(List p_363421_) { + this.chunkMap.forEachSpawnCandidateChunk(p_381767_ -> { + LevelChunk levelchunk = p_381767_.getTickingChunk(); +- if (levelchunk != null && this.level.isNaturalSpawningAllowed(p_381767_.getPos())) { ++ if (levelchunk != null && this.level.isNaturalSpawningAllowed(p_381767_.getPos()) || this.distanceManager.shouldForceTicks(p_381767_.getPos().toLong())) { + p_363421_.add(levelchunk); + } + }); +@@ -480,11 +_,17 @@ } public void addRegionTicket(TicketType p_8388_, ChunkPos p_8389_, int p_8390_, T p_8391_) { diff --git a/patches/net/minecraft/server/level/ServerEntity.java.patch b/patches/net/minecraft/server/level/ServerEntity.java.patch index bdf1f7cb..8df4830e 100644 --- a/patches/net/minecraft/server/level/ServerEntity.java.patch +++ b/patches/net/minecraft/server/level/ServerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -101,9 +_,9 @@ +@@ -104,9 +_,9 @@ if (this.entity instanceof ItemFrame itemframe && this.tickCount % 10 == 0) { ItemStack itemstack = itemframe.getItem(); @@ -12,7 +12,7 @@ if (mapitemsaveddata != null) { for (ServerPlayer serverplayer : this.level.players()) { mapitemsaveddata.tickCarriedBy(serverplayer, itemstack); -@@ -233,22 +_,25 @@ +@@ -274,22 +_,25 @@ public void removePairing(ServerPlayer p_8535_) { this.entity.stopSeenByPlayer(p_8535_); p_8535_.connection.send(new ClientboundRemoveEntitiesPacket(this.entity.getId())); diff --git a/patches/net/minecraft/server/level/ServerLevel.java.patch b/patches/net/minecraft/server/level/ServerLevel.java.patch index 411052ea..64e78785 100644 --- a/patches/net/minecraft/server/level/ServerLevel.java.patch +++ b/patches/net/minecraft/server/level/ServerLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -199,7 +_,7 @@ +@@ -202,7 +_,7 @@ private final List customSpawners; @Nullable private EndDragonFight dragonFight; @@ -9,15 +9,15 @@ private final StructureManager structureManager; private final StructureCheck structureCheck; private final boolean tickTime; -@@ -232,7 +_,6 @@ - ); +@@ -225,7 +_,6 @@ + super(p_215002_, p_215003_, p_214999_.registryAccess(), p_215004_.type(), false, p_215006_, p_215007_, p_214999_.getMaxChainedNeighborUpdates()); this.tickTime = p_215009_; this.server = p_214999_; - this.customSpawners = p_215008_; this.serverLevelData = p_215002_; ChunkGenerator chunkgenerator = p_215004_.generator(); boolean flag = p_214999_.forceSynchronousWrites(); -@@ -298,6 +_,11 @@ +@@ -291,6 +_,11 @@ this.randomSequences = Objects.requireNonNullElseGet( p_288977_, () -> this.getDataStorage().computeIfAbsent(RandomSequences.factory(i), "random_sequences") ); @@ -29,7 +29,7 @@ } @Deprecated -@@ -342,7 +_,7 @@ +@@ -336,7 +_,7 @@ if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { long j = this.levelData.getDayTime() + 24000L; @@ -38,7 +38,7 @@ } this.wakeUpAllPlayers(); -@@ -380,7 +_,7 @@ +@@ -374,7 +_,7 @@ this.handlingTick = false; profilerfiller.pop(); @@ -47,27 +47,27 @@ if (flag1) { this.resetEmptyTime(); } -@@ -412,7 +_,9 @@ - } +@@ -407,7 +_,9 @@ + } - profilerfiller.push("tick"); -- this.guardEntityTick(this::tickNonPassenger, p_308566_); -+ if (!p_308566_.isRemoved() && !(p_308566_ instanceof net.neoforged.neoforge.entity.PartEntity)) { -+ this.guardEntityTick(this::tickNonPassenger, p_308566_); -+ } - profilerfiller.pop(); - } - } -@@ -438,7 +_,7 @@ - this.serverLevelData.setGameTime(i); + profilerfiller.push("tick"); +- this.guardEntityTick(this::tickNonPassenger, p_359620_); ++ if (!p_359620_.isRemoved() && !(p_359620_ instanceof net.neoforged.neoforge.entity.PartEntity)) { ++ this.guardEntityTick(this::tickNonPassenger, p_359620_); ++ } + profilerfiller.pop(); + } + } +@@ -436,7 +_,7 @@ this.serverLevelData.getScheduledEvents().tick(this.server, i); - if (this.levelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { + Profiler.get().pop(); + if (this.serverLevelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { - this.setDayTime(this.levelData.getDayTime() + 1L); + this.setDayTime(this.levelData.getDayTime() + advanceDaytime()); } } } -@@ -542,6 +_,7 @@ +@@ -534,6 +_,7 @@ BlockPos blockpos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, p_295060_); BlockPos blockpos1 = blockpos.below(); Biome biome = this.getBiome(blockpos).value(); @@ -75,7 +75,7 @@ if (biome.shouldFreeze(this, blockpos1)) { this.setBlockAndUpdate(blockpos1, Blocks.ICE.defaultBlockState()); } -@@ -714,15 +_,19 @@ +@@ -706,15 +_,19 @@ .broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel), this.dimension()); } @@ -99,9 +99,9 @@ } } -@@ -758,7 +_,11 @@ +@@ -751,7 +_,11 @@ p_8648_.tickCount++; - this.getProfiler().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8648_.getType()).toString()); + profilerfiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8648_.getType()).toString()); profilerfiller.incrementCounter("tickNonPassenger"); - p_8648_.tick(); + // Neo: Permit cancellation of Entity#tick via EntityTickEvent.Pre @@ -109,10 +109,10 @@ + p_8648_.tick(); + net.neoforged.neoforge.event.EventHooks.fireEntityTickPost(p_8648_); + } - this.getProfiler().pop(); + profilerfiller.pop(); for (Entity entity : p_8648_.getPassengers()) { -@@ -807,6 +_,7 @@ +@@ -800,6 +_,7 @@ } else { this.entityManager.autoSave(); } @@ -120,7 +120,7 @@ } } -@@ -896,6 +_,7 @@ +@@ -894,6 +_,7 @@ } private void addPlayer(ServerPlayer p_8854_) { @@ -128,7 +128,7 @@ Entity entity = this.getEntities().get(p_8854_.getUUID()); if (entity != null) { LOGGER.warn("Force-added player with duplicate UUID {}", p_8854_.getUUID()); -@@ -903,7 +_,8 @@ +@@ -901,7 +_,8 @@ this.removePlayerImmediately((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -138,7 +138,7 @@ } private boolean addEntity(Entity p_8873_) { -@@ -911,7 +_,12 @@ +@@ -909,7 +_,12 @@ LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityType.getKey(p_8873_.getType())); return false; } else { @@ -152,7 +152,7 @@ } } -@@ -959,6 +_,12 @@ +@@ -957,6 +_,12 @@ float p_263390_, long p_263403_ ) { @@ -165,7 +165,7 @@ this.server .getPlayerList() .broadcast( -@@ -976,6 +_,12 @@ +@@ -974,6 +_,12 @@ public void playSeededSound( @Nullable Player p_263545_, Entity p_263544_, Holder p_263491_, SoundSource p_263542_, float p_263530_, float p_263520_, long p_263490_ ) { @@ -178,7 +178,7 @@ this.server .getPlayerList() .broadcast( -@@ -1019,6 +_,7 @@ +@@ -1032,6 +_,7 @@ @Override public void gameEvent(Holder p_316597_, Vec3 p_215042_, GameEvent.Context p_215043_) { @@ -186,24 +186,43 @@ this.gameEventDispatcher.post(p_316597_, p_215042_, p_215043_); } -@@ -1057,11 +_,16 @@ +@@ -1070,6 +_,7 @@ @Override public void updateNeighborsAt(BlockPos p_215045_, Block p_215046_) { + net.neoforged.neoforge.event.EventHooks.onNeighborNotify(this, p_215045_, this.getBlockState(p_215045_), java.util.EnumSet.allOf(Direction.class), false).isCanceled(); - this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215045_, p_215046_, null); + this.updateNeighborsAt(p_215045_, p_215046_, ExperimentalRedstoneUtils.initialOrientation(this, null, null)); } +@@ -1080,6 +_,10 @@ + @Override - public void updateNeighborsAtExceptFromFacing(BlockPos p_215052_, Block p_215053_, Direction p_215054_) { + public void updateNeighborsAtExceptFromFacing(BlockPos p_215052_, Block p_215053_, Direction p_215054_, @Nullable Orientation p_365231_) { + java.util.EnumSet directions = java.util.EnumSet.allOf(Direction.class); + directions.remove(p_215054_); + if (net.neoforged.neoforge.event.EventHooks.onNeighborNotify(this, p_215052_, this.getBlockState(p_215052_), directions, false).isCanceled()) + return; - this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215052_, p_215053_, p_215054_); + this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215052_, p_215053_, p_215054_, p_365231_); } -@@ -1713,8 +_,8 @@ +@@ -1125,7 +_,7 @@ + Explosion.BlockInteraction explosion$blockinteraction = switch (p_255827_) { + case NONE -> Explosion.BlockInteraction.KEEP; + case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); +- case MOB -> this.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ case MOB -> net.neoforged.neoforge.event.EventHooks.canEntityGrief(this, p_256039_) + ? this.getDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) + : Explosion.BlockInteraction.KEEP; + case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); +@@ -1133,6 +_,7 @@ + }; + Vec3 vec3 = new Vec3(p_256067_, p_256370_, p_256153_); + ServerExplosion serverexplosion = new ServerExplosion(this, p_256039_, p_255778_, p_256002_, vec3, p_256045_, p_255686_, explosion$blockinteraction); ++ if (net.neoforged.neoforge.event.EventHooks.onExplosionStart(this, serverexplosion)) return; + serverexplosion.explode(); + ParticleOptions particleoptions = serverexplosion.isSmall() ? p_312436_ : p_312391_; + +@@ -1740,8 +_,8 @@ ServerLevel.this.navigatingMobs.add(mob); } @@ -214,7 +233,7 @@ ServerLevel.this.dragonParts.put(enderdragonpart.getId(), enderdragonpart); } } -@@ -1733,24 +_,106 @@ +@@ -1760,24 +_,106 @@ if (ServerLevel.this.isUpdatingNavigations) { String s = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( diff --git a/patches/net/minecraft/server/level/ServerPlayer.java.patch b/patches/net/minecraft/server/level/ServerPlayer.java.patch index 65714200..a0e3dd56 100644 --- a/patches/net/minecraft/server/level/ServerPlayer.java.patch +++ b/patches/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,16 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -160,6 +_,9 @@ - import net.minecraft.world.scores.ScoreHolder; - import net.minecraft.world.scores.Team; - import net.minecraft.world.scores.criteria.ObjectiveCriteria; -+import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.CraftWorld; -+import org.bukkit.craftbukkit.entity.CraftPlayer; - import org.slf4j.Logger; - - public class ServerPlayer extends Player { -@@ -252,6 +_,10 @@ +@@ -278,6 +_,10 @@ } private void broadcastDataValue(AbstractContainerMenu p_143455_, int p_143456_, int p_143457_) { @@ -21,107 +11,7 @@ ServerPlayer.this.connection.send(new ClientboundContainerSetDataPacket(p_143455_.containerId, p_143456_, p_143457_)); } }; -@@ -276,6 +_,21 @@ - public final Object object; - private int containerCounter; - public boolean wonGame; -+ // CraftBukkit start -+ public CraftPlayer.TransferCookieConnection transferCookieConnection; -+ public String displayName; -+ public Component listName; -+ public org.bukkit.Location compassTarget; -+ public int newExp = 0; -+ public int newLevel = 0; -+ public int newTotalExp = 0; -+ public boolean keepLevel = false; -+ public double maxHealthCache; -+ public boolean joining = true; -+ public boolean sentListPacket = false; -+ public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent -+ // CraftBukkit end -+ - - public ServerPlayer(MinecraftServer p_254143_, ServerLevel p_254435_, GameProfile p_253651_, ClientInformation p_301997_) { - super(p_254435_, p_254435_.getSharedSpawnPos(), p_254435_.getSharedSpawnAngle(), p_253651_); -@@ -289,6 +_,77 @@ - this.object = null; - } - -+ // Use method to resend items in hands in case of client desync, because the item use got cancelled. -+ // For example, when cancelling the leash event -+ public void resendItemInHands() { -+ containerMenu.findSlot(getInventory(), getInventory().selected).ifPresent(s -> { -+ containerSynchronizer.sendSlotChange(containerMenu, s, getMainHandItem()); -+ }); -+ containerSynchronizer.sendSlotChange(inventoryMenu, InventoryMenu.SHIELD_SLOT, getOffhandItem()); -+ } -+ -+ // Yes, this doesn't match Vanilla, but it's the best we can do for now. -+ // If this is an issue, PRs are welcome -+ public final BlockPos getSpawnPoint(ServerLevel worldserver) { -+ BlockPos blockposition = worldserver.getSharedSpawnPos(); -+ -+ if (worldserver.dimensionType().hasSkyLight() && worldserver.serverLevelData.getGameType() != GameType.ADVENTURE) { -+ int i = Math.max(0, this.server.getSpawnRadius(worldserver)); -+ int j = Mth.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); -+ -+ if (j < i) { -+ i = j; -+ } -+ -+ if (j <= 1) { -+ i = 1; -+ } -+ -+ long k = (long) (i * 2 + 1); -+ long l = k * k; -+ int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; -+ int j1 = this.getCoprime(i1); -+ int k1 = RandomSource.create().nextInt(i1); -+ -+ for (int l1 = 0; l1 < i1; ++l1) { -+ int i2 = (k1 + j1 * l1) % i1; -+ int j2 = i2 % (i * 2 + 1); -+ int k2 = i2 / (i * 2 + 1); -+ BlockPos blockposition1 = PlayerRespawnLogic.getOverworldRespawnPos(worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i); -+ -+ if (blockposition1 != null) { -+ return blockposition1; -+ } -+ } -+ } -+ -+ return blockposition; -+ } -+ // CraftBukkit end -+ -+ // CraftBukkit start - World fallback code, either respawn location or global spawn -+ public void spawnIn(Level world) { -+ this.setLevel(world); -+ if (world == null) { -+ this.unsetRemoved(); -+ Vec3 position = null; -+ if (this.respawnDimension != null) { -+ world = this.server.getLevel(this.respawnDimension); -+ if (world != null && this.getRespawnPosition() != null) { -+ position = ServerPlayer.findRespawnAndUseSpawnBlock((ServerLevel) world, this.getRespawnPosition(), this.getRespawnAngle(), false, false).map(ServerPlayer.RespawnPosAngle::position).orElse(null); -+ } -+ } -+ if (world == null || position == null) { -+ world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); -+ position = Vec3.atCenterOf(world.getSharedSpawnPos()); -+ } -+ this.setLevel(world); -+ this.setPos(position); -+ } -+ this.gameMode.setLevel((ServerLevel) world); -+ } -+ // CraftBukkit end -+ - @Override - public BlockPos adjustSpawnLocation(ServerLevel p_352206_, BlockPos p_352202_) { - AABB aabb = this.getDimensions(Pose.STANDING).makeBoundingBox(Vec3.ZERO); -@@ -606,6 +_,11 @@ +@@ -768,6 +_,11 @@ this.connection.send(new ClientboundSetExperiencePacket(this.experienceProgress, this.totalExperience, this.experienceLevel)); } @@ -133,15 +23,15 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } -@@ -657,6 +_,7 @@ +@@ -850,6 +_,7 @@ @Override public void die(DamageSource p_9035_) { this.gameEvent(GameEvent.ENTITY_DIE); + if (net.neoforged.neoforge.common.CommonHooks.onLivingDeath(this, p_9035_)) return; - boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); + boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); if (flag) { Component component = this.getCombatTracker().getDeathMessage(); -@@ -826,7 +_,7 @@ +@@ -1019,7 +_,7 @@ return BedBlock.findStandUpPosition(EntityType.PLAYER, p_348505_, p_348607_, blockstate.getValue(BedBlock.FACING), p_348481_) .map(p_348148_ -> ServerPlayer.RespawnPosAngle.of(p_348148_, p_348607_)); } else if (!p_348513_) { @@ -150,37 +40,37 @@ } else { boolean flag = block.isPossibleToRespawnInThis(blockstate); BlockState blockstate1 = p_348505_.getBlockState(p_348607_.above()); -@@ -854,6 +_,7 @@ +@@ -1046,6 +_,7 @@ + @Nullable - @Override - public Entity changeDimension(DimensionTransition p_350472_) { -+ if (!net.neoforged.neoforge.common.CommonHooks.onTravelToDimension(this, p_350472_.newLevel().dimension())) return null; + public ServerPlayer teleport(TeleportTransition p_379854_) { ++ if (!net.neoforged.neoforge.common.CommonHooks.onTravelToDimension(this, p_379854_.newLevel().dimension())) return null; if (this.isRemoved()) { return null; } else { -@@ -877,7 +_,7 @@ +@@ -1073,7 +_,7 @@ PlayerList playerlist = this.server.getPlayerList(); playerlist.sendPlayerPermissionLevel(this); serverlevel1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); - this.unsetRemoved(); + this.revive(); - serverlevel1.getProfiler().push("moving"); + ProfilerFiller profilerfiller = Profiler.get(); + profilerfiller.push("moving"); if (resourcekey == Level.OVERWORLD && serverlevel.dimension() == Level.NETHER) { - this.enteredNetherPosition = this.position(); -@@ -895,10 +_,12 @@ +@@ -1093,10 +_,12 @@ playerlist.sendLevelInfo(this, serverlevel); playerlist.sendAllPlayerInfo(this); playerlist.sendActivePlayerEffects(this); + // TODO 1.21: Play custom teleport sound - p_350472_.postDimensionTransition().onTransition(this); + p_379854_.postTeleportTransition().onTransition(this); this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; -+ net.neoforged.neoforge.event.EventHooks.firePlayerChangedDimensionEvent(this, resourcekey, p_350472_.newLevel().dimension()); ++ net.neoforged.neoforge.event.EventHooks.firePlayerChangedDimensionEvent(this, resourcekey, p_379854_.newLevel().dimension()); return this; } } -@@ -934,6 +_,15 @@ +@@ -1137,6 +_,15 @@ @Override public Either startSleepInBed(BlockPos p_9115_) { @@ -196,7 +86,7 @@ Direction direction = this.level().getBlockState(p_9115_).getValue(HorizontalDirectionalBlock.FACING); if (this.isSleeping() || !this.isAlive()) { return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); -@@ -962,7 +_,21 @@ +@@ -1165,7 +_,21 @@ return Either.left(Player.BedSleepingProblem.NOT_SAFE); } } @@ -219,7 +109,7 @@ Either either = super.startSleepInBed(p_9115_).ifRight(p_9029_ -> { this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); -@@ -984,6 +_,7 @@ +@@ -1187,6 +_,7 @@ } private boolean bedInRange(BlockPos p_9117_, Direction p_9118_) { @@ -227,15 +117,8 @@ return this.isReachableBedBlock(p_9117_) || this.isReachableBedBlock(p_9117_.relative(p_9118_.getOpposite())); } -@@ -1072,13 +_,26 @@ - this.containerCounter = this.containerCounter % 100 + 1; - } +@@ -1277,11 +_,19 @@ -+ public int nextContainerCounterInt() { -+ this.containerCounter = this.containerCounter % 100 + 1; -+ return containerCounter; // CraftBukkit -+ } -+ @Override public OptionalInt openMenu(@Nullable MenuProvider p_9033_) { + return openMenu(p_9033_, (java.util.function.Consumer) null); @@ -254,7 +137,7 @@ } this.nextContainerCounter(); -@@ -1090,10 +_,16 @@ +@@ -1293,10 +_,16 @@ return OptionalInt.empty(); } else { @@ -271,7 +154,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1115,6 +_,7 @@ +@@ -1318,6 +_,7 @@ this.connection.send(new ClientboundHorseScreenOpenPacket(this.containerCounter, i, p_9059_.getId())); this.containerMenu = new HorseInventoryMenu(this.containerCounter, this.getInventory(), p_9060_, p_9059_, i); this.initMenu(this.containerMenu); @@ -279,7 +162,7 @@ } @Override -@@ -1143,6 +_,7 @@ +@@ -1346,6 +_,7 @@ public void doCloseContainer() { this.containerMenu.removed(this); this.inventoryMenu.transferState(this.containerMenu); @@ -287,7 +170,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -1375,6 +_,15 @@ +@@ -1569,6 +_,15 @@ this.setShoulderEntityLeft(p_9016_.getShoulderEntityLeft()); this.setShoulderEntityRight(p_9016_.getShoulderEntityRight()); this.setLastDeathLocation(p_9016_.getLastDeathLocation()); @@ -303,7 +186,7 @@ } @Override -@@ -1469,6 +_,8 @@ +@@ -1674,6 +_,8 @@ public boolean setGameMode(GameType p_143404_) { boolean flag = this.isSpectator(); @@ -312,15 +195,15 @@ if (!this.gameMode.changeGameModeForPlayer(p_143404_)) { return false; } else { -@@ -1617,6 +_,7 @@ +@@ -1848,6 +_,7 @@ public void setCamera(@Nullable Entity p_9214_) { Entity entity = this.getCamera(); this.camera = (Entity)(p_9214_ == null ? this : p_9214_); + while (this.camera instanceof net.neoforged.neoforge.entity.PartEntity partEntity) this.camera = partEntity.getParent(); // Neo: fix MC-46486 if (entity != this.camera) { if (this.camera.level() instanceof ServerLevel serverlevel) { - this.teleportTo(serverlevel, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot()); -@@ -1653,7 +_,11 @@ + this.teleportTo(serverlevel, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot(), false); +@@ -1884,7 +_,11 @@ @Nullable public Component getTabListDisplayName() { @@ -332,8 +215,8 @@ + return this.tabListDisplayName; } - @Override -@@ -1710,6 +_,7 @@ + public int getTabListOrder() { +@@ -1933,6 +_,7 @@ } public void setRespawnPosition(ResourceKey p_9159_, @Nullable BlockPos p_9160_, float p_9161_, boolean p_9162_, boolean p_9163_) { @@ -341,7 +224,7 @@ if (p_9160_ != null) { boolean flag = p_9160_.equals(this.respawnPosition) && p_9159_.equals(this.respawnDimension); if (p_9163_ && !flag) { -@@ -1767,6 +_,8 @@ +@@ -1990,6 +_,8 @@ if (itementity == null) { return null; } else { @@ -350,7 +233,7 @@ this.level().addFreshEntity(itementity); ItemStack itemstack = itementity.getItem(); if (p_9087_) { -@@ -1781,6 +_,75 @@ +@@ -2039,6 +_,75 @@ } } @@ -426,7 +309,7 @@ public TextFilter getTextFilter() { return this.textFilter; } -@@ -1841,9 +_,12 @@ +@@ -2099,9 +_,12 @@ public boolean drop(boolean p_182295_) { Inventory inventory = this.getInventory(); @@ -439,4 +322,4 @@ + return net.neoforged.neoforge.common.CommonHooks.onPlayerTossEvent(this, itemstack, true) != null; } - public boolean allowsListing() { + @Override diff --git a/patches/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 82bca3b2..1d50dd04 100644 --- a/patches/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/patches/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -72,7 +_,10 @@ +@@ -70,7 +_,10 @@ protected void setGameModeForPlayer(GameType p_9274_, @Nullable GameType p_9275_) { this.previousGameModeForPlayer = p_9275_; this.gameModeForPlayer = p_9274_; @@ -11,7 +11,7 @@ } public GameType getGameModeForPlayer() { -@@ -133,6 +_,10 @@ +@@ -131,6 +_,10 @@ } public void handleBlockBreakAction(BlockPos p_215120_, ServerboundPlayerActionPacket.Action p_215121_, Direction p_215122_, int p_215123_, int p_215124_) { @@ -21,8 +21,8 @@ + } if (!this.player.canInteractWithBlock(p_215120_, 1.0)) { this.debugLogging(p_215120_, false, p_215124_, "too far"); - } else if (p_215120_.getY() >= p_215123_) { -@@ -171,6 +_,7 @@ + } else if (p_215120_.getY() > p_215123_) { +@@ -169,6 +_,7 @@ blockstate, p_348149_ -> this.player.onEquippedItemBroken(p_348149_, EquipmentSlot.MAINHAND) ); @@ -30,7 +30,7 @@ blockstate.attack(this.level, p_215120_, this.player); f = blockstate.getDestroyProgress(this.player, this.player.level(), p_215120_); } -@@ -238,7 +_,8 @@ +@@ -236,7 +_,8 @@ public boolean destroyBlock(BlockPos p_9281_) { BlockState blockstate1 = this.level.getBlockState(p_9281_); @@ -40,7 +40,7 @@ return false; } else { BlockEntity blockentity = this.level.getBlockEntity(p_9281_); -@@ -250,26 +_,45 @@ +@@ -248,26 +_,45 @@ return false; } else { BlockState blockstate = block.playerWillDestroy(this.level, p_9281_, blockstate1, this.player); @@ -91,16 +91,16 @@ } public InteractionResult useItem(ServerPlayer p_9262_, Level p_9263_, ItemStack p_9264_, InteractionHand p_9265_) { -@@ -278,6 +_,8 @@ - } else if (p_9262_.getCooldowns().isOnCooldown(p_9264_.getItem())) { +@@ -276,6 +_,8 @@ + } else if (p_9262_.getCooldowns().isOnCooldown(p_9264_)) { return InteractionResult.PASS; } else { + InteractionResult cancelResult = net.neoforged.neoforge.common.CommonHooks.onItemRightClick(p_9262_, p_9265_); + if (cancelResult != null) return cancelResult; int i = p_9264_.getCount(); int j = p_9264_.getDamageValue(); - InteractionResultHolder interactionresultholder = p_9264_.use(p_9263_, p_9262_, p_9265_); -@@ -309,7 +_,10 @@ + InteractionResult interactionresult = p_9264_.use(p_9263_, p_9262_, p_9265_); +@@ -313,7 +_,10 @@ BlockState blockstate = p_9267_.getBlockState(blockpos); if (!blockstate.getBlock().isEnabled(p_9267_.enabledFeatures())) { return InteractionResult.FAIL; @@ -112,7 +112,7 @@ MenuProvider menuprovider = blockstate.getMenuProvider(p_9267_, blockpos); if (menuprovider != null) { p_9266_.openMenu(menuprovider); -@@ -318,10 +_,15 @@ +@@ -322,10 +_,15 @@ return InteractionResult.PASS; } } else { @@ -127,17 +127,17 @@ ItemStack itemstack = p_9268_.copy(); - if (!flag1) { + if (event.getUseBlock().isTrue() || (event.getUseBlock().isDefault() && !flag1)) { - ItemInteractionResult iteminteractionresult = blockstate.useItemOn(p_9266_.getItemInHand(p_9269_), p_9267_, p_9266_, p_9269_, p_9270_); - if (iteminteractionresult.consumesAction()) { + InteractionResult interactionresult = blockstate.useItemOn(p_9266_.getItemInHand(p_9269_), p_9267_, p_9266_, p_9269_, p_9270_); + if (interactionresult.consumesAction()) { CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(p_9266_, blockpos, itemstack); -@@ -337,8 +_,8 @@ +@@ -341,8 +_,8 @@ } } -- if (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_.getItem())) { +- if (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_)) { - UseOnContext useoncontext = new UseOnContext(p_9266_, p_9269_, p_9270_); -+ if (event.getUseItem().isTrue() || (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_.getItem()))) { ++ if (event.getUseItem().isTrue() || (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_))) { + if (event.getUseItem().isFalse()) return InteractionResult.PASS; - InteractionResult interactionresult1; + InteractionResult interactionresult2; if (this.isCreative()) { int i = p_9268_.getCount(); diff --git a/patches/net/minecraft/server/level/Ticket.java.patch b/patches/net/minecraft/server/level/Ticket.java.patch index b33b9fd8..51e6d151 100644 --- a/patches/net/minecraft/server/level/Ticket.java.patch +++ b/patches/net/minecraft/server/level/Ticket.java.patch @@ -3,7 +3,7 @@ @@ -9,9 +_,14 @@ private long createdTick; - public Ticket(TicketType p_9425_, int p_9426_, T p_9427_) { + protected Ticket(TicketType p_9425_, int p_9426_, T p_9427_) { + this(p_9425_, p_9426_, p_9427_, false); + } + diff --git a/patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch b/patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch index bd7b3a14..07547467 100644 --- a/patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch +++ b/patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch @@ -1,44 +1,6 @@ --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -8,6 +_,7 @@ - import net.minecraft.ReportedException; - import net.minecraft.Util; - import net.minecraft.network.Connection; -+import net.minecraft.network.ConnectionProtocol; - import net.minecraft.network.DisconnectionDetails; - import net.minecraft.network.PacketSendListener; - import net.minecraft.network.chat.Component; -@@ -23,10 +_,28 @@ - import net.minecraft.network.protocol.cookie.ServerboundCookieResponsePacket; - import net.minecraft.server.MinecraftServer; - import net.minecraft.server.level.ClientInformation; -+import net.minecraft.server.level.ServerPlayer; - import net.minecraft.util.VisibleForDebug; -+import org.bukkit.craftbukkit.entity.CraftPlayer; - import org.slf4j.Logger; - --public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener { -+public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener, CraftPlayer.TransferCookieConnection { -+ -+ @Override -+ public boolean isTransferred() { -+ return this.transferred; -+ } -+ -+ @Override -+ public ConnectionProtocol getProtocol() { -+ return protocol(); -+ } -+ -+ @Override -+ public void sendPacket(Packet packet) { -+ send(packet); -+ } -+ - private static final Logger LOGGER = LogUtils.getLogger(); - public static final int LATENCY_CHECK_INTERVAL = 15000; - private static final int CLOSED_LISTENER_TIMEOUT = 15000; -@@ -42,6 +_,19 @@ +@@ -43,6 +_,10 @@ private boolean closed = false; private int latency; private volatile boolean suspendFlushingOnServerThread = false; @@ -46,19 +8,10 @@ + * Holds the current connection type, based on the types of payloads that have been received so far. + */ + protected net.neoforged.neoforge.network.connection.ConnectionType connectionType; -+ protected ServerPlayer player; -+ protected org.bukkit.craftbukkit.CraftServer cserver; -+ public boolean processedDisconnect; -+ -+ public CraftPlayer getCraftPlayer() { -+ //return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity(); -+ // CraftBukkit end -+ return null; -+ } public ServerCommonPacketListenerImpl(MinecraftServer p_295057_, Connection p_294822_, CommonListenerCookie p_301980_) { this.server = p_295057_; -@@ -49,6 +_,8 @@ +@@ -50,6 +_,8 @@ this.keepAliveTime = Util.getMillis(); this.latency = p_301980_.latency(); this.transferred = p_301980_.transferred(); @@ -67,7 +20,7 @@ } private void close() { -@@ -83,6 +_,32 @@ +@@ -90,6 +_,32 @@ @Override public void handleCustomPayload(ServerboundCustomPayloadPacket p_294276_) { @@ -100,7 +53,7 @@ } @Override -@@ -141,7 +_,10 @@ +@@ -148,7 +_,10 @@ this.send(p_294278_, null); } @@ -111,7 +64,7 @@ if (p_295099_.isTerminal()) { this.close(); } -@@ -183,7 +_,41 @@ +@@ -190,7 +_,41 @@ return this.latency; } diff --git a/patches/net/minecraft/server/network/ServerConnectionListener.java.patch b/patches/net/minecraft/server/network/ServerConnectionListener.java.patch index 404db682..db197d54 100644 --- a/patches/net/minecraft/server/network/ServerConnectionListener.java.patch +++ b/patches/net/minecraft/server/network/ServerConnectionListener.java.patch @@ -33,14 +33,3 @@ if (ServerConnectionListener.this.server.repliesToStatus()) { channelpipeline.addLast("legacy_query", new LegacyQueryHandler(ServerConnectionListener.this.getServer())); } -@@ -179,6 +_,10 @@ - - public List getConnections() { - return this.connections; -+ } -+ -+ public void acceptConnections() { -+ - } - - static class LatencySimulator extends ChannelInboundHandlerAdapter { diff --git a/patches/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/patches/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 1f90ceeb..74247bc5 100644 --- a/patches/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/patches/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,36 +1,5 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -184,6 +_,8 @@ - import net.minecraft.world.phys.shapes.BooleanOp; - import net.minecraft.world.phys.shapes.Shapes; - import net.minecraft.world.phys.shapes.VoxelShape; -+import org.bukkit.Location; -+import org.bukkit.event.player.PlayerTeleportEvent; - import org.slf4j.Logger; - - public class ServerGamePacketListenerImpl -@@ -235,6 +_,21 @@ - private final MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault(); - private final FutureChain chatMessageChain; - private boolean waitingForSwitchToConfig; -+ // CraftBukkit start - add fields and methods -+ private int lastTick = MinecraftServer.currentTick; -+ private int allowedPlayerTicks = 1; -+ private int lastDropTick = MinecraftServer.currentTick; -+ private int lastBookTick = MinecraftServer.currentTick; -+ private int dropCount = 0; -+ -+ private boolean hasMoved = false; -+ private double lastPosX = Double.MAX_VALUE; -+ private double lastPosY = Double.MAX_VALUE; -+ private double lastPosZ = Double.MAX_VALUE; -+ private float lastPitch = Float.MAX_VALUE; -+ private float lastYaw = Float.MAX_VALUE; -+ private boolean justTeleported = false; -+ // CraftBukkit end - - public ServerGamePacketListenerImpl(MinecraftServer p_9770_, Connection p_9771_, ServerPlayer p_9772_, CommonListenerCookie p_301978_) { - super(p_9770_, p_9771_, p_301978_); @@ -439,9 +_,11 @@ } @@ -43,7 +12,7 @@ this.send(new ClientboundMoveVehiclePacket(entity)); return; } -@@ -462,6 +_,23 @@ +@@ -463,6 +_,23 @@ } } @@ -67,7 +36,7 @@ private boolean noBlocksAround(Entity p_9794_) { return p_9794_.level() .getBlockStates(p_9794_.getBoundingBox().inflate(0.0625).expandTowards(0.0, -0.55, 0.0)) -@@ -927,7 +_,7 @@ +@@ -930,7 +_,7 @@ && !flag1 && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR && !this.server.isFlightAllowed() @@ -76,37 +45,7 @@ && !this.player.hasEffect(MobEffects.LEVITATION) && !flag && !flag3 -@@ -1003,6 +_,29 @@ - this.teleport(p_9775_, p_9776_, p_9777_, p_9778_, p_9779_, Collections.emptySet()); - } - -+ public boolean teleport(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { -+ return false; -+ } -+ -+ public boolean teleport(double d0, double d1, double d2, float f, float f1, Set set, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status -+ return false; -+ } -+ -+ public void teleport(Location dest) { -+ -+ } -+ -+ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set) { -+ } -+ -+ public void chat(String s, PlayerChatMessage original, boolean async) { -+ -+ } -+ -+ private void handleCommand(String s) { -+ -+ } -+ - public void teleport(double p_9781_, double p_9782_, double p_9783_, float p_9784_, float p_9785_, Set p_9786_) { - double d0 = p_9786_.contains(RelativeMovement.X) ? this.player.getX() : 0.0; - double d1 = p_9786_.contains(RelativeMovement.Y) ? this.player.getY() : 0.0; -@@ -1031,8 +_,10 @@ +@@ -1041,8 +_,10 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { ItemStack itemstack = this.player.getItemInHand(InteractionHand.OFF_HAND); @@ -119,16 +58,16 @@ this.player.stopUsingItem(); } -@@ -1060,7 +_,7 @@ +@@ -1070,7 +_,7 @@ .handleBlockBreakAction( - blockpos, serverboundplayeractionpacket$action, p_9889_.getDirection(), this.player.level().getMaxBuildHeight(), p_9889_.getSequence() + blockpos, serverboundplayeractionpacket$action, p_9889_.getDirection(), this.player.level().getMaxY(), p_9889_.getSequence() ); - this.player.connection.ackBlockChangesUpTo(p_9889_.getSequence()); + this.player.connection.ackBlockChangesUpTo =p_9889_.getSequence(); return; default: throw new IllegalArgumentException("Invalid player action"); -@@ -1079,7 +_,7 @@ +@@ -1089,7 +_,7 @@ @Override public void handleUseItemOn(ServerboundUseItemOnPacket p_9930_) { PacketUtils.ensureRunningOnSameThread(p_9930_, this, this.player.serverLevel()); @@ -137,7 +76,7 @@ ServerLevel serverlevel = this.player.serverLevel(); InteractionHand interactionhand = p_9930_.getHand(); ItemStack itemstack = this.player.getItemInHand(interactionhand); -@@ -1231,8 +_,9 @@ +@@ -1242,8 +_,9 @@ } CompletableFuture completablefuture = this.filterTextPacket(playerchatmessage.signedContent()); @@ -148,7 +87,7 @@ PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent(component).filter(p_300785_.mask()); this.broadcastChatMessage(playerchatmessage1); }); -@@ -1561,7 +_,11 @@ +@@ -1569,7 +_,11 @@ @Override public void onInteraction(InteractionHand p_143682_, Vec3 p_143683_) { @@ -161,7 +100,7 @@ } @Override -@@ -1753,7 +_,7 @@ +@@ -1785,13 +_,15 @@ @Override public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket p_9887_) { PacketUtils.ensureRunningOnSameThread(p_9887_, this, this.player.serverLevel()); @@ -170,7 +109,15 @@ } @Override -@@ -1812,7 +_,7 @@ + public void handleClientInformation(ServerboundClientInformationPacket p_301979_) { + PacketUtils.ensureRunningOnSameThread(p_301979_, this, this.player.serverLevel()); ++ net.minecraft.server.level.ClientInformation oldInfo = this.player.clientInformation(); + this.player.updateOptions(p_301979_.information()); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.entity.player.ClientInformationUpdatedEvent(this.player, oldInfo, p_301979_.information())); + } + + @Override +@@ -1844,7 +_,7 @@ this.connection .setupInboundProtocol( ConfigurationProtocols.SERVERBOUND, @@ -179,7 +126,7 @@ ); } } -@@ -1847,6 +_,7 @@ +@@ -1879,6 +_,7 @@ @Override public void handleCustomPayload(ServerboundCustomPayloadPacket p_333887_) { diff --git a/patches/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch b/patches/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch deleted file mode 100644 index b742cdc1..00000000 --- a/patches/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -+++ b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -@@ -12,10 +_,17 @@ - import net.minecraft.network.protocol.status.StatusProtocols; - import net.minecraft.server.MinecraftServer; - -+import java.net.InetAddress; -+import java.util.HashMap; -+ - public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketListener { - private static final Component IGNORE_STATUS_REASON = Component.translatable("disconnect.ignoring_status_request"); - private final MinecraftServer server; - private final Connection connection; -+ // CraftBukkit start - add fields -+ private static final HashMap throttleTracker = new HashMap(); -+ private static int throttleCounter = 0; -+ // CraftBukkit end - - public ServerHandshakePacketListenerImpl(MinecraftServer p_9969_, Connection p_9970_) { - this.server = p_9969_; -@@ -24,6 +_,7 @@ - - @Override - public void handleIntention(ClientIntentionPacket p_9975_) { -+ this.connection.hostname = p_9975_.hostName() + ":" + p_9975_.port(); // CraftBukkit - set hostname - switch (p_9975_.intention()) { - case LOGIN: - this.beginLogin(p_9975_, false); diff --git a/patches/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/patches/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch deleted file mode 100644 index 62bee553..00000000 --- a/patches/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ /dev/null @@ -1,65 +0,0 @@ ---- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -20,10 +_,12 @@ - import net.minecraft.DefaultUncaughtExceptionHandler; - import net.minecraft.core.UUIDUtil; - import net.minecraft.network.Connection; -+import net.minecraft.network.ConnectionProtocol; - import net.minecraft.network.DisconnectionDetails; - import net.minecraft.network.PacketSendListener; - import net.minecraft.network.TickablePacketListener; - import net.minecraft.network.chat.Component; -+import net.minecraft.network.protocol.Packet; - import net.minecraft.network.protocol.configuration.ConfigurationProtocols; - import net.minecraft.network.protocol.cookie.ServerboundCookieResponsePacket; - import net.minecraft.network.protocol.login.ClientboundGameProfilePacket; -@@ -42,9 +_,26 @@ - import net.minecraft.util.RandomSource; - import net.minecraft.util.StringUtil; - import org.apache.commons.lang3.Validate; -+import org.bukkit.craftbukkit.entity.CraftPlayer; - import org.slf4j.Logger; - --public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, TickablePacketListener { -+public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, TickablePacketListener, CraftPlayer.TransferCookieConnection { -+ -+ @Override -+ public boolean isTransferred() { -+ return this.transferred; -+ } -+ -+ @Override -+ public ConnectionProtocol getProtocol() { -+ return ConnectionProtocol.LOGIN; -+ } -+ -+ @Override -+ public void sendPacket(Packet packet) { -+ this.connection.send(packet); -+ } -+ - private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0); - static final Logger LOGGER = LogUtils.getLogger(); - private static final int MAX_TICKS_BEFORE_LOGIN = 600; -@@ -86,6 +_,21 @@ - @Override - public boolean isAcceptingMessages() { - return this.connection.isConnected(); -+ } -+ -+ // CraftBukkit start -+ @Deprecated -+ public void disconnect(String s) { -+ disconnect(Component.literal(s)); -+ } -+ // CraftBukkit end -+ -+ private void postCookies(GameProfile gameprofile) { -+ -+ } -+ -+ private void callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception { -+ - } - - public void disconnect(Component p_10054_) { diff --git a/patches/net/minecraft/server/packs/repository/Pack.java.patch b/patches/net/minecraft/server/packs/repository/Pack.java.patch index ccd09d63..953df7b3 100644 --- a/patches/net/minecraft/server/packs/repository/Pack.java.patch +++ b/patches/net/minecraft/server/packs/repository/Pack.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/packs/repository/Pack.java +++ b/net/minecraft/server/packs/repository/Pack.java @@ -23,6 +_,16 @@ - public final Pack.ResourcesSupplier resources; + private final Pack.ResourcesSupplier resources; private final Pack.Metadata metadata; private final PackSelectionConfig selectionConfig; + private final boolean hidden; // Neo: Allow packs to be hidden from the UI entirely diff --git a/patches/net/minecraft/server/packs/repository/PackRepository.java.patch b/patches/net/minecraft/server/packs/repository/PackRepository.java.patch index ded59feb..fce53d72 100644 --- a/patches/net/minecraft/server/packs/repository/PackRepository.java.patch +++ b/patches/net/minecraft/server/packs/repository/PackRepository.java.patch @@ -25,7 +25,7 @@ } return ImmutableMap.copyOf(map); -@@ -77,11 +_,12 @@ +@@ -82,11 +_,12 @@ } public List rebuildSelected(Collection p_10518_) { @@ -40,7 +40,7 @@ } } -@@ -93,7 +_,7 @@ +@@ -98,7 +_,7 @@ } public Collection getAvailableIds() { @@ -49,7 +49,7 @@ } public Collection getAvailablePacks() { -@@ -101,7 +_,7 @@ +@@ -106,7 +_,7 @@ } public Collection getSelectedIds() { @@ -58,7 +58,7 @@ } public FeatureFlagSet getRequestedFeatureFlags() { -@@ -115,6 +_,10 @@ +@@ -120,6 +_,10 @@ @Nullable public Pack getPack(String p_10508_) { return this.available.get(p_10508_); diff --git a/patches/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch b/patches/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch index 00214f46..3745422f 100644 --- a/patches/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch +++ b/patches/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch @@ -1,11 +1,42 @@ --- a/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java +++ b/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java -@@ -49,4 +_,8 @@ +@@ -41,13 +_,15 @@ + + protected Map prepare(ResourceManager p_10771_, ProfilerFiller p_10772_) { + Map map = new HashMap<>(); +- scanDirectory(p_10771_, this.directory, this.ops, this.codec, map); ++ // Neo: add condition context ++ scanDirectory(p_10771_, this.directory, this.makeConditionalOps(), this.codec, map); + return map; + } + + public static void scanDirectory( + ResourceManager p_279308_, String p_279131_, DynamicOps p_371830_, Codec p_371493_, Map p_279404_ + ) { ++ var conditionalCodec = net.neoforged.neoforge.common.conditions.ConditionalOps.createConditionalCodec(p_371493_); + FileToIdConverter filetoidconverter = FileToIdConverter.json(p_279131_); + + for (Entry entry : filetoidconverter.listMatchingResources(p_279308_).entrySet()) { +@@ -55,8 +_,10 @@ + ResourceLocation resourcelocation1 = filetoidconverter.fileToId(resourcelocation); + + try (Reader reader = entry.getValue().openAsReader()) { +- p_371493_.parse(p_371830_, JsonParser.parseReader(reader)).ifSuccess(p_371454_ -> { +- if (p_279404_.putIfAbsent(resourcelocation1, (T)p_371454_) != null) { ++ conditionalCodec.parse(p_371830_, JsonParser.parseReader(reader)).ifSuccess(p_371454_ -> { ++ if (p_371454_.isEmpty()) { ++ LOGGER.debug("Skipping loading data file '{}' from '{}' as its conditions were not met", resourcelocation1, resourcelocation); ++ } else if (p_279404_.putIfAbsent(resourcelocation1, p_371454_.get()) != null) { + throw new IllegalStateException("Duplicate data file ignored with ID " + resourcelocation1); + } + }).ifError(p_371566_ -> LOGGER.error("Couldn't parse data file '{}' from '{}': {}", resourcelocation1, resourcelocation, p_371566_)); +@@ -64,5 +_,9 @@ + LOGGER.error("Couldn't parse data file '{}' from '{}'", resourcelocation1, resourcelocation, jsonparseexception); } } - } ++ } + + protected ResourceLocation getPreparedPath(ResourceLocation rl) { + return rl.withPath(this.directory + "/" + rl.getPath() + ".json"); -+ } + } } diff --git a/patches/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java.patch b/patches/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java.patch index 2d1ba1e6..afdb34f2 100644 --- a/patches/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java.patch +++ b/patches/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java +++ b/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java -@@ -4,7 +_,7 @@ - import java.util.concurrent.Executor; +@@ -5,7 +_,7 @@ + import net.minecraft.util.profiling.Profiler; import net.minecraft.util.profiling.ProfilerFiller; -public abstract class SimplePreparableReloadListener implements PreparableReloadListener { +public abstract class SimplePreparableReloadListener extends net.neoforged.neoforge.resource.ContextAwareReloadListener implements PreparableReloadListener { @Override public final CompletableFuture reload( - PreparableReloadListener.PreparationBarrier p_10780_, + PreparableReloadListener.PreparationBarrier p_10780_, ResourceManager p_10781_, Executor p_10784_, Executor p_10785_ diff --git a/patches/net/minecraft/server/players/BanListEntry.java.patch b/patches/net/minecraft/server/players/BanListEntry.java.patch deleted file mode 100644 index db31e8a9..00000000 --- a/patches/net/minecraft/server/players/BanListEntry.java.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/net/minecraft/server/players/BanListEntry.java -+++ b/net/minecraft/server/players/BanListEntry.java -@@ -49,6 +_,22 @@ - this.reason = p_10951_.has("reason") ? p_10951_.get("reason").getAsString() : "Banned by an operator."; - } - -+ private static T checkExpiry(T object, JsonObject jsonobject) { -+ Date expires = null; -+ -+ try { -+ expires = jsonobject.has("expires") ? DATE_FORMAT.parse(jsonobject.get("expires").getAsString()) : null; -+ } catch (ParseException ex) { -+ // Guess we don't have a date -+ } -+ -+ if (expires == null || expires.after(new Date())) { -+ return object; -+ } else { -+ return null; -+ } -+ } -+ - public Date getCreated() { - return this.created; - } diff --git a/patches/net/minecraft/server/players/PlayerList.java.patch b/patches/net/minecraft/server/players/PlayerList.java.patch index 963108bb..a3c0ab67 100644 --- a/patches/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/net/minecraft/server/players/PlayerList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -128,6 +_,7 @@ +@@ -129,6 +_,7 @@ private boolean allowCommandsForAllPlayers; private static final boolean ALLOW_LOGOUTIVATOR = false; private int sendAllPlayerInfoIn; @@ -8,7 +8,7 @@ public PlayerList(MinecraftServer p_203842_, LayeredRegistryAccess p_251844_, PlayerDataStorage p_203844_, int p_203845_) { this.server = p_203842_; -@@ -177,7 +_,7 @@ +@@ -178,7 +_,7 @@ p_11263_.loadGameTypes(optional1.orElse(null)); ServerGamePacketListenerImpl servergamepacketlistenerimpl = new ServerGamePacketListenerImpl(this.server, p_11262_, p_11263_, p_301988_); p_11262_.setupInboundProtocol( @@ -17,23 +17,23 @@ ); GameRules gamerules = serverlevel1.getGameRules(); boolean flag = gamerules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN); -@@ -201,6 +_,7 @@ +@@ -202,6 +_,7 @@ servergamepacketlistenerimpl.send(new ClientboundChangeDifficultyPacket(leveldata.getDifficulty(), leveldata.isDifficultyLocked())); servergamepacketlistenerimpl.send(new ClientboundPlayerAbilitiesPacket(p_11263_.getAbilities())); - servergamepacketlistenerimpl.send(new ClientboundSetCarriedItemPacket(p_11263_.getInventory().selected)); + servergamepacketlistenerimpl.send(new ClientboundSetHeldSlotPacket(p_11263_.getInventory().selected)); + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.OnDatapackSyncEvent(this, p_11263_)); - servergamepacketlistenerimpl.send(new ClientboundUpdateRecipesPacket(this.server.getRecipeManager().getOrderedRecipes())); - this.sendPlayerPermissionLevel(p_11263_); - p_11263_.getStats().markAllDirty(); -@@ -265,6 +_,7 @@ - } - + RecipeManager recipemanager = this.server.getRecipeManager(); + servergamepacketlistenerimpl.send( + new ClientboundUpdateRecipesPacket(recipemanager.getSynchronizedItemProperties(), recipemanager.getSynchronizedStonecutterRecipes()) +@@ -236,6 +_,7 @@ + p_11263_.loadAndSpawnEnderpearls(optional1); + p_11263_.loadAndSpawnParentVehicle(optional1); p_11263_.initInventoryMenu(); + net.neoforged.neoforge.event.EventHooks.firePlayerLoggedIn( p_11263_ ); } - public void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) { -@@ -330,6 +_,7 @@ + protected void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) { +@@ -301,6 +_,7 @@ optional = Optional.of(compoundtag); p_11225_.load(compoundtag); LOGGER.debug("loading single player"); @@ -41,7 +41,7 @@ } else { optional = this.playerIo.load(p_11225_); } -@@ -338,6 +_,7 @@ +@@ -309,6 +_,7 @@ } protected void save(ServerPlayer p_11277_) { @@ -49,7 +49,7 @@ this.playerIo.save(p_11277_); ServerStatsCounter serverstatscounter = this.stats.get(p_11277_.getUUID()); if (serverstatscounter != null) { -@@ -351,6 +_,7 @@ +@@ -322,6 +_,7 @@ } public void remove(ServerPlayer p_11287_) { @@ -57,37 +57,37 @@ ServerLevel serverlevel = p_11287_.serverLevel(); p_11287_.awardStat(Stats.LEAVE_GAME); this.save(p_11287_); -@@ -440,13 +_,20 @@ +@@ -416,13 +_,20 @@ this.players.remove(p_11237_); p_11237_.serverLevel().removePlayerImmediately(p_11237_, p_348558_); - DimensionTransition dimensiontransition = p_11237_.findRespawnPositionAndUseSpawnBlock(p_11238_, DimensionTransition.DO_NOTHING); + TeleportTransition teleporttransition = p_11237_.findRespawnPositionAndUseSpawnBlock(!p_11238_, TeleportTransition.DO_NOTHING); + + // Neo: Allow changing the respawn position of players. The local dimension transition is updated with the new target. -+ var event = net.neoforged.neoforge.event.EventHooks.firePlayerRespawnPositionEvent(p_11237_, dimensiontransition, p_11238_); -+ dimensiontransition = event.getDimensionTransition(); ++ var event = net.neoforged.neoforge.event.EventHooks.firePlayerRespawnPositionEvent(p_11237_, teleporttransition, p_11238_); ++ teleporttransition = event.getTeleportTransition(); + - ServerLevel serverlevel = dimensiontransition.newLevel(); + ServerLevel serverlevel = teleporttransition.newLevel(); ServerPlayer serverplayer = new ServerPlayer(this.server, serverlevel, p_11237_.getGameProfile(), p_11237_.clientInformation()); serverplayer.connection = p_11237_.connection; serverplayer.restoreFrom(p_11237_, p_11238_); serverplayer.setId(p_11237_.getId()); serverplayer.setMainArm(p_11237_.getMainArm()); -- if (!dimensiontransition.missingRespawnBlock()) { +- if (!teleporttransition.missingRespawnBlock()) { + + // Neo: Allow the event to control if the original spawn position is copied + if (event.copyOriginalSpawnPosition()) { serverplayer.copyRespawnPosition(p_11237_); } -@@ -477,6 +_,7 @@ +@@ -453,6 +_,7 @@ this.playersByUUID.put(serverplayer.getUUID(), serverplayer); serverplayer.initInventoryMenu(); serverplayer.setHealth(serverplayer.getHealth()); + net.neoforged.neoforge.event.EventHooks.firePlayerRespawnEvent(serverplayer, p_11238_); - if (!p_11238_) { - BlockPos blockpos = BlockPos.containing(dimensiontransition.pos()); - BlockState blockstate = serverlevel.getBlockState(blockpos); -@@ -582,6 +_,7 @@ + BlockPos blockpos = serverplayer.getRespawnPosition(); + ServerLevel serverlevel2 = this.server.getLevel(serverplayer.getRespawnDimension()); + if (!p_11238_ && blockpos != null && serverlevel2 != null) { +@@ -559,6 +_,7 @@ } public void op(GameProfile p_11254_) { @@ -95,7 +95,7 @@ this.ops.add(new ServerOpListEntry(p_11254_, this.server.getOperatorUserPermissionLevel(), this.ops.canBypassPlayerLimit(p_11254_))); ServerPlayer serverplayer = this.getPlayer(p_11254_.getId()); if (serverplayer != null) { -@@ -590,6 +_,7 @@ +@@ -567,6 +_,7 @@ } public void deop(GameProfile p_11281_) { @@ -103,7 +103,7 @@ this.ops.remove(p_11281_); ServerPlayer serverplayer = this.getPlayer(p_11281_.getId()); if (serverplayer != null) { -@@ -682,8 +_,12 @@ +@@ -659,8 +_,12 @@ public void sendLevelInfo(ServerPlayer p_11230_, ServerLevel p_11231_) { WorldBorder worldborder = this.server.overworld().getWorldBorder(); p_11230_.connection.send(new ClientboundInitializeBorderPacket(worldborder)); @@ -116,7 +116,7 @@ p_11230_.connection.send(new ClientboundSetDefaultSpawnPositionPacket(p_11231_.getSharedSpawnPos(), p_11231_.getSharedSpawnAngle())); if (p_11231_.isRaining()) { p_11230_.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); -@@ -808,13 +_,6 @@ +@@ -785,13 +_,6 @@ if (serverstatscounter == null) { File file1 = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR).toFile(); File file2 = new File(file1, uuid + ".json"); @@ -130,7 +130,7 @@ serverstatscounter = new ServerStatsCounter(this.server, file2); this.stats.put(uuid, serverstatscounter); -@@ -832,6 +_,8 @@ +@@ -809,6 +_,8 @@ this.advancements.put(uuid, playeradvancements); } @@ -139,7 +139,7 @@ playeradvancements.setPlayer(p_11297_); return playeradvancements; } -@@ -859,7 +_,7 @@ +@@ -836,7 +_,7 @@ } public List getPlayers() { @@ -148,11 +148,11 @@ } @Nullable -@@ -876,6 +_,7 @@ +@@ -853,6 +_,7 @@ playeradvancements.reload(this.server.getAdvancements()); } + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.OnDatapackSyncEvent(this, null)); this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries))); - ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(this.server.getRecipeManager().getOrderedRecipes()); - + RecipeManager recipemanager = this.server.getRecipeManager(); + ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket( diff --git a/patches/net/minecraft/server/rcon/RconConsoleSource.java.patch b/patches/net/minecraft/server/rcon/RconConsoleSource.java.patch index f7772248..d07e0314 100644 --- a/patches/net/minecraft/server/rcon/RconConsoleSource.java.patch +++ b/patches/net/minecraft/server/rcon/RconConsoleSource.java.patch @@ -1,31 +1,5 @@ --- a/net/minecraft/server/rcon/RconConsoleSource.java +++ b/net/minecraft/server/rcon/RconConsoleSource.java -@@ -7,14 +_,25 @@ - import net.minecraft.server.level.ServerLevel; - import net.minecraft.world.phys.Vec2; - import net.minecraft.world.phys.Vec3; -+import org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender; -+ -+import java.net.SocketAddress; - - public class RconConsoleSource implements CommandSource { - private static final String RCON = "Rcon"; - private static final Component RCON_COMPONENT = Component.literal("Rcon"); - private final StringBuffer buffer = new StringBuffer(); - private final MinecraftServer server; -+ public final SocketAddress socketAddress; -+ private final CraftRemoteConsoleCommandSender remoteConsole = new CraftRemoteConsoleCommandSender(this); -+ -+ public RconConsoleSource(MinecraftServer p_11505_, SocketAddress socketAddress) { -+ this.socketAddress = socketAddress; -+ this.server = p_11505_; -+ } - - public RconConsoleSource(MinecraftServer p_11505_) { -+ this.socketAddress = null; - this.server = p_11505_; - } - @@ -35,7 +_,7 @@ @Override @@ -35,18 +9,3 @@ } @Override -@@ -51,5 +_,14 @@ - @Override - public boolean shouldInformAdmins() { - return this.server.shouldRconBroadcast(); -+ } -+ -+ public void sendMessage(String message) { -+ this.buffer.append(message); -+ } -+ -+ @Override -+ public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { -+ return this.remoteConsole; - } - } diff --git a/patches/net/minecraft/stats/RecipeBookSettings.java.patch b/patches/net/minecraft/stats/RecipeBookSettings.java.patch index 19309732..a778f73d 100644 --- a/patches/net/minecraft/stats/RecipeBookSettings.java.patch +++ b/patches/net/minecraft/stats/RecipeBookSettings.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/stats/RecipeBookSettings.java +++ b/net/minecraft/stats/RecipeBookSettings.java -@@ -11,7 +_,7 @@ - import net.minecraft.world.inventory.RecipeBookType; - - public final class RecipeBookSettings { +@@ -14,7 +_,7 @@ + public static final StreamCodec STREAM_CODEC = StreamCodec.ofMember( + RecipeBookSettings::write, RecipeBookSettings::read + ); - private static final Map> TAG_FIELDS = ImmutableMap.of( + private static final Map> TAG_FIELDS = net.neoforged.neoforge.common.CommonHooks.buildRecipeBookTypeTagFields(ImmutableMap.of( RecipeBookType.CRAFTING, Pair.of("isGuiOpen", "isFilteringCraftable"), RecipeBookType.FURNACE, -@@ -20,7 +_,7 @@ +@@ -23,7 +_,7 @@ Pair.of("isBlastingFurnaceGuiOpen", "isBlastingFurnaceFilteringCraftable"), RecipeBookType.SMOKER, Pair.of("isSmokerGuiOpen", "isSmokerFilteringCraftable") @@ -18,13 +18,13 @@ private final Map states; private RecipeBookSettings(Map p_12730_) { -@@ -54,7 +_,8 @@ - public static RecipeBookSettings read(FriendlyByteBuf p_12753_) { - Map map = Maps.newEnumMap(RecipeBookType.class); +@@ -72,7 +_,8 @@ + private static RecipeBookSettings read(FriendlyByteBuf p_12753_) { + Map map = new EnumMap<>(RecipeBookType.class); - for (RecipeBookType recipebooktype : RecipeBookType.values()) { + // Neo: filter out modded RecipeBookTypes when connected to a vanilla server + for (RecipeBookType recipebooktype : net.neoforged.neoforge.common.CommonHooks.getFilteredRecipeBookTypeValues()) { boolean flag = p_12753_.readBoolean(); boolean flag1 = p_12753_.readBoolean(); - map.put(recipebooktype, new RecipeBookSettings.TypeSettings(flag, flag1)); + if (flag || flag1) { diff --git a/patches/net/minecraft/stats/ServerRecipeBook.java.patch b/patches/net/minecraft/stats/ServerRecipeBook.java.patch deleted file mode 100644 index 9fac57d4..00000000 --- a/patches/net/minecraft/stats/ServerRecipeBook.java.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/minecraft/stats/ServerRecipeBook.java -+++ b/net/minecraft/stats/ServerRecipeBook.java -@@ -17,6 +_,7 @@ - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.world.item.crafting.RecipeHolder; - import net.minecraft.world.item.crafting.RecipeManager; -+import org.bukkit.craftbukkit.event.CraftEventFactory; - import org.slf4j.Logger; - - public class ServerRecipeBook extends RecipeBook { -@@ -29,7 +_,7 @@ - - for (RecipeHolder recipeholder : p_12792_) { - ResourceLocation resourcelocation = recipeholder.id(); -- if (!this.known.contains(resourcelocation) && !recipeholder.value().isSpecial()) { -+ if (!this.known.contains(resourcelocation) && !recipeholder.value().isSpecial() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(p_12793_, resourcelocation)) { // CraftBukkit - this.add(resourcelocation); - this.addHighlight(resourcelocation); - list.add(resourcelocation); -@@ -63,6 +_,7 @@ - } - - private void sendRecipes(ClientboundRecipePacket.State p_12802_, ServerPlayer p_12803_, List p_12804_) { -+ if (p_12803_.connection == null) return; // SPIGOT-4478 during PlayerLoginEvent - p_12803_.connection.send(new ClientboundRecipePacket(p_12802_, p_12804_, Collections.emptyList(), this.getBookSettings())); - } - diff --git a/patches/net/minecraft/stats/StatsCounter.java.patch b/patches/net/minecraft/stats/StatsCounter.java.patch index 7862c3fe..e67449d5 100644 --- a/patches/net/minecraft/stats/StatsCounter.java.patch +++ b/patches/net/minecraft/stats/StatsCounter.java.patch @@ -1,17 +1,6 @@ --- a/net/minecraft/stats/StatsCounter.java +++ b/net/minecraft/stats/StatsCounter.java -@@ -14,11 +_,19 @@ - - public void increment(Player p_13024_, Stat p_13025_, int p_13026_) { - int i = (int)Math.min((long)this.getValue(p_13025_) + (long)p_13026_, 2147483647L); -+ -+ // CraftBukkit start - fire Statistic events -+ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(p_13024_, p_13025_, this.getValue(p_13025_), i); -+ if (cancellable != null && cancellable.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - this.setValue(p_13024_, p_13025_, i); +@@ -18,7 +_,8 @@ } public void setValue(Player p_13020_, Stat p_13021_, int p_13022_) { diff --git a/patches/net/minecraft/tags/BlockTags.java.patch b/patches/net/minecraft/tags/BlockTags.java.patch index d4f91e54..53e8b18d 100644 --- a/patches/net/minecraft/tags/BlockTags.java.patch +++ b/patches/net/minecraft/tags/BlockTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/BlockTags.java +++ b/net/minecraft/tags/BlockTags.java -@@ -196,4 +_,8 @@ +@@ -198,4 +_,8 @@ private static TagKey create(String p_203847_) { return TagKey.create(Registries.BLOCK, ResourceLocation.withDefaultNamespace(p_203847_)); } diff --git a/patches/net/minecraft/tags/ItemTags.java.patch b/patches/net/minecraft/tags/ItemTags.java.patch index 8a9759eb..9dd688d2 100644 --- a/patches/net/minecraft/tags/ItemTags.java.patch +++ b/patches/net/minecraft/tags/ItemTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/ItemTags.java +++ b/net/minecraft/tags/ItemTags.java -@@ -159,4 +_,8 @@ +@@ -183,4 +_,8 @@ private static TagKey bind(String p_203855_) { return TagKey.create(Registries.ITEM, ResourceLocation.withDefaultNamespace(p_203855_)); } diff --git a/patches/net/minecraft/tags/TagEntry.java.patch b/patches/net/minecraft/tags/TagEntry.java.patch index 3be0c67f..bbfb6872 100644 --- a/patches/net/minecraft/tags/TagEntry.java.patch +++ b/patches/net/minecraft/tags/TagEntry.java.patch @@ -18,7 +18,7 @@ + public interface Lookup { @Nullable - T element(ResourceLocation p_215956_); + T element(ResourceLocation p_215956_, boolean p_379371_); - - @Nullable Collection tag(ResourceLocation p_215957_); diff --git a/patches/net/minecraft/tags/TagLoader.java.patch b/patches/net/minecraft/tags/TagLoader.java.patch index 6e7fa7b7..e18606c9 100644 --- a/patches/net/minecraft/tags/TagLoader.java.patch +++ b/patches/net/minecraft/tags/TagLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/TagLoader.java +++ b/net/minecraft/tags/TagLoader.java -@@ -57,6 +_,7 @@ +@@ -64,6 +_,7 @@ String s = resource.sourcePackId(); tagfile.entries().forEach(p_215997_ -> list.add(new TagLoader.EntryWithSource(p_215997_, s))); @@ -8,43 +8,35 @@ } catch (Exception exception) { LOGGER.error("Couldn't read tag list {} from {} in data pack {}", resourcelocation1, resourcelocation, resource.sourcePackId(), exception); } -@@ -67,16 +_,17 @@ - } - - private Either, Collection> build(TagEntry.Lookup p_215979_, List p_215980_) { -- Builder builder = ImmutableSet.builder(); -+ var builder = new java.util.LinkedHashSet(); // Set must retain insertion order, some tag consumers rely on this being the case (see NeoForge#256) +@@ -78,7 +_,8 @@ List list = new ArrayList<>(); for (TagLoader.EntryWithSource tagloader$entrywithsource : p_215980_) { -- if (!tagloader$entrywithsource.entry().build(p_215979_, builder::add)) { -+ if (!tagloader$entrywithsource.entry().build(p_215979_, tagloader$entrywithsource.remove() ? builder::remove : builder::add)) { +- if (!tagloader$entrywithsource.entry().build(p_215979_, sequencedset::add)) { ++ if (!tagloader$entrywithsource.entry().build(p_215979_, tagloader$entrywithsource.remove() ? sequencedset::remove : sequencedset::add)) { + if (!tagloader$entrywithsource.remove()) // Treat all removals as optional at runtime. If it was missing, then it could of never been added. list.add(tagloader$entrywithsource); } } - -- return list.isEmpty() ? Either.right(builder.build()) : Either.left(list); -+ return list.isEmpty() ? Either.right(List.copyOf(builder)) : Either.left(list); - } - - public Map> build(Map> p_203899_) { -@@ -104,7 +_,7 @@ - p_215977_ -> LOGGER.error( +@@ -111,7 +_,7 @@ + p_359633_ -> LOGGER.error( "Couldn't load tag {} as it is missing following references: {}", - p_284682_, -- p_215977_.stream().map(Objects::toString).collect(Collectors.joining(", ")) -+ p_215977_.stream().map(Objects::toString).collect(Collectors.joining("\n\t", "\n\t", "")) + p_359645_, +- p_359633_.stream().map(Objects::toString).collect(Collectors.joining(", ")) ++ p_359633_.stream().map(Objects::toString).collect(Collectors.joining("\n\t", "\n\t", "")) ) ) - .ifRight(p_216001_ -> map.put(p_284682_, (Collection)p_216001_)) -@@ -116,7 +_,8 @@ - return this.build(this.load(p_203901_)); + .ifRight(p_364232_ -> map.put(p_359645_, (List)p_364232_)) +@@ -183,7 +_,11 @@ + } } - public static record EntryWithSource(TagEntry entry, String source) { + public static record EntryWithSource(TagEntry entry, String source, boolean remove) { -+ public EntryWithSource(TagEntry entry, String source) { this(entry, source, false); } ++ public EntryWithSource(TagEntry entry, String source) { ++ this(entry, source, false); ++ } ++ @Override public String toString() { return this.entry + " (from " + this.source + ")"; diff --git a/patches/net/minecraft/util/SpawnUtil.java.patch b/patches/net/minecraft/util/SpawnUtil.java.patch index 466ef980..558cc70a 100644 --- a/patches/net/minecraft/util/SpawnUtil.java.patch +++ b/patches/net/minecraft/util/SpawnUtil.java.patch @@ -1,45 +1,11 @@ --- a/net/minecraft/util/SpawnUtil.java +++ b/net/minecraft/util/SpawnUtil.java -@@ -1,6 +_,7 @@ - package net.minecraft.util; - - import java.util.Optional; -+import java.util.concurrent.atomic.AtomicReference; - import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; - import net.minecraft.server.level.ServerLevel; -@@ -13,8 +_,23 @@ - import net.minecraft.world.level.block.StainedGlassBlock; - import net.minecraft.world.level.block.StainedGlassPaneBlock; - import net.minecraft.world.level.block.state.BlockState; -+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; - - public class SpawnUtil { -+ -+ // Mohist start -+ private static final AtomicReference trySpawnMob$reason = new AtomicReference<>(SpawnReason.DEFAULT); -+ -+ public static void trySpawnMob$reason(SpawnReason reason) { -+ trySpawnMob$reason.set(reason); -+ } -+ -+ public static Optional trySpawnMob(EntityType pEntityType, MobSpawnType pSpawnType, ServerLevel pLevel, BlockPos pPos, int pAttempts, int p_216409_, int pYOffset, SpawnUtil.Strategy pStrategy, SpawnReason reason) { -+ trySpawnMob$reason(reason); -+ return trySpawnMob(pEntityType, pSpawnType, pLevel, pPos, pAttempts, p_216409_, pYOffset, pStrategy); -+ } -+ // Mohist end -+ - public static Optional trySpawnMob( - EntityType p_216404_, - MobSpawnType p_216405_, -@@ -35,8 +_,8 @@ +@@ -36,7 +_,7 @@ && moveToPossibleSpawnPosition(p_216406_, p_216410_, blockpos$mutableblockpos, p_216411_)) { - T t = (T)p_216404_.create(p_216406_, null, blockpos$mutableblockpos, p_216405_, false, false); + T t = (T)p_216404_.create(p_216406_, null, blockpos$mutableblockpos, p_364255_, false, false); if (t != null) { -- if (t.checkSpawnRules(p_216406_, p_216405_) && t.checkSpawnObstruction(p_216406_)) { -- p_216406_.addFreshEntityWithPassengers(t); -+ if (net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(t, p_216406_, p_216405_)) { -+ p_216406_.addFreshEntityWithPassengers(t, trySpawnMob$reason.getAndSet(SpawnReason.DEFAULT)); +- if (t.checkSpawnRules(p_216406_, p_364255_) && t.checkSpawnObstruction(p_216406_)) { ++ if (net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(t, p_216406_, p_364255_)) { + p_216406_.addFreshEntityWithPassengers(t); return Optional.of(t); } - diff --git a/patches/net/minecraft/util/context/ContextMap.java.patch b/patches/net/minecraft/util/context/ContextMap.java.patch new file mode 100644 index 00000000..86160aa2 --- /dev/null +++ b/patches/net/minecraft/util/context/ContextMap.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/util/context/ContextMap.java ++++ b/net/minecraft/util/context/ContextMap.java +@@ -73,7 +_,7 @@ + + public ContextMap create(ContextKeySet p_381168_) { + Set> set = Sets.difference(this.params.keySet(), p_381168_.allowed()); +- if (!set.isEmpty()) { ++ if (false && !set.isEmpty()) { + throw new IllegalArgumentException("Parameters not allowed in this parameter set: " + set); + } else { + Set> set1 = Sets.difference(p_381168_.required(), this.params.keySet()); diff --git a/patches/net/minecraft/util/datafix/DataFixers.java.patch b/patches/net/minecraft/util/datafix/DataFixers.java.patch index b6fe2020..7d19c8c1 100644 --- a/patches/net/minecraft/util/datafix/DataFixers.java.patch +++ b/patches/net/minecraft/util/datafix/DataFixers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/DataFixers.java +++ b/net/minecraft/util/datafix/DataFixers.java -@@ -1292,10 +_,35 @@ +@@ -1307,10 +_,35 @@ Schema schema199 = p_14514_.addSchema(3800, SAME_NAMESPACED); UnaryOperator unaryoperator2 = createRenamer(Map.of("minecraft:scute", "minecraft:turtle_scute")); p_14514_.addFixer(ItemRenameFix.create(schema199, "Rename scute item to turtle_scute", unaryoperator2)); @@ -24,7 +24,7 @@ + // Neo: rename neo attributes to new MC attributes + // Happens in 24w03a + Schema neoSchema3804 = p_14514_.addSchema(3804, SAME_NAMESPACED); -+ p_14514_.addFixer(new AttributesRename( ++ p_14514_.addFixer(new AttributesRenameLegacy( + neoSchema3804, + "(Neo) Rename reach attributes to vanilla", + createRenamer(ImmutableMap.of( @@ -36,15 +36,15 @@ Schema schema201 = p_14514_.addSchema(3807, V3807::new); p_14514_.addFixer(new AddNewChoices(schema201, "Added Vault", References.BLOCK_ENTITY)); Schema schema202 = p_14514_.addSchema(3807, 1, SAME_NAMESPACED); -@@ -1316,6 +_,18 @@ - p_14514_.addFixer( - new AttributesRename(schema209, "Rename jump strength attribute", createRenamer("minecraft:horse.jump_strength", "minecraft:generic.jump_strength")) +@@ -1333,6 +_,18 @@ + schema209, "Rename jump strength attribute", createRenamer("minecraft:horse.jump_strength", "minecraft:generic.jump_strength") + ) ); + + // Neo: rename neo attributes to new MC attributes + // Happens in 24w06a + Schema neoSchema3815 = p_14514_.addSchema(3815, SAME_NAMESPACED); -+ p_14514_.addFixer(new AttributesRename( ++ p_14514_.addFixer(new AttributesRenameLegacy( + neoSchema3815, + "(Neo) Rename gravity attribute to vanilla", + createRenamer( diff --git a/patches/net/minecraft/util/thread/BlockableEventLoop.java.patch b/patches/net/minecraft/util/thread/BlockableEventLoop.java.patch index 39297f64..3a19f55b 100644 --- a/patches/net/minecraft/util/thread/BlockableEventLoop.java.patch +++ b/patches/net/minecraft/util/thread/BlockableEventLoop.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/thread/BlockableEventLoop.java +++ b/net/minecraft/util/thread/BlockableEventLoop.java -@@ -56,10 +_,15 @@ +@@ -59,10 +_,15 @@ } public CompletableFuture submitAsync(Runnable p_18690_) { diff --git a/patches/net/minecraft/world/Container.java.patch b/patches/net/minecraft/world/Container.java.patch deleted file mode 100644 index fd87fd25..00000000 --- a/patches/net/minecraft/world/Container.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/world/Container.java -+++ b/net/minecraft/world/Container.java -@@ -8,6 +_,7 @@ - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.Level; - import net.minecraft.world.level.block.entity.BlockEntity; -+import org.bukkit.craftbukkit.entity.CraftHumanEntity; - - public interface Container extends Clearable { - float DEFAULT_DISTANCE_BUFFER = 4.0F; -@@ -91,4 +_,22 @@ - return level.getBlockEntity(blockpos) != p_272877_ ? false : p_272670_.canInteractWithBlock(blockpos, (double)p_320837_); - } - } -+ -+ // CraftBukkit start -+ java.util.List getContents(); -+ -+ void onOpen(CraftHumanEntity who); -+ -+ void onClose(CraftHumanEntity who); -+ -+ java.util.List getViewers(); -+ -+ org.bukkit.inventory.InventoryHolder getOwner(); -+ -+ void setMaxStackSize(int size); -+ -+ org.bukkit.Location getLocation(); -+ -+ int MAX_STACK = 99; -+ // CraftBukkit end - } diff --git a/patches/net/minecraft/world/damagesource/DamageSource.java.patch b/patches/net/minecraft/world/damagesource/DamageSource.java.patch index d8b483d1..1776b075 100644 --- a/patches/net/minecraft/world/damagesource/DamageSource.java.patch +++ b/patches/net/minecraft/world/damagesource/DamageSource.java.patch @@ -1,125 +1,5 @@ --- a/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java -@@ -20,6 +_,119 @@ - private final Entity directEntity; - @Nullable - private final Vec3 damageSourcePosition; -+ // CraftBukkit start -+ @Nullable -+ private org.bukkit.block.Block directBlock; // The block that caused the damage. damageSourcePosition is not used for all block damages -+ @Nullable -+ private org.bukkit.block.BlockState directBlockState; // The block state of the block relevant to this damage source -+ private boolean sweep = false; -+ private boolean melting = false; -+ private boolean poison = false; -+ private Entity customEntityDamager = null; // This field is a helper for when direct entity damage is not set by vanilla -+ private Entity customCausingEntityDamager = null; // This field is a helper for when causing entity damage is not set by vanilla -+ -+ public DamageSource sweep() { -+ this.sweep = true; -+ return this; -+ } -+ -+ public boolean isSweep() { -+ return this.sweep; -+ } -+ -+ public DamageSource melting() { -+ this.melting = true; -+ return this; -+ } -+ -+ public boolean isMelting() { -+ return this.melting; -+ } -+ -+ public DamageSource poison() { -+ this.poison = true; -+ return this; -+ } -+ -+ public boolean isPoison() { -+ return this.poison; -+ } -+ -+ public Entity getDamager() { -+ return (this.customEntityDamager != null) ? this.customEntityDamager : this.directEntity; -+ } -+ -+ public Entity getCausingDamager() { -+ return (this.customCausingEntityDamager != null) ? this.customCausingEntityDamager : this.causingEntity; -+ } -+ -+ public DamageSource customEntityDamager(Entity entity) { -+ // This method is not intended for change the causing entity if is already set -+ // also is only necessary if the entity passed is not the direct entity or different from the current causingEntity -+ if (this.customEntityDamager != null || this.directEntity == entity || this.causingEntity == entity) { -+ return this; -+ } -+ DamageSource damageSource = this.cloneInstance(); -+ damageSource.customEntityDamager = entity; -+ return damageSource; -+ } -+ -+ public DamageSource customCausingEntityDamager(Entity entity) { -+ // This method is not intended for change the causing entity if is already set -+ // also is only necessary if the entity passed is not the direct entity or different from the current causingEntity -+ if (this.customCausingEntityDamager != null || this.directEntity == entity || this.causingEntity == entity) { -+ return this; -+ } -+ DamageSource damageSource = this.cloneInstance(); -+ damageSource.customCausingEntityDamager = entity; -+ return damageSource; -+ } -+ -+ public org.bukkit.block.Block getDirectBlock() { -+ return this.directBlock; -+ } -+ -+ public DamageSource directBlock(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos blockPosition) { -+ if (blockPosition == null || world == null) { -+ return this; -+ } -+ return directBlock(org.bukkit.craftbukkit.block.CraftBlock.at(world, blockPosition)); -+ } -+ -+ public DamageSource directBlock(org.bukkit.block.Block block) { -+ if (block == null) { -+ return this; -+ } -+ // Cloning the instance lets us return unique instances of DamageSource without affecting constants defined in DamageSources -+ DamageSource damageSource = this.cloneInstance(); -+ damageSource.directBlock = block; -+ return damageSource; -+ } -+ -+ public org.bukkit.block.BlockState getDirectBlockState() { -+ return this.directBlockState; -+ } -+ -+ public DamageSource directBlockState(org.bukkit.block.BlockState blockState) { -+ if (blockState == null) { -+ return this; -+ } -+ // Cloning the instance lets us return unique instances of DamageSource without affecting constants defined in DamageSources -+ DamageSource damageSource = this.cloneInstance(); -+ damageSource.directBlockState = blockState; -+ return damageSource; -+ } -+ -+ private DamageSource cloneInstance() { -+ DamageSource damageSource = new DamageSource(this.type, this.directEntity, this.causingEntity, this.damageSourcePosition); -+ damageSource.directBlock = this.getDirectBlock(); -+ damageSource.directBlockState = this.getDirectBlockState(); -+ damageSource.sweep = this.isSweep(); -+ damageSource.poison = this.isPoison(); -+ damageSource.melting = this.isMelting(); -+ return damageSource; -+ } -+ // CraftBukkit end - - @Override - public String toString() { @@ -93,6 +_,10 @@ return this.type().msgId(); } diff --git a/patches/net/minecraft/world/damagesource/DamageSources.java.patch b/patches/net/minecraft/world/damagesource/DamageSources.java.patch deleted file mode 100644 index 2ae7590d..00000000 --- a/patches/net/minecraft/world/damagesource/DamageSources.java.patch +++ /dev/null @@ -1,65 +0,0 @@ ---- a/net/minecraft/world/damagesource/DamageSources.java -+++ b/net/minecraft/world/damagesource/DamageSources.java -@@ -41,9 +_,15 @@ - private final DamageSource stalagmite; - private final DamageSource outsideBorder; - private final DamageSource genericKill; -+ // CraftBukkit start -+ private final DamageSource melting; -+ private final DamageSource poison; - - public DamageSources(RegistryAccess p_270740_) { - this.damageTypes = p_270740_.registryOrThrow(Registries.DAMAGE_TYPE); -+ this.melting = this.source(DamageTypes.ON_FIRE).melting(); -+ this.poison = this.source(DamageTypes.MAGIC).poison(); -+ // CraftBukkit end - this.inFire = this.source(DamageTypes.IN_FIRE); - this.campfire = this.source(DamageTypes.CAMPFIRE); - this.lightningBolt = this.source(DamageTypes.LIGHTNING_BOLT); -@@ -82,6 +_,16 @@ - return new DamageSource(this.damageTypes.getHolderOrThrow(p_270076_), p_270656_, p_270242_); - } - -+ // CraftBukkit start -+ public DamageSource melting() { -+ return this.melting; -+ } -+ -+ public DamageSource poison() { -+ return this.poison; -+ } -+ // CraftBukkit end -+ - public DamageSource inFire() { - return this.inFire; - } -@@ -247,7 +_,13 @@ - } - - public DamageSource explosion(@Nullable Entity p_271016_, @Nullable Entity p_270814_) { -- return this.source(p_270814_ != null && p_271016_ != null ? DamageTypes.PLAYER_EXPLOSION : DamageTypes.EXPLOSION, p_271016_, p_270814_); -+ // CraftBukkit start -+ return this.explosion(p_271016_, p_270814_, p_270814_ != null && p_271016_ != null ? DamageTypes.PLAYER_EXPLOSION : DamageTypes.EXPLOSION); -+ } -+ -+ public DamageSource explosion(@Nullable Entity p_271016_, @Nullable Entity p_270814_, ResourceKey resourceKey) { -+ return this.source(resourceKey, p_271016_, p_270814_); -+ // CraftBukkit end - } - - public DamageSource sonicBoom(Entity p_270401_) { -@@ -255,7 +_,13 @@ - } - - public DamageSource badRespawnPointExplosion(Vec3 p_270175_) { -- return new DamageSource(this.damageTypes.getHolderOrThrow(DamageTypes.BAD_RESPAWN_POINT), p_270175_); -+ // CraftBukkit start -+ return badRespawnPointExplosion(p_270175_, null); -+ } -+ -+ public DamageSource badRespawnPointExplosion(Vec3 p_270175_, org.bukkit.block.BlockState blockState) { -+ return new DamageSource(this.damageTypes.getHolderOrThrow(DamageTypes.BAD_RESPAWN_POINT), p_270175_).directBlockState(blockState); -+ // CraftBukkit end - } - - public DamageSource outOfBorder() { diff --git a/patches/net/minecraft/world/effect/HealOrHarmMobEffect.java.patch b/patches/net/minecraft/world/effect/HealOrHarmMobEffect.java.patch deleted file mode 100644 index e74effd0..00000000 --- a/patches/net/minecraft/world/effect/HealOrHarmMobEffect.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/world/effect/HealOrHarmMobEffect.java -+++ b/net/minecraft/world/effect/HealOrHarmMobEffect.java -@@ -15,6 +_,8 @@ - @Override - public boolean applyEffectTick(LivingEntity p_295255_, int p_295147_) { - if (this.isHarm == p_295255_.isInvertedHealAndHarm()) { -+ p_295255_.pushHealReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit -+ p_295255_.pushHealReason(null); - p_295255_.heal((float)Math.max(4 << p_295147_, 0)); - } else { - p_295255_.hurt(p_295255_.damageSources().magic(), (float)(6 << p_295147_)); -@@ -27,6 +_,7 @@ - public void applyInstantenousEffect(@Nullable Entity p_294574_, @Nullable Entity p_295692_, LivingEntity p_296483_, int p_296095_, double p_295178_) { - if (this.isHarm == p_296483_.isInvertedHealAndHarm()) { - int i = (int)(p_295178_ * (double)(4 << p_296095_) + 0.5); -+ p_296483_.pushHealReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit - p_296483_.heal((float)i); - } else { - int j = (int)(p_295178_ * (double)(6 << p_296095_) + 0.5); diff --git a/patches/net/minecraft/world/effect/HungerMobEffect.java.patch b/patches/net/minecraft/world/effect/HungerMobEffect.java.patch deleted file mode 100644 index 544abbac..00000000 --- a/patches/net/minecraft/world/effect/HungerMobEffect.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/effect/HungerMobEffect.java -+++ b/net/minecraft/world/effect/HungerMobEffect.java -@@ -11,6 +_,7 @@ - @Override - public boolean applyEffectTick(LivingEntity p_296407_, int p_296356_) { - if (p_296407_ instanceof Player player) { -+ player.exhaustionReason(org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); - player.causeFoodExhaustion(0.005F * (float)(p_296356_ + 1)); - } - diff --git a/patches/net/minecraft/world/effect/MobEffect.java.patch b/patches/net/minecraft/world/effect/MobEffect.java.patch index e20b4fd2..135584ef 100644 --- a/patches/net/minecraft/world/effect/MobEffect.java.patch +++ b/patches/net/minecraft/world/effect/MobEffect.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffect.java +++ b/net/minecraft/world/effect/MobEffect.java -@@ -35,7 +_,7 @@ +@@ -36,7 +_,7 @@ import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; @@ -9,15 +9,7 @@ public static final Codec> CODEC = BuiltInRegistries.MOB_EFFECT.holderByNameCodec(); public static final StreamCodec> STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.MOB_EFFECT); private static final int AMBIENT_ALPHA = Mth.floor(38.25F); -@@ -56,6 +_,7 @@ - int i = p_333517_.isAmbient() ? AMBIENT_ALPHA : 255; - return ColorParticleOption.create(ParticleTypes.ENTITY_EFFECT, FastColor.ARGB32.color(i, p_19452_)); - }; -+ initClient(); - } - - protected MobEffect(MobEffectCategory p_333963_, int p_333864_, ParticleOptions p_333716_) { -@@ -130,6 +_,18 @@ +@@ -133,6 +_,18 @@ return this; } @@ -36,19 +28,11 @@ public MobEffect setBlendDuration(int p_316265_) { this.blendDurationTicks = p_316265_; return this; -@@ -181,8 +_,24 @@ +@@ -184,8 +_,16 @@ return this.requiredFeatures; } - static record AttributeTemplate(ResourceLocation id, double amount, AttributeModifier.Operation operation) { -+ /** -+ * Neo: Allowing mods to define client behavior for their MobEffects -+ * @deprecated Use {@link net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent} instead -+ */ -+ @Deprecated(forRemoval = true, since = "1.21") -+ public void initializeClient(java.util.function.Consumer consumer) { -+ } -+ + static record AttributeTemplate(ResourceLocation id, double amount, AttributeModifier.Operation operation, @Nullable it.unimi.dsi.fastutil.ints.Int2DoubleFunction curve) { + + public AttributeTemplate(ResourceLocation id, double amount, AttributeModifier.Operation operation) { diff --git a/patches/net/minecraft/world/effect/MobEffectInstance.java.patch b/patches/net/minecraft/world/effect/MobEffectInstance.java.patch index 0c314eaa..2e4c2750 100644 --- a/patches/net/minecraft/world/effect/MobEffectInstance.java.patch +++ b/patches/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -1,42 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectInstance.java +++ b/net/minecraft/world/effect/MobEffectInstance.java -@@ -80,6 +_,7 @@ - this.visible = p_19532_; - this.showIcon = p_19533_; - this.hiddenEffect = p_316863_; -+ this.effect.value().fillEffectCures(this.cures, this); - } - - public MobEffectInstance(MobEffectInstance p_19543_) { -@@ -97,6 +_,8 @@ - p_324529_.showIcon(), - p_324529_.hiddenEffect().map(p_323227_ -> new MobEffectInstance(p_324441_, p_323227_)).orElse(null) - ); -+ this.cures.clear(); -+ p_324529_.cures().ifPresent(this.cures::addAll); - } - - private MobEffectInstance.Details asDetails() { -@@ -106,7 +_,8 @@ - this.isAmbient(), - this.isVisible(), - this.showIcon(), -- Optional.ofNullable(this.hiddenEffect).map(MobEffectInstance::asDetails) -+ Optional.ofNullable(this.hiddenEffect).map(MobEffectInstance::asDetails), -+ Optional.of(this.getCures()).filter(cures -> !cures.isEmpty()) - ); - } - -@@ -124,6 +_,8 @@ - this.ambient = p_19549_.ambient; - this.visible = p_19549_.visible; - this.showIcon = p_19549_.showIcon; -+ this.cures.clear(); -+ this.cures.addAll(p_19549_.cures); - } - - public boolean update(MobEffectInstance p_19559_) { -@@ -324,11 +_,11 @@ +@@ -327,11 +_,11 @@ .compareFalseFirst(this.isAmbient(), p_19566_.isAmbient()) .compareFalseFirst(this.isInfiniteDuration(), p_19566_.isInfiniteDuration()) .compare(this.getDuration(), p_19566_.getDuration()) @@ -50,77 +14,3 @@ .result(); } -@@ -348,6 +_,15 @@ - this.blendState.setImmediate(this); - } - -+ private final java.util.Set cures = com.google.common.collect.Sets.newIdentityHashSet(); -+ -+ /** -+ * {@return the {@link net.neoforged.neoforge.common.EffectCure}s which can cure the {@link MobEffect} held by this {@link MobEffectInstance}} -+ */ -+ public java.util.Set getCures() { -+ return cures; -+ } -+ - static class BlendState { - private float factor; - private float factorPreviousFrame; -@@ -395,8 +_,7 @@ - } - - static record Details( -- int amplifier, int duration, boolean ambient, boolean showParticles, boolean showIcon, Optional hiddenEffect -- ) { -+ int amplifier, int duration, boolean ambient, boolean showParticles, boolean showIcon, Optional hiddenEffect, Optional> cures) { - public static final MapCodec MAP_CODEC = MapCodec.recursive( - "MobEffectInstance.Details", - p_323465_ -> RecordCodecBuilder.mapCodec( -@@ -407,12 +_,14 @@ - Codec.BOOL.optionalFieldOf("show_particles", Boolean.valueOf(true)).forGetter(MobEffectInstance.Details::showParticles), - Codec.BOOL.optionalFieldOf("show_icon").forGetter(p_323788_ -> Optional.of(p_323788_.showIcon())), - p_323465_.optionalFieldOf("hidden_effect").forGetter(MobEffectInstance.Details::hiddenEffect) -+ // Neo: Add additional serialization logic for custom EffectCure(s) -+ , net.neoforged.neoforge.common.util.NeoForgeExtraCodecs.setOf(net.neoforged.neoforge.common.EffectCure.CODEC).optionalFieldOf("neoforge:cures").forGetter(MobEffectInstance.Details::cures) - ) - .apply(p_324063_, MobEffectInstance.Details::create) - ) - ); -- public static final StreamCodec STREAM_CODEC = StreamCodec.recursive( -- p_329990_ -> StreamCodec.composite( -+ public static final StreamCodec STREAM_CODEC = StreamCodec.recursive( -+ p_329990_ -> net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs.composite( - ByteBufCodecs.VAR_INT, - MobEffectInstance.Details::amplifier, - ByteBufCodecs.VAR_INT, -@@ -425,6 +_,12 @@ - MobEffectInstance.Details::showIcon, - p_329990_.apply(ByteBufCodecs::optional), - MobEffectInstance.Details::hiddenEffect, -+ // Neo: Add additional serialization logic for custom EffectCure(s) -+ net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs.connectionAware( -+ ByteBufCodecs.optional(net.neoforged.neoforge.common.EffectCure.STREAM_CODEC.apply(ByteBufCodecs.collection(java.util.HashSet::new))), -+ net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs.uncheckedUnit(Optional.empty()) -+ ), -+ MobEffectInstance.Details::cures, - MobEffectInstance.Details::new - ) - ); -@@ -434,5 +_,17 @@ - ) { - return new MobEffectInstance.Details(p_323657_, p_324205_, p_324263_, p_324000_, p_323607_.orElse(p_324000_), p_324604_); - } -+ -+ private static MobEffectInstance.Details create( -+ int p_323657_, int p_324205_, boolean p_324263_, boolean p_324000_, Optional p_323607_, Optional p_324604_, Optional> cures -+ ) { -+ return new MobEffectInstance.Details(p_323657_, p_324205_, p_324263_, p_324000_, p_323607_.orElse(p_324000_), p_324604_, cures); -+ } -+ -+ @Deprecated -+ Details(int amplifier, int duration, boolean ambient, boolean showParticles, boolean showIcon, Optional hiddenEffect) { -+ this(amplifier, duration, ambient, showParticles, showIcon, hiddenEffect, Optional.empty()); -+ } -+ - } - } diff --git a/patches/net/minecraft/world/effect/PoisonMobEffect.java.patch b/patches/net/minecraft/world/effect/PoisonMobEffect.java.patch index 39db38e1..d2c1139e 100644 --- a/patches/net/minecraft/world/effect/PoisonMobEffect.java.patch +++ b/patches/net/minecraft/world/effect/PoisonMobEffect.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/effect/PoisonMobEffect.java +++ b/net/minecraft/world/effect/PoisonMobEffect.java -@@ -10,7 +_,12 @@ +@@ -11,7 +_,12 @@ @Override - public boolean applyEffectTick(LivingEntity p_296276_, int p_296233_) { + public boolean applyEffectTick(ServerLevel p_376442_, LivingEntity p_296276_, int p_296233_) { if (p_296276_.getHealth() > 1.0F) { -- p_296276_.hurt(p_296276_.damageSources().magic(), 1.0F); +- p_296276_.hurtServer(p_376442_, p_296276_.damageSources().magic(), 1.0F); + // Neo: Replace DamageSources#magic() with neoforge:poison to allow differentiating poison damage. + // Fallback to minecraft:magic in client code when connecting to a vanilla server. + // LivingEntity#hurt(DamageSource) will no-op in client code immediately, but the holder is resolved before the no-op. + var dTypeReg = p_296276_.damageSources().damageTypes; -+ var dType = dTypeReg.getHolder(net.neoforged.neoforge.common.NeoForgeMod.POISON_DAMAGE).orElse(dTypeReg.getHolderOrThrow(net.minecraft.world.damagesource.DamageTypes.MAGIC)); -+ p_296276_.hurt(new net.minecraft.world.damagesource.DamageSource(dType), 1.0F); ++ var dType = dTypeReg.get(net.neoforged.neoforge.common.NeoForgeMod.POISON_DAMAGE).orElse(dTypeReg.getOrThrow(net.minecraft.world.damagesource.DamageTypes.MAGIC)); ++ p_296276_.hurtServer(p_376442_, new net.minecraft.world.damagesource.DamageSource(dType), 1.0F); } return true; diff --git a/patches/net/minecraft/world/effect/RegenerationMobEffect.java.patch b/patches/net/minecraft/world/effect/RegenerationMobEffect.java.patch deleted file mode 100644 index 1d8ccc5a..00000000 --- a/patches/net/minecraft/world/effect/RegenerationMobEffect.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/effect/RegenerationMobEffect.java -+++ b/net/minecraft/world/effect/RegenerationMobEffect.java -@@ -10,6 +_,7 @@ - @Override - public boolean applyEffectTick(LivingEntity p_295924_, int p_296417_) { - if (p_295924_.getHealth() < p_295924_.getMaxHealth()) { -+ p_295924_.pushHealReason(org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC_REGEN); - p_295924_.heal(1.0F); - } - diff --git a/patches/net/minecraft/world/effect/SaturationMobEffect.java.patch b/patches/net/minecraft/world/effect/SaturationMobEffect.java.patch deleted file mode 100644 index fa68a13c..00000000 --- a/patches/net/minecraft/world/effect/SaturationMobEffect.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/world/effect/SaturationMobEffect.java -+++ b/net/minecraft/world/effect/SaturationMobEffect.java -@@ -2,6 +_,8 @@ - - import net.minecraft.world.entity.LivingEntity; - import net.minecraft.world.entity.player.Player; -+import org.bukkit.craftbukkit.entity.CraftPlayer; -+import org.bukkit.craftbukkit.event.CraftEventFactory; - - class SaturationMobEffect extends InstantenousMobEffect { - protected SaturationMobEffect(MobEffectCategory p_294221_, int p_295725_) { -@@ -11,7 +_,15 @@ - @Override - public boolean applyEffectTick(LivingEntity p_295892_, int p_296026_) { - if (!p_295892_.level().isClientSide && p_295892_ instanceof Player player) { -- player.getFoodData().eat(p_296026_ + 1, 1.0F); -+ // CraftBukkit start -+ int oldFoodLevel = player.getFoodData().foodLevel; -+ org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(player, p_296026_ + 1 + oldFoodLevel); -+ if (!event.isCancelled()) { -+ player.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F); -+ } -+ -+ ((CraftPlayer) player.getBukkitEntity()).sendHealthUpdate(); -+ // CraftBukkit end - } - - return true; diff --git a/patches/net/minecraft/world/entity/Entity.java.patch b/patches/net/minecraft/world/entity/Entity.java.patch index 7e0cd6af..15f8303a 100644 --- a/patches/net/minecraft/world/entity/Entity.java.patch +++ b/patches/net/minecraft/world/entity/Entity.java.patch @@ -1,23 +1,15 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -126,9 +_,15 @@ - import net.minecraft.world.scores.PlayerTeam; - import net.minecraft.world.scores.ScoreHolder; +@@ -136,7 +_,7 @@ import net.minecraft.world.scores.Team; -+import org.bukkit.Location; -+import org.bukkit.command.CommandSender; -+import org.bukkit.craftbukkit.entity.CraftEntity; -+import org.bukkit.craftbukkit.event.CraftPortalEvent; -+import org.bukkit.event.entity.EntityRemoveEvent; -+import org.bukkit.event.player.PlayerTeleportEvent; import org.slf4j.Logger; --public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, CommandSource, ScoreHolder { -+public abstract class Entity extends net.neoforged.neoforge.attachment.AttachmentHolder implements SyncedDataHolder, Nameable, EntityAccess, CommandSource, ScoreHolder, net.neoforged.neoforge.common.extensions.IEntityExtension { +-public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder { ++public abstract class Entity extends net.neoforged.neoforge.attachment.AttachmentHolder implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, net.neoforged.neoforge.common.extensions.IEntityExtension { private static final Logger LOGGER = LogUtils.getLogger(); public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -149,6 +_,7 @@ +@@ -157,6 +_,7 @@ private static final double LAVA_SLOW_FLOW_SCALE = 0.0023333333333333335; public static final String UUID_TAG = "UUID"; private static double viewScale = 1.0; @@ -25,10 +17,10 @@ private final EntityType type; private int id = ENTITY_COUNTER.incrementAndGet(); public boolean blocksBuilding; -@@ -194,8 +_,10 @@ +@@ -201,8 +_,10 @@ public int tickCount; - public int remainingFireTicks = -this.getFireImmuneTicks(); - public boolean wasTouchingWater; + private int remainingFireTicks = -this.getFireImmuneTicks(); + protected boolean wasTouchingWater; + @Deprecated // Forge: Use forgeFluidTypeHeight instead protected Object2DoubleMap> fluidHeight = new Object2DoubleArrayMap<>(2); protected boolean wasEyeInWater; @@ -36,64 +28,7 @@ private final Set> fluidOnEyes = new HashSet<>(); public int invulnerableTime; protected boolean firstTick = true; -@@ -243,6 +_,56 @@ - public boolean hasVisualFire; - @Nullable - private BlockState inBlockState = null; -+ // CraftBukkit start -+ private static final int CURRENT_LEVEL = 2; -+ static boolean isLevelAtLeast(CompoundTag tag, int level) { -+ return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; -+ } -+ -+ private CraftEntity bukkitEntity; -+ -+ public CraftEntity getBukkitEntity() { -+ if (bukkitEntity == null) { -+ bukkitEntity = CraftEntity.getEntity(level.getCraftServer(), this); -+ } -+ return bukkitEntity; -+ } -+ -+ @Override -+ public CommandSender getBukkitSender(CommandSourceStack wrapper) { -+ return getBukkitEntity(); -+ } -+ -+ // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() -+ public int getDefaultMaxAirSupply() { -+ return TOTAL_AIR_SUPPLY; -+ } -+ // CraftBukkit end -+ -+ // CraftBukkit start -+ public boolean forceDrops; -+ public boolean persist = true; -+ public boolean visibleByDefault = true; -+ public boolean valid; -+ public boolean inWorld = false; -+ public boolean generation; -+ public int maxAirTicks = getDefaultMaxAirSupply(); // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() -+ public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only -+ public boolean lastDamageCancelled; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled -+ public boolean persistentInvisibility = false; -+ public BlockPos lastLavaContact; -+ // Marks an entity, that it was removed by a plugin via Entity#remove -+ // Main use case currently is for SPIGOT-7487, preventing dropping of leash when leash is removed -+ public boolean pluginRemoved = false; -+ -+ public float getBukkitYaw() { -+ return this.yRot; -+ } -+ -+ public boolean isChunkLoaded() { -+ return level.hasChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); -+ } -+ // CraftBukkit end - - public Entity(EntityType p_19870_, Level p_19871_) { - this.type = p_19870_; -@@ -263,7 +_,10 @@ +@@ -271,7 +_,10 @@ this.defineSynchedData(synchedentitydata$builder); this.entityData = synchedentitydata$builder.build(); this.setPos(0.0, 0.0, 0.0); @@ -104,84 +39,7 @@ } public boolean isColliding(BlockPos p_20040_, BlockState p_20041_) { -@@ -333,6 +_,76 @@ - this.remove(Entity.RemovalReason.DISCARDED); - } - -+ public final void discard(EntityRemoveEvent.Cause cause) { -+ -+ } -+ -+ // CraftBukkit start -+ public void refreshEntityData(ServerPlayer to) { -+ -+ } -+ // CraftBukkit end -+ -+ public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) { -+ -+ } -+ -+ public void postTick() { -+ -+ } -+ -+ public final void igniteForSeconds(float f, boolean callEvent) { -+ -+ } -+ -+ // CraftBukkit start - Add delegate methods -+ public SoundEvent getSwimSound0() { -+ return getSwimSound(); -+ } -+ -+ public SoundEvent getSwimSplashSound0() { -+ return getSwimSplashSound(); -+ } -+ -+ public SoundEvent getSwimHighSpeedSplashSound0() { -+ return getSwimHighSpeedSplashSound(); -+ } -+ // CraftBukkit end -+ -+ // CraftBukkit start - collidable API -+ public boolean canCollideWithBukkit(Entity entity) { -+ return isPushable(); -+ } -+ // CraftBukkit end -+ -+ public boolean saveAsPassenger(CompoundTag nbttagcompound, boolean includeAll) { -+ return includeAll; -+ } -+ -+ public CompoundTag saveWithoutId(CompoundTag nbttagcompound, boolean includeAll) { -+ return nbttagcompound; -+ } -+ -+ protected void addAdditionalSaveData(CompoundTag nbttagcompound, boolean includeAll) { -+ -+ } -+ -+ protected boolean bukkit$removePassenger(Entity entity) { // CraftBukkit -+ return false; -+ } -+ -+ public CraftPortalEvent callPortalEvent(Entity entity, Location exit, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { -+ return null; -+ } -+ -+ public boolean teleportTo(ServerLevel worldserver, double d0, double d1, double d2, Set set, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { -+ return false; -+ } -+ -+ public final void setRemoved(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) { -+ -+ } -+ - protected abstract void defineSynchedData(SynchedEntityData.Builder p_326003_); - - public SynchedEntityData getEntityData() { -@@ -467,7 +_,7 @@ +@@ -478,7 +_,7 @@ if (this.isInLava()) { this.lavaHurt(); @@ -190,36 +48,22 @@ } this.checkBelowWorld(); -@@ -673,7 +_,7 @@ - double d1 = vec3.x; - double d2 = vec3.y; - double d3 = vec3.z; -- this.flyDist = this.flyDist + (float)(vec3.length() * 0.6); -+ this.flyDist = (float)((double)this.flyDist + vec3.length() * 0.6D); - BlockPos blockpos1 = this.getOnPos(); - BlockState blockstate1 = this.level().getBlockState(blockpos1); - boolean flag1 = this.isStateClimbable(blockstate1); -@@ -717,16 +_,16 @@ - this.setRemainingFireTicks(-this.getFireImmuneTicks()); - } - -- if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { -+ if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble() || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { - this.playEntityOnFireExtinguishedSound(); - } +@@ -760,12 +_,12 @@ + this.setRemainingFireTicks(-this.getFireImmuneTicks()); } -- if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { -+ if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble() || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { - this.setRemainingFireTicks(-this.getFireImmuneTicks()); +- if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { ++ if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble()|| this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { + this.playEntityOnFireExtinguishedSound(); } + } -- this.level().getProfiler().pop(); -+ this.level.getProfiler().pop(); +- if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { ++ if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble()|| this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { + this.setRemainingFireTicks(-this.getFireImmuneTicks()); } } - } -@@ -812,9 +_,7 @@ +@@ -845,9 +_,7 @@ return blockpos; } else { BlockState blockstate = this.level().getBlockState(blockpos); @@ -230,7 +74,7 @@ ? blockpos.atY(Mth.floor(this.position.y - (double)p_216987_)) : blockpos; } -@@ -1076,19 +_,19 @@ +@@ -1129,19 +_,19 @@ return !blockstate.is(BlockTags.INSIDE_STEP_SOUND_BLOCKS) && !blockstate.is(BlockTags.COMBINATION_STEP_SOUND_BLOCKS) ? p_278049_ : blockpos; } @@ -256,7 +100,7 @@ this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch()); } -@@ -1241,20 +_,23 @@ +@@ -1294,20 +_,23 @@ public void updateSwimming() { if (this.isSwimming()) { @@ -277,7 +121,7 @@ - double d0 = this.level().dimensionType().ultraWarm() ? 0.007 : 0.0023333333333333335; - boolean flag = this.updateFluidHeightAndDoFluidPushing(FluidTags.LAVA, d0); - return this.isInWater() || flag; -+ if (this.isInFluidType() && !(this.getVehicle() instanceof Boat)) { ++ if (this.isInFluidType() && !(this.getVehicle() instanceof AbstractBoat)) { + this.fallDistance *= this.forgeFluidTypeHeight.object2DoubleEntrySet().stream().filter(e -> !e.getKey().isAir() && !e.getKey().isVanilla()).map(e -> this.getFluidFallDistanceModifier(e.getKey())).min(Float::compare).orElse(1F); + if (this.isInFluidType((fluidType, height) -> !fluidType.isAir() && !fluidType.isVanilla() && this.canFluidExtinguish(fluidType))) this.clearFire(); + } @@ -285,15 +129,15 @@ } void updateInWaterStateAndDoWaterCurrentPushing() { -@@ -1279,6 +_,7 @@ +@@ -1332,6 +_,7 @@ private void updateFluidOnEyes() { this.wasEyeInWater = this.isEyeInFluid(FluidTags.WATER); this.fluidOnEyes.clear(); + this.forgeFluidTypeOnEyes = net.neoforged.neoforge.common.NeoForgeMod.EMPTY_TYPE.value(); double d0 = this.getEyeY(); - if (this.getVehicle() instanceof Boat boat && !boat.isUnderWater() && boat.getBoundingBox().maxY >= d0 && boat.getBoundingBox().minY <= d0) { - return; -@@ -1288,7 +_,7 @@ + if (this.getVehicle() instanceof AbstractBoat abstractboat + && !abstractboat.isUnderWater() +@@ -1344,7 +_,7 @@ FluidState fluidstate = this.level().getFluidState(blockpos); double d1 = (double)((float)blockpos.getY() + fluidstate.getHeight(this.level(), blockpos)); if (d1 > d0) { @@ -302,7 +146,7 @@ } } -@@ -1333,12 +_,13 @@ +@@ -1389,12 +_,13 @@ } public boolean canSpawnSprintParticle() { @@ -317,7 +161,7 @@ if (blockstate.getRenderShape() != RenderShape.INVISIBLE) { Vec3 vec3 = this.getDeltaMovement(); BlockPos blockpos1 = this.blockPosition(); -@@ -1352,16 +_,19 @@ +@@ -1408,16 +_,19 @@ d1 = Mth.clamp(d1, (double)blockpos.getZ(), (double)blockpos.getZ() + 1.0); } @@ -339,7 +183,7 @@ } public void moveRelative(float p_19921_, Vec3 p_19922_) { -@@ -1704,6 +_,10 @@ +@@ -1796,6 +_,10 @@ p_20241_.put("Tags", listtag); } @@ -350,7 +194,7 @@ this.addAdditionalSaveData(p_20241_); if (this.isVehicle()) { ListTag listtag1 = new ListTag(); -@@ -1784,6 +_,8 @@ +@@ -1877,6 +_,8 @@ this.setGlowingTag(p_20259_.getBoolean("Glowing")); this.setTicksFrozen(p_20259_.getInt("TicksFrozen")); this.hasVisualFire = p_20259_.getBoolean("HasVisualFire"); @@ -359,16 +203,16 @@ if (p_20259_.contains("Tags", 9)) { this.tags.clear(); ListTag listtag3 = p_20259_.getList("Tags", 8); -@@ -1868,6 +_,8 @@ +@@ -1959,6 +_,8 @@ } else { - ItemEntity itementity = new ItemEntity(this.level(), this.getX(), this.getY() + (double)p_19986_, this.getZ(), p_19985_); + ItemEntity itementity = new ItemEntity(p_376141_, this.getX(), this.getY() + (double)p_376881_, this.getZ(), p_376472_); itementity.setDefaultPickUpDelay(); + if (captureDrops() != null) captureDrops().add(itementity); + else - this.level().addFreshEntity(itementity); + p_376141_.addFreshEntity(itementity); return itementity; } -@@ -1935,7 +_,11 @@ +@@ -2026,7 +_,11 @@ public void rideTick() { this.setDeltaMovement(Vec3.ZERO); @@ -381,7 +225,7 @@ if (this.isPassenger()) { this.getVehicle().positionRider(this); } -@@ -1993,6 +_,7 @@ +@@ -2086,6 +_,7 @@ } } @@ -389,7 +233,7 @@ if (p_19967_ || this.canRide(p_19966_) && p_19966_.canAddPassenger(this)) { if (this.isPassenger()) { this.stopRiding(); -@@ -2024,6 +_,7 @@ +@@ -2117,6 +_,7 @@ public void removeVehicle() { if (this.vehicle != null) { Entity entity = this.vehicle; @@ -397,7 +241,7 @@ this.vehicle = null; entity.removePassenger(this); } -@@ -2073,6 +_,8 @@ +@@ -2166,6 +_,8 @@ return this.passengers.isEmpty(); } @@ -406,7 +250,7 @@ protected boolean couldAcceptPassenger() { return true; } -@@ -2257,7 +_,7 @@ +@@ -2354,7 +_,7 @@ } public boolean isVisuallyCrawling() { @@ -415,16 +259,16 @@ } public void setSwimming(boolean p_20283_) { -@@ -2366,7 +_,7 @@ +@@ -2467,7 +_,7 @@ this.igniteForSeconds(8.0F); } -- this.hurt(this.damageSources().lightningBolt(), 5.0F); +- this.hurtServer(p_19927_, this.damageSources().lightningBolt(), 5.0F); + this.hurt(this.damageSources().lightningBolt(), p_19928_.getDamage()); } public void onAboveBubbleCol(boolean p_20313_) { -@@ -2461,7 +_,7 @@ +@@ -2562,7 +_,7 @@ } protected Component getTypeName() { @@ -433,10 +277,10 @@ } public boolean is(Entity p_20356_) { -@@ -2516,10 +_,11 @@ +@@ -2617,10 +_,11 @@ } - public boolean isInvulnerableTo(DamageSource p_20122_) { + protected final boolean isInvulnerableToBase(DamageSource p_20122_) { - return this.isRemoved() + boolean isVanillaInvulnerable = this.isRemoved() || this.invulnerable && !p_20122_.is(DamageTypeTags.BYPASSES_INVULNERABILITY) && !p_20122_.isCreativePlayer() @@ -446,15 +290,15 @@ } public boolean isInvulnerable() { -@@ -2544,6 +_,7 @@ +@@ -2645,6 +_,7 @@ @Nullable - public Entity changeDimension(DimensionTransition p_350951_) { -+ if (!net.neoforged.neoforge.common.CommonHooks.onTravelToDimension(this, p_350951_.newLevel().dimension())) return null; + public Entity teleport(TeleportTransition p_379899_) { ++ if (!net.neoforged.neoforge.common.CommonHooks.onTravelToDimension(this, p_379899_.newLevel().dimension())) return null; if (this.level() instanceof ServerLevel serverlevel && !this.isRemoved()) { - ServerLevel serverlevel1 = p_350951_.newLevel(); - List list = this.getPassengers(); -@@ -2667,6 +_,7 @@ + ServerLevel serverlevel1 = p_379899_.newLevel(); + boolean flag = serverlevel1.dimension() != serverlevel.dimension(); +@@ -2852,6 +_,7 @@ return this.stringUUID; } @@ -462,7 +306,7 @@ public boolean isPushedByFluid() { return true; } -@@ -2783,6 +_,8 @@ +@@ -2960,6 +_,8 @@ EntityDimensions entitydimensions = this.dimensions; Pose pose = this.getPose(); EntityDimensions entitydimensions1 = this.getDimensions(pose); @@ -471,7 +315,7 @@ this.dimensions = entitydimensions1; this.eyeHeight = entitydimensions1.eyeHeight(); this.reapplyPosition(); -@@ -3110,9 +_,17 @@ +@@ -3265,9 +_,17 @@ return Mth.lerp(p_352259_, this.yRotO, this.yRot); } @@ -490,7 +334,7 @@ } else { AABB aabb = this.getBoundingBox().deflate(0.001); int i = Mth.floor(aabb.minX); -@@ -3127,25 +_,36 @@ +@@ -3282,25 +_,36 @@ Vec3 vec3 = Vec3.ZERO; int k1 = 0; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); @@ -534,7 +378,7 @@ } } } -@@ -3153,27 +_,30 @@ +@@ -3308,27 +_,30 @@ } } @@ -575,7 +419,7 @@ } } -@@ -3186,7 +_,10 @@ +@@ -3341,7 +_,10 @@ return !this.level().hasChunksAt(i, k, j, l); } @@ -586,7 +430,7 @@ return this.fluidHeight.getDouble(p_204037_); } -@@ -3323,6 +_,7 @@ +@@ -3478,6 +_,7 @@ this.levelCallback.onMove(); } @@ -594,9 +438,9 @@ } public void checkDespawn() { -@@ -3449,6 +_,128 @@ +@@ -3603,6 +_,128 @@ - public boolean mayInteract(Level p_146843_, BlockPos p_146844_) { + public boolean mayInteract(ServerLevel p_376870_, BlockPos p_146844_) { return true; + } + @@ -634,7 +478,7 @@ + + // Neo: Set the default behavior for trampling on Farmland + @Override -+ public boolean canTrample(BlockState state, BlockPos pos, float fallDistance) { ++ public boolean canTrample(ServerLevel level, BlockState state, BlockPos pos, float fallDistance) { + return level.random.nextFloat() < fallDistance - 0.5F + && this instanceof LivingEntity + && (this instanceof Player || net.neoforged.neoforge.event.EventHooks.canEntityGrief(level, this)) diff --git a/patches/net/minecraft/world/entity/EntityType.java.patch b/patches/net/minecraft/world/entity/EntityType.java.patch index 1f3f2990..44398736 100644 --- a/patches/net/minecraft/world/entity/EntityType.java.patch +++ b/patches/net/minecraft/world/entity/EntityType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -834,6 +_,10 @@ +@@ -1088,6 +_,10 @@ private final float spawnDimensionsScale; private final FeatureFlagSet requiredFeatures; @@ -8,14 +8,14 @@ + private final java.util.function.ToIntFunction> trackingRangeSupplier; + private final java.util.function.ToIntFunction> updateIntervalSupplier; + - private static EntityType register(String p_20635_, EntityType.Builder p_20636_) { - return Registry.register(BuiltInRegistries.ENTITY_TYPE, p_20635_, p_20636_.build(p_20635_)); + private static EntityType register(ResourceKey> p_368669_, EntityType.Builder p_368714_) { + return Registry.register(BuiltInRegistries.ENTITY_TYPE, p_368669_, p_368714_.build(p_368669_)); } -@@ -860,6 +_,26 @@ - int p_273451_, +@@ -1124,6 +_,28 @@ + Optional> p_368696_, FeatureFlagSet p_273518_ ) { -+ this(p_273268_, p_272918_, p_273417_, p_273389_, p_273556_, p_272654_, p_273631_, p_272946_, p_338404_, p_272895_, p_273451_, p_273518_, EntityType::defaultTrackDeltasSupplier, EntityType::defaultTrackingRangeSupplier, EntityType::defaultUpdateIntervalSupplier); ++ this(p_273268_, p_272918_, p_273417_, p_273389_, p_273556_, p_272654_, p_273631_, p_272946_, p_338404_, p_272895_, p_273451_, p_368582_, p_368696_, p_273518_, EntityType::defaultTrackDeltasSupplier, EntityType::defaultTrackingRangeSupplier, EntityType::defaultUpdateIntervalSupplier); + } + + public EntityType( @@ -30,6 +30,8 @@ + float p_338404_, + int p_272895_, + int p_273451_, ++ String p_368582_, ++ Optional> p_368696_, + FeatureFlagSet p_273518_, + final java.util.function.Predicate> trackDeltasSupplier, + final java.util.function.ToIntFunction> trackingRangeSupplier, @@ -38,9 +40,9 @@ this.factory = p_273268_; this.category = p_272918_; this.canSpawnFarFromPlayer = p_272654_; -@@ -872,6 +_,9 @@ - this.clientTrackingRange = p_272895_; - this.updateInterval = p_273451_; +@@ -1138,6 +_,9 @@ + this.descriptionId = p_368582_; + this.lootTable = p_368696_; this.requiredFeatures = p_273518_; + this.trackDeltasSupplier = trackDeltasSupplier; + this.trackingRangeSupplier = trackingRangeSupplier; @@ -48,10 +50,10 @@ } @Nullable -@@ -958,6 +_,15 @@ +@@ -1228,6 +_,15 @@ mob.yHeadRot = mob.getYRot(); mob.yBodyRot = mob.getYRot(); - mob.finalizeSpawn(p_262637_, p_262637_.getCurrentDifficultyAt(mob.blockPosition()), p_262666_, null); + mob.finalizeSpawn(p_262637_, p_262637_.getCurrentDifficultyAt(mob.blockPosition()), p_360546_, null); + + if (mob.isSpawnCancelled()) { + // Neo: Discard mob, spawn was cancelled @@ -64,7 +66,7 @@ mob.playAmbientSound(); } -@@ -1149,14 +_,23 @@ +@@ -1410,14 +_,23 @@ } public int clientTrackingRange() { @@ -88,8 +90,8 @@ return this != PLAYER && this != LLAMA_SPIT && this != WITHER -@@ -1192,6 +_,8 @@ - return this.builtInRegistryHolder; +@@ -1469,6 +_,8 @@ + return (p_375561_, p_375562_) -> new ChestRaft(p_375561_, p_375562_, p_376648_); } + public Stream>> getTags() {return this.builtInRegistryHolder().tags();} @@ -97,9 +99,9 @@ public static class Builder { private final EntityType.EntityFactory factory; private final MobCategory category; -@@ -1207,6 +_,10 @@ - private EntityAttachments.Builder attachments = EntityAttachments.builder(); - private FeatureFlagSet requiredFeatures = FeatureFlags.VANILLA_SET; +@@ -1488,6 +_,10 @@ + ); + private DependantName, String> descriptionId = p_367918_ -> Util.makeDescriptionId("entity", p_367918_.location()); + private java.util.function.Predicate> velocityUpdateSupplier = EntityType::defaultTrackDeltasSupplier; + private java.util.function.ToIntFunction> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier; @@ -108,32 +110,32 @@ private Builder(EntityType.EntityFactory p_20696_, MobCategory p_20697_) { this.factory = p_20696_; this.category = p_20697_; -@@ -1314,6 +_,21 @@ +@@ -1600,6 +_,21 @@ return this; } + public EntityType.Builder setUpdateInterval(int interval) { -+ this.updateIntervalSupplier = t->interval; -+ return this; ++ this.updateIntervalSupplier = t->interval; ++ return this; + } + + public EntityType.Builder setTrackingRange(int range) { -+ this.trackingRangeSupplier = t->range; -+ return this; ++ this.trackingRangeSupplier = t->range; ++ return this; + } + + public EntityType.Builder setShouldReceiveVelocityUpdates(boolean value) { -+ this.velocityUpdateSupplier = t->value; -+ return this; ++ this.velocityUpdateSupplier = t->value; ++ return this; + } + - public EntityType build(String p_20713_) { + public EntityType build(ResourceKey> p_368626_) { if (this.serialize) { - Util.fetchChoiceType(References.ENTITY_TREE, p_20713_); -@@ -1331,7 +_,10 @@ - this.spawnDimensionsScale, - this.clientTrackingRange, + Util.fetchChoiceType(References.ENTITY_TREE, p_368626_.location().toString()); +@@ -1619,7 +_,10 @@ this.updateInterval, + this.descriptionId.get(p_368626_), + this.lootTable.get(p_368626_), - this.requiredFeatures + this.requiredFeatures, + velocityUpdateSupplier, diff --git a/patches/net/minecraft/world/entity/ExperienceOrb.java.patch b/patches/net/minecraft/world/entity/ExperienceOrb.java.patch index d81cfa82..9a5df1bf 100644 --- a/patches/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/patches/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -112,7 +_,8 @@ - this.move(MoverType.SELF, this.getDeltaMovement()); +@@ -113,7 +_,8 @@ + this.applyEffectsFromBlocks(); float f = 0.98F; if (this.onGround()) { - f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; @@ -10,7 +10,7 @@ } this.setDeltaMovement(this.getDeltaMovement().multiply((double)f, 0.98, (double)f)); -@@ -133,7 +_,7 @@ +@@ -134,7 +_,7 @@ private void scanForEntities() { if (this.followingPlayer == null || this.followingPlayer.distanceToSqr(this) > 64.0) { @@ -19,7 +19,7 @@ } if (this.level() instanceof ServerLevel) { -@@ -228,6 +_,7 @@ +@@ -232,6 +_,7 @@ public void playerTouch(Player p_20792_) { if (p_20792_ instanceof ServerPlayer serverplayer) { if (p_20792_.takeXpDelay == 0) { @@ -27,7 +27,7 @@ p_20792_.takeXpDelay = 2; p_20792_.take(this, 1); int i = this.repairPlayerItems(serverplayer, this.value); -@@ -247,7 +_,7 @@ +@@ -251,7 +_,7 @@ Optional optional = EnchantmentHelper.getRandomItemWith(EnchantmentEffectComponents.REPAIR_WITH_XP, p_344821_, ItemStack::isDamaged); if (optional.isPresent()) { ItemStack itemstack = optional.get().itemStack(); diff --git a/patches/net/minecraft/world/entity/LightningBolt.java.patch b/patches/net/minecraft/world/entity/LightningBolt.java.patch index f74497ef..8a59dc34 100644 --- a/patches/net/minecraft/world/entity/LightningBolt.java.patch +++ b/patches/net/minecraft/world/entity/LightningBolt.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LightningBolt.java +++ b/net/minecraft/world/entity/LightningBolt.java -@@ -38,6 +_,7 @@ +@@ -39,6 +_,7 @@ private ServerPlayer cause; private final Set hitEntities = Sets.newHashSet(); private int blocksSetOnFire; diff --git a/patches/net/minecraft/world/entity/LivingEntity.java.patch b/patches/net/minecraft/world/entity/LivingEntity.java.patch index 71b3f87a..ebb7a0cb 100644 --- a/patches/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,19 +1,7 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -22,6 +_,7 @@ - import java.util.Optional; - import java.util.Set; - import java.util.Map.Entry; -+import java.util.concurrent.atomic.AtomicReference; - import java.util.function.Predicate; - import javax.annotation.Nonnull; - import javax.annotation.Nullable; -@@ -130,9 +_,11 @@ - import net.minecraft.world.phys.Vec3; - import net.minecraft.world.scores.PlayerTeam; +@@ -137,7 +_,7 @@ import net.minecraft.world.scores.Scoreboard; -+import org.bukkit.event.entity.EntityRegainHealthEvent; -+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.slf4j.Logger; -public abstract class LivingEntity extends Entity implements Attackable { @@ -21,22 +9,43 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; private static final ResourceLocation SPEED_MODIFIER_POWDER_SNOW_ID = ResourceLocation.withDefaultNamespace("powder_snow"); -@@ -254,6 +_,14 @@ - private boolean skipDropExperience; - private final Reference2ObjectMap> activeLocationDependentEnchantments = new Reference2ObjectArrayMap<>(); +@@ -179,13 +_,18 @@ + public static final float EXTRA_RENDER_CULLING_SIZE_WITH_BIG_HAT = 0.5F; + public static final float DEFAULT_BABY_SCALE = 0.5F; + public static final String ATTRIBUTES_FIELD = "attributes"; +- public static final Predicate PLAYER_NOT_WEARING_DISGUISE_ITEM = p_379074_ -> { ++ public static final java.util.function.BiPredicate PLAYER_NOT_WEARING_DISGUISE_ITEM_FOR_TARGET = (p_379074_, target) -> { + if (p_379074_ instanceof Player player) { + ItemStack itemstack = player.getItemBySlot(EquipmentSlot.HEAD); +- return !itemstack.is(ItemTags.GAZE_DISGUISE_EQUIPMENT); ++ return !itemstack.isGazeDisguise(player, target); + } else { + return true; + } ++ }; ++ /** @deprecated Neo: use {@link #PLAYER_NOT_WEARING_DISGUISE_ITEM_FOR_TARGET} with target info instead */ ++ @Deprecated ++ public static final Predicate PLAYER_NOT_WEARING_DISGUISE_ITEM = p_379074_ -> { ++ return PLAYER_NOT_WEARING_DISGUISE_ITEM_FOR_TARGET.test(p_379074_, null); + }; + private final AttributeMap attributes; + private final CombatTracker combatTracker = new CombatTracker(this); +@@ -268,6 +_,14 @@ + EquipmentSlot.class + ); protected float appliedScale = 1.0F; + /** + * This field stores information about damage dealt to this entity. + * a new {@link net.neoforged.neoforge.common.damagesource.DamageContainer} is instantiated + * via {@link #hurt(DamageSource, float)} after invulnerability checks, and is removed from + * the stack before the method's return. -+ **/ ++ **/ + @Nullable + protected java.util.Stack damageContainers = new java.util.Stack<>(); protected LivingEntity(EntityType p_20966_, Level p_20967_) { super(p_20966_, p_20967_); -@@ -320,7 +_,9 @@ +@@ -334,7 +_,9 @@ .add(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE) .add(Attributes.WATER_MOVEMENT_EFFICIENCY) .add(Attributes.MOVEMENT_EFFICIENCY) @@ -47,17 +56,17 @@ } @Override -@@ -348,7 +_,8 @@ +@@ -362,7 +_,8 @@ float f = (float)Mth.ceil((double)this.fallDistance - d7); double d4 = Math.min((double)(0.2F + f / 15.0F), 2.5); int i = (int)(150.0 * d4); -- ((ServerLevel)this.level()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, p_20992_), d0, d1, d2, i, 0.0, 0.0, 0.0, 0.15F); +- serverlevel.sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, p_20992_), d0, d1, d2, i, 0.0, 0.0, 0.0, 0.15F); + if (!p_20992_.addLandingEffects((ServerLevel) this.level(), p_20993_, p_20992_, this, i)) + ((ServerLevel)this.level()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, p_20992_).setPos(p_20993_), d0, d1, d2, i, 0.0, 0.0, 0.0, 0.15F); } } -@@ -358,6 +_,7 @@ +@@ -372,6 +_,7 @@ } } @@ -65,7 +74,7 @@ public final boolean canBreatheUnderwater() { return this.getType().is(EntityTypeTags.CAN_BREATHE_UNDER_WATER); } -@@ -403,6 +_,9 @@ +@@ -418,6 +_,9 @@ } } @@ -75,7 +84,7 @@ if (this.isEyeInFluid(FluidTags.WATER) && !this.level().getBlockState(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())).is(Blocks.BUBBLE_COLUMN)) { boolean flag1 = !this.canBreatheUnderwater() -@@ -441,7 +_,7 @@ +@@ -456,7 +_,7 @@ } } @@ -84,16 +93,16 @@ this.extinguishFire(); } -@@ -772,7 +_,7 @@ +@@ -787,7 +_,7 @@ Holder holder = iterator.next(); MobEffectInstance mobeffectinstance = this.activeEffects.get(holder); if (!mobeffectinstance.tick(this, () -> this.onEffectUpdated(mobeffectinstance, true, null))) { - if (!this.level().isClientSide) { + if (!this.level().isClientSide && !net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.entity.living.MobEffectEvent.Expired(this, mobeffectinstance)).isCanceled()) { iterator.remove(); - this.onEffectRemoved(mobeffectinstance); + this.onEffectsRemoved(List.of(mobeffectinstance)); } -@@ -817,8 +_,9 @@ +@@ -832,8 +_,9 @@ List list = this.activeEffects .values() .stream() @@ -105,7 +114,7 @@ .toList(); this.entityData.set(DATA_EFFECT_PARTICLES, list); this.entityData.set(DATA_EFFECT_AMBIENCE_ID, areAllEffectsAmbient(this.activeEffects.values())); -@@ -858,6 +_,7 @@ +@@ -873,6 +_,7 @@ } } @@ -113,18 +122,23 @@ return d0; } -@@ -899,7 +_,9 @@ - - boolean flag; - for (flag = false; iterator.hasNext(); flag = true) { -- this.onEffectRemoved(iterator.next()); -+ MobEffectInstance effect = iterator.next(); -+ if(net.neoforged.neoforge.event.EventHooks.onEffectRemoved(this, effect, null)) continue; -+ this.onEffectRemoved(effect); - iterator.remove(); - } - -@@ -929,11 +_,12 @@ +@@ -908,8 +_,13 @@ + } else if (this.activeEffects.isEmpty()) { + return false; + } else { +- Map, MobEffectInstance> map = Maps.newHashMap(this.activeEffects); +- this.activeEffects.clear(); ++ Map, MobEffectInstance> map = new java.util.HashMap<>(this.activeEffects.size()); ++ for (Map.Entry, MobEffectInstance> entry : this.activeEffects.entrySet()) { ++ if (!net.neoforged.neoforge.event.EventHooks.onEffectRemoved(this, entry.getValue())) { ++ map.put(entry.getKey(), entry.getValue()); ++ } ++ } ++ map.keySet().forEach(this.activeEffects::remove); + this.onEffectsRemoved(map.values()); + return true; + } +@@ -937,11 +_,12 @@ } public boolean addEffect(MobEffectInstance p_147208_, @Nullable Entity p_147209_) { @@ -138,7 +152,7 @@ if (mobeffectinstance == null) { this.activeEffects.put(p_147208_.getEffect(), p_147208_); this.onEffectAdded(p_147208_, p_147209_); -@@ -949,6 +_,14 @@ +@@ -957,6 +_,14 @@ } } @@ -153,7 +167,7 @@ public boolean canBeAffected(MobEffectInstance p_21197_) { if (this.getType().is(EntityTypeTags.IMMUNE_TO_INFESTED)) { return !p_21197_.is(MobEffects.INFESTED); -@@ -962,7 +_,7 @@ +@@ -970,7 +_,7 @@ } public void forceAddEffect(MobEffectInstance p_147216_, @Nullable Entity p_147217_) { @@ -162,106 +176,92 @@ MobEffectInstance mobeffectinstance = this.activeEffects.put(p_147216_.getEffect(), p_147216_); if (mobeffectinstance == null) { this.onEffectAdded(p_147216_, p_147217_); -@@ -983,6 +_,7 @@ +@@ -991,6 +_,7 @@ } public boolean removeEffect(Holder p_316570_) { -+ if (net.neoforged.neoforge.event.EventHooks.onEffectRemoved(this, p_316570_, null)) return false; ++ if (net.neoforged.neoforge.event.EventHooks.onEffectRemoved(this, p_316570_)) return false; MobEffectInstance mobeffectinstance = this.removeEffectNoUpdate(p_316570_); if (mobeffectinstance != null) { - this.onEffectRemoved(mobeffectinstance); -@@ -1060,13 +_,26 @@ - } + this.onEffectsRemoved(List.of(mobeffectinstance)); +@@ -1072,6 +_,8 @@ } -+ public AtomicReference regainReason0 = new AtomicReference<>(RegainReason.CUSTOM); -+ -+ public void pushHealReason(EntityRegainHealthEvent.RegainReason regainReason) { -+ this.regainReason0.set(regainReason); -+ } -+ public void heal(float p_21116_) { + p_21116_ = net.neoforged.neoforge.event.EventHooks.onLivingHeal(this, p_21116_); + if (p_21116_ <= 0) return; float f = this.getHealth(); if (f > 0.0F) { this.setHealth(f + p_21116_); - } - } - -+ public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason) { -+ this.regainReason0.set(regainReason); -+ this.heal(f); -+ } -+ - public float getHealth() { - return this.entityData.get(DATA_HEALTH_ID); - } -@@ -1090,23 +_,30 @@ - } else if (p_21016_.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { +@@ -1099,11 +_,14 @@ + } else if (p_376460_.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; } else { -+ this.damageContainers.push(new net.neoforged.neoforge.common.damagesource.DamageContainer(p_21016_, p_21017_)); ++ this.damageContainers.push(new net.neoforged.neoforge.common.damagesource.DamageContainer(p_376460_, p_376610_)); + if (net.neoforged.neoforge.common.CommonHooks.onEntityIncomingDamage(this, this.damageContainers.peek())) return false; - if (this.isSleeping() && !this.level().isClientSide) { + if (this.isSleeping()) { this.stopSleeping(); } this.noActionTime = 0; -+ p_21017_ = this.damageContainers.peek().getNewDamage(); //Neo: enforce damage container as source of truth for damage amount - float f = p_21017_; ++ p_376610_ = this.damageContainers.peek().getNewDamage(); //Neo: enforce damage container as source of truth for damage amount + if (p_376610_ < 0.0F) { + p_376610_ = 0.0F; + } +@@ -1111,15 +_,19 @@ + float f = p_376610_; boolean flag = false; float f1 = 0.0F; -- if (p_21017_ > 0.0F && this.isDamageSourceBlocked(p_21016_)) { -- this.hurtCurrentlyUsedShield(p_21017_); -- f1 = p_21017_; -- p_21017_ = 0.0F; +- if (p_376610_ > 0.0F && this.isDamageSourceBlocked(p_376460_)) { +- this.hurtCurrentlyUsedShield(p_376610_); +- f1 = p_376610_; +- p_376610_ = 0.0F; + net.neoforged.neoforge.event.entity.living.LivingShieldBlockEvent ev; -+ if (p_21017_ > 0.0F && (ev = net.neoforged.neoforge.common.CommonHooks.onDamageBlock(this, this.damageContainers.peek(), this.isDamageSourceBlocked(p_21016_))).getBlocked()) { ++ if (p_376610_ > 0.0F && (ev = net.neoforged.neoforge.common.CommonHooks.onDamageBlock(this, this.damageContainers.peek(), this.isDamageSourceBlocked(p_376460_))).getBlocked()) { + this.damageContainers.peek().setBlockedDamage(ev); -+ if(ev.shieldDamage() > 0) { ++ if (ev.shieldDamage() > 0) { + this.hurtCurrentlyUsedShield(ev.shieldDamage()); + } + f1 = ev.getBlockedDamage(); -+ p_21017_ = ev.getDamageContainer().getNewDamage(); - if (!p_21016_.is(DamageTypeTags.IS_PROJECTILE) && p_21016_.getDirectEntity() instanceof LivingEntity livingentity) { ++ p_376610_ = ev.getDamageContainer().getNewDamage(); + if (!p_376460_.is(DamageTypeTags.IS_PROJECTILE) && p_376460_.getDirectEntity() instanceof LivingEntity livingentity) { this.blockUsingShield(livingentity); } - flag = true; -+ flag = p_21017_ <= 0; ++ flag = p_376610_ <= 0; } - if (p_21016_.is(DamageTypeTags.IS_FREEZING) && this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { -@@ -1118,10 +_,12 @@ - p_21017_ *= 0.75F; + if (p_376460_.is(DamageTypeTags.IS_FREEZING) && this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { +@@ -1135,10 +_,12 @@ + if (Float.isNaN(p_376610_) || Float.isInfinite(p_376610_)) { + p_376610_ = Float.MAX_VALUE; } ++ this.damageContainers.peek().setNewDamage(p_376610_); //update container with vanilla changes -+ this.damageContainers.peek().setNewDamage(p_21017_); //update container with vanilla changes - this.walkAnimation.setSpeed(1.5F); boolean flag1 = true; - if ((float)this.invulnerableTime > 10.0F && !p_21016_.is(DamageTypeTags.BYPASSES_COOLDOWN)) { - if (p_21017_ <= this.lastHurt) { + if ((float)this.invulnerableTime > 10.0F && !p_376460_.is(DamageTypeTags.BYPASSES_COOLDOWN)) { + if (p_376610_ <= this.lastHurt) { + this.damageContainers.pop(); return false; } -@@ -1130,12 +_,13 @@ +@@ -1147,12 +_,13 @@ flag1 = false; } else { - this.lastHurt = p_21017_; + this.lastHurt = p_376610_; - this.invulnerableTime = 20; + this.invulnerableTime = this.damageContainers.peek().getPostAttackInvulnerabilityTicks(); - this.actuallyHurt(p_21016_, p_21017_); + this.actuallyHurt(p_376221_, p_376460_, p_376610_); this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -+ p_21017_ = this.damageContainers.peek().getNewDamage(); //update local with container value - Entity entity = p_21016_.getEntity(); ++ p_376610_ = this.damageContainers.peek().getNewDamage(); //update local with container value + Entity entity = p_376460_.getEntity(); if (entity != null) { if (entity instanceof LivingEntity livingentity1 -@@ -1147,9 +_,9 @@ +@@ -1164,9 +_,9 @@ if (entity instanceof Player player1) { this.lastHurtByPlayerTime = 100; this.lastHurtByPlayer = player1; @@ -273,40 +273,24 @@ this.lastHurtByPlayer = player; } else { this.lastHurtByPlayer = null; -@@ -1220,6 +_,7 @@ - CriteriaTriggers.PLAYER_HURT_ENTITY.trigger((ServerPlayer)entity, this, p_21016_, f, p_21017_, flag); +@@ -1237,6 +_,7 @@ + CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverplayer1, this, p_376460_, f, p_376610_, flag); } + this.damageContainers.pop(); return flag2; } } -@@ -1240,7 +_,7 @@ - +@@ -1259,7 +_,7 @@ for (InteractionHand interactionhand : InteractionHand.values()) { ItemStack itemstack1 = this.getItemInHand(interactionhand); -- if (itemstack1.is(Items.TOTEM_OF_UNDYING)) { -+ if (itemstack1.is(Items.TOTEM_OF_UNDYING) && net.neoforged.neoforge.common.CommonHooks.onLivingUseTotem(this, p_21263_, itemstack1, interactionhand)) { + deathprotection = itemstack1.get(DataComponents.DEATH_PROTECTION); +- if (deathprotection != null) { ++ if (deathprotection != null && net.neoforged.neoforge.common.CommonHooks.onLivingUseTotem(this, p_21263_, itemstack1, interactionhand)) { itemstack = itemstack1.copy(); itemstack1.shrink(1); break; -@@ -1249,13 +_,13 @@ - - if (itemstack != null) { - if (this instanceof ServerPlayer serverplayer) { -- serverplayer.awardStat(Stats.ITEM_USED.get(Items.TOTEM_OF_UNDYING)); -+ serverplayer.awardStat(Stats.ITEM_USED.get(Items.TOTEM_OF_UNDYING), 1); - CriteriaTriggers.USED_TOTEM.trigger(serverplayer, itemstack); - this.gameEvent(GameEvent.ITEM_INTERACT_FINISH); - } - - this.setHealth(1.0F); -- this.removeAllEffects(); -+ this.removeEffectsCuredBy(net.neoforged.neoforge.common.EffectCures.PROTECTED_BY_TOTEM); - this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 900, 1)); - this.addEffect(new MobEffectInstance(MobEffects.ABSORPTION, 100, 1)); - this.addEffect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 800, 0)); -@@ -1326,6 +_,7 @@ +@@ -1343,6 +_,7 @@ } public void die(DamageSource p_21014_) { @@ -314,45 +298,45 @@ if (!this.isRemoved() && !this.dead) { Entity entity = p_21014_.getEntity(); LivingEntity livingentity = this.getKillCredit(); -@@ -1361,7 +_,7 @@ - if (!this.level().isClientSide) { +@@ -1378,7 +_,7 @@ + if (this.level() instanceof ServerLevel serverlevel) { boolean flag = false; if (p_21269_ instanceof WitherBoss) { -- if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), p_21269_)) { +- if (serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, p_21269_)) { BlockPos blockpos = this.blockPosition(); BlockState blockstate = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level().getBlockState(blockpos).isAir() && blockstate.canSurvive(this.level(), blockpos)) { -@@ -1379,6 +_,7 @@ +@@ -1396,6 +_,7 @@ } protected void dropAllDeathLoot(ServerLevel p_348524_, DamageSource p_21192_) { + this.captureDrops(new java.util.ArrayList<>()); boolean flag = this.lastHurtByPlayerTime > 0; if (this.shouldDropLoot() && p_348524_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - this.dropFromLootTable(p_21192_, flag); -@@ -1387,6 +_,10 @@ + this.dropFromLootTable(p_348524_, p_21192_, flag); +@@ -1404,6 +_,10 @@ - this.dropEquipment(); - this.dropExperience(p_21192_.getEntity()); + this.dropEquipment(p_348524_); + this.dropExperience(p_348524_, p_21192_.getEntity()); + + Collection drops = captureDrops(null); + if (!net.neoforged.neoforge.common.CommonHooks.onLivingDrops(this, p_21192_, drops, lastHurtByPlayerTime > 0)) + drops.forEach(e -> level().addFreshEntity(e)); } - protected void dropEquipment() { -@@ -1399,7 +_,8 @@ + protected void dropEquipment(ServerLevel p_376330_) { +@@ -1415,7 +_,8 @@ this.isAlwaysExperienceDropper() - || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT) + || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && p_376909_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT) )) { -- ExperienceOrb.award(serverlevel, this.position(), this.getExperienceReward(serverlevel, p_345346_)); -+ int reward = net.neoforged.neoforge.event.EventHooks.getExperienceDrop(this, this.lastHurtByPlayer, this.getExperienceReward(serverlevel, p_345346_)); +- ExperienceOrb.award(p_376909_, this.position(), this.getExperienceReward(p_376909_, p_345346_)); ++ int reward = net.neoforged.neoforge.event.EventHooks.getExperienceDrop(this, this.lastHurtByPlayer, this.getExperienceReward(p_376909_, p_345346_)); + ExperienceOrb.award((ServerLevel) this.level(), this.position(), reward); } } -@@ -1440,6 +_,11 @@ +@@ -1496,6 +_,11 @@ } public void knockback(double p_147241_, double p_147242_, double p_147243_) { @@ -364,7 +348,7 @@ p_147241_ *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); if (!(p_147241_ <= 0.0)) { this.hasImpulse = true; -@@ -1521,15 +_,9 @@ +@@ -1569,15 +_,9 @@ } else { BlockPos blockpos = this.blockPosition(); BlockState blockstate = this.getInBlockState(); @@ -383,7 +367,27 @@ } } -@@ -1558,6 +_,11 @@ +@@ -1595,10 +_,18 @@ + return !this.isRemoved() && this.getHealth() > 0.0F; + } + ++ /** @deprecated Neo: use {@link #isLookingAtMe(LivingEntity, double, boolean, boolean, java.util.function.BiPredicate, DoubleSupplier...)} instead */ ++ @Deprecated + public boolean isLookingAtMe( + LivingEntity p_379420_, double p_379671_, boolean p_380253_, boolean p_380067_, Predicate p_380351_, DoubleSupplier... p_380073_ + ) { +- if (!p_380351_.test(p_379420_)) { ++ return isLookingAtMe(p_379420_, p_379671_, p_380253_, p_380067_, (observer, target) -> p_380351_.test(observer), p_380073_); ++ } ++ ++ public boolean isLookingAtMe( ++ LivingEntity p_379420_, double p_379671_, boolean p_380253_, boolean p_380067_, java.util.function.BiPredicate p_380351_, DoubleSupplier... p_380073_ ++ ) { ++ if (!p_380351_.test(p_379420_, this)) { + return false; + } else { + Vec3 vec3 = p_379420_.getViewVector(1.0F).normalize(); +@@ -1630,6 +_,11 @@ @Override public boolean causeFallDamage(float p_147187_, float p_147188_, DamageSource p_147189_) { @@ -395,7 +399,7 @@ boolean flag = super.causeFallDamage(p_147187_, p_147188_, p_147189_); int i = this.calculateFallDamage(p_147187_, p_147188_); if (i > 0) { -@@ -1585,9 +_,10 @@ +@@ -1657,9 +_,10 @@ int i = Mth.floor(this.getX()); int j = Mth.floor(this.getY() - 0.2F); int k = Mth.floor(this.getZ()); @@ -408,7 +412,7 @@ this.playSound(soundtype.getFallSound(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F); } } -@@ -1616,6 +_,8 @@ +@@ -1688,6 +_,8 @@ if (!(p_330394_ <= 0.0F)) { int i = (int)Math.max(1.0F, p_330394_ / 4.0F); @@ -416,8 +420,8 @@ + if (true) return; //Neo: Invalidates the loop. Armor damage happens in common hook. for (EquipmentSlot equipmentslot : p_331314_) { ItemStack itemstack = this.getItemBySlot(equipmentslot); - if (itemstack.getItem() instanceof ArmorItem && itemstack.canBeHurtBy(p_330843_)) { -@@ -1648,6 +_,7 @@ + Equippable equippable = itemstack.get(DataComponents.EQUIPPABLE); +@@ -1721,6 +_,7 @@ p_21194_ = Math.max(f / 25.0F, 0.0F); float f2 = f1 - p_21194_; if (f2 > 0.0F && f2 < 3.4028235E37F) { @@ -425,7 +429,7 @@ if (this instanceof ServerPlayer) { ((ServerPlayer)this).awardStat(Stats.DAMAGE_RESISTED, Math.round(f2 * 10.0F)); } else if (p_21193_.getEntity() instanceof ServerPlayer) { -@@ -1670,6 +_,7 @@ +@@ -1743,6 +_,7 @@ if (f3 > 0.0F) { p_21194_ = CombatRules.getDamageAfterMagicAbsorb(p_21194_, f3); @@ -433,10 +437,10 @@ } return p_21194_; -@@ -1679,11 +_,14 @@ +@@ -1752,11 +_,14 @@ - protected void actuallyHurt(DamageSource p_21240_, float p_21241_) { - if (!this.isInvulnerableTo(p_21240_)) { + protected void actuallyHurt(ServerLevel p_376745_, DamageSource p_21240_, float p_21241_) { + if (!this.isInvulnerableTo(p_376745_, p_21240_)) { - p_21241_ = this.getDamageAfterArmorAbsorb(p_21240_, p_21241_); - p_21241_ = this.getDamageAfterMagicAbsorb(p_21240_, p_21241_); - float f1 = Math.max(p_21241_ - this.getAbsorptionAmount(), 0.0F); @@ -453,7 +457,7 @@ if (f > 0.0F && f < 3.4028235E37F && p_21240_.getEntity() instanceof ServerPlayer serverplayer) { serverplayer.awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f * 10.0F)); } -@@ -1691,9 +_,10 @@ +@@ -1764,9 +_,10 @@ if (f1 != 0.0F) { this.getCombatTracker().recordDamage(p_21240_, f1); this.setHealth(this.getHealth() - f1); @@ -465,7 +469,7 @@ } } -@@ -1747,6 +_,8 @@ +@@ -1820,6 +_,8 @@ } public void swing(InteractionHand p_21012_, boolean p_21013_) { @@ -474,7 +478,7 @@ if (!this.swinging || this.swingTime >= this.getCurrentSwingDuration() / 2 || this.swingTime < 0) { this.swingTime = -1; this.swinging = true; -@@ -1859,8 +_,10 @@ +@@ -1933,8 +_,10 @@ private void swapHandItems() { ItemStack itemstack = this.getItemBySlot(EquipmentSlot.OFFHAND); @@ -487,7 +491,7 @@ } @Override -@@ -2064,15 +_,18 @@ +@@ -2152,15 +_,18 @@ } this.hasImpulse = true; @@ -508,42 +512,54 @@ } protected float getWaterSlowDown() { -@@ -2097,7 +_,8 @@ - } - +@@ -2184,7 +_,7 @@ + public void travel(Vec3 p_21280_) { + if (this.isControlledByLocalInstance()) { FluidState fluidstate = this.level().getFluidState(this.blockPosition()); -- if (this.isInWater() && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { +- if ((this.isInWater() || this.isInLava()) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { + if ((this.isInWater() || (this.isInFluidType(fluidstate) && fluidstate.getFluidType() != net.neoforged.neoforge.common.NeoForgeMod.LAVA_TYPE.value())) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { -+ if (this.isInWater() || (this.isInFluidType(fluidstate) && !this.moveInFluid(fluidstate, p_21280_, d0))) { - double d9 = this.getY(); - float f4 = this.isSprinting() ? 0.9F : this.getWaterSlowDown(); - float f5 = 0.02F; -@@ -2115,6 +_,7 @@ - f4 = 0.96F; - } + this.travelInFluid(p_21280_); + } else if (this.isFallFlying()) { + this.travelFallFlying(); +@@ -2196,7 +_,7 @@ + + private void travelInAir(Vec3 p_362457_) { + BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); +- float f = this.onGround() ? this.level().getBlockState(blockpos).getBlock().getFriction() : 1.0F; ++ float f = this.onGround() ? this.level().getBlockState(blockpos).getFriction(this.level(), blockpos, this) : 1.0F; + float f1 = f * 0.91F; + Vec3 vec3 = this.handleRelativeFrictionAndCalculateMovement(p_362457_, f); + double d0 = vec3.y; +@@ -2219,11 +_,19 @@ + } + } -+ f5 *= (float)this.getAttributeValue(net.neoforged.neoforge.common.NeoForgeMod.SWIM_SPEED); - this.moveRelative(f5, p_21280_); - this.move(MoverType.SELF, this.getDeltaMovement()); - Vec3 vec36 = this.getDeltaMovement(); -@@ -2128,6 +_,7 @@ - if (this.horizontalCollision && this.isFree(vec32.x, vec32.y + 0.6F - this.getY() + d9, vec32.z)) { - this.setDeltaMovement(vec32.x, 0.3F, vec32.z); - } -+ } - } else if (this.isInLava() && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { - double d8 = this.getY(); - this.moveRelative(0.02F, p_21280_); -@@ -2190,7 +_,7 @@ - } - } else { - BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); -- float f2 = this.level().getBlockState(blockpos).getBlock().getFriction(); -+ float f2 = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getFriction(level(), this.getBlockPosBelowThatAffectsMyMovement(), this); - float f3 = this.onGround() ? f2 * 0.91F : 0.91F; - Vec3 vec35 = this.handleRelativeFrictionAndCalculateMovement(p_21280_, f2); - double d2 = vec35.y; -@@ -2284,7 +_,7 @@ ++ /** ++ * @deprecated Neo: use {@link #travelInFluid(Vec3, FluidState)} instead ++ */ ++ @Deprecated + private void travelInFluid(Vec3 p_365480_) { ++ travelInFluid(p_365480_, net.minecraft.world.level.material.Fluids.EMPTY.defaultFluidState()); ++ } ++ ++ private void travelInFluid(Vec3 p_365480_, FluidState fluidState) { + boolean flag = this.getDeltaMovement().y <= 0.0; + double d0 = this.getY(); + double d1 = this.getEffectiveGravity(); +- if (this.isInWater()) { ++ if (this.isInWater() || (this.isInFluidType(fluidState) && !this.moveInFluid(fluidState, p_365480_, d1))) { + float f = this.isSprinting() ? 0.9F : this.getWaterSlowDown(); + float f1 = 0.02F; + float f2 = (float)this.getAttributeValue(Attributes.WATER_MOVEMENT_EFFICIENCY); +@@ -2240,6 +_,7 @@ + f = 0.96F; + } + ++ f1 *= (float)this.getAttributeValue(net.neoforged.neoforge.common.NeoForgeMod.SWIM_SPEED); + this.moveRelative(f1, p_365480_); + this.move(MoverType.SELF, this.getDeltaMovement()); + Vec3 vec3 = this.getDeltaMovement(); +@@ -2389,7 +_,7 @@ double d0 = Mth.clamp(p_21298_.x, -0.15F, 0.15F); double d1 = Mth.clamp(p_21298_.z, -0.15F, 0.15F); double d2 = Math.max(p_21298_.y, -0.15F); @@ -552,7 +568,7 @@ d2 = 0.0; } -@@ -2466,6 +_,7 @@ +@@ -2574,6 +_,7 @@ }; ItemStack itemstack1 = this.getItemBySlot(equipmentslot); if (this.equipmentHasChanged(itemstack, itemstack1)) { @@ -560,8 +576,8 @@ if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -@@ -2637,6 +_,9 @@ - this.level().getProfiler().push("jump"); +@@ -2733,6 +_,9 @@ + profilerfiller.push("jump"); if (this.jumping && this.isAffectedByFluids()) { double d3; + net.neoforged.neoforge.fluids.FluidType fluidType = this.getMaxHeightFluidType(); @@ -570,7 +586,7 @@ if (this.isInLava()) { d3 = this.getFluidHeight(FluidTags.LAVA); } else { -@@ -2647,15 +_,17 @@ +@@ -2743,15 +_,17 @@ double d4 = this.getFluidJumpThreshold(); if (!flag || this.onGround() && !(d3 > d4)) { if (!this.isInLava() || this.onGround() && !(d3 > d4)) { @@ -590,16 +606,7 @@ } } else { this.noJumpDelay = 0; -@@ -2720,6 +_,8 @@ - boolean flag = this.getSharedFlag(7); - if (flag && !this.onGround() && !this.isPassenger() && !this.hasEffect(MobEffects.LEVITATION)) { - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.CHEST); -+ flag = itemstack.canElytraFly(this) && itemstack.elytraFlightTick(this, this.fallFlyTicks); -+ if (false) //Neo: Moved to ElytraItem - if (itemstack.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(itemstack)) { - flag = true; - int i = this.fallFlyTicks + 1; -@@ -2979,8 +_,11 @@ +@@ -3104,8 +_,11 @@ private void updatingUsingItem() { if (this.isUsingItem()) { @@ -613,7 +620,7 @@ this.updateUsingItem(this.useItem); } else { this.stopUsingItem(); -@@ -2989,12 +_,15 @@ +@@ -3114,8 +_,11 @@ } protected void updateUsingItem(ItemStack p_147201_) { @@ -621,16 +628,12 @@ + this.useItemRemaining = net.neoforged.neoforge.event.EventHooks.onItemUseTick(this, p_147201_, this.getUseItemRemainingTicks()); + if (this.getUseItemRemainingTicks() > 0) p_147201_.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); - if (this.shouldTriggerItemUseEffects()) { - this.triggerItemUseEffects(p_147201_, 5); - } - - if (--this.useItemRemaining == 0 && !this.level().isClientSide && !p_147201_.useOnRelease()) { + if (--this.useItemRemaining <= 0 && !this.level().isClientSide && !p_147201_.useOnRelease()) { this.completeUsingItem(); } } -@@ -3029,8 +_,10 @@ +@@ -3143,8 +_,10 @@ public void startUsingItem(InteractionHand p_21159_) { ItemStack itemstack = this.getItemInHand(p_21159_); if (!itemstack.isEmpty() && !this.isUsingItem()) { @@ -642,17 +645,17 @@ if (!this.level().isClientSide) { this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(2, p_21159_ == InteractionHand.OFF_HAND); -@@ -3111,7 +_,8 @@ +@@ -3207,7 +_,8 @@ + this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { - this.triggerItemUseEffects(this.useItem, 16); - ItemStack itemstack = this.useItem.finishUsingItem(this.level(), this); + ItemStack copy = this.useItem.copy(); + ItemStack itemstack = net.neoforged.neoforge.event.EventHooks.onItemUseFinish(this, copy, getUseItemRemainingTicks(), this.useItem.finishUsingItem(this.level(), this)); if (itemstack != this.useItem) { this.setItemInHand(interactionhand, itemstack); } -@@ -3136,7 +_,11 @@ +@@ -3235,7 +_,11 @@ public void releaseUsingItem() { if (!this.useItem.isEmpty()) { @@ -664,7 +667,7 @@ if (this.useItem.useOnRelease()) { this.updatingUsingItem(); } -@@ -3146,6 +_,7 @@ +@@ -3245,6 +_,7 @@ } public void stopUsingItem() { @@ -672,16 +675,16 @@ if (!this.level().isClientSide) { boolean flag = this.isUsingItem(); this.setLivingEntityFlag(1, false); -@@ -3161,7 +_,7 @@ - public boolean isBlocking() { +@@ -3265,7 +_,7 @@ + public ItemStack getItemBlockingWith() { if (this.isUsingItem() && !this.useItem.isEmpty()) { Item item = this.useItem.getItem(); -- return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem, this) - this.useItemRemaining >= 5; -+ return !this.useItem.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHIELD_BLOCK) ? false : item.getUseDuration(this.useItem, this) - this.useItemRemaining >= 5; - } else { - return false; - } -@@ -3302,8 +_,8 @@ +- if (item.getUseAnimation(this.useItem) != ItemUseAnimation.BLOCK) { ++ if (!this.useItem.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHIELD_BLOCK)) { + return null; + } else { + return item.getUseDuration(this.useItem, this) - this.useItemRemaining < 5 ? null : this.useItem; +@@ -3410,8 +_,8 @@ } BlockState blockstate = this.level().getBlockState(p_21141_); @@ -692,11 +695,11 @@ } this.setPose(Pose.SLEEPING); -@@ -3318,15 +_,17 @@ +@@ -3426,15 +_,17 @@ } private boolean checkBedExists() { -- return this.getSleepingPos().map(p_352707_ -> this.level().getBlockState(p_352707_).getBlock() instanceof BedBlock).orElse(false); +- return this.getSleepingPos().map(p_381383_ -> this.level().getBlockState(p_381383_).getBlock() instanceof BedBlock).orElse(false); + // Neo: Overwrite the vanilla instanceof BedBlock check with isBed and fire the CanContinueSleepingEvent. + boolean hasBed = this.getSleepingPos().map(pos -> this.level().getBlockState(pos).isBed(this.level(), pos, this)).orElse(false); + return net.neoforged.neoforge.event.EventHooks.canEntityContinueSleeping(this, hasBed ? null : Player.BedSleepingProblem.NOT_POSSIBLE_HERE); @@ -713,7 +716,7 @@ Vec3 vec31 = BedBlock.findStandUpPosition(this.getType(), this.level(), p_261435_, direction, this.getYRot()).orElseGet(() -> { BlockPos blockpos = p_261435_.above(); return new Vec3((double)blockpos.getX() + 0.5, (double)blockpos.getY() + 0.1, (double)blockpos.getZ() + 0.5); -@@ -3347,7 +_,9 @@ +@@ -3455,7 +_,9 @@ @Nullable public Direction getBedOrientation() { BlockPos blockpos = this.getSleepingPos().orElse(null); @@ -724,7 +727,7 @@ } @Override -@@ -3356,11 +_,11 @@ +@@ -3464,7 +_,7 @@ } public ItemStack getProjectile(ItemStack p_21272_) { @@ -732,61 +735,17 @@ + return net.neoforged.neoforge.common.CommonHooks.getProjectile(this, p_21272_, ItemStack.EMPTY); } - public final ItemStack eat(Level p_21067_, ItemStack p_21068_) { -- FoodProperties foodproperties = p_21068_.get(DataComponents.FOOD); -+ FoodProperties foodproperties = p_21068_.getFoodProperties(this); - return foodproperties != null ? this.eat(p_21067_, p_21068_, foodproperties) : p_21068_; - } - -@@ -3411,6 +_,38 @@ - return p_320526_ == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND; + private static byte entityEventForEquipmentBreak(EquipmentSlot p_21267_) { +@@ -3519,6 +_,8 @@ } -+ /** -+ * Neo: Removes all potion effects that have the given {@link net.neoforged.neoforge.common.EffectCure} in their set of cures -+ * @param cure the EffectCure being used -+ */ -+ public boolean removeEffectsCuredBy(net.neoforged.neoforge.common.EffectCure cure) { -+ if (this.level().isClientSide) -+ return false; -+ boolean ret = false; -+ Iterator itr = this.activeEffects.values().iterator(); -+ while (itr.hasNext()) { -+ MobEffectInstance effect = itr.next(); -+ if (effect.getCures().contains(cure) && !net.neoforged.neoforge.event.EventHooks.onEffectRemoved(this, effect, cure)) { -+ this.onEffectRemoved(effect); -+ itr.remove(); -+ ret = true; -+ this.effectsDirty = true; -+ } -+ } -+ return ret; -+ } -+ -+ /** -+ * Neo: Returns true if the entity's rider (EntityPlayer) should face forward when mounted. -+ * currently only used in vanilla code by pigs. -+ * -+ * @param player The player who is riding the entity. -+ * @return If the player should orient the same direction as this entity. -+ */ -+ public boolean shouldRiderFaceForward(Player player) { -+ return this instanceof net.minecraft.world.entity.animal.Pig; -+ } -+ - @Override - public AABB getBoundingBoxForCulling() { - if (this.getItemBySlot(EquipmentSlot.HEAD).is(Items.DRAGON_HEAD)) { -@@ -3422,6 +_,8 @@ - } - - public EquipmentSlot getEquipmentSlotForItem(ItemStack p_147234_) { + public final EquipmentSlot getEquipmentSlotForItem(ItemStack p_147234_) { + final EquipmentSlot slot = p_147234_.getEquipmentSlot(); + if (slot != null) return slot; // FORGE: Allow modders to set a non-default equipment slot for a stack; e.g. a non-armor chestplate-slot item - Equipable equipable = Equipable.get(p_147234_); - if (equipable != null) { - EquipmentSlot equipmentslot = equipable.getEquipmentSlot(); -@@ -3507,7 +_,7 @@ + Equippable equippable = p_147234_.get(DataComponents.EQUIPPABLE); + return equippable != null && this.canUseSlot(equippable.slot()) ? equippable.slot() : EquipmentSlot.MAINHAND; + } +@@ -3604,7 +_,7 @@ } public boolean canDisableShield() { diff --git a/patches/net/minecraft/world/entity/Mob.java.patch b/patches/net/minecraft/world/entity/Mob.java.patch index 5ed8d6f8..715ee233 100644 --- a/patches/net/minecraft/world/entity/Mob.java.patch +++ b/patches/net/minecraft/world/entity/Mob.java.patch @@ -1,16 +1,18 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -131,6 +_,9 @@ +@@ -135,6 +_,11 @@ private Leashable.LeashData leashData; private BlockPos restrictCenter = BlockPos.ZERO; private float restrictRadius = -1.0F; + @Nullable -+ private MobSpawnType spawnType; ++ private EntitySpawnReason spawnType; + private boolean spawnCancelled = false; ++ /** Neo: Prevent immediate spawning from conversions to capture conversion results for events */ ++ protected boolean preventConversionSpawns = false; protected Mob(EntityType p_21368_, Level p_21369_) { super(p_21368_, p_21369_); -@@ -237,7 +_,10 @@ +@@ -241,7 +_,10 @@ } public void setTarget(@Nullable LivingEntity p_21544_) { @@ -22,7 +24,7 @@ } @Override -@@ -346,6 +_,12 @@ +@@ -344,6 +_,12 @@ if (!this.level().isClientSide && this.tickCount % 5 == 0) { this.updateControlFlags(); } @@ -30,12 +32,12 @@ + // Neo: Animal armor tick patch + if (this.canUseSlot(EquipmentSlot.BODY)) { + ItemStack stack = this.getBodyArmorItem(); -+ if (isBodyArmorItem(stack)) stack.onAnimalArmorTick(level(), this); ++ if (stack.has(DataComponents.EQUIPPABLE)) stack.onAnimalArmorTick(level(), this); + } } protected void updateControlFlags() { -@@ -425,6 +_,9 @@ +@@ -423,6 +_,9 @@ if (this.isNoAi()) { p_21484_.putBoolean("NoAI", this.isNoAi()); } @@ -45,14 +47,14 @@ } @Override -@@ -484,6 +_,14 @@ +@@ -482,6 +_,14 @@ } this.setNoAi(p_21450_.getBoolean("NoAI")); + + if (p_21450_.contains("neoforge:spawn_type")) { + try { -+ this.spawnType = MobSpawnType.valueOf(p_21450_.getString("neoforge:spawn_type")); ++ this.spawnType = EntitySpawnReason.valueOf(p_21450_.getString("neoforge:spawn_type")); + } catch (Exception ex) { + p_21450_.remove("neoforge:spawn_type"); + } @@ -60,24 +62,22 @@ } @Override -@@ -539,7 +_,7 @@ +@@ -534,7 +_,7 @@ && this.canPickUpLoot() && this.isAlive() && !this.dead -- && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ && net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this)) { +- && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ && net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, this)) { Vec3i vec3i = this.getPickupReach(); for (ItemEntity itementity : this.level() -@@ -666,6 +_,10 @@ - - private double getApproximateAttackDamageWithItem(ItemStack p_330413_) { - ItemAttributeModifiers itemattributemodifiers = p_330413_.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); -+ +@@ -666,6 +_,8 @@ + private double getApproximateAttributeWith(ItemStack p_371461_, Holder p_371421_, EquipmentSlot p_371891_) { + double d0 = this.getAttributes().hasAttribute(p_371421_) ? this.getAttributeBaseValue(p_371421_) : 0.0; + ItemAttributeModifiers itemattributemodifiers = p_371461_.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); + // Neo: Respect gameplay modifiers -+ itemattributemodifiers = p_330413_.getAttributeModifiers(); -+ - return itemattributemodifiers.compute(this.getAttributeBaseValue(Attributes.ATTACK_DAMAGE), EquipmentSlot.MAINHAND); ++ itemattributemodifiers = p_371461_.getAttributeModifiers(); + return itemattributemodifiers.compute(d0, p_371891_); } @@ -701,6 +_,7 @@ @@ -88,7 +88,7 @@ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { this.discard(); } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { -@@ -1133,6 +_,11 @@ +@@ -1127,6 +_,11 @@ } } @@ -98,17 +98,25 @@ + @Deprecated + @org.jetbrains.annotations.ApiStatus.OverrideOnly @Nullable - public SpawnGroupData finalizeSpawn(ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, MobSpawnType p_21436_, @Nullable SpawnGroupData p_21437_) { - RandomSource randomsource = p_21434_.getRandom(); -@@ -1144,6 +_,7 @@ + public SpawnGroupData finalizeSpawn( + ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, EntitySpawnReason p_363352_, @Nullable SpawnGroupData p_21437_ +@@ -1140,6 +_,7 @@ } this.setLeftHanded(randomsource.nextFloat() < 0.05F); -+ this.spawnType = p_21436_; ++ this.spawnType = p_363352_; return p_21437_; } -@@ -1470,14 +_,24 @@ +@@ -1281,6 +_,7 @@ + } else { + p_371709_.type().convert(this, t, p_371709_); + p_371266_.finalizeConversion(t); ++ if (!preventConversionSpawns) + if (this.level() instanceof ServerLevel serverlevel) { + serverlevel.addFreshEntity(t); + } +@@ -1452,14 +_,24 @@ } @Override @@ -135,19 +143,19 @@ public void removeFreeWill() { this.removeAllGoals(p_351790_ -> true); @@ -1503,5 +_,40 @@ - public ItemStack getPickResult() { - SpawnEggItem spawneggitem = SpawnEggItem.byId(this.getType()); - return spawneggitem == null ? null : new ItemStack(spawneggitem); + @VisibleForTesting + public float[] getArmorDropChances() { + return this.armorDropChances; + } + + /** -+ * Returns the type of spawn that created this mob, if applicable. -+ * If it could not be determined, this will return null. -+ *

-+ * This is set via {@link Mob#finalizeSpawn}, so you should not call this from within that method, instead using the parameter. -+ */ ++ * Returns the type of spawn that created this mob, if applicable. ++ * If it could not be determined, this will return null. ++ *

++ * This is set via {@link Mob#finalizeSpawn}, so you should not call this from within that method, instead using the parameter. ++ */ + @Nullable -+ public final MobSpawnType getSpawnType() { ++ public final EntitySpawnReason getSpawnType() { + return this.spawnType; + } + diff --git a/patches/net/minecraft/world/entity/Shearable.java.patch b/patches/net/minecraft/world/entity/Shearable.java.patch index 251e6be5..58aef72f 100644 --- a/patches/net/minecraft/world/entity/Shearable.java.patch +++ b/patches/net/minecraft/world/entity/Shearable.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/Shearable.java +++ b/net/minecraft/world/entity/Shearable.java -@@ -2,8 +_,20 @@ - +@@ -4,8 +_,20 @@ import net.minecraft.sounds.SoundSource; + import net.minecraft.world.item.ItemStack; -public interface Shearable { +/** @@ -11,13 +11,13 @@ +@Deprecated +public interface Shearable extends net.neoforged.neoforge.common.IShearable { + /** -+ * @deprecated Neo: Use {@link net.neoforged.neoforge.common.IShearable#onSheared(net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos, int)} instead. ++ * @deprecated Neo: Use {@link net.neoforged.neoforge.common.IShearable#onSheared(net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos)} instead. + */ + @Deprecated - void shear(SoundSource p_21749_); + void shear(ServerLevel p_376429_, SoundSource p_21749_, ItemStack p_372963_); + /** -+ * @deprecated Neo: Use {@link net.neoforged.neoforge.common.IShearable#isShearable(net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos)} instead. ++ * @deprecated Neo: Use {@link net.neoforged.neoforge.common.IShearable#isShearable(net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos)} instead. + */ + @Deprecated boolean readyForShearing(); diff --git a/patches/net/minecraft/world/entity/SpawnPlacements.java.patch b/patches/net/minecraft/world/entity/SpawnPlacements.java.patch index 0be5926d..4717f19f 100644 --- a/patches/net/minecraft/world/entity/SpawnPlacements.java.patch +++ b/patches/net/minecraft/world/entity/SpawnPlacements.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/SpawnPlacements.java +++ b/net/minecraft/world/entity/SpawnPlacements.java -@@ -46,6 +_,10 @@ +@@ -47,6 +_,10 @@ public class SpawnPlacements { private static final Map, SpawnPlacements.Data> DATA_BY_TYPE = Maps.newHashMap(); @@ -11,13 +11,13 @@ private static void register( EntityType p_21755_, SpawnPlacementType p_321847_, Heightmap.Types p_21757_, SpawnPlacements.SpawnPredicate p_21758_ ) { -@@ -73,7 +_,13 @@ - EntityType p_217075_, ServerLevelAccessor p_217076_, MobSpawnType p_217077_, BlockPos p_217078_, RandomSource p_217079_ +@@ -74,7 +_,13 @@ + EntityType p_217075_, ServerLevelAccessor p_217076_, EntitySpawnReason p_361433_, BlockPos p_217078_, RandomSource p_217079_ ) { SpawnPlacements.Data spawnplacements$data = DATA_BY_TYPE.get(p_217075_); -- return spawnplacements$data == null || ((SpawnPredicate)spawnplacements$data.predicate).test(p_217075_, p_217076_, p_217077_, p_217078_, p_217079_); -+ boolean vanillaResult = spawnplacements$data == null || spawnplacements$data.predicate.test((EntityType)p_217075_, p_217076_, p_217077_, p_217078_, p_217079_); -+ return net.neoforged.neoforge.event.EventHooks.checkSpawnPlacements(p_217075_, p_217076_, p_217077_, p_217078_, p_217079_, vanillaResult); +- return spawnplacements$data == null || ((SpawnPredicate)spawnplacements$data.predicate).test(p_217075_, p_217076_, p_361433_, p_217078_, p_217079_); ++ boolean vanillaResult = spawnplacements$data == null || spawnplacements$data.predicate.test((EntityType)p_217075_, p_217076_, p_361433_, p_217078_, p_217079_); ++ return net.neoforged.neoforge.event.EventHooks.checkSpawnPlacements(p_217075_, p_217076_, p_361433_, p_217078_, p_217079_, vanillaResult); + } + + // Neo: Added to allow for checking if an entity has a spawn placement @@ -26,10 +26,10 @@ } static { -@@ -168,5 +_,16 @@ +@@ -183,5 +_,16 @@ @FunctionalInterface public interface SpawnPredicate { - boolean test(EntityType p_217081_, ServerLevelAccessor p_217082_, MobSpawnType p_217083_, BlockPos p_217084_, RandomSource p_217085_); + boolean test(EntityType p_217081_, ServerLevelAccessor p_217082_, EntitySpawnReason p_363558_, BlockPos p_217084_, RandomSource p_217085_); + } + + /** diff --git a/patches/net/minecraft/world/entity/TamableAnimal.java.patch b/patches/net/minecraft/world/entity/TamableAnimal.java.patch index e55032dd..f7af6e69 100644 --- a/patches/net/minecraft/world/entity/TamableAnimal.java.patch +++ b/patches/net/minecraft/world/entity/TamableAnimal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/TamableAnimal.java +++ b/net/minecraft/world/entity/TamableAnimal.java -@@ -220,11 +_,15 @@ +@@ -221,13 +_,16 @@ @Override public void die(DamageSource p_21809_) { @@ -9,11 +9,13 @@ + super.die(p_21809_); + + if (this.dead) - if (!this.level().isClientSide && this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES) && this.getOwner() instanceof ServerPlayer) { -- this.getOwner().sendSystemMessage(this.getCombatTracker().getDeathMessage()); -+ this.getOwner().sendSystemMessage(deathMessage); + if (this.level() instanceof ServerLevel serverlevel + && serverlevel.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES) + && this.getOwner() instanceof ServerPlayer serverplayer) { +- serverplayer.sendSystemMessage(this.getCombatTracker().getDeathMessage()); ++ serverplayer.sendSystemMessage(deathMessage); } - +- - super.die(p_21809_); } diff --git a/patches/net/minecraft/world/entity/ai/attributes/Attribute.java.patch b/patches/net/minecraft/world/entity/ai/attributes/Attribute.java.patch new file mode 100644 index 00000000..3863a37e --- /dev/null +++ b/patches/net/minecraft/world/entity/ai/attributes/Attribute.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/world/entity/ai/attributes/Attribute.java ++++ b/net/minecraft/world/entity/ai/attributes/Attribute.java +@@ -9,7 +_,7 @@ + import net.minecraft.network.codec.ByteBufCodecs; + import net.minecraft.network.codec.StreamCodec; + +-public class Attribute { ++public class Attribute implements net.neoforged.neoforge.common.extensions.IAttributeExtension { + public static final Codec> CODEC = BuiltInRegistries.ATTRIBUTE.holderByNameCodec(); + public static final StreamCodec> STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.ATTRIBUTE); + private final double defaultValue; +@@ -50,6 +_,21 @@ + + public ChatFormatting getStyle(boolean p_347715_) { + return this.sentiment.getStyle(p_347715_); ++ } ++ ++ // Neo: Patch in the default implementation of IAttributeExtension#getMergedStyle since we need access to Attribute#sentiment ++ ++ protected static final net.minecraft.network.chat.TextColor MERGED_RED = net.minecraft.network.chat.TextColor.fromRgb(0xF93131); ++ protected static final net.minecraft.network.chat.TextColor MERGED_BLUE = net.minecraft.network.chat.TextColor.fromRgb(0x7A7AF9); ++ protected static final net.minecraft.network.chat.TextColor MERGED_GRAY = net.minecraft.network.chat.TextColor.fromRgb(0xCCCCCC); ++ ++ @Override ++ public net.minecraft.network.chat.TextColor getMergedStyle(boolean isPositive) { ++ return switch (this.sentiment) { ++ case POSITIVE -> isPositive ? MERGED_BLUE : MERGED_RED; ++ case NEGATIVE -> isPositive ? MERGED_RED : MERGED_BLUE; ++ case NEUTRAL -> MERGED_GRAY; ++ }; + } + + public static enum Sentiment { diff --git a/patches/net/minecraft/world/entity/ai/attributes/Attributes.java.patch b/patches/net/minecraft/world/entity/ai/attributes/Attributes.java.patch new file mode 100644 index 00000000..af4927cc --- /dev/null +++ b/patches/net/minecraft/world/entity/ai/attributes/Attributes.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/entity/ai/attributes/Attributes.java ++++ b/net/minecraft/world/entity/ai/attributes/Attributes.java +@@ -45,7 +_,7 @@ + "jump_strength", new RangedAttribute("attribute.name.jump_strength", 0.42F, 0.0, 32.0).setSyncable(true) + ); + public static final Holder KNOCKBACK_RESISTANCE = register( +- "knockback_resistance", new RangedAttribute("attribute.name.knockback_resistance", 0.0, 0.0, 1.0) ++ "knockback_resistance", new net.neoforged.neoforge.common.PercentageAttribute("attribute.name.knockback_resistance", 0.0, 0.0, 1.0) + ); + public static final Holder LUCK = register("luck", new RangedAttribute("attribute.name.luck", 0.0, -1024.0, 1024.0).setSyncable(true)); + public static final Holder MAX_ABSORPTION = register( +@@ -61,7 +_,8 @@ + "movement_efficiency", new RangedAttribute("attribute.name.movement_efficiency", 0.0, 0.0, 1.0).setSyncable(true) + ); + public static final Holder MOVEMENT_SPEED = register( +- "movement_speed", new RangedAttribute("attribute.name.movement_speed", 0.7, 0.0, 1024.0).setSyncable(true) ++ // Neo: Convert Movement Speed to percent-based for more appropriate display using IAttributeExtension. Use a scale factor of 1000 since movement speed has 0.001 units. ++ "movement_speed", new net.neoforged.neoforge.common.PercentageAttribute("attribute.name.movement_speed", 0.7, 0.0, 1024.0, 1000).setSyncable(true) + ); + public static final Holder OXYGEN_BONUS = register( + "oxygen_bonus", new RangedAttribute("attribute.name.oxygen_bonus", 0.0, 0.0, 1024.0).setSyncable(true) diff --git a/patches/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch b/patches/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch index 6497c649..26208739 100644 --- a/patches/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch +++ b/patches/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java +++ b/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java -@@ -174,11 +_,12 @@ +@@ -177,11 +_,12 @@ .build(); public static AttributeSupplier getSupplier(EntityType p_22298_) { diff --git a/patches/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java.patch b/patches/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java.patch index dfe2740a..d88adceb 100644 --- a/patches/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java.patch +++ b/patches/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java.patch @@ -1,26 +1,21 @@ --- a/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java +++ b/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java -@@ -31,6 +_,8 @@ +@@ -22,6 +_,8 @@ private static final int MIN_TIME_BETWEEN_GIFTS = 600; private static final int MAX_TIME_BETWEEN_GIFTS = 6600; private static final int TIME_TO_DELAY_FOR_HEAD_TO_FINISH_TURNING = 20; + /** @deprecated Neo: use the {@link net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps#RAID_HERO_GIFTS data map} instead */ + @Deprecated - private static final Map> GIFTS = Util.make(Maps.newHashMap(), p_23020_ -> { - p_23020_.put(VillagerProfession.ARMORER, BuiltInLootTables.ARMORER_GIFT); - p_23020_.put(VillagerProfession.BUTCHER, BuiltInLootTables.BUTCHER_GIFT); -@@ -121,8 +_,12 @@ - return ImmutableList.of(new ItemStack(Items.POPPY)); + private static final Map> GIFTS = ImmutableMap.>builder() + .put(VillagerProfession.ARMORER, BuiltInLootTables.ARMORER_GIFT) + .put(VillagerProfession.BUTCHER, BuiltInLootTables.BUTCHER_GIFT) +@@ -112,7 +_,8 @@ + return BuiltInLootTables.BABY_VILLAGER_GIFT; } else { - VillagerProfession villagerprofession = p_23010_.getVillagerData().getProfession(); -- if (GIFTS.containsKey(villagerprofession)) { -- LootTable loottable = p_23010_.level().getServer().reloadableRegistries().getLootTable(GIFTS.get(villagerprofession)); -+ LootTable loottable = null; + VillagerProfession villagerprofession = p_372869_.getVillagerData().getProfession(); +- return GIFTS.getOrDefault(villagerprofession, BuiltInLootTables.UNEMPLOYED_GIFT); + var gift = net.minecraft.core.registries.BuiltInRegistries.VILLAGER_PROFESSION.wrapAsHolder(villagerprofession).getData(net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps.RAID_HERO_GIFTS); -+ if (gift != null) { -+ loottable = p_23010_.level().getServer().reloadableRegistries().getLootTable(gift.lootTable()); -+ } -+ if (loottable != null) { - LootParams lootparams = new LootParams.Builder((ServerLevel)p_23010_.level()) - .withParameter(LootContextParams.ORIGIN, p_23010_.position()) - .withParameter(LootContextParams.THIS_ENTITY, p_23010_) ++ return gift != null ? gift.lootTable() : BuiltInLootTables.UNEMPLOYED_GIFT; + } + } + diff --git a/patches/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch b/patches/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch index daa170bb..88d24ac3 100644 --- a/patches/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch +++ b/patches/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/behavior/StartAttacking.java +++ b/net/minecraft/world/entity/ai/behavior/StartAttacking.java -@@ -30,7 +_,11 @@ - if (!p_258774_.canAttack(livingentity)) { +@@ -28,7 +_,11 @@ + if (!p_375685_.canAttack(livingentity)) { return false; } else { - p_258778_.set(livingentity); -+ net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent changeTargetEvent = net.neoforged.neoforge.common.CommonHooks.onLivingChangeTarget(p_258774_, livingentity, net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); ++ net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent changeTargetEvent = net.neoforged.neoforge.common.CommonHooks.onLivingChangeTarget(p_375685_, livingentity, net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); + if (changeTargetEvent.isCanceled() || changeTargetEvent.getNewAboutToBeSetTarget() == null) + return false; + diff --git a/patches/net/minecraft/world/entity/ai/behavior/Swim.java.patch b/patches/net/minecraft/world/entity/ai/behavior/Swim.java.patch index b9fd7fcb..f1d7a4d4 100644 --- a/patches/net/minecraft/world/entity/ai/behavior/Swim.java.patch +++ b/patches/net/minecraft/world/entity/ai/behavior/Swim.java.patch @@ -3,7 +3,7 @@ @@ -14,7 +_,7 @@ } - public static boolean shouldSwim(Mob p_316787_) { + public static boolean shouldSwim(T p_316787_) { - return p_316787_.isInWater() && p_316787_.getFluidHeight(FluidTags.WATER) > p_316787_.getFluidJumpThreshold() || p_316787_.isInLava(); + return p_316787_.isInWater() && p_316787_.getFluidHeight(FluidTags.WATER) > p_316787_.getFluidJumpThreshold() || p_316787_.isInLava() || p_316787_.isInFluidType((fluidType, height) -> p_316787_.canSwimInFluidType(fluidType) && height > p_316787_.getFluidJumpThreshold()); } diff --git a/patches/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch b/patches/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch index a0d2d9d3..a0ffc786 100644 --- a/patches/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch +++ b/patches/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch @@ -4,8 +4,8 @@ if (!super.canUse()) { return false; } else { -- return !this.mob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) -+ return !net.neoforged.neoforge.common.CommonHooks.canEntityDestroy(this.mob.level(), this.doorPos, this.mob) +- return !getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ return !net.neoforged.neoforge.common.CommonHooks.canEntityDestroy(getServerLevel(this.mob.level()), this.doorPos, this.mob) ? false : this.isValidDifficulty(this.mob.level().getDifficulty()) && !this.isOpen(); } diff --git a/patches/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/patches/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch index f817b989..64b9d0f7 100644 --- a/patches/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ b/patches/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -4,8 +4,8 @@ if (this.eatAnimationTick == this.adjustedTickDelay(4)) { BlockPos blockpos = this.mob.blockPosition(); if (IS_TALL_GRASS.test(this.level.getBlockState(blockpos))) { -- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level, this.mob)) { +- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.level), this.mob)) { this.level.destroyBlock(blockpos, false); } @@ -13,8 +13,8 @@ } else { BlockPos blockpos1 = blockpos.below(); if (this.level.getBlockState(blockpos1).is(Blocks.GRASS_BLOCK)) { -- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level, this.mob)) { +- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.level), this.mob)) { this.level.levelEvent(2001, blockpos1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); this.level.setBlock(blockpos1, Blocks.DIRT.defaultBlockState(), 2); } diff --git a/patches/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/patches/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch index 276d4f50..ecb4345b 100644 --- a/patches/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch +++ b/patches/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -4,8 +4,8 @@ @Override public boolean canUse() { -- if (!this.removerMob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.removerMob.level(), this.removerMob)) { +- if (!getServerLevel(this.removerMob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.removerMob.level()), this.removerMob)) { return false; } else if (this.nextStartTick > 0) { this.nextStartTick--; diff --git a/patches/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/patches/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch index 8461aee2..6643b3f1 100644 --- a/patches/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch +++ b/patches/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -232,10 +_,10 @@ +@@ -249,10 +_,10 @@ Vec3 vec3 = this.getTempMobPos(); this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F : 0.75F - this.mob.getBbWidth() / 2.0F; Vec3i vec3i = this.path.getNextNodePos(); diff --git a/patches/net/minecraft/world/entity/ai/village/VillageSiege.java.patch b/patches/net/minecraft/world/entity/ai/village/VillageSiege.java.patch index 075cd89a..5dc790e0 100644 --- a/patches/net/minecraft/world/entity/ai/village/VillageSiege.java.patch +++ b/patches/net/minecraft/world/entity/ai/village/VillageSiege.java.patch @@ -16,7 +16,7 @@ Zombie zombie; try { - zombie = new Zombie(p_27017_); -+ zombie = EntityType.ZOMBIE.create(p_27017_); //Forge: Direct Initialization is deprecated, use EntityType. - zombie.finalizeSpawn(p_27017_, p_27017_.getCurrentDifficultyAt(zombie.blockPosition()), MobSpawnType.EVENT, null); ++ zombie = EntityType.ZOMBIE.create(p_27017_, EntitySpawnReason.EVENT); //Forge: Direct Initialization is deprecated, use EntityType. + zombie.finalizeSpawn(p_27017_, p_27017_.getCurrentDifficultyAt(zombie.blockPosition()), EntitySpawnReason.EVENT, null); } catch (Exception exception) { LOGGER.warn("Failed to create zombie for village siege at {}", vec3, exception); diff --git a/patches/net/minecraft/world/entity/animal/Animal.java.patch b/patches/net/minecraft/world/entity/animal/Animal.java.patch index 38850749..7c60f97e 100644 --- a/patches/net/minecraft/world/entity/animal/Animal.java.patch +++ b/patches/net/minecraft/world/entity/animal/Animal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Animal.java +++ b/net/minecraft/world/entity/animal/Animal.java -@@ -201,6 +_,17 @@ +@@ -221,6 +_,17 @@ public void spawnChildFromBreeding(ServerLevel p_27564_, Animal p_27565_) { AgeableMob ageablemob = this.getBreedOffspring(p_27564_, p_27565_); diff --git a/patches/net/minecraft/world/entity/animal/Bee.java.patch b/patches/net/minecraft/world/entity/animal/Bee.java.patch index 79c82f58..3e5e9040 100644 --- a/patches/net/minecraft/world/entity/animal/Bee.java.patch +++ b/patches/net/minecraft/world/entity/animal/Bee.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java -@@ -487,7 +_,7 @@ - return false; +@@ -498,7 +_,7 @@ + if (this.hivePos == null) { + return null; } else { - BlockEntity blockentity = this.level().getBlockEntity(this.hivePos); -- return blockentity != null && blockentity.getType() == BlockEntityType.BEEHIVE; -+ return blockentity instanceof BeehiveBlockEntity; +- return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null); ++ return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos) instanceof BeehiveBlockEntity hive ? hive : null; } } -@@ -636,8 +_,18 @@ +@@ -644,8 +_,18 @@ } @Override diff --git a/patches/net/minecraft/world/entity/animal/Cat.java.patch b/patches/net/minecraft/world/entity/animal/Cat.java.patch index 2a68e762..45b5cd95 100644 --- a/patches/net/minecraft/world/entity/animal/Cat.java.patch +++ b/patches/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,18 +1,17 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java -@@ -368,9 +_,9 @@ +@@ -373,9 +_,9 @@ } } else if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) { if (!this.level().isClientSide()) { - this.usePlayerItem(p_28153_, p_28154_, itemstack); -- FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); -+ FoodProperties foodproperties = itemstack.getFoodProperties(this); + FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); this.heal(foodproperties != null ? (float)foodproperties.nutrition() : 1.0F); + this.usePlayerItem(p_28153_, p_28154_, itemstack); + this.playEatingSound(); } - return InteractionResult.sidedSuccess(this.level().isClientSide()); -@@ -430,7 +_,7 @@ +@@ -437,7 +_,7 @@ } private void tryToTame(Player p_333858_) { diff --git a/patches/net/minecraft/world/entity/animal/Fox.java.patch b/patches/net/minecraft/world/entity/animal/Fox.java.patch index b84f3471..c7059766 100644 --- a/patches/net/minecraft/world/entity/animal/Fox.java.patch +++ b/patches/net/minecraft/world/entity/animal/Fox.java.patch @@ -1,16 +1,18 @@ --- a/net/minecraft/world/entity/animal/Fox.java +++ b/net/minecraft/world/entity/animal/Fox.java -@@ -677,13 +_,16 @@ +@@ -671,13 +_,18 @@ @Override protected void dropAllDeathLoot(ServerLevel p_348640_, DamageSource p_28536_) { + super.dropAllDeathLoot(p_348640_, p_28536_); + } -+ protected void dropEquipment() { // Forge: move extra drops to dropEquipment to allow them to be captured by LivingDropsEvent -+ super.dropEquipment(); ++ ++ @Override ++ protected void dropEquipment(ServerLevel p_348640_) { // Forge: move extra drops to dropEquipment to allow them to be captured by LivingDropsEvent ++ super.dropEquipment(p_348640_); ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemstack.isEmpty()) { - this.spawnAtLocation(itemstack); + this.spawnAtLocation(p_348640_, itemstack); this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); } @@ -18,9 +20,9 @@ } public static boolean isPathClear(Fox p_28472_, LivingEntity p_28473_) { -@@ -842,6 +_,17 @@ +@@ -837,6 +_,17 @@ protected void breed() { - ServerLevel serverlevel = (ServerLevel)this.level; + ServerLevel serverlevel = this.level; Fox fox = (Fox)this.animal.getBreedOffspring(serverlevel, this.partner); + final net.neoforged.neoforge.event.entity.living.BabyEntitySpawnEvent event = new net.neoforged.neoforge.event.entity.living.BabyEntitySpawnEvent(animal, partner, fox); + final boolean cancelled = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event).isCanceled(); @@ -36,16 +38,16 @@ if (fox != null) { ServerPlayer serverplayer = this.animal.getLoveCause(); ServerPlayer serverplayer1 = this.partner.getLoveCause(); -@@ -919,7 +_,7 @@ +@@ -914,7 +_,7 @@ } protected void onReachedTarget() { -- if (Fox.this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(Fox.this.level(), Fox.this)) { +- if (getServerLevel(Fox.this.level()).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(Fox.this.level()), Fox.this)) { BlockState blockstate = Fox.this.level().getBlockState(this.blockPos); if (blockstate.is(Blocks.SWEET_BERRY_BUSH)) { this.pickSweetBerries(blockstate); -@@ -978,7 +_,7 @@ +@@ -973,7 +_,7 @@ @Override public boolean canUse() { diff --git a/patches/net/minecraft/world/entity/animal/MushroomCow.java.patch b/patches/net/minecraft/world/entity/animal/MushroomCow.java.patch index fa6f1767..373b37a1 100644 --- a/patches/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/patches/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -1,40 +1,23 @@ --- a/net/minecraft/world/entity/animal/MushroomCow.java +++ b/net/minecraft/world/entity/animal/MushroomCow.java -@@ -108,7 +_,7 @@ - - this.playSound(soundevent, 1.0F, 1.0F); - return InteractionResult.sidedSuccess(this.level().isClientSide); -- } else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { -+ } else if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { // Neo: Shear logic is handled by IShearable - this.shear(SoundSource.PLAYERS); - this.gameEvent(GameEvent.SHEAR, p_28941_); - if (!this.level().isClientSide) { -@@ -165,8 +_,10 @@ - public void shear(SoundSource p_28924_) { - this.level().playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, p_28924_, 1.0F, 1.0F); - if (!this.level().isClientSide()) { -+ if (!net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.COW, (timer) -> {})) return; - Cow cow = EntityType.COW.create(this.level()); - if (cow != null) { -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, cow); - ((ServerLevel)this.level()).sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0); - this.discard(); - cow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -@@ -185,10 +_,13 @@ - this.level().addFreshEntity(cow); - - for (int i = 0; i < 5; i++) { -- this.level() -- .addFreshEntity( -- new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock())) -- ); +@@ -166,11 +_,19 @@ + @Override + public void shear(ServerLevel p_376375_, SoundSource p_28924_, ItemStack p_373092_) { + p_376375_.playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, p_28924_, 1.0F, 1.0F); ++ if (!net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.COW, (timer) -> {})) return; + this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), p_381482_ -> { ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381482_); + p_376375_.sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0); + this.dropFromShearingLootTable(p_376375_, BuiltInLootTables.SHEAR_MOOSHROOM, p_373092_, (p_381483_, p_381484_) -> { + for (int i = 0; i < p_381484_.getCount(); i++) { +- p_381483_.addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), p_381484_.copyWithCount(1))); + // Neo: Change from addFreshEntity to spawnAtLocation to ensure captureDrops can capture this, we also need to unset the default pickup delay from the item + // Vanilla uses this.getY(1.0) for the y-level, which is this.getY() + this.getBbHeight() * 1.0, so we pass the BB height as the Y-offset. -+ ItemEntity item = spawnAtLocation(new ItemStack(this.getVariant().blockState.getBlock()), this.getBbHeight()); ++ ItemEntity item = spawnAtLocation(p_381483_, p_381484_.copyWithCount(1), this.getBbHeight()); + if (item != null) { + // addFreshEntity does not incur a pickup delay, while spawnAtLocation sets the default pickup delay. + item.setNoPickUpDelay(); + } } - } - } + }); + }); diff --git a/patches/net/minecraft/world/entity/animal/Ocelot.java.patch b/patches/net/minecraft/world/entity/animal/Ocelot.java.patch index 357c4426..6e9ec371 100644 --- a/patches/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/patches/net/minecraft/world/entity/animal/Ocelot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Ocelot.java +++ b/net/minecraft/world/entity/animal/Ocelot.java -@@ -160,7 +_,7 @@ +@@ -159,7 +_,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && p_29021_.distanceToSqr(this) < 9.0) { this.usePlayerItem(p_29021_, p_29022_, itemstack); if (!this.level().isClientSide) { diff --git a/patches/net/minecraft/world/entity/animal/Parrot.java.patch b/patches/net/minecraft/world/entity/animal/Parrot.java.patch index 0fbb4182..ba8eca84 100644 --- a/patches/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/patches/net/minecraft/world/entity/animal/Parrot.java.patch @@ -10,10 +10,10 @@ }; + /** @deprecated Neo: use the {@link net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps#PARROT_IMITATIONS data map} instead */ + @Deprecated - static final Map, SoundEvent> MOB_SOUND_MAP = Util.make(Maps.newHashMap(), p_326764_ -> { - p_326764_.put(EntityType.BLAZE, SoundEvents.PARROT_IMITATE_BLAZE); - p_326764_.put(EntityType.BOGGED, SoundEvents.PARROT_IMITATE_BOGGED); -@@ -257,7 +_,7 @@ + static final Map, SoundEvent> MOB_SOUND_MAP = Util.make(Maps.newHashMap(), p_379158_ -> { + p_379158_.put(EntityType.BLAZE, SoundEvents.PARROT_IMITATE_BLAZE); + p_379158_.put(EntityType.BOGGED, SoundEvents.PARROT_IMITATE_BOGGED); +@@ -261,7 +_,7 @@ } if (!this.level().isClientSide) { @@ -22,19 +22,19 @@ this.tame(p_29414_); this.level().broadcastEntityEvent(this, (byte)7); } else { -@@ -321,7 +_,10 @@ +@@ -325,7 +_,10 @@ public static SoundEvent getAmbient(Level p_218239_, RandomSource p_218240_) { if (p_218239_.getDifficulty() != Difficulty.PEACEFUL && p_218240_.nextInt(1000) == 0) { - List> list = Lists.newArrayList(MOB_SOUND_MAP.keySet()); + final var entities = new java.util.HashSet<>(MOB_SOUND_MAP.keySet()); -+ final var registry = p_218239_.registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.ENTITY_TYPE); -+ registry.getDataMap(net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps.PARROT_IMITATIONS).keySet().forEach(key -> entities.add(registry.get(key))); ++ final var registry = p_218239_.registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.ENTITY_TYPE); ++ registry.getDataMap(net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps.PARROT_IMITATIONS).keySet().forEach(key -> entities.add(registry.getValue(key))); + List> list = Lists.newArrayList(entities); return getImitatedSound(list.get(p_218240_.nextInt(list.size()))); } else { return SoundEvents.PARROT_AMBIENT; -@@ -329,7 +_,9 @@ +@@ -333,7 +_,9 @@ } private static SoundEvent getImitatedSound(EntityType p_29409_) { diff --git a/patches/net/minecraft/world/entity/animal/Pig.java.patch b/patches/net/minecraft/world/entity/animal/Pig.java.patch index 63461513..35f07ef1 100644 --- a/patches/net/minecraft/world/entity/animal/Pig.java.patch +++ b/patches/net/minecraft/world/entity/animal/Pig.java.patch @@ -1,19 +1,18 @@ --- a/net/minecraft/world/entity/animal/Pig.java +++ b/net/minecraft/world/entity/animal/Pig.java -@@ -206,7 +_,7 @@ +@@ -207,13 +_,14 @@ @Override public void thunderHit(ServerLevel p_29473_, LightningBolt p_29474_) { - if (p_29473_.getDifficulty() != Difficulty.PEACEFUL) { + if (p_29473_.getDifficulty() != Difficulty.PEACEFUL && net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.ZOMBIFIED_PIGLIN, (timer) -> {})) { - ZombifiedPiglin zombifiedpiglin = EntityType.ZOMBIFIED_PIGLIN.create(p_29473_); - if (zombifiedpiglin != null) { - zombifiedpiglin.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); -@@ -219,6 +_,7 @@ + ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), p_381485_ -> { + if (this.getMainHandItem().isEmpty()) { + p_381485_.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); } - zombifiedpiglin.setPersistenceRequired(); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, zombifiedpiglin); - p_29473_.addFreshEntity(zombifiedpiglin); - this.discard(); - } else { + p_381485_.setPersistenceRequired(); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381485_); + }); + if (zombifiedpiglin == null) { + super.thunderHit(p_29473_, p_29474_); diff --git a/patches/net/minecraft/world/entity/animal/Rabbit.java.patch b/patches/net/minecraft/world/entity/animal/Rabbit.java.patch index 867d550a..987d78e6 100644 --- a/patches/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/patches/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/Rabbit.java +++ b/net/minecraft/world/entity/animal/Rabbit.java -@@ -530,7 +_,7 @@ +@@ -531,7 +_,7 @@ @Override public boolean canUse() { if (this.nextStartTick <= 0) { -- if (!this.rabbit.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.rabbit.level(), this.rabbit)) { +- if (!getServerLevel(this.rabbit).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.rabbit.level()), this.rabbit)) { return false; } -@@ -585,7 +_,7 @@ +@@ -586,7 +_,7 @@ @Override protected boolean isValidTarget(LevelReader p_29785_, BlockPos p_29786_) { BlockState blockstate = p_29785_.getBlockState(p_29786_); diff --git a/patches/net/minecraft/world/entity/animal/Sheep.java.patch b/patches/net/minecraft/world/entity/animal/Sheep.java.patch index 4871c860..e22cf4c2 100644 --- a/patches/net/minecraft/world/entity/animal/Sheep.java.patch +++ b/patches/net/minecraft/world/entity/animal/Sheep.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/Sheep.java +++ b/net/minecraft/world/entity/animal/Sheep.java -@@ -212,7 +_,7 @@ +@@ -156,7 +_,7 @@ @Override public InteractionResult mobInteract(Player p_29853_, InteractionHand p_29854_) { ItemStack itemstack = p_29853_.getItemInHand(p_29854_); - if (itemstack.is(Items.SHEARS)) { + if (false && itemstack.is(Items.SHEARS)) { // Neo: Shear logic is handled by IShearable - if (!this.level().isClientSide && this.readyForShearing()) { - this.shear(SoundSource.PLAYERS); + if (this.level() instanceof ServerLevel serverlevel && this.readyForShearing()) { + this.shear(serverlevel, SoundSource.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, p_29853_); diff --git a/patches/net/minecraft/world/entity/animal/SnowGolem.java.patch b/patches/net/minecraft/world/entity/animal/SnowGolem.java.patch index 19b14ba7..04e835e6 100644 --- a/patches/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/patches/net/minecraft/world/entity/animal/SnowGolem.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/animal/SnowGolem.java +++ b/net/minecraft/world/entity/animal/SnowGolem.java -@@ -92,7 +_,7 @@ - this.hurt(this.damageSources().onFire(), 1.0F); +@@ -95,7 +_,7 @@ + this.hurtServer(serverlevel, this.damageSources().onFire(), 1.0F); } -- if (!this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this)) { +- if (!serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, this)) { return; } -@@ -127,7 +_,7 @@ +@@ -136,7 +_,7 @@ @Override protected InteractionResult mobInteract(Player p_29920_, InteractionHand p_29921_) { ItemStack itemstack = p_29920_.getItemInHand(p_29921_); - if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { + if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { // Neo: Shear logic is handled by IShearable - this.shear(SoundSource.PLAYERS); - this.gameEvent(GameEvent.SHEAR, p_29920_); - if (!this.level().isClientSide) { + if (this.level() instanceof ServerLevel serverlevel) { + this.shear(serverlevel, SoundSource.PLAYERS, itemstack); + this.gameEvent(GameEvent.SHEAR, p_29920_); diff --git a/patches/net/minecraft/world/entity/animal/Wolf.java.patch b/patches/net/minecraft/world/entity/animal/Wolf.java.patch index 5a316c46..ebd287da 100644 --- a/patches/net/minecraft/world/entity/animal/Wolf.java.patch +++ b/patches/net/minecraft/world/entity/animal/Wolf.java.patch @@ -1,29 +1,28 @@ --- a/net/minecraft/world/entity/animal/Wolf.java +++ b/net/minecraft/world/entity/animal/Wolf.java -@@ -419,10 +_,11 @@ - if (!this.level().isClientSide || this.isBaby() && this.isFood(itemstack)) { - if (this.isTame()) { - if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) { -- itemstack.consume(1, p_30412_); -- FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); -+ FoodProperties foodproperties = itemstack.getFoodProperties(this); - float f = foodproperties != null ? (float)foodproperties.nutrition() : 1.0F; - this.heal(2.0F * f); -+ itemstack.consume(1, p_30412_); -+ this.gameEvent(GameEvent.EAT); // Neo: add EAT game event - return InteractionResult.sidedSuccess(this.level().isClientSide()); - } else { - if (item instanceof DyeItem dyeitem && this.isOwnedBy(p_30412_)) { -@@ -440,7 +_,7 @@ - this.setBodyArmorItem(itemstack.copyWithCount(1)); - itemstack.consume(1, p_30412_); - return InteractionResult.SUCCESS; -- } else if (itemstack.is(Items.SHEARS) -+ } else if (itemstack.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHEARS_REMOVE_ARMOR) - && this.isOwnedBy(p_30412_) - && this.hasArmor() - && (!EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) || p_30412_.isCreative())) { -@@ -488,7 +_,7 @@ +@@ -403,10 +_,11 @@ + Item item = itemstack.getItem(); + if (this.isTame()) { + if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) { +- this.usePlayerItem(p_30412_, p_30413_, itemstack); + FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); + float f = foodproperties != null ? (float)foodproperties.nutrition() : 1.0F; + this.heal(2.0F * f); ++ this.usePlayerItem(p_30412_, p_30413_, itemstack); ++ this.gameEvent(GameEvent.EAT); // Neo: add EAT game event + return InteractionResult.SUCCESS; + } else { + if (item instanceof DyeItem dyeitem && this.isOwnedBy(p_30412_)) { +@@ -424,7 +_,7 @@ + this.setBodyArmorItem(itemstack.copyWithCount(1)); + itemstack.consume(1, p_30412_); + return InteractionResult.SUCCESS; +- } else if (itemstack.is(Items.SHEARS) ++ } else if (itemstack.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHEARS_REMOVE_ARMOR) + && this.isOwnedBy(p_30412_) + && this.isWearingBodyArmor() + && (!EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) || p_30412_.isCreative())) { +@@ -471,7 +_,7 @@ } private void tryToTame(Player p_333736_) { diff --git a/patches/net/minecraft/world/entity/animal/allay/Allay.java.patch b/patches/net/minecraft/world/entity/animal/allay/Allay.java.patch index bd58fe31..f0ede9df 100644 --- a/patches/net/minecraft/world/entity/animal/allay/Allay.java.patch +++ b/patches/net/minecraft/world/entity/animal/allay/Allay.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -368,9 +_,9 @@ - public boolean wantsToPickUp(ItemStack p_218387_) { +@@ -369,9 +_,9 @@ + public boolean wantsToPickUp(ServerLevel p_376111_, ItemStack p_218387_) { ItemStack itemstack = this.getItemInHand(InteractionHand.MAIN_HAND); return !itemstack.isEmpty() -- && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) +- && p_376111_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && this.inventory.canAddItem(p_218387_) - && this.allayConsidersItemEqual(itemstack, p_218387_); + && this.allayConsidersItemEqual(itemstack, p_218387_) -+ && net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this); ++ && net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_376111_, this); } private boolean allayConsidersItemEqual(ItemStack p_252278_, ItemStack p_250405_) { diff --git a/patches/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch b/patches/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch index e76537d3..d2768ffc 100644 --- a/patches/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch +++ b/patches/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -300,7 +_,7 @@ +@@ -305,7 +_,7 @@ @Override public InteractionResult mobInteract(Player p_316559_, InteractionHand p_316119_) { ItemStack itemstack = p_316559_.getItemInHand(p_316119_); - if (itemstack.is(Items.BRUSH) && this.brushOffScute()) { + if (itemstack.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.BRUSH_BRUSH) && this.brushOffScute()) { itemstack.hurtAndBreak(16, p_316559_, getSlotForHand(p_316119_)); - return InteractionResult.sidedSuccess(this.level().isClientSide); + return InteractionResult.SUCCESS; } else { diff --git a/patches/net/minecraft/world/entity/animal/camel/Camel.java.patch b/patches/net/minecraft/world/entity/animal/camel/Camel.java.patch index 9f451f41..40ce1b83 100644 --- a/patches/net/minecraft/world/entity/animal/camel/Camel.java.patch +++ b/patches/net/minecraft/world/entity/animal/camel/Camel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/camel/Camel.java +++ b/net/minecraft/world/entity/animal/camel/Camel.java -@@ -286,6 +_,7 @@ +@@ -289,6 +_,7 @@ this.dashCooldown = 55; this.setDashing(true); this.hasImpulse = true; diff --git a/patches/net/minecraft/world/entity/animal/frog/Tadpole.java.patch b/patches/net/minecraft/world/entity/animal/frog/Tadpole.java.patch index 637cf5ca..90a3bb47 100644 --- a/patches/net/minecraft/world/entity/animal/frog/Tadpole.java.patch +++ b/patches/net/minecraft/world/entity/animal/frog/Tadpole.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -225,8 +_,10 @@ +@@ -228,8 +_,10 @@ + } private void ageUp() { ++ if (!net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.FROG, (timer) -> {})) return; if (this.level() instanceof ServerLevel serverlevel) { -+ if (!net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.FROG, (timer) -> {})) return; - Frog frog = EntityType.FROG.create(this.level()); - if (frog != null) { -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, frog); - frog.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); - frog.finalizeSpawn(serverlevel, this.level().getCurrentDifficultyAt(frog.blockPosition()), MobSpawnType.CONVERSION, null); - frog.setNoAi(this.isNoAi()); + this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), p_381493_ -> { ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381493_); + p_381493_.finalizeSpawn(serverlevel, this.level().getCurrentDifficultyAt(p_381493_.blockPosition()), EntitySpawnReason.CONVERSION, null); + p_381493_.setPersistenceRequired(); + p_381493_.fudgePositionAfterSizeChange(this.getDimensions(this.getPose())); diff --git a/patches/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/patches/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index 4f8118fe..c011008d 100644 --- a/patches/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/patches/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -396,9 +_,9 @@ +@@ -405,9 +_,9 @@ protected void playStepSound(BlockPos p_30584_, BlockState p_30585_) { if (!p_30585_.liquid()) { BlockState blockstate = this.level().getBlockState(p_30584_.above()); @@ -12,7 +12,7 @@ } if (this.isVehicle() && this.canGallop) { -@@ -816,6 +_,7 @@ +@@ -823,6 +_,7 @@ this.setDeltaMovement(vec3.x, d0, vec3.z); this.setIsJumping(true); this.hasImpulse = true; @@ -20,10 +20,10 @@ if (p_275435_.z > 0.0) { float f = Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)); float f1 = Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)); -@@ -1118,6 +_,11 @@ +@@ -1127,6 +_,11 @@ this.randomizeAttributes(p_30555_.getRandom()); - return super.finalizeSpawn(p_30555_, p_30556_, p_30557_, p_30558_); + return super.finalizeSpawn(p_30555_, p_30556_, p_363523_, p_30558_); + } + + // Neo: Inventory getter diff --git a/patches/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch b/patches/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch index e3a7684a..ca3ab0b2 100644 --- a/patches/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch +++ b/patches/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch @@ -6,7 +6,7 @@ ServerLevel serverlevel = (ServerLevel)this.horse.level(); + // Forge: Trigger the trap in a tick task to avoid crashes when mods add goals to skeleton horses + // (MC-206338/Forge PR #7509) -+ serverlevel.getServer().tell(new net.minecraft.server.TickTask(serverlevel.getServer().getTickCount(), () -> { ++ serverlevel.getServer().schedule(new net.minecraft.server.TickTask(serverlevel.getServer().getTickCount(), () -> { + if (!this.horse.isAlive()) return; DifficultyInstance difficultyinstance = serverlevel.getCurrentDifficultyAt(this.horse.blockPosition()); this.horse.setTrap(false); diff --git a/patches/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch b/patches/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch index cfa11ac5..8c8aa4cd 100644 --- a/patches/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch +++ b/patches/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -299,7 +_,7 @@ +@@ -288,7 +_,7 @@ if (this.tickCount % 10 == 0) { this.level() .playLocalSound( diff --git a/patches/net/minecraft/world/entity/boss/EnderDragonPart.java.patch b/patches/net/minecraft/world/entity/boss/EnderDragonPart.java.patch index 1eda2ad7..c00f4cdd 100644 --- a/patches/net/minecraft/world/entity/boss/EnderDragonPart.java.patch +++ b/patches/net/minecraft/world/entity/boss/EnderDragonPart.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/EnderDragonPart.java +++ b/net/minecraft/world/entity/boss/EnderDragonPart.java -@@ -13,13 +_,13 @@ +@@ -14,13 +_,13 @@ import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.item.ItemStack; diff --git a/patches/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/patches/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index 5e9f360c..b807a36c 100644 --- a/patches/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/patches/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -103,6 +_,14 @@ +@@ -101,6 +_,14 @@ + this.setHealth(this.getMaxHealth()); this.noPhysics = true; - this.noCulling = true; this.phaseManager = new EnderDragonPhaseManager(this); + this.setId(ENTITY_COUNTER.getAndAdd(this.subEntities.length + 1) + 1); // Forge: Fix MC-158205: Make sure part ids are successors of parent mob id + } @@ -15,49 +15,52 @@ } public void setDragonFight(EndDragonFight p_287736_) { -@@ -170,8 +_,12 @@ - return adouble; +@@ -149,8 +_,15 @@ + p_326491_.define(DATA_PHASE, EnderDragonPhase.HOVERING.getId()); } -+ @org.jetbrains.annotations.Nullable private Player unlimitedLastHurtByPlayer = null; ++ @org.jetbrains.annotations.Nullable ++ private Player unlimitedLastHurtByPlayer = null; ++ @Override public void aiStep() { + // lastHurtByPlayer is cleared after 100 ticks, capture it indefinitely in unlimitedLastHurtByPlayer for LivingExperienceDropEvent + if (this.lastHurtByPlayer != null) this.unlimitedLastHurtByPlayer = lastHurtByPlayer; + if (this.unlimitedLastHurtByPlayer != null && this.unlimitedLastHurtByPlayer.isRemoved()) this.unlimitedLastHurtByPlayer = null; ++ this.processFlappingMovement(); if (this.level().isClientSide) { this.setHealth(this.getHealth()); -@@ -475,7 +_,7 @@ +@@ -445,7 +_,7 @@ BlockPos blockpos = new BlockPos(k1, l1, i2); - BlockState blockstate = this.level().getBlockState(blockpos); + BlockState blockstate = p_376795_.getBlockState(blockpos); if (!blockstate.isAir() && !blockstate.is(BlockTags.DRAGON_TRANSPARENT)) { -- if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { -+ if (net.neoforged.neoforge.common.CommonHooks.canEntityDestroy(this.level(), blockpos, this) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { - flag1 = this.level().removeBlock(blockpos, false) || flag1; +- if (p_376795_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { ++ if (net.neoforged.neoforge.common.CommonHooks.canEntityDestroy(p_376795_, blockpos, this) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { + flag1 = p_376795_.removeBlock(blockpos, false) || flag1; } else { flag = true; -@@ -569,7 +_,8 @@ +@@ -538,7 +_,8 @@ - if (this.level() instanceof ServerLevel) { - if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && flag) { -- ExperienceOrb.award((ServerLevel)this.level(), this.position(), Mth.floor((float)i * 0.08F)); + if (this.level() instanceof ServerLevel serverlevel) { + if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- ExperienceOrb.award(serverlevel, this.position(), Mth.floor((float)i * 0.08F)); + int award = net.neoforged.neoforge.event.EventHooks.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.floor((float)i * 0.08F)); + ExperienceOrb.award((ServerLevel) this.level(), this.position(), award); } if (this.dragonDeathTime == 1 && !this.isSilent()) { -@@ -580,7 +_,8 @@ +@@ -549,7 +_,8 @@ this.move(MoverType.SELF, new Vec3(0.0, 0.1F, 0.0)); - if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel) { - if (flag) { -- ExperienceOrb.award((ServerLevel)this.level(), this.position(), Mth.floor((float)i * 0.2F)); + if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel serverlevel1) { + if (serverlevel1.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- ExperienceOrb.award(serverlevel1, this.position(), Mth.floor((float)i * 0.2F)); + int award = net.neoforged.neoforge.event.EventHooks.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.floor((float)i * 0.2F)); + ExperienceOrb.award((ServerLevel) this.level(), this.position(), award); } if (this.dragonFight != null) { -@@ -912,8 +_,19 @@ +@@ -860,8 +_,19 @@ } @Override diff --git a/patches/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/patches/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index a2b0f70b..5e036c64 100644 --- a/patches/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/patches/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -322,7 +_,7 @@ +@@ -320,7 +_,7 @@ if (this.destroyBlocksTick > 0) { this.destroyBlocksTick--; -- if (this.destroyBlocksTick == 0 && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (this.destroyBlocksTick == 0 && net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this)) { +- if (this.destroyBlocksTick == 0 && p_376675_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (this.destroyBlocksTick == 0 && net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_376675_, this)) { boolean flag = false; int l = Mth.floor(this.getBbWidth() / 2.0F + 1.0F); int i1 = Mth.floor(this.getBbHeight()); -@@ -331,7 +_,7 @@ +@@ -329,7 +_,7 @@ this.getBlockX() - l, this.getBlockY(), this.getBlockZ() - l, this.getBlockX() + l, this.getBlockY() + i1, this.getBlockZ() + l )) { - BlockState blockstate = this.level().getBlockState(blockpos); + BlockState blockstate = p_376675_.getBlockState(blockpos); - if (canDestroy(blockstate)) { + if (blockstate.canEntityDestroy(this.level(), blockpos, this) && net.neoforged.neoforge.event.EventHooks.onEntityDestroyBlock(this, blockpos, blockstate)) { - flag = this.level().destroyBlock(blockpos, true, this) || flag; + flag = p_376675_.destroyBlock(blockpos, true, this) || flag; } } -@@ -350,6 +_,10 @@ +@@ -348,6 +_,10 @@ } } @@ -29,7 +29,7 @@ public static boolean canDestroy(BlockState p_31492_) { return !p_31492_.isAir() && !p_31492_.is(BlockTags.WITHER_IMMUNE); } -@@ -495,6 +_,7 @@ +@@ -493,6 +_,7 @@ @Override public void checkDespawn() { diff --git a/patches/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/patches/net/minecraft/world/entity/decoration/ArmorStand.java.patch deleted file mode 100644 index d99faa6b..00000000 --- a/patches/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/decoration/ArmorStand.java -+++ b/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -73,7 +_,7 @@ - public static final EntityDataAccessor DATA_LEFT_LEG_POSE = SynchedEntityData.defineId(ArmorStand.class, EntityDataSerializers.ROTATIONS); - public static final EntityDataAccessor DATA_RIGHT_LEG_POSE = SynchedEntityData.defineId(ArmorStand.class, EntityDataSerializers.ROTATIONS); - private static final Predicate RIDABLE_MINECARTS = p_31582_ -> p_31582_ instanceof AbstractMinecart -- && ((AbstractMinecart)p_31582_).getMinecartType() == AbstractMinecart.Type.RIDEABLE; -+ && ((AbstractMinecart)p_31582_).canBeRidden(); - private final NonNullList handItems = NonNullList.withSize(2, ItemStack.EMPTY); - private final NonNullList armorItems = NonNullList.withSize(4, ItemStack.EMPTY); - private boolean invisible; diff --git a/patches/net/minecraft/world/entity/decoration/HangingEntity.java.patch b/patches/net/minecraft/world/entity/decoration/HangingEntity.java.patch index 91ec6e8b..830741b8 100644 --- a/patches/net/minecraft/world/entity/decoration/HangingEntity.java.patch +++ b/patches/net/minecraft/world/entity/decoration/HangingEntity.java.patch @@ -1,13 +1,11 @@ --- a/net/minecraft/world/entity/decoration/HangingEntity.java +++ b/net/minecraft/world/entity/decoration/HangingEntity.java -@@ -57,8 +_,8 @@ +@@ -58,7 +_,7 @@ if (!this.level().noCollision(this)) { return false; } else { -- boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).allMatch(p_352810_ -> { -- BlockState blockstate = this.level().getBlockState(p_352810_); -+ boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).filter(pos -> !net.minecraft.world.level.block.Block.canSupportCenter(this.level(), pos, this.direction)).allMatch(p_350100_ -> { -+ BlockState blockstate = this.level().getBlockState(p_350100_); +- boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).allMatch(p_381503_ -> { ++ boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).filter(pos -> !net.minecraft.world.level.block.Block.canSupportCenter(this.level(), pos, this.direction)).allMatch(p_381503_ -> { + BlockState blockstate = this.level().getBlockState(p_381503_); return blockstate.isSolid() || DiodeBlock.isDiode(blockstate); }); - return !flag ? false : this.level().getEntities(this, this.getBoundingBox(), HANGING_ENTITY).isEmpty(); diff --git a/patches/net/minecraft/world/entity/decoration/ItemFrame.java.patch b/patches/net/minecraft/world/entity/decoration/ItemFrame.java.patch index 6500489e..788a8be1 100644 --- a/patches/net/minecraft/world/entity/decoration/ItemFrame.java.patch +++ b/patches/net/minecraft/world/entity/decoration/ItemFrame.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/net/minecraft/world/entity/decoration/ItemFrame.java -@@ -212,7 +_,7 @@ +@@ -225,7 +_,7 @@ private void removeFramedMap(ItemStack p_31811_) { MapId mapid = this.getFramedMapId(p_31811_); if (mapid != null) { @@ -8,4 +8,4 @@ + MapItemSavedData mapitemsaveddata = MapItem.getSavedData(p_31811_, this.level()); if (mapitemsaveddata != null) { mapitemsaveddata.removedFromFrame(this.pos, this.getId()); - mapitemsaveddata.setDirty(true); + } diff --git a/patches/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/patches/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index c8eae9d0..a8174886 100644 --- a/patches/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/patches/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -138,7 +_,7 @@ - if (!this.level().isClientSide && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { +@@ -148,7 +_,7 @@ + if (this.level() instanceof ServerLevel serverlevel && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { BlockPos blockpos = this.blockPosition(); boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock; - boolean flag1 = flag && this.level().getFluidState(blockpos).is(FluidTags.WATER); @@ -9,7 +9,7 @@ double d0 = this.getDeltaMovement().lengthSqr(); if (flag && d0 > 1.0) { BlockHitResult blockhitresult = this.level() -@@ -147,7 +_,7 @@ +@@ -157,7 +_,7 @@ new Vec3(this.xo, this.yo, this.zo), this.position(), ClipContext.Block.COLLIDER, ClipContext.Fluid.SOURCE_ONLY, this ) ); diff --git a/patches/net/minecraft/world/entity/item/ItemEntity.java.patch b/patches/net/minecraft/world/entity/item/ItemEntity.java.patch index 786a95f7..0b105e15 100644 --- a/patches/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/patches/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/entity/item/ItemEntity.java @@ -49,6 +_,10 @@ @Nullable - public UUID target; + private UUID target; public final float bobOffs; + /** + * The maximum age of this EntityItem. The item is expired once this is reached. @@ -45,8 +45,8 @@ if (this.isInWater() && this.getFluidHeight(FluidTags.WATER) > 0.1F) { this.setUnderwaterMovement(); } else if (this.isInLava() && this.getFluidHeight(FluidTags.LAVA) > 0.1F) { -@@ -153,7 +_,8 @@ - this.move(MoverType.SELF, this.getDeltaMovement()); +@@ -154,7 +_,8 @@ + this.applyEffectsFromBlocks(); float f = 0.98F; if (this.onGround()) { - f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; @@ -55,7 +55,7 @@ } this.setDeltaMovement(this.getDeltaMovement().multiply((double)f, 0.98, (double)f)); -@@ -185,7 +_,15 @@ +@@ -186,7 +_,15 @@ } } @@ -72,16 +72,16 @@ this.discard(); } } -@@ -282,7 +_,7 @@ - this.health = (int)((float)this.health - p_32014_); - this.gameEvent(GameEvent.ENTITY_DAMAGE, p_32013_.getEntity()); +@@ -294,7 +_,7 @@ + this.health = (int)((float)this.health - p_376562_); + this.gameEvent(GameEvent.ENTITY_DAMAGE, p_376452_.getEntity()); if (this.health <= 0) { - this.getItem().onDestroyed(this); -+ this.getItem().onDestroyed(this, p_32013_); ++ this.getItem().onDestroyed(this, p_376452_); this.discard(); } -@@ -295,6 +_,7 @@ +@@ -312,6 +_,7 @@ p_32050_.putShort("Health", (short)this.health); p_32050_.putShort("Age", (short)this.age); p_32050_.putShort("PickupDelay", (short)this.pickupDelay); @@ -89,7 +89,7 @@ if (this.thrower != null) { p_32050_.putUUID("Thrower", this.thrower); } -@@ -315,6 +_,9 @@ +@@ -332,6 +_,9 @@ if (p_32034_.contains("PickupDelay")) { this.pickupDelay = p_32034_.getShort("PickupDelay"); } @@ -99,7 +99,7 @@ if (p_32034_.hasUUID("Owner")) { this.target = p_32034_.getUUID("Owner"); -@@ -343,7 +_,22 @@ +@@ -360,7 +_,22 @@ ItemStack itemstack = this.getItem(); Item item = itemstack.getItem(); int i = itemstack.getCount(); @@ -123,7 +123,7 @@ p_32040_.take(this, i); if (itemstack.isEmpty()) { this.discard(); -@@ -398,6 +_,15 @@ +@@ -415,6 +_,15 @@ this.target = p_266724_; } @@ -139,7 +139,7 @@ public void setThrower(Entity p_306324_) { this.thrower = p_306324_.getUUID(); this.cachedThrower = p_306324_; -@@ -437,7 +_,7 @@ +@@ -454,7 +_,7 @@ public void makeFakeItem() { this.setNeverPickUp(); @@ -147,4 +147,4 @@ + this.age = getItem().getEntityLifespan(this.level()) - 1; } - public float getSpin(float p_32009_) { + public static float getSpin(float p_32009_, float p_361295_) { diff --git a/patches/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/patches/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch index 688628b3..02972fce 100644 --- a/patches/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/patches/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/AbstractSkeleton.java +++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java -@@ -157,7 +_,7 @@ +@@ -161,7 +_,7 @@ if (this.level() != null && !this.level().isClientSide) { this.goalSelector.removeGoal(this.meleeGoal); this.goalSelector.removeGoal(this.bowGoal); @@ -9,7 +9,7 @@ if (itemstack.is(Items.BOW)) { int i = this.getHardAttackInterval(); if (this.level().getDifficulty() != Difficulty.HARD) { -@@ -182,9 +_,11 @@ +@@ -186,9 +_,11 @@ @Override public void performRangedAttack(LivingEntity p_32141_, float p_32142_) { diff --git a/patches/net/minecraft/world/entity/monster/Bogged.java.patch b/patches/net/minecraft/world/entity/monster/Bogged.java.patch index c77e1925..11982e86 100644 --- a/patches/net/minecraft/world/entity/monster/Bogged.java.patch +++ b/patches/net/minecraft/world/entity/monster/Bogged.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/Bogged.java +++ b/net/minecraft/world/entity/monster/Bogged.java -@@ -74,7 +_,7 @@ +@@ -70,7 +_,7 @@ @Override protected InteractionResult mobInteract(Player p_330736_, InteractionHand p_331786_) { ItemStack itemstack = p_330736_.getItemInHand(p_331786_); - if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { + if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { // Neo: Shear logic is handled by IShearable - this.shear(SoundSource.PLAYERS); - this.gameEvent(GameEvent.SHEAR, p_330736_); - if (!this.level().isClientSide) { + if (this.level() instanceof ServerLevel serverlevel) { + this.shear(serverlevel, SoundSource.PLAYERS, itemstack); + this.gameEvent(GameEvent.SHEAR, p_330736_); diff --git a/patches/net/minecraft/world/entity/monster/EnderMan.java.patch b/patches/net/minecraft/world/entity/monster/EnderMan.java.patch index a46e7837..7ef72122 100644 --- a/patches/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/patches/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -16,16 +16,17 @@ } @Override -@@ -214,7 +_,7 @@ +@@ -213,7 +_,8 @@ + } + + boolean isBeingStaredBy(Player p_380267_) { +- return this.isLookingAtMe(p_380267_, 0.025, true, false, LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM, new DoubleSupplier[]{this::getEyeY}); ++ return this.isLookingAtMe(p_380267_, 0.025, true, false, LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM_FOR_TARGET, new DoubleSupplier[]{this::getEyeY}) && ++ !net.neoforged.neoforge.common.CommonHooks.shouldSuppressEnderManAnger(this, p_380267_); + } - boolean isLookingAtMe(Player p_32535_) { - ItemStack itemstack = p_32535_.getInventory().armor.get(3); -- if (itemstack.is(Blocks.CARVED_PUMPKIN.asItem())) { -+ if (net.neoforged.neoforge.common.CommonHooks.shouldSuppressEnderManAnger(this, p_32535_, itemstack)) { - return false; - } else { - Vec3 vec3 = p_32535_.getViewVector(1.0F).normalize(); -@@ -301,8 +_,10 @@ + @Override +@@ -291,8 +_,10 @@ boolean flag = blockstate.blocksMotion(); boolean flag1 = blockstate.getFluidState().is(FluidTags.WATER); if (flag && !flag1) { @@ -37,16 +38,16 @@ if (flag2) { this.level().gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(this)); if (!this.isSilent()) { -@@ -459,7 +_,7 @@ +@@ -449,7 +_,7 @@ if (this.enderman.getCarriedBlock() == null) { return false; } else { -- return !this.enderman.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) -+ return !net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.enderman.level(), this.enderman) +- return !getServerLevel(this.enderman).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ return !net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.enderman.level()), this.enderman) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(2000)) == 0; } -@@ -479,7 +_,7 @@ +@@ -469,7 +_,7 @@ BlockState blockstate2 = this.enderman.getCarriedBlock(); if (blockstate2 != null) { blockstate2 = Block.updateFromNeighbourShapes(blockstate2, this.enderman.level(), blockpos); @@ -55,7 +56,7 @@ level.setBlock(blockpos, blockstate2, 3); level.gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(this.enderman, blockstate2)); this.enderman.setCarriedBlock(null); -@@ -491,6 +_,7 @@ +@@ -481,6 +_,7 @@ return p_32562_.isAir() && !p_32563_.isAir() && !p_32563_.is(Blocks.BEDROCK) @@ -63,12 +64,12 @@ && p_32563_.isCollisionShapeFullBlock(p_32559_, p_32564_) && p_32561_.canSurvive(p_32559_, p_32560_) && p_32559_.getEntities(this.enderman, AABB.unitCubeFromLowerCorner(Vec3.atLowerCornerOf(p_32560_))).isEmpty(); -@@ -602,7 +_,7 @@ +@@ -592,7 +_,7 @@ if (this.enderman.getCarriedBlock() != null) { return false; } else { -- return !this.enderman.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) -+ return !net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.enderman.level(), this.enderman) +- return !getServerLevel(this.enderman).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ return !net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.enderman.level()), this.enderman) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0; } diff --git a/patches/net/minecraft/world/entity/monster/Evoker.java.patch b/patches/net/minecraft/world/entity/monster/Evoker.java.patch index a0a972cc..06281a6d 100644 --- a/patches/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/patches/net/minecraft/world/entity/monster/Evoker.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/Evoker.java +++ b/net/minecraft/world/entity/monster/Evoker.java -@@ -305,7 +_,7 @@ - return false; - } else if (Evoker.this.tickCount < this.nextAttackTickCount) { - return false; -- } else if (!Evoker.this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ } else if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(Evoker.this.level(), Evoker.this)) { +@@ -306,7 +_,7 @@ return false; } else { - List list = Evoker.this.level() + ServerLevel serverlevel = getServerLevel(Evoker.this.level()); +- if (!serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, Evoker.this)) { + return false; + } else { + List list = serverlevel.getNearbyEntities( diff --git a/patches/net/minecraft/world/entity/monster/Husk.java.patch b/patches/net/minecraft/world/entity/monster/Husk.java.patch index f36b13b0..44bb6a9a 100644 --- a/patches/net/minecraft/world/entity/monster/Husk.java.patch +++ b/patches/net/minecraft/world/entity/monster/Husk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Husk.java +++ b/net/minecraft/world/entity/monster/Husk.java -@@ -70,6 +_,7 @@ +@@ -71,6 +_,7 @@ @Override protected void doUnderWaterConversion() { diff --git a/patches/net/minecraft/world/entity/monster/Monster.java.patch b/patches/net/minecraft/world/entity/monster/Monster.java.patch index 48606282..87f0f303 100644 --- a/patches/net/minecraft/world/entity/monster/Monster.java.patch +++ b/patches/net/minecraft/world/entity/monster/Monster.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Monster.java +++ b/net/minecraft/world/entity/monster/Monster.java -@@ -136,11 +_,11 @@ +@@ -137,11 +_,11 @@ @Override public ItemStack getProjectile(ItemStack p_33038_) { if (p_33038_.getItem() instanceof ProjectileWeaponItem) { diff --git a/patches/net/minecraft/world/entity/monster/Pillager.java.patch b/patches/net/minecraft/world/entity/monster/Pillager.java.patch index f08cd904..ea74e23d 100644 --- a/patches/net/minecraft/world/entity/monster/Pillager.java.patch +++ b/patches/net/minecraft/world/entity/monster/Pillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Pillager.java +++ b/net/minecraft/world/entity/monster/Pillager.java -@@ -116,7 +_,7 @@ +@@ -119,7 +_,7 @@ public AbstractIllager.IllagerArmPose getArmPose() { if (this.isChargingCrossbow()) { return AbstractIllager.IllagerArmPose.CROSSBOW_CHARGE; diff --git a/patches/net/minecraft/world/entity/monster/Ravager.java.patch b/patches/net/minecraft/world/entity/monster/Ravager.java.patch index f22f60a2..aabe0a1c 100644 --- a/patches/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/patches/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,11 +1,20 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -134,7 +_,7 @@ - this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Mth.lerp(0.1, d1, d0)); - } +@@ -144,7 +_,7 @@ -- if (this.horizontalCollision && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (this.horizontalCollision && net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this)) { + if (this.level() instanceof ServerLevel serverlevel + && this.horizontalCollision +- && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ && net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, this)) { boolean flag = false; AABB aabb = this.getBoundingBox().inflate(0.2); +@@ -227,7 +_,7 @@ + private void roar() { + if (this.isAlive()) { + if (this.level() instanceof ServerLevel serverlevel) { +- Predicate predicate = serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ Predicate predicate = net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, this) + ? ROAR_TARGET_WITH_GRIEFING + : ROAR_TARGET_WITHOUT_GRIEFING; + diff --git a/patches/net/minecraft/world/entity/monster/Shulker.java.patch b/patches/net/minecraft/world/entity/monster/Shulker.java.patch index f7260e87..7cef3df2 100644 --- a/patches/net/minecraft/world/entity/monster/Shulker.java.patch +++ b/patches/net/minecraft/world/entity/monster/Shulker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Shulker.java +++ b/net/minecraft/world/entity/monster/Shulker.java -@@ -392,6 +_,12 @@ +@@ -395,6 +_,12 @@ && this.level().noCollision(this, new AABB(blockpos1).deflate(1.0E-6))) { Direction direction = this.findAttachableSurface(blockpos1); if (direction != null) { diff --git a/patches/net/minecraft/world/entity/monster/Silverfish.java.patch b/patches/net/minecraft/world/entity/monster/Silverfish.java.patch index 41ef0fa6..01211fe0 100644 --- a/patches/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/patches/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/monster/Silverfish.java +++ b/net/minecraft/world/entity/monster/Silverfish.java -@@ -140,7 +_,7 @@ +@@ -143,7 +_,7 @@ return false; } else { RandomSource randomsource = this.mob.getRandom(); -- if (this.mob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && randomsource.nextInt(reducedTickDelay(10)) == 0) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.mob.level(), this.mob) && randomsource.nextInt(reducedTickDelay(10)) == 0) { +- if (getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && randomsource.nextInt(reducedTickDelay(10)) == 0) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.mob.level()), this.mob) && randomsource.nextInt(reducedTickDelay(10)) == 0) { this.selectedDirection = Direction.getRandom(randomsource); BlockPos blockpos = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5, this.mob.getZ()).relative(this.selectedDirection); BlockState blockstate = this.mob.level().getBlockState(blockpos); -@@ -211,7 +_,7 @@ +@@ -214,7 +_,7 @@ BlockState blockstate = level.getBlockState(blockpos1); Block block = blockstate.getBlock(); if (block instanceof InfestedBlock) { -- if (level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(level, this.silverfish)) { +- if (getServerLevel(level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(level), this.silverfish)) { level.destroyBlock(blockpos1, true, this.silverfish); } else { level.setBlock(blockpos1, ((InfestedBlock)block).hostStateByInfested(level.getBlockState(blockpos1)), 3); diff --git a/patches/net/minecraft/world/entity/monster/Skeleton.java.patch b/patches/net/minecraft/world/entity/monster/Skeleton.java.patch index 499e41ec..2b3815fc 100644 --- a/patches/net/minecraft/world/entity/monster/Skeleton.java.patch +++ b/patches/net/minecraft/world/entity/monster/Skeleton.java.patch @@ -1,13 +1,12 @@ --- a/net/minecraft/world/entity/monster/Skeleton.java +++ b/net/minecraft/world/entity/monster/Skeleton.java -@@ -86,7 +_,9 @@ +@@ -89,7 +_,9 @@ } protected void doFreezeConversion() { -- this.convertTo(EntityType.STRAY, true); + if (!net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.STRAY, (timer) -> this.conversionTime = timer)) return; -+ Stray stray = this.convertTo(EntityType.STRAY, true); -+ if (stray != null) net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, stray); - if (!this.isSilent()) { - this.level().levelEvent(null, 1048, this.blockPosition(), 0); - } + this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), p_381508_ -> { ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381508_); + if (!this.isSilent()) { + this.level().levelEvent(null, 1048, this.blockPosition(), 0); + } diff --git a/patches/net/minecraft/world/entity/monster/Slime.java.patch b/patches/net/minecraft/world/entity/monster/Slime.java.patch index 27fde65d..7f975fbf 100644 --- a/patches/net/minecraft/world/entity/monster/Slime.java.patch +++ b/patches/net/minecraft/world/entity/monster/Slime.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java -@@ -139,6 +_,8 @@ +@@ -146,6 +_,8 @@ float f = this.getDimensions(this.getPose()).width() * 2.0F; float f1 = f / 2.0F; @@ -9,31 +9,33 @@ for (int i = 0; (float)i < f * 16.0F; i++) { float f2 = this.random.nextFloat() * (float) (Math.PI * 2); float f3 = this.random.nextFloat() * 0.5F + 0.5F; -@@ -204,6 +_,8 @@ - int j = i / 2; +@@ -210,15 +_,24 @@ int k = 2 + this.random.nextInt(3); + PlayerTeam playerteam = this.getTeam(); + var children = new java.util.ArrayList(); // Neo: Children list for MobSplitEvent. + ++ this.preventConversionSpawns = true; for (int l = 0; l < k; l++) { float f2 = ((float)(l % 2) - 0.5F) * f1; float f3 = ((float)(l / 2) - 0.5F) * f1; -@@ -218,8 +_,13 @@ - slime.setInvulnerable(this.isInvulnerable()); - slime.setSize(j, true); - slime.moveTo(this.getX() + (double)f2, this.getY() + 0.5, this.getZ() + (double)f3, this.random.nextFloat() * 360.0F, 0.0F); -- this.level().addFreshEntity(slime); -+ -+ children.add(slime); // Neo: Record the slime until after event firing. - } +- this.convertTo( ++ Slime slime = this.convertTo( + this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, playerteam), EntitySpawnReason.TRIGGERED, p_381514_ -> { + p_381514_.setSize(j, true); + p_381514_.moveTo(this.getX() + (double)f2, this.getY() + 0.5, this.getZ() + (double)f3, this.random.nextFloat() * 360.0F, 0.0F); + } + ); ++ children.add(slime); // Neo: Record the slime until after event firing. + } ++ this.preventConversionSpawns = false; + + if (!net.neoforged.neoforge.event.EventHooks.onMobSplit(this, children).isCanceled()) { + children.forEach(this.level()::addFreshEntity); } } -@@ -334,6 +_,7 @@ +@@ -327,6 +_,7 @@ Vec3 vec3 = this.getDeltaMovement(); this.setDeltaMovement(vec3.x, (double)this.getJumpPower(), vec3.z); this.hasImpulse = true; @@ -41,7 +43,7 @@ } @Nullable -@@ -363,6 +_,12 @@ +@@ -358,6 +_,12 @@ public EntityDimensions getDefaultDimensions(Pose p_316359_) { return super.getDefaultDimensions(p_316359_).scale((float)this.getSize()); } diff --git a/patches/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch b/patches/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch deleted file mode 100644 index 1d98f32d..00000000 --- a/patches/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/world/entity/monster/SpellcasterIllager.java -+++ b/net/minecraft/world/entity/monster/SpellcasterIllager.java -@@ -174,7 +_,6 @@ - } - - public abstract class SpellcasterUseSpellGoal extends Goal { -- protected SpellcasterUseSpellGoal() {} - protected int attackWarmupDelay; - protected int nextAttackTickCount; - diff --git a/patches/net/minecraft/world/entity/monster/Zombie.java.patch b/patches/net/minecraft/world/entity/monster/Zombie.java.patch index 8ea34cbb..08f332ee 100644 --- a/patches/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/patches/net/minecraft/world/entity/monster/Zombie.java.patch @@ -1,14 +1,6 @@ --- a/net/minecraft/world/entity/monster/Zombie.java +++ b/net/minecraft/world/entity/monster/Zombie.java -@@ -63,6 +_,7 @@ - import net.minecraft.world.level.ServerLevelAccessor; - import net.minecraft.world.level.block.Blocks; - import net.minecraft.world.level.block.state.BlockState; -+import org.bukkit.event.entity.CreatureSpawnEvent; - - public class Zombie extends Monster { - private static final ResourceLocation SPEED_MODIFIER_BABY_ID = ResourceLocation.withDefaultNamespace("baby"); -@@ -259,6 +_,7 @@ +@@ -257,6 +_,7 @@ } protected void doUnderWaterConversion() { @@ -16,26 +8,27 @@ this.convertToZombieType(EntityType.DROWNED); if (!this.isSilent()) { this.level().levelEvent(null, 1040, this.blockPosition(), 0); -@@ -270,6 +_,7 @@ - if (zombie != null) { - zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()); - zombie.setCanBreakDoors(zombie.supportsBreakDoorGoal() && this.canBreakDoors()); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, zombie); - } - } - -@@ -383,6 +_,10 @@ - } +@@ -267,7 +_,10 @@ + this.convertTo( + p_34311_, + ConversionParams.single(this, true, true), +- p_381517_ -> p_381517_.handleAttributes(p_381517_.level().getCurrentDifficultyAt(p_381517_.blockPosition()).getSpecialMultiplier()) ++ p_381517_ -> { ++ p_381517_.handleAttributes(p_381517_.level().getCurrentDifficultyAt(p_381517_.blockPosition()).getSpecialMultiplier()); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381517_); ++ } + ); } -+ public static ZombieVillager zombifyVillager(ServerLevel worldserver, Villager entityvillager, net.minecraft.core.BlockPos blockPosition, boolean silent, CreatureSpawnEvent.SpawnReason spawnReason) { -+ return null; -+ } -+ - @Override - public void addAdditionalSaveData(CompoundTag p_34319_) { - super.addAdditionalSaveData(p_34319_); -@@ -406,7 +_,7 @@ +@@ -287,6 +_,7 @@ + p_370686_.setGossips(p_371444_.getGossips().store(NbtOps.INSTANCE)); + p_370686_.setTradeOffers(p_371444_.getOffers().copy()); + p_370686_.setVillagerXp(p_371444_.getVillagerXp()); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(p_371444_, p_370686_); + if (!this.isSilent()) { + p_371466_.levelEvent(null, 1026, this.blockPosition(), 0); + } +@@ -437,7 +_,7 @@ @Override public boolean killedEntity(ServerLevel p_219160_, LivingEntity p_219161_) { boolean flag = super.killedEntity(p_219160_, p_219161_); @@ -44,11 +37,3 @@ if (p_219160_.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { return flag; } -@@ -423,6 +_,7 @@ - zombievillager.setGossips(villager.getGossips().store(NbtOps.INSTANCE)); - zombievillager.setTradeOffers(villager.getOffers().copy()); - zombievillager.setVillagerXp(villager.getVillagerXp()); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(p_219161_, zombievillager); - if (!this.isSilent()) { - p_219160_.levelEvent(null, 1026, this.blockPosition(), 0); - } diff --git a/patches/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/patches/net/minecraft/world/entity/monster/ZombieVillager.java.patch index 08521a52..bf52e0c7 100644 --- a/patches/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/patches/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -141,7 +_,7 @@ +@@ -143,7 +_,7 @@ if (!this.level().isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); this.villagerConversionTime -= i; @@ -9,11 +9,12 @@ this.finishConversion((ServerLevel)this.level()); } } -@@ -246,6 +_,7 @@ - if (!this.isSilent()) { - p_34399_.levelEvent(null, 1027, this.blockPosition(), 0); +@@ -250,6 +_,8 @@ + if (!this.isSilent()) { + p_34399_.levelEvent(null, 1027, this.blockPosition(), 0); + } ++ ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_375894_); } -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, villager); - } + ); } - diff --git a/patches/net/minecraft/world/entity/monster/creaking/Creaking.java.patch b/patches/net/minecraft/world/entity/monster/creaking/Creaking.java.patch new file mode 100644 index 00000000..8718946d --- /dev/null +++ b/patches/net/minecraft/world/entity/monster/creaking/Creaking.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/entity/monster/creaking/Creaking.java ++++ b/net/minecraft/world/entity/monster/creaking/Creaking.java +@@ -230,7 +_,8 @@ + + return true; + } else { +- Predicate predicate = this.isActive() ? LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM : p_380174_ -> true; ++ // Neo: provide entity being looked at to disguise check ++ java.util.function.BiPredicate predicate = this.isActive() ? LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM_FOR_TARGET : (p_380174_, target) -> true; + + for (Player player : list) { + if (!player.isCreative() diff --git a/patches/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch b/patches/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch index 14a4f5a4..4c3ea3d2 100644 --- a/patches/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch +++ b/patches/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -1,19 +1,23 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -161,7 +_,7 @@ +@@ -166,7 +_,7 @@ HoglinAi.updateActivity(this); if (this.isConverting()) { this.timeInOverworld++; - if (this.timeInOverworld > 300) { + if (this.timeInOverworld > 300 && net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.ZOGLIN, (timer) -> this.timeInOverworld = timer)) { this.makeSound(SoundEvents.HOGLIN_CONVERTED_TO_ZOMBIFIED); - this.finishConversion((ServerLevel)this.level()); + this.finishConversion(); } -@@ -259,6 +_,7 @@ - Zoglin zoglin = this.convertTo(EntityType.ZOGLIN, true); - if (zoglin != null) { - zoglin.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, zoglin); - } +@@ -266,7 +_,10 @@ + this.convertTo( + EntityType.ZOGLIN, + ConversionParams.single(this, true, false), +- p_371903_ -> p_371903_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)) ++ p_371903_ -> { ++ p_371903_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_371903_); ++ } + ); } diff --git a/patches/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch b/patches/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch index 36ab4f9c..d33c4497 100644 --- a/patches/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch +++ b/patches/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch @@ -1,19 +1,23 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java -@@ -82,7 +_,7 @@ +@@ -84,7 +_,7 @@ this.timeInOverworld = 0; } - if (this.timeInOverworld > 300) { + if (this.timeInOverworld > 300 && net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.ZOMBIFIED_PIGLIN, (timer) -> this.timeInOverworld = timer)) { this.playConvertedSound(); - this.finishConversion((ServerLevel)this.level()); - } -@@ -96,6 +_,7 @@ - ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, true); - if (zombifiedpiglin != null) { - zombifiedpiglin.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, zombifiedpiglin); + this.finishConversion(p_376586_); } +@@ -103,7 +_,10 @@ + this.convertTo( + EntityType.ZOMBIFIED_PIGLIN, + ConversionParams.single(this, true, true), +- p_371722_ -> p_371722_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)) ++ p_371722_ -> { ++ p_371722_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_371722_); ++ } + ); } diff --git a/patches/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/patches/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index 8bb786c6..fc041711 100644 --- a/patches/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/patches/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -349,7 +_,7 @@ +@@ -355,7 +_,7 @@ } else if (this.isChargingCrossbow()) { return PiglinArmPose.CROSSBOW_CHARGE; } else { -- return this.isAggressive() && this.isHolding(Items.CROSSBOW) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; -+ return this.isAggressive() && this.isHolding(is -> is.getItem() instanceof net.minecraft.world.item.CrossbowItem) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; +- return this.isHolding(Items.CROSSBOW) && CrossbowItem.isCharged(this.getWeaponItem()) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; ++ return this.isHolding(is -> is.getItem() instanceof net.minecraft.world.item.CrossbowItem) && CrossbowItem.isCharged(this.getWeaponItem()) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; } } -@@ -390,7 +_,7 @@ +@@ -392,7 +_,7 @@ } protected void holdInOffHand(ItemStack p_34786_) { @@ -18,12 +18,12 @@ this.setItemSlot(EquipmentSlot.OFFHAND, p_34786_); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -400,7 +_,7 @@ +@@ -402,7 +_,7 @@ @Override - public boolean wantsToPickUp(ItemStack p_34777_) { -- return this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); -+ return net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); + public boolean wantsToPickUp(ServerLevel p_376232_, ItemStack p_34777_) { +- return p_376232_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); ++ return net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_376232_, this) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); } protected boolean canReplaceCurrentItem(ItemStack p_34788_) { diff --git a/patches/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/patches/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch index 3aa8dcc2..6aa8151c 100644 --- a/patches/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch +++ b/patches/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java -@@ -377,7 +_,7 @@ +@@ -375,7 +_,7 @@ ItemStack itemstack = p_34868_.getItemInHand(InteractionHand.OFF_HAND); p_34868_.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); if (p_34868_.isAdult()) { @@ -9,7 +9,7 @@ if (p_34869_ && flag) { throwItems(p_34868_, getBarterResponseItems(p_34868_)); } else if (!flag) { -@@ -461,7 +_,7 @@ +@@ -459,7 +_,7 @@ return false; } else if (isAdmiringDisabled(p_34858_) && p_34858_.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; @@ -18,7 +18,7 @@ return isNotHoldingLovedItemInOffHand(p_34858_); } else { boolean flag = p_34858_.canAddToInventory(p_34859_); -@@ -551,7 +_,7 @@ +@@ -549,7 +_,7 @@ } protected static boolean canAdmire(Piglin p_34910_, ItemStack p_34911_) { @@ -26,17 +26,17 @@ + return !isAdmiringDisabled(p_34910_) && !isAdmiringItem(p_34910_) && p_34910_.isAdult() && p_34911_.isPiglinCurrency(); } - protected static void wasHurtBy(Piglin p_34838_, LivingEntity p_34839_) { -@@ -641,7 +_,7 @@ - public static boolean isWearingGold(LivingEntity p_34809_) { - for (ItemStack itemstack : p_34809_.getArmorAndBodyArmorSlots()) { - Item item = itemstack.getItem(); -- if (item instanceof ArmorItem && ((ArmorItem)item).getMaterial().is(ArmorMaterials.GOLD)) { -+ if (itemstack.makesPiglinsNeutral(p_34809_)) { + protected static void wasHurtBy(ServerLevel p_376829_, Piglin p_34838_, LivingEntity p_34839_) { +@@ -638,7 +_,7 @@ + + public static boolean isWearingSafeArmor(LivingEntity p_371788_) { + for (ItemStack itemstack : p_371788_.getArmorAndBodyArmorSlots()) { +- if (itemstack.is(ItemTags.PIGLIN_SAFE_ARMOR)) { ++ if (itemstack.makesPiglinsNeutral(p_371788_)) { return true; } } -@@ -792,7 +_,7 @@ +@@ -790,7 +_,7 @@ } private static boolean hasCrossbow(LivingEntity p_34919_) { diff --git a/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch b/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch index 29b127e4..62dfc9f6 100644 --- a/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch +++ b/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch @@ -3,9 +3,9 @@ @@ -11,7 +_,7 @@ public static BehaviorControl create() { return BehaviorBuilder.create( - p_259197_ -> p_259197_.group(p_259197_.absent(MemoryModuleType.ADMIRING_ITEM)).apply(p_259197_, p_259512_ -> (p_352826_, p_352827_, p_352828_) -> { -- if (!p_352827_.getOffhandItem().isEmpty() && !p_352827_.getOffhandItem().is(Items.SHIELD)) { -+ if (!p_352827_.getOffhandItem().isEmpty() && !p_352827_.getOffhandItem().canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHIELD_BLOCK)) { - PiglinAi.stopHoldingOffHandItem(p_352827_, true); + p_259197_ -> p_259197_.group(p_259197_.absent(MemoryModuleType.ADMIRING_ITEM)).apply(p_259197_, p_259512_ -> (p_381534_, p_381535_, p_381536_) -> { +- if (!p_381535_.getOffhandItem().isEmpty() && !p_381535_.getOffhandItem().is(Items.SHIELD)) { ++ if (!p_381535_.getOffhandItem().isEmpty() && !p_381535_.getOffhandItem().canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHIELD_BLOCK)) { + PiglinAi.stopHoldingOffHandItem(p_381534_, p_381535_, true); return true; } else { diff --git a/patches/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/patches/net/minecraft/world/entity/npc/AbstractVillager.java.patch index 043791fc..961d41ff 100644 --- a/patches/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ b/patches/net/minecraft/world/entity/npc/AbstractVillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -127,6 +_,7 @@ +@@ -129,6 +_,7 @@ if (this.tradingPlayer instanceof ServerPlayer) { CriteriaTriggers.TRADE.trigger((ServerPlayer)this.tradingPlayer, this, p_35274_.getResult()); } @@ -8,7 +8,7 @@ } protected abstract void rewardTradeXp(MerchantOffer p_35299_); -@@ -183,13 +_,6 @@ +@@ -185,13 +_,6 @@ } this.readInventoryFromTag(p_35290_, this.registryAccess()); @@ -16,9 +16,9 @@ - - @Nullable - @Override -- public Entity changeDimension(DimensionTransition p_350994_) { +- public Entity teleport(TeleportTransition p_379715_) { - this.stopTrading(); -- return super.changeDimension(p_350994_); +- return super.teleport(p_379715_); } protected void stopTrading() { diff --git a/patches/net/minecraft/world/entity/npc/CatSpawner.java.patch b/patches/net/minecraft/world/entity/npc/CatSpawner.java.patch index c0cbf518..f15338a7 100644 --- a/patches/net/minecraft/world/entity/npc/CatSpawner.java.patch +++ b/patches/net/minecraft/world/entity/npc/CatSpawner.java.patch @@ -5,7 +5,7 @@ return 0; } else { + cat.moveTo(p_35334_, 0.0F, 0.0F); // Fix MC-147659: Some witch huts spawn the incorrect cat - cat.finalizeSpawn(p_35335_, p_35335_.getCurrentDifficultyAt(p_35334_), MobSpawnType.NATURAL, null); + cat.finalizeSpawn(p_35335_, p_35335_.getCurrentDifficultyAt(p_35334_), EntitySpawnReason.NATURAL, null); - cat.moveTo(p_35334_, 0.0F, 0.0F); p_35335_.addFreshEntityWithPassengers(cat); return 1; diff --git a/patches/net/minecraft/world/entity/npc/Villager.java.patch b/patches/net/minecraft/world/entity/npc/Villager.java.patch index f206fb91..308d4a20 100644 --- a/patches/net/minecraft/world/entity/npc/Villager.java.patch +++ b/patches/net/minecraft/world/entity/npc/Villager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/Villager.java +++ b/net/minecraft/world/entity/npc/Villager.java -@@ -322,7 +_,7 @@ +@@ -313,7 +_,7 @@ @Override public InteractionResult mobInteract(Player p_35472_, InteractionHand p_35473_) { ItemStack itemstack = p_35472_.getItemInHand(p_35473_); @@ -9,7 +9,7 @@ return super.mobInteract(p_35472_, p_35473_); } else if (this.isBaby()) { this.setUnhappy(); -@@ -742,8 +_,9 @@ +@@ -719,8 +_,9 @@ @Override protected Component getTypeName() { @@ -20,32 +20,28 @@ ); } -@@ -799,7 +_,7 @@ +@@ -781,10 +_,11 @@ @Override public void thunderHit(ServerLevel p_35409_, LightningBolt p_35410_) { - if (p_35409_.getDifficulty() != Difficulty.PEACEFUL) { + if (p_35409_.getDifficulty() != Difficulty.PEACEFUL && net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.WITCH, (timer) -> {})) { LOGGER.info("Villager {} was struck by lightning {}.", this, p_35410_); - Witch witch = EntityType.WITCH.create(p_35409_); - if (witch != null) { -@@ -812,6 +_,7 @@ - } - - witch.setPersistenceRequired(); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, witch); - p_35409_.addFreshEntityWithPassengers(witch); + Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), p_381540_ -> { + p_381540_.finalizeSpawn(p_35409_, p_35409_.getCurrentDifficultyAt(p_381540_.blockPosition()), EntitySpawnReason.CONVERSION, null); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381540_); + p_381540_.setPersistenceRequired(); this.releaseAllPois(); - this.discard(); -@@ -831,7 +_,10 @@ + }); +@@ -804,7 +_,10 @@ @Override - public boolean wantsToPickUp(ItemStack p_35543_) { + public boolean wantsToPickUp(ServerLevel p_376823_, ItemStack p_35543_) { Item item = p_35543_.getItem(); -- return (WANTED_ITEMS.contains(item) || this.getVillagerData().getProfession().requestedItems().contains(item)) -+ // Neo: Patched so that Farmer Villagers will pick up SpecialPlantable items. Also fixes MC-274244 by making "minecraft:villager_plantable_seeds" tagged items also be picked up by Farmer Villagers to be planted later. -+ boolean isFarmerDesiredSeed = (p_35543_.is(ItemTags.VILLAGER_PLANTABLE_SEEDS) || (p_35543_.getItem() instanceof net.neoforged.neoforge.common.SpecialPlantable specialPlantable && specialPlantable.villagerCanPlantItem(this))) +- return (p_35543_.is(ItemTags.VILLAGER_PICKS_UP) || this.getVillagerData().getProfession().requestedItems().contains(item)) ++ // Neo: Allow Farmer Villagers to pick up SpecialPlantable items. ++ boolean isFarmerDesiredSeed = (p_35543_.getItem() instanceof net.neoforged.neoforge.common.SpecialPlantable specialPlantable && specialPlantable.villagerCanPlantItem(this)) + && this.getVillagerData().getProfession().secondaryPoi().stream().anyMatch(secondaryPoi -> secondaryPoi.defaultBlockState().is(net.neoforged.neoforge.common.Tags.Blocks.VILLAGER_FARMLANDS)); -+ return (WANTED_ITEMS.contains(item) || this.getVillagerData().getProfession().requestedItems().contains(item) || isFarmerDesiredSeed) ++ return (p_35543_.is(ItemTags.VILLAGER_PICKS_UP) || this.getVillagerData().getProfession().requestedItems().contains(item) || isFarmerDesiredSeed) && this.getInventory().canAddItem(p_35543_); } diff --git a/patches/net/minecraft/world/entity/player/Inventory.java.patch b/patches/net/minecraft/world/entity/player/Inventory.java.patch index 661a1682..17c929ae 100644 --- a/patches/net/minecraft/world/entity/player/Inventory.java.patch +++ b/patches/net/minecraft/world/entity/player/Inventory.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java -@@ -133,7 +_,7 @@ +@@ -132,7 +_,7 @@ for (int k = 0; k < 9; k++) { int l = (this.selected + k) % 9; @@ -9,7 +9,7 @@ return l; } } -@@ -214,11 +_,15 @@ +@@ -204,11 +_,15 @@ } public void tick() { @@ -26,7 +26,7 @@ } } } -@@ -268,6 +_,8 @@ +@@ -258,6 +_,8 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Adding item to inventory"); CrashReportCategory crashreportcategory = crashreport.addCategory("Item being added"); diff --git a/patches/net/minecraft/world/entity/player/Player.java.patch b/patches/net/minecraft/world/entity/player/Player.java.patch index e5436819..a4bdc8c8 100644 --- a/patches/net/minecraft/world/entity/player/Player.java.patch +++ b/patches/net/minecraft/world/entity/player/Player.java.patch @@ -1,22 +1,7 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -11,6 +_,8 @@ - import java.util.Map; - import java.util.Optional; - import java.util.OptionalInt; -+import java.util.concurrent.atomic.AtomicBoolean; -+import java.util.concurrent.atomic.AtomicReference; - import java.util.function.Predicate; - import javax.annotation.Nonnull; - import javax.annotation.Nullable; -@@ -111,9 +_,14 @@ - import net.minecraft.world.scores.PlayerTeam; - import net.minecraft.world.scores.Scoreboard; +@@ -117,7 +_,8 @@ import net.minecraft.world.scores.Team; -+import org.bukkit.craftbukkit.entity.CraftHumanEntity; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.event.entity.EntityExhaustionEvent; -+import org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason; import org.slf4j.Logger; -public abstract class Player extends LivingEntity { @@ -25,7 +10,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final HumanoidArm DEFAULT_MAIN_HAND = HumanoidArm.RIGHT; public static final int DEFAULT_MODEL_CUSTOMIZATION = 0; -@@ -193,6 +_,21 @@ +@@ -197,6 +_,10 @@ public Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse; private int currentImpulseContextResetGraceTime; @@ -33,21 +18,10 @@ + private final java.util.Collection suffixes = new java.util.LinkedList<>(); + @Nullable private Pose forcedPose; + private long lastDayTimeTick = -1L; // Neo: Used to limit TIME_SINCE_REST increases when day length is non-standard. No need to persist, at most Phantoms will spawn one tick too early for each save/load cycle. -+ -+ -+ // CraftBukkit start -+ public boolean fauxSleeping; -+ public int oldLevel = -1; -+ -+ @Override -+ public CraftHumanEntity getBukkitEntity() { -+ return (CraftHumanEntity) super.getBukkitEntity(); -+ } -+ // CraftBukkit end public Player(Level p_250508_, BlockPos p_250289_, float p_251702_, GameProfile p_252153_) { super(EntityType.PLAYER, p_250508_); -@@ -229,7 +_,8 @@ +@@ -233,7 +_,8 @@ .add(Attributes.SUBMERGED_MINING_SPEED) .add(Attributes.SNEAKING_SPEED) .add(Attributes.MINING_EFFICIENCY) @@ -57,7 +31,7 @@ } @Override -@@ -245,6 +_,7 @@ +@@ -249,6 +_,7 @@ @Override public void tick() { @@ -65,7 +39,7 @@ this.noPhysics = this.isSpectator(); if (this.isSpectator()) { this.setOnGround(false); -@@ -260,7 +_,7 @@ +@@ -264,7 +_,7 @@ this.sleepCounter = 100; } @@ -74,20 +48,20 @@ this.stopSleepInBed(false, true); } } else if (this.sleepCounter > 0) { -@@ -291,7 +_,11 @@ +@@ -295,7 +_,11 @@ } if (!this.isSleeping()) { - this.awardStat(Stats.TIME_SINCE_REST); + // Neo: Advance TIME_SINCE_REST if (a) vanilla daytime handling in effect, or (b) days are shorter, or (c) dayTime has ticked, or (d) dayTime advances are off and we need to ignore day length -+ if (level().getDayTimeFraction() < 0 || level().getDayTimeFraction() >= 1 || lastDayTimeTick != level().getDayTime() || !level().getGameRules().getRule(GameRules.RULE_DAYLIGHT).get()) { ++ if (level().getDayTimeFraction() < 0 || level().getDayTimeFraction() >= 1 || lastDayTimeTick != level().getDayTime() || !serverplayer.serverLevel().getGameRules().getRule(GameRules.RULE_DAYLIGHT).get()) { + lastDayTimeTick = level().getDayTime(); + this.awardStat(Stats.TIME_SINCE_REST); + } } } -@@ -318,6 +_,7 @@ +@@ -325,6 +_,7 @@ if (this.currentImpulseContextResetGraceTime > 0) { this.currentImpulseContextResetGraceTime--; } @@ -95,7 +69,7 @@ } @Override -@@ -397,6 +_,10 @@ +@@ -427,6 +_,10 @@ } protected void updatePlayerPose() { @@ -106,7 +80,7 @@ if (this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.SWIMMING)) { Pose pose; if (this.isFallFlying()) { -@@ -630,6 +_,7 @@ +@@ -654,6 +_,7 @@ @Override public void die(DamageSource p_36152_) { @@ -114,7 +88,7 @@ super.die(p_36152_); this.reapplyPosition(); if (!this.isSpectator() && this.level() instanceof ServerLevel serverlevel) { -@@ -684,7 +_,7 @@ +@@ -711,7 +_,7 @@ @Nullable public ItemEntity drop(ItemStack p_36177_, boolean p_36178_) { @@ -123,20 +97,23 @@ } @Nullable -@@ -726,7 +_,12 @@ - } +@@ -723,7 +_,15 @@ + return null; } -+ @Deprecated //Use location sensitive version below ++ /** ++ * @deprecated Neo: {@link #getDestroySpeed(BlockState, BlockPos)} instead ++ */ ++ @Deprecated public float getDestroySpeed(BlockState p_36282_) { -+ return getDigSpeed(p_36282_, null); ++ return getDestroySpeed(p_36282_, null); + } + -+ public float getDigSpeed(BlockState p_36282_, @Nullable BlockPos pos) { ++ public float getDestroySpeed(BlockState p_36282_, @Nullable BlockPos pos) { float f = this.inventory.getDestroySpeed(p_36282_); if (f > 1.0F) { f += (float)this.getAttributeValue(Attributes.MINING_EFFICIENCY); -@@ -754,13 +_,19 @@ +@@ -752,13 +_,19 @@ f /= 5.0F; } @@ -156,18 +133,17 @@ @Override public void readAdditionalSaveData(CompoundTag p_36215_) { super.readAdditionalSaveData(p_36215_); -@@ -872,7 +_,9 @@ - this.removeEntitiesOnShoulder(); - } - -- if (p_36154_.scalesWithDifficulty()) { -+ p_36155_ = Math.max(0.0F, p_36154_.type().scaling().getScalingFunction().scaleDamage(p_36154_, this, p_36155_, this.level().getDifficulty())); -+ -+ if (false && p_36154_.scalesWithDifficulty()) { - if (this.level().getDifficulty() == Difficulty.PEACEFUL) { - p_36155_ = 0.0F; +@@ -867,7 +_,8 @@ + return false; + } else { + this.removeEntitiesOnShoulder(); +- if (p_376171_.scalesWithDifficulty()) { ++ p_376389_ = Math.max(0.0F, p_376171_.type().scaling().getScalingFunction().scaleDamage(p_376171_, this, p_376389_, this.level().getDifficulty())); ++ if (false && p_376171_.scalesWithDifficulty()) { + if (p_376451_.getDifficulty() == Difficulty.PEACEFUL) { + p_376389_ = 0.0F; } -@@ -926,7 +_,7 @@ +@@ -922,7 +_,7 @@ @Override protected void hurtCurrentlyUsedShield(float p_36383_) { @@ -176,7 +152,7 @@ if (!this.level().isClientSide) { this.awardStat(Stats.ITEM_USED.get(this.useItem.getItem())); } -@@ -934,7 +_,13 @@ +@@ -930,7 +_,13 @@ if (p_36383_ >= 3.0F) { int i = 1 + Mth.floor(p_36383_); InteractionHand interactionhand = this.getUsedItemHand(); @@ -191,10 +167,10 @@ if (this.useItem.isEmpty()) { if (interactionhand == InteractionHand.MAIN_HAND) { this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); -@@ -952,11 +_,14 @@ +@@ -948,11 +_,14 @@ @Override - protected void actuallyHurt(DamageSource p_36312_, float p_36313_) { - if (!this.isInvulnerableTo(p_36312_)) { + protected void actuallyHurt(ServerLevel p_376500_, DamageSource p_36312_, float p_36313_) { + if (!this.isInvulnerableTo(p_376500_, p_36312_)) { - p_36313_ = this.getDamageAfterArmorAbsorb(p_36312_, p_36313_); - p_36313_ = this.getDamageAfterMagicAbsorb(p_36312_, p_36313_); - float f1 = Math.max(p_36313_ - this.getAbsorptionAmount(), 0.0F); @@ -211,7 +187,7 @@ if (f > 0.0F && f < 3.4028235E37F) { this.awardStat(Stats.DAMAGE_ABSORBED, Math.round(f * 10.0F)); } -@@ -970,7 +_,9 @@ +@@ -966,7 +_,9 @@ } this.gameEvent(GameEvent.ENTITY_DAMAGE); @@ -221,7 +197,7 @@ } } -@@ -1014,6 +_,8 @@ +@@ -1010,6 +_,8 @@ return InteractionResult.PASS; } else { @@ -230,7 +206,7 @@ ItemStack itemstack = this.getItemInHand(p_36159_); ItemStack itemstack1 = itemstack.copy(); InteractionResult interactionresult = p_36158_.interact(this, p_36159_); -@@ -1022,6 +_,9 @@ +@@ -1018,6 +_,9 @@ itemstack.setCount(itemstack1.getCount()); } @@ -240,7 +216,7 @@ return interactionresult; } else { if (!itemstack.isEmpty() && p_36158_ instanceof LivingEntity) { -@@ -1033,6 +_,7 @@ +@@ -1029,6 +_,7 @@ if (interactionresult1.consumesAction()) { this.level().gameEvent(GameEvent.ENTITY_INTERACT, p_36158_.position(), GameEvent.Context.of(this)); if (itemstack.isEmpty() && !this.abilities.instabuild) { @@ -248,7 +224,7 @@ this.setItemInHand(p_36159_, ItemStack.EMPTY); } -@@ -1062,6 +_,7 @@ +@@ -1058,6 +_,7 @@ } @Override @@ -256,7 +232,7 @@ protected Vec3 maybeBackOffFromEdge(Vec3 p_36201_, MoverType p_36202_) { float f = this.maxUpStep(); if (!this.abilities.flying -@@ -1111,6 +_,7 @@ +@@ -1107,6 +_,7 @@ } } @@ -264,7 +240,7 @@ private boolean isAboveGround(float p_341626_) { return this.onGround() || this.fallDistance < p_341626_ && !this.canFallAtLeast(0.0, 0.0, p_341626_ - this.fallDistance); } -@@ -1132,6 +_,7 @@ +@@ -1128,6 +_,7 @@ } public void attack(Entity p_36347_) { @@ -272,7 +248,7 @@ if (p_36347_.isAttackable()) { if (!p_36347_.skipAttackInteraction(this)) { float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); -@@ -1141,7 +_,6 @@ +@@ -1137,7 +_,6 @@ float f2 = this.getAttackStrengthScale(0.5F); f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -280,12 +256,12 @@ if (p_36347_.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && p_36347_ instanceof Projectile projectile && projectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, this, true)) { -@@ -1170,8 +_,12 @@ +@@ -1166,20 +_,31 @@ && !this.isPassenger() && p_36347_ instanceof LivingEntity && !this.isSprinting(); + // Neo: Fire the critical hit event and override the critical hit status and damage multiplier based on the event. -+ // The boolean local above (flag2) is the vanilla critical hit result. ++ // The boolean local above (flag1) is the vanilla critical hit result. + var critEvent = net.neoforged.neoforge.common.CommonHooks.fireCriticalHit(this, p_36347_, flag1, flag1 ? 1.5F : 1.0F); + flag1 = critEvent.isCriticalHit(); if (flag1) { @@ -294,18 +270,28 @@ } float f3 = f + f1; -@@ -1179,9 +_,7 @@ - double d0 = (double)(this.walkDist - this.walkDistO); - if (flag4 && !flag1 && !flag && this.onGround() && d0 < (double)this.getSpeed()) { - ItemStack itemstack1 = this.getItemInHand(InteractionHand.MAIN_HAND); -- if (itemstack1.getItem() instanceof SwordItem) { -- flag2 = true; -- } -+ flag2 = itemstack1.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SWORD_SWEEP); + boolean flag2 = false; +- if (flag3 && !flag1 && !flag && this.onGround()) { ++ // Neo: Replace !flag1 (!isCriticalHit) with the logic from the CriticalHitEvent. ++ boolean critBlocksSweep = critEvent.isCriticalHit() && critEvent.disableSweep(); ++ if (flag3 && !critBlocksSweep && !flag && this.onGround()) { + double d0 = this.getKnownMovement().horizontalDistanceSqr(); + double d1 = (double)this.getSpeed() * 2.5; +- if (d0 < Mth.square(d1) && this.getItemInHand(InteractionHand.MAIN_HAND).is(ItemTags.SWORDS)) { ++ // Neo: Make sweep attacks check SWORD_SWEEP instead of instanceof SwordItem. ++ if (d0 < Mth.square(d1) && this.getItemInHand(InteractionHand.MAIN_HAND).canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SWORD_SWEEP)) { + flag2 = true; + } } ++ // Neo: Fire the SweepAttackEvent and overwrite the value of flag2 (the local controlling if a sweep will occur). ++ var sweepEvent = net.neoforged.neoforge.common.CommonHooks.fireSweepAttack(this, p_36347_, flag2); ++ flag2 = sweepEvent.isSweeping(); ++ float f6 = 0.0F; -@@ -1217,11 +_,12 @@ + if (p_36347_ instanceof LivingEntity livingentity) { + f6 = livingentity.getHealth(); +@@ -1213,11 +_,12 @@ for (LivingEntity livingentity2 : this.level() .getEntitiesOfClass(LivingEntity.class, p_36347_.getBoundingBox().inflate(1.0, 0.25, 1.0))) { @@ -319,7 +305,7 @@ float f5 = this.getEnchantedDamage(livingentity2, f7, damagesource) * f2; livingentity2.knockback( 0.4F, -@@ -1268,11 +_,12 @@ +@@ -1264,11 +_,12 @@ this.setLastHurtMob(p_36347_); Entity entity = p_36347_; @@ -334,7 +320,7 @@ if (this.level() instanceof ServerLevel serverlevel1) { if (entity instanceof LivingEntity livingentity3) { flag5 = itemstack.hurtEnemy(livingentity3, this); -@@ -1287,6 +_,7 @@ +@@ -1283,6 +_,7 @@ } if (itemstack.isEmpty()) { @@ -342,7 +328,7 @@ if (itemstack == this.getMainHandItem()) { this.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY); } else { -@@ -1311,6 +_,7 @@ +@@ -1307,6 +_,7 @@ .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); } } @@ -350,28 +336,6 @@ } } } -@@ -1325,7 +_,7 @@ - } - - public void disableShield() { -- this.getCooldowns().addCooldown(Items.SHIELD, 100); -+ this.getCooldowns().addCooldown(this.getUseItem().getItem(), 100); - this.stopUsingItem(); - this.level().broadcastEntityEvent(this, (byte)30); - } -@@ -1384,6 +_,12 @@ - return this.containerMenu != this.inventoryMenu; - } - -+ protected AtomicBoolean startSleepInBed_force = new AtomicBoolean(false); -+ public Player forceSleepInBed(boolean force) { -+ startSleepInBed_force.set(force); -+ return this; -+ } -+ - public Either startSleepInBed(BlockPos p_36203_) { - this.startSleeping(p_36203_); - this.sleepCounter = 0; @@ -1391,6 +_,7 @@ } @@ -380,7 +344,7 @@ super.stopSleeping(); if (this.level() instanceof ServerLevel && p_36227_) { ((ServerLevel)this.level()).updateSleepingPlayerList(); -@@ -1503,7 +_,8 @@ +@@ -1496,7 +_,8 @@ @Override public boolean causeFallDamage(float p_150093_, float p_150094_, DamageSource p_150095_) { @@ -390,16 +354,7 @@ return false; } else { if (p_150093_ >= 2.0F) { -@@ -1535,7 +_,7 @@ - public boolean tryToStartFallFlying() { - if (!this.onGround() && !this.isFallFlying() && !this.isInWater() && !this.hasEffect(MobEffects.LEVITATION)) { - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.CHEST); -- if (itemstack.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(itemstack)) { -+ if (itemstack.canElytraFly(this)) { - this.startFallFlying(); - return true; - } -@@ -1564,13 +_,13 @@ +@@ -1555,13 +_,13 @@ protected void playStepSound(BlockPos p_282121_, BlockState p_282194_) { if (this.isInWater()) { this.waterSwimSound(); @@ -415,7 +370,7 @@ } else { super.playStepSound(blockpos, blockstate); } -@@ -1601,6 +_,10 @@ +@@ -1592,6 +_,10 @@ } public void giveExperiencePoints(int p_36291_) { @@ -426,7 +381,7 @@ this.increaseScore(p_36291_); this.experienceProgress = this.experienceProgress + (float)p_36291_ / (float)this.getXpNeededForNextLevel(); this.totalExperience = Mth.clamp(this.totalExperience + p_36291_, 0, Integer.MAX_VALUE); -@@ -1628,7 +_,7 @@ +@@ -1619,7 +_,7 @@ } public void onEnchantmentPerformed(ItemStack p_36172_, int p_36173_) { @@ -435,7 +390,7 @@ if (this.experienceLevel < 0) { this.experienceLevel = 0; this.experienceProgress = 0.0F; -@@ -1639,6 +_,10 @@ +@@ -1630,6 +_,10 @@ } public void giveExperienceLevels(int p_36276_) { @@ -443,43 +398,10 @@ + if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event).isCanceled()) return; + p_36276_ = event.getLevels(); + - this.experienceLevel += p_36276_; + this.experienceLevel = IntMath.saturatedAdd(this.experienceLevel, p_36276_); if (this.experienceLevel < 0) { this.experienceLevel = 0; -@@ -1662,12 +_,32 @@ - } - - public void causeFoodExhaustion(float p_36400_) { -+ // CraftBukkit end - if (!this.abilities.invulnerable) { - if (!this.level().isClientSide) { - this.foodData.addExhaustion(p_36400_); -+ // CraftBukkit start -+ EntityExhaustionEvent event = CraftEventFactory.callPlayerExhaustionEvent(this, reason.getAndSet(EntityExhaustionEvent.ExhaustionReason.UNKNOWN), p_36400_); -+ if (!event.isCancelled()) { -+ this.foodData.addExhaustion(event.getExhaustion()); -+ } -+ // CraftBukkit end - } - } - } -+ -+ // Mohist start -+ // CraftBukkit start -+ private AtomicReference reason = new AtomicReference<>(EntityExhaustionEvent.ExhaustionReason.UNKNOWN); -+ public void exhaustionReason(EntityExhaustionEvent.ExhaustionReason exhaustionReason) { -+ reason.set(exhaustionReason); -+ } -+ public void causeFoodExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) { -+ this.exhaustionReason(reason); -+ causeFoodExhaustion(f); -+ } -+ // CraftBukkit end -+ // Mohist end - - public Optional getWardenSpawnTracker() { - return Optional.empty(); -@@ -1847,7 +_,11 @@ +@@ -1833,7 +_,11 @@ @Override public Component getDisplayName() { @@ -492,7 +414,7 @@ return this.decorateDisplayNameComponent(mutablecomponent); } -@@ -2009,21 +_,21 @@ +@@ -1997,21 +_,21 @@ if (!(p_36349_.getItem() instanceof ProjectileWeaponItem)) { return ItemStack.EMPTY; } else { @@ -519,19 +441,7 @@ } } } -@@ -2047,7 +_,10 @@ - } - - if (!this.level().isClientSide()) { -- this.getInventory().add(optional.get().copy()); -+ ItemStack container = optional.get().copy(); -+ if (!getInventory().add(container)) { -+ drop(container, false); -+ } - } - } - -@@ -2201,5 +_,41 @@ +@@ -2172,5 +_,41 @@ public Component getMessage() { return this.message; } diff --git a/patches/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/patches/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index 38e7f69f..f8402702 100644 --- a/patches/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/patches/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -188,7 +_,7 @@ +@@ -189,7 +_,7 @@ this.shakeTime--; } @@ -9,14 +9,20 @@ this.clearFire(); } -@@ -224,7 +_,9 @@ - } - } +@@ -269,11 +_,15 @@ -- if (hitresult != null && !flag) { -+ if (hitresult != null && hitresult.getType() != HitResult.Type.MISS && !flag) { -+ if (net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult)) + if (entityhitresult == null) { + if (this.isAlive() && p_371761_.getType() != HitResult.Type.MISS) { ++ if (net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, p_371761_)) + break; - ProjectileDeflection projectiledeflection = this.hitTargetOrDeflectSelf(hitresult); + this.hitTargetOrDeflectSelf(p_371761_); this.hasImpulse = true; - if (projectiledeflection != ProjectileDeflection.NONE) { + } + break; +- } else if (this.isAlive() && !this.noPhysics) { ++ } else if (this.isAlive() && !this.noPhysics && entityhitresult.getType() != HitResult.Type.MISS) { ++ if (net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, entityhitresult)) ++ break; + ProjectileDeflection projectiledeflection = this.hitTargetOrDeflectSelf(entityhitresult); + this.hasImpulse = true; + if (this.getPierceLevel() > 0 && projectiledeflection == ProjectileDeflection.NONE) { diff --git a/patches/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch b/patches/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch index 44a57f04..e90d9725 100644 --- a/patches/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch +++ b/patches/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch @@ -1,11 +1,21 @@ --- a/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +++ b/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -@@ -78,7 +_,7 @@ - } - +@@ -76,7 +_,8 @@ + if (this.level().isClientSide || (entity == null || !entity.isRemoved()) && this.level().hasChunkAt(this.blockPosition())) { HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType()); + Vec3 vec3; - if (hitresult.getType() != HitResult.Type.MISS) { -+ if (hitresult.getType() != HitResult.Type.MISS && !net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult)) { ++ boolean impacted = hitresult.getType() != HitResult.Type.MISS && !net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult); ++ if (impacted) { + vec3 = hitresult.getLocation(); + } else { + vec3 = this.position().add(this.getDeltaMovement()); +@@ -90,7 +_,7 @@ + this.igniteForSeconds(1.0F); + } + +- if (hitresult.getType() != HitResult.Type.MISS && this.isAlive()) { ++ if (hitresult.getType() != HitResult.Type.MISS && this.isAlive() && impacted) { this.hitTargetOrDeflectSelf(hitresult); } diff --git a/patches/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/patches/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch index 930e5770..68e05636 100644 --- a/patches/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/patches/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -177,6 +_,13 @@ +@@ -182,6 +_,13 @@ } } @@ -11,6 +11,6 @@ + } + } + - private void explode() { - this.level().broadcastEntityEvent(this, (byte)17); + private void explode(ServerLevel p_376529_) { + p_376529_.broadcastEntityEvent(this, (byte)17); this.gameEvent(GameEvent.EXPLODE, this.getOwner()); diff --git a/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch b/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch index aadfd876..1a83a15f 100644 --- a/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java -@@ -240,8 +_,8 @@ +@@ -245,8 +_,8 @@ private boolean shouldStopFishing(Player p_37137_) { ItemStack itemstack = p_37137_.getMainHandItem(); ItemStack itemstack1 = p_37137_.getOffhandItem(); @@ -11,7 +11,7 @@ if (!p_37137_.isRemoved() && p_37137_.isAlive() && (flag || flag1) && !(this.distanceToSqr(p_37137_) > 1024.0)) { return false; } else { -@@ -252,7 +_,7 @@ +@@ -257,7 +_,7 @@ private void checkCollision() { HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); @@ -20,7 +20,7 @@ } @Override -@@ -441,6 +_,7 @@ +@@ -446,6 +_,7 @@ Player player = this.getPlayerOwner(); if (!this.level().isClientSide && player != null && !this.shouldStopFishing(player)) { int i = 0; @@ -28,7 +28,7 @@ if (this.hookedIn != null) { this.pullEntity(this.hookedIn); CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, Collections.emptyList()); -@@ -451,10 +_,17 @@ +@@ -456,10 +_,17 @@ .withParameter(LootContextParams.ORIGIN, this.position()) .withParameter(LootContextParams.TOOL, p_37157_) .withParameter(LootContextParams.THIS_ENTITY, this) @@ -46,7 +46,7 @@ CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, list); for (ItemStack itemstack : list) { -@@ -480,6 +_,7 @@ +@@ -485,6 +_,7 @@ } this.discard(); diff --git a/patches/net/minecraft/world/entity/projectile/LargeFireball.java.patch b/patches/net/minecraft/world/entity/projectile/LargeFireball.java.patch index f9dc490f..ca9675d4 100644 --- a/patches/net/minecraft/world/entity/projectile/LargeFireball.java.patch +++ b/patches/net/minecraft/world/entity/projectile/LargeFireball.java.patch @@ -3,10 +3,10 @@ @@ -29,7 +_,8 @@ protected void onHit(HitResult p_37218_) { super.onHit(p_37218_); - if (!this.level().isClientSide) { -- boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + if (this.level() instanceof ServerLevel serverlevel) { +- boolean flag = serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + // TODO 1.19.3: The creation of Level.ExplosionInteraction means this code path will fire EntityMobGriefingEvent twice. Should we try and fix it? -SS -+ boolean flag = net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this.getOwner()); ++ boolean flag = net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, this.getOwner()); this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float)this.explosionPower, flag, Level.ExplosionInteraction.MOB); this.discard(); } diff --git a/patches/net/minecraft/world/entity/projectile/Projectile.java.patch b/patches/net/minecraft/world/entity/projectile/Projectile.java.patch index 5309585d..b772c704 100644 --- a/patches/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/patches/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -284,7 +_,7 @@ +@@ -375,7 +_,7 @@ Entity entity = this.getOwner(); return entity instanceof Player - ? entity.mayInteract(p_150167_, p_150168_) -- : entity == null || p_150167_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -+ : entity == null || net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_150167_, entity); + ? entity.mayInteract(p_376318_, p_150168_) +- : entity == null || p_376318_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); ++ : entity == null || net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_376318_, entity); } - public boolean mayBreak(Level p_307481_) { + public boolean mayBreak(ServerLevel p_376471_) { diff --git a/patches/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch b/patches/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch index 0a939444..19a4a507 100644 --- a/patches/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch +++ b/patches/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch @@ -9,7 +9,7 @@ if (d0 == 0.0) { entity = entity1; vec3 = vec31; -@@ -153,8 +_,13 @@ +@@ -155,8 +_,13 @@ } } diff --git a/patches/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch b/patches/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch index d78a8d8f..471a8a36 100644 --- a/patches/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch +++ b/patches/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/ShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/ShulkerBullet.java -@@ -218,7 +_,7 @@ - } +@@ -228,7 +_,7 @@ + this.handlePortal(); + } - HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); -- if (hitresult.getType() != HitResult.Type.MISS) { -+ if (hitresult.getType() != HitResult.Type.MISS && !net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult)) { - this.hitTargetOrDeflectSelf(hitresult); - } +- if (hitresult != null && this.isAlive() && hitresult.getType() != HitResult.Type.MISS) { ++ if (hitresult != null && this.isAlive() && hitresult.getType() != HitResult.Type.MISS && !net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult)) { + this.hitTargetOrDeflectSelf(hitresult); } + diff --git a/patches/net/minecraft/world/entity/projectile/SmallFireball.java.patch b/patches/net/minecraft/world/entity/projectile/SmallFireball.java.patch index 5f4cf704..2a65c9d0 100644 --- a/patches/net/minecraft/world/entity/projectile/SmallFireball.java.patch +++ b/patches/net/minecraft/world/entity/projectile/SmallFireball.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/entity/projectile/SmallFireball.java @@ -51,7 +_,7 @@ super.onHitBlock(p_37384_); - if (!this.level().isClientSide) { + if (this.level() instanceof ServerLevel serverlevel) { Entity entity = this.getOwner(); -- if (!(entity instanceof Mob) || this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!(entity instanceof Mob) || net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), entity)) { +- if (!(entity instanceof Mob) || serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!(entity instanceof Mob) || net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, entity)) { BlockPos blockpos = p_37384_.getBlockPos().relative(p_37384_.getDirection()); if (this.level().isEmptyBlock(blockpos)) { this.level().setBlockAndUpdate(blockpos, BaseFireBlock.getState(this.level(), blockpos)); diff --git a/patches/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch b/patches/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch index 8db75473..0f2f4b2c 100644 --- a/patches/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch +++ b/patches/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/ThrowableProjectile.java +++ b/net/minecraft/world/entity/projectile/ThrowableProjectile.java -@@ -42,7 +_,7 @@ - public void tick() { - super.tick(); +@@ -48,7 +_,7 @@ + this.applyInertia(); HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); + Vec3 vec3; - if (hitresult.getType() != HitResult.Type.MISS) { + if (hitresult.getType() != HitResult.Type.MISS && !net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult)) { - this.hitTargetOrDeflectSelf(hitresult); - } - + vec3 = hitresult.getLocation(); + } else { + vec3 = this.position().add(this.getDeltaMovement()); diff --git a/patches/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/patches/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch index 483428ee..81b0d29e 100644 --- a/patches/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/patches/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -1,28 +1,31 @@ --- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -66,6 +_,8 @@ - +@@ -126,6 +_,8 @@ + Vec3 vec3 = this.oldPosition(); if (entity instanceof ServerPlayer serverplayer) { if (serverplayer.connection.isAcceptingMessages()) { + net.neoforged.neoforge.event.entity.EntityTeleportEvent.EnderPearl event = net.neoforged.neoforge.event.EventHooks.onEnderPearlLand(serverplayer, this.getX(), this.getY(), this.getZ(), this, 5.0F, p_37504_); + if (!event.isCanceled()) { // Don't indent to lower patch size if (this.random.nextFloat() < 0.05F && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { - Endermite endermite = EntityType.ENDERMITE.create(serverlevel); + Endermite endermite = EntityType.ENDERMITE.create(serverlevel, EntitySpawnReason.TRIGGERED); if (endermite != null) { -@@ -76,13 +_,14 @@ +@@ -140,16 +_,17 @@ - entity.changeDimension( - new DimensionTransition( -- serverlevel, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING -+ serverlevel, event.getTarget(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING + ServerPlayer serverplayer1 = serverplayer.teleport( + new TeleportTransition( +- serverlevel, vec3, Vec3.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING ++ serverlevel, event.getTarget(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), TeleportTransition.DO_NOTHING ) ); - entity.resetFallDistance(); - serverplayer.resetCurrentImpulseContext(); -- entity.hurt(this.damageSources().fall(), 5.0F); -+ entity.hurt(this.damageSources().fall(), event.getAttackDamage()); - this.playSound(serverlevel, this.position()); + if (serverplayer1 != null) { + serverplayer1.resetFallDistance(); + serverplayer1.resetCurrentImpulseContext(); +- serverplayer1.hurtServer(serverplayer.serverLevel(), this.damageSources().enderPearl(), 5.0F); ++ serverplayer1.hurtServer(serverplayer.serverLevel(), this.damageSources().fall(), event.getAttackDamage()); + } + + this.playSound(serverlevel, vec3); + } //Forge: End } } else { - entity.changeDimension( + Entity entity1 = entity.teleport( diff --git a/patches/net/minecraft/world/entity/raid/Raid.java.patch b/patches/net/minecraft/world/entity/raid/Raid.java.patch index 2175381f..1518312f 100644 --- a/patches/net/minecraft/world/entity/raid/Raid.java.patch +++ b/patches/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -503,7 +_,7 @@ +@@ -493,7 +_,7 @@ int k = 0; for (int l = 0; l < j; l++) { -- Raider raider = raid$raidertype.entityType.create(this.level); -+ Raider raider = raid$raidertype.entityTypeSupplier.get().create(this.level); +- Raider raider = raid$raidertype.entityType.create(this.level, EntitySpawnReason.EVENT); ++ Raider raider = raid$raidertype.entityTypeSupplier.get().create(this.level, EntitySpawnReason.EVENT); if (raider == null) { break; } -@@ -515,7 +_,7 @@ +@@ -505,7 +_,7 @@ } this.joinRaid(i, raider, p_37756_, false); @@ -17,8 +17,8 @@ + if (raid$raidertype.entityTypeSupplier.get() == EntityType.RAVAGER) { Raider raider1 = null; if (i == this.getNumGroups(Difficulty.NORMAL)) { - raider1 = EntityType.PILLAGER.create(this.level); -@@ -834,7 +_,7 @@ + raider1 = EntityType.PILLAGER.create(this.level, EntitySpawnReason.EVENT); +@@ -828,7 +_,7 @@ } } @@ -27,7 +27,7 @@ VINDICATOR(EntityType.VINDICATOR, new int[]{0, 0, 2, 0, 1, 4, 2, 5}), EVOKER(EntityType.EVOKER, new int[]{0, 0, 0, 0, 0, 1, 1, 2}), PILLAGER(EntityType.PILLAGER, new int[]{0, 4, 3, 3, 4, 4, 4, 2}), -@@ -842,12 +_,26 @@ +@@ -836,12 +_,26 @@ RAVAGER(EntityType.RAVAGER, new int[]{0, 0, 0, 1, 0, 1, 0, 2}); static final Raid.RaiderType[] VALUES = values(); diff --git a/patches/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch b/patches/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch new file mode 100644 index 00000000..c3894913 --- /dev/null +++ b/patches/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch @@ -0,0 +1,65 @@ +--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java ++++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java +@@ -45,7 +_,7 @@ + import net.minecraft.world.phys.shapes.Shapes; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public abstract class AbstractBoat extends VehicleEntity implements Leashable { ++public abstract class AbstractBoat extends VehicleEntity implements Leashable, net.neoforged.neoforge.common.extensions.IAbstractBoatExtension { + private static final EntityDataAccessor DATA_ID_PADDLE_LEFT = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor DATA_ID_PADDLE_RIGHT = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor DATA_ID_BUBBLE_TIME = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.INT); +@@ -478,7 +_,7 @@ + for (int i2 = i1; i2 < j1; i2++) { + blockpos$mutableblockpos.set(l1, k1, i2); + FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); +- if (fluidstate.is(FluidTags.WATER)) { ++ if (this.canBoatInFluid(fluidstate)) { + f = Math.max(f, fluidstate.getHeight(this.level(), blockpos$mutableblockpos)); + } + +@@ -524,7 +_,7 @@ + voxelshape, + BooleanOp.AND + )) { +- f += blockstate.getBlock().getFriction(); ++ f += blockstate.getFriction(this.level(), blockpos$mutableblockpos, this); + k1++; + } + } +@@ -553,7 +_,7 @@ + for (int i2 = i1; i2 < j1; i2++) { + blockpos$mutableblockpos.set(k1, l1, i2); + FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); +- if (fluidstate.is(FluidTags.WATER)) { ++ if (this.canBoatInFluid(fluidstate)) { + float f = (float)l1 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos); + this.waterLevel = Math.max((double)f, this.waterLevel); + flag |= aabb.minY < (double)f; +@@ -583,7 +_,7 @@ + for (int i2 = i1; i2 < j1; i2++) { + blockpos$mutableblockpos.set(k1, l1, i2); + FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); +- if (fluidstate.is(FluidTags.WATER) ++ if (this.canBoatInFluid(fluidstate) + && d0 < (double)((float)blockpos$mutableblockpos.getY() + fluidstate.getHeight(this.level(), blockpos$mutableblockpos))) { + if (!fluidstate.isSource()) { + return AbstractBoat.Status.UNDER_FLOWING_WATER; +@@ -790,7 +_,7 @@ + if (!this.isPassenger()) { + if (p_376924_) { + this.resetFallDistance(); +- } else if (!this.level().getFluidState(this.blockPosition().below()).is(FluidTags.WATER) && p_376661_ < 0.0) { ++ } else if (!this.canBoatInFluid(this.level().getFluidState(this.blockPosition().below())) && p_376661_ < 0.0) { + this.fallDistance -= (float)p_376661_; + } + } +@@ -814,7 +_,7 @@ + + @Override + protected boolean canAddPassenger(Entity p_376443_) { +- return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER); ++ return this.getPassengers().size() < this.getMaxPassengers() && !this.canBoatInFluid(this.getEyeInFluidType()); + } + + protected int getMaxPassengers() { diff --git a/patches/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/patches/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch index 283ba48c..3360a92b 100644 --- a/patches/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -1,307 +1,13 @@ --- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -45,7 +_,7 @@ - import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.Vec3; +@@ -430,8 +_,8 @@ --public abstract class AbstractMinecart extends VehicleEntity { -+public abstract class AbstractMinecart extends VehicleEntity implements net.neoforged.neoforge.common.extensions.IAbstractMinecartExtension { - private static final Vec3 LOWERED_PASSENGER_ATTACHMENT = new Vec3(0.0, 0.0, 0.0); - private static final EntityDataAccessor DATA_ID_DISPLAY_BLOCK = SynchedEntityData.defineId(AbstractMinecart.class, EntityDataSerializers.INT); - private static final EntityDataAccessor DATA_ID_DISPLAY_OFFSET = SynchedEntityData.defineId(AbstractMinecart.class, EntityDataSerializers.INT); -@@ -63,6 +_,7 @@ - private double lerpYRot; - private double lerpXRot; - private Vec3 targetDeltaMovement = Vec3.ZERO; -+ private boolean canBePushed = true; - private static final Map> EXITS = Util.make(Maps.newEnumMap(RailShape.class), p_38135_ -> { - Vec3i vec3i = Direction.WEST.getNormal(); - Vec3i vec3i1 = Direction.EAST.getNormal(); -@@ -83,6 +_,7 @@ - p_38135_.put(RailShape.NORTH_WEST, Pair.of(vec3i2, vec3i)); - p_38135_.put(RailShape.NORTH_EAST, Pair.of(vec3i2, vec3i1)); - }); -+ private static net.neoforged.neoforge.common.IMinecartCollisionHandler COLLISIONS = null; - - protected AbstractMinecart(EntityType p_38087_, Level p_38088_) { - super(p_38087_, p_38088_); -@@ -97,6 +_,14 @@ - this.zo = p_38094_; - } - -+ public net.neoforged.neoforge.common.IMinecartCollisionHandler getCollisionHandler() { -+ return COLLISIONS; -+ } -+ -+ public static void registerCollisionHandler(@Nullable net.neoforged.neoforge.common.IMinecartCollisionHandler handler) { -+ COLLISIONS = handler; -+ } -+ - public static AbstractMinecart createMinecart( - ServerLevel p_305794_, - double p_38121_, -@@ -139,7 +_,7 @@ - - @Override - public boolean isPushable() { -- return true; -+ return canBePushed; - } - - @Override -@@ -271,9 +_,9 @@ - BlockPos blockpos = new BlockPos(i, j, k); - BlockState blockstate = this.level().getBlockState(blockpos); - this.onRails = BaseRailBlock.isRail(blockstate); -- if (this.onRails) { -+ if (canUseRail() && this.onRails) { - this.moveAlongTrack(blockpos, blockstate); -- if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { -+ if (blockstate.getBlock() instanceof PoweredRailBlock && ((PoweredRailBlock) blockstate.getBlock()).isActivatorRail()) { - this.activateMinecart(i, j, k, blockstate.getValue(PoweredRailBlock.POWERED)); - } - } else { -@@ -298,8 +_,11 @@ - } - - this.setRot(this.getYRot(), this.getXRot()); -- if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01) { -- List list = this.level().getEntities(this, this.getBoundingBox().inflate(0.2F, 0.0, 0.2F), EntitySelector.pushableBy(this)); -+ AABB box; -+ if (getCollisionHandler() != null) box = getCollisionHandler().getMinecartCollisionBox(this); -+ else box = this.getBoundingBox().inflate(0.2F, 0.0D, 0.2F); -+ if (canBeRidden() && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) { -+ List list = this.level().getEntities(this, box, EntitySelector.pushableBy(this)); - if (!list.isEmpty()) { - for (Entity entity1 : list) { - if (!(entity1 instanceof Player) -@@ -314,7 +_,7 @@ - } - } - } else { -- for (Entity entity : this.level().getEntities(this, this.getBoundingBox().inflate(0.2F, 0.0, 0.2F))) { -+ for(Entity entity : this.level().getEntities(this, box)) { - if (!this.hasPassenger(entity) && entity.isPushable() && entity instanceof AbstractMinecart) { - entity.push(this); - } -@@ -339,16 +_,23 @@ - } - - protected void comeOffTrack() { -- double d0 = this.getMaxSpeed(); -+ double d0 = this.onGround() ? this.getMaxSpeed() : getMaxSpeedAirLateral(); - Vec3 vec3 = this.getDeltaMovement(); - this.setDeltaMovement(Mth.clamp(vec3.x, -d0, d0), vec3.y, Mth.clamp(vec3.z, -d0, d0)); - if (this.onGround()) { - this.setDeltaMovement(this.getDeltaMovement().scale(0.5)); - } - -+ if (getMaxSpeedAirVertical() > 0 && getDeltaMovement().y > getMaxSpeedAirVertical()) { -+ if(Math.abs(getDeltaMovement().x) < 0.3f && Math.abs(getDeltaMovement().z) < 0.3f) -+ setDeltaMovement(new Vec3(getDeltaMovement().x, 0.15f, getDeltaMovement().z)); -+ else -+ setDeltaMovement(new Vec3(getDeltaMovement().x, getMaxSpeedAirVertical(), getDeltaMovement().z)); -+ } -+ - this.move(MoverType.SELF, this.getDeltaMovement()); - if (!this.onGround()) { -- this.setDeltaMovement(this.getDeltaMovement().scale(0.95)); -+ this.setDeltaMovement(this.getDeltaMovement().scale(getDragAir())); - } - } - -@@ -361,18 +_,19 @@ - d1 = (double)p_38156_.getY(); - boolean flag = false; - boolean flag1 = false; -- if (p_38157_.is(Blocks.POWERED_RAIL)) { -+ BaseRailBlock baserailblock = (BaseRailBlock) p_38157_.getBlock(); -+ if (baserailblock instanceof PoweredRailBlock && !((PoweredRailBlock) baserailblock).isActivatorRail()) { - flag = p_38157_.getValue(PoweredRailBlock.POWERED); - flag1 = !flag; - } - -- double d3 = 0.0078125; -+ double d3 = getSlopeAdjustment(); - if (this.isInWater()) { - d3 *= 0.2; - } - - Vec3 vec31 = this.getDeltaMovement(); -- RailShape railshape = p_38157_.getValue(((BaseRailBlock)p_38157_.getBlock()).getShapeProperty()); -+ RailShape railshape = ((BaseRailBlock)p_38157_.getBlock()).getRailDirection(p_38157_, this.level(), p_38156_, this); - switch (railshape) { - case ASCENDING_EAST: - this.setDeltaMovement(vec31.add(-d3, 0.0, 0.0)); -@@ -418,7 +_,7 @@ - } - } - -- if (flag1) { -+ if (flag1 && shouldDoRailFunctions()) { - double d22 = this.getDeltaMovement().horizontalDistance(); - if (d22 < 0.03) { - this.setDeltaMovement(Vec3.ZERO); -@@ -447,10 +_,7 @@ - d0 = d23 + d4 * d14; - d2 = d10 + d5 * d14; - this.setPos(d0, d1, d2); -- double d24 = this.isVehicle() ? 0.75 : 1.0; -- double d25 = this.getMaxSpeed(); -- vec31 = this.getDeltaMovement(); -- this.move(MoverType.SELF, new Vec3(Mth.clamp(d24 * vec31.x, -d25, d25), 0.0, Mth.clamp(d24 * vec31.z, -d25, d25))); -+ this.moveMinecartOnRail(p_38156_); - if (vec3i.getY() != 0 && Mth.floor(this.getX()) - p_38156_.getX() == vec3i.getX() && Mth.floor(this.getZ()) - p_38156_.getZ() == vec3i.getZ()) { - this.setPos(this.getX(), this.getY() + (double)vec3i.getY(), this.getZ()); - } else if (vec3i1.getY() != 0 && Mth.floor(this.getX()) - p_38156_.getX() == vec3i1.getX() && Mth.floor(this.getZ()) - p_38156_.getZ() == vec3i1.getZ() -@@ -480,7 +_,10 @@ - this.setDeltaMovement(d26 * (double)(j - p_38156_.getX()), vec35.y, d26 * (double)(i - p_38156_.getZ())); - } - -- if (flag) { -+ if (shouldDoRailFunctions()) -+ baserailblock.onMinecartPass(p_38157_, level(), p_38156_, this); -+ -+ if (flag && shouldDoRailFunctions()) { - Vec3 vec36 = this.getDeltaMovement(); - double d27 = vec36.horizontalDistance(); - if (d27 > 0.01) { -@@ -544,7 +_,7 @@ - - BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); - if (BaseRailBlock.isRail(blockstate)) { -- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); -+ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), new BlockPos(i, j, k), this); - p_38098_ = (double)j; - if (railshape.isAscending()) { - p_38098_ = (double)(j + 1); -@@ -583,7 +_,7 @@ - - BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); - if (BaseRailBlock.isRail(blockstate)) { + public Vec3 getRedstoneDirection(BlockPos p_361470_) { + BlockState blockstate = this.level().getBlockState(p_361470_); +- if (blockstate.is(Blocks.POWERED_RAIL) && blockstate.getValue(PoweredRailBlock.POWERED)) { - RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); -+ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), new BlockPos(i, j, k), this); - Pair pair = exits(railshape); - Vec3i vec3i = pair.getFirst(); - Vec3i vec3i1 = pair.getSecond(); -@@ -647,6 +_,10 @@ - - @Override - public void push(Entity p_38165_) { -+ if (getCollisionHandler() != null) { -+ getCollisionHandler().onEntityCollision(this, p_38165_); -+ return; -+ } - if (!this.level().isClientSide) { - if (!p_38165_.noPhysics && !this.noPhysics) { - if (!this.hasPassenger(p_38165_)) { -@@ -685,13 +_,11 @@ - - Vec3 vec32 = this.getDeltaMovement(); - Vec3 vec33 = p_38165_.getDeltaMovement(); -- if (((AbstractMinecart)p_38165_).getMinecartType() == AbstractMinecart.Type.FURNACE -- && this.getMinecartType() != AbstractMinecart.Type.FURNACE) { -+ if (((AbstractMinecart)p_38165_).isPoweredCart() && !this.isPoweredCart()) { - this.setDeltaMovement(vec32.multiply(0.2, 1.0, 0.2)); - this.push(vec33.x - d0, 0.0, vec33.z - d1); - p_38165_.setDeltaMovement(vec33.multiply(0.95, 1.0, 0.95)); -- } else if (((AbstractMinecart)p_38165_).getMinecartType() != AbstractMinecart.Type.FURNACE -- && this.getMinecartType() == AbstractMinecart.Type.FURNACE) { -+ } else if (!((AbstractMinecart)p_38165_).isPoweredCart() && this.isPoweredCart()) { - p_38165_.setDeltaMovement(vec33.multiply(0.2, 1.0, 0.2)); - p_38165_.push(vec32.x + d0, 0.0, vec32.z + d1); - this.setDeltaMovement(vec32.multiply(0.95, 1.0, 0.95)); -@@ -789,6 +_,93 @@ - - public void setCustomDisplay(boolean p_38139_) { - this.getEntityData().set(DATA_ID_CUSTOM_DISPLAY, p_38139_); -+ } -+ -+ // Neo: Controls whether a Minecrart is allowed on Rails or not -+ private boolean canUseRail = true; -+ -+ @Override -+ public boolean canUseRail() { -+ return canUseRail; -+ } -+ -+ @Override -+ public void setCanUseRail(boolean value) { -+ this.canUseRail = value; -+ } -+ -+ // Neo: Controls the rail speed cap -+ private float currentSpeedCapOnRail = getMaxCartSpeedOnRail(); -+ -+ @Override -+ public float getCurrentCartSpeedCapOnRail() { -+ return currentSpeedCapOnRail; -+ } -+ -+ @Override -+ public void setCurrentCartSpeedCapOnRail(float value) { -+ currentSpeedCapOnRail = Math.min(value, getMaxCartSpeedOnRail()); -+ } -+ -+ @Override -+ public double getMaxSpeedWithRail() { //Non-default because getMaximumSpeed is protected -+ if (!canUseRail()) return getMaxSpeed(); -+ BlockPos pos = this.getCurrentRailPosition(); -+ BlockState state = this.level().getBlockState(pos); -+ if (!state.is(BlockTags.RAILS)) return getMaxSpeed(); -+ -+ float railMaxSpeed = ((BaseRailBlock)state.getBlock()).getRailMaxSpeed(state, this.level(), pos, this); -+ return Math.min(railMaxSpeed, getCurrentCartSpeedCapOnRail()); -+ } -+ -+ // Neo: Controls the horizontal air speed cap -+ @org.jetbrains.annotations.Nullable -+ private Float maxSpeedAirLateral = null; -+ -+ @Override -+ public float getMaxSpeedAirLateral() { -+ return maxSpeedAirLateral == null ? (float) this.getMaxSpeed() : maxSpeedAirLateral; -+ } -+ -+ @Override -+ public void setMaxSpeedAirLateral(float value) { -+ maxSpeedAirLateral = value; -+ } -+ -+ // Neo: Controls the vertical air speed cap -+ private float maxSpeedAirVertical = DEFAULT_MAX_SPEED_AIR_VERTICAL; -+ -+ @Override -+ public float getMaxSpeedAirVertical() { -+ return maxSpeedAirVertical; -+ } -+ -+ @Override -+ public void setMaxSpeedAirVertical(float value) { -+ maxSpeedAirVertical = value; -+ } -+ -+ // Neo: Controls the drag effect when Minecart is in air -+ private double dragAir = DEFAULT_AIR_DRAG; -+ -+ @Override -+ public double getDragAir() { -+ return dragAir; -+ } -+ -+ @Override -+ public void setDragAir(double value) { -+ dragAir = value; -+ } -+ -+ // Neo: Applies the movement speed to the Minecart -+ @Override -+ public void moveMinecartOnRail(BlockPos pos) { //Non-default because getMaximumSpeed is protected -+ AbstractMinecart mc = this; -+ double d24 = mc.isVehicle() ? 0.75D : 1.0D; -+ double d25 = mc.getMaxSpeedWithRail(); -+ Vec3 vec3d1 = mc.getDeltaMovement(); -+ mc.move(MoverType.SELF, new Vec3(Mth.clamp(d24 * vec3d1.x, -d25, d25), 0.0D, Mth.clamp(d24 * vec3d1.z, -d25, d25))); - } - - @Override ++ if (blockstate.getBlock() instanceof PoweredRailBlock poweredRail && !poweredRail.isActivatorRail() && blockstate.getValue(PoweredRailBlock.POWERED)) { ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), p_361470_, this); + if (railshape == RailShape.EAST_WEST) { + if (this.isRedstoneConductor(p_361470_.west())) { + return new Vec3(1.0, 0.0, 0.0); diff --git a/patches/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch b/patches/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch index cec5eec5..15d33613 100644 --- a/patches/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -@@ -95,6 +_,8 @@ +@@ -93,6 +_,8 @@ @Override public InteractionResult interact(Player p_38232_, InteractionHand p_38233_) { diff --git a/patches/net/minecraft/world/entity/vehicle/Boat.java.patch b/patches/net/minecraft/world/entity/vehicle/Boat.java.patch deleted file mode 100644 index fbd6f23a..00000000 --- a/patches/net/minecraft/world/entity/vehicle/Boat.java.patch +++ /dev/null @@ -1,193 +0,0 @@ ---- a/net/minecraft/world/entity/vehicle/Boat.java -+++ b/net/minecraft/world/entity/vehicle/Boat.java -@@ -52,7 +_,7 @@ - import net.minecraft.world.phys.shapes.Shapes; - import net.minecraft.world.phys.shapes.VoxelShape; - --public class Boat extends VehicleEntity implements Leashable, VariantHolder { -+public class Boat extends VehicleEntity implements Leashable, VariantHolder, net.neoforged.neoforge.common.extensions.IBoatExtension { - private static final EntityDataAccessor DATA_ID_TYPE = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.INT); - private static final EntityDataAccessor DATA_ID_PADDLE_LEFT = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.BOOLEAN); - private static final EntityDataAccessor DATA_ID_PADDLE_RIGHT = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.BOOLEAN); -@@ -157,7 +_,7 @@ - } - } - -- return new Vec3(0.0, this.getVariant() == Boat.Type.BAMBOO ? (double)(p_295933_.height() * 0.8888889F) : (double)(p_295933_.height() / 3.0F), (double)f) -+ return new Vec3(0.0, this.getVariant().isRaft() ? (double)(p_295933_.height() * 0.8888889F) : (double)(p_295933_.height() / 3.0F), (double)f) - .yRot(-this.getYRot() * (float) (Math.PI / 180.0)); - } - -@@ -212,7 +_,8 @@ - case DARK_OAK -> Items.DARK_OAK_BOAT; - case MANGROVE -> Items.MANGROVE_BOAT; - case BAMBOO -> Items.BAMBOO_RAFT; -- default -> Items.OAK_BOAT; -+ case OAK -> Items.OAK_BOAT; -+ default -> this.getVariant().boatItem.get(); - }; - } - -@@ -498,7 +_,7 @@ - for (int i2 = i1; i2 < j1; i2++) { - blockpos$mutableblockpos.set(l1, k1, i2); - FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); -- if (fluidstate.is(FluidTags.WATER)) { -+ if (this.canBoatInFluid(fluidstate)) { - f = Math.max(f, fluidstate.getHeight(this.level(), blockpos$mutableblockpos)); - } - -@@ -544,7 +_,7 @@ - voxelshape, - BooleanOp.AND - )) { -- f += blockstate.getBlock().getFriction(); -+ f += blockstate.getFriction(this.level(), blockpos$mutableblockpos, this); - k1++; - } - } -@@ -573,7 +_,7 @@ - for (int i2 = i1; i2 < j1; i2++) { - blockpos$mutableblockpos.set(k1, l1, i2); - FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); -- if (fluidstate.is(FluidTags.WATER)) { -+ if (this.canBoatInFluid(fluidstate)) { - float f = (float)l1 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos); - this.waterLevel = Math.max((double)f, this.waterLevel); - flag |= aabb.minY < (double)f; -@@ -603,7 +_,7 @@ - for (int i2 = i1; i2 < j1; i2++) { - blockpos$mutableblockpos.set(k1, l1, i2); - FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); -- if (fluidstate.is(FluidTags.WATER) -+ if (this.canBoatInFluid(fluidstate) - && d0 < (double)((float)blockpos$mutableblockpos.getY() + fluidstate.getHeight(this.level(), blockpos$mutableblockpos))) { - if (!fluidstate.isSource()) { - return Boat.Status.UNDER_FLOWING_WATER; -@@ -832,14 +_,15 @@ - } - - for (int j = 0; j < 2; j++) { -- this.spawnAtLocation(Items.STICK); -+ // Neo: allow dropping material-specific sticks instead of just generic wooden sticks -+ this.spawnAtLocation(this.getVariant().getSticks()); - } - } - } - } - - this.resetFallDistance(); -- } else if (!this.level().getFluidState(this.blockPosition().below()).is(FluidTags.WATER) && p_38307_ < 0.0) { -+ } else if (!this.canBoatInFluid(this.level().getFluidState(this.blockPosition().below())) && p_38307_ < 0.0D) { - this.fallDistance -= (float)p_38307_; - } - } -@@ -871,7 +_,7 @@ - - @Override - protected boolean canAddPassenger(Entity p_38390_) { -- return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER); -+ return this.getPassengers().size() < this.getMaxPassengers() && !this.canBoatInFluid(this.getEyeInFluidType()); - } - - protected int getMaxPassengers() { -@@ -914,7 +_,9 @@ - IN_AIR; - } - -- public static enum Type implements StringRepresentable { -+ @net.neoforged.fml.common.asm.enumextension.NamedEnum(1) -+ @net.neoforged.fml.common.asm.enumextension.NetworkedEnum(net.neoforged.fml.common.asm.enumextension.NetworkedEnum.NetworkCheck.CLIENTBOUND) -+ public static enum Type implements StringRepresentable, net.neoforged.fml.common.asm.enumextension.IExtensibleEnum { - OAK(Blocks.OAK_PLANKS, "oak"), - SPRUCE(Blocks.SPRUCE_PLANKS, "spruce"), - BIRCH(Blocks.BIRCH_PLANKS, "birch"), -@@ -923,16 +_,59 @@ - CHERRY(Blocks.CHERRY_PLANKS, "cherry"), - DARK_OAK(Blocks.DARK_OAK_PLANKS, "dark_oak"), - MANGROVE(Blocks.MANGROVE_PLANKS, "mangrove"), -- BAMBOO(Blocks.BAMBOO_PLANKS, "bamboo"); -+ BAMBOO(Blocks.BAMBOO_PLANKS, "bamboo", true); - - private final String name; -+ /** @deprecated Neo: Will be {@link Blocks#AIR} for modded boat types, use {@link #planksSupplier} instead */ -+ @Deprecated - private final Block planks; -+ private final java.util.function.Supplier planksSupplier; -+ final java.util.function.Supplier boatItem; -+ final java.util.function.Supplier chestBoatItem; -+ private final java.util.function.Supplier stickItem; -+ private final boolean raft; - public static final StringRepresentable.EnumCodec CODEC = StringRepresentable.fromEnum(Boat.Type::values); - private static final IntFunction BY_ID = ByIdMap.continuous(Enum::ordinal, values(), ByIdMap.OutOfBoundsStrategy.ZERO); - -+ @net.neoforged.fml.common.asm.enumextension.ReservedConstructor - private Type(Block p_38427_, String p_38428_) { -+ this(p_38427_, p_38428_, false); -+ } -+ -+ @net.neoforged.fml.common.asm.enumextension.ReservedConstructor -+ private Type(Block p_38427_, String p_38428_, boolean raft) { - this.name = p_38428_; - this.planks = p_38427_; -+ this.planksSupplier = () -> p_38427_; -+ this.boatItem = () -> Items.AIR; -+ this.chestBoatItem = () -> Items.AIR; -+ this.stickItem = () -> Items.STICK; -+ this.raft = raft; -+ } -+ -+ /** -+ * @param planks A supplier of the block to be dropped when the boat is destroyed by fall damage -+ * @param name The name of this boat type -+ * @param boatItem A supplier of the item to be dropped when a normal boat or raft of this type is picked up -+ * @param chestBoatItem A supplier of the item to be dropped when a chest boat or raft of this type is picked up -+ * @param stickItem A supplier of the stick item to be dropped when the boat is destroyed by fall damage -+ * @param raft Whether this boat type is a "standard" boat or a raft -+ */ -+ private Type( -+ java.util.function.Supplier planks, -+ String name, -+ java.util.function.Supplier boatItem, -+ java.util.function.Supplier chestBoatItem, -+ java.util.function.Supplier stickItem, -+ boolean raft -+ ) { -+ this.name = name; -+ this.planks = Blocks.AIR; -+ this.planksSupplier = planks; -+ this.boatItem = boatItem; -+ this.chestBoatItem = chestBoatItem; -+ this.stickItem = stickItem; -+ this.raft = raft; - } - - @Override -@@ -945,7 +_,15 @@ - } - - public Block getPlanks() { -- return this.planks; -+ return this.planksSupplier.get(); -+ } -+ -+ public Item getSticks() { -+ return this.stickItem.get(); -+ } -+ -+ public boolean isRaft() { -+ return this.raft; - } - - @Override -@@ -959,6 +_,10 @@ - - public static Boat.Type byName(String p_38433_) { - return CODEC.byName(p_38433_, OAK); -+ } -+ -+ public static net.neoforged.fml.common.asm.enumextension.ExtensionInfo getExtensionInfo() { -+ return net.neoforged.fml.common.asm.enumextension.ExtensionInfo.nonExtended(Boat.Type.class); - } - } - } diff --git a/patches/net/minecraft/world/entity/vehicle/ChestBoat.java.patch b/patches/net/minecraft/world/entity/vehicle/ChestBoat.java.patch deleted file mode 100644 index 97fcd4d1..00000000 --- a/patches/net/minecraft/world/entity/vehicle/ChestBoat.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/entity/vehicle/ChestBoat.java -+++ b/net/minecraft/world/entity/vehicle/ChestBoat.java -@@ -122,7 +_,8 @@ - case DARK_OAK -> Items.DARK_OAK_CHEST_BOAT; - case MANGROVE -> Items.MANGROVE_CHEST_BOAT; - case BAMBOO -> Items.BAMBOO_CHEST_RAFT; -- default -> Items.OAK_CHEST_BOAT; -+ case OAK -> Items.OAK_CHEST_BOAT; -+ default -> this.getVariant().chestBoatItem.get(); - }; - } - diff --git a/patches/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch b/patches/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch index 43ebd7d9..1b7edd67 100644 --- a/patches/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java -@@ -107,6 +_,9 @@ +@@ -105,6 +_,9 @@ - this.setLootTable(null); + this.setContainerLootTable(null); LootParams.Builder lootparams$builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position()); + // Neo: set the chest to attacking_entity for loot context. + if (this instanceof AbstractMinecartContainer entityContainer) diff --git a/patches/net/minecraft/world/entity/vehicle/Minecart.java.patch b/patches/net/minecraft/world/entity/vehicle/Minecart.java.patch index dcdbc9be..8a977d39 100644 --- a/patches/net/minecraft/world/entity/vehicle/Minecart.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/Minecart.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/vehicle/Minecart.java +++ b/net/minecraft/world/entity/vehicle/Minecart.java -@@ -19,6 +_,8 @@ +@@ -22,6 +_,8 @@ @Override public InteractionResult interact(Player p_38483_, InteractionHand p_38484_) { + InteractionResult ret = super.interact(p_38483_, p_38484_); + if (ret.consumesAction()) return ret; - if (p_38483_.isSecondaryUseActive()) { - return InteractionResult.PASS; - } else if (this.isVehicle()) { + if (!p_38483_.isSecondaryUseActive() && !this.isVehicle() && (this.level().isClientSide || p_38483_.startRiding(this))) { + this.playerRotationOffset = this.rotationOffset; + if (!this.level().isClientSide) { diff --git a/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch b/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch index fa2e6954..febb3543 100644 --- a/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java +++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java -@@ -85,6 +_,8 @@ +@@ -82,6 +_,8 @@ @Override public InteractionResult interact(Player p_38522_, InteractionHand p_38523_) { diff --git a/patches/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch b/patches/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch index 2d4d876d..08ca00da 100644 --- a/patches/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch @@ -1,23 +1,11 @@ --- a/net/minecraft/world/entity/vehicle/MinecartFurnace.java +++ b/net/minecraft/world/entity/vehicle/MinecartFurnace.java -@@ -116,6 +_,8 @@ +@@ -104,6 +_,8 @@ @Override public InteractionResult interact(Player p_38562_, InteractionHand p_38563_) { + InteractionResult ret = super.interact(p_38562_, p_38563_); + if (ret.consumesAction()) return ret; ItemStack itemstack = p_38562_.getItemInHand(p_38563_); - if (INGREDIENT.test(itemstack) && this.fuel + 3600 <= 32000) { + if (itemstack.is(ItemTags.FURNACE_MINECART_FUEL) && this.fuel + 3600 <= 32000) { itemstack.consume(1, p_38562_); -@@ -128,6 +_,11 @@ - } - - return InteractionResult.sidedSuccess(this.level().isClientSide); -+ } -+ -+ @Override -+ public float getMaxCartSpeedOnRail() { -+ return 0.2f; - } - - @Override diff --git a/patches/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch b/patches/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch index 4a73b0ba..253ad729 100644 --- a/patches/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/MinecartSpawner.java +++ b/net/minecraft/world/entity/vehicle/MinecartSpawner.java -@@ -17,6 +_,11 @@ +@@ -18,6 +_,11 @@ public void broadcastEvent(Level p_150342_, BlockPos p_150343_, int p_150344_) { p_150342_.broadcastEntityEvent(MinecartSpawner.this, (byte)p_150344_); } diff --git a/patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch b/patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch new file mode 100644 index 00000000..999ad242 --- /dev/null +++ b/patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch @@ -0,0 +1,57 @@ +--- a/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java +@@ -170,7 +_,7 @@ + + public void adjustToRails(BlockPos p_360495_, BlockState p_362772_, boolean p_366683_) { + if (BaseRailBlock.isRail(p_362772_)) { +- RailShape railshape = p_362772_.getValue(((BaseRailBlock)p_362772_.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)p_362772_.getBlock()).getRailDirection(p_362772_, this.level(), p_360495_, this.minecart); + Pair pair = AbstractMinecart.exits(railshape); + Vec3 vec3 = new Vec3(pair.getFirst()).scale(0.5); + Vec3 vec31 = new Vec3(pair.getSecond()).scale(0.5); +@@ -258,11 +_,11 @@ + if (flag) { + this.minecart.resetFallDistance(); + this.minecart.setOldPosAndRot(); +- if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { ++ if (blockstate.getBlock() instanceof PoweredRailBlock poweredRail && poweredRail.isActivatorRail()) { + this.minecart.activateMinecart(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockstate.getValue(PoweredRailBlock.POWERED)); + } + +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), blockpos, this.minecart);; + Vec3 vec31 = this.calculateTrackSpeed(p_376236_, vec3.horizontal(), newminecartbehavior$trackiteration, blockpos, blockstate, railshape); + if (newminecartbehavior$trackiteration.firstIteration) { + newminecartbehavior$trackiteration.movementLeft = vec31.horizontalDistance(); +@@ -393,7 +_,7 @@ + } + + private Vec3 calculateHaltTrackSpeed(Vec3 p_360517_, BlockState p_362923_) { +- if (p_362923_.is(Blocks.POWERED_RAIL) && !p_362923_.getValue(PoweredRailBlock.POWERED)) { ++ if (p_362923_.getBlock() instanceof PoweredRailBlock poweredRail && !poweredRail.isActivatorRail() && !p_362923_.getValue(PoweredRailBlock.POWERED)) { + return p_360517_.length() < 0.03 ? Vec3.ZERO : p_360517_.scale(0.5); + } else { + return p_360517_; +@@ -401,7 +_,7 @@ + } + + private Vec3 calculateBoostTrackSpeed(Vec3 p_363053_, BlockPos p_361792_, BlockState p_361859_) { +- if (p_361859_.is(Blocks.POWERED_RAIL) && p_361859_.getValue(PoweredRailBlock.POWERED)) { ++ if (p_361859_.getBlock() instanceof PoweredRailBlock poweredRail && !poweredRail.isActivatorRail() && p_361859_.getValue(PoweredRailBlock.POWERED)) { + if (p_363053_.length() > 0.01) { + return p_363053_.normalize().scale(p_363053_.length() + 0.06); + } else { +@@ -450,10 +_,11 @@ + } + + this.minecart.move(MoverType.SELF, vec36.subtract(vec3)); +- BlockState blockstate = this.level().getBlockState(BlockPos.containing(vec36)); ++ BlockPos railPos = BlockPos.containing(vec36); ++ BlockState blockstate = this.level().getBlockState(railPos); + if (flag) { + if (BaseRailBlock.isRail(blockstate)) { +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), railPos, this.minecart);; + if (this.restAtVShape(p_361660_, railshape)) { + return 0.0; + } diff --git a/patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch b/patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch new file mode 100644 index 00000000..d8e36d27 --- /dev/null +++ b/patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch @@ -0,0 +1,55 @@ +--- a/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java +@@ -97,7 +_,7 @@ + this.minecart.setOnRails($$4); + if ($$4) { + this.moveAlongTrack(serverlevel); +- if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { ++ if (blockstate.getBlock() instanceof PoweredRailBlock poweredRail && poweredRail.isActivatorRail()) { + this.minecart.activateMinecart(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockstate.getValue(PoweredRailBlock.POWERED)); + } + } else { +@@ -148,7 +_,7 @@ + d1 = (double)blockpos.getY(); + boolean flag = false; + boolean flag1 = false; +- if (blockstate.is(Blocks.POWERED_RAIL)) { ++ if (blockstate.getBlock() instanceof PoweredRailBlock poweredRail && !poweredRail.isActivatorRail()) { + flag = blockstate.getValue(PoweredRailBlock.POWERED); + flag1 = !flag; + } +@@ -159,7 +_,7 @@ + } + + Vec3 vec31 = this.getDeltaMovement(); +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), blockpos, this.minecart);; + switch (railshape) { + case ASCENDING_EAST: + this.setDeltaMovement(vec31.add(-d3, 0.0, 0.0)); +@@ -317,9 +_,10 @@ + j--; + } + +- BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); ++ BlockPos railPos = new BlockPos(i, j, k); ++ BlockState blockstate = this.level().getBlockState(railPos); + if (BaseRailBlock.isRail(blockstate)) { +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), railPos, this.minecart); + p_363435_ = (double)j; + if (railshape.isSlope()) { + p_363435_ = (double)(j + 1); +@@ -356,9 +_,10 @@ + j--; + } + +- BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); ++ BlockPos railPos = new BlockPos(i, j, k); ++ BlockState blockstate = this.level().getBlockState(railPos); + if (BaseRailBlock.isRail(blockstate)) { +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), railPos, this.minecart); + Pair pair = AbstractMinecart.exits(railshape); + Vec3i vec3i = pair.getFirst(); + Vec3i vec3i1 = pair.getSecond(); diff --git a/patches/net/minecraft/world/food/FoodData.java.patch b/patches/net/minecraft/world/food/FoodData.java.patch deleted file mode 100644 index 71af177d..00000000 --- a/patches/net/minecraft/world/food/FoodData.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/world/food/FoodData.java -+++ b/net/minecraft/world/food/FoodData.java -@@ -13,6 +_,13 @@ - private int tickTimer; - private int lastFoodLevel = 20; - -+ // CraftBukkit start -+ public Player entityhuman = null; -+ public int saturatedRegenRate = 10; -+ public int unsaturatedRegenRate = 80; -+ public int starvationRate = 80; -+ // CraftBukkit end -+ - public FoodData() { - this.saturationLevel = 5.0F; - } diff --git a/patches/net/minecraft/world/food/FoodProperties.java.patch b/patches/net/minecraft/world/food/FoodProperties.java.patch deleted file mode 100644 index feb3b071..00000000 --- a/patches/net/minecraft/world/food/FoodProperties.java.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- a/net/minecraft/world/food/FoodProperties.java -+++ b/net/minecraft/world/food/FoodProperties.java -@@ -49,6 +_,22 @@ - return (int)(this.eatSeconds * 20.0F); - } - -+ public boolean equals(Object otherObject) {// Neo: Fix MC-272643 -+ if(otherObject == this) return true; -+ if (!(otherObject instanceof FoodProperties other)) return false; -+ boolean ans = nutrition == other.nutrition && -+ saturation == other.saturation && -+ canAlwaysEat == other.canAlwaysEat && -+ eatSeconds == other.eatSeconds; -+ if (!ans) return false; -+ if (!effects.equals(other.effects)) return false; -+ ItemStack selfContainer = usingConvertsTo.orElse(null); -+ ItemStack otherContainer = other.usingConvertsTo.orElse(null); -+ if (selfContainer == otherContainer) return true; -+ if (selfContainer == null || otherContainer == null) return false; -+ return selfContainer.getCount() == otherContainer.getCount() && ItemStack.isSameItemSameComponents(selfContainer, otherContainer); -+ } -+ - public static class Builder { - private int nutrition; - private float saturationModifier; -@@ -77,11 +_,18 @@ - return this; - } - -+ // Neo: Use supplier method instead -+ @Deprecated - public FoodProperties.Builder effect(MobEffectInstance p_38763_, float p_38764_) { - this.effects.add(new FoodProperties.PossibleEffect(p_38763_, p_38764_)); - return this; - } - -+ public FoodProperties.Builder effect(java.util.function.Supplier effectIn, float probability) { -+ this.effects.add(new FoodProperties.PossibleEffect(effectIn, probability)); -+ return this; -+ } -+ - public FoodProperties.Builder usingConvertsTo(ItemLike p_347650_) { - this.usingConvertsTo = Optional.of(new ItemStack(p_347650_)); - return this; -@@ -93,7 +_,7 @@ - } - } - -- public static record PossibleEffect(MobEffectInstance effect, float probability) { -+ public static record PossibleEffect(java.util.function.Supplier effectSupplier, float probability) { - public static final Codec CODEC = RecordCodecBuilder.create( - p_337893_ -> p_337893_.group( - MobEffectInstance.CODEC.fieldOf("effect").forGetter(FoodProperties.PossibleEffect::effect), -@@ -109,8 +_,12 @@ - FoodProperties.PossibleEffect::new - ); - -+ private PossibleEffect(MobEffectInstance effect, float probability) { -+ this(() -> effect, probability); -+ } -+ - public MobEffectInstance effect() { -- return new MobEffectInstance(this.effect); -+ return new MobEffectInstance(this.effectSupplier.get()); - } - } - } diff --git a/patches/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/patches/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index 6581ab64..d23a1d76 100644 --- a/patches/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/patches/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -1,87 +1,6 @@ --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -20,6 +_,8 @@ - import net.minecraft.core.BlockPos; - import net.minecraft.core.NonNullList; - import net.minecraft.core.registries.BuiltInRegistries; -+import net.minecraft.network.chat.Component; -+import net.minecraft.resources.ResourceLocation; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.util.Mth; - import net.minecraft.world.Container; -@@ -31,6 +_,9 @@ - import net.minecraft.world.level.Level; - import net.minecraft.world.level.block.Block; - import net.minecraft.world.level.block.entity.BlockEntity; -+import org.bukkit.craftbukkit.entity.CraftHumanEntity; -+import org.bukkit.craftbukkit.inventory.CraftInventory; -+import org.bukkit.inventory.InventoryView; - import org.slf4j.Logger; - - public abstract class AbstractContainerMenu { -@@ -62,6 +_,45 @@ - private ContainerSynchronizer synchronizer; - private boolean suppressRemoteUpdates; - -+ // CraftBukkit start -+ public boolean checkReachable = true; -+ // Mohist start -+ public InventoryView bukkitView = null; -+ -+ public InventoryView getBukkitView(){ -+ return bukkitView; -+ } -+ -+ // Mohist end -+ public void transferTo(AbstractContainerMenu other, CraftHumanEntity player) { -+ InventoryView source = this.getBukkitView(), destination = other.getBukkitView(); -+ ((CraftInventory) source.getTopInventory()).getInventory().onClose(player); -+ ((CraftInventory) source.getBottomInventory()).getInventory().onClose(player); -+ ((CraftInventory) destination.getTopInventory()).getInventory().onOpen(player); -+ ((CraftInventory) destination.getBottomInventory()).getInventory().onOpen(player); -+ } -+ private Component title; -+ public Component getTitle() { -+ // Mohist: null title -> empty title -+ if (this.title == null) { -+ if (this.menuType != null) { -+ ResourceLocation key = BuiltInRegistries.MENU.getKey(this.menuType); -+ if (key == null) { -+ this.title = Component.literal(this.toString()); -+ } else { -+ this.title = Component.translatable(key.toString()); -+ } -+ } else { -+ this.title = Component.literal(this.toString()); -+ } -+ } -+ return this.title; -+ } -+ public void setTitle(Component title) { -+ this.title = title; -+ } -+ // CraftBukkit end -+ - protected AbstractContainerMenu(@Nullable MenuType p_38851_, int p_38852_) { - this.menuType = p_38851_; - this.containerId = p_38852_; -@@ -150,6 +_,15 @@ - } - } - -+ // CraftBukkit start -+ public void broadcastCarriedItem() { -+ this.remoteCarried = this.getCarried().copy(); -+ if (this.synchronizer != null) { -+ this.synchronizer.sendCarriedChange(this, this.remoteCarried); -+ } -+ } -+ // CraftBukkit end -+ - public void removeSlotListener(ContainerListener p_38944_) { - this.containerListeners.remove(p_38944_); - } -@@ -511,6 +_,11 @@ +@@ -559,6 +_,11 @@ } private boolean tryItemClickBehaviourOverride(Player p_249615_, ClickAction p_250300_, Slot p_249384_, ItemStack p_251073_, ItemStack p_252026_) { diff --git a/patches/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch b/patches/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch index aa475430..9581ed49 100644 --- a/patches/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch +++ b/patches/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java +++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java -@@ -167,7 +_,7 @@ +@@ -142,7 +_,7 @@ } protected boolean isFuel(ItemStack p_38989_) { -- return AbstractFurnaceBlockEntity.isFuel(p_38989_); -+ return p_38989_.getBurnTime(this.recipeType) > 0; +- return this.level.fuelValues().isFuel(p_38989_); ++ return p_38989_.getBurnTime(this.recipeType, this.level.fuelValues()) > 0; } public float getBurnProgress() { diff --git a/patches/net/minecraft/world/inventory/AnvilMenu.java.patch b/patches/net/minecraft/world/inventory/AnvilMenu.java.patch index 255c8259..f8446bf4 100644 --- a/patches/net/minecraft/world/inventory/AnvilMenu.java.patch +++ b/patches/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -6,11 +6,11 @@ + float breakChance = net.neoforged.neoforge.common.CommonHooks.onAnvilRepair(p_150474_, p_150475_, AnvilMenu.this.inputSlots.getItem(0), AnvilMenu.this.inputSlots.getItem(1)); + - this.inputSlots.setItem(0, ItemStack.EMPTY); if (this.repairItemCountCost > 0) { ItemStack itemstack = this.inputSlots.getItem(1); + if (!itemstack.isEmpty() && itemstack.getCount() > this.repairItemCountCost) { @@ -95,7 +_,7 @@ - this.cost.set(0); + this.inputSlots.setItem(0, ItemStack.EMPTY); this.access.execute((p_150479_, p_150480_) -> { BlockState blockstate = p_150479_.getBlockState(p_150480_); - if (!p_150474_.hasInfiniteMaterials() && blockstate.is(BlockTags.ANVIL) && p_150474_.getRandom().nextFloat() < 0.12F) { @@ -18,7 +18,7 @@ BlockState blockstate1 = AnvilBlock.damage(blockstate); if (blockstate1 == null) { p_150479_.removeBlock(p_150480_, false); -@@ -124,8 +_,10 @@ +@@ -125,8 +_,10 @@ j += (long)itemstack.getOrDefault(DataComponents.REPAIR_COST, Integer.valueOf(0)).intValue() + (long)itemstack2.getOrDefault(DataComponents.REPAIR_COST, Integer.valueOf(0)).intValue(); this.repairItemCountCost = 0; @@ -27,10 +27,10 @@ if (!itemstack2.isEmpty()) { - boolean flag = itemstack2.has(DataComponents.STORED_ENCHANTMENTS); + flag = itemstack2.has(DataComponents.STORED_ENCHANTMENTS); - if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) { + if (itemstack1.isDamageableItem() && itemstack.isValidRepairItem(itemstack2)) { int l2 = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); if (l2 <= 0) { -@@ -176,8 +_,10 @@ +@@ -177,8 +_,10 @@ int j2 = entry.getIntValue(); j2 = i2 == j2 ? j2 + 1 : Math.max(j2, i2); Enchantment enchantment = holder.value(); @@ -43,15 +43,15 @@ flag1 = true; } -@@ -228,6 +_,7 @@ +@@ -229,6 +_,7 @@ i += k; itemstack1.remove(DataComponents.CUSTOM_NAME); } + if (flag && !itemstack1.isBookEnchantable(itemstack2)) itemstack1 = ItemStack.EMPTY; - int k2 = (int)Mth.clamp(j + (long)i, 0L, 2147483647L); + int k2 = i <= 0 ? 0 : (int)Mth.clamp(j + (long)i, 0L, 2147483647L); this.cost.set(k2); -@@ -297,5 +_,12 @@ +@@ -302,5 +_,12 @@ public int getCost() { return this.cost.get(); diff --git a/patches/net/minecraft/world/inventory/BeaconMenu.java.patch b/patches/net/minecraft/world/inventory/BeaconMenu.java.patch index 8df10e8f..9c42af6e 100644 --- a/patches/net/minecraft/world/inventory/BeaconMenu.java.patch +++ b/patches/net/minecraft/world/inventory/BeaconMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/BeaconMenu.java +++ b/net/minecraft/world/inventory/BeaconMenu.java -@@ -98,10 +_,8 @@ +@@ -87,10 +_,8 @@ } slot.onQuickCraft(itemstack1, itemstack); diff --git a/patches/net/minecraft/world/inventory/BrewingStandMenu.java.patch b/patches/net/minecraft/world/inventory/BrewingStandMenu.java.patch index 9b9d7142..f562eb32 100644 --- a/patches/net/minecraft/world/inventory/BrewingStandMenu.java.patch +++ b/patches/net/minecraft/world/inventory/BrewingStandMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/BrewingStandMenu.java +++ b/net/minecraft/world/inventory/BrewingStandMenu.java -@@ -41,9 +_,9 @@ +@@ -42,9 +_,9 @@ this.brewingStand = p_39095_; this.brewingStandData = p_39096_; PotionBrewing potionbrewing = p_39094_.player.level().potionBrewing(); @@ -13,7 +13,7 @@ this.ingredientSlot = this.addSlot(new BrewingStandMenu.IngredientsSlot(potionbrewing, p_39095_, 3, 79, 17)); this.addSlot(new BrewingStandMenu.FuelSlot(p_39095_, 4, 17, 17)); this.addDataSlots(p_39096_); -@@ -81,7 +_,7 @@ +@@ -73,7 +_,7 @@ if (!this.moveItemStackTo(itemstack1, 3, 4, false)) { return ItemStack.EMPTY; } @@ -22,7 +22,7 @@ if (!this.moveItemStackTo(itemstack1, 0, 3, false)) { return ItemStack.EMPTY; } -@@ -158,13 +_,20 @@ +@@ -150,13 +_,20 @@ } static class PotionSlot extends Slot { @@ -44,7 +44,7 @@ } @Override -@@ -176,14 +_,20 @@ +@@ -168,14 +_,20 @@ public void onTake(Player p_150499_, ItemStack p_150500_) { Optional> optional = p_150500_.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).potion(); if (optional.isPresent() && p_150499_ instanceof ServerPlayer serverplayer) { diff --git a/patches/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/patches/net/minecraft/world/inventory/EnchantmentMenu.java.patch index 817bb84f..a60216de 100644 --- a/patches/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/patches/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -9,10 +9,10 @@ } @Override -@@ -101,23 +_,24 @@ +@@ -91,23 +_,24 @@ if (!itemstack.isEmpty() && itemstack.isEnchantable()) { this.access.execute((p_344366_, p_344367_) -> { - IdMap> idmap = p_344366_.registryAccess().registryOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); + IdMap> idmap = p_344366_.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); - int j = 0; + float j = 0; @@ -37,7 +37,7 @@ } for (int l = 0; l < 3; l++) { -@@ -163,14 +_,10 @@ +@@ -153,14 +_,10 @@ List list = this.getEnchantmentList(p_347276_.registryAccess(), itemstack, p_39466_, this.costs[p_39466_]); if (!list.isEmpty()) { p_39465_.onEnchantmentPerformed(itemstack, i); @@ -56,7 +56,7 @@ itemstack1.consume(i, p_39465_); if (itemstack1.isEmpty()) { -@@ -249,7 +_,7 @@ +@@ -239,7 +_,7 @@ if (!this.moveItemStackTo(itemstack1, 2, 38, true)) { return ItemStack.EMPTY; } diff --git a/patches/net/minecraft/world/inventory/GrindstoneMenu.java.patch b/patches/net/minecraft/world/inventory/GrindstoneMenu.java.patch index 55e782bb..fce1cf64 100644 --- a/patches/net/minecraft/world/inventory/GrindstoneMenu.java.patch +++ b/patches/net/minecraft/world/inventory/GrindstoneMenu.java.patch @@ -37,19 +37,19 @@ private int getExperienceAmount(Level p_39632_) { + if (xp > -1) return xp; - int l = 0; - l += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(0)); - l += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(1)); -@@ -131,6 +_,8 @@ + int i = 0; + i += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(0)); + i += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(1)); +@@ -116,6 +_,8 @@ + } - private ItemStack computeResult(ItemStack p_332654_, ItemStack p_332736_) { - boolean flag = !p_332654_.isEmpty() || !p_332736_.isEmpty(); -+ this.xp = net.neoforged.neoforge.common.CommonHooks.onGrindstoneChange(p_332654_, p_332736_, this.resultSlots, -1); -+ if (this.xp != Integer.MIN_VALUE) return ItemStack.EMPTY; // Porting 1.20.5 check if this is correct - if (!flag) { - return ItemStack.EMPTY; - } else if (p_332654_.getCount() <= 1 && p_332736_.getCount() <= 1) { -@@ -155,7 +_,7 @@ + private void createResult() { ++ this.xp = net.neoforged.neoforge.common.CommonHooks.onGrindstoneChange(this.repairSlots.getItem(0), this.repairSlots.getItem(1), this.resultSlots, -1); ++ if (this.xp == Integer.MIN_VALUE) + this.resultSlots.setItem(0, this.computeResult(this.repairSlots.getItem(0), this.repairSlots.getItem(1))); + this.broadcastChanges(); + } +@@ -146,7 +_,7 @@ int k = p_332686_.getMaxDamage() - p_332686_.getDamageValue(); int l = j + k + i * 5 / 100; int i1 = 1; @@ -58,7 +58,7 @@ if (p_332723_.getMaxStackSize() < 2 || !ItemStack.matches(p_332723_, p_332686_)) { return ItemStack.EMPTY; } -@@ -167,6 +_,7 @@ +@@ -158,6 +_,7 @@ if (itemstack.isDamageableItem()) { itemstack.set(DataComponents.MAX_DAMAGE, i); itemstack.setDamageValue(Math.max(i - l, 0)); diff --git a/patches/net/minecraft/world/inventory/LecternMenu.java.patch b/patches/net/minecraft/world/inventory/LecternMenu.java.patch deleted file mode 100644 index 36b6abd2..00000000 --- a/patches/net/minecraft/world/inventory/LecternMenu.java.patch +++ /dev/null @@ -1,68 +0,0 @@ ---- a/net/minecraft/world/inventory/LecternMenu.java -+++ b/net/minecraft/world/inventory/LecternMenu.java -@@ -2,8 +_,11 @@ - - import net.minecraft.world.Container; - import net.minecraft.world.SimpleContainer; -+import net.minecraft.world.entity.player.Inventory; - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.ItemStack; -+import org.bukkit.craftbukkit.inventory.CraftInventoryLectern; -+import org.bukkit.craftbukkit.inventory.CraftInventoryView; - - public class LecternMenu extends AbstractContainerMenu { - private static final int DATA_COUNT = 1; -@@ -15,6 +_,23 @@ - private final Container lectern; - private final ContainerData lecternData; - -+ // CraftBukkit start -+ private CraftInventoryView bukkitEntity = null; -+ private org.bukkit.entity.Player player; -+ -+ @Override -+ public CraftInventoryView getBukkitView() { -+ if (player == null) return null; -+ if (bukkitEntity != null) { -+ return bukkitEntity; -+ } -+ -+ CraftInventoryLectern inventory = new CraftInventoryLectern(this.lectern); -+ bukkitEntity = new CraftInventoryView(this.player, inventory, this); -+ return bukkitEntity; -+ } -+ // CraftBukkit end -+ - public LecternMenu(int p_39822_) { - this(p_39822_, new SimpleContainer(1), new SimpleContainerData(1)); - } -@@ -34,6 +_,29 @@ - }); - this.addDataSlots(p_39826_); - } -+ -+ // Mohist start -+ public LecternMenu player(Inventory playerinventory) { -+ player = (org.bukkit.entity.Player) playerinventory.player.getBukkitEntity(); // CraftBukkit -+ return this; -+ } -+ -+ public LecternMenu(int pContainerId, Container pLectern, ContainerData pLecternData, Inventory playerinventory) { -+ super(MenuType.LECTERN, pContainerId); -+ checkContainerSize(pLectern, 1); -+ checkContainerDataCount(pLecternData, 1); -+ this.lectern = pLectern; -+ this.lecternData = pLecternData; -+ this.addSlot(new Slot(pLectern, 0, 0, 0) { -+ public void setChanged() { -+ super.setChanged(); -+ LecternMenu.this.slotsChanged(this.container); -+ } -+ }); -+ this.addDataSlots(pLecternData); -+ player = (org.bukkit.entity.Player) playerinventory.player.getBukkitEntity(); // CraftBukkit -+ } -+ // Mohist end - - @Override - public boolean clickMenuButton(Player p_39833_, int p_39834_) { diff --git a/patches/net/minecraft/world/inventory/RecipeBookMenu.java.patch b/patches/net/minecraft/world/inventory/RecipeBookMenu.java.patch deleted file mode 100644 index c9e4cd5c..00000000 --- a/patches/net/minecraft/world/inventory/RecipeBookMenu.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/inventory/RecipeBookMenu.java -+++ b/net/minecraft/world/inventory/RecipeBookMenu.java -@@ -43,6 +_,10 @@ - - public abstract int getSize(); - -+ public java.util.List getRecipeBookCategories() { -+ return net.minecraft.client.RecipeBookCategories.getCategories(this.getRecipeBookType()); -+ } -+ - public abstract RecipeBookType getRecipeBookType(); - - public abstract boolean shouldMoveToInventory(int p_150635_); diff --git a/patches/net/minecraft/world/inventory/ResultSlot.java.patch b/patches/net/minecraft/world/inventory/ResultSlot.java.patch index 19f87b48..4f84a5e0 100644 --- a/patches/net/minecraft/world/inventory/ResultSlot.java.patch +++ b/patches/net/minecraft/world/inventory/ResultSlot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ResultSlot.java +++ b/net/minecraft/world/inventory/ResultSlot.java -@@ -47,6 +_,7 @@ +@@ -51,6 +_,7 @@ protected void checkTakeAchievements(ItemStack p_40185_) { if (this.removeCount > 0) { p_40185_.onCraftedBy(this.player.level(), this.player, this.removeCount); @@ -8,12 +8,12 @@ } if (this.container instanceof RecipeCraftingHolder recipecraftingholder) { -@@ -63,7 +_,9 @@ +@@ -86,7 +_,9 @@ CraftingInput craftinginput = craftinginput$positioned.input(); int i = craftinginput$positioned.left(); int j = craftinginput$positioned.top(); + net.neoforged.neoforge.common.CommonHooks.setCraftingPlayer(p_150638_); - NonNullList nonnulllist = p_150638_.level().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, craftinginput, p_150638_.level()); + NonNullList nonnulllist = this.getRemainingItems(craftinginput, p_150638_.level()); + net.neoforged.neoforge.common.CommonHooks.setCraftingPlayer(null); for (int k = 0; k < craftinginput.height(); k++) { diff --git a/patches/net/minecraft/world/item/ArmorItem.java.patch b/patches/net/minecraft/world/item/ArmorItem.java.patch deleted file mode 100644 index 5f30afe0..00000000 --- a/patches/net/minecraft/world/item/ArmorItem.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/ArmorItem.java -+++ b/net/minecraft/world/item/ArmorItem.java -@@ -49,6 +_,8 @@ - } else { - LivingEntity livingentity = list.get(0); - EquipmentSlot equipmentslot = livingentity.getEquipmentSlotForItem(p_40400_); -+ // Neo: Respect IItemExtension#canEquip in dispenseArmor -+ if (!p_40400_.canEquip(equipmentslot, livingentity)) return false; - ItemStack itemstack = p_40400_.split(1); - livingentity.setItemSlot(equipmentslot, itemstack); - if (livingentity instanceof Mob) { diff --git a/patches/net/minecraft/world/item/AxeItem.java.patch b/patches/net/minecraft/world/item/AxeItem.java.patch index 9f9732d1..1edab201 100644 --- a/patches/net/minecraft/world/item/AxeItem.java.patch +++ b/patches/net/minecraft/world/item/AxeItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/AxeItem.java +++ b/net/minecraft/world/item/AxeItem.java -@@ -60,7 +_,7 @@ +@@ -62,7 +_,7 @@ if (playerHasShieldUseIntent(p_40529_)) { return InteractionResult.PASS; } else { @@ -9,7 +9,7 @@ if (optional.isEmpty()) { return InteractionResult.PASS; } else { -@@ -85,20 +_,19 @@ +@@ -87,20 +_,19 @@ return p_345141_.getHand().equals(InteractionHand.MAIN_HAND) && player.getOffhandItem().is(Items.SHIELD) && !player.isSecondaryUseActive(); } @@ -34,7 +34,7 @@ if (optional2.isPresent()) { p_308922_.playSound(p_309192_, p_308899_, SoundEvents.AXE_WAX_OFF, SoundSource.BLOCKS, 1.0F, 1.0F); p_308922_.levelEvent(p_309192_, 3004, p_308899_, 0); -@@ -110,8 +_,19 @@ +@@ -112,8 +_,19 @@ } } @@ -46,7 +46,7 @@ + private Optional getStripped(BlockState p_150691_) { return Optional.ofNullable(STRIPPABLES.get(p_150691_.getBlock())) - .map(p_150689_ -> p_150689_.defaultBlockState().setValue(RotatedPillarBlock.AXIS, p_150691_.getValue(RotatedPillarBlock.AXIS))); + .map(p_360012_ -> p_360012_.defaultBlockState().setValue(RotatedPillarBlock.AXIS, p_150691_.getValue(RotatedPillarBlock.AXIS))); + } + + @Override diff --git a/patches/net/minecraft/world/item/BlockItem.java.patch b/patches/net/minecraft/world/item/BlockItem.java.patch index eed7cf8e..95447e96 100644 --- a/patches/net/minecraft/world/item/BlockItem.java.patch +++ b/patches/net/minecraft/world/item/BlockItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -82,11 +_,11 @@ +@@ -79,11 +_,11 @@ } } @@ -14,33 +14,18 @@ SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F -@@ -99,10 +_,16 @@ +@@ -96,8 +_,14 @@ } } + @Deprecated //Forge: Use more sensitive version {@link BlockItem#getPlaceSound(BlockState, IBlockReader, BlockPos, Entity) } protected SoundEvent getPlaceSound(BlockState p_40588_) { return p_40588_.getSoundType().getPlaceSound(); - } - ++ } ++ + //Forge: Sensitive version of BlockItem#getPlaceSound + protected SoundEvent getPlaceSound(BlockState state, Level world, BlockPos pos, Player entity) { + return state.getSoundType(world, pos, entity).getPlaceSound(); -+ } -+ - @Nullable - public BlockPlaceContext updatePlacementContext(BlockPlaceContext p_40609_) { - return p_40609_; -@@ -193,6 +_,12 @@ - - public void registerBlocks(Map p_40607_, Item p_40608_) { - p_40607_.put(this.getBlock(), p_40608_); -+ } -+ -+ /** @deprecated Neo: To be removed without replacement since registry replacement is not a feature anymore. */ -+ @Deprecated(forRemoval = true, since = "1.21.1") -+ public void removeFromBlockToItemMap(Map blockToItemMap, Item itemIn) { -+ blockToItemMap.remove(this.getBlock()); } - @Override + @Nullable diff --git a/patches/net/minecraft/world/item/BowItem.java.patch b/patches/net/minecraft/world/item/BowItem.java.patch index 88e532ec..0264038c 100644 --- a/patches/net/minecraft/world/item/BowItem.java.patch +++ b/patches/net/minecraft/world/item/BowItem.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/item/BowItem.java +++ b/net/minecraft/world/item/BowItem.java -@@ -28,6 +_,8 @@ - ItemStack itemstack = player.getProjectile(p_40667_); - if (!itemstack.isEmpty()) { +@@ -32,6 +_,8 @@ + return false; + } else { int i = this.getUseDuration(p_40667_, p_40669_) - p_40670_; + i = net.neoforged.neoforge.event.EventHooks.onArrowLoose(p_40667_, p_40668_, player, i, !itemstack.isEmpty()); -+ if (i < 0) return; ++ if (i < 0) return false; float f = getPowerForTime(i); - if (!((double)f < 0.1)) { - List list = draw(p_40667_, itemstack, player); -@@ -82,6 +_,10 @@ - public InteractionResultHolder use(Level p_40672_, Player p_40673_, InteractionHand p_40674_) { + if ((double)f < 0.1) { + return false; +@@ -89,6 +_,10 @@ + public InteractionResult use(Level p_40672_, Player p_40673_, InteractionHand p_40674_) { ItemStack itemstack = p_40673_.getItemInHand(p_40674_); boolean flag = !p_40673_.getProjectile(itemstack).isEmpty(); + -+ InteractionResultHolder ret = net.neoforged.neoforge.event.EventHooks.onArrowNock(itemstack, p_40672_, p_40673_, p_40674_, flag); ++ InteractionResult ret = net.neoforged.neoforge.event.EventHooks.onArrowNock(itemstack, p_40672_, p_40673_, p_40674_, flag); + if (ret != null) return ret; + if (!p_40673_.hasInfiniteMaterials() && !flag) { - return InteractionResultHolder.fail(itemstack); + return InteractionResult.FAIL; } else { diff --git a/patches/net/minecraft/world/item/BrushItem.java.patch b/patches/net/minecraft/world/item/BrushItem.java.patch index 34e22818..7b051f9c 100644 --- a/patches/net/minecraft/world/item/BrushItem.java.patch +++ b/patches/net/minecraft/world/item/BrushItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BrushItem.java +++ b/net/minecraft/world/item/BrushItem.java -@@ -142,4 +_,9 @@ +@@ -143,4 +_,9 @@ }; } } diff --git a/patches/net/minecraft/world/item/BucketItem.java.patch b/patches/net/minecraft/world/item/BucketItem.java.patch index c87fec7c..911b51c9 100644 --- a/patches/net/minecraft/world/item/BucketItem.java.patch +++ b/patches/net/minecraft/world/item/BucketItem.java.patch @@ -10,7 +10,7 @@ ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, p_40704_, itemstack3); if (!p_40703_.isClientSide) { @@ -72,8 +_,8 @@ - return InteractionResultHolder.fail(itemstack); + return InteractionResult.FAIL; } else { BlockState blockstate = p_40703_.getBlockState(blockpos); - BlockPos blockpos2 = blockstate.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? blockpos : blockpos1; diff --git a/patches/net/minecraft/world/item/BundleItem.java.patch b/patches/net/minecraft/world/item/BundleItem.java.patch index 945917f0..ff5bc705 100644 --- a/patches/net/minecraft/world/item/BundleItem.java.patch +++ b/patches/net/minecraft/world/item/BundleItem.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/item/BundleItem.java +++ b/net/minecraft/world/item/BundleItem.java -@@ -38,7 +_,7 @@ - +@@ -61,7 +_,7 @@ @Override public boolean overrideStackedOnOther(ItemStack p_150733_, Slot p_150734_, ClickAction p_150735_, Player p_150736_) { -- if (p_150735_ != ClickAction.SECONDARY) { -+ if (p_150733_.getCount() != 1 || p_150735_ != ClickAction.SECONDARY) { + BundleContents bundlecontents = p_150733_.get(DataComponents.BUNDLE_CONTENTS); +- if (bundlecontents == null) { ++ if (bundlecontents == null || p_150733_.getCount() != 1) { return false; } else { - BundleContents bundlecontents = p_150733_.get(DataComponents.BUNDLE_CONTENTS); -@@ -71,6 +_,7 @@ + ItemStack itemstack = p_150734_.getItem(); +@@ -100,6 +_,7 @@ public boolean overrideOtherStackedOnMe( ItemStack p_150742_, ItemStack p_150743_, Slot p_150744_, ClickAction p_150745_, Player p_150746_, SlotAccess p_150747_ ) { + if (p_150742_.getCount() != 1) return false; - if (p_150745_ == ClickAction.SECONDARY && p_150744_.allowModification(p_150746_)) { - BundleContents bundlecontents = p_150742_.get(DataComponents.BUNDLE_CONTENTS); - if (bundlecontents == null) { + if (p_150745_ == ClickAction.PRIMARY && p_150743_.isEmpty()) { + toggleSelectedItem(p_150742_, -1); + return false; diff --git a/patches/net/minecraft/world/item/ChorusFruitItem.java.patch b/patches/net/minecraft/world/item/ChorusFruitItem.java.patch deleted file mode 100644 index 1080f173..00000000 --- a/patches/net/minecraft/world/item/ChorusFruitItem.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/item/ChorusFruitItem.java -+++ b/net/minecraft/world/item/ChorusFruitItem.java -@@ -34,7 +_,9 @@ - } - - Vec3 vec3 = p_40714_.position(); -- if (p_40714_.randomTeleport(d0, d1, d2, true)) { -+ net.neoforged.neoforge.event.entity.EntityTeleportEvent.ChorusFruit event = net.neoforged.neoforge.event.EventHooks.onChorusFruitTeleport(p_40714_, d0, d1, d2); -+ if (event.isCanceled()) return itemstack; -+ if (p_40714_.randomTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) { - p_40713_.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(p_40714_)); - SoundSource soundsource; - SoundEvent soundevent; diff --git a/patches/net/minecraft/world/item/CrossbowItem.java.patch b/patches/net/minecraft/world/item/CrossbowItem.java.patch index b21064d1..6cb5f7be 100644 --- a/patches/net/minecraft/world/item/CrossbowItem.java.patch +++ b/patches/net/minecraft/world/item/CrossbowItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/CrossbowItem.java +++ b/net/minecraft/world/item/CrossbowItem.java -@@ -181,6 +_,7 @@ +@@ -184,6 +_,7 @@ Level p_40888_, LivingEntity p_40889_, InteractionHand p_40890_, ItemStack p_40891_, float p_40892_, float p_40893_, @Nullable LivingEntity p_331602_ ) { if (p_40888_ instanceof ServerLevel serverlevel) { diff --git a/patches/net/minecraft/world/item/DyeColor.java.patch b/patches/net/minecraft/world/item/DyeColor.java.patch index 641da941..ff5a2951 100644 --- a/patches/net/minecraft/world/item/DyeColor.java.patch +++ b/patches/net/minecraft/world/item/DyeColor.java.patch @@ -15,7 +15,7 @@ this.textColor = p_41051_; + this.dyesTag = net.minecraft.tags.ItemTags.create(net.minecraft.resources.ResourceLocation.fromNamespaceAndPath("c", "dyes/" + p_41047_)); + this.dyedTag = net.minecraft.tags.ItemTags.create(net.minecraft.resources.ResourceLocation.fromNamespaceAndPath("c", "dyed/" + p_41047_)); - this.textureDiffuseColor = FastColor.ARGB32.opaque(p_41048_); + this.textureDiffuseColor = ARGB.opaque(p_41048_); this.fireworkColor = p_41050_; } @@ -102,5 +_,35 @@ diff --git a/patches/net/minecraft/world/item/ElytraItem.java.patch b/patches/net/minecraft/world/item/ElytraItem.java.patch deleted file mode 100644 index 7dedbef3..00000000 --- a/patches/net/minecraft/world/item/ElytraItem.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/world/item/ElytraItem.java -+++ b/net/minecraft/world/item/ElytraItem.java -@@ -31,6 +_,25 @@ - } - - @Override -+ public boolean canElytraFly(ItemStack stack, net.minecraft.world.entity.LivingEntity entity) { -+ return ElytraItem.isFlyEnabled(stack); -+ } -+ -+ @Override -+ public boolean elytraFlightTick(ItemStack stack, net.minecraft.world.entity.LivingEntity entity, int flightTicks) { -+ if (!entity.level().isClientSide) { -+ int nextFlightTick = flightTicks + 1; -+ if (nextFlightTick % 10 == 0) { -+ if (nextFlightTick % 20 == 0) { -+ stack.hurtAndBreak(1, entity, net.minecraft.world.entity.EquipmentSlot.CHEST); -+ } -+ entity.gameEvent(net.minecraft.world.level.gameevent.GameEvent.ELYTRA_GLIDE); -+ } -+ } -+ return true; -+ } -+ -+ @Override - public Holder getEquipSound() { - return SoundEvents.ARMOR_EQUIP_ELYTRA; - } diff --git a/patches/net/minecraft/world/item/FishingRodItem.java.patch b/patches/net/minecraft/world/item/FishingRodItem.java.patch index 250a7e3a..7bad48b3 100644 --- a/patches/net/minecraft/world/item/FishingRodItem.java.patch +++ b/patches/net/minecraft/world/item/FishingRodItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/FishingRodItem.java +++ b/net/minecraft/world/item/FishingRodItem.java -@@ -24,7 +_,11 @@ +@@ -25,7 +_,11 @@ if (p_41291_.fishing != null) { if (!p_41290_.isClientSide) { int i = p_41291_.fishing.retrieve(itemstack); @@ -12,10 +12,10 @@ } p_41290_.playSound( -@@ -65,5 +_,10 @@ - @Override - public int getEnchantmentValue() { - return 1; +@@ -61,5 +_,10 @@ + } + + return InteractionResult.SUCCESS; + } + + @Override diff --git a/patches/net/minecraft/world/item/FlintAndSteelItem.java.patch b/patches/net/minecraft/world/item/FlintAndSteelItem.java.patch index 3a550060..aac6bbee 100644 --- a/patches/net/minecraft/world/item/FlintAndSteelItem.java.patch +++ b/patches/net/minecraft/world/item/FlintAndSteelItem.java.patch @@ -21,7 +21,7 @@ p_41297_.getItemInHand().hurtAndBreak(1, player, LivingEntity.getSlotForHand(p_41297_.getHand())); @@ -56,5 +_,10 @@ - return InteractionResult.sidedSuccess(level.isClientSide()); + return InteractionResult.SUCCESS; } + } + diff --git a/patches/net/minecraft/world/item/HoneyBottleItem.java.patch b/patches/net/minecraft/world/item/HoneyBottleItem.java.patch deleted file mode 100644 index ae550d25..00000000 --- a/patches/net/minecraft/world/item/HoneyBottleItem.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/HoneyBottleItem.java -+++ b/net/minecraft/world/item/HoneyBottleItem.java -@@ -28,7 +_,7 @@ - } - - if (!p_41349_.isClientSide) { -- p_41350_.removeEffect(MobEffects.POISON); -+ p_41350_.removeEffectsCuredBy(net.neoforged.neoforge.common.EffectCures.HONEY); - } - - if (p_41348_.isEmpty()) { diff --git a/patches/net/minecraft/world/item/Item.java.patch b/patches/net/minecraft/world/item/Item.java.patch index 4054c635..85a8aab6 100644 --- a/patches/net/minecraft/world/item/Item.java.patch +++ b/patches/net/minecraft/world/item/Item.java.patch @@ -1,19 +1,25 @@ --- a/net/minecraft/world/item/Item.java +++ b/net/minecraft/world/item/Item.java -@@ -56,9 +_,9 @@ +@@ -70,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import org.slf4j.Logger; -public class Item implements FeatureElement, ItemLike { +public class Item implements FeatureElement, ItemLike, net.neoforged.neoforge.common.extensions.IItemExtension { + public static final Codec> CODEC = BuiltInRegistries.ITEM + .holderByNameCodec() + .validate( +@@ -79,7 +_,7 @@ + : DataResult.success(p_381630_) + ); private static final Logger LOGGER = LogUtils.getLogger(); - public static final Map BY_BLOCK = Maps.newHashMap(); + public static final Map BY_BLOCK = net.neoforged.neoforge.registries.GameData.getBlockItemMap(); public static final ResourceLocation BASE_ATTACK_DAMAGE_ID = ResourceLocation.withDefaultNamespace("base_attack_damage"); public static final ResourceLocation BASE_ATTACK_SPEED_ID = ResourceLocation.withDefaultNamespace("base_attack_speed"); public static final int DEFAULT_MAX_STACK_SIZE = 64; -@@ -89,12 +_,13 @@ - this.components = p_41383_.buildAndValidateComponents(); +@@ -110,7 +_,7 @@ + this.components = p_41383_.buildAndValidateComponents(Component.translatable(this.descriptionId), p_41383_.effectiveModel()); this.craftingRemainingItem = p_41383_.craftingRemainingItem; this.requiredFeatures = p_41383_.requiredFeatures; - if (SharedConstants.IS_RUNNING_IN_IDE) { @@ -21,13 +27,7 @@ String s = this.getClass().getSimpleName(); if (!s.endsWith("Item")) { LOGGER.error("Item classes should end with Item and {} doesn't.", s); - } - } -+ this.canRepair = p_41383_.canRepair; - } - - @Deprecated -@@ -106,6 +_,15 @@ +@@ -127,6 +_,15 @@ return this.components; } @@ -37,13 +37,13 @@ + if (!net.neoforged.neoforge.internal.RegistrationEvents.canModifyComponents()) throw new IllegalStateException("Default components cannot be modified now!"); + var builder = DataComponentMap.builder().addAll(components); + patch.entrySet().forEach(entry -> builder.set((DataComponentType)entry.getKey(), entry.getValue().orElse(null))); -+ components = Properties.COMPONENT_INTERNER.intern(Properties.validateComponents(builder.build())); ++ components = Properties.validateComponents(builder.build()); + } + public int getDefaultMaxStackSize() { return this.components.getOrDefault(DataComponents.MAX_STACK_SIZE, 1); } -@@ -113,6 +_,8 @@ +@@ -134,6 +_,8 @@ public void onUseTick(Level p_41428_, LivingEntity p_41429_, ItemStack p_41430_, int p_41431_) { } @@ -52,25 +52,7 @@ public void onDestroyed(ItemEntity p_150887_) { } -@@ -139,7 +_,7 @@ - - public InteractionResultHolder use(Level p_41432_, Player p_41433_, InteractionHand p_41434_) { - ItemStack itemstack = p_41433_.getItemInHand(p_41434_); -- FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); -+ FoodProperties foodproperties = itemstack.getFoodProperties(p_41433_); - if (foodproperties != null) { - if (p_41433_.canEat(foodproperties.canAlwaysEat())) { - p_41433_.startUsingItem(p_41434_); -@@ -153,7 +_,7 @@ - } - - public ItemStack finishUsingItem(ItemStack p_41409_, Level p_41410_, LivingEntity p_41411_) { -- FoodProperties foodproperties = p_41409_.get(DataComponents.FOOD); -+ FoodProperties foodproperties = p_41409_.getFoodProperties(p_41411_); - return foodproperties != null ? p_41411_.eat(p_41410_, p_41409_, foodproperties) : p_41409_; - } - -@@ -162,12 +_,13 @@ +@@ -181,12 +_,13 @@ } public int getBarWidth(ItemStack p_150900_) { @@ -86,109 +68,49 @@ return Mth.hsvToRgb(f / 3.0F, 1.0F, 1.0F); } -@@ -240,10 +_,12 @@ - } - - @Nullable -+ @Deprecated // Use ItemStack sensitive version. - public final Item getCraftingRemainingItem() { - return this.craftingRemainingItem; +@@ -243,6 +_,7 @@ + return BuiltInRegistries.ITEM.wrapAsHolder(this).getRegisteredName(); } + @Deprecated // Use ItemStack sensitive version. - public boolean hasCraftingRemainingItem() { - return this.craftingRemainingItem != null; + public final ItemStack getCraftingRemainder() { + return this.craftingRemainingItem == null ? ItemStack.EMPTY : new ItemStack(this.craftingRemainingItem); } -@@ -267,7 +_,7 @@ - } - - public int getUseDuration(ItemStack p_41454_, LivingEntity p_344979_) { -- FoodProperties foodproperties = p_41454_.get(DataComponents.FOOD); -+ FoodProperties foodproperties = p_41454_.getFoodProperties(null); - return foodproperties != null ? foodproperties.eatDurationTicks() : 0; - } - -@@ -299,6 +_,8 @@ - return p_41436_.clip(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, p_41438_, p_41437_)); - } - -+ /** @deprecated Neo: Use ItemStack sensitive version. */ -+ @Deprecated - public int getEnchantmentValue() { - return 0; - } -@@ -307,13 +_,23 @@ - return false; - } - -+ /** -+ * @deprecated Neo: Use {@link Item#getDefaultAttributeModifiers(ItemStack)} -+ */ - @Deprecated - public ItemAttributeModifiers getDefaultAttributeModifiers() { - return ItemAttributeModifiers.EMPTY; +@@ -302,7 +_,12 @@ } -+ protected final boolean canRepair; -+ -+ @Override -+ public boolean isRepairable(ItemStack stack) { -+ return canRepair && isDamageable(stack); -+ } -+ public boolean useOnRelease(ItemStack p_41464_) { - return false; + return p_41464_.getItem() == Items.CROSSBOW; ++ } ++ ++ @Override ++ public boolean isRepairable(ItemStack stack) { ++ return stack.has(DataComponents.REPAIRABLE) && isDamageable(stack); } public ItemStack getDefaultInstance() { -@@ -341,13 +_,22 @@ +@@ -322,7 +_,7 @@ return this.requiredFeatures; } - public static class Properties { -+ /** -+ * Neo: Allowing mods to define client behavior for their Items -+ * @deprecated Use {@link net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent} instead -+ */ -+ @Deprecated(forRemoval = true, since = "1.21") -+ public void initializeClient(java.util.function.Consumer consumer) { -+ } -+ + public static class Properties implements net.neoforged.neoforge.common.extensions.IItemPropertiesExtensions { - private static final Interner COMPONENT_INTERNER = Interners.newStrongInterner(); - @Nullable - private DataComponentMap.Builder components; - @Nullable - Item craftingRemainingItem; - FeatureFlagSet requiredFeatures = FeatureFlags.VANILLA_SET; -+ private boolean canRepair = true; - - public Item.Properties food(FoodProperties p_41490_) { - return this.component(DataComponents.FOOD, p_41490_); -@@ -381,12 +_,18 @@ - return this.component(DataComponents.JUKEBOX_PLAYABLE, new JukeboxPlayable(new EitherHolder<>(p_350862_), true)); - } - -+ public Item.Properties setNoRepair() { -+ canRepair = false; -+ return this; -+ } -+ - public Item.Properties requiredFeatures(FeatureFlag... p_250948_) { - this.requiredFeatures = FeatureFlags.REGISTRY.subset(p_250948_); - return this; + private static final DependantName BLOCK_DESCRIPTION_ID = p_371954_ -> Util.makeDescriptionId("block", p_371954_.location()); + private static final DependantName ITEM_DESCRIPTION_ID = p_371511_ -> Util.makeDescriptionId("item", p_371511_.location()); + private final DataComponentMap.Builder components = DataComponentMap.builder().addAll(DataComponents.COMMON_ITEM_COMPONENTS); +@@ -438,6 +_,7 @@ } public Item.Properties component(DataComponentType p_330871_, T p_330323_) { + net.neoforged.neoforge.common.CommonHooks.validateComponent(p_330323_); - if (this.components == null) { - this.components = DataComponentMap.builder().addAll(DataComponents.COMMON_ITEM_COMPONENTS); - } -@@ -401,6 +_,10 @@ + this.components.set(p_330871_, p_330323_); + return this; + } +@@ -448,6 +_,10 @@ - DataComponentMap buildAndValidateComponents() { - DataComponentMap datacomponentmap = this.buildComponents(); + DataComponentMap buildAndValidateComponents(Component p_371796_, ResourceLocation p_371450_) { + DataComponentMap datacomponentmap = this.components.set(DataComponents.ITEM_NAME, p_371796_).set(DataComponents.ITEM_MODEL, p_371450_).build(); + return validateComponents(datacomponentmap); + } + @@ -196,7 +118,7 @@ if (datacomponentmap.has(DataComponents.DAMAGE) && datacomponentmap.getOrDefault(DataComponents.MAX_STACK_SIZE, 1) > 1) { throw new IllegalStateException("Item cannot have both durability and be stackable"); } else { -@@ -441,6 +_,14 @@ +@@ -484,6 +_,14 @@ @Nullable MapItemSavedData mapData(MapId p_339670_); @@ -211,7 +133,7 @@ static Item.TooltipContext of(@Nullable final Level p_339599_) { return p_339599_ == null ? EMPTY : new Item.TooltipContext() { @Override -@@ -456,6 +_,11 @@ +@@ -499,6 +_,11 @@ @Override public MapItemSavedData mapData(MapId p_339628_) { return p_339599_.getMapData(p_339628_); diff --git a/patches/net/minecraft/world/item/ItemStack.java.patch b/patches/net/minecraft/world/item/ItemStack.java.patch index 4c1f77b5..6842e353 100644 --- a/patches/net/minecraft/world/item/ItemStack.java.patch +++ b/patches/net/minecraft/world/item/ItemStack.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -92,7 +_,7 @@ +@@ -97,7 +_,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; -public final class ItemStack implements DataComponentHolder { +public final class ItemStack implements DataComponentHolder, net.neoforged.neoforge.common.extensions.IItemStackExtension, net.neoforged.neoforge.common.MutableDataComponentHolder { - public static final Codec> ITEM_NON_AIR_CODEC = BuiltInRegistries.ITEM - .holderByNameCodec() - .validate( -@@ -234,6 +_,10 @@ + public static final Codec CODEC = Codec.lazyInitialized( + () -> RecordCodecBuilder.create( + p_381569_ -> p_381569_.group( +@@ -233,6 +_,10 @@ return !this.isEmpty() ? this.components.asPatch() : DataComponentPatch.EMPTY; } @@ -20,7 +20,7 @@ public ItemStack(ItemLike p_41599_) { this(p_41599_, 1); } -@@ -339,7 +_,7 @@ +@@ -338,7 +_,7 @@ } public boolean is(Holder p_220166_) { @@ -29,19 +29,20 @@ } public boolean is(HolderSet p_298683_) { -@@ -351,13 +_,26 @@ +@@ -350,13 +_,27 @@ } public InteractionResult useOn(UseOnContext p_41662_) { + var e = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent(p_41662_, net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent.UsePhase.ITEM_AFTER_BLOCK)); -+ if (e.isCanceled()) return e.getCancellationResult().result(); ++ if (e.isCanceled()) return e.getCancellationResult(); + if (!p_41662_.getLevel().isClientSide) return net.neoforged.neoforge.common.CommonHooks.onPlaceItemIntoWorld(p_41662_); + return onItemUse(p_41662_, (c) -> getItem().useOn(p_41662_)); + } + ++ @Override + public InteractionResult onItemUseFirst(UseOnContext p_41662_) { + var e = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent(p_41662_, net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent.UsePhase.ITEM_BEFORE_BLOCK)); -+ if (e.isCanceled()) return e.getCancellationResult().result(); ++ if (e.isCanceled()) return e.getCancellationResult(); + return onItemUse(p_41662_, (c) -> getItem().onItemUseFirst(this, p_41662_)); + } + @@ -54,10 +55,10 @@ Item item = this.getItem(); - InteractionResult interactionresult = item.useOn(p_41662_); + InteractionResult interactionresult = callback.apply(p_41662_); - if (player != null && interactionresult.indicateItemUse()) { - player.awardStat(Stats.ITEM_USED.get(item)); - } -@@ -382,7 +_,8 @@ + if (player != null + && interactionresult instanceof InteractionResult.Success interactionresult$success + && interactionresult$success.wasItemInteraction()) { +@@ -410,7 +_,8 @@ if (this.isEmpty()) { throw new IllegalStateException("Cannot encode empty ItemStack"); } else { @@ -67,7 +68,7 @@ } } -@@ -390,7 +_,8 @@ +@@ -418,7 +_,8 @@ if (this.isEmpty()) { throw new IllegalStateException("Cannot encode empty ItemStack"); } else { @@ -77,7 +78,7 @@ } } -@@ -399,7 +_,7 @@ +@@ -427,7 +_,7 @@ } public int getMaxStackSize() { @@ -86,7 +87,7 @@ } public boolean isStackable() { -@@ -411,23 +_,28 @@ +@@ -439,19 +_,19 @@ } public boolean isDamaged() { @@ -109,28 +110,46 @@ + return this.getItem().getMaxDamage(this); } + public boolean isBroken() { +@@ -463,6 +_,11 @@ + } + public void hurtAndBreak(int p_220158_, ServerLevel p_346256_, @Nullable ServerPlayer p_220160_, Consumer p_348596_) { + this.hurtAndBreak(p_220158_, p_346256_, (LivingEntity) p_220160_, p_348596_); + } + + public void hurtAndBreak(int p_220158_, ServerLevel p_346256_, @Nullable LivingEntity p_220160_, Consumer p_348596_) { - if (this.isDamageableItem()) { -+ p_220158_ = getItem().damageItem(this, p_220158_, p_220160_, p_348596_); - if (p_220160_ == null || !p_220160_.hasInfiniteMaterials()) { - if (p_220158_ > 0) { - p_220158_ = EnchantmentHelper.processDurabilityChange(p_346256_, this, p_220158_); -@@ -436,8 +_,8 @@ - } - } - -- if (p_220160_ != null && p_220158_ != 0) { -- CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(p_220160_, this, this.getDamageValue() + p_220158_); -+ if (p_220160_ instanceof ServerPlayer sp && p_220158_ != 0) { -+ CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(sp, this, this.getDamageValue() + p_220158_); - } - - int i = this.getDamageValue() + p_220158_; -@@ -456,7 +_,7 @@ ++ p_220158_ = getItem().damageItem(this, p_220158_, p_220160_, p_348596_); + int i = this.processDurabilityChange(p_220158_, p_346256_, p_220160_); + if (i != 0) { + this.applyDamage(this.getDamageValue() + i, p_220160_, p_348596_); +@@ -470,6 +_,10 @@ + } + + private int processDurabilityChange(int p_361290_, ServerLevel p_361409_, @Nullable ServerPlayer p_364940_) { ++ return processDurabilityChange(p_361290_, p_361409_, (LivingEntity) p_364940_); ++ } ++ ++ private int processDurabilityChange(int p_361290_, ServerLevel p_361409_, @Nullable LivingEntity p_364940_) { + if (!this.isDamageableItem()) { + return 0; + } else if (p_364940_ != null && p_364940_.hasInfiniteMaterials()) { +@@ -480,8 +_,12 @@ + } + + private void applyDamage(int p_361754_, @Nullable ServerPlayer p_364853_, Consumer p_360895_) { +- if (p_364853_ != null) { +- CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(p_364853_, this, p_361754_); ++ applyDamage(p_361754_, (LivingEntity) p_364853_, p_360895_); ++ } ++ ++ private void applyDamage(int p_361754_, @Nullable LivingEntity p_364853_, Consumer p_360895_) { ++ if (p_364853_ instanceof ServerPlayer serverPlayer) { ++ CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(serverPlayer, this, p_361754_); + } + + this.setDamageValue(p_361754_); +@@ -510,7 +_,7 @@ this.hurtAndBreak( p_41623_, serverlevel, @@ -139,16 +158,27 @@ p_348383_ -> p_41624_.onEquippedItemBroken(p_348383_, p_319898_) ); } -@@ -728,7 +_,7 @@ - return List.of(); - } else { - List list = Lists.newArrayList(); -- MutableComponent mutablecomponent = Component.empty().append(this.getHoverName()).withStyle(this.getRarity().color()); -+ MutableComponent mutablecomponent = Component.empty().append(this.getHoverName()).withStyle(this.getRarity().getStyleModifier()); - if (this.has(DataComponents.CUSTOM_NAME)) { - mutablecomponent.withStyle(ChatFormatting.ITALIC); - } -@@ -784,12 +_,14 @@ +@@ -785,7 +_,7 @@ + } + + public Component getStyledHoverName() { +- MutableComponent mutablecomponent = Component.empty().append(this.getHoverName()).withStyle(this.getRarity().color()); ++ MutableComponent mutablecomponent = Component.empty().append(this.getHoverName()).withStyle(this.getRarity().getStyleModifier()); + if (this.has(DataComponents.CUSTOM_NAME)) { + mutablecomponent.withStyle(ChatFormatting.ITALIC); + } +@@ -826,7 +_,9 @@ + this.addToTooltip(DataComponents.ENCHANTMENTS, p_339637_, consumer, p_41653_); + this.addToTooltip(DataComponents.DYED_COLOR, p_339637_, consumer, p_41653_); + this.addToTooltip(DataComponents.LORE, p_339637_, consumer, p_41653_); +- this.addAttributeTooltips(consumer, p_41652_); ++ // Neo: Replace attribute tooltips with custom handling ++ net.neoforged.neoforge.common.util.AttributeUtil.addAttributeTooltips(this, consumer, ++ net.neoforged.neoforge.common.util.AttributeTooltipContext.of(p_41652_, p_339637_, p_41653_)); + this.addToTooltip(DataComponents.UNBREAKABLE, p_339637_, consumer, p_41653_); + this.addToTooltip(DataComponents.OMINOUS_BOTTLE_AMPLIFIER, p_339637_, consumer, p_41653_); + this.addToTooltip(DataComponents.SUSPICIOUS_STEW_EFFECTS, p_339637_, consumer, p_41653_); +@@ -860,10 +_,15 @@ list.add(DISABLED_ITEM_TOOLTIP); } @@ -157,13 +187,14 @@ } } ++ /** ++ * @deprecated Neo: Use {@link net.neoforged.neoforge.client.util.TooltipUtil#addAttributeTooltips} ++ */ ++ @Deprecated private void addAttributeTooltips(Consumer p_330796_, @Nullable Player p_330530_) { ItemAttributeModifiers itemattributemodifiers = this.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); -+ // Neo: We don't need to call IItemStackExtension#getAttributeModifiers here, since it will be done in forEachModifier. if (itemattributemodifiers.showInTooltip()) { - for (EquipmentSlotGroup equipmentslotgroup : EquipmentSlotGroup.values()) { - MutableBoolean mutableboolean = new MutableBoolean(true); -@@ -897,6 +_,17 @@ +@@ -973,6 +_,17 @@ return !this.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY).isEmpty(); } @@ -181,50 +212,34 @@ public ItemEnchantments getEnchantments() { return this.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY); } -@@ -922,6 +_,12 @@ +@@ -998,14 +_,26 @@ } public void forEachModifier(EquipmentSlotGroup p_348610_, BiConsumer, AttributeModifier> p_348516_) { + // Neo: Reflect real attribute modifiers when doing iteration + this.getAttributeModifiers().forEach(p_348610_, p_348516_); -+ + if (false) { + // Start disabled vanilla code -+ ItemAttributeModifiers itemattributemodifiers = this.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); - if (!itemattributemodifiers.modifiers().isEmpty()) { - itemattributemodifiers.forEach(p_348610_, p_348516_); -@@ -929,10 +_,19 @@ - this.getItem().getDefaultAttributeModifiers().forEach(p_348610_, p_348516_); - } - + itemattributemodifiers.forEach(p_348610_, p_348516_); + // end disabled vanilla code + } -+ EnchantmentHelper.forEachModifier(this, p_348610_, p_348516_); } public void forEachModifier(EquipmentSlot p_332001_, BiConsumer, AttributeModifier> p_330882_) { + // Neo: Reflect real attribute modifiers when doing iteration + this.getAttributeModifiers().forEach(p_332001_, p_330882_); -+ + if (false) { + // Start disabled vanilla code -+ ItemAttributeModifiers itemattributemodifiers = this.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); - if (!itemattributemodifiers.modifiers().isEmpty()) { - itemattributemodifiers.forEach(p_332001_, p_330882_); -@@ -940,6 +_,9 @@ - this.getItem().getDefaultAttributeModifiers().forEach(p_332001_, p_330882_); - } - + itemattributemodifiers.forEach(p_332001_, p_330882_); + // end disabled vanilla code + } -+ EnchantmentHelper.forEachModifier(this, p_332001_, p_330882_); } -@@ -951,7 +_,7 @@ +@@ -1017,7 +_,7 @@ MutableComponent mutablecomponent1 = ComponentUtils.wrapInSquareBrackets(mutablecomponent); if (!this.isEmpty()) { @@ -233,7 +248,7 @@ .withStyle(p_220170_ -> p_220170_.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new HoverEvent.ItemStackInfo(this)))); } -@@ -1014,6 +_,8 @@ +@@ -1085,6 +_,8 @@ this.getItem().onUseTick(p_41732_, p_41733_, this, p_41734_); } @@ -242,11 +257,11 @@ public void onDestroyed(ItemEntity p_150925_) { this.getItem().onDestroyed(p_150925_); } -@@ -1031,6 +_,7 @@ +@@ -1094,6 +_,7 @@ } public boolean canBeHurtBy(DamageSource p_335431_) { + if (!getItem().canBeHurtBy(this, p_335431_)) return false; - return !this.has(DataComponents.FIRE_RESISTANT) || !p_335431_.is(DamageTypeTags.IS_FIRE); + DamageResistant damageresistant = this.get(DataComponents.DAMAGE_RESISTANT); + return damageresistant == null || !damageresistant.isResistantTo(p_335431_); } - } diff --git a/patches/net/minecraft/world/item/ItemUseAnimation.java.patch b/patches/net/minecraft/world/item/ItemUseAnimation.java.patch new file mode 100644 index 00000000..bae3e760 --- /dev/null +++ b/patches/net/minecraft/world/item/ItemUseAnimation.java.patch @@ -0,0 +1,24 @@ +--- a/net/minecraft/world/item/ItemUseAnimation.java ++++ b/net/minecraft/world/item/ItemUseAnimation.java +@@ -8,7 +_,10 @@ + import net.minecraft.util.ByIdMap; + import net.minecraft.util.StringRepresentable; + +-public enum ItemUseAnimation implements StringRepresentable { ++@net.neoforged.fml.common.asm.enumextension.IndexedEnum ++@net.neoforged.fml.common.asm.enumextension.NamedEnum(1) ++@net.neoforged.fml.common.asm.enumextension.NetworkedEnum(net.neoforged.fml.common.asm.enumextension.NetworkedEnum.NetworkCheck.BIDIRECTIONAL) ++public enum ItemUseAnimation implements StringRepresentable, net.neoforged.fml.common.asm.enumextension.IExtensibleEnum { + NONE(0, "none"), + EAT(1, "eat"), + DRINK(2, "drink"), +@@ -38,5 +_,9 @@ + @Override + public String getSerializedName() { + return this.name; ++ } ++ ++ public static net.neoforged.fml.common.asm.enumextension.ExtensionInfo getExtensionInfo() { ++ return net.neoforged.fml.common.asm.enumextension.ExtensionInfo.nonExtended(ItemUseAnimation.class); + } + } diff --git a/patches/net/minecraft/world/item/Items.java.patch b/patches/net/minecraft/world/item/Items.java.patch index 5967553b..98327eb5 100644 --- a/patches/net/minecraft/world/item/Items.java.patch +++ b/patches/net/minecraft/world/item/Items.java.patch @@ -1,32 +1,27 @@ --- a/net/minecraft/world/item/Items.java +++ b/net/minecraft/world/item/Items.java -@@ -2092,11 +_,25 @@ +@@ -2326,11 +_,19 @@ } public static Item registerBlock(Block p_252092_, Block... p_248886_) { -- BlockItem blockitem = new BlockItem(p_252092_, new Item.Properties()); -+ BlockItem blockitem = new BlockItem(p_252092_, new Item.Properties()) { -+ @Override -+ public void registerBlocks(java.util.Map map, Item self) { -+ super.registerBlocks(map, self); -+ for (Block b : p_248886_) { -+ map.put(b, self); -+ } -+ } - +- Item item = registerBlock(p_252092_); +- - for (Block block : p_248886_) { -- Item.BY_BLOCK.put(block, blockitem); +- Item.BY_BLOCK.put(block, item); - } -+ /** @deprecated Neo: To be removed without replacement since registry replacement is not a feature anymore. */ -+ @Deprecated(forRemoval = true, since = "1.21.1") -+ @Override -+ public void removeFromBlockToItemMap(java.util.Map map, Item self) { -+ super.removeFromBlockToItemMap(map, self); -+ for (Block b : p_248886_) { -+ map.remove(b); -+ } -+ } -+ }; ++ Item item = registerItem( ++ blockIdToItemId(p_252092_.builtInRegistryHolder().key()), ++ p -> new BlockItem(p_252092_, p) { ++ @Override ++ public void registerBlocks(java.util.Map map, Item self) { ++ super.registerBlocks(map, self); ++ for (Block block : p_248886_) { ++ map.put(block, self); ++ } ++ } ++ }, ++ new Item.Properties().useBlockDescriptionPrefix() ++ ); - return registerBlock(blockitem); + return item; } diff --git a/patches/net/minecraft/world/item/MapItem.java.patch b/patches/net/minecraft/world/item/MapItem.java.patch index 159280f4..f5c15dc1 100644 --- a/patches/net/minecraft/world/item/MapItem.java.patch +++ b/patches/net/minecraft/world/item/MapItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MapItem.java +++ b/net/minecraft/world/item/MapItem.java -@@ -57,6 +_,16 @@ +@@ -56,6 +_,16 @@ @Nullable public static MapItemSavedData getSavedData(ItemStack p_42854_, Level p_42855_) { diff --git a/patches/net/minecraft/world/item/MilkBucketItem.java.patch b/patches/net/minecraft/world/item/MilkBucketItem.java.patch deleted file mode 100644 index 416fad27..00000000 --- a/patches/net/minecraft/world/item/MilkBucketItem.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/MilkBucketItem.java -+++ b/net/minecraft/world/item/MilkBucketItem.java -@@ -24,7 +_,7 @@ - } - - if (!p_42924_.isClientSide) { -- p_42925_.removeAllEffects(); -+ p_42925_.removeEffectsCuredBy(net.neoforged.neoforge.common.EffectCures.MILK); - } - - if (p_42925_ instanceof Player player) { diff --git a/patches/net/minecraft/world/item/MinecartItem.java.patch b/patches/net/minecraft/world/item/MinecartItem.java.patch index a28feeae..da2d05fb 100644 --- a/patches/net/minecraft/world/item/MinecartItem.java.patch +++ b/patches/net/minecraft/world/item/MinecartItem.java.patch @@ -1,29 +1,11 @@ --- a/net/minecraft/world/item/MinecartItem.java +++ b/net/minecraft/world/item/MinecartItem.java -@@ -33,7 +_,7 @@ - BlockPos blockpos = p_302448_.pos().relative(direction); - BlockState blockstate = serverlevel.getBlockState(blockpos); +@@ -34,7 +_,7 @@ + } else { + ItemStack itemstack = p_42943_.getItemInHand(); RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock - ? blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()) -+ ? ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, serverlevel, blockpos, null) - : RailShape.NORTH_SOUTH; - double d3; - if (blockstate.is(BlockTags.RAILS)) { -@@ -49,7 +_,7 @@ - - BlockState blockstate1 = serverlevel.getBlockState(blockpos.below()); - RailShape railshape1 = blockstate1.getBlock() instanceof BaseRailBlock -- ? blockstate1.getValue(((BaseRailBlock)blockstate1.getBlock()).getShapeProperty()) -+ ? ((BaseRailBlock)blockstate1.getBlock()).getRailDirection(blockstate1, serverlevel, blockpos.below(), null) - : RailShape.NORTH_SOUTH; - if (direction != Direction.DOWN && railshape1.isAscending()) { - d3 = -0.4; -@@ -90,7 +_,7 @@ - ItemStack itemstack = p_42943_.getItemInHand(); - if (level instanceof ServerLevel serverlevel) { - RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock -- ? blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()) + ? ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, level, blockpos, null) - : RailShape.NORTH_SOUTH; - double d0 = 0.0; - if (railshape.isAscending()) { + : RailShape.NORTH_SOUTH; + double d0 = 0.0; + if (railshape.isSlope()) { diff --git a/patches/net/minecraft/world/item/PickaxeItem.java.patch b/patches/net/minecraft/world/item/PickaxeItem.java.patch index f6f34185..52ad2444 100644 --- a/patches/net/minecraft/world/item/PickaxeItem.java.patch +++ b/patches/net/minecraft/world/item/PickaxeItem.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/PickaxeItem.java +++ b/net/minecraft/world/item/PickaxeItem.java @@ -6,4 +_,9 @@ - public PickaxeItem(Tier p_42961_, Item.Properties p_42964_) { - super(p_42961_, BlockTags.MINEABLE_WITH_PICKAXE, p_42964_); + public PickaxeItem(ToolMaterial p_362209_, float p_364146_, float p_361793_, Item.Properties p_42964_) { + super(p_362209_, BlockTags.MINEABLE_WITH_PICKAXE, p_364146_, p_361793_, p_42964_); } + + @Override diff --git a/patches/net/minecraft/world/item/ProjectileWeaponItem.java.patch b/patches/net/minecraft/world/item/ProjectileWeaponItem.java.patch index 06d8d427..9747fe18 100644 --- a/patches/net/minecraft/world/item/ProjectileWeaponItem.java.patch +++ b/patches/net/minecraft/world/item/ProjectileWeaponItem.java.patch @@ -43,7 +43,7 @@ public static ItemStack getHeldProjectile(LivingEntity p_43011_, Predicate p_43012_) { if (p_43012_.test(p_43011_.getItemInHand(InteractionHand.OFF_HAND))) { return p_43011_.getItemInHand(InteractionHand.OFF_HAND); -@@ -92,7 +_,7 @@ +@@ -91,7 +_,7 @@ abstractarrow.setCritArrow(true); } @@ -52,7 +52,7 @@ } protected static List draw(ItemStack p_331565_, ItemStack p_330406_, LivingEntity p_330823_) { -@@ -115,7 +_,8 @@ +@@ -114,7 +_,8 @@ } protected static ItemStack useAmmo(ItemStack p_331207_, ItemStack p_331434_, LivingEntity p_330302_, boolean p_330934_) { @@ -62,7 +62,7 @@ ? EnchantmentHelper.processAmmoUse(serverlevel, p_331207_, p_331434_, 1) : 0; if (i > p_331434_.getCount()) { -@@ -132,5 +_,20 @@ +@@ -131,5 +_,20 @@ return itemstack; } diff --git a/patches/net/minecraft/world/item/ShearsItem.java.patch b/patches/net/minecraft/world/item/ShearsItem.java.patch index 6f0ad827..1ce63f10 100644 --- a/patches/net/minecraft/world/item/ShearsItem.java.patch +++ b/patches/net/minecraft/world/item/ShearsItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ShearsItem.java +++ b/net/minecraft/world/item/ShearsItem.java -@@ -54,20 +_,57 @@ +@@ -59,20 +_,57 @@ || p_43080_.is(BlockTags.WOOL); } @@ -19,9 +19,9 @@ + // Call onSheared on both sides (mirrors vanilla shear()) + List drops = target.onSheared(player, stack, entity.level(), pos); + // Spawn drops on the server side using spawnShearedDrop to retain vanilla mob-specific behavior -+ if (!isClient) { ++ if (entity.level() instanceof net.minecraft.server.level.ServerLevel serverLevel) { + for(ItemStack drop : drops) { -+ target.spawnShearedDrop(entity.level(), pos, drop); ++ target.spawnShearedDrop(serverLevel, pos, drop); + } + } + // Call GameEvent.SHEAR on both sides @@ -31,7 +31,7 @@ + stack.hurtAndBreak(1, player, LivingEntity.getSlotForHand(hand)); + } + // Return sided success if the entity was shearable -+ return InteractionResult.sidedSuccess(isClient); ++ return InteractionResult.SUCCESS; + } + } + return InteractionResult.PASS; diff --git a/patches/net/minecraft/world/item/ShieldItem.java.patch b/patches/net/minecraft/world/item/ShieldItem.java.patch index e22dccf4..812ecb68 100644 --- a/patches/net/minecraft/world/item/ShieldItem.java.patch +++ b/patches/net/minecraft/world/item/ShieldItem.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/ShieldItem.java +++ b/net/minecraft/world/item/ShieldItem.java -@@ -58,4 +_,9 @@ - public EquipmentSlot getEquipmentSlot() { - return EquipmentSlot.OFFHAND; +@@ -43,4 +_,9 @@ + p_43100_.startUsingItem(p_43101_); + return InteractionResult.CONSUME; } + + @Override diff --git a/patches/net/minecraft/world/item/SpawnEggItem.java.patch b/patches/net/minecraft/world/item/SpawnEggItem.java.patch index 039545cc..b3a50e65 100644 --- a/patches/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/patches/net/minecraft/world/item/SpawnEggItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/SpawnEggItem.java +++ b/net/minecraft/world/item/SpawnEggItem.java -@@ -42,11 +_,14 @@ +@@ -41,11 +_,14 @@ private final int highlightColor; private final EntityType defaultType; @@ -15,7 +15,7 @@ BY_ID.put(p_43207_, this); } -@@ -134,6 +_,8 @@ +@@ -133,6 +_,8 @@ @Nullable public static SpawnEggItem byId(@Nullable EntityType p_43214_) { @@ -24,7 +24,7 @@ return BY_ID.get(p_43214_); } -@@ -143,12 +_,12 @@ +@@ -142,12 +_,12 @@ public EntityType getType(ItemStack p_330335_) { CustomData customdata = p_330335_.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY); @@ -39,7 +39,7 @@ } public Optional spawnOffspringFromSpawnEgg( -@@ -179,5 +_,9 @@ +@@ -178,5 +_,9 @@ } } } diff --git a/patches/net/minecraft/world/item/StandingAndWallBlockItem.java.patch b/patches/net/minecraft/world/item/StandingAndWallBlockItem.java.patch deleted file mode 100644 index c119b7fa..00000000 --- a/patches/net/minecraft/world/item/StandingAndWallBlockItem.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/world/item/StandingAndWallBlockItem.java -+++ b/net/minecraft/world/item/StandingAndWallBlockItem.java -@@ -50,4 +_,11 @@ - super.registerBlocks(p_43252_, p_43253_); - p_43252_.put(this.wallBlock, p_43253_); - } -+ -+ /** @deprecated Neo: To be removed without replacement since registry replacement is not a feature anymore. */ -+ @Deprecated(forRemoval = true, since = "1.21.1") -+ public void removeFromBlockToItemMap(Map blockToItemMap, Item itemIn) { -+ super.removeFromBlockToItemMap(blockToItemMap, itemIn); -+ blockToItemMap.remove(this.wallBlock); -+ } - } diff --git a/patches/net/minecraft/world/item/SwordItem.java.patch b/patches/net/minecraft/world/item/SwordItem.java.patch index bcff559c..d7c8b39e 100644 --- a/patches/net/minecraft/world/item/SwordItem.java.patch +++ b/patches/net/minecraft/world/item/SwordItem.java.patch @@ -1,32 +1,20 @@ --- a/net/minecraft/world/item/SwordItem.java +++ b/net/minecraft/world/item/SwordItem.java -@@ -21,11 +_,25 @@ - super(p_43269_, p_43272_.component(DataComponents.TOOL, createToolProperties())); +@@ -12,6 +_,13 @@ + super(p_361460_.applySwordProperties(p_43272_, p_362481_, p_364182_)); } + /** -+ * Neo: Allow modded Swords to set exactly what Tool data component to use for their sword. ++ * Neo: Allow modded Swords to set exactly what properties to use for their sword. + */ -+ public SwordItem(Tier tier, Item.Properties properties, Tool toolComponentData) { -+ super(tier, properties.component(DataComponents.TOOL, toolComponentData)); ++ public SwordItem(Item.Properties properties) { ++ super(properties); + } + - public static Tool createToolProperties() { - return new Tool(List.of(Tool.Rule.minesAndDrops(List.of(Blocks.COBWEB), 15.0F), Tool.Rule.overrideSpeed(BlockTags.SWORD_EFFICIENT, 1.5F)), 1.0F, 2); - } - - public static ItemAttributeModifiers createAttributes(Tier p_330371_, int p_331976_, float p_332104_) { -+ return createAttributes(p_330371_, (float)p_331976_, p_332104_); -+ } -+ -+ /** -+ * Neo: Method overload to allow giving a float for damage instead of an int. -+ */ -+ public static ItemAttributeModifiers createAttributes(Tier p_330371_, float p_331976_, float p_332104_) { - return ItemAttributeModifiers.builder() - .add( - Attributes.ATTACK_DAMAGE, -@@ -55,5 +_,10 @@ + @Override + public boolean canAttackBlock(BlockState p_43291_, Level p_43292_, BlockPos p_43293_, Player p_43294_) { + return !p_43294_.isCreative(); +@@ -25,5 +_,10 @@ @Override public void postHurtEnemy(ItemStack p_345553_, LivingEntity p_345771_, LivingEntity p_346282_) { p_345553_.hurtAndBreak(1, p_346282_, EquipmentSlot.MAINHAND); diff --git a/patches/net/minecraft/world/item/Tiers.java.patch b/patches/net/minecraft/world/item/Tiers.java.patch deleted file mode 100644 index 48dc1da1..00000000 --- a/patches/net/minecraft/world/item/Tiers.java.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- a/net/minecraft/world/item/Tiers.java -+++ b/net/minecraft/world/item/Tiers.java -@@ -61,4 +_,6 @@ - public Ingredient getRepairIngredient() { - return this.repairIngredient.get(); - } -+ -+ @org.jetbrains.annotations.Nullable public net.minecraft.tags.TagKey getTag() { return net.neoforged.neoforge.common.CommonHooks.getTagFromVanillaTier(this); } - } diff --git a/patches/net/minecraft/world/item/TridentItem.java.patch b/patches/net/minecraft/world/item/TridentItem.java.patch index 1f32d6ec..5cd4365e 100644 --- a/patches/net/minecraft/world/item/TridentItem.java.patch +++ b/patches/net/minecraft/world/item/TridentItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/TridentItem.java +++ b/net/minecraft/world/item/TridentItem.java -@@ -160,4 +_,9 @@ +@@ -161,4 +_,9 @@ throwntrident.pickup = AbstractArrow.Pickup.ALLOWED; return throwntrident; } diff --git a/patches/net/minecraft/world/item/UseAnim.java.patch b/patches/net/minecraft/world/item/UseAnim.java.patch deleted file mode 100644 index 3f78819e..00000000 --- a/patches/net/minecraft/world/item/UseAnim.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/world/item/UseAnim.java -+++ b/net/minecraft/world/item/UseAnim.java -@@ -10,5 +_,10 @@ - CROSSBOW, - SPYGLASS, - TOOT_HORN, -- BRUSH; -+ BRUSH, -+ /** -+ * Items with custom arm animation should return this in `Item#getUseAnimation` -+ * to prevent vanilla from also trying to animate same item -+ */ -+ CUSTOM - } diff --git a/patches/net/minecraft/world/item/alchemy/PotionBrewing.java.patch b/patches/net/minecraft/world/item/alchemy/PotionBrewing.java.patch index 9c3be6f2..7612a5ff 100644 --- a/patches/net/minecraft/world/item/alchemy/PotionBrewing.java.patch +++ b/patches/net/minecraft/world/item/alchemy/PotionBrewing.java.patch @@ -56,11 +56,22 @@ Optional> optional = p_43531_.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).potion(); if (optional.isEmpty()) { return p_43531_; -@@ -127,6 +_,7 @@ +@@ -124,9 +_,18 @@ + } + } + ++ /** ++ * @deprecated Use {@link #bootstrap(FeatureFlagSet, net.minecraft.core.RegistryAccess)} instead ++ */ ++ @Deprecated public static PotionBrewing bootstrap(FeatureFlagSet p_341301_) { ++ return bootstrap(p_341301_, net.minecraft.core.RegistryAccess.EMPTY); ++ } ++ ++ public static PotionBrewing bootstrap(FeatureFlagSet p_341301_, net.minecraft.core.RegistryAccess registryAccess) { PotionBrewing.Builder potionbrewing$builder = new PotionBrewing.Builder(p_341301_); addVanillaMixes(potionbrewing$builder); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.brewing.RegisterBrewingRecipesEvent(potionbrewing$builder)); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.brewing.RegisterBrewingRecipesEvent(potionbrewing$builder, registryAccess)); return potionbrewing$builder.build(); } diff --git a/patches/net/minecraft/world/item/alchemy/PotionContents.java.patch b/patches/net/minecraft/world/item/alchemy/PotionContents.java.patch new file mode 100644 index 00000000..f5c53ac6 --- /dev/null +++ b/patches/net/minecraft/world/item/alchemy/PotionContents.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/item/alchemy/PotionContents.java ++++ b/net/minecraft/world/item/alchemy/PotionContents.java +@@ -201,6 +_,10 @@ + p_331296_.accept(CommonComponents.EMPTY); + p_331296_.accept(Component.translatable("potion.whenDrank").withStyle(ChatFormatting.DARK_PURPLE)); + ++ // Neo: Override handling of potion attribute tooltips to support IAttributeExtension ++ net.neoforged.neoforge.common.util.AttributeUtil.addPotionTooltip(list, p_331296_); ++ if (true) return; ++ + for (Pair, AttributeModifier> pair : list) { + AttributeModifier attributemodifier = pair.getSecond(); + double d1 = attributemodifier.amount(); diff --git a/patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch b/patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch new file mode 100644 index 00000000..4e1c2927 --- /dev/null +++ b/patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java +@@ -56,7 +_,9 @@ + } + + Vec3 vec3 = p_366884_.position(); +- if (p_366884_.randomTeleport(d0, d1, d2, true)) { ++ var event = net.neoforged.neoforge.event.EventHooks.onItemConsumptionTeleport(p_366884_, p_366476_, d0, d1, d2); ++ if (event.isCanceled()) return false; ++ if (p_366884_.randomTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) { + p_366648_.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(p_366884_)); + SoundSource soundsource; + SoundEvent soundevent; diff --git a/patches/net/minecraft/world/item/crafting/AbstractCookingRecipe.java.patch b/patches/net/minecraft/world/item/crafting/AbstractCookingRecipe.java.patch new file mode 100644 index 00000000..305a1d58 --- /dev/null +++ b/patches/net/minecraft/world/item/crafting/AbstractCookingRecipe.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/crafting/AbstractCookingRecipe.java ++++ b/net/minecraft/world/item/crafting/AbstractCookingRecipe.java +@@ -75,7 +_,7 @@ + Codec.STRING.optionalFieldOf("group", "").forGetter(SingleItemRecipe::group), + CookingBookCategory.CODEC.fieldOf("category").orElse(CookingBookCategory.MISC).forGetter(AbstractCookingRecipe::category), + Ingredient.CODEC.fieldOf("ingredient").forGetter(SingleItemRecipe::input), +- ItemStack.STRICT_SINGLE_ITEM_CODEC.fieldOf("result").forGetter(SingleItemRecipe::result), ++ ItemStack.CODEC.fieldOf("result").forGetter(SingleItemRecipe::result), + Codec.FLOAT.fieldOf("experience").orElse(0.0F).forGetter(AbstractCookingRecipe::experience), + Codec.INT.fieldOf("cookingtime").orElse(p_379669_).forGetter(AbstractCookingRecipe::cookingTime) + ) diff --git a/patches/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch b/patches/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch index 7628e933..2a92e339 100644 --- a/patches/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch +++ b/patches/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch @@ -1,13 +1,11 @@ --- a/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java +++ b/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java -@@ -79,8 +_,8 @@ +@@ -84,7 +_,7 @@ for (int i = 0; i < nonnulllist.size(); i++) { ItemStack itemstack = p_345377_.getItem(i); if (!itemstack.isEmpty()) { -- if (itemstack.getItem().hasCraftingRemainingItem()) { -- nonnulllist.set(i, new ItemStack(itemstack.getItem().getCraftingRemainingItem())); -+ if (itemstack.hasCraftingRemainingItem()) { -+ nonnulllist.set(i, itemstack.getCraftingRemainingItem()); +- ItemStack itemstack1 = itemstack.getItem().getCraftingRemainder(); ++ ItemStack itemstack1 = itemstack.getCraftingRemainder(); + if (!itemstack1.isEmpty()) { + nonnulllist.set(i, itemstack1); } else if (!itemstack.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY).layers().isEmpty()) { - nonnulllist.set(i, itemstack.copyWithCount(1)); - } diff --git a/patches/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch b/patches/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch index d801583d..ccfed826 100644 --- a/patches/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch +++ b/patches/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch @@ -1,13 +1,11 @@ --- a/net/minecraft/world/item/crafting/BookCloningRecipe.java +++ b/net/minecraft/world/item/crafting/BookCloningRecipe.java -@@ -83,8 +_,8 @@ +@@ -88,7 +_,7 @@ for (int i = 0; i < nonnulllist.size(); i++) { ItemStack itemstack = p_344763_.getItem(i); -- if (itemstack.getItem().hasCraftingRemainingItem()) { -- nonnulllist.set(i, new ItemStack(itemstack.getItem().getCraftingRemainingItem())); -+ if (itemstack.hasCraftingRemainingItem()) { -+ nonnulllist.set(i, itemstack.getCraftingRemainingItem()); +- ItemStack itemstack1 = itemstack.getItem().getCraftingRemainder(); ++ ItemStack itemstack1 = itemstack.getCraftingRemainder(); + if (!itemstack1.isEmpty()) { + nonnulllist.set(i, itemstack1); } else if (itemstack.getItem() instanceof WrittenBookItem) { - nonnulllist.set(i, itemstack.copyWithCount(1)); - break; diff --git a/patches/net/minecraft/world/item/crafting/CraftingRecipe.java.patch b/patches/net/minecraft/world/item/crafting/CraftingRecipe.java.patch new file mode 100644 index 00000000..7ba401ed --- /dev/null +++ b/patches/net/minecraft/world/item/crafting/CraftingRecipe.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/crafting/CraftingRecipe.java ++++ b/net/minecraft/world/item/crafting/CraftingRecipe.java +@@ -23,7 +_,7 @@ + NonNullList nonnulllist = NonNullList.withSize(p_380223_.size(), ItemStack.EMPTY); + + for (int i = 0; i < nonnulllist.size(); i++) { +- Item item = p_380223_.getItem(i).getItem(); ++ ItemStack item = p_380223_.getItem(i); + nonnulllist.set(i, item.getCraftingRemainder()); + } + diff --git a/patches/net/minecraft/world/item/crafting/Ingredient.java.patch b/patches/net/minecraft/world/item/crafting/Ingredient.java.patch index 856f32ab..f80d5c47 100644 --- a/patches/net/minecraft/world/item/crafting/Ingredient.java.patch +++ b/patches/net/minecraft/world/item/crafting/Ingredient.java.patch @@ -1,130 +1,71 @@ --- a/net/minecraft/world/item/crafting/Ingredient.java +++ b/net/minecraft/world/item/crafting/Ingredient.java -@@ -27,17 +_,56 @@ - import net.minecraft.world.item.ItemStack; +@@ -24,18 +_,20 @@ import net.minecraft.world.level.ItemLike; --public class Ingredient implements Predicate { -+public final class Ingredient implements Predicate { - public static final Ingredient EMPTY = new Ingredient(Stream.empty()); -- public static final StreamCodec CONTENTS_STREAM_CODEC = ItemStack.LIST_STREAM_CODEC -- .map(p_319730_ -> fromValues(p_319730_.stream().map(Ingredient.ItemValue::new)), p_319731_ -> Arrays.asList(p_319731_.getItems())); -+ public static final StreamCodec CONTENTS_STREAM_CODEC = new StreamCodec<>() { -+ private static final StreamCodec CUSTOM_INGREDIENT_CODEC = net.minecraft.network.codec.ByteBufCodecs.registry(net.neoforged.neoforge.registries.NeoForgeRegistries.Keys.INGREDIENT_TYPES) -+ .dispatch(c -> c.getType(), t -> t.streamCodec()); -+ -+ @Override -+ public void encode(RegistryFriendlyByteBuf buf, Ingredient ingredient) { -+ if (ingredient.isSimple()) { -+ ItemStack.LIST_STREAM_CODEC.encode(buf, Arrays.asList(ingredient.getItems())); -+ } else { -+ buf.writeVarInt(-1); -+ CUSTOM_INGREDIENT_CODEC.encode(buf, ingredient.customIngredient); -+ } -+ } -+ -+ @Override -+ public Ingredient decode(RegistryFriendlyByteBuf buf) { -+ var size = buf.readVarInt(); -+ if (size == -1) { -+ return new Ingredient(CUSTOM_INGREDIENT_CODEC.decode(buf)); -+ } -+ return fromValues(Stream.generate(() -> ItemStack.STREAM_CODEC.decode(buf)).limit(size).map(Ingredient.ItemValue::new)); -+ } -+ }; - private final Ingredient.Value[] values; + public final class Ingredient implements Predicate { +- public static final StreamCodec CONTENTS_STREAM_CODEC = ByteBufCodecs.holderSet(Registries.ITEM) +- .map(Ingredient::new, p_360055_ -> p_360055_.values); +- public static final StreamCodec> OPTIONAL_CONTENTS_STREAM_CODEC = ByteBufCodecs.holderSet(Registries.ITEM) ++ public static final StreamCodec CONTENTS_STREAM_CODEC = net.neoforged.neoforge.common.crafting.IngredientCodecs.streamCodec(ByteBufCodecs.holderSet(Registries.ITEM) ++ .map(Ingredient::new, p_360055_ -> p_360055_.getValuesForSync())); ++ public static final StreamCodec> OPTIONAL_CONTENTS_STREAM_CODEC = net.neoforged.neoforge.common.crafting.IngredientCodecs.optionalStreamCodec(ByteBufCodecs.holderSet(Registries.ITEM) + .map( + p_360058_ -> p_360058_.size() == 0 ? Optional.empty() : Optional.of(new Ingredient((HolderSet)p_360058_)), +- p_360056_ -> p_360056_.map(p_360062_ -> p_360062_.values).orElse(HolderSet.direct()) +- ); ++ p_360056_ -> p_360056_.map(p_360062_ -> p_360062_.getValuesForSync()).orElse(HolderSet.direct()) ++ )); + public static final Codec> NON_AIR_HOLDER_SET_CODEC = HolderSetCodec.create(Registries.ITEM, Item.CODEC, false); +- public static final Codec CODEC = ExtraCodecs.nonEmptyHolderSet(NON_AIR_HOLDER_SET_CODEC).xmap(Ingredient::new, p_360061_ -> p_360061_.values); ++ public static final Codec CODEC = net.neoforged.neoforge.common.crafting.IngredientCodecs.codec(ExtraCodecs.nonEmptyHolderSet(NON_AIR_HOLDER_SET_CODEC).xmap(Ingredient::new, p_360061_ -> p_360061_.values)); + private final HolderSet values; @Nullable - public ItemStack[] itemStacks; - @Nullable - private IntList stackingIds; -- public static final Codec CODEC = codec(true); -- public static final Codec CODEC_NONEMPTY = codec(false); + private List> items; + @Nullable + private net.neoforged.neoforge.common.crafting.ICustomIngredient customIngredient = null; -+ -+ /** -+ * This codec allows both the {@code {...}} and {@code [{...}, {...}, ...]} syntax. -+ * {@code []} is allowed for empty ingredients, and will only match empty stacks. -+ */ -+ public static final Codec CODEC = net.neoforged.neoforge.common.crafting.CraftingHelper.makeIngredientCodec(true); -+ /** -+ * Same as {@link #CODEC} except that empty ingredients ({@code []}) are not allowed. -+ */ -+ public static final Codec CODEC_NONEMPTY = net.neoforged.neoforge.common.crafting.CraftingHelper.makeIngredientCodec(false); -+ /** -+ * This is a codec that only allows the {@code {...}} syntax. -+ * Array ingredients are serialized using the CompoundIngredient custom ingredient type: -+ * {@code { "type": "neoforge:compound", "ingredients": [{...}, {...}, ...] }}. -+ */ -+ public static final com.mojang.serialization.MapCodec MAP_CODEC_NONEMPTY = net.neoforged.neoforge.common.crafting.CraftingHelper.makeIngredientMapCodec(); -+ public static final Codec> LIST_CODEC = MAP_CODEC_NONEMPTY.codec().listOf(); -+ public static final Codec> LIST_CODEC_NONEMPTY = LIST_CODEC.validate(list -> list.isEmpty() ? DataResult.error(() -> "Item array cannot be empty, at least one item must be defined") : DataResult.success(list)); - public Ingredient(Stream p_43907_) { - this.values = p_43907_.toArray(Ingredient.Value[]::new); -@@ -47,9 +_,19 @@ - this.values = p_301044_; + private Ingredient(HolderSet p_365027_) { + p_365027_.unwrap().ifRight(p_360057_ -> { +@@ -48,19 +_,31 @@ + this.values = p_365027_; } + public Ingredient(net.neoforged.neoforge.common.crafting.ICustomIngredient customIngredient) { -+ this(new Value[0]); ++ this.values = HolderSet.empty(); + this.customIngredient = customIngredient; + } + - public ItemStack[] getItems() { - if (this.itemStacks == null) { -- this.itemStacks = Arrays.stream(this.values).flatMap(p_43916_ -> p_43916_.getItems().stream()).distinct().toArray(ItemStack[]::new); -+ // Neo: vanilla used Stream.distinct() here which has basically no effect as ItemStack does not override hashCode() and equals(). -+ // Using ItemStackLinkedSet::createTypeAndComponentsSet instead for a real distinct result. -+ final Stream stream = this.customIngredient == null -+ ? Arrays.stream(this.values).flatMap(value -> value.getItems().stream()) -+ : this.customIngredient.getItems(); -+ this.itemStacks = stream.collect(java.util.stream.Collectors.toCollection(net.minecraft.world.item.ItemStackLinkedSet::createTypeAndComponentsSet)).toArray(ItemStack[]::new); + public static boolean testOptionalIngredient(Optional p_362504_, ItemStack p_363604_) { + return p_362504_.map(p_360060_ -> p_360060_.test(p_363604_)).orElseGet(p_363604_::isEmpty); + } + + public List> items() { + if (this.items == null) { +- this.items = ImmutableList.copyOf(this.values); ++ if (this.customIngredient != null) { ++ this.items = this.customIngredient.items().toList(); ++ } else { ++ this.items = ImmutableList.copyOf(this.values); ++ } } - return this.itemStacks; -@@ -58,6 +_,8 @@ - public boolean test(@Nullable ItemStack p_43914_) { - if (p_43914_ == null) { - return false; -+ } else if (this.customIngredient != null) { -+ return this.customIngredient.test(p_43914_); - } else if (this.isEmpty()) { - return p_43914_.isEmpty(); - } else { -@@ -86,13 +_,65 @@ - return this.stackingIds; + return this.items; } -+ /** -+ * Returns {@code true} if this ingredient is explicitly chosen to be empty, i.e. using {@code []}. -+ */ - public boolean isEmpty() { -- return this.values.length == 0; -+ return this.values.length == 0 && !isCustom(); -+ } -+ -+ /** -+ * Returns {@code true} if this ingredient has an empty stack list. -+ * Unlike {@link #isEmpty()}, this will catch "accidentally empty" ingredients, -+ * for example a tag ingredient that has an empty tag. -+ */ -+ public boolean hasNoItems() { -+ ItemStack[] items = getItems(); -+ if (items.length == 0) -+ return true; -+ if (items.length == 1) { -+ // If we potentially added a barrier due to the ingredient being an empty tag, try and check if it is the stack we added -+ ItemStack item = items[0]; -+ return item.getItem() == net.minecraft.world.item.Items.BARRIER && item.getHoverName() instanceof net.minecraft.network.chat.MutableComponent hoverName && hoverName.getString().startsWith("Empty Tag: "); + public boolean test(ItemStack p_43914_) { ++ if (this.customIngredient != null) { ++ return this.customIngredient.test(p_43914_); + } -+ return false; - } + List> list = this.items(); + + for (int i = 0; i < list.size(); i++) { +@@ -74,7 +_,49 @@ @Override public boolean equals(Object p_301003_) { -- return p_301003_ instanceof Ingredient ingredient ? Arrays.equals((Object[])this.values, (Object[])ingredient.values) : false; -+ return p_301003_ instanceof Ingredient ingredient ? java.util.Objects.equals(this.customIngredient, ingredient.customIngredient) && Arrays.equals((Object[])this.values, (Object[])ingredient.values) : false; +- return p_301003_ instanceof Ingredient ingredient ? Objects.equals(this.values, ingredient.values) : false; ++ return p_301003_ instanceof Ingredient ingredient ? java.util.Objects.equals(this.customIngredient, ingredient.customIngredient) && Objects.equals(this.values, ingredient.values) : false; + } + + @Override @@ -132,20 +73,30 @@ + if (this.customIngredient != null) { + return this.customIngredient.hashCode(); + } -+ return Arrays.hashCode(this.values); ++ return this.values.hashCode(); + } + + /** -+ * Retrieves the underlying values of this ingredient. -+ * If this is a {@linkplain #isCustom custom ingredient}, an exception is thrown. -+ */ -+ public Value[] getValues() { ++ * Retrieves the underlying values of this ingredient. ++ * If this is a {@linkplain #isCustom custom ingredient}, an exception is thrown. ++ */ ++ public HolderSet getValues() { + if (isCustom()) { + throw new IllegalStateException("Cannot retrieve values from custom ingredient!"); + } + return this.values; + } + ++ /** ++ * Retrieves the holder set to use for syncing {@linkplain #isSimple() simple} ingredients ++ */ ++ private HolderSet getValuesForSync() { ++ if (isCustom()) { ++ return HolderSet.direct(this.items()); ++ } ++ return this.values; ++ } ++ + public boolean isSimple() { + return this.customIngredient == null || this.customIngredient.isSimple(); + } @@ -159,79 +110,14 @@ + return this.customIngredient != null; } - public static Ingredient fromValues(Stream p_43939_) { -@@ -120,6 +_,7 @@ - return fromValues(Stream.of(new Ingredient.TagValue(p_204133_))); + public static Ingredient of(ItemLike p_364285_) { +@@ -94,6 +_,9 @@ } -+ @Deprecated // Neo: We take over the codec creation entirely to support custom ingredients - see CraftingHelper - private static Codec codec(boolean p_301074_) { - Codec codec = Codec.list(Ingredient.Value.CODEC) - .comapFlatMap( -@@ -144,10 +_,11 @@ - } - - public static record ItemValue(ItemStack item) implements Ingredient.Value { -- static final Codec CODEC = RecordCodecBuilder.create( -+ static final com.mojang.serialization.MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec( - p_330109_ -> p_330109_.group(ItemStack.SIMPLE_ITEM_CODEC.fieldOf("item").forGetter(p_300919_ -> p_300919_.item)) - .apply(p_330109_, Ingredient.ItemValue::new) - ); -+ static final Codec CODEC = MAP_CODEC.codec(); - - @Override - public boolean equals(Object p_301316_) { -@@ -156,6 +_,12 @@ - : ingredient$itemvalue.item.getItem().equals(this.item.getItem()) && ingredient$itemvalue.item.getCount() == this.item.getCount(); - } - -+ // Neo: Add a hashCode() implementation that matches equals() -+ @Override -+ public int hashCode() { -+ return 31 * item.getItem().hashCode() + item.getCount(); + public SlotDisplay display() { ++ if (this.customIngredient != null) { ++ return this.customIngredient.display(); + } -+ - @Override - public Collection getItems() { - return Collections.singleton(this.item); -@@ -163,10 +_,11 @@ - } - - public static record TagValue(TagKey tag) implements Ingredient.Value { -- static final Codec CODEC = RecordCodecBuilder.create( -+ static final com.mojang.serialization.MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec( - p_301118_ -> p_301118_.group(TagKey.codec(Registries.ITEM).fieldOf("tag").forGetter(p_301154_ -> p_301154_.tag)) - .apply(p_301118_, Ingredient.TagValue::new) - ); -+ static final Codec CODEC = MAP_CODEC.codec(); - - @Override - public boolean equals(Object p_301162_) { -@@ -181,12 +_,18 @@ - list.add(new ItemStack(holder)); - } - -+ if (list.isEmpty()) { -+ net.minecraft.world.item.ItemStack itemStack = new net.minecraft.world.item.ItemStack(net.minecraft.world.level.block.Blocks.BARRIER); -+ itemStack.set(net.minecraft.core.component.DataComponents.CUSTOM_NAME, net.minecraft.network.chat.Component.literal("Empty Tag: " + this.tag.location())); -+ list.add(itemStack); -+ } - return list; - } - } - -+ // Neo: Do not extend this interface. For custom ingredient behaviors see ICustomIngredient. - public interface Value { -- Codec CODEC = Codec.xor(Ingredient.ItemValue.CODEC, Ingredient.TagValue.CODEC) -+ com.mojang.serialization.MapCodec MAP_CODEC = net.neoforged.neoforge.common.util.NeoForgeExtraCodecs.xor(Ingredient.ItemValue.MAP_CODEC, Ingredient.TagValue.MAP_CODEC) - .xmap(p_300956_ -> p_300956_.map(p_300932_ -> p_300932_, p_301313_ -> p_301313_), p_301304_ -> { - if (p_301304_ instanceof Ingredient.TagValue ingredient$tagvalue) { - return Either.right(ingredient$tagvalue); -@@ -196,6 +_,7 @@ - throw new UnsupportedOperationException("This is neither an item value nor a tag value."); - } - }); -+ Codec CODEC = MAP_CODEC.codec(); - - Collection getItems(); - } + return (SlotDisplay)this.values + .unwrap() + .map(SlotDisplay.TagSlotDisplay::new, p_380837_ -> new SlotDisplay.Composite(p_380837_.stream().map(Ingredient::displayForSingleItem).toList())); diff --git a/patches/net/minecraft/world/item/crafting/Recipe.java.patch b/patches/net/minecraft/world/item/crafting/Recipe.java.patch index 4c7128f1..7a084590 100644 --- a/patches/net/minecraft/world/item/crafting/Recipe.java.patch +++ b/patches/net/minecraft/world/item/crafting/Recipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/Recipe.java +++ b/net/minecraft/world/item/crafting/Recipe.java -@@ -15,6 +_,7 @@ +@@ -14,6 +_,7 @@ public interface Recipe { Codec> CODEC = BuiltInRegistries.RECIPE_SERIALIZER.byNameCodec().dispatch(Recipe::getSerializer, RecipeSerializer::codec); @@ -8,23 +8,3 @@ StreamCodec> STREAM_CODEC = ByteBufCodecs.registry(Registries.RECIPE_SERIALIZER) .dispatch(Recipe::getSerializer, RecipeSerializer::streamCodec); -@@ -30,9 +_,9 @@ - NonNullList nonnulllist = NonNullList.withSize(p_345383_.size(), ItemStack.EMPTY); - - for (int i = 0; i < nonnulllist.size(); i++) { -- Item item = p_345383_.getItem(i).getItem(); -+ ItemStack item = p_345383_.getItem(i); - if (item.hasCraftingRemainingItem()) { -- nonnulllist.set(i, new ItemStack(item.getCraftingRemainingItem())); -+ nonnulllist.set(i, item.getCraftingRemainingItem()); - } - } - -@@ -65,6 +_,6 @@ - - default boolean isIncomplete() { - NonNullList nonnulllist = this.getIngredients(); -- return nonnulllist.isEmpty() || nonnulllist.stream().anyMatch(p_151268_ -> p_151268_.getItems().length == 0); -+ return nonnulllist.isEmpty() || nonnulllist.stream().anyMatch(Ingredient::hasNoItems); - } - } diff --git a/patches/net/minecraft/world/item/crafting/RecipeManager.java.patch b/patches/net/minecraft/world/item/crafting/RecipeManager.java.patch deleted file mode 100644 index c4f01d12..00000000 --- a/patches/net/minecraft/world/item/crafting/RecipeManager.java.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/minecraft/world/item/crafting/RecipeManager.java -+++ b/net/minecraft/world/item/crafting/RecipeManager.java -@@ -50,16 +_,22 @@ - this.hasErrors = false; - Builder, RecipeHolder> builder = ImmutableMultimap.builder(); - com.google.common.collect.ImmutableMap.Builder> builder1 = ImmutableMap.builder(); -- RegistryOps registryops = this.registries.createSerializationContext(JsonOps.INSTANCE); -+ RegistryOps registryops = this.makeConditionalOps(); // Neo: add condition context - - for (Entry entry : p_44037_.entrySet()) { - ResourceLocation resourcelocation = entry.getKey(); -+ if (resourcelocation.getPath().startsWith("_")) continue; //Forge: filter anything beginning with "_" as it's used for metadata. - - try { -- Recipe recipe = Recipe.CODEC.parse(registryops, entry.getValue()).getOrThrow(JsonParseException::new); -+ var decoded = Recipe.CONDITIONAL_CODEC.parse(registryops, entry.getValue()).getOrThrow(JsonParseException::new); -+ decoded.ifPresentOrElse(r -> { -+ Recipe recipe = r.carrier(); - RecipeHolder recipeholder = new RecipeHolder<>(resourcelocation, recipe); - builder.put(recipe.getType(), recipeholder); - builder1.put(resourcelocation, recipeholder); -+ }, () -> { -+ LOGGER.debug("Skipping loading recipe {} as its conditions were not met", resourcelocation); -+ }); - } catch (IllegalArgumentException | JsonParseException jsonparseexception) { - LOGGER.error("Parsing error loading recipe {}", resourcelocation, jsonparseexception); - } diff --git a/patches/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch b/patches/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch index 5838660a..91780eb1 100644 --- a/patches/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch +++ b/patches/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/RepairItemRecipe.java +++ b/net/minecraft/world/item/crafting/RepairItemRecipe.java -@@ -47,7 +_,9 @@ +@@ -46,7 +_,9 @@ && p_336139_.has(DataComponents.MAX_DAMAGE) && p_335795_.has(DataComponents.MAX_DAMAGE) && p_336139_.has(DataComponents.DAMAGE) diff --git a/patches/net/minecraft/world/item/crafting/ShapedRecipe.java.patch b/patches/net/minecraft/world/item/crafting/ShapedRecipe.java.patch deleted file mode 100644 index 520c71a8..00000000 --- a/patches/net/minecraft/world/item/crafting/ShapedRecipe.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/crafting/ShapedRecipe.java -+++ b/net/minecraft/world/item/crafting/ShapedRecipe.java -@@ -84,7 +_,7 @@ - @Override - public boolean isIncomplete() { - NonNullList nonnulllist = this.getIngredients(); -- return nonnulllist.isEmpty() || nonnulllist.stream().filter(p_151277_ -> !p_151277_.isEmpty()).anyMatch(p_151273_ -> p_151273_.getItems().length == 0); -+ return nonnulllist.isEmpty() || nonnulllist.stream().filter(p_151277_ -> !p_151277_.isEmpty()).anyMatch(Ingredient::hasNoItems); - } - - public static class Serializer implements RecipeSerializer { diff --git a/patches/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch b/patches/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch index 9d6f735d..cd823dd0 100644 --- a/patches/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch +++ b/patches/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipePattern.java +++ b/net/minecraft/world/item/crafting/ShapedRecipePattern.java -@@ -20,7 +_,30 @@ +@@ -21,8 +_,31 @@ import net.minecraft.world.item.ItemStack; public final class ShapedRecipePattern { + /** @deprecated Neo: use {@link #getMaxWidth} and {@link #getMaxHeight} */ @Deprecated private static final int MAX_SIZE = 3; + public static final char EMPTY_SLOT = ' '; + static int maxWidth = 3; + static int maxHeight = 3; + @@ -31,7 +32,7 @@ public static final MapCodec MAP_CODEC = ShapedRecipePattern.Data.MAP_CODEC .flatXmap( ShapedRecipePattern::unpack, -@@ -214,16 +_,16 @@ +@@ -206,16 +_,16 @@ public static record Data(Map key, List pattern) { private static final Codec> PATTERN_CODEC = Codec.STRING.listOf().comapFlatMap(p_312085_ -> { diff --git a/patches/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/patches/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch index 67d0abb7..9e0f1712 100644 --- a/patches/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch +++ b/patches/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -18,12 +_,14 @@ - final CraftingBookCategory category; - final ItemStack result; - final NonNullList ingredients; +@@ -24,12 +_,14 @@ + final List ingredients; + @Nullable + private PlacementInfo placementInfo; + private final boolean isSimple; - public ShapelessRecipe(String p_249640_, CraftingBookCategory p_249390_, ItemStack p_252071_, NonNullList p_250689_) { + public ShapelessRecipe(String p_249640_, CraftingBookCategory p_249390_, ItemStack p_252071_, List p_361103_) { this.group = p_249640_; this.category = p_249390_; this.result = p_252071_; - this.ingredients = p_250689_; -+ this.isSimple = p_250689_.stream().allMatch(Ingredient::isSimple); + this.ingredients = p_361103_; ++ this.isSimple = p_361103_.stream().allMatch(Ingredient::isSimple); } @Override -@@ -54,6 +_,12 @@ +@@ -59,6 +_,12 @@ public boolean matches(CraftingInput p_346123_, Level p_44263_) { if (p_346123_.ingredientCount() != this.ingredients.size()) { return false; @@ -28,19 +28,12 @@ } else { return p_346123_.size() == 1 && this.ingredients.size() == 1 ? this.ingredients.getFirst().test(p_346123_.getItem(0)) -@@ -81,12 +_,12 @@ - .fieldOf("ingredients") - .flatXmap( - p_301021_ -> { -- Ingredient[] aingredient = p_301021_.stream().filter(p_300883_ -> !p_300883_.isEmpty()).toArray(Ingredient[]::new); -+ Ingredient[] aingredient = p_301021_.toArray(Ingredient[]::new); // Neo skip the empty check and immediately create the array. - if (aingredient.length == 0) { - return DataResult.error(() -> "No ingredients for shapeless recipe"); - } else { -- return aingredient.length > 9 -- ? DataResult.error(() -> "Too many ingredients for shapeless recipe") -+ return aingredient.length > ShapedRecipePattern.maxHeight * ShapedRecipePattern.maxWidth -+ ? DataResult.error(() -> "Too many ingredients for shapeless recipe. The maximum is: %s".formatted(ShapedRecipePattern.maxHeight * ShapedRecipePattern.maxWidth)) - : DataResult.success(NonNullList.of(Ingredient.EMPTY, aingredient)); - } - }, +@@ -87,7 +_,7 @@ + Codec.STRING.optionalFieldOf("group", "").forGetter(p_301127_ -> p_301127_.group), + CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(p_301133_ -> p_301133_.category), + ItemStack.STRICT_CODEC.fieldOf("result").forGetter(p_301142_ -> p_301142_.result), +- Ingredient.CODEC.listOf(1, 9).fieldOf("ingredients").forGetter(p_360071_ -> p_360071_.ingredients) ++ Codec.lazyInitialized(() -> Ingredient.CODEC.listOf(1, ShapedRecipePattern.maxHeight * ShapedRecipePattern.maxWidth)).fieldOf("ingredients").forGetter(p_360071_ -> p_360071_.ingredients) + ) + .apply(p_360072_, ShapelessRecipe::new) + ); diff --git a/patches/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch b/patches/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch deleted file mode 100644 index 8ad7cc1c..00000000 --- a/patches/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/world/item/crafting/ShulkerBoxColoring.java -+++ b/net/minecraft/world/item/crafting/ShulkerBoxColoring.java -@@ -24,7 +_,7 @@ - if (Block.byItem(itemstack.getItem()) instanceof ShulkerBoxBlock) { - i++; - } else { -- if (!(itemstack.getItem() instanceof DyeItem)) { -+ if (!itemstack.is(net.neoforged.neoforge.common.Tags.Items.DYES)) { - return false; - } - -@@ -42,7 +_,7 @@ - - public ItemStack assemble(CraftingInput p_346433_, HolderLookup.Provider p_335717_) { - ItemStack itemstack = ItemStack.EMPTY; -- DyeItem dyeitem = (DyeItem)Items.WHITE_DYE; -+ net.minecraft.world.item.DyeColor dyecolor = net.minecraft.world.item.DyeColor.WHITE; - - for (int i = 0; i < p_346433_.size(); i++) { - ItemStack itemstack1 = p_346433_.getItem(i); -@@ -50,13 +_,14 @@ - Item item = itemstack1.getItem(); - if (Block.byItem(item) instanceof ShulkerBoxBlock) { - itemstack = itemstack1; -- } else if (item instanceof DyeItem) { -- dyeitem = (DyeItem)item; -+ } else { -+ net.minecraft.world.item.DyeColor tmp = net.minecraft.world.item.DyeColor.getColor(itemstack1); -+ if (tmp != null) dyecolor = tmp; - } - } - } - -- Block block = ShulkerBoxBlock.getBlockByColor(dyeitem.getDyeColor()); -+ Block block = ShulkerBoxBlock.getBlockByColor(dyecolor); - return itemstack.transmuteCopy(block, 1); - } - diff --git a/patches/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch b/patches/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch deleted file mode 100644 index 090c3de7..00000000 --- a/patches/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SimpleCookingSerializer.java -+++ b/net/minecraft/world/item/crafting/SimpleCookingSerializer.java -@@ -20,7 +_,7 @@ - Codec.STRING.optionalFieldOf("group", "").forGetter(p_300832_ -> p_300832_.group), - CookingBookCategory.CODEC.fieldOf("category").orElse(CookingBookCategory.MISC).forGetter(p_300828_ -> p_300828_.category), - Ingredient.CODEC_NONEMPTY.fieldOf("ingredient").forGetter(p_300833_ -> p_300833_.ingredient), -- ItemStack.STRICT_SINGLE_ITEM_CODEC.fieldOf("result").forGetter(p_300827_ -> p_300827_.result), -+ ItemStack.CODEC.fieldOf("result").forGetter(p_300827_ -> p_300827_.result), - Codec.FLOAT.fieldOf("experience").orElse(0.0F).forGetter(p_300826_ -> p_300826_.experience), - Codec.INT.fieldOf("cookingtime").orElse(p_44331_).forGetter(p_300834_ -> p_300834_.cookingTime) - ) diff --git a/patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch b/patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch deleted file mode 100644 index fbf57bcd..00000000 --- a/patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -+++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -@@ -60,7 +_,7 @@ - - @Override - public boolean isIncomplete() { -- return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::isEmpty); -+ return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::hasNoItems); - } - - public static class Serializer implements RecipeSerializer { diff --git a/patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch deleted file mode 100644 index e2e5dadb..00000000 --- a/patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -+++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -89,7 +_,7 @@ - - @Override - public boolean isIncomplete() { -- return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::isEmpty); -+ return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::hasNoItems); - } - - public static class Serializer implements RecipeSerializer { diff --git a/patches/net/minecraft/world/item/enchantment/Enchantment.java.patch b/patches/net/minecraft/world/item/enchantment/Enchantment.java.patch index 9290b598..be865c99 100644 --- a/patches/net/minecraft/world/item/enchantment/Enchantment.java.patch +++ b/patches/net/minecraft/world/item/enchantment/Enchantment.java.patch @@ -43,83 +43,10 @@ public boolean canEnchant(ItemStack p_44689_) { return this.definition.supportedItems().contains(p_44689_.getItemHolder()); } -@@ -355,7 +_,7 @@ - ); - } - -- private void modifyItemFilteredCount( -+ public void modifyItemFilteredCount( - DataComponentType>> p_345794_, - ServerLevel p_345992_, - int p_345038_, -@@ -369,7 +_,7 @@ - ); - } - -- private void modifyEntityFilteredValue( -+ public void modifyEntityFilteredValue( - DataComponentType>> p_345986_, - ServerLevel p_345473_, - int p_345352_, -@@ -384,7 +_,7 @@ - ); - } - -- private void modifyDamageFilteredValue( -+ public void modifyDamageFilteredValue( - DataComponentType>> p_345367_, - ServerLevel p_345784_, - int p_344796_, -@@ -412,7 +_,7 @@ - return new LootContext.Builder(lootparams).create(Optional.empty()); - } - -- private static LootContext itemContext(ServerLevel p_345514_, int p_345186_, ItemStack p_344997_) { -+ public static LootContext itemContext(ServerLevel p_345514_, int p_345186_, ItemStack p_344997_) { - LootParams lootparams = new LootParams.Builder(p_345514_) - .withParameter(LootContextParams.TOOL, p_344997_) - .withParameter(LootContextParams.ENCHANTMENT_LEVEL, p_345186_) -@@ -420,7 +_,7 @@ - return new LootContext.Builder(lootparams).create(Optional.empty()); - } - -- private static LootContext locationContext(ServerLevel p_345134_, int p_346182_, Entity p_345416_, boolean p_345862_) { -+ public static LootContext locationContext(ServerLevel p_345134_, int p_346182_, Entity p_345416_, boolean p_345862_) { - LootParams lootparams = new LootParams.Builder(p_345134_) - .withParameter(LootContextParams.THIS_ENTITY, p_345416_) - .withParameter(LootContextParams.ENCHANTMENT_LEVEL, p_346182_) -@@ -430,7 +_,7 @@ - return new LootContext.Builder(lootparams).create(Optional.empty()); - } - -- private static LootContext entityContext(ServerLevel p_346134_, int p_346059_, Entity p_346146_, Vec3 p_345814_) { -+ public static LootContext entityContext(ServerLevel p_346134_, int p_346059_, Entity p_346146_, Vec3 p_345814_) { - LootParams lootparams = new LootParams.Builder(p_346134_) - .withParameter(LootContextParams.THIS_ENTITY, p_346146_) - .withParameter(LootContextParams.ENCHANTMENT_LEVEL, p_346059_) -@@ -439,7 +_,7 @@ - return new LootContext.Builder(lootparams).create(Optional.empty()); - } - -- private static LootContext blockHitContext(ServerLevel p_350329_, int p_350503_, Entity p_350451_, Vec3 p_350874_, BlockState p_350311_) { -+ public static LootContext blockHitContext(ServerLevel p_350329_, int p_350503_, Entity p_350451_, Vec3 p_350874_, BlockState p_350311_) { - LootParams lootparams = new LootParams.Builder(p_350329_) - .withParameter(LootContextParams.THIS_ENTITY, p_350451_) - .withParameter(LootContextParams.ENCHANTMENT_LEVEL, p_350503_) -@@ -449,7 +_,7 @@ - return new LootContext.Builder(lootparams).create(Optional.empty()); - } - -- private static void applyEffects(List> p_345860_, LootContext p_345578_, Consumer p_346164_) { -+ public static void applyEffects(List> p_345860_, LootContext p_345578_, Consumer p_346164_) { - for (ConditionalEffect conditionaleffect : p_345860_) { - if (conditionaleffect.matches(p_345578_)) { - p_346164_.accept(conditionaleffect.effect()); -@@ -503,6 +_,15 @@ - public static Enchantment.Builder enchantment(Enchantment.EnchantmentDefinition p_345873_) { +@@ -511,12 +_,26 @@ return new Enchantment.Builder(p_345873_); } -+ + +// TODO: Reimplement. Not sure if we want to patch EnchantmentDefinition or hack this in as an EnchantmentEffectComponent. +// /** +// * Is this enchantment allowed to be enchanted on books via Enchantment Table @@ -128,6 +55,46 @@ +// public boolean isAllowedOnBooks() { +// return true; +// } - ++ public static class Builder { private final Enchantment.EnchantmentDefinition definition; + private HolderSet exclusiveSet = HolderSet.direct(); + private final Map, List> effectLists = new HashMap<>(); + private final DataComponentMap.Builder effectMapBuilder = DataComponentMap.builder(); + ++ /** ++ * Neo: Allow customizing or changing the {@link Component} created by the enchantment builder. ++ */ ++ protected java.util.function.UnaryOperator nameFactory = java.util.function.UnaryOperator.identity(); ++ + public Builder(Enchantment.EnchantmentDefinition p_345317_) { + this.definition = p_345317_; + } +@@ -569,6 +_,16 @@ + return this; + } + ++ /** ++ * Allows specifying an operator that can customize the default {@link Component} created by {@link #build(ResourceLocation)}. ++ * ++ * @return this ++ */ ++ public Enchantment.Builder withCustomName(java.util.function.UnaryOperator nameFactory) { ++ this.nameFactory = nameFactory; ++ return this; ++ } ++ + private List getEffectsList(DataComponentType> p_344770_) { + return (List)this.effectLists.computeIfAbsent(p_344770_, p_346247_ -> { + ArrayList arraylist = new ArrayList<>(); +@@ -579,7 +_,9 @@ + + public Enchantment build(ResourceLocation p_344988_) { + return new Enchantment( +- Component.translatable(Util.makeDescriptionId("enchantment", p_344988_)), this.definition, this.exclusiveSet, this.effectMapBuilder.build() ++ // Neo: permit custom name components instead of a single hardcoded translatable component. ++ this.nameFactory.apply(Component.translatable(Util.makeDescriptionId("enchantment", p_344988_))), ++ this.definition, this.exclusiveSet, this.effectMapBuilder.build() + ); + } + } diff --git a/patches/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch b/patches/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch index c4589cad..3fee255d 100644 --- a/patches/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch +++ b/patches/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch @@ -20,21 +20,8 @@ ItemEnchantments itemenchantments = p_44845_.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY); return itemenchantments.getLevel(p_346179_); } -@@ -78,7 +_,7 @@ - return p_330538_.getOrDefault(getComponentType(p_330538_), ItemEnchantments.EMPTY); - } - -- private static DataComponentType getComponentType(ItemStack p_331909_) { -+ public static DataComponentType getComponentType(ItemStack p_331909_) { - return p_331909_.is(Items.ENCHANTED_BOOK) ? DataComponents.STORED_ENCHANTMENTS : DataComponents.ENCHANTMENTS; - } - -@@ -119,19 +_,29 @@ - } - } - -- private static void runIterationOnItem(ItemStack p_345425_, EnchantmentHelper.EnchantmentVisitor p_345023_) { -+ public static void runIterationOnItem(ItemStack p_345425_, EnchantmentHelper.EnchantmentVisitor p_345023_) { +@@ -128,6 +_,12 @@ + public static void runIterationOnItem(ItemStack p_345425_, EnchantmentHelper.EnchantmentVisitor p_345023_) { ItemEnchantments itemenchantments = p_345425_.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY); + // Neo: Respect gameplay-only enchantments when doing iterations @@ -46,11 +33,7 @@ for (Entry> entry : itemenchantments.entrySet()) { p_345023_.accept(entry.getKey(), entry.getIntValue()); } - } - -- private static void runIterationOnItem( -+ public static void runIterationOnItem( - ItemStack p_44852_, EquipmentSlot p_345566_, LivingEntity p_345792_, EnchantmentHelper.EnchantmentInSlotVisitor p_345683_ +@@ -138,6 +_,10 @@ ) { if (!p_44852_.isEmpty()) { ItemEnchantments itemenchantments = p_44852_.get(DataComponents.ENCHANTMENTS); @@ -61,16 +44,7 @@ if (itemenchantments != null && !itemenchantments.isEmpty()) { EnchantedItemInUse enchantediteminuse = new EnchantedItemInUse(p_44852_, p_345566_, p_345792_); -@@ -145,7 +_,7 @@ - } - } - -- private static void runIterationOnEquipment(LivingEntity p_344744_, EnchantmentHelper.EnchantmentInSlotVisitor p_345709_) { -+ public static void runIterationOnEquipment(LivingEntity p_344744_, EnchantmentHelper.EnchantmentInSlotVisitor p_345709_) { - for (EquipmentSlot equipmentslot : EquipmentSlot.values()) { - runIterationOnItem(p_344744_.getItemBySlot(equipmentslot), equipmentslot, p_344744_, p_345709_); - } -@@ -417,6 +_,12 @@ +@@ -438,6 +_,12 @@ public static boolean hasTag(ItemStack p_345665_, TagKey p_345928_) { ItemEnchantments itemenchantments = p_345665_.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY); @@ -83,25 +57,7 @@ for (Entry> entry : itemenchantments.entrySet()) { Holder holder = entry.getKey(); if (holder.is(p_345928_)) { -@@ -484,7 +_,7 @@ - - public static int getEnchantmentCost(RandomSource p_220288_, int p_220289_, int p_220290_, ItemStack p_220291_) { - Item item = p_220291_.getItem(); -- int i = item.getEnchantmentValue(); -+ int i = p_220291_.getEnchantmentValue(); - if (i <= 0) { - return 0; - } else { -@@ -529,7 +_,7 @@ - public static List selectEnchantment(RandomSource p_220298_, ItemStack p_220299_, int p_220300_, Stream> p_346061_) { - List list = Lists.newArrayList(); - Item item = p_220299_.getItem(); -- int i = item.getEnchantmentValue(); -+ int i = p_220299_.getEnchantmentValue(); - if (i <= 0) { - return list; - } else { -@@ -575,7 +_,9 @@ +@@ -594,7 +_,9 @@ public static List getAvailableEnchantmentResults(int p_44818_, ItemStack p_44819_, Stream> p_345348_) { List list = Lists.newArrayList(); boolean flag = p_44819_.is(Items.BOOK); @@ -112,18 +68,3 @@ Enchantment enchantment = p_344478_.value(); for (int i = enchantment.getMaxLevel(); i >= enchantment.getMinLevel(); i--) { -@@ -598,12 +_,12 @@ - } - - @FunctionalInterface -- interface EnchantmentInSlotVisitor { -+ public interface EnchantmentInSlotVisitor { - void accept(Holder p_346326_, int p_346009_, EnchantedItemInUse p_345960_); - } - - @FunctionalInterface -- interface EnchantmentVisitor { -+ public interface EnchantmentVisitor { - void accept(Holder p_346050_, int p_44946_); - } - } diff --git a/patches/net/minecraft/world/level/BaseSpawner.java.patch b/patches/net/minecraft/world/level/BaseSpawner.java.patch index 05af8829..6a423f6c 100644 --- a/patches/net/minecraft/world/level/BaseSpawner.java.patch +++ b/patches/net/minecraft/world/level/BaseSpawner.java.patch @@ -9,27 +9,28 @@ public static final String SPAWN_DATA_TAG = "SpawnData"; private static final Logger LOGGER = LogUtils.getLogger(); private static final int EVENT_SPAWN = 1; -@@ -151,15 +_,14 @@ +@@ -151,16 +_,14 @@ entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), randomsource.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob mob) { -- if (spawndata.getCustomSpawnRules().isEmpty() && !mob.checkSpawnRules(p_151312_, MobSpawnType.SPAWNER) +- if (spawndata.getCustomSpawnRules().isEmpty() && !mob.checkSpawnRules(p_151312_, EntitySpawnReason.SPAWNER) - || !mob.checkSpawnObstruction(p_151312_)) { -+ if (!net.neoforged.neoforge.event.EventHooks.checkSpawnPositionSpawner(mob, p_151312_, MobSpawnType.SPAWNER, spawndata, this)) { ++ if (!net.neoforged.neoforge.event.EventHooks.checkSpawnPositionSpawner(mob, p_151312_, EntitySpawnReason.SPAWNER, spawndata, this)) { continue; } boolean flag1 = spawndata.getEntityToSpawn().size() == 1 && spawndata.getEntityToSpawn().contains("id", 8); - if (flag1) { -- ((Mob)entity).finalizeSpawn(p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, null); +- ((Mob)entity) +- .finalizeSpawn(p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, null); - } + // Neo: Patch in FinalizeSpawn for spawners so it may be fired unconditionally, instead of only when vanilla would normally call it. + // The local flag1 is the conditions under which the spawner will normally call Mob#finalizeSpawn. -+ net.neoforged.neoforge.event.EventHooks.finalizeMobSpawnSpawner(mob, p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, null, this, flag1); ++ net.neoforged.neoforge.event.EventHooks.finalizeMobSpawnSpawner(mob, p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, null, this, flag1); spawndata.getEquipment().ifPresent(mob::equip); } -@@ -308,5 +_,12 @@ +@@ -309,5 +_,12 @@ public double getoSpin() { return this.oSpin; diff --git a/patches/net/minecraft/world/level/BlockGetter.java.patch b/patches/net/minecraft/world/level/BlockGetter.java.patch index c04b9cc5..60f517c0 100644 --- a/patches/net/minecraft/world/level/BlockGetter.java.patch +++ b/patches/net/minecraft/world/level/BlockGetter.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/BlockGetter.java +++ b/net/minecraft/world/level/BlockGetter.java -@@ -18,7 +_,7 @@ +@@ -20,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; -public interface BlockGetter extends LevelHeightAccessor { +public interface BlockGetter extends LevelHeightAccessor, net.neoforged.neoforge.common.extensions.IBlockGetterExtension { - @Nullable - BlockEntity getBlockEntity(BlockPos p_45570_); + int MAX_BLOCK_ITERATIONS_ALONG_TRAVEL = 16; -@@ -32,7 +_,7 @@ + @Nullable +@@ -36,7 +_,7 @@ FluidState getFluidState(BlockPos p_45569_); default int getLightEmission(BlockPos p_45572_) { @@ -17,4 +17,4 @@ + return this.getBlockState(p_45572_).getLightEmission(this, p_45572_); } - default int getMaxLightLevel() { + default Stream getBlockStates(AABB p_45557_) { diff --git a/patches/net/minecraft/world/level/Explosion.java.patch b/patches/net/minecraft/world/level/Explosion.java.patch deleted file mode 100644 index 285a7530..00000000 --- a/patches/net/minecraft/world/level/Explosion.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/world/level/Explosion.java -+++ b/net/minecraft/world/level/Explosion.java -@@ -269,6 +_,7 @@ - int j2 = Mth.floor(this.z - (double)f2 - 1.0); - int j1 = Mth.floor(this.z + (double)f2 + 1.0); - List list = this.level.getEntities(this.source, new AABB((double)k1, (double)i2, (double)j2, (double)l1, (double)i1, (double)j1)); -+ net.neoforged.neoforge.event.EventHooks.onExplosionDetonate(this.level, this, list, f2); - Vec3 vec3 = new Vec3(this.x, this.y, this.z); - - for (Entity entity : list) { -@@ -299,6 +_,7 @@ - d7 *= d10; - d9 *= d10; - Vec3 vec31 = new Vec3(d5, d7, d9); -+ vec31 = net.neoforged.neoforge.event.EventHooks.getExplosionKnockback(this.level, this, entity, vec31); - entity.setDeltaMovement(entity.getDeltaMovement().add(vec31)); - if (entity instanceof Player) { - Player player = (Player)entity; diff --git a/patches/net/minecraft/world/level/Level.java.patch b/patches/net/minecraft/world/level/Level.java.patch index 027f7bed..00df1925 100644 --- a/patches/net/minecraft/world/level/Level.java.patch +++ b/patches/net/minecraft/world/level/Level.java.patch @@ -1,48 +1,15 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -3,8 +_,10 @@ - import com.google.common.collect.Lists; - import com.mojang.serialization.Codec; - import java.io.IOException; -+import java.util.HashMap; - import java.util.Iterator; - import java.util.List; -+import java.util.Map; - import java.util.function.Consumer; - import java.util.function.Predicate; - import java.util.function.Supplier; -@@ -41,6 +_,7 @@ - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.boss.EnderDragonPart; - import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -+import net.minecraft.world.entity.item.ItemEntity; - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.item.alchemy.PotionBrewing; -@@ -59,6 +_,7 @@ - import net.minecraft.world.level.chunk.LevelChunk; - import net.minecraft.world.level.chunk.status.ChunkStatus; - import net.minecraft.world.level.dimension.DimensionType; -+import net.minecraft.world.level.dimension.LevelStem; - import net.minecraft.world.level.entity.EntityTypeTest; - import net.minecraft.world.level.entity.LevelEntityGetter; - import net.minecraft.world.level.gameevent.GameEvent; -@@ -75,8 +_,13 @@ - import net.minecraft.world.phys.AABB; +@@ -78,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Scoreboard; -+import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.CraftServer; -+import org.bukkit.craftbukkit.CraftWorld; -+import org.bukkit.craftbukkit.block.CapturedBlockState; -+import org.bukkit.entity.SpawnCategory; -public abstract class Level implements LevelAccessor, AutoCloseable { +public abstract class Level extends net.neoforged.neoforge.attachment.AttachmentHolder implements LevelAccessor, AutoCloseable, net.neoforged.neoforge.common.extensions.ILevelExtension { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); public static final ResourceKey NETHER = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("the_nether")); -@@ -114,6 +_,35 @@ +@@ -115,6 +_,11 @@ private final RegistryAccess registryAccess; private final DamageSources damageSources; private long subTickCount; @@ -51,49 +18,10 @@ + public java.util.ArrayList capturedBlockSnapshots = new java.util.ArrayList<>(); + private final java.util.ArrayList freshBlockEntities = new java.util.ArrayList<>(); + private final java.util.ArrayList pendingFreshBlockEntities = new java.util.ArrayList<>(); -+ -+ // CraftBukkit start Added the following -+ private CraftWorld world; -+ public boolean pvpMode; -+ public org.bukkit.generator.ChunkGenerator generator; -+ -+ public boolean preventPoiUpdated = false; // CraftBukkit - SPIGOT-5710 -+ public boolean captureBlockStates = false; -+ public boolean captureTreeGeneration = false; -+ public Map capturedBlockStates = new java.util.LinkedHashMap<>(); -+ public Map capturedTileEntities = new HashMap<>(); -+ public List captureDrops; -+ public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); -+ public boolean populating; -+ -+ public CraftWorld getWorld() { -+ return this.world; -+ } -+ -+ public CraftServer getCraftServer() { -+ return (CraftServer) Bukkit.getServer(); -+ } -+ -+ public abstract ResourceKey getTypeKey(); protected Level( WritableLevelData p_270739_, -@@ -156,6 +_,14 @@ - this.damageSources = new DamageSources(p_270200_); - } - -+ public void notifyAndUpdatePhysics(BlockPos blockposition, LevelChunk chunk, BlockState oldBlock, BlockState newBlock, BlockState actualBlock, int i, int j) { -+ -+ } -+ -+ public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) { -+ return null; -+ } -+ - @Override - public boolean isClientSide() { - return this.isClientSide; -@@ -216,11 +_,40 @@ +@@ -215,11 +_,36 @@ } else { LevelChunk levelchunk = this.getChunkAt(p_46605_); Block block = p_46606_.getBlock(); @@ -104,10 +32,6 @@ + blockSnapshot = net.neoforged.neoforge.common.util.BlockSnapshot.create(this.dimension, this, p_46605_, p_46607_); + this.capturedBlockSnapshots.add(blockSnapshot); + } -+ -+ BlockState old = getBlockState(p_46605_); -+ int oldLight = old.getLightEmission(this, p_46605_); -+ int oldOpacity = old.getLightBlock(this, p_46605_); + BlockState blockstate = levelchunk.setBlockState(p_46605_, p_46606_, (p_46607_ & 64) != 0); if (blockstate == null) { @@ -134,7 +58,7 @@ if (blockstate1 == p_46606_) { if (blockstate != blockstate1) { this.setBlocksDirty(p_46605_, blockstate, blockstate1); -@@ -247,9 +_,8 @@ +@@ -246,9 +_,8 @@ } this.onBlockStateChange(p_46605_, blockstate, blockstate1); @@ -145,15 +69,15 @@ } } } -@@ -301,6 +_,7 @@ +@@ -300,6 +_,7 @@ } public void updateNeighborsAt(BlockPos p_46673_, Block p_46674_) { + net.neoforged.neoforge.event.EventHooks.onNeighborNotify(this, p_46673_, this.getBlockState(p_46673_), java.util.EnumSet.allOf(Direction.class), false).isCanceled(); } - public void updateNeighborsAtExceptFromFacing(BlockPos p_46591_, Block p_46592_, Direction p_46593_) { -@@ -489,10 +_,26 @@ + public void updateNeighborsAt(BlockPos p_365514_, Block p_364886_, @Nullable Orientation p_363337_) { +@@ -491,10 +_,26 @@ (this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add(p_151526_); } @@ -166,7 +90,7 @@ + } + protected void tickBlockEntities() { - ProfilerFiller profilerfiller = this.getProfiler(); + ProfilerFiller profilerfiller = Profiler.get(); profilerfiller.push("blockEntities"); + if (!this.pendingFreshBlockEntities.isEmpty()) { + this.freshBlockEntities.addAll(this.pendingFreshBlockEntities); @@ -180,7 +104,7 @@ if (!this.pendingBlockEntityTickers.isEmpty()) { this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); this.pendingBlockEntityTickers.clear(); -@@ -516,12 +_,19 @@ +@@ -518,12 +_,19 @@ public void guardEntityTick(Consumer p_46654_, T p_46655_) { try { @@ -200,24 +124,7 @@ } } -@@ -670,7 +_,7 @@ - Explosion.BlockInteraction explosion$blockinteraction = switch (p_312265_) { - case NONE -> Explosion.BlockInteraction.KEEP; - case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); -- case MOB -> this.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) -+ case MOB -> net.neoforged.neoforge.event.EventHooks.canEntityGrief(this, p_311934_) - ? this.getDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) - : Explosion.BlockInteraction.KEEP; - case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); -@@ -691,6 +_,7 @@ - p_312060_, - p_320283_ - ); -+ if (net.neoforged.neoforge.event.EventHooks.onExplosionStart(this, explosion)) return explosion; - explosion.explode(); - explosion.finalizeExplosion(p_312145_); - return explosion; -@@ -725,6 +_,7 @@ +@@ -673,6 +_,7 @@ if (!this.isOutsideBuildHeight(p_46748_)) { this.getChunkAt(p_46748_).removeBlockEntity(p_46748_); } @@ -225,7 +132,7 @@ } public boolean isLoaded(BlockPos p_46750_) { -@@ -803,6 +_,7 @@ +@@ -751,6 +_,7 @@ list.add(p_151522_); } @@ -233,7 +140,7 @@ if (p_151522_ instanceof EnderDragon) { for (EnderDragonPart enderdragonpart : ((EnderDragon)p_151522_).getSubEntities()) { if (p_151522_ != p_46536_ && p_46538_.test(enderdragonpart)) { -@@ -811,6 +_,11 @@ +@@ -759,6 +_,11 @@ } } }); @@ -245,7 +152,7 @@ return list; } -@@ -837,6 +_,8 @@ +@@ -785,6 +_,8 @@ } } @@ -254,7 +161,7 @@ if (p_261454_ instanceof EnderDragon enderdragon) { for (EnderDragonPart enderdragonpart : enderdragon.getSubEntities()) { T t = p_261885_.tryCast(enderdragonpart); -@@ -851,6 +_,15 @@ +@@ -799,6 +_,15 @@ return AbortableIterationConsumer.Continuation.CONTINUE; }); @@ -270,7 +177,7 @@ } @Nullable -@@ -979,16 +_,15 @@ +@@ -922,16 +_,15 @@ public abstract Scoreboard getScoreboard(); public void updateNeighbourForOutputSignal(BlockPos p_46718_, Block p_46719_) { @@ -280,7 +187,7 @@ if (this.hasChunkAt(blockpos)) { BlockState blockstate = this.getBlockState(blockpos); - if (blockstate.is(Blocks.COMPARATOR)) { -- this.neighborChanged(blockstate, blockpos, p_46719_, p_46718_, false); +- this.neighborChanged(blockstate, blockpos, p_46719_, null, false); - } else if (blockstate.isRedstoneConductor(this, blockpos)) { + blockstate.onNeighborChange(this, blockpos, p_46718_); + if (blockstate.isRedstoneConductor(this, blockpos)) { @@ -288,10 +195,10 @@ blockstate = this.getBlockState(blockpos); - if (blockstate.is(Blocks.COMPARATOR)) { + if (blockstate.getWeakChanges(this, blockpos)) { - this.neighborChanged(blockstate, blockpos, p_46719_, p_46718_, false); + this.neighborChanged(blockstate, blockpos, p_46719_, null, false); } } -@@ -1078,6 +_,18 @@ +@@ -1013,6 +_,18 @@ return this.biomeManager; } @@ -310,7 +217,7 @@ public final boolean isDebug() { return this.isDebug; } -@@ -1118,5 +_,38 @@ +@@ -1055,5 +_,38 @@ public String getSerializedName() { return this.id; } diff --git a/patches/net/minecraft/world/level/LevelAccessor.java.patch b/patches/net/minecraft/world/level/LevelAccessor.java.patch deleted file mode 100644 index 9048b8e6..00000000 --- a/patches/net/minecraft/world/level/LevelAccessor.java.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- a/net/minecraft/world/level/LevelAccessor.java -+++ b/net/minecraft/world/level/LevelAccessor.java -@@ -121,4 +_,6 @@ - default void gameEvent(ResourceKey p_316780_, BlockPos p_316509_, GameEvent.Context p_316524_) { - this.gameEvent(this.registryAccess().registryOrThrow(Registries.GAME_EVENT).getHolderOrThrow(p_316780_), p_316509_, p_316524_); - } -+ -+ net.minecraft.server.level.ServerLevel getMinecraftWorld(); // CraftBukkit - } diff --git a/patches/net/minecraft/world/level/LevelSettings.java.patch b/patches/net/minecraft/world/level/LevelSettings.java.patch index e7ca7e31..086a722d 100644 --- a/patches/net/minecraft/world/level/LevelSettings.java.patch +++ b/patches/net/minecraft/world/level/LevelSettings.java.patch @@ -26,14 +26,14 @@ @@ -33,7 +_,8 @@ p_46925_.get("Difficulty").asNumber().map(p_46928_ -> Difficulty.byId(p_46928_.byteValue())).result().orElse(Difficulty.NORMAL), p_46925_.get("allowCommands").asBoolean(gametype == GameType.CREATIVE), - new GameRules(p_46925_.get("GameRules")), + new GameRules(p_251697_.enabledFeatures(), p_46925_.get("GameRules")), - p_251697_ + p_251697_, + net.neoforged.neoforge.common.CommonHooks.parseLifecycle(p_46925_.get("forgeLifecycle").asString("stable")) ); } -@@ -66,20 +_,27 @@ +@@ -66,15 +_,15 @@ } public LevelSettings withGameType(GameType p_46923_) { @@ -43,7 +43,6 @@ public LevelSettings withDifficulty(Difficulty p_46919_) { - return new LevelSettings(this.levelName, this.gameType, this.hardcore, p_46919_, this.allowCommands, this.gameRules, this.dataConfiguration); -+ net.neoforged.neoforge.common.CommonHooks.onDifficultyChange(p_46919_, this.difficulty); + return new LevelSettings(this.levelName, this.gameType, this.hardcore, p_46919_, this.allowCommands, this.gameRules, this.dataConfiguration, this.lifecycle); } @@ -53,14 +52,20 @@ } public LevelSettings copy() { - return new LevelSettings( -- this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(), this.dataConfiguration -+ this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(), this.dataConfiguration, this.lifecycle +@@ -85,7 +_,16 @@ + this.difficulty, + this.allowCommands, + this.gameRules.copy(this.dataConfiguration.enabledFeatures()), +- this.dataConfiguration ++ this.dataConfiguration, ++ this.lifecycle ); + } ++ + public LevelSettings withLifecycle(com.mojang.serialization.Lifecycle lifecycle) { + return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, this.dataConfiguration, lifecycle); + } ++ + public com.mojang.serialization.Lifecycle getLifecycle() { + return this.lifecycle; } diff --git a/patches/net/minecraft/world/level/LevelWriter.java.patch b/patches/net/minecraft/world/level/LevelWriter.java.patch deleted file mode 100644 index 55a1206c..00000000 --- a/patches/net/minecraft/world/level/LevelWriter.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/level/LevelWriter.java -+++ b/net/minecraft/world/level/LevelWriter.java -@@ -27,4 +_,10 @@ - default boolean addFreshEntity(Entity p_46964_) { - return false; - } -+ -+ // CraftBukkit start -+ default boolean addFreshEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { -+ return false; -+ } -+ // CraftBukkit end - } diff --git a/patches/net/minecraft/world/level/NaturalSpawner.java.patch b/patches/net/minecraft/world/level/NaturalSpawner.java.patch index 53f0facd..39621821 100644 --- a/patches/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/patches/net/minecraft/world/level/NaturalSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -45,6 +_,7 @@ +@@ -49,6 +_,7 @@ import net.minecraft.world.phys.Vec3; import org.slf4j.Logger; @@ -8,7 +8,7 @@ public final class NaturalSpawner { private static final Logger LOGGER = LogUtils.getLogger(); private static final int MIN_SPAWN_DISTANCE = 24; -@@ -69,7 +_,7 @@ +@@ -73,7 +_,7 @@ continue; } @@ -17,7 +17,7 @@ if (mobcategory != MobCategory.MISC) { BlockPos blockpos = entity.blockPosition(); p_186527_.query( -@@ -199,7 +_,7 @@ +@@ -214,7 +_,7 @@ l1++; p_47040_.addFreshEntityWithPassengers(mob); p_47044_.run(mob, p_47041_); @@ -26,16 +26,16 @@ return; } -@@ -272,7 +_,7 @@ +@@ -287,7 +_,7 @@ return p_46994_ > (double)(p_46993_.getType().getCategory().getDespawnDistance() * p_46993_.getType().getCategory().getDespawnDistance()) && p_46993_.removeWhenFarAway(p_46994_) ? false -- : p_46993_.checkSpawnRules(p_46992_, MobSpawnType.NATURAL) && p_46993_.checkSpawnObstruction(p_46992_); -+ : net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(p_46993_, p_46992_, MobSpawnType.NATURAL); +- : p_46993_.checkSpawnRules(p_46992_, EntitySpawnReason.NATURAL) && p_46993_.checkSpawnObstruction(p_46992_); ++ : net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(p_46993_, p_46992_, EntitySpawnReason.NATURAL); } private static Optional getRandomSpawnMobAt( -@@ -303,9 +_,14 @@ +@@ -318,9 +_,14 @@ BlockPos p_220448_, @Nullable Holder p_220449_ ) { @@ -44,7 +44,7 @@ - : p_220446_.getMobsAt(p_220449_ != null ? p_220449_ : p_220444_.getBiome(p_220448_), p_220445_, p_220447_, p_220448_); + // Forge: Add in potential spawns, and replace hardcoded nether fortress mob list + if (isInNetherFortressBounds(p_220448_, p_220444_, p_220447_, p_220445_)) { -+ var monsterSpawns = p_220445_.registryAccess().registryOrThrow(Registries.STRUCTURE).getOrThrow(BuiltinStructures.FORTRESS).spawnOverrides().get(MobCategory.MONSTER); ++ var monsterSpawns = p_220445_.registryAccess().lookupOrThrow(Registries.STRUCTURE).getValueOrThrow(BuiltinStructures.FORTRESS).spawnOverrides().get(MobCategory.MONSTER); + if (monsterSpawns != null) { // structure modifiers can clear the spawn overrides + return net.neoforged.neoforge.event.EventHooks.getPotentialSpawns(p_220444_, p_220447_, p_220448_, monsterSpawns.spawns()); + } @@ -53,13 +53,13 @@ } public static boolean isInNetherFortressBounds(BlockPos p_220456_, ServerLevel p_220457_, MobCategory p_220458_, StructureManager p_220459_) { -@@ -392,8 +_,7 @@ +@@ -407,8 +_,7 @@ entity.moveTo(d0, (double)blockpos.getY(), d1, p_220454_.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob mob -- && mob.checkSpawnRules(p_220451_, MobSpawnType.CHUNK_GENERATION) +- && mob.checkSpawnRules(p_220451_, EntitySpawnReason.CHUNK_GENERATION) - && mob.checkSpawnObstruction(p_220451_)) { -+ && net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(mob, p_220451_, MobSpawnType.CHUNK_GENERATION)) { ++ && net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(mob, p_220451_, EntitySpawnReason.CHUNK_GENERATION)) { spawngroupdata = mob.finalizeSpawn( - p_220451_, p_220451_.getCurrentDifficultyAt(mob.blockPosition()), MobSpawnType.CHUNK_GENERATION, spawngroupdata + p_220451_, p_220451_.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, spawngroupdata ); diff --git a/patches/net/minecraft/world/level/ServerExplosion.java.patch b/patches/net/minecraft/world/level/ServerExplosion.java.patch new file mode 100644 index 00000000..de66d59d --- /dev/null +++ b/patches/net/minecraft/world/level/ServerExplosion.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/level/ServerExplosion.java ++++ b/net/minecraft/world/level/ServerExplosion.java +@@ -174,7 +_,9 @@ + int i1 = Mth.floor(this.center.z - (double)f - 1.0); + int j1 = Mth.floor(this.center.z + (double)f + 1.0); + +- for (Entity entity : this.level.getEntities(this.source, new AABB((double)i, (double)k, (double)i1, (double)j, (double)l, (double)j1))) { ++ List list = this.level.getEntities(this.source, new AABB((double)i, (double)k, (double)i1, (double)j, (double)l, (double)j1)); ++ net.neoforged.neoforge.event.EventHooks.onExplosionDetonate(this.level, this, list, f); ++ for (Entity entity : list) { + if (!entity.ignoreExplosion(this)) { + double d0 = Math.sqrt(entity.distanceToSqr(this.center)) / (double)f; + if (d0 <= 1.0) { +@@ -205,6 +_,7 @@ + d2 *= d6; + d3 *= d6; + Vec3 vec3 = new Vec3(d1, d2, d3); ++ vec3 = net.neoforged.neoforge.event.EventHooks.getExplosionKnockback(this.level, this, entity, vec3); + entity.setDeltaMovement(entity.getDeltaMovement().add(vec3)); + if (entity instanceof Player) { + Player player = (Player)entity; diff --git a/patches/net/minecraft/world/level/ServerLevelAccessor.java.patch b/patches/net/minecraft/world/level/ServerLevelAccessor.java.patch deleted file mode 100644 index f4e94f8e..00000000 --- a/patches/net/minecraft/world/level/ServerLevelAccessor.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/world/level/ServerLevelAccessor.java -+++ b/net/minecraft/world/level/ServerLevelAccessor.java -@@ -9,4 +_,13 @@ - default void addFreshEntityWithPassengers(Entity p_47206_) { - p_47206_.getSelfAndPassengers().forEach(this::addFreshEntity); - } -+ -+ default void addFreshEntityWithPassengers(Entity p_47206_, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { -+ p_47206_.getSelfAndPassengers().forEach((e) -> this.addFreshEntity(e, reason)); -+ } -+ -+ @Override -+ default ServerLevel getMinecraftWorld() { -+ return getLevel(); -+ } - } diff --git a/patches/net/minecraft/world/level/biome/Biome.java.patch b/patches/net/minecraft/world/level/biome/Biome.java.patch index 756ca8a3..54c553a0 100644 --- a/patches/net/minecraft/world/level/biome/Biome.java.patch +++ b/patches/net/minecraft/world/level/biome/Biome.java.patch @@ -40,7 +40,7 @@ } public boolean hasPrecipitation() { -@@ -191,7 +_,7 @@ +@@ -188,7 +_,7 @@ } public BiomeGenerationSettings getGenerationSettings() { @@ -49,7 +49,7 @@ } public int getFogColor() { -@@ -414,5 +_,32 @@ +@@ -411,5 +_,32 @@ public String getSerializedName() { return this.name; } diff --git a/patches/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch b/patches/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch deleted file mode 100644 index a9325c1b..00000000 --- a/patches/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/world/level/biome/BiomeGenerationSettings.java -+++ b/net/minecraft/world/level/biome/BiomeGenerationSettings.java -@@ -50,6 +_,7 @@ - .apply(p_186655_, BiomeGenerationSettings::new) - ); - private final Map>> carvers; -+ private final java.util.Set carversView; - private final List> features; - private final Supplier>> flowerFeatures; - private final Supplier> featureSet; -@@ -66,10 +_,15 @@ - .collect(ImmutableList.toImmutableList()) - ); - this.featureSet = Suppliers.memoize(() -> p_186651_.stream().flatMap(HolderSet::stream).map(Holder::value).collect(Collectors.toSet())); -+ this.carversView = java.util.Collections.unmodifiableSet(carvers.keySet()); - } - - public Iterable>> getCarvers(GenerationStep.Carving p_204188_) { - return Objects.requireNonNullElseGet(this.carvers.get(p_204188_), List::of); -+ } -+ -+ public java.util.Set getCarvingStages() { -+ return this.carversView; - } - - public List> getFlowerFeatures() { diff --git a/patches/net/minecraft/world/level/block/AttachedStemBlock.java.patch b/patches/net/minecraft/world/level/block/AttachedStemBlock.java.patch index 85788acd..df3eadde 100644 --- a/patches/net/minecraft/world/level/block/AttachedStemBlock.java.patch +++ b/patches/net/minecraft/world/level/block/AttachedStemBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/AttachedStemBlock.java +++ b/net/minecraft/world/level/block/AttachedStemBlock.java -@@ -84,7 +_,7 @@ +@@ -94,7 +_,7 @@ @Override protected boolean mayPlaceOn(BlockState p_48863_, BlockGetter p_48864_, BlockPos p_48865_) { diff --git a/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch b/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch index cce4907a..f3b8f17d 100644 --- a/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch @@ -9,7 +9,7 @@ return p_48987_.getBlockState(p_48988_.below()).is(BlockTags.BAMBOO_PLANTABLE_ON); } -@@ -88,7 +_,7 @@ +@@ -95,7 +_,7 @@ @Override protected float getDestroyProgress(BlockState p_48981_, Player p_48982_, BlockGetter p_48983_, BlockPos p_48984_) { diff --git a/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch index efaeb2b8..91d4635c 100644 --- a/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -33,7 +33,7 @@ return p_262154_.getBlockState(p_261493_.below()).is(BlockTags.BAMBOO_PLANTABLE_ON); } -@@ -193,7 +_,7 @@ +@@ -198,7 +_,7 @@ @Override protected float getDestroyProgress(BlockState p_261691_, Player p_262171_, BlockGetter p_261621_, BlockPos p_261500_) { diff --git a/patches/net/minecraft/world/level/block/BaseFireBlock.java.patch b/patches/net/minecraft/world/level/block/BaseFireBlock.java.patch index c4bc4e33..ade6a8b9 100644 --- a/patches/net/minecraft/world/level/block/BaseFireBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BaseFireBlock.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BaseFireBlock.java +++ b/net/minecraft/world/level/block/BaseFireBlock.java -@@ -143,6 +_,7 @@ +@@ -152,6 +_,7 @@ if (!p_49282_.is(p_49279_.getBlock())) { if (inPortalDimension(p_49280_)) { Optional optional = PortalShape.findEmptyPortalShape(p_49280_, p_49281_, Direction.Axis.X); + optional = net.neoforged.neoforge.event.EventHooks.onTrySpawnPortal(p_49280_, p_49281_, optional); if (optional.isPresent()) { - optional.get().createPortalBlocks(); + optional.get().createPortalBlocks(p_49280_); return; -@@ -185,7 +_,7 @@ +@@ -194,7 +_,7 @@ boolean flag = false; for (Direction direction : Direction.values()) { diff --git a/patches/net/minecraft/world/level/block/BaseRailBlock.java.patch b/patches/net/minecraft/world/level/block/BaseRailBlock.java.patch index af4fb513..cf64085b 100644 --- a/patches/net/minecraft/world/level/block/BaseRailBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BaseRailBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BaseRailBlock.java +++ b/net/minecraft/world/level/block/BaseRailBlock.java -@@ -20,7 +_,7 @@ +@@ -23,7 +_,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,33 +9,43 @@ protected static final VoxelShape FLAT_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 2.0, 16.0); protected static final VoxelShape HALF_BLOCK_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0); public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; -@@ -49,6 +_,7 @@ +@@ -51,7 +_,7 @@ + @Override protected VoxelShape getShape(BlockState p_49403_, BlockGetter p_49404_, BlockPos p_49405_, CollisionContext p_49406_) { - RailShape railshape = p_49403_.is(this) ? p_49403_.getValue(this.getShapeProperty()) : null; -+ RailShape railShape2 = p_49403_.is(this) ? getRailDirection(p_49403_, p_49404_, p_49405_, null) : null; - return railshape != null && railshape.isAscending() ? HALF_BLOCK_AABB : FLAT_AABB; +- RailShape railshape = p_49403_.is(this) ? p_49403_.getValue(this.getShapeProperty()) : null; ++ RailShape railshape = p_49403_.is(this) ? getRailDirection(p_49403_, p_49404_, p_49405_, null) : null; + return railshape != null && railshape.isSlope() ? HALF_BLOCK_AABB : FLAT_AABB; } -@@ -76,7 +_,7 @@ +@@ -79,7 +_,7 @@ @Override - protected void neighborChanged(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, BlockPos p_49381_, boolean p_49382_) { + protected void neighborChanged(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, @Nullable Orientation p_361387_, boolean p_49382_) { if (!p_49378_.isClientSide && p_49378_.getBlockState(p_49379_).is(this)) { - RailShape railshape = p_49377_.getValue(this.getShapeProperty()); + RailShape railshape = getRailDirection(p_49377_, p_49378_, p_49379_, null); if (shouldBeRemoved(p_49379_, p_49378_, railshape)) { dropResources(p_49377_, p_49378_, p_49379_); p_49378_.removeBlock(p_49379_, p_49382_); -@@ -121,7 +_,7 @@ +@@ -115,7 +_,7 @@ + if (p_49368_.isClientSide) { + return p_49370_; + } else { +- RailShape railshape = p_49370_.getValue(this.getShapeProperty()); ++ RailShape railshape = getRailDirection(p_49370_, p_49368_, p_49369_, null); + return new RailState(p_49368_, p_49369_, p_49370_).place(p_49368_.hasNeighborSignal(p_49369_), p_49371_, railshape).getState(); + } + } +@@ -124,7 +_,7 @@ protected void onRemove(BlockState p_49384_, Level p_49385_, BlockPos p_49386_, BlockState p_49387_, boolean p_49388_) { if (!p_49388_) { super.onRemove(p_49384_, p_49385_, p_49386_, p_49387_, p_49388_); -- if (p_49384_.getValue(this.getShapeProperty()).isAscending()) { -+ if (getRailDirection(p_49384_, p_49385_, p_49386_, null).isAscending()) { +- if (p_49384_.getValue(this.getShapeProperty()).isSlope()) { ++ if (getRailDirection(p_49384_, p_49385_, p_49386_, null).isSlope()) { p_49385_.updateNeighborsAt(p_49386_.above(), this); } -@@ -142,6 +_,11 @@ +@@ -145,6 +_,11 @@ return blockstate.setValue(this.getShapeProperty(), flag1 ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH).setValue(WATERLOGGED, Boolean.valueOf(flag)); } @@ -47,7 +57,7 @@ public abstract Property getShapeProperty(); @Override -@@ -158,5 +_,15 @@ +@@ -168,5 +_,15 @@ @Override protected FluidState getFluidState(BlockState p_152158_) { return p_152158_.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(p_152158_); @@ -55,7 +65,7 @@ + + @Override + public boolean isFlexibleRail(BlockState state, BlockGetter world, BlockPos pos) { -+ return !this.isStraight; ++ return !this.isStraight; + } + + @Override diff --git a/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch b/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch index 5e59b85a..8f858d24 100644 --- a/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BeehiveBlock.java +++ b/net/minecraft/world/level/block/BeehiveBlock.java -@@ -126,7 +_,7 @@ +@@ -142,7 +_,7 @@ boolean flag = false; if (i >= 5) { Item item = p_316844_.getItem(); diff --git a/patches/net/minecraft/world/level/block/BigDripleafBlock.java.patch b/patches/net/minecraft/world/level/block/BigDripleafBlock.java.patch index 909353ce..a95895aa 100644 --- a/patches/net/minecraft/world/level/block/BigDripleafBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BigDripleafBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BigDripleafBlock.java +++ b/net/minecraft/world/level/block/BigDripleafBlock.java -@@ -146,6 +_,8 @@ +@@ -148,6 +_,8 @@ protected boolean canSurvive(BlockState p_152289_, LevelReader p_152290_, BlockPos p_152291_) { BlockPos blockpos = p_152291_.below(); BlockState blockstate = p_152290_.getBlockState(blockpos); diff --git a/patches/net/minecraft/world/level/block/Block.java.patch b/patches/net/minecraft/world/level/block/Block.java.patch index ca575a2e..652a4680 100644 --- a/patches/net/minecraft/world/level/block/Block.java.patch +++ b/patches/net/minecraft/world/level/block/Block.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -61,11 +_,11 @@ +@@ -60,11 +_,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.slf4j.Logger; @@ -14,7 +14,7 @@ private static final LoadingCache SHAPE_FULL_BLOCK_CACHE = CacheBuilder.newBuilder() .maximumSize(512L) .weakKeys() -@@ -186,7 +_,7 @@ +@@ -182,7 +_,7 @@ this.createBlockStateDefinition(builder); this.stateDefinition = builder.create(Block::defaultBlockState, BlockState::new); this.registerDefaultState(this.stateDefinition.any()); @@ -23,16 +23,30 @@ String s = this.getClass().getSimpleName(); if (!s.endsWith("Block")) { LOGGER.error("Block classes should end with Block and {} doesn't.", s); -@@ -208,6 +_,8 @@ - BlockState blockstate = p_152446_.getBlockState(p_152449_); - if (p_152445_.skipRendering(blockstate, p_152448_)) { +@@ -200,12 +_,22 @@ + || p_152464_.is(BlockTags.SHULKER_BOXES); + } + ++ /** ++ * @deprecated Neo: use overload with level context instead ++ */ ++ @Deprecated + public static boolean shouldRenderFace(BlockState p_152445_, BlockState p_361252_, Direction p_152448_) { ++ return shouldRenderFace(net.minecraft.world.level.EmptyBlockGetter.INSTANCE, BlockPos.ZERO, p_152445_, p_361252_, p_152448_); ++ } ++ ++ public static boolean shouldRenderFace(BlockGetter level, BlockPos pos, BlockState p_152445_, BlockState p_361252_, Direction p_152448_) { + VoxelShape voxelshape = p_361252_.getFaceOcclusionShape(p_152448_.getOpposite()); + if (voxelshape == Shapes.block()) { return false; -+ } else if (blockstate.hidesNeighborFace(p_152446_, p_152449_, p_152445_, p_152448_.getOpposite()) && p_152445_.supportsExternalFaceHiding()) { + } else if (p_152445_.skipRendering(p_361252_, p_152448_)) { + return false; ++ } else if (p_361252_.hidesNeighborFace(level, pos.relative(p_152448_), p_152445_, p_152448_.getOpposite()) && p_152445_.supportsExternalFaceHiding()) { + return false; - } else if (blockstate.canOcclude()) { - Block.BlockStatePairKey block$blockstatepairkey = new Block.BlockStatePairKey(p_152445_, blockstate, p_152448_); - Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = OCCLUSION_CACHE.get(); -@@ -281,24 +_,30 @@ + } else if (voxelshape == Shapes.empty()) { + return true; + } else { +@@ -278,24 +_,30 @@ public static void dropResources(BlockState p_49951_, Level p_49952_, BlockPos p_49953_) { if (p_49952_ instanceof ServerLevel) { @@ -67,15 +81,16 @@ } } -@@ -326,19 +_,26 @@ +@@ -323,20 +_,26 @@ } private static void popResource(Level p_152441_, Supplier p_152442_, ItemStack p_152443_) { -- if (!p_152441_.isClientSide && !p_152443_.isEmpty() && p_152441_.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { -+ if (!p_152441_.isClientSide && !p_152443_.isEmpty() && p_152441_.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && !p_152441_.restoringBlockSnapshots) { +- if (p_152441_ instanceof ServerLevel serverlevel && !p_152443_.isEmpty() && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { ++ if (p_152441_ instanceof ServerLevel serverLevel && !p_152443_.isEmpty() && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && !p_152441_.restoringBlockSnapshots) { ItemEntity itementity = p_152442_.get(); itementity.setDefaultPickUpDelay(); - p_152441_.addFreshEntity(itementity); +- return; + // Neo: Add drops to the captured list if capturing is enabled. + if (capturedDrops != null) { + capturedDrops.add(itementity); @@ -97,9 +112,9 @@ public float getExplosionResistance() { return this.explosionResistance; } -@@ -385,8 +_,10 @@ +@@ -375,8 +_,10 @@ - public void updateEntityAfterFallOn(BlockGetter p_49821_, Entity p_49822_) { + public void updateEntityMovementAfterFallOn(BlockGetter p_49821_, Entity p_49822_) { p_49822_.setDeltaMovement(p_49822_.getDeltaMovement().multiply(1.0, 0.0, 1.0)); + p_49822_.setDeltaMovement(p_49822_.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D)); } @@ -108,7 +123,7 @@ public ItemStack getCloneItemStack(LevelReader p_304395_, BlockPos p_49824_, BlockState p_49825_) { return new ItemStack(this); } -@@ -420,6 +_,7 @@ +@@ -410,6 +_,7 @@ public void handlePrecipitation(BlockState p_152450_, Level p_152451_, BlockPos p_152452_, Biome.Precipitation p_152453_) { } @@ -116,7 +131,7 @@ public boolean dropFromExplosion(Explosion p_49826_) { return true; } -@@ -485,6 +_,43 @@ +@@ -475,6 +_,35 @@ return this.stateDefinition.getPossibleStates().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), p_152459_)); } @@ -148,14 +163,6 @@ + return drops; + } + -+ /** -+ * Neo: Allowing mods to define client behavior for their Blocks -+ * @deprecated Use {@link net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent} instead -+ */ -+ @Deprecated(forRemoval = true, since = "1.21") -+ public void initializeClient(java.util.function.Consumer consumer) { -+ } -+ + /** @deprecated */ @Deprecated public Holder.Reference builtInRegistryHolder() { diff --git a/patches/net/minecraft/world/level/block/Blocks.java.patch b/patches/net/minecraft/world/level/block/Blocks.java.patch index 2985e101..c9befa08 100644 --- a/patches/net/minecraft/world/level/block/Blocks.java.patch +++ b/patches/net/minecraft/world/level/block/Blocks.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/Blocks.java +++ b/net/minecraft/world/level/block/Blocks.java -@@ -754,7 +_,7 @@ - public static final Block RED_BED = register("red_bed", bed(DyeColor.RED)); - public static final Block BLACK_BED = register("black_bed", bed(DyeColor.BLACK)); +@@ -690,7 +_,7 @@ + public static final Block RED_BED = registerBed("red_bed", DyeColor.RED); + public static final Block BLACK_BED = registerBed("black_bed", DyeColor.BLACK); public static final Block POWERED_RAIL = register( -- "powered_rail", new PoweredRailBlock(BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL)) -+ "powered_rail", new PoweredRailBlock(BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL), true) +- "powered_rail", PoweredRailBlock::new, BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) ++ "powered_rail", p_55218_ -> new PoweredRailBlock(p_55218_, true), BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) ); public static final Block DETECTOR_RAIL = register( - "detector_rail", new DetectorRailBlock(BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL)) -@@ -7806,7 +_,8 @@ + "detector_rail", DetectorRailBlock::new, BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) +@@ -6919,7 +_,8 @@ static { for (Block block : BuiltInRegistries.BLOCK) { for (BlockState blockstate : block.getStateDefinition().getPossibleStates()) { @@ -18,4 +18,4 @@ + //Block.BLOCK_STATE_REGISTRY.add(blockstate); blockstate.initCache(); } - + } diff --git a/patches/net/minecraft/world/level/block/BubbleColumnBlock.java.patch b/patches/net/minecraft/world/level/block/BubbleColumnBlock.java.patch index 526c55e2..37842d42 100644 --- a/patches/net/minecraft/world/level/block/BubbleColumnBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BubbleColumnBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BubbleColumnBlock.java +++ b/net/minecraft/world/level/block/BubbleColumnBlock.java -@@ -121,10 +_,12 @@ +@@ -122,10 +_,12 @@ private static BlockState getColumnState(BlockState p_152718_) { if (p_152718_.is(Blocks.BUBBLE_COLUMN)) { return p_152718_; @@ -15,7 +15,7 @@ ? Blocks.BUBBLE_COLUMN.defaultBlockState().setValue(DRAG_DOWN, Boolean.valueOf(true)) : Blocks.WATER.defaultBlockState(); } -@@ -190,7 +_,7 @@ +@@ -200,7 +_,7 @@ @Override protected boolean canSurvive(BlockState p_50986_, LevelReader p_50987_, BlockPos p_50988_) { BlockState blockstate = p_50987_.getBlockState(p_50988_.below()); diff --git a/patches/net/minecraft/world/level/block/BushBlock.java.patch b/patches/net/minecraft/world/level/block/BushBlock.java.patch index e1321e50..1a330738 100644 --- a/patches/net/minecraft/world/level/block/BushBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BushBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BushBlock.java +++ b/net/minecraft/world/level/block/BushBlock.java -@@ -20,7 +_,7 @@ +@@ -21,7 +_,7 @@ protected abstract MapCodec codec(); protected boolean mayPlaceOn(BlockState p_51042_, BlockGetter p_51043_, BlockPos p_51044_) { @@ -9,7 +9,7 @@ } @Override -@@ -33,7 +_,10 @@ +@@ -43,7 +_,10 @@ @Override protected boolean canSurvive(BlockState p_51028_, LevelReader p_51029_, BlockPos p_51030_) { BlockPos blockpos = p_51030_.below(); diff --git a/patches/net/minecraft/world/level/block/CactusBlock.java.patch b/patches/net/minecraft/world/level/block/CactusBlock.java.patch index 037a99fb..c4a87b69 100644 --- a/patches/net/minecraft/world/level/block/CactusBlock.java.patch +++ b/patches/net/minecraft/world/level/block/CactusBlock.java.patch @@ -25,7 +25,7 @@ } } } -@@ -99,6 +_,8 @@ +@@ -108,6 +_,8 @@ } BlockState blockstate1 = p_51154_.getBlockState(p_51155_.below()); diff --git a/patches/net/minecraft/world/level/block/CampfireBlock.java.patch b/patches/net/minecraft/world/level/block/CampfireBlock.java.patch index e81ecca3..927f77d8 100644 --- a/patches/net/minecraft/world/level/block/CampfireBlock.java.patch +++ b/patches/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CampfireBlock.java +++ b/net/minecraft/world/level/block/CampfireBlock.java -@@ -279,7 +_,7 @@ +@@ -292,7 +_,7 @@ return true; } diff --git a/patches/net/minecraft/world/level/block/ChestBlock.java.patch b/patches/net/minecraft/world/level/block/ChestBlock.java.patch index 05013391..47e4ad18 100644 --- a/patches/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ChestBlock.java.patch @@ -1,46 +1,6 @@ --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -113,6 +_,39 @@ - } - }; - -+ // CraftBukkit start -+ public static class DoubleInventory implements Container { -+ /* -+ -+ private final ChestBlockEntity tileentitychest; -+ private final ChestBlockEntity tileentitychest1; -+ public final inventorylargechest; -+ -+ public DoubleInventory(ChestBlockEntity tileentitychest, ChestBlockEntity tileentitychest1, InventoryLargeChest inventorylargechest) { -+ this.tileentitychest = tileentitychest; -+ this.tileentitychest1 = tileentitychest1; -+ this.inventorylargechest = inventorylargechest; -+ } -+ -+ @Nullable -+ @Override -+ public Container createMenu(int i, PlayerInventory playerinventory, Player entityhuman) { -+ if (tileentitychest.canOpen(entityhuman) && tileentitychest1.canOpen(entityhuman)) { -+ tileentitychest.unpackLootTable(playerinventory.player); -+ tileentitychest1.unpackLootTable(playerinventory.player); -+ return ContainerChest.sixRows(i, playerinventory, inventorylargechest); -+ } else { -+ return null; -+ } -+ } -+ -+ @Override -+ public Component getDisplayName() { -+ return (Component) (tileentitychest.hasCustomName() ? tileentitychest.getDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getDisplayName() : Component.translatable("container.chestDouble"))); -+ }*/ -+ }; -+ // CraftBukkit end -+ - @Override - public MapCodec codec() { - return CODEC; -@@ -357,7 +_,8 @@ +@@ -365,7 +_,8 @@ @Override protected BlockState mirror(BlockState p_51549_, Mirror p_51550_) { diff --git a/patches/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch b/patches/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch index 7f01cbf3..c9fd63af 100644 --- a/patches/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/ChorusFlowerBlock.java +++ b/net/minecraft/world/level/block/ChorusFlowerBlock.java -@@ -65,10 +_,13 @@ +@@ -66,10 +_,13 @@ BlockPos blockpos = p_220982_.above(); - if (p_220981_.isEmptyBlock(blockpos) && blockpos.getY() < p_220981_.getMaxBuildHeight()) { + if (p_220981_.isEmptyBlock(blockpos) && blockpos.getY() <= p_220981_.getMaxY()) { int i = p_220980_.getValue(AGE); - if (i < 5) { + if (i < 5 && net.neoforged.neoforge.common.CommonHooks.canCropGrow(p_220981_, blockpos, p_220980_, true)) { @@ -15,7 +15,7 @@ if (blockstate.is(Blocks.END_STONE)) { flag = true; } else if (blockstate.is(this.plant)) { -@@ -77,6 +_,8 @@ +@@ -78,6 +_,8 @@ for (int k = 0; k < 4; k++) { BlockState blockstate1 = p_220981_.getBlockState(p_220982_.below(j + 1)); if (!blockstate1.is(this.plant)) { @@ -24,7 +24,7 @@ if (blockstate1.is(Blocks.END_STONE)) { flag1 = true; } -@@ -123,6 +_,7 @@ +@@ -124,6 +_,7 @@ } else { this.placeDeadFlower(p_220981_, p_220982_); } @@ -32,7 +32,7 @@ } } } -@@ -159,6 +_,8 @@ +@@ -169,6 +_,8 @@ @Override protected boolean canSurvive(BlockState p_51683_, LevelReader p_51684_, BlockPos p_51685_) { BlockState blockstate = p_51684_.getBlockState(p_51685_.below()); diff --git a/patches/net/minecraft/world/level/block/ChorusPlantBlock.java.patch b/patches/net/minecraft/world/level/block/ChorusPlantBlock.java.patch index d01ed837..5c9b256f 100644 --- a/patches/net/minecraft/world/level/block/ChorusPlantBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ChorusPlantBlock.java.patch @@ -10,12 +10,12 @@ .trySetValue(UP, Boolean.valueOf(blockstate1.is(block) || blockstate1.is(Blocks.CHORUS_FLOWER))) .trySetValue(NORTH, Boolean.valueOf(blockstate2.is(block) || blockstate2.is(Blocks.CHORUS_FLOWER))) .trySetValue(EAST, Boolean.valueOf(blockstate3.is(block) || blockstate3.is(Blocks.CHORUS_FLOWER))) -@@ -64,6 +_,12 @@ - return super.updateShape(p_51728_, p_51729_, p_51730_, p_51731_, p_51732_, p_51733_); +@@ -73,6 +_,12 @@ + return super.updateShape(p_51728_, p_374320_, p_374500_, p_51732_, p_51729_, p_51733_, p_51730_, p_374170_); } else { boolean flag = p_51730_.is(this) || p_51730_.is(Blocks.CHORUS_FLOWER) || p_51729_ == Direction.DOWN && p_51730_.is(Blocks.END_STONE); + if (p_51729_ == Direction.DOWN) { -+ net.neoforged.neoforge.common.util.TriState soilDecision = p_51730_.canSustainPlant(p_51731_, p_51733_.relative(p_51729_), p_51729_.getOpposite(), p_51728_); ++ net.neoforged.neoforge.common.util.TriState soilDecision = p_51730_.canSustainPlant(p_374320_, p_51733_.relative(p_51729_), p_51729_.getOpposite(), p_51728_); + if (!soilDecision.isDefault()) { + flag = soilDecision.isTrue(); + } @@ -23,7 +23,7 @@ return p_51728_.setValue(PROPERTY_BY_DIRECTION.get(p_51729_), Boolean.valueOf(flag)); } } -@@ -95,6 +_,8 @@ +@@ -104,6 +_,8 @@ } } diff --git a/patches/net/minecraft/world/level/block/ComparatorBlock.java.patch b/patches/net/minecraft/world/level/block/ComparatorBlock.java.patch index c8fc8917..82dbe7fe 100644 --- a/patches/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ComparatorBlock.java +++ b/net/minecraft/world/level/block/ComparatorBlock.java -@@ -199,4 +_,16 @@ +@@ -207,4 +_,17 @@ protected void createBlockStateDefinition(StateDefinition.Builder p_51887_) { p_51887_.add(FACING, MODE, POWERED); } @@ -11,9 +11,10 @@ + } + + @Override -+ public void onNeighborChange(BlockState state, net.minecraft.world.level.LevelReader world, BlockPos pos, BlockPos neighbor) { -+ if (pos.getY() == neighbor.getY() && world instanceof Level && !((Level)world).isClientSide()) { -+ state.handleNeighborChanged((Level)world, pos, world.getBlockState(neighbor).getBlock(), neighbor, false); ++ public void onNeighborChange(BlockState state, net.minecraft.world.level.LevelReader levelReader, BlockPos pos, BlockPos neighbor) { ++ if (pos.getY() == neighbor.getY() && levelReader instanceof Level level && !levelReader.isClientSide()) { ++ // TODO porting: check this still works as expected ++ state.handleNeighborChanged(level, pos, levelReader.getBlockState(neighbor).getBlock(), null, false); + } + } } diff --git a/patches/net/minecraft/world/level/block/ComposterBlock.java.patch b/patches/net/minecraft/world/level/block/ComposterBlock.java.patch index 9a3dc818..5d1d96dd 100644 --- a/patches/net/minecraft/world/level/block/ComposterBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ComposterBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ComposterBlock.java +++ b/net/minecraft/world/level/block/ComposterBlock.java -@@ -48,6 +_,8 @@ +@@ -47,6 +_,8 @@ public static final int MIN_LEVEL = 0; public static final int MAX_LEVEL = 7; public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL_COMPOSTER; @@ -9,7 +9,7 @@ public static final Object2FloatMap COMPOSTABLES = new Object2FloatOpenHashMap<>(); private static final int AABB_SIDE_THICKNESS = 2; private static final VoxelShape OUTER_SHAPE = Shapes.block(); -@@ -227,6 +_,15 @@ +@@ -231,6 +_,15 @@ if (p_51978_.getValue(LEVEL) == 7) { p_51979_.scheduleTick(p_51980_, p_51978_.getBlock(), 20); } @@ -25,7 +25,7 @@ } @Override -@@ -234,7 +_,7 @@ +@@ -238,7 +_,7 @@ ItemStack p_316332_, BlockState p_316118_, Level p_316624_, BlockPos p_316660_, Player p_316715_, InteractionHand p_316472_, BlockHitResult p_316606_ ) { int i = p_316118_.getValue(LEVEL); @@ -34,7 +34,7 @@ if (i < 7 && !p_316624_.isClientSide) { BlockState blockstate = addItem(p_316715_, p_316118_, p_316624_, p_316660_, p_316332_); p_316624_.levelEvent(1500, p_316660_, p_316118_ != blockstate ? 1 : 0); -@@ -261,7 +_,7 @@ +@@ -265,7 +_,7 @@ public static BlockState insertItem(Entity p_270919_, BlockState p_270087_, ServerLevel p_270284_, ItemStack p_270253_, BlockPos p_270678_) { int i = p_270087_.getValue(LEVEL); @@ -43,7 +43,7 @@ BlockState blockstate = addItem(p_270919_, p_270087_, p_270284_, p_270678_, p_270253_); p_270253_.shrink(1); return blockstate; -@@ -292,7 +_,7 @@ +@@ -296,7 +_,7 @@ static BlockState addItem(@Nullable Entity p_270464_, BlockState p_270603_, LevelAccessor p_270151_, BlockPos p_270547_, ItemStack p_270354_) { int i = p_270603_.getValue(LEVEL); @@ -52,7 +52,7 @@ if ((i != 0 || !(f > 0.0F)) && !(p_270151_.getRandom().nextDouble() < (double)f)) { return p_270603_; } else { -@@ -392,7 +_,7 @@ +@@ -396,7 +_,7 @@ @Override public boolean canPlaceItemThroughFace(int p_52028_, ItemStack p_52029_, @Nullable Direction p_52030_) { @@ -61,7 +61,7 @@ } @Override -@@ -450,5 +_,11 @@ +@@ -454,5 +_,11 @@ ComposterBlock.empty(null, this.state, this.level, this.pos); this.changed = true; } diff --git a/patches/net/minecraft/world/level/block/ConcretePowderBlock.java.patch b/patches/net/minecraft/world/level/block/ConcretePowderBlock.java.patch index 30355c02..9254fe66 100644 --- a/patches/net/minecraft/world/level/block/ConcretePowderBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ConcretePowderBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ConcretePowderBlock.java +++ b/net/minecraft/world/level/block/ConcretePowderBlock.java -@@ -34,7 +_,7 @@ +@@ -36,7 +_,7 @@ @Override public void onLand(Level p_52068_, BlockPos p_52069_, BlockState p_52070_, BlockState p_52071_, FallingBlockEntity p_52072_) { @@ -9,7 +9,7 @@ p_52068_.setBlock(p_52069_, this.concrete.defaultBlockState(), 3); } } -@@ -47,20 +_,24 @@ +@@ -49,20 +_,24 @@ return shouldSolidify(blockgetter, blockpos, blockstate) ? this.concrete.defaultBlockState() : super.getStateForPlacement(p_52063_); } @@ -38,12 +38,12 @@ flag = true; break; } -@@ -76,7 +_,7 @@ - - @Override - protected BlockState updateShape(BlockState p_52074_, Direction p_52075_, BlockState p_52076_, LevelAccessor p_52077_, BlockPos p_52078_, BlockPos p_52079_) { -- return touchesLiquid(p_52077_, p_52078_) -+ return touchesLiquid(p_52077_, p_52078_, p_52074_) +@@ -87,7 +_,7 @@ + BlockState p_52076_, + RandomSource p_374119_ + ) { +- return touchesLiquid(p_374245_, p_52078_) ++ return touchesLiquid(p_374245_, p_52078_, p_52074_) ? this.concrete.defaultBlockState() - : super.updateShape(p_52074_, p_52075_, p_52076_, p_52077_, p_52078_, p_52079_); + : super.updateShape(p_52074_, p_374245_, p_374286_, p_52078_, p_52075_, p_52079_, p_52076_, p_374119_); } diff --git a/patches/net/minecraft/world/level/block/CoralBlock.java.patch b/patches/net/minecraft/world/level/block/CoralBlock.java.patch index 5a1ed63e..ea6a1bed 100644 --- a/patches/net/minecraft/world/level/block/CoralBlock.java.patch +++ b/patches/net/minecraft/world/level/block/CoralBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CoralBlock.java +++ b/net/minecraft/world/level/block/CoralBlock.java -@@ -51,9 +_,10 @@ +@@ -61,9 +_,10 @@ } protected boolean scanForWater(BlockGetter p_52135_, BlockPos p_52136_) { diff --git a/patches/net/minecraft/world/level/block/CrafterBlock.java.patch b/patches/net/minecraft/world/level/block/CrafterBlock.java.patch index ac39be32..a80e470e 100644 --- a/patches/net/minecraft/world/level/block/CrafterBlock.java.patch +++ b/patches/net/minecraft/world/level/block/CrafterBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java -@@ -221,6 +_,8 @@ +@@ -214,6 +_,8 @@ break; } } diff --git a/patches/net/minecraft/world/level/block/CropBlock.java.patch b/patches/net/minecraft/world/level/block/CropBlock.java.patch index e00cad50..f947ffdb 100644 --- a/patches/net/minecraft/world/level/block/CropBlock.java.patch +++ b/patches/net/minecraft/world/level/block/CropBlock.java.patch @@ -62,8 +62,8 @@ @Override protected void entityInside(BlockState p_52277_, Level p_52278_, BlockPos p_52279_, Entity p_52280_) { -- if (p_52280_ instanceof Ravager && p_52278_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (p_52280_ instanceof Ravager && net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_52278_, p_52280_)) { - p_52278_.destroyBlock(p_52279_, true, p_52280_); +- if (p_52278_ instanceof ServerLevel serverlevel && p_52280_ instanceof Ravager && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (p_52278_ instanceof ServerLevel serverlevel && p_52280_ instanceof Ravager && net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, p_52280_)) { + serverlevel.destroyBlock(p_52279_, true, p_52280_); } diff --git a/patches/net/minecraft/world/level/block/DetectorRailBlock.java.patch b/patches/net/minecraft/world/level/block/DetectorRailBlock.java.patch index bccb3636..37e40454 100644 --- a/patches/net/minecraft/world/level/block/DetectorRailBlock.java.patch +++ b/patches/net/minecraft/world/level/block/DetectorRailBlock.java.patch @@ -11,19 +11,6 @@ this.registerDefaultState( this.stateDefinition .any() -@@ -152,9 +_,9 @@ - return list.get(0).getCommandBlock().getSuccessCount(); - } - -- List list1 = this.getInteractingMinecartOfType( -- p_52455_, p_52456_, AbstractMinecart.class, EntitySelector.CONTAINER_ENTITY_SELECTOR -- ); -+ List carts = this.getInteractingMinecartOfType(p_52455_, p_52456_, AbstractMinecart.class, e -> e.isAlive()); -+ if (!carts.isEmpty() && carts.get(0).getComparatorLevel() > -1) return carts.get(0).getComparatorLevel(); -+ List list1 = carts.stream().filter(EntitySelector.CONTAINER_ENTITY_SELECTOR).collect(java.util.stream.Collectors.toList()); - if (!list1.isEmpty()) { - return AbstractContainerMenu.getRedstoneSignalFromContainer((Container)list1.get(0)); - } @@ -299,6 +_,6 @@ @Override diff --git a/patches/net/minecraft/world/level/block/DiodeBlock.java.patch b/patches/net/minecraft/world/level/block/DiodeBlock.java.patch index 13cfbf4a..50271b65 100644 --- a/patches/net/minecraft/world/level/block/DiodeBlock.java.patch +++ b/patches/net/minecraft/world/level/block/DiodeBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/DiodeBlock.java +++ b/net/minecraft/world/level/block/DiodeBlock.java -@@ -173,6 +_,8 @@ +@@ -176,6 +_,8 @@ protected void updateNeighborsInFront(Level p_52581_, BlockPos p_52582_, BlockState p_52583_) { Direction direction = p_52583_.getValue(FACING); BlockPos blockpos = p_52582_.relative(direction.getOpposite()); + if (net.neoforged.neoforge.event.EventHooks.onNeighborNotify(p_52581_, p_52582_, p_52581_.getBlockState(p_52582_), java.util.EnumSet.of(direction.getOpposite()), false).isCanceled()) + return; - p_52581_.neighborChanged(blockpos, this, p_52582_); - p_52581_.updateNeighborsAtExceptFromFacing(blockpos, this, direction); - } + Orientation orientation = ExperimentalRedstoneUtils.initialOrientation(p_52581_, direction.getOpposite(), Direction.UP); + p_52581_.neighborChanged(blockpos, this, orientation); + p_52581_.updateNeighborsAtExceptFromFacing(blockpos, this, direction, orientation); diff --git a/patches/net/minecraft/world/level/block/DoorBlock.java.patch b/patches/net/minecraft/world/level/block/DoorBlock.java.patch index 2c444805..bd91c16f 100644 --- a/patches/net/minecraft/world/level/block/DoorBlock.java.patch +++ b/patches/net/minecraft/world/level/block/DoorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoorBlock.java +++ b/net/minecraft/world/level/block/DoorBlock.java -@@ -119,7 +_,7 @@ +@@ -132,7 +_,7 @@ @Override public BlockState playerWillDestroy(Level p_52755_, BlockPos p_52756_, BlockState p_52757_, Player p_52758_) { diff --git a/patches/net/minecraft/world/level/block/DoublePlantBlock.java.patch b/patches/net/minecraft/world/level/block/DoublePlantBlock.java.patch index edfa73df..b9261ddc 100644 --- a/patches/net/minecraft/world/level/block/DoublePlantBlock.java.patch +++ b/patches/net/minecraft/world/level/block/DoublePlantBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoublePlantBlock.java +++ b/net/minecraft/world/level/block/DoublePlantBlock.java -@@ -71,6 +_,7 @@ +@@ -80,6 +_,7 @@ return super.canSurvive(p_52887_, p_52888_, p_52889_); } else { BlockState blockstate = p_52888_.getBlockState(p_52889_.below()); diff --git a/patches/net/minecraft/world/level/block/FarmBlock.java.patch b/patches/net/minecraft/world/level/block/FarmBlock.java.patch index 7b5c19bf..72f3a0e0 100644 --- a/patches/net/minecraft/world/level/block/FarmBlock.java.patch +++ b/patches/net/minecraft/world/level/block/FarmBlock.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/level/block/FarmBlock.java +++ b/net/minecraft/world/level/block/FarmBlock.java -@@ -100,10 +_,7 @@ +@@ -109,10 +_,7 @@ @Override public void fallOn(Level p_153227_, BlockState p_153228_, BlockPos p_153229_, Entity p_153230_, float p_153231_) { - if (!p_153227_.isClientSide + if (p_153227_ instanceof ServerLevel serverlevel - && p_153227_.random.nextFloat() < p_153231_ - 0.5F - && p_153230_ instanceof LivingEntity -- && (p_153230_ instanceof Player || p_153227_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) +- && (p_153230_ instanceof Player || serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) - && p_153230_.getBbWidth() * p_153230_.getBbWidth() * p_153230_.getBbHeight() > 0.512F) { -+ && net.neoforged.neoforge.common.CommonHooks.onFarmlandTrample(p_153227_, p_153229_, Blocks.DIRT.defaultBlockState(), p_153231_, p_153230_)) { // Forge: Move logic to Entity#canTrample ++ && net.neoforged.neoforge.common.CommonHooks.onFarmlandTrample(serverlevel, p_153229_, Blocks.DIRT.defaultBlockState(), p_153231_, p_153230_)) { // Forge: Move logic to Entity#canTrample turnToDirt(p_153230_, p_153228_, p_153227_, p_153229_); } -@@ -121,13 +_,14 @@ +@@ -130,13 +_,14 @@ } private static boolean isNearWater(LevelReader p_53259_, BlockPos p_53260_) { diff --git a/patches/net/minecraft/world/level/block/FenceGateBlock.java.patch b/patches/net/minecraft/world/level/block/FenceGateBlock.java.patch index e31aaf5e..042b0ecf 100644 --- a/patches/net/minecraft/world/level/block/FenceGateBlock.java.patch +++ b/patches/net/minecraft/world/level/block/FenceGateBlock.java.patch @@ -1,17 +1,19 @@ --- a/net/minecraft/world/level/block/FenceGateBlock.java +++ b/net/minecraft/world/level/block/FenceGateBlock.java -@@ -31,7 +_,9 @@ +@@ -36,8 +_,10 @@ public class FenceGateBlock extends HorizontalDirectionalBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( -- p_308823_ -> p_308823_.group(WoodType.CODEC.fieldOf("wood_type").forGetter(p_304842_ -> p_304842_.type), propertiesCodec()) +- p_368422_ -> p_368422_.group(WoodType.CODEC.fieldOf("wood_type").forGetter(p_304842_ -> p_304842_.type), propertiesCodec()) +- .apply(p_368422_, FenceGateBlock::new) + p_308823_ -> p_308823_.group(WoodType.CODEC.optionalFieldOf("wood_type").forGetter(p_304842_ -> java.util.Optional.ofNullable(p_304842_.type)), propertiesCodec(), + net.minecraft.sounds.SoundEvent.DIRECT_CODEC.optionalFieldOf("open_sound").forGetter(fence -> java.util.Optional.of(fence.openSound).filter(s -> fence.type == null || s != fence.type.fenceGateOpen())), + net.minecraft.sounds.SoundEvent.DIRECT_CODEC.optionalFieldOf("close_sound").forGetter(fence -> java.util.Optional.of(fence.closeSound).filter(s -> fence.type == null || s != fence.type.fenceGateClose()))) - .apply(p_308823_, FenceGateBlock::new) ++ .apply(p_308823_, FenceGateBlock::new) ); public static final BooleanProperty OPEN = BlockStateProperties.OPEN; -@@ -49,6 +_,8 @@ + public static final BooleanProperty POWERED = BlockStateProperties.POWERED; +@@ -54,6 +_,8 @@ protected static final VoxelShape X_OCCLUSION_SHAPE = Shapes.or(Block.box(7.0, 5.0, 0.0, 9.0, 16.0, 2.0), Block.box(7.0, 5.0, 14.0, 9.0, 16.0, 16.0)); protected static final VoxelShape Z_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(0.0, 2.0, 7.0, 2.0, 13.0, 9.0), Block.box(14.0, 2.0, 7.0, 16.0, 13.0, 9.0)); protected static final VoxelShape X_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(7.0, 2.0, 0.0, 9.0, 13.0, 2.0), Block.box(7.0, 2.0, 14.0, 9.0, 13.0, 16.0)); @@ -20,7 +22,7 @@ private final WoodType type; @Override -@@ -57,8 +_,17 @@ +@@ -62,8 +_,17 @@ } public FenceGateBlock(WoodType p_273340_, BlockBehaviour.Properties p_273352_) { @@ -40,7 +42,7 @@ this.registerDefaultState( this.stateDefinition .any() -@@ -169,7 +_,7 @@ +@@ -183,7 +_,7 @@ p_53366_.playSound( p_53368_, p_53367_, @@ -49,16 +51,16 @@ SoundSource.BLOCKS, 1.0F, p_53366_.getRandom().nextFloat() * 0.1F + 0.9F -@@ -186,7 +_,7 @@ - p_311813_.playSound( +@@ -202,7 +_,7 @@ + p_361116_.playSound( null, p_312680_, - flag ? this.type.fenceGateClose() : this.type.fenceGateOpen(), + flag ? closeSound : openSound, SoundSource.BLOCKS, 1.0F, - p_311813_.getRandom().nextFloat() * 0.1F + 0.9F -@@ -207,7 +_,7 @@ + p_361116_.getRandom().nextFloat() * 0.1F + 0.9F +@@ -223,7 +_,7 @@ p_53373_.playSound( null, p_53374_, diff --git a/patches/net/minecraft/world/level/block/FireBlock.java.patch b/patches/net/minecraft/world/level/block/FireBlock.java.patch index 0e6d1d83..1b005e4d 100644 --- a/patches/net/minecraft/world/level/block/FireBlock.java.patch +++ b/patches/net/minecraft/world/level/block/FireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FireBlock.java +++ b/net/minecraft/world/level/block/FireBlock.java -@@ -132,13 +_,13 @@ +@@ -141,13 +_,13 @@ protected BlockState getStateForPlacement(BlockGetter p_53471_, BlockPos p_53472_) { BlockPos blockpos = p_53472_.below(); BlockState blockstate = p_53471_.getBlockState(blockpos); @@ -16,7 +16,7 @@ } } -@@ -163,7 +_,7 @@ +@@ -172,7 +_,7 @@ } BlockState blockstate = p_221161_.getBlockState(p_221162_.below()); @@ -25,7 +25,7 @@ int i = p_221160_.getValue(AGE); if (!flag && p_221161_.isRaining() && this.isNearRain(p_221161_, p_221162_) && p_221163_.nextFloat() < 0.2F + (float)i * 0.03F) { p_221161_.removeBlock(p_221162_, false); -@@ -184,7 +_,7 @@ +@@ -193,7 +_,7 @@ return; } @@ -34,7 +34,7 @@ p_221161_.removeBlock(p_221162_, false); return; } -@@ -192,12 +_,12 @@ +@@ -201,12 +_,12 @@ boolean flag1 = p_221161_.getBiome(p_221162_).is(BiomeTags.INCREASED_FIRE_BURNOUT); int k = flag1 ? -50 : 0; @@ -53,7 +53,7 @@ BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int l = -1; l <= 1; l++) { -@@ -240,33 +_,32 @@ +@@ -249,33 +_,32 @@ || p_53429_.isRainingAt(p_53430_.south()); } @@ -93,7 +93,7 @@ } } -@@ -277,7 +_,7 @@ +@@ -286,7 +_,7 @@ private boolean isValidFireLocation(BlockGetter p_53486_, BlockPos p_53487_) { for (Direction direction : Direction.values()) { @@ -102,7 +102,7 @@ return true; } } -@@ -293,7 +_,7 @@ +@@ -302,7 +_,7 @@ for (Direction direction : Direction.values()) { BlockState blockstate = p_221157_.getBlockState(p_221158_.relative(direction)); @@ -111,7 +111,7 @@ } return i; -@@ -301,6 +_,7 @@ +@@ -310,6 +_,7 @@ } @Override @@ -119,7 +119,7 @@ protected boolean canBurn(BlockState p_53489_) { return this.getIgniteOdds(p_53489_) > 0; } -@@ -321,8 +_,21 @@ +@@ -330,8 +_,21 @@ } public void setFlammable(Block p_53445_, int p_53446_, int p_53447_) { diff --git a/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch index e2a75a86..ce68c441 100644 --- a/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -59,9 +59,9 @@ - p_316655_.setBlock(p_316654_, Blocks.FLOWER_POT.defaultBlockState(), 3); + p_316655_.setBlock(p_316654_, getEmptyPot().defaultBlockState(), 3); p_316655_.gameEvent(p_316338_, GameEvent.BLOCK_CHANGE, p_316654_); - return InteractionResult.sidedSuccess(p_316655_.isClientSide); + return InteractionResult.SUCCESS; } -@@ -107,11 +_,44 @@ +@@ -116,11 +_,44 @@ } public Block getPotted() { diff --git a/patches/net/minecraft/world/level/block/LeavesBlock.java.patch b/patches/net/minecraft/world/level/block/LeavesBlock.java.patch index b086bca9..7807a016 100644 --- a/patches/net/minecraft/world/level/block/LeavesBlock.java.patch +++ b/patches/net/minecraft/world/level/block/LeavesBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LeavesBlock.java +++ b/net/minecraft/world/level/block/LeavesBlock.java -@@ -24,7 +_,7 @@ +@@ -26,7 +_,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; diff --git a/patches/net/minecraft/world/level/block/LiquidBlock.java.patch b/patches/net/minecraft/world/level/block/LiquidBlock.java.patch index bc1dea49..5d6aea4b 100644 --- a/patches/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/patches/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java -@@ -134,7 +_,7 @@ +@@ -137,7 +_,7 @@ @Override protected void onPlace(BlockState p_54754_, Level p_54755_, BlockPos p_54756_, BlockState p_54757_, boolean p_54758_) { @@ -9,10 +9,10 @@ p_54755_.scheduleTick(p_54756_, p_54754_.getFluidState().getType(), this.fluid.getTickDelay(p_54755_)); } } -@@ -150,11 +_,12 @@ +@@ -162,11 +_,12 @@ @Override - protected void neighborChanged(BlockState p_54709_, Level p_54710_, BlockPos p_54711_, Block p_54712_, BlockPos p_54713_, boolean p_54714_) { + protected void neighborChanged(BlockState p_54709_, Level p_54710_, BlockPos p_54711_, Block p_54712_, @Nullable Orientation p_361226_, boolean p_54714_) { - if (this.shouldSpreadLiquid(p_54710_, p_54711_, p_54709_)) { + if (!net.neoforged.neoforge.fluids.FluidInteractionRegistry.canInteract(p_54710_, p_54711_)) { p_54710_.scheduleTick(p_54711_, p_54709_.getFluidState().getType(), this.fluid.getTickDelay(p_54710_)); diff --git a/patches/net/minecraft/world/level/block/MushroomBlock.java.patch b/patches/net/minecraft/world/level/block/MushroomBlock.java.patch index a977b185..6283cb27 100644 --- a/patches/net/minecraft/world/level/block/MushroomBlock.java.patch +++ b/patches/net/minecraft/world/level/block/MushroomBlock.java.patch @@ -13,8 +13,8 @@ public boolean growMushroom(ServerLevel p_221774_, BlockPos p_221775_, BlockState p_221776_, RandomSource p_221777_) { Optional>> optional = p_221774_.registryAccess() - .registryOrThrow(Registries.CONFIGURED_FEATURE) - .getHolder(this.feature); + .lookupOrThrow(Registries.CONFIGURED_FEATURE) + .get(this.feature); + + // Neo: Fire the BlockGrowFeatureEvent and update the result of the Optional local with the new feature. + var event = net.neoforged.neoforge.event.EventHooks.fireBlockGrowFeature(p_221774_, p_221777_, p_221775_, optional.orElse(null)); diff --git a/patches/net/minecraft/world/level/block/NoteBlock.java.patch b/patches/net/minecraft/world/level/block/NoteBlock.java.patch index 5c0e59db..9c9392db 100644 --- a/patches/net/minecraft/world/level/block/NoteBlock.java.patch +++ b/patches/net/minecraft/world/level/block/NoteBlock.java.patch @@ -1,17 +1,16 @@ --- a/net/minecraft/world/level/block/NoteBlock.java +++ b/net/minecraft/world/level/block/NoteBlock.java -@@ -110,7 +_,9 @@ - if (p_316774_.isClientSide) { - return InteractionResult.SUCCESS; - } else { -- p_316441_ = p_316441_.cycle(NOTE); +@@ -122,6 +_,9 @@ + protected InteractionResult useWithoutItem(BlockState p_316441_, Level p_316774_, BlockPos p_316344_, Player p_316884_, BlockHitResult p_316631_) { + if (!p_316774_.isClientSide) { + p_316441_ = p_316441_.cycle(NOTE); + int _new = net.neoforged.neoforge.common.CommonHooks.onNoteChange(p_316774_, p_316344_, p_316441_, p_316441_.getValue(NOTE), p_316441_.cycle(NOTE).getValue(NOTE)); + if (_new == -1) return InteractionResult.FAIL; + p_316441_ = p_316441_.setValue(NOTE, _new); p_316774_.setBlock(p_316344_, p_316441_, 3); this.playNote(p_316884_, p_316441_, p_316774_, p_316344_); p_316884_.awardStat(Stats.TUNE_NOTEBLOCK); -@@ -132,6 +_,9 @@ +@@ -144,6 +_,9 @@ @Override protected boolean triggerEvent(BlockState p_55023_, Level p_55024_, BlockPos p_55025_, int p_55026_, int p_55027_) { diff --git a/patches/net/minecraft/world/level/block/PitcherCropBlock.java.patch b/patches/net/minecraft/world/level/block/PitcherCropBlock.java.patch index b38b96d4..f3be3ce2 100644 --- a/patches/net/minecraft/world/level/block/PitcherCropBlock.java.patch +++ b/patches/net/minecraft/world/level/block/PitcherCropBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PitcherCropBlock.java +++ b/net/minecraft/world/level/block/PitcherCropBlock.java -@@ -86,12 +_,13 @@ +@@ -93,12 +_,13 @@ @Override public boolean canSurvive(BlockState p_277671_, LevelReader p_277477_, BlockPos p_278085_) { @@ -16,7 +16,7 @@ } @Override -@@ -125,7 +_,7 @@ +@@ -132,7 +_,7 @@ @Override public void randomTick(BlockState p_277950_, ServerLevel p_277589_, BlockPos p_277937_, RandomSource p_277887_) { diff --git a/patches/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch b/patches/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch index 433f12e7..4ba64c1b 100644 --- a/patches/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch +++ b/patches/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java -@@ -184,7 +_,7 @@ +@@ -192,7 +_,7 @@ @VisibleForTesting public static void maybeTransferFluid(BlockState p_221860_, ServerLevel p_221861_, BlockPos p_221862_, float p_221863_) { @@ -9,7 +9,7 @@ if (isStalactiteStartPos(p_221860_, p_221861_, p_221862_)) { Optional optional = getFluidAboveStalactite(p_221861_, p_221862_, p_221860_); if (!optional.isEmpty()) { -@@ -193,14 +_,12 @@ +@@ -201,14 +_,12 @@ if (fluid == Fluids.WATER) { f = 0.17578125F; } else { @@ -26,7 +26,7 @@ BlockPos blockpos = findTip(p_221860_, p_221861_, p_221862_, 11, false); if (blockpos != null) { if (optional.get().sourceState.is(Blocks.MUD) && fluid == Fluids.WATER) { -@@ -411,7 +_,8 @@ +@@ -419,7 +_,8 @@ double d2 = (double)((float)(p_154073_.getY() + 1) - 0.6875F) - 0.0625; double d3 = (double)p_154073_.getZ() + 0.5 + vec3.z; Fluid fluid = getDripFluid(p_154072_, p_154075_); @@ -36,7 +36,7 @@ p_154072_.addParticle(particleoptions, d1, d2, d3, 0.0, 0.0, 0.0); } -@@ -563,7 +_,7 @@ +@@ -571,7 +_,7 @@ } private static boolean canFillCauldron(Fluid p_154159_) { diff --git a/patches/net/minecraft/world/level/block/PowderSnowBlock.java.patch b/patches/net/minecraft/world/level/block/PowderSnowBlock.java.patch index 29c7e6ca..923d5b94 100644 --- a/patches/net/minecraft/world/level/block/PowderSnowBlock.java.patch +++ b/patches/net/minecraft/world/level/block/PowderSnowBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PowderSnowBlock.java +++ b/net/minecraft/world/level/block/PowderSnowBlock.java -@@ -130,7 +_,7 @@ +@@ -126,7 +_,7 @@ if (p_154256_.getType().is(EntityTypeTags.POWDER_SNOW_WALKABLE_MOBS)) { return true; } else { diff --git a/patches/net/minecraft/world/level/block/PoweredRailBlock.java.patch b/patches/net/minecraft/world/level/block/PoweredRailBlock.java.patch index 7e5da26d..e0a519f6 100644 --- a/patches/net/minecraft/world/level/block/PoweredRailBlock.java.patch +++ b/patches/net/minecraft/world/level/block/PoweredRailBlock.java.patch @@ -25,7 +25,7 @@ int k = p_55221_.getZ(); boolean flag = true; - RailShape railshape = p_55222_.getValue(SHAPE); -+ RailShape railshape = p_55222_.getValue(getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)p_55222_.getBlock()).getRailDirection(p_55222_, p_55220_, p_55221_, null); switch (railshape) { case NORTH_SOUTH: if (p_55223_) { @@ -56,8 +56,8 @@ if (flag1 != flag) { p_55233_.setBlock(p_55234_, p_55232_.setValue(POWERED, Boolean.valueOf(flag1)), 3); p_55233_.updateNeighborsAt(p_55234_.below(), this); -- if (p_55232_.getValue(SHAPE).isAscending()) { -+ if (p_55232_.getValue(getShapeProperty()).isAscending()) { +- if (p_55232_.getValue(SHAPE).isSlope()) { ++ if (((BaseRailBlock)p_55232_.getBlock()).getRailDirection(p_55232_, p_55233_, p_55234_, null).isSlope()) { p_55233_.updateNeighborsAt(p_55234_.above(), this); } } diff --git a/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch b/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch index 64546ae9..6c99c628 100644 --- a/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch +++ b/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/PumpkinBlock.java +++ b/net/minecraft/world/level/block/PumpkinBlock.java @@ -35,7 +_,7 @@ - protected ItemInteractionResult useItemOn( + protected InteractionResult useItemOn( ItemStack p_316383_, BlockState p_316676_, Level p_316272_, BlockPos p_316484_, Player p_316367_, InteractionHand p_316216_, BlockHitResult p_316827_ ) { - if (!p_316383_.is(Items.SHEARS)) { + if (!p_316383_.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHEARS_CARVE)) { return super.useItemOn(p_316383_, p_316676_, p_316272_, p_316484_, p_316367_, p_316216_, p_316827_); } else if (p_316272_.isClientSide) { - return ItemInteractionResult.sidedSuccess(p_316272_.isClientSide); + return InteractionResult.SUCCESS; diff --git a/patches/net/minecraft/world/level/block/RedStoneWireBlock.java.patch b/patches/net/minecraft/world/level/block/RedStoneWireBlock.java.patch index 79ce4b3f..1e9a7cfc 100644 --- a/patches/net/minecraft/world/level/block/RedStoneWireBlock.java.patch +++ b/patches/net/minecraft/world/level/block/RedStoneWireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -253,7 +_,7 @@ +@@ -268,7 +_,7 @@ BlockState blockstate = p_55523_.getBlockState(blockpos); if (p_55526_) { boolean flag = blockstate.getBlock() instanceof TrapDoorBlock || this.canSurviveOn(p_55523_, blockpos, blockstate); @@ -9,7 +9,7 @@ if (blockstate.isFaceSturdy(p_55523_, blockpos, p_55525_.getOpposite())) { return RedstoneSide.UP; } -@@ -262,10 +_,14 @@ +@@ -277,10 +_,14 @@ } } diff --git a/patches/net/minecraft/world/level/block/SculkSensorBlock.java.patch b/patches/net/minecraft/world/level/block/SculkSensorBlock.java.patch index 12f47c32..5aee48d6 100644 --- a/patches/net/minecraft/world/level/block/SculkSensorBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SculkSensorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -291,8 +_,13 @@ +@@ -299,8 +_,13 @@ @Override protected void spawnAfterBreak(BlockState p_222142_, ServerLevel p_222143_, BlockPos p_222144_, ItemStack p_222145_, boolean p_222146_) { super.spawnAfterBreak(p_222142_, p_222143_, p_222144_, p_222145_, p_222146_); diff --git a/patches/net/minecraft/world/level/block/SculkShriekerBlock.java.patch b/patches/net/minecraft/world/level/block/SculkShriekerBlock.java.patch index 6f5dedbc..646554aa 100644 --- a/patches/net/minecraft/world/level/block/SculkShriekerBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SculkShriekerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkShriekerBlock.java +++ b/net/minecraft/world/level/block/SculkShriekerBlock.java -@@ -141,9 +_,14 @@ +@@ -149,9 +_,14 @@ @Override protected void spawnAfterBreak(BlockState p_222192_, ServerLevel p_222193_, BlockPos p_222194_, ItemStack p_222195_, boolean p_222196_) { super.spawnAfterBreak(p_222192_, p_222193_, p_222194_, p_222195_, p_222196_); diff --git a/patches/net/minecraft/world/level/block/SeagrassBlock.java.patch b/patches/net/minecraft/world/level/block/SeagrassBlock.java.patch index a3580320..f596a92b 100644 --- a/patches/net/minecraft/world/level/block/SeagrassBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SeagrassBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SeagrassBlock.java +++ b/net/minecraft/world/level/block/SeagrassBlock.java -@@ -22,7 +_,7 @@ +@@ -23,7 +_,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; diff --git a/patches/net/minecraft/world/level/block/SoundType.java.patch b/patches/net/minecraft/world/level/block/SoundType.java.patch index 005925ab..92c1ab63 100644 --- a/patches/net/minecraft/world/level/block/SoundType.java.patch +++ b/patches/net/minecraft/world/level/block/SoundType.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/SoundType.java +++ b/net/minecraft/world/level/block/SoundType.java -@@ -777,6 +_,7 @@ - public final SoundEvent hitSound; +@@ -789,6 +_,7 @@ + private final SoundEvent hitSound; private final SoundEvent fallSound; + @Deprecated // Forge: Use {@link net.neoforged.neoforge.common.util.DeferredSoundType} instead for suppliers diff --git a/patches/net/minecraft/world/level/block/SpongeBlock.java.patch b/patches/net/minecraft/world/level/block/SpongeBlock.java.patch index 69c47ae1..ac00ddee 100644 --- a/patches/net/minecraft/world/level/block/SpongeBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SpongeBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpongeBlock.java +++ b/net/minecraft/world/level/block/SpongeBlock.java -@@ -49,6 +_,7 @@ +@@ -51,6 +_,7 @@ } private boolean removeWaterBreadthFirstSearch(Level p_56808_, BlockPos p_56809_) { @@ -8,7 +8,7 @@ return BlockPos.breadthFirstTraversal( p_56809_, 6, -@@ -64,7 +_,7 @@ +@@ -66,7 +_,7 @@ } else { BlockState blockstate = p_56808_.getBlockState(p_294069_); FluidState fluidstate = p_56808_.getFluidState(p_294069_); diff --git a/patches/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch b/patches/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch index 2f24cf95..0c7f4162 100644 --- a/patches/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java +++ b/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java -@@ -42,8 +_,10 @@ +@@ -40,8 +_,10 @@ @Override protected void randomTick(BlockState p_222508_, ServerLevel p_222509_, BlockPos p_222510_, RandomSource p_222511_) { if (!canBeGrass(p_222508_, p_222509_, p_222510_)) { diff --git a/patches/net/minecraft/world/level/block/StemBlock.java.patch b/patches/net/minecraft/world/level/block/StemBlock.java.patch index 17d8f22e..f8d64680 100644 --- a/patches/net/minecraft/world/level/block/StemBlock.java.patch +++ b/patches/net/minecraft/world/level/block/StemBlock.java.patch @@ -27,7 +27,7 @@ BlockState blockstate = p_222539_.getBlockState(blockpos.below()); - if (p_222539_.getBlockState(blockpos).isAir() && (blockstate.is(Blocks.FARMLAND) || blockstate.is(BlockTags.DIRT))) { + if (p_222539_.isEmptyBlock(blockpos) && (blockstate.getBlock() instanceof net.minecraft.world.level.block.FarmBlock || blockstate.is(BlockTags.DIRT))) { - Registry registry = p_222539_.registryAccess().registryOrThrow(Registries.BLOCK); + Registry registry = p_222539_.registryAccess().lookupOrThrow(Registries.BLOCK); Optional optional = registry.getOptional(this.fruit); Optional optional1 = registry.getOptional(this.attachedStem); @@ -100,6 +_,7 @@ diff --git a/patches/net/minecraft/world/level/block/SugarCaneBlock.java.patch b/patches/net/minecraft/world/level/block/SugarCaneBlock.java.patch index 55a9cd85..dbf78879 100644 --- a/patches/net/minecraft/world/level/block/SugarCaneBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SugarCaneBlock.java.patch @@ -16,7 +16,7 @@ } } } -@@ -83,13 +_,15 @@ +@@ -92,13 +_,15 @@ if (blockstate.is(this)) { return true; } else { diff --git a/patches/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch b/patches/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch index 934879d9..9abbbc3e 100644 --- a/patches/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SweetBerryBushBlock.java +++ b/net/minecraft/world/level/block/SweetBerryBushBlock.java -@@ -69,9 +_,10 @@ +@@ -68,9 +_,10 @@ @Override protected void randomTick(BlockState p_222563_, ServerLevel p_222564_, BlockPos p_222565_, RandomSource p_222566_) { int i = p_222563_.getValue(AGE); diff --git a/patches/net/minecraft/world/level/block/TntBlock.java.patch b/patches/net/minecraft/world/level/block/TntBlock.java.patch index acf16ed6..eb50b4ce 100644 --- a/patches/net/minecraft/world/level/block/TntBlock.java.patch +++ b/patches/net/minecraft/world/level/block/TntBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TntBlock.java +++ b/net/minecraft/world/level/block/TntBlock.java -@@ -41,10 +_,14 @@ +@@ -43,10 +_,14 @@ } @Override @@ -16,16 +16,16 @@ p_57467_.removeBlock(p_57468_, false); } } -@@ -53,7 +_,7 @@ +@@ -55,7 +_,7 @@ @Override - protected void neighborChanged(BlockState p_57457_, Level p_57458_, BlockPos p_57459_, Block p_57460_, BlockPos p_57461_, boolean p_57462_) { + protected void neighborChanged(BlockState p_57457_, Level p_57458_, BlockPos p_57459_, Block p_57460_, @Nullable Orientation p_364510_, boolean p_57462_) { if (p_57458_.hasNeighborSignal(p_57459_)) { - explode(p_57458_, p_57459_); + onCaughtFire(p_57457_, p_57458_, p_57459_, null, null); p_57458_.removeBlock(p_57459_, false); } } -@@ -61,7 +_,7 @@ +@@ -63,7 +_,7 @@ @Override public BlockState playerWillDestroy(Level p_57445_, BlockPos p_57446_, BlockState p_57447_, Player p_57448_) { if (!p_57445_.isClientSide() && !p_57448_.isCreative() && p_57447_.getValue(UNSTABLE)) { @@ -35,7 +35,7 @@ return super.playerWillDestroy(p_57445_, p_57446_, p_57447_, p_57448_); @@ -79,10 +_,12 @@ - } + p_364953_.addFreshEntity(primedtnt); } + @Deprecated //Forge: Prefer using IForgeBlock#catchFire @@ -59,7 +59,7 @@ @@ -119,7 +_,7 @@ BlockPos blockpos = p_57431_.getBlockPos(); Entity entity = p_57432_.getOwner(); - if (p_57432_.isOnFire() && p_57432_.mayInteract(p_57429_, blockpos)) { + if (p_57432_.isOnFire() && p_57432_.mayInteract(serverlevel, blockpos)) { - explode(p_57429_, blockpos, entity instanceof LivingEntity ? (LivingEntity)entity : null); + onCaughtFire(p_57430_, p_57429_, blockpos, null, entity instanceof LivingEntity ? (LivingEntity)entity : null); p_57429_.removeBlock(blockpos, false); diff --git a/patches/net/minecraft/world/level/block/TrapDoorBlock.java.patch b/patches/net/minecraft/world/level/block/TrapDoorBlock.java.patch index 6fb22ca4..3ebddb6f 100644 --- a/patches/net/minecraft/world/level/block/TrapDoorBlock.java.patch +++ b/patches/net/minecraft/world/level/block/TrapDoorBlock.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/TrapDoorBlock.java +++ b/net/minecraft/world/level/block/TrapDoorBlock.java -@@ -200,6 +_,17 @@ - return super.updateShape(p_57554_, p_57555_, p_57556_, p_57557_, p_57558_, p_57559_); +@@ -215,6 +_,17 @@ + return super.updateShape(p_57554_, p_374386_, p_374038_, p_57558_, p_57555_, p_57559_, p_57556_, p_374093_); } + // Neo: Allows Trapdoors to be climbable if any ladder, even modded ladders, is below Trapdoor diff --git a/patches/net/minecraft/world/level/block/TripWireBlock.java.patch b/patches/net/minecraft/world/level/block/TripWireBlock.java.patch index 1d1fd559..e1bdf7fc 100644 --- a/patches/net/minecraft/world/level/block/TripWireBlock.java.patch +++ b/patches/net/minecraft/world/level/block/TripWireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TripWireBlock.java +++ b/net/minecraft/world/level/block/TripWireBlock.java -@@ -104,7 +_,7 @@ +@@ -114,7 +_,7 @@ @Override public BlockState playerWillDestroy(Level p_57615_, BlockPos p_57616_, BlockState p_57617_, Player p_57618_) { diff --git a/patches/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/patches/net/minecraft/world/level/block/TripWireHookBlock.java.patch deleted file mode 100644 index f06ccb74..00000000 --- a/patches/net/minecraft/world/level/block/TripWireHookBlock.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/level/block/TripWireHookBlock.java -+++ b/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -176,8 +_,8 @@ - BlockPos blockpos2 = p_57687_.relative(direction, k); - BlockState blockstate2 = ablockstate[k]; - if (blockstate2 != null) { -+ if (!p_57686_.getBlockState(blockpos2).isAir()) { // FORGE: fix MC-129055 - p_57686_.setBlock(blockpos2, blockstate2.trySetValue(ATTACHED, Boolean.valueOf(flag2)), 3); -- if (!p_57686_.getBlockState(blockpos2).isAir()) { - } - } - } diff --git a/patches/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/patches/net/minecraft/world/level/block/TurtleEggBlock.java.patch index 3f07d685..d3294faa 100644 --- a/patches/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/patches/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/TurtleEggBlock.java +++ b/net/minecraft/world/level/block/TurtleEggBlock.java -@@ -171,7 +_,7 @@ +@@ -173,7 +_,7 @@ if (p_57769_ instanceof Turtle || p_57769_ instanceof Bat) { return false; } else { -- return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || p_57768_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -+ return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_57768_, p_57769_); +- return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || p_376510_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); ++ return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_376510_, p_57769_); } } } diff --git a/patches/net/minecraft/world/level/block/VineBlock.java.patch b/patches/net/minecraft/world/level/block/VineBlock.java.patch index f83b32be..70537e1e 100644 --- a/patches/net/minecraft/world/level/block/VineBlock.java.patch +++ b/patches/net/minecraft/world/level/block/VineBlock.java.patch @@ -9,7 +9,7 @@ public static final MapCodec CODEC = simpleCodec(VineBlock::new); public static final BooleanProperty UP = PipeBlock.UP; public static final BooleanProperty NORTH = PipeBlock.NORTH; -@@ -183,7 +_,7 @@ +@@ -192,7 +_,7 @@ @Override protected void randomTick(BlockState p_222655_, ServerLevel p_222656_, BlockPos p_222657_, RandomSource p_222658_) { if (p_222656_.getGameRules().getBoolean(GameRules.RULE_DO_VINES_SPREAD)) { diff --git a/patches/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/patches/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index 9b060c11..03bd036a 100644 --- a/patches/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/patches/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -60,6 +_,7 @@ - public static final int NUM_DATA_VALUES = 4; +@@ -54,6 +_,7 @@ public static final int BURN_TIME_STANDARD = 200; public static final int BURN_COOL_SPEED = 2; + public static final int UNKNOWN_LIT_DURATION = 0; + private final RecipeType recipeType; protected NonNullList items = NonNullList.withSize(3, ItemStack.EMPTY); - public int litTime; - int litDuration; -@@ -72,9 +_,14 @@ + int litTime; + int litDuration = 0; +@@ -64,9 +_,14 @@ public int get(int p_58431_) { switch (p_58431_) { case 0: @@ -24,57 +24,15 @@ case 2: return AbstractFurnaceBlockEntity.this.cookingProgress; case 3: -@@ -114,18 +_,40 @@ +@@ -106,6 +_,7 @@ ) { super(p_154991_, p_154992_, p_154993_); this.quickCheck = RecipeManager.createCheck((RecipeType)p_154994_); + this.recipeType = p_154994_; } - public static void invalidateCache() { - fuelCache = null; - } - -+ /** -+ * @deprecated Neo: get burn times by calling {@link net.neoforged.neoforge.common.extensions.IItemStackExtension#getBurnTime(RecipeType)} -+ */ -+ @Deprecated - public static Map getFuel() { - Map map = fuelCache; - if (map != null) { - return map; - } else { - Map map1 = Maps.newLinkedHashMap(); -+ buildFuels((e, time) -> e.ifRight(tag -> add(map1, tag, time)).ifLeft(item -> add(map1, item, time))); -+ fuelCache = map1; -+ return map1; -+ } -+ } -+ -+ private static void add(java.util.function.ObjIntConsumer>> consumer, ItemLike item, int time) { -+ consumer.accept(com.mojang.datafixers.util.Either.left(item.asItem()), time); -+ } -+ -+ private static void add(java.util.function.ObjIntConsumer>> consumer, TagKey tag, int time) { -+ consumer.accept(com.mojang.datafixers.util.Either.right(tag), time); -+ } -+ -+ @org.jetbrains.annotations.ApiStatus.Internal -+ public static void buildFuels(java.util.function.ObjIntConsumer>> map1) { -+ { - add(map1, Items.LAVA_BUCKET, 20000); - add(map1, Blocks.COAL_BLOCK, 16000); - add(map1, Items.BLAZE_ROD, 2400); -@@ -185,8 +_,6 @@ - add(map1, Blocks.AZALEA, 100); - add(map1, Blocks.FLOWERING_AZALEA, 100); - add(map1, Blocks.MANGROVE_ROOTS, 300); -- fuelCache = map1; -- return map1; - } - } - -@@ -226,9 +_,9 @@ + private boolean isLit() { +@@ -117,9 +_,9 @@ super.loadAdditional(p_155025_, p_323468_); this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); ContainerHelper.loadAllItems(p_155025_, this.items, p_323468_); @@ -84,10 +42,10 @@ + this.litTime = p_155025_.getInt("BurnTime"); + this.cookingProgress = p_155025_.getInt("CookTime"); + this.cookingTotalTime = p_155025_.getInt("CookTimeTotal"); - this.litDuration = this.getBurnDuration(this.items.get(1)); + this.litDuration = 0; CompoundTag compoundtag = p_155025_.getCompound("RecipesUsed"); -@@ -240,9 +_,9 @@ +@@ -131,9 +_,9 @@ @Override protected void saveAdditional(CompoundTag p_187452_, HolderLookup.Provider p_323656_) { super.saveAdditional(p_187452_, p_323656_); @@ -99,56 +57,25 @@ + p_187452_.putInt("CookTimeTotal", this.cookingTotalTime); ContainerHelper.saveAllItems(p_187452_, this.items, p_323656_); CompoundTag compoundtag = new CompoundTag(); - this.recipesUsed.forEach((p_187449_, p_187450_) -> compoundtag.putInt(p_187449_.toString(), p_187450_)); -@@ -269,28 +_,30 @@ - } - - int i = p_155017_.getMaxStackSize(); -- if (!p_155017_.isLit() && canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { -+ if (!p_155017_.isLit() && canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i, p_155017_)) { - p_155017_.litTime = p_155017_.getBurnDuration(itemstack); + this.recipesUsed.forEach((p_380898_, p_380899_) -> compoundtag.putInt(p_380898_.location().toString(), p_380899_)); +@@ -170,11 +_,15 @@ p_155017_.litDuration = p_155017_.litTime; if (p_155017_.isLit()) { flag1 = true; -+ if (itemstack.hasCraftingRemainingItem()) -+ p_155017_.items.set(1, itemstack.getCraftingRemainingItem()); ++ var remainder = itemstack.getCraftingRemainder(); ++ if (!remainder.isEmpty()) ++ p_155017_.items.set(1, remainder); + else if (flag3) { Item item = itemstack.getItem(); itemstack.shrink(1); if (itemstack.isEmpty()) { -- Item item1 = item.getCraftingRemainingItem(); -- p_155017_.items.set(1, item1 == null ? ItemStack.EMPTY : new ItemStack(item1)); -+ p_155017_.items.set(1, itemstack.getCraftingRemainingItem()); +- p_155017_.items.set(1, item.getCraftingRemainder()); ++ p_155017_.items.set(1, item.getCraftingRemainder()); // Neo: Remainder is handled in the `if` check above. } } } - } - -- if (p_155017_.isLit() && canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { -+ if (p_155017_.isLit() && canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i, p_155017_)) { - p_155017_.cookingProgress++; - if (p_155017_.cookingProgress == p_155017_.cookingTotalTime) { - p_155017_.cookingProgress = 0; - p_155017_.cookingTotalTime = getTotalCookTime(p_155014_, p_155017_); -- if (burn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { -+ if (burn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i, p_155017_)) { - p_155017_.setRecipeUsed(recipeholder); - } - -@@ -314,9 +_,9 @@ - } - } - -- private static boolean canBurn(RegistryAccess p_266924_, @Nullable RecipeHolder p_301107_, NonNullList p_155007_, int p_155008_) { -+ private static boolean canBurn(RegistryAccess p_266924_, @Nullable RecipeHolder p_301107_, NonNullList p_155007_, int p_155008_, AbstractFurnaceBlockEntity furnace) { - if (!p_155007_.get(0).isEmpty() && p_301107_ != null) { -- ItemStack itemstack = p_301107_.value().getResultItem(p_266924_); -+ ItemStack itemstack = ((RecipeHolder) p_301107_).value().assemble(new SingleRecipeInput(furnace.getItem(0)), p_266924_); - if (itemstack.isEmpty()) { - return false; - } else { -@@ -326,9 +_,9 @@ +@@ -227,9 +_,9 @@ } else if (!ItemStack.isSameItemSameComponents(itemstack1, itemstack)) { return false; } else { @@ -160,18 +87,7 @@ } } } else { -@@ -336,15 +_,15 @@ - } - } - -- private static boolean burn(RegistryAccess p_266740_, @Nullable RecipeHolder p_300910_, NonNullList p_267073_, int p_267157_) { -- if (p_300910_ != null && canBurn(p_266740_, p_300910_, p_267073_, p_267157_)) { -+ private static boolean burn(RegistryAccess p_266740_, @Nullable RecipeHolder p_300910_, NonNullList p_267073_, int p_267157_, AbstractFurnaceBlockEntity furnace) { -+ if (p_300910_ != null && canBurn(p_266740_, p_300910_, p_267073_, p_267157_, furnace)) { - ItemStack itemstack = p_267073_.get(0); -- ItemStack itemstack1 = p_300910_.value().getResultItem(p_266740_); -+ ItemStack itemstack1 = ((RecipeHolder) p_300910_).value().assemble(new SingleRecipeInput(furnace.getItem(0)), p_266740_); - ItemStack itemstack2 = p_267073_.get(2); +@@ -251,7 +_,7 @@ if (itemstack2.isEmpty()) { p_267073_.set(2, itemstack1.copy()); } else if (ItemStack.isSameItemSameComponents(itemstack2, itemstack1)) { @@ -180,31 +96,21 @@ } if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !p_267073_.get(1).isEmpty() && p_267073_.get(1).is(Items.BUCKET)) { -@@ -362,8 +_,7 @@ - if (p_58343_.isEmpty()) { - return 0; - } else { -- Item item = p_58343_.getItem(); -- return getFuel().getOrDefault(item, 0); -+ return p_58343_.getBurnTime(this.recipeType); - } +@@ -266,7 +_,7 @@ } -@@ -373,7 +_,7 @@ + protected int getBurnDuration(FuelValues p_363501_, ItemStack p_58343_) { +- return p_363501_.burnDuration(p_58343_); ++ return p_58343_.getBurnTime(this.recipeType, p_363501_); } - public static boolean isFuel(ItemStack p_58400_) { -- return getFuel().containsKey(p_58400_.getItem()); -+ return p_58400_.getBurnTime(null) > 0; - } - - @Override -@@ -431,7 +_,7 @@ + private static int getTotalCookTime(ServerLevel p_380169_, AbstractFurnaceBlockEntity p_222694_) { +@@ -329,7 +_,7 @@ return true; } else { ItemStack itemstack = this.items.get(1); -- return isFuel(p_58390_) || p_58390_.is(Items.BUCKET) && !itemstack.is(Items.BUCKET); -+ return p_58390_.getBurnTime(this.recipeType) > 0 || p_58390_.is(Items.BUCKET) && !itemstack.is(Items.BUCKET); +- return this.level.fuelValues().isFuel(p_58390_) || p_58390_.is(Items.BUCKET) && !itemstack.is(Items.BUCKET); ++ return p_58390_.getBurnTime(this.recipeType, this.level.fuelValues()) > 0 || p_58390_.is(Items.BUCKET) && !itemstack.is(Items.BUCKET); } } diff --git a/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch b/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch index ab720f4a..16fb21f9 100644 --- a/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch +++ b/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch @@ -10,7 +10,7 @@ + @Deprecated // Neo: always use getType() private final BlockEntityType type; @Nullable - public Level level; + protected Level level; @@ -36,6 +_,8 @@ protected boolean remove; private BlockState blockState; @@ -48,7 +48,7 @@ } public final CompoundTag saveWithFullMetadata(HolderLookup.Provider p_323767_) { -@@ -216,10 +_,14 @@ +@@ -217,10 +_,14 @@ public void setRemoved() { this.remove = true; @@ -63,7 +63,7 @@ } public boolean triggerEvent(int p_58889_, int p_58890_) { -@@ -246,6 +_,27 @@ +@@ -247,6 +_,27 @@ return this.type; } @@ -91,7 +91,7 @@ @Deprecated public void setBlockState(BlockState p_155251_) { this.validateBlockState(p_155251_); -@@ -325,5 +_,15 @@ +@@ -326,5 +_,15 @@ T get(DataComponentType p_338658_); T getOrDefault(DataComponentType p_338573_, T p_338734_); diff --git a/patches/net/minecraft/world/level/block/entity/BlockEntityType.java.patch b/patches/net/minecraft/world/level/block/entity/BlockEntityType.java.patch index 62798620..77f3f48d 100644 --- a/patches/net/minecraft/world/level/block/entity/BlockEntityType.java.patch +++ b/patches/net/minecraft/world/level/block/entity/BlockEntityType.java.patch @@ -1,14 +1,25 @@ --- a/net/minecraft/world/level/block/entity/BlockEntityType.java +++ b/net/minecraft/world/level/block/entity/BlockEntityType.java -@@ -268,6 +_,7 @@ - ); - public static final BlockEntityType VAULT = register("vault", BlockEntityType.Builder.of(VaultBlockEntity::new, Blocks.VAULT)); +@@ -229,6 +_,7 @@ + public static final BlockEntityType TRIAL_SPAWNER = register("trial_spawner", TrialSpawnerBlockEntity::new, Blocks.TRIAL_SPAWNER); + public static final BlockEntityType VAULT = register("vault", VaultBlockEntity::new, Blocks.VAULT); private final BlockEntityType.BlockEntitySupplier factory; + // Neo: This field will be modified by BlockEntityTypeAddBlocksEvent event. Please use the event to add to this field for vanilla or other mod's BlockEntityTypes. private final Set validBlocks; - private final Type dataType; private final Holder.Reference> builtInRegistryHolder = BuiltInRegistries.BLOCK_ENTITY_TYPE.createIntrusiveHolder(this); -@@ -295,6 +_,13 @@ + +@@ -253,9 +_,24 @@ + this.validBlocks = p_155260_; + } + ++ // Neo: Additional constructor for convenience. ++ public BlockEntityType(BlockEntityType.BlockEntitySupplier p_155259_, Block... p_155260_) { ++ this(p_155259_, Set.of(p_155260_)); ++ if (p_155260_.length == 0) { ++ throw new IllegalArgumentException("Block entity type instantiated without valid blocks. If this is intentional, pass Set.of() instead of an empty varag."); ++ } ++ } ++ @Nullable public T create(BlockPos p_155265_, BlockState p_155266_) { return (T)this.factory.create(p_155265_, p_155266_); diff --git a/patches/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch b/patches/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch index 95af4ec3..12d0923b 100644 --- a/patches/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch +++ b/patches/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -@@ -164,6 +_,7 @@ +@@ -165,6 +_,7 @@ } private static void doBrew(Level p_155291_, BlockPos p_155292_, NonNullList p_155293_) { @@ -8,28 +8,18 @@ ItemStack itemstack = p_155293_.get(3); PotionBrewing potionbrewing = p_155291_.potionBrewing(); -@@ -171,15 +_,17 @@ +@@ -172,8 +_,9 @@ p_155293_.set(i, potionbrewing.mix(itemstack, p_155293_.get(i))); } -- itemstack.shrink(1); -- if (itemstack.getItem().hasCraftingRemainingItem()) { -- ItemStack itemstack1 = new ItemStack(itemstack.getItem().getCraftingRemainingItem()); + net.neoforged.neoforge.event.EventHooks.onPotionBrewed(p_155293_); -+ if (itemstack.hasCraftingRemainingItem()) { -+ ItemStack itemstack1 = itemstack.getCraftingRemainingItem(); -+ itemstack.shrink(1); ++ ItemStack itemstack1 = itemstack.getCraftingRemainder(); + itemstack.shrink(1); +- ItemStack itemstack1 = itemstack.getItem().getCraftingRemainder(); + if (!itemstack1.isEmpty()) { if (itemstack.isEmpty()) { itemstack = itemstack1; - } else { - Containers.dropItemStack(p_155291_, (double)p_155292_.getX(), (double)p_155292_.getY(), (double)p_155292_.getZ(), itemstack1); - } - } -+ else itemstack.shrink(1); - - p_155293_.set(3, itemstack); - p_155291_.levelEvent(1035, p_155292_, 0); -@@ -208,13 +_,13 @@ +@@ -209,13 +_,13 @@ @Override public boolean canPlaceItem(int p_59017_, ItemStack p_59018_) { @@ -39,7 +29,7 @@ return potionbrewing.isIngredient(p_59018_); } else { return p_59017_ == 4 - ? p_59018_.is(Items.BLAZE_POWDER) + ? p_59018_.is(ItemTags.BREWING_FUEL) - : (p_59018_.is(Items.POTION) || p_59018_.is(Items.SPLASH_POTION) || p_59018_.is(Items.LINGERING_POTION) || p_59018_.is(Items.GLASS_BOTTLE)) + : (potionbrewing.isInput(p_59018_) || p_59018_.is(Items.GLASS_BOTTLE)) && this.getItem(p_59017_).isEmpty(); diff --git a/patches/net/minecraft/world/level/block/entity/FuelValues.java.patch b/patches/net/minecraft/world/level/block/entity/FuelValues.java.patch new file mode 100644 index 00000000..b5166418 --- /dev/null +++ b/patches/net/minecraft/world/level/block/entity/FuelValues.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/world/level/block/entity/FuelValues.java ++++ b/net/minecraft/world/level/block/entity/FuelValues.java +@@ -32,6 +_,10 @@ + return Collections.unmodifiableSequencedSet(this.values.keySet()); + } + ++ /** ++ * @deprecated Neo: use {@link ItemStack#getBurnTime(net.minecraft.world.item.crafting.RecipeType, FuelValues)} instead ++ */ ++ @Deprecated + public int burnDuration(ItemStack p_362816_) { + return p_362816_.isEmpty() ? 0 : this.values.getInt(p_362816_.getItem()); + } +@@ -41,7 +_,11 @@ + } + + public static FuelValues vanillaBurnTimes(HolderLookup.Provider p_362290_, FeatureFlagSet p_364291_, int p_363365_) { +- return new FuelValues.Builder(p_362290_, p_364291_) ++ return vanillaBurnTimes(new FuelValues.Builder(p_362290_, p_364291_), p_363365_); ++ } ++ ++ public static FuelValues vanillaBurnTimes(FuelValues.Builder builder, int p_363365_) { ++ return builder + .add(Items.LAVA_BUCKET, p_363365_ * 100) + .add(Blocks.COAL_BLOCK, p_363365_ * 8 * 10) + .add(Items.BLAZE_ROD, p_363365_ * 12) diff --git a/patches/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch b/patches/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch new file mode 100644 index 00000000..e3a36de8 --- /dev/null +++ b/patches/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +@@ -255,7 +_,7 @@ + + @Override + public boolean shouldRenderFace(Direction p_59959_) { +- return Block.shouldRenderFace(this.getBlockState(), this.level.getBlockState(this.getBlockPos().relative(p_59959_)), p_59959_); ++ return Block.shouldRenderFace(this.level, this.worldPosition, this.getBlockState(), this.level.getBlockState(this.getBlockPos().relative(p_59959_)), p_59959_); + } + + public int getParticleAmount() { diff --git a/patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch b/patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch index cd80ce06..54f0c947 100644 --- a/patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch +++ b/patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java -@@ -43,7 +_,7 @@ +@@ -44,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; @@ -9,20 +9,20 @@ public static final String NORMAL_CONFIG_TAG_NAME = "normal_config"; public static final String OMINOUS_CONFIG_TAG_NAME = "ominous_config"; public static final int DETECT_PLAYER_SPAWN_BUFFER = 40; -@@ -229,9 +_,9 @@ +@@ -237,9 +_,9 @@ } boolean flag = spawndata.getEntityToSpawn().size() == 1 && spawndata.getEntityToSpawn().contains("id", 8); - if (flag) { -- mob.finalizeSpawn(p_312582_, p_312582_.getCurrentDifficultyAt(mob.blockPosition()), MobSpawnType.TRIAL_SPAWNER, null); +- mob.finalizeSpawn(p_312582_, p_312582_.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.TRIAL_SPAWNER, null); - } + // Neo: Patch in FinalizeSpawn for spawners so it may be fired unconditionally, instead of only when vanilla would normally call it. + // The local flag is the conditions under which the spawner will normally call Mob#finalizeSpawn. -+ net.neoforged.neoforge.event.EventHooks.finalizeMobSpawnSpawner(mob, p_312582_, p_312582_.getCurrentDifficultyAt(mob.blockPosition()), MobSpawnType.TRIAL_SPAWNER, null, this, flag); ++ net.neoforged.neoforge.event.EventHooks.finalizeMobSpawnSpawner(mob, p_312582_, p_312582_.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.TRIAL_SPAWNER, null, this, flag); mob.setPersistenceRequired(); spawndata.getEquipment().ifPresent(mob::equip); -@@ -405,5 +_,14 @@ +@@ -413,5 +_,14 @@ TrialSpawnerState getState(); void markUpdated(); diff --git a/patches/net/minecraft/world/level/block/grower/TreeGrower.java.patch b/patches/net/minecraft/world/level/block/grower/TreeGrower.java.patch index 04738fa4..bef15f25 100644 --- a/patches/net/minecraft/world/level/block/grower/TreeGrower.java.patch +++ b/patches/net/minecraft/world/level/block/grower/TreeGrower.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/level/block/grower/TreeGrower.java +++ b/net/minecraft/world/level/block/grower/TreeGrower.java -@@ -130,6 +_,9 @@ - .registryOrThrow(Registries.CONFIGURED_FEATURE) - .getHolder(resourcekey) - .orElse(null); +@@ -128,6 +_,9 @@ + ResourceKey> resourcekey = this.getConfiguredMegaFeature(p_304893_); + if (resourcekey != null) { + Holder> holder = p_304396_.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey).orElse(null); + var event = net.neoforged.neoforge.event.EventHooks.fireBlockGrowFeature(p_304396_, p_304893_, p_304643_, holder); + holder = event.getFeature(); + if (event.isCanceled()) return false; if (holder != null) { for (int i = 0; i >= -1; i--) { for (int j = 0; j >= -1; j--) { -@@ -163,6 +_,9 @@ - .registryOrThrow(Registries.CONFIGURED_FEATURE) - .getHolder(resourcekey1) - .orElse(null); +@@ -158,6 +_,9 @@ + return false; + } else { + Holder> holder1 = p_304396_.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey1).orElse(null); + var event = net.neoforged.neoforge.event.EventHooks.fireBlockGrowFeature(p_304396_, p_304893_, p_304643_, holder1); + holder1 = event.getFeature(); + if (event.isCanceled()) return false; diff --git a/patches/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch b/patches/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch index 0f685960..5b3568cb 100644 --- a/patches/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch +++ b/patches/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java -@@ -186,6 +_,7 @@ +@@ -189,6 +_,7 @@ } if (p_60195_ == 0) { @@ -8,7 +8,7 @@ if (!this.moveBlocks(p_60193_, p_60194_, direction, true)) { return false; } -@@ -194,6 +_,7 @@ +@@ -197,6 +_,7 @@ p_60193_.playSound(null, p_60194_, SoundEvents.PISTON_EXTEND, SoundSource.BLOCKS, 0.5F, p_60193_.random.nextFloat() * 0.25F + 0.6F); p_60193_.gameEvent(GameEvent.BLOCK_ACTIVATE, p_60194_, GameEvent.Context.of(blockstate)); } else if (p_60195_ == 1 || p_60195_ == 2) { @@ -16,7 +16,7 @@ BlockEntity blockentity = p_60193_.getBlockEntity(p_60194_.relative(direction)); if (blockentity instanceof PistonMovingBlockEntity) { ((PistonMovingBlockEntity)blockentity).finalTick(); -@@ -243,6 +_,7 @@ +@@ -246,6 +_,7 @@ p_60193_.gameEvent(GameEvent.BLOCK_DEACTIVATE, p_60194_, GameEvent.Context.of(blockstate1)); } @@ -24,7 +24,7 @@ return true; } -@@ -314,8 +_,7 @@ +@@ -315,8 +_,7 @@ BlockState blockstate1 = p_60182_.getBlockState(blockpos2); BlockEntity blockentity = blockstate1.hasBlockEntity() ? p_60182_.getBlockEntity(blockpos2) : null; dropResources(blockstate1, p_60182_, blockpos2, blockentity); @@ -34,7 +34,7 @@ if (!blockstate1.is(BlockTags.FIRE)) { p_60182_.addDestroyBlockEffect(blockpos2, blockstate1); } -@@ -387,6 +_,10 @@ +@@ -389,6 +_,10 @@ @Override protected BlockState rotate(BlockState p_60215_, Rotation p_60216_) { return p_60215_.setValue(FACING, p_60216_.rotate(p_60215_.getValue(FACING))); diff --git a/patches/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch b/patches/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch index 94bcbb53..70dbd39e 100644 --- a/patches/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch +++ b/patches/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -115,7 +_,7 @@ +@@ -116,7 +_,7 @@ List list = p_155911_.getEntities(null, PistonMath.getMovementArea(aabb, direction, d0).minmax(aabb)); if (!list.isEmpty()) { List list1 = voxelshape.toAabbs(); diff --git a/patches/net/minecraft/world/level/block/state/BlockBehaviour.java.patch b/patches/net/minecraft/world/level/block/state/BlockBehaviour.java.patch index 851387e2..9fdd0ace 100644 --- a/patches/net/minecraft/world/level/block/state/BlockBehaviour.java.patch +++ b/patches/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -1,64 +1,36 @@ --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -111,6 +_,17 @@ - this.dynamicShape = p_60452_.dynamicShape; - this.requiredFeatures = p_60452_.requiredFeatures; - this.properties = p_60452_; -+ final ResourceKey lootTableCache = p_60452_.drops; -+ if (lootTableCache != null) { -+ this.lootTableSupplier = () -> lootTableCache; -+ } else if (p_60452_.lootTableSupplier != null) { -+ this.lootTableSupplier = p_60452_.lootTableSupplier; -+ } else { -+ this.lootTableSupplier = () -> { -+ ResourceLocation resourcelocation = BuiltInRegistries.BLOCK.getKey(this.asBlock()); -+ return ResourceKey.create(Registries.LOOT_TABLE, resourcelocation.withPrefix("blocks/")); -+ }; -+ } - } - - public BlockBehaviour.Properties properties() { -@@ -168,7 +_,7 @@ +@@ -182,7 +_,7 @@ if (!p_311951_.isAir() && p_312925_.getBlockInteraction() != Explosion.BlockInteraction.TRIGGER_BLOCK) { Block block = p_311951_.getBlock(); boolean flag = p_312925_.getIndirectSourceEntity() instanceof Player; -- if (block.dropFromExplosion(p_312925_) && p_312820_ instanceof ServerLevel serverlevel) { -+ if (p_311951_.canDropFromExplosion(p_312820_, p_312489_, p_312925_) && p_312820_ instanceof ServerLevel serverlevel) { - BlockEntity blockentity = p_311951_.hasBlockEntity() ? p_312820_.getBlockEntity(p_312489_) : null; - LootParams.Builder lootparams$builder = new LootParams.Builder(serverlevel) +- if (block.dropFromExplosion(p_312925_)) { ++ if (p_311951_.canDropFromExplosion(p_365148_, p_312489_, p_312925_)) { + BlockEntity blockentity = p_311951_.hasBlockEntity() ? p_365148_.getBlockEntity(p_312489_) : null; + LootParams.Builder lootparams$builder = new LootParams.Builder(p_365148_) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(p_312489_)) -@@ -183,8 +_,7 @@ +@@ -197,8 +_,7 @@ p_311951_.getDrops(lootparams$builder).forEach(p_311752_ -> p_312073_.accept(p_311752_, p_312489_)); } -- p_312820_.setBlock(p_312489_, Blocks.AIR.defaultBlockState(), 3); -- block.wasExploded(p_312820_, p_312489_, p_312925_); -+ p_311951_.onBlockExploded(p_312820_, p_312489_, p_312925_); +- p_365148_.setBlock(p_312489_, Blocks.AIR.defaultBlockState(), 3); +- block.wasExploded(p_365148_, p_312489_, p_312925_); ++ p_311951_.onBlockExploded(p_365148_, p_312489_, p_312925_); } } -@@ -335,8 +_,8 @@ +@@ -344,8 +_,8 @@ if (f == -1.0F) { return 0.0F; } else { - int i = p_60467_.hasCorrectToolForDrops(p_60466_) ? 30 : 100; - return p_60467_.getDestroySpeed(p_60466_) / f / (float)i; + int i = net.neoforged.neoforge.event.EventHooks.doPlayerHarvestCheck(p_60467_, p_60466_, p_60468_, p_60469_) ? 30 : 100; -+ return p_60467_.getDigSpeed(p_60466_, p_60469_) / f / (float)i; ++ return p_60467_.getDestroySpeed(p_60466_, p_60469_) / f / (float)i; } } -@@ -359,8 +_,7 @@ - - public final ResourceKey getLootTable() { - if (this.drops == null) { -- ResourceLocation resourcelocation = BuiltInRegistries.BLOCK.getKey(this.asBlock()); -- this.drops = ResourceKey.create(Registries.LOOT_TABLE, resourcelocation.withPrefix("blocks/")); -+ this.drops = this.lootTableSupplier.get(); - } - - return this.drops; -@@ -377,6 +_,7 @@ +@@ -389,6 +_,7 @@ return this.isRandomlyTicking; } @@ -66,21 +38,18 @@ protected SoundType getSoundType(BlockState p_320941_) { return this.soundType; } -@@ -393,6 +_,13 @@ +@@ -405,6 +_,10 @@ return this.properties.destroyTime; } + protected boolean isAir(BlockState state) { + return ((BlockStateBase)state).isAir; + } -+ -+ // Neo: Holds the loot table for this block's drops. Used for getLootTable method. -+ private final java.util.function.Supplier> lootTableSupplier; + public abstract static class BlockStateBase extends StateHolder { - private final int lightEmission; - private final boolean useShapeForLightOcclusion; -@@ -523,12 +_,14 @@ + private static final Direction[] DIRECTIONS = Direction.values(); + private static final VoxelShape[] EMPTY_OCCLUSION_SHAPES = Util.make( +@@ -561,12 +_,14 @@ return this.useShapeForLightOcclusion; } @@ -96,7 +65,7 @@ } public boolean ignitedByLava() { -@@ -541,9 +_,11 @@ +@@ -579,9 +_,11 @@ } public MapColor getMapColor(BlockGetter p_285002_, BlockPos p_285293_) { @@ -109,7 +78,7 @@ public BlockState rotate(Rotation p_60718_) { return this.getBlock().rotate(this.asState(), p_60718_); } -@@ -597,6 +_,8 @@ +@@ -635,6 +_,8 @@ } public PushReaction getPistonPushReaction() { @@ -118,17 +87,17 @@ return this.pushReaction; } -@@ -724,6 +_,9 @@ +@@ -762,6 +_,9 @@ } - public ItemInteractionResult useItemOn(ItemStack p_316374_, Level p_316651_, Player p_316623_, InteractionHand p_316469_, BlockHitResult p_316877_) { + public InteractionResult useItemOn(ItemStack p_316374_, Level p_316651_, Player p_316623_, InteractionHand p_316469_, BlockHitResult p_316877_) { + var useOnContext = new net.minecraft.world.item.context.UseOnContext(p_316651_, p_316623_, p_316469_, p_316623_.getItemInHand(p_316469_).copy(), p_316877_); + var e = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent(useOnContext, net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent.UsePhase.BLOCK)); + if (e.isCanceled()) return e.getCancellationResult(); return this.getBlock().useItemOn(p_316374_, this.asState(), p_316651_, p_316877_.getBlockPos(), p_316623_, p_316469_, p_316877_); } -@@ -825,6 +_,7 @@ +@@ -871,6 +_,7 @@ return this.getBlock().getSeed(this.asState(), p_60727_); } @@ -136,34 +105,12 @@ public SoundType getSoundType() { return this.getBlock().getSoundType(this.asState()); } -@@ -959,11 +_,12 @@ - PushReaction pushReaction = PushReaction.NORMAL; - boolean spawnTerrainParticles = true; - NoteBlockInstrument instrument = NoteBlockInstrument.HARP; -+ private java.util.function.Supplier> lootTableSupplier; - boolean replaceable; - BlockBehaviour.StateArgumentPredicate> isValidSpawn = (p_284893_, p_284894_, p_284895_, p_284896_) -> p_284893_.isFaceSturdy( - p_284894_, p_284895_, Direction.UP +@@ -996,7 +_,7 @@ + BlockBehaviour.StateArgumentPredicate> isValidSpawn = (p_360193_, p_360194_, p_360195_, p_360196_) -> p_360193_.isFaceSturdy( + p_360194_, p_360195_, Direction.UP ) -- && p_284893_.getLightEmission() < 14; -+ && p_284893_.getLightEmission(p_284894_, p_284895_) < 14; - BlockBehaviour.StatePredicate isRedstoneConductor = (p_284888_, p_284889_, p_284890_) -> p_284888_.isCollisionShapeFullBlock(p_284889_, p_284890_); - BlockBehaviour.StatePredicate isSuffocating = (p_284885_, p_284886_, p_284887_) -> p_284885_.blocksMotion() - && p_284885_.isCollisionShapeFullBlock(p_284886_, p_284887_); -@@ -1105,9 +_,15 @@ - return this; - } - -+ @Deprecated // FORGE: Use the variant that takes a Supplier below - public BlockBehaviour.Properties dropsLike(Block p_60917_) { -- this.drops = p_60917_.getLootTable(); -+ this.lootTableSupplier = () -> p_60917_.getLootTable(); - return this; -+ } -+ -+ public BlockBehaviour.Properties lootFrom(java.util.function.Supplier blockIn) { -+ this.lootTableSupplier = () -> blockIn.get().getLootTable(); -+ return this; - } - - public BlockBehaviour.Properties ignitedByLava() { +- && p_360193_.getLightEmission() < 14; ++ && p_360193_.getLightEmission(p_360194_, p_360195_) < 14; + BlockBehaviour.StatePredicate isRedstoneConductor = (p_360190_, p_360191_, p_360192_) -> p_360190_.isCollisionShapeFullBlock(p_360191_, p_360192_); + BlockBehaviour.StatePredicate isSuffocating = (p_360187_, p_360188_, p_360189_) -> p_360187_.blocksMotion() + && p_360187_.isCollisionShapeFullBlock(p_360188_, p_360189_); diff --git a/patches/net/minecraft/world/level/chunk/ChunkAccess.java.patch b/patches/net/minecraft/world/level/chunk/ChunkAccess.java.patch index 311f7f49..7de81bd2 100644 --- a/patches/net/minecraft/world/level/chunk/ChunkAccess.java.patch +++ b/patches/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -4,16 +4,16 @@ import net.minecraft.world.ticks.TickContainerAccess; import org.slf4j.Logger; --public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess { -+public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess, net.neoforged.neoforge.attachment.IAttachmentHolder { +-public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess { ++public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess, net.neoforged.neoforge.attachment.IAttachmentHolder { public static final int NO_FILLED_SECTION = -1; private static final Logger LOGGER = LogUtils.getLogger(); private static final LongSet EMPTY_REFERENCE_SET = new LongOpenHashSet(); -@@ -315,10 +_,19 @@ +@@ -324,10 +_,19 @@ @Override public final void findBlockLightSources(BiConsumer p_285269_) { -- this.findBlocks(p_284897_ -> p_284897_.getLightEmission() != 0, p_285269_); +- this.findBlocks(p_360197_ -> p_360197_.getLightEmission() != 0, p_285269_); + this.findBlocks(p_284897_ -> p_284897_.hasDynamicLightEmission() || p_284897_.getLightEmission(net.minecraft.world.level.EmptyBlockGetter.INSTANCE, BlockPos.ZERO) != 0, (p_284897_, pos) -> p_284897_.getLightEmission(this, pos) != 0, p_285269_); } @@ -29,8 +29,8 @@ + public void findBlocks(Predicate p_285343_, java.util.function.BiPredicate fineFilter, BiConsumer p_285030_) { BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); - for (int i = this.getMinSection(); i < this.getMaxSection(); i++) { -@@ -330,8 +_,9 @@ + for (int i = this.getMinSectionY(); i <= this.getMaxSectionY(); i++) { +@@ -339,8 +_,9 @@ for (int k = 0; k < 16; k++) { for (int l = 0; l < 16; l++) { BlockState blockstate = levelchunksection.getBlockState(l, j, k); @@ -42,9 +42,9 @@ } } } -@@ -476,4 +_,72 @@ - - public static record TicksToSave(SerializableTickContainer blocks, SerializableTickContainer fluids) { +@@ -482,6 +_,74 @@ + public ChunkSkyLightSources getSkyLightSources() { + return this.skyLightSources; } + + // Neo: Hook in AttachmentHolder to chunks for data storage and retrieval @@ -73,14 +73,14 @@ + @Override + @Nullable + public T setData(net.neoforged.neoforge.attachment.AttachmentType type, T data) { -+ setUnsaved(true); ++ markUnsaved(); + return getAttachmentHolder().setData(type, data); + } + + @Override + @Nullable + public T removeData(net.neoforged.neoforge.attachment.AttachmentType type) { -+ setUnsaved(true); ++ markUnsaved(); + return getAttachmentHolder().removeData(type); + } + @@ -114,4 +114,6 @@ + // Neo: Allow for exposing the Level a chunk is tied to if available + @Nullable + public net.minecraft.world.level.Level getLevel() { return null; } - } + + public static record PackedTicks(List> blocks, List> fluids) { + } diff --git a/patches/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch b/patches/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch index 82743958..6481ea0f 100644 --- a/patches/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch +++ b/patches/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/net/minecraft/world/level/chunk/ImposterProtoChunk.java -@@ -219,6 +_,15 @@ +@@ -223,6 +_,15 @@ } @Override @@ -16,7 +16,7 @@ public TickContainerAccess getBlockTicks() { return this.allowWrites ? this.wrapped.getBlockTicks() : BlackholeTickAccess.emptyContainer(); } -@@ -291,5 +_,10 @@ +@@ -290,5 +_,10 @@ @Override public ChunkSkyLightSources getSkyLightSources() { return this.wrapped.getSkyLightSources(); diff --git a/patches/net/minecraft/world/level/chunk/LevelChunk.java.patch b/patches/net/minecraft/world/level/chunk/LevelChunk.java.patch index a47b0de4..dfa6a02f 100644 --- a/patches/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/patches/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -50,7 +_,7 @@ +@@ -51,7 +_,7 @@ import net.minecraft.world.ticks.TickContainerAccess; import org.slf4j.Logger; @@ -9,7 +9,7 @@ static final Logger LOGGER = LogUtils.getLogger(); private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { @Override -@@ -139,6 +_,7 @@ +@@ -142,6 +_,7 @@ this.setAllStarts(p_196851_.getAllStarts()); this.setAllReferences(p_196851_.getAllReferences()); @@ -17,7 +17,16 @@ for (Entry entry : p_196851_.getHeightmaps()) { if (ChunkStatus.FULL.heightmapsAfter().contains(entry.getKey())) { this.setHeightmap(entry.getKey(), entry.getValue().getRawData()); -@@ -278,7 +_,7 @@ +@@ -279,7 +_,7 @@ + this.level.getChunkSource().onSectionEmptinessChanged(this.chunkPos.x, SectionPos.blockToSectionCoord(i), this.chunkPos.z, flag1); + } + +- if (LightEngine.hasDifferentLightProperties(blockstate, p_62866_)) { ++ if (LightEngine.hasDifferentLightProperties(this, p_62865_, blockstate, p_62866_)) { + ProfilerFiller profilerfiller = Profiler.get(); + profilerfiller.push("updateSkyLightSources"); + this.skyLightSources.update(this, j, i, l); +@@ -298,7 +_,7 @@ if (!levelchunksection.getBlockState(j, k, l).is(block)) { return null; } else { @@ -26,7 +35,7 @@ p_62866_.onPlace(this.level, p_62865_, blockstate, p_62867_); } -@@ -327,6 +_,10 @@ +@@ -353,6 +_,10 @@ @Nullable public BlockEntity getBlockEntity(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { BlockEntity blockentity = this.blockEntities.get(p_62868_); @@ -37,7 +46,7 @@ if (blockentity == null) { CompoundTag compoundtag = this.pendingBlockEntities.remove(p_62868_); if (compoundtag != null) { -@@ -344,9 +_,6 @@ +@@ -370,9 +_,6 @@ this.addAndRegisterBlockEntity(blockentity); } } @@ -47,7 +56,7 @@ } return blockentity; -@@ -360,6 +_,7 @@ +@@ -386,6 +_,7 @@ } this.updateBlockEntityTicker(p_156391_); @@ -55,7 +64,7 @@ } } -@@ -403,6 +_,7 @@ +@@ -429,6 +_,7 @@ BlockEntity blockentity = this.blockEntities.put(blockpos.immutable(), p_156374_); if (blockentity != null && blockentity != p_156374_) { blockentity.setRemoved(); @@ -63,7 +72,7 @@ } } } -@@ -412,9 +_,14 @@ +@@ -438,9 +_,14 @@ public CompoundTag getBlockEntityNbtForSaving(BlockPos p_62932_, HolderLookup.Provider p_323699_) { BlockEntity blockentity = this.getBlockEntity(p_62932_); if (blockentity != null && !blockentity.isRemoved()) { @@ -78,7 +87,7 @@ } else { CompoundTag compoundtag = this.pendingBlockEntities.get(p_62932_); if (compoundtag != null) { -@@ -436,6 +_,7 @@ +@@ -462,6 +_,7 @@ } blockentity.setRemoved(); @@ -86,7 +95,7 @@ } } -@@ -496,7 +_,7 @@ +@@ -522,7 +_,7 @@ p_187974_.accept((p_338077_, p_338078_, p_338079_) -> { BlockEntity blockentity = this.getBlockEntity(p_338077_, LevelChunk.EntityCreationType.IMMEDIATE); if (blockentity != null && p_338079_ != null && blockentity.getType() == p_338078_) { @@ -95,7 +104,7 @@ } }); } -@@ -604,6 +_,7 @@ +@@ -632,6 +_,7 @@ } public void clearAllBlockEntities() { @@ -103,7 +112,7 @@ this.blockEntities.values().forEach(BlockEntity::setRemoved); this.blockEntities.clear(); this.tickersInLevel.values().forEach(p_187966_ -> p_187966_.rebind(NULL_TICKER)); -@@ -611,6 +_,7 @@ +@@ -639,6 +_,7 @@ } public void registerAllBlockEntitiesAfterLevelLoad() { @@ -111,7 +120,7 @@ this.blockEntities.values().forEach(p_187988_ -> { if (this.level instanceof ServerLevel serverlevel) { this.addGameEventListener(p_187988_, serverlevel); -@@ -662,6 +_,14 @@ +@@ -690,6 +_,14 @@ return new LevelChunk.BoundTickingBlockEntity<>(p_156376_, p_156377_); } @@ -126,15 +135,15 @@ class BoundTickingBlockEntity implements TickingBlockEntity { private final T blockEntity; private final BlockEntityTicker ticker; -@@ -679,6 +_,7 @@ +@@ -707,6 +_,7 @@ if (LevelChunk.this.isTicking(blockpos)) { try { - ProfilerFiller profilerfiller = LevelChunk.this.level.getProfiler(); + ProfilerFiller profilerfiller = Profiler.get(); + net.neoforged.neoforge.server.timings.TimeTracker.BLOCK_ENTITY_UPDATE.trackStart(blockEntity); profilerfiller.push(this::getType); BlockState blockstate = LevelChunk.this.getBlockState(blockpos); if (this.blockEntity.getType().isValid(blockstate)) { -@@ -700,7 +_,15 @@ +@@ -728,7 +_,15 @@ CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking block entity"); CrashReportCategory crashreportcategory = crashreport.addCategory("Block entity being ticked"); this.blockEntity.fillCrashReportCategory(crashreportcategory); diff --git a/patches/net/minecraft/world/level/chunk/LevelChunkSection.java.patch b/patches/net/minecraft/world/level/chunk/LevelChunkSection.java.patch index 42b524a3..ba7c17c9 100644 --- a/patches/net/minecraft/world/level/chunk/LevelChunkSection.java.patch +++ b/patches/net/minecraft/world/level/chunk/LevelChunkSection.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -65,7 +_,7 @@ +@@ -73,7 +_,7 @@ FluidState fluidstate = blockstate.getFluidState(); FluidState fluidstate1 = p_62995_.getFluidState(); @@ -9,7 +9,7 @@ this.nonEmptyBlockCount--; if (blockstate.isRandomlyTicking()) { this.tickingBlockCount--; -@@ -76,7 +_,7 @@ +@@ -84,7 +_,7 @@ this.tickingFluidCount--; } @@ -18,7 +18,7 @@ this.nonEmptyBlockCount++; if (p_62995_.isRandomlyTicking()) { this.tickingBlockCount++; -@@ -114,7 +_,7 @@ +@@ -122,7 +_,7 @@ public void accept(BlockState p_204444_, int p_204445_) { FluidState fluidstate = p_204444_.getFluidState(); diff --git a/patches/net/minecraft/world/level/chunk/PalettedContainer.java.patch b/patches/net/minecraft/world/level/chunk/PalettedContainer.java.patch index 60e8344a..23ac00f2 100644 --- a/patches/net/minecraft/world/level/chunk/PalettedContainer.java.patch +++ b/patches/net/minecraft/world/level/chunk/PalettedContainer.java.patch @@ -7,4 +7,4 @@ + // TODO: forceBits-parametered setBits function. -C private static final int MIN_PALETTE_BITS = 0; private final PaletteResize dummyPaletteResize = (p_238275_, p_238276_) -> 0; - public final IdMap registry; + private final IdMap registry; diff --git a/patches/net/minecraft/world/level/chunk/ProtoChunk.java.patch b/patches/net/minecraft/world/level/chunk/ProtoChunk.java.patch new file mode 100644 index 00000000..ecd7f80c --- /dev/null +++ b/patches/net/minecraft/world/level/chunk/ProtoChunk.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/chunk/ProtoChunk.java ++++ b/net/minecraft/world/level/chunk/ProtoChunk.java +@@ -134,7 +_,7 @@ + this.lightEngine.updateSectionStatus(p_63217_, flag1); + } + +- if (LightEngine.hasDifferentLightProperties(blockstate, p_63218_)) { ++ if (LightEngine.hasDifferentLightProperties(this, p_63217_, blockstate, p_63218_)) { + this.skyLightSources.update(this, i1, j, k1); + this.lightEngine.checkBlock(p_63217_); + } diff --git a/patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch b/patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch index 788be921..a16cba61 100644 --- a/patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch +++ b/patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch @@ -1,24 +1,25 @@ --- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java -@@ -201,10 +_,21 @@ - } +@@ -198,11 +_,22 @@ + } - levelchunk.setFullStatus(generationchunkholder::getFullStatus); -+ try { -+ generationchunkholder.currentlyLoading = levelchunk; // Neo: bypass the future chain when getChunk is called, this prevents deadlocks. - levelchunk.runPostLoad(); -+ } finally { -+ generationchunkholder.currentlyLoading = null; // Neo: Stop bypassing the future chain. -+ } - levelchunk.setLoaded(true); -+ try { -+ generationchunkholder.currentlyLoading = levelchunk; // Neo: bypass the future chain when getChunk is called, this prevents deadlocks. - levelchunk.registerAllBlockEntitiesAfterLevelLoad(); - levelchunk.registerTickContainerInLevel(serverlevel); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkEvent.Load(levelchunk, !(protochunk instanceof ImposterProtoChunk))); -+ } finally { -+ generationchunkholder.currentlyLoading = null; // Neo: Stop bypassing the future chain. -+ } - return levelchunk; - }, - p_347404_ -> p_347565_.mainThreadMailBox() + levelchunk.setFullStatus(generationchunkholder::getFullStatus); ++ try { ++ generationchunkholder.currentlyLoading = levelchunk; // Neo: bypass the future chain when getChunk is called, this prevents deadlocks. + levelchunk.runPostLoad(); ++ } finally { ++ generationchunkholder.currentlyLoading = null; // Neo: Stop bypassing the future chain. ++ } + levelchunk.setLoaded(true); ++ try { ++ generationchunkholder.currentlyLoading = levelchunk; // Neo: bypass the future chain when getChunk is called, this prevents deadlocks. + levelchunk.registerAllBlockEntitiesAfterLevelLoad(); + levelchunk.registerTickContainerInLevel(serverlevel); + levelchunk.setUnsavedListener(p_347565_.unsavedListener()); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkEvent.Load(levelchunk, !(protochunk instanceof ImposterProtoChunk))); ++ } finally { ++ generationchunkholder.currentlyLoading = null; // Neo: Stop bypassing the future chain. ++ } + return levelchunk; + }, p_347565_.mainThreadExecutor()); + } diff --git a/patches/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch b/patches/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch deleted file mode 100644 index fa78db91..00000000 --- a/patches/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- a/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -+++ b/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -@@ -183,6 +_,8 @@ - postLoadChunk(p_188231_, p_188234_), - blendingdata - ); -+ if (p_188234_.contains(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, net.minecraft.nbt.Tag.TAG_LIST)) -+ Objects.requireNonNull(((LevelChunk)chunkaccess).getAuxLightManager(p_188233_)).deserializeNBT(p_188231_.registryAccess(), p_188234_.getList(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, net.minecraft.nbt.Tag.TAG_COMPOUND)); - } else { - ProtoChunkTicks protochunkticks = ProtoChunkTicks.load( - p_188234_.getList("block_ticks", 10), p_258992_ -> BuiltInRegistries.BLOCK.getOptional(ResourceLocation.tryParse(p_258992_)), p_188233_ -@@ -209,6 +_,8 @@ - } - } - -+ if (p_188234_.contains(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY, net.minecraft.nbt.Tag.TAG_COMPOUND)) -+ chunkaccess.readAttachmentsFromNBT(p_188231_.registryAccess(), p_188234_.getCompound(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY)); - chunkaccess.setLightCorrect(flag); - CompoundTag compoundtag2 = p_188234_.getCompound("Heightmaps"); - EnumSet enumset = EnumSet.noneOf(Heightmap.Types.class); -@@ -241,6 +_,7 @@ - } - - if (chunktype == ChunkType.LEVELCHUNK) { -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkDataEvent.Load(chunkaccess, p_188234_, chunktype)); - return new ImposterProtoChunk((LevelChunk)chunkaccess, false); - } else { - ProtoChunk protochunk1 = (ProtoChunk)chunkaccess; -@@ -264,6 +_,7 @@ - protochunk1.setCarvingMask(generationstep$carving, new CarvingMask(compoundtag4.getLongArray(s1), chunkaccess.getMinBuildHeight())); - } - -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkDataEvent.Load(chunkaccess, p_188234_, chunktype)); - return protochunk1; - } - } -@@ -374,6 +_,11 @@ - - compoundtag.put("CarvingMasks", compoundtag4); - } -+ else if (p_63456_ instanceof LevelChunk levelChunk){ -+ -+ Tag lightTag = levelChunk.getAuxLightManager(chunkpos).serializeNBT(p_63455_.registryAccess()); -+ if (lightTag != null) compoundtag.put(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, lightTag); -+ } - - saveTicks(p_63455_, compoundtag, p_63456_.getTicksForSerialization()); - compoundtag.put("PostProcessing", packOffsets(p_63456_.getPostProcessing())); -@@ -385,6 +_,12 @@ - } - } - -+ try { -+ final CompoundTag capTag = p_63456_.writeAttachmentsToNBT(p_63455_.registryAccess()); -+ if (capTag != null) compoundtag.put(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY, capTag); -+ } catch (Exception exception) { -+ LOGGER.error("Failed to write chunk attachments. An attachment has likely thrown an exception trying to write state. It will not persist. Report this to the mod author", exception); -+ } - compoundtag.put("Heightmaps", compoundtag2); - compoundtag.put( - "structures", diff --git a/patches/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch b/patches/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch index 07090ecf..9adff111 100644 --- a/patches/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch +++ b/patches/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/storage/EntityStorage.java +++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java -@@ -94,8 +_,12 @@ +@@ -95,8 +_,12 @@ ListTag listtag = new ListTag(); p_156559_.getEntities().forEach(p_156567_ -> { CompoundTag compoundtag1 = new CompoundTag(); diff --git a/patches/net/minecraft/world/level/chunk/storage/SectionStorage.java.patch b/patches/net/minecraft/world/level/chunk/storage/SectionStorage.java.patch index e19c187a..5eef3aff 100644 --- a/patches/net/minecraft/world/level/chunk/storage/SectionStorage.java.patch +++ b/patches/net/minecraft/world/level/chunk/storage/SectionStorage.java.patch @@ -1,15 +1,22 @@ --- a/net/minecraft/world/level/chunk/storage/SectionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SectionStorage.java -@@ -238,4 +_,12 @@ - public void close() throws IOException { +@@ -302,6 +_,19 @@ this.simpleRegionStorage.close(); } -+ + + /** + * Neo: Removes the data for the given chunk position. + * See PR #937 + */ -+ public void remove(long sectionPosAsLong) { -+ this.storage.remove(sectionPosAsLong); ++ public void remove(ChunkPos chunkPos) { ++ synchronized (this.loadLock) { ++ for (int y = this.levelHeightAccessor.getMinSectionY(); y <= this.levelHeightAccessor.getMaxSectionY(); y++) { ++ this.storage.remove(getKey(chunkPos, y)); ++ } ++ this.loadedChunks.remove(chunkPos.toLong()); ++ } + } - } ++ + static record PackedChunk(Int2ObjectMap sectionsByY, boolean versionChanged) { + public static SectionStorage.PackedChunk parse( + Codec p_365233_, DynamicOps p_363840_, Tag p_364375_, SimpleRegionStorage p_362076_, LevelHeightAccessor p_362314_ diff --git a/patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch b/patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch new file mode 100644 index 00000000..9cea770e --- /dev/null +++ b/patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch @@ -0,0 +1,139 @@ +--- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java ++++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +@@ -91,7 +_,9 @@ + List sectionData, + List entities, + List blockEntities, +- CompoundTag structureData ++ CompoundTag structureData, ++ @Nullable CompoundTag attachmentData, ++ @Nullable ListTag auxLightData + ) { + private static final Codec> BLOCK_STATE_CODEC = PalettedContainer.codecRW( + Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState() +@@ -108,6 +_,33 @@ + public static final String BLOCK_LIGHT_TAG = "BlockLight"; + public static final String SKY_LIGHT_TAG = "SkyLight"; + ++ /** ++ * @deprecated Neo: use constructor with additional data instead ++ */ ++ @Deprecated ++ SerializableChunkData( ++ Registry biomeRegistry, ++ ChunkPos chunkPos, ++ int minSectionY, ++ long lastUpdateTime, ++ long inhabitedTime, ++ ChunkStatus chunkStatus, ++ @Nullable BlendingData.Packed blendingData, ++ @Nullable BelowZeroRetrogen belowZeroRetrogen, ++ UpgradeData upgradeData, ++ @Nullable long[] carvingMask, ++ Map heightmaps, ++ ChunkAccess.PackedTicks packedTicks, ++ ShortList[] postProcessingSections, ++ boolean lightCorrect, ++ List sectionData, ++ List entities, ++ List blockEntities, ++ CompoundTag structureData ++ ) { ++ this(biomeRegistry, chunkPos, minSectionY, lastUpdateTime, inhabitedTime, chunkStatus, blendingData, belowZeroRetrogen, upgradeData, carvingMask, heightmaps, packedTicks, postProcessingSections, lightCorrect, sectionData, entities, blockEntities, structureData, null, null); ++ } ++ + @Nullable + public static SerializableChunkData parse(LevelHeightAccessor p_361938_, RegistryAccess p_365010_, CompoundTag p_362040_) { + if (!p_362040_.contains("Status", 8)) { +@@ -224,6 +_,15 @@ + list.add(new SerializableChunkData.SectionData(j1, levelchunksection, datalayer, datalayer1)); + } + ++ CompoundTag attachmentData = null; ++ if (p_362040_.contains(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY, Tag.TAG_COMPOUND)) { ++ attachmentData = p_362040_.getCompound(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY); ++ } ++ ListTag auxLightData = null; ++ if (p_362040_.contains(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, Tag.TAG_LIST)) { ++ auxLightData = p_362040_.getList(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, Tag.TAG_COMPOUND); ++ } ++ + return new SerializableChunkData( + registry, + chunkpos, +@@ -242,7 +_,9 @@ + list, + list3, + list4, +- compoundtag2 ++ compoundtag2, ++ attachmentData, ++ auxLightData + ); + } + } +@@ -302,6 +_,9 @@ + postLoadChunk(p_360452_, this.entities, this.blockEntities), + BlendingData.unpack(this.blendingData) + ); ++ if (this.auxLightData != null) { ++ ((LevelChunk) chunkaccess).getAuxLightManager(chunkPos).deserializeNBT(p_360452_.registryAccess(), this.auxLightData); ++ } + } else { + ProtoChunkTicks protochunkticks = ProtoChunkTicks.load(this.packedTicks.blocks()); + ProtoChunkTicks protochunkticks1 = ProtoChunkTicks.load(this.packedTicks.fluids()); +@@ -340,6 +_,10 @@ + chunkaccess.addPackedPostProcess(this.postProcessingSections[j], j); + } + ++ if (this.attachmentData != null) { ++ chunkaccess.readAttachmentsFromNBT(p_360452_.registryAccess(), this.attachmentData); ++ } ++ + if (chunktype == ChunkType.LEVELCHUNK) { + return new ImposterProtoChunk((LevelChunk)chunkaccess, false); + } else { +@@ -429,6 +_,17 @@ + CompoundTag compoundtag1 = packStructureData( + StructurePieceSerializationContext.fromLevel(p_365319_), chunkpos, p_362284_.getAllStarts(), p_362284_.getAllReferences() + ); ++ ++ CompoundTag attachmentData = null; ++ try { ++ attachmentData = p_362284_.writeAttachmentsToNBT(p_365319_.registryAccess()); ++ } catch (Exception exception) { ++ LOGGER.error("Failed to write chunk attachments. An attachment has likely thrown an exception trying to write state. It will not persist. Report this to the mod author", exception); ++ } ++ ListTag auxLightData = null; ++ if (p_362284_ instanceof LevelChunk levelChunk) { ++ auxLightData = levelChunk.getAuxLightManager(chunkpos).serializeNBT(p_365319_.registryAccess()); ++ } + return new SerializableChunkData( + p_365319_.registryAccess().lookupOrThrow(Registries.BIOME), + chunkpos, +@@ -447,7 +_,9 @@ + list, + list2, + list1, +- compoundtag1 ++ compoundtag1, ++ attachmentData, ++ auxLightData + ); + } + } +@@ -526,6 +_,14 @@ + this.heightmaps.forEach((p_362472_, p_363515_) -> compoundtag2.put(p_362472_.getSerializationKey(), new LongArrayTag(p_363515_))); + compoundtag.put("Heightmaps", compoundtag2); + compoundtag.put("structures", this.structureData); ++ ++ if (attachmentData != null) { ++ compoundtag.put(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY, attachmentData); ++ } ++ if (auxLightData != null) { ++ compoundtag.put(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, auxLightData); ++ } ++ + return compoundtag; + } + diff --git a/patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch b/patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch index a62dbf7b..181d5880 100644 --- a/patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch +++ b/patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch @@ -20,7 +20,7 @@ static int getGameEventFrequency(ResourceKey p_316800_) { - return VIBRATION_FREQUENCY_FOR_EVENT.applyAsInt(p_316800_); -+ var holder = net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.getHolder(p_316800_); ++ var holder = net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.get(p_316800_); + return holder.map(VibrationSystem::getGameEventFrequency).orElse(0); } diff --git a/patches/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch b/patches/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch index 198e5cab..f715082e 100644 --- a/patches/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch +++ b/patches/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch @@ -27,4 +27,4 @@ + int l = event.getPhantomsToSpawn(); for (int i1 = 0; i1 < l; i1++) { - Phantom phantom = EntityType.PHANTOM.create(p_64576_); + Phantom phantom = EntityType.PHANTOM.create(p_64576_, EntitySpawnReason.NATURAL); diff --git a/patches/net/minecraft/world/level/levelgen/WorldDimensions.java.patch b/patches/net/minecraft/world/level/levelgen/WorldDimensions.java.patch index 33276ce2..a65a43a3 100644 --- a/patches/net/minecraft/world/level/levelgen/WorldDimensions.java.patch +++ b/patches/net/minecraft/world/level/levelgen/WorldDimensions.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/WorldDimensions.java +++ b/net/minecraft/world/level/levelgen/WorldDimensions.java -@@ -36,7 +_,8 @@ +@@ -37,7 +_,8 @@ public record WorldDimensions(Map, LevelStem> dimensions) { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( p_325905_ -> p_325905_.group( diff --git a/patches/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/patches/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch index 1b2ac4b7..63803d46 100644 --- a/patches/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch +++ b/patches/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java +++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java -@@ -91,6 +_,9 @@ +@@ -92,6 +_,9 @@ } public final CompoundTag createTag(StructurePieceSerializationContext p_192645_) { diff --git a/patches/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch b/patches/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch index 71ababbf..79c1cb74 100644 --- a/patches/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch +++ b/patches/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch @@ -4,9 +4,9 @@ public CompoundTag createTag(StructurePieceSerializationContext p_192661_, ChunkPos p_192662_) { CompoundTag compoundtag = new CompoundTag(); if (this.isValid()) { -+ if (p_192661_.registryAccess().registryOrThrow(Registries.STRUCTURE).getKey(this.getStructure()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below ++ if (p_192661_.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(this.getStructure()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below + throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\": \"" + this.getStructure() + "\" unregistered, serializing impossible."); + } - compoundtag.putString("id", p_192661_.registryAccess().registryOrThrow(Registries.STRUCTURE).getKey(this.structure).toString()); + compoundtag.putString("id", p_192661_.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(this.structure).toString()); compoundtag.putInt("ChunkX", p_192662_.x); compoundtag.putInt("ChunkZ", p_192662_.z); diff --git a/patches/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/patches/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index 04e9e46f..5f34e65a 100644 --- a/patches/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/patches/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java -@@ -219,6 +_,10 @@ +@@ -248,6 +_,10 @@ return transform(p_74565_, p_74564_.getMirror(), p_74564_.getRotation(), p_74564_.getRotationPivot()); } @@ -11,7 +11,7 @@ public boolean placeInWorld( ServerLevelAccessor p_230329_, BlockPos p_230330_, BlockPos p_230331_, StructurePlaceSettings p_230332_, RandomSource p_230333_, int p_230334_ ) { -@@ -242,7 +_,7 @@ +@@ -271,7 +_,7 @@ int j1 = Integer.MIN_VALUE; for (StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : processBlockInfos( @@ -20,7 +20,7 @@ )) { BlockPos blockpos = structuretemplate$structureblockinfo.pos; if (boundingbox == null || boundingbox.isInside(blockpos)) { -@@ -355,15 +_,7 @@ +@@ -384,15 +_,7 @@ } if (!p_230332_.isIgnoreEntities()) { @@ -37,7 +37,7 @@ } return true; -@@ -402,12 +_,20 @@ +@@ -433,12 +_,20 @@ } public static List processBlockInfos( @@ -58,7 +58,7 @@ List list = new ArrayList<>(); List list1 = new ArrayList<>(); -@@ -422,7 +_,7 @@ +@@ -453,7 +_,7 @@ while (structuretemplate$structureblockinfo1 != null && iterator.hasNext()) { structuretemplate$structureblockinfo1 = iterator.next() @@ -67,7 +67,7 @@ } if (structuretemplate$structureblockinfo1 != null) { -@@ -438,21 +_,29 @@ +@@ -469,21 +_,29 @@ return list1; } @@ -111,26 +111,26 @@ ListTag listtag = new ListTag(); listtag.add(DoubleTag.valueOf(vec31.x)); listtag.add(DoubleTag.valueOf(vec31.y)); -@@ -460,10 +_,10 @@ - compoundtag.put("Pos", listtag); - compoundtag.remove("UUID"); - createEntityIgnoreException(p_74524_, compoundtag).ifPresent(p_275190_ -> { -- float f = p_275190_.rotate(p_74527_); -- f += p_275190_.mirror(p_74526_) - p_275190_.getYRot(); -+ float f = p_275190_.rotate(placementIn.getRotation()); -+ f += p_275190_.mirror(placementIn.getMirror()) - p_275190_.getYRot(); - p_275190_.moveTo(vec31.x, vec31.y, vec31.z, f, p_275190_.getXRot()); -- if (p_74530_ && p_275190_ instanceof Mob) { -+ if (placementIn.shouldFinalizeEntities() && p_275190_ instanceof Mob) { - ((Mob)p_275190_).finalizeSpawn(p_74524_, p_74524_.getCurrentDifficultyAt(BlockPos.containing(vec31)), MobSpawnType.STRUCTURE, null); - } - -@@ -777,7 +_,7 @@ +@@ -493,10 +_,10 @@ + createEntityIgnoreException(p_74524_, compoundtag) + .ifPresent( + p_275190_ -> { +- float f = p_275190_.rotate(p_74527_); +- f += p_275190_.mirror(p_74526_) - p_275190_.getYRot(); ++ float f = p_275190_.rotate(placementIn.getRotation()); ++ f += p_275190_.mirror(placementIn.getMirror()) - p_275190_.getYRot(); + p_275190_.moveTo(vec31.x, vec31.y, vec31.z, f, p_275190_.getXRot()); +- if (p_74530_ && p_275190_ instanceof Mob) { ++ if (placementIn.shouldFinalizeEntities() && p_275190_ instanceof Mob) { + ((Mob)p_275190_) + .finalizeSpawn(p_74524_, p_74524_.getCurrentDifficultyAt(BlockPos.containing(vec31)), EntitySpawnReason.STRUCTURE, null); + } +@@ -867,7 +_,7 @@ public static final class Palette { private final List blocks; - private final Map> cache = Maps.newHashMap(); + private final Map> cache = Maps.newConcurrentMap(); // Neo: Fixes MC-271899 - Make the global StructureTemplate's palette caches now thread safe for worldgen + @Nullable + private List cachedJigsaws; - Palette(List p_74648_) { - this.blocks = p_74648_; diff --git a/patches/net/minecraft/world/level/lighting/BlockLightEngine.java.patch b/patches/net/minecraft/world/level/lighting/BlockLightEngine.java.patch index 1ddb75ca..7696c79c 100644 --- a/patches/net/minecraft/world/level/lighting/BlockLightEngine.java.patch +++ b/patches/net/minecraft/world/level/lighting/BlockLightEngine.java.patch @@ -12,9 +12,9 @@ @@ -119,7 +_,7 @@ LightChunk lightchunk = this.chunkSource.getChunkForLighting(p_285274_.x, p_285274_.z); if (lightchunk != null) { - lightchunk.findBlockLightSources((p_285266_, p_285452_) -> { -- int i = p_285452_.getLightEmission(); -+ int i = p_285452_.getLightEmission(chunkSource.getLevel(), p_285266_); - this.enqueueIncrease(p_285266_.asLong(), LightEngine.QueueEntry.increaseLightFromEmission(i, isEmptyShape(p_285452_))); + lightchunk.findBlockLightSources((p_360252_, p_360253_) -> { +- int i = p_360253_.getLightEmission(); ++ int i = p_360253_.getLightEmission(chunkSource.getLevel(), p_360252_); + this.enqueueIncrease(p_360252_.asLong(), LightEngine.QueueEntry.increaseLightFromEmission(i, isEmptyShape(p_360253_))); }); } diff --git a/patches/net/minecraft/world/level/lighting/LightEngine.java.patch b/patches/net/minecraft/world/level/lighting/LightEngine.java.patch index 63adb6e1..618090b5 100644 --- a/patches/net/minecraft/world/level/lighting/LightEngine.java.patch +++ b/patches/net/minecraft/world/level/lighting/LightEngine.java.patch @@ -1,11 +1,23 @@ --- a/net/minecraft/world/level/lighting/LightEngine.java +++ b/net/minecraft/world/level/lighting/LightEngine.java -@@ -44,7 +_,7 @@ +@@ -38,11 +_,19 @@ + this.clearChunkCache(); + } + ++ /** ++ * @deprecated Neo: use overload with level context instead ++ */ ++ @Deprecated + public static boolean hasDifferentLightProperties(BlockState p_285110_, BlockState p_285372_) { ++ return hasDifferentLightProperties(net.minecraft.world.level.EmptyBlockGetter.INSTANCE, BlockPos.ZERO, p_285110_, p_285372_); ++ } ++ ++ public static boolean hasDifferentLightProperties(net.minecraft.world.level.BlockGetter level, BlockPos pos, BlockState p_285110_, BlockState p_285372_) { return p_285372_ == p_285110_ ? false - : p_285372_.getLightBlock(p_285159_, p_284985_) != p_285110_.getLightBlock(p_285159_, p_284985_) + : p_285372_.getLightBlock() != p_285110_.getLightBlock() - || p_285372_.getLightEmission() != p_285110_.getLightEmission() -+ || p_285372_.getLightEmission(p_285159_, p_284985_) != p_285110_.getLightEmission(p_285159_, p_284985_) ++ || p_285372_.getLightEmission(level, pos) != p_285110_.getLightEmission(level, pos) || p_285372_.useShapeForLightOcclusion() || p_285110_.useShapeForLightOcclusion(); } diff --git a/patches/net/minecraft/world/level/material/FlowingFluid.java.patch b/patches/net/minecraft/world/level/material/FlowingFluid.java.patch index a0acfa62..29f99b88 100644 --- a/patches/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/patches/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -1,36 +1,36 @@ --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java -@@ -164,7 +_,7 @@ - BlockState blockstate = p_256464_.getBlockState(blockpos); +@@ -171,7 +_,7 @@ + BlockState blockstate = p_376839_.getBlockState(blockpos); FluidState fluidstate = blockstate.getFluidState(); - if (fluidstate.getType().isSame(this) && this.canPassThroughWall(direction, p_256464_, p_76037_, p_76038_, blockpos, blockstate)) { + if (fluidstate.getType().isSame(this) && canPassThroughWall(direction, p_376839_, p_76037_, p_76038_, blockpos, blockstate)) { - if (fluidstate.isSource()) { -+ if (fluidstate.isSource() && net.neoforged.neoforge.event.EventHooks.canCreateFluidSource(p_256464_, blockpos, blockstate)) { ++ if (fluidstate.isSource() && net.neoforged.neoforge.event.EventHooks.canCreateFluidSource(p_376839_, blockpos, blockstate)) { j++; } -@@ -172,7 +_,7 @@ +@@ -179,7 +_,7 @@ } } -- if (this.canConvertToSource(p_256464_) && j >= 2) { +- if (j >= 2 && this.canConvertToSource(p_376839_)) { + if (j >= 2) { - BlockState blockstate1 = p_256464_.getBlockState(p_76037_.below()); + BlockState blockstate1 = p_376839_.getBlockState(blockpos$mutableblockpos.setWithOffset(p_76037_, Direction.DOWN)); FluidState fluidstate1 = blockstate1.getFluidState(); if (blockstate1.isSolid() || this.isSourceBlockOfThisType(fluidstate1)) { -@@ -238,6 +_,15 @@ +@@ -257,6 +_,15 @@ return this.getSource().defaultFluidState().setValue(FALLING, Boolean.valueOf(p_76069_)); } + @Override -+ public boolean canConvertToSource(FluidState state, Level level, BlockPos pos) { ++ public boolean canConvertToSource(FluidState state, ServerLevel level, BlockPos pos) { + return this.canConvertToSource(level); + } + + /** -+ * @deprecated Forge: Use {@link #canConvertToSource(FluidState, Level, BlockPos)} instead. ++ * @deprecated Forge: Use {@link #canConvertToSource(FluidState, ServerLevel, BlockPos)} instead. + */ + @Deprecated - protected abstract boolean canConvertToSource(Level p_256009_); + protected abstract boolean canConvertToSource(ServerLevel p_376940_); protected void spreadTo(LevelAccessor p_76005_, BlockPos p_76006_, BlockState p_76007_, Direction p_76008_, FluidState p_76009_) { diff --git a/patches/net/minecraft/world/level/material/Fluid.java.patch b/patches/net/minecraft/world/level/material/Fluid.java.patch index 9bb749ea..918a9f72 100644 --- a/patches/net/minecraft/world/level/material/Fluid.java.patch +++ b/patches/net/minecraft/world/level/material/Fluid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/Fluid.java +++ b/net/minecraft/world/level/material/Fluid.java -@@ -20,7 +_,7 @@ +@@ -21,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,7 @@ public static final IdMapper FLUID_STATE_REGISTRY = new IdMapper<>(); protected final StateDefinition stateDefinition; private FluidState defaultFluidState; -@@ -100,6 +_,13 @@ +@@ -101,6 +_,13 @@ } public abstract VoxelShape getShape(FluidState p_76137_, BlockGetter p_76138_, BlockPos p_76139_); diff --git a/patches/net/minecraft/world/level/material/FluidState.java.patch b/patches/net/minecraft/world/level/material/FluidState.java.patch index 399850a6..acc03677 100644 --- a/patches/net/minecraft/world/level/material/FluidState.java.patch +++ b/patches/net/minecraft/world/level/material/FluidState.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/FluidState.java +++ b/net/minecraft/world/level/material/FluidState.java -@@ -21,7 +_,7 @@ +@@ -22,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,7 @@ public static final Codec CODEC = codec(BuiltInRegistries.FLUID.byNameCodec(), Fluid::defaultFluidState).stable(); public static final int AMOUNT_MAX = 9; public static final int AMOUNT_FULL = 8; -@@ -113,6 +_,7 @@ +@@ -114,6 +_,7 @@ return this.getType() == p_192918_; } diff --git a/patches/net/minecraft/world/level/material/LavaFluid.java.patch b/patches/net/minecraft/world/level/material/LavaFluid.java.patch index 22bbfb96..8569dec5 100644 --- a/patches/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/patches/net/minecraft/world/level/material/LavaFluid.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java -@@ -87,7 +_,7 @@ - BlockState blockstate = p_230572_.getBlockState(blockpos); +@@ -88,7 +_,7 @@ + BlockState blockstate = p_376493_.getBlockState(blockpos); if (blockstate.isAir()) { - if (this.hasFlammableNeighbours(p_230572_, blockpos)) { -- p_230572_.setBlockAndUpdate(blockpos, BaseFireBlock.getState(p_230572_, blockpos)); -+ p_230572_.setBlockAndUpdate(blockpos, net.neoforged.neoforge.event.EventHooks.fireFluidPlaceBlockEvent(p_230572_, blockpos, p_230573_, BaseFireBlock.getState(p_230572_, blockpos))); + if (this.hasFlammableNeighbours(p_376493_, blockpos)) { +- p_376493_.setBlockAndUpdate(blockpos, BaseFireBlock.getState(p_376493_, blockpos)); ++ p_376493_.setBlockAndUpdate(blockpos, net.neoforged.neoforge.event.EventHooks.fireFluidPlaceBlockEvent(p_376493_, blockpos, p_230573_, BaseFireBlock.getState(p_376493_, blockpos))); return; } } else if (blockstate.blocksMotion()) { -@@ -101,8 +_,8 @@ +@@ -102,8 +_,8 @@ return; } -- if (p_230572_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_230572_, blockpos1)) { -- p_230572_.setBlockAndUpdate(blockpos1.above(), BaseFireBlock.getState(p_230572_, blockpos1)); -+ if (p_230572_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_230572_, blockpos1, Direction.UP)) { -+ p_230572_.setBlockAndUpdate(blockpos1.above(), net.neoforged.neoforge.event.EventHooks.fireFluidPlaceBlockEvent(p_230572_, blockpos1.above(), p_230573_, BaseFireBlock.getState(p_230572_, blockpos1))); +- if (p_376493_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_376493_, blockpos1)) { +- p_376493_.setBlockAndUpdate(blockpos1.above(), BaseFireBlock.getState(p_376493_, blockpos1)); ++ if (p_376493_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_376493_, blockpos1, Direction.UP)) { ++ p_376493_.setBlockAndUpdate(blockpos1.above(), net.neoforged.neoforge.event.EventHooks.fireFluidPlaceBlockEvent(p_376493_, blockpos1.above(), p_230573_, BaseFireBlock.getState(p_376493_, blockpos1))); } } } -@@ -111,7 +_,7 @@ +@@ -112,7 +_,7 @@ private boolean hasFlammableNeighbours(LevelReader p_76228_, BlockPos p_76229_) { for (Direction direction : Direction.values()) { @@ -29,20 +29,18 @@ return true; } } -@@ -119,12 +_,22 @@ +@@ -120,10 +_,20 @@ return false; } + /** @deprecated Forge: use {@link LavaFluid#isFlammable(LevelReader,BlockPos,Direction)} instead */ + @Deprecated private boolean isFlammable(LevelReader p_76246_, BlockPos p_76247_) { - return p_76247_.getY() >= p_76246_.getMinBuildHeight() && p_76247_.getY() < p_76246_.getMaxBuildHeight() && !p_76246_.hasChunkAt(p_76247_) - ? false - : p_76246_.getBlockState(p_76247_).ignitedByLava(); + return p_76246_.isInsideBuildHeight(p_76247_.getY()) && !p_76246_.hasChunkAt(p_76247_) ? false : p_76246_.getBlockState(p_76247_).ignitedByLava(); } + private boolean isFlammable(LevelReader level, BlockPos pos, Direction face) { -+ if (pos.getY() >= level.getMinBuildHeight() && pos.getY() < level.getMaxBuildHeight() && !level.hasChunkAt(pos)) { ++ if (level.isInsideBuildHeight(pos.getY()) && !level.hasChunkAt(pos)) { + return false; + } + BlockState state = level.getBlockState(pos); @@ -52,7 +50,7 @@ @Nullable @Override public ParticleOptions getDripParticle() { -@@ -196,7 +_,7 @@ +@@ -195,7 +_,7 @@ FluidState fluidstate = p_76220_.getFluidState(p_76221_); if (this.is(FluidTags.LAVA) && fluidstate.is(FluidTags.WATER)) { if (p_76222_.getBlock() instanceof LiquidBlock) { diff --git a/patches/net/minecraft/world/level/portal/PortalShape.java.patch b/patches/net/minecraft/world/level/portal/PortalShape.java.patch index 133b3d80..6da90f68 100644 --- a/patches/net/minecraft/world/level/portal/PortalShape.java.patch +++ b/patches/net/minecraft/world/level/portal/PortalShape.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/portal/PortalShape.java +++ b/net/minecraft/world/level/portal/PortalShape.java -@@ -27,7 +_,7 @@ +@@ -28,7 +_,7 @@ public static final int MAX_WIDTH = 21; private static final int MIN_HEIGHT = 3; public static final int MAX_HEIGHT = 21; @@ -8,4 +8,4 @@ + private static final BlockBehaviour.StatePredicate FRAME = net.neoforged.neoforge.common.extensions.IBlockStateExtension::isPortalFrame; private static final float SAFE_TRAVEL_MAX_ENTITY_XY = 4.0F; private static final double SAFE_TRAVEL_MAX_VERTICAL_DELTA = 1.0; - private final LevelAccessor level; + private final Direction.Axis axis; diff --git a/patches/net/minecraft/world/level/saveddata/SavedData.java.patch b/patches/net/minecraft/world/level/saveddata/SavedData.java.patch index ac130d73..ed2c2352 100644 --- a/patches/net/minecraft/world/level/saveddata/SavedData.java.patch +++ b/patches/net/minecraft/world/level/saveddata/SavedData.java.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/world/level/saveddata/SavedData.java +++ b/net/minecraft/world/level/saveddata/SavedData.java -@@ -37,7 +_,7 @@ - NbtUtils.addCurrentDataVersion(compoundtag); - - try { -- NbtIo.writeCompressed(compoundtag, p_77758_.toPath()); -+ net.neoforged.neoforge.common.IOUtilities.writeNbtCompressed(compoundtag, p_77758_.toPath()); - } catch (IOException ioexception) { - LOGGER.error("Could not save data {}", this, ioexception); - } -@@ -47,7 +_,10 @@ +@@ -33,7 +_,10 @@ } public static record Factory( diff --git a/patches/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch b/patches/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch deleted file mode 100644 index ab312154..00000000 --- a/patches/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -+++ b/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -@@ -268,7 +_,7 @@ - } - } - -- public void removeDecoration(String p_164800_) { -+ private void removeDecoration(String p_164800_) { - MapDecoration mapdecoration = this.decorations.remove(p_164800_); - if (mapdecoration != null && mapdecoration.type().value().trackCount()) { - this.trackedDecorationCount--; -@@ -285,7 +_,7 @@ - } - } - -- public void addDecoration( -+ private void addDecoration( - Holder p_335830_, - @Nullable LevelAccessor p_77939_, - String p_77940_, diff --git a/patches/net/minecraft/world/level/storage/DimensionDataStorage.java.patch b/patches/net/minecraft/world/level/storage/DimensionDataStorage.java.patch index ecf3e431..8dd492af 100644 --- a/patches/net/minecraft/world/level/storage/DimensionDataStorage.java.patch +++ b/patches/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -63,7 +_,7 @@ +@@ -69,7 +_,7 @@ } @Nullable - private T readSavedData(BiFunction p_324609_, DataFixTypes p_295832_, String p_164870_) { + private T readSavedData(BiFunction p_324609_, @Nullable DataFixTypes p_295832_, String p_164870_) { try { - File file1 = this.getDataFile(p_164870_); - if (file1.exists()) { -@@ -81,7 +_,7 @@ - this.cache.put(p_164856_, p_164857_); + Path path = this.getDataFile(p_164870_); + if (Files.exists(path)) { +@@ -88,7 +_,7 @@ + p_164857_.setDirty(); } - public CompoundTag readTagFromDisk(String p_78159_, DataFixTypes p_295038_, int p_78160_) throws IOException { + public CompoundTag readTagFromDisk(String p_78159_, @Nullable DataFixTypes p_295038_, int p_78160_) throws IOException { - File file1 = this.getDataFile(p_78159_); - CompoundTag compoundtag1; -@@ -98,9 +_,16 @@ + try ( + InputStream inputstream = Files.newInputStream(this.getDataFile(p_78159_)); +@@ -103,9 +_,16 @@ } } @@ -33,7 +33,20 @@ } + + // Neo: delete any temporary files so that we don't inflate disk space unnecessarily. -+ net.neoforged.neoforge.common.IOUtilities.cleanupTempFiles(this.dataFolder.toPath(), p_78159_); ++ net.neoforged.neoforge.common.IOUtilities.cleanupTempFiles(this.dataFolder, p_78159_); return compoundtag1; } +@@ -156,7 +_,11 @@ + private static CompletableFuture tryWriteAsync(Path p_364583_, CompoundTag p_363128_) { + return CompletableFuture.runAsync(() -> { + try { +- NbtIo.writeCompressed(p_363128_, p_364583_); ++ // Neo: ensure parent directories exist if the SavedData's path contains slashes ++ if (!Files.exists(p_364583_)) { ++ Files.createDirectories(p_364583_.getParent()); ++ } ++ net.neoforged.neoforge.common.IOUtilities.writeNbtCompressed(p_363128_, p_364583_); + } catch (IOException ioexception) { + LOGGER.error("Could not save data to {}", p_364583_.getFileName(), ioexception); + } diff --git a/patches/net/minecraft/world/level/storage/ServerLevelData.java.patch b/patches/net/minecraft/world/level/storage/ServerLevelData.java.patch index d56c58c4..ff29008c 100644 --- a/patches/net/minecraft/world/level/storage/ServerLevelData.java.patch +++ b/patches/net/minecraft/world/level/storage/ServerLevelData.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/storage/ServerLevelData.java +++ b/net/minecraft/world/level/storage/ServerLevelData.java -@@ -87,4 +_,10 @@ - void setGameTime(long p_78617_); - +@@ -90,4 +_,10 @@ void setDayTime(long p_78624_); + + GameRules getGameRules(); + + //Neo + float getDayTimeFraction(); diff --git a/patches/net/minecraft/world/level/storage/loot/LootContext.java.patch b/patches/net/minecraft/world/level/storage/loot/LootContext.java.patch index 533f10a1..2c5260f9 100644 --- a/patches/net/minecraft/world/level/storage/loot/LootContext.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/LootContext.java.patch @@ -64,7 +64,7 @@ @@ -140,6 +_,11 @@ - public LootContextParam getParam() { + public ContextKey getParam() { return this.param; + } + diff --git a/patches/net/minecraft/world/level/storage/loot/LootDataType.java.patch b/patches/net/minecraft/world/level/storage/loot/LootDataType.java.patch index 1fc2c3ab..0cbbb86d 100644 --- a/patches/net/minecraft/world/level/storage/loot/LootDataType.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/LootDataType.java.patch @@ -1,15 +1,14 @@ --- a/net/minecraft/world/level/storage/loot/LootDataType.java +++ b/net/minecraft/world/level/storage/loot/LootDataType.java -@@ -16,7 +_,7 @@ +@@ -9,14 +_,26 @@ + import net.minecraft.world.level.storage.loot.functions.LootItemFunctions; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; - import org.slf4j.Logger; -public record LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.Validator validator) { -+public record LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.Validator validator, @org.jetbrains.annotations.Nullable T defaultValue, Codec> conditionalCodec, java.util.function.BiConsumer idSetter) { - private static final Logger LOGGER = LogUtils.getLogger(); ++public record LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.Validator validator, @org.jetbrains.annotations.Nullable T defaultValue, Codec> conditionalCodec, java.util.function.BiConsumer idSetter) { public static final LootDataType PREDICATE = new LootDataType<>( Registries.PREDICATE, LootItemCondition.DIRECT_CODEC, createSimpleValidator() -@@ -24,17 +_,33 @@ + ); public static final LootDataType MODIFIER = new LootDataType<>( Registries.ITEM_MODIFIER, LootItemFunctions.ROOT_CODEC, createSimpleValidator() ); @@ -24,39 +23,21 @@ + this(registryKey, codec, validator, null, (it, id) -> {}); + } + -+ private LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.Validator validator, @org.jetbrains.annotations.Nullable T defaultValue, java.util.function.BiConsumer idSetter) { ++ private LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.Validator validator, @org.jetbrains.annotations.Nullable T defaultValue, java.util.function.BiConsumer idSetter) { + this(registryKey, codec, validator, defaultValue, net.neoforged.neoforge.common.conditions.ConditionalOps.createConditionalCodec(codec), idSetter); + } public void runValidation(ValidationContext p_279366_, ResourceKey p_336149_, T p_279124_) { this.validator.run(p_279366_, p_336149_, p_279124_); - } - - public Optional deserialize(ResourceLocation p_279253_, DynamicOps p_324006_, V p_324329_) { -- DataResult dataresult = this.codec.parse(p_324006_, p_324329_); -- dataresult.error() -- .ifPresent(p_350259_ -> LOGGER.error("Couldn't parse element {}/{} - {}", this.registryKey.location(), p_279253_, p_350259_.message())); -- return dataresult.result(); -+ var dataresult = this.conditionalCodec.parse(p_324006_, p_324329_); -+ dataresult.error().ifPresent(p_338121_ -> LOGGER.error("Couldn't parse element {}:{} - {}", this.registryKey, p_279253_, p_338121_.message())); -+ return dataresult.result().map(it -> { -+ it.ifPresent(val -> idSetter.accept(val, p_279253_)); -+ T value = it.orElse(defaultValue); -+ if (value instanceof LootTable lootTable) value = (T) net.neoforged.neoforge.event.EventHooks.loadLootTable(p_279253_, lootTable); -+ return value; -+ }); - } - - public static Stream> values() { -@@ -48,9 +_,11 @@ +@@ -33,9 +_,11 @@ } private static LootDataType.Validator createLootTableValidator() { -- return (p_339557_, p_339558_, p_339559_) -> p_339559_.validate( -- p_339557_.setParams(p_339559_.getParamSet()).enterElement("{" + p_339558_.registry() + "/" + p_339558_.location() + "}", p_339558_) +- return (p_380902_, p_380903_, p_380904_) -> p_380904_.validate( +- p_380902_.setContextKeySet(p_380904_.getParamSet()).enterElement("{" + p_380903_.registry() + "/" + p_380903_.location() + "}", p_380903_) + return (p_279333_, p_279227_, p_279406_) -> { + p_279406_.validate( -+ p_279333_.setParams(p_279406_.getParamSet()).enterElement("{" + p_279227_.registry() + ":" + p_279227_.location() + "}", p_279227_) ++ p_279333_.setContextKeySet(p_279406_.getParamSet()).enterElement("{" + p_279227_.registry() + ":" + p_279227_.location() + "}", p_279227_) ); + }; } diff --git a/patches/net/minecraft/world/level/storage/loot/LootParams.java.patch b/patches/net/minecraft/world/level/storage/loot/LootParams.java.patch deleted file mode 100644 index f2d7d0cb..00000000 --- a/patches/net/minecraft/world/level/storage/loot/LootParams.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/storage/loot/LootParams.java -+++ b/net/minecraft/world/level/storage/loot/LootParams.java -@@ -125,7 +_,7 @@ - - public LootParams create(LootContextParamSet p_287701_) { - Set> set = Sets.difference(this.params.keySet(), p_287701_.getAllowed()); -- if (!set.isEmpty()) { -+ if (false && !set.isEmpty()) { // Forge: Allow mods to pass custom loot parameters (not part of the vanilla loot table) to the loot context. - throw new IllegalArgumentException("Parameters not allowed in this parameter set: " + set); - } else { - Set> set1 = Sets.difference(p_287701_.getRequired(), this.params.keySet()); diff --git a/patches/net/minecraft/world/level/storage/loot/LootTable.java.patch b/patches/net/minecraft/world/level/storage/loot/LootTable.java.patch index 8e1d44d1..38d536c3 100644 --- a/patches/net/minecraft/world/level/storage/loot/LootTable.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/LootTable.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/level/storage/loot/LootTable.java +++ b/net/minecraft/world/level/storage/loot/LootTable.java @@ -38,8 +_,8 @@ - p_338123_ -> p_338123_.group( - LootContextParamSets.CODEC.lenientOptionalFieldOf("type", DEFAULT_PARAM_SET).forGetter(p_298001_ -> p_298001_.paramSet), + p_380905_ -> p_380905_.group( + LootContextParamSets.CODEC.lenientOptionalFieldOf("type", DEFAULT_PARAM_SET).forGetter(p_380906_ -> p_380906_.paramSet), ResourceLocation.CODEC.optionalFieldOf("random_sequence").forGetter(p_297998_ -> p_297998_.randomSequence), - LootPool.CODEC.listOf().optionalFieldOf("pools", List.of()).forGetter(p_298002_ -> p_298002_.pools), - LootItemFunctions.ROOT_CODEC.listOf().optionalFieldOf("functions", List.of()).forGetter(p_298000_ -> p_298000_.functions) + net.neoforged.neoforge.common.CommonHooks.lootPoolsCodec(LootPool::setName).optionalFieldOf("pools", List.of()).forGetter(p_298002_ -> p_298002_.pools), + net.neoforged.neoforge.common.conditions.ConditionalOps.decodeListWithElementConditions(LootItemFunctions.ROOT_CODEC).optionalFieldOf("functions", List.of()).forGetter(p_298000_ -> p_298000_.functions) ) - .apply(p_338123_, LootTable::new) + .apply(p_380905_, LootTable::new) ); @@ -53,7 +_,7 @@ - LootTable(LootContextParamSet p_287716_, Optional p_299055_, List p_298390_, List p_298775_) { - this.paramSet = p_287716_; + LootTable(ContextKeySet p_380952_, Optional p_299055_, List p_298390_, List p_298775_) { + this.paramSet = p_380952_; this.randomSequence = p_299055_; - this.pools = p_298390_; + this.pools = Lists.newArrayList(p_298390_); diff --git a/patches/net/minecraft/world/level/storage/loot/functions/EnchantRandomlyFunction.java.patch b/patches/net/minecraft/world/level/storage/loot/functions/EnchantRandomlyFunction.java.patch index 57bef157..d56bd6e4 100644 --- a/patches/net/minecraft/world/level/storage/loot/functions/EnchantRandomlyFunction.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/functions/EnchantRandomlyFunction.java.patch @@ -3,7 +3,7 @@ @@ -59,7 +_,7 @@ Stream> stream = this.options .map(HolderSet::stream) - .orElseGet(() -> p_80430_.getLevel().registryAccess().registryOrThrow(Registries.ENCHANTMENT).holders().map(Function.identity())) + .orElseGet(() -> p_80430_.getLevel().registryAccess().lookupOrThrow(Registries.ENCHANTMENT).listElements().map(Function.identity())) - .filter(p_344686_ -> !flag1 || p_344686_.value().canEnchant(p_80429_)); + .filter(p_344686_ -> !flag1 || p_80429_.supportsEnchantment(p_344686_)); // Neo: Respect IItemExtension#supportsEnchantment List> list = stream.toList(); diff --git a/patches/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch b/patches/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch index 22bb631d..0851d8d1 100644 --- a/patches/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java +++ b/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java -@@ -41,7 +_,7 @@ +@@ -42,7 +_,7 @@ if (optional.isPresent()) { - ItemStack itemstack = optional.get().value().getResultItem(p_81269_.getLevel().registryAccess()); + ItemStack itemstack = optional.get().value().assemble(singlerecipeinput, p_81269_.getLevel().registryAccess()); if (!itemstack.isEmpty()) { - return itemstack.copyWithCount(p_81268_.getCount()); + return itemstack.copyWithCount(p_81268_.getCount() * itemstack.getCount()); // Forge: Support smelting returning multiple diff --git a/patches/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch b/patches/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch index 17ecf039..ad4a552c 100644 --- a/patches/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java +++ b/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java -@@ -20,7 +_,7 @@ - public static final LootContextParamSet EMPTY = register("empty", p_81454_ -> { +@@ -21,7 +_,7 @@ + public static final ContextKeySet EMPTY = register("empty", p_381149_ -> { }); - public static final LootContextParamSet CHEST = register( -- "chest", p_323464_ -> p_323464_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) + public static final ContextKeySet CHEST = register( +- "chest", p_380909_ -> p_380909_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) + "chest", p_81452_ -> p_81452_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY).optional(LootContextParams.ATTACKING_ENTITY) //Forge: Chest minecarts can have killer entities ); - public static final LootContextParamSet COMMAND = register( - "command", p_330195_ -> p_330195_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) -@@ -29,7 +_,7 @@ - "selector", p_81442_ -> p_81442_.required(LootContextParams.ORIGIN).required(LootContextParams.THIS_ENTITY) + public static final ContextKeySet COMMAND = register( + "command", p_380924_ -> p_380924_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) +@@ -30,7 +_,7 @@ + "selector", p_380913_ -> p_380913_.required(LootContextParams.ORIGIN).required(LootContextParams.THIS_ENTITY) ); - public static final LootContextParamSet FISHING = register( -- "fishing", p_81446_ -> p_81446_.required(LootContextParams.ORIGIN).required(LootContextParams.TOOL).optional(LootContextParams.THIS_ENTITY) + public static final ContextKeySet FISHING = register( +- "fishing", p_380928_ -> p_380928_.required(LootContextParams.ORIGIN).required(LootContextParams.TOOL).optional(LootContextParams.THIS_ENTITY) + "fishing", p_81446_ -> p_81446_.required(LootContextParams.ORIGIN).required(LootContextParams.TOOL).optional(LootContextParams.THIS_ENTITY).optional(LootContextParams.ATTACKING_ENTITY) //Forge: Add the fisher as a killer. ); - public static final LootContextParamSet ENTITY = register( + public static final ContextKeySet ENTITY = register( "entity", diff --git a/patches/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch b/patches/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch index c00e7262..69771175 100644 --- a/patches/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java +++ b/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java -@@ -60,7 +_,7 @@ +@@ -59,7 +_,7 @@ @Override public String getId() { diff --git a/patches/net/minecraft/world/phys/AABB.java.patch b/patches/net/minecraft/world/phys/AABB.java.patch index 334c4f33..1f108aea 100644 --- a/patches/net/minecraft/world/phys/AABB.java.patch +++ b/patches/net/minecraft/world/phys/AABB.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/phys/AABB.java +++ b/net/minecraft/world/phys/AABB.java -@@ -10,6 +_,7 @@ +@@ -11,6 +_,7 @@ public class AABB { private static final double EPSILON = 1.0E-7; @@ -8,7 +8,7 @@ public final double minX; public final double minY; public final double minZ; -@@ -528,5 +_,13 @@ +@@ -584,5 +_,13 @@ p_165883_.y + p_165885_ / 2.0, p_165883_.z + p_165886_ / 2.0 ); diff --git a/patches/net/minecraft/world/phys/shapes/MinecartCollisionContext.java.patch b/patches/net/minecraft/world/phys/shapes/MinecartCollisionContext.java.patch new file mode 100644 index 00000000..fec89058 --- /dev/null +++ b/patches/net/minecraft/world/phys/shapes/MinecartCollisionContext.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/phys/shapes/MinecartCollisionContext.java ++++ b/net/minecraft/world/phys/shapes/MinecartCollisionContext.java +@@ -25,7 +_,7 @@ + boolean flag = BaseRailBlock.isRail(blockstate); + if (flag) { + this.ingoreBelow = blockpos.below(); +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, p_366450_.level(), blockpos, p_366450_); + if (railshape.isSlope()) { + this.slopeIgnore = switch (railshape) { + case ASCENDING_EAST -> blockpos.east(); diff --git a/projects/neoforge/build.gradle b/projects/neoforge/build.gradle index af5c1fc6..cf9a7a67 100644 --- a/projects/neoforge/build.gradle +++ b/projects/neoforge/build.gradle @@ -74,11 +74,15 @@ dependencies { runtimeOnly "cpw.mods:bootstraplauncher:${project.bootstraplauncher_version}" moduleOnly "cpw.mods:securejarhandler:${project.securejarhandler_version}" - moduleOnly "org.ow2.asm:asm:${project.asm_version}" - moduleOnly "org.ow2.asm:asm-commons:${project.asm_version}" - moduleOnly "org.ow2.asm:asm-tree:${project.asm_version}" - moduleOnly "org.ow2.asm:asm-util:${project.asm_version}" - moduleOnly "org.ow2.asm:asm-analysis:${project.asm_version}" + for (var asmModule : ["org.ow2.asm:asm", "org.ow2.asm:asm-commons", "org.ow2.asm:asm-tree", "org.ow2.asm:asm-util", "org.ow2.asm:asm-analysis"]) { + moduleOnly(asmModule) { + // Vanilla ships with ASM 9.3 transitively (via their OpenID connect library dependency), we require + // ASM in a more recent version and have to strictly require this to override the strict Minecraft version. + version { + strictly project.asm_version + } + } + } moduleOnly "cpw.mods:bootstraplauncher:${project.bootstraplauncher_version}" moduleOnly "net.neoforged:JarJarFileSystems:${project.jarjar_version}" @@ -151,6 +155,10 @@ dependencies { installer 'commons-lang:commons-lang:2.6-mohist' } +tasks.register("genPatches") { + dependsOn tasks.unpackSourcePatches +} + launcherProfile { arguments { game '--fml.neoForgeVersion' diff --git a/rejects/net/minecraft/commands/arguments/EntityArgument.java.patch.rej b/rejects/net/minecraft/commands/arguments/EntityArgument.java.patch.rej deleted file mode 100644 index ec80a71d..00000000 --- a/rejects/net/minecraft/commands/arguments/EntityArgument.java.patch.rej +++ /dev/null @@ -1,25 +0,0 @@ -++++ REJECTED HUNK: 1 -@@ -94,6 +94,10 @@ - } - } - -+ public EntitySelector parse(StringReader stringreader, boolean overridePermissions) throws CommandSyntaxException { -+ throw new RuntimeException("Not Implemented"); -+ } -+ - public EntitySelector parse(StringReader p_91451_) throws CommandSyntaxException { - int i = 0; - EntitySelectorParser entityselectorparser = new EntitySelectorParser(p_91451_); -++++ END HUNK - -++++ REJECTED HUNK: 2 -@@ -119,7 +123,7 @@ - if (p_91482_.getSource() instanceof SharedSuggestionProvider sharedsuggestionprovider) { - StringReader stringreader = new StringReader(p_91483_.getInput()); - stringreader.setCursor(p_91483_.getStart()); -- EntitySelectorParser entityselectorparser = new EntitySelectorParser(stringreader, sharedsuggestionprovider.hasPermission(2)); -+ EntitySelectorParser entityselectorparser = new EntitySelectorParser(stringreader, net.neoforged.neoforge.common.CommonHooks.canUseEntitySelectors(sharedsuggestionprovider)); - - try { - entityselectorparser.parse(); -++++ END HUNK diff --git a/rejects/net/minecraft/commands/arguments/MessageArgument.java.patch.rej b/rejects/net/minecraft/commands/arguments/MessageArgument.java.patch.rej deleted file mode 100644 index 28569931..00000000 --- a/rejects/net/minecraft/commands/arguments/MessageArgument.java.patch.rej +++ /dev/null @@ -1,11 +0,0 @@ -++++ REJECTED HUNK: 1 -@@ -84,7 +84,7 @@ - - public static record Message(String text, MessageArgument.Part[] parts) { - Component resolveComponent(CommandSourceStack p_232197_) throws CommandSyntaxException { -- return this.toComponent(p_232197_, p_232197_.hasPermission(2)); -+ return this.toComponent(p_232197_, net.neoforged.neoforge.common.CommonHooks.canUseEntitySelectors(p_232197_)); - } - - public Component toComponent(CommandSourceStack p_96850_, boolean p_96851_) throws CommandSyntaxException { -++++ END HUNK diff --git a/rejects/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch.rej b/rejects/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch.rej deleted file mode 100644 index 4dcc3a3c..00000000 --- a/rejects/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch.rej +++ /dev/null @@ -1,41 +0,0 @@ -++++ REJECTED HUNK: 1 -@@ -199,6 +199,14 @@ - }; - } - -+ protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException { -+ throw new RuntimeException("Not Implemented"); -+ } -+ -+ public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException { -+ throw new RuntimeException("Not Implemented"); -+ } -+ - protected void parseSelector() throws CommandSyntaxException { - this.usesSelectors = true; - this.suggestions = this::suggestSelector; -++++ END HUNK - -++++ REJECTED HUNK: 2 -@@ -476,6 +484,9 @@ - } - - this.reader.skip(); -+ EntitySelector forgeSelector = net.neoforged.neoforge.common.command.EntitySelectorManager.parseSelector(this); -+ if (forgeSelector != null) -+ return forgeSelector; - this.parseSelector(); - } else { - this.parseNameOrUUID(); -++++ END HUNK - -++++ REJECTED HUNK: 3 -@@ -492,6 +503,7 @@ - p_121248_.suggest("@s", Component.translatable("argument.entity.selector.self")); - p_121248_.suggest("@e", Component.translatable("argument.entity.selector.allEntities")); - p_121248_.suggest("@n", Component.translatable("argument.entity.selector.nearestEntity")); -+ net.neoforged.neoforge.common.command.EntitySelectorManager.fillSelectorSuggestions(p_121248_); - } - - private CompletableFuture suggestNameOrSelector(SuggestionsBuilder p_121287_, Consumer p_121288_) { -++++ END HUNK diff --git a/rejects/net/minecraft/world/level/block/SculkSensorBlock.java.patch.rej b/rejects/net/minecraft/world/level/block/SculkSensorBlock.java.patch.rej deleted file mode 100644 index fb18419b..00000000 --- a/rejects/net/minecraft/world/level/block/SculkSensorBlock.java.patch.rej +++ /dev/null @@ -1,19 +0,0 @@ -++++ REJECTED HUNK: 1 -@@ -292,8 +292,13 @@ - @Override - protected void spawnAfterBreak(BlockState p_222142_, ServerLevel p_222143_, BlockPos p_222144_, ItemStack p_222145_, boolean p_222146_) { - super.spawnAfterBreak(p_222142_, p_222143_, p_222144_, p_222145_, p_222146_); -- if (p_222146_) { -- this.tryDropExperience(p_222143_, p_222144_, p_222145_, ConstantInt.of(5)); -- } -+ } -+ -+ // Neo: Patch-in override for getExpDrop. Original vanilla logic passes ConstantInt.of(5) to tryDropExperience. -+ @Override -+ public int getExpDrop(BlockState state, net.minecraft.world.level.LevelAccessor level, BlockPos pos, -+ @org.jetbrains.annotations.Nullable net.minecraft.world.level.block.entity.BlockEntity blockEntity, -+ @org.jetbrains.annotations.Nullable net.minecraft.world.entity.Entity breaker, ItemStack tool) { -+ return 5; - } - } -++++ END HUNK diff --git a/rejects/net/minecraft/world/level/block/entity/BlockEntity.java.patch.rej b/rejects/net/minecraft/world/level/block/entity/BlockEntity.java.patch.rej deleted file mode 100644 index 7a73c595..00000000 --- a/rejects/net/minecraft/world/level/block/entity/BlockEntity.java.patch.rej +++ /dev/null @@ -1,92 +0,0 @@ -++++ REJECTED HUNK: 3 -@@ -61,6 +63,8 @@ - } - - protected void loadAdditional(CompoundTag p_338466_, HolderLookup.Provider p_338445_) { -+ if (p_338466_.contains("NeoForgeData", net.minecraft.nbt.Tag.TAG_COMPOUND)) this.customPersistentData = p_338466_.getCompound("NeoForgeData"); -+ if (p_338466_.contains(ATTACHMENTS_NBT_KEY, net.minecraft.nbt.Tag.TAG_COMPOUND)) deserializeAttachments(p_338445_, p_338466_.getCompound(ATTACHMENTS_NBT_KEY)); - } - - public final void loadWithComponents(CompoundTag p_338356_, HolderLookup.Provider p_338558_) { -++++ END HUNK - -++++ REJECTED HUNK: 4 -@@ -76,6 +80,9 @@ - } - - protected void saveAdditional(CompoundTag p_187471_, HolderLookup.Provider p_323635_) { -+ if (this.customPersistentData != null) p_187471_.put("NeoForgeData", this.customPersistentData.copy()); -+ var attachmentsTag = serializeAttachments(p_323635_); -+ if (attachmentsTag != null) p_187471_.put(ATTACHMENTS_NBT_KEY, attachmentsTag); - } - - public final CompoundTag saveWithFullMetadata(HolderLookup.Provider p_323767_) { -++++ END HUNK - -++++ REJECTED HUNK: 5 -@@ -205,10 +212,14 @@ - - public void setRemoved() { - this.remove = true; -+ this.invalidateCapabilities(); -+ requestModelDataUpdate(); - } - - public void clearRemoved() { - this.remove = false; -+ // Neo: invalidate capabilities on block entity placement -+ invalidateCapabilities(); - } - - public boolean triggerEvent(int p_58889_, int p_58890_) { -++++ END HUNK - -++++ REJECTED HUNK: 6 -@@ -231,6 +242,27 @@ - return this.type; - } - -+ @Override -+ public CompoundTag getPersistentData() { -+ if (this.customPersistentData == null) -+ this.customPersistentData = new CompoundTag(); -+ return this.customPersistentData; -+ } -+ -+ @Override -+ @Nullable -+ public final T setData(net.neoforged.neoforge.attachment.AttachmentType type, T data) { -+ setChanged(); -+ return super.setData(type, data); -+ } -+ -+ @Override -+ @Nullable -+ public final T removeData(net.neoforged.neoforge.attachment.AttachmentType type) { -+ setChanged(); -+ return super.removeData(type); -+ } -+ - @Deprecated - public void setBlockState(BlockState p_155251_) { - this.blockState = p_155251_; -++++ END HUNK - -++++ REJECTED HUNK: 7 -@@ -309,5 +341,15 @@ - T get(DataComponentType p_338658_); - - T getOrDefault(DataComponentType p_338573_, T p_338734_); -+ -+ // Neo: Utility for modded component types, to remove the need to invoke '.value()' -+ @Nullable -+ default T get(java.util.function.Supplier> componentType) { -+ return get(componentType.get()); -+ } -+ -+ default T getOrDefault(java.util.function.Supplier> componentType, T value) { -+ return getOrDefault(componentType.get(), value); -+ } - } - } -++++ END HUNK diff --git a/rejects/net/minecraft/world/level/chunk/LevelChunk.java.patch.rej b/rejects/net/minecraft/world/level/chunk/LevelChunk.java.patch.rej deleted file mode 100644 index 34958294..00000000 --- a/rejects/net/minecraft/world/level/chunk/LevelChunk.java.patch.rej +++ /dev/null @@ -1,160 +0,0 @@ -++++ REJECTED HUNK: 4 -@@ -322,6 +323,10 @@ - @Nullable - public BlockEntity getBlockEntity(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { - BlockEntity blockentity = this.blockEntities.get(p_62868_); -+ if (blockentity != null && blockentity.isRemoved()) { -+ blockEntities.remove(p_62868_); -+ blockentity = null; -+ } - if (blockentity == null) { - CompoundTag compoundtag = this.pendingBlockEntities.remove(p_62868_); - if (compoundtag != null) { -++++ END HUNK - -++++ REJECTED HUNK: 5 -@@ -339,9 +344,6 @@ - this.addAndRegisterBlockEntity(blockentity); - } - } -- } else if (blockentity.isRemoved()) { -- this.blockEntities.remove(p_62868_); -- return null; - } - - return blockentity; -++++ END HUNK - -++++ REJECTED HUNK: 6 -@@ -355,6 +357,7 @@ - } - - this.updateBlockEntityTicker(p_156391_); -+ this.level.addFreshBlockEntities(java.util.List.of(p_156391_)); - } - } - -++++ END HUNK - -++++ REJECTED HUNK: 7 -@@ -398,6 +401,7 @@ - BlockEntity blockentity = this.blockEntities.put(blockpos.immutable(), p_156374_); - if (blockentity != null && blockentity != p_156374_) { - blockentity.setRemoved(); -+ auxLightManager.removeLightAt(blockpos); - } - } - } -++++ END HUNK - -++++ REJECTED HUNK: 8 -@@ -407,9 +411,14 @@ - public CompoundTag getBlockEntityNbtForSaving(BlockPos p_62932_, HolderLookup.Provider p_323699_) { - BlockEntity blockentity = this.getBlockEntity(p_62932_); - if (blockentity != null && !blockentity.isRemoved()) { -+ try { - CompoundTag compoundtag1 = blockentity.saveWithFullMetadata(this.level.registryAccess()); - compoundtag1.putBoolean("keepPacked", false); - return compoundtag1; -+ } catch (Exception e) { -+ LOGGER.error("A BlockEntity type {} has thrown an exception trying to write state. It will not persist, Report this to the mod author", blockentity.getClass().getName(), e); -+ return null; -+ } - } else { - CompoundTag compoundtag = this.pendingBlockEntities.get(p_62932_); - if (compoundtag != null) { -++++ END HUNK - -++++ REJECTED HUNK: 9 -@@ -431,6 +440,7 @@ - } - - blockentity.setRemoved(); -+ auxLightManager.removeLightAt(p_62919_); - } - } - -++++ END HUNK - -++++ REJECTED HUNK: 10 -@@ -491,7 +501,7 @@ - p_187974_.accept((p_338077_, p_338078_, p_338079_) -> { - BlockEntity blockentity = this.getBlockEntity(p_338077_, LevelChunk.EntityCreationType.IMMEDIATE); - if (blockentity != null && p_338079_ != null && blockentity.getType() == p_338078_) { -- blockentity.loadWithComponents(p_338079_, this.level.registryAccess()); -+ blockentity.handleUpdateTag(p_338079_, this.level.registryAccess()); - } - }); - } -++++ END HUNK - -++++ REJECTED HUNK: 11 -@@ -599,6 +609,7 @@ - } - - public void clearAllBlockEntities() { -+ this.blockEntities.values().forEach(BlockEntity::onChunkUnloaded); - this.blockEntities.values().forEach(BlockEntity::setRemoved); - this.blockEntities.clear(); - this.tickersInLevel.values().forEach(p_187966_ -> p_187966_.rebind(NULL_TICKER)); -++++ END HUNK - -++++ REJECTED HUNK: 12 -@@ -606,6 +617,7 @@ - } - - public void registerAllBlockEntitiesAfterLevelLoad() { -+ this.level.addFreshBlockEntities(this.blockEntities.values()); - this.blockEntities.values().forEach(p_187988_ -> { - if (this.level instanceof ServerLevel serverlevel) { - this.addGameEventListener(p_187988_, serverlevel); -++++ END HUNK - -++++ REJECTED HUNK: 13 -@@ -657,6 +669,15 @@ - return new LevelChunk.BoundTickingBlockEntity<>(p_156376_, p_156377_); - } - -+ // FORGE START -+ private final net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager auxLightManager = new net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager(this); -+ -+ @Override -+ public net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager getAuxLightManager(ChunkPos pos) { -+ return auxLightManager; -+ } -+ // FORGE END -+ - class BoundTickingBlockEntity implements TickingBlockEntity { - private final T blockEntity; - private final BlockEntityTicker ticker; -++++ END HUNK - -++++ REJECTED HUNK: 14 -@@ -674,6 +695,7 @@ - if (LevelChunk.this.isTicking(blockpos)) { - try { - ProfilerFiller profilerfiller = LevelChunk.this.level.getProfiler(); -+ net.neoforged.neoforge.server.timings.TimeTracker.BLOCK_ENTITY_UPDATE.trackStart(blockEntity); - profilerfiller.push(this::getType); - BlockState blockstate = LevelChunk.this.getBlockState(blockpos); - if (this.blockEntity.getType().isValid(blockstate)) { -++++ END HUNK - -++++ REJECTED HUNK: 15 -@@ -695,7 +717,15 @@ - CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking block entity"); - CrashReportCategory crashreportcategory = crashreport.addCategory("Block entity being ticked"); - this.blockEntity.fillCrashReportCategory(crashreportcategory); -+ -+ if (net.neoforged.neoforge.common.NeoForgeConfig.SERVER.removeErroringBlockEntities.get()) { -+ LOGGER.error("{}", crashreport.getFriendlyReport(net.minecraft.ReportType.CRASH)); -+ blockEntity.setRemoved(); -+ LevelChunk.this.removeBlockEntity(blockEntity.getBlockPos()); -+ } else - throw new ReportedException(crashreport); -+ } finally { -+ net.neoforged.neoforge.server.timings.TimeTracker.BLOCK_ENTITY_UPDATE.trackEnd(blockEntity); - } - } - } -++++ END HUNK diff --git a/src/generated/resources/assets/c/lang/en_us.json b/src/generated/resources/assets/c/lang/en_us.json index 1988c30b..3c27e29b 100644 --- a/src/generated/resources/assets/c/lang/en_us.json +++ b/src/generated/resources/assets/c/lang/en_us.json @@ -53,6 +53,8 @@ "tag.block.c.hidden_from_recipe_viewers": "Hidden From Recipe Viewers", "tag.block.c.netherracks": "Netherracks", "tag.block.c.obsidians": "Obsidians", + "tag.block.c.obsidians.crying": "Crying Obsidians", + "tag.block.c.obsidians.normal": "Normal Obsidians", "tag.block.c.ore_bearing_ground.deepslate": "Deepslate Ore Bearing Ground", "tag.block.c.ore_bearing_ground.netherrack": "Netherrack Ore Bearing Ground", "tag.block.c.ore_bearing_ground.stone": "Stone Ore Bearing Ground", @@ -108,6 +110,8 @@ "tag.block.c.storage_blocks.redstone": "Redstone Storage Blocks", "tag.block.c.storage_blocks.slime": "Slime Storage Blocks", "tag.block.c.storage_blocks.wheat": "Wheat Storage Blocks", + "tag.block.c.stripped_logs": "Stripped Logs", + "tag.block.c.stripped_woods": "Stripped Woods", "tag.block.c.villager_job_sites": "Villager Job Sites", "tag.block.neoforge.enderman_place_on_blacklist": "Enderman Place On Blacklist", "tag.block.neoforge.needs_gold_tool": "Needs Gold Tools", @@ -126,6 +130,7 @@ "tag.entity_type.c.minecarts": "Minecarts", "tag.entity_type.c.teleporting_not_supported": "Teleporting Not Supported", "tag.fluid.c.beetroot_soup": "Beetroot Soup", + "tag.fluid.c.experience": "Experience", "tag.fluid.c.gaseous": "Gaseous", "tag.fluid.c.hidden_from_recipe_viewers": "Hidden From Recipe Viewers", "tag.fluid.c.honey": "Honey", @@ -237,6 +242,7 @@ "tag.item.c.foods.food_poisoning": "Food Poisoning Foods", "tag.item.c.foods.fruit": "Fruits", "tag.item.c.foods.golden": "Golden Foods", + "tag.item.c.foods.pie": "Pies", "tag.item.c.foods.raw_fish": "Raw Fishes", "tag.item.c.foods.raw_meat": "Raw Meats", "tag.item.c.foods.soup": "Soups", @@ -272,6 +278,8 @@ "tag.item.c.nuggets.gold": "Gold Nuggets", "tag.item.c.nuggets.iron": "Iron Nuggets", "tag.item.c.obsidians": "Obsidians", + "tag.item.c.obsidians.crying": "Crying Obsidians", + "tag.item.c.obsidians.normal": "Normal Obsidians", "tag.item.c.ore_bearing_ground.deepslate": "Deepslate Ore Bearing Ground", "tag.item.c.ore_bearing_ground.netherrack": "Netherrack Ore Bearing Ground", "tag.item.c.ore_bearing_ground.stone": "Stone Ore Bearing Ground", @@ -342,6 +350,8 @@ "tag.item.c.storage_blocks.slime": "Slime Storage Blocks", "tag.item.c.storage_blocks.wheat": "Wheat Storage Blocks", "tag.item.c.strings": "Strings", + "tag.item.c.stripped_logs": "Stripped Log Blocks", + "tag.item.c.stripped_woods": "Stripped Wood Blocks", "tag.item.c.tools": "Tools", "tag.item.c.tools.bow": "Bows", "tag.item.c.tools.brush": "Brushes", diff --git a/src/generated/resources/data/c/tags/block/obsidians.json b/src/generated/resources/data/c/tags/block/obsidians.json index aa3315f6..3986b73d 100644 --- a/src/generated/resources/data/c/tags/block/obsidians.json +++ b/src/generated/resources/data/c/tags/block/obsidians.json @@ -1,6 +1,7 @@ { "values": [ - "minecraft:obsidian", + "#c:obsidians/normal", + "#c:obsidians/crying", { "id": "#forge:obsidian", "required": false diff --git a/src/generated/resources/data/c/tags/block/obsidians/crying.json b/src/generated/resources/data/c/tags/block/obsidians/crying.json new file mode 100644 index 00000000..2e8b37a1 --- /dev/null +++ b/src/generated/resources/data/c/tags/block/obsidians/crying.json @@ -0,0 +1,5 @@ +{ + "values": [ + "minecraft:crying_obsidian" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/block/obsidians/normal.json b/src/generated/resources/data/c/tags/block/obsidians/normal.json new file mode 100644 index 00000000..17024845 --- /dev/null +++ b/src/generated/resources/data/c/tags/block/obsidians/normal.json @@ -0,0 +1,5 @@ +{ + "values": [ + "minecraft:obsidian" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/block/stripped_logs.json b/src/generated/resources/data/c/tags/block/stripped_logs.json new file mode 100644 index 00000000..ae69c996 --- /dev/null +++ b/src/generated/resources/data/c/tags/block/stripped_logs.json @@ -0,0 +1,13 @@ +{ + "values": [ + "minecraft:stripped_acacia_log", + "minecraft:stripped_bamboo_block", + "minecraft:stripped_birch_log", + "minecraft:stripped_cherry_log", + "minecraft:stripped_dark_oak_log", + "minecraft:stripped_jungle_log", + "minecraft:stripped_mangrove_log", + "minecraft:stripped_oak_log", + "minecraft:stripped_spruce_log" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/block/stripped_woods.json b/src/generated/resources/data/c/tags/block/stripped_woods.json new file mode 100644 index 00000000..19754289 --- /dev/null +++ b/src/generated/resources/data/c/tags/block/stripped_woods.json @@ -0,0 +1,12 @@ +{ + "values": [ + "minecraft:stripped_acacia_wood", + "minecraft:stripped_birch_wood", + "minecraft:stripped_cherry_wood", + "minecraft:stripped_dark_oak_wood", + "minecraft:stripped_jungle_wood", + "minecraft:stripped_mangrove_wood", + "minecraft:stripped_oak_wood", + "minecraft:stripped_spruce_wood" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/entity_type/boats.json b/src/generated/resources/data/c/tags/entity_type/boats.json index 58e89216..13475972 100644 --- a/src/generated/resources/data/c/tags/entity_type/boats.json +++ b/src/generated/resources/data/c/tags/entity_type/boats.json @@ -1,7 +1,15 @@ { "values": [ - "minecraft:boat", - "minecraft:chest_boat", + "#minecraft:boat", + "minecraft:oak_chest_boat", + "minecraft:spruce_chest_boat", + "minecraft:birch_chest_boat", + "minecraft:jungle_chest_boat", + "minecraft:acacia_chest_boat", + "minecraft:cherry_chest_boat", + "minecraft:dark_oak_chest_boat", + "minecraft:mangrove_chest_boat", + "minecraft:bamboo_chest_raft", { "id": "#forge:boats", "required": false diff --git a/src/generated/resources/data/c/tags/item/foods/candies.json b/src/generated/resources/data/c/tags/fluid/experience.json similarity index 100% rename from src/generated/resources/data/c/tags/item/foods/candies.json rename to src/generated/resources/data/c/tags/fluid/experience.json diff --git a/src/generated/resources/data/c/tags/item/foods.json b/src/generated/resources/data/c/tags/item/foods.json index 78e6a194..401cd7e0 100644 --- a/src/generated/resources/data/c/tags/item/foods.json +++ b/src/generated/resources/data/c/tags/item/foods.json @@ -16,6 +16,7 @@ "#c:foods/cooked_fish", "#c:foods/soup", "#c:foods/candy", + "#c:foods/pie", "#c:foods/golden", "#c:foods/edible_when_placed", "#c:foods/food_poisoning" diff --git a/src/generated/resources/data/c/tags/item/foods/berries.json b/src/generated/resources/data/c/tags/item/foods/berries.json deleted file mode 100644 index 500bd943..00000000 --- a/src/generated/resources/data/c/tags/item/foods/berries.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "values": [ - "minecraft:sweet_berries", - "minecraft:glow_berries" - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/foods/breads.json b/src/generated/resources/data/c/tags/item/foods/breads.json deleted file mode 100644 index 7873bb3c..00000000 --- a/src/generated/resources/data/c/tags/item/foods/breads.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "values": [ - "minecraft:bread" - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/foods/cooked_fishes.json b/src/generated/resources/data/c/tags/item/foods/cooked_fishes.json deleted file mode 100644 index 4e459bea..00000000 --- a/src/generated/resources/data/c/tags/item/foods/cooked_fishes.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "values": [ - "minecraft:cooked_cod", - "minecraft:cooked_salmon" - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/foods/cooked_meats.json b/src/generated/resources/data/c/tags/item/foods/cooked_meats.json deleted file mode 100644 index ffd78dc1..00000000 --- a/src/generated/resources/data/c/tags/item/foods/cooked_meats.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "values": [ - "minecraft:cooked_beef", - "minecraft:cooked_porkchop", - "minecraft:cooked_chicken", - "minecraft:cooked_rabbit", - "minecraft:cooked_mutton" - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/foods/cookies.json b/src/generated/resources/data/c/tags/item/foods/cookies.json deleted file mode 100644 index a7c0dc91..00000000 --- a/src/generated/resources/data/c/tags/item/foods/cookies.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "values": [ - "minecraft:cookie" - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/foods/fruits.json b/src/generated/resources/data/c/tags/item/foods/fruits.json deleted file mode 100644 index 895ad4a3..00000000 --- a/src/generated/resources/data/c/tags/item/foods/fruits.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "values": [ - "minecraft:apple", - "minecraft:golden_apple", - "minecraft:enchanted_golden_apple" - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/foods/pie.json b/src/generated/resources/data/c/tags/item/foods/pie.json new file mode 100644 index 00000000..7589c5f2 --- /dev/null +++ b/src/generated/resources/data/c/tags/item/foods/pie.json @@ -0,0 +1,5 @@ +{ + "values": [ + "minecraft:pumpkin_pie" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/foods/raw_fishes.json b/src/generated/resources/data/c/tags/item/foods/raw_fishes.json deleted file mode 100644 index 83d056aa..00000000 --- a/src/generated/resources/data/c/tags/item/foods/raw_fishes.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "values": [ - "minecraft:cod", - "minecraft:salmon", - "minecraft:tropical_fish", - "minecraft:pufferfish" - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/foods/raw_meats.json b/src/generated/resources/data/c/tags/item/foods/raw_meats.json deleted file mode 100644 index c548b57f..00000000 --- a/src/generated/resources/data/c/tags/item/foods/raw_meats.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "values": [ - "minecraft:beef", - "minecraft:porkchop", - "minecraft:chicken", - "minecraft:rabbit", - "minecraft:mutton" - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/foods/soups.json b/src/generated/resources/data/c/tags/item/foods/soups.json deleted file mode 100644 index 5a1a3392..00000000 --- a/src/generated/resources/data/c/tags/item/foods/soups.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "values": [ - "minecraft:beetroot_soup", - "minecraft:mushroom_stew", - "minecraft:rabbit_stew", - "minecraft:suspicious_stew" - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/foods/vegetables.json b/src/generated/resources/data/c/tags/item/foods/vegetables.json deleted file mode 100644 index 0476304c..00000000 --- a/src/generated/resources/data/c/tags/item/foods/vegetables.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "values": [ - "minecraft:carrot", - "minecraft:golden_carrot", - "minecraft:potato", - "minecraft:melon_slice", - "minecraft:beetroot" - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/obsidians.json b/src/generated/resources/data/c/tags/item/obsidians.json index aa3315f6..3986b73d 100644 --- a/src/generated/resources/data/c/tags/item/obsidians.json +++ b/src/generated/resources/data/c/tags/item/obsidians.json @@ -1,6 +1,7 @@ { "values": [ - "minecraft:obsidian", + "#c:obsidians/normal", + "#c:obsidians/crying", { "id": "#forge:obsidian", "required": false diff --git a/src/generated/resources/data/c/tags/item/obsidians/crying.json b/src/generated/resources/data/c/tags/item/obsidians/crying.json new file mode 100644 index 00000000..2e8b37a1 --- /dev/null +++ b/src/generated/resources/data/c/tags/item/obsidians/crying.json @@ -0,0 +1,5 @@ +{ + "values": [ + "minecraft:crying_obsidian" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/obsidians/normal.json b/src/generated/resources/data/c/tags/item/obsidians/normal.json new file mode 100644 index 00000000..17024845 --- /dev/null +++ b/src/generated/resources/data/c/tags/item/obsidians/normal.json @@ -0,0 +1,5 @@ +{ + "values": [ + "minecraft:obsidian" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/stripped_logs.json b/src/generated/resources/data/c/tags/item/stripped_logs.json new file mode 100644 index 00000000..ae69c996 --- /dev/null +++ b/src/generated/resources/data/c/tags/item/stripped_logs.json @@ -0,0 +1,13 @@ +{ + "values": [ + "minecraft:stripped_acacia_log", + "minecraft:stripped_bamboo_block", + "minecraft:stripped_birch_log", + "minecraft:stripped_cherry_log", + "minecraft:stripped_dark_oak_log", + "minecraft:stripped_jungle_log", + "minecraft:stripped_mangrove_log", + "minecraft:stripped_oak_log", + "minecraft:stripped_spruce_log" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/stripped_woods.json b/src/generated/resources/data/c/tags/item/stripped_woods.json new file mode 100644 index 00000000..19754289 --- /dev/null +++ b/src/generated/resources/data/c/tags/item/stripped_woods.json @@ -0,0 +1,12 @@ +{ + "values": [ + "minecraft:stripped_acacia_wood", + "minecraft:stripped_birch_wood", + "minecraft:stripped_cherry_wood", + "minecraft:stripped_dark_oak_wood", + "minecraft:stripped_jungle_wood", + "minecraft:stripped_mangrove_wood", + "minecraft:stripped_oak_wood", + "minecraft:stripped_spruce_wood" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/acacia_chest_boat.json b/src/generated/resources/data/minecraft/recipe/acacia_chest_boat.json index 96b6a5a3..745f8237 100644 --- a/src/generated/resources/data/minecraft/recipe/acacia_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/acacia_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:acacia_boat" - } + "minecraft:acacia_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/acacia_fence.json b/src/generated/resources/data/minecraft/recipe/acacia_fence.json index 1df661b7..abc4d37c 100644 --- a/src/generated/resources/data/minecraft/recipe/acacia_fence.json +++ b/src/generated/resources/data/minecraft/recipe/acacia_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:acacia_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:acacia_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/acacia_fence_gate.json b/src/generated/resources/data/minecraft/recipe/acacia_fence_gate.json index 01c8f1d4..af366bf3 100644 --- a/src/generated/resources/data/minecraft/recipe/acacia_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/acacia_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:acacia_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:acacia_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/acacia_sign.json b/src/generated/resources/data/minecraft/recipe/acacia_sign.json index 8591a10c..3232b1b8 100644 --- a/src/generated/resources/data/minecraft/recipe/acacia_sign.json +++ b/src/generated/resources/data/minecraft/recipe/acacia_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:acacia_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:acacia_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/activator_rail.json b/src/generated/resources/data/minecraft/recipe/activator_rail.json index f3e8a6d9..555bb300 100644 --- a/src/generated/resources/data/minecraft/recipe/activator_rail.json +++ b/src/generated/resources/data/minecraft/recipe/activator_rail.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:redstone_torch" - }, - "S": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "minecraft:redstone_torch", + "S": "#c:rods/wooden", + "X": "#c:ingots/iron" }, "pattern": [ "XSX", diff --git a/src/generated/resources/data/minecraft/recipe/andesite.json b/src/generated/resources/data/minecraft/recipe/andesite.json index 909e6271..5dfdf07c 100644 --- a/src/generated/resources/data/minecraft/recipe/andesite.json +++ b/src/generated/resources/data/minecraft/recipe/andesite.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "building", "ingredients": [ - { - "item": "minecraft:diorite" - }, - { - "tag": "c:cobblestones/normal" - } + "minecraft:diorite", + "#c:cobblestones/normal" ], "result": { "count": 2, diff --git a/src/generated/resources/data/minecraft/recipe/anvil.json b/src/generated/resources/data/minecraft/recipe/anvil.json index 405668a7..e50cd1fe 100644 --- a/src/generated/resources/data/minecraft/recipe/anvil.json +++ b/src/generated/resources/data/minecraft/recipe/anvil.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "I": { - "item": "minecraft:iron_block" - }, - "i": { - "tag": "c:ingots/iron" - } + "I": "minecraft:iron_block", + "i": "#c:ingots/iron" }, "pattern": [ "III", diff --git a/src/generated/resources/data/minecraft/recipe/armor_stand.json b/src/generated/resources/data/minecraft/recipe/armor_stand.json index 55e7dbea..a3ad60d1 100644 --- a/src/generated/resources/data/minecraft/recipe/armor_stand.json +++ b/src/generated/resources/data/minecraft/recipe/armor_stand.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "/": { - "tag": "c:rods/wooden" - }, - "_": { - "item": "minecraft:smooth_stone_slab" - } + "/": "#c:rods/wooden", + "_": "minecraft:smooth_stone_slab" }, "pattern": [ "///", diff --git a/src/generated/resources/data/minecraft/recipe/arrow.json b/src/generated/resources/data/minecraft/recipe/arrow.json index 5b160e1c..8948fda6 100644 --- a/src/generated/resources/data/minecraft/recipe/arrow.json +++ b/src/generated/resources/data/minecraft/recipe/arrow.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:flint" - }, - "Y": { - "item": "minecraft:feather" - } + "#": "#c:rods/wooden", + "X": "minecraft:flint", + "Y": "minecraft:feather" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/bamboo_chest_raft.json b/src/generated/resources/data/minecraft/recipe/bamboo_chest_raft.json index a26be3e5..0b97b7f4 100644 --- a/src/generated/resources/data/minecraft/recipe/bamboo_chest_raft.json +++ b/src/generated/resources/data/minecraft/recipe/bamboo_chest_raft.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:bamboo_raft" - } + "minecraft:bamboo_raft" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/bamboo_fence.json b/src/generated/resources/data/minecraft/recipe/bamboo_fence.json index 190c83b6..d3641301 100644 --- a/src/generated/resources/data/minecraft/recipe/bamboo_fence.json +++ b/src/generated/resources/data/minecraft/recipe/bamboo_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:bamboo_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:bamboo_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/bamboo_fence_gate.json b/src/generated/resources/data/minecraft/recipe/bamboo_fence_gate.json index 1d2e0f10..444acda7 100644 --- a/src/generated/resources/data/minecraft/recipe/bamboo_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/bamboo_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:bamboo_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:bamboo_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/bamboo_sign.json b/src/generated/resources/data/minecraft/recipe/bamboo_sign.json index 2ea52885..79d256d9 100644 --- a/src/generated/resources/data/minecraft/recipe/bamboo_sign.json +++ b/src/generated/resources/data/minecraft/recipe/bamboo_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:bamboo_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:bamboo_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/birch_chest_boat.json b/src/generated/resources/data/minecraft/recipe/birch_chest_boat.json index 92de5a6d..3043b219 100644 --- a/src/generated/resources/data/minecraft/recipe/birch_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/birch_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:birch_boat" - } + "minecraft:birch_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/birch_fence.json b/src/generated/resources/data/minecraft/recipe/birch_fence.json index fef03a74..f340e905 100644 --- a/src/generated/resources/data/minecraft/recipe/birch_fence.json +++ b/src/generated/resources/data/minecraft/recipe/birch_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:birch_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:birch_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/birch_fence_gate.json b/src/generated/resources/data/minecraft/recipe/birch_fence_gate.json index c0f380a7..55e6c513 100644 --- a/src/generated/resources/data/minecraft/recipe/birch_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/birch_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:birch_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:birch_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/birch_sign.json b/src/generated/resources/data/minecraft/recipe/birch_sign.json index c7a1c36a..94b286ed 100644 --- a/src/generated/resources/data/minecraft/recipe/birch_sign.json +++ b/src/generated/resources/data/minecraft/recipe/birch_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:birch_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:birch_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/black_banner.json b/src/generated/resources/data/minecraft/recipe/black_banner.json index 26cb29a8..7f676002 100644 --- a/src/generated/resources/data/minecraft/recipe/black_banner.json +++ b/src/generated/resources/data/minecraft/recipe/black_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:black_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:black_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/black_candle.json b/src/generated/resources/data/minecraft/recipe/black_candle.json new file mode 100644 index 00000000..5d54b78d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/black_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/black" + ], + "result": { + "count": 1, + "id": "minecraft:black_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/black_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/black_concrete_powder.json new file mode 100644 index 00000000..10288802 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/black_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/black", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:black_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/black_stained_glass.json b/src/generated/resources/data/minecraft/recipe/black_stained_glass.json new file mode 100644 index 00000000..4373c795 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/black_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/black" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:black_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/black_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/black_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..68ad84bb --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/black_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/black" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:black_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/black_terracotta.json b/src/generated/resources/data/minecraft/recipe/black_terracotta.json new file mode 100644 index 00000000..8dcb0044 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/black_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/black" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:black_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/blast_furnace.json b/src/generated/resources/data/minecraft/recipe/blast_furnace.json index 6b73dce3..eb2c292a 100644 --- a/src/generated/resources/data/minecraft/recipe/blast_furnace.json +++ b/src/generated/resources/data/minecraft/recipe/blast_furnace.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:smooth_stone" - }, - "I": { - "tag": "c:ingots/iron" - }, - "X": { - "item": "minecraft:furnace" - } + "#": "minecraft:smooth_stone", + "I": "#c:ingots/iron", + "X": "minecraft:furnace" }, "pattern": [ "III", diff --git a/src/generated/resources/data/minecraft/recipe/blue_banner.json b/src/generated/resources/data/minecraft/recipe/blue_banner.json index afb3cddb..a98940c6 100644 --- a/src/generated/resources/data/minecraft/recipe/blue_banner.json +++ b/src/generated/resources/data/minecraft/recipe/blue_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:blue_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:blue_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/blue_candle.json b/src/generated/resources/data/minecraft/recipe/blue_candle.json new file mode 100644 index 00000000..34f58060 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/blue_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/blue" + ], + "result": { + "count": 1, + "id": "minecraft:blue_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/blue_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/blue_concrete_powder.json new file mode 100644 index 00000000..0c04ee5a --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/blue_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/blue", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:blue_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/blue_stained_glass.json b/src/generated/resources/data/minecraft/recipe/blue_stained_glass.json new file mode 100644 index 00000000..d58eff4d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/blue_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/blue" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:blue_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/blue_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/blue_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..02431bf0 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/blue_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/blue" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:blue_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/blue_terracotta.json b/src/generated/resources/data/minecraft/recipe/blue_terracotta.json new file mode 100644 index 00000000..58d3ee05 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/blue_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/blue" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:blue_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/bolt_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/bolt_armor_trim_smithing_template.json index c7dcf7eb..e5db1679 100644 --- a/src/generated/resources/data/minecraft/recipe/bolt_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/bolt_armor_trim_smithing_template.json @@ -2,20 +2,12 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, + "#": "#c:gems/diamond", "C": [ - { - "item": "minecraft:copper_block" - }, - { - "item": "minecraft:waxed_copper_block" - } + "minecraft:copper_block", + "minecraft:waxed_copper_block" ], - "S": { - "item": "minecraft:bolt_armor_trim_smithing_template" - } + "S": "minecraft:bolt_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/bow.json b/src/generated/resources/data/minecraft/recipe/bow.json index b531f496..5831fc36 100644 --- a/src/generated/resources/data/minecraft/recipe/bow.json +++ b/src/generated/resources/data/minecraft/recipe/bow.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:strings" - } + "#": "#c:rods/wooden", + "X": "#c:strings" }, "pattern": [ " #X", diff --git a/src/generated/resources/data/minecraft/recipe/brown_banner.json b/src/generated/resources/data/minecraft/recipe/brown_banner.json index b3b8c24a..5394a3d3 100644 --- a/src/generated/resources/data/minecraft/recipe/brown_banner.json +++ b/src/generated/resources/data/minecraft/recipe/brown_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:brown_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:brown_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/brown_candle.json b/src/generated/resources/data/minecraft/recipe/brown_candle.json new file mode 100644 index 00000000..730b8025 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/brown_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/brown" + ], + "result": { + "count": 1, + "id": "minecraft:brown_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/brown_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/brown_concrete_powder.json new file mode 100644 index 00000000..32a7ffd0 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/brown_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/brown", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:brown_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/brown_stained_glass.json b/src/generated/resources/data/minecraft/recipe/brown_stained_glass.json new file mode 100644 index 00000000..a74be306 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/brown_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/brown" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:brown_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/brown_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/brown_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..0ab288f7 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/brown_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/brown" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:brown_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/brown_terracotta.json b/src/generated/resources/data/minecraft/recipe/brown_terracotta.json new file mode 100644 index 00000000..1447b2e5 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/brown_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/brown" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:brown_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/brush.json b/src/generated/resources/data/minecraft/recipe/brush.json index ff366537..4fc5863c 100644 --- a/src/generated/resources/data/minecraft/recipe/brush.json +++ b/src/generated/resources/data/minecraft/recipe/brush.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/copper" - }, - "I": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:feather" - } + "#": "#c:ingots/copper", + "I": "#c:rods/wooden", + "X": "minecraft:feather" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/bucket.json b/src/generated/resources/data/minecraft/recipe/bucket.json index 6da8ba3d..692ea8b7 100644 --- a/src/generated/resources/data/minecraft/recipe/bucket.json +++ b/src/generated/resources/data/minecraft/recipe/bucket.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "# #", diff --git a/src/generated/resources/data/minecraft/recipe/bundle.json b/src/generated/resources/data/minecraft/recipe/bundle.json new file mode 100644 index 00000000..fb9cad86 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/bundle.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "minecraft:leather", + "-": "#c:strings" + }, + "pattern": [ + "-", + "#" + ], + "result": { + "count": 1, + "id": "minecraft:bundle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/calibrated_sculk_sensor.json b/src/generated/resources/data/minecraft/recipe/calibrated_sculk_sensor.json index 5cb919ad..7b748c17 100644 --- a/src/generated/resources/data/minecraft/recipe/calibrated_sculk_sensor.json +++ b/src/generated/resources/data/minecraft/recipe/calibrated_sculk_sensor.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:gems/amethyst" - }, - "X": { - "item": "minecraft:sculk_sensor" - } + "#": "#c:gems/amethyst", + "X": "minecraft:sculk_sensor" }, "pattern": [ " # ", diff --git a/src/generated/resources/data/minecraft/recipe/campfire.json b/src/generated/resources/data/minecraft/recipe/campfire.json index de8dffe4..fd2f3375 100644 --- a/src/generated/resources/data/minecraft/recipe/campfire.json +++ b/src/generated/resources/data/minecraft/recipe/campfire.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "C": { - "tag": "minecraft:coals" - }, - "L": { - "tag": "minecraft:logs" - }, - "S": { - "tag": "c:rods/wooden" - } + "C": "#minecraft:coals", + "L": "#minecraft:logs", + "S": "#c:rods/wooden" }, "pattern": [ " S ", diff --git a/src/generated/resources/data/minecraft/recipe/candle.json b/src/generated/resources/data/minecraft/recipe/candle.json index c19d2b0e..6cb6864e 100644 --- a/src/generated/resources/data/minecraft/recipe/candle.json +++ b/src/generated/resources/data/minecraft/recipe/candle.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "H": { - "item": "minecraft:honeycomb" - }, - "S": { - "tag": "c:strings" - } + "H": "minecraft:honeycomb", + "S": "#c:strings" }, "pattern": [ "S", diff --git a/src/generated/resources/data/minecraft/recipe/cauldron.json b/src/generated/resources/data/minecraft/recipe/cauldron.json index 9fbb8b5a..101a0b54 100644 --- a/src/generated/resources/data/minecraft/recipe/cauldron.json +++ b/src/generated/resources/data/minecraft/recipe/cauldron.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "# #", diff --git a/src/generated/resources/data/minecraft/recipe/chain.json b/src/generated/resources/data/minecraft/recipe/chain.json index 057c9304..5e16cbe1 100644 --- a/src/generated/resources/data/minecraft/recipe/chain.json +++ b/src/generated/resources/data/minecraft/recipe/chain.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "I": { - "tag": "c:ingots/iron" - }, - "N": { - "tag": "c:nuggets/iron" - } + "I": "#c:ingots/iron", + "N": "#c:nuggets/iron" }, "pattern": [ "N", diff --git a/src/generated/resources/data/minecraft/recipe/cherry_chest_boat.json b/src/generated/resources/data/minecraft/recipe/cherry_chest_boat.json index c5806df8..1a6fb591 100644 --- a/src/generated/resources/data/minecraft/recipe/cherry_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/cherry_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:cherry_boat" - } + "minecraft:cherry_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/cherry_fence.json b/src/generated/resources/data/minecraft/recipe/cherry_fence.json index c1993868..9866480f 100644 --- a/src/generated/resources/data/minecraft/recipe/cherry_fence.json +++ b/src/generated/resources/data/minecraft/recipe/cherry_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:cherry_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:cherry_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/cherry_fence_gate.json b/src/generated/resources/data/minecraft/recipe/cherry_fence_gate.json index d3f75095..7ad275d0 100644 --- a/src/generated/resources/data/minecraft/recipe/cherry_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/cherry_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:cherry_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:cherry_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/cherry_sign.json b/src/generated/resources/data/minecraft/recipe/cherry_sign.json index fbd15b6e..000659bd 100644 --- a/src/generated/resources/data/minecraft/recipe/cherry_sign.json +++ b/src/generated/resources/data/minecraft/recipe/cherry_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:cherry_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:cherry_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/chest_minecart.json b/src/generated/resources/data/minecraft/recipe/chest_minecart.json index 160f7813..961f8952 100644 --- a/src/generated/resources/data/minecraft/recipe/chest_minecart.json +++ b/src/generated/resources/data/minecraft/recipe/chest_minecart.json @@ -3,17 +3,11 @@ "category": "misc", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:minecart" - } + "minecraft:minecart" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/clock.json b/src/generated/resources/data/minecraft/recipe/clock.json index 276fe557..0ffa5dfe 100644 --- a/src/generated/resources/data/minecraft/recipe/clock.json +++ b/src/generated/resources/data/minecraft/recipe/clock.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/gold" - }, - "X": { - "item": "minecraft:redstone" - } + "#": "#c:ingots/gold", + "X": "minecraft:redstone" }, "pattern": [ " # ", diff --git a/src/generated/resources/data/minecraft/recipe/coast_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/coast_armor_trim_smithing_template.json index b507e536..91af5fba 100644 --- a/src/generated/resources/data/minecraft/recipe/coast_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/coast_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "c:cobblestones/normal" - }, - "S": { - "item": "minecraft:coast_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#c:cobblestones/normal", + "S": "minecraft:coast_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/compass.json b/src/generated/resources/data/minecraft/recipe/compass.json index 3c7cbcb0..89310bdf 100644 --- a/src/generated/resources/data/minecraft/recipe/compass.json +++ b/src/generated/resources/data/minecraft/recipe/compass.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/iron" - }, - "X": { - "item": "minecraft:redstone" - } + "#": "#c:ingots/iron", + "X": "minecraft:redstone" }, "pattern": [ " # ", diff --git a/src/generated/resources/data/minecraft/recipe/copper_door.json b/src/generated/resources/data/minecraft/recipe/copper_door.json index b4010399..544440c5 100644 --- a/src/generated/resources/data/minecraft/recipe/copper_door.json +++ b/src/generated/resources/data/minecraft/recipe/copper_door.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/copper" - } + "#": "#c:ingots/copper" }, "pattern": [ "##", diff --git a/src/generated/resources/data/minecraft/recipe/copper_trapdoor.json b/src/generated/resources/data/minecraft/recipe/copper_trapdoor.json index 2e8d8efe..2a117e7c 100644 --- a/src/generated/resources/data/minecraft/recipe/copper_trapdoor.json +++ b/src/generated/resources/data/minecraft/recipe/copper_trapdoor.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/copper" - } + "#": "#c:ingots/copper" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/crafter.json b/src/generated/resources/data/minecraft/recipe/crafter.json index b01e9c25..8db88e04 100644 --- a/src/generated/resources/data/minecraft/recipe/crafter.json +++ b/src/generated/resources/data/minecraft/recipe/crafter.json @@ -2,18 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - }, - "C": { - "item": "minecraft:crafting_table" - }, - "D": { - "item": "minecraft:dropper" - }, - "R": { - "item": "minecraft:redstone" - } + "#": "#c:ingots/iron", + "C": "minecraft:crafting_table", + "D": "minecraft:dropper", + "R": "minecraft:redstone" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/crimson_fence.json b/src/generated/resources/data/minecraft/recipe/crimson_fence.json index 7b9e1742..20e9d8a6 100644 --- a/src/generated/resources/data/minecraft/recipe/crimson_fence.json +++ b/src/generated/resources/data/minecraft/recipe/crimson_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:crimson_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:crimson_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/crimson_fence_gate.json b/src/generated/resources/data/minecraft/recipe/crimson_fence_gate.json index 69537991..fdbdfa0f 100644 --- a/src/generated/resources/data/minecraft/recipe/crimson_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/crimson_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:crimson_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:crimson_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/crimson_sign.json b/src/generated/resources/data/minecraft/recipe/crimson_sign.json index 3bb6d2cd..b1752420 100644 --- a/src/generated/resources/data/minecraft/recipe/crimson_sign.json +++ b/src/generated/resources/data/minecraft/recipe/crimson_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:crimson_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:crimson_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/crossbow.json b/src/generated/resources/data/minecraft/recipe/crossbow.json index 87d3fb5b..96364225 100644 --- a/src/generated/resources/data/minecraft/recipe/crossbow.json +++ b/src/generated/resources/data/minecraft/recipe/crossbow.json @@ -2,18 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "$": { - "item": "minecraft:tripwire_hook" - }, - "&": { - "tag": "c:ingots/iron" - }, - "~": { - "tag": "c:strings" - } + "#": "#c:rods/wooden", + "$": "minecraft:tripwire_hook", + "&": "#c:ingots/iron", + "~": "#c:strings" }, "pattern": [ "#&#", diff --git a/src/generated/resources/data/minecraft/recipe/cyan_banner.json b/src/generated/resources/data/minecraft/recipe/cyan_banner.json index 7c029672..2efc2367 100644 --- a/src/generated/resources/data/minecraft/recipe/cyan_banner.json +++ b/src/generated/resources/data/minecraft/recipe/cyan_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:cyan_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:cyan_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/cyan_candle.json b/src/generated/resources/data/minecraft/recipe/cyan_candle.json new file mode 100644 index 00000000..50c38c52 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/cyan" + ], + "result": { + "count": 1, + "id": "minecraft:cyan_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/cyan_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/cyan_concrete_powder.json new file mode 100644 index 00000000..37639265 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/cyan", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:cyan_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/cyan_dye.json b/src/generated/resources/data/minecraft/recipe/cyan_dye.json new file mode 100644 index 00000000..da65344e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_dye.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "cyan_dye", + "ingredients": [ + "#c:dyes/blue", + "#c:dyes/green" + ], + "result": { + "count": 2, + "id": "minecraft:cyan_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/cyan_stained_glass.json b/src/generated/resources/data/minecraft/recipe/cyan_stained_glass.json new file mode 100644 index 00000000..a7981f9a --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/cyan" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:cyan_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/cyan_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/cyan_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..007546af --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/cyan" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:cyan_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/cyan_terracotta.json b/src/generated/resources/data/minecraft/recipe/cyan_terracotta.json new file mode 100644 index 00000000..ed9858a7 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/cyan" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:cyan_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dark_oak_chest_boat.json b/src/generated/resources/data/minecraft/recipe/dark_oak_chest_boat.json index 8396336c..e7dd8b53 100644 --- a/src/generated/resources/data/minecraft/recipe/dark_oak_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/dark_oak_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:dark_oak_boat" - } + "minecraft:dark_oak_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/dark_oak_fence.json b/src/generated/resources/data/minecraft/recipe/dark_oak_fence.json index ba37e3f8..d5c3933b 100644 --- a/src/generated/resources/data/minecraft/recipe/dark_oak_fence.json +++ b/src/generated/resources/data/minecraft/recipe/dark_oak_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:dark_oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:dark_oak_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/dark_oak_fence_gate.json b/src/generated/resources/data/minecraft/recipe/dark_oak_fence_gate.json index b8365d4a..d7db1861 100644 --- a/src/generated/resources/data/minecraft/recipe/dark_oak_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/dark_oak_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:dark_oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:dark_oak_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/dark_oak_sign.json b/src/generated/resources/data/minecraft/recipe/dark_oak_sign.json index 4d53a6d2..aeb6ace8 100644 --- a/src/generated/resources/data/minecraft/recipe/dark_oak_sign.json +++ b/src/generated/resources/data/minecraft/recipe/dark_oak_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:dark_oak_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:dark_oak_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/dark_prismarine.json b/src/generated/resources/data/minecraft/recipe/dark_prismarine.json new file mode 100644 index 00000000..c81c46bf --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dark_prismarine.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "key": { + "I": "#c:dyes/black", + "S": "minecraft:prismarine_shard" + }, + "pattern": [ + "SSS", + "SIS", + "SSS" + ], + "result": { + "count": 1, + "id": "minecraft:dark_prismarine" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/detector_rail.json b/src/generated/resources/data/minecraft/recipe/detector_rail.json index 97238ca6..aa0d8b1f 100644 --- a/src/generated/resources/data/minecraft/recipe/detector_rail.json +++ b/src/generated/resources/data/minecraft/recipe/detector_rail.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:stone_pressure_plate" - }, - "R": { - "item": "minecraft:redstone" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "minecraft:stone_pressure_plate", + "R": "minecraft:redstone", + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_axe.json b/src/generated/resources/data/minecraft/recipe/diamond_axe.json index 118f99e5..81cfd048 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_axe.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_boots.json b/src/generated/resources/data/minecraft/recipe/diamond_boots.json index 7d6ace85..38ea7f8e 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_boots.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_boots.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_chestplate.json b/src/generated/resources/data/minecraft/recipe/diamond_chestplate.json index 46ad865d..bace9a7d 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_chestplate.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_chestplate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_helmet.json b/src/generated/resources/data/minecraft/recipe/diamond_helmet.json index 50a88a09..59067194 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_helmet.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_helmet.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_hoe.json b/src/generated/resources/data/minecraft/recipe/diamond_hoe.json index b2bf02dd..6a770c04 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_hoe.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_leggings.json b/src/generated/resources/data/minecraft/recipe/diamond_leggings.json index 5df56358..7992a0d4 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_leggings.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_leggings.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_pickaxe.json b/src/generated/resources/data/minecraft/recipe/diamond_pickaxe.json index 3397993a..bc06ce4a 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_shovel.json b/src/generated/resources/data/minecraft/recipe/diamond_shovel.json index ae4f9eb9..ff947a6f 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_shovel.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_sword.json b/src/generated/resources/data/minecraft/recipe/diamond_sword.json index 338ca632..cb872879 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_sword.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/diorite.json b/src/generated/resources/data/minecraft/recipe/diorite.json index 54714b8f..35427a73 100644 --- a/src/generated/resources/data/minecraft/recipe/diorite.json +++ b/src/generated/resources/data/minecraft/recipe/diorite.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "C": { - "tag": "c:cobblestones/normal" - }, - "Q": { - "item": "minecraft:quartz" - } + "C": "#c:cobblestones/normal", + "Q": "minecraft:quartz" }, "pattern": [ "CQ", diff --git a/src/generated/resources/data/minecraft/recipe/dispenser.json b/src/generated/resources/data/minecraft/recipe/dispenser.json index 6ab105c1..08d2b51f 100644 --- a/src/generated/resources/data/minecraft/recipe/dispenser.json +++ b/src/generated/resources/data/minecraft/recipe/dispenser.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:cobblestones/normal" - }, - "R": { - "item": "minecraft:redstone" - }, - "X": { - "item": "minecraft:bow" - } + "#": "#c:cobblestones/normal", + "R": "minecraft:redstone", + "X": "minecraft:bow" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/dropper.json b/src/generated/resources/data/minecraft/recipe/dropper.json index e358894c..a079f7c1 100644 --- a/src/generated/resources/data/minecraft/recipe/dropper.json +++ b/src/generated/resources/data/minecraft/recipe/dropper.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:cobblestones/normal" - }, - "R": { - "item": "minecraft:redstone" - } + "#": "#c:cobblestones/normal", + "R": "minecraft:redstone" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/dune_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/dune_armor_trim_smithing_template.json index 905e1f3f..a732119f 100644 --- a/src/generated/resources/data/minecraft/recipe/dune_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/dune_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:sandstone" - }, - "S": { - "item": "minecraft:dune_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:sandstone", + "S": "minecraft:dune_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/dye_black_bed.json b/src/generated/resources/data/minecraft/recipe/dye_black_bed.json new file mode 100644 index 00000000..46ce620b --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_black_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/black", + [ + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:black_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_black_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_black_carpet.json new file mode 100644 index 00000000..24345b76 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_black_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/black", + [ + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:black_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_black_wool.json b/src/generated/resources/data/minecraft/recipe/dye_black_wool.json new file mode 100644 index 00000000..4b00f9de --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_black_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/black", + [ + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:black_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_blue_bed.json b/src/generated/resources/data/minecraft/recipe/dye_blue_bed.json new file mode 100644 index 00000000..1addcaaf --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_blue_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/blue", + [ + "minecraft:black_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:blue_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_blue_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_blue_carpet.json new file mode 100644 index 00000000..f936b365 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_blue_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/blue", + [ + "minecraft:black_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:blue_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_blue_wool.json b/src/generated/resources/data/minecraft/recipe/dye_blue_wool.json new file mode 100644 index 00000000..1e41106f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_blue_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/blue", + [ + "minecraft:black_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:blue_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_brown_bed.json b/src/generated/resources/data/minecraft/recipe/dye_brown_bed.json new file mode 100644 index 00000000..acd45c9c --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_brown_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/brown", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:brown_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_brown_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_brown_carpet.json new file mode 100644 index 00000000..40fd195d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_brown_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/brown", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:brown_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_brown_wool.json b/src/generated/resources/data/minecraft/recipe/dye_brown_wool.json new file mode 100644 index 00000000..ce725581 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_brown_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/brown", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:brown_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_cyan_bed.json b/src/generated/resources/data/minecraft/recipe/dye_cyan_bed.json new file mode 100644 index 00000000..58c42b41 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_cyan_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/cyan", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:cyan_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_cyan_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_cyan_carpet.json new file mode 100644 index 00000000..d3568935 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_cyan_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/cyan", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:cyan_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_cyan_wool.json b/src/generated/resources/data/minecraft/recipe/dye_cyan_wool.json new file mode 100644 index 00000000..3c655132 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_cyan_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/cyan", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:cyan_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_gray_bed.json b/src/generated/resources/data/minecraft/recipe/dye_gray_bed.json new file mode 100644 index 00000000..e65ec79a --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_gray_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/gray", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:gray_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_gray_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_gray_carpet.json new file mode 100644 index 00000000..0c93c78c --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_gray_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/gray", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:gray_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_gray_wool.json b/src/generated/resources/data/minecraft/recipe/dye_gray_wool.json new file mode 100644 index 00000000..54b7a841 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_gray_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/gray", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:gray_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_green_bed.json b/src/generated/resources/data/minecraft/recipe/dye_green_bed.json new file mode 100644 index 00000000..d743ad31 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_green_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/green", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:green_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_green_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_green_carpet.json new file mode 100644 index 00000000..575f6b4e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_green_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/green", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:green_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_green_wool.json b/src/generated/resources/data/minecraft/recipe/dye_green_wool.json new file mode 100644 index 00000000..63e86df3 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_green_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/green", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:green_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_blue_bed.json b/src/generated/resources/data/minecraft/recipe/dye_light_blue_bed.json new file mode 100644 index 00000000..fd5df881 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_blue_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/light_blue", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_blue_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_blue_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_light_blue_carpet.json new file mode 100644 index 00000000..b9f92de4 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_blue_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/light_blue", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_blue_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_blue_wool.json b/src/generated/resources/data/minecraft/recipe/dye_light_blue_wool.json new file mode 100644 index 00000000..9c97901e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_blue_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/light_blue", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_blue_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_gray_bed.json b/src/generated/resources/data/minecraft/recipe/dye_light_gray_bed.json new file mode 100644 index 00000000..9a859ed1 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_gray_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/light_gray", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_gray_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_gray_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_light_gray_carpet.json new file mode 100644 index 00000000..f0d0c19a --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_gray_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/light_gray", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_gray_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_gray_wool.json b/src/generated/resources/data/minecraft/recipe/dye_light_gray_wool.json new file mode 100644 index 00000000..701df4f9 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_gray_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/light_gray", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_gray_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_lime_bed.json b/src/generated/resources/data/minecraft/recipe/dye_lime_bed.json new file mode 100644 index 00000000..af4ec42f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_lime_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/lime", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:lime_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_lime_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_lime_carpet.json new file mode 100644 index 00000000..4a0a8df0 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_lime_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/lime", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:lime_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_lime_wool.json b/src/generated/resources/data/minecraft/recipe/dye_lime_wool.json new file mode 100644 index 00000000..9cfaecd1 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_lime_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/lime", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:lime_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_magenta_bed.json b/src/generated/resources/data/minecraft/recipe/dye_magenta_bed.json new file mode 100644 index 00000000..f6683771 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_magenta_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/magenta", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:magenta_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_magenta_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_magenta_carpet.json new file mode 100644 index 00000000..7e97162e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_magenta_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/magenta", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:magenta_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_magenta_wool.json b/src/generated/resources/data/minecraft/recipe/dye_magenta_wool.json new file mode 100644 index 00000000..b5cb50c8 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_magenta_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/magenta", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:magenta_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_orange_bed.json b/src/generated/resources/data/minecraft/recipe/dye_orange_bed.json new file mode 100644 index 00000000..4f051cff --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_orange_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/orange", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:orange_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_orange_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_orange_carpet.json new file mode 100644 index 00000000..a4271e57 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_orange_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/orange", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:orange_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_orange_wool.json b/src/generated/resources/data/minecraft/recipe/dye_orange_wool.json new file mode 100644 index 00000000..0b89a2fe --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_orange_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/orange", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:orange_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_pink_bed.json b/src/generated/resources/data/minecraft/recipe/dye_pink_bed.json new file mode 100644 index 00000000..6c597606 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_pink_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/pink", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:pink_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_pink_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_pink_carpet.json new file mode 100644 index 00000000..bda90f99 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_pink_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/pink", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:pink_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_pink_wool.json b/src/generated/resources/data/minecraft/recipe/dye_pink_wool.json new file mode 100644 index 00000000..bb15342a --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_pink_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/pink", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:pink_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_purple_bed.json b/src/generated/resources/data/minecraft/recipe/dye_purple_bed.json new file mode 100644 index 00000000..ab9de930 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_purple_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/purple", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:purple_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_purple_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_purple_carpet.json new file mode 100644 index 00000000..1c23eee2 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_purple_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/purple", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:purple_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_purple_wool.json b/src/generated/resources/data/minecraft/recipe/dye_purple_wool.json new file mode 100644 index 00000000..8d26252d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_purple_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/purple", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:purple_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_red_bed.json b/src/generated/resources/data/minecraft/recipe/dye_red_bed.json new file mode 100644 index 00000000..1fe4e977 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_red_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/red", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:red_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_red_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_red_carpet.json new file mode 100644 index 00000000..5d778fac --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_red_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/red", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:red_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_red_wool.json b/src/generated/resources/data/minecraft/recipe/dye_red_wool.json new file mode 100644 index 00000000..cfd0569b --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_red_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/red", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:red_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_white_bed.json b/src/generated/resources/data/minecraft/recipe/dye_white_bed.json new file mode 100644 index 00000000..759f3294 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_white_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/white", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:white_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_white_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_white_carpet.json new file mode 100644 index 00000000..9065897b --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_white_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/white", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:white_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_white_wool.json b/src/generated/resources/data/minecraft/recipe/dye_white_wool.json new file mode 100644 index 00000000..f88f447f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_white_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/white", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:white_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_yellow_bed.json b/src/generated/resources/data/minecraft/recipe/dye_yellow_bed.json new file mode 100644 index 00000000..f336bb85 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_yellow_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/yellow", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:yellow_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_yellow_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_yellow_carpet.json new file mode 100644 index 00000000..81f9c193 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_yellow_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/yellow", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:yellow_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_yellow_wool.json b/src/generated/resources/data/minecraft/recipe/dye_yellow_wool.json new file mode 100644 index 00000000..7cb4a1f1 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_yellow_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/yellow", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:yellow_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/enchanting_table.json b/src/generated/resources/data/minecraft/recipe/enchanting_table.json index 0b202c95..a18e62aa 100644 --- a/src/generated/resources/data/minecraft/recipe/enchanting_table.json +++ b/src/generated/resources/data/minecraft/recipe/enchanting_table.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:obsidian" - }, - "B": { - "item": "minecraft:book" - }, - "D": { - "tag": "c:gems/diamond" - } + "#": "minecraft:obsidian", + "B": "minecraft:book", + "D": "#c:gems/diamond" }, "pattern": [ " B ", diff --git a/src/generated/resources/data/minecraft/recipe/eye_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/eye_armor_trim_smithing_template.json index f4183152..24c0e2e4 100644 --- a/src/generated/resources/data/minecraft/recipe/eye_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/eye_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:end_stone" - }, - "S": { - "item": "minecraft:eye_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:end_stone", + "S": "minecraft:eye_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/fishing_rod.json b/src/generated/resources/data/minecraft/recipe/fishing_rod.json index 72690672..8308c1ef 100644 --- a/src/generated/resources/data/minecraft/recipe/fishing_rod.json +++ b/src/generated/resources/data/minecraft/recipe/fishing_rod.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:strings" - } + "#": "#c:rods/wooden", + "X": "#c:strings" }, "pattern": [ " #", diff --git a/src/generated/resources/data/minecraft/recipe/flint_and_steel.json b/src/generated/resources/data/minecraft/recipe/flint_and_steel.json index c1ecbca5..291b1860 100644 --- a/src/generated/resources/data/minecraft/recipe/flint_and_steel.json +++ b/src/generated/resources/data/minecraft/recipe/flint_and_steel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "equipment", "ingredients": [ - { - "tag": "c:ingots/iron" - }, - { - "item": "minecraft:flint" - } + "#c:ingots/iron", + "minecraft:flint" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/flow_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/flow_armor_trim_smithing_template.json index 3b8d02a5..958fdf6b 100644 --- a/src/generated/resources/data/minecraft/recipe/flow_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/flow_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:breeze_rod" - }, - "S": { - "item": "minecraft:flow_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:breeze_rod", + "S": "minecraft:flow_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/glistering_melon_slice.json b/src/generated/resources/data/minecraft/recipe/glistering_melon_slice.json index 52c02f80..d9f7cb56 100644 --- a/src/generated/resources/data/minecraft/recipe/glistering_melon_slice.json +++ b/src/generated/resources/data/minecraft/recipe/glistering_melon_slice.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:nuggets/gold" - }, - "X": { - "item": "minecraft:melon_slice" - } + "#": "#c:nuggets/gold", + "X": "minecraft:melon_slice" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/gold_ingot_from_nuggets.json b/src/generated/resources/data/minecraft/recipe/gold_ingot_from_nuggets.json index ca6e7b86..e1e752fd 100644 --- a/src/generated/resources/data/minecraft/recipe/gold_ingot_from_nuggets.json +++ b/src/generated/resources/data/minecraft/recipe/gold_ingot_from_nuggets.json @@ -3,9 +3,7 @@ "category": "misc", "group": "gold_ingot", "key": { - "#": { - "tag": "c:nuggets/gold" - } + "#": "#c:nuggets/gold" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/golden_apple.json b/src/generated/resources/data/minecraft/recipe/golden_apple.json index 6839d31d..0a029564 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_apple.json +++ b/src/generated/resources/data/minecraft/recipe/golden_apple.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/gold" - }, - "X": { - "item": "minecraft:apple" - } + "#": "#c:ingots/gold", + "X": "minecraft:apple" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/golden_axe.json b/src/generated/resources/data/minecraft/recipe/golden_axe.json index ed95ebdd..aad3355e 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_axe.json +++ b/src/generated/resources/data/minecraft/recipe/golden_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/golden_boots.json b/src/generated/resources/data/minecraft/recipe/golden_boots.json index 0b9010aa..baede9b2 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_boots.json +++ b/src/generated/resources/data/minecraft/recipe/golden_boots.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/golden_carrot.json b/src/generated/resources/data/minecraft/recipe/golden_carrot.json index 444588c0..de198430 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_carrot.json +++ b/src/generated/resources/data/minecraft/recipe/golden_carrot.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:nuggets/gold" - }, - "X": { - "item": "minecraft:carrot" - } + "#": "#c:nuggets/gold", + "X": "minecraft:carrot" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/golden_chestplate.json b/src/generated/resources/data/minecraft/recipe/golden_chestplate.json index edd79c99..44610c5b 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_chestplate.json +++ b/src/generated/resources/data/minecraft/recipe/golden_chestplate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/golden_helmet.json b/src/generated/resources/data/minecraft/recipe/golden_helmet.json index f275fa75..77e0c12b 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_helmet.json +++ b/src/generated/resources/data/minecraft/recipe/golden_helmet.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/golden_hoe.json b/src/generated/resources/data/minecraft/recipe/golden_hoe.json index 6a305f1b..6a31db7e 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_hoe.json +++ b/src/generated/resources/data/minecraft/recipe/golden_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/golden_leggings.json b/src/generated/resources/data/minecraft/recipe/golden_leggings.json index 54c8ae06..6ffc3edd 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_leggings.json +++ b/src/generated/resources/data/minecraft/recipe/golden_leggings.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/golden_pickaxe.json b/src/generated/resources/data/minecraft/recipe/golden_pickaxe.json index be94e94d..7e88522f 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipe/golden_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/golden_shovel.json b/src/generated/resources/data/minecraft/recipe/golden_shovel.json index b71a44cb..ed7b5352 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_shovel.json +++ b/src/generated/resources/data/minecraft/recipe/golden_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/golden_sword.json b/src/generated/resources/data/minecraft/recipe/golden_sword.json index fdfc713b..a400bb81 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_sword.json +++ b/src/generated/resources/data/minecraft/recipe/golden_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/gray_banner.json b/src/generated/resources/data/minecraft/recipe/gray_banner.json index 9a36e40a..75e5ac3e 100644 --- a/src/generated/resources/data/minecraft/recipe/gray_banner.json +++ b/src/generated/resources/data/minecraft/recipe/gray_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:gray_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:gray_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/gray_candle.json b/src/generated/resources/data/minecraft/recipe/gray_candle.json new file mode 100644 index 00000000..ef9a61de --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/gray" + ], + "result": { + "count": 1, + "id": "minecraft:gray_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/gray_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/gray_concrete_powder.json new file mode 100644 index 00000000..11e77a04 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/gray", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:gray_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/gray_dye.json b/src/generated/resources/data/minecraft/recipe/gray_dye.json new file mode 100644 index 00000000..eaf25e28 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_dye.json @@ -0,0 +1,12 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + "#c:dyes/black", + "#c:dyes/white" + ], + "result": { + "count": 2, + "id": "minecraft:gray_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/gray_stained_glass.json b/src/generated/resources/data/minecraft/recipe/gray_stained_glass.json new file mode 100644 index 00000000..6944a3a0 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/gray" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:gray_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/gray_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/gray_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..d73c5334 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/gray" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:gray_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/gray_terracotta.json b/src/generated/resources/data/minecraft/recipe/gray_terracotta.json new file mode 100644 index 00000000..4aa191b3 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/gray" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:gray_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/green_banner.json b/src/generated/resources/data/minecraft/recipe/green_banner.json index 3960ffd8..e18d67a1 100644 --- a/src/generated/resources/data/minecraft/recipe/green_banner.json +++ b/src/generated/resources/data/minecraft/recipe/green_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:green_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:green_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/green_candle.json b/src/generated/resources/data/minecraft/recipe/green_candle.json new file mode 100644 index 00000000..a95ce3d9 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/green_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/green" + ], + "result": { + "count": 1, + "id": "minecraft:green_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/green_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/green_concrete_powder.json new file mode 100644 index 00000000..9f5cfeab --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/green_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/green", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:green_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/green_stained_glass.json b/src/generated/resources/data/minecraft/recipe/green_stained_glass.json new file mode 100644 index 00000000..d2deaf88 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/green_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/green" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:green_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/green_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/green_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..683c58b1 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/green_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/green" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:green_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/green_terracotta.json b/src/generated/resources/data/minecraft/recipe/green_terracotta.json new file mode 100644 index 00000000..72478243 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/green_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/green" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:green_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/grindstone.json b/src/generated/resources/data/minecraft/recipe/grindstone.json index 234b5a8e..5edf22f7 100644 --- a/src/generated/resources/data/minecraft/recipe/grindstone.json +++ b/src/generated/resources/data/minecraft/recipe/grindstone.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "-": { - "item": "minecraft:stone_slab" - }, - "I": { - "tag": "c:rods/wooden" - } + "#": "#minecraft:planks", + "-": "minecraft:stone_slab", + "I": "#c:rods/wooden" }, "pattern": [ "I-I", diff --git a/src/generated/resources/data/minecraft/recipe/heavy_weighted_pressure_plate.json b/src/generated/resources/data/minecraft/recipe/heavy_weighted_pressure_plate.json index ac9cd700..e4c401e3 100644 --- a/src/generated/resources/data/minecraft/recipe/heavy_weighted_pressure_plate.json +++ b/src/generated/resources/data/minecraft/recipe/heavy_weighted_pressure_plate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "##" diff --git a/src/generated/resources/data/minecraft/recipe/hopper.json b/src/generated/resources/data/minecraft/recipe/hopper.json index 91bdccdd..37560a9e 100644 --- a/src/generated/resources/data/minecraft/recipe/hopper.json +++ b/src/generated/resources/data/minecraft/recipe/hopper.json @@ -3,17 +3,11 @@ "category": "redstone", "key": { "C": { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - "I": { - "tag": "c:ingots/iron" - } + "I": "#c:ingots/iron" }, "pattern": [ "I I", diff --git a/src/generated/resources/data/minecraft/recipe/host_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/host_armor_trim_smithing_template.json index f84de52a..ae84d48c 100644 --- a/src/generated/resources/data/minecraft/recipe/host_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/host_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:host_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:host_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/iron_axe.json b/src/generated/resources/data/minecraft/recipe/iron_axe.json index 950fa6ac..535479a2 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_axe.json +++ b/src/generated/resources/data/minecraft/recipe/iron_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/iron_bars.json b/src/generated/resources/data/minecraft/recipe/iron_bars.json index 28be431f..e33ecdcc 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_bars.json +++ b/src/generated/resources/data/minecraft/recipe/iron_bars.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/iron_boots.json b/src/generated/resources/data/minecraft/recipe/iron_boots.json index f489f382..459f7533 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_boots.json +++ b/src/generated/resources/data/minecraft/recipe/iron_boots.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/iron_chestplate.json b/src/generated/resources/data/minecraft/recipe/iron_chestplate.json index 67f70bc1..42ac070a 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_chestplate.json +++ b/src/generated/resources/data/minecraft/recipe/iron_chestplate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/iron_door.json b/src/generated/resources/data/minecraft/recipe/iron_door.json index be3bbbf4..2155da53 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_door.json +++ b/src/generated/resources/data/minecraft/recipe/iron_door.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "##", diff --git a/src/generated/resources/data/minecraft/recipe/iron_helmet.json b/src/generated/resources/data/minecraft/recipe/iron_helmet.json index 4b7326c7..67b4fa72 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_helmet.json +++ b/src/generated/resources/data/minecraft/recipe/iron_helmet.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/iron_hoe.json b/src/generated/resources/data/minecraft/recipe/iron_hoe.json index e175c35d..65fb6202 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_hoe.json +++ b/src/generated/resources/data/minecraft/recipe/iron_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/iron_ingot_from_nuggets.json b/src/generated/resources/data/minecraft/recipe/iron_ingot_from_nuggets.json index 2cf9cdfd..38806185 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_ingot_from_nuggets.json +++ b/src/generated/resources/data/minecraft/recipe/iron_ingot_from_nuggets.json @@ -3,9 +3,7 @@ "category": "misc", "group": "iron_ingot", "key": { - "#": { - "tag": "c:nuggets/iron" - } + "#": "#c:nuggets/iron" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/iron_leggings.json b/src/generated/resources/data/minecraft/recipe/iron_leggings.json index db1ad085..ca4c45bc 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_leggings.json +++ b/src/generated/resources/data/minecraft/recipe/iron_leggings.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/iron_pickaxe.json b/src/generated/resources/data/minecraft/recipe/iron_pickaxe.json index f829c9df..169d8f70 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipe/iron_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/iron_shovel.json b/src/generated/resources/data/minecraft/recipe/iron_shovel.json index 5a11203a..b4367667 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_shovel.json +++ b/src/generated/resources/data/minecraft/recipe/iron_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/iron_sword.json b/src/generated/resources/data/minecraft/recipe/iron_sword.json index 6f4c0a46..8c909bfa 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_sword.json +++ b/src/generated/resources/data/minecraft/recipe/iron_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/iron_trapdoor.json b/src/generated/resources/data/minecraft/recipe/iron_trapdoor.json index 45d33574..a64774b4 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_trapdoor.json +++ b/src/generated/resources/data/minecraft/recipe/iron_trapdoor.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "##", diff --git a/src/generated/resources/data/minecraft/recipe/item_frame.json b/src/generated/resources/data/minecraft/recipe/item_frame.json index f73e86fe..9daf39f5 100644 --- a/src/generated/resources/data/minecraft/recipe/item_frame.json +++ b/src/generated/resources/data/minecraft/recipe/item_frame.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:leather" - } + "#": "#c:rods/wooden", + "X": "minecraft:leather" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/jukebox.json b/src/generated/resources/data/minecraft/recipe/jukebox.json index 08f3d3b4..c7c109d9 100644 --- a/src/generated/resources/data/minecraft/recipe/jukebox.json +++ b/src/generated/resources/data/minecraft/recipe/jukebox.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#minecraft:planks", + "X": "#c:gems/diamond" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/jungle_chest_boat.json b/src/generated/resources/data/minecraft/recipe/jungle_chest_boat.json index 8a86eca6..4ce71a21 100644 --- a/src/generated/resources/data/minecraft/recipe/jungle_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/jungle_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:jungle_boat" - } + "minecraft:jungle_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/jungle_fence.json b/src/generated/resources/data/minecraft/recipe/jungle_fence.json index b49a38c1..dc919dea 100644 --- a/src/generated/resources/data/minecraft/recipe/jungle_fence.json +++ b/src/generated/resources/data/minecraft/recipe/jungle_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:jungle_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:jungle_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/jungle_fence_gate.json b/src/generated/resources/data/minecraft/recipe/jungle_fence_gate.json index a1dcfbde..3f3ee533 100644 --- a/src/generated/resources/data/minecraft/recipe/jungle_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/jungle_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:jungle_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:jungle_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/jungle_sign.json b/src/generated/resources/data/minecraft/recipe/jungle_sign.json index 713c47d1..9c22e2bc 100644 --- a/src/generated/resources/data/minecraft/recipe/jungle_sign.json +++ b/src/generated/resources/data/minecraft/recipe/jungle_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:jungle_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:jungle_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/ladder.json b/src/generated/resources/data/minecraft/recipe/ladder.json index 8d64f336..0aefdd02 100644 --- a/src/generated/resources/data/minecraft/recipe/ladder.json +++ b/src/generated/resources/data/minecraft/recipe/ladder.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - } + "#": "#c:rods/wooden" }, "pattern": [ "# #", diff --git a/src/generated/resources/data/minecraft/recipe/lantern.json b/src/generated/resources/data/minecraft/recipe/lantern.json index d7435e4e..547cee52 100644 --- a/src/generated/resources/data/minecraft/recipe/lantern.json +++ b/src/generated/resources/data/minecraft/recipe/lantern.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:torch" - }, - "X": { - "tag": "c:nuggets/iron" - } + "#": "minecraft:torch", + "X": "#c:nuggets/iron" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/lead.json b/src/generated/resources/data/minecraft/recipe/lead.json index 57ca6d0b..a48100d6 100644 --- a/src/generated/resources/data/minecraft/recipe/lead.json +++ b/src/generated/resources/data/minecraft/recipe/lead.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "O": { - "item": "minecraft:slime_ball" - }, - "~": { - "tag": "c:strings" - } + "O": "minecraft:slime_ball", + "~": "#c:strings" }, "pattern": [ "~~ ", diff --git a/src/generated/resources/data/minecraft/recipe/lever.json b/src/generated/resources/data/minecraft/recipe/lever.json index a92056e2..25196040 100644 --- a/src/generated/resources/data/minecraft/recipe/lever.json +++ b/src/generated/resources/data/minecraft/recipe/lever.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:cobblestones/normal" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "#c:cobblestones/normal", + "X": "#c:rods/wooden" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_banner.json b/src/generated/resources/data/minecraft/recipe/light_blue_banner.json index 1fb0a66d..b0fa0803 100644 --- a/src/generated/resources/data/minecraft/recipe/light_blue_banner.json +++ b/src/generated/resources/data/minecraft/recipe/light_blue_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:light_blue_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:light_blue_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_candle.json b/src/generated/resources/data/minecraft/recipe/light_blue_candle.json new file mode 100644 index 00000000..43cbfe02 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/light_blue" + ], + "result": { + "count": 1, + "id": "minecraft:light_blue_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/light_blue_concrete_powder.json new file mode 100644 index 00000000..ffb30f06 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/light_blue", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:light_blue_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_dye_from_blue_white_dye.json b/src/generated/resources/data/minecraft/recipe/light_blue_dye_from_blue_white_dye.json new file mode 100644 index 00000000..1d33b2a8 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_dye_from_blue_white_dye.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "light_blue_dye", + "ingredients": [ + "#c:dyes/blue", + "#c:dyes/white" + ], + "result": { + "count": 2, + "id": "minecraft:light_blue_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass.json b/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass.json new file mode 100644 index 00000000..9768131c --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/light_blue" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_blue_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..0b1d1516 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/light_blue" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_blue_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_terracotta.json b/src/generated/resources/data/minecraft/recipe/light_blue_terracotta.json new file mode 100644 index 00000000..21953688 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/light_blue" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_blue_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_banner.json b/src/generated/resources/data/minecraft/recipe/light_gray_banner.json index 35d93c66..7a16563c 100644 --- a/src/generated/resources/data/minecraft/recipe/light_gray_banner.json +++ b/src/generated/resources/data/minecraft/recipe/light_gray_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:light_gray_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:light_gray_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_candle.json b/src/generated/resources/data/minecraft/recipe/light_gray_candle.json new file mode 100644 index 00000000..5fbd4a55 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/light_gray" + ], + "result": { + "count": 1, + "id": "minecraft:light_gray_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/light_gray_concrete_powder.json new file mode 100644 index 00000000..e967595c --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/light_gray", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:light_gray_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_black_white_dye.json b/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_black_white_dye.json new file mode 100644 index 00000000..23c04e80 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_black_white_dye.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "light_gray_dye", + "ingredients": [ + "#c:dyes/black", + "#c:dyes/white", + "#c:dyes/white" + ], + "result": { + "count": 3, + "id": "minecraft:light_gray_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_gray_white_dye.json b/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_gray_white_dye.json new file mode 100644 index 00000000..24ffa80d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_gray_white_dye.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "light_gray_dye", + "ingredients": [ + "#c:dyes/gray", + "#c:dyes/white" + ], + "result": { + "count": 2, + "id": "minecraft:light_gray_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass.json b/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass.json new file mode 100644 index 00000000..9956a976 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/light_gray" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_gray_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..3cf7396f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/light_gray" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_gray_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_terracotta.json b/src/generated/resources/data/minecraft/recipe/light_gray_terracotta.json new file mode 100644 index 00000000..7bd8663b --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/light_gray" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_gray_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_weighted_pressure_plate.json b/src/generated/resources/data/minecraft/recipe/light_weighted_pressure_plate.json index 0d6eec23..ef08a13e 100644 --- a/src/generated/resources/data/minecraft/recipe/light_weighted_pressure_plate.json +++ b/src/generated/resources/data/minecraft/recipe/light_weighted_pressure_plate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/gold" - } + "#": "#c:ingots/gold" }, "pattern": [ "##" diff --git a/src/generated/resources/data/minecraft/recipe/lightning_rod.json b/src/generated/resources/data/minecraft/recipe/lightning_rod.json index 5a2186f6..614ed273 100644 --- a/src/generated/resources/data/minecraft/recipe/lightning_rod.json +++ b/src/generated/resources/data/minecraft/recipe/lightning_rod.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/copper" - } + "#": "#c:ingots/copper" }, "pattern": [ "#", diff --git a/src/generated/resources/data/minecraft/recipe/lime_banner.json b/src/generated/resources/data/minecraft/recipe/lime_banner.json index c076add0..49b26aba 100644 --- a/src/generated/resources/data/minecraft/recipe/lime_banner.json +++ b/src/generated/resources/data/minecraft/recipe/lime_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:lime_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:lime_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/lime_candle.json b/src/generated/resources/data/minecraft/recipe/lime_candle.json new file mode 100644 index 00000000..f38b4cd3 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/lime" + ], + "result": { + "count": 1, + "id": "minecraft:lime_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lime_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/lime_concrete_powder.json new file mode 100644 index 00000000..d3e0f4a0 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/lime", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:lime_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lime_dye.json b/src/generated/resources/data/minecraft/recipe/lime_dye.json new file mode 100644 index 00000000..03f7de71 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_dye.json @@ -0,0 +1,12 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + "#c:dyes/green", + "#c:dyes/white" + ], + "result": { + "count": 2, + "id": "minecraft:lime_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lime_stained_glass.json b/src/generated/resources/data/minecraft/recipe/lime_stained_glass.json new file mode 100644 index 00000000..ced0fd36 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/lime" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:lime_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lime_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/lime_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..a6fd9c36 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/lime" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:lime_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lime_terracotta.json b/src/generated/resources/data/minecraft/recipe/lime_terracotta.json new file mode 100644 index 00000000..199a1fab --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/lime" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:lime_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lodestone.json b/src/generated/resources/data/minecraft/recipe/lodestone.json index 5d1bc8a3..aabb2183 100644 --- a/src/generated/resources/data/minecraft/recipe/lodestone.json +++ b/src/generated/resources/data/minecraft/recipe/lodestone.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/netherite" - }, - "S": { - "item": "minecraft:chiseled_stone_bricks" - } + "#": "#c:ingots/netherite", + "S": "minecraft:chiseled_stone_bricks" }, "pattern": [ "SSS", diff --git a/src/generated/resources/data/minecraft/recipe/loom.json b/src/generated/resources/data/minecraft/recipe/loom.json index 7fbb48df..9b25eeb3 100644 --- a/src/generated/resources/data/minecraft/recipe/loom.json +++ b/src/generated/resources/data/minecraft/recipe/loom.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "@": { - "tag": "c:strings" - } + "#": "#minecraft:planks", + "@": "#c:strings" }, "pattern": [ "@@", diff --git a/src/generated/resources/data/minecraft/recipe/magenta_banner.json b/src/generated/resources/data/minecraft/recipe/magenta_banner.json index 5996580e..f09624c2 100644 --- a/src/generated/resources/data/minecraft/recipe/magenta_banner.json +++ b/src/generated/resources/data/minecraft/recipe/magenta_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:magenta_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:magenta_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/magenta_candle.json b/src/generated/resources/data/minecraft/recipe/magenta_candle.json new file mode 100644 index 00000000..a424f297 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/magenta" + ], + "result": { + "count": 1, + "id": "minecraft:magenta_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/magenta_concrete_powder.json new file mode 100644 index 00000000..16e3792d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/magenta", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:magenta_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_pink.json b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_pink.json new file mode 100644 index 00000000..a2fa3f6d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_pink.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "magenta_dye", + "ingredients": [ + "#c:dyes/blue", + "#c:dyes/red", + "#c:dyes/pink" + ], + "result": { + "count": 3, + "id": "minecraft:magenta_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_white_dye.json b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_white_dye.json new file mode 100644 index 00000000..4eae1007 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_white_dye.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "magenta_dye", + "ingredients": [ + "#c:dyes/blue", + "#c:dyes/red", + "#c:dyes/red", + "#c:dyes/white" + ], + "result": { + "count": 4, + "id": "minecraft:magenta_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_dye_from_purple_and_pink.json b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_purple_and_pink.json new file mode 100644 index 00000000..ef29fdbd --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_purple_and_pink.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "magenta_dye", + "ingredients": [ + "#c:dyes/purple", + "#c:dyes/pink" + ], + "result": { + "count": 2, + "id": "minecraft:magenta_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_stained_glass.json b/src/generated/resources/data/minecraft/recipe/magenta_stained_glass.json new file mode 100644 index 00000000..35c7057b --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/magenta" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:magenta_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/magenta_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..79dbe623 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/magenta" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:magenta_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_terracotta.json b/src/generated/resources/data/minecraft/recipe/magenta_terracotta.json new file mode 100644 index 00000000..3205ae48 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/magenta" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:magenta_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/mangrove_chest_boat.json b/src/generated/resources/data/minecraft/recipe/mangrove_chest_boat.json index 23e510eb..66a4dacf 100644 --- a/src/generated/resources/data/minecraft/recipe/mangrove_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/mangrove_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:mangrove_boat" - } + "minecraft:mangrove_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/mangrove_fence.json b/src/generated/resources/data/minecraft/recipe/mangrove_fence.json index 01d6d241..f9398109 100644 --- a/src/generated/resources/data/minecraft/recipe/mangrove_fence.json +++ b/src/generated/resources/data/minecraft/recipe/mangrove_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:mangrove_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:mangrove_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/mangrove_fence_gate.json b/src/generated/resources/data/minecraft/recipe/mangrove_fence_gate.json index 3a0927be..8510a15d 100644 --- a/src/generated/resources/data/minecraft/recipe/mangrove_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/mangrove_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:mangrove_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:mangrove_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/mangrove_sign.json b/src/generated/resources/data/minecraft/recipe/mangrove_sign.json index a55530fc..2c1eeab8 100644 --- a/src/generated/resources/data/minecraft/recipe/mangrove_sign.json +++ b/src/generated/resources/data/minecraft/recipe/mangrove_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:mangrove_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:mangrove_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/minecart.json b/src/generated/resources/data/minecraft/recipe/minecart.json index 15fdd90d..3a407b04 100644 --- a/src/generated/resources/data/minecraft/recipe/minecart.json +++ b/src/generated/resources/data/minecraft/recipe/minecart.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "# #", diff --git a/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json b/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json index 80acf71a..0600f034 100644 --- a/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json +++ b/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json @@ -3,12 +3,8 @@ "category": "building", "group": "mossy_cobblestone", "ingredients": [ - { - "tag": "c:cobblestones/normal" - }, - { - "item": "minecraft:moss_block" - } + "#c:cobblestones/normal", + "minecraft:moss_block" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_vine.json b/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_vine.json index 6980c8b3..fb390766 100644 --- a/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_vine.json +++ b/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_vine.json @@ -3,12 +3,8 @@ "category": "building", "group": "mossy_cobblestone", "ingredients": [ - { - "tag": "c:cobblestones/normal" - }, - { - "item": "minecraft:vine" - } + "#c:cobblestones/normal", + "minecraft:vine" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/netherite_ingot.json b/src/generated/resources/data/minecraft/recipe/netherite_ingot.json index ffa22499..839b4ad4 100644 --- a/src/generated/resources/data/minecraft/recipe/netherite_ingot.json +++ b/src/generated/resources/data/minecraft/recipe/netherite_ingot.json @@ -3,30 +3,14 @@ "category": "misc", "group": "netherite_ingot", "ingredients": [ - { - "item": "minecraft:netherite_scrap" - }, - { - "item": "minecraft:netherite_scrap" - }, - { - "item": "minecraft:netherite_scrap" - }, - { - "item": "minecraft:netherite_scrap" - }, - { - "tag": "c:ingots/gold" - }, - { - "tag": "c:ingots/gold" - }, - { - "tag": "c:ingots/gold" - }, - { - "tag": "c:ingots/gold" - } + "minecraft:netherite_scrap", + "minecraft:netherite_scrap", + "minecraft:netherite_scrap", + "minecraft:netherite_scrap", + "#c:ingots/gold", + "#c:ingots/gold", + "#c:ingots/gold", + "#c:ingots/gold" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/netherite_upgrade_smithing_template.json b/src/generated/resources/data/minecraft/recipe/netherite_upgrade_smithing_template.json index 44fc4801..aa03072c 100644 --- a/src/generated/resources/data/minecraft/recipe/netherite_upgrade_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/netherite_upgrade_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:netherrack" - }, - "S": { - "item": "minecraft:netherite_upgrade_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:netherrack", + "S": "minecraft:netherite_upgrade_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/oak_chest_boat.json b/src/generated/resources/data/minecraft/recipe/oak_chest_boat.json index 4477f498..76a88f4a 100644 --- a/src/generated/resources/data/minecraft/recipe/oak_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/oak_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:oak_boat" - } + "minecraft:oak_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/oak_fence.json b/src/generated/resources/data/minecraft/recipe/oak_fence.json index 3227fa2b..b3684fd8 100644 --- a/src/generated/resources/data/minecraft/recipe/oak_fence.json +++ b/src/generated/resources/data/minecraft/recipe/oak_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:oak_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/oak_fence_gate.json b/src/generated/resources/data/minecraft/recipe/oak_fence_gate.json index 45923171..36941138 100644 --- a/src/generated/resources/data/minecraft/recipe/oak_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/oak_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:oak_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/oak_sign.json b/src/generated/resources/data/minecraft/recipe/oak_sign.json index 618d6d41..1692e49e 100644 --- a/src/generated/resources/data/minecraft/recipe/oak_sign.json +++ b/src/generated/resources/data/minecraft/recipe/oak_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:oak_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:oak_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/observer.json b/src/generated/resources/data/minecraft/recipe/observer.json index d48ca4ad..f29722af 100644 --- a/src/generated/resources/data/minecraft/recipe/observer.json +++ b/src/generated/resources/data/minecraft/recipe/observer.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:cobblestones/normal" - }, - "Q": { - "item": "minecraft:quartz" - }, - "R": { - "item": "minecraft:redstone" - } + "#": "#c:cobblestones/normal", + "Q": "minecraft:quartz", + "R": "minecraft:redstone" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/orange_banner.json b/src/generated/resources/data/minecraft/recipe/orange_banner.json index f2f3b03d..8bbc0dbf 100644 --- a/src/generated/resources/data/minecraft/recipe/orange_banner.json +++ b/src/generated/resources/data/minecraft/recipe/orange_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:orange_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:orange_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/orange_candle.json b/src/generated/resources/data/minecraft/recipe/orange_candle.json new file mode 100644 index 00000000..9708bbc2 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/orange" + ], + "result": { + "count": 1, + "id": "minecraft:orange_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/orange_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/orange_concrete_powder.json new file mode 100644 index 00000000..39d2b83e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/orange", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:orange_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/orange_dye_from_red_yellow.json b/src/generated/resources/data/minecraft/recipe/orange_dye_from_red_yellow.json new file mode 100644 index 00000000..72f05727 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_dye_from_red_yellow.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "orange_dye", + "ingredients": [ + "#c:dyes/red", + "#c:dyes/yellow" + ], + "result": { + "count": 2, + "id": "minecraft:orange_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/orange_stained_glass.json b/src/generated/resources/data/minecraft/recipe/orange_stained_glass.json new file mode 100644 index 00000000..2af7f1c9 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/orange" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:orange_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/orange_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/orange_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..34da9c5f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/orange" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:orange_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/orange_terracotta.json b/src/generated/resources/data/minecraft/recipe/orange_terracotta.json new file mode 100644 index 00000000..aad543f0 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/orange" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:orange_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/painting.json b/src/generated/resources/data/minecraft/recipe/painting.json index df1b6d32..64b32014 100644 --- a/src/generated/resources/data/minecraft/recipe/painting.json +++ b/src/generated/resources/data/minecraft/recipe/painting.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:wool" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wool" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/pink_banner.json b/src/generated/resources/data/minecraft/recipe/pink_banner.json index 951e77ce..4fd7901e 100644 --- a/src/generated/resources/data/minecraft/recipe/pink_banner.json +++ b/src/generated/resources/data/minecraft/recipe/pink_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:pink_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:pink_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/pink_candle.json b/src/generated/resources/data/minecraft/recipe/pink_candle.json new file mode 100644 index 00000000..d62dd117 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/pink" + ], + "result": { + "count": 1, + "id": "minecraft:pink_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/pink_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/pink_concrete_powder.json new file mode 100644 index 00000000..90df434f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/pink", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:pink_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/pink_dye_from_red_white_dye.json b/src/generated/resources/data/minecraft/recipe/pink_dye_from_red_white_dye.json new file mode 100644 index 00000000..7118cf03 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_dye_from_red_white_dye.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "pink_dye", + "ingredients": [ + "#c:dyes/red", + "#c:dyes/white" + ], + "result": { + "count": 2, + "id": "minecraft:pink_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/pink_stained_glass.json b/src/generated/resources/data/minecraft/recipe/pink_stained_glass.json new file mode 100644 index 00000000..ea7cf3ec --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/pink" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:pink_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/pink_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/pink_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..d2e13b56 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/pink" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:pink_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/pink_terracotta.json b/src/generated/resources/data/minecraft/recipe/pink_terracotta.json new file mode 100644 index 00000000..6d21dd2a --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/pink" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:pink_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/piston.json b/src/generated/resources/data/minecraft/recipe/piston.json index b57e13cf..84593e66 100644 --- a/src/generated/resources/data/minecraft/recipe/piston.json +++ b/src/generated/resources/data/minecraft/recipe/piston.json @@ -2,18 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:cobblestones/normal" - }, - "R": { - "item": "minecraft:redstone" - }, - "T": { - "tag": "minecraft:planks" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:cobblestones/normal", + "R": "minecraft:redstone", + "T": "#minecraft:planks", + "X": "#c:ingots/iron" }, "pattern": [ "TTT", diff --git a/src/generated/resources/data/minecraft/recipe/polished_deepslate.json b/src/generated/resources/data/minecraft/recipe/polished_deepslate.json index 97f277e6..10b6ccbf 100644 --- a/src/generated/resources/data/minecraft/recipe/polished_deepslate.json +++ b/src/generated/resources/data/minecraft/recipe/polished_deepslate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "S": { - "tag": "c:cobblestones/deepslate" - } + "S": "#c:cobblestones/deepslate" }, "pattern": [ "SS", diff --git a/src/generated/resources/data/minecraft/recipe/powered_rail.json b/src/generated/resources/data/minecraft/recipe/powered_rail.json index 97f3e179..40d834f6 100644 --- a/src/generated/resources/data/minecraft/recipe/powered_rail.json +++ b/src/generated/resources/data/minecraft/recipe/powered_rail.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "R": { - "item": "minecraft:redstone" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "R": "minecraft:redstone", + "X": "#c:ingots/gold" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/purple_banner.json b/src/generated/resources/data/minecraft/recipe/purple_banner.json index 5475bffc..ed4b36c1 100644 --- a/src/generated/resources/data/minecraft/recipe/purple_banner.json +++ b/src/generated/resources/data/minecraft/recipe/purple_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:purple_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:purple_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/purple_candle.json b/src/generated/resources/data/minecraft/recipe/purple_candle.json new file mode 100644 index 00000000..7f5ddcf2 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/purple" + ], + "result": { + "count": 1, + "id": "minecraft:purple_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/purple_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/purple_concrete_powder.json new file mode 100644 index 00000000..4f0c587f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/purple", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:purple_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/purple_dye.json b/src/generated/resources/data/minecraft/recipe/purple_dye.json new file mode 100644 index 00000000..c3c75ae3 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_dye.json @@ -0,0 +1,12 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + "#c:dyes/blue", + "#c:dyes/red" + ], + "result": { + "count": 2, + "id": "minecraft:purple_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/purple_stained_glass.json b/src/generated/resources/data/minecraft/recipe/purple_stained_glass.json new file mode 100644 index 00000000..a76149bc --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/purple" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:purple_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/purple_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/purple_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..bf11a7d6 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/purple" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:purple_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/purple_terracotta.json b/src/generated/resources/data/minecraft/recipe/purple_terracotta.json new file mode 100644 index 00000000..a7ee6cc7 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/purple" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:purple_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/rail.json b/src/generated/resources/data/minecraft/recipe/rail.json index 481af10e..b9ed74f2 100644 --- a/src/generated/resources/data/minecraft/recipe/rail.json +++ b/src/generated/resources/data/minecraft/recipe/rail.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/raiser_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/raiser_armor_trim_smithing_template.json index 97a148d1..f49dd8b5 100644 --- a/src/generated/resources/data/minecraft/recipe/raiser_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/raiser_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:raiser_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:raiser_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/red_banner.json b/src/generated/resources/data/minecraft/recipe/red_banner.json index 89b92a54..9b064311 100644 --- a/src/generated/resources/data/minecraft/recipe/red_banner.json +++ b/src/generated/resources/data/minecraft/recipe/red_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:red_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:red_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/red_candle.json b/src/generated/resources/data/minecraft/recipe/red_candle.json new file mode 100644 index 00000000..f658efa5 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/red_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/red" + ], + "result": { + "count": 1, + "id": "minecraft:red_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/red_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/red_concrete_powder.json new file mode 100644 index 00000000..06ede8a2 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/red_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/red", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:red_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/red_stained_glass.json b/src/generated/resources/data/minecraft/recipe/red_stained_glass.json new file mode 100644 index 00000000..0323b84f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/red_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/red" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:red_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/red_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/red_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..32f75114 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/red_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/red" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:red_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/red_terracotta.json b/src/generated/resources/data/minecraft/recipe/red_terracotta.json new file mode 100644 index 00000000..3a006cab --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/red_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/red" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:red_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/redstone_torch.json b/src/generated/resources/data/minecraft/recipe/redstone_torch.json index 378c0d7b..ea402cb6 100644 --- a/src/generated/resources/data/minecraft/recipe/redstone_torch.json +++ b/src/generated/resources/data/minecraft/recipe/redstone_torch.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:redstone" - } + "#": "#c:rods/wooden", + "X": "minecraft:redstone" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/rib_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/rib_armor_trim_smithing_template.json index 6ec72db0..f99a49c8 100644 --- a/src/generated/resources/data/minecraft/recipe/rib_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/rib_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:netherrack" - }, - "S": { - "item": "minecraft:rib_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:netherrack", + "S": "minecraft:rib_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/scaffolding.json b/src/generated/resources/data/minecraft/recipe/scaffolding.json index c0290aba..1393f3b4 100644 --- a/src/generated/resources/data/minecraft/recipe/scaffolding.json +++ b/src/generated/resources/data/minecraft/recipe/scaffolding.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "I": { - "item": "minecraft:bamboo" - }, - "~": { - "tag": "c:strings" - } + "I": "minecraft:bamboo", + "~": "#c:strings" }, "pattern": [ "I~I", diff --git a/src/generated/resources/data/minecraft/recipe/sentry_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/sentry_armor_trim_smithing_template.json index 8bfac2e3..e0a1a2a4 100644 --- a/src/generated/resources/data/minecraft/recipe/sentry_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/sentry_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "c:cobblestones/normal" - }, - "S": { - "item": "minecraft:sentry_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#c:cobblestones/normal", + "S": "minecraft:sentry_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/shaper_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/shaper_armor_trim_smithing_template.json index 980b1d21..e1f08a5c 100644 --- a/src/generated/resources/data/minecraft/recipe/shaper_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/shaper_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:shaper_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:shaper_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/shears.json b/src/generated/resources/data/minecraft/recipe/shears.json index cc526718..ca02dfb8 100644 --- a/src/generated/resources/data/minecraft/recipe/shears.json +++ b/src/generated/resources/data/minecraft/recipe/shears.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ " #", diff --git a/src/generated/resources/data/minecraft/recipe/shield.json b/src/generated/resources/data/minecraft/recipe/shield.json index 46aa8fbe..e0cc4be9 100644 --- a/src/generated/resources/data/minecraft/recipe/shield.json +++ b/src/generated/resources/data/minecraft/recipe/shield.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "W": { - "tag": "minecraft:planks" - }, - "o": { - "tag": "c:ingots/iron" - } + "W": "#minecraft:wooden_tool_materials", + "o": "#c:ingots/iron" }, "pattern": [ "WoW", diff --git a/src/generated/resources/data/minecraft/recipe/shulker_box.json b/src/generated/resources/data/minecraft/recipe/shulker_box.json index dd1c9701..6b74b70a 100644 --- a/src/generated/resources/data/minecraft/recipe/shulker_box.json +++ b/src/generated/resources/data/minecraft/recipe/shulker_box.json @@ -3,17 +3,11 @@ "category": "misc", "key": { "#": { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - "-": { - "item": "minecraft:shulker_shell" - } + "-": "minecraft:shulker_shell" }, "pattern": [ "-", diff --git a/src/generated/resources/data/minecraft/recipe/silence_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/silence_armor_trim_smithing_template.json index 4ade3dea..364cdd75 100644 --- a/src/generated/resources/data/minecraft/recipe/silence_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/silence_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "c:cobblestones/deepslate" - }, - "S": { - "item": "minecraft:silence_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#c:cobblestones/deepslate", + "S": "minecraft:silence_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/smithing_table.json b/src/generated/resources/data/minecraft/recipe/smithing_table.json index e7dadd83..cdf474df 100644 --- a/src/generated/resources/data/minecraft/recipe/smithing_table.json +++ b/src/generated/resources/data/minecraft/recipe/smithing_table.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "@": { - "tag": "c:ingots/iron" - } + "#": "#minecraft:planks", + "@": "#c:ingots/iron" }, "pattern": [ "@@", diff --git a/src/generated/resources/data/minecraft/recipe/snout_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/snout_armor_trim_smithing_template.json index 8aa0dd55..8f24674f 100644 --- a/src/generated/resources/data/minecraft/recipe/snout_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/snout_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:blackstone" - }, - "S": { - "item": "minecraft:snout_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:blackstone", + "S": "minecraft:snout_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/soul_campfire.json b/src/generated/resources/data/minecraft/recipe/soul_campfire.json index e7459aa0..8daec84a 100644 --- a/src/generated/resources/data/minecraft/recipe/soul_campfire.json +++ b/src/generated/resources/data/minecraft/recipe/soul_campfire.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:soul_fire_base_blocks" - }, - "L": { - "tag": "minecraft:logs" - }, - "S": { - "tag": "c:rods/wooden" - } + "#": "#minecraft:soul_fire_base_blocks", + "L": "#minecraft:logs", + "S": "#c:rods/wooden" }, "pattern": [ " S ", diff --git a/src/generated/resources/data/minecraft/recipe/soul_lantern.json b/src/generated/resources/data/minecraft/recipe/soul_lantern.json index e5f39ad8..3d06fd51 100644 --- a/src/generated/resources/data/minecraft/recipe/soul_lantern.json +++ b/src/generated/resources/data/minecraft/recipe/soul_lantern.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:soul_torch" - }, - "X": { - "tag": "c:nuggets/iron" - } + "#": "minecraft:soul_torch", + "X": "#c:nuggets/iron" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/soul_torch.json b/src/generated/resources/data/minecraft/recipe/soul_torch.json index fc57b7b0..89fba8cf 100644 --- a/src/generated/resources/data/minecraft/recipe/soul_torch.json +++ b/src/generated/resources/data/minecraft/recipe/soul_torch.json @@ -2,19 +2,11 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "S": { - "tag": "minecraft:soul_fire_base_blocks" - }, + "#": "#c:rods/wooden", + "S": "#minecraft:soul_fire_base_blocks", "X": [ - { - "item": "minecraft:coal" - }, - { - "item": "minecraft:charcoal" - } + "minecraft:coal", + "minecraft:charcoal" ] }, "pattern": [ diff --git a/src/generated/resources/data/minecraft/recipe/spire_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/spire_armor_trim_smithing_template.json index 4cd59d3d..a4f55cc1 100644 --- a/src/generated/resources/data/minecraft/recipe/spire_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/spire_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:purpur_block" - }, - "S": { - "item": "minecraft:spire_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:purpur_block", + "S": "minecraft:spire_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/spruce_chest_boat.json b/src/generated/resources/data/minecraft/recipe/spruce_chest_boat.json index a98470ee..b1c05471 100644 --- a/src/generated/resources/data/minecraft/recipe/spruce_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/spruce_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:spruce_boat" - } + "minecraft:spruce_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/spruce_fence.json b/src/generated/resources/data/minecraft/recipe/spruce_fence.json index d8790bce..f84b63a7 100644 --- a/src/generated/resources/data/minecraft/recipe/spruce_fence.json +++ b/src/generated/resources/data/minecraft/recipe/spruce_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:spruce_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:spruce_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/spruce_fence_gate.json b/src/generated/resources/data/minecraft/recipe/spruce_fence_gate.json index 61815e96..ea1f612c 100644 --- a/src/generated/resources/data/minecraft/recipe/spruce_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/spruce_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:spruce_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:spruce_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/spruce_sign.json b/src/generated/resources/data/minecraft/recipe/spruce_sign.json index 03fb2813..58046b48 100644 --- a/src/generated/resources/data/minecraft/recipe/spruce_sign.json +++ b/src/generated/resources/data/minecraft/recipe/spruce_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:spruce_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:spruce_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/spyglass.json b/src/generated/resources/data/minecraft/recipe/spyglass.json index ea680e3f..d2caaad3 100644 --- a/src/generated/resources/data/minecraft/recipe/spyglass.json +++ b/src/generated/resources/data/minecraft/recipe/spyglass.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:gems/amethyst" - }, - "X": { - "tag": "c:ingots/copper" - } + "#": "#c:gems/amethyst", + "X": "#c:ingots/copper" }, "pattern": [ " # ", diff --git a/src/generated/resources/data/minecraft/recipe/stone_axe.json b/src/generated/resources/data/minecraft/recipe/stone_axe.json index 0bac2f11..8d557557 100644 --- a/src/generated/resources/data/minecraft/recipe/stone_axe.json +++ b/src/generated/resources/data/minecraft/recipe/stone_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/stone_hoe.json b/src/generated/resources/data/minecraft/recipe/stone_hoe.json index 8c5b5ece..8ed74421 100644 --- a/src/generated/resources/data/minecraft/recipe/stone_hoe.json +++ b/src/generated/resources/data/minecraft/recipe/stone_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/stone_pickaxe.json b/src/generated/resources/data/minecraft/recipe/stone_pickaxe.json index b366ac20..cd245c22 100644 --- a/src/generated/resources/data/minecraft/recipe/stone_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipe/stone_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/stone_shovel.json b/src/generated/resources/data/minecraft/recipe/stone_shovel.json index d1fbdebd..bde9b0a8 100644 --- a/src/generated/resources/data/minecraft/recipe/stone_shovel.json +++ b/src/generated/resources/data/minecraft/recipe/stone_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/stone_sword.json b/src/generated/resources/data/minecraft/recipe/stone_sword.json index 559caac7..cdff3bf4 100644 --- a/src/generated/resources/data/minecraft/recipe/stone_sword.json +++ b/src/generated/resources/data/minecraft/recipe/stone_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/stonecutter.json b/src/generated/resources/data/minecraft/recipe/stonecutter.json index e0820aee..e2f95eec 100644 --- a/src/generated/resources/data/minecraft/recipe/stonecutter.json +++ b/src/generated/resources/data/minecraft/recipe/stonecutter.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:stone" - }, - "I": { - "tag": "c:ingots/iron" - } + "#": "minecraft:stone", + "I": "#c:ingots/iron" }, "pattern": [ " I ", diff --git a/src/generated/resources/data/minecraft/recipe/tide_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/tide_armor_trim_smithing_template.json index 8292dd09..4f4f0fee 100644 --- a/src/generated/resources/data/minecraft/recipe/tide_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/tide_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:prismarine" - }, - "S": { - "item": "minecraft:tide_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:prismarine", + "S": "minecraft:tide_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/tinted_glass.json b/src/generated/resources/data/minecraft/recipe/tinted_glass.json index 99d27ab3..899d357f 100644 --- a/src/generated/resources/data/minecraft/recipe/tinted_glass.json +++ b/src/generated/resources/data/minecraft/recipe/tinted_glass.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "G": { - "item": "minecraft:glass" - }, - "S": { - "tag": "c:gems/amethyst" - } + "G": "minecraft:glass", + "S": "#c:gems/amethyst" }, "pattern": [ " S ", diff --git a/src/generated/resources/data/minecraft/recipe/torch.json b/src/generated/resources/data/minecraft/recipe/torch.json index 031078fa..442a6178 100644 --- a/src/generated/resources/data/minecraft/recipe/torch.json +++ b/src/generated/resources/data/minecraft/recipe/torch.json @@ -2,16 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, + "#": "#c:rods/wooden", "X": [ - { - "item": "minecraft:coal" - }, - { - "item": "minecraft:charcoal" - } + "minecraft:coal", + "minecraft:charcoal" ] }, "pattern": [ diff --git a/src/generated/resources/data/minecraft/recipe/trapped_chest.json b/src/generated/resources/data/minecraft/recipe/trapped_chest.json index 1d48d691..bd85e9bc 100644 --- a/src/generated/resources/data/minecraft/recipe/trapped_chest.json +++ b/src/generated/resources/data/minecraft/recipe/trapped_chest.json @@ -3,17 +3,11 @@ "category": "redstone", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:tripwire_hook" - } + "minecraft:tripwire_hook" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/tripwire_hook.json b/src/generated/resources/data/minecraft/recipe/tripwire_hook.json index b966ce7a..9248d997 100644 --- a/src/generated/resources/data/minecraft/recipe/tripwire_hook.json +++ b/src/generated/resources/data/minecraft/recipe/tripwire_hook.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "minecraft:planks" - }, - "I": { - "tag": "c:ingots/iron" - }, - "S": { - "tag": "c:rods/wooden" - } + "#": "#minecraft:planks", + "I": "#c:ingots/iron", + "S": "#c:rods/wooden" }, "pattern": [ "I", diff --git a/src/generated/resources/data/minecraft/recipe/vex_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/vex_armor_trim_smithing_template.json index c4346ef9..33b599c5 100644 --- a/src/generated/resources/data/minecraft/recipe/vex_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/vex_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "c:cobblestones/normal" - }, - "S": { - "item": "minecraft:vex_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#c:cobblestones/normal", + "S": "minecraft:vex_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/ward_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/ward_armor_trim_smithing_template.json index 1e6185aa..9a4b94b4 100644 --- a/src/generated/resources/data/minecraft/recipe/ward_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/ward_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "c:cobblestones/deepslate" - }, - "S": { - "item": "minecraft:ward_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#c:cobblestones/deepslate", + "S": "minecraft:ward_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/warped_fence.json b/src/generated/resources/data/minecraft/recipe/warped_fence.json index 715d558d..54684ffb 100644 --- a/src/generated/resources/data/minecraft/recipe/warped_fence.json +++ b/src/generated/resources/data/minecraft/recipe/warped_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:warped_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:warped_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/warped_fence_gate.json b/src/generated/resources/data/minecraft/recipe/warped_fence_gate.json index 15dcad57..bd500ac0 100644 --- a/src/generated/resources/data/minecraft/recipe/warped_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/warped_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:warped_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:warped_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/warped_sign.json b/src/generated/resources/data/minecraft/recipe/warped_sign.json index b0f4112a..fd63852c 100644 --- a/src/generated/resources/data/minecraft/recipe/warped_sign.json +++ b/src/generated/resources/data/minecraft/recipe/warped_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:warped_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:warped_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json index 563776c2..3c93a650 100644 --- a/src/generated/resources/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:wayfinder_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:wayfinder_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/white_banner.json b/src/generated/resources/data/minecraft/recipe/white_banner.json index 418906d5..0f87a1e8 100644 --- a/src/generated/resources/data/minecraft/recipe/white_banner.json +++ b/src/generated/resources/data/minecraft/recipe/white_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:white_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:white_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/white_candle.json b/src/generated/resources/data/minecraft/recipe/white_candle.json new file mode 100644 index 00000000..45b193d9 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/white_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/white" + ], + "result": { + "count": 1, + "id": "minecraft:white_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/white_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/white_concrete_powder.json new file mode 100644 index 00000000..e5778a9f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/white_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/white", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:white_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/white_stained_glass.json b/src/generated/resources/data/minecraft/recipe/white_stained_glass.json new file mode 100644 index 00000000..f609fa37 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/white_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/white" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:white_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/white_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/white_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..ce5471a1 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/white_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/white" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:white_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/white_terracotta.json b/src/generated/resources/data/minecraft/recipe/white_terracotta.json new file mode 100644 index 00000000..7fd1569e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/white_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/white" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:white_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/wild_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/wild_armor_trim_smithing_template.json index 8eec0dc5..0048eb45 100644 --- a/src/generated/resources/data/minecraft/recipe/wild_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/wild_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:mossy_cobblestone" - }, - "S": { - "item": "minecraft:wild_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:mossy_cobblestone", + "S": "minecraft:wild_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/wooden_axe.json b/src/generated/resources/data/minecraft/recipe/wooden_axe.json index 25cc73c4..05fdaaad 100644 --- a/src/generated/resources/data/minecraft/recipe/wooden_axe.json +++ b/src/generated/resources/data/minecraft/recipe/wooden_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/wooden_hoe.json b/src/generated/resources/data/minecraft/recipe/wooden_hoe.json index a068c7fd..6fd2085d 100644 --- a/src/generated/resources/data/minecraft/recipe/wooden_hoe.json +++ b/src/generated/resources/data/minecraft/recipe/wooden_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/wooden_pickaxe.json b/src/generated/resources/data/minecraft/recipe/wooden_pickaxe.json index b09f9389..ff84e265 100644 --- a/src/generated/resources/data/minecraft/recipe/wooden_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipe/wooden_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/wooden_shovel.json b/src/generated/resources/data/minecraft/recipe/wooden_shovel.json index dd2aa5e3..3aac8226 100644 --- a/src/generated/resources/data/minecraft/recipe/wooden_shovel.json +++ b/src/generated/resources/data/minecraft/recipe/wooden_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/wooden_sword.json b/src/generated/resources/data/minecraft/recipe/wooden_sword.json index 8906ea87..35a7a421 100644 --- a/src/generated/resources/data/minecraft/recipe/wooden_sword.json +++ b/src/generated/resources/data/minecraft/recipe/wooden_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/yellow_banner.json b/src/generated/resources/data/minecraft/recipe/yellow_banner.json index 5c1c07e8..62286508 100644 --- a/src/generated/resources/data/minecraft/recipe/yellow_banner.json +++ b/src/generated/resources/data/minecraft/recipe/yellow_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:yellow_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:yellow_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/yellow_candle.json b/src/generated/resources/data/minecraft/recipe/yellow_candle.json new file mode 100644 index 00000000..a3decc14 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/yellow_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/yellow" + ], + "result": { + "count": 1, + "id": "minecraft:yellow_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/yellow_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/yellow_concrete_powder.json new file mode 100644 index 00000000..924d9199 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/yellow_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/yellow", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:yellow_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/yellow_stained_glass.json b/src/generated/resources/data/minecraft/recipe/yellow_stained_glass.json new file mode 100644 index 00000000..40f451fd --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/yellow_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/yellow" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:yellow_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/yellow_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/yellow_stained_glass_pane_from_glass_pane.json new file mode 100644 index 00000000..ddfae846 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/yellow_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/yellow" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:yellow_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/yellow_terracotta.json b/src/generated/resources/data/minecraft/recipe/yellow_terracotta.json new file mode 100644 index 00000000..250951ee --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/yellow_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/yellow" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:yellow_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/neoforge/data_maps/entity_type/parrot_imitations.json b/src/generated/resources/data/neoforge/data_maps/entity_type/parrot_imitations.json index 15a39110..513f0341 100644 --- a/src/generated/resources/data/neoforge/data_maps/entity_type/parrot_imitations.json +++ b/src/generated/resources/data/neoforge/data_maps/entity_type/parrot_imitations.json @@ -12,6 +12,12 @@ "minecraft:cave_spider": { "sound": "minecraft:entity.parrot.imitate.spider" }, + "minecraft:creaking": { + "sound": "minecraft:entity.parrot.imitate.creaking" + }, + "minecraft:creaking_transient": { + "sound": "minecraft:entity.parrot.imitate.creaking" + }, "minecraft:creeper": { "sound": "minecraft:entity.parrot.imitate.creeper" }, diff --git a/src/generated/resources/data/neoforge/data_maps/item/compostables.json b/src/generated/resources/data/neoforge/data_maps/item/compostables.json index 7ed50fab..2b3bdff6 100644 --- a/src/generated/resources/data/neoforge/data_maps/item/compostables.json +++ b/src/generated/resources/data/neoforge/data_maps/item/compostables.json @@ -190,6 +190,21 @@ "minecraft:oxeye_daisy": { "chance": 0.65 }, + "minecraft:pale_hanging_moss": { + "chance": 0.3 + }, + "minecraft:pale_moss_block": { + "chance": 0.65 + }, + "minecraft:pale_moss_carpet": { + "chance": 0.3 + }, + "minecraft:pale_oak_leaves": { + "chance": 0.3 + }, + "minecraft:pale_oak_sapling": { + "chance": 0.3 + }, "minecraft:peony": { "chance": 0.65 }, diff --git a/src/generated/resources/pack.mcmeta b/src/generated/resources/pack.mcmeta index 6ab35463..f49d678e 100644 --- a/src/generated/resources/pack.mcmeta +++ b/src/generated/resources/pack.mcmeta @@ -3,7 +3,7 @@ "description": { "translate": "pack.neoforge.description" }, - "pack_format": 48, + "pack_format": 57, "supported_formats": [ 0, 2147483647 diff --git a/src/generated/resources/reports/registry_order.json b/src/generated/resources/reports/registry_order.json index 17ea12b6..0a52e90b 100644 --- a/src/generated/resources/reports/registry_order.json +++ b/src/generated/resources/reports/registry_order.json @@ -2,7 +2,6 @@ "order": [ "minecraft:attribute", "minecraft:data_component_type", - "minecraft:armor_material", "minecraft:game_event", "minecraft:sound_event", "minecraft:fluid", @@ -64,7 +63,6 @@ "minecraft:worldgen/pool_alias_binding", "minecraft:cat_variant", "minecraft:frog_variant", - "minecraft:instrument", "minecraft:decorated_pot_pattern", "minecraft:creative_mode_tab", "minecraft:trigger_type", @@ -78,6 +76,10 @@ "minecraft:enchantment_location_based_effect_type", "minecraft:enchantment_value_effect_type", "minecraft:enchantment_provider_type", + "minecraft:consume_effect_type", + "minecraft:recipe_display", + "minecraft:slot_display", + "minecraft:recipe_book_category", "neoforge:attachment_types", "neoforge:biome_modifier_serializers", "neoforge:condition_codecs", diff --git a/src/main/java/net/neoforged/neoforge/attachment/AttachmentHolder.java b/src/main/java/net/neoforged/neoforge/attachment/AttachmentHolder.java index 53b2c8bc..e822d369 100644 --- a/src/main/java/net/neoforged/neoforge/attachment/AttachmentHolder.java +++ b/src/main/java/net/neoforged/neoforge/attachment/AttachmentHolder.java @@ -145,7 +145,7 @@ protected final void deserializeAttachments(HolderLookup.Provider provider, Comp continue; } - var type = NeoForgeRegistries.ATTACHMENT_TYPES.get(keyLocation); + var type = NeoForgeRegistries.ATTACHMENT_TYPES.getValue(keyLocation); if (type == null || type.serializer == null) { LOGGER.error("Encountered unknown or non-serializable data attachment {}. Skipping.", key); continue; diff --git a/src/main/java/net/neoforged/neoforge/capabilities/CapabilityHooks.java b/src/main/java/net/neoforged/neoforge/capabilities/CapabilityHooks.java index 73fe62a7..478e79e2 100644 --- a/src/main/java/net/neoforged/neoforge/capabilities/CapabilityHooks.java +++ b/src/main/java/net/neoforged/neoforge/capabilities/CapabilityHooks.java @@ -104,7 +104,15 @@ public static void registerVanillaProviders(RegisterCapabilitiesEvent event) { // Entities var containerEntities = List.of( - EntityType.CHEST_BOAT, + EntityType.ACACIA_CHEST_BOAT, + EntityType.BIRCH_CHEST_BOAT, + EntityType.CHERRY_CHEST_BOAT, + EntityType.DARK_OAK_CHEST_BOAT, + EntityType.JUNGLE_CHEST_BOAT, + EntityType.MANGROVE_CHEST_BOAT, + EntityType.OAK_CHEST_BOAT, + EntityType.SPRUCE_CHEST_BOAT, + EntityType.BAMBOO_CHEST_RAFT, EntityType.CHEST_MINECART, EntityType.HOPPER_MINECART); for (var entityType : containerEntities) { diff --git a/src/main/java/net/neoforged/neoforge/client/BlockEntityRenderBoundsDebugRenderer.java b/src/main/java/net/neoforged/neoforge/client/BlockEntityRenderBoundsDebugRenderer.java index a7cef0f0..4df6e384 100644 --- a/src/main/java/net/neoforged/neoforge/client/BlockEntityRenderBoundsDebugRenderer.java +++ b/src/main/java/net/neoforged/neoforge/client/BlockEntityRenderBoundsDebugRenderer.java @@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.ShapeRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.commands.Commands; import net.minecraft.core.BlockPos; @@ -52,7 +53,7 @@ private static void drawRenderBoundingBox(PoseStack poseStack, VertexConsumer co poseStack.pushPose(); poseStack.translate(offset.x, offset.y, offset.z); - LevelRenderer.renderLineBox(poseStack, consumer, aabb, 1F, 0F, 0F, 1F); + ShapeRenderer.renderLineBox(poseStack, consumer, aabb, 1F, 0F, 0F, 1F); poseStack.popPose(); } } diff --git a/src/main/java/net/neoforged/neoforge/client/ClientCommandHandler.java b/src/main/java/net/neoforged/neoforge/client/ClientCommandHandler.java index 742a76da..f4d4f28d 100644 --- a/src/main/java/net/neoforged/neoforge/client/ClientCommandHandler.java +++ b/src/main/java/net/neoforged/neoforge/client/ClientCommandHandler.java @@ -20,6 +20,7 @@ import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.player.LocalPlayer; import net.minecraft.commands.CommandBuildContext; +import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.synchronization.SuggestionProviders; @@ -105,7 +106,28 @@ public static CommandDispatcher getDispatcher() { */ public static ClientCommandSourceStack getSource() { LocalPlayer player = Minecraft.getInstance().player; - return new ClientCommandSourceStack(player, player.position(), player.getRotationVector(), player.getPermissionLevel(), + CommandSource commandSource = new CommandSource() { + @Override + public boolean acceptsSuccess() { + return true; + } + + @Override + public boolean acceptsFailure() { + return true; + } + + @Override + public boolean shouldInformAdmins() { + return true; + } + + @Override + public void sendSystemMessage(Component message) { + Minecraft.getInstance().gui.getChat().addMessage(message); + } + }; + return new ClientCommandSourceStack(commandSource, player.position(), player.getRotationVector(), player.getPermissionLevel(), player.getName().getString(), player.getDisplayName(), player); } @@ -157,7 +179,7 @@ public static boolean runCommand(String command) { // in case of unknown command, let the server try and handle it return false; } - Minecraft.getInstance().player.sendSystemMessage( + Minecraft.getInstance().gui.getChat().addMessage( Component.literal("").append(ComponentUtils.fromMessage(syntax.getRawMessage())).withStyle(ChatFormatting.RED)); if (syntax.getInput() != null && syntax.getCursor() >= 0) { int position = Math.min(syntax.getInput().length(), syntax.getCursor()); @@ -173,12 +195,12 @@ public static boolean runCommand(String command) { details.append(Component.literal(syntax.getInput().substring(position)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE)); } details.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC)); - Minecraft.getInstance().player.sendSystemMessage(Component.literal("").append(details).withStyle(ChatFormatting.RED)); + Minecraft.getInstance().gui.getChat().addMessage(Component.literal("").append(details).withStyle(ChatFormatting.RED)); } } catch (Exception generic)// Probably thrown by the command { MutableComponent message = Component.literal(generic.getMessage() == null ? generic.getClass().getName() : generic.getMessage()); - Minecraft.getInstance().player.sendSystemMessage(Component.translatable("command.failed") + Minecraft.getInstance().gui.getChat().addMessage(Component.translatable("command.failed") .withStyle(ChatFormatting.RED) .withStyle((style) -> style .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, message)))); diff --git a/src/main/java/net/neoforged/neoforge/client/ClientCommandSourceStack.java b/src/main/java/net/neoforged/neoforge/client/ClientCommandSourceStack.java index 0d5a537d..471b085f 100644 --- a/src/main/java/net/neoforged/neoforge/client/ClientCommandSourceStack.java +++ b/src/main/java/net/neoforged/neoforge/client/ClientCommandSourceStack.java @@ -5,27 +5,33 @@ package net.neoforged.neoforge.client; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; import java.util.Collection; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; import java.util.stream.Collectors; -import java.util.stream.Stream; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.client.Minecraft; import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; -import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Scoreboard; +import org.jetbrains.annotations.Nullable; /** * overrides for {@link CommandSourceStack} so that the methods will run successfully client side @@ -41,7 +47,7 @@ public ClientCommandSourceStack(CommandSource source, Vec3 position, Vec2 rotati */ @Override public void sendSuccess(Supplier message, boolean sendToAdmins) { - Minecraft.getInstance().player.sendSystemMessage(message.get()); + Minecraft.getInstance().gui.getChat().addMessage(message.get()); } /** @@ -60,12 +66,17 @@ public Collection getOnlinePlayerNames() { return Minecraft.getInstance().getConnection().getOnlinePlayers().stream().map((player) -> player.getProfile().getName()).collect(Collectors.toList()); } - /** - * {@return a {@link Stream} of recipe ids that are available on the client} - */ @Override - public Stream getRecipeNames() { - return Minecraft.getInstance().getConnection().getRecipeManager().getRecipeIds(); + public CompletableFuture suggestRegistryElements( + ResourceKey> p_212330_, + SharedSuggestionProvider.ElementSuggestionType p_212331_, + SuggestionsBuilder p_212332_, + CommandContext p_212333_) { + // TODO 1.21.2: Not sure what to do here. Letting super get called will cause an NPE on this.server. + if (p_212330_ == Registries.RECIPE || p_212330_ == Registries.ADVANCEMENT) { + return Suggestions.empty(); + } + return super.suggestRegistryElements(p_212330_, p_212331_, p_212332_, p_212333_); } /** @@ -96,18 +107,11 @@ public Scoreboard getScoreboard() { * {@return the advancement from the id from the client side where the advancement needs to be visible to the player} */ @Override + @Nullable public AdvancementHolder getAdvancement(ResourceLocation id) { return Minecraft.getInstance().getConnection().getAdvancements().get(id); } - /** - * {@return the {@link RecipeManager} from the client side} - */ - @Override - public RecipeManager getRecipeManager() { - return Minecraft.getInstance().getConnection().getRecipeManager(); - } - /** * {@return the level from the client side} */ diff --git a/src/main/java/net/neoforged/neoforge/client/ClientHooks.java b/src/main/java/net/neoforged/neoforge/client/ClientHooks.java index 8bc74f25..0132b8a8 100644 --- a/src/main/java/net/neoforged/neoforge/client/ClientHooks.java +++ b/src/main/java/net/neoforged/neoforge/client/ClientHooks.java @@ -10,14 +10,11 @@ import com.google.common.collect.ImmutableMap; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.shaders.FogShape; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.datafixers.util.Either; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -34,7 +31,6 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; -import net.minecraft.FileUtil; import net.minecraft.client.Camera; import net.minecraft.client.DeltaTracker; import net.minecraft.client.KeyMapping; @@ -50,7 +46,8 @@ import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.TitleScreen; -import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.gui.screens.inventory.EffectsInInventory; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner; import net.minecraft.client.model.HumanoidModel; @@ -64,14 +61,16 @@ import net.minecraft.client.particle.ParticleEngine; import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.player.AbstractClientPlayer; -import net.minecraft.client.player.Input; +import net.minecraft.client.player.ClientInput; import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.FogParameters; import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.ShaderInstance; +import net.minecraft.client.renderer.ShaderDefines; +import net.minecraft.client.renderer.ShaderProgram; import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockElement; @@ -79,6 +78,7 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.chunk.RenderChunkRegion; import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.client.renderer.entity.state.HumanoidRenderState; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.atlas.SpriteSourceType; @@ -107,19 +107,18 @@ import net.minecraft.sounds.Music; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; +import net.minecraft.util.profiling.Profiler; import net.minecraft.world.InteractionHand; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.RecipeBookType; import net.minecraft.world.inventory.tooltip.TooltipComponent; -import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeManager; +import net.minecraft.world.item.equipment.EquipmentModel; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; @@ -129,8 +128,6 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FogType; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.EntityHitResult; -import net.minecraft.world.phys.HitResult; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.Event; import net.neoforged.bus.api.SubscribeEvent; @@ -154,7 +151,6 @@ import net.neoforged.neoforge.client.event.InputEvent; import net.neoforged.neoforge.client.event.ModelEvent; import net.neoforged.neoforge.client.event.MovementInputUpdateEvent; -import net.neoforged.neoforge.client.event.RecipesUpdatedEvent; import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; @@ -196,6 +192,7 @@ import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.joml.Vector3f; +import org.joml.Vector4f; /** * Class for various client-side-only hooks. @@ -256,9 +253,9 @@ public static float getGuiFarPlane() { return 11_000F + depth; } - public static ResourceLocation getArmorTexture(Entity entity, ItemStack armor, ArmorMaterial.Layer layer, boolean innerModel, EquipmentSlot slot) { - ResourceLocation result = armor.getItem().getArmorTexture(armor, entity, slot, layer, innerModel); - return result != null ? result : layer.texture(innerModel); + public static ResourceLocation getArmorTexture(ItemStack armor, EquipmentModel.LayerType type, EquipmentModel.Layer layer, ResourceLocation _default) { + ResourceLocation result = armor.getItem().getArmorTexture(armor, type, layer, _default); + return result != null ? result : _default; } public static boolean onClientPauseChangePre(boolean pause) { @@ -270,25 +267,15 @@ public static void onClientPauseChangePost(boolean pause) { NeoForge.EVENT_BUS.post(new ClientPauseChangeEvent.Post(pause)); } - public static boolean onDrawHighlight(LevelRenderer context, Camera camera, HitResult target, DeltaTracker deltaTracker, PoseStack poseStack, MultiBufferSource bufferSource) { - switch (target.getType()) { - case BLOCK: - if (!(target instanceof BlockHitResult blockTarget)) return false; - return NeoForge.EVENT_BUS.post(new RenderHighlightEvent.Block(context, camera, blockTarget, deltaTracker, poseStack, bufferSource)).isCanceled(); - case ENTITY: - if (!(target instanceof EntityHitResult entityTarget)) return false; - NeoForge.EVENT_BUS.post(new RenderHighlightEvent.Entity(context, camera, entityTarget, deltaTracker, poseStack, bufferSource)); - return false; - default: - return false; // NO-OP - This doesn't even get called for anything other than blocks and entities - } + public static boolean onDrawHighlight(LevelRenderer context, Camera camera, BlockHitResult target, DeltaTracker deltaTracker, PoseStack poseStack, MultiBufferSource bufferSource, boolean forTranslucentBlocks) { + return NeoForge.EVENT_BUS.post(new RenderHighlightEvent.Block(context, camera, target, deltaTracker, poseStack, bufferSource, forTranslucentBlocks)).isCanceled(); } public static void dispatchRenderStage(RenderLevelStageEvent.Stage stage, LevelRenderer levelRenderer, @Nullable PoseStack poseStack, Matrix4f modelViewMatrix, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum) { var mc = Minecraft.getInstance(); - var profiler = mc.getProfiler(); + var profiler = Profiler.get(); profiler.push(stage.toString()); - NeoForge.EVENT_BUS.post(new RenderLevelStageEvent(stage, levelRenderer, poseStack, modelViewMatrix, projectionMatrix, renderTick, mc.getTimer(), camera, frustum)); + NeoForge.EVENT_BUS.post(new RenderLevelStageEvent(stage, levelRenderer, poseStack, modelViewMatrix, projectionMatrix, renderTick, mc.getDeltaTracker(), camera, frustum)); profiler.pop(); } @@ -318,13 +305,13 @@ public static void onItemColorsInit(ItemColors itemColors, BlockColors blockColo ModLoader.postEvent(new RegisterColorHandlersEvent.Item(itemColors, blockColors)); } - public static Model getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot slot, HumanoidModel _default) { - return IClientItemExtensions.of(itemStack).getGenericArmorModel(entityLiving, itemStack, slot, _default); + public static Model getArmorModel(ItemStack itemStack, EquipmentModel.LayerType layerType, Model _default) { + return IClientItemExtensions.of(itemStack).getGenericArmorModel(itemStack, layerType, _default); } /** Copies humanoid model properties from the original model to another, used for armor models */ @SuppressWarnings("unchecked") - public static void copyModelProperties(HumanoidModel original, HumanoidModel replacement) { + public static void copyModelProperties(HumanoidModel original, HumanoidModel replacement) { // this function does not make use of the generic, so the unchecked cast should be safe original.copyPropertiesTo((HumanoidModel) replacement); replacement.head.visible = original.head.visible; @@ -352,13 +339,13 @@ public static String fixDomain(String base, String complex) { } } - public static float getFieldOfViewModifier(Player entity, float fovModifier) { - ComputeFovModifierEvent fovModifierEvent = new ComputeFovModifierEvent(entity, fovModifier); + public static float getFieldOfViewModifier(Player entity, float fovModifier, float fovScale) { + ComputeFovModifierEvent fovModifierEvent = new ComputeFovModifierEvent(entity, fovModifier, fovScale); NeoForge.EVENT_BUS.post(fovModifierEvent); return fovModifierEvent.getNewFovModifier(); } - public static double getFieldOfView(GameRenderer renderer, Camera camera, double partialTick, double fov, boolean usedConfiguredFov) { + public static float getFieldOfView(GameRenderer renderer, Camera camera, float partialTick, float fov, boolean usedConfiguredFov) { ViewportEvent.ComputeFov event = new ViewportEvent.ComputeFov(renderer, camera, partialTick, fov, usedConfiguredFov); NeoForge.EVENT_BUS.post(event); return event.getFOV(); @@ -429,10 +416,10 @@ private static void drawScreenInternal(Screen screen, GuiGraphics guiGraphics, i NeoForge.EVENT_BUS.post(new ScreenEvent.Render.Post(screen, guiGraphics, mouseX, mouseY, partialTick)); } - public static Vector3f getFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, float fogRed, float fogGreen, float fogBlue) { + public static Vector4f getFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, float fogRed, float fogGreen, float fogBlue) { // Modify fog color depending on the fluid FluidState state = level.getFluidState(camera.getBlockPosition()); - Vector3f fluidFogColor = new Vector3f(fogRed, fogGreen, fogBlue); + Vector4f fluidFogColor = new Vector4f(fogRed, fogGreen, fogBlue, 1F); if (camera.getPosition().y < (double) ((float) camera.getBlockPosition().getY() + state.getHeight(level, camera.getBlockPosition()))) fluidFogColor = IClientFluidTypeExtensions.of(state).modifyFogColor(camera, partialTick, level, renderDistance, darkenWorldAmount, fluidFogColor); @@ -443,18 +430,24 @@ public static Vector3f getFogColor(Camera camera, float partialTick, ClientLevel return fluidFogColor; } - public static void onFogRender(FogRenderer.FogMode mode, FogType type, Camera camera, float partialTick, float renderDistance, float nearDistance, float farDistance, FogShape shape) { + public static FogParameters onFogRender(FogRenderer.FogMode mode, FogType type, Camera camera, float partialTick, float renderDistance, FogParameters fogParameters) { // Modify fog rendering depending on the fluid FluidState state = camera.getEntity().level().getFluidState(camera.getBlockPosition()); if (camera.getPosition().y < (double) ((float) camera.getBlockPosition().getY() + state.getHeight(camera.getEntity().level(), camera.getBlockPosition()))) - IClientFluidTypeExtensions.of(state).modifyFogRender(camera, mode, renderDistance, partialTick, nearDistance, farDistance, shape); + fogParameters = IClientFluidTypeExtensions.of(state).modifyFogRender(camera, mode, renderDistance, partialTick, fogParameters); - ViewportEvent.RenderFog event = new ViewportEvent.RenderFog(mode, type, camera, partialTick, nearDistance, farDistance, shape); + ViewportEvent.RenderFog event = new ViewportEvent.RenderFog(mode, type, camera, partialTick, fogParameters); if (NeoForge.EVENT_BUS.post(event).isCanceled()) { - RenderSystem.setShaderFogStart(event.getNearPlaneDistance()); - RenderSystem.setShaderFogEnd(event.getFarPlaneDistance()); - RenderSystem.setShaderFogShape(event.getFogShape()); + return new FogParameters( + event.getNearPlaneDistance(), + event.getFarPlaneDistance(), + event.getFogShape(), + fogParameters.red(), + fogParameters.green(), + fogParameters.blue(), + fogParameters.alpha()); } + return fogParameters; } public static void onModifyBakingResult(Map models, Map stitchResults, ModelBakery modelBakery) { @@ -530,11 +523,11 @@ public static boolean calculateFaceWithoutAO(BlockAndTintGetter getter, BlockSta return true; } - public static void loadEntityShader(Entity entity, GameRenderer entityRenderer) { + public static void loadEntityShader(@Nullable Entity entity, GameRenderer gameRenderer) { if (entity != null) { ResourceLocation shader = EntitySpectatorShaderManager.get(entity.getType()); if (shader != null) { - entityRenderer.loadEffect(shader); + gameRenderer.setPostEffect(shader); } } } @@ -558,7 +551,7 @@ public static boolean shouldCauseReequipAnimation(ItemStack from, ItemStack to, public static CustomizeGuiOverlayEvent.BossEventProgress onCustomizeBossEventProgress(GuiGraphics guiGraphics, Window window, LerpingBossEvent bossInfo, int x, int y, int increment) { CustomizeGuiOverlayEvent.BossEventProgress evt = new CustomizeGuiOverlayEvent.BossEventProgress(window, guiGraphics, - Minecraft.getInstance().getTimer(), bossInfo, x, y, increment); + Minecraft.getInstance().getDeltaTracker(), bossInfo, x, y, increment); NeoForge.EVENT_BUS.post(evt); return evt; } @@ -576,7 +569,7 @@ public static void onClientChangeGameType(PlayerInfo info, GameType currentGameM } } - public static void onMovementInputUpdate(Player player, Input movementInput) { + public static void onMovementInputUpdate(Player player, ClientInput movementInput) { NeoForge.EVENT_BUS.post(new MovementInputUpdateEvent(player, movementInput)); } @@ -658,11 +651,6 @@ public static void onScreenCharTypedPost(Screen guiScreen, char codePoint, int m NeoForge.EVENT_BUS.post(event); } - public static void onRecipesUpdated(RecipeManager mgr) { - Event event = new RecipesUpdatedEvent(mgr); - NeoForge.EVENT_BUS.post(event); - } - public static boolean onMouseButtonPre(int button, int action, int mods) { return NeoForge.EVENT_BUS.post(new InputEvent.MouseButton.Pre(button, action, mods)).isCanceled(); } @@ -686,12 +674,9 @@ public static InputEvent.InteractionKeyMappingTriggered onClickInput(int button, return event; } - public static boolean isNameplateInRenderDistance(Entity entity, double squareDistance) { - if (entity instanceof LivingEntity) { - double value = ((LivingEntity) entity).getAttributeValue(NeoForgeMod.NAMETAG_DISTANCE); - return !(squareDistance > value * value); - } - return !(squareDistance > 4096.0f); + public static boolean isNameplateInRenderDistance(LivingEntity entity, double squareDistance) { + double value = entity.getAttributeValue(NeoForgeMod.NAMETAG_DISTANCE); + return !(squareDistance > value * value); } public static void renderPistonMovedBlocks(BlockPos pos, BlockState state, PoseStack stack, MultiBufferSource bufferSource, Level level, boolean checkSides, int packedOverlay, BlockRenderDispatcher blockRenderer) { @@ -765,28 +750,16 @@ public static String onClientSendMessage(String message) { return NeoForge.EVENT_BUS.post(event).isCanceled() ? "" : event.getMessage(); } - /** - * Mimics the behavior of {@link net.minecraft.client.renderer.ItemBlockRenderTypes#getRenderType(BlockState, boolean)} - * for the input {@link RenderType}. - */ - public static RenderType getEntityRenderType(RenderType chunkRenderType, boolean cull) { - return RenderTypeHelper.getEntityRenderType(chunkRenderType, cull); - } - @EventBusSubscriber(value = Dist.CLIENT, modid = "neoforge", bus = EventBusSubscriber.Bus.MOD) public static class ClientEvents { - @Nullable - private static ShaderInstance rendertypeEntityTranslucentUnlitShader; - - public static ShaderInstance getEntityTranslucentUnlitShader() { - return Objects.requireNonNull(rendertypeEntityTranslucentUnlitShader, "Attempted to call getEntityTranslucentUnlitShader before shaders have finished loading."); - } + public static final ShaderProgram RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER = new ShaderProgram( + ResourceLocation.fromNamespaceAndPath(NeoForgeVersion.MOD_ID, "core/rendertype_entity_unlit_translucent"), + DefaultVertexFormat.NEW_ENTITY, + ShaderDefines.EMPTY); @SubscribeEvent - public static void registerShaders(RegisterShadersEvent event) throws IOException { - event.registerShader(new ShaderInstance(event.getResourceProvider(), ResourceLocation.fromNamespaceAndPath("neoforge", "rendertype_entity_unlit_translucent"), DefaultVertexFormat.NEW_ENTITY), (p_172645_) -> { - rendertypeEntityTranslucentUnlitShader = p_172645_; - }); + public static void registerShaders(RegisterShadersEvent event) { + event.registerShader(RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER); } } @@ -801,10 +774,8 @@ public static RenderTooltipEvent.Pre onRenderTooltipPre(ItemStack stack, GuiGrap return preEvent; } - public static RenderTooltipEvent.Color onRenderTooltipColor(ItemStack stack, GuiGraphics graphics, int x, int y, Font font, List components) { - var colorEvent = new RenderTooltipEvent.Color(stack, graphics, x, y, font, 0xf0100010, 0x505000FF, 0x5028007f, components); - NeoForge.EVENT_BUS.post(colorEvent); - return colorEvent; + public static RenderTooltipEvent.Texture onRenderTooltipTexture(ItemStack stack, GuiGraphics graphics, int x, int y, Font font, List components, @Nullable ResourceLocation texture) { + return NeoForge.EVENT_BUS.post(new RenderTooltipEvent.Texture(stack, graphics, x, y, font, components, texture)); } public static List gatherTooltipComponents(ItemStack stack, List textElements, int mouseX, int screenWidth, int screenHeight, Font fallbackFont) { @@ -923,13 +894,6 @@ public static int getMaxMipmapLevel(int width, int height) { Mth.log2(Math.max(1, height))); } - public static ResourceLocation getShaderImportLocation(String basePath, boolean isRelative, String importPath) { - final var loc = ResourceLocation.parse(importPath); - final var normalised = FileUtil.normalizeResourcePath( - (isRelative ? basePath : "shaders/include/") + loc.getPath()); - return ResourceLocation.fromNamespaceAndPath(loc.getNamespace(), normalised); - } - private static final BiMap SPRITE_SOURCE_TYPES_MAP = HashBiMap.create(); public static BiMap makeSpriteSourceTypesMap() { @@ -1038,10 +1002,11 @@ public static void initClientHooks(Minecraft mc, ReloadableResourceManager resou MapDecorationRendererManager.init(); DimensionTransitionScreenManager.init(); AnimationTypeManager.init(); + CoreShaderManager.init(); } /** - * Fires {@link RenderFrameEvent.Pre}. Called just before {@link GameRenderer#render(float, long, boolean)} in {@link Minecraft#runTick(boolean)}. + * Fires {@link RenderFrameEvent.Pre}. Called just before {@link GameRenderer#render(DeltaTracker, boolean)} in {@link Minecraft#runTick(boolean)}. *

* Fired before the profiler section for "gameRenderer" is started. * @@ -1052,14 +1017,14 @@ public static void fireRenderFramePre(DeltaTracker partialTick) { } /** - * Fires {@link RenderFrameEvent.Post}. Called just after {@link GameRenderer#render(float, long, boolean)} in {@link Minecraft#runTick(boolean)}. + * Fires {@link RenderFrameEvent.Post}. Called just after {@link GameRenderer#render(DeltaTracker, boolean)} in {@link Minecraft#runTick(boolean)}. *

* Fired after the profiler section for "gameRenderer" is ended. * * @param partialTick The current partial tick */ - public static void fireRenderFramePost(DeltaTracker partialRick) { - NeoForge.EVENT_BUS.post(new RenderFrameEvent.Post(partialRick)); + public static void fireRenderFramePost(DeltaTracker partialTick) { + NeoForge.EVENT_BUS.post(new RenderFrameEvent.Post(partialTick)); } /** @@ -1089,14 +1054,14 @@ public static RegistryLookup resolveLookup(ResourceKey - * Called from {@link EffectRenderingInventoryScreen#renderEffects} just before {@link GuiGraphics#renderTooltip(Font, List, Optional, int, int)} is called. + * Called from {@link EffectsInInventory#renderEffects} just before {@link GuiGraphics#renderTooltip(Font, List, Optional, int, int)} is called. * * @param screen The screen rendering the tooltip. * @param effectInst The effect instance whose tooltip is being rendered. * @param tooltip An immutable list containing the existing tooltip lines, which consist of the name and the duration. * @return The new tooltip lines, modified by the event. */ - public static List getEffectTooltip(EffectRenderingInventoryScreen screen, MobEffectInstance effectInst, List tooltip) { + public static List getEffectTooltip(AbstractContainerScreen screen, MobEffectInstance effectInst, List tooltip) { var event = new GatherEffectScreenTooltipsEvent(screen, effectInst, tooltip); NeoForge.EVENT_BUS.post(event); return event.getTooltip(); @@ -1120,4 +1085,13 @@ public static RecipeBookType[] getFilteredRecipeBookTypeValues() { } return RECIPE_BOOK_TYPES; } + + private static final RandomSource OUTLINE_PASS_RANDOM = RandomSource.create(); + + public static boolean isInTranslucentBlockOutlinePass(Level level, BlockPos pos, BlockState state) { + BakedModel model = Minecraft.getInstance().getBlockRenderer().getBlockModel(state); + OUTLINE_PASS_RANDOM.setSeed(42); + ChunkRenderTypeSet renderTypes = model.getRenderTypes(state, OUTLINE_PASS_RANDOM, level.getModelData(pos)); + return renderTypes.contains(RenderType.TRANSLUCENT) || renderTypes.contains(RenderType.TRIPWIRE); + } } diff --git a/src/main/java/net/neoforged/neoforge/client/ClientNeoForgeMod.java b/src/main/java/net/neoforged/neoforge/client/ClientNeoForgeMod.java index 07197723..c3781944 100644 --- a/src/main/java/net/neoforged/neoforge/client/ClientNeoForgeMod.java +++ b/src/main/java/net/neoforged/neoforge/client/ClientNeoForgeMod.java @@ -30,7 +30,6 @@ import net.neoforged.neoforge.client.gui.IConfigScreenFactory; import net.neoforged.neoforge.client.model.CompositeModel; import net.neoforged.neoforge.client.model.DynamicFluidContainerModel; -import net.neoforged.neoforge.client.model.ElementsModel; import net.neoforged.neoforge.client.model.EmptyModel; import net.neoforged.neoforge.client.model.ItemLayerModel; import net.neoforged.neoforge.client.model.SeparateTransformsModel; @@ -66,7 +65,6 @@ public ClientNeoForgeMod(IEventBus modEventBus, ModContainer container) { @SubscribeEvent static void onRegisterGeometryLoaders(ModelEvent.RegisterGeometryLoaders event) { event.register(ResourceLocation.fromNamespaceAndPath("neoforge", "empty"), EmptyModel.LOADER); - event.register(ResourceLocation.fromNamespaceAndPath("neoforge", "elements"), ElementsModel.Loader.INSTANCE); event.register(ResourceLocation.fromNamespaceAndPath("neoforge", "obj"), ObjLoader.INSTANCE); event.register(ResourceLocation.fromNamespaceAndPath("neoforge", "fluid_container"), DynamicFluidContainerModel.Loader.INSTANCE); event.register(ResourceLocation.fromNamespaceAndPath("neoforge", "composite"), CompositeModel.Loader.INSTANCE); diff --git a/src/main/java/net/neoforged/neoforge/client/CoreShaderManager.java b/src/main/java/net/neoforged/neoforge/client/CoreShaderManager.java new file mode 100644 index 00000000..a07d12e8 --- /dev/null +++ b/src/main/java/net/neoforged/neoforge/client/CoreShaderManager.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) NeoForged and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.neoforged.neoforge.client; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import net.minecraft.client.renderer.CoreShaders; +import net.minecraft.client.renderer.ShaderProgram; +import net.neoforged.fml.ModLoader; +import net.neoforged.neoforge.client.event.RegisterShadersEvent; +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.Internal +public final class CoreShaderManager { + private static List shaderPrograms = Collections.emptyList(); + + private CoreShaderManager() {} + + public static void init() { + List programs = new ArrayList<>(CoreShaders.getProgramsToPreload()); + ModLoader.postEvent(new RegisterShadersEvent(programs)); + shaderPrograms = List.copyOf(programs); + } + + public static List getProgramsToPreload() { + return shaderPrograms; + } +} diff --git a/src/main/java/net/neoforged/neoforge/client/IArmPoseTransformer.java b/src/main/java/net/neoforged/neoforge/client/IArmPoseTransformer.java index cd41d9e1..9cac689c 100644 --- a/src/main/java/net/neoforged/neoforge/client/IArmPoseTransformer.java +++ b/src/main/java/net/neoforged/neoforge/client/IArmPoseTransformer.java @@ -6,6 +6,7 @@ package net.neoforged.neoforge.client; import net.minecraft.client.model.HumanoidModel; +import net.minecraft.client.renderer.entity.state.HumanoidRenderState; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; @@ -27,5 +28,5 @@ public interface IArmPoseTransformer { * @param entity The humanoid entity * @param arm Arm to pose */ - void applyTransform(HumanoidModel model, LivingEntity entity, HumanoidArm arm); + void applyTransform(HumanoidModel model, HumanoidRenderState entity, HumanoidArm arm); } diff --git a/src/main/java/net/neoforged/neoforge/client/NeoForgeRenderTypes.java b/src/main/java/net/neoforged/neoforge/client/NeoForgeRenderTypes.java index 2fc2461c..98988e55 100644 --- a/src/main/java/net/neoforged/neoforge/client/NeoForgeRenderTypes.java +++ b/src/main/java/net/neoforged/neoforge/client/NeoForgeRenderTypes.java @@ -17,6 +17,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.TriState; import net.neoforged.neoforge.client.event.RenderLevelStageEvent; import net.neoforged.neoforge.common.util.Lazy; @@ -157,7 +158,7 @@ public RenderType get() { } private static class Internal { - private static final RenderStateShard.ShaderStateShard RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER = new RenderStateShard.ShaderStateShard(ClientHooks.ClientEvents::getEntityTranslucentUnlitShader); + private static final RenderStateShard.ShaderStateShard RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER = new RenderStateShard.ShaderStateShard(ClientHooks.ClientEvents.RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER); public static Function UNSORTED_TRANSLUCENT = Util.memoize(Internal::unsortedTranslucent); @@ -165,7 +166,7 @@ private static RenderType unsortedTranslucent(ResourceLocation textureLocation) final boolean sortingEnabled = false; var renderState = RenderType.CompositeState.builder() .setShaderState(RenderType.RENDERTYPE_ENTITY_TRANSLUCENT_SHADER) - .setTextureState(new TextureStateShard(textureLocation, false, false)) + .setTextureState(new TextureStateShard(textureLocation, TriState.DEFAULT, false)) .setTransparencyState(RenderType.TRANSLUCENT_TRANSPARENCY) .setCullState(RenderType.NO_CULL) .setLightmapState(RenderType.LIGHTMAP) @@ -180,7 +181,7 @@ private static RenderType unsortedTranslucent(ResourceLocation textureLocation) private static RenderType unlitTranslucent(ResourceLocation textureLocation, boolean sortingEnabled) { var renderState = RenderType.CompositeState.builder() .setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER) - .setTextureState(new TextureStateShard(textureLocation, false, false)) + .setTextureState(new TextureStateShard(textureLocation, TriState.DEFAULT, false)) .setTransparencyState(RenderType.TRANSLUCENT_TRANSPARENCY) .setCullState(RenderType.NO_CULL) .setLightmapState(RenderType.LIGHTMAP) @@ -194,7 +195,7 @@ private static RenderType unlitTranslucent(ResourceLocation textureLocation, boo private static RenderType layeredItemSolid(ResourceLocation locationIn) { var rendertype$state = RenderType.CompositeState.builder() .setShaderState(RenderType.RENDERTYPE_ENTITY_SOLID_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false)) + .setTextureState(new RenderStateShard.TextureStateShard(locationIn, TriState.DEFAULT, false)) .setTransparencyState(RenderType.NO_TRANSPARENCY) .setLightmapState(RenderType.LIGHTMAP) .setOverlayState(RenderType.OVERLAY) @@ -207,7 +208,7 @@ private static RenderType layeredItemSolid(ResourceLocation locationIn) { private static RenderType layeredItemCutout(ResourceLocation locationIn) { var rendertype$state = RenderType.CompositeState.builder() .setShaderState(RenderType.RENDERTYPE_ENTITY_CUTOUT_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false)) + .setTextureState(new RenderStateShard.TextureStateShard(locationIn, TriState.DEFAULT, false)) .setTransparencyState(RenderType.NO_TRANSPARENCY) .setLightmapState(RenderType.LIGHTMAP) .setOverlayState(RenderType.OVERLAY) @@ -220,7 +221,7 @@ private static RenderType layeredItemCutout(ResourceLocation locationIn) { private static RenderType layeredItemCutoutMipped(ResourceLocation locationIn) { var rendertype$state = RenderType.CompositeState.builder() .setShaderState(RenderType.RENDERTYPE_ENTITY_SMOOTH_CUTOUT_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, true)) + .setTextureState(new RenderStateShard.TextureStateShard(locationIn, TriState.DEFAULT, true)) .setTransparencyState(RenderType.NO_TRANSPARENCY) .setLightmapState(RenderType.LIGHTMAP) .setOverlayState(RenderType.OVERLAY) @@ -233,7 +234,7 @@ private static RenderType layeredItemCutoutMipped(ResourceLocation locationIn) { private static RenderType layeredItemTranslucent(ResourceLocation locationIn) { var rendertype$state = RenderType.CompositeState.builder() .setShaderState(RenderType.RENDERTYPE_ENTITY_TRANSLUCENT_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false)) + .setTextureState(new RenderStateShard.TextureStateShard(locationIn, TriState.DEFAULT, false)) .setTransparencyState(RenderType.TRANSLUCENT_TRANSPARENCY) .setLightmapState(RenderType.LIGHTMAP) .setOverlayState(RenderType.OVERLAY) @@ -324,7 +325,7 @@ private static RenderType getTextIntensitySeeThrough(ResourceLocation locationIn private static RenderType getTranslucentParticlesTarget(ResourceLocation locationIn) { var rendertype$state = RenderType.CompositeState.builder() .setShaderState(RenderType.RENDERTYPE_TRANSLUCENT_SHADER) - .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, true)) + .setTextureState(new RenderStateShard.TextureStateShard(locationIn, TriState.DEFAULT, true)) .setTransparencyState(RenderType.TRANSLUCENT_TRANSPARENCY) .setLightmapState(RenderType.LIGHTMAP) .setOutputState(RenderType.PARTICLES_TARGET) @@ -338,7 +339,7 @@ private static class CustomizableTextureState extends TextureStateShard { private final BooleanSupplier mipmapSupplier; private CustomizableTextureState(ResourceLocation resLoc, BooleanSupplier blur, BooleanSupplier mipmap) { - super(resLoc, blur.getAsBoolean(), mipmap.getAsBoolean()); + super(resLoc, blur.getAsBoolean() ? TriState.TRUE : TriState.DEFAULT, mipmap.getAsBoolean()); blurSupplier = blur; mipmapSupplier = mipmap; } @@ -346,7 +347,7 @@ private CustomizableTextureState(ResourceLocation resLoc, BooleanSupplier blur, @Override public void setupRenderState() { // must be done before super call as super uses the `blur` and `mipmap` fields within the `setupState` runnable | See super constructor - blur = blurSupplier.getAsBoolean(); + blur = blurSupplier.getAsBoolean() ? TriState.TRUE : TriState.DEFAULT; mipmap = mipmapSupplier.getAsBoolean(); super.setupRenderState(); } diff --git a/src/main/java/net/neoforged/neoforge/client/ParticleBoundsDebugRenderer.java b/src/main/java/net/neoforged/neoforge/client/ParticleBoundsDebugRenderer.java index 9b57ae8f..eef4be79 100644 --- a/src/main/java/net/neoforged/neoforge/client/ParticleBoundsDebugRenderer.java +++ b/src/main/java/net/neoforged/neoforge/client/ParticleBoundsDebugRenderer.java @@ -10,8 +10,8 @@ import com.mojang.brigadier.Command; import com.mojang.brigadier.arguments.BoolArgumentType; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.ShapeRenderer; import net.minecraft.commands.Commands; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; @@ -44,7 +44,7 @@ public static void onRenderLevelStage(RenderLevelStageEvent event) { var offset = particle.getPos().subtract(camPos); poseStack.translate(offset.x, offset.y, offset.z); bb = bb.move(-particle.getPos().x, -particle.getPos().y, -particle.getPos().z); - LevelRenderer.renderLineBox(poseStack, consumer, bb, 1F, 0F, 0F, 1F); + ShapeRenderer.renderLineBox(poseStack, consumer, bb, 1F, 0F, 0F, 1F); poseStack.popPose(); } }); diff --git a/src/main/java/net/neoforged/neoforge/client/RecipeBookManager.java b/src/main/java/net/neoforged/neoforge/client/RecipeBookManager.java index 829d5f27..c8eb9165 100644 --- a/src/main/java/net/neoforged/neoforge/client/RecipeBookManager.java +++ b/src/main/java/net/neoforged/neoforge/client/RecipeBookManager.java @@ -5,69 +5,31 @@ package net.neoforged.neoforge.client; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import java.util.Collections; -import java.util.HashMap; +import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import java.util.function.Function; -import net.minecraft.client.RecipeBookCategories; -import net.minecraft.world.inventory.RecipeBookType; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeHolder; -import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.ExtendedRecipeBookCategory; +import net.minecraft.world.item.crafting.RecipeBookCategory; import net.neoforged.fml.ModLoader; -import net.neoforged.neoforge.client.event.RegisterRecipeBookCategoriesEvent; +import net.neoforged.neoforge.client.event.RegisterRecipeBookSearchCategoriesEvent; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; /** - * Manager for {@link RecipeBookType recipe book types} and {@link RecipeBookCategories categories}. - *

- * Provides a recipe category lookup. + * Manager for mod-provided search {@link ExtendedRecipeBookCategory} implementations. */ public final class RecipeBookManager { - // Not using ConcurrentHashMap here because it's slower for lookups, so we only use it during init - private static final Map> AGGREGATE_CATEGORIES = new HashMap<>(); - private static final Map> TYPE_CATEGORIES = new HashMap<>(); - private static final Map, Function, RecipeBookCategories>> RECIPE_CATEGORY_LOOKUPS = new HashMap<>(); - private static final Map> AGGREGATE_CATEGORIES_VIEW = Collections.unmodifiableMap(AGGREGATE_CATEGORIES); + private static Map> searchCategories = Map.of(); - /** - * Finds the category the specified recipe should display in, or null if none. - */ - @Nullable - public static > RecipeBookCategories findCategories(RecipeType type, RecipeHolder recipe) { - var lookup = RECIPE_CATEGORY_LOOKUPS.get(type); - return lookup != null ? lookup.apply(recipe) : null; - } - - @ApiStatus.Internal - public static Map> getAggregateCategories() { - return AGGREGATE_CATEGORIES_VIEW; - } - - @ApiStatus.Internal - public static List getCustomCategoriesOrEmpty(RecipeBookType recipeBookType) { - return TYPE_CATEGORIES.getOrDefault(recipeBookType, List.of()); + public static Map> getSearchCategories() { + return searchCategories; } @ApiStatus.Internal public static void init() { - // The ImmutableMap is the patched out value of AGGREGATE_CATEGORIES - var aggregateCategories = new HashMap<>(ImmutableMap.of( - RecipeBookCategories.CRAFTING_SEARCH, ImmutableList.of(RecipeBookCategories.CRAFTING_EQUIPMENT, RecipeBookCategories.CRAFTING_BUILDING_BLOCKS, RecipeBookCategories.CRAFTING_MISC, RecipeBookCategories.CRAFTING_REDSTONE), - RecipeBookCategories.FURNACE_SEARCH, ImmutableList.of(RecipeBookCategories.FURNACE_FOOD, RecipeBookCategories.FURNACE_BLOCKS, RecipeBookCategories.FURNACE_MISC), - RecipeBookCategories.BLAST_FURNACE_SEARCH, ImmutableList.of(RecipeBookCategories.BLAST_FURNACE_BLOCKS, RecipeBookCategories.BLAST_FURNACE_MISC), - RecipeBookCategories.SMOKER_SEARCH, ImmutableList.of(RecipeBookCategories.SMOKER_FOOD))); - - var typeCategories = new HashMap>(); - var recipeCategoryLookups = new HashMap, Function, RecipeBookCategories>>(); - var event = new RegisterRecipeBookCategoriesEvent(aggregateCategories, typeCategories, recipeCategoryLookups); - ModLoader.postEventWrapContainerInModOrder(event); - AGGREGATE_CATEGORIES.putAll(aggregateCategories); - TYPE_CATEGORIES.putAll(typeCategories); - RECIPE_CATEGORY_LOOKUPS.putAll(recipeCategoryLookups); + var searchCategories = new IdentityHashMap>(); + var event = new RegisterRecipeBookSearchCategoriesEvent(searchCategories); + ModLoader.postEvent(event); + RecipeBookManager.searchCategories = Collections.unmodifiableMap(searchCategories); } } diff --git a/src/main/java/net/neoforged/neoforge/client/RenderTypeGroup.java b/src/main/java/net/neoforged/neoforge/client/RenderTypeGroup.java index 91d9eccf..18c34366 100644 --- a/src/main/java/net/neoforged/neoforge/client/RenderTypeGroup.java +++ b/src/main/java/net/neoforged/neoforge/client/RenderTypeGroup.java @@ -9,21 +9,15 @@ /** * A set of functionally equivalent shaders. One using {@link com.mojang.blaze3d.vertex.DefaultVertexFormat#BLOCK}, - * and the other two using {@link com.mojang.blaze3d.vertex.DefaultVertexFormat#NEW_ENTITY}. - * {@code entityFabulous} may support custom render targets and other aspects of the fabulous pipeline, or can otherwise - * be the same as {@code entity}. + * and the other one using {@link com.mojang.blaze3d.vertex.DefaultVertexFormat#NEW_ENTITY}. */ -public record RenderTypeGroup(RenderType block, RenderType entity, RenderType entityFabulous) { +public record RenderTypeGroup(RenderType block, RenderType entity) { public RenderTypeGroup { - if ((block == null) != (entity == null) || (block == null) != (entityFabulous == null)) + if ((block == null) != (entity == null)) throw new IllegalArgumentException("The render types in a group must either be all null, or all non-null."); } - public RenderTypeGroup(RenderType block, RenderType entity) { - this(block, entity, entity); - } - - public static RenderTypeGroup EMPTY = new RenderTypeGroup(null, null, null); + public static RenderTypeGroup EMPTY = new RenderTypeGroup(null, null); /** * {@return true if this group has render types or not. It either has all, or none} diff --git a/src/main/java/net/neoforged/neoforge/client/RenderTypeHelper.java b/src/main/java/net/neoforged/neoforge/client/RenderTypeHelper.java index ef5a4869..ad22d070 100644 --- a/src/main/java/net/neoforged/neoforge/client/RenderTypeHelper.java +++ b/src/main/java/net/neoforged/neoforge/client/RenderTypeHelper.java @@ -6,7 +6,6 @@ package net.neoforged.neoforge.client; import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Sheets; @@ -25,12 +24,12 @@ public final class RenderTypeHelper { * Provides a {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY} for the given {@link DefaultVertexFormat#BLOCK} format. * This should be called for each {@link RenderType} returned by {@link BakedModel#getRenderTypes(BlockState, RandomSource, ModelData)}. *

- * Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getRenderType(BlockState, boolean)}. + * Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getRenderType(BlockState)}. */ - public static RenderType getEntityRenderType(RenderType chunkRenderType, boolean cull) { + public static RenderType getEntityRenderType(RenderType chunkRenderType) { if (chunkRenderType != RenderType.translucent()) return Sheets.cutoutBlockSheet(); - return cull || !Minecraft.useShaderTransparency() ? Sheets.translucentCullBlockSheet() : Sheets.translucentItemSheet(); + return Sheets.translucentItemSheet(); } /** @@ -48,17 +47,17 @@ public static RenderType getMovingBlockRenderType(RenderType renderType) { /** * Provides a fallback {@link RenderType} for the given {@link ItemStack} in the case that none is explicitly specified. *

- * Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getRenderType(ItemStack, boolean)} + * Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getRenderType(ItemStack)} * but removes the need to query the model again if the item is a {@link BlockItem}. */ - public static RenderType getFallbackItemRenderType(ItemStack stack, BakedModel model, boolean cull) { + public static RenderType getFallbackItemRenderType(ItemStack stack, BakedModel model) { if (stack.getItem() instanceof BlockItem blockItem) { var renderTypes = model.getRenderTypes(blockItem.getBlock().defaultBlockState(), RandomSource.create(42), ModelData.EMPTY); if (renderTypes.contains(RenderType.translucent())) - return getEntityRenderType(RenderType.translucent(), cull); + return getEntityRenderType(RenderType.translucent()); return Sheets.cutoutBlockSheet(); } - return cull ? Sheets.translucentCullBlockSheet() : Sheets.translucentItemSheet(); + return Sheets.translucentItemSheet(); } private RenderTypeHelper() {} diff --git a/src/main/java/net/neoforged/neoforge/client/TagConventionLogWarningClient.java b/src/main/java/net/neoforged/neoforge/client/TagConventionLogWarningClient.java index 4e68adbe..72c8d0b8 100644 --- a/src/main/java/net/neoforged/neoforge/client/TagConventionLogWarningClient.java +++ b/src/main/java/net/neoforged/neoforge/client/TagConventionLogWarningClient.java @@ -8,6 +8,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.List; import net.minecraft.client.resources.language.I18n; +import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; @@ -49,7 +50,7 @@ static void setupUntranslatedItemTagWarning(IEventBus forgeBus) { if (!FMLLoader.isProduction() == isConfigSetToDev) { List> untranslatedTags = new ObjectArrayList<>(); RegistryAccess.Frozen registryAccess = serverStartingEvent.getServer().registryAccess(); - extractUnregisteredModdedTags(registryAccess.registryOrThrow(Registries.ITEM), untranslatedTags); + extractUnregisteredModdedTags(registryAccess.lookupOrThrow(Registries.ITEM), untranslatedTags); if (!untranslatedTags.isEmpty()) { StringBuilder stringBuilder = new StringBuilder(); @@ -80,7 +81,7 @@ static void setupUntranslatedItemTagWarning(IEventBus forgeBus) { } private static void extractUnregisteredModdedTags(Registry registry, List> untranslatedTags) { - registry.getTagNames().forEach(itemTagKey -> { + registry.getTags().map(HolderSet.Named::key).forEach(itemTagKey -> { // We do not translate vanilla's tags at this moment. if (itemTagKey.location().getNamespace().equals("minecraft")) { return; diff --git a/src/main/java/net/neoforged/neoforge/client/entity/animation/json/AnimationLoader.java b/src/main/java/net/neoforged/neoforge/client/entity/animation/json/AnimationLoader.java index 8fd278c8..7d788419 100644 --- a/src/main/java/net/neoforged/neoforge/client/entity/animation/json/AnimationLoader.java +++ b/src/main/java/net/neoforged/neoforge/client/entity/animation/json/AnimationLoader.java @@ -6,11 +6,7 @@ package net.neoforged.neoforge.client.entity.animation.json; import com.google.common.collect.MapMaker; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; import com.mojang.logging.LogUtils; -import com.mojang.serialization.JsonOps; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -25,7 +21,7 @@ /** * A loader for entity animations written in JSON. You can also get parsed animations from this class. */ -public final class AnimationLoader extends SimpleJsonResourceReloadListener { +public final class AnimationLoader extends SimpleJsonResourceReloadListener { private static final Logger LOGGER = LogUtils.getLogger(); public static final AnimationLoader INSTANCE = new AnimationLoader(); @@ -35,7 +31,7 @@ public final class AnimationLoader extends SimpleJsonResourceReloadListener { private final List strongHolderReferences = new ArrayList<>(); private AnimationLoader() { - super(new Gson(), "neoforge/animations/entity"); + super(AnimationParser.CODEC, "neoforge/animations/entity"); } /** @@ -56,21 +52,15 @@ public AnimationHolder getAnimationHolder(ResourceLocation key) { } @Override - protected void apply(Map animationJsons, ResourceManager resourceManager, ProfilerFiller profiler) { + protected void apply(Map animationJsons, ResourceManager resourceManager, ProfilerFiller profiler) { animations.values().forEach(AnimationHolder::unbind); strongHolderReferences.clear(); int loaded = 0; for (final var entry : animationJsons.entrySet()) { - try { - final var animation = AnimationParser.CODEC.parse(JsonOps.INSTANCE, entry.getValue()) - .getOrThrow(JsonParseException::new); - final var holder = getAnimationHolder(entry.getKey()); - holder.bind(animation); - strongHolderReferences.add(holder); - loaded++; - } catch (Exception e) { - LOGGER.error("Failed to load animation {}", entry.getKey(), e); - } + final var holder = getAnimationHolder(entry.getKey()); + holder.bind(entry.getValue()); + strongHolderReferences.add(holder); + loaded++; } LOGGER.info("Loaded {} entity animations", loaded); } diff --git a/src/main/java/net/neoforged/neoforge/client/event/AddAttributeTooltipsEvent.java b/src/main/java/net/neoforged/neoforge/client/event/AddAttributeTooltipsEvent.java new file mode 100644 index 00000000..b39ffb1f --- /dev/null +++ b/src/main/java/net/neoforged/neoforge/client/event/AddAttributeTooltipsEvent.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) NeoForged and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.neoforged.neoforge.client.event; + +import java.util.function.Consumer; +import net.minecraft.core.component.DataComponents; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.component.ItemAttributeModifiers; +import net.neoforged.bus.api.Event; +import net.neoforged.neoforge.common.util.AttributeTooltipContext; +import net.neoforged.neoforge.common.util.AttributeUtil; + +/** + * This event is fired after attribute tooltip lines have been added to an item stack's tooltip in {@link AttributeUtil#addAttributeTooltips}. + *

+ * It can be used to add additional tooltip lines adjacent to the attribute lines without having to manually locate the inject point. + *

+ * This event may be fired on both the logical client and logical server. + */ +public class AddAttributeTooltipsEvent extends Event { + protected final ItemStack stack; + protected final Consumer tooltip; + protected final AttributeTooltipContext ctx; + + public AddAttributeTooltipsEvent(ItemStack stack, Consumer tooltip, AttributeTooltipContext ctx) { + this.stack = stack; + this.tooltip = tooltip; + this.ctx = ctx; + } + + /** + * The current tooltip context. + */ + public AttributeTooltipContext getContext() { + return this.ctx; + } + + /** + * The {@link ItemStack} with the tooltip. + */ + public ItemStack getStack() { + return this.stack; + } + + /** + * Adds one or more {@link Component}s to the tooltip. + */ + public void addTooltipLines(Component... comps) { + for (Component comp : comps) { + this.tooltip.accept(comp); + } + } + + /** + * Checks if the attribute tooltips should be shown on the current item stack. + *

+ * This event is fired even if the component would prevent the normal tooltip lines from showing. + */ + public boolean shouldShow() { + return this.stack.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY).showInTooltip(); + } +} diff --git a/src/main/java/net/neoforged/neoforge/client/event/ComputeFovModifierEvent.java b/src/main/java/net/neoforged/neoforge/client/event/ComputeFovModifierEvent.java index 7e85540c..a2afcc39 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/ComputeFovModifierEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/ComputeFovModifierEvent.java @@ -5,7 +5,6 @@ package net.neoforged.neoforge.client.event; -import net.minecraft.client.Minecraft; import net.minecraft.util.Mth; import net.minecraft.world.entity.player.Player; import net.neoforged.bus.api.Event; @@ -26,13 +25,15 @@ public class ComputeFovModifierEvent extends Event { private final Player player; private final float fovModifier; + private final float fovScale; private float newFovModifier; @ApiStatus.Internal - public ComputeFovModifierEvent(Player player, float fovModifier) { + public ComputeFovModifierEvent(Player player, float fovModifier, float fovScale) { this.player = player; this.fovModifier = fovModifier; - this.setNewFovModifier((float) Mth.lerp(Minecraft.getInstance().options.fovEffectScale().get(), 1.0F, fovModifier)); + this.fovScale = fovScale; + this.setNewFovModifier(Mth.lerp(fovScale, 1.0F, fovModifier)); } /** @@ -49,6 +50,13 @@ public float getFovModifier() { return fovModifier; } + /** + * {@return the FOV scale to use for interpolating the final FOV modifier} + */ + public float getFovScale() { + return fovScale; + } + /** * {@return the current field of vision (FOV) of the player} */ diff --git a/src/main/java/net/neoforged/neoforge/client/event/EntityRenderersEvent.java b/src/main/java/net/neoforged/neoforge/client/event/EntityRenderersEvent.java index 9498a500..fc2d26c7 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/EntityRenderersEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/EntityRenderersEvent.java @@ -121,12 +121,12 @@ public void registerBlockEntityRenderer(BlockEntityType< * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ public static class AddLayers extends EntityRenderersEvent { - private final Map, EntityRenderer> renderers; - private final Map> skinMap; + private final Map, EntityRenderer> renderers; + private final Map> skinMap; private final EntityRendererProvider.Context context; @ApiStatus.Internal - public AddLayers(Map, EntityRenderer> renderers, Map> playerRenderers, EntityRendererProvider.Context context) { + public AddLayers(Map, EntityRenderer> renderers, Map> playerRenderers, EntityRendererProvider.Context context) { this.renderers = renderers; this.skinMap = playerRenderers; this.context = context; @@ -153,7 +153,7 @@ public Set getSkins() { */ @Nullable @SuppressWarnings("unchecked") - public > R getSkin(PlayerSkin.Model skinModel) { + public > R getSkin(PlayerSkin.Model skinModel) { return (R) skinMap.get(skinModel); } @@ -175,7 +175,7 @@ public Set> getEntityTypes() { */ @Nullable @SuppressWarnings("unchecked") - public > R getRenderer(EntityType entityType) { + public > R getRenderer(EntityType entityType) { return (R) renderers.get(entityType); } diff --git a/src/main/java/net/neoforged/neoforge/client/event/GatherEffectScreenTooltipsEvent.java b/src/main/java/net/neoforged/neoforge/client/event/GatherEffectScreenTooltipsEvent.java index 6eb49da8..9cb08cea 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/GatherEffectScreenTooltipsEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/GatherEffectScreenTooltipsEvent.java @@ -7,24 +7,25 @@ import java.util.ArrayList; import java.util.List; -import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.gui.screens.inventory.EffectsInInventory; import net.minecraft.network.chat.Component; import net.minecraft.world.effect.MobEffectInstance; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.Event; /** - * This event is called when an {@link EffectRenderingInventoryScreen} draws the tooltip lines for a hovered {@link MobEffectInstance}. + * This event is called when {@link EffectsInInventory} draws the tooltip lines for a hovered {@link MobEffectInstance} in an {@link AbstractContainerScreen}. * It can be used to modify the tooltip. *

* This event is only fired on the {@linkplain Dist#CLIENT physical client}. */ public class GatherEffectScreenTooltipsEvent extends Event { - protected final EffectRenderingInventoryScreen screen; + protected final AbstractContainerScreen screen; protected final MobEffectInstance effectInst; protected final List tooltip; - public GatherEffectScreenTooltipsEvent(EffectRenderingInventoryScreen screen, MobEffectInstance effectInst, List tooltip) { + public GatherEffectScreenTooltipsEvent(AbstractContainerScreen screen, MobEffectInstance effectInst, List tooltip) { this.screen = screen; this.effectInst = effectInst; this.tooltip = new ArrayList<>(tooltip); @@ -33,7 +34,7 @@ public GatherEffectScreenTooltipsEvent(EffectRenderingInventoryScreen screen, /** * @return The screen which will be rendering the tooltip lines. */ - public EffectRenderingInventoryScreen getScreen() { + public AbstractContainerScreen getScreen() { return this.screen; } diff --git a/src/main/java/net/neoforged/neoforge/client/event/GatherSkippedAttributeTooltipsEvent.java b/src/main/java/net/neoforged/neoforge/client/event/GatherSkippedAttributeTooltipsEvent.java new file mode 100644 index 00000000..851439e1 --- /dev/null +++ b/src/main/java/net/neoforged/neoforge/client/event/GatherSkippedAttributeTooltipsEvent.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) NeoForged and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.neoforged.neoforge.client.event; + +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.EquipmentSlotGroup; +import net.minecraft.world.item.ItemStack; +import net.neoforged.bus.api.Event; +import net.neoforged.neoforge.common.util.AttributeTooltipContext; +import org.jetbrains.annotations.Nullable; + +/** + * This event is used to collect the IDs of attribute modifiers that will not be displayed in item tooltips. + *

+ * It allows hiding some (or all) of the modifiers, potentially for displaying them in an alternative way (or for hiding information from the player). + *

+ * This event may be fired on both the logical client and logical server. + */ +public class GatherSkippedAttributeTooltipsEvent extends Event { + protected final ItemStack stack; + protected final AttributeTooltipContext ctx; + + @Nullable + private Set skippedIds = null; + + @Nullable + private Set skippedGroups = null; + + private boolean skipAll = false; + + public GatherSkippedAttributeTooltipsEvent(ItemStack stack, AttributeTooltipContext ctx) { + this.stack = stack; + this.ctx = ctx; + // Skip sets are lazily initialized by the getter functions to avoid memory churn + } + + /** + * The current tooltip context. + */ + public AttributeTooltipContext getContext() { + return this.ctx; + } + + /** + * The {@link ItemStack} with the tooltip. + */ + public ItemStack getStack() { + return this.stack; + } + + /** + * Marks the id of a specific attribute modifier as skipped, causing it to not be displayed in the tooltip. + */ + public void skipId(ResourceLocation id) { + this.getSkippedIds().add(id); + } + + /** + * Marks an entire {@link EquipmentSlotGroup} as skipped, preventing all modifiers for that group from showing. + */ + public void skipGroup(EquipmentSlotGroup group) { + this.getSkippedGroups().add(group); + } + + /** + * Checks if a given id is skipped or not. If all modifiers are skipped, this method always returns true. + */ + public boolean isSkipped(ResourceLocation id) { + return this.skipAll || (this.skippedIds != null && this.skippedIds.contains(id)); + } + + /** + * Checks if a given group is skipped or not. If all modifiers are skipped, this method always returns true. + */ + public boolean isSkipped(EquipmentSlotGroup group) { + return this.skipAll || (this.skippedGroups != null && this.skippedGroups.contains(group)); + } + + /** + * Sets if the event should skip displaying all attribute modifiers. + */ + public void setSkipAll(boolean skip) { + this.skipAll = skip; + } + + /** + * Checks if the event will cause all attribute modifiers to be skipped. + */ + public boolean isSkippingAll() { + return this.skipAll; + } + + /** + * Initializes {@link #skippedIds} if necessary, and returns it. + */ + protected Set getSkippedIds() { + if (this.skippedIds == null) { + this.skippedIds = new HashSet<>(); + } + return this.skippedIds; + } + + /** + * Initializes {@link #skippedGroups} if necessary, and returns it. + */ + protected Set getSkippedGroups() { + if (this.skippedGroups == null) { + this.skippedGroups = EnumSet.noneOf(EquipmentSlotGroup.class); + } + return this.skippedGroups; + } +} diff --git a/src/main/java/net/neoforged/neoforge/client/event/MovementInputUpdateEvent.java b/src/main/java/net/neoforged/neoforge/client/event/MovementInputUpdateEvent.java index 1478760b..4fa6142d 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/MovementInputUpdateEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/MovementInputUpdateEvent.java @@ -5,7 +5,7 @@ package net.neoforged.neoforge.client.event; -import net.minecraft.client.player.Input; +import net.minecraft.client.player.ClientInput; import net.minecraft.world.entity.player.Player; import net.neoforged.bus.api.Event; import net.neoforged.fml.LogicalSide; @@ -22,10 +22,10 @@ * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ public class MovementInputUpdateEvent extends PlayerEvent { - private final Input input; + private final ClientInput input; @ApiStatus.Internal - public MovementInputUpdateEvent(Player player, Input input) { + public MovementInputUpdateEvent(Player player, ClientInput input) { super(player); this.input = input; } @@ -33,7 +33,7 @@ public MovementInputUpdateEvent(Player player, Input input) { /** * {@return the player's movement inputs} */ - public Input getInput() { + public ClientInput getInput() { return input; } } diff --git a/src/main/java/net/neoforged/neoforge/client/event/RecipesUpdatedEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RecipesUpdatedEvent.java deleted file mode 100644 index 1e434369..00000000 --- a/src/main/java/net/neoforged/neoforge/client/event/RecipesUpdatedEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.neoforge.client.event; - -import net.minecraft.world.item.crafting.RecipeManager; -import net.neoforged.bus.api.Event; -import net.neoforged.fml.LogicalSide; -import net.neoforged.neoforge.common.NeoForge; -import org.jetbrains.annotations.ApiStatus; - -/** - * Fired when the {@link RecipeManager} has received and synced the recipes from the server to the client. - * - *

This event is not {@linkplain ICancellableEvent cancellable}, and does not {@linkplain HasResult have a result}.

- * - *

This event is fired on the {@linkplain NeoForge#EVENT_BUS main Forge event bus}, - * only on the {@linkplain LogicalSide#CLIENT logical client}.

- */ -public class RecipesUpdatedEvent extends Event { - private final RecipeManager recipeManager; - - @ApiStatus.Internal - public RecipesUpdatedEvent(RecipeManager recipeManager) { - this.recipeManager = recipeManager; - } - - /** - * {@return the recipe manager} - */ - public RecipeManager getRecipeManager() { - return recipeManager; - } -} diff --git a/src/main/java/net/neoforged/neoforge/client/event/RegisterNamedRenderTypesEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RegisterNamedRenderTypesEvent.java index df6a02fa..7464dbac 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/RegisterNamedRenderTypesEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/RegisterNamedRenderTypesEvent.java @@ -40,24 +40,10 @@ public RegisterNamedRenderTypesEvent(Map rend * @param entityRenderType A {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY} */ public void register(ResourceLocation key, RenderType blockRenderType, RenderType entityRenderType) { - register(key, blockRenderType, entityRenderType, entityRenderType); - } - - /** - * Registers a named {@link RenderTypeGroup}. - * - * @param key The ID of the group - * @param blockRenderType One of the values returned by {@link RenderType#chunkBufferLayers()} - * @param entityRenderType A {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY} - * @param fabulousEntityRenderType A {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY} for use when - * "fabulous" rendering is enabled - */ - public void register(ResourceLocation key, RenderType blockRenderType, RenderType entityRenderType, RenderType fabulousEntityRenderType) { Preconditions.checkArgument(!renderTypes.containsKey(key), "Render type already registered: " + key); Preconditions.checkArgument(blockRenderType.format() == DefaultVertexFormat.BLOCK, "The block render type must use the BLOCK vertex format."); Preconditions.checkArgument(blockRenderType.getChunkLayerId() >= 0, "Only chunk render types can be used for block rendering. Query RenderType#chunkBufferLayers() for a list."); Preconditions.checkArgument(entityRenderType.format() == DefaultVertexFormat.NEW_ENTITY, "The entity render type must use the NEW_ENTITY vertex format."); - Preconditions.checkArgument(fabulousEntityRenderType.format() == DefaultVertexFormat.NEW_ENTITY, "The fabulous entity render type must use the NEW_ENTITY vertex format."); - renderTypes.put(key, new RenderTypeGroup(blockRenderType, entityRenderType, fabulousEntityRenderType)); + renderTypes.put(key, new RenderTypeGroup(blockRenderType, entityRenderType)); } } diff --git a/src/main/java/net/neoforged/neoforge/client/event/RegisterRecipeBookCategoriesEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RegisterRecipeBookCategoriesEvent.java deleted file mode 100644 index 4a2c2ef6..00000000 --- a/src/main/java/net/neoforged/neoforge/client/event/RegisterRecipeBookCategoriesEvent.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.neoforge.client.event; - -import com.google.common.collect.ImmutableList; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import net.minecraft.client.RecipeBookCategories; -import net.minecraft.world.inventory.RecipeBookType; -import net.minecraft.world.item.crafting.RecipeHolder; -import net.minecraft.world.item.crafting.RecipeType; -import net.neoforged.bus.api.Event; -import net.neoforged.bus.api.ICancellableEvent; -import net.neoforged.fml.LogicalSide; -import net.neoforged.fml.event.IModBusEvent; -import org.jetbrains.annotations.ApiStatus; - -/** - * Allows users to register custom categories for the vanilla recipe book, making it usable in modded GUIs. - * - *

This event is not {@linkplain ICancellableEvent cancellable}, and does not {@linkplain HasResult have a result}. - * - *

This event is fired on the mod-specific event bus, only on the {@linkplain LogicalSide#CLIENT logical client}.

- */ -public class RegisterRecipeBookCategoriesEvent extends Event implements IModBusEvent { - private final Map> aggregateCategories; - private final Map> typeCategories; - private final Map, Function, RecipeBookCategories>> recipeCategoryLookups; - - @ApiStatus.Internal - public RegisterRecipeBookCategoriesEvent( - Map> aggregateCategories, - Map> typeCategories, - Map, Function, RecipeBookCategories>> recipeCategoryLookups) { - this.aggregateCategories = aggregateCategories; - this.typeCategories = typeCategories; - this.recipeCategoryLookups = recipeCategoryLookups; - } - - /** - * Registers the list of categories that compose an aggregate category. - */ - public void registerAggregateCategory(RecipeBookCategories category, List others) { - aggregateCategories.put(category, ImmutableList.copyOf(others)); - } - - /** - * Registers the list of categories that compose a recipe book. - */ - public void registerBookCategories(RecipeBookType type, List categories) { - typeCategories.put(type, ImmutableList.copyOf(categories)); - } - - /** - * Registers a category lookup for a certain recipe type. - */ - public void registerRecipeCategoryFinder(RecipeType type, Function, RecipeBookCategories> lookup) { - recipeCategoryLookups.put(type, lookup); - } -} diff --git a/src/main/java/net/neoforged/neoforge/client/event/RegisterRecipeBookSearchCategoriesEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RegisterRecipeBookSearchCategoriesEvent.java new file mode 100644 index 00000000..af1827c9 --- /dev/null +++ b/src/main/java/net/neoforged/neoforge/client/event/RegisterRecipeBookSearchCategoriesEvent.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) NeoForged and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.neoforged.neoforge.client.event; + +import java.util.List; +import java.util.Map; +import net.minecraft.client.gui.screens.recipebook.SearchRecipeBookCategory; +import net.minecraft.world.item.crafting.ExtendedRecipeBookCategory; +import net.minecraft.world.item.crafting.RecipeBookCategory; +import net.neoforged.bus.api.Event; +import net.neoforged.fml.LogicalSide; +import net.neoforged.fml.event.IModBusEvent; +import org.jetbrains.annotations.ApiStatus; + +/** + * Event to register {@link ExtendedRecipeBookCategory} instances for search. + * Modded equivalent of vanilla's {@link SearchRecipeBookCategory}. + * + *

This event is fired on the mod-specific event bus, only on the {@linkplain LogicalSide#CLIENT logical client}. + */ +public class RegisterRecipeBookSearchCategoriesEvent extends Event implements IModBusEvent { + private final Map> categories; + + @ApiStatus.Internal + public RegisterRecipeBookSearchCategoriesEvent(Map> categories) { + this.categories = categories; + } + + public void register(ExtendedRecipeBookCategory searchCategory, RecipeBookCategory... includedCategories) { + if (includedCategories.length == 0) { + throw new IllegalArgumentException("Forgot to register included categories."); + } + if (categories.containsKey(searchCategory)) { + throw new IllegalArgumentException("Duplicate registration of search category " + searchCategory); + } + categories.put(searchCategory, List.of(includedCategories)); + } +} diff --git a/src/main/java/net/neoforged/neoforge/client/event/RegisterShadersEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RegisterShadersEvent.java index 28f1788c..a0a89fe7 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/RegisterShadersEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/RegisterShadersEvent.java @@ -5,11 +5,8 @@ package net.neoforged.neoforge.client.event; -import com.mojang.datafixers.util.Pair; import java.util.List; -import java.util.function.Consumer; -import net.minecraft.client.renderer.ShaderInstance; -import net.minecraft.server.packs.resources.ResourceProvider; +import net.minecraft.client.renderer.ShaderProgram; import net.neoforged.bus.api.Event; import net.neoforged.bus.api.ICancellableEvent; import net.neoforged.fml.LogicalSide; @@ -17,43 +14,27 @@ import org.jetbrains.annotations.ApiStatus; /** - * Fired to allow mods to register custom {@linkplain ShaderInstance shaders}. + * Fired to allow mods to register custom {@linkplain ShaderProgram shaders}. * This event is fired after the default Minecraft shaders have been registered. * - *

This event is not {@linkplain ICancellableEvent cancellable}, and does not {@linkplain HasResult have a result}.

+ *

This event is not {@linkplain ICancellableEvent cancellable}.

* *

This event is fired on the mod-specific event bus, only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ public class RegisterShadersEvent extends Event implements IModBusEvent { - private final ResourceProvider resourceProvider; - private final List>> shaderList; + private final List shaderList; @ApiStatus.Internal - public RegisterShadersEvent(ResourceProvider resourceProvider, List>> shaderList) { - this.resourceProvider = resourceProvider; + public RegisterShadersEvent(List shaderList) { this.shaderList = shaderList; } /** - * {@return the client-side resource provider} - */ - public ResourceProvider getResourceProvider() { - return resourceProvider; - } - - /** - * Registers a shader, and a callback for when the shader is loaded. - * - *

When creating a {@link ShaderInstance}, pass in the {@linkplain #getResourceProvider() - * client-side resource provider} as the resource provider.

- * - *

Mods should not store the shader instance passed into this method. Instead, mods should store the shader - * passed into the registered load callback.

+ * Registers a {@link ShaderProgram} * - * @param shaderInstance a shader - * @param onLoaded a callback for when the shader is loaded + * @param program a shader */ - public void registerShader(ShaderInstance shaderInstance, Consumer onLoaded) { - shaderList.add(Pair.of(shaderInstance, onLoaded)); + public void registerShader(ShaderProgram program) { + shaderList.add(program); } } diff --git a/src/main/java/net/neoforged/neoforge/client/event/RenderHighlightEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RenderHighlightEvent.java index 089081b6..69b486d4 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/RenderHighlightEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/RenderHighlightEvent.java @@ -96,9 +96,12 @@ public MultiBufferSource getMultiBufferSource() { * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ public static class Block extends RenderHighlightEvent implements ICancellableEvent { + private final boolean forTranslucentBlocks; + @ApiStatus.Internal - public Block(LevelRenderer levelRenderer, Camera camera, BlockHitResult target, DeltaTracker deltaTracker, PoseStack poseStack, MultiBufferSource bufferSource) { + public Block(LevelRenderer levelRenderer, Camera camera, BlockHitResult target, DeltaTracker deltaTracker, PoseStack poseStack, MultiBufferSource bufferSource, boolean forTranslucentBlocks) { super(levelRenderer, camera, target, deltaTracker, poseStack, bufferSource); + this.forTranslucentBlocks = forTranslucentBlocks; } /** @@ -108,6 +111,13 @@ public Block(LevelRenderer levelRenderer, Camera camera, BlockHitResult target, public BlockHitResult getTarget() { return (BlockHitResult) super.target; } + + /** + * {@return whether the event is fired for outlines on translucent or non-translucent blocks} + */ + public boolean isForTranslucentBlocks() { + return forTranslucentBlocks; + } } /** @@ -118,6 +128,7 @@ public BlockHitResult getTarget() { *

This event is fired on the {@linkplain NeoForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ + // TODO porting: reevaluate public static class Entity extends RenderHighlightEvent { @ApiStatus.Internal public Entity(LevelRenderer levelRenderer, Camera camera, EntityHitResult target, DeltaTracker deltaTracker, PoseStack poseStack, MultiBufferSource bufferSource) { diff --git a/src/main/java/net/neoforged/neoforge/client/event/RenderItemInFrameEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RenderItemInFrameEvent.java index 09753d88..479758d4 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/RenderItemInFrameEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/RenderItemInFrameEvent.java @@ -9,7 +9,7 @@ import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.ItemFrameRenderer; -import net.minecraft.world.entity.decoration.ItemFrame; +import net.minecraft.client.renderer.entity.state.ItemFrameRenderState; import net.minecraft.world.item.ItemStack; import net.neoforged.bus.api.Event; import net.neoforged.bus.api.ICancellableEvent; @@ -31,18 +31,18 @@ */ public class RenderItemInFrameEvent extends Event implements ICancellableEvent { private final ItemStack itemStack; - private final ItemFrame itemFrameEntity; + private final ItemFrameRenderState frameRenderState; private final ItemFrameRenderer renderer; private final PoseStack poseStack; private final MultiBufferSource multiBufferSource; private final int packedLight; @ApiStatus.Internal - public RenderItemInFrameEvent(ItemFrame itemFrame, ItemFrameRenderer renderItemFrame, PoseStack poseStack, + public RenderItemInFrameEvent(ItemFrameRenderState frameRenderState, ItemFrameRenderer renderItemFrame, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - itemStack = itemFrame.getItem(); - itemFrameEntity = itemFrame; - renderer = renderItemFrame; + this.itemStack = frameRenderState.itemStack; + this.frameRenderState = frameRenderState; + this.renderer = renderItemFrame; this.poseStack = poseStack; this.multiBufferSource = multiBufferSource; this.packedLight = packedLight; @@ -58,8 +58,8 @@ public ItemStack getItemStack() { /** * {@return the item frame entity} */ - public ItemFrame getItemFrameEntity() { - return itemFrameEntity; + public ItemFrameRenderState getItemFrameRenderState() { + return frameRenderState; } /** diff --git a/src/main/java/net/neoforged/neoforge/client/event/RenderLivingEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RenderLivingEvent.java index 6c8f4298..5ecbefe3 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/RenderLivingEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/RenderLivingEvent.java @@ -10,6 +10,7 @@ import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.LivingEntityRenderer; +import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; import net.minecraft.world.entity.LivingEntity; import net.neoforged.bus.api.Event; import net.neoforged.bus.api.ICancellableEvent; @@ -31,18 +32,18 @@ * @see RenderPlayerEvent * @see LivingEntityRenderer */ -public abstract class RenderLivingEvent> extends Event { - private final LivingEntity entity; - private final LivingEntityRenderer renderer; +public abstract class RenderLivingEvent> extends Event { + private final S renderState; + private final LivingEntityRenderer renderer; private final float partialTick; private final PoseStack poseStack; private final MultiBufferSource multiBufferSource; private final int packedLight; @ApiStatus.Internal - protected RenderLivingEvent(LivingEntity entity, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, + protected RenderLivingEvent(S renderState, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - this.entity = entity; + this.renderState = renderState; this.renderer = renderer; this.partialTick = partialTick; this.poseStack = poseStack; @@ -51,16 +52,16 @@ protected RenderLivingEvent(LivingEntity entity, LivingEntityRenderer rend } /** - * @return the living entity being rendered + * @return the render state of the living entity being rendered */ - public LivingEntity getEntity() { - return entity; + public S getRenderState() { + return renderState; } /** * @return the renderer for the living entity */ - public LivingEntityRenderer getRenderer() { + public LivingEntityRenderer getRenderer() { return renderer; } @@ -108,10 +109,10 @@ public int getPackedLight() { * @param the living entity that is being rendered * @param the model for the living entity */ - public static class Pre> extends RenderLivingEvent implements ICancellableEvent { + public static class Pre> extends RenderLivingEvent implements ICancellableEvent { @ApiStatus.Internal - public Pre(LivingEntity entity, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(entity, renderer, partialTick, poseStack, multiBufferSource, packedLight); + public Pre(S renderState, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + super(renderState, renderer, partialTick, poseStack, multiBufferSource, packedLight); } } @@ -126,10 +127,10 @@ public Pre(LivingEntity entity, LivingEntityRenderer renderer, float parti * @param the living entity that was rendered * @param the model for the living entity */ - public static class Post> extends RenderLivingEvent { + public static class Post> extends RenderLivingEvent { @ApiStatus.Internal - public Post(LivingEntity entity, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(entity, renderer, partialTick, poseStack, multiBufferSource, packedLight); + public Post(S renderState, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + super(renderState, renderer, partialTick, poseStack, multiBufferSource, packedLight); } } } diff --git a/src/main/java/net/neoforged/neoforge/client/event/RenderNameTagEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RenderNameTagEvent.java index fcc27f82..6e6c501f 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/RenderNameTagEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/RenderNameTagEvent.java @@ -8,117 +8,174 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.state.EntityRenderState; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.Entity; +import net.neoforged.bus.api.Event; +import net.neoforged.bus.api.ICancellableEvent; +import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.common.util.TriState; -import net.neoforged.neoforge.event.entity.EntityEvent; import org.jetbrains.annotations.ApiStatus; /** * This event is fired before an entity renderer renders the nameplate of an entity. - * It allows reacting to the render and controlling if the name plate will be rendered, as well as changing the rendered name. *

* This event is only fired on the logical client. * * @see EntityRenderer */ -public class RenderNameTagEvent extends EntityEvent { - private final Component originalContent; - private final EntityRenderer entityRenderer; - private final PoseStack poseStack; - private final MultiBufferSource multiBufferSource; - private final int packedLight; +public abstract class RenderNameTagEvent extends Event { + private final EntityRenderState renderState; + protected final Component originalContent; + private final EntityRenderer entityRenderer; private final float partialTick; - private Component content; - private TriState canRender = TriState.DEFAULT; - @ApiStatus.Internal - public RenderNameTagEvent(Entity entity, Component content, EntityRenderer entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, float partialTick) { - super(entity); + public RenderNameTagEvent(EntityRenderState renderState, Component content, EntityRenderer entityRenderer, float partialTick) { + this.renderState = renderState; this.originalContent = content; - this.setContent(this.originalContent); this.entityRenderer = entityRenderer; - this.poseStack = poseStack; - this.multiBufferSource = multiBufferSource; - this.packedLight = packedLight; this.partialTick = partialTick; } /** - * Changes if the {@link #getContent() content} of the nameplate will be rendered. - * {@link TriState#TRUE} and {@link TriState#FALSE} will allow/deny the render respectively. - *

- * Using {@link TriState#DEFAULT} will cause the name to render if {@link EntityRenderer#shouldShowName} returns true. + * {@return the render state of the entity whose nameplate is being rendered} */ - public void setCanRender(TriState canRender) { - this.canRender = canRender; + public EntityRenderState getEntityRenderState() { + return renderState; } /** - * {@return if the nameplate will render or not} + * {@return the entity renderer rendering the nameplate} */ - public TriState canRender() { - return canRender; + public EntityRenderer getEntityRenderer() { + return this.entityRenderer; } /** - * Sets the new text on the nameplate. - * - * @param contents the new text + * {@return the partial tick} */ - public void setContent(Component contents) { - this.content = contents; + public float getPartialTick() { + return this.partialTick; } /** - * {@return the text on the nameplate that will be rendered} + * This event is fired when an entity renderer extracts the render state of an entity relevant to rendering the nametag. + * It allows controlling whether the name plate will be rendered, as well as changing the rendered name. + *

+ * This event is only fired on the logical client on the {@link NeoForge#EVENT_BUS}. + * + * @see EntityRenderer */ - public Component getContent() { - return this.content; - } + public static class CanRender extends RenderNameTagEvent { + private final Entity entity; + private Component content; + private TriState canRender = TriState.DEFAULT; - /** - * {@return the original text on the nameplate} - */ - public Component getOriginalContent() { - return this.originalContent; - } + public CanRender(Entity entity, EntityRenderState renderState, Component content, EntityRenderer entityRenderer, float partialTick) { + super(renderState, content, entityRenderer, partialTick); + this.entity = entity; + this.content = content; + } - /** - * {@return the entity renderer rendering the nameplate} - */ - public EntityRenderer getEntityRenderer() { - return this.entityRenderer; - } + /** + * {@return the entity whose nameplate is being rendered} + */ + public Entity getEntity() { + return entity; + } - /** - * {@return the pose stack used for rendering} - */ - public PoseStack getPoseStack() { - return this.poseStack; - } + /** + * {@return the original text on the nameplate} + */ + public Component getOriginalContent() { + return this.originalContent; + } - /** - * {@return the source of rendering buffers} - */ - public MultiBufferSource getMultiBufferSource() { - return this.multiBufferSource; + /** + * Changes if the {@link #getContent() content} of the nameplate will be rendered. + * {@link TriState#TRUE} and {@link TriState#FALSE} will allow/deny the render respectively. + *

+ * Using {@link TriState#DEFAULT} will cause the name to render if {@link EntityRenderer#shouldShowName} returns true. + */ + public void setCanRender(TriState canRender) { + this.canRender = canRender; + } + + /** + * {@return if the nameplate will render or not} + */ + public TriState canRender() { + return canRender; + } + + /** + * Sets the new text on the nameplate. + * + * @param contents the new text + */ + public void setContent(Component contents) { + this.content = contents; + } + + /** + * {@return the text on the nameplate that will be rendered} + */ + public Component getContent() { + return this.content; + } } /** - * {@return the amount of packed (sky and block) light for rendering} + * This event is fired before an entity renderer renders the nameplate of an entity. + *

+ * It allows reacting to the rendering as well as performing custom rendering and preventing + * the vanilla rendering. + *

+ * This event is only fired on the logical client on the {@link NeoForge#EVENT_BUS}. * - * @see net.minecraft.client.renderer.LightTexture + * @see EntityRenderer */ - public int getPackedLight() { - return this.packedLight; - } + public static class DoRender extends RenderNameTagEvent implements ICancellableEvent { + private final PoseStack poseStack; + private final MultiBufferSource multiBufferSource; + private final int packedLight; - /** - * {@return the partial tick} - */ - public float getPartialTick() { - return this.partialTick; + public DoRender(EntityRenderState renderState, Component content, EntityRenderer entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, float partialTick) { + super(renderState, content, entityRenderer, partialTick); + this.poseStack = poseStack; + this.multiBufferSource = multiBufferSource; + this.packedLight = packedLight; + } + + /** + * {@return the text on the nameplate} + */ + public Component getContent() { + return this.originalContent; + } + + /** + * {@return the pose stack used for rendering} + */ + public PoseStack getPoseStack() { + return this.poseStack; + } + + /** + * {@return the source of rendering buffers} + */ + public MultiBufferSource getMultiBufferSource() { + return this.multiBufferSource; + } + + /** + * {@return the amount of packed (sky and block) light for rendering} + * + * @see net.minecraft.client.renderer.LightTexture + */ + public int getPackedLight() { + return this.packedLight; + } } } diff --git a/src/main/java/net/neoforged/neoforge/client/event/RenderPlayerEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RenderPlayerEvent.java index b9b3fc68..b2fd3652 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/RenderPlayerEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/RenderPlayerEvent.java @@ -6,15 +6,15 @@ package net.neoforged.neoforge.client.event; import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.model.PlayerModel; +import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.player.PlayerRenderer; -import net.minecraft.world.entity.player.Player; +import net.minecraft.client.renderer.entity.state.PlayerRenderState; import net.neoforged.bus.api.Event; import net.neoforged.bus.api.ICancellableEvent; import net.neoforged.fml.LogicalSide; import net.neoforged.neoforge.common.NeoForge; -import net.neoforged.neoforge.event.entity.player.PlayerEvent; import org.jetbrains.annotations.ApiStatus; /** @@ -25,58 +25,10 @@ * @see RenderPlayerEvent.Post * @see PlayerRenderer */ -public abstract class RenderPlayerEvent extends PlayerEvent { - private final PlayerRenderer renderer; - private final float partialTick; - private final PoseStack poseStack; - private final MultiBufferSource multiBufferSource; - private final int packedLight; - +public abstract class RenderPlayerEvent extends RenderLivingEvent { @ApiStatus.Internal - protected RenderPlayerEvent(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(player); - this.renderer = renderer; - this.partialTick = partialTick; - this.poseStack = poseStack; - this.multiBufferSource = multiBufferSource; - this.packedLight = packedLight; - } - - /** - * {@return the player entity renderer} - */ - public PlayerRenderer getRenderer() { - return renderer; - } - - /** - * {@return the partial tick} - */ - public float getPartialTick() { - return partialTick; - } - - /** - * {@return the pose stack used for rendering} - */ - public PoseStack getPoseStack() { - return poseStack; - } - - /** - * {@return the source of rendering buffers} - */ - public MultiBufferSource getMultiBufferSource() { - return multiBufferSource; - } - - /** - * {@return the amount of packed (sky and block) light for rendering} - * - * @see LightTexture - */ - public int getPackedLight() { - return packedLight; + protected RenderPlayerEvent(PlayerRenderState renderState, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + super(renderState, renderer, partialTick, poseStack, multiBufferSource, packedLight); } /** @@ -92,8 +44,8 @@ public int getPackedLight() { */ public static class Pre extends RenderPlayerEvent implements ICancellableEvent { @ApiStatus.Internal - public Pre(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(player, renderer, partialTick, poseStack, multiBufferSource, packedLight); + public Pre(PlayerRenderState renderState, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + super(renderState, renderer, partialTick, poseStack, multiBufferSource, packedLight); } } @@ -107,8 +59,8 @@ public Pre(Player player, PlayerRenderer renderer, float partialTick, PoseStack */ public static class Post extends RenderPlayerEvent { @ApiStatus.Internal - public Post(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { - super(player, renderer, partialTick, poseStack, multiBufferSource, packedLight); + public Post(PlayerRenderState renderState, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { + super(renderState, renderer, partialTick, poseStack, multiBufferSource, packedLight); } } } diff --git a/src/main/java/net/neoforged/neoforge/client/event/RenderTooltipEvent.java b/src/main/java/net/neoforged/neoforge/client/event/RenderTooltipEvent.java index e7f7c846..1fff84cf 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/RenderTooltipEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/RenderTooltipEvent.java @@ -12,7 +12,9 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner; +import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.FormattedText; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.item.ItemStack; import net.neoforged.bus.api.Event; @@ -21,6 +23,7 @@ import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; /** * Fired during tooltip rendering. @@ -28,7 +31,7 @@ * * @see RenderTooltipEvent.GatherComponents * @see RenderTooltipEvent.Pre - * @see RenderTooltipEvent.Color + * @see RenderTooltipEvent.Texture */ public abstract class RenderTooltipEvent extends Event { protected final ItemStack itemStack; @@ -99,7 +102,7 @@ public Font getFont() { * *

This event is {@linkplain ICancellableEvent cancellable}, and does not {@linkplain HasResult have a result}. * If this event is cancelled, then the list of components will be empty, causing the tooltip to not be rendered and - * the corresponding {@link RenderTooltipEvent.Pre} and {@link RenderTooltipEvent.Color} to not be fired.

+ * the corresponding {@link RenderTooltipEvent.Pre} and {@link RenderTooltipEvent.Texture} to not be fired.

* *

This event is fired on the {@linkplain NeoForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

@@ -179,7 +182,7 @@ public void setMaxWidth(int maxWidth) { * *

This event is {@linkplain ICancellableEvent cancellable}, and does not {@linkplain HasResult have a result}. * If this event is cancelled, then the tooltip will not be rendered and the corresponding - * {@link RenderTooltipEvent.Color} will not be fired.

+ * {@link RenderTooltipEvent.Texture} will not be fired.

* *

This event is fired on the {@linkplain NeoForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

@@ -247,136 +250,51 @@ public void setY(int y) { } /** - * Fired when the colours for the tooltip background are determined. - * This can be used to modify the background color and the border's gradient colors. + * Fired when the textures for the tooltip background are determined. + * This can be used to modify the background and frame texture. * - *

This event is not {@linkplain ICancellableEvent cancellable}, and does not {@linkplain HasResult have a result}.

+ *

This event is not {@linkplain ICancellableEvent cancellable}.

* *

This event is fired on the {@linkplain NeoForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ - public static class Color extends RenderTooltipEvent { - private final int originalBackground; - private final int originalBorderStart; - private final int originalBorderEnd; - private int backgroundStart; - private int backgroundEnd; - private int borderStart; - private int borderEnd; + public static class Texture extends RenderTooltipEvent { + @Nullable + private final ResourceLocation originalTexture; + @Nullable + private ResourceLocation texture; @ApiStatus.Internal - public Color(ItemStack stack, GuiGraphics graphics, int x, int y, Font fr, int background, int borderStart, int borderEnd, List components) { - super(stack, graphics, x, y, fr, components); - this.originalBackground = background; - this.originalBorderStart = borderStart; - this.originalBorderEnd = borderEnd; - this.backgroundStart = background; - this.backgroundEnd = background; - this.borderStart = borderStart; - this.borderEnd = borderEnd; - } - - /** - * {@return the gradient start color for the tooltip background (top edge)} - */ - public int getBackgroundStart() { - return backgroundStart; - } - - /** - * {@return the gradient end color for the tooltip background (bottom edge)} - */ - public int getBackgroundEnd() { - return backgroundEnd; - } - - /** - * Sets the new color for the tooltip background. This sets both the gradient start and end color for the - * background to this color. - * - * @param background the new color for the tooltip background - */ - public void setBackground(int background) { - this.backgroundStart = background; - this.backgroundEnd = background; - } - - /** - * Sets the new start color for the gradient of the tooltip background (top edge). - * - * @param backgroundStart the new start color for the tooltip background - */ - public void setBackgroundStart(int backgroundStart) { - this.backgroundStart = backgroundStart; - } - - /** - * Sets the new end color for the gradient of the tooltip background (bottom edge). - * - * @param backgroundEnd the new end color for the tooltip background - */ - public void setBackgroundEnd(int backgroundEnd) { - this.backgroundEnd = backgroundEnd; - } - - /** - * {@return the gradient start color for the tooltip border (top edge)} - */ - public int getBorderStart() { - return borderStart; - } - - /** - * Sets the new start color for the gradient of the tooltip border (top edge). - * - * @param borderStart the new start color for the tooltip border - */ - public void setBorderStart(int borderStart) { - this.borderStart = borderStart; - } - - /** - * {@return the gradient end color for the tooltip border (bottom edge)} - */ - public int getBorderEnd() { - return borderEnd; - } - - /** - * Sets the new end color for the gradient of the tooltip border (bottom edge). - * - * @param borderEnd the new end color for the tooltip border - */ - public void setBorderEnd(int borderEnd) { - this.borderEnd = borderEnd; - } - - /** - * {@return the original tooltip background's gradient start color (top edge)} - */ - public int getOriginalBackgroundStart() { - return originalBackground; + public Texture(ItemStack stack, GuiGraphics graphics, int x, int y, Font font, List components, @Nullable ResourceLocation texture) { + super(stack, graphics, x, y, font, components); + this.originalTexture = texture; + this.texture = texture; } /** - * {@return the original tooltip background's gradient end color (bottom edge)} + * {@return the original texture location given to the tooltip render method (may originate from {@link DataComponents#TOOLTIP_STYLE})} */ - public int getOriginalBackgroundEnd() { - return originalBackground; + @Nullable + public ResourceLocation getOriginalTexture() { + return originalTexture; } /** - * {@return the original tooltip border's gradient start color (top edge)} + * {@return the texture location that will be used to render the tooltip} */ - public int getOriginalBorderStart() { - return originalBorderStart; + @Nullable + public ResourceLocation getTexture() { + return texture; } /** - * {@return the original tooltip border's gradient end color (bottom edge)} + * Set the texture to use for the tooltip background and frame or {@code null} to use the default textures. + *

+ * The given {@link ResourceLocation} will be prefixed with {@code tooltip/} and suffixed with {@code _background} + * and {@code _frame} to determine the background and frame texture respectively */ - public int getOriginalBorderEnd() { - return originalBorderEnd; + public void setTexture(@Nullable ResourceLocation texture) { + this.texture = texture; } } } diff --git a/src/main/java/net/neoforged/neoforge/client/event/ScreenEvent.java b/src/main/java/net/neoforged/neoforge/client/event/ScreenEvent.java index bb40c082..d3d22931 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/ScreenEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/ScreenEvent.java @@ -13,7 +13,8 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.gui.screens.inventory.EffectsInInventory; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.bus.api.Event; @@ -256,7 +257,7 @@ public GuiGraphics getGuiGraphics() { } /** - * Fired ahead of rendering any active mob effects in the {@link EffectRenderingInventoryScreen inventory screen}. + * Fired ahead of rendering any active mob effects in the {@link EffectsInInventory} held by a {@link AbstractContainerScreen}. * Can be used to select the size of the effects display (full or compact) or even hide or replace vanilla's rendering entirely. * This event can also be used to modify the horizontal position of the stack of effects being rendered. * diff --git a/src/main/java/net/neoforged/neoforge/client/event/ViewportEvent.java b/src/main/java/net/neoforged/neoforge/client/event/ViewportEvent.java index 77c66441..cf0e2541 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/ViewportEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/ViewportEvent.java @@ -8,6 +8,7 @@ import com.mojang.blaze3d.shaders.FogShape; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.FogParameters; import net.minecraft.client.renderer.FogRenderer.FogMode; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.world.level.material.FogType; @@ -80,13 +81,13 @@ public static class RenderFog extends ViewportEvent implements ICancellableEvent private FogShape fogShape; @ApiStatus.Internal - public RenderFog(FogMode mode, FogType type, Camera camera, float partialTicks, float nearPlaneDistance, float farPlaneDistance, FogShape fogShape) { + public RenderFog(FogMode mode, FogType type, Camera camera, float partialTicks, FogParameters fogParameters) { super(Minecraft.getInstance().gameRenderer, camera, partialTicks); this.mode = mode; this.type = type; - setFarPlaneDistance(farPlaneDistance); - setNearPlaneDistance(nearPlaneDistance); - setFogShape(fogShape); + setFarPlaneDistance(fogParameters.end()); + setNearPlaneDistance(fogParameters.start()); + setFogShape(fogParameters.shape()); } /** @@ -326,10 +327,10 @@ public void setRoll(float roll) { */ public static class ComputeFov extends ViewportEvent { private final boolean usedConfiguredFov; - private double fov; + private float fov; @ApiStatus.Internal - public ComputeFov(GameRenderer renderer, Camera camera, double renderPartialTicks, double fov, boolean usedConfiguredFov) { + public ComputeFov(GameRenderer renderer, Camera camera, float renderPartialTicks, float fov, boolean usedConfiguredFov) { super(renderer, camera, renderPartialTicks); this.usedConfiguredFov = usedConfiguredFov; this.setFOV(fov); @@ -338,7 +339,7 @@ public ComputeFov(GameRenderer renderer, Camera camera, double renderPartialTick /** * {@return the raw field of view value} */ - public double getFOV() { + public float getFOV() { return fov; } @@ -347,7 +348,7 @@ public double getFOV() { * * @param fov the new FOV value */ - public void setFOV(double fov) { + public void setFOV(float fov) { this.fov = fov; } diff --git a/src/main/java/net/neoforged/neoforge/client/extensions/IBakedModelExtension.java b/src/main/java/net/neoforged/neoforge/client/extensions/IBakedModelExtension.java index 52ffd3c8..eee572c5 100644 --- a/src/main/java/net/neoforged/neoforge/client/extensions/IBakedModelExtension.java +++ b/src/main/java/net/neoforged/neoforge/client/extensions/IBakedModelExtension.java @@ -89,25 +89,25 @@ default ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, M * Gets an ordered list of {@link RenderType render types} to use when drawing this item. * All render types using the {@link com.mojang.blaze3d.vertex.DefaultVertexFormat#NEW_ENTITY} format are supported. *

- * This method will only be called on the models returned by {@link #getRenderPasses(ItemStack, boolean)}. + * This method will only be called on the models returned by {@link #getRenderPasses(ItemStack)}. *

* By default, defers query to {@link ItemBlockRenderTypes}. * - * @see #getRenderPasses(ItemStack, boolean) + * @see #getRenderPasses(ItemStack) */ - default List getRenderTypes(ItemStack itemStack, boolean fabulous) { - return List.of(RenderTypeHelper.getFallbackItemRenderType(itemStack, self(), fabulous)); + default List getRenderTypes(ItemStack itemStack) { + return List.of(RenderTypeHelper.getFallbackItemRenderType(itemStack, self())); } /** * Gets an ordered list of baked models used to render this model as an item. - * Each of those models' render types will be queried via {@link #getRenderTypes(ItemStack, boolean)}. + * Each of those models' render types will be queried via {@link #getRenderTypes(ItemStack)}. *

* By default, returns the model itself. * - * @see #getRenderTypes(ItemStack, boolean) + * @see #getRenderTypes(ItemStack) */ - default List getRenderPasses(ItemStack itemStack, boolean fabulous) { + default List getRenderPasses(ItemStack itemStack) { return List.of(self()); } } diff --git a/src/main/java/net/neoforged/neoforge/client/extensions/IDimensionSpecialEffectsExtension.java b/src/main/java/net/neoforged/neoforge/client/extensions/IDimensionSpecialEffectsExtension.java index b8253c7b..9268c200 100644 --- a/src/main/java/net/neoforged/neoforge/client/extensions/IDimensionSpecialEffectsExtension.java +++ b/src/main/java/net/neoforged/neoforge/client/extensions/IDimensionSpecialEffectsExtension.java @@ -5,13 +5,11 @@ package net.neoforged.neoforge.client.extensions; -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.DimensionSpecialEffects; import net.minecraft.client.renderer.LightTexture; import org.joml.Matrix4f; -import org.joml.Vector3f; /** * Extension interface for {@link DimensionSpecialEffects}. @@ -26,7 +24,7 @@ private DimensionSpecialEffects self() { * * @return true to prevent vanilla cloud rendering */ - default boolean renderClouds(ClientLevel level, int ticks, float partialTick, PoseStack poseStack, double camX, double camY, double camZ, Matrix4f modelViewMatrix, Matrix4f projectionMatrix) { + default boolean renderClouds(ClientLevel level, int ticks, float partialTick, double camX, double camY, double camZ, Matrix4f modelViewMatrix, Matrix4f projectionMatrix) { return false; } @@ -35,7 +33,7 @@ default boolean renderClouds(ClientLevel level, int ticks, float partialTick, Po * * @return true to prevent vanilla sky rendering */ - default boolean renderSky(ClientLevel level, int ticks, float partialTick, Matrix4f modelViewMatrix, Camera camera, Matrix4f projectionMatrix, boolean isFoggy, Runnable setupFog) { + default boolean renderSky(ClientLevel level, int ticks, float partialTick, Matrix4f modelViewMatrix, Camera camera, Matrix4f projectionMatrix, Runnable setupFog) { return false; } @@ -56,20 +54,4 @@ default boolean renderSnowAndRain(ClientLevel level, int ticks, float partialTic default boolean tickRain(ClientLevel level, int ticks, Camera camera) { return false; } - - /** - * Allows for manipulating the coloring of the lightmap texture. - * Will be called for each 16*16 combination of sky/block light values. - * - * @param level The current level (client-side). - * @param partialTicks Progress between ticks. - * @param skyDarken Current darkness of the sky (can be used to calculate sky light). - * @param blockLightRedFlicker Block light flicker factor (red color) (can be used to calculate block light). - * @param skyLight Sky light brightness (accounting for sky darkness). - * @param pixelX X-coordinate of the lightmap texture (block). - * @param pixelY Y-coordinate of the lightmap texture (sky). - * @param colors The color values that will be used: [r, g, b]. - * @see LightTexture#updateLightTexture(float) - */ - default void adjustLightmapColors(ClientLevel level, float partialTicks, float skyDarken, float blockLightRedFlicker, float skyLight, int pixelX, int pixelY, Vector3f colors) {} } diff --git a/src/main/java/net/neoforged/neoforge/client/extensions/IGuiGraphicsExtension.java b/src/main/java/net/neoforged/neoforge/client/extensions/IGuiGraphicsExtension.java index ff0d2c3c..d6b1da00 100644 --- a/src/main/java/net/neoforged/neoforge/client/extensions/IGuiGraphicsExtension.java +++ b/src/main/java/net/neoforged/neoforge/client/extensions/IGuiGraphicsExtension.java @@ -8,6 +8,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -49,6 +50,7 @@ default int drawScrollingString(Font font, Component text, int minX, int maxX, i } } + // TODO: 1.21.2: do we need to fix these or can we just remove them? /** * Draws a textured box of any size (smallest size is borderSize * 2 square) * based on a fixed size textured box with continuous borders and filler. @@ -64,9 +66,9 @@ default int drawScrollingString(Font font, Component text, int minX, int maxX, i * @param textureHeight the height of the box texture in the resource location image * @param borderSize the size of the box's borders */ - default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize) { + /*default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize) { this.blitWithBorder(texture, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize); - } + }*/ /** * Draws a textured box of any size (smallest size is borderSize * 2 square) @@ -86,7 +88,7 @@ default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v * @param leftBorder the size of the box's left border * @param rightBorder the size of the box's right border */ - default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder) { + /*default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder) { int fillerWidth = textureWidth - leftBorder - rightBorder; int fillerHeight = textureHeight - topBorder - bottomBorder; int canvasWidth = width - leftBorder - rightBorder; @@ -95,7 +97,7 @@ default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v int remainderWidth = canvasWidth % fillerWidth; int yPasses = canvasHeight / fillerHeight; int remainderHeight = canvasHeight % fillerHeight; - + // Draw Border // Top Left self().blit(texture, x, y, u, v, leftBorder, topBorder); @@ -105,18 +107,18 @@ default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v self().blit(texture, x, y + topBorder + canvasHeight, u, v + topBorder + fillerHeight, leftBorder, bottomBorder); // Bottom Right self().blit(texture, x + leftBorder + canvasWidth, y + topBorder + canvasHeight, u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder); - + for (int i = 0; i < xPasses + (remainderWidth > 0 ? 1 : 0); i++) { // Top Border self().blit(texture, x + leftBorder + (i * fillerWidth), y, u + leftBorder, v, (i == xPasses ? remainderWidth : fillerWidth), topBorder); // Bottom Border self().blit(texture, x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, u + leftBorder, v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder); - + // Throw in some filler for good measure for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++) self().blit(texture, x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight), u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth), (j == yPasses ? remainderHeight : fillerHeight)); } - + // Side Borders for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++) { // Left Border @@ -124,7 +126,7 @@ default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v // Right Border self().blit(texture, x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight), u + leftBorder + fillerWidth, v + topBorder, rightBorder, (j == yPasses ? remainderHeight : fillerHeight)); } - } + }*/ default void blitInscribed(ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight) { this.blitInscribed(texture, x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true); @@ -141,7 +143,7 @@ default void blitInscribed(ResourceLocation texture, int x, int y, int boundsWid if (centerX) x += (w - boundsWidth) / 2; } - self().blit(texture, x, y, boundsWidth, boundsHeight, 0.0f, 0.0f, rectWidth, rectHeight, rectWidth, rectHeight); + self().blit(RenderType::guiTextured, texture, x, y, boundsWidth, boundsHeight, 0, 0, rectWidth, rectHeight, rectWidth, rectHeight); } // TODO: 1.20.2: do we need to fix these or can we just remove them? diff --git a/src/main/java/net/neoforged/neoforge/client/extensions/IModelBakerExtension.java b/src/main/java/net/neoforged/neoforge/client/extensions/IModelBakerExtension.java index c509d32b..90d84c39 100644 --- a/src/main/java/net/neoforged/neoforge/client/extensions/IModelBakerExtension.java +++ b/src/main/java/net/neoforged/neoforge/client/extensions/IModelBakerExtension.java @@ -19,10 +19,8 @@ public interface IModelBakerExtension { @Nullable UnbakedModel getTopLevelModel(ModelResourceLocation location); - @Nullable BakedModel bake(ResourceLocation location, ModelState state, Function sprites); - @Nullable BakedModel bakeUncached(UnbakedModel model, ModelState state, Function sprites); Function getModelTextureGetter(); diff --git a/src/main/java/net/neoforged/neoforge/client/extensions/common/ClientExtensionsManager.java b/src/main/java/net/neoforged/neoforge/client/extensions/common/ClientExtensionsManager.java index 731f4322..7d7a22d6 100644 --- a/src/main/java/net/neoforged/neoforge/client/extensions/common/ClientExtensionsManager.java +++ b/src/main/java/net/neoforged/neoforge/client/extensions/common/ClientExtensionsManager.java @@ -9,14 +9,12 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.neoforged.fml.ModLoader; import net.neoforged.neoforge.data.loading.DatagenModLoader; import net.neoforged.neoforge.fluids.FluidType; -import net.neoforged.neoforge.registries.NeoForgeRegistries; import org.jetbrains.annotations.ApiStatus; @ApiStatus.Internal @@ -25,7 +23,6 @@ public final class ClientExtensionsManager { static final Map ITEM_EXTENSIONS = new Reference2ObjectOpenHashMap<>(); static final Map MOB_EFFECT_EXTENSIONS = new Reference2ObjectOpenHashMap<>(); static final Map FLUID_TYPE_EXTENSIONS = new Reference2ObjectOpenHashMap<>(); - private static boolean earlyInitialized = false; private static boolean initialized = false; private ClientExtensionsManager() {} @@ -51,22 +48,6 @@ static void register(E extensions, Map target, T... objects) { } } - @Deprecated(forRemoval = true, since = "1.21") - public static void earlyInit() { - // Minecraft instance isn't available in datagen, so don't initialize client extensions in datagen - if (DatagenModLoader.isRunningDataGen()) return; - - if (earlyInitialized) { - throw new IllegalStateException("Duplicate early initialization of ClientExtensionsManager"); - } - - earlyInitialized = true; - BuiltInRegistries.BLOCK.forEach(block -> block.initializeClient(ext -> register(ext, BLOCK_EXTENSIONS, block))); - BuiltInRegistries.ITEM.forEach(item -> item.initializeClient(ext -> register(ext, ITEM_EXTENSIONS, item))); - BuiltInRegistries.MOB_EFFECT.forEach(mobEffect -> mobEffect.initializeClient(ext -> register(ext, MOB_EFFECT_EXTENSIONS, mobEffect))); - NeoForgeRegistries.FLUID_TYPES.forEach(fluidType -> fluidType.initializeClient(ext -> register(ext, FLUID_TYPE_EXTENSIONS, fluidType))); - } - public static void init() { // Minecraft instance isn't available in datagen, so don't initialize client extensions in datagen if (DatagenModLoader.isRunningDataGen()) return; diff --git a/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientFluidTypeExtensions.java b/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientFluidTypeExtensions.java index 11e44b56..d9df521c 100644 --- a/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientFluidTypeExtensions.java +++ b/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientFluidTypeExtensions.java @@ -5,13 +5,13 @@ package net.neoforged.neoforge.client.extensions.common; -import com.mojang.blaze3d.shaders.FogShape; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import java.util.function.Consumer; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.FogParameters; import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.renderer.ScreenEffectRenderer; import net.minecraft.core.BlockPos; @@ -25,7 +25,7 @@ import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.FluidType; import org.jetbrains.annotations.Nullable; -import org.joml.Vector3f; +import org.joml.Vector4f; /** * {@linkplain LogicalSide#CLIENT Client-only} extensions to {@link FluidType}. @@ -167,10 +167,10 @@ default void renderOverlay(Minecraft mc, PoseStack poseStack) { * @param level the level the camera is located in * @param renderDistance the render distance of the client * @param darkenWorldAmount the amount to darken the world by - * @param fluidFogColor the current color of the fog + * @param fluidFogColor the current RGBA color of the fog * @return the color of the fog */ - default Vector3f modifyFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, Vector3f fluidFogColor) { + default Vector4f modifyFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, Vector4f fluidFogColor) { return fluidFogColor; } @@ -182,11 +182,12 @@ default Vector3f modifyFogColor(Camera camera, float partialTick, ClientLevel le * @param mode the type of fog being rendered * @param renderDistance the render distance of the client * @param partialTick the delta time of where the current frame is within a tick - * @param nearDistance the near plane of where the fog starts to render - * @param farDistance the far plane of where the fog ends rendering - * @param shape the shape of the fog being rendered + * @param fogParameters the parameters to use for rendering the fog + * @return the modified fog parameters */ - default void modifyFogRender(Camera camera, FogRenderer.FogMode mode, float renderDistance, float partialTick, float nearDistance, float farDistance, FogShape shape) {} + default FogParameters modifyFogRender(Camera camera, FogRenderer.FogMode mode, float renderDistance, float partialTick, FogParameters fogParameters) { + return fogParameters; + } /* Level-Based Accessors */ diff --git a/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java b/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java index 385d45a6..34018888 100644 --- a/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java +++ b/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientItemExtensions.java @@ -6,35 +6,34 @@ package net.neoforged.neoforge.client.extensions.common; import com.mojang.blaze3d.vertex.PoseStack; -import java.util.function.Consumer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.Model; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; +import net.minecraft.client.renderer.entity.layers.EquipmentLayerRenderer; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.tags.ItemTags; -import net.minecraft.util.FastColor; +import net.minecraft.util.ARGB; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.component.DyedItemColor; +import net.minecraft.world.item.equipment.EquipmentModel; import net.minecraft.world.level.block.state.BlockState; import net.neoforged.fml.LogicalSide; -import net.neoforged.neoforge.client.ClientHooks; import net.neoforged.neoforge.client.IArmPoseTransformer; import org.jetbrains.annotations.Nullable; /** * {@linkplain LogicalSide#CLIENT Client-only} extensions to {@link Item}. * - * @see Item#initializeClient(Consumer) + * @see RegisterClientExtensionsEvent */ public interface IClientItemExtensions { IClientItemExtensions DEFAULT = new IClientItemExtensions() {}; @@ -93,40 +92,56 @@ default boolean applyForgeHandTransform(PoseStack poseStack, LocalPlayer player, /** * Queries the humanoid armor model for this item when it's equipped. * - * @param livingEntity The entity wearing the armor - * @param itemStack The item stack - * @param equipmentSlot The slot the item is in - * @param original The original armor model. Will have attributes set. + * @param itemStack The item stack + * @param layerType The slot the item is in + * @param original The original armor model. Will have attributes set. * @return A HumanoidModel to be rendered. Relevant properties are to be copied over by the caller. - * @see #getGenericArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel) + * @see #getGenericArmorModel(ItemStack, EquipmentModel.LayerType, Model) */ - default HumanoidModel getHumanoidArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel original) { + default Model getHumanoidArmorModel(ItemStack itemStack, EquipmentModel.LayerType layerType, Model original) { return original; } /** * Queries the armor model for this item when it's equipped. Useful in place of - * {@link #getHumanoidArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)} for wrapping the original + * {@link #getHumanoidArmorModel(ItemStack, EquipmentModel.LayerType, Model)} for wrapping the original * model or returning anything non-standard. *

* If you override this method you are responsible for copying any properties you care about from the original model. * - * @param livingEntity The entity wearing the armor - * @param itemStack The item stack - * @param equipmentSlot The slot the item is in - * @param original The original armor model. Will have attributes set. + * @param itemStack The item stack + * @param layerType The slot the item is in + * @param original The original armor model. Will have attributes set. * @return A Model to be rendered. Relevant properties must be copied over manually. - * @see #getHumanoidArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel) + * @see #getHumanoidArmorModel(ItemStack, EquipmentModel.LayerType, Model) */ - default Model getGenericArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel original) { - HumanoidModel replacement = getHumanoidArmorModel(livingEntity, itemStack, equipmentSlot, original); + default Model getGenericArmorModel(ItemStack itemStack, EquipmentModel.LayerType layerType, Model original) { + Model replacement = getHumanoidArmorModel(itemStack, layerType, original); if (replacement != original) { - ClientHooks.copyModelProperties(original, replacement); + // FIXME: equipment rendering deals with a plain Model now + //ClientHooks.copyModelProperties(original, replacement); return replacement; } return original; } + /** + * Called when an armor piece is about to be rendered, allowing parts of the model to be animated or changed. + * + * @param itemStack The item stack being worn + * @param livingEntity The entity wearing the armor + * @param equipmentSlot The slot the armor stack is being worn in + * @param model The armor model being rendered + * @param limbSwing The swing position of the entity's walk animation + * @param limbSwingAmount The swing speed of the entity's walk animation + * @param partialTick The partial tick time + * @param ageInTicks The total age of the entity, with partialTick already applied + * @param netHeadYaw The yaw (Y rotation) of the entity's head + * @param headPitch The pitch (X rotation) of the entity's head + */ + // TODO 1.21.2: add back patch that calls this method from HumanoidArmorLayer + default void setupModelAnimations(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, Model model, float limbSwing, float limbSwingAmount, float partialTick, float ageInTicks, float netHeadYaw, float headPitch) {} + /** * Called when the client starts rendering the HUD, and is wearing this item in the helmet slot. *

@@ -171,7 +186,7 @@ default boolean shouldSpreadAsEntity(ItemStack stack) { } /** - * Called when armor layers are rendered by {@link net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer}. + * Called when armor layers are rendered by {@link net.minecraft.client.renderer.entity.layers.EquipmentLayerRenderer}. *

* Allows custom dye colors to be specified per-layer; default vanilla behavior allows for only a single dye color * (specified by the {@link net.minecraft.core.component.DataComponents#DYED_COLOR} data component) for all layers. @@ -180,20 +195,19 @@ default boolean shouldSpreadAsEntity(ItemStack stack) { * doesn't need to be rendered for a particular armor slot. * * @param stack the armor item stack being rendered - * @param entity the entity wearing the armor * @param layer the armor layer being rendered * @param layerIdx an index into the list of layers for the {@code ArmorMaterial} used by this item * @param fallbackColor the return value of {@link #getDefaultDyeColor(ItemStack)}, passed as a parameter for * performance * @return a custom color for the layer, in ARGB format, or 0 to skip rendering */ - default int getArmorLayerTintColor(ItemStack stack, LivingEntity entity, ArmorMaterial.Layer layer, int layerIdx, int fallbackColor) { - return layer.dyeable() ? fallbackColor : 0xFFFFFFFF; + default int getArmorLayerTintColor(ItemStack stack, EquipmentModel.Layer layer, int layerIdx, int fallbackColor) { + return EquipmentLayerRenderer.getColorForLayer(layer, fallbackColor); } /** * Called once per render pass of equipped armor items, regardless of the number of layers; the return value of this - * method is passed to {@link #getArmorLayerTintColor(ItemStack, LivingEntity, ArmorMaterial.Layer, int, int)} as + * method is passed to {@link #getArmorLayerTintColor(ItemStack, EquipmentModel.Layer, int, int)} as * the {@code fallbackColor} parameter. *

* You can override this method for your custom armor item to provide an alternative default color for the item when @@ -203,7 +217,7 @@ default int getArmorLayerTintColor(ItemStack stack, LivingEntity entity, ArmorMa * @return a default color for the layer, in ARGB format */ default int getDefaultDyeColor(ItemStack stack) { - return stack.is(ItemTags.DYEABLE) ? FastColor.ARGB32.opaque(DyedItemColor.getOrDefault(stack, DyedItemColor.LEATHER_COLOR)) : 0xFFFFFFFF; + return stack.is(ItemTags.DYEABLE) ? ARGB.opaque(DyedItemColor.getOrDefault(stack, 0)) : 0; } enum FontContext { diff --git a/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientMobEffectExtensions.java b/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientMobEffectExtensions.java index dbcde127..d8cc3913 100644 --- a/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientMobEffectExtensions.java +++ b/src/main/java/net/neoforged/neoforge/client/extensions/common/IClientMobEffectExtensions.java @@ -5,10 +5,9 @@ package net.neoforged.neoforge.client.extensions.common; -import java.util.function.Consumer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; import net.neoforged.fml.LogicalSide; @@ -16,7 +15,7 @@ /** * {@linkplain LogicalSide#CLIENT Client-only} extensions to {@link MobEffect}. * - * @see MobEffect#initializeClient(Consumer) + * @see RegisterClientExtensionsEvent */ public interface IClientMobEffectExtensions { IClientMobEffectExtensions DEFAULT = new IClientMobEffectExtensions() {}; @@ -59,7 +58,7 @@ default boolean isVisibleInGui(MobEffectInstance instance) { * @param blitOffset The blit offset * @return true to prevent default rendering, false otherwise */ - default boolean renderInventoryIcon(MobEffectInstance instance, EffectRenderingInventoryScreen screen, GuiGraphics guiGraphics, int x, int y, int blitOffset) { + default boolean renderInventoryIcon(MobEffectInstance instance, AbstractContainerScreen screen, GuiGraphics guiGraphics, int x, int y, int blitOffset) { return false; } @@ -74,7 +73,7 @@ default boolean renderInventoryIcon(MobEffectInstance instance, EffectRenderingI * @param blitOffset The blit offset * @return true to prevent default rendering, false otherwise */ - default boolean renderInventoryText(MobEffectInstance instance, EffectRenderingInventoryScreen screen, GuiGraphics guiGraphics, int x, int y, int blitOffset) { + default boolean renderInventoryText(MobEffectInstance instance, AbstractContainerScreen screen, GuiGraphics guiGraphics, int x, int y, int blitOffset) { return false; } diff --git a/src/main/java/net/neoforged/neoforge/client/gui/ScreenUtils.java b/src/main/java/net/neoforged/neoforge/client/gui/ScreenUtils.java index 9ec8fc38..456a0dd0 100644 --- a/src/main/java/net/neoforged/neoforge/client/gui/ScreenUtils.java +++ b/src/main/java/net/neoforged/neoforge/client/gui/ScreenUtils.java @@ -12,7 +12,7 @@ import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.CoreShaders; import net.minecraft.resources.ResourceLocation; import net.neoforged.neoforge.client.extensions.IGuiGraphicsExtension; import org.joml.Matrix4f; @@ -108,7 +108,7 @@ public static void blitWithBorder(GuiGraphics guiGraphics, ResourceLocation res, */ public static void blitWithBorder(GuiGraphics guiGraphics, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel) { - RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShader(CoreShaders.POSITION_TEX); RenderSystem.setShaderTexture(0, res); blitWithBorder(guiGraphics, x, y, u, v, width, height, textureWidth, textureHeight, topBorder, bottomBorder, leftBorder, rightBorder, zLevel); } @@ -213,7 +213,7 @@ public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, RenderSystem.enableDepthTest(); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - RenderSystem.setShader(GameRenderer::getPositionColorShader); + RenderSystem.setShader(CoreShaders.POSITION_COLOR); Tesselator tessellator = Tesselator.getInstance(); BufferBuilder buffer = tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); @@ -224,22 +224,4 @@ public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, BufferUploader.drawWithShader(buffer.buildOrThrow()); RenderSystem.disableBlend(); } - - public static void blitInscribed(GuiGraphics guiGraphics, ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight) { - blitInscribed(guiGraphics, texture, x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true); - } - - public static void blitInscribed(GuiGraphics guiGraphics, ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY) { - if (rectWidth * boundsHeight > rectHeight * boundsWidth) { - int h = boundsHeight; - boundsHeight = (int) (boundsWidth * ((double) rectHeight / rectWidth)); - if (centerY) y += (h - boundsHeight) / 2; - } else { - int w = boundsWidth; - boundsWidth = (int) (boundsHeight * ((double) rectWidth / rectHeight)); - if (centerX) x += (w - boundsWidth) / 2; - } - - guiGraphics.blit(texture, x, y, boundsWidth, boundsHeight, 0.0f, 0.0f, rectWidth, rectHeight, rectWidth, rectHeight); - } } diff --git a/src/main/java/net/neoforged/neoforge/client/gui/map/IMapDecorationRenderer.java b/src/main/java/net/neoforged/neoforge/client/gui/map/IMapDecorationRenderer.java index 09154bab..3e86c410 100644 --- a/src/main/java/net/neoforged/neoforge/client/gui/map/IMapDecorationRenderer.java +++ b/src/main/java/net/neoforged/neoforge/client/gui/map/IMapDecorationRenderer.java @@ -7,9 +7,9 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.state.MapRenderState; import net.minecraft.client.resources.MapDecorationTextureManager; import net.minecraft.world.level.saveddata.maps.MapDecoration; -import net.minecraft.world.level.saveddata.maps.MapItemSavedData; /** * Interface for custom {@link MapDecoration} renderers @@ -19,21 +19,21 @@ public interface IMapDecorationRenderer { * Render the given {@link MapDecoration} on the map. If this method returns true, the vanilla rendering will be * canceled. Otherwise, it will render above whatever is rendered in this method, if anything * - * @param decoration The decoration to be rendered - * @param poseStack The {@link PoseStack} to render the decoration with - * @param bufferSource The {@link MultiBufferSource} to render the decoration with - * @param mapData The data of the map being rendered - * @param decorationTextures The manager holding map decoration sprites - * @param inItemFrame Whether the map is being rendered in an item frame - * @param packedLight The packed light value - * @param index The z index of the decoration being rendered + * @param decorationRenderState The state decoration to be rendered + * @param poseStack The {@link PoseStack} to render the decoration with + * @param bufferSource The {@link MultiBufferSource} to render the decoration with + * @param mapRenderState The state of the map being rendered + * @param decorationTextures The manager holding map decoration sprites + * @param inItemFrame Whether the map is being rendered in an item frame + * @param packedLight The packed light value + * @param index The z index of the decoration being rendered * @return true to cancel vanilla rendering */ boolean render( - MapDecoration decoration, + MapRenderState.MapDecorationRenderState decorationRenderState, PoseStack poseStack, MultiBufferSource bufferSource, - MapItemSavedData mapData, + MapRenderState mapRenderState, MapDecorationTextureManager decorationTextures, boolean inItemFrame, int packedLight, diff --git a/src/main/java/net/neoforged/neoforge/client/gui/map/MapDecorationRendererManager.java b/src/main/java/net/neoforged/neoforge/client/gui/map/MapDecorationRendererManager.java index df4dafc3..6cfda70c 100644 --- a/src/main/java/net/neoforged/neoforge/client/gui/map/MapDecorationRendererManager.java +++ b/src/main/java/net/neoforged/neoforge/client/gui/map/MapDecorationRendererManager.java @@ -9,10 +9,9 @@ import java.util.IdentityHashMap; import java.util.Map; import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.state.MapRenderState; import net.minecraft.client.resources.MapDecorationTextureManager; -import net.minecraft.world.level.saveddata.maps.MapDecoration; import net.minecraft.world.level.saveddata.maps.MapDecorationType; -import net.minecraft.world.level.saveddata.maps.MapItemSavedData; import net.neoforged.fml.ModLoader; import org.jetbrains.annotations.ApiStatus; @@ -24,17 +23,17 @@ public final class MapDecorationRendererManager { private MapDecorationRendererManager() {} public static boolean render( - MapDecoration decoration, + MapRenderState.MapDecorationRenderState decorationRenderState, PoseStack poseStack, MultiBufferSource bufferSource, - MapItemSavedData mapData, + MapRenderState mapRenderState, MapDecorationTextureManager decorationTextures, boolean inItemFrame, int packedLight, int index) { - IMapDecorationRenderer decorationRenderer = RENDERERS.get(decoration.type().value()); + IMapDecorationRenderer decorationRenderer = RENDERERS.get(decorationRenderState.type.value()); if (decorationRenderer != null) { - return decorationRenderer.render(decoration, poseStack, bufferSource, mapData, decorationTextures, inItemFrame, packedLight, index); + return decorationRenderer.render(decorationRenderState, poseStack, bufferSource, mapRenderState, decorationTextures, inItemFrame, packedLight, index); } return false; } diff --git a/src/main/java/net/neoforged/neoforge/client/gui/widget/ExtendedButton.java b/src/main/java/net/neoforged/neoforge/client/gui/widget/ExtendedButton.java index cf1b0ecb..7636faf0 100644 --- a/src/main/java/net/neoforged/neoforge/client/gui/widget/ExtendedButton.java +++ b/src/main/java/net/neoforged/neoforge/client/gui/widget/ExtendedButton.java @@ -8,6 +8,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; +import net.minecraft.client.renderer.RenderType; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; @@ -41,7 +42,7 @@ public ExtendedButton(Button.Builder builder) { @Override public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { Minecraft mc = Minecraft.getInstance(); - guiGraphics.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); + guiGraphics.blitSprite(RenderType::guiTextured, SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); final FormattedText buttonText = mc.font.ellipsize(this.getMessage(), this.width - 6); // Remove 6 pixels so that the text is always contained within the button's borders guiGraphics.drawCenteredString(mc.font, Language.getInstance().getVisualOrder(buttonText), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, getFGColor()); diff --git a/src/main/java/net/neoforged/neoforge/client/gui/widget/ExtendedSlider.java b/src/main/java/net/neoforged/neoforge/client/gui/widget/ExtendedSlider.java index ec4f2e9d..787e9706 100644 --- a/src/main/java/net/neoforged/neoforge/client/gui/widget/ExtendedSlider.java +++ b/src/main/java/net/neoforged/neoforge/client/gui/widget/ExtendedSlider.java @@ -5,12 +5,13 @@ package net.neoforged.neoforge.client.gui.widget; -import com.mojang.blaze3d.systems.RenderSystem; import java.text.DecimalFormat; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractSliderButton; +import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; +import net.minecraft.util.ARGB; import net.minecraft.util.Mth; import org.lwjgl.glfw.GLFW; @@ -195,13 +196,8 @@ protected void applyValue() {} @Override public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { Minecraft minecraft = Minecraft.getInstance(); - guiGraphics.setColor(1.0F, 1.0F, 1.0F, this.alpha); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - RenderSystem.enableDepthTest(); - guiGraphics.blitSprite(this.getSprite(), this.getX(), this.getY(), this.getWidth(), this.getHeight()); - guiGraphics.blitSprite(this.getHandleSprite(), this.getX() + (int) (this.value * (double) (this.width - 8)), this.getY(), 8, this.getHeight()); - guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F); + guiGraphics.blitSprite(RenderType::guiTextured, this.getSprite(), this.getX(), this.getY(), this.getWidth(), this.getHeight(), ARGB.white(this.alpha)); + guiGraphics.blitSprite(RenderType::guiTextured, this.getHandleSprite(), this.getX() + (int) (this.value * (double) (this.width - 8)), this.getY(), 8, this.getHeight(), ARGB.white(this.alpha)); int i = this.active ? 16777215 : 10526880; this.renderScrollingString(guiGraphics, minecraft.font, 2, i | Mth.ceil(this.alpha * 255.0F) << 24); } diff --git a/src/main/java/net/neoforged/neoforge/client/gui/widget/ModListWidget.java b/src/main/java/net/neoforged/neoforge/client/gui/widget/ModListWidget.java index 2411aec9..cd6626c3 100644 --- a/src/main/java/net/neoforged/neoforge/client/gui/widget/ModListWidget.java +++ b/src/main/java/net/neoforged/neoforge/client/gui/widget/ModListWidget.java @@ -9,6 +9,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.client.renderer.RenderType; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; @@ -79,7 +80,7 @@ public void render(GuiGraphics guiGraphics, int entryIdx, int top, int left, int //TODO: Consider adding more icons for visualization RenderSystem.setShaderColor(1, 1, 1, 1); guiGraphics.pose().pushPose(); - guiGraphics.blit(VERSION_CHECK_ICONS, getX() + width - 12, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16); + guiGraphics.blit(RenderType::guiTextured, VERSION_CHECK_ICONS, getX() + width - 12, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16); guiGraphics.pose().popPose(); } } diff --git a/src/main/java/net/neoforged/neoforge/client/gui/widget/ModsButton.java b/src/main/java/net/neoforged/neoforge/client/gui/widget/ModsButton.java index c06a6635..518fe707 100644 --- a/src/main/java/net/neoforged/neoforge/client/gui/widget/ModsButton.java +++ b/src/main/java/net/neoforged/neoforge/client/gui/widget/ModsButton.java @@ -7,6 +7,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; +import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; import net.neoforged.fml.VersionChecker; import net.neoforged.fml.loading.FMLConfig; @@ -49,6 +50,7 @@ protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, flo int h = getHeight(); guiGraphics.blit( + RenderType::guiTextured, VERSION_CHECK_ICONS, x + w - (h / 2 + 4), y + (h / 2 - 4), diff --git a/src/main/java/net/neoforged/neoforge/client/gui/widget/ScrollPanel.java b/src/main/java/net/neoforged/neoforge/client/gui/widget/ScrollPanel.java index 9e12367e..e836d58b 100644 --- a/src/main/java/net/neoforged/neoforge/client/gui/widget/ScrollPanel.java +++ b/src/main/java/net/neoforged/neoforge/client/gui/widget/ScrollPanel.java @@ -20,7 +20,7 @@ import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.CoreShaders; /** * Abstract scroll panel class. @@ -250,7 +250,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia int barBgGreen = this.barBgColor >> 8 & 0xff; int barBgBlue = this.barBgColor & 0xff; - RenderSystem.setShader(GameRenderer::getPositionColorShader); + RenderSystem.setShader(CoreShaders.POSITION_COLOR); BufferBuilder worldr = tess.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); worldr.addVertex(barLeft, this.bottom, 0.0F).setColor(barBgRed, barBgGreen, barBgBlue, barBgAlpha); worldr.addVertex(barLeft + barWidth, this.bottom, 0.0F).setColor(barBgRed, barBgGreen, barBgBlue, barBgAlpha); diff --git a/src/main/java/net/neoforged/neoforge/client/gui/widget/UnicodeGlyphButton.java b/src/main/java/net/neoforged/neoforge/client/gui/widget/UnicodeGlyphButton.java index ec903080..d733fd55 100644 --- a/src/main/java/net/neoforged/neoforge/client/gui/widget/UnicodeGlyphButton.java +++ b/src/main/java/net/neoforged/neoforge/client/gui/widget/UnicodeGlyphButton.java @@ -7,6 +7,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; /** @@ -27,7 +28,7 @@ public UnicodeGlyphButton(int xPos, int yPos, int width, int height, Component d @Override public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { Minecraft mc = Minecraft.getInstance(); - guiGraphics.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); + guiGraphics.blitSprite(RenderType::guiTextured, SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); Component buttonText = this.createNarrationMessage(); int glyphWidth = (int) (mc.font.width(glyph) * glyphScale); diff --git a/src/main/java/net/neoforged/neoforge/client/loading/ClientModLoader.java b/src/main/java/net/neoforged/neoforge/client/loading/ClientModLoader.java index 2b1f3ca8..d8c4a35e 100644 --- a/src/main/java/net/neoforged/neoforge/client/loading/ClientModLoader.java +++ b/src/main/java/net/neoforged/neoforge/client/loading/ClientModLoader.java @@ -15,7 +15,6 @@ import net.minecraft.server.packs.resources.PreparableReloadListener; import net.minecraft.server.packs.resources.ReloadableResourceManager; import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.level.DataPackConfig; import net.neoforged.fml.Logging; import net.neoforged.fml.ModList; @@ -69,7 +68,7 @@ public static void begin(final Minecraft minecraft, final PackRepository default } } - private static CompletableFuture onResourceReload(final PreparableReloadListener.PreparationBarrier stage, final ResourceManager resourceManager, final ProfilerFiller prepareProfiler, final ProfilerFiller executeProfiler, final Executor asyncExecutor, final Executor syncExecutor) { + private static CompletableFuture onResourceReload(final PreparableReloadListener.PreparationBarrier stage, final ResourceManager resourceManager, final Executor asyncExecutor, final Executor syncExecutor) { return CompletableFuture.runAsync(() -> startModLoading(syncExecutor, asyncExecutor), ModWorkManager.parallelExecutor()) .thenCompose(stage::wait) .thenRunAsync(() -> finishModLoading(syncExecutor, asyncExecutor), ModWorkManager.parallelExecutor()); diff --git a/src/main/java/net/neoforged/neoforge/client/loading/NeoForgeLoadingOverlay.java b/src/main/java/net/neoforged/neoforge/client/loading/NeoForgeLoadingOverlay.java index 4b51f797..9f14b44d 100644 --- a/src/main/java/net/neoforged/neoforge/client/loading/NeoForgeLoadingOverlay.java +++ b/src/main/java/net/neoforged/neoforge/client/loading/NeoForgeLoadingOverlay.java @@ -5,6 +5,7 @@ package net.neoforged.neoforge.client.loading; +import com.mojang.blaze3d.ProjectionType; import com.mojang.blaze3d.platform.GlConst; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; @@ -14,7 +15,6 @@ import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexFormat; -import com.mojang.blaze3d.vertex.VertexSorting; import java.util.Optional; import java.util.function.Consumer; import java.util.function.Supplier; @@ -22,7 +22,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.LoadingOverlay; -import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.CoreShaders; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.ReloadInstance; import net.minecraft.util.Mth; @@ -80,9 +80,11 @@ public void render(final GuiGraphics graphics, final int mouseX, final int mouse displayWindow.render(0xff); } else { GlStateManager._clearColor(colour.redf(), colour.greenf(), colour.bluef(), 1f); - GlStateManager._clear(GlConst.GL_COLOR_BUFFER_BIT, Minecraft.ON_OSX); + GlStateManager._clear(GlConst.GL_COLOR_BUFFER_BIT); displayWindow.render(0xFF); } + // EarlyWindow will call glBindTexture with 0. Make sure the GlStateManager's cache is aware of it. + RenderSystem.bindTexture(0); RenderSystem.enableBlend(); RenderSystem.blendFunc(GlConst.GL_SRC_ALPHA, GlConst.GL_ONE_MINUS_SRC_ALPHA); var fbWidth = this.minecraft.getWindow().getWidth(); @@ -102,8 +104,8 @@ public void render(final GuiGraphics graphics, final int mouseX, final int mouse BufferBuilder bufferbuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, fade); RenderSystem.getModelViewMatrix().identity(); - RenderSystem.setProjectionMatrix(new Matrix4f().setOrtho(0.0F, fbWidth, 0.0F, fbHeight, 0.1f, -0.1f), VertexSorting.ORTHOGRAPHIC_Z); - RenderSystem.setShader(GameRenderer::getPositionColorShader); + RenderSystem.setProjectionMatrix(new Matrix4f().setOrtho(0.0F, fbWidth, 0.0F, fbHeight, 0.1f, -0.1f), ProjectionType.ORTHOGRAPHIC); + RenderSystem.setShader(CoreShaders.RENDERTYPE_GUI_OVERLAY); // This is fill in around the edges - it's empty solid colour // top box from hpos addQuad(bufferbuilder, 0, fbWidth, wtop, fbHeight, colour, fade); @@ -118,7 +120,7 @@ public void render(final GuiGraphics graphics, final int mouseX, final int mouse // This is the actual screen data from the loading screen RenderSystem.enableBlend(); RenderSystem.blendFunc(GlConst.GL_SRC_ALPHA, GlConst.GL_ONE_MINUS_SRC_ALPHA); - RenderSystem.setShader(GameRenderer::getPositionTexColorShader); + RenderSystem.setShader(CoreShaders.POSITION_TEX_COLOR); RenderSystem.setShaderTexture(0, displayWindow.getFramebufferTextureId()); bufferbuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); bufferbuilder.addVertex(wleft, wbottom, 0f).setUv(0, 0).setColor(1f, 1f, 1f, fade); diff --git a/src/main/java/net/neoforged/neoforge/client/model/BakedModelWrapper.java b/src/main/java/net/neoforged/neoforge/client/model/BakedModelWrapper.java index 0b9491dc..01417638 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/BakedModelWrapper.java +++ b/src/main/java/net/neoforged/neoforge/client/model/BakedModelWrapper.java @@ -8,8 +8,8 @@ import com.mojang.blaze3d.vertex.PoseStack; import java.util.List; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.block.model.BakedOverrides; import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; @@ -78,8 +78,8 @@ public ItemTransforms getTransforms() { } @Override - public ItemOverrides getOverrides() { - return originalModel.getOverrides(); + public BakedOverrides overrides() { + return originalModel.overrides(); } @Override @@ -108,12 +108,12 @@ public ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, Mo } @Override - public List getRenderTypes(ItemStack itemStack, boolean fabulous) { - return originalModel.getRenderTypes(itemStack, fabulous); + public List getRenderTypes(ItemStack itemStack) { + return originalModel.getRenderTypes(itemStack); } @Override - public List getRenderPasses(ItemStack itemStack, boolean fabulous) { - return originalModel.getRenderPasses(itemStack, fabulous); + public List getRenderPasses(ItemStack itemStack) { + return originalModel.getRenderPasses(itemStack); } } diff --git a/src/main/java/net/neoforged/neoforge/client/model/CompositeModel.java b/src/main/java/net/neoforged/neoforge/client/model/CompositeModel.java index 8ee0e0fd..93fde9b7 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/CompositeModel.java +++ b/src/main/java/net/neoforged/neoforge/client/model/CompositeModel.java @@ -21,19 +21,20 @@ import java.util.Set; import java.util.function.Function; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.block.model.BakedOverrides; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockModel; -import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemOverride; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ItemModel; import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.resources.ResourceLocation; import net.minecraft.util.RandomSource; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockAndTintGetter; @@ -65,7 +66,7 @@ public CompositeModel(ImmutableMap children, ImmutableList spriteGetter, ModelState modelState, ItemOverrides overrides) { + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, List overrides) { Material particleLocation = context.getMaterial("particle"); TextureAtlasSprite particle = spriteGetter.apply(particleLocation); @@ -79,7 +80,7 @@ public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Functio if (!context.isComponentVisible(name, true)) continue; var model = entry.getValue(); - bakedPartsBuilder.put(name, model.bake(baker, model, spriteGetter, modelState, true)); + bakedPartsBuilder.put(name, model.bake(baker, spriteGetter, modelState)); } var bakedParts = bakedPartsBuilder.build(); @@ -91,12 +92,16 @@ public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Functio itemPassesBuilder.add(model); } - return new Baked(context.isGui3d(), context.useBlockLight(), context.useAmbientOcclusion(), particle, context.getTransforms(), overrides, bakedParts, itemPassesBuilder.build()); + BakedModel baked = new Baked(context.isGui3d(), context.useBlockLight(), context.useAmbientOcclusion(), particle, context.getTransforms(), bakedParts, itemPassesBuilder.build()); + if (!overrides.isEmpty()) { + baked = new ItemModel.BakedModelWithOverrides(baked, new BakedOverrides(baker, overrides, spriteGetter)); + } + return baked; } @Override - public void resolveParents(Function modelGetter, IGeometryBakingContext context) { - children.values().forEach(child -> child.resolveParents(modelGetter)); + public void resolveDependencies(UnbakedModel.Resolver modelGetter, IGeometryBakingContext context) { + children.values().forEach(child -> child.resolveDependencies(modelGetter)); } @Override @@ -109,18 +114,16 @@ public static class Baked implements IDynamicBakedModel { private final boolean isGui3d; private final boolean isSideLit; private final TextureAtlasSprite particle; - private final ItemOverrides overrides; private final ItemTransforms transforms; private final ImmutableMap children; private final ImmutableList itemPasses; - public Baked(boolean isGui3d, boolean isSideLit, boolean isAmbientOcclusion, TextureAtlasSprite particle, ItemTransforms transforms, ItemOverrides overrides, ImmutableMap children, ImmutableList itemPasses) { + public Baked(boolean isGui3d, boolean isSideLit, boolean isAmbientOcclusion, TextureAtlasSprite particle, ItemTransforms transforms, ImmutableMap children, ImmutableList itemPasses) { this.children = children; this.isAmbientOcclusion = isAmbientOcclusion; this.isGui3d = isGui3d; this.isSideLit = isSideLit; this.particle = particle; - this.overrides = overrides; this.transforms = transforms; this.itemPasses = itemPasses; } @@ -169,11 +172,6 @@ public TextureAtlasSprite getParticleIcon() { return particle; } - @Override - public ItemOverrides getOverrides() { - return overrides; - } - @Override public ItemTransforms getTransforms() { return transforms; @@ -188,7 +186,7 @@ public ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, Mo } @Override - public List getRenderPasses(ItemStack itemStack, boolean fabulous) { + public List getRenderPasses(ItemStack itemStack) { return itemPasses; } @@ -197,12 +195,12 @@ public BakedModel getPart(String name) { return children.get(name); } - public static Builder builder(IGeometryBakingContext owner, TextureAtlasSprite particle, ItemOverrides overrides, ItemTransforms cameraTransforms) { - return builder(owner.useAmbientOcclusion(), owner.isGui3d(), owner.useBlockLight(), particle, overrides, cameraTransforms); + public static Builder builder(IGeometryBakingContext owner, TextureAtlasSprite particle, ItemTransforms cameraTransforms) { + return builder(owner.useAmbientOcclusion(), owner.isGui3d(), owner.useBlockLight(), particle, cameraTransforms); } - public static Builder builder(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrides overrides, ItemTransforms cameraTransforms) { - return new Builder(isAmbientOcclusion, isGui3d, isSideLit, particle, overrides, cameraTransforms); + public static Builder builder(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemTransforms cameraTransforms) { + return new Builder(isAmbientOcclusion, isGui3d, isSideLit, particle, cameraTransforms); } public static class Builder { @@ -211,17 +209,15 @@ public static class Builder { private final boolean isSideLit; private final List children = new ArrayList<>(); private final List quads = new ArrayList<>(); - private final ItemOverrides overrides; private final ItemTransforms transforms; private TextureAtlasSprite particle; private RenderTypeGroup lastRenderTypes = RenderTypeGroup.EMPTY; - private Builder(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrides overrides, ItemTransforms transforms) { + private Builder(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemTransforms transforms) { this.isAmbientOcclusion = isAmbientOcclusion; this.isGui3d = isGui3d; this.isSideLit = isSideLit; this.particle = particle; - this.overrides = overrides; this.transforms = transforms; } @@ -231,14 +227,14 @@ public void addLayer(BakedModel model) { } private void addLayer(RenderTypeGroup renderTypes, List quads) { - var modelBuilder = IModelBuilder.of(isAmbientOcclusion, isSideLit, isGui3d, transforms, overrides, particle, renderTypes); + var modelBuilder = IModelBuilder.of(isAmbientOcclusion, isSideLit, isGui3d, transforms, particle, renderTypes); quads.forEach(modelBuilder::addUnculledFace); children.add(modelBuilder.build()); } - private void flushQuads(RenderTypeGroup renderTypes) { + private void flushQuads(@Nullable RenderTypeGroup renderTypes) { if (!Objects.equals(renderTypes, lastRenderTypes)) { - if (quads.size() > 0) { + if (!quads.isEmpty()) { addLayer(lastRenderTypes, quads); quads.clear(); } @@ -264,7 +260,7 @@ public Builder addQuads(RenderTypeGroup renderTypes, Collection quads } public BakedModel build() { - if (quads.size() > 0) { + if (!quads.isEmpty()) { addLayer(lastRenderTypes, quads); } var childrenBuilder = ImmutableMap.builder(); @@ -274,7 +270,7 @@ public BakedModel build() { childrenBuilder.put("model_" + (i++), model); itemPassesBuilder.add(model); } - return new Baked(isGui3d, isSideLit, isAmbientOcclusion, particle, transforms, overrides, childrenBuilder.build(), itemPassesBuilder.build()); + return new Baked(isGui3d, isSideLit, isAmbientOcclusion, particle, transforms, childrenBuilder.build(), itemPassesBuilder.build()); } } } diff --git a/src/main/java/net/neoforged/neoforge/client/model/DynamicFluidContainerModel.java b/src/main/java/net/neoforged/neoforge/client/model/DynamicFluidContainerModel.java index 44f3e434..b15c779a 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/DynamicFluidContainerModel.java +++ b/src/main/java/net/neoforged/neoforge/client/model/DynamicFluidContainerModel.java @@ -9,15 +9,18 @@ import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.mojang.math.Transformation; +import java.util.List; import java.util.Map; import java.util.function.Function; import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.BakedOverrides; +import net.minecraft.client.renderer.block.model.ItemOverride; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BlockModelRotation; +import net.minecraft.client.resources.model.ItemModel; import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; @@ -82,7 +85,7 @@ public DynamicFluidContainerModel withFluid(Fluid newFluid) { } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides) { + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, List overrides) { Material particleLocation = context.hasMaterial("particle") ? context.getMaterial("particle") : null; Material baseLocation = context.hasMaterial("base") ? context.getMaterial("base") : null; Material fluidMaskLocation = context.hasMaterial("fluid") ? context.getMaterial("fluid") : null; @@ -107,7 +110,7 @@ public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Functio // We need to disable GUI 3D and block lighting for this to render properly var itemContext = StandaloneGeometryBakingContext.builder(context).withGui3d(false).withUseBlockLight(false).build(ResourceLocation.fromNamespaceAndPath("neoforge", "dynamic_fluid_container")); - var modelBuilder = CompositeModel.Baked.builder(itemContext, particleSprite, new ContainedFluidOverrideHandler(overrides, baker, itemContext, this), context.getTransforms()); + var modelBuilder = CompositeModel.Baked.builder(itemContext, particleSprite, context.getTransforms()); var normalRenderTypes = getLayerRenderTypes(false); @@ -147,7 +150,9 @@ public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Functio modelBuilder.setParticle(particleSprite); - return modelBuilder.build(); + BakedModel bakedModel = modelBuilder.build(); + var bakedOverrides = new ContainedFluidOverrideHandler(new BakedOverrides(baker, overrides, spriteGetter), bakedModel, baker, itemContext, this); + return new ItemModel.BakedModelWithOverrides(bakedModel, bakedOverrides); } public static final class Loader implements IGeometryLoader { @@ -162,7 +167,7 @@ public DynamicFluidContainerModel read(JsonObject jsonObject, JsonDeserializatio ResourceLocation fluidName = ResourceLocation.parse(jsonObject.get("fluid").getAsString()); - Fluid fluid = BuiltInRegistries.FLUID.get(fluidName); + Fluid fluid = BuiltInRegistries.FLUID.getValue(fluidName); boolean flip = GsonHelper.getAsBoolean(jsonObject, "flip_gas", false); boolean coverIsMask = GsonHelper.getAsBoolean(jsonObject, "cover_is_mask", true); @@ -173,24 +178,28 @@ public DynamicFluidContainerModel read(JsonObject jsonObject, JsonDeserializatio } } - private static final class ContainedFluidOverrideHandler extends ItemOverrides { + private static final class ContainedFluidOverrideHandler extends BakedOverrides { private final Map cache = Maps.newHashMap(); // contains all the baked models since they'll never change - private final ItemOverrides nested; + private final BakedOverrides nested; + private final BakedModel baseModel; private final ModelBaker baker; private final IGeometryBakingContext owner; private final DynamicFluidContainerModel parent; - private ContainedFluidOverrideHandler(ItemOverrides nested, ModelBaker baker, IGeometryBakingContext owner, DynamicFluidContainerModel parent) { + private ContainedFluidOverrideHandler(BakedOverrides nested, BakedModel baseModel, ModelBaker baker, IGeometryBakingContext owner, DynamicFluidContainerModel parent) { this.nested = nested; + this.baseModel = baseModel; this.baker = baker; this.owner = owner; this.parent = parent; } @Override - public BakedModel resolve(BakedModel originalModel, ItemStack stack, @Nullable ClientLevel level, @Nullable LivingEntity entity, int seed) { - BakedModel overridden = nested.resolve(originalModel, stack, level, entity, seed); - if (overridden != originalModel) return overridden; + @Nullable + public BakedModel findOverride(ItemStack stack, @Nullable ClientLevel level, @Nullable LivingEntity entity, int seed) { + BakedModel overridden = nested.findOverride(stack, level, entity, seed); + if (overridden != null) return overridden; + return FluidUtil.getFluidContained(stack) .map(fluidStack -> { Fluid fluid = fluidStack.getFluid(); @@ -198,7 +207,7 @@ public BakedModel resolve(BakedModel originalModel, ItemStack stack, @Nullable C if (!cache.containsKey(name)) { DynamicFluidContainerModel unbaked = this.parent.withFluid(fluid); - BakedModel bakedModel = unbaked.bake(owner, baker, Material::sprite, BlockModelRotation.X0_Y0, this); + BakedModel bakedModel = unbaked.bake(owner, baker, Material::sprite, BlockModelRotation.X0_Y0, List.of()); cache.put(name, bakedModel); return bakedModel; } @@ -206,7 +215,7 @@ public BakedModel resolve(BakedModel originalModel, ItemStack stack, @Nullable C return cache.get(name); }) // not a fluid item apparently - .orElse(originalModel); // empty bucket + .orElse(baseModel); // empty bucket } } diff --git a/src/main/java/net/neoforged/neoforge/client/model/ElementsModel.java b/src/main/java/net/neoforged/neoforge/client/model/ElementsModel.java deleted file mode 100644 index 879ef812..00000000 --- a/src/main/java/net/neoforged/neoforge/client/model/ElementsModel.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.neoforge.client.model; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Function; -import net.minecraft.client.renderer.block.model.BlockElement; -import net.minecraft.client.renderer.block.model.BlockModel; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBaker; -import net.minecraft.client.resources.model.ModelState; -import net.minecraft.core.Direction; -import net.minecraft.util.GsonHelper; -import net.neoforged.neoforge.client.model.geometry.IGeometryBakingContext; -import net.neoforged.neoforge.client.model.geometry.IGeometryLoader; -import net.neoforged.neoforge.client.model.geometry.SimpleUnbakedGeometry; -import net.neoforged.neoforge.client.model.geometry.UnbakedGeometryHelper; - -/** - * A model composed of vanilla {@linkplain BlockElement block elements}. - */ -public class ElementsModel extends SimpleUnbakedGeometry { - private final List elements; - - public ElementsModel(List elements) { - this.elements = elements; - } - - @Override - protected void addQuads(IGeometryBakingContext context, IModelBuilder modelBuilder, ModelBaker baker, Function spriteGetter, ModelState modelState) { - // If there is a root transform, undo the ModelState transform, apply it, then re-apply the ModelState transform. - // This is necessary because of things like UV locking, which should only respond to the ModelState, and as such - // that is the only transform that should be applied during face bake. - var postTransform = QuadTransformers.empty(); - var rootTransform = context.getRootTransform(); - if (!rootTransform.isIdentity()) - postTransform = UnbakedGeometryHelper.applyRootTransform(modelState, rootTransform); - - for (BlockElement element : elements) { - for (Direction direction : element.faces.keySet()) { - var face = element.faces.get(direction); - var sprite = spriteGetter.apply(context.getMaterial(face.texture())); - var quad = BlockModel.bakeFace(element, face, sprite, direction, modelState); - postTransform.processInPlace(quad); - - if (face.cullForDirection() == null) - modelBuilder.addUnculledFace(quad); - else - modelBuilder.addCulledFace(modelState.getRotation().rotateTransform(face.cullForDirection()), quad); - } - } - } - - public static final class Loader implements IGeometryLoader { - public static final Loader INSTANCE = new Loader(); - - private Loader() {} - - @Override - public ElementsModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) throws JsonParseException { - if (!jsonObject.has("elements")) - throw new JsonParseException("An element model must have an \"elements\" member."); - - List elements = new ArrayList<>(); - for (JsonElement element : GsonHelper.getAsJsonArray(jsonObject, "elements")) { - elements.add(deserializationContext.deserialize(element, BlockElement.class)); - } - - return new ElementsModel(elements); - } - } -} diff --git a/src/main/java/net/neoforged/neoforge/client/model/EmptyModel.java b/src/main/java/net/neoforged/neoforge/client/model/EmptyModel.java index fb598d9c..f3e1084e 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/EmptyModel.java +++ b/src/main/java/net/neoforged/neoforge/client/model/EmptyModel.java @@ -10,7 +10,7 @@ import java.util.Map; import java.util.function.Function; import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemOverride; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlas; @@ -46,7 +46,7 @@ protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuil } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides) { + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, List overrides) { return BAKED; } @@ -63,7 +63,7 @@ private static Map> makeEmptyCulledFaces() { } public Baked() { - super(List.of(), makeEmptyCulledFaces(), false, false, false, UnitTextureAtlasSprite.INSTANCE, ItemTransforms.NO_TRANSFORMS, ItemOverrides.EMPTY, RenderTypeGroup.EMPTY); + super(List.of(), makeEmptyCulledFaces(), false, false, false, UnitTextureAtlasSprite.INSTANCE, ItemTransforms.NO_TRANSFORMS, RenderTypeGroup.EMPTY); } @Override diff --git a/src/main/java/net/neoforged/neoforge/client/model/IModelBuilder.java b/src/main/java/net/neoforged/neoforge/client/model/IModelBuilder.java index 9713bebe..51111b4d 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/IModelBuilder.java +++ b/src/main/java/net/neoforged/neoforge/client/model/IModelBuilder.java @@ -7,7 +7,6 @@ import java.util.List; import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; @@ -18,7 +17,7 @@ /** * Base interface for any object that collects culled and unculled faces and bakes them into a model. *

- * Provides a generic base implementation via {@link #of(boolean, boolean, boolean, ItemTransforms, ItemOverrides, TextureAtlasSprite, RenderTypeGroup)} + * Provides a generic base implementation via {@link #of(boolean, boolean, boolean, ItemTransforms, TextureAtlasSprite, RenderTypeGroup)} * and a quad-collecting alternative via {@link #collecting(List)}. */ public interface IModelBuilder> { @@ -26,9 +25,9 @@ public interface IModelBuilder> { * Creates a new model builder that uses the provided attributes in the final baked model. */ static IModelBuilder of(boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d, - ItemTransforms transforms, ItemOverrides overrides, TextureAtlasSprite particle, + ItemTransforms transforms, TextureAtlasSprite particle, RenderTypeGroup renderTypes) { - return new Simple(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, overrides, particle, renderTypes); + return new Simple(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, particle, renderTypes); } /** @@ -50,9 +49,9 @@ class Simple implements IModelBuilder { private final RenderTypeGroup renderTypes; private Simple(boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d, - ItemTransforms transforms, ItemOverrides overrides, TextureAtlasSprite particle, + ItemTransforms transforms, TextureAtlasSprite particle, RenderTypeGroup renderTypes) { - this.builder = new SimpleBakedModel.Builder(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, overrides).particle(particle); + this.builder = new SimpleBakedModel.Builder(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms).particle(particle); this.renderTypes = renderTypes; } diff --git a/src/main/java/net/neoforged/neoforge/client/model/IQuadTransformer.java b/src/main/java/net/neoforged/neoforge/client/model/IQuadTransformer.java index 9ee0b0a7..eaa5b26b 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/IQuadTransformer.java +++ b/src/main/java/net/neoforged/neoforge/client/model/IQuadTransformer.java @@ -51,7 +51,7 @@ default IQuadTransformer andThen(IQuadTransformer other) { private static BakedQuad copy(BakedQuad quad) { var vertices = quad.getVertices(); - return new BakedQuad(Arrays.copyOf(vertices, vertices.length), quad.getTintIndex(), quad.getDirection(), quad.getSprite(), quad.isShade(), quad.hasAmbientOcclusion()); + return new BakedQuad(Arrays.copyOf(vertices, vertices.length), quad.getTintIndex(), quad.getDirection(), quad.getSprite(), quad.isShade(), quad.getLightEmission(), quad.hasAmbientOcclusion()); } private static int findOffset(VertexFormatElement element) { diff --git a/src/main/java/net/neoforged/neoforge/client/model/ItemLayerModel.java b/src/main/java/net/neoforged/neoforge/client/model/ItemLayerModel.java index f5fa3865..005c98f6 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/ItemLayerModel.java +++ b/src/main/java/net/neoforged/neoforge/client/model/ItemLayerModel.java @@ -13,13 +13,16 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import java.util.List; import java.util.Map; import java.util.function.Function; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.block.model.BakedOverrides; import net.minecraft.client.renderer.block.model.ItemModelGenerator; -import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemOverride; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ItemModel; import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; @@ -51,7 +54,7 @@ private ItemLayerModel(@Nullable ImmutableList textures, Int2ObjectMap } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides) { + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, List overrides) { if (textures == null) { ImmutableList.Builder builder = ImmutableList.builder(); for (int i = 0; context.hasMaterial("layer" + i); i++) { @@ -67,7 +70,7 @@ public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Functio modelState = UnbakedGeometryHelper.composeRootTransformIntoModelState(modelState, rootTransform); var normalRenderTypes = new RenderTypeGroup(RenderType.translucent(), NeoForgeRenderTypes.ITEM_UNSORTED_TRANSLUCENT.get()); - CompositeModel.Baked.Builder builder = CompositeModel.Baked.builder(context, particle, overrides, context.getTransforms()); + CompositeModel.Baked.Builder builder = CompositeModel.Baked.builder(context, particle, context.getTransforms()); for (int i = 0; i < textures.size(); i++) { TextureAtlasSprite sprite = spriteGetter.apply(textures.get(i)); var unbaked = UnbakedGeometryHelper.createUnbakedItemElements(i, sprite, this.layerData.get(i)); @@ -77,7 +80,11 @@ public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Functio builder.addQuads(renderTypes != null ? renderTypes : normalRenderTypes, quads); } - return builder.build(); + BakedModel baked = builder.build(); + if (!overrides.isEmpty()) { + baked = new ItemModel.BakedModelWithOverrides(baked, new BakedOverrides(baker, overrides, spriteGetter)); + } + return baked; } public static final class Loader implements IGeometryLoader { @@ -97,7 +104,6 @@ public ItemLayerModel read(JsonObject jsonObject, JsonDeserializationContext des } var emissiveLayers = new Int2ObjectArrayMap(); - if (jsonObject.has("forge_data")) throw new JsonParseException("forge_data should be replaced by neoforge_data"); // TODO 1.22: Remove if (jsonObject.has("neoforge_data")) { JsonObject forgeData = jsonObject.get("neoforge_data").getAsJsonObject(); readLayerData(forgeData, "layers", renderTypeNames, emissiveLayers, false); diff --git a/src/main/java/net/neoforged/neoforge/client/model/RegistryAwareItemModelShaper.java b/src/main/java/net/neoforged/neoforge/client/model/RegistryAwareItemModelShaper.java deleted file mode 100644 index 33b033f8..00000000 --- a/src/main/java/net/neoforged/neoforge/client/model/RegistryAwareItemModelShaper.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.neoforge.client.model; - -import com.google.common.collect.Maps; -import java.util.Map; -import net.minecraft.client.renderer.ItemModelShaper; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelManager; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - -/** - * Wrapper around {@link ItemModelShaper} that cleans up the internal maps to respect ID remapping. - */ -@ApiStatus.Internal -public class RegistryAwareItemModelShaper extends ItemModelShaper { - private final Map locations = Maps.newIdentityHashMap(); - private final Map models = Maps.newIdentityHashMap(); - - public RegistryAwareItemModelShaper(ModelManager manager) { - super(manager); - } - - @Override - @Nullable - public BakedModel getItemModel(Item item) { - return models.get(item); - } - - @Override - public void register(Item item, ModelResourceLocation location) { - locations.put(item, location); - models.put(item, getModelManager().getModel(location)); - } - - @Override - public void rebuildCache() { - final ModelManager manager = this.getModelManager(); - for (var e : locations.entrySet()) { - models.put(e.getKey(), manager.getModel(e.getValue())); - } - } - - public ModelResourceLocation getLocation(ItemStack stack) { - ModelResourceLocation location = locations.get(stack.getItem()); - return location == null ? ModelBakery.MISSING_MODEL_VARIANT : location; - } -} diff --git a/src/main/java/net/neoforged/neoforge/client/model/SeparateTransformsModel.java b/src/main/java/net/neoforged/neoforge/client/model/SeparateTransformsModel.java index 4bb79b4e..03e4d72b 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/SeparateTransformsModel.java +++ b/src/main/java/net/neoforged/neoforge/client/model/SeparateTransformsModel.java @@ -15,18 +15,19 @@ import java.util.Map; import java.util.function.Function; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.block.model.BakedOverrides; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockModel; -import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemOverride; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ItemModel; import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.core.Direction; -import net.minecraft.resources.ResourceLocation; import net.minecraft.util.GsonHelper; import net.minecraft.util.RandomSource; import net.minecraft.world.item.ItemDisplayContext; @@ -51,20 +52,22 @@ public SeparateTransformsModel(BlockModel baseModel, ImmutableMap spriteGetter, ModelState modelState, ItemOverrides overrides) { - return new Baked( + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, List overrides) { + BakedModel baked = new Baked( context.useAmbientOcclusion(), context.isGui3d(), context.useBlockLight(), - spriteGetter.apply(context.getMaterial("particle")), overrides, - baseModel.bake(baker, baseModel, spriteGetter, modelState, context.useBlockLight()), - ImmutableMap.copyOf(Maps.transformValues(perspectives, value -> { - return value.bake(baker, value, spriteGetter, modelState, context.useBlockLight()); - }))); + spriteGetter.apply(context.getMaterial("particle")), + baseModel.bake(baker, spriteGetter, modelState), + ImmutableMap.copyOf(Maps.transformValues(perspectives, value -> value.bake(baker, spriteGetter, modelState)))); + if (!overrides.isEmpty()) { + baked = new ItemModel.BakedModelWithOverrides(baked, new BakedOverrides(baker, overrides, spriteGetter)); + } + return baked; } @Override - public void resolveParents(Function modelGetter, IGeometryBakingContext context) { - baseModel.resolveParents(modelGetter); - perspectives.values().forEach(model -> model.resolveParents(modelGetter)); + public void resolveDependencies(UnbakedModel.Resolver modelGetter, IGeometryBakingContext context) { + baseModel.resolveDependencies(modelGetter); + perspectives.values().forEach(model -> model.resolveDependencies(modelGetter)); } public static class Baked implements IDynamicBakedModel { @@ -72,16 +75,14 @@ public static class Baked implements IDynamicBakedModel { private final boolean isGui3d; private final boolean isSideLit; private final TextureAtlasSprite particle; - private final ItemOverrides overrides; private final BakedModel baseModel; private final ImmutableMap perspectives; - public Baked(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrides overrides, BakedModel baseModel, ImmutableMap perspectives) { + public Baked(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, BakedModel baseModel, ImmutableMap perspectives) { this.isAmbientOcclusion = isAmbientOcclusion; this.isGui3d = isGui3d; this.isSideLit = isSideLit; this.particle = particle; - this.overrides = overrides; this.baseModel = baseModel; this.perspectives = perspectives; } @@ -116,11 +117,6 @@ public TextureAtlasSprite getParticleIcon() { return particle; } - @Override - public ItemOverrides getOverrides() { - return overrides; - } - @Override public ItemTransforms getTransforms() { return ItemTransforms.NO_TRANSFORMS; diff --git a/src/main/java/net/neoforged/neoforge/client/model/data/ModelDataManager.java b/src/main/java/net/neoforged/neoforge/client/model/data/ModelDataManager.java index 65afdc76..69e03a43 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/data/ModelDataManager.java +++ b/src/main/java/net/neoforged/neoforge/client/model/data/ModelDataManager.java @@ -163,8 +163,8 @@ public static void onChunkUnload(ChunkEvent.Unload event) { var modelDataManager = level.getModelDataManager(); if (modelDataManager != null) { ChunkPos chunk = event.getChunk().getPos(); - int maxSection = level.getMaxSection(); - for (int y = level.getMinSection(); y < maxSection; y++) { + int maxSection = level.getMaxSectionY(); + for (int y = level.getMinSectionY(); y < maxSection; y++) { long section = SectionPos.asLong(chunk.x, y, chunk.z); modelDataManager.needModelDataRefresh.remove(section); modelDataManager.modelDataCache.remove(section); diff --git a/src/main/java/net/neoforged/neoforge/client/model/data/MultipartModelData.java b/src/main/java/net/neoforged/neoforge/client/model/data/MultipartModelData.java index a7320ca4..d0e69f9a 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/data/MultipartModelData.java +++ b/src/main/java/net/neoforged/neoforge/client/model/data/MultipartModelData.java @@ -9,12 +9,11 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import java.util.function.Predicate; import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.MultiPartBakedModel; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; -import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.ApiStatus; @ApiStatus.Internal @@ -36,13 +35,13 @@ public static ModelData resolve(ModelData modelData, BakedModel model) { return partData != null ? partData : modelData; } - public static ModelData create(List, BakedModel>> selectors, BitSet bitset, BlockAndTintGetter level, BlockPos pos, BlockState state, ModelData tileModelData) { + public static ModelData create(List selectors, BitSet bitset, BlockAndTintGetter level, BlockPos pos, BlockState state, ModelData tileModelData) { // Don't allocate memory if no submodel changes the model data Map dataMap = null; for (int i = 0; i < bitset.length(); ++i) { if (bitset.get(i)) { - var model = selectors.get(i).getRight(); + var model = selectors.get(i).model(); var data = model.getModelData(level, pos, state, tileModelData); if (data != tileModelData) { diff --git a/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelBuilder.java b/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelBuilder.java index 2f740123..eaadbae0 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelBuilder.java +++ b/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelBuilder.java @@ -14,8 +14,8 @@ import java.util.Map; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.armortrim.TrimMaterial; -import net.minecraft.world.item.armortrim.TrimMaterials; +import net.minecraft.world.item.equipment.trim.TrimMaterial; +import net.minecraft.world.item.equipment.trim.TrimMaterials; import net.neoforged.neoforge.common.data.ExistingFileHelper; /** diff --git a/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelProvider.java b/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelProvider.java index f4af7fde..046ef315 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelProvider.java +++ b/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelProvider.java @@ -10,6 +10,7 @@ import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; import net.neoforged.neoforge.common.data.ExistingFileHelper; /** @@ -31,6 +32,33 @@ public ItemModelBuilder basicItem(ResourceLocation item) { .texture("layer0", ResourceLocation.fromNamespaceAndPath(item.getNamespace(), "item/" + item.getPath())); } + public ItemModelBuilder handheldItem(Item item) { + return handheldItem(Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(item))); + } + + public ItemModelBuilder handheldItem(ResourceLocation item) { + return getBuilder(item.toString()) + .parent(new ModelFile.UncheckedModelFile("item/handheld")) + .texture("layer0", ResourceLocation.fromNamespaceAndPath(item.getNamespace(), "item/" + item.getPath())); + } + + public ItemModelBuilder spawnEggItem(Item item) { + return spawnEggItem(Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(item))); + } + + public ItemModelBuilder spawnEggItem(ResourceLocation item) { + return getBuilder(item.toString()) + .parent(new ModelFile.UncheckedModelFile("item/template_spawn_egg")); + } + + public ItemModelBuilder simpleBlockItem(Block block) { + return simpleBlockItem(Objects.requireNonNull(BuiltInRegistries.BLOCK.getKey(block))); + } + + public ItemModelBuilder simpleBlockItem(ResourceLocation block) { + return withExistingParent(block.toString(), ResourceLocation.fromNamespaceAndPath(block.getNamespace(), "block/" + block.getPath())); + } + @Override public String getName() { return "Item Models: " + modid; diff --git a/src/main/java/net/neoforged/neoforge/client/model/generators/ModelBuilder.java b/src/main/java/net/neoforged/neoforge/client/model/generators/ModelBuilder.java index c96419f8..9afe777b 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/generators/ModelBuilder.java +++ b/src/main/java/net/neoforged/neoforge/client/model/generators/ModelBuilder.java @@ -395,6 +395,7 @@ public class ElementBuilder { private final Map faces = new LinkedHashMap<>(); private RotationBuilder rotation; private boolean shade = true; + private int lightEmission = 0; private int color = 0xFFFFFFFF; private int blockLight = 0, skyLight = 0; private boolean hasAmbientOcclusion = true; @@ -558,6 +559,19 @@ public ElementBuilder emissivity(int blockLight, int skyLight) { return this; } + /** + * Set the light emission of the element (0-15) + *

+ * If block and sky light values should be different, use {@link #emissivity(int, int)} instead + * + * @param lightEmission the light value + * @return this builder + */ + public ElementBuilder lightEmission(int lightEmission) { + this.lightEmission = lightEmission; + return this; + } + /** * Sets the color of the element. * @@ -589,7 +603,7 @@ BlockElement build() { .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().build(), (k1, k2) -> { throw new IllegalArgumentException(); }, LinkedHashMap::new)); - return new BlockElement(from, to, faces, rotation == null ? null : rotation.build(), shade, new ExtraFaceData(this.color, this.blockLight, this.skyLight, this.hasAmbientOcclusion)); + return new BlockElement(from, to, faces, rotation == null ? null : rotation.build(), shade, lightEmission, new ExtraFaceData(this.color, this.blockLight, this.skyLight, this.hasAmbientOcclusion)); } public T end() { diff --git a/src/main/java/net/neoforged/neoforge/client/model/geometry/BlockGeometryBakingContext.java b/src/main/java/net/neoforged/neoforge/client/model/geometry/BlockGeometryBakingContext.java index a60eb84e..02c53783 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/geometry/BlockGeometryBakingContext.java +++ b/src/main/java/net/neoforged/neoforge/client/model/geometry/BlockGeometryBakingContext.java @@ -7,10 +7,11 @@ import com.mojang.math.Transformation; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.function.Function; import net.minecraft.client.renderer.block.model.BlockModel; -import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemOverride; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; @@ -130,7 +131,7 @@ public void copyFrom(BlockGeometryBakingContext other) { this.gui3d = other.gui3d; } - public BakedModel bake(ModelBaker baker, Function bakedTextureGetter, ModelState modelTransform, ItemOverrides overrides) { + public BakedModel bake(ModelBaker baker, Function bakedTextureGetter, ModelState modelTransform, List overrides) { IUnbakedGeometry geometry = getCustomGeometry(); if (geometry == null) throw new IllegalStateException("Can not use custom baking without custom geometry"); diff --git a/src/main/java/net/neoforged/neoforge/client/model/geometry/IUnbakedGeometry.java b/src/main/java/net/neoforged/neoforge/client/model/geometry/IUnbakedGeometry.java index 2eb62ffe..79be568a 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/geometry/IUnbakedGeometry.java +++ b/src/main/java/net/neoforged/neoforge/client/model/geometry/IUnbakedGeometry.java @@ -5,17 +5,17 @@ package net.neoforged.neoforge.client.model.geometry; +import java.util.List; import java.util.Set; import java.util.function.Function; import net.minecraft.client.renderer.block.model.BlockModel; -import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemOverride; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.UnbakedModel; -import net.minecraft.resources.ResourceLocation; /** * General interface for any model that can be baked, superset of vanilla {@link UnbakedModel}. @@ -26,14 +26,14 @@ * @see IGeometryBakingContext */ public interface IUnbakedGeometry> { - BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides); + BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, List overrides); /** * Resolve parents of nested {@link BlockModel}s which are later used in - * {@link IUnbakedGeometry#bake(IGeometryBakingContext, ModelBaker, Function, ModelState, ItemOverrides)} - * via {@link BlockModel#resolveParents(Function)} + * {@link IUnbakedGeometry#bake(IGeometryBakingContext, ModelBaker, Function, ModelState, List)} + * via {@link BlockModel#resolveDependencies(UnbakedModel.Resolver)} */ - default void resolveParents(Function modelGetter, IGeometryBakingContext context) {} + default void resolveDependencies(UnbakedModel.Resolver modelGetter, IGeometryBakingContext context) {} /** * {@return a set of all the components whose visibility may be configured via {@link IGeometryBakingContext}} diff --git a/src/main/java/net/neoforged/neoforge/client/model/geometry/SimpleUnbakedGeometry.java b/src/main/java/net/neoforged/neoforge/client/model/geometry/SimpleUnbakedGeometry.java index a07af2af..1c8ea096 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/geometry/SimpleUnbakedGeometry.java +++ b/src/main/java/net/neoforged/neoforge/client/model/geometry/SimpleUnbakedGeometry.java @@ -5,9 +5,10 @@ package net.neoforged.neoforge.client.model.geometry; +import java.util.List; import java.util.function.Function; import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.ItemOverride; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.Material; @@ -22,13 +23,13 @@ */ public abstract class SimpleUnbakedGeometry> implements IUnbakedGeometry { @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, ItemOverrides overrides) { + public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function spriteGetter, ModelState modelState, List overrides) { TextureAtlasSprite particle = spriteGetter.apply(context.getMaterial("particle")); var renderTypeHint = context.getRenderTypeHint(); var renderTypes = renderTypeHint != null ? context.getRenderType(renderTypeHint) : RenderTypeGroup.EMPTY; IModelBuilder builder = IModelBuilder.of(context.useAmbientOcclusion(), context.useBlockLight(), context.isGui3d(), - context.getTransforms(), overrides, particle, renderTypes); + context.getTransforms(), particle, renderTypes); addQuads(context, builder, baker, spriteGetter, modelState); diff --git a/src/main/java/net/neoforged/neoforge/client/model/geometry/UnbakedGeometryHelper.java b/src/main/java/net/neoforged/neoforge/client/model/geometry/UnbakedGeometryHelper.java index 04e74f51..e790cef4 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/geometry/UnbakedGeometryHelper.java +++ b/src/main/java/net/neoforged/neoforge/client/model/geometry/UnbakedGeometryHelper.java @@ -25,22 +25,14 @@ import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.BuiltInModel; import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBaker; -import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelState; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; import net.neoforged.neoforge.client.ClientHooks; -import net.neoforged.neoforge.client.model.ElementsModel; import net.neoforged.neoforge.client.model.ExtraFaceData; import net.neoforged.neoforge.client.model.IModelBuilder; -import net.neoforged.neoforge.client.model.IQuadTransformer; -import net.neoforged.neoforge.client.model.QuadTransformers; import net.neoforged.neoforge.client.model.SimpleModelState; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import org.joml.Vector3f; @@ -90,28 +82,6 @@ public static Material resolveDirtyMaterial(@Nullable String tex, IGeometryBakin return new Material(TextureAtlas.LOCATION_BLOCKS, ResourceLocation.parse(tex)); } - /** - * Helper for baking {@link BlockModel} instances. Handles baking custom geometries and deferring item model baking. - */ - @ApiStatus.Internal - public static BakedModel bake(BlockModel blockModel, ModelBaker modelBaker, BlockModel owner, Function spriteGetter, ModelState modelState, boolean guiLight3d) { - IUnbakedGeometry customModel = blockModel.customData.getCustomGeometry(); - if (customModel != null) - return customModel.bake(blockModel.customData, modelBaker, spriteGetter, modelState, blockModel.getOverrides(modelBaker, owner, spriteGetter)); - - // Handle vanilla item models here, since vanilla has a shortcut for them - if (blockModel.getRootModel() == ModelBakery.GENERATION_MARKER) - return ITEM_MODEL_GENERATOR.generateBlockModel(spriteGetter, blockModel).bakeVanilla(modelBaker, blockModel, spriteGetter, modelState, guiLight3d); - - if (blockModel.getRootModel() == ModelBakery.BLOCK_ENTITY_MARKER) { - var particleSprite = spriteGetter.apply(blockModel.getMaterial("particle")); - return new BuiltInModel(blockModel.getTransforms(), blockModel.getOverrides(modelBaker, owner, spriteGetter), particleSprite, blockModel.getGuiLight().lightLikeBlock()); - } - - var elementsModel = new ElementsModel(blockModel.getElements()); - return elementsModel.bake(blockModel.customData, modelBaker, spriteGetter, modelState, blockModel.getOverrides(modelBaker, owner, spriteGetter)); - } - /** * @see #createUnbakedItemElements(int, TextureAtlasSprite, ExtraFaceData) */ @@ -198,7 +168,8 @@ public static List createUnbakedItemMaskElements(int layerIndex, T map.put(direction, new BlockElementFace(null, layerIndex, "layer" + layerIndex, new BlockFaceUV(null, 0))); }), null, - true)); + true, + 0)); // Reset xStart xStart = -1; @@ -215,7 +186,7 @@ public static void bakeElements(IModelBuilder builder, List ele for (BlockElement element : elements) { element.faces.forEach((side, face) -> { var sprite = spriteGetter.apply(new Material(TextureAtlas.LOCATION_BLOCKS, ResourceLocation.parse(face.texture()))); - var quad = bakeElementFace(element, face, sprite, side, modelState); + BakedQuad quad = BlockModel.bakeFace(element, face, sprite, side, modelState); if (face.cullForDirection() == null) builder.addUnculledFace(quad); else @@ -235,29 +206,6 @@ public static List bakeElements(List elements, Function return list; } - /** - * Turns a single {@link BlockElementFace} into a {@link BakedQuad}. - */ - public static BakedQuad bakeElementFace(BlockElement element, BlockElementFace face, TextureAtlasSprite sprite, Direction direction, ModelState state) { - return FACE_BAKERY.bakeQuad(element.from, element.to, face, sprite, direction, state, element.rotation, element.shade); - } - - /** - * Create an {@link IQuadTransformer} to apply a {@link Transformation} that undoes the {@link ModelState} - * transform (blockstate transform), applies the given root transform and then re-applies the - * blockstate transform. - * - * @return an {@code IQuadTransformer} that applies the root transform to a baked quad that already has the - * transformation of the given {@code ModelState} applied to it - */ - public static IQuadTransformer applyRootTransform(ModelState modelState, Transformation rootTransform) { - // Move the origin of the ModelState transform and its inverse from the negative corner to the block center - // to replicate the way the ModelState transform is applied in the FaceBakery by moving the vertices such that - // the negative corner acts as the block center - Transformation transform = modelState.getRotation().applyOrigin(new Vector3f(.5F, .5F, .5F)); - return QuadTransformers.applying(transform.compose(rootTransform).compose(transform.inverse())); - } - /** * {@return a {@link ModelState} that combines the existing model state and the {@linkplain Transformation root transform}} */ diff --git a/src/main/java/net/neoforged/neoforge/client/model/lighting/LightPipelineAwareModelBlockRenderer.java b/src/main/java/net/neoforged/neoforge/client/model/lighting/LightPipelineAwareModelBlockRenderer.java index a17fbaf9..bb5316d8 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/lighting/LightPipelineAwareModelBlockRenderer.java +++ b/src/main/java/net/neoforged/neoforge/client/model/lighting/LightPipelineAwareModelBlockRenderer.java @@ -83,7 +83,7 @@ public static boolean render(VertexConsumer vertexConsumer, QuadLighter lighter, } for (Direction side : SIDES) { - if (checkSides && !Block.shouldRenderFace(state, level, pos, side, pos.relative(side))) { + if (checkSides && !Block.shouldRenderFace(level, pos, state, level.getBlockState(pos.relative(side)), side)) { continue; } rand.setSeed(seed); diff --git a/src/main/java/net/neoforged/neoforge/client/model/lighting/SmoothQuadLighter.java b/src/main/java/net/neoforged/neoforge/client/model/lighting/SmoothQuadLighter.java index 57c3ff0e..f9c5d765 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/lighting/SmoothQuadLighter.java +++ b/src/main/java/net/neoforged/neoforge/client/model/lighting/SmoothQuadLighter.java @@ -43,7 +43,7 @@ protected void computeLightingAt(BlockAndTintGetter level, BlockPos origin, Bloc for (int z = 0; z <= 2; z++) { pos.setWithOffset(origin, x - 1, y - 1, z - 1); BlockState neighborState = level.getBlockState(pos); - t[x][y][z] = neighborState.getLightBlock(level, pos) < 15; + t[x][y][z] = neighborState.getLightBlock() < 15; int brightness = LevelRenderer.getLightColor(level, neighborState, pos); s[x][y][z] = LightTexture.sky(brightness); b[x][y][z] = LightTexture.block(brightness); @@ -58,7 +58,7 @@ protected void computeLightingAt(BlockAndTintGetter level, BlockPos origin, Bloc BlockState thisStateShape = state.canOcclude() && state.useShapeForLightOcclusion() ? state : Blocks.AIR.defaultBlockState(); BlockState otherStateShape = neighborState.canOcclude() && neighborState.useShapeForLightOcclusion() ? neighborState : Blocks.AIR.defaultBlockState(); - if (neighborState.getLightBlock(level, pos) == 15 || Shapes.faceShapeOccludes(thisStateShape.getFaceOcclusionShape(level, origin, side), otherStateShape.getFaceOcclusionShape(level, pos, side.getOpposite()))) { + if (neighborState.getLightBlock() == 15 || Shapes.faceShapeOccludes(thisStateShape.getFaceOcclusionShape(side), otherStateShape.getFaceOcclusionShape(side.getOpposite()))) { int x = side.getStepX() + 1; int y = side.getStepY() + 1; int z = side.getStepZ() + 1; diff --git a/src/main/java/net/neoforged/neoforge/client/model/obj/ObjModel.java b/src/main/java/net/neoforged/neoforge/client/model/obj/ObjModel.java index 83f3496e..25404e54 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/obj/ObjModel.java +++ b/src/main/java/net/neoforged/neoforge/client/model/obj/ObjModel.java @@ -377,7 +377,7 @@ private Pair makeQuad(int[][] indices, int tintIndex, Vect quadBaker.setLight(uv2); quadBaker.setNormal(normal.x(), normal.y(), normal.z()); if (i == 0) { - quadBaker.setDirection(Direction.getNearest(normal.x(), normal.y(), normal.z())); + quadBaker.setDirection(Direction.getApproximateNearest(normal.x(), normal.y(), normal.z())); } pos[i] = position; norm[i] = normal; diff --git a/src/main/java/net/neoforged/neoforge/client/model/pipeline/QuadBakingVertexConsumer.java b/src/main/java/net/neoforged/neoforge/client/model/pipeline/QuadBakingVertexConsumer.java index 72509ebf..dd73612d 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/pipeline/QuadBakingVertexConsumer.java +++ b/src/main/java/net/neoforged/neoforge/client/model/pipeline/QuadBakingVertexConsumer.java @@ -41,6 +41,7 @@ public class QuadBakingVertexConsumer implements VertexConsumer { private Direction direction = Direction.DOWN; private TextureAtlasSprite sprite = UnitTextureAtlasSprite.INSTANCE; private boolean shade; + private int lightEmission; private boolean hasAmbientOcclusion; @Override @@ -128,6 +129,10 @@ public void setShade(boolean shade) { this.shade = shade; } + public void setLightEmission(int lightEmission) { + this.lightEmission = lightEmission; + } + public void setHasAmbientOcclusion(boolean hasAmbientOcclusion) { this.hasAmbientOcclusion = hasAmbientOcclusion; } @@ -137,7 +142,7 @@ public BakedQuad bakeQuad() { throw new IllegalStateException("Not enough vertices available. Vertices in buffer: " + vertexIndex); } - BakedQuad quad = new BakedQuad(quadData.clone(), tintIndex, direction, sprite, shade, hasAmbientOcclusion); + BakedQuad quad = new BakedQuad(quadData.clone(), tintIndex, direction, sprite, shade, lightEmission, hasAmbientOcclusion); vertexIndex = 0; building = false; Arrays.fill(quadData, 0); diff --git a/src/main/java/net/neoforged/neoforge/common/BooleanAttribute.java b/src/main/java/net/neoforged/neoforge/common/BooleanAttribute.java index 453cb3ba..faf72771 100644 --- a/src/main/java/net/neoforged/neoforge/common/BooleanAttribute.java +++ b/src/main/java/net/neoforged/neoforge/common/BooleanAttribute.java @@ -5,8 +5,14 @@ package net.neoforged.neoforge.common; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation; +import net.minecraft.world.item.TooltipFlag; +import org.jetbrains.annotations.Nullable; /** * A boolean attribute only has two states, on or off, represented by a value of 0 (false) or 1 (true). @@ -34,4 +40,27 @@ public double sanitizeValue(double value) { } return value > 0 ? 1 : 0; } + + @Override + public MutableComponent toValueComponent(@Nullable Operation op, double value, TooltipFlag flag) { + if (op == null) { + return Component.translatable("neoforge.value.boolean." + (value > 0 ? "enabled" : "disabled")); + } else if (op == Operation.ADD_VALUE && value > 0) { + return Component.translatable("neoforge.value.boolean.enable"); + } else if (op == Operation.ADD_MULTIPLIED_TOTAL && (int) value == -1) { + return Component.translatable("neoforge.value.boolean.disable"); + } else { + return Component.translatable("neoforge.value.boolean.invalid"); + } + } + + @Override + public MutableComponent toComponent(AttributeModifier modif, TooltipFlag flag) { + double value = modif.amount(); + + ChatFormatting color = this.getStyle(value > 0); + MutableComponent comp = Component.translatable("neoforge.modifier.bool", this.toValueComponent(modif.operation(), value, flag), Component.translatable(this.getDescriptionId())).withStyle(color); + + return comp.append(this.getDebugInfo(modif, flag)); + } } diff --git a/src/main/java/net/neoforged/neoforge/common/CommonHooks.java b/src/main/java/net/neoforged/neoforge/common/CommonHooks.java index e434bbb5..d81c7891 100644 --- a/src/main/java/net/neoforged/neoforge/common/CommonHooks.java +++ b/src/main/java/net/neoforged/neoforge/common/CommonHooks.java @@ -47,7 +47,6 @@ import net.minecraft.core.HolderLookup.RegistryLookup; import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; -import net.minecraft.core.SectionPos; import net.minecraft.core.component.DataComponentMap; import net.minecraft.core.component.DataComponents; import net.minecraft.core.dispenser.BlockSource; @@ -73,7 +72,6 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.packs.PackType; import net.minecraft.stats.Stats; -import net.minecraft.tags.BlockTags; import net.minecraft.tags.TagKey; import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap; import net.minecraft.util.Mth; @@ -106,15 +104,12 @@ import net.minecraft.world.inventory.RecipeBookType; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.AdventureModePredicate; -import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.EnchantedBookItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.PotionItem; import net.minecraft.world.item.SpawnEggItem; -import net.minecraft.world.item.Tiers; import net.minecraft.world.item.TippedArrowItem; import net.minecraft.world.item.alchemy.Potion; import net.minecraft.world.item.alchemy.PotionContents; @@ -123,6 +118,7 @@ import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentInstance; import net.minecraft.world.item.enchantment.ItemEnchantments; +import net.minecraft.world.item.equipment.Equippable; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; @@ -205,6 +201,7 @@ import net.neoforged.neoforge.event.entity.player.PlayerEnchantItemEvent; import net.neoforged.neoforge.event.entity.player.PlayerEvent; import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; +import net.neoforged.neoforge.event.entity.player.SweepAttackEvent; import net.neoforged.neoforge.event.level.BlockDropsEvent; import net.neoforged.neoforge.event.level.BlockEvent; import net.neoforged.neoforge.event.level.NoteBlockEvent; @@ -268,7 +265,7 @@ public static LivingChangeTargetEvent onLivingChangeTarget(LivingEntity entity, /** * Creates and posts an {@link EntityInvulnerabilityCheckEvent}. This is invoked in - * {@link Entity#isInvulnerableTo(DamageSource)} and returns a post-listener result + * {@link Entity#isInvulnerableToBase(DamageSource)} and returns a post-listener result * to the invulnerability status of the entity to the damage source. * * @param entity the entity being checked for invulnerability @@ -348,7 +345,8 @@ public static void onArmorHurt(DamageSource source, EquipmentSlot[] slots, float for (EquipmentSlot slot : slots) { ItemStack armorPiece = armoredEntity.getItemBySlot(slot); if (armorPiece.isEmpty()) continue; - float damageAfterFireResist = (armorPiece.getItem() instanceof ArmorItem && armorPiece.canBeHurtBy(source)) ? damage : 0; + Equippable equippable = armorPiece.get(DataComponents.EQUIPPABLE); + float damageAfterFireResist = (equippable != null && equippable.damageOnHurt() && armorPiece.isDamageableItem() && armorPiece.canBeHurtBy(source)) ? damage : 0; armorMap.put(slot, new ArmorHurtEvent.ArmorEntry(armorPiece, damageAfterFireResist)); } @@ -740,16 +738,13 @@ public static Player getCraftingPlayer() { return craftingPlayer.get(); } - public static ItemStack getCraftingRemainingItem(ItemStack stack) { - if (stack.getItem().hasCraftingRemainingItem(stack)) { - stack = stack.getItem().getCraftingRemainingItem(stack); - if (!stack.isEmpty() && stack.isDamageableItem() && stack.getDamageValue() > stack.getMaxDamage()) { - EventHooks.onPlayerDestroyItem(craftingPlayer.get(), stack, null); - return ItemStack.EMPTY; - } - return stack; + public static ItemStack getCraftingRemainder(ItemStack stack) { + stack = stack.getCraftingRemainder(); + if (!stack.isEmpty() && stack.isDamageableItem() && stack.getDamageValue() > stack.getMaxDamage()) { + EventHooks.onPlayerDestroyItem(craftingPlayer.get(), stack, null); + return ItemStack.EMPTY; } - return ItemStack.EMPTY; + return stack; } public static boolean onPlayerAttackTarget(Player player, Entity target) { @@ -871,7 +866,8 @@ public static FluidType getVanillaFluidType(Fluid fluid) { throw new RuntimeException("Mod fluids must override getFluidType."); } - public static TagKey getTagFromVanillaTier(Tiers tier) { + // FIXME: is this still needed + /*public static TagKey getTagFromVanillaTier(Tiers tier) { return switch (tier) { case WOOD -> Tags.Blocks.NEEDS_WOOD_TOOL; case GOLD -> Tags.Blocks.NEEDS_GOLD_TOOL; @@ -880,7 +876,7 @@ public static TagKey getTagFromVanillaTier(Tiers tier) { case DIAMOND -> BlockTags.NEEDS_DIAMOND_TOOL; case NETHERITE -> Tags.Blocks.NEEDS_NETHERITE_TOOL; }; - } + }*/ public static Collection onCheckCreativeTabs(CreativeModeTab... vanillaTabs) { final List tabs = new ArrayList<>(Arrays.asList(vanillaTabs)); @@ -923,6 +919,17 @@ public static CriticalHitEvent fireCriticalHit(Player player, Entity target, boo return NeoForge.EVENT_BUS.post(new CriticalHitEvent(player, target, damageModifier, vanillaCritical)); } + /** + * Fires the {@link SweepAttackEvent} and returns the resulting event. + * + * @param player The attacking player. + * @param target The attack target. + * @param isVanillaSweep If the attack would have been a sweep attack by vanilla's rules in {@link Player#attack(Entity)}. + */ + public static SweepAttackEvent fireSweepAttack(Player player, Entity target, boolean isVanillaSweep) { + return NeoForge.EVENT_BUS.post(new SweepAttackEvent(player, target, isVanillaSweep)); + } + /** * Hook to fire {@link ItemAttributeModifierEvent}. Modders should use {@link ItemStack#forEachModifier(EquipmentSlot, BiConsumer)} instead. */ @@ -950,7 +957,7 @@ public static String getDefaultCreatorModId(ItemStack itemStack) { ResourceLocation registryName = BuiltInRegistries.ITEM.getKey(item); String modId = registryName == null ? null : registryName.getNamespace(); if ("minecraft".equals(modId)) { - if (item instanceof EnchantedBookItem) { + if (itemStack.has(DataComponents.STORED_ENCHANTMENTS)) { Set> enchantments = itemStack.getOrDefault(DataComponents.STORED_ENCHANTMENTS, ItemEnchantments.EMPTY).keySet(); if (enchantments.size() == 1) { Holder enchantmentHolder = enchantments.iterator().next(); @@ -976,8 +983,8 @@ public static String getDefaultCreatorModId(ItemStack itemStack) { return modId; } - public static boolean onFarmlandTrample(Level level, BlockPos pos, BlockState state, float fallDistance, Entity entity) { - if (entity.canTrample(state, pos, fallDistance)) { + public static boolean onFarmlandTrample(ServerLevel level, BlockPos pos, BlockState state, float fallDistance, Entity entity) { + if (entity.canTrample(level, state, pos, fallDistance)) { BlockEvent.FarmlandTrampleEvent event = new BlockEvent.FarmlandTrampleEvent(level, pos, state, fallDistance, entity); NeoForge.EVENT_BUS.post(event); return !event.isCanceled(); @@ -1014,7 +1021,7 @@ public static int getSerializerId(EntityDataSerializer serializer, CrudeIncre return id; } - public static boolean canEntityDestroy(Level level, BlockPos pos, LivingEntity entity) { + public static boolean canEntityDestroy(ServerLevel level, BlockPos pos, LivingEntity entity) { if (!level.isLoaded(pos)) return false; BlockState state = level.getBlockState(pos); @@ -1252,14 +1259,14 @@ public static MobEffect loadMobEffect(CompoundTag nbt, String key, @Nullable Mob return fallback; } try { - return BuiltInRegistries.MOB_EFFECT.get(ResourceLocation.parse(registryName)); + return BuiltInRegistries.MOB_EFFECT.getValue(ResourceLocation.parse(registryName)); } catch (ResourceLocationException e) { return fallback; } } - public static boolean shouldSuppressEnderManAnger(EnderMan enderMan, Player player, ItemStack mask) { - return mask.isEnderMask(player, enderMan) || NeoForge.EVENT_BUS.post(new EnderManAngerEvent(enderMan, player)).isCanceled(); + public static boolean shouldSuppressEnderManAnger(EnderMan enderMan, Player player) { + return NeoForge.EVENT_BUS.post(new EnderManAngerEvent(enderMan, player)).isCanceled(); } private static final Lazy> FORGE_CONVERSION_MAP = Lazy.of(() -> { @@ -1482,11 +1489,7 @@ public static void onChunkUnload(PoiManager poiManager, ChunkAccess chunkAccess) poiManager.flush(chunkPos); // Make sure all POI in chunk are saved to disk first. // Remove the cached POIs for this chunk's location. - int SectionPosMinY = SectionPos.blockToSectionCoord(chunkAccess.getMinBuildHeight()); - for (int currentSectionY = 0; currentSectionY < chunkAccess.getSectionsCount(); currentSectionY++) { - long sectionPosKey = SectionPos.asLong(chunkPos.x, SectionPosMinY + currentSectionY, chunkPos.z); - poiManager.remove(sectionPosKey); - } + poiManager.remove(chunkPos); } /** diff --git a/src/main/java/net/neoforged/neoforge/common/CreativeModeTabRegistry.java b/src/main/java/net/neoforged/neoforge/common/CreativeModeTabRegistry.java index 3f4de607..00438cdd 100644 --- a/src/main/java/net/neoforged/neoforge/common/CreativeModeTabRegistry.java +++ b/src/main/java/net/neoforged/neoforge/common/CreativeModeTabRegistry.java @@ -69,7 +69,7 @@ public static List getDefaultTabs() { */ @Nullable public static CreativeModeTab getTab(ResourceLocation name) { - return BuiltInRegistries.CREATIVE_MODE_TAB.get(name); + return BuiltInRegistries.CREATIVE_MODE_TAB.getValue(name); } /** @@ -173,13 +173,13 @@ private static void runInServerThreadIfPossible(BooleanConsumer runnable) { public static void sortTabs() { edges.clear(); - DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.HOTBAR)); - DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.SEARCH)); - DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.OP_BLOCKS)); - DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.INVENTORY)); + DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.getValue(CreativeModeTabs.HOTBAR)); + DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.getValue(CreativeModeTabs.SEARCH)); + DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.getValue(CreativeModeTabs.OP_BLOCKS)); + DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.getValue(CreativeModeTabs.INVENTORY)); final List> indexed = new ArrayList<>(); - BuiltInRegistries.CREATIVE_MODE_TAB.holders().filter(c -> !DEFAULT_TABS.contains(c.value())).forEach(indexed::add); + BuiltInRegistries.CREATIVE_MODE_TAB.listElements().filter(c -> !DEFAULT_TABS.contains(c.value())).forEach(indexed::add); int vanillaTabs = 10; for (int i = 0; i < vanillaTabs; i++) // Vanilla ordering diff --git a/src/main/java/net/neoforged/neoforge/common/DataMapHooks.java b/src/main/java/net/neoforged/neoforge/common/DataMapHooks.java index 5b61e8a4..5761d1a5 100644 --- a/src/main/java/net/neoforged/neoforge/common/DataMapHooks.java +++ b/src/main/java/net/neoforged/neoforge/common/DataMapHooks.java @@ -8,11 +8,16 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import net.minecraft.core.Registry; +import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; +import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.item.HoneycombItem; +import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.WeatheringCopper; +import net.minecraft.world.level.block.entity.FuelValues; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.neoforge.registries.datamaps.DataMapsUpdatedEvent; import net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps; @@ -62,6 +67,14 @@ public static Block getBlockUnwaxed(Block block) { return INVERSE_WAXABLES_DATAMAP.containsKey(block) ? INVERSE_WAXABLES_DATAMAP.get(block) : HoneycombItem.WAX_OFF_BY_BLOCK.get().get(block); } + @ApiStatus.Internal + public static FuelValues populateFuelValues(RegistryAccess lookupProvider, FeatureFlagSet features) { + FuelValues.Builder builder = new FuelValues.Builder(lookupProvider, features); + Registry registry = lookupProvider.lookupOrThrow(Registries.ITEM); + registry.getDataMap(NeoForgeDataMaps.FURNACE_FUELS).forEach((key, fuel) -> builder.add(registry.getValue(key), fuel.burnTime())); + return builder.build(); + } + @SubscribeEvent static void onDataMapsUpdated(DataMapsUpdatedEvent event) { event.ifRegistry(Registries.BLOCK, registry -> { @@ -69,7 +82,7 @@ static void onDataMapsUpdated(DataMapsUpdatedEvent event) { INVERSE_WAXABLES_DATAMAP_INTERNAL.clear(); registry.getDataMap(NeoForgeDataMaps.OXIDIZABLES).forEach((resourceKey, oxidizable) -> { - INVERSE_OXIDIZABLES_DATAMAP_INTERNAL.put(oxidizable.nextOxidationStage(), BuiltInRegistries.BLOCK.get(resourceKey)); + INVERSE_OXIDIZABLES_DATAMAP_INTERNAL.put(oxidizable.nextOxidationStage(), BuiltInRegistries.BLOCK.getValue(resourceKey)); }); //noinspection deprecation @@ -81,7 +94,7 @@ static void onDataMapsUpdated(DataMapsUpdatedEvent event) { }); registry.getDataMap(NeoForgeDataMaps.WAXABLES).forEach((resourceKey, waxable) -> { - INVERSE_WAXABLES_DATAMAP_INTERNAL.put(waxable.waxed(), BuiltInRegistries.BLOCK.get(resourceKey)); + INVERSE_WAXABLES_DATAMAP_INTERNAL.put(waxable.waxed(), BuiltInRegistries.BLOCK.getValue(resourceKey)); }); //noinspection deprecation diff --git a/src/main/java/net/neoforged/neoforge/common/DeferredSpawnEggItem.java b/src/main/java/net/neoforged/neoforge/common/DeferredSpawnEggItem.java index 1b1ac206..67c84ef0 100644 --- a/src/main/java/net/neoforged/neoforge/common/DeferredSpawnEggItem.java +++ b/src/main/java/net/neoforged/neoforge/common/DeferredSpawnEggItem.java @@ -12,10 +12,10 @@ import java.util.function.Supplier; import net.minecraft.core.Direction; import net.minecraft.core.dispenser.DispenseItemBehavior; -import net.minecraft.util.FastColor; +import net.minecraft.util.ARGB; +import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SpawnEggItem; import net.minecraft.world.level.block.DispenserBlock; @@ -62,7 +62,7 @@ protected EntityType getDefaultType() { EntityType type = ((SpawnEggItem) stack.getItem()).getType(stack); try { - type.spawn(source.level(), stack, null, source.pos().relative(face), MobSpawnType.DISPENSER, face != Direction.UP, false); + type.spawn(source.level(), stack, null, source.pos().relative(face), EntitySpawnReason.DISPENSER, face != Direction.UP, false); } catch (Exception exception) { DispenseItemBehavior.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", source.pos(), exception); return ItemStack.EMPTY; @@ -94,7 +94,7 @@ public static void onCommonSetup(FMLCommonSetupEvent event) { private static class ColorRegisterHandler { @SubscribeEvent(priority = EventPriority.HIGHEST) public static void registerSpawnEggColors(RegisterColorHandlersEvent.Item event) { - MOD_EGGS.forEach(egg -> event.register((stack, layer) -> FastColor.ARGB32.opaque(egg.getColor(layer)), egg)); + MOD_EGGS.forEach(egg -> event.register((stack, layer) -> ARGB.opaque(egg.getColor(layer)), egg)); } } } diff --git a/src/main/java/net/neoforged/neoforge/common/EffectCure.java b/src/main/java/net/neoforged/neoforge/common/EffectCure.java deleted file mode 100644 index e26da9f6..00000000 --- a/src/main/java/net/neoforged/neoforge/common/EffectCure.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) NeoForged and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.neoforge.common; - -import com.mojang.serialization.Codec; -import io.netty.buffer.ByteBuf; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import net.minecraft.network.codec.ByteBufCodecs; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.entity.LivingEntity; -import net.neoforged.neoforge.event.entity.living.MobEffectEvent; - -/** - * Defines a cure that is used to remove {@link MobEffect}s from a {@link LivingEntity}. - *

Cures can be added to or removed from your own effects via {@link MobEffect#fillEffectCures(Set, MobEffectInstance)} - * or any effect by modifying the set of cures on the {@link MobEffectInstance} in {@link MobEffectEvent.Added} - */ -public final class EffectCure { - private static final Map CURES = new ConcurrentHashMap<>(); - - public static Codec CODEC = Codec.STRING.xmap(EffectCure::get, EffectCure::name); - public static final StreamCodec STREAM_CODEC = ByteBufCodecs.STRING_UTF8.map(EffectCure::get, EffectCure::name); - - /** - * {@return all registered cures} - * This collection can be kept around, and will update itself in response to changes to the map. - * See {@link ConcurrentHashMap#values()} for details. - */ - public static Collection getAllCures() { - return Collections.unmodifiableCollection(CURES.values()); - } - - /** - * Gets or creates a new EffectCure for the given name. - */ - public static EffectCure get(String name) { - return CURES.computeIfAbsent(name, EffectCure::new); - } - - /** - * {@return the name of this cure} - */ - public String name() { - return name; - } - - @Override - public String toString() { - return "EffectCure[" + name + "]"; - } - - private final String name; - - /** - * Use {@link #get(String)} to get or create an EffectCure - */ - private EffectCure(String name) { - this.name = name; - } -} diff --git a/src/main/java/net/neoforged/neoforge/common/EffectCures.java b/src/main/java/net/neoforged/neoforge/common/EffectCures.java deleted file mode 100644 index 43620159..00000000 --- a/src/main/java/net/neoforged/neoforge/common/EffectCures.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) NeoForged and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.neoforge.common; - -import java.util.Set; - -public class EffectCures { - /** - * Cure used when a milk bucket is consumed. Cures any effect by default. - */ - public static final EffectCure MILK = EffectCure.get("milk"); - /** - * Cure used when a honey bottle is consumed. Only cures poison by default. - */ - public static final EffectCure HONEY = EffectCure.get("honey"); - /** - * Cure used when a totem of undying protects the player from death. Cures any effect by default. - */ - public static final EffectCure PROTECTED_BY_TOTEM = EffectCure.get("protected_by_totem"); - - public static final Set DEFAULT_CURES = Set.of(MILK, PROTECTED_BY_TOTEM); -} diff --git a/src/main/java/net/neoforged/neoforge/common/IShearable.java b/src/main/java/net/neoforged/neoforge/common/IShearable.java index ae5d51aa..2be90986 100644 --- a/src/main/java/net/neoforged/neoforge/common/IShearable.java +++ b/src/main/java/net/neoforged/neoforge/common/IShearable.java @@ -9,6 +9,7 @@ import java.util.Collections; import java.util.List; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundSource; import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; @@ -64,9 +65,9 @@ default boolean isShearable(@Nullable Player player, ItemStack item, Level level @SuppressWarnings("deprecation") // Expected call to deprecated vanilla Shearable#shear default List onSheared(@Nullable Player player, ItemStack item, Level level, BlockPos pos) { if (this instanceof LivingEntity entity && this instanceof Shearable shearable) { - if (!level.isClientSide) { + if (level instanceof ServerLevel serverLevel) { entity.captureDrops(new ArrayList<>()); - shearable.shear(player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS); + shearable.shear(serverLevel, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, item); return entity.captureDrops(null).stream().map(ItemEntity::getItem).toList(); } } @@ -82,23 +83,23 @@ default List onSheared(@Nullable Player player, ItemStack item, Level * @param pos The block position of this object (if this is an entity, the value of {@link Entity#blockPosition()}. * @param drop The stack to drop, from the list of drops returned by {@link #onSheared}. */ - default void spawnShearedDrop(Level level, BlockPos pos, ItemStack drop) { + default void spawnShearedDrop(ServerLevel level, BlockPos pos, ItemStack drop) { if (this instanceof SnowGolem golem) { // SnowGolem#shear uses spawnAtLocation(..., this.getEyeHeight()); - golem.spawnAtLocation(drop, golem.getEyeHeight()); + golem.spawnAtLocation(level, drop, golem.getEyeHeight()); } else if (this instanceof Bogged bogged) { // Bogged#spawnShearedMushrooms uses spawnAtLocation(..., this.getBbHeight()); - bogged.spawnAtLocation(drop, bogged.getBbHeight()); + bogged.spawnAtLocation(level, drop, bogged.getBbHeight()); } else if (this instanceof MushroomCow cow) { // We patch Mooshrooms from using addFreshEntity to spawnAtLocation to spawnAtLocation to capture the drops. // In case a mod is also capturing drops, we also replicate that logic here. - ItemEntity itemEntity = cow.spawnAtLocation(drop, cow.getBbHeight()); + ItemEntity itemEntity = cow.spawnAtLocation(level, drop, cow.getBbHeight()); if (itemEntity != null) { itemEntity.setNoPickUpDelay(); } } else if (this instanceof Entity entity) { // Everything else uses the "default" rules invented by Sheep#shear, which uses a y-offset of 1 and these random delta movement values. - ItemEntity itemEntity = entity.spawnAtLocation(drop, 1); + ItemEntity itemEntity = entity.spawnAtLocation(level, drop, 1); if (itemEntity != null) { RandomSource rand = entity.getRandom(); Vec3 newDelta = itemEntity.getDeltaMovement().add( diff --git a/src/main/java/net/neoforged/neoforge/common/MonsterRoomHooks.java b/src/main/java/net/neoforged/neoforge/common/MonsterRoomHooks.java index dca24a23..e2f08277 100644 --- a/src/main/java/net/neoforged/neoforge/common/MonsterRoomHooks.java +++ b/src/main/java/net/neoforged/neoforge/common/MonsterRoomHooks.java @@ -26,7 +26,7 @@ public class MonsterRoomHooks { @SubscribeEvent public static void onDataMapsUpdated(DataMapsUpdatedEvent event) { event.ifRegistry(Registries.ENTITY_TYPE, registry -> monsterRoomMobs = registry.getDataMap(NeoForgeDataMaps.MONSTER_ROOM_MOBS).entrySet().stream().map((entry) -> { - EntityType type = Objects.requireNonNull(registry.get(entry.getKey()), "Nonexistent entity " + entry.getKey() + " in monster room datamap!"); + EntityType type = Objects.requireNonNull(registry.getValue(entry.getKey()), "Nonexistent entity " + entry.getKey() + " in monster room datamap!"); return new MobEntry(type, entry.getValue().weight()); }).toList()); } diff --git a/src/main/java/net/neoforged/neoforge/common/NeoForgeConfig.java b/src/main/java/net/neoforged/neoforge/common/NeoForgeConfig.java index ebbe55f8..91a232a8 100644 --- a/src/main/java/net/neoforged/neoforge/common/NeoForgeConfig.java +++ b/src/main/java/net/neoforged/neoforge/common/NeoForgeConfig.java @@ -87,8 +87,6 @@ public static class Client { public final BooleanValue showLoadWarnings; - public final BooleanValue useCombinedDepthStencilAttachment; - public final BooleanValue logUntranslatedConfigurationWarnings; Client(ModConfigSpec.Builder builder) { @@ -102,11 +100,6 @@ public static class Client { .translation("neoforge.configgui.showLoadWarnings") .define("showLoadWarnings", true); - useCombinedDepthStencilAttachment = builder - .comment("Set to true to use a combined DEPTH_STENCIL attachment instead of two separate ones.") - .translation("neoforge.configgui.useCombinedDepthStencilAttachment") - .define("useCombinedDepthStencilAttachment", false); - logUntranslatedConfigurationWarnings = builder .comment("A config option mainly for developers. Logs out configuration values that do not have translations when running a client in a development environment.") .translation("neoforge.configgui.logUntranslatedConfigurationWarnings") diff --git a/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java b/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java index 2e2e14ab..d7440f1e 100644 --- a/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java +++ b/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java @@ -57,7 +57,7 @@ public void onEntityJoinWorld(EntityJoinLevelEvent event) { entity.discard(); event.setCanceled(true); var executor = LogicalSidedProvider.WORKQUEUE.get(event.getLevel().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER); - executor.tell(new TickTask(0, () -> event.getLevel().addFreshEntity(newEntity))); + executor.schedule(new TickTask(0, () -> event.getLevel().addFreshEntity(newEntity))); } } } @@ -110,7 +110,7 @@ public void tagsUpdated(TagsUpdatedEvent event) { public void onDpSync(final OnDatapackSyncEvent event) { RegistryManager.getDataMaps().forEach((registry, values) -> { final var regOpt = event.getPlayerList().getServer().overworld().registryAccess() - .registry(registry); + .lookup(registry); if (regOpt.isEmpty()) return; event.getRelevantPlayers().forEach(player -> { if (!player.connection.hasChannel(RegistryDataMapSyncPayload.TYPE)) { diff --git a/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java b/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java index 3c0ca35b..c19d9e78 100644 --- a/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java +++ b/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java @@ -35,6 +35,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.metadata.pack.PackMetadataSection; import net.minecraft.sounds.SoundEvent; @@ -47,19 +48,19 @@ import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.Attribute.Sentiment; import net.minecraft.world.entity.ai.attributes.RangedAttribute; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.display.SlotDisplay; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.GameRules; -import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.MobSpawnSettings; import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.PointedDripstoneBlock; -import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.GenerationStep.Decoration; import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; import net.minecraft.world.level.levelgen.placement.PlacedFeature; @@ -98,6 +99,7 @@ import net.neoforged.neoforge.common.conditions.TrueCondition; import net.neoforged.neoforge.common.crafting.BlockTagIngredient; import net.neoforged.neoforge.common.crafting.CompoundIngredient; +import net.neoforged.neoforge.common.crafting.CustomDisplayIngredient; import net.neoforged.neoforge.common.crafting.DataComponentIngredient; import net.neoforged.neoforge.common.crafting.DifferenceIngredient; import net.neoforged.neoforge.common.crafting.IngredientType; @@ -140,13 +142,16 @@ import net.neoforged.neoforge.fluids.CauldronFluidContent; import net.neoforged.neoforge.fluids.FluidType; import net.neoforged.neoforge.fluids.crafting.CompoundFluidIngredient; +import net.neoforged.neoforge.fluids.crafting.CustomDisplayFluidIngredient; import net.neoforged.neoforge.fluids.crafting.DataComponentFluidIngredient; import net.neoforged.neoforge.fluids.crafting.DifferenceFluidIngredient; -import net.neoforged.neoforge.fluids.crafting.EmptyFluidIngredient; +import net.neoforged.neoforge.fluids.crafting.FluidIngredientCodecs; import net.neoforged.neoforge.fluids.crafting.FluidIngredientType; import net.neoforged.neoforge.fluids.crafting.IntersectionFluidIngredient; -import net.neoforged.neoforge.fluids.crafting.SingleFluidIngredient; -import net.neoforged.neoforge.fluids.crafting.TagFluidIngredient; +import net.neoforged.neoforge.fluids.crafting.SimpleFluidIngredient; +import net.neoforged.neoforge.fluids.crafting.display.FluidSlotDisplay; +import net.neoforged.neoforge.fluids.crafting.display.FluidStackSlotDisplay; +import net.neoforged.neoforge.fluids.crafting.display.FluidTagSlotDisplay; import net.neoforged.neoforge.forge.snapshots.ForgeSnapshotsMod; import net.neoforged.neoforge.internal.versions.neoforge.NeoForgeVersion; import net.neoforged.neoforge.network.DualStackUtils; @@ -194,8 +199,8 @@ public class NeoForgeMod { private static final DeferredHolder, SingletonArgumentInfo> MODID_COMMAND_ARGUMENT_TYPE = COMMAND_ARGUMENT_TYPES.register("modid", () -> ArgumentTypeInfos.registerByClass(ModIdArgument.class, SingletonArgumentInfo.contextFree(ModIdArgument::modIdArgument))); - public static final Holder SWIM_SPEED = ATTRIBUTES.register("swim_speed", () -> new RangedAttribute("neoforge.swim_speed", 1.0D, 0.0D, 1024.0D).setSyncable(true)); - public static final Holder NAMETAG_DISTANCE = ATTRIBUTES.register("nametag_distance", () -> new RangedAttribute("neoforge.name_tag_distance", 64.0D, 0.0D, 64.0).setSyncable(true)); + public static final Holder SWIM_SPEED = ATTRIBUTES.register("swim_speed", () -> new PercentageAttribute("neoforge.swim_speed", 1.0D, 0.0D, 1024.0D).setSyncable(true)); + public static final Holder NAMETAG_DISTANCE = ATTRIBUTES.register("nametag_distance", () -> new RangedAttribute("neoforge.name_tag_distance", 32.0D, 0.0D, 32.0).setSyncable(true).setSentiment(Sentiment.NEUTRAL)); /** * This attribute controls if the player may use creative flight when not in creative mode. @@ -272,18 +277,14 @@ public class NeoForgeMod { */ public static final DeferredHolder, MapCodec> ADD_CARVERS_BIOME_MODIFIER_TYPE = BIOME_MODIFIER_SERIALIZERS.register("add_carvers", () -> RecordCodecBuilder.mapCodec(builder -> builder.group( Biome.LIST_CODEC.fieldOf("biomes").forGetter(BiomeModifiers.AddCarversBiomeModifier::biomes), - ConfiguredWorldCarver.LIST_CODEC.fieldOf("carvers").forGetter(BiomeModifiers.AddCarversBiomeModifier::carvers), - GenerationStep.Carving.CODEC.fieldOf("step").forGetter(BiomeModifiers.AddCarversBiomeModifier::step)).apply(builder, BiomeModifiers.AddCarversBiomeModifier::new))); + ConfiguredWorldCarver.LIST_CODEC.fieldOf("carvers").forGetter(BiomeModifiers.AddCarversBiomeModifier::carvers)).apply(builder, BiomeModifiers.AddCarversBiomeModifier::new))); /** * Stock biome modifier for removing carvers from biomes. */ public static final DeferredHolder, MapCodec> REMOVE_CARVERS_BIOME_MODIFIER_TYPE = BIOME_MODIFIER_SERIALIZERS.register("remove_carvers", () -> RecordCodecBuilder.mapCodec(builder -> builder.group( Biome.LIST_CODEC.fieldOf("biomes").forGetter(BiomeModifiers.RemoveCarversBiomeModifier::biomes), - ConfiguredWorldCarver.LIST_CODEC.fieldOf("carvers").forGetter(BiomeModifiers.RemoveCarversBiomeModifier::carvers), - Codec.either(GenerationStep.Carving.CODEC.listOf(), GenerationStep.Carving.CODEC).xmap( - either -> either.map(Set::copyOf, Set::of), - set -> set.size() == 1 ? Either.right(set.toArray(GenerationStep.Carving[]::new)[0]) : Either.left(List.copyOf(set))).optionalFieldOf("steps", EnumSet.allOf(GenerationStep.Carving.class)).forGetter(BiomeModifiers.RemoveCarversBiomeModifier::steps)) + ConfiguredWorldCarver.LIST_CODEC.fieldOf("carvers").forGetter(BiomeModifiers.RemoveCarversBiomeModifier::carvers)) .apply(builder, BiomeModifiers.RemoveCarversBiomeModifier::new))); /** @@ -356,6 +357,12 @@ public class NeoForgeMod { */ public static final Holder NOT_HOLDER_SET = HOLDER_SET_TYPES.register("not", NotHolderSet.Type::new); + private static final DeferredRegister> SLOT_DISPLAY_TYPES = DeferredRegister.create(Registries.SLOT_DISPLAY, NeoForgeVersion.MOD_ID); + + public static final DeferredHolder, SlotDisplay.Type> FLUID_SLOT_DISPLAY = SLOT_DISPLAY_TYPES.register("fluid", () -> new SlotDisplay.Type<>(FluidSlotDisplay.MAP_CODEC, FluidSlotDisplay.STREAM_CODEC)); + public static final DeferredHolder, SlotDisplay.Type> FLUID_STACK_SLOT_DISPLAY = SLOT_DISPLAY_TYPES.register("fluid_stack", () -> new SlotDisplay.Type<>(FluidStackSlotDisplay.MAP_CODEC, FluidStackSlotDisplay.STREAM_CODEC)); + public static final DeferredHolder, SlotDisplay.Type> FLUID_TAG_SLOT_DISPLAY = SLOT_DISPLAY_TYPES.register("fluid_tag", () -> new SlotDisplay.Type<>(FluidTagSlotDisplay.MAP_CODEC, FluidTagSlotDisplay.STREAM_CODEC)); + private static final DeferredRegister> INGREDIENT_TYPES = DeferredRegister.create(NeoForgeRegistries.Keys.INGREDIENT_TYPES, NeoForgeVersion.MOD_ID); public static final DeferredHolder, IngredientType> COMPOUND_INGREDIENT_TYPE = INGREDIENT_TYPES.register("compound", () -> new IngredientType<>(CompoundIngredient.CODEC)); @@ -363,15 +370,15 @@ public class NeoForgeMod { public static final DeferredHolder, IngredientType> DIFFERENCE_INGREDIENT_TYPE = INGREDIENT_TYPES.register("difference", () -> new IngredientType<>(DifferenceIngredient.CODEC)); public static final DeferredHolder, IngredientType> INTERSECTION_INGREDIENT_TYPE = INGREDIENT_TYPES.register("intersection", () -> new IngredientType<>(IntersectionIngredient.CODEC)); public static final DeferredHolder, IngredientType> BLOCK_TAG_INGREDIENT = INGREDIENT_TYPES.register("block_tag", () -> new IngredientType<>(BlockTagIngredient.CODEC)); + public static final DeferredHolder, IngredientType> CUSTOM_DISPLAY_INGREDIENT = INGREDIENT_TYPES.register("custom_display", () -> new IngredientType<>(CustomDisplayIngredient.CODEC)); private static final DeferredRegister> FLUID_INGREDIENT_TYPES = DeferredRegister.create(NeoForgeRegistries.Keys.FLUID_INGREDIENT_TYPES, NeoForgeVersion.MOD_ID); - public static final DeferredHolder, FluidIngredientType> SINGLE_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("single", () -> new FluidIngredientType<>(SingleFluidIngredient.CODEC)); - public static final DeferredHolder, FluidIngredientType> TAG_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("tag", () -> new FluidIngredientType<>(TagFluidIngredient.CODEC)); - public static final DeferredHolder, FluidIngredientType> EMPTY_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("empty", () -> new FluidIngredientType<>(EmptyFluidIngredient.CODEC)); + public static final DeferredHolder, FluidIngredientType> SIMPLE_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("simple", FluidIngredientCodecs::simpleType); public static final DeferredHolder, FluidIngredientType> COMPOUND_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("compound", () -> new FluidIngredientType<>(CompoundFluidIngredient.CODEC)); public static final DeferredHolder, FluidIngredientType> DATA_COMPONENT_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("components", () -> new FluidIngredientType<>(DataComponentFluidIngredient.CODEC)); public static final DeferredHolder, FluidIngredientType> DIFFERENCE_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("difference", () -> new FluidIngredientType<>(DifferenceFluidIngredient.CODEC)); public static final DeferredHolder, FluidIngredientType> INTERSECTION_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("intersection", () -> new FluidIngredientType<>(IntersectionFluidIngredient.CODEC)); + public static final DeferredHolder, FluidIngredientType> CUSTOM_DISPLAY_FLUID_INGREDIENT = FLUID_INGREDIENT_TYPES.register("custom_display", () -> new FluidIngredientType<>(CustomDisplayFluidIngredient.CODEC, CustomDisplayFluidIngredient.STREAM_CODEC)); private static final DeferredRegister> CONDITION_CODECS = DeferredRegister.create(NeoForgeRegistries.Keys.CONDITION_CODECS, NeoForgeVersion.MOD_ID); public static final DeferredHolder, MapCodec> AND_CONDITION = CONDITION_CODECS.register("and", () -> AndCondition.CODEC); @@ -423,7 +430,7 @@ public void setItemMovement(ItemEntity entity) { .addDripstoneDripping(PointedDripstoneBlock.WATER_TRANSFER_PROBABILITY_PER_RANDOM_TICK, ParticleTypes.DRIPPING_DRIPSTONE_WATER, Blocks.WATER_CAULDRON, SoundEvents.POINTED_DRIPSTONE_DRIP_WATER_INTO_CAULDRON)) { @Override public boolean canConvertToSource(FluidState state, LevelReader reader, BlockPos pos) { - if (reader instanceof Level level) { + if (reader instanceof ServerLevel level) { return level.getGameRules().getBoolean(GameRules.RULE_WATER_SOURCE_CONVERSION); } //Best guess fallback to default (true) @@ -450,7 +457,7 @@ public boolean canConvertToSource(FluidState state, LevelReader reader, BlockPos .addDripstoneDripping(PointedDripstoneBlock.LAVA_TRANSFER_PROBABILITY_PER_RANDOM_TICK, ParticleTypes.DRIPPING_DRIPSTONE_LAVA, Blocks.LAVA_CAULDRON, SoundEvents.POINTED_DRIPSTONE_DRIP_LAVA_INTO_CAULDRON)) { @Override public boolean canConvertToSource(FluidState state, LevelReader reader, BlockPos pos) { - if (reader instanceof Level level) { + if (reader instanceof ServerLevel level) { return level.getGameRules().getBoolean(GameRules.RULE_LAVA_SOURCE_CONVERSION); } //Best guess fallback to default (false) @@ -471,6 +478,8 @@ public void setItemMovement(ItemEntity entity) { private static boolean enableProperFilenameValidation = false; private static boolean enableMilkFluid = false; + private static boolean enableMergedAttributeTooltips = false; + public static final DeferredHolder BUCKET_EMPTY_MILK = DeferredHolder.create(Registries.SOUND_EVENT, ResourceLocation.withDefaultNamespace("item.bucket.empty_milk")); public static final DeferredHolder BUCKET_FILL_MILK = DeferredHolder.create(Registries.SOUND_EVENT, ResourceLocation.withDefaultNamespace("item.bucket.fill_milk")); public static final DeferredHolder MILK_TYPE = DeferredHolder.create(NeoForgeRegistries.Keys.FLUID_TYPES, ResourceLocation.withDefaultNamespace("milk")); @@ -493,6 +502,13 @@ public static void enableMilkFluid() { enableMilkFluid = true; } + /** + * Run this during mod construction to enable merged attribute tooltip functionality. + */ + public static void enableMergedAttributeTooltips() { + enableMergedAttributeTooltips = true; + } + /** * Run this method during mod constructor to enable {@link net.minecraft.FileUtil#RESERVED_WINDOWS_FILENAMES_NEOFORGE} regex being used for filepath validation. * Fixes MC-268617 at cost of vanilla incompat edge cases with files generated with this activated and them migrated to vanilla instance - See PR #767 @@ -505,6 +521,10 @@ public static boolean getProperFilenameValidation() { return enableProperFilenameValidation; } + public static boolean shouldMergeAttributeTooltips() { + return enableMergedAttributeTooltips; + } + public NeoForgeMod(IEventBus modEventBus, Dist dist, ModContainer container) { LOGGER.info(NEOFORGEMOD, "NeoForge mod loading, version {}, for MC {}", NeoForgeVersion.getVersion(), DetectedVersion.BUILT_IN.getName()); ForgeSnapshotsMod.logStartupWarning(); @@ -536,6 +556,7 @@ public NeoForgeMod(IEventBus modEventBus, Dist dist, ModContainer container) { VANILLA_FLUID_TYPES.register(modEventBus); ENTITY_PREDICATE_CODECS.register(modEventBus); ITEM_SUB_PREDICATES.register(modEventBus); + SLOT_DISPLAY_TYPES.register(modEventBus); INGREDIENT_TYPES.register(modEventBus); CONDITION_CODECS.register(modEventBus); GLOBAL_LOOT_MODIFIER_SERIALIZERS.register(modEventBus); @@ -608,7 +629,7 @@ public void gatherData(GatherDataEvent event) { gen.addProvider(event.includeServer(), new NeoForgeEntityTypeTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new NeoForgeFluidTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new NeoForgeEnchantmentTagsProvider(packOutput, lookupProvider, existingFileHelper)); - gen.addProvider(event.includeServer(), new NeoForgeRecipeProvider(packOutput, lookupProvider)); + gen.addProvider(event.includeServer(), new NeoForgeRecipeProvider.Runner(packOutput, lookupProvider)); gen.addProvider(event.includeServer(), new NeoForgeLootTableProvider(packOutput, lookupProvider)); gen.addProvider(event.includeServer(), new NeoForgeBiomeTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new NeoForgeStructureTagsProvider(packOutput, lookupProvider, existingFileHelper)); diff --git a/src/main/java/net/neoforged/neoforge/common/PercentageAttribute.java b/src/main/java/net/neoforged/neoforge/common/PercentageAttribute.java new file mode 100644 index 00000000..75a845fe --- /dev/null +++ b/src/main/java/net/neoforged/neoforge/common/PercentageAttribute.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) NeoForged and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.neoforged.neoforge.common; + +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation; +import net.minecraft.world.entity.ai.attributes.RangedAttribute; +import net.minecraft.world.item.TooltipFlag; + +/** + * A Percentage Attribute is one which always displays modifiers as percentages, including for {@link Operation#ADD_VALUE}. + *

+ * This is used for attributes that would not make sense being displayed as flat additions (ex: +0.05 Swim Speed). + */ +public class PercentageAttribute extends RangedAttribute { + protected final double scaleFactor; + + /** + * Creates a new PercentageAttribute with the given description, value information, and scale factor. + *

+ * If your attribute's "real" value correlates 1 == 100%, you would use a scale factor of 100 to convert to 1 to 100%. + * + * @param pDescriptionId The description id used for generating the attribute's lang key. + * @param pDefaultValue The default value of the attribute + * @param pMin The minimum value + * @param pMax The maximum value + * @param scaleFactor The scale factor, used to convert the literal value to a percentage value. + */ + public PercentageAttribute(String pDescriptionId, double pDefaultValue, double pMin, double pMax, double scaleFactor) { + super(pDescriptionId, pDefaultValue, pMin, pMax); + this.scaleFactor = scaleFactor; + } + + /** + * Creates a new PercentageAttribute with the default scale factor of 100. + * + * @see #PercentageAttribute(String, double, double, double, double) + */ + public PercentageAttribute(String pDescriptionId, double pDefaultValue, double pMin, double pMax) { + this(pDescriptionId, pDefaultValue, pMin, pMax, 100); + } + + @Override + public MutableComponent toValueComponent(Operation op, double value, TooltipFlag flag) { + return Component.translatable("neoforge.value.percent", FORMAT.format(value * this.scaleFactor)); + } +} diff --git a/src/main/java/net/neoforged/neoforge/common/SimpleTier.java b/src/main/java/net/neoforged/neoforge/common/SimpleTier.java index 73b4dfdd..556ba03e 100644 --- a/src/main/java/net/neoforged/neoforge/common/SimpleTier.java +++ b/src/main/java/net/neoforged/neoforge/common/SimpleTier.java @@ -7,14 +7,14 @@ import java.util.function.Supplier; import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Tier; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.Block; /** * Helper class to define a custom tier + * FIXME: is this still needed? */ -public class SimpleTier implements Tier { +public class SimpleTier /*implements Tier*/ { private final TagKey incorrectBlocksForDrops; private final int uses; private final float speed; @@ -32,35 +32,35 @@ public SimpleTier(TagKey incorrectBlocksForDrops, int uses, float speed, this.repairIngredient = repairIngredient; } - @Override + /*@Override public int getUses() { return this.uses; } - + @Override public float getSpeed() { return this.speed; } - + @Override public float getAttackDamageBonus() { return this.attackDamageBonus; } - + @Override public TagKey getIncorrectBlocksForDrops() { return incorrectBlocksForDrops; } - + @Override public int getEnchantmentValue() { return this.enchantmentValue; } - + @Override public Ingredient getRepairIngredient() { return this.repairIngredient.get(); - } + }*/ @Override public String toString() { diff --git a/src/main/java/net/neoforged/neoforge/common/TagConventionLogWarning.java b/src/main/java/net/neoforged/neoforge/common/TagConventionLogWarning.java index f874d457..6f00ace7 100644 --- a/src/main/java/net/neoforged/neoforge/common/TagConventionLogWarning.java +++ b/src/main/java/net/neoforged/neoforge/common/TagConventionLogWarning.java @@ -10,6 +10,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; @@ -411,12 +412,17 @@ public enum LogWarningMode { createForgeMapEntry(Registries.ITEM, "candy", Tags.Items.FOODS_CANDY), createForgeMapEntry(Registries.ITEM, "candies", Tags.Items.FOODS_CANDY), createMapEntry(Registries.ITEM, "c", "foods/candies", Tags.Items.FOODS_CANDY), + createForgeMapEntry(Registries.ITEM, "pie", Tags.Items.FOODS_PIE), + createForgeMapEntry(Registries.ITEM, "pies", Tags.Items.FOODS_PIE), + createMapEntry(Registries.ITEM, "c", "foods/pies", Tags.Items.FOODS_PIE), createForgeMapEntry(Registries.FLUID, "water", Tags.Fluids.WATER), createForgeMapEntry(Registries.FLUID, "lava", Tags.Fluids.LAVA), createForgeMapEntry(Registries.FLUID, "milk", Tags.Fluids.MILK), createForgeMapEntry(Registries.FLUID, "gaseous", Tags.Fluids.GASEOUS), createForgeMapEntry(Registries.FLUID, "honey", Tags.Fluids.HONEY), + createForgeMapEntry(Registries.FLUID, "xp", Tags.Fluids.EXPERIENCE), + createForgeMapEntry(Registries.FLUID, "experience", Tags.Fluids.EXPERIENCE), createForgeMapEntry(Registries.FLUID, "potion", Tags.Fluids.POTION), createForgeMapEntry(Registries.FLUID, "plantoil", "plant_oil"), @@ -498,7 +504,7 @@ private static void setupLegacyTagWarning(IEventBus forgeBus) { // We only care about vanilla registries registryAccess.registries().forEach(registryEntry -> { if (registryEntry.key().location().getNamespace().equals("minecraft")) { - registryEntry.value().getTagNames().forEach(tagKey -> { + registryEntry.value().getTags().map(HolderSet.Named::key).forEach(tagKey -> { // Grab tags under 'forge' namespace if (LEGACY_FORGE_TAGS.containsKey(tagKey) || tagKey.location().getNamespace().equals("forge")) { legacyTags.add(tagKey); diff --git a/src/main/java/net/neoforged/neoforge/common/Tags.java b/src/main/java/net/neoforged/neoforge/common/Tags.java index c02af99a..8a57785d 100644 --- a/src/main/java/net/neoforged/neoforge/common/Tags.java +++ b/src/main/java/net/neoforged/neoforge/common/Tags.java @@ -115,6 +115,12 @@ public static class Blocks { public static final TagKey HIDDEN_FROM_RECIPE_VIEWERS = tag("hidden_from_recipe_viewers"); public static final TagKey NETHERRACKS = tag("netherracks"); public static final TagKey OBSIDIANS = tag("obsidians"); + /** + * For common obsidian that has no special quirks or behaviors. Ideal for recipe use. + * Crying Obsidian, for example, is a light block and harder to obtain. So it gets its own tag instead of being under normal tag. + */ + public static final TagKey OBSIDIANS_NORMAL = tag("obsidians/normal"); + public static final TagKey OBSIDIANS_CRYING = tag("obsidians/crying"); /** * Blocks which are often replaced by deepslate ores, i.e. the ores in the tag {@link #ORES_IN_GROUND_DEEPSLATE}, during world generation */ @@ -218,6 +224,8 @@ public static class Blocks { public static final TagKey STORAGE_BLOCKS_REDSTONE = tag("storage_blocks/redstone"); public static final TagKey STORAGE_BLOCKS_SLIME = tag("storage_blocks/slime"); public static final TagKey STORAGE_BLOCKS_WHEAT = tag("storage_blocks/wheat"); + public static final TagKey STRIPPED_LOGS = tag("stripped_logs"); + public static final TagKey STRIPPED_WOODS = tag("stripped_woods"); public static final TagKey VILLAGER_JOB_SITES = tag("villager_job_sites"); /** @@ -423,6 +431,10 @@ public static class Items { * Sweets and candies like lollipops or chocolate belong in this tag. */ public static final TagKey FOODS_CANDY = tag("foods/candy"); + /** + * Pies and other pie-like foods belong in this tag. + */ + public static final TagKey FOODS_PIE = tag("foods/pie"); /** * Any gold-based foods would go in this tag. Such as Golden Apples or Glistering Melon Slice. */ @@ -485,6 +497,12 @@ public static class Items { public static final TagKey NUGGETS_GOLD = tag("nuggets/gold"); public static final TagKey NUGGETS_IRON = tag("nuggets/iron"); public static final TagKey OBSIDIANS = tag("obsidians"); + /** + * For common obsidian that has no special quirks or behaviors. Ideal for recipe use. + * Crying Obsidian, for example, is a light block and harder to obtain. So it gets its own tag instead of being under normal tag. + */ + public static final TagKey OBSIDIANS_NORMAL = tag("obsidians/normal"); + public static final TagKey OBSIDIANS_CRYING = tag("obsidians/crying"); /** * Blocks which are often replaced by deepslate ores, i.e. the ores in the tag {@link #ORES_IN_GROUND_DEEPSLATE}, during world generation */ @@ -611,6 +629,8 @@ public static class Items { public static final TagKey STORAGE_BLOCKS_SLIME = tag("storage_blocks/slime"); public static final TagKey STORAGE_BLOCKS_WHEAT = tag("storage_blocks/wheat"); public static final TagKey STRINGS = tag("strings"); + public static final TagKey STRIPPED_LOGS = tag("stripped_logs"); + public static final TagKey STRIPPED_WOODS = tag("stripped_woods"); public static final TagKey VILLAGER_JOB_SITES = tag("villager_job_sites"); // Tools and Armors @@ -752,12 +772,12 @@ private static TagKey neoforgeTag(String name) { */ public static class Fluids { /** - * Holds all fluids related to water. + * Holds all fluids related to water.

* This tag is done to help out multi-loader mods/datapacks where the vanilla water tag has attached behaviors outside Neo. */ public static final TagKey WATER = tag("water"); /** - * Holds all fluids related to lava. + * Holds all fluids related to lava.

* This tag is done to help out multi-loader mods/datapacks where the vanilla lava tag has attached behaviors outside Neo. */ public static final TagKey LAVA = tag("lava"); @@ -770,36 +790,48 @@ public static class Fluids { */ public static final TagKey GASEOUS = tag("gaseous"); /** - * Holds all fluids related to honey.

+ * Holds all fluids related to honey. + *

* (Standard unit for honey bottle is 250mb per bottle) */ public static final TagKey HONEY = tag("honey"); /** - * Holds all fluids related to potions. The effects of the potion fluid should be read from NBT. + * Holds all fluids related to experience. + *

+ * (Standard unit for experience is 20mb per 1 experience. However, extraction from Bottle o' Enchanting should yield 250mb while smashing yields less) + */ + public static final TagKey EXPERIENCE = tag("experience"); + /** + * Holds all fluids related to potions. The effects of the potion fluid should be read from DataComponents. * The effects and color of the potion fluid should be read from {@link net.minecraft.core.component.DataComponents#POTION_CONTENTS} - * component that people should be attaching to the fluidstack of this fluid.

+ * component that people should be attaching to the fluidstack of this fluid. + *

* (Standard unit for potions is 250mb per bottle) */ public static final TagKey POTION = tag("potion"); /** * Holds all fluids related to Suspicious Stew. * The effects of the suspicious stew fluid should be read from {@link net.minecraft.core.component.DataComponents#SUSPICIOUS_STEW_EFFECTS} - * component that people should be attaching to the fluidstack of this fluid.

+ * component that people should be attaching to the fluidstack of this fluid. + *

* (Standard unit for suspicious stew is 250mb per bowl) */ public static final TagKey SUSPICIOUS_STEW = tag("suspicious_stew"); /** - * Holds all fluids related to Mushroom Stew.

+ * Holds all fluids related to Mushroom Stew. + *

* (Standard unit for mushroom stew is 250mb per bowl) */ public static final TagKey MUSHROOM_STEW = tag("mushroom_stew"); /** - * Holds all fluids related to Rabbit Stew.

+ * Holds all fluids related to Rabbit Stew. + *

* (Standard unit for rabbit stew is 250mb per bowl) */ public static final TagKey RABBIT_STEW = tag("rabbit_stew"); /** - * Holds all fluids related to Beetroot Soup.

+ * Holds all fluids related to Beetroot Soup. + *

* (Standard unit for beetroot soup is 250mb per bowl) */ public static final TagKey BEETROOT_SOUP = tag("beetroot_soup"); diff --git a/src/main/java/net/neoforged/neoforge/common/VillagerTradingManager.java b/src/main/java/net/neoforged/neoforge/common/VillagerTradingManager.java index 92a0a16b..6bfebd3b 100644 --- a/src/main/java/net/neoforged/neoforge/common/VillagerTradingManager.java +++ b/src/main/java/net/neoforged/neoforge/common/VillagerTradingManager.java @@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.entity.npc.VillagerProfession; @@ -35,20 +36,20 @@ public class VillagerTradingManager { static void loadTrades(TagsUpdatedEvent e) { if (e.getUpdateCause() == TagsUpdatedEvent.UpdateCause.SERVER_DATA_LOAD) { - postWandererEvent(); - postVillagerEvents(); + postWandererEvent(e.getLookupProvider()); + postVillagerEvents(e.getLookupProvider()); } } /** * Posts the WandererTradesEvent. */ - private static void postWandererEvent() { + private static void postWandererEvent(HolderLookup.Provider registries) { List generic = NonNullList.create(); List rare = NonNullList.create(); Arrays.stream(WANDERER_TRADES.get(1)).forEach(generic::add); Arrays.stream(WANDERER_TRADES.get(2)).forEach(rare::add); - NeoForge.EVENT_BUS.post(new WandererTradesEvent(generic, rare)); + NeoForge.EVENT_BUS.post(new WandererTradesEvent(generic, rare, registries)); VillagerTrades.WANDERING_TRADER_TRADES.put(1, generic.toArray(new ItemListing[0])); VillagerTrades.WANDERING_TRADER_TRADES.put(2, rare.toArray(new ItemListing[0])); } @@ -56,7 +57,7 @@ private static void postWandererEvent() { /** * Posts a VillagerTradesEvent for each registered profession. */ - private static void postVillagerEvents() { + private static void postVillagerEvents(HolderLookup.Provider registries) { for (VillagerProfession prof : BuiltInRegistries.VILLAGER_PROFESSION) { Int2ObjectMap trades = VANILLA_TRADES.getOrDefault(prof, new Int2ObjectOpenHashMap<>()); Int2ObjectMap> mutableTrades = new Int2ObjectOpenHashMap<>(); @@ -66,7 +67,7 @@ private static void postVillagerEvents() { trades.int2ObjectEntrySet().forEach(e -> { Arrays.stream(e.getValue()).forEach(mutableTrades.get(e.getIntKey())::add); }); - NeoForge.EVENT_BUS.post(new VillagerTradesEvent(mutableTrades, prof)); + NeoForge.EVENT_BUS.post(new VillagerTradesEvent(mutableTrades, prof, registries)); Int2ObjectMap newTrades = new Int2ObjectOpenHashMap<>(); mutableTrades.int2ObjectEntrySet().forEach(e -> newTrades.put(e.getIntKey(), e.getValue().toArray(new ItemListing[0]))); VillagerTrades.TRADES.put(prof, newTrades); diff --git a/src/main/java/net/neoforged/neoforge/common/conditions/ConditionContext.java b/src/main/java/net/neoforged/neoforge/common/conditions/ConditionContext.java index 186cbb63..de5b9b5d 100644 --- a/src/main/java/net/neoforged/neoforge/common/conditions/ConditionContext.java +++ b/src/main/java/net/neoforged/neoforge/common/conditions/ConditionContext.java @@ -5,40 +5,32 @@ package net.neoforged.neoforge.common.conditions; -import java.util.Collection; -import java.util.Collections; import java.util.IdentityHashMap; +import java.util.List; import java.util.Map; -import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagManager; -import org.jetbrains.annotations.Nullable; +import net.minecraft.tags.TagKey; public class ConditionContext implements ICondition.IContext { - private final TagManager tagManager; - @Nullable - // TODO 1.20.5: Clear loaded tags after reloads complete. The context object may leak, but we still want to invalidate it. - private Map, Map>>> loadedTags = null; + private final Map>, HolderLookup.RegistryLookup> pendingTags; - public ConditionContext(TagManager tagManager) { - this.tagManager = tagManager; + public ConditionContext(List> pendingTags) { + this.pendingTags = new IdentityHashMap<>(); + for (var tags : pendingTags) { + this.pendingTags.put(tags.key(), tags.lookup()); + } } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public Map>> getAllTags(ResourceKey> registry) { - if (loadedTags == null) { - var tags = tagManager.getResult(); - if (tags.isEmpty()) throw new IllegalStateException("Tags have not been loaded yet."); + public void clear() { + this.pendingTags.clear(); + } - loadedTags = new IdentityHashMap<>(); - for (var loadResult : tags) { - Map>> map = Collections.unmodifiableMap(loadResult.tags()); - loadedTags.put(loadResult.key(), (Map) map); - } - } - return (Map) loadedTags.getOrDefault(registry, Collections.emptyMap()); + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public boolean isTagLoaded(TagKey key) { + var lookup = pendingTags.get(key.registry()); + return lookup != null && lookup.get((TagKey) key).isPresent(); } } diff --git a/src/main/java/net/neoforged/neoforge/common/conditions/ICondition.java b/src/main/java/net/neoforged/neoforge/common/conditions/ICondition.java index 04e0ff5f..1be7e0ce 100644 --- a/src/main/java/net/neoforged/neoforge/common/conditions/ICondition.java +++ b/src/main/java/net/neoforged/neoforge/common/conditions/ICondition.java @@ -12,19 +12,11 @@ import com.mojang.serialization.DynamicOps; import com.mojang.serialization.JsonOps; import com.mojang.serialization.MapCodec; -import java.util.Collection; -import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.function.Function; -import net.minecraft.core.Holder; import net.minecraft.core.HolderLookup; -import net.minecraft.core.Registry; import net.minecraft.resources.RegistryOps; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.util.Unit; import net.neoforged.neoforge.registries.NeoForgeRegistries; @@ -80,32 +72,24 @@ static void writeConditions(DynamicOps jsonOps, JsonObject jsonObje MapCodec codec(); - interface IContext { + interface IContext { // TODO 1.21.2: potentially remove since all the info is available via RegistryOps IContext EMPTY = new IContext() { @Override - public Map>> getAllTags(ResourceKey> registry) { - return Collections.emptyMap(); + public boolean isTagLoaded(TagKey key) { + return false; } }; IContext TAGS_INVALID = new IContext() { @Override - public Map>> getAllTags(ResourceKey> registry) { + public boolean isTagLoaded(TagKey key) { throw new UnsupportedOperationException("Usage of tag-based conditions is not permitted in this context!"); } }; /** - * Return the requested tag if available, or an empty tag otherwise. + * Returns {@code true} if the requested tag is available. */ - default Collection> getTag(TagKey key) { - return getAllTags(key.registry()).getOrDefault(key.location(), Set.of()); - } - - /** - * Return all the loaded tags for the passed registry, or an empty map if none is available. - * Note that the map and the tags are unmodifiable. - */ - Map>> getAllTags(ResourceKey> registry); + boolean isTagLoaded(TagKey key); } } diff --git a/src/main/java/net/neoforged/neoforge/common/conditions/TagEmptyCondition.java b/src/main/java/net/neoforged/neoforge/common/conditions/TagEmptyCondition.java index b7ecc851..6da7798c 100644 --- a/src/main/java/net/neoforged/neoforge/common/conditions/TagEmptyCondition.java +++ b/src/main/java/net/neoforged/neoforge/common/conditions/TagEmptyCondition.java @@ -33,7 +33,7 @@ public TagEmptyCondition(ResourceLocation tag) { @Override public boolean test(ICondition.IContext context) { - return context.getTag(tag).isEmpty(); + return !context.isTagLoaded(tag); } @Override diff --git a/src/main/java/net/neoforged/neoforge/common/crafting/BlockTagIngredient.java b/src/main/java/net/neoforged/neoforge/common/crafting/BlockTagIngredient.java index 4994e805..a99a2f17 100644 --- a/src/main/java/net/neoforged/neoforge/common/crafting/BlockTagIngredient.java +++ b/src/main/java/net/neoforged/neoforge/common/crafting/BlockTagIngredient.java @@ -10,15 +10,16 @@ import java.util.List; import java.util.stream.Stream; import net.minecraft.core.Holder; -import net.minecraft.core.component.DataComponents; +import net.minecraft.core.HolderSet; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; -import net.minecraft.network.chat.Component; import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.display.SlotDisplay; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; import net.neoforged.neoforge.common.NeoForgeMod; import org.jetbrains.annotations.Nullable; @@ -26,7 +27,7 @@ * {@link Ingredient} that matches {@link ItemStack}s of {@link Block}s from a {@link TagKey}, useful in cases * like {@code "minecraft:convertable_to_mud"} where there isn't an accompanying item tag *

- * Notice: This should not be used as a replacement for the normal {@link Ingredient#of(TagKey)}, + * Notice: This should not be used as a replacement for the normal item tag ingredient. * This should only be used when there is no way an item tag can be used in your use case */ public class BlockTagIngredient implements ICustomIngredient { @@ -36,36 +37,30 @@ public class BlockTagIngredient implements ICustomIngredient { protected final TagKey tag; @Nullable - protected ItemStack[] itemStacks; + protected HolderSet items; public BlockTagIngredient(TagKey tag) { this.tag = tag; } - protected void dissolve() { - if (itemStacks == null) { - List list = new ArrayList<>(); + protected HolderSet dissolve() { + if (items == null) { + List> list = new ArrayList<>(); for (Holder block : BuiltInRegistries.BLOCK.getTagOrEmpty(tag)) { - ItemStack stack = new ItemStack(block.value()); - if (!stack.isEmpty()) { - list.add(stack); + var item = block.value().asItem(); + if (item != Items.AIR) { + list.add(item.builtInRegistryHolder()); } } - if (list.isEmpty()) { - ItemStack itemStack = new ItemStack(Blocks.BARRIER); - itemStack.set(DataComponents.CUSTOM_NAME, Component.literal("Empty Tag: " + this.tag.location())); - list.add(itemStack); - } - - itemStacks = list.toArray(ItemStack[]::new); + items = HolderSet.direct(list); } + return items; } @Override - public Stream getItems() { - dissolve(); - return Stream.of(itemStacks); + public Stream> items() { + return dissolve().stream(); } @Override @@ -73,14 +68,7 @@ public boolean test(@Nullable ItemStack stack) { if (stack == null) return false; - dissolve(); - for (ItemStack itemStack : itemStacks) { - if (itemStack.is(stack.getItem())) { - return true; - } - } - - return false; + return dissolve().contains(stack.getItemHolder()); } public TagKey getTag() { @@ -97,6 +85,13 @@ public IngredientType getType() { return NeoForgeMod.BLOCK_TAG_INGREDIENT.get(); } + @Override + public SlotDisplay display() { + return new SlotDisplay.Composite(dissolve().stream() + .map(Ingredient::displayForSingleItem) + .toList()); + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/net/neoforged/neoforge/common/crafting/CompoundIngredient.java b/src/main/java/net/neoforged/neoforge/common/crafting/CompoundIngredient.java index e874d3e8..f7030270 100644 --- a/src/main/java/net/neoforged/neoforge/common/crafting/CompoundIngredient.java +++ b/src/main/java/net/neoforged/neoforge/common/crafting/CompoundIngredient.java @@ -6,11 +6,13 @@ package net.neoforged.neoforge.common.crafting; import com.mojang.serialization.MapCodec; -import java.util.Arrays; import java.util.List; import java.util.stream.Stream; +import net.minecraft.core.Holder; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.display.SlotDisplay; import net.neoforged.neoforge.common.NeoForgeMod; import net.neoforged.neoforge.common.util.NeoForgeExtraCodecs; @@ -20,15 +22,13 @@ public record CompoundIngredient(List children) implements ICustomIn public CompoundIngredient { if (children.isEmpty()) { // Empty ingredients are always represented as Ingredient.EMPTY. - throw new IllegalArgumentException("Compound ingredient must have at least one child"); + throw new IllegalArgumentException("Compound ingredient must have at least one child."); } } - public static final MapCodec CODEC = NeoForgeExtraCodecs.aliasedFieldOf(Ingredient.LIST_CODEC_NONEMPTY, "children", "ingredients").xmap(CompoundIngredient::new, CompoundIngredient::children); + public static final MapCodec CODEC = NeoForgeExtraCodecs.aliasedFieldOf(Ingredient.CODEC.listOf(1, Integer.MAX_VALUE), "children", "ingredients").xmap(CompoundIngredient::new, CompoundIngredient::children); /** Creates a compound ingredient from the given list of ingredients */ public static Ingredient of(Ingredient... children) { - if (children.length == 0) - return Ingredient.EMPTY; if (children.length == 1) return children[0]; @@ -36,8 +36,8 @@ public static Ingredient of(Ingredient... children) { } @Override - public Stream getItems() { - return children.stream().flatMap(child -> Arrays.stream(child.getItems())); + public Stream> items() { + return children.stream().flatMap(child -> child.items().stream()); } @Override @@ -64,4 +64,9 @@ public boolean isSimple() { public IngredientType getType() { return NeoForgeMod.COMPOUND_INGREDIENT_TYPE.get(); } + + @Override + public SlotDisplay display() { + return new SlotDisplay.Composite(children.stream().map(Ingredient::display).toList()); + } } diff --git a/src/main/java/net/neoforged/neoforge/common/crafting/ConditionalRecipeOutput.java b/src/main/java/net/neoforged/neoforge/common/crafting/ConditionalRecipeOutput.java index 3a7321e2..ad522261 100644 --- a/src/main/java/net/neoforged/neoforge/common/crafting/ConditionalRecipeOutput.java +++ b/src/main/java/net/neoforged/neoforge/common/crafting/ConditionalRecipeOutput.java @@ -8,7 +8,7 @@ import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.data.recipes.RecipeOutput; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.crafting.Recipe; import net.neoforged.neoforge.common.conditions.ICondition; import org.apache.commons.lang3.ArrayUtils; @@ -35,7 +35,7 @@ public Advancement.Builder advancement() { } @Override - public void accept(ResourceLocation id, Recipe recipe, @Nullable AdvancementHolder advancement, ICondition... conditions) { + public void accept(ResourceKey> id, Recipe recipe, @Nullable AdvancementHolder advancement, ICondition... conditions) { ICondition[] innerConditions; if (conditions.length == 0) { innerConditions = this.conditions; @@ -46,4 +46,9 @@ public void accept(ResourceLocation id, Recipe recipe, @Nullable AdvancementH } inner.accept(id, recipe, advancement, innerConditions); } + + @Override + public void includeRootAdvancement() { + inner.includeRootAdvancement(); + } } diff --git a/src/main/java/net/neoforged/neoforge/common/crafting/CraftingHelper.java b/src/main/java/net/neoforged/neoforge/common/crafting/CraftingHelper.java deleted file mode 100644 index e89e5480..00000000 --- a/src/main/java/net/neoforged/neoforge/common/crafting/CraftingHelper.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.neoforge.common.crafting; - -import com.mojang.datafixers.util.Either; -import com.mojang.serialization.Codec; -import com.mojang.serialization.DataResult; -import com.mojang.serialization.MapCodec; -import java.util.stream.Stream; -import net.minecraft.world.item.crafting.Ingredient; -import net.neoforged.neoforge.common.util.NeoForgeExtraCodecs; -import net.neoforged.neoforge.registries.NeoForgeRegistries; -import org.jetbrains.annotations.ApiStatus; - -@ApiStatus.Internal -public class CraftingHelper { - public static Codec makeIngredientCodec(boolean allowEmpty) { - var listCodec = Codec.lazyInitialized(() -> allowEmpty ? Ingredient.LIST_CODEC : Ingredient.LIST_CODEC_NONEMPTY); - return Codec.either(listCodec, makeIngredientMapCodec().codec()) - .xmap(either -> either.map(list -> { - // Use CompoundIngredient.of(...) to convert empty ingredients to Ingredient.EMPTY - return CompoundIngredient.of(list.toArray(Ingredient[]::new)); - }, i -> i), ingredient -> { - if (ingredient.isCustom()) { - if (ingredient.getCustomIngredient() instanceof CompoundIngredient compound) { - // Use [] syntax for CompoundIngredients. - return Either.left(compound.children()); - } - } else if (ingredient.getValues().length != 1) { - // Use [] syntax for vanilla ingredients that either 0 or 2+ values. - return Either.left(Stream.of(ingredient.getValues()).map(v -> Ingredient.fromValues(Stream.of(v))).toList()); - } - // Else use {} syntax. - return Either.right(ingredient); - }); - } - - public static MapCodec makeIngredientMapCodec() { - // Dispatch codec for custom ingredient types, else fallback to vanilla ingredient codec. - return NeoForgeExtraCodecs., ICustomIngredient, Ingredient.Value>dispatchMapOrElse( - NeoForgeRegistries.INGREDIENT_TYPES.byNameCodec(), - ICustomIngredient::getType, - IngredientType::codec, - Ingredient.Value.MAP_CODEC) - .xmap(either -> either.map(ICustomIngredient::toVanilla, v -> Ingredient.fromValues(Stream.of(v))), ingredient -> { - if (!ingredient.isCustom()) { - var values = ingredient.getValues(); - if (values.length == 1) { - return Either.right(values[0]); - } - // Convert vanilla ingredients with 2+ values to a CompoundIngredient. Empty ingredients are not allowed here. - return Either.left(new CompoundIngredient(Stream.of(ingredient.getValues()).map(v -> Ingredient.fromValues(Stream.of(v))).toList())); - } - return Either.left(ingredient.getCustomIngredient()); - }) - .validate(ingredient -> { - if (!ingredient.isCustom() && ingredient.getValues().length == 0) { - return DataResult.error(() -> "Cannot serialize empty ingredient using the map codec"); - } - return DataResult.success(ingredient); - }); - } -} diff --git a/src/main/java/net/neoforged/neoforge/common/crafting/CustomDisplayIngredient.java b/src/main/java/net/neoforged/neoforge/common/crafting/CustomDisplayIngredient.java new file mode 100644 index 00000000..2c88c2fa --- /dev/null +++ b/src/main/java/net/neoforged/neoforge/common/crafting/CustomDisplayIngredient.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) NeoForged and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.neoforged.neoforge.common.crafting; + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import java.util.stream.Stream; +import net.minecraft.core.Holder; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.display.SlotDisplay; +import net.neoforged.neoforge.common.NeoForgeMod; + +/** + * Ingredient that wraps another ingredient to override its {@link SlotDisplay}. + */ +public record CustomDisplayIngredient(Ingredient base, SlotDisplay display) implements ICustomIngredient { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( + instance -> instance + .group( + Ingredient.CODEC.fieldOf("base").forGetter(CustomDisplayIngredient::base), + SlotDisplay.CODEC.fieldOf("display").forGetter(CustomDisplayIngredient::display)) + .apply(instance, CustomDisplayIngredient::new)); + + public static Ingredient of(Ingredient base, SlotDisplay display) { + return new CustomDisplayIngredient(base, display).toVanilla(); + } + + @Override + public boolean test(ItemStack stack) { + return base.test(stack); + } + + @Override + public Stream> items() { + return base.items().stream(); + } + + @Override + public boolean isSimple() { + return base.isSimple(); + } + + @Override + public IngredientType getType() { + return NeoForgeMod.CUSTOM_DISPLAY_INGREDIENT.get(); + } +} diff --git a/src/main/java/net/neoforged/neoforge/common/crafting/DataComponentIngredient.java b/src/main/java/net/neoforged/neoforge/common/crafting/DataComponentIngredient.java index 7d8951e7..b83d5c32 100644 --- a/src/main/java/net/neoforged/neoforge/common/crafting/DataComponentIngredient.java +++ b/src/main/java/net/neoforged/neoforge/common/crafting/DataComponentIngredient.java @@ -22,6 +22,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.display.SlotDisplay; import net.minecraft.world.level.ItemLike; import net.neoforged.neoforge.common.NeoForgeMod; @@ -35,7 +36,7 @@ public class DataComponentIngredient implements ICustomIngredient { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( builder -> builder .group( - HolderSetCodec.create(Registries.ITEM, BuiltInRegistries.ITEM.holderByNameCodec(), false).fieldOf("items").forGetter(DataComponentIngredient::items), + HolderSetCodec.create(Registries.ITEM, BuiltInRegistries.ITEM.holderByNameCodec(), false).fieldOf("items").forGetter(DataComponentIngredient::itemSet), DataComponentPredicate.CODEC.fieldOf("components").forGetter(DataComponentIngredient::components), Codec.BOOL.optionalFieldOf("strict", false).forGetter(DataComponentIngredient::isStrict)) .apply(builder, DataComponentIngredient::new)); @@ -67,8 +68,8 @@ public boolean test(ItemStack stack) { } @Override - public Stream getItems() { - return Stream.of(stacks); + public Stream> items() { + return items.stream(); } @Override @@ -81,7 +82,23 @@ public IngredientType getType() { return NeoForgeMod.DATA_COMPONENT_INGREDIENT_TYPE.get(); } - public HolderSet items() { + @Override + public SlotDisplay display() { + return new SlotDisplay.Composite(Stream.of(stacks) + .map(stack -> { + SlotDisplay display = new SlotDisplay.ItemStackSlotDisplay(stack); + ItemStack remainder = stack.getCraftingRemainder(); + if (!remainder.isEmpty()) { + SlotDisplay remainderDisplay = new SlotDisplay.ItemStackSlotDisplay(remainder); + return new SlotDisplay.WithRemainder(display, remainderDisplay); + } else { + return display; + } + }) + .toList()); + } + + public HolderSet itemSet() { return items; } diff --git a/src/main/java/net/neoforged/neoforge/common/crafting/DifferenceIngredient.java b/src/main/java/net/neoforged/neoforge/common/crafting/DifferenceIngredient.java index 2fed470d..3ce8c7d3 100644 --- a/src/main/java/net/neoforged/neoforge/common/crafting/DifferenceIngredient.java +++ b/src/main/java/net/neoforged/neoforge/common/crafting/DifferenceIngredient.java @@ -8,6 +8,8 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import java.util.stream.Stream; +import net.minecraft.core.Holder; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.neoforged.neoforge.common.NeoForgeMod; @@ -22,8 +24,8 @@ public record DifferenceIngredient(Ingredient base, Ingredient subtracted) imple .apply(builder, DifferenceIngredient::new)); @Override - public Stream getItems() { - return Stream.of(base.getItems()).filter(subtracted.negate()); + public Stream> items() { + return base.items().stream().filter(i -> !subtracted.test(i.value().getDefaultInstance())); } @Override diff --git a/src/main/java/net/neoforged/neoforge/common/crafting/ICustomIngredient.java b/src/main/java/net/neoforged/neoforge/common/crafting/ICustomIngredient.java index dc213aee..ee93d08a 100644 --- a/src/main/java/net/neoforged/neoforge/common/crafting/ICustomIngredient.java +++ b/src/main/java/net/neoforged/neoforge/common/crafting/ICustomIngredient.java @@ -6,9 +6,11 @@ package net.neoforged.neoforge.common.crafting; import java.util.stream.Stream; +import net.minecraft.core.Holder; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.display.SlotDisplay; import net.neoforged.neoforge.registries.NeoForgeRegistries; import org.jetbrains.annotations.ApiStatus; @@ -35,21 +37,21 @@ public interface ICustomIngredient { boolean test(ItemStack stack); /** - * {@return the list of stacks that this ingredient accepts} + * {@return the list of items that this ingredient accepts} * *

The following guidelines should be followed for good compatibility: *

    - *
  • These stacks are generally used for display purposes, and need not be exhaustive or perfectly accurate.
  • - *
  • An exception is ingredients that {@linkplain #isSimple() are simple}, - * for which it is important that the returned stacks correspond exactly to all the accepted {@link Item}s.
  • - *
  • At least one stack must be returned for the ingredient not to be considered {@linkplain Ingredient#hasNoItems() accidentally empty}.
  • - *
  • The ingredient should try to return at least one stack with each accepted {@link Item}. + *
  • At least one item must be returned for the ingredient not to be considered empty. Empty ingredients invalidate the entire recipe.
  • + *
  • The ingredient should return all {@link Item}s it might possible accept. * This allows mods that inspect the ingredient to figure out which stacks it might accept.
  • + *
  • Returned items might not always be accepted by the ingredient, as an ingredient might still perform additional NBT-dependent tests.
  • + *
  • An exception is ingredients that {@linkplain #isSimple() are simple}, + * for which {@link #test testing a stack} is equivalent to testing if the item is in the returned list.
  • *
* *

Note: no caching needs to be done by the implementation, this is already handled by the ingredient itself. */ - Stream getItems(); + Stream> items(); /** * Returns whether this ingredient always requires {@linkplain #test direct stack testing}. @@ -66,6 +68,22 @@ public interface ICustomIngredient { */ IngredientType getType(); + /** + * Returns the display for this ingredient. + * + *

The display is synced to the client, and is also used to retrieve the {@link ItemStack}s that are shown to the client. + * + * @implNote The default implementation just constructs a list of stacks from {@link #items()}. + * This is generally suitable for {@link #isSimple() simple} ingredients. + * Non-simple ingredients can either override this method to provide a more customized display, + * or let data pack writers use {@link CustomDisplayIngredient} to override the display of an ingredient. + */ + default SlotDisplay display() { + return new SlotDisplay.Composite(items() + .map(Ingredient::displayForSingleItem) + .toList()); + } + /** * {@return a new {@link Ingredient} behaving as defined by this custom ingredient} */ diff --git a/src/main/java/net/neoforged/neoforge/common/crafting/IngredientCodecs.java b/src/main/java/net/neoforged/neoforge/common/crafting/IngredientCodecs.java new file mode 100644 index 00000000..8f174f98 --- /dev/null +++ b/src/main/java/net/neoforged/neoforge/common/crafting/IngredientCodecs.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.neoforged.neoforge.common.crafting; + +import com.mojang.datafixers.util.Either; +import com.mojang.serialization.Codec; +import java.util.Optional; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.world.item.crafting.Ingredient; +import net.neoforged.neoforge.registries.NeoForgeRegistries; +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.Internal +public class IngredientCodecs { + public static Codec codec(Codec vanillaCodec) { + var customIngredientCodec = NeoForgeRegistries.INGREDIENT_TYPES.byNameCodec().dispatch( + "neoforge:ingredient_type", ICustomIngredient::getType, IngredientType::codec); + return Codec.xor(customIngredientCodec, vanillaCodec) + .xmap( + either -> either.map(ICustomIngredient::toVanilla, i -> i), + ingredient -> { + if (ingredient.isCustom()) { + return Either.left(ingredient.getCustomIngredient()); + } else { + return Either.right(ingredient); + } + }); + } + + private static final int CUSTOM_INGREDIENT_MARKER = -1000; + private static final StreamCodec CUSTOM_INGREDIENT_CODEC = ByteBufCodecs.registry(NeoForgeRegistries.Keys.INGREDIENT_TYPES) + .dispatch(ICustomIngredient::getType, IngredientType::streamCodec); + + public static StreamCodec streamCodec(StreamCodec vanillaCodec) { + return new StreamCodec<>() { + @Override + public Ingredient decode(RegistryFriendlyByteBuf buf) { + var readerIndex = buf.readerIndex(); + var length = buf.readVarInt(); + if (length == CUSTOM_INGREDIENT_MARKER) { + return CUSTOM_INGREDIENT_CODEC.decode(buf).toVanilla(); + } else { + buf.readerIndex(readerIndex); + return vanillaCodec.decode(buf); + } + }; + + @Override + public void encode(RegistryFriendlyByteBuf buf, Ingredient ingredient) { + if (ingredient.isCustom() && buf.getConnectionType().isNeoForge()) { + buf.writeVarInt(CUSTOM_INGREDIENT_MARKER); + CUSTOM_INGREDIENT_CODEC.encode(buf, ingredient.getCustomIngredient()); + } else { + vanillaCodec.encode(buf, ingredient); + } + } + }; + } + + public static StreamCodec> optionalStreamCodec(StreamCodec> vanillaCodec) { + return new StreamCodec<>() { + @Override + public Optional decode(RegistryFriendlyByteBuf buf) { + var readerIndex = buf.readerIndex(); + var length = buf.readVarInt(); + if (length == CUSTOM_INGREDIENT_MARKER) { + return Optional.of(CUSTOM_INGREDIENT_CODEC.decode(buf).toVanilla()); + } else { + buf.readerIndex(readerIndex); + return vanillaCodec.decode(buf); + } + } + + @Override + public void encode(RegistryFriendlyByteBuf buf, Optional ingredient) { + if (ingredient.isPresent() && ingredient.get().isCustom() && buf.getConnectionType().isNeoForge()) { + buf.writeVarInt(CUSTOM_INGREDIENT_MARKER); + CUSTOM_INGREDIENT_CODEC.encode(buf, ingredient.get().getCustomIngredient()); + } else { + vanillaCodec.encode(buf, ingredient); + } + } + }; + } +} diff --git a/src/main/java/net/neoforged/neoforge/common/crafting/IntersectionIngredient.java b/src/main/java/net/neoforged/neoforge/common/crafting/IntersectionIngredient.java index e8830c55..b41dc850 100644 --- a/src/main/java/net/neoforged/neoforge/common/crafting/IntersectionIngredient.java +++ b/src/main/java/net/neoforged/neoforge/common/crafting/IntersectionIngredient.java @@ -10,6 +10,8 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Stream; +import net.minecraft.core.Holder; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.neoforged.neoforge.common.NeoForgeMod; @@ -19,13 +21,13 @@ public record IntersectionIngredient(List children) implements ICust public IntersectionIngredient { if (children.isEmpty()) { - throw new IllegalArgumentException("Cannot create an IntersectionIngredient with no children, use Ingredient.of() to create an empty ingredient"); + throw new IllegalArgumentException("Intersection ingredient must have at least one child."); } } public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( builder -> builder .group( - Ingredient.LIST_CODEC_NONEMPTY.fieldOf("children").forGetter(IntersectionIngredient::children)) + Ingredient.CODEC.listOf(1, Integer.MAX_VALUE).fieldOf("children").forGetter(IntersectionIngredient::children)) .apply(builder, IntersectionIngredient::new)); /** @@ -35,8 +37,6 @@ public record IntersectionIngredient(List children) implements ICust * @return Ingredient that only matches if all the passed ingredients match */ public static Ingredient of(Ingredient... ingredients) { - if (ingredients.length == 0) - throw new IllegalArgumentException("Cannot create an IntersectionIngredient with no children, use Ingredient.of() to create an empty ingredient"); if (ingredients.length == 1) return ingredients[0]; @@ -54,10 +54,10 @@ public boolean test(ItemStack stack) { } @Override - public Stream getItems() { + public Stream> items() { return children.stream() - .flatMap(child -> Arrays.stream(child.getItems())) - .filter(this::test); + .flatMap(child -> child.items().stream()) + .filter(i -> test(i.value().getDefaultInstance())); } @Override diff --git a/src/main/java/net/neoforged/neoforge/common/crafting/SizedIngredient.java b/src/main/java/net/neoforged/neoforge/common/crafting/SizedIngredient.java index a7128865..ec241d7d 100644 --- a/src/main/java/net/neoforged/neoforge/common/crafting/SizedIngredient.java +++ b/src/main/java/net/neoforged/neoforge/common/crafting/SizedIngredient.java @@ -8,18 +8,14 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import java.util.Objects; -import java.util.stream.Stream; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.tags.TagKey; import net.minecraft.util.ExtraCodecs; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.ItemLike; import net.neoforged.neoforge.common.util.NeoForgeExtraCodecs; -import org.jetbrains.annotations.Nullable; /** * Standard implementation for an ingredient and a count. @@ -28,38 +24,6 @@ * and provide a standard serialization format. */ public final class SizedIngredient { - /** - * The "flat" codec for {@link SizedIngredient}. - * - *

The count is serialized inline with the rest of the ingredient, for example: - * - *

{@code
-     * {
-     *     "item": "minecraft:apple",
-     *     "count": 3
-     * }
-     * }
- * - * Array ingredients are serialized using the compound ingredient type: - * - *
{@code
-     * {
-     *     "type": "neoforge:compound",
-     *     "ingredients": [
-     *         { "item": "minecraft:coal" },
-     *         { "item": "minecraft:charcoal" }
-     *     ],
-     *     "count": 2
-     * }
-     * }
- * - * See {@link Ingredient#MAP_CODEC_NONEMPTY} for details of the ingredient serialization. - */ - public static final Codec FLAT_CODEC = RecordCodecBuilder.create(instance -> instance.group( - Ingredient.MAP_CODEC_NONEMPTY.forGetter(SizedIngredient::ingredient), - NeoForgeExtraCodecs.optionalFieldAlwaysWrite(ExtraCodecs.POSITIVE_INT, "count", 1).forGetter(SizedIngredient::count)) - .apply(instance, SizedIngredient::new)); - /** * The "nested" codec for {@link SizedIngredient}. * @@ -67,15 +31,13 @@ public final class SizedIngredient { * *
{@code
      * {
-     *     "ingredient": {
-     *         "item": "minecraft:apple"
-     *     },
+     *     "ingredient": "minecraft:apple",
      *     "count": 3
      * }
      * }
*/ public static final Codec NESTED_CODEC = RecordCodecBuilder.create(instance -> instance.group( - Ingredient.CODEC_NONEMPTY.fieldOf("ingredient").forGetter(SizedIngredient::ingredient), + Ingredient.CODEC.fieldOf("ingredient").forGetter(SizedIngredient::ingredient), NeoForgeExtraCodecs.optionalFieldAlwaysWrite(ExtraCodecs.POSITIVE_INT, "count", 1).forGetter(SizedIngredient::count)) .apply(instance, SizedIngredient::new)); @@ -93,17 +55,8 @@ public static SizedIngredient of(ItemLike item, int count) { return new SizedIngredient(Ingredient.of(item), count); } - /** - * Helper method to create a simple sized ingredient that matches items in a tag. - */ - public static SizedIngredient of(TagKey tag, int count) { - return new SizedIngredient(Ingredient.of(tag), count); - } - private final Ingredient ingredient; private final int count; - @Nullable - private ItemStack[] cachedStacks; public SizedIngredient(Ingredient ingredient, int count) { if (count <= 0) { @@ -130,20 +83,6 @@ public boolean test(ItemStack stack) { return ingredient.test(stack) && stack.getCount() >= count; } - /** - * Returns a list of the stacks from this {@link #ingredient}, with an updated {@link #count}. - * - * @implNote the array is cached and should not be modified, just like {@link Ingredient#getItems()}. - */ - public ItemStack[] getItems() { - if (cachedStacks == null) { - cachedStacks = Stream.of(ingredient.getItems()) - .map(s -> s.copyWithCount(count)) - .toArray(ItemStack[]::new); - } - return cachedStacks; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java b/src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java index feb26716..4c325590 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java @@ -60,9 +60,9 @@ protected DataMapProvider(PackOutput packOutput, CompletableFuture run(CachedOutput cache) { - gather(); - return lookupProvider.thenCompose(provider -> { + gather(provider); + final DynamicOps dynamicOps = RegistryOps.create(JsonOps.INSTANCE, provider); return CompletableFuture.allOf(this.builders.entrySet().stream().map(entry -> { @@ -83,7 +83,7 @@ private CompletableFuture generate(Path out, CachedOutput cache, Build /** * Generate data map entries. */ - protected abstract void gather(); + protected abstract void gather(HolderLookup.Provider provider); @SuppressWarnings("unchecked") public Builder builder(DataMapType type) { diff --git a/src/main/java/net/neoforged/neoforge/common/data/LanguageProvider.java b/src/main/java/net/neoforged/neoforge/common/data/LanguageProvider.java index c7a64d64..196484b1 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/LanguageProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/LanguageProvider.java @@ -83,7 +83,7 @@ public void addItemStack(Supplier key, String name) { } public void add(ItemStack key, String name) { - add(key.getDescriptionId(), name); + add(key.getItem().getDescriptionId(), name); } /* diff --git a/src/main/java/net/neoforged/neoforge/common/data/SoundDefinitionsProvider.java b/src/main/java/net/neoforged/neoforge/common/data/SoundDefinitionsProvider.java index d71360a9..fba916e8 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/SoundDefinitionsProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/SoundDefinitionsProvider.java @@ -145,7 +145,7 @@ protected void add(final Supplier soundEvent, final SoundDefinition * @param definition The {@link SoundDefinition} that defines the given event. */ protected void add(final SoundEvent soundEvent, final SoundDefinition definition) { - this.add(soundEvent.getLocation(), definition); + this.add(soundEvent.location(), definition); } /** diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java index e5fec339..55477b72 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java @@ -9,6 +9,7 @@ import com.google.gson.JsonObject; import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; +import com.mojang.serialization.DynamicOps; import com.mojang.serialization.JsonOps; import java.util.ArrayList; import java.util.List; @@ -18,6 +19,7 @@ import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.UnaryOperator; +import java.util.stream.Stream; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.Criterion; @@ -30,12 +32,18 @@ import net.minecraft.advancements.critereon.PlayerInteractTrigger; import net.minecraft.advancements.critereon.SimpleCriterionTrigger; import net.minecraft.core.HolderLookup; +import net.minecraft.core.HolderOwner; import net.minecraft.core.HolderSet; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; import net.minecraft.data.advancements.AdvancementSubProvider; import net.minecraft.data.advancements.packs.VanillaAdvancementProvider; import net.minecraft.data.advancements.packs.VanillaHusbandryAdvancements; import net.minecraft.resources.RegistryOps; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.ItemTags; +import net.minecraft.tags.TagKey; import net.minecraft.world.entity.monster.piglin.PiglinAi; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; @@ -66,14 +74,14 @@ private static List getVanillaAdvancementProviders(PackOut criteriaReplacers.add(replaceInteractCriteria(ItemPredicate.Builder.item().withSubPredicate(ItemAbilityPredicate.TYPE, new ItemAbilityPredicate(ItemAbilities.SHEARS_REMOVE_ARMOR)).build(), Items.SHEARS)); criteriaReplacers.add(replaceInteractCriteria(ItemPredicate.Builder.item().withSubPredicate(PiglinCurrencyItemPredicate.TYPE, PiglinCurrencyItemPredicate.INSTANCE).build(), PiglinAi.BARTERING_ITEM)); criteriaReplacers.add(replaceWearingPredicate(PiglinNeutralArmorEntityPredicate.INSTANCE, predicate -> { - if (predicate.head().filter(item -> predicateMatches(item, Items.GOLDEN_HELMET)).isPresent()) { + if (predicate.head().filter(item -> predicateMatches(item, ItemTags.PIGLIN_SAFE_ARMOR)).isPresent()) { return true; - } else if (predicate.chest().filter(item -> predicateMatches(item, Items.GOLDEN_CHESTPLATE)).isPresent()) { + } else if (predicate.chest().filter(item -> predicateMatches(item, ItemTags.PIGLIN_SAFE_ARMOR)).isPresent()) { return true; - } else if (predicate.legs().filter(item -> predicateMatches(item, Items.GOLDEN_LEGGINGS)).isPresent()) { + } else if (predicate.legs().filter(item -> predicateMatches(item, ItemTags.PIGLIN_SAFE_ARMOR)).isPresent()) { return true; } - return predicate.feet().filter(item -> predicateMatches(item, Items.GOLDEN_BOOTS)).isPresent(); + return predicate.feet().filter(item -> predicateMatches(item, ItemTags.PIGLIN_SAFE_ARMOR)).isPresent(); })); //Walk on powdered snow criteriaReplacers.add(replaceWearingPredicate(SnowBootsEntityPredicate.INSTANCE, predicate -> predicate.feet().filter(item -> predicateMatches(item, Items.LEATHER_BOOTS)).isPresent())); @@ -127,6 +135,13 @@ private static boolean predicateMatches(ItemPredicate predicate, ItemLike... tar return true; } + private static boolean predicateMatches(ItemPredicate predicate, TagKey tagKey) { + return predicate.items().orElse(HolderSet.empty()) + .unwrapKey() + .map(k -> k == tagKey) + .orElse(false); + } + private static BiFunction, HolderLookup.Provider, Criterion> replaceWearingPredicate(EntitySubPredicate subPredicate, Predicate shouldReplace) { return replacePlayerPredicate(condition -> { boolean invert = false; @@ -235,8 +250,53 @@ private static T getPrivateValue(Class clazz, @Nullable C inst, String private record NeoForgeAdvancementGenerator(AdvancementSubProvider vanillaProvider, List, HolderLookup.Provider, Criterion>> criteriaReplacers) implements AdvancementGenerator { @Override public void generate(HolderLookup.Provider registries, Consumer saver, ExistingFileHelper existingFileHelper) { - vanillaProvider.generate(registries, advancementHolder -> { - Advancement.Builder newBuilder = findAndReplaceInHolder(advancementHolder, registries); + // Warning: ugly code here. + // Wrap the registries to allow using any tag. This is used to make decoding using the codec work in `replacePlayerPredicate`. + var registriesWithAnyTag = new HolderLookup.Provider() { + @Override + public Stream>> listRegistryKeys() { + return registries.listRegistryKeys(); + } + + @Override + public Optional> lookup(ResourceKey> p_256285_) { + return registries.lookup(p_256285_); + } + + @Override + public RegistryOps createSerializationContext(DynamicOps p_326817_) { + return RegistryOps.create(p_326817_, new RegistryOps.RegistryInfoLookup() { + @Override + public Optional> lookup(ResourceKey> registry) { + var builtInRegistry = (Registry) BuiltInRegistries.REGISTRY.getValue(registry.location()); + return registries.lookup(registry) + // Need to pass the builtin registry as the holder owner to make deserialization work! + .map(lookup -> new RegistryOps.RegistryInfo<>(builtInRegistry, new HolderLookup.RegistryLookup.Delegate<>() { + @Override + public RegistryLookup parent() { + return lookup; + } + + @Override + public boolean canSerializeIn(HolderOwner p_255875_) { + return parent().canSerializeIn(p_255875_); + } + + @Override + public Optional> get(TagKey tagKey) { + var ret = Delegate.super.get(tagKey); + if (ret.isEmpty()) { + ret = Optional.of(HolderSet.emptyNamed(lookup, tagKey)); + } + return ret; + } + }, lookup.registryLifecycle())); + } + }); + } + }; + vanillaProvider.generate(registriesWithAnyTag, advancementHolder -> { + Advancement.Builder newBuilder = findAndReplaceInHolder(advancementHolder, registriesWithAnyTag); if (newBuilder != null) { newBuilder.save(saver, advancementHolder.id(), existingFileHelper); } diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeBlockTagsProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeBlockTagsProvider.java index 71da6a58..a1959d5a 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeBlockTagsProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeBlockTagsProvider.java @@ -80,7 +80,9 @@ public void addTags(HolderLookup.Provider p_256380_) { tag(Tags.Blocks.SKULLS).add(Blocks.SKELETON_SKULL, Blocks.SKELETON_WALL_SKULL, Blocks.WITHER_SKELETON_SKULL, Blocks.WITHER_SKELETON_WALL_SKULL, Blocks.PLAYER_HEAD, Blocks.PLAYER_WALL_HEAD, Blocks.ZOMBIE_HEAD, Blocks.ZOMBIE_WALL_HEAD, Blocks.CREEPER_HEAD, Blocks.CREEPER_WALL_HEAD, Blocks.PIGLIN_HEAD, Blocks.PIGLIN_WALL_HEAD, Blocks.DRAGON_HEAD, Blocks.DRAGON_WALL_HEAD); tag(Tags.Blocks.HIDDEN_FROM_RECIPE_VIEWERS); tag(Tags.Blocks.NETHERRACKS).add(Blocks.NETHERRACK); - tag(Tags.Blocks.OBSIDIANS).add(Blocks.OBSIDIAN); + tag(Tags.Blocks.OBSIDIANS_NORMAL).add(Blocks.OBSIDIAN); + tag(Tags.Blocks.OBSIDIANS_CRYING).add(Blocks.CRYING_OBSIDIAN); + tag(Tags.Blocks.OBSIDIANS).addTags(Tags.Blocks.OBSIDIANS_NORMAL, Tags.Blocks.OBSIDIANS_CRYING); tag(Tags.Blocks.ORE_BEARING_GROUND_DEEPSLATE).add(Blocks.DEEPSLATE); tag(Tags.Blocks.ORE_BEARING_GROUND_NETHERRACK).add(Blocks.NETHERRACK); tag(Tags.Blocks.ORE_BEARING_GROUND_STONE).add(Blocks.STONE); @@ -142,6 +144,14 @@ public void addTags(HolderLookup.Provider p_256380_) { tag(Tags.Blocks.STORAGE_BLOCKS_REDSTONE).add(Blocks.REDSTONE_BLOCK); tag(Tags.Blocks.STORAGE_BLOCKS_SLIME).add(Blocks.SLIME_BLOCK); tag(Tags.Blocks.STORAGE_BLOCKS_WHEAT).add(Blocks.HAY_BLOCK); + tag(Tags.Blocks.STRIPPED_LOGS).add( + Blocks.STRIPPED_ACACIA_LOG, Blocks.STRIPPED_BAMBOO_BLOCK, Blocks.STRIPPED_BIRCH_LOG, + Blocks.STRIPPED_CHERRY_LOG, Blocks.STRIPPED_DARK_OAK_LOG, Blocks.STRIPPED_JUNGLE_LOG, + Blocks.STRIPPED_MANGROVE_LOG, Blocks.STRIPPED_OAK_LOG, Blocks.STRIPPED_SPRUCE_LOG); + tag(Tags.Blocks.STRIPPED_WOODS).add( + Blocks.STRIPPED_ACACIA_WOOD, Blocks.STRIPPED_BIRCH_WOOD, Blocks.STRIPPED_CHERRY_WOOD, + Blocks.STRIPPED_DARK_OAK_WOOD, Blocks.STRIPPED_JUNGLE_WOOD, Blocks.STRIPPED_MANGROVE_WOOD, + Blocks.STRIPPED_OAK_WOOD, Blocks.STRIPPED_SPRUCE_WOOD); tag(Tags.Blocks.VILLAGER_JOB_SITES).add( Blocks.BARREL, Blocks.BLAST_FURNACE, Blocks.BREWING_STAND, Blocks.CARTOGRAPHY_TABLE, Blocks.CAULDRON, Blocks.WATER_CAULDRON, Blocks.LAVA_CAULDRON, Blocks.POWDER_SNOW_CAULDRON, @@ -284,7 +294,7 @@ private void addColored(TagKey group, String pattern) { for (DyeColor color : DyeColor.values()) { ResourceLocation key = ResourceLocation.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); TagKey tag = getForgeTag(prefix + color.getName()); - Block block = BuiltInRegistries.BLOCK.get(key); + Block block = BuiltInRegistries.BLOCK.getValue(key); if (block == null || block == Blocks.AIR) throw new IllegalStateException("Unknown vanilla block: " + key); tag(tag).add(block); diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java index 9e5604aa..1dd3b1d0 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java @@ -17,18 +17,21 @@ import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceKey; import net.minecraft.sounds.SoundEvent; -import net.minecraft.tags.ItemTags; +import net.minecraft.tags.TagKey; import net.minecraft.util.random.Weight; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.ai.behavior.GiveGiftToHero; import net.minecraft.world.entity.ai.behavior.WorkAtComposter; import net.minecraft.world.entity.animal.Parrot; import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.item.HoneycombItem; import net.minecraft.world.item.Item; +import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.ComposterBlock; import net.minecraft.world.level.block.WeatheringCopper; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; +import net.minecraft.world.level.block.entity.FuelValues; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.gameevent.vibrations.VibrationSystem; import net.minecraft.world.level.levelgen.feature.MonsterRoomFeature; @@ -51,16 +54,13 @@ public NeoForgeDataMapsProvider(PackOutput packOutput, CompletableFuture villagerCompostables = ObfuscationReflectionHelper.getPrivateValue(WorkAtComposter.class, null, "COMPOSTABLE_ITEMS"); ComposterBlock.COMPOSTABLES.forEach((item, chance) -> compostables.add(item.asItem().builtInRegistryHolder(), new Compostable(chance, villagerCompostables.contains(item.asItem())), false)); final var fuels = builder(NeoForgeDataMaps.FURNACE_FUELS); - AbstractFurnaceBlockEntity.buildFuels((value, time) -> value.ifLeft(item -> fuels.add(item.builtInRegistryHolder(), new FurnaceFuel(time), false)) - .ifRight(tag -> fuels.add(tag, new FurnaceFuel(time), false))); - // Mojang decided to use an exclusion tag for nether wood - fuels.remove(ItemTags.NON_FLAMMABLE_WOOD); + FuelValues.vanillaBurnTimes(new FuelValuesDataMapBuilder(provider, fuels), AbstractFurnaceBlockEntity.BURN_TIME_STANDARD); final var vibrationFrequencies = builder(NeoForgeDataMaps.VIBRATION_FREQUENCIES); ((Reference2IntMap>) VibrationSystem.VIBRATION_FREQUENCY_FOR_EVENT) @@ -89,4 +89,31 @@ protected void gather() { waxables.add(now.builtInRegistryHolder(), new Waxable(after), false); }); } + + private static class FuelValuesDataMapBuilder extends FuelValues.Builder { + private final Builder builder; + + public FuelValuesDataMapBuilder(HolderLookup.Provider lookupProvider, DataMapProvider.Builder builder) { + super(lookupProvider, FeatureFlags.DEFAULT_FLAGS); + this.builder = builder; + } + + @Override + public FuelValuesDataMapBuilder add(TagKey tagKey, int burnTime) { + this.builder.add(tagKey, new FurnaceFuel(burnTime), false); + return this; + } + + @Override + public FuelValuesDataMapBuilder add(ItemLike item, int burnTime) { + this.builder.add(item.asItem().builtInRegistryHolder(), new FurnaceFuel(burnTime), false); + return this; + } + + @Override + public FuelValuesDataMapBuilder remove(TagKey tagKey) { + this.builder.remove(tagKey); + return this; + } + } } diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeEntityTypeTagsProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeEntityTypeTagsProvider.java index 16a951be..e12f911f 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeEntityTypeTagsProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeEntityTypeTagsProvider.java @@ -10,6 +10,7 @@ import net.minecraft.data.PackOutput; import net.minecraft.data.tags.EntityTypeTagsProvider; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.EntityTypeTags; import net.minecraft.world.entity.EntityType; import net.neoforged.neoforge.common.Tags; import net.neoforged.neoforge.common.data.ExistingFileHelper; @@ -23,7 +24,17 @@ public NeoForgeEntityTypeTagsProvider(PackOutput output, CompletableFuture group, String pattern) { for (DyeColor color : DyeColor.values()) { ResourceLocation key = ResourceLocation.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); TagKey tag = getForgeItemTag(prefix + color.getName()); - Item item = BuiltInRegistries.ITEM.get(key); + Item item = BuiltInRegistries.ITEM.getValue(key); if (item == null || item == Items.AIR) throw new IllegalStateException("Unknown vanilla item: " + key); tag(tag).add(item); diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLanguageProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLanguageProvider.java index bb2a30e4..f764016f 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLanguageProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLanguageProvider.java @@ -69,6 +69,8 @@ protected void addTranslations() { add(Tags.Blocks.NEEDS_GOLD_TOOL, "Needs Gold Tools"); add(Tags.Blocks.NEEDS_NETHERITE_TOOL, "Needs Netherite Tools"); add(Tags.Blocks.OBSIDIANS, "Obsidians"); + add(Tags.Blocks.OBSIDIANS_NORMAL, "Normal Obsidians"); + add(Tags.Blocks.OBSIDIANS_CRYING, "Crying Obsidians"); add(Tags.Blocks.ORE_BEARING_GROUND_DEEPSLATE, "Deepslate Ore Bearing Ground"); add(Tags.Blocks.ORE_BEARING_GROUND_NETHERRACK, "Netherrack Ore Bearing Ground"); add(Tags.Blocks.ORE_BEARING_GROUND_STONE, "Stone Ore Bearing Ground"); @@ -123,6 +125,8 @@ protected void addTranslations() { add(Tags.Blocks.STORAGE_BLOCKS_REDSTONE, "Redstone Storage Blocks"); add(Tags.Blocks.STORAGE_BLOCKS_SLIME, "Slime Storage Blocks"); add(Tags.Blocks.STORAGE_BLOCKS_WHEAT, "Wheat Storage Blocks"); + add(Tags.Blocks.STRIPPED_LOGS, "Stripped Logs"); + add(Tags.Blocks.STRIPPED_WOODS, "Stripped Woods"); add(Tags.Blocks.VILLAGER_JOB_SITES, "Villager Job Sites"); add(Tags.Blocks.VILLAGER_FARMLANDS, "Villager Farmlands"); @@ -204,6 +208,7 @@ protected void addTranslations() { add(Tags.Items.FOODS_BERRY, "Berries"); add(Tags.Items.FOODS_BREAD, "Breads"); add(Tags.Items.FOODS_CANDY, "Candies"); + add(Tags.Items.FOODS_PIE, "Pies"); add(Tags.Items.FOODS_COOKED_FISH, "Cooked Fishes"); add(Tags.Items.FOODS_COOKED_MEAT, "Cooked Meats"); add(Tags.Items.FOODS_COOKIE, "Cookies"); @@ -247,6 +252,8 @@ protected void addTranslations() { add(Tags.Items.NUGGETS_IRON, "Iron Nuggets"); add(Tags.Items.NUGGETS_GOLD, "Gold Nuggets"); add(Tags.Items.OBSIDIANS, "Obsidians"); + add(Tags.Items.OBSIDIANS_NORMAL, "Normal Obsidians"); + add(Tags.Items.OBSIDIANS_CRYING, "Crying Obsidians"); add(Tags.Items.ORE_BEARING_GROUND_DEEPSLATE, "Deepslate Ore Bearing Ground"); add(Tags.Items.ORE_BEARING_GROUND_NETHERRACK, "Netherrack Ore Bearing Ground"); add(Tags.Items.ORE_BEARING_GROUND_STONE, "Stone Ore Bearing Ground"); @@ -317,6 +324,8 @@ protected void addTranslations() { add(Tags.Items.STORAGE_BLOCKS_SLIME, "Slime Storage Blocks"); add(Tags.Items.STORAGE_BLOCKS_WHEAT, "Wheat Storage Blocks"); add(Tags.Items.STRINGS, "Strings"); + add(Tags.Items.STRIPPED_LOGS, "Stripped Log Blocks"); + add(Tags.Items.STRIPPED_WOODS, "Stripped Wood Blocks"); add(Tags.Items.VILLAGER_JOB_SITES, "Villager Job Sites"); add(Tags.Items.TOOLS_SHEAR, "Shears"); add(Tags.Items.TOOLS_SHIELD, "Shields"); @@ -340,6 +349,7 @@ protected void addTranslations() { add(Tags.Fluids.MILK, "Milk"); add(Tags.Fluids.GASEOUS, "Gaseous"); add(Tags.Fluids.HONEY, "Honey"); + add(Tags.Fluids.EXPERIENCE, "Experience"); add(Tags.Fluids.POTION, "Potion"); add(Tags.Fluids.SUSPICIOUS_STEW, "Suspicious Stew"); add(Tags.Fluids.MUSHROOM_STEW, "Mushroom Stew"); diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java index cfbefe02..7a1394c4 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java @@ -5,7 +5,6 @@ package net.neoforged.neoforge.common.data.internal; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -15,21 +14,20 @@ import java.util.concurrent.CompletableFuture; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementHolder; +import net.minecraft.core.HolderGetter; import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.data.CachedOutput; +import net.minecraft.core.registries.Registries; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; +import net.minecraft.data.recipes.RecipeProvider; import net.minecraft.data.recipes.packs.VanillaRecipeProvider; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.Ingredient.ItemValue; -import net.minecraft.world.item.crafting.Ingredient.TagValue; -import net.minecraft.world.item.crafting.Ingredient.Value; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraft.world.item.crafting.ShapedRecipePattern; @@ -43,28 +41,27 @@ import org.jetbrains.annotations.Nullable; public final class NeoForgeRecipeProvider extends VanillaRecipeProvider { - private final Map> replacements = new HashMap<>(); - private final Map specialReplacements = new HashMap<>(); - private final Set excludes = new HashSet<>(); + private final InterceptingRecipeOutput output; - public NeoForgeRecipeProvider(PackOutput packOutput, CompletableFuture provider) { - super(packOutput, provider); + private NeoForgeRecipeProvider(HolderLookup.Provider provider, InterceptingRecipeOutput output) { + super(provider, output); + this.output = output; } private void exclude(ItemLike item) { - excludes.add(BuiltInRegistries.ITEM.getKey(item.asItem())); + output.excludes.add(ResourceKey.create(Registries.RECIPE, BuiltInRegistries.ITEM.getKey(item.asItem()))); } private void exclude(String name) { - excludes.add(ResourceLocation.parse(name)); + output.excludes.add(ResourceKey.create(Registries.RECIPE, ResourceLocation.parse(name))); } private void replace(ItemLike item, TagKey tag) { - replacements.put(item.asItem(), tag); + output.replacements.put(item.asItem(), tag); } @Override - protected void buildRecipes(RecipeOutput recipeOutput) { + protected void buildRecipes() { replace(Items.STICK, Tags.Items.RODS_WOODEN); replace(Items.GOLD_INGOT, Tags.Items.INGOTS_GOLD); replace(Items.GOLD_NUGGET, Tags.Items.NUGGETS_GOLD); @@ -76,6 +73,23 @@ protected void buildRecipes(RecipeOutput recipeOutput) { replace(Items.DIAMOND, Tags.Items.GEMS_DIAMOND); replace(Items.EMERALD, Tags.Items.GEMS_EMERALD); + replace(Items.WHITE_DYE, Tags.Items.DYES_WHITE); + replace(Items.ORANGE_DYE, Tags.Items.DYES_ORANGE); + replace(Items.MAGENTA_DYE, Tags.Items.DYES_MAGENTA); + replace(Items.LIGHT_BLUE_DYE, Tags.Items.DYES_LIGHT_BLUE); + replace(Items.YELLOW_DYE, Tags.Items.DYES_YELLOW); + replace(Items.LIME_DYE, Tags.Items.DYES_LIME); + replace(Items.PINK_DYE, Tags.Items.DYES_PINK); + replace(Items.GRAY_DYE, Tags.Items.DYES_GRAY); + replace(Items.LIGHT_GRAY_DYE, Tags.Items.DYES_LIGHT_GRAY); + replace(Items.CYAN_DYE, Tags.Items.DYES_CYAN); + replace(Items.PURPLE_DYE, Tags.Items.DYES_PURPLE); + replace(Items.BLUE_DYE, Tags.Items.DYES_BLUE); + replace(Items.BROWN_DYE, Tags.Items.DYES_BROWN); + replace(Items.GREEN_DYE, Tags.Items.DYES_GREEN); + replace(Items.RED_DYE, Tags.Items.DYES_RED); + replace(Items.BLACK_DYE, Tags.Items.DYES_BLACK); + replace(Blocks.COBBLESTONE, Tags.Items.COBBLESTONES_NORMAL); replace(Blocks.COBBLED_DEEPSLATE, Tags.Items.COBBLESTONES_DEEPSLATE); @@ -99,97 +113,123 @@ protected void buildRecipes(RecipeOutput recipeOutput) { exclude(Blocks.COBBLED_DEEPSLATE_SLAB); exclude(Blocks.COBBLED_DEEPSLATE_WALL); - specialReplacements.put(Items.CHEST, DifferenceIngredient.of(Ingredient.of(Tags.Items.CHESTS_WOODEN), Ingredient.of(Tags.Items.CHESTS_TRAPPED))); - - super.buildRecipes(new RecipeOutput() { - @Override - public void accept(ResourceLocation id, Recipe recipe, @Nullable AdvancementHolder advancement, ICondition... conditions) { - Recipe modified = enhance(id, recipe); - if (modified != null) - recipeOutput.accept(id, modified, null, conditions); - } + output.specialReplacements.put(Items.CHEST, DifferenceIngredient.of(tag(Tags.Items.CHESTS_WOODEN), tag(Tags.Items.CHESTS_TRAPPED))); - @Override - public Advancement.Builder advancement() { - return recipeOutput.advancement(); - } - }); + super.buildRecipes(); } - @Nullable - private Recipe enhance(ResourceLocation id, Recipe vanilla) { - if (vanilla instanceof ShapelessRecipe shapeless) - return enhance(id, shapeless); - if (vanilla instanceof ShapedRecipe shaped) - return enhance(id, shaped); - return null; - } + private static class InterceptingRecipeOutput implements RecipeOutput { + private final HolderGetter items; + private final RecipeOutput output; + private final Map> replacements = new HashMap<>(); + private final Map specialReplacements = new HashMap<>(); + private final Set>> excludes = new HashSet<>(); - @Nullable - private ShapelessRecipe enhance(ResourceLocation id, ShapelessRecipe vanilla) { - List ingredients = vanilla.getIngredients(); - boolean modified = false; - for (int x = 0; x < ingredients.size(); x++) { - Ingredient ing = enhance(id, ingredients.get(x)); - if (ing != null) { - ingredients.set(x, ing); - modified = true; - } + private InterceptingRecipeOutput(HolderGetter items, RecipeOutput output) { + this.items = items; + this.output = output; } - return modified ? vanilla : null; - } - @Override - protected CompletableFuture buildAdvancement(CachedOutput p_253674_, HolderLookup.Provider p_323646_, AdvancementHolder p_301116_) { - // NOOP - We don't replace any of the advancement things yet... - return CompletableFuture.allOf(); - } + @Override + public Advancement.Builder advancement() { + return output.advancement(); + } - @Nullable - private ShapedRecipe enhance(ResourceLocation id, ShapedRecipe vanilla) { - ShapedRecipePattern pattern = ObfuscationReflectionHelper.getPrivateValue(ShapedRecipe.class, vanilla, "pattern"); - if (pattern == null) throw new IllegalStateException(ShapedRecipe.class.getName() + " has no field pattern"); - ShapedRecipePattern.Data data = ((Optional) ObfuscationReflectionHelper.getPrivateValue(ShapedRecipePattern.class, pattern, "data")).orElseThrow(() -> new IllegalArgumentException("recipe " + id + " does not have pattern data")); - Map ingredients = data.key(); - boolean modified = false; - for (Character x : ingredients.keySet()) { - Ingredient ing = enhance(id, ingredients.get(x)); - if (ing != null) { - ingredients.put(x, ing); - modified = true; - } + @Override + public void includeRootAdvancement() { + // Let's not + } + + @Override + public void accept(ResourceKey> id, Recipe recipe, @Nullable AdvancementHolder advancement, ICondition... conditions) { + Recipe modified = enhance(id, recipe); + if (modified != null) + output.accept(id, modified, null, conditions); } - return modified ? vanilla : null; - } - @Nullable - private Ingredient enhance(ResourceLocation name, Ingredient vanilla) { - if (excludes.contains(name)) + @Nullable + private Recipe enhance(ResourceKey> id, Recipe vanilla) { + if (vanilla instanceof ShapelessRecipe shapeless) + return enhance(id, shapeless); + if (vanilla instanceof ShapedRecipe shaped) + return enhance(id, shaped); return null; + } - boolean modified = false; - List items = new ArrayList<>(); - Value[] vanillaItems = vanilla.getValues(); - if (vanillaItems.length == 1 && vanillaItems[0] instanceof ItemValue itemValue) { - Item item = itemValue.item().getItem(); - Ingredient replacement = specialReplacements.get(item); - if (replacement != null) { - return replacement; + @Nullable + private ShapelessRecipe enhance(ResourceKey> id, ShapelessRecipe vanilla) { + List ingredients = ObfuscationReflectionHelper.getPrivateValue(ShapelessRecipe.class, vanilla, "ingredients"); + boolean modified = false; + for (int x = 0; x < ingredients.size(); x++) { + Ingredient ing = enhance(id, ingredients.get(x)); + if (ing != null) { + ingredients.set(x, ing); + modified = true; + } } + return modified ? vanilla : null; } - for (Value entry : vanillaItems) { - if (entry instanceof ItemValue) { - ItemStack stack = entry.getItems().stream().findFirst().orElse(ItemStack.EMPTY); - TagKey replacement = replacements.get(stack.getItem()); - if (replacement != null) { - items.add(new TagValue(replacement)); + @Nullable + private ShapedRecipe enhance(ResourceKey> id, ShapedRecipe vanilla) { + ShapedRecipePattern pattern = ObfuscationReflectionHelper.getPrivateValue(ShapedRecipe.class, vanilla, "pattern"); + if (pattern == null) throw new IllegalStateException(ShapedRecipe.class.getName() + " has no field pattern"); + ShapedRecipePattern.Data data = ((Optional) ObfuscationReflectionHelper.getPrivateValue(ShapedRecipePattern.class, pattern, "data")).orElseThrow(() -> new IllegalArgumentException("recipe " + id + " does not have pattern data")); + Map ingredients = data.key(); + boolean modified = false; + for (Character x : ingredients.keySet()) { + Ingredient ing = enhance(id, ingredients.get(x)); + if (ing != null) { + ingredients.put(x, ing); modified = true; - } else - items.add(entry); - } else - items.add(entry); + } + } + return modified ? vanilla : null; + } + + @Nullable + private Ingredient enhance(ResourceKey> name, Ingredient vanilla) { + if (excludes.contains(name)) + return null; + + return vanilla.getValues().unwrap().map( + tagKey -> null, + items -> { + if (items.size() == 1) { + var specialReplacement = specialReplacements.get(items.getFirst().value()); + if (specialReplacement != null) { + return specialReplacement; + } + + var replacement = replacements.get(items.getFirst().value()); + if (replacement != null) { + return Ingredient.of(this.items.getOrThrow(replacement)); + } + } + + for (var holder : items) { + if (replacements.containsKey(holder.value())) { + throw new IllegalArgumentException("Cannot replace '%s' which is part of a multi-item ingredient.".formatted(holder.value())); + } + } + return null; + }); + } + } + + public static final class Runner extends RecipeProvider.Runner { + public Runner(PackOutput output, CompletableFuture lookupProvider) { + super(output, lookupProvider); + } + + @Override + protected RecipeProvider createRecipeProvider(HolderLookup.Provider lookupProvider, RecipeOutput output) { + return new NeoForgeRecipeProvider(lookupProvider, new InterceptingRecipeOutput(lookupProvider.lookupOrThrow(Registries.ITEM), output)); + } + + @Override + public String getName() { + return "NeoForge recipes"; } - return modified ? Ingredient.fromValues(items.stream()) : null; } } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBoatExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IAbstractBoatExtension.java similarity index 83% rename from src/main/java/net/neoforged/neoforge/common/extensions/IBoatExtension.java rename to src/main/java/net/neoforged/neoforge/common/extensions/IAbstractBoatExtension.java index f3b90e39..b7b896d1 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBoatExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IAbstractBoatExtension.java @@ -5,13 +5,13 @@ package net.neoforged.neoforge.common.extensions; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.AbstractBoat; import net.minecraft.world.level.material.FluidState; import net.neoforged.neoforge.fluids.FluidType; -public interface IBoatExtension { - private Boat self() { - return (Boat) this; +public interface IAbstractBoatExtension { + private AbstractBoat self() { + return (AbstractBoat) this; } /** diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IAbstractMinecartExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IAbstractMinecartExtension.java deleted file mode 100644 index fa1f2f36..00000000 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IAbstractMinecartExtension.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.neoforge.common.extensions; - -import net.minecraft.core.BlockPos; -import net.minecraft.tags.BlockTags; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.vehicle.AbstractMinecart; - -public interface IAbstractMinecartExtension { - public static float DEFAULT_MAX_SPEED_AIR_LATERAL = 0.4f; - public static float DEFAULT_MAX_SPEED_AIR_VERTICAL = -1.0f; - public static double DEFAULT_AIR_DRAG = 0.95f; - - private AbstractMinecart self() { - return (AbstractMinecart) this; - } - - /** - * Internal, returns the current spot to look for the attached rail. - */ - default BlockPos getCurrentRailPosition() { - int x = Mth.floor(self().getX()); - int y = Mth.floor(self().getY()); - int z = Mth.floor(self().getZ()); - BlockPos pos = new BlockPos(x, y, z); - if (self().level().getBlockState(pos.below()).is(BlockTags.RAILS)) pos = pos.below(); - return pos; - } - - double getMaxSpeedWithRail(); - - /** - * Moved to allow overrides. - * This code handles minecart movement and speed capping when on a rail. - */ - void moveMinecartOnRail(BlockPos pos); - - /** - * Returns true if this cart can currently use rails. - * This function is mainly used to gracefully detach a minecart from a rail. - * - * @return True if the minecart can use rails. - */ - boolean canUseRail(); - - /** - * Set whether the minecart can use rails. - * This function is mainly used to gracefully detach a minecart from a rail. - * - * @param use Whether the minecart can currently use rails. - */ - void setCanUseRail(boolean use); - - /** - * Return false if this cart should not call onMinecartPass() and should ignore Powered Rails. - * - * @return True if this cart should call onMinecartPass(). - */ - default boolean shouldDoRailFunctions() { - return true; - } - - /** - * Returns true if this cart is self propelled. - * - * @return True if powered. - */ - default boolean isPoweredCart() { - return self().getMinecartType() == AbstractMinecart.Type.FURNACE; - } - - /** - * Returns true if this cart can be ridden by an Entity. - * - * @return True if this cart can be ridden. - */ - default boolean canBeRidden() { - return self().getMinecartType() == AbstractMinecart.Type.RIDEABLE; - } - - /** - * Returns the carts max speed when traveling on rails. Carts going faster - * than 1.1 cause issues with chunk loading. Carts cant traverse slopes or - * corners at greater than 0.5 - 0.6. This value is compared with the rails - * max speed and the carts current speed cap to determine the carts current - * max speed. A normal rail's max speed is 0.4. - * - * @return Carts max speed. - */ - default float getMaxCartSpeedOnRail() { - return 1.2f; - } - - /** - * Returns the current speed cap for the cart when traveling on rails. This - * functions differs from getMaxCartSpeedOnRail() in that it controls - * current movement and cannot be overridden. The value however can never be - * higher than getMaxCartSpeedOnRail(). - */ - float getCurrentCartSpeedCapOnRail(); - - void setCurrentCartSpeedCapOnRail(float value); - - float getMaxSpeedAirLateral(); - - void setMaxSpeedAirLateral(float value); - - float getMaxSpeedAirVertical(); - - void setMaxSpeedAirVertical(float value); - - double getDragAir(); - - void setDragAir(double value); - - default double getSlopeAdjustment() { - return 0.0078125D; - } - - /** - * Called from Detector Rails to retrieve a redstone power level for comparators. - */ - default int getComparatorLevel() { - return -1; - } -} diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IAttributeExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IAttributeExtension.java new file mode 100644 index 00000000..6a5c5156 --- /dev/null +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IAttributeExtension.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) NeoForged and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.neoforged.neoforge.common.extensions; + +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; +import net.minecraft.ChatFormatting; +import net.minecraft.Util; +import net.minecraft.core.Holder; +import net.minecraft.network.chat.CommonComponents; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.TextColor; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.Attribute.Sentiment; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.item.TooltipFlag; +import net.neoforged.neoforge.common.NeoForgeMod; +import net.neoforged.neoforge.common.util.AttributeUtil; +import org.jetbrains.annotations.Nullable; + +public interface IAttributeExtension { + public static final DecimalFormat FORMAT = Util.make(new DecimalFormat("#.##"), fmt -> fmt.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT)));; + + /** + * Converts the value of an attribute modifier to the value that will be displayed. + *

+ * For multiplicative modifiers, this method is responsible for converting the value to percentage form. + * + * @param op The operation of the modifier. Null if we are just displaying the raw value and not a modifier. + * @param value The value to convert. Either the current attribute value (if null operation) or the attribute modifier's amount. + * @param flag The tooltip flag. + * @return The component form of the formatted value. + */ + default MutableComponent toValueComponent(@Nullable Operation op, double value, TooltipFlag flag) { + if (isNullOrAddition(op)) { + return Component.translatable("neoforge.value.flat", FORMAT.format(value)); + } + + return Component.translatable("neoforge.value.percent", FORMAT.format(value * 100)); + } + + /** + * Converts an attribute modifier into its tooltip representation. + *

+ * This method does not handle formatting of "base" modifiers, such as Attack Damage or Attack Speed. + *

+ * The returned component may append additional debug information based on the tooltip flag. + * + * @param modif The attribute modifier being converted to a component. + * @param flag The tooltip flag. + * @return The component representation of the passed attribute modifier, with debug info appended if enabled. + */ + default MutableComponent toComponent(AttributeModifier modif, TooltipFlag flag) { + Attribute attr = self(); + double value = modif.amount(); + String key = value > 0 ? "neoforge.modifier.plus" : "neoforge.modifier.take"; + ChatFormatting color = attr.getStyle(value > 0); + + Component attrDesc = Component.translatable(attr.getDescriptionId()); + Component valueComp = this.toValueComponent(modif.operation(), value, flag); + MutableComponent comp = Component.translatable(key, valueComp, attrDesc).withStyle(color); + + return comp.append(this.getDebugInfo(modif, flag)); + } + + /** + * Computes the additional debug information for a given attribute modifier, if the flag {@linkplain TooltipFlag#isAdvanced() is advanced}. + * + * @param modif The attribute modifier being converted to a component. + * @param flag The tooltip flag. + * @return The debug component, or {@link CommonComponents#EMPTY} if disabled. + * @apiNote This information is automatically appended to {@link #toComponent(AttributeModifier, TooltipFlag)}. + */ + default Component getDebugInfo(AttributeModifier modif, TooltipFlag flag) { + Component debugInfo = CommonComponents.EMPTY; + + if (flag.isAdvanced()) { + // Advanced Tooltips show the underlying operation and the "true" value. We offset MULTIPLY_TOTAL by 1 due to how the operation is calculated. + double advValue = (modif.operation() == Operation.ADD_MULTIPLIED_TOTAL ? 1 : 0) + modif.amount(); + String valueStr = FORMAT.format(advValue); + String txt = switch (modif.operation()) { + case ADD_VALUE -> String.format(Locale.ROOT, advValue > 0 ? "[+%s]" : "[%s]", valueStr); + case ADD_MULTIPLIED_BASE -> String.format(Locale.ROOT, advValue > 0 ? "[+%sx]" : "[%sx]", valueStr); + case ADD_MULTIPLIED_TOTAL -> String.format(Locale.ROOT, "[x%s]", valueStr); + }; + debugInfo = Component.literal(" ").append(Component.literal(txt).withStyle(ChatFormatting.GRAY)); + } + return debugInfo; + } + + /** + * Gets the specific ID that represents a "base" (green) modifier for this attribute. + * + * @return The ID of the "base" modifier, or null, if no such modifier may exist. + */ + @Nullable + default ResourceLocation getBaseId() { + if (this == Attributes.ATTACK_DAMAGE.value()) return AttributeUtil.BASE_ATTACK_DAMAGE_ID; + else if (this == Attributes.ATTACK_SPEED.value()) return AttributeUtil.BASE_ATTACK_SPEED_ID; + else if (this == Attributes.ENTITY_INTERACTION_RANGE.value()) return AttributeUtil.BASE_ENTITY_REACH_ID; + return null; + } + + /** + * Converts a "base" attribute modifier (as dictated by {@link #getBaseId()}) into a text component. + *

+ * Similar to {@link #toComponent}, this method is responsible for adding debug information when the tooltip flag {@linkplain TooltipFlag#isAdvanced() is advanced}. + * + * @param value The value to be shown (after having been added to the entity's base value) + * @param entityBase The entity's base value for this attribute from {@link LivingEntity#getAttributeBaseValue(Holder)}. + * @param merged If we are displaying a merged base component (which will have a non-merged base component as a child). + * @param flag The tooltip flag. + * @return The component representation of the passed attribute modifier. + */ + default MutableComponent toBaseComponent(double value, double entityBase, boolean merged, TooltipFlag flag) { + Attribute attr = self(); + MutableComponent comp = Component.translatable("attribute.modifier.equals.0", FORMAT.format(value), Component.translatable(attr.getDescriptionId())); + + // Emit both the value of the modifier, and the entity's base value as debug information, since both are flattened into the modifier. + // Skip showing debug information here when displaying a merged modifier, since it will be shown if the user holds shift to display the un-merged modifier. + if (flag.isAdvanced() && !merged) { + Component debugInfo = Component.literal(" ").append(Component.translatable("neoforge.attribute.debug.base", FORMAT.format(entityBase), FORMAT.format(value - entityBase)).withStyle(ChatFormatting.GRAY)); + comp.append(debugInfo); + } + + return comp; + } + + /** + * Returns the color used by merged attribute modifiers. Only used when {@link NeoForgeMod#enableMergedAttributeTooltips()} is active. + *

+ * Similarly to {@link Attribute#getStyle(boolean)}, this method should return a color based on the attribute's {@link Sentiment}. + * The returned color should be distinguishable from the color used by {@link Attribute#getStyle(boolean)}. + * + * @param positive If the attribute modifier value is positive or not. + */ + TextColor getMergedStyle(boolean isPositive); + + public static boolean isNullOrAddition(@Nullable Operation op) { + return op == null || op == Operation.ADD_VALUE; + } + + private Attribute self() { + return (Attribute) this; + } +} diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockAndTintGetterExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockAndTintGetterExtension.java index c177f3b8..b6bcf97a 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockAndTintGetterExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockAndTintGetterExtension.java @@ -21,6 +21,6 @@ private BlockAndTintGetter self() { * Alternate version of the vanilla method taking in a {@link Direction}. */ default float getShade(float normalX, float normalY, float normalZ, boolean shade) { - return self().getShade(Direction.getNearest(normalX, normalY, normalZ), shade); + return self().getShade(Direction.getApproximateNearest(normalX, normalY, normalZ), shade); } } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockEntityExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockEntityExtension.java index c76d91ab..4dfa896b 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockEntityExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockEntityExtension.java @@ -11,7 +11,6 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.chunk.LevelChunk; @@ -96,16 +95,6 @@ default ModelData getModelData() { return ModelData.EMPTY; } - /** - * Returns whether this {@link BlockEntity} has custom outline rendering behavior. - * - * @param player the local player currently viewing this {@code BlockEntity} - * @return {@code true} to enable outline processing - */ - default boolean hasCustomOutlineRendering(Player player) { - return false; - } - /** * Notify all listeners that the capabilities at the positions of this block entity might have changed. * This includes new capabilities becoming available. diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java index f193bfff..813b8a39 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java @@ -723,7 +723,7 @@ default boolean canDropFromExplosion(BlockState state, BlockGetter level, BlockP * @param pos Block position in level * @param explosion The explosion instance affecting the block */ - default void onBlockExploded(BlockState state, Level level, BlockPos pos, Explosion explosion) { + default void onBlockExploded(BlockState state, ServerLevel level, BlockPos pos, Explosion explosion) { level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3); self().wasExploded(level, pos, explosion); } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java index b1f5b3a2..3e08a8b5 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java @@ -596,7 +596,7 @@ default boolean canDropFromExplosion(BlockGetter level, BlockPos pos, Explosion * @param pos Block position in level * @param explosion The explosion instance affecting the block */ - default void onBlockExploded(Level level, BlockPos pos, Explosion explosion) { + default void onBlockExploded(ServerLevel level, BlockPos pos, Explosion explosion) { self().getBlock().onBlockExploded(self(), level, pos, explosion); } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/ICommandSourceStackExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/ICommandSourceStackExtension.java index 5cb99874..19e3beaf 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/ICommandSourceStackExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/ICommandSourceStackExtension.java @@ -8,9 +8,9 @@ import net.minecraft.advancements.AdvancementHolder; import net.minecraft.commands.CommandSourceStack; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.level.Level; import net.minecraft.world.scores.Scoreboard; +import org.jetbrains.annotations.Nullable; /** * Additional methods for {@link CommandSourceStack} so that commands and arguments can access various things without directly referencing using server specific classes @@ -30,17 +30,11 @@ default Scoreboard getScoreboard() { /** * @return the advancement from the id */ + @Nullable default AdvancementHolder getAdvancement(ResourceLocation id) { return self().getServer().getAdvancements().get(id); } - /** - * @return the recipe manager - */ - default RecipeManager getRecipeManager() { - return self().getServer().getRecipeManager(); - } - /** * @return the level but without being specifically the server side level */ diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IEntityExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IEntityExtension.java index a3a2234b..3b495ea5 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IEntityExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IEntityExtension.java @@ -12,6 +12,7 @@ import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.entity.Entity; @@ -128,7 +129,7 @@ default boolean canBeRiddenUnderFluidType(FluidType type, Entity rider) { * @param fallDistance The fall distance * @return {@code true} if this entity can trample, {@code false} otherwise */ - boolean canTrample(BlockState state, BlockPos pos, float fallDistance); + boolean canTrample(ServerLevel level, BlockState state, BlockPos pos, float fallDistance); /** * Returns The classification of this entity diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IFluidExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IFluidExtension.java index f8749b3a..b2d9c498 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IFluidExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IFluidExtension.java @@ -6,12 +6,12 @@ package net.neoforged.neoforge.common.extensions; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.AbstractBoat; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; @@ -72,7 +72,7 @@ default boolean move(FluidState state, LivingEntity entity, Vec3 movementVector, * @param pos the location of the fluid * @return {@code true} if the fluid can create a source, {@code false} otherwise */ - default boolean canConvertToSource(FluidState state, Level level, BlockPos pos) { + default boolean canConvertToSource(FluidState state, ServerLevel level, BlockPos pos) { return getFluidType().canConvertToSource(state, level, pos); } @@ -83,7 +83,7 @@ default boolean canConvertToSource(FluidState state, Level level, BlockPos pos) * @param boat the boat trying to be used on the fluid * @return {@code true} if the boat can be used, {@code false} otherwise */ - default boolean supportsBoating(FluidState state, Boat boat) { + default boolean supportsBoating(FluidState state, AbstractBoat boat) { return getFluidType().supportsBoating(state, boat); } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IFluidStateExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IFluidStateExtension.java index a8082fca..97f9a158 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IFluidStateExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IFluidStateExtension.java @@ -6,12 +6,12 @@ package net.neoforged.neoforge.common.extensions; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.AbstractBoat; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.pathfinder.PathType; @@ -66,7 +66,7 @@ default boolean move(LivingEntity entity, Vec3 movementVector, double gravity) { * @param pos the location of the fluid * @return {@code true} if the fluid can create a source, {@code false} otherwise */ - default boolean canConvertToSource(Level level, BlockPos pos) { + default boolean canConvertToSource(ServerLevel level, BlockPos pos) { return self().getType().canConvertToSource(self(), level, pos); } @@ -76,7 +76,7 @@ default boolean canConvertToSource(Level level, BlockPos pos) { * @param boat the boat trying to be used on the fluid * @return {@code true} if the boat can be used, {@code false} otherwise */ - default boolean supportsBoating(Boat boat) { + default boolean supportsBoating(AbstractBoat boat) { return self().getType().supportsBoating(self(), boat); } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IHolderLookupProviderExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IHolderLookupProviderExtension.java index b80b29e4..0c2037fe 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IHolderLookupProviderExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IHolderLookupProviderExtension.java @@ -28,7 +28,7 @@ default Holder holderOrThrow(ResourceKey key) { * Shortcut method to get an optional holder from a ResourceKey. */ default Optional> holder(ResourceKey key) { - Optional> registry = this.self().lookup(key.registryKey()); + Optional> registry = this.self().lookup(key.registryKey()); return registry.flatMap(tRegistryLookup -> tRegistryLookup.get(key)); } } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java index 0ae0cb4b..ab5cc0f8 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java @@ -20,6 +20,8 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.ItemTags; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -31,15 +33,10 @@ import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.animal.horse.Horse; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.entity.monster.piglin.PiglinAi; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.AnimalArmorItem; -import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.ArmorMaterial; -import net.minecraft.world.item.ArmorMaterials; import net.minecraft.world.item.AxeItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -51,14 +48,13 @@ import net.minecraft.world.item.enchantment.Enchantment.EnchantmentDefinition; import net.minecraft.world.item.enchantment.EnchantmentInstance; import net.minecraft.world.item.enchantment.ItemEnchantments; +import net.minecraft.world.item.equipment.EquipmentModel; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.FuelValues; import net.minecraft.world.phys.AABB; import net.neoforged.neoforge.common.CommonHooks; import net.neoforged.neoforge.common.ItemAbilities; import net.neoforged.neoforge.common.ItemAbility; -import net.neoforged.neoforge.registries.datamaps.builtin.FurnaceFuel; -import net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -75,7 +71,7 @@ private Item self() { */ @SuppressWarnings("deprecation") default ItemAttributeModifiers getDefaultAttributeModifiers(ItemStack stack) { - return self().getDefaultAttributeModifiers(); + return ItemAttributeModifiers.EMPTY; } /** @@ -130,7 +126,7 @@ default boolean isPiglinCurrency(ItemStack stack) { * @return True if piglins are neutral to players wearing this item in an armor slot */ default boolean makesPiglinsNeutral(ItemStack stack, LivingEntity wearer) { - return stack.getItem() instanceof ArmorItem && ((ArmorItem) stack.getItem()).getMaterial() == ArmorMaterials.GOLD; + return stack.is(ItemTags.PIGLIN_SAFE_ARMOR); } /** @@ -154,7 +150,7 @@ default float getXpRepairRatio(ItemStack stack) { * * Note that if you break an item while using it (that is, it becomes empty without swapping the stack instance), this hook may not be called on the serverside as you are * technically still using the empty item (thus this hook is called on air instead). It is necessary to call {@link LivingEntity#stopUsingItem()} as part of your - * {@link ItemStack#hurtAndBreak(int, LivingEntity, Consumer)} callback to prevent this issue. + * {@link ItemStack#hurtAndBreak(int, ServerLevel, LivingEntity, Consumer)} callback to prevent this issue. * * For most uses, you likely want one of the following: *