diff --git a/build_forge.gradle b/build_forge.gradle index b33259f714..b2b773ee3c 100644 --- a/build_forge.gradle +++ b/build_forge.gradle @@ -92,7 +92,7 @@ final String MAVEN_PATH = ext.MAVEN_PATH final String BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.2.0:fatjar' final String INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.4.3' final String FART = 'net.minecraftforge:ForgeAutoRenamingTool:1.0.6' -final String S2S_TOOL = 'net.minecraftforge:Srg2Source:8.1.0:fatjar' +final String S2S_TOOL = 'net.minecraftforge:Srg2Source:8.1.1:fatjar' configurations { // Don't pull all libraries, if we're missing something, add it to the installer list so the installer knows to download it. @@ -209,7 +209,6 @@ patcher { '--all', '--validate', '--output', rootProject.file('src/main/generated/'), - '--validate', '--existing', sourceSets.main.resources.srcDirs[0], '--assetsDir', downloadAssets.output, '--assetIndex', "{asset_index}" diff --git a/build_shared.gradle b/build_shared.gradle index 2ba0acb889..36074208c9 100644 --- a/build_shared.gradle +++ b/build_shared.gradle @@ -44,7 +44,7 @@ tasks.withType(JavaCompile).configureEach { dependsOn 'processResources' // Needed because we merge the output of this with the output of the compile task. And gradle detects downstream tasks using the output without a hard dep options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation options.warnings = false // Shutup deprecated for removal warnings - options.forkOptions.jvmArgs += '-Xmx3G' // Needed to make compiling faster, and not run out of heap space in some cases. + options.forkOptions.jvmArgs += '-Xmx6G' // Needed to make compiling faster, and not run out of heap space in some cases. } // Merge the resources and classes into the same directory. We'll need to split them at runtime because diff --git a/docs/README.md b/docs/README.md index e7af7019fc..8a2254f8c4 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,7 +3,7 @@ MinecraftForge ============= [![Stable Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Stable&prefix=1.21.4-&query=$.promos["1.21.4-recommended"]&color=brightgreen&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtc3RhciBmYS13LTE4IiBhcmlhLWhpZGRlbj0idHJ1ZSIgZGF0YS1pY29uPSJzdGFyIiBkYXRhLXByZWZpeD0iZmFzIiBmb2N1c2FibGU9ImZhbHNlIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCA1NzYgNTEyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMjU5LjMgMTcuOEwxOTQgMTUwLjIgNDcuOSAxNzEuNWMtMjYuMiAzLjgtMzYuNyAzNi4xLTE3LjcgNTQuNmwxMDUuNyAxMDMtMjUgMTQ1LjVjLTQuNSAyNi4zIDIzLjIgNDYgNDYuNCAzMy43TDI4OCA0MzkuNmwxMzAuNyA2OC43YzIzLjIgMTIuMiA1MC45LTcuNCA0Ni40LTMzLjdsLTI1LTE0NS41IDEwNS43LTEwM2MxOS0xOC41IDguNS01MC44LTE3LjctNTQuNkwzODIgMTUwLjIgMzE2LjcgMTcuOGMtMTEuNy0yMy42LTQ1LjYtMjMuOS01Ny40IDB6IiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K)][Download] -[![Latest Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Latest&prefix=1.21.4-&query=$.promos["1.21.4-latest"]&color=blue&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtYnVnIGZhLXctMTYiIGFyaWEtaGlkZGVuPSJ0cnVlIiBkYXRhLWljb249ImJ1ZyIgZGF0YS1wcmVmaXg9ImZhcyIgZm9jdXNhYmxlPSJmYWxzZSIgcm9sZT0iaW1nIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTUxMS45ODggMjg4LjljLS40NzggMTcuNDMtMTUuMjE3IDMxLjEtMzIuNjUzIDMxLjFINDI0djE2YzAgMjEuODY0LTQuODgyIDQyLjU4NC0xMy42IDYxLjE0NWw2MC4yMjggNjAuMjI4YzEyLjQ5NiAxMi40OTcgMTIuNDk2IDMyLjc1OCAwIDQ1LjI1NS0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDBsLTU0LjczNi01NC43MzZDMzQ1Ljg4NiA0NjcuOTY1IDMxNC4zNTEgNDgwIDI4MCA0ODBWMjM2YzAtNi42MjctNS4zNzMtMTItMTItMTJoLTI0Yy02LjYyNyAwLTEyIDUuMzczLTEyIDEydjI0NGMtMzQuMzUxIDAtNjUuODg2LTEyLjAzNS05MC42MzYtMzIuMTA4bC01NC43MzYgNTQuNzM2Yy0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDAtMTIuNDk2LTEyLjQ5Ny0xMi40OTYtMzIuNzU4IDAtNDUuMjU1bDYwLjIyOC02MC4yMjhDOTIuODgyIDM3OC41ODQgODggMzU3Ljg2NCA4OCAzMzZ2LTE2SDMyLjY2NkMxNS4yMyAzMjAgLjQ5MSAzMDYuMzMuMDEzIDI4OC45LS40ODQgMjcwLjgxNiAxNC4wMjggMjU2IDMyIDI1Nmg1NnYtNTguNzQ1bC00Ni42MjgtNDYuNjI4Yy0xMi40OTYtMTIuNDk3LTEyLjQ5Ni0zMi43NTggMC00NS4yNTUgMTIuNDk4LTEyLjQ5NyAzMi43NTgtMTIuNDk3IDQ1LjI1NiAwTDE0MS4yNTUgMTYwaDIyOS40ODlsNTQuNjI3LTU0LjYyN2MxMi40OTgtMTIuNDk3IDMyLjc1OC0xMi40OTcgNDUuMjU2IDAgMTIuNDk2IDEyLjQ5NyAxMi40OTYgMzIuNzU4IDAgNDUuMjU1TDQyNCAxOTcuMjU1VjI1Nmg1NmMxNy45NzIgMCAzMi40ODQgMTQuODE2IDMxLjk4OCAzMi45ek0yNTcgMGMtNjEuODU2IDAtMTEyIDUwLjE0NC0xMTIgMTEyaDIyNEMzNjkgNTAuMTQ0IDMxOC44NTYgMCAyNTcgMHoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo= +[![Latest Release](https://img.shields.io/badge/dynamic/json?url=https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json&label=Latest&prefix=1.21.5-&query=$.promos["1.21.5-latest"]&color=blue&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBjbGFzcz0ic3ZnLWlubGluZS0tZmEgZmEtYnVnIGZhLXctMTYiIGFyaWEtaGlkZGVuPSJ0cnVlIiBkYXRhLWljb249ImJ1ZyIgZGF0YS1wcmVmaXg9ImZhcyIgZm9jdXNhYmxlPSJmYWxzZSIgcm9sZT0iaW1nIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTUxMS45ODggMjg4LjljLS40NzggMTcuNDMtMTUuMjE3IDMxLjEtMzIuNjUzIDMxLjFINDI0djE2YzAgMjEuODY0LTQuODgyIDQyLjU4NC0xMy42IDYxLjE0NWw2MC4yMjggNjAuMjI4YzEyLjQ5NiAxMi40OTcgMTIuNDk2IDMyLjc1OCAwIDQ1LjI1NS0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDBsLTU0LjczNi01NC43MzZDMzQ1Ljg4NiA0NjcuOTY1IDMxNC4zNTEgNDgwIDI4MCA0ODBWMjM2YzAtNi42MjctNS4zNzMtMTItMTItMTJoLTI0Yy02LjYyNyAwLTEyIDUuMzczLTEyIDEydjI0NGMtMzQuMzUxIDAtNjUuODg2LTEyLjAzNS05MC42MzYtMzIuMTA4bC01NC43MzYgNTQuNzM2Yy0xMi40OTggMTIuNDk3LTMyLjc1OSAxMi40OTYtNDUuMjU2IDAtMTIuNDk2LTEyLjQ5Ny0xMi40OTYtMzIuNzU4IDAtNDUuMjU1bDYwLjIyOC02MC4yMjhDOTIuODgyIDM3OC41ODQgODggMzU3Ljg2NCA4OCAzMzZ2LTE2SDMyLjY2NkMxNS4yMyAzMjAgLjQ5MSAzMDYuMzMuMDEzIDI4OC45LS40ODQgMjcwLjgxNiAxNC4wMjggMjU2IDMyIDI1Nmg1NnYtNTguNzQ1bC00Ni42MjgtNDYuNjI4Yy0xMi40OTYtMTIuNDk3LTEyLjQ5Ni0zMi43NTggMC00NS4yNTUgMTIuNDk4LTEyLjQ5NyAzMi43NTgtMTIuNDk3IDQ1LjI1NiAwTDE0MS4yNTUgMTYwaDIyOS40ODlsNTQuNjI3LTU0LjYyN2MxMi40OTgtMTIuNDk3IDMyLjc1OC0xMi40OTcgNDUuMjU2IDAgMTIuNDk2IDEyLjQ5NyAxMi40OTYgMzIuNzU4IDAgNDUuMjU1TDQyNCAxOTcuMjU1VjI1Nmg1NmMxNy45NzIgMCAzMi40ODQgMTQuODE2IDMxLjk4OCAzMi45ek0yNTcgMGMtNjEuODU2IDAtMTEyIDUwLjE0NC0xMTIgMTEyaDIyNEMzNjkgNTAuMTQ0IDMxOC44NTYgMCAyNTcgMHoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo= )][Download] [![Discord](https://img.shields.io/discord/313125603924639766.svg?color=%237289da&label=Discord&logo=discord&logoColor=%237289da)][Discord] [![Support](https://img.shields.io/badge/Patreon-Support-orange.svg?logo=Patreon)][Patreon] Forge is a free, open-source modding API all of your favourite mods use! diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java index 48dabecee5..6f2dca80e3 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java @@ -7,7 +7,6 @@ package net.minecraftforge.fml.loading; import com.mojang.logging.LogUtils; import cpw.mods.modlauncher.api.*; -import joptsimple.OptionSpecBuilder; import net.minecraftforge.fml.loading.moddiscovery.ModFile; import net.minecraftforge.forgespi.Environment; import org.jetbrains.annotations.NotNull; @@ -19,7 +18,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.function.BiFunction; import static net.minecraftforge.fml.loading.LogMarkers.CORE; public class FMLServiceProvider implements ITransformationService { diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModIdentifier.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModIdentifier.java index 880fa7d6bf..8d6cd490da 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModIdentifier.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModIdentifier.java @@ -9,7 +9,6 @@ import cpw.mods.modlauncher.api.LamdbaExceptionUtils.Supplier_WithExceptions; import net.minecraftforge.fml.loading.StringUtils; import java.nio.file.Path; -import java.util.Arrays; import java.util.Optional; import java.util.function.BiPredicate; import java.util.stream.Stream; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java index fae7209bfe..b15352d6b8 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java @@ -17,7 +17,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import java.util.Locale; diff --git a/gradle.properties b/gradle.properties index 49ed8d37f7..8a3617efeb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,17 @@ # Sets default memory used for gradle commands. Can be overridden by user or command line properties. # This is required to provide enough memory for the Minecraft decompilation process. -org.gradle.jvmargs=-Xmx3G +org.gradle.jvmargs=-Xmx6G org.gradle.daemon=false org.gradle.parallel=true JAVA_VERSION=21 -MC_VERSION=1.21.4 +MC_VERSION=1.21.5 MC_NEXT_VERSION=1.22 -MCP_VERSION=20241203.143248 +MCP_VERSION=20250325.155543 MAPPING_CHANNEL=official -MAPPING_VERSION=1.21.4 +MAPPING_VERSION=1.21.5 -// Set to true before the first build of a new MC version, so we don't do compatibility checks +# Set to true before the first build of a new MC version, so we don't do compatibility checks CHECK_COMPATIBILITY=false -// Set to true to allow for fuzzy patching. Useful during updateing -UPDATING=false \ No newline at end of file +# Set to true to allow for fuzzy patching. Useful during updateing +UPDATING=false diff --git a/patches/minecraft/com/mojang/blaze3d/opengl/GlCommandEncoder.java.patch b/patches/minecraft/com/mojang/blaze3d/opengl/GlCommandEncoder.java.patch new file mode 100644 index 0000000000..79413934aa --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/opengl/GlCommandEncoder.java.patch @@ -0,0 +1,12 @@ +--- a/com/mojang/blaze3d/opengl/GlCommandEncoder.java ++++ b/com/mojang/blaze3d/opengl/GlCommandEncoder.java +@@ -109,6 +_,9 @@ + GlStateManager._colorMask(true, true, true, true); + GlStateManager._clear(16384); + GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, 0, 0); ++ // Forge: if using stencil, clear it as well (3553 = GlConst.GL_TEXTURE_2D) ++ if (p_394273_.isStencilEnabled()) ++ GlStateManager._glFramebufferTexture2D(GlConst.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_STENCIL_ATTACHMENT, GlConst.GL_TEXTURE_2D, 0, 0); + GlStateManager._glBindFramebuffer(36160, 0); + } + } diff --git a/patches/minecraft/com/mojang/blaze3d/opengl/GlDebug.java.patch b/patches/minecraft/com/mojang/blaze3d/opengl/GlDebug.java.patch new file mode 100644 index 0000000000..8498af84a3 --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/opengl/GlDebug.java.patch @@ -0,0 +1,34 @@ +--- a/com/mojang/blaze3d/opengl/GlDebug.java ++++ b/com/mojang/blaze3d/opengl/GlDebug.java +@@ -23,6 +_,14 @@ + + @OnlyIn(Dist.CLIENT) + public class GlDebug { ++ /** ++ * TODO: [Forge][Rendering][VEN] Expose this in the configs ++ *

++ * Will enable synchronous OpenGL debug logging, which means the message will be sent from the call that ++ * would have caused the error. Additionally, enables printing a stacktrace when and where this occurs. ++ */ ++ private static final boolean PRINT_STACKTRACE_ON_ERROR = Boolean.getBoolean("forge.printGLStackOnError"); ++ + private static final Logger LOGGER = LogUtils.getLogger(); + private static final int CIRCULAR_LOG_SIZE = 10; + private final Queue MESSAGE_BUFFER = EvictingQueue.create(10); +@@ -105,6 +_,8 @@ + } + + LOGGER.info("OpenGL debug message: {}", gldebug$logentry); ++ // TODO: [VEN] Trim the stack trace ++ if (PRINT_STACKTRACE_ON_ERROR) LOGGER.info("Trace: ", new Throwable("GlDebug")); + } + + public List getLastOpenGlDebugMessages() { +@@ -121,6 +_,7 @@ + + @Nullable + public static GlDebug enableDebugCallback(int p_394351_, boolean p_393026_, Set p_393339_) { ++ p_393026_ |= PRINT_STACKTRACE_ON_ERROR; + if (p_394351_ <= 0) { + return null; + } else { diff --git a/patches/minecraft/com/mojang/blaze3d/opengl/GlDevice.java.patch b/patches/minecraft/com/mojang/blaze3d/opengl/GlDevice.java.patch new file mode 100644 index 0000000000..cb5a5d21f5 --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/opengl/GlDevice.java.patch @@ -0,0 +1,53 @@ +--- a/com/mojang/blaze3d/opengl/GlDevice.java ++++ b/com/mojang/blaze3d/opengl/GlDevice.java +@@ -80,11 +_,25 @@ + + @Override + public GpuTexture createTexture(@Nullable Supplier p_397830_, TextureFormat p_394839_, int p_394481_, int p_391831_, int p_395609_) { +- return this.createTexture(this.debugLabels.exists() && p_397830_ != null ? p_397830_.get() : null, p_394839_, p_394481_, p_391831_, p_395609_); ++ return this.createTexture(p_397830_, p_394839_, p_394481_, p_391831_, p_395609_, false); ++ } ++ ++ /** @see GpuDevice#createTexture(Supplier, TextureFormat, int, int, int, boolean) */ ++ @Override ++ public GpuTexture createTexture(@Nullable Supplier p_397830_, TextureFormat p_394839_, int p_394481_, int p_391831_, int p_395609_, boolean stencil) { ++ return this.createTexture(this.debugLabels.exists() && p_397830_ != null ? p_397830_.get() : null, p_394839_, p_394481_, p_391831_, p_395609_, stencil); + } + + @Override + public GpuTexture createTexture(@Nullable String p_394142_, TextureFormat p_394951_, int p_395535_, int p_393944_, int p_392329_) { ++ return this.createTexture(p_394142_, p_394951_, p_395535_, p_393944_, p_392329_, false); ++ } ++ ++ /** @see GpuDevice#createTexture(String, TextureFormat, int, int, int, boolean) */ ++ @Override ++ public GpuTexture createTexture(@Nullable String p_394142_, TextureFormat p_394951_, int p_395535_, int p_393944_, int p_392329_, boolean stencil) { ++ // Forge: stencil rendering is only for depth ++ stencil &= p_394951_.hasDepthAspect(); + if (p_392329_ < 1) { + throw new IllegalArgumentException("mipLevels must be at least 1"); + } else { +@@ -106,11 +_,14 @@ + GlStateManager._texImage2D( + 3553, + j, ++ stencil ? org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8 : + GlConst.toGlInternalId(p_394951_), + p_395535_ >> j, + p_393944_ >> j, + 0, ++ stencil ? org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL : + GlConst.toGlExternalId(p_394951_), ++ stencil ? org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV : + GlConst.toGlType(p_394951_), + null + ); +@@ -122,7 +_,7 @@ + } else if (k != 0) { + throw new IllegalStateException("OpenGL error " + k); + } else { +- GlTexture gltexture = new GlTexture(p_394142_, p_394951_, p_395535_, p_393944_, p_392329_, i); ++ GlTexture gltexture = new GlTexture(p_394142_, p_394951_, p_395535_, p_393944_, p_392329_, i, stencil); + this.debugLabels.applyLabel(gltexture); + return gltexture; + } diff --git a/patches/minecraft/com/mojang/blaze3d/opengl/GlStateManager.java.patch b/patches/minecraft/com/mojang/blaze3d/opengl/GlStateManager.java.patch new file mode 100644 index 0000000000..bcab727130 --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/opengl/GlStateManager.java.patch @@ -0,0 +1,32 @@ +--- a/com/mojang/blaze3d/opengl/GlStateManager.java ++++ b/com/mojang/blaze3d/opengl/GlStateManager.java +@@ -90,6 +_,11 @@ + } + } + ++ public static boolean _isBlendEnabled() { ++ RenderSystem.assertOnRenderThread(); ++ return BLEND.mode.enabled; ++ } ++ + public static void _disableBlend() { + RenderSystem.assertOnRenderThread(); + BLEND.mode.disable(); +@@ -411,9 +_,17 @@ + } + } + ++ /* Stores the last values sent into glMultiTexCoord2f */ ++ public static float lastBrightnessX = 0.0f; ++ public static float lastBrightnessY = 0.0f; ++ + public static void _texParameter(int p_393876_, int p_397998_, int p_396741_) { + RenderSystem.assertOnRenderThread(); + GL11.glTexParameteri(p_393876_, p_397998_, p_396741_); ++ if (p_393876_ == GL13.GL_TEXTURE1) { ++ lastBrightnessX = p_397998_; ++ lastBrightnessY = p_396741_; ++ } + } + + public static int _getTexLevelParameter(int p_393352_, int p_397204_, int p_396319_) { diff --git a/patches/minecraft/com/mojang/blaze3d/opengl/GlTexture.java.patch b/patches/minecraft/com/mojang/blaze3d/opengl/GlTexture.java.patch new file mode 100644 index 0000000000..f0a24cb5bd --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/opengl/GlTexture.java.patch @@ -0,0 +1,32 @@ +--- a/com/mojang/blaze3d/opengl/GlTexture.java ++++ b/com/mojang/blaze3d/opengl/GlTexture.java +@@ -18,8 +_,13 @@ + protected boolean modesDirty = true; + + protected GlTexture(String p_393950_, TextureFormat p_392837_, int p_394590_, int p_391379_, int p_391947_, int p_396659_) { ++ this(p_393950_, p_392837_, p_394590_, p_391379_, p_391947_, p_396659_, false); ++ } ++ ++ protected GlTexture(String p_393950_, TextureFormat p_392837_, int p_394590_, int p_391379_, int p_391947_, int p_396659_, boolean stencil) { + super(p_393950_, p_392837_, p_394590_, p_391379_, p_391947_); + this.id = p_396659_; ++ this.stencilEnabled = stencil; + } + + @Override +@@ -86,5 +_,15 @@ + public void setTextureFilter(FilterMode p_394977_, FilterMode p_397175_, boolean p_393558_) { + super.setTextureFilter(p_394977_, p_397175_, p_393558_); + this.modesDirty = true; ++ } ++ ++ ++ /* FORGE START */ ++ ++ private final boolean stencilEnabled; ++ ++ @Override ++ public boolean isStencilEnabled() { ++ return this.stencilEnabled; + } + } diff --git a/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch index 80357dbf48..b1caef68b0 100644 --- a/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/pipeline/RenderTarget.java.patch @@ -1,28 +1,18 @@ --- a/com/mojang/blaze3d/pipeline/RenderTarget.java +++ b/com/mojang/blaze3d/pipeline/RenderTarget.java -@@ -96,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); -@@ -108,6 +_,7 @@ - GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, this.colorTextureId, 0); +@@ -75,7 +_,7 @@ + this.width = p_83951_; + this.height = p_83952_; if (this.useDepth) { - GlStateManager._glFramebufferTexture2D(36160, 36096, 3553, this.depthBufferId, 0); -+ if (stencilEnabled) GlStateManager._glFramebufferTexture2D(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_STENCIL_ATTACHMENT, 3553, this.depthBufferId, 0); +- this.depthTexture = RenderSystem.getDevice().createTexture(() -> this.label + " / Depth", TextureFormat.DEPTH32, p_83951_, p_83952_, 1); ++ this.depthTexture = RenderSystem.getDevice().createTexture(() -> this.label + " / Depth", TextureFormat.DEPTH32, p_83951_, p_83952_, 1, this.stencilEnabled); + this.depthTexture.setTextureFilter(FilterMode.NEAREST, false); + this.depthTexture.setAddressMode(AddressMode.CLAMP_TO_EDGE); } - - this.checkStatus(); -@@ -229,5 +_,26 @@ - - public int getDepthTextureId() { - return this.depthBufferId; +@@ -134,5 +_,26 @@ + @Nullable + public GpuTexture getDepthTexture() { + return this.depthTexture; + } + + private boolean stencilEnabled = false; diff --git a/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch deleted file mode 100644 index 6b6ce56a7a..0000000000 --- a/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/com/mojang/blaze3d/platform/GlStateManager.java -+++ b/com/mojang/blaze3d/platform/GlStateManager.java -@@ -94,6 +_,11 @@ - } - } - -+ public static boolean _isBlendEnabled() { -+ RenderSystem.assertOnRenderThread(); -+ return BLEND.mode.enabled; -+ } -+ - public static void _disableBlend() { - RenderSystem.assertOnRenderThread(); - BLEND.mode.disable(); -@@ -519,9 +_,17 @@ - } - } - -+ /* Stores the last values sent into glMultiTexCoord2f */ -+ public static float lastBrightnessX = 0.0f; -+ public static float lastBrightnessY = 0.0f; -+ - public static void _texParameter(int p_84161_, int p_84162_, float p_84163_) { - RenderSystem.assertOnRenderThreadOrInit(); - GL11.glTexParameterf(p_84161_, p_84162_, p_84163_); -+ if (p_84161_ == GL13.GL_TEXTURE1) { -+ lastBrightnessX = p_84162_; -+ lastBrightnessY = p_84163_; -+ } - } - - public static void _texParameter(int p_84332_, int p_84333_, int p_84334_) { diff --git a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch index 06acc31f03..d6ce34c689 100644 --- a/patches/minecraft/com/mojang/blaze3d/platform/Window.java.patch +++ b/patches/minecraft/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 -@@ -89,7 +_,8 @@ +@@ -88,7 +_,8 @@ GLFW.glfwWindowHint(139267, 2); GLFW.glfwWindowHint(139272, 204801); GLFW.glfwWindowHint(139270, 1); @@ -10,15 +10,15 @@ 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; -@@ -101,6 +_,7 @@ +@@ -100,6 +_,7 @@ this.windowedX = this.x = aint1[0]; this.windowedY = this.y = aint[0]; } + } - GLFW.glfwMakeContextCurrent(this.window); - GL.createCapabilities(); -@@ -271,6 +_,9 @@ + this.setMode(); + this.refreshFramebufferSize(); +@@ -266,6 +_,9 @@ 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/minecraft/com/mojang/blaze3d/systems/GpuDevice.java.patch b/patches/minecraft/com/mojang/blaze3d/systems/GpuDevice.java.patch new file mode 100644 index 0000000000..4883dc6739 --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/systems/GpuDevice.java.patch @@ -0,0 +1,20 @@ +--- a/com/mojang/blaze3d/systems/GpuDevice.java ++++ b/com/mojang/blaze3d/systems/GpuDevice.java +@@ -25,7 +_,17 @@ + + GpuTexture createTexture(@Nullable Supplier p_394357_, TextureFormat p_395807_, int p_395623_, int p_395802_, int p_396157_); + ++ /** Forge: same as {@link #createTexture(Supplier, TextureFormat, int, int, int)} but with stencil support */ ++ default GpuTexture createTexture(@Nullable Supplier p_394357_, TextureFormat p_395807_, int p_395623_, int p_395802_, int p_396157_, boolean stencil) { ++ return this.createTexture(p_394357_, p_395807_, p_395623_, p_395802_, p_396157_); ++ } ++ + GpuTexture createTexture(@Nullable String p_391798_, TextureFormat p_393333_, int p_391800_, int p_395600_, int p_394065_); ++ ++ /** Forge: same as {@link #createTexture(String, TextureFormat, int, int, int)} but with stencil support */ ++ default GpuTexture createTexture(@Nullable String p_391798_, TextureFormat p_393333_, int p_391800_, int p_395600_, int p_394065_, boolean stencil) { ++ return this.createTexture(p_391798_, p_393333_, p_391800_, p_395600_, p_394065_); ++ } + + GpuBuffer createBuffer(@Nullable Supplier p_395215_, BufferType p_392847_, BufferUsage p_391478_, int p_397054_); + diff --git a/patches/minecraft/com/mojang/blaze3d/systems/RenderSystem.java.patch b/patches/minecraft/com/mojang/blaze3d/systems/RenderSystem.java.patch deleted file mode 100644 index c9e0b8b1c3..0000000000 --- a/patches/minecraft/com/mojang/blaze3d/systems/RenderSystem.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/com/mojang/blaze3d/systems/RenderSystem.java -+++ b/com/mojang/blaze3d/systems/RenderSystem.java -@@ -196,6 +_,11 @@ - GlStateManager._depthMask(p_69459_); - } - -+ public static boolean isBlendEnabled() { -+ assertOnRenderThread(); -+ return GlStateManager._isBlendEnabled(); -+ } -+ - public static void enableBlend() { - assertOnRenderThread(); - GlStateManager._enableBlend(); diff --git a/patches/minecraft/com/mojang/blaze3d/textures/GpuTexture.java.patch b/patches/minecraft/com/mojang/blaze3d/textures/GpuTexture.java.patch new file mode 100644 index 0000000000..caca67f0bf --- /dev/null +++ b/patches/minecraft/com/mojang/blaze3d/textures/GpuTexture.java.patch @@ -0,0 +1,11 @@ +--- a/com/mojang/blaze3d/textures/GpuTexture.java ++++ b/com/mojang/blaze3d/textures/GpuTexture.java +@@ -6,7 +_,7 @@ + + @OnlyIn(Dist.CLIENT) + @DontObfuscate +-public abstract class GpuTexture implements AutoCloseable { ++public abstract class GpuTexture implements AutoCloseable, net.minecraftforge.client.extensions.IForgeGpuTexture { + private final TextureFormat format; + private final int width; + private final int height; diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch index a28f85f1ad..bedbe42f21 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/PoseStack.java.patch @@ -1,11 +1,11 @@ --- a/com/mojang/blaze3d/vertex/PoseStack.java +++ b/com/mojang/blaze3d/vertex/PoseStack.java -@@ -14,7 +_,7 @@ - import org.joml.Vector3f; +@@ -15,7 +_,7 @@ + import org.joml.Vector3fc; @OnlyIn(Dist.CLIENT) -public class PoseStack { +public class PoseStack implements net.minecraftforge.client.extensions.IForgePoseStack { - private final Deque poseStack = Util.make(Queues.newArrayDeque(), p_85848_ -> { - Matrix4f matrix4f = new Matrix4f(); - Matrix3f matrix3f = new Matrix3f(); + private final List poses = new ArrayList<>(16); + private int lastIndex; + diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch index cc32c45123..a780e6721f 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexFormat.java.patch @@ -1,23 +1,23 @@ --- a/com/mojang/blaze3d/vertex/VertexFormat.java +++ b/com/mojang/blaze3d/vertex/VertexFormat.java -@@ -14,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; +@@ -20,7 +_,7 @@ @OnlyIn(Dist.CLIENT) + @DontObfuscate -public class VertexFormat { +public class VertexFormat implements net.minecraftforge.client.extensions.IForgeVertexFormat { public static final int UNKNOWN_ELEMENT = -1; private final List elements; private final List names; -@@ -23,6 +_,7 @@ - private final int[] offsetsByElement = new int[32]; +@@ -31,6 +_,7 @@ + private GpuBuffer immediateDrawVertexBuffer; @Nullable - private VertexBuffer immediateDrawVertexBuffer; + private GpuBuffer immediateDrawIndexBuffer; + private final com.google.common.collect.ImmutableMap elementMapping; VertexFormat(List p_343616_, List p_345241_, IntList p_345522_, int p_344162_) { this.elements = p_343616_; -@@ -35,6 +_,11 @@ +@@ -43,6 +_,11 @@ int j = vertexformatelement != null ? p_343616_.indexOf(vertexformatelement) : -1; this.offsetsByElement[i] = j != -1 ? p_345522_.getInt(j) : -1; } @@ -29,13 +29,13 @@ } public static VertexFormat.Builder builder() { -@@ -141,6 +_,9 @@ +@@ -146,6 +_,9 @@ - return vertexbuffer; + return this.immediateDrawIndexBuffer; } + + public ImmutableMap getElementMapping() { return elementMapping; } + public int getOffset(int index) { return offsetsByElement[index]; } @OnlyIn(Dist.CLIENT) - public static class Builder { + @DontObfuscate diff --git a/patches/minecraft/com/mojang/math/Transformation.java.patch b/patches/minecraft/com/mojang/math/Transformation.java.patch index 000bd8ef2b..c5a29d0353 100644 --- a/patches/minecraft/com/mojang/math/Transformation.java.patch +++ b/patches/minecraft/com/mojang/math/Transformation.java.patch @@ -1,15 +1,15 @@ --- a/com/mojang/math/Transformation.java +++ b/com/mojang/math/Transformation.java -@@ -13,7 +_,7 @@ +@@ -14,7 +_,7 @@ import org.joml.Quaternionf; import org.joml.Vector3f; -public final class Transformation { +public final class Transformation implements net.minecraftforge.common.extensions.IForgeTransformation { - private final Matrix4f matrix; + private final Matrix4fc matrix; public static final Codec CODEC = RecordCodecBuilder.create( p_269604_ -> p_269604_.group( -@@ -169,5 +_,19 @@ +@@ -174,5 +_,19 @@ vector3f1.lerp(p_175938_.getScale(), p_175939_); quaternionf1.slerp(p_175938_.getRightRotation(), p_175939_); return new Transformation(vector3f, quaternionf, vector3f1, quaternionf1); diff --git a/patches/minecraft/net/minecraft/CrashReportCategory.java.patch b/patches/minecraft/net/minecraft/CrashReportCategory.java.patch index 68be11a5d5..f00e05ece7 100644 --- a/patches/minecraft/net/minecraft/CrashReportCategory.java.patch +++ b/patches/minecraft/net/minecraft/CrashReportCategory.java.patch @@ -34,4 +34,4 @@ + this.stackTrace = t.getStackTrace(); } - public static void populateBlockDetails(CrashReportCategory p_178951_, LevelHeightAccessor p_178952_, BlockPos p_178953_, @Nullable BlockState p_178954_) { + public static void populateBlockDetails(CrashReportCategory p_178951_, LevelHeightAccessor p_178952_, BlockPos p_178953_, BlockState p_178954_) { diff --git a/patches/minecraft/net/minecraft/SharedConstants.java.patch b/patches/minecraft/net/minecraft/SharedConstants.java.patch index 6202c3fe8a..224810a1bc 100644 --- a/patches/minecraft/net/minecraft/SharedConstants.java.patch +++ b/patches/minecraft/net/minecraft/SharedConstants.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java -@@ -170,6 +_,7 @@ +@@ -171,6 +_,7 @@ } static { diff --git a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch index 436c0bbccd..454fffd962 100644 --- a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch +++ b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java -@@ -214,7 +_,11 @@ +@@ -226,7 +_,11 @@ } public AdvancementHolder save(Consumer p_138390_, String p_138391_) { diff --git a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch index b8110f15fe..55fdf25a68 100644 --- a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch +++ b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/AdvancementRewards.java +++ b/net/minecraft/advancements/AdvancementRewards.java -@@ -41,6 +_,7 @@ +@@ -40,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/minecraft/net/minecraft/client/Camera.java.patch b/patches/minecraft/net/minecraft/client/Camera.java.patch index 93a5d1ebe2..4ebd9f85f5 100644 --- a/patches/minecraft/net/minecraft/client/Camera.java.patch +++ b/patches/minecraft/net/minecraft/client/Camera.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Camera.java +++ b/net/minecraft/client/Camera.java -@@ -120,9 +_,13 @@ +@@ -118,9 +_,13 @@ } protected void setRotation(float p_90573_, float p_90574_) { @@ -15,7 +15,7 @@ FORWARDS.rotate(this.rotation, this.forwards); UP.rotate(this.rotation, this.up); LEFT.rotate(this.rotation, this.left); -@@ -238,6 +_,13 @@ +@@ -236,6 +_,13 @@ public float getPartialTickTime() { return this.partialTickTime; diff --git a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch index b975627132..9d42ba236e 100644 --- a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java -@@ -424,12 +_,12 @@ +@@ -431,12 +_,12 @@ if (screen != null) { try { if (p_90897_ != 1 && p_90897_ != 2) { @@ -15,7 +15,7 @@ return; } } -@@ -505,6 +_,7 @@ +@@ -495,6 +_,7 @@ } } } @@ -23,7 +23,7 @@ } } -@@ -514,10 +_,10 @@ +@@ -504,10 +_,10 @@ if (screen != null && this.minecraft.getOverlay() == null) { try { if (Character.isBmpCodePoint(p_90891_)) { diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index fcd350c753..037fbffe1b 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java -@@ -250,7 +_,7 @@ +@@ -248,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; -@@ -428,7 +_,6 @@ +@@ -426,7 +_,6 @@ } }, Util.nonCriticalIoPool()); LOGGER.info("Setting user: {}", this.user.getName()); @@ -17,7 +17,7 @@ this.demo = p_91084_.game.demo; this.allowsMultiplayer = !p_91084_.game.disableMultiplayer; this.allowsChat = !p_91084_.game.disableChat; -@@ -475,15 +_,15 @@ +@@ -478,10 +_,9 @@ LOGGER.error("Couldn't set icon", (Throwable)ioexception); } @@ -26,16 +26,18 @@ - this.mouseHandler.setup(this.window.getWindow()); this.keyboardHandler = new KeyboardHandler(this); - this.keyboardHandler.setup(this.window.getWindow()); - RenderSystem.initRenderer(this.options.glDebugVerbosity, false); + RenderSystem.initRenderer( + this.window.getWindow(), + this.options.glDebugVerbosity, +@@ -492,6 +_,7 @@ + LOGGER.info("Using optional rendering extensions: {}", String.join(", ", RenderSystem.getDevice().getEnabledExtensions())); this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight()); - this.mainRenderTarget.setClearColor(0.0F, 0.0F, 0.0F, 0.0F); - this.mainRenderTarget.clear(); this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); + net.minecraftforge.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_340763_ -> { -@@ -561,6 +_,7 @@ +@@ -570,6 +_,7 @@ this.blockEntityRenderDispatcher = new BlockEntityRenderDispatcher(this.font, this.modelManager.entityModels(), this.blockRenderer, this.itemModelResolver, this.itemRenderer, this.entityRenderDispatcher); this.resourceManager.registerReloadListener(this.blockEntityRenderDispatcher); this.particleEngine = new ParticleEngine(this.level, this.textureManager); @@ -43,7 +45,7 @@ this.resourceManager.registerReloadListener(this.particleEngine); this.paintingTextures = new PaintingTextureManager(this.textureManager); this.resourceManager.registerReloadListener(this.paintingTextures); -@@ -576,6 +_,9 @@ +@@ -585,6 +_,9 @@ this.resourceManager.registerReloadListener(this.gpuWarnlistManager); this.resourceManager.registerReloadListener(this.regionalCompliancies); this.gui = new Gui(this); @@ -51,17 +53,17 @@ + this.mouseHandler.setup(this.window.getWindow()); + this.keyboardHandler.setup(this.window.getWindow()); this.debugRenderer = new DebugRenderer(this); - RealmsClient realmsclient = RealmsClient.create(this); + RealmsClient realmsclient = RealmsClient.getOrCreate(this); this.realmsDataFetcher = new RealmsDataFetcher(realmsclient); -@@ -599,6 +_,7 @@ - this.options.fullscreen().set(this.window.isFullscreen()); +@@ -618,6 +_,7 @@ + } } + net.minecraftforge.client.ForgeHooksClient.initClientHooks(this, this.resourceManager); this.window.updateVsync(this.options.enableVsync().get()); this.window.updateRawMouseInput(this.options.rawMouseInput().get()); this.window.setDefaultErrorCallback(); -@@ -620,16 +_,17 @@ +@@ -639,16 +_,17 @@ GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS); Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay); this.setOverlay( @@ -69,20 +71,20 @@ - this, reloadinstance, p_296164_ -> Util.ifElse(p_296164_, p_296162_ -> this.rollbackResourcePacks(p_296162_, minecraft$gameloadcookie), () -> { + net.minecraftforge.fml.loading.ImmediateWindowHandler.loadingOverlay( + () -> this, () -> reloadinstance, p_296164_ -> Util.ifElse(p_296164_, p_296162_ -> this.rollbackResourcePacks(p_296162_, minecraft$gameloadcookie), () -> { - if (SharedConstants.IS_RUNNING_IN_IDE) { - this.selfTest(); - } + if (SharedConstants.IS_RUNNING_IN_IDE) { + this.selfTest(); + } - this.reloadStateTracker.finishReload(); - this.onResourceLoadFinished(minecraft$gameloadcookie); -+ net.minecraftforge.client.loading.ClientModLoader.completeModLoading(); - }), false + this.reloadStateTracker.finishReload(); + this.onResourceLoadFinished(minecraft$gameloadcookie); ++ net.minecraftforge.client.loading.ClientModLoader.completeModLoading(); + }), false - ) + ).get() ); this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.path()); this.framerateLimitTracker = new FramerateLimitTracker(this.options, this); -@@ -724,6 +_,7 @@ +@@ -746,6 +_,7 @@ StringBuilder stringbuilder = new StringBuilder("Minecraft"); if (checkModStatus().shouldReportAsModified()) { stringbuilder.append("*"); @@ -90,7 +92,7 @@ } stringbuilder.append(" "); -@@ -747,6 +_,8 @@ +@@ -769,6 +_,8 @@ } private UserApiService createUserApiService(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { @@ -99,7 +101,7 @@ return p_193587_.user.user.getType() != User.Type.MSA ? UserApiService.OFFLINE : p_193586_.createUserApiService(p_193587_.user.user.getAccessToken()); -@@ -757,7 +_,7 @@ +@@ -779,7 +_,7 @@ } private void rollbackResourcePacks(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299515_) { @@ -108,7 +110,7 @@ this.clearResourcePacksOnError(p_91240_, null, p_299515_); } else { Util.throwAsRuntime(p_91240_); -@@ -1043,12 +_,6 @@ +@@ -1065,12 +_,6 @@ LOGGER.error("setScreen called from non-game thread"); } @@ -121,7 +123,7 @@ if (p_91153_ == null && this.clientLevelTeardownInProgress) { throw new IllegalStateException("Trying to return to in-game GUI during disconnection"); } else { -@@ -1062,6 +_,23 @@ +@@ -1084,6 +_,23 @@ } } @@ -145,15 +147,15 @@ this.screen = p_91153_; if (this.screen != null) { this.screen.added(); -@@ -1146,6 +_,7 @@ - +@@ -1168,6 +_,7 @@ FreeTypeUtil.destroy(); Util.shutdownExecutors(); + RenderSystem.getDevice().close(); + net.minecraftforge.fml.config.ConfigTracker.INSTANCE.forceUnload(); } catch (Throwable throwable) { LOGGER.error("Shutdown failure!", throwable); throw throwable; -@@ -1215,9 +_,11 @@ +@@ -1237,9 +_,11 @@ this.mouseHandler.handleAccumulatedMovement(); profilerfiller.pop(); if (!this.noRender) { @@ -165,8 +167,8 @@ } profilerfiller.push("blit"); -@@ -1342,10 +_,12 @@ - this.window.setGuiScale((double)i); +@@ -1363,10 +_,12 @@ + this.window.setGuiScale(i); if (this.screen != null) { this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); + net.minecraftforge.client.ForgeHooksClient.resizeGuiLayers(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); @@ -178,7 +180,7 @@ this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight()); this.mouseHandler.setIgnoreFirstMove(); } -@@ -1486,6 +_,7 @@ +@@ -1504,6 +_,7 @@ } public void stop() { @@ -186,7 +188,7 @@ this.running = false; } -@@ -1514,10 +_,18 @@ +@@ -1532,10 +_,18 @@ if (p_91387_ && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) { BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockPos blockpos = blockhitresult.getBlockPos(); @@ -208,7 +210,7 @@ this.player.swing(InteractionHand.MAIN_HAND); } } -@@ -1545,6 +_,8 @@ +@@ -1563,6 +_,8 @@ return false; } else { boolean flag = false; @@ -217,7 +219,7 @@ switch (this.hitResult.getType()) { case ENTITY: this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity()); -@@ -1552,7 +_,7 @@ +@@ -1570,7 +_,7 @@ case BLOCK: BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockPos blockpos = blockhitresult.getBlockPos(); @@ -226,7 +228,7 @@ this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection()); if (this.level.getBlockState(blockpos).isAir()) { flag = true; -@@ -1565,8 +_,10 @@ +@@ -1583,8 +_,10 @@ } this.player.resetAttackStrengthTicker(); @@ -237,7 +239,7 @@ this.player.swing(InteractionHand.MAIN_HAND); return flag; } -@@ -1582,6 +_,12 @@ +@@ -1600,6 +_,12 @@ } for (InteractionHand interactionhand : InteractionHand.values()) { @@ -250,7 +252,7 @@ ItemStack itemstack = this.player.getItemInHand(interactionhand); if (!itemstack.isItemEnabled(this.level.enabledFeatures())) { return; -@@ -1602,7 +_,7 @@ +@@ -1620,7 +_,7 @@ } if (interactionresult instanceof InteractionResult.Success interactionresult$success2) { @@ -259,16 +261,16 @@ this.player.swing(interactionhand); } -@@ -1614,7 +_,7 @@ +@@ -1632,7 +_,7 @@ int i = itemstack.getCount(); InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult); 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())) { + if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.player.hasInfiniteMaterials())) { this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand); -@@ -1630,6 +_,9 @@ +@@ -1648,6 +_,9 @@ } } @@ -278,7 +280,7 @@ if (!itemstack.isEmpty() && this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) { if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) { -@@ -1659,6 +_,8 @@ +@@ -1677,6 +_,8 @@ } ProfilerFiller profilerfiller = Profiler.get(); @@ -287,7 +289,7 @@ profilerfiller.push("gui"); this.chatListener.tick(); this.gui.tick(this.pause); -@@ -1748,6 +_,7 @@ +@@ -1766,6 +_,7 @@ this.tutorial.tick(); @@ -295,7 +297,7 @@ try { this.level.tick(() -> true); } catch (Throwable throwable1) { -@@ -1761,6 +_,7 @@ +@@ -1779,6 +_,7 @@ throw new ReportedException(crashreport1); } @@ -303,7 +305,7 @@ } profilerfiller.popPush("animateTick"); -@@ -1785,6 +_,7 @@ +@@ -1803,6 +_,7 @@ profilerfiller.popPush("keyboard"); this.keyboardHandler.tick(); profilerfiller.pop(); @@ -311,7 +313,7 @@ } private boolean isLevelRunningNormally() { -@@ -1986,6 +_,7 @@ +@@ -2003,6 +_,7 @@ } public void setLevel(ClientLevel p_91157_, ReceivingLevelScreen.Reason p_335893_) { @@ -319,7 +321,7 @@ this.updateScreenAndTick(new ReceivingLevelScreen(() -> false, p_335893_)); this.level = p_91157_; this.updateLevelInEngines(p_91157_); -@@ -2023,6 +_,7 @@ +@@ -2040,6 +_,7 @@ IntegratedServer integratedserver = this.singleplayerServer; this.singleplayerServer = null; this.gameRenderer.resetData(); @@ -327,7 +329,7 @@ this.gameMode = null; this.narrator.clear(); this.clientLevelTeardownInProgress = true; -@@ -2030,6 +_,7 @@ +@@ -2047,6 +_,7 @@ try { this.updateScreenAndTick(p_335030_); if (this.level != null) { @@ -335,7 +337,7 @@ if (integratedserver != null) { ProfilerFiller profilerfiller = Profiler.get(); profilerfiller.push("waitForServer"); -@@ -2043,6 +_,7 @@ +@@ -2060,6 +_,7 @@ this.gui.onDisconnected(); this.isLocalServer = false; @@ -343,11 +345,11 @@ } this.level = null; -@@ -2190,6 +_,7 @@ +@@ -2207,6 +_,7 @@ private void pickBlock() { if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onClickInput(2, this.options.keyPickItem, InteractionHand.MAIN_HAND).isCanceled()) return; boolean flag = Screen.hasControlDown(); - HitResult hitresult = this.hitResult; - Objects.requireNonNull(this.hitResult); + switch (this.hitResult) { + case BlockHitResult blockhitresult: diff --git a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch index a6bb21b24f..b25442cb1a 100644 --- a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/MouseHandler.java +++ b/net/minecraft/client/MouseHandler.java -@@ -85,6 +_,7 @@ +@@ -90,6 +_,7 @@ this.activeButton = -1; } @@ -8,7 +8,7 @@ if (this.minecraft.getOverlay() == null) { if (this.minecraft.screen == null) { if (!this.mouseGrabbed && flag) { -@@ -98,7 +_,7 @@ +@@ -103,7 +_,7 @@ screen.afterMouseAction(); try { @@ -17,7 +17,7 @@ return; } } catch (Throwable throwable1) { -@@ -112,7 +_,7 @@ +@@ -116,7 +_,7 @@ } } else { try { @@ -26,18 +26,18 @@ return; } } catch (Throwable throwable) { -@@ -147,6 +_,7 @@ +@@ -150,6 +_,7 @@ } } } + net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(p_91532_, p_91533_, p_91534_); } - private void onScroll(long p_91527_, double p_91528_, double p_91529_) { -@@ -160,7 +_,9 @@ + public void fillMousePositionDetails(CrashReportCategory p_398230_, Window p_398216_) { +@@ -189,7 +_,9 @@ 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(); + double d3 = this.getScaledXPos(this.minecraft.getWindow()); + double d4 = this.getScaledYPos(this.minecraft.getWindow()); - this.minecraft.screen.mouseScrolled(d3, d4, d1, d2); + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseScrollPre(this.minecraft.screen, d3, d4, d1, d2)) return; + if (this.minecraft.screen.mouseScrolled(d3, d4, d1, d2)) return; @@ -45,7 +45,7 @@ this.minecraft.screen.afterMouseAction(); } else if (this.minecraft.player != null) { Vector2i vector2i = this.scrollWheelHandler.onMouseScroll(d1, d2); -@@ -169,6 +_,7 @@ +@@ -198,6 +_,7 @@ } int i = vector2i.y == 0 ? -vector2i.x : vector2i.y; @@ -53,8 +53,8 @@ if (this.minecraft.player.isSpectator()) { if (this.minecraft.gui.getSpectatorGui().isMenuActive()) { this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i); -@@ -274,7 +_,7 @@ - double d5 = this.accumulatedDY * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getScreenHeight(); +@@ -303,7 +_,7 @@ + double d5 = getScaledYPos(window, this.accumulatedDY); try { - screen.mouseDragged(d2, d3, this.activeButton, d4, d5); @@ -62,7 +62,7 @@ } catch (Throwable throwable) { CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler"); screen.fillCrashDetails(crashreport1); -@@ -349,6 +_,14 @@ +@@ -393,6 +_,14 @@ public double ypos() { return this.ypos; diff --git a/patches/minecraft/net/minecraft/client/Options.java.patch b/patches/minecraft/net/minecraft/client/Options.java.patch index 9b54094b87..99ade15074 100644 --- a/patches/minecraft/net/minecraft/client/Options.java.patch +++ b/patches/minecraft/net/minecraft/client/Options.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java -@@ -698,7 +_,8 @@ +@@ -668,7 +_,8 @@ }, new OptionInstance.LazyEnum<>( () -> Stream.concat(Stream.of(""), Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().stream()).toList(), - p_232011_ -> Minecraft.getInstance().isRunning() && p_232011_ != "" && !Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().contains(p_232011_) + // FORGE: fix incorrect string comparison - PR #8767 + p_232011_ -> Minecraft.getInstance().isRunning() && (p_232011_ == null || !p_232011_.isEmpty()) && !Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().contains(p_232011_) - ? Optional.empty() - : Optional.of(p_232011_), + ? Optional.empty() + : Optional.of(p_232011_), Codec.STRING -@@ -1079,6 +_,7 @@ +@@ -1050,6 +_,7 @@ } public Options(Minecraft p_92138_, File p_92139_) { @@ -18,10 +18,10 @@ this.minecraft = p_92138_; this.optionsFile = new File(p_92139_, "options.txt"); boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L; -@@ -1210,12 +_,22 @@ - p_168428_.process("telemetryOptInExtra", this.telemetryOptInExtra); +@@ -1181,12 +_,22 @@ this.onboardAccessibility = p_168428_.process("onboardAccessibility", this.onboardAccessibility); p_168428_.process("menuBackgroundBlurriness", this.menuBackgroundBlurriness); + this.startedCleanly = p_168428_.process("startedCleanly", this.startedCleanly); + processOptionsForge(p_168428_); + } @@ -42,7 +42,7 @@ } } -@@ -1233,6 +_,10 @@ +@@ -1204,6 +_,10 @@ } public void load() { @@ -53,8 +53,8 @@ try { if (!this.optionsFile.exists()) { return; -@@ -1260,7 +_,8 @@ - } +@@ -1228,7 +_,8 @@ + this.graphicsMode.set(isTrue(optional.get()) ? GraphicsStatus.FANCY : GraphicsStatus.FAST); } - this.processOptions( @@ -62,8 +62,8 @@ + processor.accept( new Options.FieldAccess() { @Nullable - private String getValueOrNull(String p_168459_) { -@@ -1451,6 +_,7 @@ + private String getValue(String p_394210_) { +@@ -1433,6 +_,7 @@ } public void broadcastOptions() { @@ -71,7 +71,7 @@ if (this.minecraft.player != null) { this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation()); } -@@ -1564,6 +_,23 @@ +@@ -1546,6 +_,23 @@ public static Component genericValueLabel(Component p_231901_, int p_231902_) { return genericValueLabel(p_231901_, Component.literal(Integer.toString(p_231902_))); diff --git a/patches/minecraft/net/minecraft/client/Screenshot.java.patch b/patches/minecraft/net/minecraft/client/Screenshot.java.patch index 8dc41417f8..3c58f917d7 100644 --- a/patches/minecraft/net/minecraft/client/Screenshot.java.patch +++ b/patches/minecraft/net/minecraft/client/Screenshot.java.patch @@ -1,30 +1,32 @@ --- a/net/minecraft/client/Screenshot.java +++ b/net/minecraft/client/Screenshot.java -@@ -54,14 +_,24 @@ - file2 = new File(file1, p_92307_); - } +@@ -43,6 +_,13 @@ + file2 = new File(file1, p_92297_); + } -+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenshot(nativeimage, file2); -+ if (event.isCanceled()) { -+ p_92311_.accept(event.getCancelMessage()); -+ return; -+ } -+ final File target = event.getScreenshotFile(); ++ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenshot(p_389141_, file2); ++ if (event.isCanceled()) { ++ p_92301_.accept(event.getCancelMessage()); ++ return; ++ } ++ final File target = event.getScreenshotFile(); + - Util.ioPool() - .execute( - () -> { - try { -- nativeimage.writeToFile(file2); -- Component component = Component.literal(file2.getName()) -+ nativeimage.writeToFile(target); -+ Component component = Component.literal(target.getName()) - .withStyle(ChatFormatting.UNDERLINE) -- .withStyle(p_168608_ -> p_168608_.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file2.getAbsolutePath()))); -+ .withStyle(p_168608_ -> p_168608_.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, target.getAbsolutePath()))); -+ if (event.getResultMessage() != null) -+ p_92311_.accept(event.getResultMessage()); -+ else - p_92311_.accept(Component.translatable("screenshot.success", component)); - } catch (Exception exception) { - LOGGER.warn("Couldn't save screenshot", (Throwable)exception); + Util.ioPool() + .execute( + () -> { +@@ -50,10 +_,13 @@ + NativeImage $$4x = p_389141_; + + try { +- p_389141_.writeToFile(file2); +- Component component = Component.literal(file2.getName()) ++ p_389141_.writeToFile(target); ++ Component component = Component.literal(target.getName()) + .withStyle(ChatFormatting.UNDERLINE) + .withStyle(p_389149_ -> p_389149_.withClickEvent(new ClickEvent.OpenFile(file2.getAbsoluteFile()))); ++ if (event.getResultMessage() != null) ++ p_92301_.accept(event.getResultMessage()); ++ else + p_92301_.accept(Component.translatable("screenshot.success", component)); + } catch (Throwable throwable1) { + if (p_389141_ != null) { diff --git a/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch b/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch index ee5ebf41c7..66cbe4f364 100644 --- a/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch +++ b/patches/minecraft/net/minecraft/client/color/block/BlockColors.java.patch @@ -10,7 +10,7 @@ private final Map>> coloringStates = Maps.newHashMap(); public static BlockColors createDefault() { -@@ -90,11 +_,12 @@ +@@ -95,11 +_,12 @@ }, Blocks.MELON_STEM, Blocks.PUMPKIN_STEM); blockcolors.addColoringState(StemBlock.AGE, Blocks.MELON_STEM, Blocks.PUMPKIN_STEM); blockcolors.register((p_92596_, p_92597_, p_92598_, p_92599_) -> p_92597_ != null && p_92598_ != null ? -14647248 : -9321636, Blocks.LILY_PAD); @@ -24,7 +24,7 @@ if (blockcolor != null) { return blockcolor.getColor(p_92583_, null, null, 0); } else { -@@ -104,13 +_,15 @@ +@@ -109,13 +_,15 @@ } public int getColor(BlockState p_92578_, @Nullable BlockAndTintGetter p_92579_, @Nullable BlockPos p_92580_, int p_92581_) { diff --git a/patches/minecraft/net/minecraft/client/data/models/ModelProvider.java.patch b/patches/minecraft/net/minecraft/client/data/models/ModelProvider.java.patch index a1f7b8da70..21bc63f439 100644 --- a/patches/minecraft/net/minecraft/client/data/models/ModelProvider.java.patch +++ b/patches/minecraft/net/minecraft/client/data/models/ModelProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/data/models/ModelProvider.java +++ b/net/minecraft/client/data/models/ModelProvider.java -@@ -43,11 +_,11 @@ +@@ -45,11 +_,11 @@ @Override public CompletableFuture run(CachedOutput p_376268_) { @@ -16,7 +16,7 @@ modelprovider$blockstategeneratorcollector.validate(); modelprovider$iteminfocollector.finalizeAndValidate(); return CompletableFuture.allOf( -@@ -57,6 +_,22 @@ +@@ -59,6 +_,22 @@ ); } @@ -36,13 +36,13 @@ + return new ItemModelGenerators(items, models); + } + - static CompletableFuture saveAll(CachedOutput p_378816_, Function p_377914_, Map> p_377836_) { - return DataProvider.saveAll(p_378816_, Supplier::get, p_377914_, p_377836_); - } -@@ -69,6 +_,15 @@ + @Override + public final String getName() { + return "Model Definitions"; +@@ -67,6 +_,15 @@ @OnlyIn(Dist.CLIENT) - public static class BlockStateGeneratorCollector implements Consumer { - private final Map generators = new HashMap<>(); + public static class BlockStateGeneratorCollector implements Consumer { + private final Map generators = new HashMap<>(); + private final Supplier> known; + + public BlockStateGeneratorCollector() { @@ -53,9 +53,9 @@ + this.known = known; + } - public void accept(BlockStateGenerator p_378147_) { - Block block = p_378147_.getBlock(); -@@ -79,7 +_,7 @@ + public void accept(BlockModelDefinitionGenerator p_393399_) { + Block block = p_393399_.block(); +@@ -77,7 +_,7 @@ } public void validate() { diff --git a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch index 1687e9df6c..f500066361 100644 --- a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch +++ b/patches/minecraft/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 -@@ -147,7 +_,7 @@ +@@ -148,7 +_,7 @@ public float vignetteBrightness = 1.0F; private int toolHighlightTimer; private ItemStack lastToolHighlight = ItemStack.EMPTY; @@ -9,16 +9,16 @@ private final SubtitleOverlay subtitleOverlay; private final SpectatorGui spectatorGui; private final PlayerTabOverlay tabList; -@@ -345,7 +_,7 @@ +@@ -347,7 +_,7 @@ Window window = this.minecraft.getWindow(); - int i = Mth.floor(this.minecraft.mouseHandler.xpos() * (double)window.getGuiScaledWidth() / (double)window.getScreenWidth()); - int j = Mth.floor(this.minecraft.mouseHandler.ypos() * (double)window.getGuiScaledHeight() / (double)window.getScreenHeight()); + int i = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window)); + int j = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window)); - this.chat.render(p_329202_, this.tickCount, i, j, false); + net.minecraftforge.client.ForgeHooksClient.onCustomizeChatEvent(p_329202_, this.chat, window, i, j, this.tickCount); } } -@@ -443,6 +_,8 @@ +@@ -445,6 +_,8 @@ for (MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { Holder holder = mobeffectinstance.getEffect(); @@ -27,7 +27,7 @@ if (mobeffectinstance.showIcon()) { int k = p_282812_.guiWidth(); int l = 1; -@@ -473,6 +_,7 @@ +@@ -475,6 +_,7 @@ } } @@ -35,7 +35,7 @@ TextureAtlasSprite textureatlassprite = mobeffecttexturemanager.get(holder); int l1 = k; int k1 = l; -@@ -623,6 +_,10 @@ +@@ -625,6 +_,10 @@ } private void renderSelectedItemName(GuiGraphics p_283501_) { @@ -46,7 +46,7 @@ Profiler.get().push("selectedItemName"); if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) { MutableComponent mutablecomponent = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color()); -@@ -630,9 +_,13 @@ +@@ -632,9 +_,13 @@ mutablecomponent.withStyle(ChatFormatting.ITALIC); } @@ -62,7 +62,7 @@ if (!this.minecraft.gameMode.canHurtPlayer()) { k += 14; } -@@ -643,7 +_,7 @@ +@@ -645,7 +_,7 @@ } if (l > 0) { @@ -71,8 +71,8 @@ } } -@@ -1152,7 +_,7 @@ - ItemStack itemstack = this.minecraft.player.getInventory().getSelected(); +@@ -1154,7 +_,7 @@ + ItemStack itemstack = this.minecraft.player.getInventory().getSelectedItem(); if (itemstack.isEmpty()) { this.toolHighlightTimer = 0; - } else if (this.lastToolHighlight.isEmpty() || !itemstack.is(this.lastToolHighlight.getItem()) || !itemstack.getHoverName().equals(this.lastToolHighlight.getHoverName())) { diff --git a/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch index deef495d95..9b076126b1 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiGraphics.java.patch @@ -31,9 +31,9 @@ + // Forge: Add float variant for x,y coordinates + public int drawString(Font p_282636_, FormattedCharSequence p_281596_, float p_281586_, float p_282816_, int p_281743_, boolean p_282394_) { return p_282636_.drawInBatch( - p_281596_, - (float)p_281586_, -@@ -859,6 +_,7 @@ + p_281596_, p_281586_, p_282816_, p_281743_, p_282394_, this.pose.last().pose(), this.bufferSource, Font.DisplayMode.NORMAL, 0, 15728880 + ); +@@ -850,6 +_,7 @@ CrashReport crashreport = CrashReport.forThrowable(throwable, "Rendering item"); CrashReportCategory crashreportcategory = crashreport.addCategory("Item being rendered"); crashreportcategory.setDetail("Item Type", () -> String.valueOf(p_281675_.getItem())); @@ -41,7 +41,7 @@ crashreportcategory.setDetail("Item Components", () -> String.valueOf(p_281675_.getComponents())); crashreportcategory.setDetail("Item Foil", () -> String.valueOf(p_281675_.hasFoil())); throw new ReportedException(crashreport); -@@ -879,13 +_,24 @@ +@@ -870,13 +_,24 @@ this.renderItemCount(p_282005_, p_283349_, p_282641_, p_282146_, p_282803_); this.renderItemCooldown(p_283349_, p_282641_, p_282146_); this.pose.popPose(); @@ -66,7 +66,7 @@ } public void renderTooltip(Font p_283128_, List p_282716_, Optional p_281682_, int p_283678_, int p_281696_) { -@@ -895,8 +_,7 @@ +@@ -886,8 +_,7 @@ public void renderTooltip( Font p_362491_, List p_368544_, Optional p_362815_, int p_366300_, int p_368952_, @Nullable ResourceLocation p_368469_ ) { @@ -76,7 +76,7 @@ this.renderTooltipInternal(p_362491_, list, p_366300_, p_368952_, DefaultTooltipPositioner.INSTANCE, p_368469_); } -@@ -909,7 +_,22 @@ +@@ -900,7 +_,22 @@ } public void renderComponentTooltip(Font p_282739_, List p_281832_, int p_282191_, int p_282446_) { @@ -100,7 +100,7 @@ } public void renderComponentTooltip(Font p_369090_, List p_365405_, int p_368143_, int p_366244_, @Nullable ResourceLocation p_364763_) { -@@ -951,11 +_,13 @@ +@@ -942,11 +_,13 @@ @Nullable ResourceLocation p_368234_ ) { if (!p_282615_.isEmpty()) { @@ -115,7 +115,7 @@ if (k > i) { i = k; } -@@ -965,18 +_,19 @@ +@@ -956,18 +_,19 @@ int i2 = i; int j2 = j; @@ -138,7 +138,7 @@ k1 += clienttooltipcomponent1.getHeight(p_282675_) + (l1 == 0 ? 2 : 0); } -@@ -984,7 +_,7 @@ +@@ -975,7 +_,7 @@ for (int k2 = 0; k2 < p_282615_.size(); k2++) { ClientTooltipComponent clienttooltipcomponent2 = p_282615_.get(k2); @@ -147,8 +147,8 @@ k1 += clienttooltipcomponent2.getHeight(p_282675_) + (k2 == 0 ? 2 : 0); } -@@ -1041,6 +_,10 @@ - } +@@ -1030,6 +_,10 @@ + default: } } + } diff --git a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch index b9aae530d0..d61101a232 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/DebugScreenOverlay.java +++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java -@@ -105,9 +_,9 @@ +@@ -134,9 +_,9 @@ @Nullable private CompletableFuture serverChunk; private boolean renderDebug; @@ -13,7 +13,7 @@ private final LocalSampleLogger frameTimeLogger = new LocalSampleLogger(1); private final LocalSampleLogger tickTimeLogger = new LocalSampleLogger(TpsDebugDimensions.values().length); private final LocalSampleLogger pingLogger = new LocalSampleLogger(1); -@@ -135,14 +_,18 @@ +@@ -179,14 +_,18 @@ this.clientChunk = null; } @@ -35,7 +35,7 @@ this.profilerPieChart.setBottomOffset(10); if (this.renderFpsCharts) { int i = p_281427_.guiWidth(); -@@ -155,7 +_,9 @@ +@@ -199,7 +_,9 @@ this.profilerPieChart.setBottomOffset(this.tpsChart.getFullHeight()); } @@ -45,7 +45,7 @@ if (this.renderNetworkCharts) { int l = p_281427_.guiWidth(); int i1 = l / 2; -@@ -171,12 +_,22 @@ +@@ -215,12 +_,22 @@ try (Zone zone = profilerfiller.zone("profilerPie")) { this.profilerPieChart.render(p_281427_); } @@ -70,7 +70,7 @@ list.add(""); boolean flag = this.minecraft.getSingleplayerServer() != null; list.add( -@@ -190,11 +_,18 @@ +@@ -234,11 +_,18 @@ + (this.renderNetworkCharts ? " visible" : " hidden") ); list.add("For help: press F3 + Q"); @@ -90,7 +90,7 @@ this.renderLines(p_281261_, list, false); } -@@ -543,6 +_,7 @@ +@@ -592,6 +_,7 @@ list.add(""); list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()))); diff --git a/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastManager.java.patch b/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastManager.java.patch index d0fa544e40..e657afdccf 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastManager.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/toasts/ToastManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/toasts/ToastManager.java +++ b/net/minecraft/client/gui/components/toasts/ToastManager.java -@@ -107,6 +_,7 @@ +@@ -127,6 +_,7 @@ } public void addToast(Toast p_360768_) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch index 5c59bdff1f..13fd69243a 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch @@ -9,17 +9,17 @@ @Override public void render(GuiGraphics p_281839_, int p_282704_, int p_283650_, float p_283394_) { int i = p_281839_.guiWidth(); -@@ -99,6 +_,7 @@ +@@ -95,6 +_,7 @@ f2 = 1.0F; } + if (renderContents(p_281839_, f2)) { - int k2 = (int)((double)p_281839_.guiWidth() * 0.5); - int l2 = (int)((double)p_281839_.guiHeight() * 0.5); - double d1 = Math.min((double)p_281839_.guiWidth() * 0.75, (double)p_281839_.guiHeight()) * 0.25; -@@ -114,12 +_,14 @@ + int l2 = (int)(p_281839_.guiWidth() * 0.5); + int i1 = (int)(p_281839_.guiHeight() * 0.5); + double d0 = Math.min(p_281839_.guiWidth() * 0.75, (double)p_281839_.guiHeight()) * 0.25; +@@ -110,12 +_,14 @@ if (f < 1.0F) { - this.drawProgressBar(p_281839_, i / 2 - j1, l1 - 5, i / 2 + j1, l1 + 5, 1.0F - Mth.clamp(f, 0.0F, 1.0F)); + this.drawProgressBar(p_281839_, i / 2 - k1, i2 - 5, i / 2 + k1, i2 + 5, 1.0F - Mth.clamp(f, 0.0F, 1.0F)); } + } @@ -32,7 +32,7 @@ try { this.reload.checkExceptions(); this.onFinish.accept(Optional.empty()); -@@ -127,7 +_,6 @@ +@@ -123,7 +_,6 @@ this.onFinish.accept(Optional.of(throwable)); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch index b2ffeb2dd9..e2b65e56e0 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch +++ b/patches/minecraft/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 -@@ -200,7 +_,7 @@ +@@ -197,7 +_,7 @@ } public void onClose() { @@ -39,7 +39,7 @@ } protected void renderBlurredBackground() { -@@ -454,6 +_,19 @@ +@@ -453,6 +_,19 @@ } public void onFilesDrop(List p_96591_) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch index ddd9a85098..50a625950f 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch +++ b/patches/minecraft/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 -@@ -38,6 +_,7 @@ +@@ -39,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_297568_, DisplayInfo p_97150_ -@@ -54,6 +_,15 @@ +@@ -55,6 +_,15 @@ this.addWidget(this.root, p_297568_.holder()); } @@ -24,7 +24,7 @@ public AdvancementTabType getType() { return this.type; } -@@ -147,8 +_,8 @@ +@@ -148,8 +_,8 @@ return null; } else { for (AdvancementTabType advancementtabtype : AdvancementTabType.values()) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch index f39b9b6186..c9e0eceaf0 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch @@ -55,6 +55,6 @@ if (this.tabs.size() > 1) { for (AdvancementTab advancementtab : this.tabs.values()) { + if (advancementtab.getPage() == tabPage) - if (advancementtab.isMouseOver(p_281519_, p_283371_, (double)p_283556_, (double)p_282458_)) { + if (advancementtab.isMouseOver(p_281519_, p_283371_, p_283556_, p_282458_)) { p_282784_.renderTooltip(this.font, advancementtab.getTitle(), p_283556_, p_282458_); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch index f12164fe27..df022baabc 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch @@ -6,7 +6,7 @@ super.render(p_283479_, p_283661_, p_281248_, p_281886_); + net.minecraftforge.client.event.ForgeEventFactoryClient.onContainerRenderBackground(this, p_283479_, p_283661_, p_281248_); p_283479_.pose().pushPose(); - p_283479_.pose().translate((float)i, (float)j, 0.0F); + p_283479_.pose().translate(i, j, 0.0F); Slot slot = this.hoveredSlot; @@ -117,6 +_,8 @@ this.onStopHovering(slot); @@ -40,7 +40,7 @@ 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(); +- boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_97750_) && this.minecraft.player.hasInfiniteMaterials(); + InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97750_); + boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey); Slot slot = this.getHoveredSlot(p_97748_, p_97749_); @@ -72,7 +72,7 @@ this.quickCraftingType = 2; } } -@@ -464,10 +_,13 @@ +@@ -461,10 +_,13 @@ @Override public boolean mouseReleased(double p_97812_, double p_97813_, int p_97814_) { @@ -86,7 +86,7 @@ int k = -1; if (slot != null) { k = slot.index; -@@ -484,7 +_,7 @@ +@@ -481,7 +_,7 @@ if (slot2 != null && slot2.mayPickup(this.minecraft.player) && slot2.hasItem() @@ -95,7 +95,7 @@ && AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) { this.slotClicked(slot2, slot2.index, p_97814_, ClickType.QUICK_MOVE); } -@@ -548,7 +_,7 @@ +@@ -545,7 +_,7 @@ this.slotClicked(null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT); } else if (!this.menu.getCarried().isEmpty()) { @@ -104,7 +104,7 @@ this.slotClicked(slot, k, p_97814_, ClickType.CLONE); } else { boolean flag1 = k != -999 -@@ -628,9 +_,10 @@ +@@ -622,9 +_,10 @@ @Override public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) { @@ -116,7 +116,7 @@ this.onClose(); return true; } else { -@@ -704,4 +_,11 @@ +@@ -698,4 +_,11 @@ super.onClose(); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch index 91cf1163ff..57e5fbecae 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch @@ -20,7 +20,7 @@ this.menu.items.addAll(p_261591_); @@ -330,6 +_,35 @@ protected void init() { - if (this.minecraft.gameMode.hasInfiniteItems()) { + if (this.minecraft.player.hasInfiniteMaterials()) { super.init(); + this.pages.clear(); + int tabIndex = 0; @@ -98,14 +98,14 @@ protected void renderLabels(GuiGraphics p_283168_, int p_281774_, int p_281466_) { if (selectedTab.showTitle()) { - p_283168_.drawString(this.font, selectedTab.getDisplayName(), 8, 6, 4210752, false); -+ com.mojang.blaze3d.systems.RenderSystem.disableBlend(); ++ com.mojang.blaze3d.opengl.GlStateManager._disableBlend(); + p_283168_.drawString(this.font, selectedTab.getDisplayName(), 8, 6, selectedTab.getLabelColor(), false); } } @@ -488,7 +_,7 @@ - double d0 = p_98531_ - (double)this.leftPos; - double d1 = p_98532_ - (double)this.topPos; + double d0 = p_98531_ - this.leftPos; + double d1 = p_98532_ - this.topPos; - for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { + for (CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { @@ -113,7 +113,7 @@ return true; } @@ -510,7 +_,7 @@ - double d1 = p_98623_ - (double)this.topPos; + double d1 = p_98623_ - this.topPos; this.scrolling = false; - for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { @@ -138,7 +138,7 @@ this.refreshSearchResults(); } else { -@@ -676,7 +_,15 @@ +@@ -673,7 +_,15 @@ super.render(p_283000_, p_281317_, p_282770_, p_281295_); this.effects.render(p_283000_, p_281317_, p_282770_, p_281295_); @@ -155,7 +155,7 @@ if (this.checkTabHovering(p_283000_, creativemodetab, p_281317_, p_282770_)) { break; } -@@ -688,6 +_,7 @@ +@@ -685,6 +_,7 @@ p_283000_.renderTooltip(this.font, TRASH_SLOT_TOOLTIP, p_281317_, p_282770_); } @@ -163,7 +163,7 @@ this.renderTooltip(p_283000_, p_281317_, p_282770_); } -@@ -700,7 +_,7 @@ +@@ -697,7 +_,7 @@ public List getTooltipFromContainerItem(ItemStack p_281769_) { boolean flag = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot; boolean flag1 = selectedTab.getType() == CreativeModeTab.Type.CATEGORY; @@ -172,16 +172,16 @@ TooltipFlag.Default tooltipflag$default = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL; TooltipFlag tooltipflag = flag ? tooltipflag$default.asCreative() : tooltipflag$default; List list = p_281769_.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipflag); -@@ -719,7 +_,7 @@ +@@ -718,7 +_,7 @@ int i = 1; for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { - if (creativemodetab.getType() != CreativeModeTab.Type.SEARCH && creativemodetab.contains(p_281769_)) { -+ if (!creativemodetab.hasSearchBar() && creativemodetab.contains(p_281769_)) { ++ if (creativemodetab.hasSearchBar() && creativemodetab.contains(p_281769_)) { list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE)); } } -@@ -730,7 +_,7 @@ +@@ -729,7 +_,7 @@ @Override protected void renderBg(GuiGraphics p_282663_, float p_282504_, int p_282089_, int p_282249_) { @@ -190,15 +190,15 @@ if (creativemodetab != selectedTab) { this.renderTabButton(p_282663_, creativemodetab); } -@@ -746,6 +_,7 @@ - p_282663_.blitSprite(RenderType::guiTextured, resourcelocation, j, k + (int)((float)(i - k - 17) * this.scrollOffs), 12, 15); +@@ -745,6 +_,7 @@ + p_282663_.blitSprite(RenderType::guiTextured, resourcelocation, j, k + (int)((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( -@@ -764,7 +_,7 @@ +@@ -763,7 +_,7 @@ } private int getTabX(CreativeModeTab p_260136_) { @@ -207,7 +207,7 @@ int j = 27; int k = 27 * i; if (p_260136_.isAlignedRight()) { -@@ -776,7 +_,7 @@ +@@ -775,7 +_,7 @@ private int getTabY(CreativeModeTab p_260181_) { int i = 0; @@ -216,7 +216,7 @@ i -= 32; } else { i += this.imageHeight; -@@ -804,8 +_,8 @@ +@@ -803,8 +_,8 @@ protected void renderTabButton(GuiGraphics p_283590_, CreativeModeTab p_283489_) { boolean flag = p_283489_ == selectedTab; @@ -227,15 +227,15 @@ int j = this.leftPos + this.getTabX(p_283489_); int k = this.topPos - (flag1 ? 28 : -(this.imageHeight - 4)); ResourceLocation[] aresourcelocation; -@@ -815,6 +_,7 @@ +@@ -814,6 +_,7 @@ aresourcelocation = flag ? SELECTED_BOTTOM_TABS : UNSELECTED_BOTTOM_TABS; } -+ com.mojang.blaze3d.systems.RenderSystem.enableBlend(); //Forge: Make sure blend is enabled else tabs show a white border. ++ com.mojang.blaze3d.opengl.GlStateManager._enableBlend(); //Forge: Make sure blend is enabled else tabs show a white border. 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); -@@ -856,6 +_,14 @@ +@@ -855,6 +_,14 @@ } } @@ -250,7 +250,7 @@ @OnlyIn(Dist.CLIENT) static class CustomCreativeSlot extends Slot { public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) { -@@ -1037,6 +_,22 @@ +@@ -1036,6 +_,22 @@ @Override public boolean mayPickup(Player p_98665_) { return this.target.mayPickup(p_98665_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch index 53c7b11e43..8901e5d902 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch @@ -4,8 +4,8 @@ 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{ +- if ((k < l + 1 || this.minecraft.player.experienceLevel < k1) && !this.minecraft.player.hasInfiniteMaterials()) { ++ if (((k < l + 1 || this.minecraft.player.experienceLevel < k1) && !this.minecraft.player.hasInfiniteMaterials()) || this.menu.enchantClue[l] == -1) { // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels{ 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, false); @@ -17,7 +17,7 @@ + { int l = this.menu.levelClue[j]; int i1 = j + 1; -- if (this.isHovering(60, 14 + 19 * j, 108, 17, (double)p_282491_, (double)p_281953_) && k > 0 && l >= 0 && optional != null) { +- if (this.isHovering(60, 14 + 19 * j, 108, 17, p_282491_, p_281953_) && k > 0 && l >= 0 && optional != null) { + if (this.isHovering(60, 14 + 19 * j, 108, 17, (double)p_282491_, (double)p_281953_) && k > 0) { List list = Lists.newArrayList(); - list.add(Component.translatable("container.enchant.clue", Enchantment.getFullname(optional.get(), l)).withStyle(ChatFormatting.WHITE)); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch index bbf34272e3..5fa71a34da 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java +++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java -@@ -25,7 +_,7 @@ +@@ -22,7 +_,7 @@ case ClientActivePlayersTooltip.ActivePlayersTooltip clientactiveplayerstooltip$activeplayerstooltip -> new ClientActivePlayersTooltip( - clientactiveplayerstooltip$activeplayerstooltip - ); + clientactiveplayerstooltip$activeplayerstooltip + ); - default -> throw new IllegalArgumentException("Unknown TooltipComponent"); + default -> net.minecraftforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(p_169951_); }); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch index 0c30ae1842..f0cff3c860 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch @@ -11,7 +11,7 @@ + .bounds(0, 0, 75 + 20 /* Forge: Add space */, 20) .createNarration( p_342179_ -> p_343088_.isUnbound() - ? Component.translatable("narrator.controls.unbound", p_343976_) + ? Component.translatable("narrator.controls.unbound", p_343976_) @@ -158,7 +_,7 @@ ) .build(); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch index 0eb7369f43..04e2ad228e 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/packs/PackSelectionScreen.java.patch @@ -6,6 +6,6 @@ p_100014_.setSelected(null); - p_100015_.forEach( + p_100015_.filter(PackSelectionModel.Entry::notHidden).forEach( - p_374582_ -> { + p_389318_ -> { TransferableSelectionList.PackEntry transferableselectionlist$packentry1 = new TransferableSelectionList.PackEntry( - this.minecraft, p_100014_, p_374582_ + this.minecraft, p_100014_, p_389318_ diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch index 8362cba197..7e26fdfda3 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java +++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java -@@ -168,6 +_,7 @@ - ) { - queueLoadScreen(p_369292_, PREPARING_WORLD_DATA); - PackRepository packrepository = new PackRepository(new ServerPacksSource(p_369292_.directoryValidator())); +@@ -171,6 +_,7 @@ + WorldDataConfiguration worlddataconfiguration = SharedConstants.IS_RUNNING_IN_IDE + ? new WorldDataConfiguration(new DataPackConfig(List.of("vanilla", "tests"), List.of()), FeatureFlags.DEFAULT_FLAGS) + : WorldDataConfiguration.DEFAULT; + net.minecraftforge.event.ForgeEventFactory.addPackFindersServer(packrepository::addPackFinder); - WorldLoader.InitConfig worldloader$initconfig = createDefaultLoadConfig(packrepository, WorldDataConfiguration.DEFAULT); + WorldLoader.InitConfig worldloader$initconfig = createDefaultLoadConfig(packrepository, worlddataconfiguration); CompletableFuture completablefuture = WorldLoader.load( worldloader$initconfig, -@@ -468,7 +_,7 @@ +@@ -471,7 +_,7 @@ if (p_269627_) { p_270552_.accept(this.uiState.getSettings().dataConfiguration()); } else { @@ -17,7 +17,7 @@ } }, Component.translatable("dataPack.validation.failed"), -@@ -582,6 +_,7 @@ +@@ -585,6 +_,7 @@ if (path != null) { if (this.tempDataPackRepository == null) { this.tempDataPackRepository = ServerPacksSource.createPackRepository(path, this.packValidator); diff --git a/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch b/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch index 802af04216..2dad4bbb94 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/LayerDefinitions.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java -@@ -464,6 +_,7 @@ - builder.put(ModelLayers.createHangingSignModelName(p_374591_, hangingsignrenderer$attachmenttype), layerdefinition55); +@@ -497,6 +_,7 @@ + builder.put(ModelLayers.createHangingSignModelName(p_374591_, hangingsignrenderer$attachmenttype), layerdefinition60); } }); + net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(builder); diff --git a/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch b/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch index d0200e2142..41d5b58fc6 100644 --- a/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch +++ b/patches/minecraft/net/minecraft/client/model/geom/ModelLayers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/model/geom/ModelLayers.java +++ b/net/minecraft/client/model/geom/ModelLayers.java -@@ -308,15 +_,18 @@ +@@ -330,15 +_,18 @@ } public static ModelLayerLocation createStandingSignModelName(WoodType p_171292_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch index 1621efa410..57ea968d12 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientChunkCache.java +++ b/net/minecraft/client/multiplayer/ClientChunkCache.java -@@ -63,6 +_,7 @@ +@@ -64,6 +_,7 @@ int i = this.storage.getIndex(p_298665_.x, p_298665_.z); LevelChunk levelchunk = this.storage.getChunk(i); if (isValidChunk(levelchunk, p_298665_.x, p_298665_.z)) { @@ -8,7 +8,7 @@ this.storage.drop(i, levelchunk); } } -@@ -124,6 +_,7 @@ +@@ -125,6 +_,7 @@ } this.level.onChunkLoaded(chunkpos); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch index e8ef0efe00..2598d4df90 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java -@@ -142,6 +_,7 @@ - ); - this.connection.send(ServerboundFinishConfigurationPacket.INSTANCE); - this.connection.setupOutboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(registryaccess$frozen))); +@@ -147,6 +_,7 @@ + return true; + } + })); + net.minecraftforge.common.ForgeHooks.handleClientConfigurationComplete(this.connection); } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch index 6858b16c24..4c7386b114 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/multiplayer/ClientLevel.java +++ b/net/minecraft/client/multiplayer/ClientLevel.java -@@ -123,6 +_,7 @@ - p_194170_.put(BiomeColors.GRASS_COLOR_RESOLVER, new BlockTintCache(p_194181_ -> this.calculateBlockTint(p_194181_, BiomeColors.GRASS_COLOR_RESOLVER))); - p_194170_.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_194177_ -> this.calculateBlockTint(p_194177_, BiomeColors.FOLIAGE_COLOR_RESOLVER))); - p_194170_.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(p_194168_ -> this.calculateBlockTint(p_194168_, BiomeColors.WATER_COLOR_RESOLVER))); -+ net.minecraftforge.client.ColorResolverManager.registerBlockTintCaches(ClientLevel.this, p_194170_); +@@ -126,6 +_,7 @@ + p_389331_.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_194177_ -> this.calculateBlockTint(p_194177_, BiomeColors.FOLIAGE_COLOR_RESOLVER))); + p_389331_.put(BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER, new BlockTintCache(p_389335_ -> this.calculateBlockTint(p_389335_, BiomeColors.DRY_FOLIAGE_COLOR_RESOLVER))); + p_389331_.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(p_194168_ -> this.calculateBlockTint(p_194168_, BiomeColors.WATER_COLOR_RESOLVER))); ++ net.minecraftforge.client.ColorResolverManager.registerBlockTintCaches(ClientLevel.this, p_389331_); }); private final ClientChunkCache chunkSource; private final Deque lightUpdateQueue = Queues.newArrayDeque(); -@@ -131,6 +_,8 @@ +@@ -134,6 +_,8 @@ private final int seaLevel; private boolean tickDayTime; private static final Set MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT); @@ -17,7 +17,7 @@ public void handleBlockChangedAck(int p_233652_) { this.blockStatePredictionHandler.endPredictionsUpTo(p_233652_, this); -@@ -197,6 +_,8 @@ +@@ -200,6 +_,8 @@ this.serverSimulationDistance = p_364305_; this.updateSkyBrightness(); this.prepareWeather(); @@ -26,7 +26,7 @@ } public void queueLightUpdate(Runnable p_194172_) { -@@ -279,6 +_,7 @@ +@@ -282,6 +_,7 @@ p_104640_.setOldPosAndRot(); p_104640_.tickCount++; Profiler.get().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString()); @@ -34,7 +34,7 @@ p_104640_.tick(); Profiler.get().pop(); -@@ -330,8 +_,10 @@ +@@ -333,8 +_,10 @@ } public void addEntity(Entity p_104741_) { @@ -45,7 +45,7 @@ } public void removeEntity(int p_171643_, Entity.RemovalReason p_171644_) { -@@ -502,6 +_,12 @@ +@@ -516,6 +_,12 @@ float p_263349_, long p_263408_ ) { @@ -55,12 +55,12 @@ + p_263417_ = event.getSource(); + p_263416_ = event.getNewVolume(); + p_263349_ = event.getNewPitch(); - if (p_263381_ == this.minecraft.player) { + if (p_394722_ == 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 @@ +@@ -525,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_ + @Nullable Entity p_263536_, Entity p_396496_, Holder p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_ ) { + var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_263536_, p_263518_, p_263487_, p_263538_, p_263524_); + if (event.isCanceled() || event.getSound() == null) return; @@ -68,11 +68,11 @@ + p_263487_ = event.getSource(); + p_263538_ = event.getNewVolume(); + p_263524_ = event.getNewPitch(); - 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_)); + if (p_263536_ == this.minecraft.player) { + this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_263518_.value(), p_263487_, p_263538_, p_263524_, p_396496_, p_263509_)); } -@@ -953,6 +_,24 @@ - return this.seaLevel; +@@ -975,6 +_,16 @@ + this.connection.registerForCleaning(p_396040_); } + @Override @@ -84,19 +84,11 @@ + public net.minecraftforge.client.model.data.ModelDataManager getModelDataManager() { + return modelDataManager; + } -+ -+ @Override -+ public float getShade(float normalX, float normalY, float normalZ, boolean shade) { -+ boolean constantAmbientLight = this.effects().constantAmbientLight(); -+ if (!shade) -+ return constantAmbientLight ? 0.9F : 1.0F; -+ return net.minecraftforge.client.model.lighting.QuadLighter.calculateShade(normalX, normalY, normalZ, constantAmbientLight); -+ } + @OnlyIn(Dist.CLIENT) public static class ClientLevelData implements WritableLevelData { private final boolean hardcore; -@@ -1041,6 +_,7 @@ +@@ -1063,6 +_,7 @@ } public void setDifficulty(Difficulty p_104852_) { @@ -104,7 +96,7 @@ this.difficulty = p_104852_; } -@@ -1084,6 +_,12 @@ +@@ -1105,6 +_,12 @@ break; default: } @@ -117,7 +109,7 @@ } public void onTrackingEnd(Entity p_171716_) { -@@ -1097,6 +_,15 @@ +@@ -1117,6 +_,15 @@ ClientLevel.this.dragonParts.removeAll(Arrays.asList(enderdragon.getSubEntities())); break; default: diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch index 8be7186f6c..c265cd2777 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch +++ b/patches/minecraft/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 -@@ -452,6 +_,7 @@ +@@ -477,6 +_,7 @@ this.minecraft.debugRenderer.clear(); this.minecraft.player.resetPos(); @@ -8,7 +8,7 @@ this.minecraft.player.setId(p_105030_.playerId()); this.level.addEntity(this.minecraft.player); this.minecraft.player.input = new KeyboardInput(this.minecraft.options); -@@ -1249,6 +_,8 @@ +@@ -1263,6 +_,8 @@ localplayer1.getAttributes().assignBaseValues(localplayer.getAttributes()); } @@ -17,19 +17,16 @@ this.level.addEntity(localplayer1); localplayer1.input = new KeyboardInput(this.minecraft.options); this.minecraft.gameMode.adjustPlayer(localplayer1); -@@ -1393,10 +_,7 @@ +@@ -1407,7 +_,7 @@ PacketUtils.ensureRunningOnSameThread(p_104976_, this, this.minecraft); BlockPos blockpos = p_104976_.getPos(); - this.minecraft.level.getBlockEntity(blockpos, p_104976_.getType()).ifPresent(p_325478_ -> { -- CompoundTag compoundtag = p_104976_.getTag(); -- if (!compoundtag.isEmpty()) { -- p_325478_.loadWithComponents(compoundtag, this.registryAccess); -- } -+ p_325478_.onDataPacket(connection, p_104976_, this.registryAccess); - - if (p_325478_ instanceof CommandBlockEntity && this.minecraft.screen instanceof CommandBlockEditScreen) { + this.minecraft.level.getBlockEntity(blockpos, p_104976_.getType()).ifPresent(p_389343_ -> { +- p_389343_.loadWithComponents(p_104976_.getTag(), this.registryAccess); ++ p_389343_.onDataPacket(connection, p_104976_, this.registryAccess); + if (p_389343_ instanceof CommandBlockEntity && this.minecraft.screen instanceof CommandBlockEditScreen) { ((CommandBlockEditScreen)this.minecraft.screen).updateGui(); -@@ -1557,7 +_,9 @@ + } +@@ -1567,7 +_,9 @@ @Override public void handleCommands(ClientboundCommandsPacket p_104990_) { PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft); @@ -40,7 +37,7 @@ } @Override -@@ -1658,6 +_,7 @@ +@@ -1668,6 +_,7 @@ if (this.minecraft.screen instanceof RecipeUpdateListener recipeupdatelistener) { recipeupdatelistener.recipesUpdated(); } @@ -48,7 +45,7 @@ } @Override -@@ -1696,6 +_,8 @@ +@@ -1706,6 +_,8 @@ this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures); List list1 = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); this.searchTrees.updateCreativeTags(list1); @@ -57,7 +54,7 @@ } @Override -@@ -2530,6 +_,8 @@ +@@ -2548,6 +_,8 @@ } public void sendChat(String p_249888_) { @@ -66,7 +63,7 @@ Instant instant = Instant.now(); long i = Crypt.SaltSupplier.getLong(); LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.lastSeenMessages.generateAndApplyUpdate(); -@@ -2538,6 +_,7 @@ +@@ -2556,6 +_,7 @@ } public void sendCommand(String p_250092_) { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch index fe4dedbece..d597ce606b 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch +++ b/patches/minecraft/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 -@@ -107,6 +_,7 @@ +@@ -110,6 +_,7 @@ } public boolean destroyBlock(BlockPos p_105268_) { @@ -8,7 +8,7 @@ if (this.minecraft.player.blockActionRestricted(this.minecraft.level, p_105268_, this.localPlayerMode)) { return false; } else { -@@ -121,9 +_,8 @@ +@@ -124,9 +_,8 @@ } else if (blockstate.isAir()) { return false; } else { @@ -19,7 +19,7 @@ if (flag) { block.destroy(level, p_105268_, blockstate); } -@@ -144,6 +_,7 @@ +@@ -147,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_ -> { @@ -27,7 +27,7 @@ this.destroyBlock(p_105270_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233757_); }); -@@ -153,15 +_,18 @@ +@@ -156,15 +_,18 @@ this.connection .send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, p_105271_)); } @@ -46,7 +46,7 @@ if (flag && blockstate1.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105270_) >= 1.0F) { this.destroyBlock(p_105270_); } else { -@@ -172,6 +_,7 @@ +@@ -175,6 +_,7 @@ this.destroyTicks = 0.0F; this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage()); } @@ -54,7 +54,7 @@ return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233728_); }); -@@ -204,6 +_,7 @@ +@@ -207,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_ -> { @@ -62,7 +62,7 @@ this.destroyBlock(p_105284_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_, p_233753_); }); -@@ -216,7 +_,7 @@ +@@ -219,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) { @@ -71,7 +71,7 @@ this.minecraft .getSoundManager() .play( -@@ -233,6 +_,7 @@ +@@ -236,6 +_,7 @@ this.destroyTicks++; this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate, Mth.clamp(this.destroyProgress, 0.0F, 1.0F)); @@ -79,7 +79,7 @@ if (this.destroyProgress >= 1.0F) { this.isDestroying = false; this.startPrediction(this.minecraft.level, p_233739_ -> { -@@ -271,7 +_,7 @@ +@@ -274,7 +_,7 @@ private boolean sameDestroyTarget(BlockPos p_105282_) { ItemStack itemstack = this.minecraft.player.getMainHandItem(); @@ -88,7 +88,7 @@ } private void ensureHasSentCarriedItem() { -@@ -299,12 +_,23 @@ +@@ -302,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_); @@ -114,7 +114,7 @@ BlockState blockstate = this.minecraft.level.getBlockState(blockpos); if (!this.connection.isFeatureEnabled(blockstate.getBlock().requiredFeatures())) { return InteractionResult.FAIL; -@@ -325,8 +_,10 @@ +@@ -328,8 +_,10 @@ } } @@ -125,9 +125,9 @@ + } + if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack))) { InteractionResult interactionresult2; - if (this.localPlayerMode.isCreative()) { + if (p_233747_.hasInfiniteMaterials()) { int i = itemstack.getCount(); -@@ -360,6 +_,11 @@ +@@ -363,6 +_,11 @@ mutableobject.setValue(InteractionResult.PASS); return serverbounduseitempacket; } else { @@ -139,7 +139,7 @@ InteractionResult interactionresult = itemstack.use(this.minecraft.level, p_233722_, p_233723_); ItemStack itemstack1; if (interactionresult instanceof InteractionResult.Success interactionresult$success) { -@@ -370,6 +_,9 @@ +@@ -373,6 +_,9 @@ if (itemstack1 != itemstack) { p_233722_.setItemInHand(p_233723_, itemstack1); @@ -149,7 +149,7 @@ } mutableobject.setValue(interactionresult); -@@ -401,6 +_,10 @@ +@@ -404,6 +_,10 @@ public InteractionResult interact(Player p_105227_, Entity p_105228_, InteractionHand p_105229_) { this.ensureHasSentCarriedItem(); this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105228_, p_105227_.isShiftKeyDown(), p_105229_)); @@ -160,7 +160,7 @@ return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105227_.interactOn(p_105228_, p_105229_)); } -@@ -408,6 +_,10 @@ +@@ -411,6 +_,10 @@ 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)); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch index 3f0aa160ed..75c176cbff 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ServerData.java +++ b/net/minecraft/client/multiplayer/ServerData.java -@@ -34,6 +_,7 @@ +@@ -37,6 +_,7 @@ private byte[] iconBytes; private ServerData.Type type; private ServerData.State state = ServerData.State.INITIAL; diff --git a/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch index 86400f9a3e..f968d0a34a 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch @@ -11,7 +11,7 @@ private CompletableFuture> recipeSearch = CompletableFuture.completedFuture(SearchTree.empty()); private final Map reloaders = new IdentityHashMap<>(); -@@ -92,44 +_,52 @@ +@@ -90,44 +_,52 @@ } public void updateCreativeTags(List p_344581_) { @@ -53,11 +53,11 @@ + CompletableFuture completablefuture = this.creativeSearch.getOrDefault(entry.getValue(), EMPTY); + this.creativeSearch.put(entry.getValue(), CompletableFuture.supplyAsync( () -> new FullTextSearchTree<>( - p_345254_ -> getTooltipLines(Stream.of(p_345254_), item$tooltipcontext, tooltipflag), - p_344415_ -> p_344415_.getItemHolder().unwrapKey().map(ResourceKey::location).stream(), -- p_342500_ -+ items - ), + p_345254_ -> getTooltipLines(Stream.of(p_345254_), item$tooltipcontext, tooltipflag), + p_344415_ -> p_344415_.getItemHolder().unwrapKey().map(ResourceKey::location).stream(), +- p_342500_ ++ items + ), Util.backgroundExecutor() - ); + )); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch index c90cf3798d..0ea804a8b6 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/chat/ChatListener.java +++ b/net/minecraft/client/multiplayer/chat/ChatListener.java -@@ -118,7 +_,9 @@ +@@ -123,7 +_,9 @@ Instant instant = Instant.now(); this.handleMessage(null, () -> { Component component = p_251256_.decorate(p_250375_); @@ -11,7 +11,7 @@ this.narrateChatMessage(p_251256_, p_250375_); this.logSystemMessage(component, instant); this.previousMessageTime = Util.getMillis(); -@@ -137,12 +_,16 @@ +@@ -142,12 +_,16 @@ MessageSignature messagesignature = p_249430_.signature(); FilterMask filtermask = p_249430_.filterMask(); if (filtermask.isEmpty()) { @@ -30,7 +30,7 @@ this.narrateChatMessage(p_251766_, component); } } -@@ -175,6 +_,8 @@ +@@ -180,6 +_,8 @@ public void handleSystemMessage(Component p_240522_, boolean p_240642_) { if (!this.minecraft.options.hideMatchedNames().get() || !this.minecraft.isBlocked(this.guessChatUUID(p_240522_))) { diff --git a/patches/minecraft/net/minecraft/client/particle/FlyTowardsPositionParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/FlyTowardsPositionParticle.java.patch index 40c1bc8c52..8fd52f5f15 100644 --- a/patches/minecraft/net/minecraft/client/particle/FlyTowardsPositionParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/FlyTowardsPositionParticle.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/particle/FlyTowardsPositionParticle.java +++ b/net/minecraft/client/particle/FlyTowardsPositionParticle.java @@ -104,6 +_,7 @@ - this.x = this.xStart + this.xd * (double)f; - this.y = this.yStart + this.yd * (double)f - (double)(f1 * 1.2F); - this.z = this.zStart + this.zd * (double)f; + this.x = this.xStart + this.xd * f; + this.y = this.yStart + this.yd * f - f1 * 1.2F; + this.z = this.zStart + this.zd * f; + this.setPos(this.x, this.y, this.z); // FORGE: update the particle's bounding box } } diff --git a/patches/minecraft/net/minecraft/client/particle/Particle.java.patch b/patches/minecraft/net/minecraft/client/particle/Particle.java.patch index 1cb94ee68e..353390c723 100644 --- a/patches/minecraft/net/minecraft/client/particle/Particle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/Particle.java.patch @@ -17,5 +17,5 @@ + } + @OnlyIn(Dist.CLIENT) - public static record LifetimeAlpha(float startAlpha, float endAlpha, float startAtNormalizedAge, float endAtNormalizedAge) { + public record LifetimeAlpha(float startAlpha, float endAlpha, float startAtNormalizedAge, float endAtNormalizedAge) { public static final Particle.LifetimeAlpha ALWAYS_OPAQUE = new Particle.LifetimeAlpha(1.0F, 1.0F, 0.0F, 1.0F); diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch index 0785e5fe4f..f195225c68 100644 --- a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch @@ -1,13 +1,12 @@ --- a/net/minecraft/client/particle/ParticleEngine.java +++ b/net/minecraft/client/particle/ParticleEngine.java -@@ -72,11 +_,11 @@ +@@ -72,10 +_,10 @@ private static final int MAX_PARTICLES_PER_LAYER = 16384; private static final List RENDER_ORDER = List.of(ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT); protected ClientLevel level; - private final Map> particles = Maps.newIdentityHashMap(); + private final Map> particles = Maps.newTreeMap(net.minecraftforge.client.ForgeHooksClient.makeParticleRenderTypeComparator(RENDER_ORDER)); private final Queue trackingEmitters = Queues.newArrayDeque(); - private final TextureManager textureManager; private final RandomSource random = RandomSource.create(); - private final Int2ObjectMap> providers = new Int2ObjectOpenHashMap<>(); + private final Map> providers = new java.util.HashMap<>(); @@ -15,7 +14,7 @@ private final Map spriteSets = Maps.newHashMap(); private final TextureAtlas textureAtlas; @@ -205,10 +_,14 @@ - this.register(ParticleTypes.BLOCK_CRUMBLE, new TerrainParticle.CrumblingProvider()); + this.register(ParticleTypes.FIREFLY, FireflyParticle.FireflyProvider::new); } + /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ @@ -139,7 +138,7 @@ BlockState blockstate = this.level.getBlockState(p_107368_); if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.shouldSpawnTerrainParticles()) { @@ -558,7 +_,7 @@ - d0 = (double)i + aabb.maxX + 0.1F; + d0 = i + aabb.maxX + 0.1F; } - this.add(new TerrainParticle(this.level, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_107368_).setPower(0.2F).scale(0.6F)); diff --git a/patches/minecraft/net/minecraft/client/particle/PortalParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/PortalParticle.java.patch index 96641fc25c..ebaf5cc8d8 100644 --- a/patches/minecraft/net/minecraft/client/particle/PortalParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/PortalParticle.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/particle/PortalParticle.java +++ b/net/minecraft/client/particle/PortalParticle.java @@ -80,6 +_,7 @@ - this.x = this.xStart + this.xd * (double)f2; - this.y = this.yStart + this.yd * (double)f2 + (double)(1.0F - f); - this.z = this.zStart + this.zd * (double)f2; + this.x = this.xStart + this.xd * f2; + this.y = this.yStart + this.yd * f2 + (1.0F - f); + this.z = this.zStart + this.zd * f2; + this.setPos(this.x, this.y, this.z); // FORGE: update the particle's bounding box } } diff --git a/patches/minecraft/net/minecraft/client/particle/ReversePortalParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/ReversePortalParticle.java.patch index 3833e0a3f8..2f584aba76 100644 --- a/patches/minecraft/net/minecraft/client/particle/ReversePortalParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/ReversePortalParticle.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/particle/ReversePortalParticle.java +++ b/net/minecraft/client/particle/ReversePortalParticle.java @@ -31,6 +_,7 @@ - this.x = this.x + this.xd * (double)f; - this.y = this.y + this.yd * (double)f; - this.z = this.z + this.zd * (double)f; + this.x = this.x + this.xd * f; + this.y = this.y + this.yd * f; + this.z = this.z + this.zd * f; + this.setPos(this.x, this.y, this.z); // FORGE: update the particle's bounding box } } diff --git a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch index 8534db2dd3..a03512829c 100644 --- a/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/TerrainParticle.java.patch @@ -7,22 +7,21 @@ - if (!p_172458_.is(Blocks.GRASS_BLOCK)) { + if (net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(p_172458_).areBreakingParticlesTinted(p_172458_, p_172451_, p_172459_)) { int i = Minecraft.getInstance().getBlockColors().getColor(p_172458_, p_172451_, p_172459_, 0); - this.rCol *= (float)(i >> 16 & 0xFF) / 255.0F; - this.gCol *= (float)(i >> 8 & 0xFF) / 255.0F; -@@ -97,9 +_,15 @@ + this.rCol *= (i >> 16 & 0xFF) / 255.0F; + this.gCol *= (i >> 8 & 0xFF) / 255.0F; +@@ -97,8 +_,14 @@ ) { BlockState blockstate = p_331600_.getState(); return !blockstate.isAir() && !blockstate.is(Blocks.MOVING_PISTON) && blockstate.shouldSpawnTerrainParticles() - ? new TerrainParticle(p_334810_, p_328897_, p_329583_, p_331123_, p_333546_, p_335782_, p_335068_, blockstate) + ? (TerrainParticle)new TerrainParticle(p_334810_, p_328897_, p_329583_, p_331123_, p_333546_, p_335782_, p_335068_, blockstate).updateSprite(blockstate, p_331600_.getPos()) : null; - } ++ } + + public Particle updateSprite(BlockState state, BlockPos pos) { //FORGE: we cannot assume that the x y z of the particles match the block pos of the block. + if (pos != null) // There are cases where we are not able to obtain the correct source pos, and need to fallback to the non-model data version -+ this.setSprite(Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getTexture(state, level, pos)); ++ this.setSprite(Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getParticleIcon(state, level, pos)); + return this; -+ } + } @OnlyIn(Dist.CLIENT) - public static class CrumblingProvider implements ParticleProvider { diff --git a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch index 1174814098..f36c796aca 100644 --- a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/AbstractClientPlayer.java +++ b/net/minecraft/client/player/AbstractClientPlayer.java -@@ -91,6 +_,6 @@ +@@ -86,6 +_,6 @@ } } diff --git a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch index 69ccad5be7..7dc616c8f1 100644 --- a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch +++ b/patches/minecraft/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 -@@ -308,6 +_,7 @@ +@@ -303,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(); -@@ -493,7 +_,11 @@ +@@ -483,7 +_,11 @@ @Override public void playSound(SoundEvent p_108651_, float p_108652_, float p_108653_) { @@ -21,43 +21,15 @@ } @Override -@@ -686,6 +_,7 @@ +@@ -716,6 +_,7 @@ && this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.CROUCHING) && (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING)); this.input.tick(); + net.minecraftforge.client.ForgeHooksClient.onMovementInputUpdate(this, this.input); this.minecraft.getTutorial().onInput(this.input); - if (this.shouldStopSprinting()) { - this.setSprinting(false); -@@ -724,7 +_,7 @@ - boolean flag3 = this.canStartSprinting(); - boolean flag4 = this.isPassenger() ? this.getVehicle().onGround() : this.onGround(); - boolean flag5 = !flag1 && !flag2; -- if ((flag4 || this.isUnderWater()) && flag5 && flag3) { -+ if ((flag4 || this.isUnderWater() || this.canStartSwimming()) && flag5 && flag3) { - if (this.sprintTriggerTime <= 0 && !this.minecraft.options.keySprint.isDown()) { - this.sprintTriggerTime = 7; - } else { -@@ -732,15 +_,16 @@ - } - } - -- if ((!this.isInWater() || this.isUnderWater()) && flag3 && this.minecraft.options.keySprint.isDown()) { -+ if ((!this.isInWaterOrSwimmable() || this.isUnderWater() || this.canStartSwimming()) && flag3 && this.minecraft.options.keySprint.isDown()) { - this.setSprinting(true); - } - - if (this.isSprinting()) { - boolean flag6 = !this.input.hasForwardImpulse() || !this.hasEnoughFoodToStartSprinting(); - boolean flag7 = flag6 || this.horizontalCollision && !this.minorHorizontalCollision || this.isInWater() && !this.isUnderWater(); -+ flag7 = flag7 || (this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)) && !this.canStartSwimming()); - if (this.isSwimming()) { -- if (!this.onGround() && !this.input.keyPresses.shift() && flag6 || !this.isInWater()) { -+ if (!this.onGround() && !this.input.keyPresses.shift() && flag7 || !this.isInWaterOrSwimmable()) { - this.setSprinting(false); - } - } else if (flag7) { -@@ -777,8 +_,9 @@ + boolean flag3 = false; + if (this.autoJumpTime > 0) { +@@ -788,8 +_,9 @@ } this.wasFallFlying = this.isFallFlying(); @@ -69,7 +41,24 @@ } if (this.isEyeInFluid(FluidTags.WATER)) { -@@ -900,6 +_,8 @@ +@@ -856,13 +_,14 @@ + || !this.input.hasForwardImpulse() + || !this.hasEnoughFoodToSprint() + || this.horizontalCollision && !this.minorHorizontalCollision +- || this.isInWater() && !this.isUnderWater(); ++ || this.isInWater() && !this.isUnderWater() ++ || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)) && !this.canStartSwimming(); + } + + private boolean shouldStopSwimSprinting() { + return this.hasBlindness() + || this.isPassenger() && !this.vehicleCanSprint(this.getVehicle()) +- || !this.isInWater() ++ || !this.isInWaterOrSwimmable() + || !this.input.hasForwardImpulse() && !this.onGround() && !this.input.keyPresses.shift() + || !this.hasEnoughFoodToSprint(); + } +@@ -914,6 +_,8 @@ @Override public void rideTick() { super.rideTick(); @@ -78,7 +67,16 @@ this.handsBusy = false; if (this.getControlledVehicle() instanceof AbstractBoat abstractboat) { abstractboat.setInput( -@@ -1177,6 +_,18 @@ +@@ -1090,7 +_,7 @@ + && (!this.isPassenger() || this.vehicleCanSprint(this.getVehicle())) + && (!this.isFallFlying() || this.isUnderWater()) + && (!this.isMovingSlowly() || this.isUnderWater()) +- && (!this.isInWater() || this.isUnderWater()); ++ && (!this.isInWater() || this.isUnderWater() || this.canStartSwimming()); + } + + private boolean vehicleCanSprint(Entity p_265184_) { +@@ -1169,6 +_,18 @@ @Override public float getVisualRotationYInDegrees() { return this.getYRot(); diff --git a/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch index c2a055fb86..6c6c933d70 100644 --- a/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/FogRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/FogRenderer.java +++ b/net/minecraft/client/renderer/FogRenderer.java -@@ -192,6 +_,12 @@ +@@ -187,6 +_,12 @@ f2 = f2 * (1.0F - f10) + f2 * f12 * f10; } @@ -13,7 +13,7 @@ return new Vector4f(f, f1, f2, 1.0F); } -@@ -270,9 +_,10 @@ +@@ -265,9 +_,10 @@ fogrenderer$fogdata.shape = FogShape.CYLINDER; } diff --git a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch index 1cda9f2b03..89eceda991 100644 --- a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/GameRenderer.java +++ b/net/minecraft/client/renderer/GameRenderer.java -@@ -158,6 +_,10 @@ +@@ -168,6 +_,10 @@ this.setPostEffect(ResourceLocation.withDefaultNamespace("spider")); } else if (p_109107_ instanceof EnderMan) { this.setPostEffect(ResourceLocation.withDefaultNamespace("invert")); @@ -11,21 +11,21 @@ } } -@@ -171,8 +_,13 @@ +@@ -181,7 +_,13 @@ if (!(f < 1.0F)) { PostChain postchain = this.minecraft.getShaderManager().getPostChain(BLUR_POST_CHAIN_ID, LevelTargetBundle.MAIN_TARGETS); if (postchain != null) { -+ boolean wasBlendEnabled = RenderSystem.isBlendEnabled(); ++ // TODO: [Forge][Rendering] Check if this blend management is needed anymnore with the new render pipeline changes ++ boolean wasBlendEnabled = com.mojang.blaze3d.opengl.GlStateManager._isBlendEnabled(); + if (wasBlendEnabled) -+ RenderSystem.disableBlend(); - postchain.setUniform("Radius", f); - postchain.process(this.minecraft.getMainRenderTarget(), this.resourcePool); ++ com.mojang.blaze3d.opengl.GlStateManager._disableBlend(); + postchain.process(this.minecraft.getMainRenderTarget(), this.resourcePool, p_389358_ -> p_389358_.setUniform("Radius", f)); + if (wasBlendEnabled) -+ RenderSystem.enableBlend(); ++ com.mojang.blaze3d.opengl.GlStateManager._enableBlend(); } } } -@@ -312,7 +_,7 @@ +@@ -347,7 +_,7 @@ f *= Mth.lerp(f2, 1.0F, 0.85714287F); } @@ -34,13 +34,12 @@ } } -@@ -470,12 +_,12 @@ - (float)((double)window.getHeight() / window.getGuiScale()), - 0.0F, - 1000.0F, -- 21000.0F -+ net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane() - ); +@@ -490,11 +_,11 @@ + RenderTarget rendertarget = this.minecraft.getMainRenderTarget(); + RenderSystem.getDevice().createCommandEncoder().clearDepthTexture(rendertarget.getDepthTexture(), 1.0); + Matrix4f matrix4f = new Matrix4f() +- .setOrtho(0.0F, (float)(window.getWidth() / window.getGuiScale()), (float)(window.getHeight() / window.getGuiScale()), 0.0F, 1000.0F, 21000.0F); ++ .setOrtho(0.0F, (float)(window.getWidth() / window.getGuiScale()), (float)(window.getHeight() / window.getGuiScale()), 0.0F, 1000.0F, net.minecraftforge.client.ForgeHooksClient.getGuiFarPlane()); RenderSystem.setProjectionMatrix(matrix4f, ProjectionType.ORTHOGRAPHIC); Matrix4fStack matrix4fstack = RenderSystem.getModelViewStack(); matrix4fstack.pushMatrix(); @@ -49,7 +48,7 @@ Lighting.setupFor3DItems(); GuiGraphics guigraphics = new GuiGraphics(this.minecraft, this.renderBuffers.bufferSource()); if (flag && p_109096_ && this.minecraft.level != null) { -@@ -501,7 +_,7 @@ +@@ -520,7 +_,7 @@ } } else if (flag && this.minecraft.screen != null) { try { @@ -58,7 +57,7 @@ } catch (Throwable throwable1) { CrashReport crashreport1 = CrashReport.forThrowable(throwable1, "Rendering screen"); CrashReportCategory crashreportcategory1 = crashreport1.addCategory("Screen render details"); -@@ -657,6 +_,9 @@ +@@ -654,6 +_,9 @@ if (this.minecraft.options.bobView().get()) { this.bobView(posestack, camera.getPartialTickTime()); } diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch index 34c1029311..7bfc36b098 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch @@ -5,18 +5,18 @@ @OnlyIn(Dist.CLIENT) public class ItemBlockRenderTypes { + @Deprecated - private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_374604_ -> { + private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_389364_ -> { RenderType rendertype = RenderType.tripwire(); - p_374604_.put(Blocks.TRIPWIRE, rendertype); -@@ -345,6 +_,7 @@ - p_374604_.put(Blocks.BUBBLE_COLUMN, rendertype3); - p_374604_.put(Blocks.TINTED_GLASS, rendertype3); + p_389364_.put(Blocks.TRIPWIRE, rendertype); +@@ -352,6 +_,7 @@ + p_389364_.put(Blocks.BUBBLE_COLUMN, rendertype3); + p_389364_.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); -@@ -352,6 +_,8 @@ +@@ -359,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) { -@@ -362,6 +_,8 @@ +@@ -369,6 +_,8 @@ } } @@ -34,7 +34,7 @@ public static RenderType getMovingBlockRenderType(BlockState p_109294_) { Block block = p_109294_.getBlock(); if (block instanceof LeavesBlock) { -@@ -376,11 +_,14 @@ +@@ -383,11 +_,14 @@ } } @@ -49,7 +49,7 @@ public static RenderType getRenderType(ItemStack p_363859_) { if (p_363859_.getItem() instanceof BlockItem blockitem) { Block block = blockitem.getBlock(); -@@ -390,12 +_,81 @@ +@@ -397,12 +_,81 @@ } } diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch index 0cf57f67ae..016515ca10 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemInHandRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/ItemInHandRenderer.java +++ b/net/minecraft/client/renderer/ItemInHandRenderer.java -@@ -343,12 +_,14 @@ +@@ -336,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); @@ -15,7 +15,7 @@ this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.offHandItem, f7, p_109316_, p_109317_, p_109319_); } -@@ -414,7 +_,7 @@ +@@ -407,7 +_,7 @@ } else { this.renderOneHandedMap(p_109379_, p_109380_, p_109381_, p_109378_, humanoidarm, p_109376_, p_109377_); } @@ -24,7 +24,7 @@ boolean flag1 = CrossbowItem.isCharged(p_109377_); boolean flag2 = humanoidarm == HumanoidArm.RIGHT; int i = flag2 ? 1 : -1; -@@ -460,6 +_,7 @@ +@@ -452,6 +_,7 @@ } else { boolean flag3 = humanoidarm == HumanoidArm.RIGHT; int j = flag3 ? 1 : -1; @@ -32,14 +32,14 @@ if (p_109372_.isUsingItem() && p_109372_.getUseItemRemainingTicks() > 0 && p_109372_.getUsedItemHand() == p_109375_) { switch (p_109377_.getUseAnimation()) { case NONE: -@@ -588,8 +_,18 @@ +@@ -579,8 +_,18 @@ this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F); } else { float f = localplayer.getAttackStrengthScale(1.0F); - float f1 = this.mainHandItem != itemstack ? 0.0F : f * f * f; - float f2 = this.offHandItem != itemstack1 ? 0.0F : 1.0F; + -+ boolean requipM = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.mainHandItem, itemstack, localplayer.getInventory().selected); ++ boolean requipM = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.mainHandItem, itemstack, localplayer.getInventory().getSelectedSlot()); + boolean requipO = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.offHandItem, itemstack1, -1); + + if (!requipM && this.mainHandItem != itemstack) diff --git a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch index 4d00a9a971..a94b392ad4 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/LevelRenderer.java +++ b/net/minecraft/client/renderer/LevelRenderer.java -@@ -109,7 +_,7 @@ +@@ -113,7 +_,7 @@ private final SkyRenderer skyRenderer = new SkyRenderer(); private final CloudRenderer cloudRenderer = new CloudRenderer(); private final WorldBorderRenderer worldBorderRenderer = new WorldBorderRenderer(); @@ -9,8 +9,8 @@ @Nullable private ClientLevel level; private final SectionOcclusionGraph sectionOcclusionGraph = new SectionOcclusionGraph(); -@@ -482,7 +_,7 @@ - postchain1.addToFrame(framegraphbuilder, i, j, this.targets); +@@ -483,7 +_,7 @@ + postchain1.addToFrame(framegraphbuilder, i, j, this.targets, null); } - this.addParticlesPass(framegraphbuilder, p_109604_, f, fogparameters); @@ -18,7 +18,7 @@ CloudStatus cloudstatus = this.minecraft.options.getCloudsType(); if (cloudstatus != CloudStatus.OFF) { float f2 = this.level.effects().getCloudHeight(); -@@ -564,7 +_,11 @@ +@@ -561,7 +_,11 @@ double d2 = vec3.z(); p_369478_.push("terrain"); this.renderSectionLayer(RenderType.solid(), d0, d1, d2, p_361439_, p_369924_); @@ -30,7 +30,7 @@ this.renderSectionLayer(RenderType.cutout(), d0, d1, d2, p_361439_, p_369924_); if (this.level.effects().constantAmbientLight()) { Lighting.setupNetherLevel(); -@@ -598,7 +_,7 @@ +@@ -586,7 +_,7 @@ multibuffersource$buffersource.endLastBatch(); this.checkPoseStack(posestack); p_369478_.popPush("blockentities"); @@ -39,7 +39,7 @@ multibuffersource$buffersource.endLastBatch(); this.checkPoseStack(posestack); multibuffersource$buffersource.endBatch(RenderType.solid()); -@@ -612,8 +_,8 @@ +@@ -600,8 +_,8 @@ multibuffersource$buffersource.endBatch(Sheets.hangingSignSheet()); multibuffersource$buffersource.endBatch(Sheets.chestSheet()); this.renderBuffers.outlineBufferSource().endOutlineBatch(); @@ -50,7 +50,7 @@ } p_369478_.popPush("debug"); -@@ -643,8 +_,8 @@ +@@ -629,8 +_,8 @@ this.renderSectionLayer(RenderType.translucent(), d0, d1, d2, p_361439_, p_369924_); p_369478_.popPush("string"); this.renderSectionLayer(RenderType.tripwire(), d0, d1, d2, p_361439_, p_369924_); @@ -61,7 +61,7 @@ } multibuffersource$buffersource.endBatch(); -@@ -652,7 +_,7 @@ +@@ -638,7 +_,7 @@ }); } @@ -70,7 +70,7 @@ FramePass framepass = p_366471_.addPass("particles"); if (this.targets.particles != null) { this.targets.particles = framepass.readsAndWrites(this.targets.particles); -@@ -671,7 +_,7 @@ +@@ -655,7 +_,7 @@ resourcehandle1.get().copyDepthFrom(resourcehandle.get()); } @@ -79,7 +79,7 @@ }); } -@@ -759,9 +_,9 @@ +@@ -725,9 +_,9 @@ || p_365712_.isDetached() || p_365712_.getEntity() instanceof LivingEntity && ((LivingEntity)p_365712_.getEntity()).isSleeping() ) @@ -91,7 +91,7 @@ flag = true; } } -@@ -801,9 +_,10 @@ +@@ -767,9 +_,10 @@ } } @@ -104,7 +104,7 @@ Vec3 vec3 = p_369847_.getPosition(); double d0 = vec3.x(); double d1 = vec3.y(); -@@ -813,6 +_,7 @@ +@@ -779,6 +_,7 @@ List list = sectionrenderdispatcher$rendersection.getCompiled().getRenderableBlockEntities(); if (!list.isEmpty()) { for (BlockEntity blockentity : list) { @@ -112,7 +112,7 @@ BlockPos blockpos = blockentity.getBlockPos(); MultiBufferSource multibuffersource = p_362022_; p_366168_.pushPose(); -@@ -832,6 +_,9 @@ +@@ -798,6 +_,9 @@ } } @@ -122,14 +122,14 @@ this.blockEntityRenderDispatcher.render(blockentity, p_367074_, p_366168_, multibuffersource); p_366168_.popPose(); } -@@ -840,13 +_,18 @@ +@@ -806,13 +_,18 @@ synchronized (this.globalBlockEntities) { for (BlockEntity blockentity1 : this.globalBlockEntities) { + if (!frustum.isVisible(blockentity1.getRenderBoundingBox())) continue; BlockPos blockpos1 = blockentity1.getBlockPos(); p_366168_.pushPose(); - p_366168_.translate((double)blockpos1.getX() - d0, (double)blockpos1.getY() - d1, (double)blockpos1.getZ() - d2); + p_366168_.translate(blockpos1.getX() - d0, blockpos1.getY() - d1, blockpos1.getZ() - d2); + if (!customOutline && this.shouldShowEntityOutlines() && blockentity1.hasCustomOutlineRendering(this.minecraft.player)) + customOutline = true; this.blockEntityRenderDispatcher.render(blockentity1, p_367074_, p_366168_, p_362022_); @@ -141,8 +141,8 @@ } private void renderBlockDestroyAnimation(PoseStack p_366956_, Camera p_369324_, MultiBufferSource.BufferSource p_365998_) { -@@ -865,14 +_,14 @@ - p_366956_.translate((double)blockpos.getX() - d0, (double)blockpos.getY() - d1, (double)blockpos.getZ() - d2); +@@ -831,14 +_,14 @@ + p_366956_.translate(blockpos.getX() - d0, blockpos.getY() - d1, blockpos.getZ() - d2); PoseStack.Pose posestack$pose = p_366956_.last(); VertexConsumer vertexconsumer = new SheetedDecalTextureGenerator(p_365998_.getBuffer(ModelBakery.DESTROY_TYPES.get(i)), posestack$pose, 1.0F); - this.minecraft.getBlockRenderer().renderBreakingTexture(this.level.getBlockState(blockpos), blockpos, this.level, p_366956_, vertexconsumer); @@ -158,7 +158,7 @@ if (this.minecraft.hitResult instanceof BlockHitResult blockhitresult) { if (blockhitresult.getType() != HitResult.Type.MISS) { BlockPos blockpos = blockhitresult.getBlockPos(); -@@ -883,6 +_,9 @@ +@@ -849,6 +_,9 @@ return; } @@ -168,7 +168,7 @@ Vec3 vec3 = p_367935_.getPosition(); Boolean obool = this.minecraft.options.highContrastBlockOutline().get(); if (obool) { -@@ -898,6 +_,8 @@ +@@ -864,6 +_,8 @@ p_367206_.endLastBatch(); } } @@ -177,16 +177,16 @@ } } -@@ -1367,7 +_,7 @@ +@@ -1359,7 +_,7 @@ } else { - int i = p_109538_.getBrightness(LightLayer.SKY, p_109540_); - int j = p_109538_.getBrightness(LightLayer.BLOCK, p_109540_); + int i = p_398213_.packedBrightness(p_109538_, p_109540_); + int j = LightTexture.block(i); - int k = p_109539_.getLightEmission(); + int k = p_109539_.getLightEmission(p_109538_, p_109540_); if (j < k) { - j = k; - } -@@ -1429,5 +_,21 @@ + int l = LightTexture.sky(i); + return LightTexture.pack(k, l); +@@ -1422,6 +_,22 @@ public CloudRenderer getCloudRenderer() { return this.cloudRenderer; @@ -207,4 +207,5 @@ + public void setWeatherEffects(WeatherEffectRenderer value) { + this.weatherEffectRenderer = value; } - } + + @FunctionalInterface diff --git a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch index 7af3a43fc3..55ee25fdb7 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LightTexture.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/LightTexture.java +++ b/net/minecraft/client/renderer/LightTexture.java -@@ -143,7 +_,7 @@ +@@ -142,7 +_,7 @@ } public static int block(int p_109884_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch b/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch index b07181c479..d71b63d3d6 100644 --- a/patches/minecraft/net/minecraft/client/renderer/RenderType.java.patch +++ b/patches/minecraft/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 -@@ -929,11 +_,22 @@ +@@ -633,9 +_,20 @@ .createCompositeState(false) ); private static final ImmutableList CHUNK_BUFFER_LAYERS = ImmutableList.of(solid(), cutoutMipped(), cutout(), translucent(), tripwire()); @@ -10,8 +10,6 @@ + layer.chunkLayerId = i++; + } + - private final VertexFormat format; - private final VertexFormat.Mode mode; private final int bufferSize; private final boolean affectsCrumbling; private final boolean sortOnUpload; @@ -23,7 +21,7 @@ public static RenderType solid() { return SOLID; -@@ -1154,7 +_,7 @@ +@@ -820,7 +_,7 @@ } public static RenderType text(ResourceLocation p_110498_) { @@ -32,7 +30,7 @@ } public static RenderType textBackground() { -@@ -1162,19 +_,19 @@ +@@ -828,19 +_,19 @@ } public static RenderType textIntensity(ResourceLocation p_173238_) { @@ -56,7 +54,7 @@ } public static RenderType textBackgroundSeeThrough() { -@@ -1182,7 +_,7 @@ +@@ -848,7 +_,7 @@ } public static RenderType textIntensitySeeThrough(ResourceLocation p_173241_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch index 28043374b2..dde920d9ad 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch @@ -9,7 +9,7 @@ + var overlay = getOverlayBlock(player); + if (overlay != null) { + if (!net.minecraftforge.client.ForgeHooksClient.renderBlockOverlay(player, p_110720_, net.minecraftforge.client.event.RenderBlockScreenEffectEvent.OverlayType.BLOCK, overlay.getLeft(), overlay.getRight())) { -+ renderTex(p_110719_.getBlockRenderer().getBlockModelShaper().getTexture(overlay.getLeft(), p_110719_.level, overlay.getRight()), p_110720_, p_378238_); ++ renderTex(p_110719_.getBlockRenderer().getBlockModelShaper().getParticleIcon(overlay.getLeft(), p_110719_.level, overlay.getRight()), p_110720_, p_378238_); + } } } diff --git a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch index 08c0a5ed18..f6d7a7b6f6 100644 --- a/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/Sheets.java.patch @@ -1,24 +1,20 @@ --- a/net/minecraft/client/renderer/Sheets.java +++ b/net/minecraft/client/renderer/Sheets.java -@@ -155,7 +_,7 @@ +@@ -157,11 +_,11 @@ } private static Material createSignMaterial(WoodType p_173386_) { -- return createSignMaterial(ResourceLocation.withDefaultNamespace(p_173386_.name())); -+ return createSignMaterial(ResourceLocation.parse(p_173386_.name())); - } - - public static Material createSignMaterial(ResourceLocation p_378064_) { -@@ -163,7 +_,7 @@ +- return SIGN_MAPPER.defaultNamespaceApply(p_173386_.name()); ++ return SIGN_MAPPER.apply(ResourceLocation.parse(p_173386_.name())); } private static Material createHangingSignMaterial(WoodType p_251735_) { -- return createHangingSignMaterial(ResourceLocation.withDefaultNamespace(p_251735_.name())); -+ return createHangingSignMaterial(ResourceLocation.parse(p_251735_.name())); +- return HANGING_SIGN_MAPPER.defaultNamespaceApply(p_251735_.name()); ++ return HANGING_SIGN_MAPPER.apply(ResourceLocation.parse(p_251735_.name())); } - public static Material createHangingSignMaterial(ResourceLocation p_377324_) { -@@ -230,6 +_,23 @@ + public static Material getSignMaterial(WoodType p_173382_) { +@@ -206,6 +_,23 @@ case SINGLE: default: return p_110773_; diff --git a/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch index 2be632c1b7..83e6e44400 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/BlockModelShaper.java.patch @@ -1,19 +1,17 @@ --- a/net/minecraft/client/renderer/block/BlockModelShaper.java +++ b/net/minecraft/client/renderer/block/BlockModelShaper.java -@@ -22,8 +_,15 @@ +@@ -17,8 +_,13 @@ this.modelManager = p_110880_; } -+ @Deprecated ++ /** @deprecated Forge: Use {@link #getParticleIcon(BlockState, net.minecraft.world.level.Level, net.minecraft.core.BlockPos) getParticleIcon(BlockState, Level, Pos)} */ public TextureAtlasSprite getParticleIcon(BlockState p_110883_) { -- return this.getBlockModel(p_110883_).getParticleIcon(); -+ return this.getBlockModel(p_110883_).getParticleIcon(net.minecraftforge.client.model.data.ModelData.EMPTY); +- return this.getBlockModel(p_110883_).particleIcon(); ++ return this.getBlockModel(p_110883_).particleIcon(net.minecraftforge.client.model.data.ModelData.EMPTY); + } + -+ public TextureAtlasSprite getTexture(BlockState p_110883_, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) { -+ var data = level.getModelDataManager().getAt(pos); -+ BakedModel model = this.getBlockModel(p_110883_); -+ return model.getParticleIcon(model.getModelData(level, pos, p_110883_, data == null ? net.minecraftforge.client.model.data.ModelData.EMPTY : data)); ++ public TextureAtlasSprite getParticleIcon(BlockState p_110883_, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) { ++ return this.getBlockModel(p_110883_).particleIcon(level.getModelDataManager().getAt(pos)); } - public BakedModel getBlockModel(BlockState p_110894_) { + public BlockStateModel getBlockModel(BlockState p_110894_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch index 3c56573450..64177d30b2 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/client/renderer/block/BlockRenderDispatcher.java +++ b/net/minecraft/client/renderer/block/BlockRenderDispatcher.java -@@ -37,7 +_,7 @@ - this.blockModelShaper = p_173399_; - this.specialBlockModelRenderer = p_378785_; - this.blockColors = p_173401_; -- this.modelRenderer = new ModelBlockRenderer(this.blockColors); -+ this.modelRenderer = new net.minecraftforge.client.model.lighting.ForgeModelBlockRenderer(this.blockColors); - this.liquidBlockRenderer = new LiquidBlockRenderer(); - } - -@@ -45,12 +_,22 @@ +@@ -49,12 +_,17 @@ return this.blockModelShaper; } @@ -20,42 +11,15 @@ + + public void renderBreakingTexture(BlockState p_110919_, BlockPos p_110920_, BlockAndTintGetter p_110921_, PoseStack p_110922_, VertexConsumer p_110923_, net.minecraftforge.client.model.data.ModelData modelData) { if (p_110919_.getRenderShape() == RenderShape.MODEL) { - BakedModel bakedmodel = this.blockModelShaper.getBlockModel(p_110919_); - long i = p_110919_.getSeed(p_110920_); -- this.modelRenderer.tesselateBlock(p_110921_, bakedmodel, p_110919_, p_110920_, p_110922_, p_110923_, true, this.random, i, OverlayTexture.NO_OVERLAY); -+ this.modelRenderer.tesselateBlock(p_110921_, bakedmodel, p_110919_, p_110920_, p_110922_, p_110923_, true, this.random, i, OverlayTexture.NO_OVERLAY, modelData, null); + BlockStateModel blockstatemodel = this.blockModelShaper.getBlockModel(p_110919_); + this.singleThreadRandom.setSeed(p_110919_.getSeed(p_110920_)); + this.singleThreadPartList.clear(); +- blockstatemodel.collectParts(this.singleThreadRandom, this.singleThreadPartList); ++ blockstatemodel.collectParts(this.singleThreadRandom, this.singleThreadPartList, modelData, null); + this.modelRenderer.tesselateBlock(p_110921_, this.singleThreadPartList, p_110919_, p_110920_, p_110922_, p_110923_, true, OverlayTexture.NO_OVERLAY); } -+ } -+ -+ @Deprecated //Forge: Model data and render type parameter -+ public void renderBatched(BlockState p_234356_, BlockPos p_234357_, BlockAndTintGetter p_234358_, PoseStack p_234359_, VertexConsumer p_234360_, boolean p_234361_, RandomSource p_234362_) { -+ renderBatched(p_234356_, p_234357_, p_234358_, p_234359_, p_234360_, p_234361_, p_234362_, net.minecraftforge.client.model.data.ModelData.EMPTY, null); } - - public void renderBatched( -@@ -60,7 +_,9 @@ - PoseStack p_234359_, - VertexConsumer p_234360_, - boolean p_234361_, -- RandomSource p_234362_ -+ RandomSource p_234362_, -+ net.minecraftforge.client.model.data.ModelData modelData, -+ net.minecraft.client.renderer.RenderType renderType - ) { - try { - this.modelRenderer -@@ -74,7 +_,9 @@ - p_234361_, - p_234362_, - p_234356_.getSeed(p_234357_), -- OverlayTexture.NO_OVERLAY -+ OverlayTexture.NO_OVERLAY, -+ modelData, -+ renderType - ); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating block in world"); -@@ -103,7 +_,12 @@ +@@ -97,7 +_,12 @@ return this.blockModelShaper.getBlockModel(p_110911_); } @@ -67,16 +31,15 @@ + public void renderSingleBlock(BlockState p_110913_, PoseStack p_110914_, MultiBufferSource p_110915_, int p_110916_, int p_110917_, net.minecraftforge.client.model.data.ModelData modelData, net.minecraft.client.renderer.RenderType renderType) { RenderShape rendershape = p_110913_.getRenderShape(); if (rendershape != RenderShape.INVISIBLE) { - BakedModel bakedmodel = this.getBlockModel(p_110913_); -@@ -111,9 +_,10 @@ - float f = (float)(i >> 16 & 0xFF) / 255.0F; - float f1 = (float)(i >> 8 & 0xFF) / 255.0F; - float f2 = (float)(i & 0xFF) / 255.0F; -+ for (var rt : bakedmodel.getRenderTypes(p_110913_, RandomSource.create(42), modelData)) - this.modelRenderer - .renderModel( -- p_110914_.last(), p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_)), p_110913_, bakedmodel, f, f1, f2, p_110916_, p_110917_ -+ p_110914_.last(), p_110915_.getBuffer(renderType != null ? renderType : net.minecraftforge.client.RenderTypeHelper.getEntityRenderType(rt)), p_110913_, bakedmodel, f, f1, f2, p_110916_, p_110917_, modelData, rt - ); + BlockStateModel blockstatemodel = this.getBlockModel(p_110913_); +@@ -105,8 +_,9 @@ + float f = (i >> 16 & 0xFF) / 255.0F; + float f1 = (i >> 8 & 0xFF) / 255.0F; + float f2 = (i & 0xFF) / 255.0F; ++ for (var rt : blockstatemodel.getRenderTypes(p_110913_, RandomSource.create(42), modelData)) + ModelBlockRenderer.renderModel( +- p_110914_.last(), p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_)), blockstatemodel, f, f1, f2, p_110916_, p_110917_ ++ p_110914_.last(), p_110915_.getBuffer(renderType != null ? renderType : net.minecraftforge.client.RenderTypeHelper.getEntityRenderType(rt)), blockstatemodel, f, f1, f2, p_110916_, p_110917_, modelData, rt + ); this.specialBlockModelRenderer.get().renderByBlock(p_110913_.getBlock(), ItemDisplayContext.NONE, p_110914_, p_110915_, p_110916_, p_110917_); } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch index e3d8dd1dfa..b88ea9f657 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch @@ -10,9 +10,9 @@ + int i = net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions.of(p_234374_).getTintColor(p_234374_, p_234370_, p_234371_); + float alpha = (float)(i >> 24 & 255) / 255.0F; + - float f = (float)(i >> 16 & 0xFF) / 255.0F; - float f1 = (float)(i >> 8 & 0xFF) / 255.0F; - float f2 = (float)(i & 0xFF) / 255.0F; + float f = (i >> 16 & 0xFF) / 255.0F; + float f1 = (i >> 8 & 0xFF) / 255.0F; + float f2 = (i & 0xFF) / 255.0F; @@ -180,15 +_,15 @@ float f57 = f4 * f; float f29 = f4 * f1; diff --git a/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch index 5a7df23666..9287bddb8e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch @@ -1,160 +1,37 @@ --- a/net/minecraft/client/renderer/block/ModelBlockRenderer.java +++ b/net/minecraft/client/renderer/block/ModelBlockRenderer.java -@@ -39,6 +_,11 @@ - this.blockColors = p_110999_; - } - -+ @Deprecated //Forge: Model data and render type parameter -+ 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_) { -+ tesselateBlock(p_234380_, p_234381_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234387_, p_234388_, p_234389_, net.minecraftforge.client.model.data.ModelData.EMPTY, null); -+ } -+ - public void tesselateBlock( - BlockAndTintGetter p_234380_, - BakedModel p_234381_, -@@ -49,16 +_,18 @@ - boolean p_234386_, - RandomSource p_234387_, - long p_234388_, -- int p_234389_ -+ int p_234389_, -+ net.minecraftforge.client.model.data.ModelData modelData, -+ @Nullable net.minecraft.client.renderer.RenderType renderType +@@ -48,7 +_,7 @@ + int p_234389_ ) { -- boolean flag = Minecraft.useAmbientOcclusion() && p_234382_.getLightEmission() == 0 && p_234381_.useAmbientOcclusion(); -+ boolean flag = Minecraft.useAmbientOcclusion() && p_234382_.getLightEmission(p_234380_, p_234383_) == 0 && p_234381_.useAmbientOcclusion(p_234382_, renderType); - p_234384_.translate(p_234382_.getOffset(p_234383_)); + if (!p_393688_.isEmpty()) { +- boolean flag = Minecraft.useAmbientOcclusion() && p_234382_.getLightEmission() == 0 && p_393688_.getFirst().useAmbientOcclusion(); ++ boolean flag = Minecraft.useAmbientOcclusion() && p_234382_.getLightEmission(p_234380_, p_234383_) == 0 && p_393688_.getFirst().useAmbientOcclusion(); + p_234384_.translate(p_234382_.getOffset(p_234383_)); - try { - if (flag) { -- this.tesselateWithAO(p_234380_, p_234381_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234387_, p_234388_, p_234389_); -+ this.tesselateWithAO(p_234380_, p_234381_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234387_, p_234388_, p_234389_, modelData, renderType); - } else { -- this.tesselateWithoutAO(p_234380_, p_234381_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234387_, p_234388_, p_234389_); -+ this.tesselateWithoutAO(p_234380_, p_234381_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234387_, p_234388_, p_234389_, modelData, renderType); - } - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating block model"); -@@ -69,6 +_,11 @@ + try { +@@ -322,6 +_,11 @@ } } + @Deprecated //Forge: Model data and render type parameter -+ public void tesselateWithAO(BlockAndTintGetter p_234391_, BakedModel p_234392_, BlockState p_234393_, BlockPos p_234394_, PoseStack p_234395_, VertexConsumer p_234396_, boolean p_234397_, RandomSource p_234398_, 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.minecraftforge.client.model.data.ModelData.EMPTY, null); ++ public static void renderModel(PoseStack.Pose p_111068_, VertexConsumer p_111069_, BlockStateModel p_111070_, float p_111072_, float p_111073_, float p_111074_, int p_111075_, int p_111076_) { ++ renderModel(p_111068_, p_111069_, p_111070_, p_111072_, p_111073_, p_111074_, p_111075_, p_111076_, net.minecraftforge.client.model.data.ModelData.EMPTY, null); + } + - public void tesselateWithAO( - BlockAndTintGetter p_234391_, - BakedModel p_234392_, -@@ -79,7 +_,9 @@ - boolean p_234397_, - RandomSource p_234398_, - long p_234399_, -- int p_234400_ -+ int p_234400_, -+ net.minecraftforge.client.model.data.ModelData modelData, -+ @Nullable net.minecraft.client.renderer.RenderType renderType - ) { - float[] afloat = new float[DIRECTIONS.length * 2]; - BitSet bitset = new BitSet(3); -@@ -88,7 +_,7 @@ - - for (Direction direction : DIRECTIONS) { - p_234398_.setSeed(p_234399_); -- List list = p_234392_.getQuads(p_234393_, direction, p_234398_); -+ 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_.getBlockState(blockpos$mutableblockpos), direction)) { -@@ -100,12 +_,17 @@ - } - - p_234398_.setSeed(p_234399_); -- List list1 = p_234392_.getQuads(p_234393_, null, p_234398_); -+ List list1 = p_234392_.getQuads(p_234393_, null, p_234398_, modelData, renderType); - if (!list1.isEmpty()) { - this.renderModelFaceAO(p_234391_, p_234393_, p_234394_, p_234395_, p_234396_, list1, afloat, bitset, modelblockrenderer$ambientocclusionface, p_234400_); - } - } - -+ @Deprecated //Forge: Model data and render type parameter -+ public void tesselateWithoutAO(BlockAndTintGetter p_234402_, BakedModel p_234403_, BlockState p_234404_, BlockPos p_234405_, PoseStack p_234406_, VertexConsumer p_234407_, boolean p_234408_, RandomSource p_234409_, 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.minecraftforge.client.model.data.ModelData.EMPTY, null); -+ } -+ - public void tesselateWithoutAO( - BlockAndTintGetter p_234402_, - BakedModel p_234403_, -@@ -116,14 +_,16 @@ - boolean p_234408_, - RandomSource p_234409_, - long p_234410_, -- int p_234411_ -+ int p_234411_, -+ net.minecraftforge.client.model.data.ModelData modelData, -+ @Nullable net.minecraft.client.renderer.RenderType renderType - ) { - BitSet bitset = new BitSet(3); - BlockPos.MutableBlockPos blockpos$mutableblockpos = p_234405_.mutable(); - - for (Direction direction : DIRECTIONS) { - p_234409_.setSeed(p_234410_); -- List list = p_234403_.getQuads(p_234404_, direction, p_234409_); -+ 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_.getBlockState(blockpos$mutableblockpos), direction)) { -@@ -134,7 +_,7 @@ - } - - p_234409_.setSeed(p_234410_); -- List list1 = p_234403_.getQuads(p_234404_, null, p_234409_); -+ List list1 = p_234403_.getQuads(p_234404_, null, p_234409_, modelData, renderType); - if (!list1.isEmpty()) { - this.renderModelFaceFlat(p_234402_, p_234404_, p_234405_, -1, p_234411_, true, p_234406_, p_234407_, list1, bitset); - } -@@ -154,6 +_,7 @@ - ) { - for (BakedQuad bakedquad : p_111018_) { - this.calculateShape(p_111013_, p_111014_, p_111015_, bakedquad.getVertices(), bakedquad.getDirection(), p_111019_, p_111020_); -+ if (!net.minecraftforge.client.ForgeHooksClient.calculateFaceWithoutAO(p_111013_, p_111014_, p_111015_, bakedquad, p_111020_.get(0), p_111021_.brightness, p_111021_.lightmap)) - p_111021_.calculate(p_111013_, p_111014_, p_111015_, bakedquad.getDirection(), p_111019_, p_111020_, bakedquad.isShade()); - this.putQuadData( - p_111013_, -@@ -319,6 +_,11 @@ - } - } - -+ @Deprecated //Forge: Model data and render type parameter -+ public void renderModel(PoseStack.Pose p_111068_, VertexConsumer p_111069_, @Nullable BlockState p_111070_, BakedModel p_111071_, float p_111072_, float p_111073_, float p_111074_, int p_111075_, int p_111076_) { -+ renderModel(p_111068_, p_111069_, p_111070_, p_111071_, p_111072_, p_111073_, p_111074_, p_111075_, p_111076_, net.minecraftforge.client.model.data.ModelData.EMPTY, null); -+ } -+ - public void renderModel( + public static void renderModel( PoseStack.Pose p_111068_, VertexConsumer p_111069_, -@@ -328,18 +_,20 @@ +@@ -330,9 +_,11 @@ float p_111073_, float p_111074_, int p_111075_, - int p_111076_ + int p_111076_, + net.minecraftforge.client.model.data.ModelData modelData, -+ @Nullable net.minecraft.client.renderer.RenderType renderType ++ @org.jetbrains.annotations.Nullable net.minecraft.client.renderer.RenderType renderType ) { - RandomSource randomsource = RandomSource.create(); - long i = 42L; - - for (Direction direction : DIRECTIONS) { - randomsource.setSeed(42L); -- renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, direction, randomsource), p_111075_, p_111076_); -+ renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, direction, randomsource, modelData, renderType), p_111075_, p_111076_); - } - - randomsource.setSeed(42L); -- renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, null, randomsource), p_111075_, p_111076_); -+ renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, null, randomsource, modelData, renderType), p_111075_, p_111076_); - } - - private static void renderQuadList( +- for (BlockModelPart blockmodelpart : p_397754_.collectParts(RandomSource.create(42L))) { ++ for (BlockModelPart blockmodelpart : p_397754_.collectParts(RandomSource.create(42L), modelData, renderType)) { + for (Direction direction : DIRECTIONS) { + renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, blockmodelpart.getQuads(direction), p_111075_, p_111076_); + } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch index 16df7669c3..3017f12e04 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch @@ -1,33 +1,15 @@ --- a/net/minecraft/client/renderer/block/model/BakedQuad.java +++ b/net/minecraft/client/renderer/block/model/BakedQuad.java -@@ -13,14 +_,20 @@ - protected final TextureAtlasSprite sprite; - private final boolean shade; - private final int lightEmission; -+ private final boolean hasAmbientOcclusion; +@@ -6,7 +_,11 @@ + import net.minecraftforge.api.distmarker.OnlyIn; - public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, int p_366759_) { -+ this(p_111298_, p_111299_, p_111300_, p_111301_, p_111302_, p_366759_, true); + @OnlyIn(Dist.CLIENT) +-public record BakedQuad(int[] vertices, int tintIndex, Direction direction, TextureAtlasSprite sprite, boolean shade, int lightEmission) { ++public record BakedQuad(int[] vertices, int tintIndex, Direction direction, TextureAtlasSprite sprite, boolean shade, int lightEmission, boolean ambientOcclusion) { ++ public BakedQuad(int[] vertices, int tintIndex, Direction direction, TextureAtlasSprite sprite, boolean shade, int lightEmission) { ++ this(vertices, tintIndex, direction, sprite, shade, lightEmission, true); + } + -+ public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, int p_366759_, 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_366759_; -+ this.hasAmbientOcclusion = hasAmbientOcclusion; + public boolean isTinted() { + return this.tintIndex != -1; } - - public TextureAtlasSprite getSprite() { -@@ -49,5 +_,9 @@ - - public int getLightEmission() { - return this.lightEmission; -+ } -+ -+ public boolean hasAmbientOcclusion() { -+ return this.hasAmbientOcclusion; - } - } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockElementFace.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockElementFace.java.patch index 1456bbf910..e8be6a9071 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockElementFace.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockElementFace.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/renderer/block/model/BlockElementFace.java +++ b/net/minecraft/client/renderer/block/model/BlockElementFace.java -@@ -13,9 +_,18 @@ +@@ -15,9 +_,18 @@ import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) --public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, BlockFaceUV uv) { -+public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, BlockFaceUV uv, @Nullable net.minecraftforge.client.model.ForgeFaceData data) { +-public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, @Nullable BlockElementFace.UVs uvs, Quadrant rotation) { ++public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, @Nullable BlockElementFace.UVs uvs, Quadrant rotation, @Nullable net.minecraftforge.client.model.ForgeFaceData data) { public static final int NO_TINT = -1; -+ public BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, BlockFaceUV uv) { -+ this(cullForDirection, tintIndex, texture, uv, null); ++ public BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, @Nullable BlockElementFace.UVs uvs, Quadrant rotation) { ++ this(cullForDirection, tintIndex, texture, uvs, rotation, null); + } + + @Override @@ -17,15 +17,15 @@ + return this.data == null ? net.minecraftforge.client.model.ForgeFaceData.DEFAULT : this.data; + } + - @OnlyIn(Dist.CLIENT) - public static class Deserializer implements JsonDeserializer { - private static final int DEFAULT_TINT_INDEX = -1; -@@ -26,7 +_,7 @@ - int i = this.getTintIndex(jsonobject); - String s = this.getTexture(jsonobject); - BlockFaceUV blockfaceuv = p_111367_.deserialize(jsonobject, BlockFaceUV.class); -- return new BlockElementFace(direction, i, s, blockfaceuv); -+ return new BlockElementFace(direction, i, s, blockfaceuv, net.minecraftforge.client.model.ForgeFaceData.read(jsonobject.get("forge_data"), null)); + public static float getU(BlockElementFace.UVs p_396140_, Quadrant p_396737_, int p_395337_) { + return p_396140_.getVertexU(p_396737_.rotateVertexIndex(p_395337_)) / 16.0F; + } +@@ -38,7 +_,7 @@ + String s = getTexture(jsonobject); + BlockElementFace.UVs blockelementface$uvs = getUVs(jsonobject); + Quadrant quadrant = getRotation(jsonobject); +- return new BlockElementFace(direction, i, s, blockelementface$uvs, quadrant); ++ return new BlockElementFace(direction, i, s, blockelementface$uvs, quadrant, net.minecraftforge.client.model.ForgeFaceData.read(jsonobject.get("forge_data"), null)); } - protected int getTintIndex(JsonObject p_111369_) { + private static int getTintIndex(JsonObject p_111369_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch index 51a7aa0972..c30bc4394f 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockModel.java.patch @@ -1,52 +1,45 @@ --- a/net/minecraft/client/renderer/block/model/BlockModel.java +++ b/net/minecraft/client/renderer/block/model/BlockModel.java -@@ -49,6 +_,7 @@ - public UnbakedModel parent; - @Nullable - private final ResourceLocation parentLocation; -+ public final net.minecraftforge.client.model.geometry.BlockGeometryBakingContext customData = new net.minecraftforge.client.model.geometry.BlockGeometryBakingContext(this); - - public static BlockModel fromStream(Reader p_111462_) { - return GsonHelper.fromJson(GSON, p_111462_, BlockModel.class); -@@ -85,6 +_,8 @@ - @Override - public void resolveDependencies(ResolvableModel.Resolver p_377823_) { - if (this.parentLocation != null) { -+ if (customData.hasCustomGeometry()) -+ customData.getCustomGeometry().resolveDependencies(p_377823_, customData); - this.parent = p_377823_.resolve(this.parentLocation); - } - } -@@ -110,14 +_,20 @@ - public BakedModel bake( - TextureSlots p_378598_, ModelBaker p_378458_, ModelState p_111453_, boolean p_111455_, boolean p_377435_, ItemTransforms p_378085_ - ) { -+ if (this.customData.getCustomGeometry() != null) -+ return this.customData.getCustomGeometry().bake(customData, p_378458_, p_378598_, p_111453_); +@@ -28,8 +_,20 @@ + @Nullable Boolean ambientOcclusion, + @Nullable ItemTransforms transforms, + TextureSlots.Data textureSlots, +- @Nullable ResourceLocation parent ++ @Nullable ResourceLocation parent, ++ @Nullable net.minecraftforge.client.model.ForgeBlockModelData forgeData + ) implements UnbakedModel { ++ public BlockModel( ++ @Nullable UnbakedGeometry geometry, ++ @Nullable UnbakedModel.GuiLight guiLight, ++ @Nullable Boolean ambientOcclusion, ++ @Nullable ItemTransforms transforms, ++ TextureSlots.Data textureSlots, ++ @Nullable ResourceLocation parent ++ ) { ++ this(geometry, guiLight, ambientOcclusion, transforms, textureSlots, parent, null); ++ } + -+ var wrapped = net.minecraftforge.client.ForgeHooksClient.wrapRenderType(p_378458_, this.customData.getRenderType(), this.customData.getRenderTypeFast()); -+ - return this.elements.isEmpty() && this.parent != null -- ? this.parent.bake(p_378598_, p_378458_, p_111453_, p_111455_, p_377435_, p_378085_) -- : SimpleBakedModel.bakeElements(this.elements, p_378598_, p_378458_.sprites(), p_111453_, p_111455_, p_377435_, true, p_378085_); -+ ? this.parent.bake(p_378598_, wrapped, p_111453_, p_111455_, p_377435_, p_378085_) -+ : SimpleBakedModel.bakeElements(this.elements, p_378598_, p_378458_.sprites(), p_111453_, p_111455_, p_377435_, true, p_378085_, wrapped.renderType(), wrapped.renderTypeFast()); - } - - @Nullable @VisibleForTesting - List getElements() { -+ if (customData.hasCustomGeometry()) return java.util.Collections.emptyList(); - return this.elements; - } - -@@ -147,7 +_,8 @@ + static final Gson GSON = new GsonBuilder() + .registerTypeAdapter(BlockModel.class, new BlockModel.Deserializer()) +@@ -97,8 +_,9 @@ + unbakedmodel$guilight = UnbakedModel.GuiLight.getByName(GsonHelper.getAsString(jsonobject, "gui_light")); } ++ var forgeData = net.minecraftforge.client.ForgeHooksClient.deserializeBlockModel(jsonobject, p_111500_); ResourceLocation resourcelocation = s.isEmpty() ? null : ResourceLocation.parse(s); -- return new BlockModel(resourcelocation, list, textureslots$data, obool, unbakedmodel$guilight, itemtransforms); -+ var ret = new BlockModel(resourcelocation, list, textureslots$data, obool, unbakedmodel$guilight, itemtransforms); -+ return net.minecraftforge.client.ForgeHooksClient.deserializeBlockModel(ret, ret.getElements(), jsonobject, p_111500_); +- return new BlockModel(unbakedgeometry, unbakedmodel$guilight, obool, itemtransforms, textureslots$data, resourcelocation); ++ return new BlockModel(unbakedgeometry, unbakedmodel$guilight, obool, itemtransforms, textureslots$data, resourcelocation, forgeData); } private TextureSlots.Data getTextureMap(JsonObject p_111510_) { +@@ -121,6 +_,9 @@ + + @Nullable + protected UnbakedGeometry getElements(JsonDeserializationContext p_111507_, JsonObject p_111508_) { ++ var geo = net.minecraftforge.client.ForgeHooksClient.deserializeBlockModelGeometry(p_111508_, p_111507_); ++ if (geo != null) ++ return geo; + if (!p_111508_.has("elements")) { + return null; + } else { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BlockStateModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockStateModel.java.patch new file mode 100644 index 0000000000..98f0c8f968 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BlockStateModel.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/client/renderer/block/model/BlockStateModel.java ++++ b/net/minecraft/client/renderer/block/model/BlockStateModel.java +@@ -22,15 +_,21 @@ + import net.minecraftforge.api.distmarker.OnlyIn; + + @OnlyIn(Dist.CLIENT) +-public interface BlockStateModel { ++public interface BlockStateModel extends net.minecraftforge.client.extensions.IForgeBlockStateModel { ++ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBlockStateModel#collectParts(RandomSource, List, net.minecraftforge.client.model.data.ModelData, net.minecraft.client.renderer.RenderType)}*/ ++ @Deprecated + void collectParts(RandomSource p_397689_, List p_394710_); + ++ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBlockStateModel#collectParts(RandomSource, net.minecraftforge.client.model.data.ModelData, net.minecraft.client.renderer.RenderType)}*/ ++ @Deprecated + default List collectParts(RandomSource p_392713_) { + List list = new ObjectArrayList<>(); +- this.collectParts(p_392713_, list); ++ this.collectParts(p_392713_, list, net.minecraftforge.client.model.data.ModelData.EMPTY, null); + return list; + } + ++ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBlockStateModel#particleIcon(net.minecraftforge.client.model.data.ModelData)}*/ ++ @Deprecated + TextureAtlasSprite particleIcon(); + + @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch index ef03fcdd16..705f6f07b5 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/model/FaceBakery.java +++ b/net/minecraft/client/renderer/block/model/FaceBakery.java -@@ -58,7 +_,13 @@ +@@ -67,7 +_,14 @@ recalculateWinding(aint, direction); } @@ -8,10 +8,11 @@ + var data = p_111603_.data(); + var quad = new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, p_364904_, data.ambientOcclusion()); + if (!net.minecraftforge.client.model.ForgeFaceData.DEFAULT.equals(data)) { -+ net.minecraftforge.client.model.QuadTransformers.applyingLightmap(data.blockLight(), data.skyLight()).processInPlace(quad); -+ net.minecraftforge.client.model.QuadTransformers.applyingColor(data.color()).processInPlace(quad); ++ quad = net.minecraftforge.client.model.QuadTransformers.applyingLightmap(data.blockLight(), data.skyLight()) ++ .andThen(net.minecraftforge.client.model.QuadTransformers.applyingColor(data.color())) ++ .process(quad); + } + return quad; } - public static BlockFaceUV recomputeUVs(BlockFaceUV p_111582_, Direction p_111583_, Transformation p_111584_) { + private static BlockElementFace.UVs shrinkUVs(TextureAtlasSprite p_397002_, BlockElementFace.UVs p_394057_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch index ab59daaf96..e0c3de578b 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransform.java.patch @@ -1,24 +1,19 @@ --- a/net/minecraft/client/renderer/block/model/ItemTransform.java +++ b/net/minecraft/client/renderer/block/model/ItemTransform.java -@@ -21,11 +_,17 @@ - public final Vector3f rotation; - public final Vector3f translation; - public final Vector3f scale; -+ public final Vector3f rightRotation; +@@ -17,7 +_,11 @@ + import org.joml.Vector3fc; - public ItemTransform(Vector3f p_254427_, Vector3f p_254496_, Vector3f p_254022_) { -+ this(p_254427_, p_254496_, p_254022_, new Vector3f()); + @OnlyIn(Dist.CLIENT) +-public record ItemTransform(Vector3fc rotation, Vector3fc translation, Vector3fc scale) { ++public record ItemTransform(Vector3fc rotation, Vector3fc translation, Vector3fc scale, Vector3fc rightRotation) { ++ public ItemTransform(Vector3fc rotation, Vector3fc translation, Vector3fc scale) { ++ this(rotation, translation, scale, new Vector3f()); + } + -+ public ItemTransform(Vector3f p_254427_, Vector3f p_254496_, Vector3f p_254022_, Vector3f rightRotation) { - this.rotation = new Vector3f(p_254427_); - this.translation = new Vector3f(p_254496_); - this.scale = new Vector3f(p_254022_); -+ this.rightRotation = new Vector3f(rightRotation); - } + public static final ItemTransform NO_TRANSFORM = new ItemTransform(new Vector3f(), new Vector3f(), new Vector3f(1.0F, 1.0F, 1.0F)); - public void apply(boolean p_111764_, PoseStack p_111765_) { -@@ -82,7 +_,7 @@ + public void apply(boolean p_111764_, PoseStack.Pose p_397991_) { +@@ -62,7 +_,7 @@ vector3f1.set(Mth.clamp(vector3f1.x, -5.0F, 5.0F), Mth.clamp(vector3f1.y, -5.0F, 5.0F), Mth.clamp(vector3f1.z, -5.0F, 5.0F)); Vector3f vector3f2 = this.getVector3f(jsonobject, "scale", DEFAULT_SCALE); vector3f2.set(Mth.clamp(vector3f2.x, -4.0F, 4.0F), Mth.clamp(vector3f2.y, -4.0F, 4.0F), Mth.clamp(vector3f2.z, -4.0F, 4.0F)); diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/multipart/MultiPartModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/multipart/MultiPartModel.java.patch new file mode 100644 index 0000000000..ac60287467 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/multipart/MultiPartModel.java.patch @@ -0,0 +1,54 @@ +--- a/net/minecraft/client/renderer/block/model/multipart/MultiPartModel.java ++++ b/net/minecraft/client/renderer/block/model/multipart/MultiPartModel.java +@@ -38,6 +_,11 @@ + } + + @Override ++ public TextureAtlasSprite particleIcon(net.minecraftforge.client.model.data.ModelData data) { ++ return this.shared.firstModel.particleIcon(data); ++ } ++ ++ @Override + public void collectParts(RandomSource p_391247_, List p_397207_) { + if (this.models == null) { + this.models = this.shared.selectModels(this.blockState); +@@ -51,6 +_,20 @@ + } + } + ++ @Override ++ public void collectParts(RandomSource rand, List dest, net.minecraftforge.client.model.data.ModelData extraData, net.minecraft.client.renderer.RenderType renderType) { ++ if (this.models == null) { ++ this.models = this.shared.selectModels(this.blockState); ++ } ++ ++ long i = rand.nextLong(); ++ ++ for (BlockStateModel blockstatemodel : this.models) { ++ rand.setSeed(i); ++ blockstatemodel.collectParts(rand, dest, extraData, renderType); ++ } ++ } ++ + @OnlyIn(Dist.CLIENT) + public record Selector(Predicate condition, T model) { + public MultiPartModel.Selector with(S p_393772_) { +@@ -62,6 +_,7 @@ + static final class SharedBakedState { + private final List> selectors; + final TextureAtlasSprite particleIcon; ++ final BlockStateModel firstModel; + private final Map> subsets = new ConcurrentHashMap<>(); + + private static BlockStateModel getFirstModel(List> p_392132_) { +@@ -74,8 +_,8 @@ + + public SharedBakedState(List> p_393647_) { + this.selectors = p_393647_; +- BlockStateModel blockstatemodel = getFirstModel(p_393647_); +- this.particleIcon = blockstatemodel.particleIcon(); ++ this.firstModel = getFirstModel(p_393647_); ++ this.particleIcon = firstModel.particleIcon(); + } + + public List selectModels(BlockState p_392405_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch index b1e9face0a..39227c83c1 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch +++ b/patches/minecraft/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 -@@ -66,7 +_,7 @@ +@@ -67,7 +_,7 @@ f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; int i = neighborcombineresult.apply(new BrightnessCombiner<>()).applyAsInt(p_112367_); @@ -9,7 +9,7 @@ VertexConsumer vertexconsumer = material.buffer(p_112366_, RenderType::entityCutout); if (flag1) { if (chesttype == ChestType.LEFT) { -@@ -85,5 +_,9 @@ +@@ -86,5 +_,9 @@ private void render(PoseStack p_112370_, VertexConsumer p_112371_, ChestModel p_363333_, float p_112375_, int p_112376_, int p_112377_) { p_363333_.setupAnim(p_112375_); p_363333_.renderToBuffer(p_112370_, p_112371_, p_112376_, p_112377_); diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch index 2f6182f685..40b64348a8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java.patch @@ -1,33 +1,19 @@ --- a/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java +++ b/net/minecraft/client/renderer/blockentity/PistonHeadRenderer.java -@@ -65,13 +_,15 @@ +@@ -70,10 +_,15 @@ private void renderBlock( BlockPos p_112459_, BlockState p_112460_, PoseStack p_112461_, MultiBufferSource p_112462_, Level p_112463_, boolean p_112464_, int p_112465_ ) { - RenderType rendertype = ItemBlockRenderTypes.getMovingBlockRenderType(p_112460_); -- VertexConsumer vertexconsumer = p_112462_.getBuffer(rendertype); -+ var model = blockRenderer.getBlockModel(p_112460_); ++ var model = this.blockRenderer.getBlockModel(p_112460_); ++ var rand = RandomSource.create(p_112460_.getSeed(p_112459_)); + var data = net.minecraftforge.client.model.data.ModelData.EMPTY; -+ for (var rendertype : model.getRenderTypes(p_112460_, RandomSource.create(p_112460_.getSeed(p_112459_)), data)) { -+ VertexConsumer vertexconsumer = p_112462_.getBuffer(net.minecraftforge.client.RenderTypeHelper.getMovingBlockRenderType(rendertype)); - this.blockRenderer - .getModelRenderer() - .tesselateBlock( - p_112463_, -- this.blockRenderer.getBlockModel(p_112460_), -+ model, - p_112460_, - p_112459_, - p_112461_, -@@ -79,8 +_,11 @@ - p_112464_, - RandomSource.create(), - p_112460_.getSeed(p_112459_), -- p_112465_ -+ p_112465_, -+ data, -+ rendertype - ); ++ for (var rendertype : model.getRenderTypes(p_112460_, rand, data)) { ++ rand = RandomSource.create(p_112460_.getSeed(p_112459_)); // Reset rand to keep + VertexConsumer vertexconsumer = p_112462_.getBuffer(rendertype); +- List list = this.blockRenderer.getBlockModel(p_112460_).collectParts(RandomSource.create(p_112460_.getSeed(p_112459_))); ++ List list = model.collectParts(rand, data, net.minecraftforge.client.RenderTypeHelper.getMovingBlockRenderType(rendertype)); + this.blockRenderer.getModelRenderer().tesselateBlock(p_112463_, list, p_112460_, p_112459_, p_112461_, vertexconsumer, p_112464_, p_112465_); + } } diff --git a/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch index 53e6125c78..895a416d39 100644 --- a/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java +++ b/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java -@@ -33,6 +_,7 @@ +@@ -34,6 +_,7 @@ @OnlyIn(Dist.CLIENT) public class SkullBlockRenderer implements BlockEntityRenderer { @@ -8,7 +8,7 @@ private final Function modelByType; public static final Map SKIN_BY_TYPE = Util.make(Maps.newHashMap(), p_340906_ -> { p_340906_.put(SkullBlock.Types.SKELETON, ResourceLocation.withDefaultNamespace("textures/entity/skeleton/skeleton.png")); -@@ -57,7 +_,9 @@ +@@ -58,7 +_,9 @@ case PIGLIN -> new PiglinHeadModel(p_376421_.bakeLayer(ModelLayers.PIGLIN_HEAD)); }); } else { diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunkRegion.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunkRegion.java.patch index cd78101c9c..1f8c0993ea 100644 --- a/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunkRegion.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunkRegion.java.patch @@ -1,16 +1,11 @@ --- a/net/minecraft/client/renderer/chunk/RenderChunkRegion.java +++ b/net/minecraft/client/renderer/chunk/RenderChunkRegion.java -@@ -78,4 +_,14 @@ +@@ -78,4 +_,9 @@ public static int index(int p_345383_, int p_342744_, int p_343921_, int p_343462_) { return p_343921_ - p_345383_ + (p_343462_ - p_342744_) * 3; } + + @Override -+ public float getShade(float normalX, float normalY, float normalZ, boolean shade) { -+ return this.level.getShade(normalX, normalY, normalZ, shade); -+ } -+ -+ @Override + public net.minecraftforge.client.model.data.ModelDataManager getModelDataManager() { + return level.getModelDataManager(); + } diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/SectionCompiler.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/SectionCompiler.java.patch index 8a88dd23de..180639fc93 100644 --- a/patches/minecraft/net/minecraft/client/renderer/chunk/SectionCompiler.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/chunk/SectionCompiler.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/chunk/SectionCompiler.java +++ b/net/minecraft/client/renderer/chunk/SectionCompiler.java -@@ -41,6 +_,7 @@ +@@ -43,6 +_,7 @@ } public SectionCompiler.Results compile(SectionPos p_344383_, RenderChunkRegion p_342669_, VertexSorting p_342522_, SectionBufferBuilderPack p_343546_) { @@ -8,7 +8,7 @@ SectionCompiler.Results sectioncompiler$results = new SectionCompiler.Results(); BlockPos blockpos = p_344383_.origin(); BlockPos blockpos1 = blockpos.offset(15, 15, 15); -@@ -71,7 +_,11 @@ +@@ -74,10 +_,14 @@ } if (blockstate.getRenderShape() == RenderShape.MODEL) { @@ -16,23 +16,24 @@ + var model = this.blockRenderer.getBlockModel(blockstate); + var data = modelDataMap.getOrDefault(blockpos2, net.minecraftforge.client.model.data.ModelData.EMPTY); + data = model.getModelData(p_342669_, blockpos2, blockstate, data); -+ randomsource.setSeed(blockstate.getSeed(blockpos2)); ++ randomsource.setSeed(blockstate.getSeed(blockpos2)); // Forge: We set this on purpose twice so that getRenderTypes can have the same RNG as collectParts + for (RenderType rendertype2 : model.getRenderTypes(blockstate, randomsource, data)) { BufferBuilder bufferbuilder1 = this.getOrBeginLayer(map, p_343546_, rendertype2); + randomsource.setSeed(blockstate.getSeed(blockpos2)); +- this.blockRenderer.getBlockModel(blockstate).collectParts(randomsource, list); ++ model.collectParts(randomsource, list, data, rendertype2); posestack.pushPose(); posestack.translate( -@@ -79,8 +_,9 @@ - (float)SectionPos.sectionRelative(blockpos2.getY()), - (float)SectionPos.sectionRelative(blockpos2.getZ()) - ); -- this.blockRenderer.renderBatched(blockstate, blockpos2, p_342669_, posestack, bufferbuilder1, true, randomsource); -+ this.blockRenderer.renderBatched(blockstate, blockpos2, p_342669_, posestack, bufferbuilder1, true, randomsource, data, rendertype2); + SectionPos.sectionRelative(blockpos2.getX()), SectionPos.sectionRelative(blockpos2.getY()), SectionPos.sectionRelative(blockpos2.getZ()) +@@ -85,6 +_,7 @@ + this.blockRenderer.renderBatched(blockstate, blockpos2, p_342669_, posestack, bufferbuilder1, true, list); posestack.popPose(); + list.clear(); + } } } -@@ -115,9 +_,10 @@ +@@ -119,9 +_,10 @@ private void handleBlockEntity(SectionCompiler.Results p_343713_, E p_343478_) { BlockEntityRenderer blockentityrenderer = this.blockEntityRenderer.getRenderer(p_343478_); if (blockentityrenderer != null) { diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EnderDragonRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EnderDragonRenderer.java.patch new file mode 100644 index 0000000000..ab17b9a353 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EnderDragonRenderer.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/client/renderer/entity/EnderDragonRenderer.java ++++ b/net/minecraft/client/renderer/entity/EnderDragonRenderer.java +@@ -225,11 +_,15 @@ + + protected void extractAdditionalHitboxes(EnderDragon p_394570_, Builder p_396096_, float p_397646_) { + super.extractAdditionalHitboxes(p_394570_, p_396096_, p_397646_); ++ } ++ ++ public static void extractAdditionalHitboxexGeneric(net.minecraft.world.entity.Entity p_394570_, Builder p_396096_, float p_397646_) { ++ if (!p_394570_.isMultipartEntity()) return; + double d0 = -Mth.lerp(p_397646_, p_394570_.xOld, p_394570_.getX()); + double d1 = -Mth.lerp(p_397646_, p_394570_.yOld, p_394570_.getY()); + double d2 = -Mth.lerp(p_397646_, p_394570_.zOld, p_394570_.getZ()); + +- for (EnderDragonPart enderdragonpart : p_394570_.getSubEntities()) { ++ for (var enderdragonpart : p_394570_.getParts()) { + AABB aabb = enderdragonpart.getBoundingBox(); + HitboxRenderState hitboxrenderstate = new HitboxRenderState( + aabb.minX - enderdragonpart.getX(), diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch index 89ec992df0..2fc2896391 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch @@ -1,21 +1,6 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java +++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java -@@ -246,12 +_,12 @@ - ) { - AABB aabb = p_114444_.getBoundingBox().move(-p_114444_.getX(), -p_114444_.getY(), -p_114444_.getZ()); - ShapeRenderer.renderLineBox(p_114442_, p_114443_, aabb, p_343193_, p_342304_, p_342638_, 1.0F); -- if (p_114444_ instanceof EnderDragon) { -+ if (p_114444_.isMultipartEntity()) { - double d0 = -Mth.lerp((double)p_114445_, p_114444_.xOld, p_114444_.getX()); - double d1 = -Mth.lerp((double)p_114445_, p_114444_.yOld, p_114444_.getY()); - double d2 = -Mth.lerp((double)p_114445_, p_114444_.zOld, p_114444_.getZ()); - -- for (EnderDragonPart enderdragonpart : ((EnderDragon)p_114444_).getSubEntities()) { -+ for (var enderdragonpart : p_114444_.getParts()) { - 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()); -@@ -484,6 +_,10 @@ +@@ -492,6 +_,10 @@ return this.itemInHandRenderer; } @@ -26,7 +11,7 @@ @Override public void onResourceManagerReload(ResourceManager p_174004_) { EntityRendererProvider.Context entityrendererprovider$context = new EntityRendererProvider.Context( -@@ -491,5 +_,6 @@ +@@ -499,5 +_,6 @@ ); this.renderers = EntityRenderers.createEntityRenderers(entityrendererprovider$context); this.playerRenderers = EntityRenderers.createPlayerRenderers(entityrendererprovider$context); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch index 75b18632c9..3f7003b501 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderer.java +++ b/net/minecraft/client/renderer/entity/EntityRenderer.java -@@ -104,8 +_,9 @@ +@@ -109,8 +_,9 @@ renderLeash(p_114488_, p_114489_, entityrenderstate$leashstate); } @@ -12,7 +12,7 @@ } } -@@ -272,7 +_,7 @@ +@@ -278,7 +_,7 @@ } p_367427_.distanceToCameraSq = this.entityRenderDispatcher.distanceToSqr(p_367571_); @@ -21,3 +21,11 @@ if (flag) { p_367427_.nameTag = this.getNameTag(p_367571_); p_367427_.nameTagAttachment = p_367571_.getAttachments().getNullable(EntityAttachment.NAME_TAG, 0, p_367571_.getYRot(p_363243_)); +@@ -372,6 +_,7 @@ + } + + protected void extractAdditionalHitboxes(T p_392955_, Builder p_395671_, float p_395030_) { ++ net.minecraft.client.renderer.entity.EnderDragonRenderer.extractAdditionalHitboxexGeneric(p_392955_, p_395671_, p_395030_); // Forge: Extract for our generic multi-part entity system + } + + @Nullable diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch index 6759e32229..059c92d64c 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/client/renderer/entity/ItemFrameRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemFrameRenderer.java -@@ -96,6 +_,7 @@ +@@ -94,6 +_,7 @@ if (p_361692_.mapId != null) { int j = p_361692_.rotation % 4 * 2; - p_115061_.mulPose(Axis.ZP.rotationDegrees((float)j * 360.0F / 8.0F)); + p_115061_.mulPose(Axis.ZP.rotationDegrees(j * 360.0F / 8.0F)); + if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderItemInFrame(p_361692_, this, p_115061_, p_115062_, p_115063_)) { p_115061_.mulPose(Axis.ZP.rotationDegrees(180.0F)); float f2 = 0.0078125F; p_115061_.scale(0.0078125F, 0.0078125F, 0.0078125F); -@@ -103,6 +_,7 @@ +@@ -101,6 +_,7 @@ p_115061_.translate(0.0F, 0.0F, -1.0F); int i = this.getLightCoords(p_361692_.isGlowFrame, 15728850, p_115063_); this.mapRenderer.render(p_361692_.mapRenderState, p_115061_, p_115062_, true, i); + } } else if (!p_361692_.item.isEmpty()) { - p_115061_.mulPose(Axis.ZP.rotationDegrees((float)p_361692_.rotation * 360.0F / 8.0F)); + p_115061_.mulPose(Axis.ZP.rotationDegrees(p_361692_.rotation * 360.0F / 8.0F)); int k = this.getLightCoords(p_361692_.isGlowFrame, 15728880, p_115063_); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch index 2571fbc4ec..f6da161137 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/ItemRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/ItemRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemRenderer.java -@@ -130,7 +_,7 @@ +@@ -114,7 +_,7 @@ f3 = 1.0F; } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch index 2f5e0be8f7..2eee9ca8cc 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/LivingEntityRenderer.java +++ b/net/minecraft/client/renderer/entity/LivingEntityRenderer.java -@@ -73,6 +_,7 @@ +@@ -75,6 +_,7 @@ } public void render(S p_364280_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { @@ -8,7 +8,7 @@ p_115311_.pushPose(); if (p_364280_.hasPose(Pose.SLEEPING)) { Direction direction = p_364280_.bedOrientation; -@@ -108,6 +_,7 @@ +@@ -110,6 +_,7 @@ p_115311_.popPose(); super.render(p_364280_, p_115311_, p_115312_, p_115313_); @@ -16,11 +16,19 @@ } protected boolean shouldRenderLayers(S p_360804_) { -@@ -290,6 +_,7 @@ - p_363057_.isFullyFrozen = p_368665_.isFullyFrozen(); - p_363057_.isBaby = p_368665_.isBaby(); - p_363057_.isInWater = p_368665_.isInWater(); -+ p_363057_.isInWater = p_368665_.isInWaterOrSwimmable(); - p_363057_.isAutoSpinAttack = p_368665_.isAutoSpinAttack(); - p_363057_.hasRedOverlay = p_368665_.hurtTime > 0 || p_368665_.deathTime > 0; - ItemStack itemstack = p_368665_.getItemBySlot(EquipmentSlot.HEAD); +@@ -291,6 +_,7 @@ + p_363057_.isFullyFrozen = p_368665_.isFullyFrozen(); + p_363057_.isBaby = p_368665_.isBaby(); + p_363057_.isInWater = p_368665_.isInWater(); ++ p_363057_.isInWater = p_368665_.isInWaterOrSwimmable(); + p_363057_.isAutoSpinAttack = p_368665_.isAutoSpinAttack(); + p_363057_.hasRedOverlay = p_368665_.hurtTime > 0 || p_368665_.deathTime > 0; + ItemStack itemstack = p_368665_.getItemBySlot(EquipmentSlot.HEAD); +@@ -315,6 +_,7 @@ + } + + protected void extractAdditionalHitboxes(T p_392957_, Builder p_396936_, float p_397822_) { ++ super.extractAdditionalHitboxes(p_392957_, p_396936_, p_397822_); + AABB aabb = p_392957_.getBoundingBox(); + float f = 0.01F; + HitboxRenderState hitboxrenderstate = new HitboxRenderState( diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch index 01bb860fa9..193f7fc697 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch @@ -1,12 +1,16 @@ --- a/net/minecraft/client/renderer/entity/player/PlayerRenderer.java +++ b/net/minecraft/client/renderer/entity/player/PlayerRenderer.java -@@ -128,10 +_,14 @@ - if (itemuseanimation == ItemUseAnimation.BRUSH) { - return HumanoidModel.ArmPose.BRUSH; +@@ -98,7 +_,7 @@ + private static HumanoidModel.ArmPose getArmPose(Player p_376602_, ItemStack p_376446_, InteractionHand p_361073_) { + if (p_376446_.isEmpty()) { + return HumanoidModel.ArmPose.EMPTY; +- } else if (!p_376602_.swinging && p_376446_.is(Items.CROSSBOW) && CrossbowItem.isCharged(p_376446_)) { ++ } else if (!p_376602_.swinging && p_376446_.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(p_376446_)) { + return HumanoidModel.ArmPose.CROSSBOW_HOLD; + } else { + if (p_376602_.getUsedItemHand() == p_361073_ && p_376602_.getUseItemRemainingTicks() > 0) { +@@ -132,6 +_,10 @@ } -- } else if (!p_376602_.swinging && p_376446_.is(Items.CROSSBOW) && CrossbowItem.isCharged(p_376446_)) { -+ } else if (!p_376602_.swinging && p_376446_.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(p_376446_)) { - return HumanoidModel.ArmPose.CROSSBOW_HOLD; } + var pose = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(p_376446_).getArmPose(p_376602_, p_361073_, p_376446_); @@ -16,7 +20,7 @@ return HumanoidModel.ArmPose.ITEM; } } -@@ -255,10 +_,12 @@ +@@ -253,10 +_,12 @@ } public void renderRightHand(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, ResourceLocation p_364347_, boolean p_367689_) { @@ -29,7 +33,7 @@ this.renderHand(p_117814_, p_117815_, p_117816_, p_368419_, this.model.leftArm, p_362915_); } -@@ -297,5 +_,12 @@ +@@ -295,5 +_,12 @@ } else { super.setupRotations(p_369667_, p_117803_, p_117804_, p_117805_); } diff --git a/patches/minecraft/net/minecraft/client/renderer/item/BlockModelWrapper.java.patch b/patches/minecraft/net/minecraft/client/renderer/item/BlockModelWrapper.java.patch deleted file mode 100644 index fa4c5f3dbd..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/item/BlockModelWrapper.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/client/renderer/item/BlockModelWrapper.java -+++ b/net/minecraft/client/renderer/item/BlockModelWrapper.java -@@ -55,6 +_,12 @@ - aint[j] = this.tints.get(j).calculate(p_378482_, p_376532_, p_376906_); - } - -+ // TODO: [Rendering] Figure out how to add multiple passes -+ /* -+ - RenderType rendertype = ItemBlockRenderTypes.getRenderType(p_378482_); -+ + for (var model : p_367824_.getRenderPasses(p_378482_, true)) { -+ + for (var rendertype : model.getRenderTypes(p_378482_, true)) { -+ */ - RenderType rendertype = ItemBlockRenderTypes.getRenderType(p_378482_); - itemstackrenderstate$layerrenderstate.setupBlockModel(this.model, rendertype); - } diff --git a/patches/minecraft/net/minecraft/client/renderer/item/ItemStackRenderState.java.patch b/patches/minecraft/net/minecraft/client/renderer/item/ItemStackRenderState.java.patch deleted file mode 100644 index 31e45365cd..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/item/ItemStackRenderState.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/client/renderer/item/ItemStackRenderState.java -+++ b/net/minecraft/client/renderer/item/ItemStackRenderState.java -@@ -72,7 +_,7 @@ - return null; - } else { - BakedModel bakedmodel = this.layers[p_376964_.nextInt(this.activeLayerCount)].model; -- return bakedmodel == null ? null : bakedmodel.getParticleIcon(); -+ return bakedmodel == null ? null : bakedmodel.getParticleIcon(net.minecraftforge.client.model.data.ModelData.EMPTY); - } - } - -@@ -149,6 +_,9 @@ - - void render(PoseStack p_377989_, MultiBufferSource p_377594_, int p_375616_, int p_376132_) { - p_377989_.pushPose(); -+ if (this.model != null) -+ this.model.applyTransform(ItemStackRenderState.this.displayContext, p_377989_, ItemStackRenderState.this.isLeftHand); -+ else - this.transform().apply(ItemStackRenderState.this.isLeftHand, p_377989_); - p_377989_.translate(-0.5F, -0.5F, -0.5F); - if (this.specialRenderer != null) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch index 38e3ff9e92..a5034ed573 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/client/renderer/texture/AbstractTexture.java +++ b/net/minecraft/client/renderer/texture/AbstractTexture.java -@@ -53,6 +_,8 @@ - RenderSystem.assertOnRenderThreadOrInit(); - int i; - int j; -+ this.blur = p_117961_; -+ this.mipmap = p_117962_; - if (p_117961_) { - i = p_117962_ ? 9987 : 9729; - j = 9729; -@@ -110,5 +_,18 @@ - - @Override - public void close() { +@@ -30,6 +_,8 @@ + if (this.texture == null) { + throw new IllegalStateException("Texture does not exist, can't get change its filter before something initializes it"); + } else { ++ this.blur = p_117961_; ++ this.mipmap = p_117962_; + this.texture.setTextureFilter(p_117961_ ? FilterMode.LINEAR : FilterMode.NEAREST, p_117962_); + } + } +@@ -40,6 +_,19 @@ + this.texture.close(); + this.texture = null; + } + } + + // FORGE: This seems to have been stripped out, but we need it @@ -27,4 +27,5 @@ + public void restoreLastBlurMipmap() { + setFilter(this.lastBlur, this.lastMipmap); } - } + + public GpuTexture getTexture() { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch index 97de83a047..f3ff887709 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteContents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/texture/SpriteContents.java +++ b/net/minecraft/client/renderer/texture/SpriteContents.java -@@ -34,8 +_,18 @@ +@@ -36,8 +_,18 @@ @Nullable final SpriteContents.AnimatedTexture animatedTexture; private final ResourceMetadata metadata; @@ -19,7 +19,7 @@ this.name = p_249787_; this.width = p_251031_.width(); this.height = p_251031_.height(); -@@ -45,6 +_,7 @@ +@@ -47,6 +_,7 @@ .orElse(null); this.originalImage = p_252131_; this.byMipLevel = new NativeImage[]{this.originalImage}; @@ -27,17 +27,17 @@ } public void increaseMipLevel(int p_248864_) { -@@ -130,6 +_,9 @@ +@@ -132,6 +_,9 @@ - void upload(int p_248895_, int p_250245_, int p_250458_, int p_251337_, NativeImage[] p_248825_) { + void upload(int p_248895_, int p_250245_, int p_250458_, int p_251337_, NativeImage[] p_248825_, GpuTexture p_392525_) { for (int i = 0; i < this.byMipLevel.length; i++) { + // Forge: Skip uploading if the texture would be made invalid by mip level + if ((this.width >> i) <= 0 || (this.height >> i) <= 0) -+ break; - p_248825_[i].upload(i, p_248895_ >> i, p_250245_ >> i, p_250458_ >> i, p_251337_ >> i, this.width >> i, this.height >> i, false); - } - } -@@ -149,6 +_,10 @@ ++ break; + RenderSystem.getDevice() + .createCommandEncoder() + .writeToTexture( +@@ -155,6 +_,10 @@ return this.name; } @@ -48,7 +48,7 @@ public IntStream getUniqueFrames() { return this.animatedTexture != null ? this.animatedTexture.getUniqueFrames() : IntStream.of(1); } -@@ -244,7 +_,8 @@ +@@ -250,7 +_,8 @@ for (int i = 0; i < this.activeFrame.length; i++) { int j = SpriteContents.this.width >> i; int k = SpriteContents.this.height >> i; @@ -58,7 +58,7 @@ } } -@@ -259,6 +_,9 @@ +@@ -265,6 +_,9 @@ for (int k = 0; k < this.activeFrame.length; k++) { int l = SpriteContents.this.width >> k; int i1 = SpriteContents.this.height >> k; diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch index 743739e90a..b587d2ab8d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/SpriteLoader.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/client/renderer/texture/SpriteLoader.java +++ b/net/minecraft/client/renderer/texture/SpriteLoader.java -@@ -74,7 +_,7 @@ - int j1 = Math.min(j, k); - int k1 = Mth.log2(j1); - int l1; -- if (k1 < p_261919_) { -+ if (k1 < p_261919_ && net.minecraftforge.common.ForgeConfig.CLIENT.allowMipmapLowering()) { // Forge: Do not lower the mipmap level - LOGGER.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.location, p_261919_, k1, j1); - l1 = k1; - } else { -@@ -138,9 +_,14 @@ +@@ -78,7 +_,7 @@ + int j1 = Math.min(j, k); + int k1 = Mth.log2(j1); + int l1; +- if (k1 < p_261919_) { ++ if (k1 < p_261919_ && net.minecraftforge.common.ForgeConfig.CLIENT.allowMipmapLowering()) { // Forge: Do not lower the mipmap level + LOGGER.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.location, p_261919_, k1, j1); + l1 = k1; + } else { +@@ -145,9 +_,14 @@ private Map getStitchedSprites(Stitcher p_276117_, int p_276111_, int p_276112_) { Map map = new HashMap<>(); p_276117_.gatherSprites( - (p_251421_, p_250533_, p_251913_) -> map.put( -- p_251421_.name(), new TextureAtlasSprite(this.location, p_251421_, p_276111_, p_276112_, p_250533_, p_251913_) -- ) +- p_251421_.name(), new TextureAtlasSprite(this.location, p_251421_, p_276111_, p_276112_, p_250533_, p_251913_) +- ) + (p_251421_, p_250533_, p_251913_) -> { + TextureAtlasSprite sprite = net.minecraftforge.client.ForgeHooksClient.loadTextureAtlasSprite(this.location, p_251421_, p_276111_, p_276112_, p_250533_, p_251913_, p_251421_.byMipLevel.length - 1); + if (sprite != null) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch index e1df40047a..4db27b4adc 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/texture/TextureAtlas.java +++ b/net/minecraft/client/renderer/texture/TextureAtlas.java -@@ -82,6 +_,7 @@ +@@ -84,6 +_,7 @@ this.sprites = List.copyOf(list); this.animatedTextures = List.copyOf(list1); } @@ -8,7 +8,7 @@ } @Override -@@ -159,5 +_,10 @@ +@@ -161,5 +_,10 @@ int getHeight() { return this.height; diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch index e29adf0202..3c0bc43131 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/texture/TextureAtlasSprite.java +++ b/net/minecraft/client/renderer/texture/TextureAtlasSprite.java -@@ -137,4 +_,13 @@ +@@ -138,4 +_,13 @@ @Override void close(); } diff --git a/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch deleted file mode 100644 index b3ad1b216b..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/model/BakedModel.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/client/resources/model/BakedModel.java -+++ b/net/minecraft/client/resources/model/BakedModel.java -@@ -12,7 +_,9 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public interface BakedModel { -+public interface BakedModel extends net.minecraftforge.client.extensions.IForgeBakedModel { -+ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#getQuads(BlockState, Direction, RandomSource, net.minecraftforge.client.model.data.ModelData, net.minecraft.client.renderer.RenderType)}*/ -+ @Deprecated - List getQuads(@Nullable BlockState p_235039_, @Nullable Direction p_235040_, RandomSource p_235041_); - - boolean useAmbientOcclusion(); -@@ -21,7 +_,11 @@ - - boolean usesBlockLight(); - -+ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#getParticleIcon(net.minecraftforge.client.model.data.ModelData)}*/ -+ @Deprecated - TextureAtlasSprite getParticleIcon(); - -- ItemTransforms getTransforms(); -+ /**@deprecated Forge: Use {@link net.minecraftforge.client.extensions.IForgeBakedModel#applyTransform(ItemTransforms.TransformType, com.mojang.blaze3d.vertex.PoseStack, boolean)} instead */ -+ @Deprecated -+ default ItemTransforms getTransforms() { return ItemTransforms.NO_TRANSFORMS; } - } diff --git a/patches/minecraft/net/minecraft/client/resources/model/BlockStateModelLoader.java.patch b/patches/minecraft/net/minecraft/client/resources/model/BlockStateDefinitions.java.patch similarity index 61% rename from patches/minecraft/net/minecraft/client/resources/model/BlockStateModelLoader.java.patch rename to patches/minecraft/net/minecraft/client/resources/model/BlockStateDefinitions.java.patch index 1921378808..a4b5566887 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/BlockStateModelLoader.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/BlockStateDefinitions.java.patch @@ -1,8 +1,8 @@ ---- a/net/minecraft/client/resources/model/BlockStateModelLoader.java -+++ b/net/minecraft/client/resources/model/BlockStateModelLoader.java -@@ -52,6 +_,8 @@ +--- a/net/minecraft/client/resources/model/BlockStateDefinitions.java ++++ b/net/minecraft/client/resources/model/BlockStateDefinitions.java +@@ -33,6 +_,8 @@ - private static Function> definitionLocationToBlockMapper() { + static Function> definitionLocationToBlockStateMapper() { Map> map = new HashMap<>(STATIC_DEFINITIONS); + var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onRegisterModeStateDefinitions(); + map.putAll(event.getStates()); diff --git a/patches/minecraft/net/minecraft/client/resources/model/DelegateBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/DelegateBakedModel.java.patch deleted file mode 100644 index f710941d44..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/model/DelegateBakedModel.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/client/resources/model/DelegateBakedModel.java -+++ b/net/minecraft/client/resources/model/DelegateBakedModel.java -@@ -25,8 +_,18 @@ - } - - @Override -+ public List getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, net.minecraftforge.client.model.data.ModelData extraData, @Nullable net.minecraft.client.renderer.RenderType renderType) { -+ return this.parent.getQuads(state, side, rand, extraData, renderType); -+ } -+ -+ @Override - public boolean useAmbientOcclusion() { - return this.parent.useAmbientOcclusion(); -+ } -+ -+ @Override -+ public boolean useAmbientOcclusion(BlockState state, net.minecraft.client.renderer.RenderType renderType) { -+ return this.parent.useAmbientOcclusion(state, renderType); - } - - @Override diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch index d7b8d48e66..e8a7a61485 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelBaker.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/resources/model/ModelBaker.java +++ b/net/minecraft/client/resources/model/ModelBaker.java -@@ -13,4 +_,16 @@ - - @VisibleForDebug - ModelDebugName rootName(); +@@ -17,4 +_,16 @@ + public interface SharedOperationKey { + T compute(ModelBaker p_393089_); + } + + /** Forge: Return the render type to use when baking this model, its a dirty hack to pass down this value to parents */ + @org.jetbrains.annotations.Nullable diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelDiscovery.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelDiscovery.java.patch new file mode 100644 index 0000000000..24ceed714f --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelDiscovery.java.patch @@ -0,0 +1,35 @@ +--- a/net/minecraft/client/resources/model/ModelDiscovery.java ++++ b/net/minecraft/client/resources/model/ModelDiscovery.java +@@ -174,6 +_,14 @@ + return this.parent; + } + ++ @Nullable private net.minecraftforge.client.model.geometry.ModelContext context = null; ++ @Override ++ public net.minecraftforge.client.model.geometry.IGeometryBakingContext getContext() { ++ if (context == null || context.parent() != parent) ++ context = new net.minecraftforge.client.model.geometry.ModelContext(this); ++ return context; ++ } ++ + @Override + public String debugName() { + return this.id.toString(); +@@ -227,7 +_,7 @@ + + private QuadCollection bakeDefaultState(TextureSlots p_392267_, ModelBaker p_393576_, ModelState p_391972_) { + QuadCollection quadcollection = this.getSlot(KEY_DEFAULT_GEOMETRY); +- return quadcollection != null ? quadcollection : this.updateSlot(KEY_DEFAULT_GEOMETRY, this.getTopGeometry().bake(p_392267_, p_393576_, p_391972_, this)); ++ return quadcollection != null ? quadcollection : this.updateSlot(KEY_DEFAULT_GEOMETRY, this.getTopGeometry().bake(p_392267_, p_393576_, p_391972_, this, getContext())); + } + + @Override +@@ -236,7 +_,7 @@ + ? this.bakeDefaultState(p_396404_, p_391625_, p_396681_) + : this.modelBakeCache.computeIfAbsent(p_396681_, p_394933_ -> { + UnbakedGeometry unbakedgeometry = this.getTopGeometry(); +- return unbakedgeometry.bake(p_396404_, p_391625_, p_394933_, this); ++ return unbakedgeometry.bake(p_396404_, p_391625_, p_394933_, this, getContext()); + }); + } + } diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch index e812e33cb2..aa15a750e7 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch @@ -1,36 +1,23 @@ --- a/net/minecraft/client/resources/model/ModelManager.java +++ b/net/minecraft/client/resources/model/ModelManager.java -@@ -72,7 +_,9 @@ - ResourceLocation.withDefaultNamespace("blocks") +@@ -77,6 +_,7 @@ + AtlasIds.BLOCKS ); - private Map bakedBlockStateModels = Map.of(); -+ private Map bakedBlockStateModelsView = Map.of(); private Map bakedItemStackModels = Map.of(); + private Map bakedItemStackModelsView = Map.of(); private Map itemProperties = Map.of(); private final AtlasSet atlases; private final BlockModelShaper blockModelShaper; -@@ -83,6 +_,7 @@ - private BakedModel missingModel; - private ItemModel missingItemModel; +@@ -86,6 +_,7 @@ + private int maxMipmapLevels; + private ModelBakery.MissingModels missingModels; private Object2IntMap modelGroups = Object2IntMaps.emptyMap(); + private ModelBakery modelBakery; public ModelManager(TextureManager p_119406_, BlockColors p_119407_, int p_119408_) { this.blockColors = p_119407_; -@@ -95,6 +_,10 @@ - return this.bakedBlockStateModels.getOrDefault(p_119423_, this.missingModel); - } - -+ public Map getModels() { -+ return this.bakedBlockStateModelsView; -+ } -+ - public BakedModel getMissingModel() { - return this.missingModel; - } -@@ -103,6 +_,10 @@ - return this.bakedItemStackModels.getOrDefault(p_376816_, this.missingItemModel); +@@ -102,6 +_,10 @@ + return this.bakedItemStackModels.getOrDefault(p_376816_, this.missingModels.item()); } + public Map getItemModels() { @@ -40,48 +27,48 @@ public ClientItem.Properties getItemProperties(ResourceLocation p_378319_) { return this.itemProperties.getOrDefault(p_378319_, ClientItem.Properties.DEFAULT); } -@@ -115,6 +_,7 @@ +@@ -114,6 +_,7 @@ public final CompletableFuture reload( PreparableReloadListener.PreparationBarrier p_249079_, ResourceManager p_251134_, Executor p_250550_, Executor p_249221_ ) { + net.minecraftforge.client.model.geometry.GeometryLoaderManager.init(); - UnbakedModel unbakedmodel = MissingBlockModel.missingModel(); CompletableFuture completablefuture = CompletableFuture.supplyAsync(EntityModelSet::vanilla, p_250550_); CompletableFuture completablefuture1 = completablefuture.thenApplyAsync(SpecialBlockModelRenderer::vanilla, p_250550_); -@@ -260,13 +_,15 @@ - p_374740_.stream().sorted().map(p_374742_ -> " " + p_374742_).collect(Collectors.joining("\n")) - ) + CompletableFuture> completablefuture2 = loadBlockModels(p_251134_, p_250550_); +@@ -251,6 +_,7 @@ + }, p_394729_) + .thenApply( + p_389636_ -> { ++ net.minecraftforge.client.ForgeHooksClient.onModifyBakingResult(p_248945_, p_389636_); + multimap.asMap() + .forEach( + (p_376688_, p_252017_) -> LOGGER.warn( +@@ -271,7 +_,7 @@ + ) + ); + Map map = createBlockStateToModelDispatch(p_389636_.blockStateModels(), p_389636_.missingModels().block()); +- return new ModelManager.ReloadState(p_389636_, p_361513_, map, p_250646_, p_378097_, p_377275_, completablefuture); ++ return new ModelManager.ReloadState(p_389636_, p_361513_, map, p_250646_, p_378097_, p_377275_, completablefuture, p_248945_); + } ); -+ p_252136_.popPush("forge_modify_baking_result"); -+ net.minecraftforge.client.ForgeHooksClient.onModifyBakingResult(p_248945_, modelbakery$bakingresult); - p_252136_.popPush("dispatch"); - Map map = createBlockStateToModelDispatch(modelbakery$bakingresult.blockStateModels(), modelbakery$bakingresult.missingModel()); - CompletableFuture completablefuture = CompletableFuture.allOf( - p_250646_.values().stream().map(AtlasSet.StitchResult::readyForUpload).toArray(CompletableFuture[]::new) - ); - p_252136_.pop(); -- return new ModelManager.ReloadState(modelbakery$bakingresult, p_361513_, map, p_250646_, p_378097_, p_377275_, completablefuture); -+ return new ModelManager.ReloadState(modelbakery$bakingresult, p_361513_, map, p_250646_, p_378097_, p_377275_, completablefuture, p_248945_); } - - private static Map createBlockStateToModelDispatch(Map p_377857_, BakedModel p_378390_) { -@@ -298,11 +_,15 @@ +@@ -308,10 +_,15 @@ + p_251960_.push("upload"); p_248996_.atlasPreparations.values().forEach(AtlasSet.StitchResult::upload); ModelBakery.BakingResult modelbakery$bakingresult = p_248996_.bakedModels; - this.bakedBlockStateModels = modelbakery$bakingresult.blockStateModels(); -+ this.bakedBlockStateModelsView = java.util.Collections.unmodifiableMap(this.bakedBlockStateModels); ++ // TODO [BlockState Models] fix ++ //this.bakedBlockStateModelsView = java.util.Collections.unmodifiableMap(this.bakedBlockStateModels); this.bakedItemStackModels = modelbakery$bakingresult.itemStackModels(); + this.bakedItemStackModelsView = java.util.Collections.unmodifiableMap(this.bakedItemStackModels); this.itemProperties = modelbakery$bakingresult.itemProperties(); this.modelGroups = p_248996_.modelGroups; - this.missingModel = modelbakery$bakingresult.missingModel(); - this.missingItemModel = modelbakery$bakingresult.missingItemModel(); + this.missingModels = modelbakery$bakingresult.missingModels(); + this.modelBakery = p_248996_.modelBakery(); + net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.modelBakery); p_251960_.popPush("cache"); this.blockModelShaper.replaceCache(p_248996_.modelCache); this.specialBlockModelRenderer = p_248996_.specialBlockModelRenderer; -@@ -329,6 +_,7 @@ +@@ -338,6 +_,7 @@ } public TextureAtlas getAtlas(ResourceLocation p_119429_) { @@ -89,7 +76,7 @@ return this.atlases.getAtlas(p_119429_); } -@@ -341,6 +_,10 @@ +@@ -350,6 +_,10 @@ this.maxMipmapLevels = p_119411_; } @@ -100,7 +87,7 @@ public Supplier specialBlockModelRenderer() { return () -> this.specialBlockModelRenderer; } -@@ -357,7 +_,8 @@ +@@ -366,7 +_,8 @@ Map atlasPreparations, EntityModelSet entityModelSet, SpecialBlockModelRenderer specialBlockModelRenderer, @@ -109,4 +96,4 @@ + ModelBakery modelBakery ) { } - } + diff --git a/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch deleted file mode 100644 index 2460df51f7..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch +++ /dev/null @@ -1,65 +0,0 @@ ---- a/net/minecraft/client/resources/model/MultiPartBakedModel.java -+++ b/net/minecraft/client/resources/model/MultiPartBakedModel.java -@@ -33,11 +_,7 @@ - this.selectors = p_119462_; - } - -- @Override -- public List getQuads(@Nullable BlockState p_235050_, @Nullable Direction p_235051_, RandomSource p_235052_) { -- if (p_235050_ == null) { -- return Collections.emptyList(); -- } else { -+ public BitSet getSelectors(@Nullable BlockState p_235050_) { - BitSet bitset = this.selectorCache.get(p_235050_); - if (bitset == null) { - bitset = new BitSet(); -@@ -50,19 +_,45 @@ - - this.selectorCache.put(p_235050_, bitset); - } -+ return bitset; -+ } - -- List list = new ArrayList<>(); -+ // FORGE: Implement our overloads (here and below) so child models can have custom logic -+ public List getQuads(@Nullable BlockState p_235050_, @Nullable Direction p_235051_, RandomSource p_235052_, net.minecraftforge.client.model.data.ModelData modelData, @Nullable net.minecraft.client.renderer.RenderType renderType) { -+ if (p_235050_ == null) { -+ return Collections.emptyList(); -+ } else { -+ BitSet bitset = getSelectors(p_235050_); -+ List list = new ArrayList<>();; - long j = p_235052_.nextLong(); - - 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(); -+ // FORGE: Only put quad data if the model is using the render type passed -+ if (renderType != null && !model.getRenderTypes(p_235050_, p_235052_, modelData).contains(renderType)) -+ continue; -+ var data = net.minecraftforge.client.model.data.MultipartModelData.resolve(modelData, model); -+ list.addAll(model.getQuads(p_235050_, p_235051_, p_235052_, data, renderType)); - } - } - -- return list; -- } -+ return net.minecraftforge.common.util.ConcatenatedListView.of(list); -+ } -+ } -+ -+ @Override // FORGE: Get render types based on the selectors matched by the given block state -+ public net.minecraftforge.client.ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, net.minecraftforge.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).model().getRenderTypes(state, rand, data)); -+ } -+ } -+ -+ return net.minecraftforge.client.ChunkRenderTypeSet.union(renderTypeSets); - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/resources/model/QuadCollection.java.patch b/patches/minecraft/net/minecraft/client/resources/model/QuadCollection.java.patch new file mode 100644 index 0000000000..ed32c8bf6e --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/QuadCollection.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/client/resources/model/QuadCollection.java ++++ b/net/minecraft/client/resources/model/QuadCollection.java +@@ -59,6 +_,12 @@ + return this.all; + } + ++ public QuadCollection transform(net.minecraftforge.client.model.IQuadTransformer transformer) { ++ return new QuadCollection(transformer.process(this.all), transformer.process(this.unculled), ++ transformer.process(this.north), transformer.process(this.south), transformer.process(this.east), ++ transformer.process(this.west), transformer.process(this.up), transformer.process(this.down)); ++ } ++ + @OnlyIn(Dist.CLIENT) + public static class Builder { + private final ImmutableList.Builder unculledFaces = ImmutableList.builder(); diff --git a/patches/minecraft/net/minecraft/client/resources/model/ResolvedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ResolvedModel.java.patch new file mode 100644 index 0000000000..e264c5367f --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/ResolvedModel.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/client/resources/model/ResolvedModel.java ++++ b/net/minecraft/client/resources/model/ResolvedModel.java +@@ -86,7 +_,7 @@ + } + + default QuadCollection bakeTopGeometry(TextureSlots p_396041_, ModelBaker p_395367_, ModelState p_396505_) { +- return this.getTopGeometry().bake(p_396041_, p_395367_, p_396505_, this); ++ return this.getTopGeometry().bake(p_396041_, p_395367_, p_396505_, this, getContext()); + } + + static TextureAtlasSprite resolveParticleSprite(TextureSlots p_391346_, ModelBaker p_396500_, ModelDebugName p_393309_) { +@@ -127,5 +_,9 @@ + + default ItemTransforms getTopTransforms() { + return findTopTransforms(this); ++ } ++ ++ default net.minecraftforge.client.model.geometry.IGeometryBakingContext getContext() { ++ return new net.minecraftforge.client.model.geometry.ModelContext(this); + } + } diff --git a/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch deleted file mode 100644 index 0aebcc93ab..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/model/SimpleBakedModel.java.patch +++ /dev/null @@ -1,159 +0,0 @@ ---- a/net/minecraft/client/resources/model/SimpleBakedModel.java -+++ b/net/minecraft/client/resources/model/SimpleBakedModel.java -@@ -29,7 +_,26 @@ - private final boolean usesBlockLight; - private final TextureAtlasSprite particleIcon; - private final ItemTransforms transforms; -- -+ /** Forge: Block render types to be used with {@linkplain net.minecraft.client.GraphicsStatus#FANCY fancy graphics} */ -+ protected final net.minecraftforge.client.ChunkRenderTypeSet blockRenderTypes; -+ /** Forge: Block render types to be used with {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics} */ -+ protected final net.minecraftforge.client.ChunkRenderTypeSet blockRenderTypesFast; -+ /** Forge: If this model's {@linkplain #blockRenderTypes block render types} are rendering cutout, to account for older leaves model JSONs */ -+ protected final boolean isRenderingCutout; -+ -+ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, net.minecraftforge.client.RenderTypeGroup, net.minecraftforge.client.RenderTypeGroup) variant with RenderTypeGroup} **/ -+ @Deprecated -+ public SimpleBakedModel(List p_119489_, Map> p_119490_, boolean p_119491_, boolean p_119492_, boolean p_119493_, TextureAtlasSprite p_119494_, ItemTransforms p_119495_) { -+ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, net.minecraftforge.client.RenderTypeGroup.EMPTY); -+ } -+ -+ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, net.minecraftforge.client.RenderTypeGroup, net.minecraftforge.client.RenderTypeGroup) variant with RenderTypeGroup for fast graphics} **/ -+ @Deprecated(forRemoval = true, since = "1.21.4") -+ public SimpleBakedModel(List p_119489_, Map> p_119490_, boolean p_119491_, boolean p_119492_, boolean p_119493_, TextureAtlasSprite p_119494_, ItemTransforms p_119495_, net.minecraftforge.client.RenderTypeGroup renderTypes) { -+ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, renderTypes, net.minecraftforge.client.RenderTypeGroup.EMPTY); -+ } -+ -+ /** Constructor with {@link net.minecraftforge.client.RenderTypeGroup RenderTypeGroup} for fancy and fast graphics. Preferred over {@link net.minecraft.client.renderer.ItemBlockRenderTypes#setRenderLayer(net.minecraft.world.level.block.Block, net.minecraft.client.renderer.RenderType) ItemBlockRenderTypes.setRenderLayer(Block, RenderType)}. */ - public SimpleBakedModel( - List p_119489_, - Map> p_119490_, -@@ -37,7 +_,9 @@ - boolean p_119492_, - boolean p_119493_, - TextureAtlasSprite p_119494_, -- ItemTransforms p_119495_ -+ ItemTransforms p_119495_, -+ net.minecraftforge.client.RenderTypeGroup renderTypes, -+ net.minecraftforge.client.RenderTypeGroup renderTypesFast - ) { - this.unculledFaces = p_119489_; - this.culledFaces = p_119490_; -@@ -46,6 +_,20 @@ - this.usesBlockLight = p_119492_; - this.particleIcon = p_119494_; - this.transforms = p_119495_; -+ -+ boolean hasRenderTypes = renderTypes != null && !renderTypes.isEmpty(); -+ boolean hasRenderTypesFast = renderTypesFast != null && !renderTypesFast.isEmpty(); -+ this.blockRenderTypes = hasRenderTypes ? net.minecraftforge.client.ChunkRenderTypeSet.of(renderTypes.block()) : null; -+ this.blockRenderTypesFast = hasRenderTypesFast ? net.minecraftforge.client.ChunkRenderTypeSet.of(renderTypesFast.block()) : null; -+ this.isRenderingCutout = hasRenderTypes && (renderTypes.block() == net.minecraft.client.renderer.RenderType.cutout() || renderTypes.block() == net.minecraft.client.renderer.RenderType.cutoutMipped()); -+ } -+ -+ public static BakedModel bakeElements(List p_377425_, TextureSlots p_378525_, SpriteGetter p_375793_, ModelState p_376680_, boolean p_375745_, boolean p_376866_, boolean p_376846_, ItemTransforms p_376883_) { -+ return bakeElements(p_377425_, p_378525_, p_375793_, p_376680_, p_375745_, p_376866_, p_376846_, p_376883_, null); -+ } -+ -+ public static BakedModel bakeElements(List p_377425_, TextureSlots p_378525_, SpriteGetter p_375793_, ModelState p_376680_, boolean p_375745_, boolean p_376866_, boolean p_376846_, ItemTransforms p_376883_, @Nullable net.minecraftforge.client.RenderTypeGroup renderType) { -+ return bakeElements(p_377425_, p_378525_, p_375793_, p_376680_, p_375745_, p_376866_, p_376846_, p_376883_, renderType, null); - } - - public static BakedModel bakeElements( -@@ -56,7 +_,9 @@ - boolean p_375745_, - boolean p_376866_, - boolean p_376846_, -- ItemTransforms p_376883_ -+ ItemTransforms p_376883_, -+ @Nullable net.minecraftforge.client.RenderTypeGroup renderType, -+ @Nullable net.minecraftforge.client.RenderTypeGroup renderTypeFast - ) { - TextureAtlasSprite textureatlassprite = findSprite(p_375793_, p_378525_, "particle"); - SimpleBakedModel.Builder simplebakedmodel$builder = new SimpleBakedModel.Builder(p_375745_, p_376866_, p_376846_, p_376883_) -@@ -77,6 +_,13 @@ - } - } - -+ if (renderType != null && !renderType.isEmpty()) { -+ if (renderTypeFast != null && !renderTypeFast.isEmpty()) -+ simplebakedmodel$builder.renderTypes(renderType, renderTypeFast); -+ else -+ simplebakedmodel$builder.renderTypes(renderType); -+ } -+ - return simplebakedmodel$builder.build(); - } - -@@ -123,6 +_,19 @@ - return this.transforms; - } - -+ private static final net.minecraftforge.client.ChunkRenderTypeSet SOLID_BLOCK = net.minecraftforge.client.ChunkRenderTypeSet.of(net.minecraft.client.renderer.RenderType.solid()); -+ -+ @Override -+ public net.minecraftforge.client.ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, net.minecraftforge.client.model.data.ModelData data) { -+ if (!net.minecraft.client.renderer.ItemBlockRenderTypes.isFancy()) { -+ if (blockRenderTypesFast != null) -+ return blockRenderTypesFast; -+ if (isRenderingCutout && state.getBlock() instanceof net.minecraft.world.level.block.LeavesBlock) -+ return SOLID_BLOCK; -+ } -+ return blockRenderTypes != null ? blockRenderTypes : BakedModel.super.getRenderTypes(state, rand, data); -+ } -+ - @OnlyIn(Dist.CLIENT) - public static class Builder { - private final ImmutableList.Builder unculledFaces = ImmutableList.builder(); -@@ -164,13 +_,50 @@ - return this; - } - -+ private net.minecraftforge.client.RenderTypeGroup renderTypes = net.minecraftforge.client.RenderTypeGroup.EMPTY; -+ private net.minecraftforge.client.RenderTypeGroup renderTypesFast = net.minecraftforge.client.RenderTypeGroup.EMPTY; -+ -+ /** -+ * Sets the render type to be used for this model, and will be used for any graphics setting. -+ *

-+ * If you need to set a specific render type for -+ * {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics}, consider using -+ * {@link #renderTypes(net.minecraftforge.client.RenderTypeGroup, net.minecraftforge.client.RenderTypeGroup) -+ * renderTypes(RenderTypeGroup, RenderTypeGroup)} instead which allows choosing render types for both fancy and -+ * fast graphics. -+ * -+ * @apiNote If this model is for {@linkplain net.minecraft.world.level.block.LeavesBlock leaves} and if the -+ * given render type is either {@linkplain net.minecraft.client.renderer.RenderType#cutout() cutout} or -+ * {@linkplain net.minecraft.client.renderer.RenderType#cutoutMipped() cutout mipped}, it will be overridden -+ * with {@linkplain net.minecraft.client.renderer.RenderType#solid() solid} when fast graphics is enabled. -+ * @see #renderTypes(net.minecraftforge.client.RenderTypeGroup, net.minecraftforge.client.RenderTypeGroup) -+ * renderTypes(RenderTypeGroup, RenderTypeGroup) -+ */ -+ public SimpleBakedModel.Builder renderTypes(net.minecraftforge.client.RenderTypeGroup renderTypes) { -+ return this.renderTypes(renderTypes, net.minecraftforge.client.RenderTypeGroup.EMPTY); -+ } -+ -+ /** -+ * Sets the render types to be used for this model: one for -+ * {@linkplain net.minecraft.client.GraphicsStatus#FANCY fancy graphics} and one for -+ * {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics}. -+ * -+ * @see #renderTypes(net.minecraftforge.client.RenderTypeGroup) -+ */ -+ public SimpleBakedModel.Builder renderTypes(net.minecraftforge.client.RenderTypeGroup renderTypes, net.minecraftforge.client.RenderTypeGroup renderTypesFast) { -+ this.renderTypes = renderTypes; -+ this.renderTypesFast = renderTypesFast; -+ return this; -+ } -+ - public BakedModel build() { - if (this.particleIcon == null) { - throw new RuntimeException("Missing particle!"); - } else { - Map> map = Maps.transformValues(this.culledFaces, ImmutableList.Builder::build); - return new SimpleBakedModel( -- this.unculledFaces.build(), new EnumMap<>(map), this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms -+ // Forge: Account for render types in model JSONs -+ this.unculledFaces.build(), new EnumMap<>(map), this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms, this.renderTypes, this.renderTypesFast - ); - } - } diff --git a/patches/minecraft/net/minecraft/client/resources/model/SpriteGetter.java.patch b/patches/minecraft/net/minecraft/client/resources/model/SpriteGetter.java.patch deleted file mode 100644 index 9eed2ad9d4..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/model/SpriteGetter.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/client/resources/model/SpriteGetter.java -+++ b/net/minecraft/client/resources/model/SpriteGetter.java -@@ -9,4 +_,9 @@ - TextureAtlasSprite get(Material p_376066_); - - TextureAtlasSprite reportMissingReference(String p_377389_); -+ -+ default TextureAtlasSprite maybeMissing(net.minecraft.client.renderer.block.model.TextureSlots textures, String name) { -+ var material = textures.getMaterial(name); -+ return material != null ? get(material) : reportMissingReference(name); -+ } - } diff --git a/patches/minecraft/net/minecraft/client/resources/model/UnbakedGeometry.java.patch b/patches/minecraft/net/minecraft/client/resources/model/UnbakedGeometry.java.patch new file mode 100644 index 0000000000..cff29db2b4 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/UnbakedGeometry.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/resources/model/UnbakedGeometry.java ++++ b/net/minecraft/client/resources/model/UnbakedGeometry.java +@@ -10,4 +_,8 @@ + UnbakedGeometry EMPTY = (p_396370_, p_395488_, p_393569_, p_397842_) -> QuadCollection.EMPTY; + + QuadCollection bake(TextureSlots p_391189_, ModelBaker p_391275_, ModelState p_397070_, ModelDebugName p_391995_); ++ ++ default QuadCollection bake(TextureSlots slots, ModelBaker baker, ModelState state, ModelDebugName name, net.minecraftforge.client.model.geometry.IGeometryBakingContext context) { ++ return bake(slots, baker, state, name); ++ } + } diff --git a/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch index 00f3905f4d..3cec0c6d7e 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch @@ -1,24 +1,12 @@ --- a/net/minecraft/client/resources/model/UnbakedModel.java +++ b/net/minecraft/client/resources/model/UnbakedModel.java -@@ -13,6 +_,10 @@ - boolean DEFAULT_AMBIENT_OCCLUSION = true; - UnbakedModel.GuiLight DEFAULT_GUI_LIGHT = UnbakedModel.GuiLight.SIDE; - -+ default BakedModel bake(TextureSlots textures, ModelBaker baker, ModelState state) { -+ return bake(textures, baker, state, this.getAmbientOcclusion(), this.getGuiLight().lightLikeBlock(), this.getTransforms()); -+ } -+ - BakedModel bake(TextureSlots p_376037_, ModelBaker p_250133_, ModelState p_119536_, boolean p_378145_, boolean p_377763_, ItemTransforms p_375499_); - - @Nullable -@@ -135,6 +_,10 @@ - +@@ -64,5 +_,9 @@ public boolean lightLikeBlock() { return this == SIDE; -+ } + } + + public String getSerializedName() { + return name; - } ++ } } } diff --git a/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch deleted file mode 100644 index d1adf4f964..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/client/resources/model/WeightedBakedModel.java -+++ b/net/minecraft/client/resources/model/WeightedBakedModel.java -@@ -24,4 +_,9 @@ - public List getQuads(@Nullable BlockState p_235058_, @Nullable Direction p_235059_, RandomSource p_235060_) { - return this.list.getRandomValue(p_235060_).map(p_358058_ -> p_358058_.getQuads(p_235058_, p_235059_, p_235060_)).orElse(Collections.emptyList()); - } -+ -+ @Override -+ public List getQuads(@Nullable BlockState p_235058_, @Nullable Direction p_235059_, RandomSource p_235060_, net.minecraftforge.client.model.data.ModelData extraData, @Nullable net.minecraft.client.renderer.RenderType renderType) { -+ return this.list.getRandomValue(p_235060_).map(p_358058_ -> p_358058_.getQuads(p_235058_, p_235059_, p_235060_, extraData, renderType)).orElse(Collections.emptyList()); -+ } - } diff --git a/patches/minecraft/net/minecraft/client/resources/model/WeightedVariants.java.patch b/patches/minecraft/net/minecraft/client/resources/model/WeightedVariants.java.patch new file mode 100644 index 0000000000..0b61bdb924 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/WeightedVariants.java.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/client/resources/model/WeightedVariants.java ++++ b/net/minecraft/client/resources/model/WeightedVariants.java +@@ -13,12 +_,13 @@ + @OnlyIn(Dist.CLIENT) + public class WeightedVariants implements BlockStateModel { + private final WeightedList list; ++ private final BlockStateModel firstModel; + private final TextureAtlasSprite particleIcon; + + public WeightedVariants(WeightedList p_394939_) { + this.list = p_394939_; +- BlockStateModel blockstatemodel = p_394939_.unwrap().getFirst().value(); +- this.particleIcon = blockstatemodel.particleIcon(); ++ this.firstModel = p_394939_.unwrap().getFirst().value(); ++ this.particleIcon = firstModel.particleIcon(); + } + + @Override +@@ -27,8 +_,18 @@ + } + + @Override ++ public TextureAtlasSprite particleIcon(net.minecraftforge.client.model.data.ModelData data) { ++ return this.firstModel.particleIcon(data); ++ } ++ ++ @Override + public void collectParts(RandomSource p_397916_, List p_394308_) { + this.list.getRandomOrThrow(p_397916_).collectParts(p_397916_, p_394308_); ++ } ++ ++ @Override ++ public void collectParts(RandomSource random, List dest, net.minecraftforge.client.model.data.ModelData data, net.minecraft.client.renderer.RenderType renderType) { ++ this.list.getRandomOrThrow(random).collectParts(random, dest, data, renderType); + } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch index 72ef7fe597..21c6323e61 100644 --- a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch @@ -35,19 +35,19 @@ this.soundBuffers .getCompleteBuffer(sound.getPath()) .thenAccept(p_377326_ -> channelaccess$channelhandle.execute(p_194495_ -> { - p_194495_.attachStaticBuffer(p_377326_); - p_194495_.play(); + p_194495_.attachStaticBuffer(p_377326_); + p_194495_.play(); + net.minecraftforge.client.event.ForgeEventFactoryClient.onPlaySoundSource(this, soundinstance, p_194495_); - })); + })); } else { - this.soundBuffers - .getStream(sound.getPath(), flag1) + soundinstance + .getStream(this.soundBuffers, sound, flag1) .thenAccept(p_376862_ -> channelaccess$channelhandle.execute(p_194498_ -> { - p_194498_.attachBufferStream(p_376862_); - p_194498_.play(); + p_194498_.attachBufferStream(p_376862_); + p_194498_.play(); + net.minecraftforge.client.event.ForgeEventFactoryClient.onPlayStreamingSource(this, soundinstance, p_194498_); - })); + })); } diff --git a/patches/minecraft/net/minecraft/commands/Commands.java.patch b/patches/minecraft/net/minecraft/commands/Commands.java.patch index 551520c845..38ec27a11e 100644 --- a/patches/minecraft/net/minecraft/commands/Commands.java.patch +++ b/patches/minecraft/net/minecraft/commands/Commands.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -219,7 +_,7 @@ +@@ -220,7 +_,7 @@ JfrCommand.register(this.dispatcher); } - if (SharedConstants.IS_RUNNING_IN_IDE) { + if (net.minecraftforge.gametest.ForgeGameTestHooks.isGametestEnabled()) { - TestCommand.register(this.dispatcher); RaidCommand.register(this.dispatcher, p_230944_); DebugPathCommand.register(this.dispatcher); + DebugMobSpawningCommand.register(this.dispatcher); @@ -253,6 +_,7 @@ if (p_230943_.includeIntegrated) { PublishCommand.register(this.dispatcher); diff --git a/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch b/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch index 5c1a098f55..48a8e2c782 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/MessageArgument.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/commands/arguments/MessageArgument.java @@ -89,7 +_,7 @@ - public static record Message(String text, MessageArgument.Part[] parts) { + public record Message(String text, MessageArgument.Part[] parts) { Component resolveComponent(CommandSourceStack p_232197_) throws CommandSyntaxException { - return this.toComponent(p_232197_, EntitySelectorParser.allowSelectors(p_232197_)); + return this.toComponent(p_232197_, net.minecraftforge.common.ForgeHooks.canUseEntitySelectors(p_232197_)); diff --git a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch index d1ee61dbf9..e0637c19f6 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelector.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -105,7 +_,7 @@ +@@ -104,7 +_,7 @@ } private void checkPermissions(CommandSourceStack p_121169_) throws CommandSyntaxException { diff --git a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch index ceae1b6b8f..70e77fad8a 100644 --- a/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch +++ b/patches/minecraft/net/minecraft/commands/arguments/selector/EntitySelectorParser.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/arguments/selector/EntitySelectorParser.java +++ b/net/minecraft/commands/arguments/selector/EntitySelectorParser.java -@@ -477,6 +_,11 @@ +@@ -473,6 +_,11 @@ } this.reader.skip(); @@ -12,7 +12,7 @@ this.parseSelector(); } else { this.parseNameOrUUID(); -@@ -493,6 +_,7 @@ +@@ -489,6 +_,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")); diff --git a/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypeInfos.java.patch b/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypeInfos.java.patch index a6129070e1..e7dd7cfb10 100644 --- a/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypeInfos.java.patch +++ b/patches/minecraft/net/minecraft/commands/synchronization/ArgumentTypeInfos.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/synchronization/ArgumentTypeInfos.java +++ b/net/minecraft/commands/synchronization/ArgumentTypeInfos.java -@@ -68,6 +_,20 @@ +@@ -66,6 +_,20 @@ public class ArgumentTypeInfos { private static final Map, ArgumentTypeInfo> BY_CLASS = Maps.newHashMap(); @@ -21,20 +21,3 @@ private static , T extends ArgumentTypeInfo.Template> ArgumentTypeInfo register( Registry> p_235387_, String p_235388_, Class p_235389_, ArgumentTypeInfo p_235390_ ) { -@@ -131,12 +_,14 @@ - p_235385_, "loot_predicate", ResourceOrIdArgument.LootPredicateArgument.class, SingletonArgumentInfo.contextAware(ResourceOrIdArgument::lootPredicate) - ); - register(p_235385_, "loot_modifier", ResourceOrIdArgument.LootModifierArgument.class, SingletonArgumentInfo.contextAware(ResourceOrIdArgument::lootModifier)); -- if (SharedConstants.IS_RUNNING_IN_IDE) { -+ // Forge: Register before gametest arguments to provide forge server <-> vanilla client interop and matching int ids -+ var uuidInfo = register(p_235385_, "uuid", UuidArgument.class, SingletonArgumentInfo.contextFree(UuidArgument::uuid)); -+ if (true) { // Forge: Always register gametest arguments to prevent issues when connecting from gametest-enabled client/server to non-gametest-enabled client/server - register(p_235385_, "test_argument", TestFunctionArgument.class, SingletonArgumentInfo.contextFree(TestFunctionArgument::testFunctionArgument)); - register(p_235385_, "test_class", TestClassNameArgument.class, SingletonArgumentInfo.contextFree(TestClassNameArgument::testClassName)); - } - -- return register(p_235385_, "uuid", UuidArgument.class, SingletonArgumentInfo.contextFree(UuidArgument::uuid)); -+ return uuidInfo; - } - - private static > Class fixClassType(Class p_235396_) { diff --git a/patches/minecraft/net/minecraft/core/Direction.java.patch b/patches/minecraft/net/minecraft/core/Direction.java.patch index 1213925f35..ffc687973e 100644 --- a/patches/minecraft/net/minecraft/core/Direction.java.patch +++ b/patches/minecraft/net/minecraft/core/Direction.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/Direction.java +++ b/net/minecraft/core/Direction.java -@@ -49,6 +_,15 @@ - private final Vec3i normal; +@@ -54,6 +_,15 @@ private final Vec3 normalVec3; + private final Vector3fc normalVec3f; private static final Direction[] VALUES = values(); + private static final List VALUES_VIEW = java.util.Collections.unmodifiableList(Arrays.asList(VALUES)); + public static final List valuesView() { diff --git a/patches/minecraft/net/minecraft/core/HolderSet.java.patch b/patches/minecraft/net/minecraft/core/HolderSet.java.patch index 9d3b2176df..a92cf1b2e5 100644 --- a/patches/minecraft/net/minecraft/core/HolderSet.java.patch +++ b/patches/minecraft/net/minecraft/core/HolderSet.java.patch @@ -9,7 +9,7 @@ Stream> stream(); int size(); -@@ -182,6 +_,7 @@ +@@ -174,6 +_,7 @@ public void bind(List> p_205836_) { this.contents = List.copyOf(p_205836_); @@ -17,7 +17,7 @@ } public TagKey key() { -@@ -225,6 +_,12 @@ +@@ -217,6 +_,12 @@ @Override public boolean canSerializeIn(HolderOwner p_256542_) { return this.owner.canSerializeIn(p_256542_); diff --git a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch index 5221f9e0c9..ece1a3572b 100644 --- a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch +++ b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -86,6 +_,7 @@ +@@ -85,6 +_,7 @@ @Override public Holder.Reference register(ResourceKey p_256252_, T p_256591_, RegistrationInfo p_329661_) { @@ -8,7 +8,7 @@ this.validateWrite(p_256252_); Objects.requireNonNull(p_256252_); Objects.requireNonNull(p_256591_); -@@ -104,6 +_,8 @@ +@@ -103,6 +_,8 @@ reference.bindKey(p_256252_); } else { reference = this.byKey.computeIfAbsent(p_256252_, p_358082_ -> Holder.Reference.createStandAlone(this, (ResourceKey)p_358082_)); @@ -17,7 +17,7 @@ } this.byKey.put(p_256252_, reference); -@@ -275,7 +_,6 @@ +@@ -274,7 +_,6 @@ return this; } else { this.frozen = true; @@ -25,7 +25,7 @@ List list = this.byKey .entrySet() .stream() -@@ -291,7 +_,8 @@ +@@ -290,7 +_,8 @@ throw new IllegalStateException("Some intrusive holders were not registered: " + this.unregisteredIntrusiveHolders.values()); } @@ -35,7 +35,7 @@ } if (this.allTags.isBound()) { -@@ -390,6 +_,31 @@ +@@ -389,6 +_,31 @@ }; } @@ -67,7 +67,7 @@ @Override public Registry.PendingTags prepareTagReload(TagLoader.LoadResult p_368827_) { if (!this.frozen) { -@@ -437,6 +_,11 @@ +@@ -436,6 +_,11 @@ @Override public HolderLookup.RegistryLookup lookup() { return registrylookup; diff --git a/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch index 0c8b8a1c0b..d3e29aec3e 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java @@ -29,18 +_,22 @@ - double d2 = vec3.y() + (double)((float)direction.getStepY() * 1.125F); - double d3 = vec3.z() + (double)direction.getStepZ() * d0; + double d2 = vec3.y() + direction.getStepY() * 1.125F; + double d3 = vec3.z() + direction.getStepZ() * d0; BlockPos blockpos = p_123375_.pos().relative(direction); + AbstractBoat abstractboat = this.type.create(serverlevel, EntitySpawnReason.DISPENSER); + if (abstractboat == null) { diff --git a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index fbcbfdd3ef..c2dd740353 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,26 +1,23 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -193,7 +_,7 @@ - DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_335219_.getItem(); - BlockPos blockpos = p_335842_.pos().relative(p_335842_.state().getValue(DispenserBlock.FACING)); - Level level = p_335842_.level(); +@@ -172,7 +_,7 @@ + DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_334276_.getItem(); + BlockPos blockpos = p_334868_.pos().relative(p_334868_.state().getValue(DispenserBlock.FACING)); + Level level = p_334868_.level(); - if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null)) { -+ if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null, p_335219_)) { - dispensiblecontaineritem.checkExtraContent(null, level, p_335219_, blockpos); - return this.consumeWithRemainder(p_335842_, p_335219_, new ItemStack(Items.BUCKET)); ++ if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null, p_334276_)) { + dispensiblecontaineritem.checkExtraContent(null, level, p_334276_, blockpos); + return this.consumeWithRemainder(p_334868_, p_334276_, new ItemStack(Items.BUCKET)); } else { -@@ -244,9 +_,11 @@ +@@ -223,8 +_,9 @@ } else if (CampfireBlock.canLight(blockstate) || CandleBlock.canLight(blockstate) || CandleCakeBlock.canLight(blockstate)) { - serverlevel.setBlockAndUpdate(blockpos, blockstate.setValue(BlockStateProperties.LIT, Boolean.valueOf(true))); + serverlevel.setBlockAndUpdate(blockpos, blockstate.setValue(BlockStateProperties.LIT, true)); 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_332842_.state().getValue(DispenserBlock.FACING).getOpposite())) { -+ blockstate.onCaughtFire(serverlevel, blockpos, p_332842_.state().getValue(DispenserBlock.FACING).getOpposite(), null); -+ if (blockstate.getBlock() instanceof TntBlock) { -+ serverlevel.removeBlock(blockpos, false); -+ } - } else { - this.setSuccess(false); - } +- if (TntBlock.prime(serverlevel, blockpos)) { ++ } else if (blockstate.isFlammable(serverlevel, blockpos, p_333645_.state().getValue(DispenserBlock.FACING).getOpposite())) { ++ if (blockstate.onCaughtFire(serverlevel, blockpos, p_333645_.state().getValue(DispenserBlock.FACING).getOpposite(), null)) { ++ if (blockstate.getBlock() instanceof TntBlock) + serverlevel.removeBlock(blockpos, false); + } else { + this.setSuccess(false); diff --git a/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch b/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch index b0db883bc3..333e1b2f4c 100644 --- a/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/patches/minecraft/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -246,7 +_,9 @@ +@@ -257,7 +_,9 @@ ) { Bootstrap.checkBootstrapCalled(() -> "registry " + p_259230_.location()); ResourceLocation resourcelocation = p_259230_.location(); @@ -11,7 +11,7 @@ WRITABLE_REGISTRY.register((ResourceKey)p_259230_, p_260327_, RegistrationInfo.BUILT_IN); return p_260327_; } -@@ -282,7 +_,7 @@ +@@ -293,7 +_,7 @@ if (p_358159_ instanceof DefaultedRegistry) { ResourceLocation resourcelocation = ((DefaultedRegistry)p_358159_).getDefaultKey(); diff --git a/patches/minecraft/net/minecraft/core/registries/Registries.java.patch b/patches/minecraft/net/minecraft/core/registries/Registries.java.patch index 82007db607..93de7ef64d 100644 --- a/patches/minecraft/net/minecraft/core/registries/Registries.java.patch +++ b/patches/minecraft/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 -@@ -245,10 +_,14 @@ +@@ -266,10 +_,14 @@ } public static String elementsDirPath(ResourceKey> p_343743_) { diff --git a/patches/minecraft/net/minecraft/data/Main.java.patch b/patches/minecraft/net/minecraft/data/Main.java.patch index eb7a9bc282..e41cf571a1 100644 --- a/patches/minecraft/net/minecraft/data/Main.java.patch +++ b/patches/minecraft/net/minecraft/data/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/Main.java +++ b/net/minecraft/data/Main.java -@@ -77,14 +_,17 @@ +@@ -75,14 +_,17 @@ OptionSpec optionspec4 = optionparser.accepts("all", "Include all generators"); OptionSpec optionspec5 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated"); OptionSpec optionspec6 = optionparser.accepts("input", "Input folder").withRequiredArg(); diff --git a/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch index a097b1ef43..244bffed05 100644 --- a/patches/minecraft/net/minecraft/data/loot/BlockLootSubProvider.java.patch +++ b/patches/minecraft/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 -@@ -690,12 +_,16 @@ +@@ -700,12 +_,16 @@ protected abstract void generate(); diff --git a/patches/minecraft/net/minecraft/data/loot/EntityLootSubProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/EntityLootSubProvider.java.patch index 4bacd5425a..c891e46b5a 100644 --- a/patches/minecraft/net/minecraft/data/loot/EntityLootSubProvider.java.patch +++ b/patches/minecraft/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 -@@ -104,12 +_,16 @@ +@@ -121,12 +_,16 @@ public abstract void generate(); diff --git a/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch index b1a4044b4d..7fc2b24cd4 100644 --- a/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/LootTableProvider.java.patch @@ -6,9 +6,9 @@ Map map = new Object2ObjectOpenHashMap<>(); - this.subProviders.forEach(p_341016_ -> p_341016_.provider().apply(p_331092_).generate((p_358218_, p_358219_) -> { + this.getTables().forEach(p_341016_ -> p_341016_.provider().apply(p_331092_).generate((p_358218_, p_358219_) -> { - ResourceLocation resourcelocation = sequenceIdForLootTable(p_358218_); - ResourceLocation resourcelocation1 = map.put(RandomSequence.seedForKey(resourcelocation), resourcelocation); - if (resourcelocation1 != null) { + ResourceLocation resourcelocation = sequenceIdForLootTable(p_358218_); + ResourceLocation resourcelocation1 = map.put(RandomSequence.seedForKey(resourcelocation), resourcelocation); + if (resourcelocation1 != null) { @@ -78,18 +_,8 @@ HolderGetter.Provider holdergetter$provider = new RegistryAccess.ImmutableRegistryAccess(List.of(writableregistry)).freeze(); ValidationContext validationcontext = new ValidationContext(problemreporter$collector, LootContextParamSets.ALL_PARAMS, holdergetter$provider); @@ -21,10 +21,10 @@ - writableregistry.listElements() - .forEach( - p_358221_ -> p_358221_.value() -- .validate( -- validationcontext.setContextKeySet(p_358221_.value().getParamSet()) -- .enterElement("{" + p_358221_.key().location() + "}", p_358221_.key()) -- ) +- .validate( +- validationcontext.setContextKeySet(p_358221_.value().getParamSet()) +- .enterElement("{" + p_358221_.key().location() + "}", p_358221_.key()) +- ) - ); Multimap multimap = problemreporter$collector.get(); if (!multimap.isEmpty()) { @@ -50,4 +50,4 @@ + )); } - public static record SubProviderEntry(Function provider, ContextKeySet paramSet) { + public record SubProviderEntry(Function provider, ContextKeySet paramSet) { diff --git a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch index d8e7f0c25c..a140cd2800 100644 --- a/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/recipes/RecipeProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/recipes/RecipeProvider.java +++ b/net/minecraft/data/recipes/RecipeProvider.java -@@ -732,7 +_,7 @@ +@@ -735,7 +_,7 @@ RecipeBuilder create(RecipeProvider p_363045_, ItemLike p_362746_, ItemLike p_364674_); } @@ -9,7 +9,7 @@ private final PackOutput packOutput; private final CompletableFuture registries; -@@ -752,13 +_,13 @@ +@@ -755,13 +_,13 @@ final List> list = new ArrayList<>(); RecipeOutput recipeoutput = new RecipeOutput() { @Override @@ -26,7 +26,7 @@ } } } -@@ -773,7 +_,9 @@ +@@ -776,7 +_,9 @@ AdvancementHolder advancementholder = Advancement.Builder.recipeAdvancement() .addCriterion("impossible", CriteriaTriggers.IMPOSSIBLE.createCriterion(new ImpossibleTrigger.TriggerInstance())) .build(RecipeBuilder.ROOT_RECIPE_ADVANCEMENT); @@ -37,7 +37,7 @@ } private void saveRecipe(ResourceKey> p_368864_, Recipe p_368184_) { -@@ -784,16 +_,19 @@ +@@ -787,16 +_,19 @@ ); } diff --git a/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch b/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch index 61b728f2b1..3272c9aff3 100644 --- a/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch +++ b/patches/minecraft/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch @@ -39,4 +39,4 @@ + .filter(holder -> this.namespacePredicate.test(holder.key().location().getNamespace())) .map( p_256105_ -> dumpValue( - packoutput$pathprovider.json(p_256105_.key().location()), + packoutput$pathprovider.json(p_256105_.key().location()), diff --git a/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch b/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch index 2831c7f25b..7a441193a0 100644 --- a/patches/minecraft/net/minecraft/data/registries/VanillaRegistries.java.patch +++ b/patches/minecraft/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 -@@ -72,6 +_,7 @@ - .add(Registries.ENCHANTMENT_PROVIDER, VanillaEnchantmentProviders::bootstrap) - .add(Registries.JUKEBOX_SONG, JukeboxSongs::bootstrap) - .add(Registries.INSTRUMENT, Instruments::bootstrap); +@@ -88,6 +_,7 @@ + .add(Registries.TEST_INSTANCE, GameTestInstances::bootstrap) + .add(Registries.FROG_VARIANT, FrogVariants::bootstrap) + .add(Registries.CAT_VARIANT, CatVariants::bootstrap); + public static final List>> DATAPACK_REGISTRY_KEYS = BUILDER.getEntryKeys(); private static void validateThatAllBiomeFeaturesHaveBiomeFilter(HolderLookup.Provider p_256242_) { diff --git a/patches/minecraft/net/minecraft/data/tags/CatVariantTagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/CatVariantTagsProvider.java.patch deleted file mode 100644 index 395185634e..0000000000 --- a/patches/minecraft/net/minecraft/data/tags/CatVariantTagsProvider.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/data/tags/CatVariantTagsProvider.java -+++ b/net/minecraft/data/tags/CatVariantTagsProvider.java -@@ -12,6 +_,10 @@ - super(p_256547_, Registries.CAT_VARIANT, p_256090_); - } - -+ public CatVariantTagsProvider(PackOutput p_256547_, CompletableFuture p_256090_, String modId, @org.jetbrains.annotations.Nullable net.minecraftforge.common.data.ExistingFileHelper existingFileHelper) { -+ super(p_256547_, Registries.CAT_VARIANT, p_256090_, modId, existingFileHelper); -+ } -+ - @Override - protected void addTags(HolderLookup.Provider p_256078_) { - this.tag(CatVariantTags.DEFAULT_SPAWNS) diff --git a/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch b/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch index d38da9b74e..f153569cba 100644 --- a/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch +++ b/patches/minecraft/net/minecraft/data/tags/TagsProvider.java.patch @@ -75,7 +75,7 @@ + }); Predicate predicate = p_255496_ -> registrylookup.get(ResourceKey.create(this.registryKey, p_255496_)).isPresent(); Predicate predicate1 = p_274776_ -> this.builders.containsKey(p_274776_) - || p_325926_.parent.contains(TagKey.create(this.registryKey, p_274776_)); + || p_325926_.parent.contains(TagKey.create(this.registryKey, p_274776_)); @@ -82,7 +_,7 @@ ResourceLocation resourcelocation = p_325931_.getKey(); TagBuilder tagbuilder = p_325931_.getValue(); diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch index 06988861f5..b02a66f9ac 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTestHelper.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestHelper.java +++ b/net/minecraft/gametest/framework/GameTestHelper.java -@@ -65,7 +_,7 @@ +@@ -66,7 +_,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; @@ -9,9 +9,22 @@ private final GameTestInfo testInfo; private boolean finalCheckAdded; -@@ -996,5 +_,25 @@ +@@ -963,6 +_,12 @@ + return this.testInfo.getTick(); + } + ++ /** Forge: same as {@link #getTick()} without implicit cast to long */ ++ @Override ++ public int getTickAsInt() { ++ return this.testInfo.getTick(); ++ } ++ + public AABB getBounds() { + return this.testInfo.getStructureBounds(); + } +@@ -1005,5 +_,25 @@ if (either.right().isPresent()) { - this.fail("Failed to set biome for test"); + throw this.assertionException("test.error.set_biome"); } + } + diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestInfo.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestInfo.java.patch deleted file mode 100644 index 3ba28ba53f..0000000000 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestInfo.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/gametest/framework/GameTestInfo.java -+++ b/net/minecraft/gametest/framework/GameTestInfo.java -@@ -265,7 +_,7 @@ - BlockPos blockpos = this.getOrCalculateNorthwestCorner(); - this.structureBlockEntity = StructureUtils.prepareTestStructure(this, blockpos, this.getRotation(), this.level); - this.structureBlockPos = this.structureBlockEntity.getBlockPos(); -- StructureUtils.addCommandBlockAndButtonToStartTest(this.structureBlockPos, new BlockPos(1, 0, -1), this.getRotation(), this.level); -+ StructureUtils.addCommandBlockAndButtonToStartTest(this.structureBlockPos, new BlockPos(1, 0, -1), Rotation.NONE, this.level); // Forge: The control blocks are always in the North West Corner - StructureUtils.encaseStructure(this.getStructureBounds(), this.level, !this.testFunction.skyAccess()); - this.listeners.forEach(p_127630_ -> p_127630_.testStructureLoaded(this)); - return this; diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestRegistry.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestRegistry.java.patch deleted file mode 100644 index 201c694970..0000000000 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestRegistry.java.patch +++ /dev/null @@ -1,77 +0,0 @@ ---- a/net/minecraft/gametest/framework/GameTestRegistry.java -+++ b/net/minecraft/gametest/framework/GameTestRegistry.java -@@ -25,22 +_,33 @@ - private static final Map> AFTER_BATCH_FUNCTIONS = Maps.newHashMap(); - private static final Set LAST_FAILED_TESTS = Sets.newHashSet(); - -+ -+ /** @deprecated Forge: Use {@link net.minecraftforge.event.RegisterGameTestsEvent RegisterGameTestsEvent} to register game tests */ -+ @Deprecated - public static void register(Class p_177502_) { - Arrays.stream(p_177502_.getDeclaredMethods()).sorted(Comparator.comparing(Method::getName)).forEach(GameTestRegistry::register); - } - -+ /** @deprecated Forge: Use {@link net.minecraftforge.event.RegisterGameTestsEvent RegisterGameTestsEvent} to register game tests */ -+ @Deprecated - public static void register(Method p_177504_) { -+ register(p_177504_, java.util.Set.of()); -+ } -+ -+ /** @deprecated Forge: Use {@link net.minecraftforge.event.RegisterGameTestsEvent RegisterGameTestsEvent} to register game tests */ -+ @Deprecated -+ public static void register(Method p_177504_, java.util.Set allowed) { - String s = p_177504_.getDeclaringClass().getSimpleName(); - GameTest gametest = p_177504_.getAnnotation(GameTest.class); - if (gametest != null) { -- TEST_FUNCTIONS.add(turnMethodIntoTestFunction(p_177504_)); -- TEST_CLASS_NAMES.add(s); -+ net.minecraftforge.gametest.ForgeGameTestHooks.addTest(TEST_FUNCTIONS, TEST_CLASS_NAMES, allowed, turnMethodIntoTestFunction(p_177504_)); - } - - GameTestGenerator gametestgenerator = p_177504_.getAnnotation(GameTestGenerator.class); - if (gametestgenerator != null) { -- TEST_FUNCTIONS.addAll(useTestGeneratorMethod(p_177504_)); -- TEST_CLASS_NAMES.add(s); -+ for (var func : useTestGeneratorMethod(p_177504_)) { -+ net.minecraftforge.gametest.ForgeGameTestHooks.addTest(TEST_FUNCTIONS, TEST_CLASS_NAMES, allowed, func); -+ } - } - - registerBatchFunction(p_177504_, BeforeBatch.class, BeforeBatch::batch, BEFORE_BATCH_FUNCTIONS); -@@ -101,7 +_,10 @@ - - private static Collection useTestGeneratorMethod(Method p_177514_) { - try { -- Object object = p_177514_.getDeclaringClass().newInstance(); -+ Object object = null; -+ if (!java.lang.reflect.Modifier.isStatic(p_177514_.getModifiers())) { -+ object = p_177514_.getDeclaringClass().newInstance(); -+ } - return (Collection)p_177514_.invoke(object); - } catch (ReflectiveOperationException reflectiveoperationexception) { - throw new RuntimeException(reflectiveoperationexception); -@@ -112,9 +_,9 @@ - GameTest gametest = p_177516_.getAnnotation(GameTest.class); - String s = p_177516_.getDeclaringClass().getSimpleName(); - String s1 = s.toLowerCase(); -- String s2 = s1 + "." + p_177516_.getName().toLowerCase(); -- String s3 = gametest.template().isEmpty() ? s2 : s1 + "." + gametest.template(); -- String s4 = gametest.batch(); -+ String s2 = net.minecraftforge.gametest.ForgeGameTestHooks.getTestName(p_177516_, gametest); -+ String s3 = net.minecraftforge.gametest.ForgeGameTestHooks.getTestTemplate(p_177516_, gametest, s2); -+ String s4 = net.minecraftforge.gametest.ForgeGameTestHooks.getTestBatch(p_177516_, gametest); - Rotation rotation = StructureUtils.getRotationForRotationSteps(gametest.rotationSteps()); - return new TestFunction( - s4, -@@ -135,7 +_,10 @@ - private static Consumer turnMethodIntoConsumer(Method p_177520_) { - return p_177512_ -> { - try { -- Object object = p_177520_.getDeclaringClass().newInstance(); -+ Object object = null; -+ if (!java.lang.reflect.Modifier.isStatic(p_177520_.getModifiers())) { -+ object = p_177520_.getDeclaringClass().newInstance(); -+ } - p_177520_.invoke(object, p_177512_); - } catch (InvocationTargetException invocationtargetexception) { - if (invocationtargetexception.getCause() instanceof RuntimeException) { diff --git a/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch b/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch index fc1f8979a4..ccf79d7e88 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -83,7 +_,7 @@ - } else { - p_206609_.reload(); - WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration( -- new DataPackConfig(new ArrayList<>(p_206609_.getAvailableIds()), List.of()), ENABLED_FEATURES -+ new DataPackConfig(new ArrayList<>(p_206609_.getSelectedIds()), List.of()), ENABLED_FEATURES // Forge: Use the selected datapacks as this takes sorting into account. - ); - LevelSettings levelsettings = new LevelSettings("Test Level", GameType.CREATIVE, false, Difficulty.NORMAL, true, TEST_GAME_RULES, worlddataconfiguration); - WorldLoader.PackConfig worldloader$packconfig = new WorldLoader.PackConfig(p_206609_, worlddataconfiguration, false, true); -@@ -142,6 +_,7 @@ +@@ -80,7 +_,7 @@ + Thread p_206607_, LevelStorageSource.LevelStorageAccess p_206608_, PackRepository p_206609_, Optional p_392741_, boolean p_392375_ + ) { + p_206609_.reload(); +- ArrayList arraylist = new ArrayList<>(p_206609_.getAvailableIds()); ++ ArrayList arraylist = new ArrayList<>(p_206609_.getSelectedIds()); // Forge: Use the selected datapacks as this takes sorting into account. + arraylist.remove("vanilla"); + arraylist.addFirst("vanilla"); + WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(new DataPackConfig(arraylist, List.of()), ENABLED_FEATURES); +@@ -140,6 +_,7 @@ @Override public boolean initServer() { + if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; - this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, 1) { - }); + this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, 1) {}); this.loadLevel(); + ServerLevel serverlevel = this.overworld(); diff --git a/patches/minecraft/net/minecraft/gametest/framework/ReportGameListener.java.patch b/patches/minecraft/net/minecraft/gametest/framework/ReportGameListener.java.patch deleted file mode 100644 index 9cc37009ef..0000000000 --- a/patches/minecraft/net/minecraft/gametest/framework/ReportGameListener.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/gametest/framework/ReportGameListener.java -+++ b/net/minecraft/gametest/framework/ReportGameListener.java -@@ -151,7 +_,7 @@ - private static BlockPos getBeaconPos(GameTestInfo p_344999_) { - BlockPos blockpos = p_344999_.getStructureBlockPos(); - BlockPos blockpos1 = new BlockPos(-1, -2, -1); -- return StructureTemplate.transform(blockpos.offset(blockpos1), Mirror.NONE, p_344999_.getRotation(), blockpos); -+ return blockpos.offset(blockpos1); // Forge: The control blocks are always in the North West Corner - } - - private static void updateBeaconGlass(GameTestInfo p_343978_, Block p_344076_) { -@@ -167,8 +_,8 @@ - ServerLevel serverlevel = p_177739_.getLevel(); - BlockPos blockpos = p_177739_.getStructureBlockPos(); - BlockPos blockpos1 = new BlockPos(-1, 0, -1); -- BlockPos blockpos2 = StructureTemplate.transform(blockpos.offset(blockpos1), Mirror.NONE, p_177739_.getRotation(), blockpos); -- serverlevel.setBlockAndUpdate(blockpos2, Blocks.LECTERN.defaultBlockState().rotate(p_177739_.getRotation())); -+ BlockPos blockpos2 = blockpos.offset(blockpos1); // Forge: The control blocks are always in the North West Corner -+ serverlevel.setBlockAndUpdate(blockpos2, Blocks.LECTERN.defaultBlockState()); - BlockState blockstate = serverlevel.getBlockState(blockpos2); - ItemStack itemstack = createBook(p_177739_.getTestName(), p_177739_.isRequired(), p_177740_); - LecternBlock.tryPlaceBook(null, serverlevel, blockpos2, blockstate, itemstack); diff --git a/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch b/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch deleted file mode 100644 index b1757f2e2b..0000000000 --- a/patches/minecraft/net/minecraft/gametest/framework/StructureUtils.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/gametest/framework/StructureUtils.java -+++ b/net/minecraft/gametest/framework/StructureUtils.java -@@ -132,10 +_,16 @@ - .orElseThrow(() -> new IllegalStateException("Missing test structure: " + p_311701_.getStructureName())) - .getSize(); - BoundingBox boundingbox = getStructureBoundingBox(p_311042_, vec3i, p_310584_); -- BlockPos blockpos = getStartCorner(p_311701_, p_311042_, p_310584_, p_312330_); -+ BlockPos blockpos = getStartCorner(p_311701_, p_311042_, Rotation.NONE, p_312330_); // Forge: The control blocks are always in the North West Corner - forceLoadChunks(boundingbox, p_312330_); - clearSpaceForStructure(boundingbox, p_312330_); -- return createStructureBlock(p_311701_, blockpos.below(), p_310584_, p_312330_); -+ var entity = createStructureBlock(p_311701_, blockpos.below(), p_310584_, p_312330_); -+ //Forge: We need to offset the structure so that it will load within bounds. -+ if (p_310584_ != Rotation.NONE) { -+ var rotated = StructureTemplate.getZeroPositionWithTransform(BlockPos.ZERO, Mirror.NONE, p_310584_, entity.getStructureSize().getX(), entity.getStructureSize().getZ()); -+ entity.setStructurePos(rotated.offset(new BlockPos(0, 1, 0))); -+ } -+ return entity; - } - - public static void encaseStructure(AABB p_330422_, ServerLevel p_331249_, boolean p_328180_) { diff --git a/patches/minecraft/net/minecraft/gametest/framework/TestCommand.java.patch b/patches/minecraft/net/minecraft/gametest/framework/TestCommand.java.patch index a4a6ffc7f7..3144f625e0 100644 --- a/patches/minecraft/net/minecraft/gametest/framework/TestCommand.java.patch +++ b/patches/minecraft/net/minecraft/gametest/framework/TestCommand.java.patch @@ -1,15 +1,16 @@ --- a/net/minecraft/gametest/framework/TestCommand.java +++ b/net/minecraft/gametest/framework/TestCommand.java -@@ -313,7 +_,11 @@ +@@ -490,7 +_,12 @@ return Optional.empty(); } else { - TestFunction testfunction = optional.get(); -- GameTestInfo gametestinfo = new GameTestInfo(testfunction, structureblockentity.getRotation(), p_328153_, p_330368_); + Holder.Reference reference = optional.get(); +- GameTestInfo gametestinfo = new GameTestInfo(reference, testinstanceblockentity.getRotation(), serverlevel, p_330368_); + // Forge: The rotation is stored in the structure block, and added in the GameTestInfo constructor. + // So reverse it to find the manually specified rotation so the test runs the same every time. -+ var steps = StructureUtils.getRotationStepsForRotation(structureblockentity.getRotation()) - StructureUtils.getRotationStepsForRotation(testfunction.rotation()); ++ var rotation = testinstanceblockentity.test().flatMap(testinstanceblockentity.getLevel().registryAccess()::get).map(Holder::value).map(GameTestInstance::rotation).orElse(Rotation.NONE); ++ var steps = StructureUtils.getRotationStepsForRotation(testinstanceblockentity.getRotation()) - StructureUtils.getRotationStepsForRotation(rotation); + if (steps < 0) steps += 4; -+ GameTestInfo gametestinfo = new GameTestInfo(testfunction, StructureUtils.getRotationForRotationSteps(steps), p_328153_, p_330368_); - gametestinfo.setStructureBlockPos(p_332856_); - return !verifyStructureExists(p_328153_, gametestinfo.getStructureName()) ? Optional.empty() : Optional.of(gametestinfo); ++ GameTestInfo gametestinfo = new GameTestInfo(reference, StructureUtils.getRotationForRotationSteps(steps), serverlevel, p_330368_); + gametestinfo.setTestBlockPos(p_332856_); + return !verifyStructureExists(p_393532_, gametestinfo.getStructure()) ? Optional.empty() : Optional.of(gametestinfo); } diff --git a/patches/minecraft/net/minecraft/locale/Language.java.patch b/patches/minecraft/net/minecraft/locale/Language.java.patch index 18ce036ffe..42f4d908da 100644 --- a/patches/minecraft/net/minecraft/locale/Language.java.patch +++ b/patches/minecraft/net/minecraft/locale/Language.java.patch @@ -11,8 +11,8 @@ @Override public String getOrDefault(String p_128127_, String p_265421_) { @@ -63,6 +_,11 @@ - ) - .isPresent(); + ) + .isPresent(); } + + @Override diff --git a/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch b/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch index 5b7b0d539b..793bd4889b 100644 --- a/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch +++ b/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/nbt/CompoundTag.java +++ b/net/minecraft/nbt/CompoundTag.java -@@ -20,6 +_,10 @@ - import net.minecraft.ReportedException; +@@ -25,6 +_,10 @@ - public class CompoundTag implements Tag { + public final class CompoundTag implements Tag { + private static final Logger LOGGER = LogUtils.getLogger(); + public static net.minecraftforge.common.util.INBTBuilder.Builder builder() { + return (new net.minecraftforge.common.util.INBTBuilder(){}).nbt(); + } diff --git a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch index 2b423269a7..13100047fa 100644 --- a/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/patches/minecraft/net/minecraft/network/FriendlyByteBuf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/FriendlyByteBuf.java +++ b/net/minecraft/network/FriendlyByteBuf.java -@@ -1624,4 +_,8 @@ +@@ -1632,4 +_,8 @@ public boolean release(int p_130347_) { return this.source.release(p_130347_); } diff --git a/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch index 73a96bb3ef..bc2cea99d1 100644 --- a/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch @@ -9,7 +9,7 @@ Util.make( Lists.newArrayList( new CustomPacketPayload.TypeAndCodec<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC), -@@ -66,7 +_,7 @@ +@@ -65,7 +_,7 @@ ) .map(ClientboundCustomPayloadPacket::new, ClientboundCustomPayloadPacket::payload); public static final StreamCodec CONFIG_STREAM_CODEC = CustomPacketPayload.codec( diff --git a/patches/minecraft/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch index 201ed60972..d15dbb6838 100644 --- a/patches/minecraft/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch @@ -6,6 +6,6 @@ public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec( - p_335203_ -> DiscardedPayload.codec(p_335203_, 32767), + p_335203_ -> net.minecraftforge.common.ForgeHooks.getCustomPayloadCodec(p_335203_, 32767), - Util.make(Lists.newArrayList(new CustomPacketPayload.TypeAndCodec<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)), p_334419_ -> { - }) + Util.make(Lists.newArrayList(new CustomPacketPayload.TypeAndCodec<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)), p_334419_ -> {}) ) + .map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload); diff --git a/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch index 067e08f8fb..663c75020a 100644 --- a/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch @@ -11,12 +11,12 @@ public static final Codec CODEC = RecordCodecBuilder.create( p_326135_ -> p_326135_.group( @@ -29,7 +_,8 @@ - ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players), - ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version), - ServerStatus.Favicon.CODEC.lenientOptionalFieldOf("favicon").forGetter(ServerStatus::favicon), -- Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", Boolean.valueOf(false)).forGetter(ServerStatus::enforcesSecureChat) -+ Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", Boolean.valueOf(false)).forGetter(ServerStatus::enforcesSecureChat), -+ net.minecraftforge.network.ServerStatusPing.CODEC.optionalFieldOf("forgeData").forGetter(ServerStatus::forgeData) - ) - .apply(p_326135_, ServerStatus::new) + ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players), + ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version), + ServerStatus.Favicon.CODEC.lenientOptionalFieldOf("favicon").forGetter(ServerStatus::favicon), +- Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", false).forGetter(ServerStatus::enforcesSecureChat) ++ Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", false).forGetter(ServerStatus::enforcesSecureChat), ++ net.minecraftforge.network.ServerStatusPing.CODEC.optionalFieldOf("forgeData").forGetter(ServerStatus::forgeData) + ) + .apply(p_326135_, ServerStatus::new) ); diff --git a/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch b/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch index 6951635687..4931cbb477 100644 --- a/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch +++ b/patches/minecraft/net/minecraft/network/syncher/EntityDataSerializers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/syncher/EntityDataSerializers.java +++ b/net/minecraft/network/syncher/EntityDataSerializers.java -@@ -119,16 +_,18 @@ +@@ -129,16 +_,18 @@ public static final EntityDataSerializer QUATERNION = EntityDataSerializer.forValueType(ByteBufCodecs.QUATERNIONF); public static void registerSerializer(EntityDataSerializer p_135051_) { diff --git a/patches/minecraft/net/minecraft/resources/DelegatingOps.java.patch b/patches/minecraft/net/minecraft/resources/DelegatingOps.java.patch index 204d236add..92525f825e 100644 --- a/patches/minecraft/net/minecraft/resources/DelegatingOps.java.patch +++ b/patches/minecraft/net/minecraft/resources/DelegatingOps.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/resources/DelegatingOps.java +++ b/net/minecraft/resources/DelegatingOps.java -@@ -216,11 +_,29 @@ +@@ -218,12 +_,30 @@ @Override public ListBuilder listBuilder() { -- return new Builder<>(this); +- return new DelegatingOps.DelegateListBuilder(this.delegate.listBuilder()); + return new ListBuilder.Builder<>(this); } @Override public RecordBuilder mapBuilder() { - return new MapBuilder<>(this); + return new DelegatingOps.DelegateRecordBuilder(this.delegate.mapBuilder()); + } + + // Forge start @@ -30,4 +30,5 @@ + this.ctx.put(key, ctx); + return (R)this; } - } + + protected class DelegateListBuilder implements ListBuilder { diff --git a/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch b/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch index 5d949e97fd..002ec203ca 100644 --- a/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch +++ b/patches/minecraft/net/minecraft/resources/RegistryDataLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/RegistryDataLoader.java +++ b/net/minecraft/resources/RegistryDataLoader.java -@@ -80,7 +_,7 @@ +@@ -88,7 +_,7 @@ Lifecycle lifecycle = p_326161_.map(KnownPack::isVanilla).map(p_326166_ -> Lifecycle.stable()).orElse(Lifecycle.experimental()); return new RegistrationInfo(p_326161_, lifecycle); }); @@ -9,7 +9,7 @@ new RegistryDataLoader.RegistryData<>(Registries.DIMENSION_TYPE, DimensionType.DIRECT_CODEC), new RegistryDataLoader.RegistryData<>(Registries.BIOME, Biome.DIRECT_CODEC), new RegistryDataLoader.RegistryData<>(Registries.CHAT_TYPE, ChatType.DIRECT_CODEC), -@@ -112,7 +_,7 @@ +@@ -128,7 +_,7 @@ public static final List> DIMENSION_REGISTRIES = List.of( new RegistryDataLoader.RegistryData<>(Registries.LEVEL_STEM, LevelStem.CODEC) ); @@ -18,8 +18,8 @@ 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), -@@ -127,6 +_,10 @@ - new RegistryDataLoader.RegistryData<>(Registries.INSTRUMENT, Instrument.DIRECT_CODEC) +@@ -151,6 +_,10 @@ + new RegistryDataLoader.RegistryData<>(Registries.TEST_INSTANCE, GameTestInstance.DIRECT_CODEC) ); + public static java.util.stream.Stream> getWorldGenAndDimensionStream() { @@ -29,7 +29,7 @@ public static RegistryAccess.Frozen load( ResourceManager p_252046_, List> p_250344_, List> p_366741_ ) { -@@ -243,7 +_,7 @@ +@@ -267,7 +_,7 @@ private static void loadElementFromResource( WritableRegistry p_330991_, @@ -38,7 +38,7 @@ RegistryOps p_332135_, ResourceKey p_332850_, Resource p_335244_, -@@ -251,7 +_,23 @@ +@@ -275,7 +_,23 @@ ) throws IOException { try (Reader reader = p_335244_.openAsReader()) { JsonElement jsonelement = JsonParser.parseReader(reader); @@ -63,7 +63,7 @@ E e = dataresult.getOrThrow(); p_330991_.register(p_332850_, e, p_332222_); } -@@ -266,6 +_,7 @@ +@@ -290,6 +_,7 @@ ) { FileToIdConverter filetoidconverter = FileToIdConverter.registry(p_331358_.key()); RegistryOps registryops = RegistryOps.create(JsonOps.INSTANCE, p_333035_); @@ -71,7 +71,7 @@ for (Entry entry : filetoidconverter.listMatchingResources(p_335634_).entrySet()) { ResourceLocation resourcelocation = entry.getKey(); -@@ -274,7 +_,7 @@ +@@ -298,7 +_,7 @@ RegistrationInfo registrationinfo = REGISTRATION_INFO_CACHE.apply(resource.knownPackInfo()); try { @@ -80,7 +80,7 @@ } catch (Exception exception) { p_335074_.put( resourcekey, -@@ -297,7 +_,8 @@ +@@ -321,7 +_,8 @@ RegistryDataLoader.NetworkedRegistryData registrydataloader$networkedregistrydata = p_331925_.get(p_332518_.key()); if (registrydataloader$networkedregistrydata != null) { RegistryOps registryops = RegistryOps.create(NbtOps.INSTANCE, p_329253_); @@ -90,7 +90,7 @@ FileToIdConverter filetoidconverter = FileToIdConverter.registry(p_332518_.key()); for (RegistrySynchronization.PackedRegistryEntry registrysynchronization$packedregistryentry : registrydataloader$networkedregistrydata.elements) { -@@ -319,7 +_,7 @@ +@@ -343,7 +_,7 @@ try { Resource resource = p_332010_.getResourceOrThrow(resourcelocation); diff --git a/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch index 2258b4a090..8776a57a65 100644 --- a/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch +++ b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch @@ -12,7 +12,7 @@ @@ -67,5 +_,18 @@ } - static record InternKey(ResourceLocation registry, ResourceLocation location) { + record InternKey(ResourceLocation registry, ResourceLocation location) { + } + + @Override diff --git a/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch b/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch index d79b2f77b9..e1c1e9bc77 100644 --- a/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch +++ b/patches/minecraft/net/minecraft/resources/ResourceLocation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/ResourceLocation.java +++ b/net/minecraft/resources/ResourceLocation.java -@@ -163,6 +_,12 @@ +@@ -154,6 +_,12 @@ return i; } diff --git a/patches/minecraft/net/minecraft/server/Main.java.patch b/patches/minecraft/net/minecraft/server/Main.java.patch index 1edc690417..e43baca411 100644 --- a/patches/minecraft/net/minecraft/server/Main.java.patch +++ b/patches/minecraft/net/minecraft/server/Main.java.patch @@ -81,48 +81,47 @@ WorldStem worldstem; try { WorldLoader.InitConfig worldloader$initconfig = loadOrCreateConfig(dedicatedserversettings.getProperties(), dynamic1, flag, packrepository); -@@ -218,6 +_,16 @@ - worlddimensions = dedicatedserverproperties.createDimensions(p_358511_.datapackWorldgen()); - } +@@ -216,6 +_,16 @@ + worlddimensions = dedicatedserverproperties.createDimensions(p_358511_.datapackWorldgen()); + } -+ //Forge: Do a write-read-cycle to inject modded dimensions on first start of a dedicated server into its generated world dimensions list. -+ var dynamicops = net.minecraft.resources.RegistryOps.create(net.minecraft.nbt.NbtOps.INSTANCE, p_358511_.datapackWorldgen()); -+ worlddimensions = WorldDimensions.CODEC.encoder() -+ .encodeStart(dynamicops, worlddimensions) -+ .flatMap((writtenPayloadWithModdedDimensions) -> -+ WorldDimensions.CODEC.decoder().parse(dynamicops, writtenPayloadWithModdedDimensions) -+ ) -+ .resultOrPartial(LOGGER::error) -+ .orElse(worlddimensions); ++ //Forge: Do a write-read-cycle to inject modded dimensions on first start of a dedicated server into its generated world dimensions list. ++ var dynamicops = net.minecraft.resources.RegistryOps.create(net.minecraft.nbt.NbtOps.INSTANCE, p_358511_.datapackWorldgen()); ++ worlddimensions = WorldDimensions.CODEC.encoder() ++ .encodeStart(dynamicops, worlddimensions) ++ .flatMap((writtenPayloadWithModdedDimensions) -> ++ WorldDimensions.CODEC.decoder().parse(dynamicops, writtenPayloadWithModdedDimensions) ++ ) ++ .resultOrPartial(LOGGER::error) ++ .orElse(worlddimensions); + - WorldDimensions.Complete worlddimensions$complete = worlddimensions.bake(registry); - Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_358511_.datapackWorldgen().allRegistriesLifecycle()); - return new WorldLoader.DataLoadOutput<>( -@@ -248,9 +_,16 @@ + WorldDimensions.Complete worlddimensions$complete = worlddimensions.bake(registry); + Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_358511_.datapackWorldgen().allRegistriesLifecycle()); + return new WorldLoader.DataLoadOutput<>( +@@ -254,9 +_,20 @@ + } - WorldData worlddata = worldstem.worldData(); levelstoragesource$levelstorageaccess.saveDataTag(registryaccess$frozen, worlddata); - final DedicatedServer dedicatedserver = MinecraftServer.spin( + final MinecraftServer dedicatedserver = MinecraftServer.spin( p_296433_ -> { - DedicatedServer dedicatedserver1 = new DedicatedServer( + MinecraftServer dedicatedserver1; ++ // TODO: [Forge][GameTest] URGENT !!! FIX GAME TESTS !!! ++ /* + if (gametestEnabled) { + net.minecraftforge.gametest.ForgeGameTestHooks.registerGametests(); + var tests = net.minecraft.gametest.framework.GameTestRegistry.getAllTestFunctions(); + var spawnPos = optionset.valueOf(spawnPosOpt); + dedicatedserver1 = net.minecraft.gametest.framework.GameTestServer.create(p_296433_, levelstoragesource$levelstorageaccess, packrepository, tests, spawnPos); ++ + } else { ++ */ + dedicatedserver1 = new DedicatedServer( p_296433_, levelstoragesource$levelstorageaccess, packrepository, -@@ -260,12 +_,13 @@ - services, - LoggerChunkProgressListener::createFromGameruleRadius - ); -+ } - dedicatedserver1.setPort(optionset.valueOf(optionspec11)); +@@ -270,8 +_,8 @@ dedicatedserver1.setDemo(optionset.has(optionspec2)); dedicatedserver1.setId(optionset.valueOf(optionspec12)); boolean flag2 = !optionset.has(optionspec) && !optionset.valuesOf(optionspec15).contains("nogui"); @@ -133,7 +132,7 @@ } return dedicatedserver1; -@@ -274,7 +_,10 @@ +@@ -280,7 +_,10 @@ Thread thread = new Thread("Server Shutdown Thread") { @Override public void run() { diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index 2cbe540287..8460a7d528 100644 --- a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -275,7 +_,7 @@ +@@ -273,7 +_,7 @@ public static S spin(Function p_129873_) { AtomicReference atomicreference = new AtomicReference<>(); @@ -9,7 +9,7 @@ thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> LOGGER.error("Uncaught exception in server thread", p_177910_)); if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); -@@ -381,6 +_,7 @@ +@@ -379,6 +_,7 @@ this.readScoreboard(dimensiondatastorage); this.commandStorage = new CommandStorage(dimensiondatastorage); WorldBorder worldborder = serverlevel.getWorldBorder(); @@ -17,7 +17,7 @@ if (!serverleveldata.isInitialized()) { try { setInitialSpawn(serverlevel, serverleveldata, worldoptions.generateBonusChest(), flag); -@@ -430,6 +_,7 @@ +@@ -428,6 +_,7 @@ ); worldborder.addListener(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.getWorldBorder())); this.levels.put(resourcekey1, serverlevel1); @@ -25,7 +25,7 @@ } } -@@ -441,6 +_,7 @@ +@@ -439,6 +_,7 @@ p_177898_.setSpawn(BlockPos.ZERO.above(80), 0.0F); } else { ServerChunkCache serverchunkcache = p_177897_.getChunkSource(); @@ -33,15 +33,7 @@ ChunkPos chunkpos = new ChunkPos(serverchunkcache.randomState().sampler().findSpawnPosition()); int i = serverchunkcache.getGenerator().getSpawnHeight(p_177897_); if (i < p_177897_.getMinY()) { -@@ -522,6 +_,7 @@ - ChunkPos chunkpos = new ChunkPos(k); - serverlevel1.getChunkSource().updateChunkForced(chunkpos, true); - } -+ net.minecraftforge.common.world.ForgeChunkManager.reinstatePersistentChunks(serverlevel1, forcedchunkssaveddata); - } - } - -@@ -629,6 +_,7 @@ +@@ -621,6 +_,7 @@ for (ServerLevel serverlevel2 : this.getAllLevels()) { if (serverlevel2 != null) { try { @@ -49,7 +41,7 @@ serverlevel2.close(); } catch (IOException ioexception1) { LOGGER.error("Exception closing the level", (Throwable)ioexception1); -@@ -675,9 +_,11 @@ +@@ -667,9 +_,11 @@ throw new IllegalStateException("Failed to initialize server"); } @@ -61,7 +53,7 @@ while (this.running) { long i; -@@ -729,6 +_,8 @@ +@@ -721,6 +_,8 @@ this.isReady = true; JvmProfiler.INSTANCE.onServerTick(this.smoothedTickTimeMillis); } @@ -70,7 +62,7 @@ } catch (Throwable throwable2) { LOGGER.error("Encountered an unexpected exception", throwable2); CrashReport crashreport = constructOrExtractCrashReport(throwable2); -@@ -740,6 +_,7 @@ +@@ -732,6 +_,7 @@ LOGGER.error("We were unable to save this crash report to disk."); } @@ -78,7 +70,7 @@ this.onServerCrash(crashreport); } finally { try { -@@ -752,6 +_,7 @@ +@@ -744,6 +_,7 @@ this.services.profileCache().clearExecutor(); } @@ -86,7 +78,7 @@ this.onServerExit(); } } -@@ -941,12 +_,14 @@ +@@ -933,12 +_,14 @@ } } @@ -101,7 +93,7 @@ } this.ticksUntilAutosave--; -@@ -964,6 +_,7 @@ +@@ -956,6 +_,7 @@ this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float)k / (float)TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F; this.logTickMethodTime(i); profilerfiller.pop(); @@ -109,7 +101,7 @@ } private void autoSave() { -@@ -1013,7 +_,8 @@ +@@ -1005,7 +_,8 @@ Optional.of(serverstatus$players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), @@ -119,7 +111,7 @@ ); } -@@ -1044,7 +_,8 @@ +@@ -1036,7 +_,8 @@ this.getFunctions().tick(); profilerfiller.popPush("levels"); @@ -129,7 +121,7 @@ profilerfiller.push(() -> serverlevel + " " + serverlevel.dimension().location()); if (this.tickCount % 20 == 0) { profilerfiller.push("timeSync"); -@@ -1053,6 +_,7 @@ +@@ -1045,6 +_,7 @@ } profilerfiller.push("tick"); @@ -137,7 +129,7 @@ try { serverlevel.tick(p_129954_); -@@ -1061,16 +_,18 @@ +@@ -1053,16 +_,18 @@ serverlevel.fillReportDetails(crashreport); throw new ReportedException(crashreport); } @@ -152,12 +144,12 @@ this.tickConnection(); profilerfiller.popPush("players"); this.playerList.tick(); -- if (SharedConstants.IS_RUNNING_IN_IDE && this.tickRateManager.runsNormally()) { +- if (this.tickRateManager.runsNormally()) { + if (net.minecraftforge.gametest.ForgeGameTestHooks.isGametestEnabled() && this.tickRateManager.runsNormally()) { GameTestTicker.SINGLETON.tick(); } -@@ -1171,7 +_,7 @@ +@@ -1163,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -166,7 +158,7 @@ } public SystemReport fillSystemReport(SystemReport p_177936_) { -@@ -1523,6 +_,7 @@ +@@ -1515,6 +_,7 @@ this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary()); this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager); this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures()); @@ -174,7 +166,7 @@ }, this); if (this.isSameThread()) { this.managedBlock(completablefuture::isDone); -@@ -1532,12 +_,15 @@ +@@ -1524,12 +_,15 @@ } public static WorldDataConfiguration configurePackRepository(PackRepository p_248681_, WorldDataConfiguration p_331931_, boolean p_249869_, boolean p_330480_) { @@ -191,7 +183,7 @@ } else { Set set = Sets.newLinkedHashSet(); -@@ -2041,6 +_,48 @@ +@@ -2033,6 +_,48 @@ public ServerLinks serverLinks() { return ServerLinks.EMPTY; diff --git a/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch index d14347a016..aec5340431 100644 --- a/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/SpreadPlayersCommand.java.patch @@ -12,9 +12,9 @@ + if (!event.isCanceled()) entity.teleportTo( p_138731_, -- (double)Mth.floor(spreadplayerscommand$position.x) + 0.5, -- (double)spreadplayerscommand$position.getSpawnY(p_138731_, p_138733_), -- (double)Mth.floor(spreadplayerscommand$position.z) + 0.5, +- Mth.floor(spreadplayerscommand$position.x) + 0.5, +- spreadplayerscommand$position.getSpawnY(p_138731_, p_138733_), +- Mth.floor(spreadplayerscommand$position.z) + 0.5, + event.getTargetX(), + event.getTargetY(), + event.getTargetZ(), diff --git a/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch b/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch index cd4a8fa277..83a61e854a 100644 --- a/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch +++ b/patches/minecraft/net/minecraft/server/commands/TeleportCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/TeleportCommand.java +++ b/net/minecraft/server/commands/TeleportCommand.java -@@ -277,6 +_,9 @@ +@@ -275,6 +_,9 @@ float p_139023_, @Nullable LookAt p_365991_ ) throws CommandSyntaxException { diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch index 5bc247d9ea..cd2a55769d 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -25,7 +25,7 @@ LOGGER.info("Preparing level \"{}\"", this.getLevelIdName()); this.loadLevel(); long j = Util.getNanos() - i; - String s = String.format(Locale.ROOT, "%.3fs", (double)j / 1.0E9); + String s = String.format(Locale.ROOT, "%.3fs", j / 1.0E9); LOGGER.info("Done ({})! For help, type \"help\"", s); + this.nextTickTimeNanos = Util.getNanos(); //Forge: Update server time to prevent watchdog/spaming during long load. if (dedicatedserverproperties.announcePlayerAchievements != null) { diff --git a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch index 71333ff559..27de7e071d 100644 --- a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch +++ b/patches/minecraft/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 -@@ -393,6 +_,7 @@ +@@ -391,6 +_,7 @@ this.modified = true; } @@ -8,7 +8,7 @@ return p_140179_; } } -@@ -519,6 +_,7 @@ +@@ -517,6 +_,7 @@ if (this.pendingUnloads.remove(p_140182_, p_140183_) && chunkaccess != null) { if (chunkaccess instanceof LevelChunk levelchunk) { levelchunk.setLoaded(false); @@ -16,7 +16,7 @@ } this.save(chunkaccess); -@@ -769,6 +_,7 @@ +@@ -767,6 +_,7 @@ this.activeChunkWrites.incrementAndGet(); SerializableChunkData serializablechunkdata = SerializableChunkData.copyOf(this.level, p_140259_); CompletableFuture completablefuture = CompletableFuture.supplyAsync(serializablechunkdata::write, Util.backgroundExecutor()); @@ -24,36 +24,7 @@ this.write(chunkpos, completablefuture::join).handle((p_358676_, p_358677_) -> { if (p_358677_ != null) { this.level.getServer().reportChunkSaveFailure(p_358677_, this.storageInfo(), chunkpos); -@@ -934,10 +_,27 @@ - void forEachSpawnCandidateChunk(Consumer p_364582_) { - LongIterator longiterator = this.distanceManager.getSpawnCandidateChunks(); - -+ // FORGE: separated forEach logic into its own method -+ this.forEachChunk(longiterator, this::anyPlayerCloseEnoughForSpawningInternal, p_364582_); -+ } -+ -+ /** FORGE: grab forced chunks, use forEachChunk to avoid duplicate logic */ -+ void forEachForcedChunk(Consumer callback) { -+ LongIterator longiterator = this.distanceManager.forcedTickets.keySet().iterator(); -+ this.forEachChunk(longiterator, pos -> true, callback); -+ } -+ -+ /** FORGE: check if there are any forced chunks */ -+ boolean hasForcedChunks() { -+ return !this.distanceManager.forcedTickets.isEmpty(); -+ } -+ -+ /** FORGE: commonize logic between forEachSpawnCandidateChunk and forEachForcedChunk */ -+ private void forEachChunk(LongIterator longiterator, java.util.function.Predicate filter, Consumer p_364582_) { - while (longiterator.hasNext()) { - long i = longiterator.nextLong(); - ChunkHolder chunkholder = this.visibleChunkMap.get(i); -- if (chunkholder != null && this.anyPlayerCloseEnoughForSpawningInternal(chunkholder.getPos())) { -+ if (chunkholder != null && filter.test(chunkholder.getPos())) { - p_364582_.accept(chunkholder); - } - } -@@ -1102,7 +_,7 @@ +@@ -1122,7 +_,7 @@ } protected void addEntity(Entity p_140200_) { diff --git a/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch index c07749b854..c3e4756ad1 100644 --- a/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch +++ b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch @@ -1,74 +1,13 @@ --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -50,6 +_,7 @@ - final Executor mainThreadExecutor; - private long ticketTickCounter; - private int simulationDistance = 10; -+ final Long2ObjectOpenHashMap>> forcedTickets = new Long2ObjectOpenHashMap<>(); - - protected DistanceManager(Executor p_140774_, Executor p_140775_) { - TaskScheduler taskscheduler = TaskScheduler.wrapExecutor("player ticket throttler", p_140775_); -@@ -150,6 +_,11 @@ - if (p_140786_.getTicketLevel() < i) { - this.ticketTracker.update(p_140785_, p_140786_.getTicketLevel(), true); - } -+ -+ if (p_140786_.isForceTicks()) { -+ var tickets = forcedTickets.computeIfAbsent(p_140785_, e -> SortedArraySet.create(4)); -+ tickets.addOrGet(ticket); -+ } - } - - void removeTicket(long p_140819_, Ticket p_140820_) { -@@ -162,6 +_,14 @@ - } - - this.ticketTracker.update(p_140819_, getTicketLevelAt(sortedarrayset), false); -+ -+ -+ if (p_140820_.isForceTicks()) { -+ var tickets = forcedTickets.get(p_140819_); -+ if (tickets != null) { -+ tickets.remove(p_140820_); -+ } -+ } - } - - public void addTicket(TicketType p_140793_, ChunkPos p_140794_, int p_140795_, T p_140796_) { -@@ -174,14 +_,22 @@ - } - - public void addRegionTicket(TicketType p_140841_, ChunkPos p_140842_, int p_140843_, T p_140844_) { -- Ticket ticket = new Ticket<>(p_140841_, ChunkLevel.byStatus(FullChunkStatus.FULL) - p_140843_, p_140844_); -+ addRegionTicket(p_140841_, p_140842_, p_140843_, p_140844_, false); -+ } -+ -+ public void addRegionTicket(TicketType p_140841_, ChunkPos p_140842_, int p_140843_, T p_140844_, boolean forceTicks) { -+ Ticket ticket = new Ticket<>(p_140841_, ChunkLevel.byStatus(FullChunkStatus.FULL) - p_140843_, p_140844_, forceTicks); - long i = p_140842_.toLong(); - this.addTicket(i, ticket); - this.tickingTicketsTracker.addTicket(i, ticket); - } - - public void removeRegionTicket(TicketType p_140850_, ChunkPos p_140851_, int p_140852_, T p_140853_) { -- Ticket ticket = new Ticket<>(p_140850_, ChunkLevel.byStatus(FullChunkStatus.FULL) - p_140852_, p_140853_); -+ removeRegionTicket(p_140850_, p_140851_, p_140852_, p_140853_, false); -+ } -+ -+ public void removeRegionTicket(TicketType p_140850_, ChunkPos p_140851_, int p_140852_, T p_140853_, boolean forceTicks) { -+ Ticket ticket = new Ticket<>(p_140850_, ChunkLevel.byStatus(FullChunkStatus.FULL) - p_140852_, p_140853_, forceTicks); - long i = p_140851_.toLong(); - this.removeTicket(i, ticket); - this.tickingTicketsTracker.removeTicket(i, ticket); -@@ -270,6 +_,11 @@ - - public String getDebugStatus() { +@@ -189,6 +_,10 @@ return this.ticketDispatcher.getDebugStatus(); -+ } -+ -+ public boolean shouldForceTicks(long chunkPos) { -+ SortedArraySet> tickets = forcedTickets.get(chunkPos); -+ return tickets != null && !tickets.isEmpty(); } - private void dumpTickets(String p_143208_) { ++ public boolean shouldForceTicks(long chunkPos) { ++ return this.ticketStorage.getForceLoadedChunks().contains(chunkPos); ++ } ++ + public boolean hasTickets() { + return this.ticketStorage.hasTickets(); + } diff --git a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch index 1ffffc4bc4..76f8ba5dba 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -187,6 +_,10 @@ +@@ -205,6 +_,10 @@ if (chunkholder == null) { return null; } else { @@ -11,53 +11,21 @@ ChunkAccess chunkaccess1 = chunkholder.getChunkIfPresent(ChunkStatus.FULL); if (chunkaccess1 != null) { this.storeInCache(i, chunkaccess1, ChunkStatus.FULL); -@@ -368,9 +_,25 @@ - } - - private void collectTickingChunks(List p_368970_) { -- this.chunkMap.forEachSpawnCandidateChunk(p_358696_ -> { -+ // FORGE: If there are no forced chunks, just do the vanilla logic -+ if (!this.chunkMap.hasForcedChunks()) { -+ this.chunkMap.forEachSpawnCandidateChunk(this.getChunkCollector(p_368970_, chunk -> this.level.isNaturalSpawningAllowed(chunk.getPos()))); -+ return; -+ } -+ -+ // FORGE: We have forced chunks? Ok, use a linked hash set to preserve order -+ Set set = new java.util.LinkedHashSet<>(); -+ this.chunkMap.forEachSpawnCandidateChunk(this.getChunkCollector(set, chunk -> this.level.isNaturalSpawningAllowed(chunk.getPos()))); -+ this.chunkMap.forEachForcedChunk(this.getChunkCollector(set, chunk -> true)); -+ p_368970_.addAll(set); -+ } -+ -+ /** FORGE: Isolate chunk collection callback */ -+ private Consumer getChunkCollector(java.util.Collection p_368970_, java.util.function.Predicate predicate) { -+ return (p_358696_ -> { - LevelChunk levelchunk = p_358696_.getTickingChunk(); -- if (levelchunk != null && this.level.isNaturalSpawningAllowed(p_358696_.getPos())) { -+ // FORGE: Use custom predicate instead of only checking isNaturalSpawningAllowed -+ if (levelchunk != null && predicate.test(levelchunk)) { - p_368970_.add(levelchunk); +@@ -621,5 +_,17 @@ + return super.pollTask(); } - }); -@@ -466,11 +_,19 @@ - } - - public void addRegionTicket(TicketType p_8388_, ChunkPos p_8389_, int p_8390_, T p_8391_) { -- this.distanceManager.addRegionTicket(p_8388_, p_8389_, p_8390_, p_8391_); -+ addRegionTicket(p_8388_, p_8389_, p_8390_, p_8391_, false); + } + } + -+ public void addRegionTicket(TicketType p_8388_, ChunkPos p_8389_, int p_8390_, T p_8391_, boolean forceTicks) { -+ this.distanceManager.addRegionTicket(p_8388_, p_8389_, p_8390_, p_8391_, forceTicks); - } - - public void removeRegionTicket(TicketType p_8439_, ChunkPos p_8440_, int p_8441_, T p_8442_) { -- this.distanceManager.removeRegionTicket(p_8439_, p_8440_, p_8441_, p_8442_); -+ removeRegionTicket(p_8439_, p_8440_, p_8441_, p_8442_, false); ++ /** @deprecated Use {@link #addTicketWithRadius(TicketType, ChunkPos, int)} with {@link TicketType#FORCED} */ ++ @Deprecated(forRemoval = true, since = "1.21.5") ++ public void addRegionTicket(TicketType type, ChunkPos pos, int ticketLevel, boolean forceTicks) { ++ this.addTicketWithRadius(forceTicks ? TicketType.FORCED : type, pos, ticketLevel); + } + -+ public void removeRegionTicket(TicketType p_8439_, ChunkPos p_8440_, int p_8441_, T p_8442_, boolean forceTicks) { -+ this.distanceManager.removeRegionTicket(p_8439_, p_8440_, p_8441_, p_8442_, forceTicks); ++ /** @deprecated Use {@link #removeTicketWithRadius(TicketType, ChunkPos, int)} with {@link TicketType#FORCED} */ ++ @Deprecated(forRemoval = true, since = "1.21.5") ++ public void removeRegionTicket(TicketType type, ChunkPos pos, int ticketLevel, boolean forceTicks) { ++ this.removeTicketWithRadius(forceTicks ? TicketType.FORCED : type, pos, ticketLevel); } - - @Override + } diff --git a/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch b/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch index 2f8f49c877..7413ea0a14 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerEntity.java.patch +++ b/patches/minecraft/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 -@@ -277,6 +_,7 @@ +@@ -264,6 +_,7 @@ public void removePairing(ServerPlayer p_8535_) { this.entity.stopSeenByPlayer(p_8535_); p_8535_.connection.send(new ClientboundRemoveEntitiesPacket(this.entity.getId())); @@ -8,7 +8,7 @@ } public void addPairing(ServerPlayer p_8542_) { -@@ -284,6 +_,7 @@ +@@ -271,6 +_,7 @@ this.sendPairingData(p_8542_, list::add); p_8542_.connection.send(new ClientboundBundlePacket(list)); this.entity.startSeenByPlayer(p_8542_); diff --git a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch index feea14cc4c..c5b5a3b643 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch +++ b/patches/minecraft/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 -@@ -204,10 +_,12 @@ +@@ -200,10 +_,12 @@ @Nullable private EndDragonFight dragonFight; final Int2ObjectMap dragonParts = new Int2ObjectOpenHashMap<>(); @@ -13,20 +13,26 @@ public ServerLevel( MinecraftServer p_214999_, -@@ -290,6 +_,12 @@ +@@ -286,6 +_,18 @@ this.sleepStatus = new SleepStatus(); this.gameEventDispatcher = new GameEventDispatcher(this); - this.randomSequences = Objects.requireNonNullElseGet(p_288977_, () -> this.getDataStorage().computeIfAbsent(RandomSequences.factory(i), "random_sequences")); + this.randomSequences = Objects.requireNonNullElseGet(p_288977_, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); + this.initCapabilities(); + } + + protected void initCapabilities() { + this.gatherCapabilities(); -+ capabilityData = net.minecraftforge.common.util.LevelCapabilityData.compute(this.getDataStorage(), getCapabilities()); ++ capabilityData = this.getDataStorage().computeIfAbsent(net.minecraftforge.common.util.LevelCapabilityData.TYPE); ++ } ++ ++ /** Forge: Internal method only for out capability storage system */ ++ @org.jetbrains.annotations.ApiStatus.Internal ++ public @org.jetbrains.annotations.Nullable net.minecraftforge.common.capabilities.CapabilityDispatcher getCapabilityDispatcher() { ++ return getCapabilities(); } @Deprecated -@@ -331,8 +_,8 @@ +@@ -327,8 +_,8 @@ int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { @@ -37,17 +43,7 @@ } this.wakeUpAllPlayers(); -@@ -370,7 +_,8 @@ - - this.handlingTick = false; - profilerfiller.pop(); -- boolean flag1 = !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); -+ // Forge: Replace vanilla's has forced chunk check with forge's that checks both the vanilla and forge added ones -+ boolean flag1 = !this.players.isEmpty() || net.minecraftforge.common.world.ForgeChunkManager.hasForcedChunks(this); - if (flag1) { - this.resetEmptyTime(); - } -@@ -399,6 +_,7 @@ +@@ -395,6 +_,7 @@ p_358707_.stopRiding(); } @@ -55,7 +51,7 @@ profilerfiller.push("tick"); this.guardEntityTick(this::tickNonPassenger, p_358707_); profilerfiller.pop(); -@@ -526,6 +_,7 @@ +@@ -530,6 +_,7 @@ BlockPos blockpos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, p_300602_); BlockPos blockpos1 = blockpos.below(); Biome biome = this.getBiome(blockpos).value(); @@ -63,7 +59,7 @@ if (biome.shouldFreeze(this, blockpos1)) { this.setBlockAndUpdate(blockpos1, Blocks.ICE.defaultBlockState()); } -@@ -701,8 +_,8 @@ +@@ -705,8 +_,8 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); } @@ -74,7 +70,7 @@ } } -@@ -739,6 +_,7 @@ +@@ -743,6 +_,7 @@ p_8648_.tickCount++; profilerfiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8648_.getType()).toString()); profilerfiller.incrementCounter("tickNonPassenger"); @@ -82,7 +78,7 @@ p_8648_.tick(); profilerfiller.pop(); -@@ -756,6 +_,7 @@ +@@ -760,6 +_,7 @@ ProfilerFiller profilerfiller = Profiler.get(); profilerfiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8664_.getType()).toString()); profilerfiller.incrementCounter("tickPassenger"); @@ -90,7 +86,7 @@ p_8664_.rideTick(); profilerfiller.pop(); -@@ -788,6 +_,7 @@ +@@ -792,6 +_,7 @@ } else { this.entityManager.autoSave(); } @@ -98,15 +94,15 @@ } } -@@ -882,6 +_,7 @@ +@@ -886,6 +_,7 @@ } private void addPlayer(ServerPlayer p_8854_) { + if (net.minecraftforge.event.ForgeEventFactory.onEntityJoinLevel(p_8854_, this)) return; - Entity entity = this.getEntities().get(p_8854_.getUUID()); + Entity entity = this.getEntity(p_8854_.getUUID()); if (entity != null) { LOGGER.warn("Force-added player with duplicate UUID {}", p_8854_.getUUID()); -@@ -889,7 +_,8 @@ +@@ -893,7 +_,8 @@ this.removePlayerImmediately((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -116,7 +112,7 @@ } private boolean addEntity(Entity p_8873_) { -@@ -897,7 +_,12 @@ +@@ -901,7 +_,12 @@ LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityType.getKey(p_8873_.getType())); return false; } else { @@ -130,24 +126,11 @@ } } -@@ -945,6 +_,12 @@ - float p_263390_, - long p_263403_ +@@ -949,6 +_,12 @@ + float p_263520_, + long p_263490_ ) { -+ var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtPosition(this, p_263393_, p_263369_, p_263354_, p_263412_, p_263338_, p_263352_, p_263390_); -+ if (event.isCanceled() || event.getSound() == null) return; -+ p_263412_ = event.getSound(); -+ p_263338_ = event.getSource(); -+ p_263352_ = event.getNewVolume(); -+ p_263390_ = event.getNewPitch(); - this.server - .getPlayerList() - .broadcast( -@@ -962,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_ - ) { -+ var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_263544_, p_263491_, p_263542_, p_263530_, p_263520_); ++ var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtPosition(this, p_393402_, p_397340_, p_394643_, p_263491_, p_263542_, p_263530_, p_263520_); + if (event.isCanceled() || event.getSound() == null) return; + p_263491_ = event.getSound(); + p_263542_ = event.getSource(); @@ -156,7 +139,20 @@ this.server .getPlayerList() .broadcast( -@@ -1020,6 +_,7 @@ +@@ -966,6 +_,12 @@ + public void playSeededSound( + @Nullable Entity p_392657_, Entity p_394285_, Holder p_263412_, SoundSource p_263338_, float p_263352_, float p_263390_, long p_263403_ + ) { ++ var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_394285_, p_263412_, p_263338_, p_263352_, p_263390_); ++ if (event.isCanceled() || event.getSound() == null) return; ++ p_263412_ = event.getSound(); ++ p_263338_ = event.getSource(); ++ p_263352_ = event.getNewVolume(); ++ p_263390_ = event.getNewPitch(); + this.server + .getPlayerList() + .broadcast( +@@ -1024,6 +_,7 @@ @Override public void gameEvent(Holder p_334475_, Vec3 p_215042_, GameEvent.Context p_215043_) { @@ -164,7 +160,7 @@ this.gameEventDispatcher.post(p_334475_, p_215042_, p_215043_); } -@@ -1058,16 +_,24 @@ +@@ -1062,16 +_,24 @@ @Override public void updateNeighborsAt(BlockPos p_215045_, Block p_215046_) { @@ -189,7 +185,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215052_, p_215053_, p_215054_, p_370072_); } -@@ -1113,12 +_,14 @@ +@@ -1117,12 +_,14 @@ Explosion.BlockInteraction explosion$blockinteraction = switch (p_255827_) { case NONE -> Explosion.BlockInteraction.KEEP; case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); @@ -205,7 +201,7 @@ serverexplosion.explode(); ParticleOptions particleoptions = serverexplosion.isSmall() ? p_310962_ : p_310322_; -@@ -1714,6 +_,11 @@ +@@ -1698,6 +_,11 @@ return this.chunkSource.getGenerator().getSeaLevel(); } @@ -217,7 +213,7 @@ final class EntityCallbacks implements LevelCallback { public void onCreated(Entity p_143355_) { } -@@ -1754,6 +_,12 @@ +@@ -1738,6 +_,12 @@ } } @@ -230,7 +226,7 @@ p_143371_.updateDynamicGameEventListener(DynamicGameEventListener::add); } -@@ -1781,7 +_,16 @@ +@@ -1765,7 +_,16 @@ } } diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch index a963c2e152..4bc0191e67 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -180,7 +_,8 @@ +@@ -190,7 +_,8 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; import org.slf4j.Logger; @@ -10,7 +10,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32; private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10; -@@ -844,6 +_,7 @@ +@@ -800,6 +_,7 @@ @Override public void die(DamageSource p_9035_) { @@ -18,7 +18,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); if (flag) { -@@ -1034,6 +_,7 @@ +@@ -979,6 +_,7 @@ @Nullable public ServerPlayer teleport(TeleportTransition p_361322_) { @@ -26,7 +26,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1061,7 +_,7 @@ +@@ -1006,7 +_,7 @@ PlayerList playerlist = this.server.getPlayerList(); playerlist.sendPlayerPermissionLevel(this); serverlevel1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); @@ -35,7 +35,7 @@ ProfilerFiller profilerfiller = Profiler.get(); profilerfiller.push("moving"); if (resourcekey == Level.OVERWORLD && serverlevel.dimension() == Level.NETHER) { -@@ -1085,6 +_,7 @@ +@@ -1030,6 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -43,7 +43,7 @@ return this; } } -@@ -1125,6 +_,9 @@ +@@ -1070,6 +_,9 @@ @Override public Either startSleepInBed(BlockPos p_9115_) { @@ -53,16 +53,16 @@ Direction direction = this.level().getBlockState(p_9115_).getValue(HorizontalDirectionalBlock.FACING); if (this.isSleeping() || !this.isAlive()) { return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); -@@ -1136,7 +_,7 @@ +@@ -1081,7 +_,7 @@ return Either.left(Player.BedSleepingProblem.OBSTRUCTED); } else { - this.setRespawnPosition(this.level().dimension(), p_9115_, this.getYRot(), false, true); -- if (this.level().isDay()) { + this.setRespawnPosition(new ServerPlayer.RespawnConfig(this.level().dimension(), p_9115_, this.getYRot(), false), true); +- if (this.level().isBrightOutside()) { + if (!net.minecraftforge.event.ForgeEventFactory.onSleepingTimeCheck(this, optAt)) { return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); } else { if (!this.isCreative()) { -@@ -1182,6 +_,7 @@ +@@ -1127,6 +_,7 @@ } private boolean bedInRange(BlockPos p_9117_, Direction p_9118_) { @@ -70,7 +70,7 @@ return this.isReachableBedBlock(p_9117_) || this.isReachableBedBlock(p_9117_.relative(p_9118_.getOpposite())); } -@@ -1286,6 +_,7 @@ +@@ -1225,6 +_,7 @@ this.connection.send(new ClientboundOpenScreenPacket(abstractcontainermenu.containerId, abstractcontainermenu.getType(), p_9033_.getDisplayName())); this.initMenu(abstractcontainermenu); this.containerMenu = abstractcontainermenu; @@ -78,7 +78,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1335,6 +_,7 @@ +@@ -1274,6 +_,7 @@ public void doCloseContainer() { this.containerMenu.removed(this); this.inventoryMenu.transferState(this.containerMenu); @@ -86,7 +86,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -1558,6 +_,15 @@ +@@ -1497,6 +_,15 @@ this.setShoulderEntityLeft(p_9016_.getShoulderEntityLeft()); this.setShoulderEntityRight(p_9016_.getShoulderEntityRight()); this.setLastDeathLocation(p_9016_.getLastDeathLocation()); @@ -102,7 +102,7 @@ } @Override -@@ -1657,6 +_,7 @@ +@@ -1596,6 +_,7 @@ public boolean setGameMode(GameType p_143404_) { boolean flag = this.isSpectator(); @@ -110,7 +110,7 @@ if (!this.gameMode.changeGameModeForPlayer(p_143404_)) { return false; } else { -@@ -1821,6 +_,9 @@ +@@ -1756,6 +_,9 @@ public void setCamera(@Nullable Entity p_9214_) { Entity entity = this.getCamera(); this.camera = (Entity)(p_9214_ == null ? this : p_9214_); @@ -120,7 +120,7 @@ if (entity != this.camera) { if (this.camera.level() instanceof ServerLevel serverlevel) { this.teleportTo( -@@ -1859,7 +_,11 @@ +@@ -1794,7 +_,11 @@ @Nullable public Component getTabListDisplayName() { @@ -133,41 +133,29 @@ } public int getTabListOrder() { -@@ -1906,6 +_,9 @@ +@@ -1829,6 +_,7 @@ } - public void setRespawnPosition(ResourceKey p_9159_, @Nullable BlockPos p_9160_, float p_9161_, boolean p_9162_, boolean p_9163_) { -+ if (net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnSet(this, p_9160_ == null ? Level.OVERWORLD : p_9159_, p_9160_, p_9162_)) { -+ return; -+ } - if (p_9160_ != null) { - boolean flag = p_9160_.equals(this.respawnPosition) && p_9159_.equals(this.respawnDimension); - if (p_9163_ && !flag) { -@@ -1963,6 +_,9 @@ - if (itementity == null) { - return null; - } else { -+ if (captureDrops() != null) -+ captureDrops().add(itementity); -+ else - this.level().addFreshEntity(itementity); - ItemStack itemstack = itementity.getItem(); - if (p_9087_) { -@@ -2069,9 +_,12 @@ + public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig p_396560_, boolean p_9162_) { ++ if (net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnSet(this, p_396560_)) return; + if (p_9162_ && p_396560_ != null && !p_396560_.isSamePosition(this.respawnConfig)) { + this.sendSystemMessage(SPAWN_SET_MESSAGE); + } +@@ -1938,9 +_,12 @@ public boolean drop(boolean p_182295_) { Inventory inventory = this.getInventory(); -+ ItemStack selected = inventory.getSelected(); ++ ItemStack selected = inventory.getSelectedItem(); + if (selected.isEmpty() || !selected.onDroppedByPlayer(this)) return false; + if (isUsingItem() && getUsedItemHand() == InteractionHand.MAIN_HAND && (p_182295_ || selected.getCount() == 1)) stopUsingItem(); // Forge: fix MC-231097 on the serverside ItemStack itemstack = inventory.removeFromSelected(p_182295_); - this.containerMenu.findSlot(inventory, inventory.selected).ifPresent(p_287377_ -> this.containerMenu.setRemoteSlot(p_287377_, inventory.getSelected())); + this.containerMenu.findSlot(inventory, inventory.getSelectedSlot()).ifPresent(p_390148_ -> this.containerMenu.setRemoteSlot(p_390148_, inventory.getSelectedItem())); - return this.drop(itemstack, false, true) != null; + return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, itemstack, true) != null; } @Override -@@ -2170,6 +_,75 @@ +@@ -2044,6 +_,75 @@ @Nullable public BlockPos getRaidOmenPosition() { return this.raidOmenPosition; diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 83954ef15a..5d1e15969a 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -31,7 +31,7 @@ public boolean destroyBlock(BlockPos p_9281_) { BlockState blockstate1 = this.level.getBlockState(p_9281_); -- if (!this.player.getMainHandItem().getItem().canAttackBlock(blockstate1, this.level, p_9281_, this.player)) { +- if (!this.player.getMainHandItem().canDestroyBlock(blockstate1, this.level, p_9281_, this.player)) { + int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(level, gameModeForPlayer, player, p_9281_); + if (exp == -1) { return false; @@ -53,7 +53,7 @@ - } - + BlockState blockstate = blockstate1; - if (this.isCreative()) { + if (this.player.preventsBlockDrops()) { + removeBlock(p_9281_, false); return true; } else { @@ -140,5 +140,5 @@ + if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_))) { + if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return InteractionResult.PASS; InteractionResult interactionresult2; - if (this.isCreative()) { + if (p_9266_.hasInfiniteMaterials()) { int i = p_9268_.getCount(); diff --git a/patches/minecraft/net/minecraft/server/level/Ticket.java.patch b/patches/minecraft/net/minecraft/server/level/Ticket.java.patch deleted file mode 100644 index 74a78df937..0000000000 --- a/patches/minecraft/net/minecraft/server/level/Ticket.java.patch +++ /dev/null @@ -1,54 +0,0 @@ ---- a/net/minecraft/server/level/Ticket.java -+++ b/net/minecraft/server/level/Ticket.java -@@ -6,12 +_,18 @@ - private final TicketType type; - private final int ticketLevel; - private final T key; -+ private final boolean forceTicks; - private long createdTick; - - protected Ticket(TicketType p_9425_, int p_9426_, T p_9427_) { -+ this(p_9425_, p_9426_, p_9427_, false); -+ } -+ -+ public Ticket(TicketType p_9425_, int p_9426_, T p_9427_, boolean forceTicks) { - this.type = p_9425_; - this.ticketLevel = p_9426_; - this.key = p_9427_; -+ this.forceTicks = forceTicks; - } - - public int compareTo(Ticket p_9432_) { -@@ -31,18 +_,18 @@ - } else { - return !(p_9439_ instanceof Ticket ticket) - ? false -- : this.ticketLevel == ticket.ticketLevel && Objects.equals(this.type, ticket.type) && Objects.equals(this.key, ticket.key); -+ : this.ticketLevel == ticket.ticketLevel && Objects.equals(this.type, ticket.type) && Objects.equals(this.key, ticket.key) && this.forceTicks == ticket.forceTicks; - } - } - - @Override - public int hashCode() { -- return Objects.hash(this.type, this.ticketLevel, this.key); -+ return Objects.hash(this.type, this.ticketLevel, this.key, this.forceTicks); - } - - @Override - public String toString() { -- return "Ticket[" + this.type + " " + this.ticketLevel + " (" + this.key + ")] at " + this.createdTick; -+ return "Ticket[" + this.type + " " + this.ticketLevel + " (" + this.key + ")] at " + this.createdTick + " force ticks " + forceTicks; - } - - public TicketType getType() { -@@ -51,6 +_,10 @@ - - public int getTicketLevel() { - return this.ticketLevel; -+ } -+ -+ public boolean isForceTicks() { -+ return this.forceTicks; - } - - protected void setCreatedTick(long p_9430_) { diff --git a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 2d3e75da8f..0f672dce8c 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1081,9 +_,10 @@ +@@ -1156,9 +_,10 @@ switch (serverboundplayeractionpacket$action) { case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { @@ -14,7 +14,7 @@ this.player.stopUsingItem(); } -@@ -1281,8 +_,9 @@ +@@ -1356,8 +_,9 @@ } CompletableFuture completablefuture = this.filterTextPacket(playerchatmessage.signedContent()); @@ -25,7 +25,7 @@ PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent(component).filter(p_296589_.mask()); this.broadcastChatMessage(playerchatmessage1); }); -@@ -1607,7 +_,7 @@ +@@ -1693,7 +_,7 @@ @Override public void onInteraction(InteractionHand p_143682_, Vec3 p_143683_) { @@ -34,7 +34,7 @@ } @Override -@@ -1912,6 +_,7 @@ +@@ -1991,6 +_,7 @@ @Override public void handleCustomPayload(ServerboundCustomPayloadPacket p_329963_) { diff --git a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch index 4887867b60..d702d88be2 100644 --- a/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/repository/Pack.java.patch @@ -40,7 +40,7 @@ return this.location.hashCode(); } -- public static record Metadata(Component description, PackCompatibility compatibility, FeatureFlagSet requestedFeatures, List overlays) { +- public record Metadata(Component description, PackCompatibility compatibility, FeatureFlagSet requestedFeatures, List overlays) { + public static record Metadata(Component description, PackCompatibility compatibility, FeatureFlagSet requestedFeatures, List overlays, boolean isHidden) { + public Metadata(Component description, PackCompatibility compatibility, FeatureFlagSet requestedFeatures, List overlays) { + this(description, compatibility, requestedFeatures, overlays, false); diff --git a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch index 2f84974634..5e54ef0ef6 100644 --- a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch @@ -8,23 +8,23 @@ public PlayerList(MinecraftServer p_203842_, LayeredRegistryAccess p_251844_, PlayerDataStorage p_203844_, int p_203845_) { this.server = p_203842_; -@@ -201,6 +_,7 @@ +@@ -204,6 +_,7 @@ servergamepacketlistenerimpl.send(new ClientboundPlayerAbilitiesPacket(p_11263_.getAbilities())); - servergamepacketlistenerimpl.send(new ClientboundSetHeldSlotPacket(p_11263_.getInventory().selected)); + servergamepacketlistenerimpl.send(new ClientboundSetHeldSlotPacket(p_11263_.getInventory().getSelectedSlot())); RecipeManager recipemanager = this.server.getRecipeManager(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.OnDatapackSyncEvent(this, p_11263_)); servergamepacketlistenerimpl.send(new ClientboundUpdateRecipesPacket(recipemanager.getSynchronizedItemProperties(), recipemanager.getSynchronizedStonecutterRecipes())); this.sendPlayerPermissionLevel(p_11263_); p_11263_.getStats().markAllDirty(); -@@ -232,6 +_,7 @@ - p_11263_.loadAndSpawnEnderpearls(optional1); - p_11263_.loadAndSpawnParentVehicle(optional1); +@@ -237,6 +_,7 @@ + p_11263_.loadAndSpawnParentVehicle(p_390188_); + }); p_11263_.initInventoryMenu(); + net.minecraftforge.event.ForgeEventFactory.firePlayerLoggedIn(p_11263_); } protected void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) { -@@ -297,6 +_,7 @@ +@@ -302,6 +_,7 @@ optional = Optional.of(compoundtag); p_11225_.load(compoundtag); LOGGER.debug("loading single player"); @@ -32,7 +32,7 @@ } else { optional = this.playerIo.load(p_11225_); } -@@ -305,6 +_,7 @@ +@@ -310,6 +_,7 @@ } protected void save(ServerPlayer p_11277_) { @@ -40,7 +40,7 @@ this.playerIo.save(p_11277_); ServerStatsCounter serverstatscounter = this.stats.get(p_11277_.getUUID()); if (serverstatscounter != null) { -@@ -318,6 +_,7 @@ +@@ -323,6 +_,7 @@ } public void remove(ServerPlayer p_11287_) { @@ -48,15 +48,15 @@ ServerLevel serverlevel = p_11287_.serverLevel(); p_11287_.awardStat(Stats.LEAVE_GAME); this.save(p_11287_); -@@ -443,6 +_,7 @@ +@@ -448,6 +_,7 @@ this.playersByUUID.put(serverplayer.getUUID(), serverplayer); serverplayer.initInventoryMenu(); serverplayer.setHealth(serverplayer.getHealth()); + net.minecraftforge.event.ForgeEventFactory.firePlayerRespawnEvent(serverplayer, p_11238_); - BlockPos blockpos = serverplayer.getRespawnPosition(); - ServerLevel serverlevel2 = this.server.getLevel(serverplayer.getRespawnDimension()); - if (!p_11238_ && blockpos != null && serverlevel2 != null) { -@@ -549,6 +_,7 @@ + ServerPlayer.RespawnConfig serverplayer$respawnconfig = serverplayer.getRespawnConfig(); + if (!p_11238_ && serverplayer$respawnconfig != null) { + ServerLevel serverlevel2 = this.server.getLevel(serverplayer$respawnconfig.dimension()); +@@ -557,6 +_,7 @@ } public void op(GameProfile p_11254_) { @@ -64,7 +64,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) { -@@ -557,6 +_,7 @@ +@@ -565,6 +_,7 @@ } public void deop(GameProfile p_11281_) { @@ -72,7 +72,7 @@ this.ops.remove(p_11281_); ServerPlayer serverplayer = this.getPlayer(p_11281_.getId()); if (serverplayer != null) { -@@ -770,13 +_,6 @@ +@@ -778,13 +_,6 @@ if (serverstatscounter == null) { File file1 = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR).toFile(); File file2 = new File(file1, uuid + ".json"); @@ -86,7 +86,7 @@ serverstatscounter = new ServerStatsCounter(this.server, file2); this.stats.put(uuid, serverstatscounter); -@@ -821,7 +_,7 @@ +@@ -829,7 +_,7 @@ } public List getPlayers() { @@ -95,7 +95,7 @@ } @Nullable -@@ -838,6 +_,7 @@ +@@ -846,6 +_,7 @@ playeradvancements.reload(this.server.getAdvancements()); } diff --git a/patches/minecraft/net/minecraft/tags/BiomeTags.java.patch b/patches/minecraft/net/minecraft/tags/BiomeTags.java.patch index d20a955c26..90c99016b4 100644 --- a/patches/minecraft/net/minecraft/tags/BiomeTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BiomeTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/BiomeTags.java +++ b/net/minecraft/tags/BiomeTags.java -@@ -82,4 +_,12 @@ +@@ -84,4 +_,12 @@ private static TagKey create(String p_207631_) { return TagKey.create(Registries.BIOME, ResourceLocation.withDefaultNamespace(p_207631_)); } diff --git a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch index 40dec3ec8d..89705caa1b 100644 --- a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/BlockTags.java +++ b/net/minecraft/tags/BlockTags.java -@@ -198,4 +_,12 @@ +@@ -203,4 +_,12 @@ private static TagKey create(String p_203847_) { return TagKey.create(Registries.BLOCK, ResourceLocation.withDefaultNamespace(p_203847_)); } diff --git a/patches/minecraft/net/minecraft/tags/CatVariantTags.java.patch b/patches/minecraft/net/minecraft/tags/CatVariantTags.java.patch deleted file mode 100644 index b8c3003c76..0000000000 --- a/patches/minecraft/net/minecraft/tags/CatVariantTags.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/tags/CatVariantTags.java -+++ b/net/minecraft/tags/CatVariantTags.java -@@ -14,4 +_,12 @@ - private static TagKey create(String p_215846_) { - return TagKey.create(Registries.CAT_VARIANT, ResourceLocation.withDefaultNamespace(p_215846_)); - } -+ -+ public static TagKey create(String namepsace, String path) { -+ return create(ResourceLocation.fromNamespaceAndPath(namepsace, path)); -+ } -+ -+ public static TagKey create(ResourceLocation name) { -+ return TagKey.create(Registries.CAT_VARIANT, name); -+ } - } diff --git a/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch b/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch index abe499b01e..2f774e615f 100644 --- a/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/EntityTypeTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/EntityTypeTags.java +++ b/net/minecraft/tags/EntityTypeTags.java -@@ -44,4 +_,12 @@ +@@ -46,4 +_,12 @@ private static TagKey> create(String p_203849_) { return TagKey.create(Registries.ENTITY_TYPE, ResourceLocation.withDefaultNamespace(p_203849_)); } diff --git a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch index 472a7d87c1..f331a44ef1 100644 --- a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/ItemTags.java +++ b/net/minecraft/tags/ItemTags.java -@@ -185,4 +_,12 @@ +@@ -188,4 +_,12 @@ private static TagKey bind(String p_203855_) { return TagKey.create(Registries.ITEM, ResourceLocation.withDefaultNamespace(p_203855_)); } diff --git a/patches/minecraft/net/minecraft/tags/TagFile.java.patch b/patches/minecraft/net/minecraft/tags/TagFile.java.patch index 4076757e7c..e2cedd49cb 100644 --- a/patches/minecraft/net/minecraft/tags/TagFile.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagFile.java.patch @@ -8,12 +8,12 @@ +public record TagFile(List entries, boolean replace, List remove) { public static final Codec CODEC = RecordCodecBuilder.create( p_215967_ -> p_215967_.group( - TagEntry.CODEC.listOf().fieldOf("values").forGetter(TagFile::entries), -- Codec.BOOL.optionalFieldOf("replace", Boolean.valueOf(false)).forGetter(TagFile::replace) -+ Codec.BOOL.optionalFieldOf("replace", Boolean.valueOf(false)).forGetter(TagFile::replace), -+ TagEntry.CODEC.listOf().optionalFieldOf("remove", List.of()).forGetter(TagFile::remove) - ) - .apply(p_215967_, TagFile::new) + TagEntry.CODEC.listOf().fieldOf("values").forGetter(TagFile::entries), +- Codec.BOOL.optionalFieldOf("replace", false).forGetter(TagFile::replace) ++ Codec.BOOL.optionalFieldOf("replace", false).forGetter(TagFile::replace), ++ TagEntry.CODEC.listOf().optionalFieldOf("remove", List.of()).forGetter(TagFile::remove) + ) + .apply(p_215967_, TagFile::new) ); + + public TagFile(List entries, boolean replace) { diff --git a/patches/minecraft/net/minecraft/tags/TagLoader.java.patch b/patches/minecraft/net/minecraft/tags/TagLoader.java.patch index 420dbc738d..d43786da47 100644 --- a/patches/minecraft/net/minecraft/tags/TagLoader.java.patch +++ b/patches/minecraft/net/minecraft/tags/TagLoader.java.patch @@ -30,19 +30,19 @@ public Map> build(Map> p_203899_) { @@ -111,7 +_,7 @@ - p_358772_ -> LOGGER.error( - "Couldn't load tag {} as it is missing following references: {}", - p_358780_, -- p_358772_.stream().map(Objects::toString).collect(Collectors.joining(", ")) -+ p_358772_.stream().map(Objects::toString).collect(Collectors.joining(", \n\t")) - ) + p_358772_ -> LOGGER.error( + "Couldn't load tag {} as it is missing following references: {}", + p_358780_, +- p_358772_.stream().map(Objects::toString).collect(Collectors.joining(", ")) ++ p_358772_.stream().map(Objects::toString).collect(Collectors.joining(", \n\t")) ) - .ifRight(p_369415_ -> map.put(p_358780_, (List)p_369415_)) + ) + .ifRight(p_369415_ -> map.put(p_358780_, (List)p_369415_)) @@ -188,7 +_,11 @@ } } -- public static record EntryWithSource(TagEntry entry, String source) { +- public 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); diff --git a/patches/minecraft/net/minecraft/util/SpawnUtil.java.patch b/patches/minecraft/net/minecraft/util/SpawnUtil.java.patch index ea52bf708c..11a7ba2411 100644 --- a/patches/minecraft/net/minecraft/util/SpawnUtil.java.patch +++ b/patches/minecraft/net/minecraft/util/SpawnUtil.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/SpawnUtil.java +++ b/net/minecraft/util/SpawnUtil.java -@@ -47,7 +_,7 @@ +@@ -45,7 +_,7 @@ )) { T t = (T)p_216404_.create(p_216406_, null, blockpos$mutableblockpos, p_369127_, false, false); if (t != null) { diff --git a/patches/minecraft/net/minecraft/util/datafix/schemas/V2832.java.patch b/patches/minecraft/net/minecraft/util/datafix/schemas/V2832.java.patch index 33101426bd..755a1e5d2f 100644 --- a/patches/minecraft/net/minecraft/util/datafix/schemas/V2832.java.patch +++ b/patches/minecraft/net/minecraft/util/datafix/schemas/V2832.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/util/datafix/schemas/V2832.java +++ b/net/minecraft/util/datafix/schemas/V2832.java @@ -52,7 +_,7 @@ - DSL.constType(namespacedString()), - DSL.fields( - "generator", -- DSL.taggedChoiceLazy( -+ DSL.or(DSL.taggedChoiceLazy( - "type", - DSL.string(), - ImmutableMap.of( + DSL.constType(namespacedString()), + DSL.fields( + "generator", +- DSL.taggedChoiceLazy( ++ DSL.or(DSL.taggedChoiceLazy( + "type", + DSL.string(), + ImmutableMap.of( @@ -97,7 +_,7 @@ - ) - ) + ) ) -- ) -+ ), DSL.remainder()) // Keep data if the generator type can't be found - ) + ) +- ) ++ ), DSL.remainder()) // Keep data if the generator type can't be found ) ) + ) diff --git a/patches/minecraft/net/minecraft/util/random/WeightedList.java.patch b/patches/minecraft/net/minecraft/util/random/WeightedList.java.patch new file mode 100644 index 0000000000..3ced836c38 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/random/WeightedList.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/util/random/WeightedList.java ++++ b/net/minecraft/util/random/WeightedList.java +@@ -13,7 +_,7 @@ + import net.minecraft.util.ExtraCodecs; + import net.minecraft.util.RandomSource; + +-public final class WeightedList { ++public final class WeightedList implements net.minecraftforge.common.extensions.IForgeWeightedList { + private static final int FLAT_THRESHOLD = 64; + private final int totalWeight; + private final List> items; +@@ -126,7 +_,7 @@ + return 31 * i + this.items.hashCode(); + } + +- public static class Builder { ++ public static class Builder implements net.minecraftforge.common.extensions.IForgeWeightedList.Builder { + private final ImmutableList.Builder> result = ImmutableList.builder(); + + public WeightedList.Builder add(E p_395636_) { diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch index 34813ecc6d..7958de1284 100644 --- a/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch +++ b/patches/minecraft/net/minecraft/world/effect/MobEffect.java.patch @@ -10,7 +10,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); -@@ -57,12 +_,14 @@ +@@ -59,12 +_,14 @@ int i = p_358853_.isAmbient() ? AMBIENT_ALPHA : 255; return ColorParticleOption.create(ParticleTypes.ENTITY_EFFECT, ARGB.color(i, p_19452_)); }; @@ -24,9 +24,9 @@ + initClient(); } - public int getBlendDurationTicks() { -@@ -187,4 +_,28 @@ - return new AttributeModifier(this.id, this.amount * (double)(p_332230_ + 1), this.operation); + public int getBlendInDurationTicks() { +@@ -203,4 +_,28 @@ + return new AttributeModifier(this.id, this.amount * (p_332230_ + 1), this.operation); } } + diff --git a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch index 45189f1a90..bfef156035 100644 --- a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -136,7 +_,7 @@ +@@ -141,7 +_,7 @@ import net.minecraft.world.scores.Team; - import org.slf4j.Logger; + import org.jetbrains.annotations.Contract; --public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder { -+public abstract class Entity extends net.minecraftforge.common.capabilities.CapabilityProvider implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, net.minecraftforge.common.extensions.IForgeEntity { - private static final Logger LOGGER = LogUtils.getLogger(); +-public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter { ++public abstract class Entity extends net.minecraftforge.common.capabilities.CapabilityProvider implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, net.minecraftforge.common.extensions.IForgeEntity { public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -157,6 +_,7 @@ + private static final String DATA_TAG = "data"; +@@ -165,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; @@ -17,7 +17,7 @@ private final EntityType type; private int id = ENTITY_COUNTER.incrementAndGet(); public boolean blocksBuilding; -@@ -201,8 +_,10 @@ +@@ -208,8 +_,10 @@ public int tickCount; private int remainingFireTicks = -this.getFireImmuneTicks(); protected boolean wasTouchingWater; @@ -28,15 +28,15 @@ private final Set> fluidOnEyes = new HashSet<>(); public int invulnerableTime; protected boolean firstTick = true; -@@ -251,6 +_,7 @@ - private final LongSet visitedBlocks = new LongOpenHashSet(); +@@ -260,6 +_,7 @@ + private CustomData customData = CustomData.EMPTY; public Entity(EntityType p_19870_, Level p_19871_) { + super(Entity.class); this.type = p_19870_; this.level = p_19871_; this.dimensions = p_19870_.getDimensions(); -@@ -270,6 +_,8 @@ +@@ -279,6 +_,8 @@ this.entityData = synchedentitydata$builder.build(); this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); @@ -45,7 +45,7 @@ } public boolean isColliding(BlockPos p_20040_, BlockState p_20041_) { -@@ -357,6 +_,7 @@ +@@ -365,6 +_,7 @@ public void remove(Entity.RemovalReason p_146834_) { this.setRemoved(p_146834_); @@ -53,42 +53,27 @@ } public void onClientRemoval() { -@@ -480,7 +_,7 @@ +@@ -482,7 +_,7 @@ + } if (this.isInLava()) { - this.lavaHurt(); -- this.fallDistance *= 0.5F; +- this.fallDistance *= 0.5; + this.fallDistance *= this.getFluidFallDistanceModifier(net.minecraftforge.common.ForgeMod.LAVA_TYPE.get()); } this.checkBelowWorld(); -@@ -779,12 +_,12 @@ - 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(); - } - } - -- 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()); - } - } -@@ -864,9 +_,7 @@ +@@ -912,9 +_,7 @@ return blockpos; } else { BlockState blockstate = this.level().getBlockState(blockpos); -- return (!((double)p_216987_ <= 0.5) || !blockstate.is(BlockTags.FENCES)) +- return (!(p_216987_ <= 0.5) || !blockstate.is(BlockTags.FENCES)) - && !blockstate.is(BlockTags.WALLS) - && !(blockstate.getBlock() instanceof FenceGateBlock) + return (!((double)p_216987_ <= 0.5) || !blockstate.collisionExtendsVertically(this.level(), blockpos, this)) - ? blockpos.atY(Mth.floor(this.position.y - (double)p_216987_)) + ? blockpos.atY(Mth.floor(this.position.y - p_216987_)) : blockpos; } -@@ -1150,19 +_,19 @@ +@@ -1193,19 +_,19 @@ return !blockstate.is(BlockTags.INSIDE_STEP_SOUND_BLOCKS) && !blockstate.is(BlockTags.COMBINATION_STEP_SOUND_BLOCKS) ? p_278049_ : blockpos; } @@ -114,7 +99,7 @@ this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch()); } -@@ -1290,6 +_,10 @@ +@@ -1338,6 +_,10 @@ return this.wasTouchingWater; } @@ -122,10 +107,10 @@ + return this.isInWater() || isInFluidType((fluidType, height) -> canSwimInFluidType(fluidType)); + } + - private boolean isInRain() { + boolean isInRain() { BlockPos blockpos = this.blockPosition(); return this.level().isRainingAt(blockpos) -@@ -1322,27 +_,33 @@ +@@ -1358,24 +_,32 @@ public void updateSwimming() { if (this.isSwimming()) { @@ -155,36 +140,34 @@ + java.util.function.BooleanSupplier updateFluidHeight = () -> this.updateFluidHeightAndDoFluidPushing(FluidTags.WATER, 0.014D); if (this.getVehicle() instanceof AbstractBoat abstractboat && !abstractboat.isUnderWater()) { - this.wasTouchingWater = false; -- return; +- } else if (this.updateFluidHeightAndDoFluidPushing(FluidTags.WATER, 0.014)) { + updateFluidHeight = () -> { + this.updateFluidHeightAndDoFluidPushing(state -> this.shouldUpdateFluidWhileBoating(state, abstractboat)); + return false; + }; - } - -- if (this.updateFluidHeightAndDoFluidPushing(FluidTags.WATER, 0.014)) { ++ } + if (updateFluidHeight.getAsBoolean()) { if (!this.wasTouchingWater && !this.firstTick) { this.doWaterSplashEffect(); } -@@ -1358,6 +_,7 @@ +@@ -1390,6 +_,7 @@ private void updateFluidOnEyes() { this.wasEyeInWater = this.isEyeInFluid(FluidTags.WATER); this.fluidOnEyes.clear(); + this.forgeFluidTypeOnEyes = net.minecraftforge.common.ForgeMod.EMPTY_TYPE.get(); double d0 = this.getEyeY(); - if (this.getVehicle() instanceof AbstractBoat abstractboat - && !abstractboat.isUnderWater() -@@ -1370,7 +_,7 @@ - FluidState fluidstate = this.level().getFluidState(blockpos); - double d1 = (double)((float)blockpos.getY() + fluidstate.getHeight(this.level(), blockpos)); - if (d1 > d0) { -- fluidstate.getTags().forEach(this.fluidOnEyes::add); -+ this.forgeFluidTypeOnEyes = fluidstate.getFluidType(); + if (!( + this.getVehicle() instanceof AbstractBoat abstractboat +@@ -1401,7 +_,7 @@ + FluidState fluidstate = this.level().getFluidState(blockpos); + double d1 = blockpos.getY() + fluidstate.getHeight(this.level(), blockpos); + if (d1 > d0) { +- fluidstate.getTags().forEach(this.fluidOnEyes::add); ++ this.forgeFluidTypeOnEyes = fluidstate.getFluidType(); + } } } - -@@ -1424,12 +_,13 @@ +@@ -1455,12 +_,13 @@ } public boolean canSpawnSprintParticle() { @@ -199,7 +182,7 @@ if (blockstate.getRenderShape() != RenderShape.INVISIBLE) { Vec3 vec3 = this.getDeltaMovement(); BlockPos blockpos1 = this.blockPosition(); -@@ -1445,7 +_,7 @@ +@@ -1476,7 +_,7 @@ this.level() .addParticle( @@ -208,7 +191,7 @@ d0, this.getY() + 0.1, d1, -@@ -1456,12 +_,15 @@ +@@ -1487,12 +_,15 @@ } } @@ -225,7 +208,7 @@ } public void moveRelative(float p_19921_, Vec3 p_19922_) { -@@ -1831,6 +_,11 @@ +@@ -1862,6 +_,11 @@ p_20241_.putBoolean("HasVisualFire", this.hasVisualFire); } @@ -235,28 +218,28 @@ + if (persistentData != null) p_20241_.put("ForgeData", persistentData.copy()); + if (!this.tags.isEmpty()) { - ListTag listtag = new ListTag(); - -@@ -1924,6 +_,9 @@ - this.setGlowingTag(p_20259_.getBoolean("Glowing")); - this.setTicksFrozen(p_20259_.getInt("TicksFrozen")); - this.hasVisualFire = p_20259_.getBoolean("HasVisualFire"); -+ if (p_20259_.contains("ForgeData", 10)) persistentData = p_20259_.getCompound("ForgeData"); -+ if (p_20259_.contains("CanUpdate", 99)) this.canUpdate(p_20259_.getBoolean("CanUpdate")); -+ if (p_20259_.contains("ForgeCaps", 10)) deserializeCaps(this.registryAccess(), p_20259_.getCompound("ForgeCaps")); - if (p_20259_.contains("Tags", 9)) { - this.tags.clear(); - ListTag listtag3 = p_20259_.getList("Tags", 8); -@@ -2006,6 +_,8 @@ + p_20241_.store("Tags", TAG_LIST_CODEC, List.copyOf(this.tags)); + } +@@ -1940,6 +_,9 @@ + this.setGlowingTag(p_20259_.getBooleanOr("Glowing", false)); + this.setTicksFrozen(p_20259_.getIntOr("TicksFrozen", 0)); + this.hasVisualFire = p_20259_.getBooleanOr("HasVisualFire", false); ++ p_20259_.getCompound("ForgeData").ifPresent(data -> this.persistentData = data); ++ p_20259_.getBoolean("CanUpdate").ifPresent(this::canUpdate); ++ p_20259_.getCompound("ForgeCaps").ifPresent(caps -> this.deserializeCaps(this.registryAccess(), caps)); + this.customData = p_20259_.read("data", CustomData.CODEC).orElse(CustomData.EMPTY); + this.tags.clear(); + p_20259_.read("Tags", TAG_LIST_CODEC).ifPresent(this.tags::addAll); +@@ -1995,6 +_,8 @@ } else { - ItemEntity itementity = new ItemEntity(p_364149_, this.getX(), this.getY() + (double)p_367722_, this.getZ(), p_366908_); + ItemEntity itementity = new ItemEntity(p_364149_, this.getX(), this.getY() + p_367722_, this.getZ(), p_366908_); itementity.setDefaultPickUpDelay(); + if (captureDrops() != null) captureDrops().add(itementity); + else p_364149_.addFreshEntity(itementity); return itementity; } -@@ -2078,6 +_,7 @@ +@@ -2062,6 +_,7 @@ public void rideTick() { this.setDeltaMovement(Vec3.ZERO); @@ -264,7 +247,7 @@ this.tick(); if (this.isPassenger()) { this.getVehicle().positionRider(this); -@@ -2138,6 +_,7 @@ +@@ -2122,6 +_,7 @@ } } @@ -272,7 +255,7 @@ if (p_19967_ || this.canRide(p_19966_) && p_19966_.canAddPassenger(this)) { if (this.isPassenger()) { this.stopRiding(); -@@ -2169,6 +_,7 @@ +@@ -2153,6 +_,7 @@ public void removeVehicle() { if (this.vehicle != null) { Entity entity = this.vehicle; @@ -280,7 +263,7 @@ this.vehicle = null; entity.removePassenger(this); } -@@ -2218,6 +_,8 @@ +@@ -2202,6 +_,8 @@ return this.passengers.isEmpty(); } @@ -289,7 +272,7 @@ protected boolean couldAcceptPassenger() { return true; } -@@ -2406,7 +_,7 @@ +@@ -2381,7 +_,7 @@ } public boolean isVisuallyCrawling() { @@ -298,7 +281,7 @@ } public void setSwimming(boolean p_20283_) { -@@ -2519,7 +_,7 @@ +@@ -2498,7 +_,7 @@ this.igniteForSeconds(8.0F); } @@ -306,8 +289,8 @@ + this.hurtServer(p_19927_, this.damageSources().lightningBolt(), p_19928_.getDamage()); } - public void onAboveBubbleCol(boolean p_20313_) { -@@ -2614,7 +_,7 @@ + public void onAboveBubbleColumn(boolean p_392709_, BlockPos p_391902_) { +@@ -2631,7 +_,7 @@ } protected Component getTypeName() { @@ -316,7 +299,7 @@ } public boolean is(Entity p_20356_) { -@@ -2907,6 +_,7 @@ +@@ -2919,6 +_,7 @@ return this.stringUUID; } @@ -324,7 +307,7 @@ public boolean isPushedByFluid() { return true; } -@@ -3307,9 +_,17 @@ +@@ -3325,9 +_,17 @@ return Mth.lerp(p_344421_, this.yRotO, this.yRot); } @@ -343,7 +326,7 @@ } else { AABB aabb = this.getBoundingBox().deflate(0.001); int i = Mth.floor(aabb.minX); -@@ -3324,25 +_,28 @@ +@@ -3342,25 +_,28 @@ Vec3 vec3 = Vec3.ZERO; int k1 = 0; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); @@ -357,7 +340,7 @@ - if (fluidstate.is(p_204032_)) { + net.minecraftforge.fluids.FluidType fluidType = fluidstate.getFluidType(); + if (!fluidType.isAir() && shouldUpdate.test(fluidstate)) { - double d1 = (double)((float)i2 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos)); + double d1 = i2 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos); if (d1 >= aabb.minY) { flag1 = true; - d0 = Math.max(d1 - aabb.minY, d0); @@ -379,13 +362,13 @@ } } } -@@ -3350,27 +_,28 @@ +@@ -3368,27 +_,28 @@ } } - if (vec3.length() > 0.0) { - if (k1 > 0) { -- vec3 = vec3.scale(1.0 / (double)k1); +- vec3 = vec3.scale(1.0 / k1); + interimCalcs.forEach((fluidType, interim) -> { + if (interim.getMiddle().length() > 0.0D) { + if (interim.getRight() > 0) { @@ -418,7 +401,7 @@ } } -@@ -3383,7 +_,10 @@ +@@ -3401,7 +_,10 @@ return !this.level().hasChunksAt(i, k, j, l); } @@ -429,7 +412,7 @@ return this.fluidHeight.getDouble(p_204037_); } -@@ -3399,7 +_,9 @@ +@@ -3417,7 +_,9 @@ return this.dimensions.height(); } @@ -439,7 +422,7 @@ return new ClientboundAddEntityPacket(this, p_344981_); } -@@ -3520,6 +_,11 @@ +@@ -3538,6 +_,11 @@ this.levelCallback.onMove(); } @@ -451,8 +434,8 @@ } public void checkDespawn() { -@@ -3672,6 +_,100 @@ - float f1 = (float)Mth.lerp(d0, (double)this.getXRot(), p_298926_); +@@ -3693,6 +_,100 @@ + float f1 = (float)Mth.lerp(d0, this.getXRot(), p_298926_); this.setPos(d1, d2, d3); this.setRot(f, f1); + } @@ -490,7 +473,7 @@ + } + + @Override -+ public boolean canTrample(ServerLevel level, BlockState state, BlockPos pos, float fallDistance) { ++ public boolean canTrample(ServerLevel level, BlockState state, BlockPos pos, double fallDistance) { + return level.random.nextFloat() < fallDistance - 0.5F + && this instanceof LivingEntity + && (this instanceof Player || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(level, this)) diff --git a/patches/minecraft/net/minecraft/world/entity/EntityEquipment.java.patch b/patches/minecraft/net/minecraft/world/entity/EntityEquipment.java.patch new file mode 100644 index 0000000000..d03973831f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/EntityEquipment.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/entity/EntityEquipment.java ++++ b/net/minecraft/world/entity/EntityEquipment.java +@@ -50,7 +_,7 @@ + for (Entry entry : this.items.entrySet()) { + ItemStack itemstack = entry.getValue(); + if (!itemstack.isEmpty()) { +- itemstack.inventoryTick(p_394224_.level(), p_394224_, entry.getKey()); ++ itemstack.inventoryTick(p_394224_.level(), p_394224_, entry.getKey(), -1); + } + } + } +@@ -70,5 +_,9 @@ + + public void clear() { + this.items.replaceAll((p_393205_, p_394162_) -> ItemStack.EMPTY); ++ } ++ ++ public int size() { ++ return this.items.size(); + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch index e9b2151182..0d5dafa1c7 100644 --- a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch +++ b/patches/minecraft/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 -@@ -867,6 +_,11 @@ +@@ -877,6 +_,11 @@ private final float spawnDimensionsScale; private final FeatureFlagSet requiredFeatures; @@ -12,7 +12,7 @@ private static EntityType register(ResourceKey> p_368406_, EntityType.Builder p_363129_) { return Registry.register(BuiltInRegistries.ENTITY_TYPE, p_368406_, p_363129_.build(p_368406_)); } -@@ -901,7 +_,8 @@ +@@ -911,7 +_,8 @@ int p_273451_, String p_367006_, Optional> p_364691_, @@ -22,7 +22,7 @@ ) { this.factory = p_273268_; this.category = p_272918_; -@@ -917,6 +_,10 @@ +@@ -927,6 +_,10 @@ this.descriptionId = p_367006_; this.lootTable = p_364691_; this.requiredFeatures = p_273518_; @@ -33,7 +33,7 @@ } @Nullable -@@ -1193,14 +_,26 @@ +@@ -1181,14 +_,26 @@ } public int clientTrackingRange() { @@ -60,7 +60,7 @@ return this != PLAYER && this != LLAMA_SPIT && this != WITHER -@@ -1256,6 +_,12 @@ +@@ -1244,6 +_,12 @@ return OP_ONLY_CUSTOM_DATA.contains(this); } @@ -73,10 +73,10 @@ public static class Builder { private final EntityType.EntityFactory factory; private final MobCategory category; -@@ -1274,6 +_,10 @@ - ResourceKey.create(Registries.LOOT_TABLE, p_358877_.location().withPrefix("entities/")) - ); - private DependantName, String> descriptionId = p_358878_ -> Util.makeDescriptionId("entity", p_358878_.location()); +@@ -1262,6 +_,10 @@ + ResourceKey.create(Registries.LOOT_TABLE, p_358877_.location().withPrefix("entities/")) + ); + private final DependantName, String> descriptionId = p_358878_ -> Util.makeDescriptionId("entity", p_358878_.location()); + private java.util.function.Predicate> velocityUpdateSupplier = EntityType::defaultVelocitySupplier; + private java.util.function.ToIntFunction> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier; + private java.util.function.ToIntFunction> updateIntervalSupplier = EntityType::defaultUpdateIntervalSupplier; @@ -84,7 +84,7 @@ private Builder(EntityType.EntityFactory p_20696_, MobCategory p_20697_) { this.factory = p_20696_; -@@ -1387,6 +_,30 @@ +@@ -1375,6 +_,30 @@ return this; } @@ -115,7 +115,7 @@ public EntityType build(ResourceKey> p_369693_) { if (this.serialize) { Util.fetchChoiceType(References.ENTITY_TREE, p_369693_.location().toString()); -@@ -1406,7 +_,8 @@ +@@ -1394,7 +_,8 @@ this.updateInterval, this.descriptionId.get(p_369693_), this.lootTable.get(p_369693_), diff --git a/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch index 31a1de102e..53ccf9fcc9 100644 --- a/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -112,7 +_,8 @@ - this.applyEffectsFromBlocks(); - float f = 0.98F; - if (this.onGround()) { -- f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; -+ BlockPos pos = getBlockPosBelowThatAffectsMyMovement(); -+ f = this.level().getBlockState(pos).getFriction(this.level(), pos, this) * 0.98F; - } +@@ -109,7 +_,8 @@ + this.applyEffectsFromBlocks(); + float f = 0.98F; + if (this.onGround()) { +- f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; ++ BlockPos pos = getBlockPosBelowThatAffectsMyMovement(); ++ f = this.level().getBlockState(pos).getFriction(this.level(), pos, this) * 0.98F; + } - this.setDeltaMovement(this.getDeltaMovement().multiply((double)f, 0.98, (double)f)); -@@ -231,6 +_,7 @@ + this.setDeltaMovement(this.getDeltaMovement().scale(f)); +@@ -247,6 +_,7 @@ public void playerTouch(Player p_20792_) { if (p_20792_ instanceof ServerPlayer serverplayer) { if (p_20792_.takeXpDelay == 0) { + if (net.minecraftforge.event.ForgeEventFactory.onPlayerPickupXp(p_20792_, this)) return; p_20792_.takeXpDelay = 2; p_20792_.take(this, 1); - int i = this.repairPlayerItems(serverplayer, this.value); + int i = this.repairPlayerItems(serverplayer, this.getValue()); diff --git a/patches/minecraft/net/minecraft/world/entity/FlyingMob.java.patch b/patches/minecraft/net/minecraft/world/entity/FlyingMob.java.patch index b60e5c8aec..5efbdd8d6d 100644 --- a/patches/minecraft/net/minecraft/world/entity/FlyingMob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/FlyingMob.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/entity/FlyingMob.java +++ b/net/minecraft/world/entity/FlyingMob.java -@@ -26,15 +_,16 @@ - this.move(MoverType.SELF, this.getDeltaMovement()); - this.setDeltaMovement(this.getDeltaMovement().scale(0.5)); - } else { +@@ -25,15 +_,16 @@ + this.move(MoverType.SELF, this.getDeltaMovement()); + this.setDeltaMovement(this.getDeltaMovement().scale(0.5)); + } else { + BlockPos ground = getBlockPosBelowThatAffectsMyMovement(); - float f = 0.91F; - if (this.onGround()) { -- f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.91F; -+ f = this.level().getBlockState(ground).getFriction(this.level(), ground, this) * 0.91F; - } + float f = 0.91F; + if (this.onGround()) { +- f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.91F; ++ f = this.level().getBlockState(ground).getFriction(this.level(), ground, this) * 0.91F; + } - float f1 = 0.16277137F / (f * f * f); - f = 0.91F; - if (this.onGround()) { -- f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.91F; -+ f = this.level().getBlockState(ground).getFriction(this.level(), ground, this) * 0.91F; - } + float f1 = 0.16277137F / (f * f * f); + f = 0.91F; + if (this.onGround()) { +- f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.91F; ++ f = this.level().getBlockState(ground).getFriction(this.level(), ground, this) * 0.91F; + } - this.moveRelative(this.onGround() ? 0.1F * f1 : 0.02F, p_20818_); + this.moveRelative(this.onGround() ? 0.1F * f1 : 0.02F, p_20818_); diff --git a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch index 70f30e1f2b..222e49566e 100644 --- a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -136,7 +_,7 @@ - import net.minecraft.world.scores.Scoreboard; +@@ -135,7 +_,7 @@ + import org.jetbrains.annotations.Contract; import org.slf4j.Logger; -public abstract class LivingEntity extends Entity implements Attackable { @@ -9,16 +9,16 @@ 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"); -@@ -172,6 +_,8 @@ +@@ -171,6 +_,8 @@ 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"; + /** Forge: Use a variant that calls {@link ItemStack#isMonsterDisguise(Player, net.minecraft.world.entity.monster.Monster)} and {@link net.minecraftforge.event.entity.living.MonsterDisguiseEvent} */ + @Deprecated - public static final Predicate PLAYER_NOT_WEARING_DISGUISE_ITEM = p_358894_ -> { - if (p_358894_ instanceof Player player) { + public static final Predicate PLAYER_NOT_WEARING_DISGUISE_ITEM = p_390518_ -> { + if (p_390518_ instanceof Player player) { ItemStack itemstack = player.getItemBySlot(EquipmentSlot.HEAD); -@@ -270,7 +_,8 @@ +@@ -254,7 +_,8 @@ this.setYRot((float)(Math.random() * (float) (Math.PI * 2))); this.yHeadRot = this.getYRot(); NbtOps nbtops = NbtOps.INSTANCE; @@ -27,8 +27,8 @@ + this.brain = net.minecraftforge.common.ForgeHooks.onLivingMakeBrain(this, this.makeBrain(dyn), dyn); } - public Brain getBrain() { -@@ -324,7 +_,8 @@ + @Contract( +@@ -315,7 +_,8 @@ .add(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE) .add(Attributes.WATER_MOVEMENT_EFFICIENCY) .add(Attributes.MOVEMENT_EFFICIENCY) @@ -38,17 +38,17 @@ } @Override -@@ -352,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); +@@ -342,7 +_,8 @@ + + double d7 = Math.min(0.2F + d6 / 15.0, 2.5); + int i = (int)(150.0 * d7); - 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); } } -@@ -362,6 +_,7 @@ +@@ -352,6 +_,7 @@ } } @@ -56,7 +56,7 @@ public final boolean canBreatheUnderwater() { return this.getType().is(EntityTypeTags.CAN_BREATHE_UNDER_WATER); } -@@ -408,6 +_,10 @@ +@@ -396,6 +_,10 @@ } } @@ -65,37 +65,42 @@ + net.minecraftforge.common.ForgeHooks.onLivingBreathe(this, airSupply - decreaseAirSupply(airSupply), increaseAirSupply(airSupply) - airSupply); + if (false) // Forge: Handled in ForgeHooks#onLivingBreathe(LivingEntity, int, int) if (this.isEyeInFluid(FluidTags.WATER) - && !this.level().getBlockState(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())).is(Blocks.BUBBLE_COLUMN)) { + && !serverlevel1.getBlockState(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())).is(Blocks.BUBBLE_COLUMN)) { boolean flag1 = !this.canBreatheUnderwater() && !MobEffectUtil.hasWaterBreathing(this) && (!flag || !((Player)this).getAbilities().invulnerable); -@@ -455,7 +_,7 @@ +@@ -731,6 +_,9 @@ + } else { + ItemEntity itementity = this.createItemStackToDrop(p_395943_, p_393118_, p_392158_); + if (itementity != null) { ++ if (captureDrops() != null) ++ captureDrops().add(itementity); ++ else + this.level().addFreshEntity(itementity); } - } -- if (this.isAlive() && (this.isInWaterRainOrBubble() || this.isInPowderSnow)) { -+ if (this.isAlive() && (this.isInWaterRainOrBubble() || this.isInPowderSnow || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { - this.extinguishFire(); - } - -@@ -782,7 +_,8 @@ - } - - if (p_21096_.contains("Brain", 10)) { -- this.brain = this.makeBrain(new Dynamic<>(NbtOps.INSTANCE, p_21096_.get("Brain"))); -+ var dyn = new Dynamic<>(NbtOps.INSTANCE, p_21096_.get("Brain")); +@@ -773,7 +_,10 @@ + this.setPosToBed(p_390515_); + } + }, this::clearSleepingPos); +- p_21096_.getCompound("Brain").ifPresent(p_390523_ -> this.brain = this.makeBrain(new Dynamic<>(NbtOps.INSTANCE, p_390523_))); ++ p_21096_.getCompound("Brain").ifPresent(p_390523_ -> { ++ var dyn = new Dynamic<>(NbtOps.INSTANCE, p_390523_); + this.brain = net.minecraftforge.common.ForgeHooks.onLivingMakeBrain(this, this.makeBrain(dyn), dyn); - } - } - -@@ -794,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.minecraftforge.event.ForgeEventFactory.onLivingEffectExpire(this, mobeffectinstance)) { ++ }); + this.lastHurtByPlayer = EntityReference.read(p_21096_, "last_hurt_by_player"); + this.lastHurtByPlayerMemoryTime = p_21096_.getIntOr("last_hurt_by_player_memory_time", 0); + this.lastHurtByMob = EntityReference.read(p_21096_, "last_hurt_by_mob"); +@@ -790,8 +_,10 @@ + Holder holder = iterator.next(); + MobEffectInstance mobeffectinstance = this.activeEffects.get(holder); + if (!mobeffectinstance.tickServer(serverlevel, this, () -> this.onEffectUpdated(mobeffectinstance, true, null))) { ++ if (!net.minecraftforge.event.ForgeEventFactory.onLivingEffectExpire(this, mobeffectinstance)) { iterator.remove(); this.onEffectsRemoved(List.of(mobeffectinstance)); ++ } + } else if (mobeffectinstance.getDuration() % 600 == 0) { + this.onEffectUpdated(mobeffectinstance, false, null); } -@@ -875,6 +_,7 @@ +@@ -871,6 +_,7 @@ } } @@ -103,7 +108,7 @@ return d0; } -@@ -944,6 +_,7 @@ +@@ -945,6 +_,7 @@ } else { MobEffectInstance mobeffectinstance = this.activeEffects.get(p_147208_.getEffect()); boolean flag = false; @@ -111,7 +116,7 @@ if (mobeffectinstance == null) { this.activeEffects.put(p_147208_.getEffect(), p_147208_); this.onEffectAdded(p_147208_, p_147209_); -@@ -960,6 +_,10 @@ +@@ -961,6 +_,10 @@ } public boolean canBeAffected(MobEffectInstance p_21197_) { @@ -122,7 +127,7 @@ if (this.getType().is(EntityTypeTags.IMMUNE_TO_INFESTED)) { return !p_21197_.is(MobEffects.INFESTED); } else if (this.getType().is(EntityTypeTags.IMMUNE_TO_OOZING)) { -@@ -993,6 +_,9 @@ +@@ -994,6 +_,9 @@ } public boolean removeEffect(Holder p_335910_) { @@ -132,9 +137,9 @@ MobEffectInstance mobeffectinstance = this.removeEffectNoUpdate(p_335910_); if (mobeffectinstance != null) { this.onEffectsRemoved(List.of(mobeffectinstance)); -@@ -1036,6 +_,9 @@ - this.effectsDirty = true; - if (!this.level().isClientSide) { +@@ -1038,6 +_,9 @@ + this.effectsDirty = true; + for (MobEffectInstance mobeffectinstance : p_364717_) { + if (net.minecraftforge.event.ForgeEventFactory.onLivingEffectRemove(this, mobeffectinstance)) { + continue; @@ -142,7 +147,7 @@ mobeffectinstance.getEffect().value().removeAttributeModifiers(this.getAttributes()); for (Entity entity : this.getPassengers()) { -@@ -1074,6 +_,10 @@ +@@ -1078,6 +_,10 @@ } public void heal(float p_21116_) { @@ -153,7 +158,7 @@ float f = this.getHealth(); if (f > 0.0F) { this.setHealth(f + p_21116_); -@@ -1094,6 +_,9 @@ +@@ -1098,6 +_,9 @@ @Override public boolean hurtServer(ServerLevel p_361743_, DamageSource p_361865_, float p_365677_) { @@ -163,47 +168,27 @@ if (this.isInvulnerableTo(p_361743_, p_361865_)) { return false; } else if (this.isDeadOrDying()) { -@@ -1114,14 +_,18 @@ - boolean flag = false; - float f1 = 0.0F; - if (p_365677_ > 0.0F && this.isDamageSourceBlocked(p_361865_)) { -+ var ev = net.minecraftforge.event.ForgeEventFactory.onShieldBlock(this, p_361865_, p_365677_); -+ if (!ev.isCanceled()) { -+ if (ev.shieldTakesDamage()) - this.hurtCurrentlyUsedShield(p_365677_); -- f1 = p_365677_; -- p_365677_ = 0.0F; -+ f1 = ev.getBlockedDamage(); -+ p_365677_ -= ev.getBlockedDamage(); - if (!p_361865_.is(DamageTypeTags.IS_PROJECTILE) && p_361865_.getDirectEntity() instanceof LivingEntity livingentity) { - this.blockUsingShield(livingentity); - } +@@ -1244,6 +_,10 @@ + } -- flag = true; -+ flag = p_365677_ <= 0; -+ } - } - - if (p_361865_.is(DamageTypeTags.IS_FREEZING) && this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { -@@ -1212,7 +_,7 @@ - if (this instanceof ServerPlayer serverplayer) { - CriteriaTriggers.ENTITY_HURT_PLAYER.trigger(serverplayer, p_361865_, f, p_365677_, flag); - if (f1 > 0.0F && f1 < 3.4028235E37F) { -- serverplayer.awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, Math.round(f1 * 10.0F)); -+ ((ServerPlayer)this).awardStat(Stats.CUSTOM.get(Stats.DAMAGE_BLOCKED_BY_SHIELD), Math.round(f1 * 10.0F)); - } - } - -@@ -1240,7 +_,7 @@ - this.lastHurtByPlayer = player; - return player; - } else { -- if (entity instanceof Wolf wolf && wolf.isTame()) { -+ if (entity instanceof net.minecraft.world.entity.TamableAnimal wolf && wolf.isTame()) { - this.lastHurtByPlayerTime = 100; - if (wolf.getOwner() instanceof Player player1) { - this.lastHurtByPlayer = player1; -@@ -1273,7 +_,7 @@ + float f = blocksattacks.resolveBlockedDamage(p_392511_, p_394545_, d0); ++ var ev = net.minecraftforge.event.ForgeEventFactory.onShieldBlock(this, p_392511_, f, itemstack); ++ if (ev.isCanceled()) return 0.0F; ++ f = ev.getBlockedDamage(); ++ if (ev.shieldTakesDamage()) + blocksattacks.hurtBlockingItem(this.level(), itemstack, this, this.getUsedItemHand(), f); + if (!p_392511_.is(DamageTypeTags.IS_PROJECTILE) && p_392511_.getDirectEntity() instanceof LivingEntity livingentity) { + this.blockUsingItem(p_396198_, livingentity); +@@ -1278,7 +_,7 @@ + Entity entity = p_378258_.getEntity(); + if (entity instanceof Player player) { + this.setLastHurtByPlayer(player, 100); +- } else if (entity instanceof Wolf wolf && wolf.isTame()) { ++ } else if (entity instanceof net.minecraft.world.entity.TamableAnimal wolf && wolf.isTame()) { + if (wolf.getOwnerReference() != null) { + this.setLastHurtByPlayer(wolf.getOwnerReference().getUUID(), 100); + } else { +@@ -1308,7 +_,7 @@ for (InteractionHand interactionhand : InteractionHand.values()) { ItemStack itemstack1 = this.getItemInHand(interactionhand); deathprotection = itemstack1.get(DataComponents.DEATH_PROTECTION); @@ -212,7 +197,7 @@ itemstack = itemstack1.copy(); itemstack1.shrink(1); break; -@@ -1357,6 +_,7 @@ +@@ -1372,6 +_,7 @@ } public void die(DamageSource p_21014_) { @@ -220,7 +205,7 @@ if (!this.isRemoved() && !this.dead) { Entity entity = p_21014_.getEntity(); LivingEntity livingentity = this.getKillCredit(); -@@ -1392,10 +_,10 @@ +@@ -1407,10 +_,10 @@ if (this.level() instanceof ServerLevel serverlevel) { boolean flag = false; if (p_21269_ instanceof WitherBoss) { @@ -233,37 +218,37 @@ this.level().setBlock(blockpos, blockstate, 3); flag = true; } -@@ -1410,6 +_,7 @@ +@@ -1425,6 +_,7 @@ } protected void dropAllDeathLoot(ServerLevel p_342160_, DamageSource p_21192_) { + this.captureDrops(new java.util.ArrayList<>()); - boolean flag = this.lastHurtByPlayerTime > 0; + boolean flag = this.lastHurtByPlayerMemoryTime > 0; if (this.shouldDropLoot() && p_342160_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { this.dropFromLootTable(p_342160_, p_21192_, flag); -@@ -1418,6 +_,11 @@ +@@ -1433,6 +_,11 @@ this.dropEquipment(p_342160_); this.dropExperience(p_342160_, p_21192_.getEntity()); + + var drops = captureDrops(null); -+ if (!net.minecraftforge.event.ForgeEventFactory.onLivingDrops(this, p_21192_, drops, lastHurtByPlayerTime > 0)) { ++ if (!net.minecraftforge.event.ForgeEventFactory.onLivingDrops(this, p_21192_, drops, flag)) { + drops.forEach(e -> level().addFreshEntity(e)); + } } protected void dropEquipment(ServerLevel p_365823_) { -@@ -1425,7 +_,8 @@ +@@ -1440,7 +_,8 @@ protected void dropExperience(ServerLevel p_370040_, @Nullable Entity p_342525_) { - if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && p_370040_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { + if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && p_370040_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { - ExperienceOrb.award(p_370040_, this.position(), this.getExperienceReward(p_370040_, p_342525_)); -+ int reward = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.lastHurtByPlayer, this.getExperienceReward(p_370040_, p_342525_)); ++ int reward = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.getLastHurtByPlayer(), this.getExperienceReward(p_370040_, p_342525_)); + ExperienceOrb.award(p_370040_, this.position(), reward); } } -@@ -1501,6 +_,11 @@ +@@ -1517,6 +_,11 @@ } public void knockback(double p_147241_, double p_147242_, double p_147243_) { @@ -275,7 +260,7 @@ p_147241_ *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); if (!(p_147241_ <= 0.0)) { this.hasImpulse = true; -@@ -1582,6 +_,13 @@ +@@ -1594,6 +_,13 @@ } else { BlockPos blockpos = this.blockPosition(); BlockState blockstate = this.getInBlockState(); @@ -289,18 +274,18 @@ if (blockstate.is(BlockTags.CLIMBABLE)) { this.lastClimbablePos = Optional.of(blockpos); return true; -@@ -1636,6 +_,10 @@ +@@ -1648,6 +_,10 @@ @Override - public boolean causeFallDamage(float p_147187_, float p_147188_, DamageSource p_147189_) { -+ var event = net.minecraftforge.event.ForgeEventFactory.onLivingFall(this, p_147187_, p_147188_); + public boolean causeFallDamage(double p_393354_, float p_147187_, DamageSource p_147189_) { ++ var event = net.minecraftforge.event.ForgeEventFactory.onLivingFall(this, p_393354_, p_147187_); + if (event.isCanceled()) return false; -+ p_147187_ = event.getDistance(); -+ p_147188_ = event.getDamageMultiplier(); - boolean flag = super.causeFallDamage(p_147187_, p_147188_, p_147189_); - int i = this.calculateFallDamage(p_147187_, p_147188_); ++ p_393354_ = event.getDistance(); ++ p_147187_ = event.getDamageMultiplier(); + boolean flag = super.causeFallDamage(p_393354_, p_147187_, p_147189_); + int i = this.calculateFallDamage(p_393354_, p_147187_); if (i > 0) { -@@ -1663,9 +_,10 @@ +@@ -1678,9 +_,10 @@ int i = Mth.floor(this.getX()); int j = Mth.floor(this.getY() - 0.2F); int k = Mth.floor(this.getZ()); @@ -313,7 +298,7 @@ this.playSound(soundtype.getFallSound(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F); } } -@@ -1726,9 +_,9 @@ +@@ -1738,9 +_,9 @@ float f2 = f1 - p_21194_; if (f2 > 0.0F && f2 < 3.4028235E37F) { if (this instanceof ServerPlayer) { @@ -325,7 +310,7 @@ } } } -@@ -1756,6 +_,8 @@ +@@ -1768,6 +_,8 @@ protected void actuallyHurt(ServerLevel p_365124_, DamageSource p_21240_, float p_21241_) { if (!this.isInvulnerableTo(p_365124_, p_21240_)) { @@ -334,7 +319,7 @@ 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); -@@ -1765,6 +_,7 @@ +@@ -1777,6 +_,7 @@ serverplayer.awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f * 10.0F)); } @@ -342,7 +327,7 @@ if (f1 != 0.0F) { this.getCombatTracker().recordDamage(p_21240_, f1); this.setHealth(this.getHealth() - f1); -@@ -1824,6 +_,8 @@ +@@ -1836,6 +_,8 @@ } public void swing(InteractionHand p_21012_, boolean p_21013_) { @@ -351,7 +336,7 @@ if (!this.swinging || this.swingTime >= this.getCurrentSwingDuration() / 2 || this.swingTime < 0) { this.swingTime = -1; this.swinging = true; -@@ -1936,9 +_,10 @@ +@@ -1960,9 +_,10 @@ } private void swapHandItems() { @@ -365,7 +350,7 @@ } @Override -@@ -2156,15 +_,18 @@ +@@ -2168,15 +_,18 @@ } this.hasImpulse = true; @@ -386,18 +371,18 @@ } protected float getWaterSlowDown() { -@@ -2188,8 +_,8 @@ +@@ -2199,8 +_,8 @@ + public void travel(Vec3 p_21280_) { - if (this.isControlledByLocalInstance()) { - FluidState fluidstate = this.level().getFluidState(this.blockPosition()); -- if ((this.isInWater() || this.isInLava()) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { -- this.travelInFluid(p_21280_); -+ if ((this.isInWater() || this.isInLava() || this.isInFluidType(fluidstate)) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { -+ this.travelInFluid(p_21280_, fluidstate); - } else if (this.isFallFlying()) { - this.travelFallFlying(); - } else { -@@ -2200,7 +_,7 @@ + FluidState fluidstate = this.level().getFluidState(this.blockPosition()); +- if ((this.isInWater() || this.isInLava()) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { +- this.travelInFluid(p_21280_); ++ if ((this.isInWater() || this.isInLava() || this.isInFluidType(fluidstate)) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { ++ this.travelInFluid(p_21280_, fluidstate); + } else if (this.isFallFlying()) { + this.travelFallFlying(p_21280_); + } else { +@@ -2210,7 +_,7 @@ private void travelInAir(Vec3 p_362087_) { BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); @@ -406,7 +391,7 @@ float f1 = f * 0.91F; Vec3 vec3 = this.handleRelativeFrictionAndCalculateMovement(p_362087_, f); double d0 = vec3.y; -@@ -2223,10 +_,18 @@ +@@ -2233,10 +_,18 @@ } } @@ -426,7 +411,7 @@ if (this.isInWater()) { float f = this.isSprinting() ? 0.9F : this.getWaterSlowDown(); float f1 = 0.02F; -@@ -2244,6 +_,7 @@ +@@ -2254,6 +_,7 @@ f = 0.96F; } @@ -434,7 +419,7 @@ this.moveRelative(f1, p_362114_); this.move(MoverType.SELF, this.getDeltaMovement()); Vec3 vec3 = this.getDeltaMovement(); -@@ -2392,7 +_,7 @@ +@@ -2412,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); @@ -443,7 +428,7 @@ d2 = 0.0; } -@@ -2425,6 +_,7 @@ +@@ -2445,6 +_,7 @@ @Override public void tick() { @@ -451,15 +436,15 @@ super.tick(); this.updatingUsingItem(); this.updateSwimAmount(); -@@ -2577,6 +_,7 @@ - }; +@@ -2576,6 +_,7 @@ + ItemStack itemstack = this.lastEquipmentItems.get(equipmentslot); ItemStack itemstack1 = this.getItemBySlot(equipmentslot); if (this.equipmentHasChanged(itemstack, itemstack1)) { + net.minecraftforge.event.ForgeEventFactory.onLivingEquipmentChange(this, equipmentslot, itemstack, itemstack1); if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -@@ -2736,6 +_,10 @@ +@@ -2711,6 +_,10 @@ profilerfiller.push("jump"); if (this.jumping && this.isAffectedByFluids()) { double d3; @@ -470,7 +455,7 @@ if (this.isInLava()) { d3 = this.getFluidHeight(FluidTags.LAVA); } else { -@@ -2746,15 +_,22 @@ +@@ -2721,15 +_,22 @@ double d4 = this.getFluidJumpThreshold(); if (!flag || this.onGround() && !(d3 > d4)) { if (!this.isInLava() || this.onGround() && !(d3 > d4)) { @@ -495,7 +480,7 @@ } } else { this.noJumpDelay = 0; -@@ -3104,8 +_,11 @@ +@@ -3041,8 +_,11 @@ private void updatingUsingItem() { if (this.isUsingItem()) { @@ -508,7 +493,7 @@ this.updateUsingItem(this.useItem); } else { this.stopUsingItem(); -@@ -3114,8 +_,12 @@ +@@ -3086,8 +_,12 @@ } protected void updateUsingItem(ItemStack p_147201_) { @@ -522,7 +507,7 @@ this.completeUsingItem(); } } -@@ -3143,8 +_,10 @@ +@@ -3115,8 +_,10 @@ public void startUsingItem(InteractionHand p_21159_) { ItemStack itemstack = this.getItemInHand(p_21159_); if (!itemstack.isEmpty() && !this.isUsingItem()) { @@ -534,7 +519,7 @@ if (!this.level().isClientSide) { this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(2, p_21159_ == InteractionHand.OFF_HAND); -@@ -3196,6 +_,9 @@ +@@ -3168,6 +_,9 @@ vec31 = vec31.xRot(-this.getXRot() * (float) (Math.PI / 180.0)); vec31 = vec31.yRot(-this.getYRot() * (float) (Math.PI / 180.0)); vec31 = vec31.add(this.getX(), this.getEyeY(), this.getZ()); @@ -544,7 +529,7 @@ this.level() .addParticle( new ItemParticleOption(ParticleTypes.ITEM, p_21061_), -@@ -3216,7 +_,9 @@ +@@ -3188,7 +_,9 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -554,10 +539,10 @@ if (itemstack != this.useItem) { this.setItemInHand(interactionhand, itemstack); } -@@ -3244,7 +_,13 @@ - - public void releaseUsingItem() { - if (!this.useItem.isEmpty()) { +@@ -3218,7 +_,13 @@ + ItemStack itemstack = this.getItemInHand(this.getUsedItemHand()); + if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemstack, this.useItem)) { + this.useItem = itemstack; + if (!net.minecraftforge.event.ForgeEventFactory.onUseItemStop(this, useItem, this.getUseItemRemainingTicks())) { + ItemStack copy = this instanceof Player ? useItem.copy() : null; this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); @@ -568,7 +553,7 @@ if (this.useItem.useOnRelease()) { this.updatingUsingItem(); } -@@ -3254,6 +_,7 @@ +@@ -3228,6 +_,7 @@ } public void stopUsingItem() { @@ -576,28 +561,18 @@ if (!this.level().isClientSide) { boolean flag = this.isUsingItem(); this.setLivingEntityFlag(1, false); -@@ -3274,7 +_,8 @@ - public ItemStack getItemBlockingWith() { - if (this.isUsingItem() && !this.useItem.isEmpty()) { - Item item = this.useItem.getItem(); -- if (item.getUseAnimation(this.useItem) != ItemUseAnimation.BLOCK) { -+ boolean canBlock = this.useItem.canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK); -+ if (!canBlock) { - return null; - } else { - return item.getUseDuration(this.useItem, this) - this.useItemRemaining < 5 ? null : this.useItem; -@@ -3419,8 +_,8 @@ +@@ -3396,8 +_,8 @@ } BlockState blockstate = this.level().getBlockState(p_21141_); - if (blockstate.getBlock() instanceof BedBlock) { -- this.level().setBlock(p_21141_, blockstate.setValue(BedBlock.OCCUPIED, Boolean.valueOf(true)), 3); +- this.level().setBlock(p_21141_, blockstate.setValue(BedBlock.OCCUPIED, true), 3); + if (blockstate.isBed(level(), p_21141_, this)) { + blockstate.setBedOccupied(level(), p_21141_, this, true); } this.setPose(Pose.SLEEPING); -@@ -3435,15 +_,15 @@ +@@ -3412,15 +_,15 @@ } private boolean checkBedExists() { @@ -611,12 +586,12 @@ - if (blockstate.getBlock() instanceof BedBlock) { + if (blockstate.isBed(level(), p_261435_, this)) { Direction direction = blockstate.getValue(BedBlock.FACING); -- this.level().setBlock(p_261435_, blockstate.setValue(BedBlock.OCCUPIED, Boolean.valueOf(false)), 3); +- this.level().setBlock(p_261435_, blockstate.setValue(BedBlock.OCCUPIED, false), 3); + blockstate.setBedOccupied(level(), p_261435_, this, false); 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); -@@ -3464,7 +_,9 @@ + return new Vec3(blockpos.getX() + 0.5, blockpos.getY() + 0.1, blockpos.getZ() + 0.5); +@@ -3441,7 +_,9 @@ @Nullable public Direction getBedOrientation() { BlockPos blockpos = this.getSleepingPos().orElse(null); @@ -627,7 +602,7 @@ } @Override -@@ -3473,7 +_,7 @@ +@@ -3450,7 +_,7 @@ } public ItemStack getProjectile(ItemStack p_21272_) { @@ -636,7 +611,7 @@ } private static byte entityEventForEquipmentBreak(EquipmentSlot p_21267_) { -@@ -3528,6 +_,8 @@ +@@ -3506,6 +_,8 @@ } public final EquipmentSlot getEquipmentSlotForItem(ItemStack p_147234_) { @@ -645,10 +620,10 @@ Equippable equippable = p_147234_.get(DataComponents.EQUIPPABLE); return equippable != null && this.canUseSlot(equippable.slot()) ? equippable.slot() : EquipmentSlot.MAINHAND; } -@@ -3659,5 +_,42 @@ +@@ -3641,5 +_,42 @@ } - public static record Fallsounds(SoundEvent small, SoundEvent big) { + public record Fallsounds(SoundEvent small, SoundEvent big) { + } + + /** diff --git a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch index a6f7a455b0..84723ddf57 100644 --- a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -129,6 +_,9 @@ +@@ -124,6 +_,9 @@ private Leashable.LeashData leashData; private BlockPos restrictCenter = BlockPos.ZERO; private float restrictRadius = -1.0F; @@ -10,7 +10,7 @@ protected Mob(EntityType p_21368_, Level p_21369_) { super(p_21368_, p_21369_); -@@ -235,7 +_,10 @@ +@@ -220,7 +_,10 @@ } public void setTarget(@Nullable LivingEntity p_21544_) { @@ -22,7 +22,7 @@ } @Override -@@ -418,6 +_,10 @@ +@@ -356,6 +_,10 @@ if (this.isNoAi()) { p_21484_.putBoolean("NoAI", this.isNoAi()); } @@ -33,22 +33,22 @@ } @Override -@@ -484,6 +_,14 @@ - - this.lootTableSeed = p_21450_.getLong("DeathLootTableSeed"); - this.setNoAi(p_21450_.getBoolean("NoAI")); +@@ -370,6 +_,14 @@ + this.lootTable = p_21450_.read("DeathLootTable", LootTable.KEY_CODEC); + this.lootTableSeed = p_21450_.getLongOr("DeathLootTableSeed", 0L); + this.setNoAi(p_21450_.getBooleanOr("NoAI", false)); + -+ if (p_21450_.contains("forge:spawn_type")) { ++ p_21450_.getString("forge:spawn_type").ifPresent(type -> { + try { -+ this.spawnReason = EntitySpawnReason.valueOf(p_21450_.getString("forge:spawn_type")); ++ this.spawnReason = EntitySpawnReason.valueOf(type); + } catch (Exception ex) { + p_21450_.remove("forge:spawn_type"); + } -+ } ++ }); } @Override -@@ -536,7 +_,7 @@ +@@ -422,7 +_,7 @@ && this.canPickUpLoot() && this.isAlive() && !this.dead @@ -57,7 +57,7 @@ Vec3i vec3i = this.getPickupReach(); for (ItemEntity itementity : this.level() -@@ -702,6 +_,14 @@ +@@ -583,6 +_,14 @@ this.discard(); } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { Entity entity = this.level().getNearestPlayer(this, -1.0); @@ -72,7 +72,7 @@ if (entity != null) { double d0 = entity.distanceToSqr(this); int i = this.getType().getCategory().getDespawnDistance(); -@@ -1118,6 +_,16 @@ +@@ -973,6 +_,16 @@ } } @@ -89,7 +89,7 @@ @Nullable public SpawnGroupData finalizeSpawn(ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, EntitySpawnReason p_369316_, @Nullable SpawnGroupData p_21437_) { RandomSource randomsource = p_21434_.getRandom(); -@@ -1129,6 +_,7 @@ +@@ -984,6 +_,7 @@ } this.setLeftHanded(randomsource.nextFloat() < 0.05F); @@ -97,7 +97,7 @@ return p_21437_; } -@@ -1439,15 +_,25 @@ +@@ -1288,15 +_,25 @@ return false; } @@ -124,7 +124,7 @@ @VisibleForTesting public void removeFreeWill() { this.removeAllGoals(p_341273_ -> true); -@@ -1473,6 +_,41 @@ +@@ -1324,6 +_,41 @@ public ItemStack getPickResult() { SpawnEggItem spawneggitem = SpawnEggItem.byId(this.getType()); return spawneggitem == null ? null : new ItemStack(spawneggitem); diff --git a/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch b/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch index 5771b2f0ab..eb8ea6af80 100644 --- a/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch +++ b/patches/minecraft/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 -@@ -47,6 +_,7 @@ +@@ -48,6 +_,7 @@ public class SpawnPlacements { private static final Map, SpawnPlacements.Data> DATA_BY_TYPE = Maps.newHashMap(); @@ -8,7 +8,7 @@ private static void register( EntityType p_21755_, SpawnPlacementType p_331557_, Heightmap.Types p_21757_, SpawnPlacements.SpawnPredicate p_21758_ ) { -@@ -74,7 +_,8 @@ +@@ -75,7 +_,8 @@ EntityType p_217075_, ServerLevelAccessor p_217076_, EntitySpawnReason p_369208_, BlockPos p_217078_, RandomSource p_217079_ ) { SpawnPlacements.Data spawnplacements$data = DATA_BY_TYPE.get(p_217075_); @@ -18,7 +18,7 @@ } static { -@@ -163,5 +_,13 @@ +@@ -165,5 +_,13 @@ @FunctionalInterface public interface SpawnPredicate { boolean test(EntityType p_217081_, ServerLevelAccessor p_217082_, EntitySpawnReason p_365908_, BlockPos p_217084_, RandomSource p_217085_); diff --git a/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch b/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch index edf2fe0e34..fc94098d8e 100644 --- a/patches/minecraft/net/minecraft/world/entity/TamableAnimal.java.patch +++ b/patches/minecraft/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 -@@ -222,13 +_,16 @@ +@@ -227,13 +_,16 @@ @Override public void die(DamageSource p_21809_) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/Brain.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/Brain.java.patch index f42e662382..2f9211a67b 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/Brain.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/Brain.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/Brain.java +++ b/net/minecraft/world/entity/ai/Brain.java -@@ -485,6 +_,30 @@ +@@ -494,6 +_,30 @@ return builder.build(); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch index 1af9f965f7..de94fe07e4 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java.patch @@ -7,7 +7,7 @@ - if (!p_23174_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(p_23174_, p_23175_)) { return false; - } else if (p_23175_.getVillagerData().getProfession() != VillagerProfession.FARMER) { + } else if (!p_23175_.getVillagerData().profession().is(VillagerProfession.FARMER)) { return false; @@ -118,6 +_,11 @@ p_23196_.setBlockAndUpdate(this.aboveFarmlandPos, blockstate1); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch index d6dd940464..73ea8dcde8 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/ai/behavior/StartAttacking.java +++ b/net/minecraft/world/entity/ai/behavior/StartAttacking.java @@ -28,7 +_,11 @@ - if (!p_359049_.canAttack(livingentity)) { - return false; - } else { -- p_258778_.set(livingentity); -+ var changeTargetEvent = net.minecraftforge.event.ForgeEventFactory.onLivingChangeTargetBehavior(p_359049_, livingentity); -+ if (changeTargetEvent.isCanceled()) -+ return false; + if (!p_359049_.canAttack(livingentity)) { + return false; + } else { +- p_258778_.set(livingentity); ++ var changeTargetEvent = net.minecraftforge.event.ForgeEventFactory.onLivingChangeTargetBehavior(p_359049_, livingentity); ++ if (changeTargetEvent.isCanceled()) ++ return false; + -+ p_258778_.set(changeTargetEvent.getNewTarget()); - p_258779_.erase(); - return true; - } ++ p_258778_.set(changeTargetEvent.getNewTarget()); + p_258779_.erase(); + return true; + } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch index e66e871ad1..32a98074c0 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -3,7 +3,7 @@ @@ -61,7 +_,7 @@ if (this.eatAnimationTick == this.adjustedTickDelay(4)) { BlockPos blockpos = this.mob.blockPosition(); - if (IS_TALL_GRASS.test(this.level.getBlockState(blockpos))) { + if (IS_EDIBLE.test(this.level.getBlockState(blockpos))) { - if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(getServerLevel(this.level), this.mob)) { this.level.destroyBlock(blockpos, false); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch index befbd929da..ad9d78a170 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -9,7 +9,7 @@ return false; } else if (this.nextStartTick > 0) { this.nextStartTick--; -@@ -158,7 +_,8 @@ +@@ -150,7 +_,8 @@ ); return chunkaccess == null ? false diff --git a/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch index 9251d759c4..36a855eea6 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -4,11 +4,11 @@ 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(); -- double d0 = Math.abs(this.mob.getX() - ((double)vec3i.getX() + 0.5)); +- double d0 = Math.abs(this.mob.getX() - (vec3i.getX() + 0.5)); + double d0 = Math.abs(this.mob.getX() - ((double)vec3i.getX() + (this.mob.getBbWidth() + 1) / 2D)); //Forge: Fix MC-94054 - double d1 = Math.abs(this.mob.getY() - (double)vec3i.getY()); -- double d2 = Math.abs(this.mob.getZ() - ((double)vec3i.getZ() + 0.5)); -- boolean flag = d0 < (double)this.maxDistanceToWaypoint && d2 < (double)this.maxDistanceToWaypoint && d1 < 1.0; + double d1 = Math.abs(this.mob.getY() - vec3i.getY()); +- double d2 = Math.abs(this.mob.getZ() - (vec3i.getZ() + 0.5)); +- boolean flag = d0 < this.maxDistanceToWaypoint && d2 < this.maxDistanceToWaypoint && d1 < 1.0; + double d2 = Math.abs(this.mob.getZ() - ((double)vec3i.getZ() + (this.mob.getBbWidth() + 1) / 2D)); //Forge: Fix MC-94054 + boolean flag = d0 <= (double)this.maxDistanceToWaypoint && d2 <= (double)this.maxDistanceToWaypoint && d1 < 1.0D; //Forge: Fix MC-94054 if (flag || this.canCutCorner(this.path.getNextNode().type) && this.shouldTargetNextNodeInDirection(vec3)) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch index 0f38827712..304587b8f2 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch @@ -4,14 +4,14 @@ super.tick(); } else { if (this.pathToPosition != null) { -- if (!this.pathToPosition.closerToCenterThan(this.mob.position(), (double)this.mob.getBbWidth()) +- if (!this.pathToPosition.closerToCenterThan(this.mob.position(), this.mob.getBbWidth()) - && ( -- !(this.mob.getY() > (double)this.pathToPosition.getY()) -- || !BlockPos.containing((double)this.pathToPosition.getX(), this.mob.getY(), (double)this.pathToPosition.getZ()) -- .closerToCenterThan(this.mob.position(), (double)this.mob.getBbWidth()) +- !(this.mob.getY() > this.pathToPosition.getY()) +- || !BlockPos.containing(this.pathToPosition.getX(), this.mob.getY(), this.pathToPosition.getZ()) +- .closerToCenterThan(this.mob.position(), this.mob.getBbWidth()) - )) { + // FORGE: Fix MC-94054 + if (!this.pathToPosition.closerToCenterThan(this.mob.position(), Math.max((double)this.mob.getBbWidth(), 1.0D)) && (!(this.mob.getY() > (double)this.pathToPosition.getY()) || !(BlockPos.containing((double)this.pathToPosition.getX(), this.mob.getY(), (double)this.pathToPosition.getZ())).closerToCenterThan(this.mob.position(), Math.max((double)this.mob.getBbWidth(), 1.0D)))) { - this.mob - .getMoveControl() - .setWantedPosition((double)this.pathToPosition.getX(), (double)this.pathToPosition.getY(), (double)this.pathToPosition.getZ(), this.speedModifier); + this.mob.getMoveControl().setWantedPosition(this.pathToPosition.getX(), this.pathToPosition.getY(), this.pathToPosition.getZ(), this.speedModifier); + } else { + this.pathToPosition = null; diff --git a/patches/minecraft/net/minecraft/world/entity/ai/village/VillageSiege.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/village/VillageSiege.java.patch index 6a3315f081..d2c88011d1 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/village/VillageSiege.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/village/VillageSiege.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/village/VillageSiege.java +++ b/net/minecraft/world/entity/ai/village/VillageSiege.java -@@ -77,7 +_,10 @@ +@@ -71,7 +_,10 @@ this.spawnX = blockpos.getX() + Mth.floor(Mth.cos(f) * 32.0F); this.spawnY = blockpos.getY(); this.spawnZ = blockpos.getZ() + Mth.floor(Mth.sin(f) * 32.0F); @@ -12,7 +12,7 @@ this.nextSpawnTime = 0; this.zombiesToSpawn = 20; break; -@@ -97,7 +_,7 @@ +@@ -91,7 +_,7 @@ if (vec3 != null) { Zombie zombie; try { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch index fc2d58de78..e785e21f17 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch @@ -17,4 +17,4 @@ + } if (ageablemob != null) { ageablemob.setBaby(true); - ageablemob.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); + ageablemob.snapTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch index 3affe941b4..0bb8dbb57f 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java -@@ -505,7 +_,9 @@ +@@ -503,7 +_,9 @@ if (this.hivePos == null) { return null; } else { @@ -11,7 +11,7 @@ } } -@@ -668,13 +_,22 @@ +@@ -666,13 +_,22 @@ } @Override @@ -21,7 +21,7 @@ - - @Override public Vec3 getLeashOffset() { - return new Vec3(0.0, (double)(0.5F * this.getEyeHeight()), (double)(this.getBbWidth() * 0.2F)); + return new Vec3(0.0, 0.5F * this.getEyeHeight(), this.getBbWidth() * 0.2F); + } + + @Deprecated // FORGE: use jumpInFluid instead diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch index ca43f5dce3..b3f575cfc7 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java -@@ -369,10 +_,10 @@ +@@ -384,10 +_,10 @@ } } 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); - this.heal(foodproperties != null ? (float)foodproperties.nutrition() : 1.0F); + this.heal(foodproperties != null ? foodproperties.nutrition() : 1.0F); this.playEatingSound(); + this.usePlayerItem(p_28153_, p_28154_, itemstack); } return InteractionResult.SUCCESS; -@@ -433,7 +_,7 @@ +@@ -448,7 +_,7 @@ } private void tryToTame(Player p_333297_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch index 4781cc76a7..bb0585ac94 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Fox.java +++ b/net/minecraft/world/entity/animal/Fox.java -@@ -834,6 +_,16 @@ +@@ -858,6 +_,16 @@ protected void breed() { ServerLevel serverlevel = this.level; Fox fox = (Fox)this.animal.getBreedOffspring(serverlevel, this.partner); @@ -17,7 +17,7 @@ if (fox != null) { ServerPlayer serverplayer = this.animal.getLoveCause(); ServerPlayer serverplayer1 = this.partner.getLoveCause(); -@@ -917,7 +_,7 @@ +@@ -941,7 +_,7 @@ } protected void onReachedTarget() { @@ -26,7 +26,7 @@ BlockState blockstate = Fox.this.level().getBlockState(this.blockPos); if (blockstate.is(Blocks.SWEET_BERRY_BUSH)) { this.pickSweetBerries(blockstate); -@@ -976,7 +_,7 @@ +@@ -1000,7 +_,7 @@ @Override public boolean canUse() { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch index 52c6d8701a..bec8568c74 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/MushroomCow.java +++ b/net/minecraft/world/entity/animal/MushroomCow.java -@@ -109,7 +_,7 @@ +@@ -114,7 +_,7 @@ this.playSound(soundevent, 1.0F, 1.0F); return InteractionResult.SUCCESS; @@ -9,7 +9,7 @@ if (this.level() instanceof ServerLevel serverlevel) { this.shear(serverlevel, SoundSource.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, p_28941_); -@@ -164,15 +_,26 @@ +@@ -169,15 +_,26 @@ @Override public void shear(ServerLevel p_369641_, SoundSource p_28924_, ItemStack p_364876_) { @@ -39,7 +39,7 @@ } @Override -@@ -232,6 +_,15 @@ +@@ -255,6 +_,15 @@ } return mushroomcow$variant2; diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch index 59bf6610b5..2c47fe2550 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/patches/minecraft/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 -@@ -159,7 +_,7 @@ +@@ -160,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/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch index dbbe84225e..4d7a14a886 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Parrot.java +++ b/net/minecraft/world/entity/animal/Parrot.java -@@ -257,7 +_,7 @@ +@@ -262,7 +_,7 @@ } if (!this.level().isClientSide) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch index fdbc17fb7b..3c41645928 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Pig.java.patch @@ -6,13 +6,13 @@ public void thunderHit(ServerLevel p_29473_, LightningBolt p_29474_) { - if (p_29473_.getDifficulty() != Difficulty.PEACEFUL) { + if (p_29473_.getDifficulty() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.ZOMBIFIED_PIGLIN, (timer) -> {})) { - ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), p_375111_ -> { + ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), p_390653_ -> { if (this.getMainHandItem().isEmpty()) { - p_375111_.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); + p_390653_.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); } - p_375111_.setPersistenceRequired(); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_375111_); + p_390653_.setPersistenceRequired(); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_390653_); }); if (zombifiedpiglin == null) { super.thunderHit(p_29473_, p_29474_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch index ef62dc5797..841a8c98e3 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Rabbit.java +++ b/net/minecraft/world/entity/animal/Rabbit.java -@@ -528,7 +_,7 @@ +@@ -554,7 +_,7 @@ @Override public boolean canUse() { if (this.nextStartTick <= 0) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch index 90fd6357b9..3e24627d5b 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch @@ -8,8 +8,8 @@ +public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob, net.minecraftforge.common.IForgeShearable { private static final EntityDataAccessor DATA_PUMPKIN_ID = SynchedEntityData.defineId(SnowGolem.class, EntityDataSerializers.BYTE); private static final byte PUMPKIN_FLAG = 16; - -@@ -95,7 +_,7 @@ + private static final boolean DEFAULT_PUMPKIN = true; +@@ -94,7 +_,7 @@ this.hurtServer(serverlevel, this.damageSources().onFire(), 1.0F); } @@ -18,16 +18,16 @@ return; } -@@ -106,7 +_,7 @@ +@@ -105,7 +_,7 @@ int k = Mth.floor(this.getY()); - int l = Mth.floor(this.getZ() + (double)((float)(i / 2 % 2 * 2 - 1) * 0.25F)); + int l = Mth.floor(this.getZ() + (i / 2 % 2 * 2 - 1) * 0.25F); BlockPos blockpos = new BlockPos(j, k, l); - if (this.level().getBlockState(blockpos).isAir() && blockstate.canSurvive(this.level(), blockpos)) { + if (this.level().isEmptyBlock(blockpos) && blockstate.canSurvive(this.level(), blockpos)) { this.level().setBlockAndUpdate(blockpos, blockstate); this.level().gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(this, blockstate)); } -@@ -136,7 +_,7 @@ +@@ -135,7 +_,7 @@ @Override protected InteractionResult mobInteract(Player p_29920_, InteractionHand p_29921_) { ItemStack itemstack = p_29920_.getItemInHand(p_29921_); @@ -36,9 +36,9 @@ if (this.level() instanceof ServerLevel serverlevel) { this.shear(serverlevel, SoundSource.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, p_29920_); -@@ -196,4 +_,18 @@ +@@ -195,4 +_,18 @@ public Vec3 getLeashOffset() { - return new Vec3(0.0, (double)(0.75F * this.getEyeHeight()), (double)(this.getBbWidth() * 0.4F)); + return new Vec3(0.0, 0.75F * this.getEyeHeight(), this.getBbWidth() * 0.4F); } + + @org.jetbrains.annotations.NotNull diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch deleted file mode 100644 index db2887afe0..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- a/net/minecraft/world/entity/animal/Wolf.java -+++ b/net/minecraft/world/entity/animal/Wolf.java -@@ -85,7 +_,7 @@ - import net.minecraft.world.level.pathfinder.PathType; - import net.minecraft.world.phys.Vec3; - --public class Wolf extends TamableAnimal implements NeutralMob, VariantHolder> { -+public class Wolf extends TamableAnimal implements NeutralMob, VariantHolder>, net.minecraftforge.common.IForgeShearable { - private static final EntityDataAccessor DATA_INTERESTED_ID = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.BOOLEAN); - private static final EntityDataAccessor DATA_COLLAR_COLOR = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.INT); - private static final EntityDataAccessor DATA_REMAINING_ANGER_TIME = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.INT); -@@ -430,19 +_,11 @@ - this.setBodyArmorItem(itemstack.copyWithCount(1)); - itemstack.consume(1, p_30412_); - return InteractionResult.SUCCESS; -- } else if (itemstack.is(Items.SHEARS) -+ } else if (itemstack.canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_HARVEST) - && this.isOwnedBy(p_30412_) - && this.isWearingBodyArmor() - && (!EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) || p_30412_.isCreative())) { -- itemstack.hurtAndBreak(1, p_30412_, getSlotForHand(p_30413_)); -- this.playSound(SoundEvents.ARMOR_UNEQUIP_WOLF); -- ItemStack itemstack1 = this.getBodyArmorItem(); -- this.setBodyArmorItem(ItemStack.EMPTY); -- if (this.level() instanceof ServerLevel serverlevel) { -- this.spawnAtLocation(serverlevel, itemstack1); -- } -- -- return InteractionResult.SUCCESS; -+ return InteractionResult.PASS; - } else if (this.isInSittingPose() - && this.isWearingBodyArmor() - && this.isOwnedBy(p_30412_) -@@ -477,7 +_,7 @@ - } - - private void tryToTame(Player p_336244_) { -- if (this.random.nextInt(3) == 0) { -+ if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_336244_)) { - this.tame(p_336244_); - this.navigation.stop(); - this.setTarget(null); -@@ -623,6 +_,24 @@ - - return true; - } -+ } -+ -+ @Override -+ public boolean isShearable(ItemStack item, Level world, BlockPos pos) { -+ return this.isWearingBodyArmor(); -+ } -+ -+ @Override -+ public java.util.List onSheared(@org.jetbrains.annotations.Nullable Player player, @org.jetbrains.annotations.NotNull ItemStack item, Level world, BlockPos pos, int fortune) { -+ if (!this.isWearingBodyArmor() || (player != null && !this.isOwnedBy(player)) || -+ (EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) && (player == null || !player.isCreative())) -+ ) -+ return java.util.Collections.emptyList(); -+ -+ this.playSound(SoundEvents.ARMOR_UNEQUIP_WOLF); -+ var armor = this.getBodyArmorItem(); -+ this.setBodyArmorItem(ItemStack.EMPTY); -+ return java.util.List.of(armor); - } - - @Override diff --git a/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch index 106817be0f..d5b36e6eb2 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/allay/Allay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -373,7 +_,7 @@ +@@ -369,7 +_,7 @@ public boolean wantsToPickUp(ServerLevel p_363882_, ItemStack p_218387_) { ItemStack itemstack = this.getItemInHand(InteractionHand.MAIN_HAND); return !itemstack.isEmpty() diff --git a/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch index b42f0888e3..abc90f7d9c 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/camel/Camel.java.patch +++ b/patches/minecraft/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 -@@ -330,7 +_,7 @@ +@@ -342,7 +_,7 @@ @Override protected void playStepSound(BlockPos p_252056_, BlockState p_251457_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index 1cff62e726..e6cd269686 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -312,6 +_,11 @@ - - @Override - public boolean causeFallDamage(float p_149499_, float p_149500_, DamageSource p_149501_) { -+ var event = net.minecraftforge.event.ForgeEventFactory.onLivingFall(this, p_149499_, p_149500_); -+ if (event.isCanceled()) return false; -+ p_149499_ = event.getDistance(); -+ p_149500_ = event.getDamageMultiplier(); -+ - if (p_149499_ > 1.0F) { - this.playSound(SoundEvents.HORSE_LAND, 0.4F, 1.0F); +@@ -139,6 +_,7 @@ } -@@ -357,6 +_,7 @@ - this.inventory.addListener(this); - this.syncSaddleToClients(); + this.addBehaviourGoals(); + this.itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this.inventory)); } - protected void syncSaddleToClients() { -@@ -402,9 +_,9 @@ + protected void addBehaviourGoals() { +@@ -273,6 +_,11 @@ + + @Override + public boolean causeFallDamage(double p_391990_, float p_149499_, DamageSource p_149501_) { ++ var event = net.minecraftforge.event.ForgeEventFactory.onLivingFall(this, p_391990_, p_149499_); ++ if (event.isCanceled()) return false; ++ p_391990_ = event.getDistance(); ++ p_149499_ = event.getDamageMultiplier(); ++ + if (p_391990_ > 1.0) { + this.playSound(SoundEvents.HORSE_LAND, 0.4F, 1.0F); + } +@@ -344,9 +_,9 @@ protected void playStepSound(BlockPos p_30584_, BlockState p_30585_) { if (!p_30585_.liquid()) { BlockState blockstate = this.level().getBlockState(p_30584_.above()); @@ -32,18 +32,18 @@ } if (this.isVehicle() && this.canGallop) { -@@ -825,6 +_,7 @@ +@@ -766,6 +_,7 @@ float f1 = Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)); - this.setDeltaMovement(this.getDeltaMovement().add((double)(-0.4F * f * p_248808_), 0.0, (double)(0.4F * f1 * p_248808_))); + this.setDeltaMovement(this.getDeltaMovement().add(-0.4F * f * p_248808_, 0.0, 0.4F * f1 * p_248808_)); } + net.minecraftforge.common.ForgeHooks.onLivingJump(this); } protected void playJumpSound() { -@@ -1141,6 +_,26 @@ +@@ -1010,6 +_,26 @@ - public final Container getBodyArmorAccess() { - return this.bodyArmorAccess; + public boolean hasInventoryChanged(Container p_149512_) { + return this.inventory != p_149512_; + } + + private net.minecraftforge.common.util.LazyOptional itemHandler = null; @@ -66,4 +66,4 @@ + } } - public int getInventoryColumns() { + public int getAmbientStandInterval() { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch index 50d36b46d1..cc852cba7c 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/Llama.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/entity/animal/horse/Llama.java +++ b/net/minecraft/world/entity/animal/horse/Llama.java -@@ -355,6 +_,10 @@ +@@ -374,6 +_,10 @@ @Override - public boolean causeFallDamage(float p_149538_, float p_149539_, DamageSource p_149540_) { -+ var event = net.minecraftforge.event.ForgeEventFactory.onLivingFall(this, p_149538_, p_149539_); + public boolean causeFallDamage(double p_396436_, float p_149538_, DamageSource p_149540_) { ++ var event = net.minecraftforge.event.ForgeEventFactory.onLivingFall(this, p_396436_, p_149538_); + if (event.isCanceled()) return false; -+ p_149538_ = event.getDistance(); -+ p_149539_ = event.getDamageMultiplier(); - int i = this.calculateFallDamage(p_149538_, p_149539_); ++ p_396436_ = event.getDistance(); ++ p_149538_ = event.getDamageMultiplier(); + int i = this.calculateFallDamage(p_396436_, p_149538_); if (i <= 0) { return false; diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/sheep/Sheep.java.patch similarity index 50% rename from patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch rename to patches/minecraft/net/minecraft/world/entity/animal/sheep/Sheep.java.patch index 84445d73b3..d78f4faae1 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Sheep.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/sheep/Sheep.java.patch @@ -1,40 +1,41 @@ ---- a/net/minecraft/world/entity/animal/Sheep.java -+++ b/net/minecraft/world/entity/animal/Sheep.java +--- a/net/minecraft/world/entity/animal/sheep/Sheep.java ++++ b/net/minecraft/world/entity/animal/sheep/Sheep.java @@ -156,7 +_,7 @@ @Override - public InteractionResult mobInteract(Player p_29853_, InteractionHand p_29854_) { - ItemStack itemstack = p_29853_.getItemInHand(p_29854_); + public InteractionResult mobInteract(Player p_397056_, InteractionHand p_391211_) { + ItemStack itemstack = p_397056_.getItemInHand(p_391211_); - if (itemstack.is(Items.SHEARS)) { + if (false && itemstack.is(Items.SHEARS)) { // Forge: Moved to onSheared if (this.level() instanceof ServerLevel serverlevel && this.readyForShearing()) { this.shear(serverlevel, SoundSource.PLAYERS, itemstack); - this.gameEvent(GameEvent.SHEAR, p_29853_); -@@ -172,12 +_,26 @@ + this.gameEvent(GameEvent.SHEAR, p_397056_); +@@ -172,12 +_,27 @@ @Override - public void shear(ServerLevel p_365174_, SoundSource p_29819_, ItemStack p_361058_) { -+ dropItems(p_365174_, shearInternal(p_365174_, p_29819_, p_361058_)); + public void shear(ServerLevel p_397708_, SoundSource p_395553_, ItemStack p_396000_) { ++ dropItems(p_397708_, shearInternal(p_397708_, p_395553_, p_396000_)); + } + -+ private java.util.List shearInternal(ServerLevel p_365174_, SoundSource p_29819_, ItemStack p_361058_) { ++ private java.util.List shearInternal(ServerLevel p_397708_, SoundSource p_395553_, ItemStack p_396000_) { + var ret = new java.util.ArrayList(); - p_365174_.playSound(null, this, SoundEvents.SHEEP_SHEAR, p_29819_, 1.0F, 1.0F); + p_397708_.playSound(null, this, SoundEvents.SHEEP_SHEAR, p_395553_, 1.0F, 1.0F); this.dropFromShearingLootTable( - p_365174_, + p_397708_, BuiltInLootTables.SHEAR_SHEEP, - p_361058_, - (p_359182_, p_359183_) -> { -+ ret.add(p_359183_); + p_396000_, + (p_397779_, p_393350_) -> { ++ ret.add(p_393350_); + } + ); + this.setSheared(true); + return ret; + } + -+ private void dropItems(ServerLevel p_359182_, java.util.Collection items) { -+ for (var p_359183_ : items) { - for (int i = 0; i < p_359183_.getCount(); i++) { - ItemEntity itementity = this.spawnAtLocation(p_359182_, p_359183_.copyWithCount(1), 1.0F); ++ private void dropItems(ServerLevel p_397779_, java.util.Collection items) { ++ // double indented to make the patch look nicer ++ for (var p_393350_ : items) { + for (int i = 0; i < p_393350_.getCount(); i++) { + ItemEntity itementity = this.spawnAtLocation(p_397779_, p_393350_.copyWithCount(1), 1.0F); if (itementity != null) { @@ -192,8 +_,14 @@ } @@ -45,8 +46,8 @@ + } + + @Override -+ public java.util.List onSheared(@Nullable Player player, ItemStack item, Level world, BlockPos pos, int fortune) { -+ if (world instanceof ServerLevel server) { ++ public java.util.List onSheared(@Nullable Player player, ItemStack item, Level level, BlockPos pos, int fortune) { ++ if (level instanceof ServerLevel server) { + return shearInternal(server, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, item); + } + return java.util.Collections.emptyList(); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch index 7c81e17a79..21cfe988c7 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch +++ b/patches/minecraft/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 -@@ -293,8 +_,7 @@ +@@ -286,8 +_,7 @@ } if (this.tickCount % 10 == 0) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/wolf/Wolf.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/wolf/Wolf.java.patch new file mode 100644 index 0000000000..a0afa6f590 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/entity/animal/wolf/Wolf.java.patch @@ -0,0 +1,62 @@ +--- a/net/minecraft/world/entity/animal/wolf/Wolf.java ++++ b/net/minecraft/world/entity/animal/wolf/Wolf.java +@@ -88,7 +_,7 @@ + import net.minecraft.world.level.pathfinder.PathType; + import net.minecraft.world.phys.Vec3; + +-public class Wolf extends TamableAnimal implements NeutralMob { ++public class Wolf extends TamableAnimal implements NeutralMob, net.minecraftforge.common.IForgeShearable { + private static final EntityDataAccessor DATA_INTERESTED_ID = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor DATA_COLLAR_COLOR = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.INT); + private static final EntityDataAccessor DATA_REMAINING_ANGER_TIME = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.INT); +@@ -464,7 +_,7 @@ + return InteractionResult.SUCCESS; + } + +- if (!itemstack.is(Items.SHEARS) ++ if (!itemstack.canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_HARVEST) + || !this.isOwnedBy(p_391202_) + || !this.isWearingBodyArmor() + || EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) && !p_391202_.isCreative()) { +@@ -491,6 +_,8 @@ + return interactionresult; + } + ++ // Forge: moved to onSheared ++ if (true) return InteractionResult.PASS; + itemstack.hurtAndBreak(1, p_391202_, getSlotForHand(p_391687_)); + this.playSound(SoundEvents.ARMOR_UNEQUIP_WOLF); + ItemStack itemstack1 = this.getBodyArmorItem(); +@@ -518,7 +_,7 @@ + } + + private void tryToTame(Player p_397321_) { +- if (this.random.nextInt(3) == 0) { ++ if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, p_397321_)) { + this.tame(p_397321_); + this.navigation.stop(); + this.setTarget(null); +@@ -713,5 +_,23 @@ + super(false); + this.type = p_391612_; + } ++ } ++ ++ @Override ++ public boolean isShearable(ItemStack item, Level world, BlockPos pos) { ++ return this.isWearingBodyArmor(); ++ } ++ ++ @Override ++ public java.util.List onSheared(@org.jetbrains.annotations.Nullable Player player, @org.jetbrains.annotations.NotNull ItemStack item, Level world, BlockPos pos, int fortune) { ++ if (!this.isWearingBodyArmor() || (player != null && !this.isOwnedBy(player)) || ++ (EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) && (player == null || !player.isCreative())) ++ ) ++ return java.util.Collections.emptyList(); ++ ++ this.playSound(SoundEvents.ARMOR_UNEQUIP_WOLF); ++ var armor = this.getBodyArmorItem(); ++ this.setBodyArmorItem(ItemStack.EMPTY); ++ return java.util.List.of(armor); + } + } diff --git a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index 27788eb6eb..151143c593 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -103,6 +_,15 @@ +@@ -104,6 +_,15 @@ this.setHealth(this.getMaxHealth()); this.noPhysics = true; this.phaseManager = new EnderDragonPhaseManager(this); @@ -16,11 +16,18 @@ } public void setDragonFight(EndDragonFight p_287736_) { -@@ -151,8 +_,19 @@ +@@ -152,8 +_,26 @@ p_330342_.define(DATA_PHASE, EnderDragonPhase.HOVERING.getId()); } -+ @org.jetbrains.annotations.Nullable private Player unlimitedLastHurtByPlayer = null; ++ private @Nullable net.minecraft.world.entity.EntityReference unlimitedLastHurtByPlayer = null; ++ private @Nullable Player getUnlimitedLastHurtByPlayer() { ++ return net.minecraft.world.entity.EntityReference.get(this.unlimitedLastHurtByPlayer, this.level(), Player.class); ++ } ++ private boolean isUnlimitedLastHurtByPlayerInvalid() { ++ var player = getUnlimitedLastHurtByPlayer(); ++ return player == null || player.isRemoved(); ++ } + @Override public void aiStep() { @@ -29,14 +36,14 @@ + this.unlimitedLastHurtByPlayer = lastHurtByPlayer; + } + -+ if (this.unlimitedLastHurtByPlayer != null && this.unlimitedLastHurtByPlayer.isRemoved()) { ++ if (this.isUnlimitedLastHurtByPlayerInvalid()) { + this.unlimitedLastHurtByPlayer = null; + } + this.processFlappingMovement(); if (this.level().isClientSide) { this.setHealth(this.getHealth()); -@@ -445,7 +_,7 @@ +@@ -440,7 +_,7 @@ BlockPos blockpos = new BlockPos(k1, l1, i2); BlockState blockstate = p_363273_.getBlockState(blockpos); if (!blockstate.isAir() && !blockstate.is(BlockTags.DRAGON_TRANSPARENT)) { @@ -45,27 +52,27 @@ flag1 = p_363273_.removeBlock(blockpos, false) || flag1; } else { flag = true; -@@ -540,7 +_,8 @@ +@@ -534,7 +_,8 @@ 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.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.floor((float)i * 0.08F)); +- ExperienceOrb.award(serverlevel, this.position(), Mth.floor(i * 0.08F)); ++ int award = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.getUnlimitedLastHurtByPlayer(), Mth.floor((float)i * 0.08F)); + ExperienceOrb.award(serverlevel, this.position(), award); } if (this.dragonDeathTime == 1 && !this.isSilent()) { -@@ -558,7 +_,8 @@ +@@ -552,7 +_,8 @@ 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.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.floor((float)i * 0.2F)); +- ExperienceOrb.award(serverlevel1, this.position(), Mth.floor(i * 0.2F)); ++ int award = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.getUnlimitedLastHurtByPlayer(), Mth.floor((float)i * 0.2F)); + ExperienceOrb.award(serverlevel1, this.position(), award); } if (this.dragonFight != null) { -@@ -871,6 +_,7 @@ +@@ -860,6 +_,7 @@ @Override public void recreateFromPacket(ClientboundAddEntityPacket p_218825_) { super.recreateFromPacket(p_218825_); @@ -73,7 +80,7 @@ EnderDragonPart[] aenderdragonpart = this.getSubEntities(); for (int i = 0; i < aenderdragonpart.length; i++) { -@@ -886,5 +_,15 @@ +@@ -875,5 +_,15 @@ @Override protected float sanitizeScale(float p_333905_) { return 1.0F; diff --git a/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index 2273e783ec..2728a9cee9 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -314,7 +_,7 @@ +@@ -315,7 +_,7 @@ if (this.destroyBlocksTick > 0) { this.destroyBlocksTick--; @@ -9,7 +9,7 @@ boolean flag = false; int l = Mth.floor(this.getBbWidth() / 2.0F + 1.0F); int i1 = Mth.floor(this.getBbHeight()); -@@ -323,7 +_,7 @@ +@@ -324,7 +_,7 @@ this.getBlockX() - l, this.getBlockY(), this.getBlockZ() - l, this.getBlockX() + l, this.getBlockY() + i1, this.getBlockZ() + l )) { BlockState blockstate = p_363567_.getBlockState(blockpos); @@ -18,7 +18,7 @@ flag = p_363567_.destroyBlock(blockpos, true, this) || flag; } } -@@ -342,6 +_,10 @@ +@@ -343,6 +_,10 @@ } } diff --git a/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index 38f8fc8b4e..2f377335a5 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -148,7 +_,7 @@ +@@ -155,7 +_,7 @@ if (this.level() instanceof ServerLevel serverlevel && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { BlockPos blockpos = this.blockPosition(); boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock; @@ -9,7 +9,7 @@ double d0 = this.getDeltaMovement().lengthSqr(); if (flag && d0 > 1.0) { BlockHitResult blockhitresult = this.level() -@@ -161,7 +_,7 @@ +@@ -168,7 +_,7 @@ this ) ); diff --git a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch index 55b39f2d98..56636824e5 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -49,6 +_,10 @@ +@@ -56,6 +_,10 @@ @Nullable private UUID target; public final float bobOffs; @@ -11,7 +11,7 @@ public ItemEntity(EntityType p_31991_, Level p_31992_) { super(p_31991_, p_31992_); -@@ -67,6 +_,7 @@ +@@ -74,6 +_,7 @@ this.setPos(p_149664_, p_149665_, p_149666_); this.setDeltaMovement(p_149668_, p_149669_, p_149670_); this.setItem(p_149667_); @@ -19,7 +19,7 @@ } private ItemEntity(ItemEntity p_31994_) { -@@ -75,6 +_,7 @@ +@@ -82,6 +_,7 @@ this.copyPosition(p_31994_); this.age = p_31994_.age; this.bobOffs = p_31994_.bobOffs; @@ -27,7 +27,7 @@ } @Override -@@ -120,6 +_,7 @@ +@@ -127,6 +_,7 @@ @Override public void tick() { @@ -35,7 +35,7 @@ if (this.getItem().isEmpty()) { this.discard(); } else { -@@ -132,6 +_,10 @@ +@@ -139,6 +_,10 @@ this.yo = this.getY(); this.zo = this.getZ(); Vec3 vec3 = this.getDeltaMovement(); @@ -46,7 +46,7 @@ if (this.isInWater() && this.getFluidHeight(FluidTags.WATER) > 0.1F) { this.setUnderwaterMovement(); } else if (this.isInLava() && this.getFluidHeight(FluidTags.LAVA) > 0.1F) { -@@ -154,7 +_,8 @@ +@@ -161,7 +_,8 @@ this.applyEffectsFromBlocks(); float f = 0.98F; if (this.onGround()) { @@ -55,8 +55,8 @@ + f = this.level().getBlockState(groundPos).getFriction(level(), groundPos, this) * 0.98F; } - this.setDeltaMovement(this.getDeltaMovement().multiply((double)f, 0.98, (double)f)); -@@ -186,7 +_,16 @@ + this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.98, f)); +@@ -193,7 +_,16 @@ } } @@ -74,8 +74,8 @@ this.discard(); } } -@@ -294,7 +_,7 @@ - this.health = (int)((float)this.health - p_362683_); +@@ -301,7 +_,7 @@ + this.health = (int)(this.health - p_362683_); this.gameEvent(GameEvent.ENTITY_DAMAGE, p_364841_.getEntity()); if (this.health <= 0) { - this.getItem().onDestroyed(this); @@ -83,26 +83,23 @@ this.discard(); } -@@ -312,6 +_,7 @@ +@@ -319,6 +_,7 @@ p_32050_.putShort("Health", (short)this.health); p_32050_.putShort("Age", (short)this.age); p_32050_.putShort("PickupDelay", (short)this.pickupDelay); + p_32050_.putInt("Lifespan", this.lifespan); - if (this.thrower != null) { - p_32050_.putUUID("Thrower", this.thrower); - } -@@ -333,6 +_,10 @@ - this.pickupDelay = p_32034_.getShort("PickupDelay"); - } - -+ if (p_32034_.contains("Lifespan")) { -+ this.lifespan = p_32034_.getInt("Lifespan"); -+ } -+ - if (p_32034_.hasUUID("Owner")) { - this.target = p_32034_.getUUID("Owner"); - } -@@ -357,10 +_,17 @@ + p_32050_.storeNullable("Thrower", UUIDUtil.CODEC, this.thrower); + p_32050_.storeNullable("Owner", UUIDUtil.CODEC, this.target); + if (!this.getItem().isEmpty()) { +@@ -332,6 +_,7 @@ + this.health = p_32034_.getShortOr("Health", (short)5); + this.age = p_32034_.getShortOr("Age", (short)0); + this.pickupDelay = p_32034_.getShortOr("PickupDelay", (short)0); ++ p_32034_.getInt("Lifespan").ifPresent(lifespan -> this.lifespan = lifespan); + this.target = p_32034_.read("Owner", UUIDUtil.CODEC).orElse(null); + this.thrower = p_32034_.read("Thrower", UUIDUtil.CODEC).orElse(null); + this.cachedThrower = null; +@@ -345,10 +_,17 @@ @Override public void playerTouch(Player p_32040_) { if (!this.level().isClientSide) { @@ -121,7 +118,7 @@ p_32040_.take(this, i); if (itemstack.isEmpty()) { this.discard(); -@@ -454,7 +_,7 @@ +@@ -442,7 +_,7 @@ public void makeFakeItem() { this.setNeverPickUp(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Bogged.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Bogged.java.patch index e2610cea20..594a49ba7f 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Bogged.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Bogged.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Bogged.java +++ b/net/minecraft/world/entity/monster/Bogged.java -@@ -70,7 +_,7 @@ +@@ -71,7 +_,7 @@ @Override protected InteractionResult mobInteract(Player p_335303_, InteractionHand p_335145_) { ItemStack itemstack = p_335303_.getItemInHand(p_335145_); @@ -9,7 +9,7 @@ if (this.level() instanceof ServerLevel serverlevel) { this.shear(serverlevel, SoundSource.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, p_335303_); -@@ -137,5 +_,17 @@ +@@ -138,5 +_,17 @@ @Override public boolean readyForShearing() { return !this.isSheared() && this.isAlive(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch index 8de742d7ee..1d2bccf5be 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/CrossbowAttackMob.java.patch @@ -11,5 +11,5 @@ + if (p_32337_.isHolding(is -> is.getItem() instanceof CrossbowItem)) { + var crossbowitem = (CrossbowItem) itemstack.getItem(); crossbowitem.performShooting( - p_32337_.level(), p_32337_, interactionhand, itemstack, p_32338_, (float)(14 - p_32337_.level().getDifficulty().getId() * 4), this.getTarget() + p_32337_.level(), p_32337_, interactionhand, itemstack, p_32338_, 14 - p_32337_.level().getDifficulty().getId() * 4, this.getTarget() ); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch index 2d754dff48..4b35056700 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -113,7 +_,6 @@ +@@ -114,7 +_,6 @@ @Override public void setTarget(@Nullable LivingEntity p_32537_) { @@ -8,7 +8,7 @@ AttributeInstance attributeinstance = this.getAttribute(Attributes.MOVEMENT_SPEED); if (p_32537_ == null) { this.targetChangeTime = 0; -@@ -127,6 +_,7 @@ +@@ -128,6 +_,7 @@ attributeinstance.addTransientModifier(SPEED_MODIFIER_ATTACKING); } } @@ -16,7 +16,7 @@ } @Override -@@ -208,7 +_,7 @@ +@@ -203,7 +_,7 @@ } boolean isBeingStaredBy(Player p_368759_) { @@ -25,7 +25,7 @@ } @Override -@@ -286,8 +_,10 @@ +@@ -281,8 +_,10 @@ boolean flag = blockstate.blocksMotion(); boolean flag1 = blockstate.getFluidState().is(FluidTags.WATER); if (flag && !flag1) { @@ -37,7 +37,7 @@ if (flag2) { this.level().gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(this)); if (!this.isSilent()) { -@@ -440,7 +_,7 @@ +@@ -437,7 +_,7 @@ if (this.enderman.getCarriedBlock() == null) { return false; } else { @@ -46,7 +46,7 @@ } } -@@ -458,7 +_,7 @@ +@@ -455,7 +_,7 @@ BlockState blockstate2 = this.enderman.getCarriedBlock(); if (blockstate2 != null) { blockstate2 = Block.updateFromNeighbourShapes(blockstate2, this.enderman.level(), blockpos); @@ -55,7 +55,7 @@ level.setBlock(blockpos, blockstate2, 3); level.gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(this.enderman, blockstate2)); this.enderman.setCarriedBlock(null); -@@ -470,6 +_,7 @@ +@@ -467,6 +_,7 @@ return p_32562_.isAir() && !p_32563_.isAir() && !p_32563_.is(Blocks.BEDROCK) @@ -63,7 +63,7 @@ && 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(); -@@ -579,7 +_,7 @@ +@@ -576,7 +_,7 @@ if (this.enderman.getCarriedBlock() != null) { return false; } else { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch index 6e67393d92..ee04ffab5b 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Evoker.java +++ b/net/minecraft/world/entity/monster/Evoker.java -@@ -308,7 +_,7 @@ +@@ -300,7 +_,7 @@ return false; } else { ServerLevel serverlevel = getServerLevel(Evoker.this.level()); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch index ab2a3a37ff..8a4c413884 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Illusioner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Illusioner.java +++ b/net/minecraft/world/entity/monster/Illusioner.java -@@ -171,9 +_,12 @@ +@@ -169,9 +_,12 @@ @Override public void performRangedAttack(LivingEntity p_32918_, float p_32919_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch index 4958bcdd1a..ea351355dc 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/MagmaCube.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/MagmaCube.java +++ b/net/minecraft/world/entity/monster/MagmaCube.java @@ -71,17 +_,28 @@ - float f = (float)this.getSize() * 0.1F; - this.setDeltaMovement(vec3.x, (double)(this.getJumpPower() + f), vec3.z); + float f = this.getSize() * 0.1F; + this.setDeltaMovement(vec3.x, this.getJumpPower() + f, vec3.z); this.hasImpulse = true; + net.minecraftforge.common.ForgeHooks.onLivingJump(this); } @@ -17,7 +17,7 @@ + private void jumpInLiquidInternal(java.util.function.BooleanSupplier isLava, Runnable onSuper) { + if (isLava.getAsBoolean()) { Vec3 vec3 = this.getDeltaMovement(); - this.setDeltaMovement(vec3.x, (double)(0.22F + (float)this.getSize() * 0.05F), vec3.z); + this.setDeltaMovement(vec3.x, 0.22F + this.getSize() * 0.05F, vec3.z); this.hasImpulse = true; } else { - super.jumpInLiquid(p_204065_); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch index 29feef1ec9..6a7b9077cc 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -136,7 +_,7 @@ +@@ -139,7 +_,7 @@ this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Mth.lerp(0.1, d1, d0)); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch index 7d62f91964..57898694b6 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Shulker.java.patch +++ b/patches/minecraft/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 -@@ -389,6 +_,12 @@ +@@ -381,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/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch index 5f5c7eb560..df57972b65 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Silverfish.java +++ b/net/minecraft/world/entity/monster/Silverfish.java -@@ -143,7 +_,7 @@ +@@ -141,7 +_,7 @@ return false; } else { RandomSource randomsource = this.mob.getRandom(); @@ -9,7 +9,7 @@ this.selectedDirection = Direction.getRandom(randomsource); BlockPos blockpos = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5, this.mob.getZ()) .relative(this.selectedDirection); -@@ -216,7 +_,7 @@ +@@ -214,7 +_,7 @@ BlockState blockstate = level.getBlockState(blockpos1); Block block = blockstate.getBlock(); if (block instanceof InfestedBlock) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch index 541eb09220..64357fb2cc 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Skeleton.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/entity/monster/Skeleton.java +++ b/net/minecraft/world/entity/monster/Skeleton.java -@@ -89,6 +_,7 @@ +@@ -93,6 +_,7 @@ } protected void doFreezeConversion() { + if (!net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.STRAY, (timer) -> this.conversionTime = timer)) return; - this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), p_375136_ -> { + this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), p_390682_ -> { if (!this.isSilent()) { this.level().levelEvent(null, 1048, this.blockPosition(), 0); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch index b7cb2ca5de..e1b8573425 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Slime.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java -@@ -146,13 +_,15 @@ +@@ -147,13 +_,15 @@ float f = this.getDimensions(this.getPose()).width() * 2.0F; float f1 = f / 2.0F; -- for (int i = 0; (float)i < f * 16.0F; i++) { +- for (int i = 0; i < f * 16.0F; i++) { - float f2 = this.random.nextFloat() * (float) (Math.PI * 2); - float f3 = this.random.nextFloat() * 0.5F + 0.5F; - float f4 = Mth.sin(f2) * f1 * f3; - float f5 = Mth.cos(f2) * f1 * f3; -- this.level().addParticle(this.getParticleType(), this.getX() + (double)f4, this.getY(), this.getZ() + (double)f5, 0.0, 0.0, 0.0); +- this.level().addParticle(this.getParticleType(), this.getX() + f4, this.getY(), this.getZ() + f5, 0.0, 0.0, 0.0); - } + // Forge: Don't spawn particles if it's handled by the implementation itself + if (!spawnCustomParticles()) @@ -23,7 +23,7 @@ this.playSound(this.getSquishSound(), this.getSoundVolume(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); this.targetSquish = -0.5F; -@@ -163,6 +_,12 @@ +@@ -164,6 +_,12 @@ this.wasOnGround = this.onGround(); this.decreaseSquish(); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch index 7f1f2ab1cf..04b7a1252e 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Zombie.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Zombie.java +++ b/net/minecraft/world/entity/monster/Zombie.java -@@ -262,21 +_,28 @@ +@@ -266,21 +_,28 @@ } protected void convertToZombieType(EntityType p_34311_) { @@ -23,21 +23,21 @@ ZombieVillager zombievillager = p_360910_.convertTo(EntityType.ZOMBIE_VILLAGER, ConversionParams.single(p_360910_, true, true), p_359258_ -> { p_359258_.finalizeSpawn(p_369430_, p_369430_.getCurrentDifficultyAt(p_359258_.blockPosition()), EntitySpawnReason.CONVERSION, new Zombie.ZombieGroupData(false, true)); p_359258_.setVillagerData(p_360910_.getVillagerData()); - p_359258_.setGossips(p_360910_.getGossips().store(NbtOps.INSTANCE)); + p_359258_.setGossips(p_360910_.getGossips().copy()); p_359258_.setTradeOffers(p_360910_.getOffers().copy()); p_359258_.setVillagerXp(p_360910_.getVillagerXp()); + net.minecraftforge.event.ForgeEventFactory.onLivingConvert(p_360910_, p_359258_); if (!this.isSilent()) { p_369430_.levelEvent(null, 1026, this.blockPosition(), 0); } -@@ -298,19 +_,26 @@ +@@ -302,19 +_,26 @@ livingentity = (LivingEntity)p_363403_.getEntity(); } - if (livingentity != null + var vanilla = (livingentity != null && p_363771_.getDifficulty() == Difficulty.HARD - && (double)this.random.nextFloat() < this.getAttributeValue(Attributes.SPAWN_REINFORCEMENTS_CHANCE) + && this.random.nextFloat() < this.getAttributeValue(Attributes.SPAWN_REINFORCEMENTS_CHANCE) - && p_363771_.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { + && p_363771_.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)); int i = Mth.floor(this.getX()); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch index 29995ca1f2..be8df9992a 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/patches/minecraft/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 -@@ -137,7 +_,7 @@ +@@ -114,7 +_,7 @@ if (!this.level().isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); this.villagerConversionTime -= i; @@ -9,7 +9,7 @@ this.finishConversion((ServerLevel)this.level()); } } -@@ -244,6 +_,7 @@ +@@ -221,6 +_,7 @@ if (!this.isSilent()) { p_34399_.levelEvent(null, 1027, this.blockPosition(), 0); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/creaking/Creaking.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/creaking/Creaking.java.patch index 2e543386c2..9ef048f28f 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/creaking/Creaking.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/creaking/Creaking.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/creaking/Creaking.java +++ b/net/minecraft/world/entity/monster/creaking/Creaking.java -@@ -507,7 +_,7 @@ +@@ -488,7 +_,7 @@ for (Player player : list) { if (this.canAttack(player) && !this.isAlliedTo(player)) { flag1 = true; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch index aafb49dd92..40c36b8855 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -166,7 +_,7 @@ +@@ -169,7 +_,7 @@ HoglinAi.updateActivity(this); if (this.isConverting()) { this.timeInOverworld++; @@ -9,14 +9,14 @@ this.makeSound(SoundEvents.HOGLIN_CONVERTED_TO_ZOMBIFIED); this.finishConversion(); } -@@ -264,7 +_,10 @@ +@@ -267,7 +_,10 @@ this.convertTo( EntityType.ZOGLIN, ConversionParams.single(this, true, false), -- p_365626_ -> p_365626_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)) -+ p_365626_ -> { -+ p_365626_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_365626_); +- p_390697_ -> p_390697_.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)) ++ p_390697_ -> { ++ p_390697_.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_390697_); + } ); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch index 3d65b6811c..d8260c891a 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java -@@ -82,7 +_,7 @@ +@@ -85,7 +_,7 @@ this.timeInOverworld = 0; } @@ -9,14 +9,14 @@ this.playConvertedSound(); this.finishConversion(p_360786_); } -@@ -101,7 +_,10 @@ +@@ -104,7 +_,10 @@ this.convertTo( EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), -- p_369673_ -> p_369673_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)) -+ p_369673_ -> { -+ p_369673_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); -+ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_369673_); +- p_390698_ -> p_390698_.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)) ++ p_390698_ -> { ++ p_390698_.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)); ++ net.minecraftforge.event.ForgeEventFactory.onLivingConvert(this, p_390698_); + } ); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index 36910d5361..d47c5dbe95 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -359,7 +_,7 @@ +@@ -356,7 +_,7 @@ } else if (this.isChargingCrossbow()) { return PiglinArmPose.CROSSBOW_CHARGE; } else { @@ -9,7 +9,7 @@ } } -@@ -396,7 +_,7 @@ +@@ -393,7 +_,7 @@ } protected void holdInOffHand(ItemStack p_34786_) { @@ -18,7 +18,7 @@ this.setItemSlot(EquipmentSlot.OFFHAND, p_34786_); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -406,7 +_,7 @@ +@@ -403,7 +_,7 @@ @Override public boolean wantsToPickUp(ServerLevel p_369934_, ItemStack p_34777_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch index e2113d0edc..de9a55aa5c 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java -@@ -632,7 +_,7 @@ +@@ -634,7 +_,7 @@ public static boolean isWearingSafeArmor(LivingEntity p_365495_) { - for (ItemStack itemstack : p_365495_.getArmorAndBodyArmorSlots()) { -- if (itemstack.is(ItemTags.PIGLIN_SAFE_ARMOR)) { -+ if (itemstack.makesPiglinsNeutral(p_365495_)) { + for (EquipmentSlot equipmentslot : EquipmentSlotGroup.ARMOR) { +- if (p_365495_.getItemBySlot(equipmentslot).is(ItemTags.PIGLIN_SAFE_ARMOR)) { ++ if (p_365495_.getItemBySlot(equipmentslot).makesPiglinsNeutral(p_365495_)) { return true; } } -@@ -776,7 +_,7 @@ +@@ -778,7 +_,7 @@ } private static boolean hasCrossbow(LivingEntity p_34919_) { @@ -18,7 +18,7 @@ } private static void admireGoldItem(LivingEntity p_34939_) { -@@ -788,7 +_,7 @@ +@@ -790,7 +_,7 @@ } private static boolean isBarterCurrency(ItemStack p_149968_) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch deleted file mode 100644 index c97dd00ccd..0000000000 --- a/patches/minecraft/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java -+++ b/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java -@@ -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_359309_, p_359310_, p_359311_) -> { -- if (!p_359310_.getOffhandItem().isEmpty() && !p_359310_.getOffhandItem().is(Items.SHIELD)) { -+ if (!p_359310_.getOffhandItem().isEmpty() && !p_359310_.getOffhandItem().canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK)) { - PiglinAi.stopHoldingOffHandItem(p_359309_, p_359310_, true); - return true; - } else { diff --git a/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch index 0318a221ed..3776cf66bf 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ b/patches/minecraft/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 +_,8 @@ +@@ -123,6 +_,8 @@ if (this.tradingPlayer instanceof ServerPlayer) { CriteriaTriggers.TRADE.trigger((ServerPlayer)this.tradingPlayer, this, p_35274_.getResult()); } diff --git a/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch index f15338a740..a23064d1fc 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/CatSpawner.java.patch @@ -1,12 +1,16 @@ --- a/net/minecraft/world/entity/npc/CatSpawner.java +++ b/net/minecraft/world/entity/npc/CatSpawner.java -@@ -83,8 +_,8 @@ - if (cat == null) { - return 0; - } else { -+ cat.moveTo(p_35334_, 0.0F, 0.0F); // Fix MC-147659: Some witch huts spawn the incorrect cat +@@ -69,12 +_,12 @@ + private void spawnCat(BlockPos p_35334_, ServerLevel p_35335_, boolean p_392522_) { + Cat cat = EntityType.CAT.create(p_35335_, EntitySpawnReason.NATURAL); + if (cat != null) { ++ cat.snapTo(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_), EntitySpawnReason.NATURAL, null); -- cat.moveTo(p_35334_, 0.0F, 0.0F); + if (p_392522_) { + cat.setPersistenceRequired(); + } + +- cat.snapTo(p_35334_, 0.0F, 0.0F); p_35335_.addFreshEntityWithPassengers(cat); - return 1; } + } diff --git a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch index 4368388b96..6b46d9396f 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch +++ b/patches/minecraft/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 -@@ -313,7 +_,7 @@ +@@ -320,7 +_,7 @@ @Override public InteractionResult mobInteract(Player p_35472_, InteractionHand p_35473_) { ItemStack itemstack = p_35472_.getItemInHand(p_35473_); @@ -9,22 +9,12 @@ return super.mobInteract(p_35472_, p_35473_); } else if (this.isBaby()) { this.setUnhappy(); -@@ -712,7 +_,8 @@ - - @Override - protected Component getTypeName() { -- return Component.translatable(this.getType().getDescriptionId() + "." + BuiltInRegistries.VILLAGER_PROFESSION.getKey(this.getVillagerData().getProfession()).getPath()); -+ var profName = net.minecraftforge.registries.ForgeRegistries.VILLAGER_PROFESSIONS.getKey(this.getVillagerData().getProfession()); -+ return Component.translatable(this.getType().getDescriptionId() + '.' + (!"minecraft".equals(profName.getNamespace()) ? profName.getNamespace() + '.' : "") + profName.getPath()); - } - - @Override -@@ -770,7 +_,7 @@ +@@ -766,7 +_,7 @@ @Override public void thunderHit(ServerLevel p_35409_, LightningBolt p_35410_) { - if (p_35409_.getDifficulty() != Difficulty.PEACEFUL) { + if (p_35409_.getDifficulty() != Difficulty.PEACEFUL && net.minecraftforge.event.ForgeEventFactory.canLivingConvert(this, EntityType.WITCH, (timer) -> {})) { LOGGER.info("Villager {} was struck by lightning {}.", this, p_35410_); - Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), p_375163_ -> { - p_375163_.finalizeSpawn(p_35409_, p_35409_.getCurrentDifficultyAt(p_375163_.blockPosition()), EntitySpawnReason.CONVERSION, null); + Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), p_390723_ -> { + p_390723_.finalizeSpawn(p_35409_, p_35409_.getCurrentDifficultyAt(p_390723_.blockPosition()), EntitySpawnReason.CONVERSION, null); diff --git a/patches/minecraft/net/minecraft/world/entity/npc/VillagerTrades.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/VillagerTrades.java.patch index 8348b0f418..e7f6b3fa37 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/VillagerTrades.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/VillagerTrades.java.patch @@ -1,21 +1,30 @@ --- a/net/minecraft/world/entity/npc/VillagerTrades.java +++ b/net/minecraft/world/entity/npc/VillagerTrades.java -@@ -1367,6 +_,7 @@ +@@ -855,7 +_,7 @@ + 5 + ) + ) +- .build(); ++ .build().stream().collect(net.minecraft.Util.toMutableList()); // Forge: Turned into an ArrayList so it can be modified in VillagerTradingManager + public static final Map, Int2ObjectMap> EXPERIMENTAL_TRADES = Map.of( + VillagerProfession.LIBRARIAN, + toIntMap( +@@ -1280,6 +_,7 @@ private final int villagerXp; - public EmeraldsForVillagerTypeItem(int p_35669_, int p_35670_, int p_35671_, Map p_35672_) { + public EmeraldsForVillagerTypeItem(int p_35669_, int p_35670_, int p_35671_, Map, Item> p_35672_) { + if (false) // FORGE: Modders can add custom villager types, so remove this validation - BuiltInRegistries.VILLAGER_TYPE.stream().filter(p_35680_ -> !p_35672_.containsKey(p_35680_)).findAny().ifPresent(p_327046_ -> { - throw new IllegalStateException("Missing trade for villager type: " + BuiltInRegistries.VILLAGER_TYPE.getKey(p_327046_)); + BuiltInRegistries.VILLAGER_TYPE.registryKeySet().stream().filter(p_397256_ -> !p_35672_.containsKey(p_397256_)).findAny().ifPresent(p_390730_ -> { + throw new IllegalStateException("Missing trade for villager type: " + p_390730_); }); -@@ -1380,7 +_,9 @@ - @Override - public MerchantOffer getOffer(Entity p_219685_, RandomSource p_219686_) { - if (p_219685_ instanceof VillagerDataHolder villagerdataholder) { -- ItemCost itemcost = new ItemCost(this.trades.get(villagerdataholder.getVillagerData().getType()), this.cost); -+ Item item = this.trades.get(villagerdataholder.getVillagerData().getType()); -+ if (item == null) return null; // FORGE: Account for modded villager types by returning null if there is no trade -+ ItemCost itemcost = new ItemCost(item, this.cost); - return new MerchantOffer(itemcost, new ItemStack(Items.EMERALD), this.maxUses, this.villagerXp, 0.05F); +@@ -1297,7 +_,9 @@ + if (resourcekey == null) { + return null; + } else { +- ItemCost itemcost = new ItemCost(this.trades.get(resourcekey), this.cost); ++ Item item = this.trades.get(resourcekey); ++ if (item == null) return null; // FORGE: Account for modded villager types by returning null if there is no trade ++ ItemCost itemcost = new ItemCost(item, this.cost); + return new MerchantOffer(itemcost, new ItemStack(Items.EMERALD), this.maxUses, this.villagerXp, 0.05F); + } } else { - return null; diff --git a/patches/minecraft/net/minecraft/world/entity/npc/VillagerType.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/VillagerType.java.patch index ea3609eac6..72bb1c3e85 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/VillagerType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/VillagerType.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/entity/npc/VillagerType.java +++ b/net/minecraft/world/entity/npc/VillagerType.java -@@ -69,4 +_,9 @@ - public static VillagerType byBiome(Holder p_204074_) { +@@ -80,4 +_,9 @@ + public static ResourceKey byBiome(Holder p_204074_) { return p_204074_.unwrapKey().map(BY_BIOME::get).orElse(PLAINS); } + + /** FORGE: Registers the VillagerType that will spawn in the given biome. This method should be called during FMLCommonSetupEvent using event.enqueueWork() */ -+ public static void registerBiomeType(ResourceKey biomeKey, VillagerType villagerType) { ++ public static void registerBiomeType(ResourceKey biomeKey, ResourceKey villagerType) { + BY_BIOME.put(biomeKey, villagerType); + } } diff --git a/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch index 68283d9864..370906ddf1 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch @@ -1,6 +1,17 @@ --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java -@@ -123,7 +_,7 @@ +@@ -83,6 +_,10 @@ + return this.items; + } + ++ public EntityEquipment getEquipment() { ++ return this.equipment; ++ } ++ + private boolean hasRemainingSpaceForItem(ItemStack p_36015_, ItemStack p_36016_) { + return !p_36015_.isEmpty() && ItemStack.isSameItemSameComponents(p_36015_, p_36016_) && p_36015_.isStackable() && p_36015_.getCount() < this.getMaxStackSize(p_36015_); + } +@@ -158,7 +_,7 @@ for (int k = 0; k < 9; k++) { int l = (this.selected + k) % 9; @@ -9,22 +20,16 @@ return l; } } -@@ -195,11 +_,13 @@ - } - - public void tick() { -+ int idx = 0; - for (NonNullList nonnulllist : this.compartments) { - for (int i = 0; i < nonnulllist.size(); i++) { - if (!nonnulllist.get(i).isEmpty()) { -- nonnulllist.get(i).inventoryTick(this.player.level(), this.player, i, this.selected == i); -+ nonnulllist.get(i).onInventoryTick(this.player.level(), this.player, idx, this.selected); - } -+ idx++; +@@ -229,7 +_,7 @@ + for (int i = 0; i < this.items.size(); i++) { + ItemStack itemstack = this.getItem(i); + if (!itemstack.isEmpty()) { +- itemstack.inventoryTick(this.player.level(), this.player, i == this.selected ? EquipmentSlot.MAINHAND : null); ++ itemstack.inventoryTick(this.player.level(), this.player, i == this.selected ? EquipmentSlot.MAINHAND : null, i); } } } -@@ -249,6 +_,8 @@ +@@ -279,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/minecraft/net/minecraft/world/entity/player/Player.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch index f85ad116b2..76dc34bb00 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch @@ -1,25 +1,43 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -117,7 +_,7 @@ +@@ -118,7 +_,7 @@ + import net.minecraft.world.scores.Scoreboard; import net.minecraft.world.scores.Team; - import org.slf4j.Logger; -public abstract class Player extends LivingEntity { +public abstract class Player extends LivingEntity implements net.minecraftforge.common.extensions.IForgePlayer { - private static final Logger LOGGER = LogUtils.getLogger(); public static final HumanoidArm DEFAULT_MAIN_HAND = HumanoidArm.RIGHT; public static final int DEFAULT_MODEL_CUSTOMIZATION = 0; -@@ -198,6 +_,9 @@ + public static final int MAX_HEALTH = 20; +@@ -207,6 +_,9 @@ public Entity currentExplosionCause; - private boolean ignoreFallDamageFromCurrentImpulse; - private int currentImpulseContextResetGraceTime; + private boolean ignoreFallDamageFromCurrentImpulse = false; + private int currentImpulseContextResetGraceTime = 0; + private final java.util.Collection prefixes = new java.util.LinkedList<>(); + private final java.util.Collection suffixes = new java.util.LinkedList<>(); + @Nullable private Pose forcedPose; public Player(Level p_250508_, BlockPos p_250289_, float p_251702_, GameProfile p_252153_) { super(EntityType.PLAYER, p_250508_); -@@ -230,11 +_,12 @@ +@@ -216,6 +_,17 @@ + this.inventoryMenu = new InventoryMenu(this.inventory, !p_250508_.isClientSide, this); + this.containerMenu = this.inventoryMenu; + this.snapTo(p_250289_.getX() + 0.5, p_250289_.getY() + 1, p_250289_.getZ() + 0.5, p_251702_, 0.0F); ++ ++ // Forge: wrapped inventories moved to constructor as the inventory init was moved in here too ++ this.playerMainHandler = net.minecraftforge.common.util.LazyOptional.of( ++ () -> new net.minecraftforge.items.wrapper.PlayerMainInvWrapper(inventory)); ++ this.playerEquipmentHandler = net.minecraftforge.common.util.LazyOptional.of( ++ () -> new net.minecraftforge.items.wrapper.PlayerEquipmentInvWrapper(inventory)); ++ this.playerJoinedHandler = net.minecraftforge.common.util.LazyOptional.of( ++ () -> new net.minecraftforge.items.wrapper.CombinedInvWrapper( ++ new net.minecraftforge.items.wrapper.PlayerMainInvWrapper(inventory), ++ new net.minecraftforge.items.wrapper.PlayerEquipmentInvWrapper(inventory) ++ )); + } + + @Override +@@ -244,11 +_,12 @@ .add(Attributes.LUCK) .add(Attributes.BLOCK_INTERACTION_RANGE, 4.5) .add(Attributes.ENTITY_INTERACTION_RANGE, 3.0) @@ -34,7 +52,7 @@ } @Override -@@ -250,6 +_,7 @@ +@@ -264,6 +_,7 @@ @Override public void tick() { @@ -42,16 +60,16 @@ this.noPhysics = this.isSpectator(); if (this.isSpectator() || this.isPassenger()) { this.setOnGround(false); -@@ -265,7 +_,7 @@ +@@ -279,7 +_,7 @@ this.sleepCounter = 100; } -- if (!this.level().isClientSide && this.level().isDay()) { +- if (!this.level().isClientSide && this.level().isBrightOutside()) { + if (!this.level().isClientSide && !net.minecraftforge.event.ForgeEventFactory.onSleepingTimeCheck(this, getSleepingPos())) { this.stopSleepInBed(false, true); } } else if (this.sleepCounter > 0) { -@@ -326,6 +_,7 @@ +@@ -340,6 +_,7 @@ if (this.currentImpulseContextResetGraceTime > 0) { this.currentImpulseContextResetGraceTime--; } @@ -59,7 +77,7 @@ } @Override -@@ -428,6 +_,10 @@ +@@ -442,6 +_,10 @@ } protected void updatePlayerPose() { @@ -68,9 +86,9 @@ + return; + } if (this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.SWIMMING)) { - Pose pose; - if (this.isFallFlying()) { -@@ -655,6 +_,7 @@ + Pose pose = this.getDesiredPose(); + Pose pose1; +@@ -660,6 +_,7 @@ @Override public void die(DamageSource p_36152_) { @@ -78,7 +96,7 @@ super.die(p_36152_); this.reapplyPosition(); if (!this.isSpectator() && this.level() instanceof ServerLevel serverlevel) { -@@ -712,7 +_,7 @@ +@@ -717,10 +_,15 @@ @Nullable public ItemEntity drop(ItemStack p_36177_, boolean p_36178_) { @@ -86,21 +104,16 @@ + return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, p_36177_, p_36178_); } - @Nullable -@@ -724,7 +_,12 @@ - return null; - } - + /** @deprecated Use {@link #getDestroySpeed(BlockState,BlockPos) */ public float getDestroySpeed(BlockState p_36282_) { + return getDestroySpeed(p_36282_, null); + } + + public float getDestroySpeed(BlockState p_36282_, @Nullable BlockPos pos) { - float f = this.inventory.getDestroySpeed(p_36282_); + float f = this.inventory.getSelectedItem().getDestroySpeed(p_36282_); if (f > 1.0F) { f += (float)this.getAttributeValue(Attributes.MINING_EFFICIENCY); -@@ -753,11 +_,14 @@ +@@ -749,11 +_,14 @@ f /= 5.0F; } @@ -110,13 +123,13 @@ } public boolean hasCorrectToolForDrops(BlockState p_36299_) { -- return !p_36299_.requiresCorrectToolForDrops() || this.inventory.getSelected().isCorrectToolForDrops(p_36299_); -+ var vanilla = !p_36299_.requiresCorrectToolForDrops() || this.inventory.getSelected().isCorrectToolForDrops(p_36299_); +- return !p_36299_.requiresCorrectToolForDrops() || this.inventory.getSelectedItem().isCorrectToolForDrops(p_36299_); ++ var vanilla = !p_36299_.requiresCorrectToolForDrops() || this.inventory.getSelectedItem().isCorrectToolForDrops(p_36299_); + return net.minecraftforge.event.ForgeEventFactory.doPlayerHarvestCheck(this, p_36299_, vanilla); } @Override -@@ -858,6 +_,7 @@ +@@ -831,6 +_,7 @@ @Override public boolean hurtServer(ServerLevel p_369360_, DamageSource p_364544_, float p_368576_) { @@ -124,38 +137,7 @@ if (this.isInvulnerableTo(p_369360_, p_364544_)) { return false; } else if (this.abilities.invulnerable && !p_364544_.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { -@@ -891,7 +_,7 @@ - protected void blockUsingShield(LivingEntity p_36295_) { - super.blockUsingShield(p_36295_); - ItemStack itemstack = this.getItemBlockingWith(); -- if (p_36295_.canDisableShield() && itemstack != null) { -+ if (itemstack != null && p_36295_.getWeaponItem().canDisableShield(itemstack, this, p_36295_)) { - this.disableShield(itemstack); - } - } -@@ -923,7 +_,7 @@ - - @Override - protected void hurtCurrentlyUsedShield(float p_36383_) { -- if (this.useItem.is(Items.SHIELD)) { -+ if (this.useItem.canPerformAction(net.minecraftforge.common.ToolActions.SHIELD_BLOCK)) { - if (!this.level().isClientSide) { - this.awardStat(Stats.ITEM_USED.get(this.useItem.getItem())); - } -@@ -931,8 +_,11 @@ - if (p_36383_ >= 3.0F) { - int i = 1 + Mth.floor(p_36383_); - InteractionHand interactionhand = this.getUsedItemHand(); -+ // FORGE: cache this.useItem -- if this.stopUsingItem() is called, it will be set to ItemStack.EMPTY -+ ItemStack currentItem = this.useItem; - this.useItem.hurtAndBreak(i, this, getSlotForHand(interactionhand)); -- if (this.useItem.isEmpty()) { -+ // FORGE: use cached item since this.useItem could be ItemStack.EMPTY -+ if (currentItem.isEmpty()) { - if (interactionhand == InteractionHand.MAIN_HAND) { - this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); - } else { -@@ -949,10 +_,13 @@ +@@ -899,10 +_,13 @@ @Override protected void actuallyHurt(ServerLevel p_365751_, DamageSource p_36312_, float p_36313_) { if (!this.isInvulnerableTo(p_365751_, p_36312_)) { @@ -169,7 +151,7 @@ float f = p_36313_ - f1; if (f > 0.0F && f < 3.4028235E37F) { this.awardStat(Stats.DAMAGE_ABSORBED, Math.round(f * 10.0F)); -@@ -1011,6 +_,10 @@ +@@ -967,6 +_,10 @@ return InteractionResult.PASS; } else { @@ -180,7 +162,7 @@ ItemStack itemstack = this.getItemInHand(p_36159_); ItemStack itemstack1 = itemstack.copy(); InteractionResult interactionresult = p_36158_.interact(this, p_36159_); -@@ -1019,6 +_,10 @@ +@@ -975,6 +_,10 @@ itemstack.setCount(itemstack1.getCount()); } @@ -191,15 +173,15 @@ return interactionresult; } else { if (!itemstack.isEmpty() && p_36158_ instanceof LivingEntity) { -@@ -1030,6 +_,7 @@ +@@ -986,6 +_,7 @@ if (interactionresult1.consumesAction()) { this.level().gameEvent(GameEvent.ENTITY_INTERACT, p_36158_.position(), GameEvent.Context.of(this)); - if (itemstack.isEmpty() && !this.abilities.instabuild) { + if (itemstack.isEmpty() && !this.hasInfiniteMaterials()) { + net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, getSlotForHand(p_36159_)); this.setItemInHand(p_36159_, ItemStack.EMPTY); } -@@ -1129,6 +_,7 @@ +@@ -1085,6 +_,7 @@ } public void attack(Entity p_36347_) { @@ -207,56 +189,56 @@ if (p_36347_.isAttackable()) { if (!p_36347_.skipAttackInteraction(this)) { float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); -@@ -1166,8 +_,10 @@ - && !this.isPassenger() - && p_36347_ instanceof LivingEntity - && !this.isSprinting(); -+ var hitResult = net.minecraftforge.common.ForgeHooks.getCriticalHit(this, p_36347_, flag1, flag1 ? 1.5F : 1.0F); -+ flag1 = hitResult != null; - if (flag1) { -- f *= 1.5F; +@@ -1120,8 +_,10 @@ + && !this.isPassenger() + && p_36347_ instanceof LivingEntity + && !this.isSprinting(); ++ var hitResult = net.minecraftforge.common.ForgeHooks.getCriticalHit(this, p_36347_, flag1, flag1 ? 1.5F : 1.0F); ++ flag1 = hitResult != null; + if (flag1) { +- f *= 1.5F; + f *= hitResult.getDamageModifier(); - } - - float f3 = f + f1; -@@ -1175,7 +_,7 @@ - if (flag3 && !flag1 && !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)) { -+ if (d0 < Mth.square(d1) && this.getItemInHand(InteractionHand.MAIN_HAND).canPerformAction(net.minecraftforge.common.ToolActions.SWORD_SWEEP)) { - flag2 = true; } - } -@@ -1211,7 +_,7 @@ - if (flag2) { - float f7 = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * f; -- for (LivingEntity livingentity2 : this.level().getEntitiesOfClass(LivingEntity.class, p_36347_.getBoundingBox().inflate(1.0, 0.25, 1.0))) { + float f3 = f + f1; +@@ -1129,7 +_,7 @@ + if (flag3 && !flag1 && !flag && this.onGround()) { + double d0 = this.getKnownMovement().horizontalDistanceSqr(); + double d1 = this.getSpeed() * 2.5; +- if (d0 < Mth.square(d1) && this.getItemInHand(InteractionHand.MAIN_HAND).is(ItemTags.SWORDS)) { ++ if (d0 < Mth.square(d1) && this.getItemInHand(InteractionHand.MAIN_HAND).canPerformAction(net.minecraftforge.common.ToolActions.SWORD_SWEEP)) { + flag2 = true; + } + } +@@ -1165,7 +_,7 @@ + if (flag2) { + float f6 = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * f; + +- for (LivingEntity livingentity2 : this.level().getEntitiesOfClass(LivingEntity.class, p_36347_.getBoundingBox().inflate(1.0, 0.25, 1.0))) { + for (LivingEntity livingentity2 : this.level().getEntitiesOfClass(LivingEntity.class, this.getItemInHand(InteractionHand.MAIN_HAND).getSweepHitBox(this, p_36347_))) { - if (livingentity2 != this - && livingentity2 != p_36347_ - && !this.isAlliedTo(livingentity2) -@@ -1261,8 +_,8 @@ + if (livingentity2 != this + && livingentity2 != p_36347_ + && !this.isAlliedTo(livingentity2) +@@ -1216,8 +_,8 @@ - this.setLastHurtMob(p_36347_); - Entity entity = p_36347_; -- if (p_36347_ instanceof EnderDragonPart) { -- entity = ((EnderDragonPart)p_36347_).parentMob; -+ if (p_36347_ instanceof net.minecraftforge.entity.PartEntity pe) { -+ entity = pe.getParent(); + this.setLastHurtMob(p_36347_); + Entity entity = p_36347_; +- if (p_36347_ instanceof EnderDragonPart) { +- entity = ((EnderDragonPart)p_36347_).parentMob; ++ if (p_36347_ instanceof net.minecraftforge.entity.PartEntity pe) { ++ entity = pe.getParent(); + } + + boolean flag5 = false; +@@ -1261,6 +_,7 @@ } - - boolean flag5 = false; -@@ -1303,6 +_,7 @@ - this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); } } + this.resetAttackStrengthTicker(); // FORGE: Moved from beginning of attack() so that getAttackStrengthScale() returns an accurate value during all attack events } } } -@@ -1387,6 +_,7 @@ +@@ -1363,6 +_,7 @@ } public void stopSleepInBed(boolean p_36226_, boolean p_36227_) { @@ -264,15 +246,15 @@ super.stopSleeping(); if (this.level() instanceof ServerLevel && p_36227_) { ((ServerLevel)this.level()).updateSleepingPlayerList(); -@@ -1495,6 +_,7 @@ +@@ -1471,6 +_,7 @@ @Override - public boolean causeFallDamage(float p_150093_, float p_150094_, DamageSource p_150095_) { + public boolean causeFallDamage(double p_391627_, float p_150093_, DamageSource p_150095_) { if (this.abilities.mayfly) { + net.minecraftforge.event.ForgeEventFactory.onPlayerFall(this, p_150093_, p_150093_); return false; } else { - if (p_150093_ >= 2.0F) { -@@ -1553,13 +_,13 @@ + if (p_391627_ >= 2.0) { +@@ -1525,13 +_,13 @@ protected void playStepSound(BlockPos p_282121_, BlockState p_282194_) { if (this.isInWater()) { this.waterSwimSound(); @@ -288,7 +270,7 @@ } else { super.playStepSound(blockpos, blockstate); } -@@ -1590,6 +_,12 @@ +@@ -1562,6 +_,12 @@ } public void giveExperiencePoints(int p_36291_) { @@ -299,9 +281,9 @@ + p_36291_ = event.getAmount(); + this.increaseScore(p_36291_); - this.experienceProgress = this.experienceProgress + (float)p_36291_ / (float)this.getXpNeededForNextLevel(); + this.experienceProgress = this.experienceProgress + (float)p_36291_ / this.getXpNeededForNextLevel(); this.totalExperience = Mth.clamp(this.totalExperience + p_36291_, 0, Integer.MAX_VALUE); -@@ -1617,7 +_,7 @@ +@@ -1589,7 +_,7 @@ } public void onEnchantmentPerformed(ItemStack p_36172_, int p_36173_) { @@ -310,7 +292,7 @@ if (this.experienceLevel < 0) { this.experienceLevel = 0; this.experienceProgress = 0.0F; -@@ -1628,6 +_,12 @@ +@@ -1600,6 +_,12 @@ } public void giveExperienceLevels(int p_36276_) { @@ -323,7 +305,7 @@ this.experienceLevel = IntMath.saturatedAdd(this.experienceLevel, p_36276_); if (this.experienceLevel < 0) { this.experienceLevel = 0; -@@ -1831,7 +_,13 @@ +@@ -1772,7 +_,13 @@ @Override public Component getDisplayName() { @@ -338,7 +320,7 @@ return this.decorateDisplayNameComponent(mutablecomponent); } -@@ -1994,18 +_,19 @@ +@@ -1934,18 +_,19 @@ Predicate predicate = ((ProjectileWeaponItem)p_36349_.getItem()).getSupportedHeldProjectiles(); ItemStack itemstack = ProjectileWeaponItem.getHeldProjectile(this, predicate); if (!itemstack.isEmpty()) { @@ -355,13 +337,13 @@ } } -- return this.abilities.instabuild ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; +- return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; + var vanilla = this.abilities.instabuild ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; + return net.minecraftforge.common.ForgeHooks.getProjectile(this, p_36349_, vanilla); } } } -@@ -2150,6 +_,65 @@ +@@ -2090,6 +_,54 @@ this.currentImpulseImpactPos = null; this.ignoreFallDamageFromCurrentImpulse = false; } @@ -384,18 +366,7 @@ + } + + private final net.minecraftforge.common.util.LazyOptional -+ playerMainHandler = net.minecraftforge.common.util.LazyOptional.of( -+ () -> new net.minecraftforge.items.wrapper.PlayerMainInvWrapper(inventory)); -+ -+ private final net.minecraftforge.common.util.LazyOptional -+ playerEquipmentHandler = net.minecraftforge.common.util.LazyOptional.of( -+ () -> new net.minecraftforge.items.wrapper.CombinedInvWrapper( -+ new net.minecraftforge.items.wrapper.PlayerArmorInvWrapper(inventory), -+ new net.minecraftforge.items.wrapper.PlayerOffhandInvWrapper(inventory))); -+ -+ private final net.minecraftforge.common.util.LazyOptional -+ playerJoinedHandler = net.minecraftforge.common.util.LazyOptional.of( -+ () -> new net.minecraftforge.items.wrapper.PlayerInvWrapper(inventory)); ++ playerMainHandler, playerEquipmentHandler, playerJoinedHandler; + + @Override + public net.minecraftforge.common.util.LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) { diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index 783805bbf7..88de33c31c 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/patches/minecraft/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 -@@ -73,6 +_,7 @@ +@@ -79,6 +_,7 @@ private ItemStack pickupItemStack = this.getDefaultPickupItem(); @Nullable private ItemStack firedFromWeapon = null; @@ -8,7 +8,7 @@ protected AbstractArrow(EntityType p_332730_, Level p_335646_) { super(p_332730_, p_335646_); -@@ -191,7 +_,7 @@ +@@ -192,7 +_,7 @@ this.shakeTime--; } @@ -17,7 +17,7 @@ this.clearFire(); } -@@ -556,7 +_,7 @@ +@@ -569,7 +_,7 @@ protected boolean canHitEntity(Entity p_36743_) { return p_36743_ instanceof Player && this.getOwner() instanceof Player player && !player.canHarmPlayer((Player)p_36743_) ? false diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch index c4d1526934..8597d0ba1d 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/patches/minecraft/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 -@@ -310,6 +_,13 @@ +@@ -311,6 +_,13 @@ } @Override diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch index 5dcc8c1f31..40497d89ef 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/patches/minecraft/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 -@@ -244,8 +_,8 @@ +@@ -240,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 { -@@ -256,6 +_,7 @@ +@@ -252,6 +_,7 @@ private void checkCollision() { HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); @@ -19,7 +19,7 @@ this.hitTargetOrDeflectSelf(hitresult); } -@@ -445,6 +_,7 @@ +@@ -441,6 +_,7 @@ Player player = this.getPlayerOwner(); if (!this.level().isClientSide && player != null && !this.shouldStopFishing(player)) { int i = 0; @@ -27,12 +27,12 @@ if (this.hookedIn != null) { this.pullEntity(this.hookedIn); CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, Collections.emptyList()); -@@ -455,10 +_,16 @@ +@@ -451,10 +_,16 @@ .withParameter(LootContextParams.ORIGIN, this.position()) .withParameter(LootContextParams.TOOL, p_37157_) .withParameter(LootContextParams.THIS_ENTITY, this) + .withParameter(LootContextParams.ATTACKING_ENTITY, this.getOwner()) - .withLuck((float)this.luck + player.getLuck()) + .withLuck(this.luck + player.getLuck()) .create(LootContextParamSets.FISHING); LootTable loottable = this.level().getServer().reloadableRegistries().getLootTable(BuiltInLootTables.FISHING); List list = loottable.getRandomItems(lootparams); @@ -44,7 +44,7 @@ CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, list); for (ItemStack itemstack : list) { -@@ -488,7 +_,7 @@ +@@ -484,7 +_,7 @@ } this.discard(); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch index 33c5d6b7fb..b8614a0aac 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/LargeFireball.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/LargeFireball.java +++ b/net/minecraft/world/entity/projectile/LargeFireball.java -@@ -29,7 +_,7 @@ +@@ -30,7 +_,7 @@ protected void onHit(HitResult p_37218_) { super.onHit(p_37218_); if (this.level() instanceof ServerLevel serverlevel) { - boolean flag = serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, this.getOwner()); - this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float)this.explosionPower, flag, Level.ExplosionInteraction.MOB); + this.level().explode(this, this.getX(), this.getY(), this.getZ(), this.explosionPower, flag, Level.ExplosionInteraction.MOB); this.discard(); } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch index 61ef3eb469..72473625b2 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -359,7 +_,7 @@ +@@ -367,7 +_,7 @@ @Override public boolean mayInteract(ServerLevel p_364907_, BlockPos p_150168_) { Entity entity = this.getOwner(); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch index f6985a6649..30bf7b7e13 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/ShulkerBullet.java -@@ -230,7 +_,7 @@ +@@ -223,7 +_,7 @@ this.handlePortal(); } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch index 42f244ae6d..41d4112127 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ThrowableProjectile.java +++ b/net/minecraft/world/entity/projectile/ThrowableProjectile.java -@@ -58,7 +_,7 @@ +@@ -59,7 +_,7 @@ this.updateRotation(); this.applyEffectsFromBlocks(); super.tick(); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch index 88101b1bf5..46ce19cf0b 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -126,6 +_,13 @@ +@@ -122,6 +_,13 @@ Vec3 vec3 = this.oldPosition(); if (entity instanceof ServerPlayer serverplayer) { if (serverplayer.connection.isAcceptingMessages()) { @@ -14,7 +14,7 @@ if (this.random.nextFloat() < 0.05F && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { Endermite endermite = EntityType.ENDERMITE.create(serverlevel, EntitySpawnReason.TRIGGERED); if (endermite != null) { -@@ -152,7 +_,7 @@ +@@ -148,7 +_,7 @@ if (serverplayer1 != null) { serverplayer1.resetFallDistance(); serverplayer1.resetCurrentImpulseContext(); diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch index 7567adc030..7cb895596a 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/WitherSkull.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/WitherSkull.java +++ b/net/minecraft/world/entity/projectile/WitherSkull.java -@@ -47,7 +_,7 @@ +@@ -48,7 +_,7 @@ @Override public float getBlockExplosionResistance(Explosion p_37619_, BlockGetter p_37620_, BlockPos p_37621_, BlockState p_37622_, FluidState p_37623_, float p_37624_) { diff --git a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch index 4ec96972b2..2549652b4f 100644 --- a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -827,7 +_,7 @@ +@@ -801,7 +_,7 @@ } } @@ -9,7 +9,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}), -@@ -841,6 +_,20 @@ +@@ -815,6 +_,20 @@ private RaiderType(final EntityType p_37821_, final int[] p_37822_) { this.entityType = p_37821_; this.spawnsPerWaveBeforeBonus = p_37822_; diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch index 76fb83c64e..9ced25eb96 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/AbstractBoat.java +++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java -@@ -45,7 +_,7 @@ +@@ -47,7 +_,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,7 @@ 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); -@@ -476,7 +_,7 @@ +@@ -424,7 +_,7 @@ for (int i2 = i1; i2 < j1; i2++) { blockpos$mutableblockpos.set(l1, k1, i2); FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); @@ -18,7 +18,7 @@ f = Math.max(f, fluidstate.getHeight(this.level(), blockpos$mutableblockpos)); } -@@ -522,7 +_,7 @@ +@@ -470,7 +_,7 @@ voxelshape, BooleanOp.AND )) { @@ -27,25 +27,25 @@ k1++; } } -@@ -551,7 +_,7 @@ +@@ -499,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); + float f = l1 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos); this.waterLevel = Math.max((double)f, this.waterLevel); - flag |= aabb.minY < (double)f; -@@ -581,7 +_,7 @@ + flag |= aabb.minY < f; +@@ -529,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))) { + && d0 < blockpos$mutableblockpos.getY() + fluidstate.getHeight(this.level(), blockpos$mutableblockpos)) { if (!fluidstate.isSource()) { return AbstractBoat.Status.UNDER_FLOWING_WATER; -@@ -786,7 +_,7 @@ +@@ -732,7 +_,7 @@ if (!this.isPassenger()) { if (p_361999_) { this.resetFallDistance(); @@ -54,7 +54,7 @@ this.fallDistance -= (float)p_361830_; } } -@@ -810,7 +_,7 @@ +@@ -756,7 +_,7 @@ @Override protected boolean canAddPassenger(Entity p_366021_) { diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch index 05a6dad8b0..705d6c807f 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -43,7 +_,7 @@ +@@ -44,7 +_,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -public abstract class AbstractMinecart extends VehicleEntity { +public abstract class AbstractMinecart extends VehicleEntity implements net.minecraftforge.common.extensions.IForgeAbstractMinecart { 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); -@@ -75,15 +_,12 @@ - p_38135_.put(RailShape.NORTH_WEST, Pair.of(vec3i2, vec3i)); - p_38135_.put(RailShape.NORTH_EAST, Pair.of(vec3i2, vec3i1)); - }); + private static final EntityDataAccessor> DATA_ID_CUSTOM_DISPLAY_BLOCK = SynchedEntityData.defineId( + AbstractMinecart.class, EntityDataSerializers.OPTIONAL_BLOCK_STATE +@@ -94,15 +_,12 @@ + } + ) + ); + private boolean canBePushed = true; protected AbstractMinecart(EntityType p_38087_, Level p_38088_) { @@ -27,7 +27,7 @@ } protected AbstractMinecart(EntityType p_38090_, Level p_38091_, double p_38092_, double p_38093_, double p_38094_) { -@@ -147,7 +_,7 @@ +@@ -165,7 +_,7 @@ @Override public boolean isPushable() { @@ -36,7 +36,7 @@ } @Override -@@ -366,16 +_,24 @@ +@@ -355,16 +_,24 @@ } protected void comeOffTrack(ServerLevel p_365684_) { @@ -63,7 +63,7 @@ } } -@@ -431,7 +_,7 @@ +@@ -420,7 +_,7 @@ public Vec3 getRedstoneDirection(BlockPos p_369874_) { BlockState blockstate = this.level().getBlockState(p_369874_); if (blockstate.is(Blocks.POWERED_RAIL) && blockstate.getValue(PoweredRailBlock.POWERED)) { @@ -72,7 +72,7 @@ if (railshape == RailShape.EAST_WEST) { if (this.isRedstoneConductor(p_369874_.west())) { return new Vec3(1.0, 0.0, 0.0); -@@ -614,5 +_,42 @@ +@@ -596,5 +_,42 @@ public boolean isFurnace() { return false; diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch index 03227892c3..2157ea10eb 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/ChestBoat.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/entity/vehicle/ChestBoat.java @@ -15,4 +_,26 @@ protected double rideHeight(EntityDimensions p_362135_) { - return (double)(p_362135_.height() / 3.0F); + return p_362135_.height() / 3.0F; } + + private net.minecraftforge.common.util.LazyOptional itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new net.minecraftforge.items.wrapper.InvWrapper(this)); diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch index 342d2413e8..d90c85b995 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java -@@ -105,6 +_,9 @@ +@@ -103,6 +_,9 @@ this.setContainerLootTable(null); LootParams.Builder lootparams$builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position()); diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch index 483ff2ae1d..0ca2f907bf 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/vehicle/MinecartFurnace.java +++ b/net/minecraft/world/entity/vehicle/MinecartFurnace.java -@@ -146,4 +_,9 @@ +@@ -148,4 +_,9 @@ public BlockState getDefaultDisplayBlockState() { - return Blocks.FURNACE.defaultBlockState().setValue(FurnaceBlock.FACING, Direction.NORTH).setValue(FurnaceBlock.LIT, Boolean.valueOf(this.hasFuel())); + return Blocks.FURNACE.defaultBlockState().setValue(FurnaceBlock.FACING, Direction.NORTH).setValue(FurnaceBlock.LIT, this.hasFuel()); } + + @Override diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch index bd2ea5d75d..2bf8ce0c9d 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch @@ -9,7 +9,7 @@ Pair pair = AbstractMinecart.exits(railshape); Vec3 vec3 = new Vec3(pair.getFirst()).scale(0.5); Vec3 vec31 = new Vec3(pair.getSecond()).scale(0.5); -@@ -262,11 +_,11 @@ +@@ -260,11 +_,11 @@ if (flag) { this.minecart.resetFallDistance(); this.minecart.setOldPosAndRot(); @@ -23,7 +23,7 @@ Vec3 vec31 = this.calculateTrackSpeed(p_369629_, vec3.horizontal(), newminecartbehavior$trackiteration, blockpos, blockstate, railshape); if (newminecartbehavior$trackiteration.firstIteration) { newminecartbehavior$trackiteration.movementLeft = vec31.horizontalDistance(); -@@ -395,7 +_,7 @@ +@@ -393,7 +_,7 @@ } private Vec3 calculateHaltTrackSpeed(Vec3 p_364212_, BlockState p_362846_) { @@ -32,7 +32,7 @@ return p_364212_.length() < 0.03 ? Vec3.ZERO : p_364212_.scale(0.5); } else { return p_364212_; -@@ -403,7 +_,7 @@ +@@ -401,7 +_,7 @@ } private Vec3 calculateBoostTrackSpeed(Vec3 p_366761_, BlockPos p_361866_, BlockState p_368734_) { @@ -41,7 +41,7 @@ if (p_366761_.length() > 0.01) { return p_366761_.normalize().scale(p_366761_.length() + 0.06); } else { -@@ -455,7 +_,7 @@ +@@ -453,7 +_,7 @@ BlockState blockstate = this.level().getBlockState(BlockPos.containing(vec36)); if (flag) { if (BaseRailBlock.isRail(blockstate)) { diff --git a/patches/minecraft/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch b/patches/minecraft/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch index b2cef1abdc..3e3629afde 100644 --- a/patches/minecraft/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java +++ b/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java -@@ -95,9 +_,9 @@ +@@ -60,9 +_,9 @@ BlockState blockstate = this.level().getBlockState(blockpos); boolean $$4 = BaseRailBlock.isRail(blockstate); this.minecart.setOnRails($$4); @@ -12,8 +12,8 @@ this.minecart.activateMinecart(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockstate.getValue(PoweredRailBlock.POWERED)); } } else { -@@ -148,18 +_,19 @@ - d1 = (double)blockpos.getY(); +@@ -112,18 +_,19 @@ + d1 = blockpos.getY(); boolean flag = false; boolean flag1 = false; - if (blockstate.is(Blocks.POWERED_RAIL)) { @@ -35,7 +35,7 @@ switch (railshape) { case ASCENDING_EAST: this.setDeltaMovement(vec31.add(-d3, 0.0, 0.0)); -@@ -211,7 +_,7 @@ +@@ -175,7 +_,7 @@ } } @@ -44,7 +44,7 @@ double d20 = this.getDeltaMovement().horizontalDistance(); if (d20 < 0.03) { this.setDeltaMovement(Vec3.ZERO); -@@ -240,10 +_,7 @@ +@@ -204,10 +_,7 @@ d0 = d21 + d4 * d12; d2 = d9 + d5 * d12; this.setPos(d0, d1, d2); @@ -56,8 +56,8 @@ if (vec3i.getY() != 0 && Mth.floor(this.minecart.getX()) - blockpos.getX() == vec3i.getX() && Mth.floor(this.minecart.getZ()) - blockpos.getZ() == vec3i.getZ()) { -@@ -275,7 +_,11 @@ - this.setDeltaMovement(d25 * (double)(j - blockpos.getX()), vec36.y, d25 * (double)(i - blockpos.getZ())); +@@ -239,7 +_,11 @@ + this.setDeltaMovement(d25 * (j - blockpos.getX()), vec36.y, d25 * (i - blockpos.getZ())); } - if (flag) { @@ -69,16 +69,16 @@ Vec3 vec37 = this.getDeltaMovement(); double d26 = vec37.horizontalDistance(); if (d26 > 0.01) { -@@ -319,7 +_,7 @@ +@@ -283,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.minecart); - p_364195_ = (double)j; + p_364195_ = j; if (railshape.isSlope()) { - p_364195_ = (double)(j + 1); -@@ -358,7 +_,7 @@ + p_364195_ = j + 1; +@@ -322,7 +_,7 @@ BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); if (BaseRailBlock.isRail(blockstate)) { @@ -87,7 +87,7 @@ Pair pair = AbstractMinecart.exits(railshape); Vec3i vec3i = pair.getFirst(); Vec3i vec3i1 = pair.getSecond(); -@@ -449,5 +_,20 @@ +@@ -415,5 +_,20 @@ @Override public double getSlowdownFactor() { return this.minecart.isVehicle() ? 0.997 : 0.96; diff --git a/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index 573a4d5b18..73ac30974b 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -433,6 +_,7 @@ +@@ -441,6 +_,7 @@ ItemStack itemstack10 = this.getCarried(); p_150434_.updateTutorialInventoryAction(itemstack10, slot7.getItem(), clickaction); if (!this.tryItemClickBehaviourOverride(p_150434_, clickaction, slot7, itemstack9, itemstack10)) { @@ -8,7 +8,7 @@ if (itemstack9.isEmpty()) { if (!itemstack10.isEmpty()) { int i3 = clickaction == ClickAction.PRIMARY ? itemstack10.getCount() : 1; -@@ -653,7 +_,7 @@ +@@ -650,7 +_,7 @@ ItemStack itemstack = slot.getItem(); if (!itemstack.isEmpty() && ItemStack.isSameItemSameComponents(p_38904_, itemstack)) { int j = itemstack.getCount() + p_38904_.getCount(); diff --git a/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch index 547166272e..21256f0080 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -18,9 +18,9 @@ BlockState blockstate1 = AnvilBlock.damage(blockstate); if (blockstate1 == null) { p_150479_.removeBlock(p_150480_, false); -@@ -125,8 +_,11 @@ - j += (long)itemstack.getOrDefault(DataComponents.REPAIR_COST, Integer.valueOf(0)).intValue() - + (long)itemstack2.getOrDefault(DataComponents.REPAIR_COST, Integer.valueOf(0)).intValue(); +@@ -124,8 +_,11 @@ + ItemEnchantments.Mutable itemenchantments$mutable = new ItemEnchantments.Mutable(EnchantmentHelper.getEnchantmentsForCrafting(itemstack1)); + j += (long)itemstack.getOrDefault(DataComponents.REPAIR_COST, 0).intValue() + itemstack2.getOrDefault(DataComponents.REPAIR_COST, 0).intValue(); this.repairItemCountCost = 0; + boolean flag = false; + @@ -31,7 +31,7 @@ if (itemstack1.isDamageableItem() && itemstack.isValidRepairItem(itemstack2)) { int l2 = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); if (l2 <= 0) { -@@ -230,6 +_,10 @@ +@@ -229,6 +_,10 @@ itemstack1.remove(DataComponents.CUSTOM_NAME); } @@ -39,10 +39,10 @@ + itemstack1 = ItemStack.EMPTY; + } + - int k2 = i <= 0 ? 0 : (int)Mth.clamp(j + (long)i, 0L, 2147483647L); + int k2 = i <= 0 ? 0 : (int)Mth.clamp(j + i, 0L, 2147483647L); this.cost.set(k2); if (i <= 0) { -@@ -302,5 +_,9 @@ +@@ -301,5 +_,9 @@ public int getCost() { return this.cost.get(); diff --git a/patches/minecraft/net/minecraft/world/inventory/ArmorSlot.java.patch b/patches/minecraft/net/minecraft/world/inventory/ArmorSlot.java.patch index 59f3ccbc88..00c8151fba 100644 --- a/patches/minecraft/net/minecraft/world/inventory/ArmorSlot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/ArmorSlot.java.patch @@ -4,7 +4,7 @@ @Override public boolean mayPlace(ItemStack p_344267_) { -- return this.slot == this.owner.getEquipmentSlotForItem(p_344267_); +- return this.owner.isEquippableInSlot(p_344267_, this.slot); + return p_344267_.canEquip(slot, owner); } diff --git a/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch index 6f681e40c5..460e2871be 100644 --- a/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -23,7 +23,7 @@ } } - this.random.setSeed((long)this.enchantmentSeed.get()); + this.random.setSeed(this.enchantmentSeed.get()); for (int k = 0; k < 3; k++) { - this.costs[k] = EnchantmentHelper.getEnchantmentCost(this.random, k, j, itemstack); diff --git a/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch b/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch index 5143d99708..bb560d646d 100644 --- a/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch @@ -3,7 +3,7 @@ @@ -51,6 +_,7 @@ protected void checkTakeAchievements(ItemStack p_40185_) { if (this.removeCount > 0) { - p_40185_.onCraftedBy(this.player.level(), this.player, this.removeCount); + p_40185_.onCraftedBy(this.player, this.removeCount); + net.minecraftforge.event.ForgeEventFactory.firePlayerCraftingEvent(this.player, p_40185_, this.craftSlots); } diff --git a/patches/minecraft/net/minecraft/world/item/AnimalArmorItem.java.patch b/patches/minecraft/net/minecraft/world/item/AnimalArmorItem.java.patch deleted file mode 100644 index 4cd44d3722..0000000000 --- a/patches/minecraft/net/minecraft/world/item/AnimalArmorItem.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/world/item/AnimalArmorItem.java -+++ b/net/minecraft/world/item/AnimalArmorItem.java -@@ -27,7 +_,7 @@ - return this.bodyType.breakingSound; - } - -- public static enum BodyType { -+ public static enum BodyType implements net.minecraftforge.common.IExtensibleEnum { - EQUESTRIAN(SoundEvents.ITEM_BREAK, EntityType.HORSE), - CANINE(SoundEvents.WOLF_ARMOR_BREAK, EntityType.WOLF); - -@@ -37,6 +_,10 @@ - private BodyType(final SoundEvent p_335661_, final EntityType... p_364750_) { - this.breakingSound = p_335661_; - this.allowedEntities = HolderSet.direct(EntityType::builtInRegistryHolder, p_364750_); -+ } -+ -+ public static BodyType create(String name, SoundEvent sound, EntityType... types) { -+ throw new IllegalStateException("Enum not extended"); - } - } - } diff --git a/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch b/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch index f802e5bc9e..bd9001072b 100644 --- a/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/AxeItem.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/item/AxeItem.java +++ b/net/minecraft/world/item/AxeItem.java @@ -62,7 +_,8 @@ - if (playerHasShieldUseIntent(p_40529_)) { + if (playerHasBlockingItemUseIntent(p_40529_)) { return InteractionResult.PASS; } else { - Optional optional = this.evaluateNewBlockState(level, blockpos, player, level.getBlockState(blockpos)); diff --git a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch index 2ee13fedb2..a1becfb7f0 100644 --- a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch +++ b/patches/minecraft/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 -@@ -79,9 +_,9 @@ +@@ -77,9 +_,9 @@ } } @@ -12,7 +12,7 @@ ); level.gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(player, blockstate1)); itemstack.consume(1, player); -@@ -91,10 +_,16 @@ +@@ -89,10 +_,16 @@ } } @@ -29,7 +29,7 @@ @Nullable public BlockPlaceContext updatePlacementContext(BlockPlaceContext p_40609_) { return p_40609_; -@@ -202,6 +_,10 @@ +@@ -193,6 +_,10 @@ public void registerBlocks(Map p_40607_, Item p_40608_) { p_40607_.put(this.getBlock(), p_40608_); diff --git a/patches/minecraft/net/minecraft/world/item/BowItem.java.patch b/patches/minecraft/net/minecraft/world/item/BowItem.java.patch index 60e6b0ec66..dc8ed330ba 100644 --- a/patches/minecraft/net/minecraft/world/item/BowItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BowItem.java.patch @@ -8,7 +8,7 @@ + if (i < 0) return false; + float f = getPowerForTime(i); - if ((double)f < 0.1) { + if (f < 0.1) { return false; @@ -89,6 +_,8 @@ public InteractionResult use(Level p_40672_, Player p_40673_, InteractionHand p_40674_) { diff --git a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch index 739b92b946..0f89e29902 100644 --- a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BucketItem.java +++ b/net/minecraft/world/item/BucketItem.java -@@ -31,15 +_,29 @@ +@@ -32,15 +_,29 @@ public class BucketItem extends Item implements DispensibleContainerItem { private final Fluid content; @@ -30,7 +30,7 @@ if (blockhitresult.getType() == HitResult.Type.MISS) { return InteractionResult.PASS; } else if (blockhitresult.getType() != HitResult.Type.BLOCK) { -@@ -56,7 +_,7 @@ +@@ -57,7 +_,7 @@ ItemStack itemstack3 = bucketpickup.pickupBlock(p_40704_, p_40703_, blockpos, blockstate1); if (!itemstack3.isEmpty()) { p_40704_.awardStat(Stats.ITEM_USED.get(this)); @@ -39,7 +39,7 @@ p_40703_.gameEvent(p_40704_, GameEvent.FLUID_PICKUP, blockpos); ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, p_40704_, itemstack3); if (!p_40703_.isClientSide) { -@@ -70,8 +_,8 @@ +@@ -71,8 +_,8 @@ return InteractionResult.FAIL; } else { BlockState blockstate = p_40703_.getBlockState(blockpos); @@ -50,53 +50,53 @@ this.checkExtraContent(p_40704_, p_40703_, itemstack, blockpos2); if (p_40704_ instanceof ServerPlayer) { CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)p_40704_, blockpos2, itemstack); -@@ -95,8 +_,13 @@ - public void checkExtraContent(@Nullable Player p_150711_, Level p_150712_, ItemStack p_150713_, BlockPos p_150714_) { +@@ -96,8 +_,13 @@ + public void checkExtraContent(@Nullable LivingEntity p_397951_, Level p_150712_, ItemStack p_150713_, BlockPos p_150714_) { } + @Deprecated //Forge: use the ItemStack sensitive version @Override - public boolean emptyContents(@Nullable Player p_150716_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_) { -+ return this.emptyContents(p_150716_, p_150717_, p_150718_, p_150719_, null); + public boolean emptyContents(@Nullable LivingEntity p_392717_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_) { ++ return this.emptyContents(p_392717_, p_150717_, p_150718_, p_150719_, null); + } + -+ public boolean emptyContents(@Nullable Player p_150716_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_, @Nullable ItemStack container) { ++ public boolean emptyContents(@Nullable LivingEntity p_392717_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_, @Nullable ItemStack container) { if (!(this.content instanceof FlowingFluid flowingfluid)) { return false; } else { -@@ -123,8 +_,12 @@ - } - - boolean flag1 = flag2; +@@ -108,8 +_,12 @@ + || $$8 + || $$7 instanceof LiquidBlockContainer liquidblockcontainer + && liquidblockcontainer.canPlaceLiquid(p_392717_, p_150717_, p_150718_, blockstate, this.content); + java.util.Optional containedFluidStack = java.util.Optional.ofNullable(container).flatMap(net.minecraftforge.fluids.FluidUtil::getFluidContained); if (!flag1) { -- return p_150719_ != null && this.emptyContents(p_150716_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), null); -+ return p_150719_ != null && this.emptyContents(p_150716_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), null, container); +- return p_150719_ != null && this.emptyContents(p_392717_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), null); ++ return p_150719_ != null && this.emptyContents(p_392717_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), null, container); + } else if (containedFluidStack.isPresent() && this.content.getFluidType().isVaporizedOnPlacement(p_150717_, p_150718_, containedFluidStack.get())) { -+ this.content.getFluidType().onVaporize(p_150716_, p_150717_, p_150718_, containedFluidStack.get()); ++ this.content.getFluidType().onVaporize(p_392717_, p_150717_, p_150718_, containedFluidStack.get()); + return true; } else if (p_150717_.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { int l = p_150718_.getX(); int i = p_150718_.getY(); -@@ -144,7 +_,7 @@ +@@ -128,7 +_,7 @@ + } return true; - } else { -- if ($$7 instanceof LiquidBlockContainer liquidblockcontainer1 && this.content == Fluids.WATER) { -+ if ($$7 instanceof LiquidBlockContainer liquidblockcontainer1 && liquidblockcontainer1.canPlaceLiquid(p_150716_, p_150717_, p_150718_, blockstate, content) && this.content == Fluids.WATER) { - liquidblockcontainer1.placeLiquid(p_150717_, p_150718_, blockstate, flowingfluid.getSource(false)); - this.playEmptySound(p_150716_, p_150717_, p_150718_); - return true; -@@ -166,7 +_,32 @@ +- } else if ($$7 instanceof LiquidBlockContainer liquidblockcontainer1 && this.content == Fluids.WATER) { ++ } else if ($$7 instanceof LiquidBlockContainer liquidblockcontainer1 && liquidblockcontainer1.canPlaceLiquid(p_392717_, p_150717_, p_150718_, blockstate, content) && this.content == Fluids.WATER) { + liquidblockcontainer1.placeLiquid(p_150717_, p_150718_, blockstate, flowingfluid.getSource(false)); + this.playEmptySound(p_392717_, p_150717_, p_150718_); + return true; +@@ -149,7 +_,32 @@ - protected void playEmptySound(@Nullable Player p_40696_, LevelAccessor p_40697_, BlockPos p_40698_) { + protected void playEmptySound(@Nullable LivingEntity p_393933_, LevelAccessor p_40697_, BlockPos p_40698_) { SoundEvent soundevent = this.content.is(FluidTags.LAVA) ? SoundEvents.BUCKET_EMPTY_LAVA : SoundEvents.BUCKET_EMPTY; -+ var custom = this.content.getFluidType().getSound(p_40696_, p_40697_, p_40698_, net.minecraftforge.common.SoundActions.BUCKET_EMPTY); ++ var custom = this.content.getFluidType().getSound(p_393933_, p_40697_, p_40698_, net.minecraftforge.common.SoundActions.BUCKET_EMPTY); + if (custom != null) { + soundevent = custom; + } - p_40697_.playSound(p_40696_, p_40698_, soundevent, SoundSource.BLOCKS, 1.0F, 1.0F); - p_40697_.gameEvent(p_40696_, GameEvent.FLUID_PLACE, p_40698_); + p_40697_.playSound(p_393933_, p_40698_, soundevent, SoundSource.BLOCKS, 1.0F, 1.0F); + p_40697_.gameEvent(p_393933_, GameEvent.FLUID_PLACE, p_40698_); + } + + /** Forge: TODO: Forge ItemStack capabilities - Lex 042724 diff --git a/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch b/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch index b9b75883e1..0e18379e1f 100644 --- a/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BundleItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BundleItem.java +++ b/net/minecraft/world/item/BundleItem.java -@@ -85,6 +_,7 @@ +@@ -86,6 +_,7 @@ @Override public boolean overrideOtherStackedOnMe(ItemStack p_150742_, ItemStack p_150743_, Slot p_150744_, ClickAction p_150745_, Player p_150746_, SlotAccess p_150747_) { diff --git a/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch index 30cc27326e..1a68e187e9 100644 --- a/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch +++ b/patches/minecraft/net/minecraft/world/item/CreativeModeTab.java.patch @@ -81,9 +81,9 @@ + } + public static class Builder { - private static final CreativeModeTab.DisplayItemsGenerator EMPTY_GENERATOR = (p_270422_, p_259433_) -> { - }; -@@ -136,6 +_,14 @@ + private static final CreativeModeTab.DisplayItemsGenerator EMPTY_GENERATOR = (p_270422_, p_259433_) -> {}; + private final CreativeModeTab.Row row; +@@ -135,6 +_,14 @@ private boolean alignedRight = false; private CreativeModeTab.Type type = CreativeModeTab.Type.CATEGORY; private ResourceLocation backgroundTexture = CreativeModeTab.DEFAULT_BACKGROUND; @@ -98,7 +98,7 @@ public Builder(CreativeModeTab.Row p_259171_, int p_259661_) { this.row = p_259171_; -@@ -174,6 +_,9 @@ +@@ -173,6 +_,9 @@ protected CreativeModeTab.Builder type(CreativeModeTab.Type p_259283_) { this.type = p_259283_; @@ -108,7 +108,7 @@ return this; } -@@ -182,13 +_,78 @@ +@@ -181,13 +_,78 @@ return this; } diff --git a/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch b/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch index 47c8da301d..f29e9cbbe8 100644 --- a/patches/minecraft/net/minecraft/world/item/CrossbowItem.java.patch +++ b/patches/minecraft/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 -@@ -186,6 +_,7 @@ +@@ -163,6 +_,7 @@ Level p_40888_, LivingEntity p_40889_, InteractionHand p_40890_, ItemStack p_40891_, float p_40892_, float p_40893_, @Nullable LivingEntity p_329478_ ) { if (p_40888_ instanceof ServerLevel serverlevel) { diff --git a/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch b/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch index d04842eb0a..8fd8f55a4c 100644 --- a/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/DispensibleContainerItem.java.patch @@ -6,9 +6,9 @@ -public interface DispensibleContainerItem { +public interface DispensibleContainerItem extends net.minecraftforge.common.extensions.IForgeDispensibleContainerItem { - default void checkExtraContent(@Nullable Player p_150817_, Level p_150818_, ItemStack p_150819_, BlockPos p_150820_) { + default void checkExtraContent(@Nullable LivingEntity p_391486_, Level p_150818_, ItemStack p_150819_, BlockPos p_150820_) { } + @Deprecated //Forge: use the ItemStack sensitive version - boolean emptyContents(@Nullable Player p_150821_, Level p_150822_, BlockPos p_150823_, @Nullable BlockHitResult p_150824_); + boolean emptyContents(@Nullable LivingEntity p_396492_, Level p_150822_, BlockPos p_150823_, @Nullable BlockHitResult p_150824_); } diff --git a/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch index 7b449c98f9..4d25cd6a57 100644 --- a/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch +++ b/patches/minecraft/net/minecraft/world/item/DyeColor.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/DyeColor.java +++ b/net/minecraft/world/item/DyeColor.java -@@ -49,6 +_,8 @@ +@@ -52,6 +_,8 @@ private final int textureDiffuseColor; private final int fireworkColor; private final int textColor; @@ -9,7 +9,7 @@ private DyeColor(final int p_41046_, final String p_41047_, final int p_41048_, final MapColor p_285297_, final int p_41050_, final int p_41051_) { this.id = p_41046_; -@@ -57,6 +_,8 @@ +@@ -60,6 +_,8 @@ this.textColor = p_41051_; this.textureDiffuseColor = ARGB.opaque(p_41048_); this.fireworkColor = p_41050_; @@ -18,7 +18,7 @@ } public int getId() { -@@ -107,6 +_,27 @@ +@@ -110,6 +_,27 @@ @Override public String getSerializedName() { return this.name; diff --git a/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch b/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch index 8a0ac05b5d..4e76a0ba91 100644 --- a/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/HoeItem.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/HoeItem.java +++ b/net/minecraft/world/item/HoeItem.java -@@ -23,6 +_,12 @@ +@@ -22,6 +_,12 @@ import net.minecraft.world.level.gameevent.GameEvent; - public class HoeItem extends DiggerItem { + public class HoeItem extends Item { + /** + * @deprecated Forge: This map is patched out of vanilla code. + * Listen to {@link net.minecraftforge.event.world.BlockEvent.BlockToolModificationEvent} @@ -13,7 +13,7 @@ protected static final Map, Consumer>> TILLABLES = Maps.newHashMap( ImmutableMap.of( Blocks.GRASS_BLOCK, -@@ -46,7 +_,8 @@ +@@ -45,7 +_,8 @@ public InteractionResult useOn(UseOnContext p_41341_) { Level level = p_41341_.getLevel(); BlockPos blockpos = p_41341_.getClickedPos(); @@ -23,7 +23,7 @@ if (pair == null) { return InteractionResult.PASS; } else { -@@ -86,5 +_,10 @@ +@@ -85,5 +_,10 @@ public static boolean onlyIfAirAbove(UseOnContext p_150857_) { return p_150857_.getClickedFace() != Direction.DOWN && p_150857_.getLevel().getBlockState(p_150857_.getClickedPos().above()).isAir(); diff --git a/patches/minecraft/net/minecraft/world/item/Item.java.patch b/patches/minecraft/net/minecraft/world/item/Item.java.patch index 7751ee45bd..03fb323212 100644 --- a/patches/minecraft/net/minecraft/world/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Item.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/Item.java +++ b/net/minecraft/world/item/Item.java -@@ -70,7 +_,7 @@ +@@ -83,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import org.slf4j.Logger; @@ -9,18 +9,16 @@ public static final Codec> CODEC = BuiltInRegistries.ITEM .holderByNameCodec() .validate( -@@ -79,7 +_,9 @@ - : DataResult.success(p_361655_) +@@ -93,7 +_,7 @@ ); + public static final StreamCodec> STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.ITEM); private static final Logger LOGGER = LogUtils.getLogger(); - public static final Map BY_BLOCK = Maps.newHashMap(); -+ public static final net.minecraft.network.codec.StreamCodec> STREAM_CODEC = -+ net.minecraft.network.codec.ByteBufCodecs.holderRegistry(net.minecraft.core.registries.Registries.ITEM); + public static final Map BY_BLOCK = net.minecraftforge.registries.GameData.ItemCallbacks.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; -@@ -116,6 +_,7 @@ +@@ -131,6 +_,7 @@ LOGGER.error("Item classes should end with Item and {} doesn't.", s); } } @@ -28,7 +26,7 @@ } @Deprecated -@@ -123,17 +_,25 @@ +@@ -138,17 +_,25 @@ return this.builtInRegistryHolder; } @@ -56,7 +54,7 @@ public void onDestroyed(ItemEntity p_150887_) { } -@@ -239,6 +_,8 @@ +@@ -264,6 +_,8 @@ return BuiltInRegistries.ITEM.wrapAsHolder(this).getRegisteredName(); } @@ -65,7 +63,7 @@ public final ItemStack getCraftingRemainder() { return this.craftingRemainingItem == null ? ItemStack.EMPTY : new ItemStack(this.craftingRemainingItem); } -@@ -322,6 +_,30 @@ +@@ -354,6 +_,30 @@ return false; } @@ -96,7 +94,7 @@ public static class Properties { private static final DependantName BLOCK_DESCRIPTION_ID = p_367498_ -> Util.makeDescriptionId("block", p_367498_.location()); private static final DependantName ITEM_DESCRIPTION_ID = p_367603_ -> Util.makeDescriptionId("item", p_367603_.location()); -@@ -482,6 +_,11 @@ +@@ -584,6 +_,11 @@ @Nullable MapItemSavedData mapData(MapId p_335695_); @@ -108,7 +106,7 @@ static Item.TooltipContext of(@Nullable final Level p_332083_) { return p_332083_ == null ? EMPTY : new Item.TooltipContext() { @Override -@@ -497,6 +_,11 @@ +@@ -599,6 +_,11 @@ @Override public MapItemSavedData mapData(MapId p_330171_) { return p_332083_.getMapData(p_330171_); diff --git a/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch b/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch index 04af35d83d..c536db2c89 100644 --- a/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ItemDisplayContext.java.patch @@ -28,9 +28,9 @@ } @Override -@@ -38,4 +_,29 @@ - public boolean firstPerson() { - return this == FIRST_PERSON_LEFT_HAND || this == FIRST_PERSON_RIGHT_HAND; +@@ -42,4 +_,29 @@ + public boolean leftHand() { + return this == FIRST_PERSON_LEFT_HAND || this == THIRD_PERSON_LEFT_HAND; } + + private final boolean isModded; diff --git a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch index 2ced7bd6f2..71385af3c4 100644 --- a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -97,7 +_,7 @@ +@@ -99,7 +_,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; @@ -9,7 +9,7 @@ private static final List OP_NBT_WARNING = List.of( Component.translatable("item.op_warning.line1").withStyle(ChatFormatting.RED, ChatFormatting.BOLD), Component.translatable("item.op_warning.line2").withStyle(ChatFormatting.RED), -@@ -261,13 +_,16 @@ +@@ -269,13 +_,16 @@ } private ItemStack(ItemLike p_331826_, int p_332766_, PatchedDataComponentMap p_333722_) { @@ -26,7 +26,7 @@ this.item = null; this.components = new PatchedDataComponentMap(DataComponentMap.EMPTY); } -@@ -357,13 +_,22 @@ +@@ -361,13 +_,22 @@ } public InteractionResult useOn(UseOnContext p_41662_) { @@ -78,7 +78,7 @@ return p_362423_ > 0 ? EnchantmentHelper.processDurabilityChange(p_364910_, this, p_362423_) : p_362423_; } } -@@ -516,7 +_,13 @@ +@@ -515,7 +_,13 @@ p_41623_, serverlevel, p_41624_ instanceof ServerPlayer serverplayer ? serverplayer : null, @@ -93,16 +93,15 @@ ); } } -@@ -876,6 +_,8 @@ - list.addAll(OP_NBT_WARNING); - } - +@@ -838,6 +_,7 @@ + List list = Lists.newArrayList(); + list.add(this.getStyledHoverName()); + this.addDetailsToTooltip(p_331329_, tooltipdisplay, p_41652_, p_41653_, list::add); + net.minecraftforge.event.ForgeEventFactory.onItemTooltip(this, p_41652_, list, p_41653_); -+ return list; } } -@@ -1102,6 +_,7 @@ +@@ -1134,6 +_,7 @@ this.getItem().onUseTick(p_41732_, p_41733_, this, p_41734_); } diff --git a/patches/minecraft/net/minecraft/world/item/Items.java.patch b/patches/minecraft/net/minecraft/world/item/Items.java.patch index 93e1bdc37a..e8a170960c 100644 --- a/patches/minecraft/net/minecraft/world/item/Items.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Items.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/Items.java +++ b/net/minecraft/world/item/Items.java -@@ -2078,7 +_,25 @@ +@@ -2097,7 +_,25 @@ } public static Item registerBlock(Block p_252092_, Block... p_248886_) { @@ -27,7 +27,7 @@ for (Block block : p_248886_) { Item.BY_BLOCK.put(block, item); -@@ -2117,10 +_,6 @@ +@@ -2136,10 +_,6 @@ public static Item registerItem(ResourceKey p_364577_, Function p_366144_, Item.Properties p_369845_) { Item item = p_366144_.apply(p_369845_.setId(p_364577_)); diff --git a/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch index a48818eed9..15470fd311 100644 --- a/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/MobBucketItem.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/MobBucketItem.java +++ b/net/minecraft/world/item/MobBucketItem.java -@@ -26,13 +_,18 @@ +@@ -18,13 +_,18 @@ + import net.minecraft.world.level.material.Fluid; public class MobBucketItem extends BucketItem { - private static final MapCodec VARIANT_FIELD_CODEC = TropicalFish.Variant.CODEC.fieldOf("BucketVariantTag"); - private final EntityType type; - private final SoundEvent emptySound; + private final java.util.function.Supplier> entityTypeSupplier; @@ -24,12 +24,12 @@ } @Override -@@ -45,11 +_,11 @@ +@@ -37,11 +_,11 @@ @Override - protected void playEmptySound(@Nullable Player p_151151_, LevelAccessor p_151152_, BlockPos p_151153_) { -- p_151152_.playSound(p_151151_, p_151153_, this.emptySound, SoundSource.NEUTRAL, 1.0F, 1.0F); -+ p_151152_.playSound(p_151151_, p_151153_, this.getEmptySound(), SoundSource.NEUTRAL, 1.0F, 1.0F); + protected void playEmptySound(@Nullable LivingEntity p_391719_, LevelAccessor p_151152_, BlockPos p_151153_) { +- p_151152_.playSound(p_391719_, p_151153_, this.emptySound, SoundSource.NEUTRAL, 1.0F, 1.0F); ++ p_151152_.playSound(p_391719_, p_151153_, this.getEmptySound(), SoundSource.NEUTRAL, 1.0F, 1.0F); } private void spawn(ServerLevel p_151142_, ItemStack p_151143_, BlockPos p_151144_) { @@ -38,18 +38,9 @@ if (mob instanceof Bucketable bucketable) { CustomData customdata = p_151143_.getOrDefault(DataComponents.BUCKET_ENTITY_DATA, CustomData.EMPTY); bucketable.loadFromBucketTag(customdata.copyTag()); -@@ -64,7 +_,7 @@ - - @Override - public void appendHoverText(ItemStack p_151155_, Item.TooltipContext p_329546_, List p_151157_, TooltipFlag p_151158_) { -- if (this.type == EntityType.TROPICAL_FISH) { -+ if (this.getFishType() == EntityType.TROPICAL_FISH) { - CustomData customdata = p_151155_.getOrDefault(DataComponents.BUCKET_ENTITY_DATA, CustomData.EMPTY); - if (customdata.isEmpty()) { - return; -@@ -92,5 +_,13 @@ - p_151157_.add(mutablecomponent); - } +@@ -52,5 +_,13 @@ + p_151142_.addFreshEntityWithPassengers(mob); + mob.playAmbientSound(); } + } + diff --git a/patches/minecraft/net/minecraft/world/item/PickaxeItem.java.patch b/patches/minecraft/net/minecraft/world/item/PickaxeItem.java.patch deleted file mode 100644 index c59bca667f..0000000000 --- a/patches/minecraft/net/minecraft/world/item/PickaxeItem.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/item/PickaxeItem.java -+++ b/net/minecraft/world/item/PickaxeItem.java -@@ -6,4 +_,9 @@ - public PickaxeItem(ToolMaterial p_363941_, float p_367504_, float p_368380_, Item.Properties p_42964_) { - super(p_363941_, BlockTags.MINEABLE_WITH_PICKAXE, p_367504_, p_368380_, p_42964_); - } -+ -+ @Override -+ public boolean canPerformAction(ItemStack stack, net.minecraftforge.common.ToolAction toolAction) { -+ return net.minecraftforge.common.ToolActions.DEFAULT_PICKAXE_ACTIONS.contains(toolAction); -+ } - } diff --git a/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch index 3f1301530d..66709dce0b 100644 --- a/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/ShearsItem.java +++ b/net/minecraft/world/item/ShearsItem.java -@@ -84,4 +_,34 @@ - - return super.useOn(p_186371_); +@@ -83,4 +_,34 @@ + return super.useOn(p_186371_); + } } + + @Override diff --git a/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch index 2b6300796f..a031feae79 100644 --- a/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/world/item/ShieldItem.java +++ b/net/minecraft/world/item/ShieldItem.java -@@ -43,4 +_,9 @@ - p_43100_.startUsingItem(p_43101_); - return InteractionResult.CONSUME; +@@ -13,4 +_,10 @@ + DyeColor dyecolor = p_360971_.get(DataComponents.BASE_COLOR); + return (Component)(dyecolor != null ? Component.translatable(this.descriptionId + "." + dyecolor.getName()) : super.getName(p_360971_)); } + + @Override ++ @Deprecated(forRemoval = true, since = "1.21.5") + public boolean canPerformAction(ItemStack stack, net.minecraftforge.common.ToolAction toolAction) { + return net.minecraftforge.common.ToolActions.DEFAULT_SHIELD_ACTIONS.contains(toolAction); + } diff --git a/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch index 22058b574f..232d485abd 100644 --- a/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ShovelItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ShovelItem.java +++ b/net/minecraft/world/item/ShovelItem.java -@@ -44,9 +_,9 @@ +@@ -43,9 +_,9 @@ return InteractionResult.PASS; } else { Player player = p_43119_.getPlayer(); @@ -12,7 +12,7 @@ level.playSound(player, blockpos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); blockstate2 = blockstate1; } else if (blockstate.getBlock() instanceof CampfireBlock && blockstate.getValue(CampfireBlock.LIT)) { -@@ -72,5 +_,15 @@ +@@ -71,5 +_,15 @@ return InteractionResult.PASS; } } diff --git a/patches/minecraft/net/minecraft/world/item/SwordItem.java.patch b/patches/minecraft/net/minecraft/world/item/SwordItem.java.patch deleted file mode 100644 index aeb5b8d150..0000000000 --- a/patches/minecraft/net/minecraft/world/item/SwordItem.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/item/SwordItem.java -+++ b/net/minecraft/world/item/SwordItem.java -@@ -26,4 +_,9 @@ - public void postHurtEnemy(ItemStack p_342189_, LivingEntity p_344347_, LivingEntity p_343888_) { - p_342189_.hurtAndBreak(1, p_343888_, EquipmentSlot.MAINHAND); - } -+ -+ @Override -+ public boolean canPerformAction(ItemStack stack, net.minecraftforge.common.ToolAction toolAction) { -+ return net.minecraftforge.common.ToolActions.DEFAULT_SWORD_ACTIONS.contains(toolAction); -+ } - } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch index 5250195ea8..2ed408a6db 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java +++ b/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java -@@ -84,7 +_,7 @@ +@@ -81,7 +_,7 @@ for (int i = 0; i < nonnulllist.size(); i++) { ItemStack itemstack = p_342084_.getItem(i); if (!itemstack.isEmpty()) { diff --git a/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch index f9eee67178..02ad0ced58 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/BookCloningRecipe.java +++ b/net/minecraft/world/item/crafting/BookCloningRecipe.java -@@ -88,7 +_,7 @@ +@@ -87,7 +_,7 @@ for (int i = 0; i < nonnulllist.size(); i++) { ItemStack itemstack = p_344901_.getItem(i); @@ -8,4 +8,4 @@ + ItemStack itemstack1 = itemstack.getCraftingRemainder(); if (!itemstack1.isEmpty()) { nonnulllist.set(i, itemstack1); - } else if (itemstack.getItem() instanceof WrittenBookItem) { + } else if (itemstack.has(DataComponents.WRITTEN_BOOK_CONTENT)) { diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch index 9d5d1bcc46..d97f857523 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch @@ -8,7 +8,7 @@ + return this.data; + } + - public static record Data(Map key, List pattern) { + public record Data(Map key, List pattern) { private static final Codec> PATTERN_CODEC = Codec.STRING.listOf().comapFlatMap(p_311191_ -> { - if (p_311191_.size() > 3) { - return DataResult.error(() -> "Invalid pattern: too many rows, 3 is maximum"); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch index 987c8e6bf2..3e2170acdb 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -32,11 +32,11 @@ } @@ -87,7 +_,7 @@ - Codec.STRING.optionalFieldOf("group", "").forGetter(p_299460_ -> p_299460_.group), - CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(p_297437_ -> p_297437_.category), - ItemStack.STRICT_CODEC.fieldOf("result").forGetter(p_300770_ -> p_300770_.result), -- Ingredient.CODEC.listOf(1, 9).fieldOf("ingredients").forGetter(p_359857_ -> p_359857_.ingredients) -+ Ingredient.CODEC.listOf(/*1, 9 Forge: Make this usable for larger crafting windows*/).fieldOf("ingredients").forGetter(p_359857_ -> p_359857_.ingredients) - ) - .apply(p_359856_, ShapelessRecipe::new) + Codec.STRING.optionalFieldOf("group", "").forGetter(p_299460_ -> p_299460_.group), + CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(p_297437_ -> p_297437_.category), + ItemStack.STRICT_CODEC.fieldOf("result").forGetter(p_300770_ -> p_300770_.result), +- Ingredient.CODEC.listOf(1, 9).fieldOf("ingredients").forGetter(p_359857_ -> p_359857_.ingredients) ++ Ingredient.CODEC.listOf(/*1, 9 Forge: Make this usable for larger crafting windows*/).fieldOf("ingredients").forGetter(p_359857_ -> p_359857_.ingredients) + ) + .apply(p_359856_, ShapelessRecipe::new) ); diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java.patch index 6252283e45..175219cc72 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java @@ -48,6 +_,7 @@ for (BlockPos blockpos1 : BlockPos.betweenClosed(blockpos.offset(-i, 0, -i), blockpos.offset(i, Math.min(j - 1, 0), i))) { - if (blockpos1.distToCenterSqr(p_342913_.x(), (double)blockpos1.getY() + 0.5, p_342913_.z()) < (double)Mth.square(i) + if (blockpos1.distToCenterSqr(p_342913_.x(), blockpos1.getY() + 0.5, p_342913_.z()) < Mth.square(i) && this.predicate.map(p_343365_ -> p_343365_.test(p_343394_, blockpos1)).orElse(true) + && !net.minecraftforge.event.ForgeEventFactory.onBlockPlace(p_343742_, net.minecraftforge.common.util.BlockSnapshot.create(p_343394_.dimension(), p_343394_, blockpos), net.minecraft.core.Direction.UP) && p_343394_.setBlockAndUpdate(blockpos1, this.blockState.getState(randomsource, blockpos1))) { diff --git a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch index d764b19c6c..a31f6935dc 100644 --- a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/BaseSpawner.java +++ b/net/minecraft/world/level/BaseSpawner.java -@@ -149,13 +_,15 @@ +@@ -148,13 +_,15 @@ - entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), randomsource.nextFloat() * 360.0F, 0.0F); + entity.snapTo(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_, EntitySpawnReason.SPAWNER) || !mob.checkSpawnObstruction(p_151312_)) { + if (!net.minecraftforge.event.ForgeEventFactory.checkSpawnPositionSpawner(mob, p_151312_, EntitySpawnReason.SPAWNER, spawndata, this)) { continue; } - boolean flag1 = spawndata.getEntityToSpawn().size() == 1 && spawndata.getEntityToSpawn().contains("id", 8); + boolean flag1 = spawndata.getEntityToSpawn().size() == 1 && spawndata.getEntityToSpawn().getString("id").isPresent(); - if (flag1) { - ((Mob)entity).finalizeSpawn(p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, null); + // Forge: Patch in FinalizeSpawn for spawners so it may be fired unconditionally, instead of only when vanilla normally would trigger it. @@ -19,7 +19,7 @@ } spawndata.getEquipment().ifPresent(mob::equip); -@@ -305,5 +_,15 @@ +@@ -270,5 +_,15 @@ public double getoSpin() { return this.oSpin; diff --git a/patches/minecraft/net/minecraft/world/level/BlockAndTintGetter.java.patch b/patches/minecraft/net/minecraft/world/level/BlockAndTintGetter.java.patch deleted file mode 100644 index 42354c7656..0000000000 --- a/patches/minecraft/net/minecraft/world/level/BlockAndTintGetter.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/BlockAndTintGetter.java -+++ b/net/minecraft/world/level/BlockAndTintGetter.java -@@ -4,7 +_,7 @@ - import net.minecraft.core.Direction; - import net.minecraft.world.level.lighting.LevelLightEngine; - --public interface BlockAndTintGetter extends BlockGetter { -+public interface BlockAndTintGetter extends BlockGetter, net.minecraftforge.client.extensions.IForgeBlockAndTintGetter { - float getShade(Direction p_45522_, boolean p_45523_); - - LevelLightEngine getLightEngine(); diff --git a/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch b/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch deleted file mode 100644 index 50a30ffdb1..0000000000 --- a/patches/minecraft/net/minecraft/world/level/ForcedChunksSavedData.java.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/net/minecraft/world/level/ForcedChunksSavedData.java -+++ b/net/minecraft/world/level/ForcedChunksSavedData.java -@@ -25,16 +_,31 @@ - } - - public static ForcedChunksSavedData load(CompoundTag p_151484_, HolderLookup.Provider p_329967_) { -- return new ForcedChunksSavedData(new LongOpenHashSet(p_151484_.getLongArray("Forced"))); -+ var ret = new ForcedChunksSavedData(new LongOpenHashSet(p_151484_.getLongArray("Forced"))); -+ net.minecraftforge.common.world.ForgeChunkManager.readForgeForcedChunks(p_151484_, ret.blockForcedChunks, ret.entityForcedChunks); -+ return ret; - } - - @Override - public CompoundTag save(CompoundTag p_46120_, HolderLookup.Provider p_329035_) { - p_46120_.putLongArray("Forced", this.chunks.toLongArray()); -+ net.minecraftforge.common.world.ForgeChunkManager.writeForgeForcedChunks(p_46120_, this.blockForcedChunks, this.entityForcedChunks); - return p_46120_; - } - - public LongSet getChunks() { - return this.chunks; -+ } -+ -+ // TODO: not sure if these are being written correctly. load used to refer to these directly. -+ private net.minecraftforge.common.world.ForgeChunkManager.TicketTracker blockForcedChunks = new net.minecraftforge.common.world.ForgeChunkManager.TicketTracker<>(); -+ private net.minecraftforge.common.world.ForgeChunkManager.TicketTracker entityForcedChunks = new net.minecraftforge.common.world.ForgeChunkManager.TicketTracker<>(); -+ -+ public net.minecraftforge.common.world.ForgeChunkManager.TicketTracker getBlockForcedChunks() { -+ return this.blockForcedChunks; -+ } -+ -+ public net.minecraftforge.common.world.ForgeChunkManager.TicketTracker getEntityForcedChunks() { -+ return this.entityForcedChunks; - } - } diff --git a/patches/minecraft/net/minecraft/world/level/Level.java.patch b/patches/minecraft/net/minecraft/world/level/Level.java.patch index af0be8224a..280629bb63 100644 --- a/patches/minecraft/net/minecraft/world/level/Level.java.patch +++ b/patches/minecraft/net/minecraft/world/level/Level.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -79,7 +_,7 @@ +@@ -83,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Scoreboard; --public abstract class Level implements LevelAccessor, AutoCloseable { -+public abstract class Level extends net.minecraftforge.common.capabilities.CapabilityProvider implements LevelAccessor, AutoCloseable, net.minecraftforge.common.extensions.IForgeLevel { +-public abstract class Level implements LevelAccessor, UUIDLookup, AutoCloseable { ++public abstract class Level extends net.minecraftforge.common.capabilities.CapabilityProvider implements LevelAccessor, UUIDLookup, AutoCloseable, net.minecraftforge.common.extensions.IForgeLevel { 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")); -@@ -116,6 +_,11 @@ +@@ -120,6 +_,11 @@ private final RegistryAccess registryAccess; private final DamageSources damageSources; private long subTickCount; @@ -21,7 +21,7 @@ protected Level( WritableLevelData p_270739_, -@@ -127,6 +_,7 @@ +@@ -131,6 +_,7 @@ long p_270248_, int p_270466_ ) { @@ -29,7 +29,7 @@ this.levelData = p_270739_; this.dimensionTypeRegistration = p_270240_; final DimensionType dimensiontype = p_270240_.value(); -@@ -216,11 +_,35 @@ +@@ -220,11 +_,35 @@ } else { LevelChunk levelchunk = this.getChunkAt(p_46605_); Block block = p_46606_.getBlock(); @@ -41,7 +41,7 @@ + this.capturedBlockSnapshots.add(blockSnapshot); + } + - BlockState blockstate = levelchunk.setBlockState(p_46605_, p_46606_, (p_46607_ & 64) != 0); + BlockState blockstate = levelchunk.setBlockState(p_46605_, p_46606_, p_46607_); if (blockstate == null) { + if (blockSnapshot != null) this.capturedBlockSnapshots.remove(blockSnapshot); return false; @@ -65,10 +65,10 @@ if (blockstate1 == p_46606_) { if (blockstate != blockstate1) { this.setBlocksDirty(p_46605_, blockstate, blockstate1); -@@ -247,9 +_,8 @@ +@@ -251,9 +_,8 @@ } - this.onBlockStateChange(p_46605_, blockstate, blockstate1); + this.updatePOIOnBlockStateChange(p_46605_, blockstate, blockstate1); + p_46606_.onBlockStateChange(this, p_46605_, blockstate); } - @@ -76,7 +76,7 @@ } } } -@@ -499,10 +_,30 @@ +@@ -501,10 +_,30 @@ (this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add(p_151526_); } @@ -107,7 +107,7 @@ if (!this.pendingBlockEntityTickers.isEmpty()) { this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); this.pendingBlockEntityTickers.clear(); -@@ -526,12 +_,19 @@ +@@ -528,12 +_,19 @@ public void guardEntityTick(Consumer p_46654_, T p_46655_) { try { @@ -127,7 +127,7 @@ } } -@@ -683,6 +_,7 @@ +@@ -685,6 +_,7 @@ if (!this.isOutsideBuildHeight(p_46748_)) { this.getChunkAt(p_46748_).removeBlockEntity(p_46748_); } @@ -135,7 +135,7 @@ } public boolean isLoaded(BlockPos p_46750_) { -@@ -760,9 +_,9 @@ +@@ -762,9 +_,9 @@ } }); @@ -147,7 +147,7 @@ && p_46538_.test(enderdragonpart) && p_46537_.intersects(enderdragonpart.getBoundingBox())) { list.add(enderdragonpart); -@@ -795,8 +_,8 @@ +@@ -797,8 +_,8 @@ } } @@ -158,7 +158,7 @@ T t = p_261885_.tryCast(enderdragonpart); if (t != null && p_261688_.test(t)) { p_262071_.add(t); -@@ -932,17 +_,16 @@ +@@ -942,17 +_,16 @@ public abstract Scoreboard getScoreboard(); public void updateNeighbourForOutputSignal(BlockPos p_46718_, Block p_46719_) { @@ -181,7 +181,7 @@ } } } -@@ -1044,6 +_,20 @@ +@@ -1054,6 +_,20 @@ } public abstract PotionBrewing potionBrewing(); diff --git a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch index 41e703c8f1..4e66077d5f 100644 --- a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch +++ b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/LevelReader.java +++ b/net/minecraft/world/level/LevelReader.java -@@ -172,6 +_,12 @@ +@@ -176,6 +_,12 @@ : 15; } diff --git a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch index bee00b1db2..30737568ff 100644 --- a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -71,7 +_,7 @@ - continue; - } +@@ -69,7 +_,7 @@ -- MobCategory mobcategory = entity.getType().getCategory(); -+ MobCategory mobcategory = entity.getClassification(true); - if (mobcategory != MobCategory.MISC) { - BlockPos blockpos = entity.blockPosition(); - p_186527_.query(ChunkPos.asLong(blockpos), p_275163_ -> { -@@ -202,7 +_,7 @@ + for (Entity entity : p_186526_) { + if (!(entity instanceof Mob mob && (mob.isPersistenceRequired() || mob.requiresCustomPersistence()))) { +- MobCategory mobcategory = entity.getType().getCategory(); ++ MobCategory mobcategory = entity.getClassification(true); + if (mobcategory != MobCategory.MISC) { + BlockPos blockpos = entity.blockPosition(); + p_186527_.query(ChunkPos.asLong(blockpos), p_275163_ -> { +@@ -200,7 +_,7 @@ l1++; p_47040_.addFreshEntityWithPassengers(mob); p_47044_.run(mob, p_47041_); @@ -18,16 +18,16 @@ return; } -@@ -275,7 +_,7 @@ +@@ -270,7 +_,7 @@ private static boolean isValidPositionForMob(ServerLevel p_46992_, Mob p_46993_, double p_46994_) { - return p_46994_ > (double)(p_46993_.getType().getCategory().getDespawnDistance() * p_46993_.getType().getCategory().getDespawnDistance()) && p_46993_.removeWhenFarAway(p_46994_) + return p_46994_ > p_46993_.getType().getCategory().getDespawnDistance() * p_46993_.getType().getCategory().getDespawnDistance() && p_46993_.removeWhenFarAway(p_46994_) ? false - : p_46993_.checkSpawnRules(p_46992_, EntitySpawnReason.NATURAL) && p_46993_.checkSpawnObstruction(p_46992_); + : net.minecraftforge.event.ForgeEventFactory.checkSpawnPosition(p_46993_, p_46992_, EntitySpawnReason.NATURAL); } private static Optional getRandomSpawnMobAt( -@@ -306,9 +_,13 @@ +@@ -301,9 +_,13 @@ BlockPos p_220448_, @Nullable Holder p_220449_ ) { @@ -44,16 +44,16 @@ } public static boolean isInNetherFortressBounds(BlockPos p_220456_, ServerLevel p_220457_, MobCategory p_220458_, StructureManager p_220459_) { -@@ -394,7 +_,7 @@ +@@ -389,7 +_,7 @@ } - entity.moveTo(d0, (double)blockpos.getY(), d1, p_220454_.nextFloat() * 360.0F, 0.0F); + entity.snapTo(d0, blockpos.getY(), d1, p_220454_.nextFloat() * 360.0F, 0.0F); - if (entity instanceof Mob mob && mob.checkSpawnRules(p_220451_, EntitySpawnReason.CHUNK_GENERATION) && mob.checkSpawnObstruction(p_220451_)) { + if (entity instanceof Mob mob && net.minecraftforge.event.ForgeEventFactory.checkSpawnPosition(mob, p_220451_, EntitySpawnReason.CHUNK_GENERATION)) { spawngroupdata = mob.finalizeSpawn( p_220451_, p_220451_.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, spawngroupdata ); -@@ -500,7 +_,7 @@ +@@ -495,7 +_,7 @@ } this.spawnPotential.addCharge(blockpos, d0); diff --git a/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch b/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch index b4b9d38fc3..43d5e07c0e 100644 --- a/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch +++ b/patches/minecraft/net/minecraft/world/level/ServerExplosion.java.patch @@ -7,20 +7,20 @@ - private void hurtEntities() { + private void hurtEntities(List blocks) { float f = this.radius * 2.0F; - int i = Mth.floor(this.center.x - (double)f - 1.0); - int j = Mth.floor(this.center.x + (double)f + 1.0); + int i = Mth.floor(this.center.x - f - 1.0); + int j = Mth.floor(this.center.x + f + 1.0); @@ -176,7 +_,9 @@ - int i1 = Mth.floor(this.center.z - (double)f - 1.0); - int j1 = Mth.floor(this.center.z + (double)f + 1.0); + int i1 = Mth.floor(this.center.z - f - 1.0); + int j1 = Mth.floor(this.center.z + 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))) { -+ var entities = this.level.getEntities(this.source, new AABB((double)i, (double)k, (double)i1, (double)j, (double)l, (double)j1)); +- for (Entity entity : this.level.getEntities(this.source, new AABB(i, k, i1, j, l, j1))) { ++ var entities = this.level.getEntities(this.source, new AABB(i, k, i1, j, l, j1)); + net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.level, this, blocks, entities, f); + for (Entity entity : entities) { if (!entity.ignoreExplosion(this)) { - double d0 = Math.sqrt(entity.distanceToSqr(this.center)) / (double)f; + double d0 = Math.sqrt(entity.distanceToSqr(this.center)) / f; if (d0 <= 1.0) { -@@ -248,7 +_,7 @@ +@@ -245,7 +_,7 @@ public void explode() { this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); List list = this.calculateExplodedPositions(); diff --git a/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch b/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch index 90d4c994f0..de142370a0 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/biome/Biome.java +++ b/net/minecraft/world/level/biome/Biome.java -@@ -36,8 +_,8 @@ +@@ -37,8 +_,8 @@ public final class Biome { public static final Codec DIRECT_CODEC = RecordCodecBuilder.create( p_220544_ -> p_220544_.group( -- Biome.ClimateSettings.CODEC.forGetter(p_151717_ -> p_151717_.climateSettings), -- BiomeSpecialEffects.CODEC.fieldOf("effects").forGetter(p_220550_ -> p_220550_.specialEffects), -+ Biome.ClimateSettings.CODEC.forGetter(p_151717_ -> p_151717_.modifiableBiomeInfo().getOriginalBiomeInfo().climateSettings()), // FORGE: Patch codec to ignore field redirect coremods. -+ BiomeSpecialEffects.CODEC.fieldOf("effects").forGetter(p_220550_ -> p_220550_.modifiableBiomeInfo().getOriginalBiomeInfo().effects()), // FORGE: Patch codec to ignore field redirect coremods. - BiomeGenerationSettings.CODEC.forGetter(p_220548_ -> p_220548_.generationSettings), - MobSpawnSettings.CODEC.forGetter(p_220546_ -> p_220546_.mobSettings) - ) -@@ -59,8 +_,10 @@ +- Biome.ClimateSettings.CODEC.forGetter(p_151717_ -> p_151717_.climateSettings), +- BiomeSpecialEffects.CODEC.fieldOf("effects").forGetter(p_220550_ -> p_220550_.specialEffects), ++ Biome.ClimateSettings.CODEC.forGetter(p_151717_ -> p_151717_.modifiableBiomeInfo().getOriginalBiomeInfo().climateSettings()), // FORGE: Patch codec to ignore field redirect coremods. ++ BiomeSpecialEffects.CODEC.fieldOf("effects").forGetter(p_220550_ -> p_220550_.modifiableBiomeInfo().getOriginalBiomeInfo().effects()), // FORGE: Patch codec to ignore field redirect coremods. + BiomeGenerationSettings.CODEC.forGetter(p_220548_ -> p_220548_.generationSettings), + MobSpawnSettings.CODEC.forGetter(p_220546_ -> p_220546_.mobSettings) + ) +@@ -60,8 +_,10 @@ ) public static final PerlinSimplexNoise BIOME_INFO_NOISE = new PerlinSimplexNoise(new WorldgenRandom(new LegacyRandomSource(2345L)), ImmutableList.of(0)); private static final int TEMPERATURE_CACHE_SIZE = 1024; @@ -22,10 +22,10 @@ private final MobSpawnSettings mobSettings; private final BiomeSpecialEffects specialEffects; private final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> { -@@ -72,12 +_,14 @@ - long2floatlinkedopenhashmap.defaultReturnValue(Float.NaN); - return long2floatlinkedopenhashmap; - })); +@@ -73,12 +_,14 @@ + long2floatlinkedopenhashmap.defaultReturnValue(Float.NaN); + return long2floatlinkedopenhashmap; + })); + private final net.minecraftforge.common.world.ModifiableBiomeInfo modifiableBiomeInfo; Biome(Biome.ClimateSettings p_220530_, BiomeSpecialEffects p_220531_, BiomeGenerationSettings p_220532_, MobSpawnSettings p_220533_) { @@ -37,7 +37,7 @@ } public int getSkyColor() { -@@ -85,7 +_,7 @@ +@@ -86,7 +_,7 @@ } public MobSpawnSettings getMobSettings() { @@ -46,7 +46,7 @@ } public boolean hasPrecipitation() { -@@ -187,7 +_,7 @@ +@@ -188,7 +_,7 @@ } public BiomeGenerationSettings getGenerationSettings() { @@ -55,7 +55,7 @@ } public int getFogColor() { -@@ -253,6 +_,31 @@ +@@ -269,6 +_,31 @@ public float getBackgroundMusicVolume() { return this.specialEffects.getBackgroundMusicVolume(); diff --git a/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch index ca29e1d4fd..70970fd618 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/biome/BiomeSpecialEffects.java +++ b/net/minecraft/world/level/biome/BiomeSpecialEffects.java -@@ -242,7 +_,7 @@ +@@ -257,7 +_,7 @@ } } @@ -9,7 +9,7 @@ NONE("none") { @Override public int modifyColor(double p_48081_, double p_48082_, int p_48083_) { -@@ -264,11 +_,16 @@ +@@ -279,11 +_,16 @@ }; private final String name; @@ -29,7 +29,7 @@ GrassColorModifier(final String p_48058_) { this.name = p_48058_; -@@ -281,6 +_,30 @@ +@@ -296,6 +_,30 @@ @Override public String getSerializedName() { return this.name; diff --git a/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch b/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch index 3815e1afc1..39cfc1af83 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/biome/MobSpawnSettings.java +++ b/net/minecraft/world/level/biome/MobSpawnSettings.java -@@ -49,6 +_,8 @@ +@@ -44,6 +_,8 @@ private final float creatureGenerationProbability; - private final Map> spawners; + private final Map> spawners; private final Map, MobSpawnSettings.MobSpawnCost> mobSpawnCosts; + private final java.util.Set typesView; + private final java.util.Set> costView; MobSpawnSettings( - float p_196689_, -@@ -58,6 +_,8 @@ + float p_196689_, Map> p_196690_, Map, MobSpawnSettings.MobSpawnCost> p_196691_ +@@ -51,6 +_,8 @@ this.creatureGenerationProbability = p_196689_; this.spawners = ImmutableMap.copyOf(p_196690_); this.mobSpawnCosts = ImmutableMap.copyOf(p_196691_); @@ -17,8 +17,8 @@ + this.costView = java.util.Collections.unmodifiableSet(this.mobSpawnCosts.keySet()); } - public WeightedRandomList getMobs(MobCategory p_151799_) { -@@ -71,6 +_,14 @@ + public WeightedList getMobs(MobCategory p_151799_) { +@@ -64,6 +_,14 @@ public float getCreatureProbability() { return this.creatureGenerationProbability; diff --git a/patches/minecraft/net/minecraft/world/level/block/BambooSaplingBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BambooSaplingBlock.java.patch deleted file mode 100644 index c2be990066..0000000000 --- a/patches/minecraft/net/minecraft/world/level/block/BambooSaplingBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/block/BambooSaplingBlock.java -+++ b/net/minecraft/world/level/block/BambooSaplingBlock.java -@@ -95,7 +_,7 @@ - - @Override - protected float getDestroyProgress(BlockState p_48981_, Player p_48982_, BlockGetter p_48983_, BlockPos p_48984_) { -- return p_48982_.getMainHandItem().getItem() instanceof SwordItem ? 1.0F : super.getDestroyProgress(p_48981_, p_48982_, p_48983_, p_48984_); -+ return p_48982_.getMainHandItem().canPerformAction(net.minecraftforge.common.ToolActions.SWORD_DIG) ? 1.0F : super.getDestroyProgress(p_48981_, p_48982_, p_48983_, p_48984_); - } - - protected void growBamboo(Level p_48973_, BlockPos p_48974_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch index 7f5e4b451e..a891704c68 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BambooStalkBlock.java +++ b/net/minecraft/world/level/block/BambooStalkBlock.java -@@ -27,7 +_,7 @@ +@@ -24,7 +_,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -public class BambooStalkBlock extends Block implements BonemealableBlock { +public class BambooStalkBlock extends Block implements BonemealableBlock, net.minecraftforge.common.IPlantable { public static final MapCodec CODEC = simpleCodec(BambooStalkBlock::new); - protected static final float SMALL_LEAVES_AABB_OFFSET = 3.0F; - protected static final float LARGE_LEAVES_AABB_OFFSET = 5.0F; -@@ -130,10 +_,12 @@ + private static final VoxelShape SHAPE_SMALL = Block.column(6.0, 0.0, 16.0); + private static final VoxelShape SHAPE_LARGE = Block.column(10.0, 0.0, 16.0); +@@ -120,10 +_,12 @@ @Override protected void randomTick(BlockState p_261931_, ServerLevel p_261751_, BlockPos p_261616_, RandomSource p_261766_) { if (p_261931_.getValue(STAGE) == 0) { @@ -24,16 +24,7 @@ } } } -@@ -198,7 +_,7 @@ - - @Override - protected float getDestroyProgress(BlockState p_261691_, Player p_262171_, BlockGetter p_261621_, BlockPos p_261500_) { -- return p_262171_.getMainHandItem().getItem() instanceof SwordItem ? 1.0F : super.getDestroyProgress(p_261691_, p_262171_, p_261621_, p_261500_); -+ return p_262171_.getMainHandItem().canPerformAction(net.minecraftforge.common.ToolActions.SWORD_DIG) ? 1.0F : super.getDestroyProgress(p_261691_, p_262171_, p_261621_, p_261500_); - } - - protected void growBamboo(BlockState p_261855_, Level p_262076_, BlockPos p_262109_, RandomSource p_261633_, int p_261759_) { -@@ -245,5 +_,11 @@ +@@ -226,5 +_,11 @@ } return i; diff --git a/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch index 9752527feb..c521d8071a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BaseFireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BaseFireBlock.java +++ b/net/minecraft/world/level/block/BaseFireBlock.java -@@ -150,6 +_,7 @@ +@@ -153,6 +_,7 @@ if (!p_49282_.is(p_49279_.getBlock())) { if (inPortalDimension(p_49280_)) { Optional optional = PortalShape.findEmptyPortalShape(p_49280_, p_49281_, Direction.Axis.X); @@ -8,7 +8,7 @@ if (optional.isPresent()) { optional.get().createPortalBlocks(p_49280_); return; -@@ -192,7 +_,7 @@ +@@ -195,7 +_,7 @@ boolean flag = false; for (Direction direction : Direction.values()) { diff --git a/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch index 24d89e2c7e..d564c60aeb 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BaseRailBlock.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BaseRailBlock.java +++ b/net/minecraft/world/level/block/BaseRailBlock.java -@@ -23,7 +_,7 @@ +@@ -24,7 +_,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -public abstract class BaseRailBlock extends Block implements SimpleWaterloggedBlock { +public abstract class BaseRailBlock extends Block implements SimpleWaterloggedBlock, net.minecraftforge.common.extensions.IForgeBaseRailBlock { - 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; + private static final VoxelShape SHAPE_FLAT = Block.column(16.0, 0.0, 2.0); + private static final VoxelShape SHAPE_SLOPE = Block.column(16.0, 0.0, 8.0); @@ -79,7 +_,7 @@ @Override protected void neighborChanged(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, @Nullable Orientation p_362860_, boolean p_49382_) { @@ -18,17 +18,17 @@ if (shouldBeRemoved(p_49379_, p_49378_, railshape)) { dropResources(p_49377_, p_49378_, p_49379_); p_49378_.removeBlock(p_49379_, p_49382_); -@@ -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()).isSlope()) { -+ if (getRailDirection(p_49384_, p_49385_, p_49386_, null).isSlope()) { - p_49385_.updateNeighborsAt(p_49386_.above(), this); +@@ -123,7 +_,7 @@ + @Override + protected void affectNeighborsAfterRemoval(BlockState p_397007_, ServerLevel p_395211_, BlockPos p_393934_, boolean p_393188_) { + if (!p_393188_) { +- if (p_397007_.getValue(this.getShapeProperty()).isSlope()) { ++ if (getRailDirection(p_397007_, p_395211_, p_393934_, null).isSlope()) { + p_395211_.updateNeighborsAt(p_393934_.above(), this); } -@@ -145,6 +_,11 @@ - return blockstate.setValue(this.getShapeProperty(), flag1 ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH).setValue(WATERLOGGED, Boolean.valueOf(flag)); +@@ -144,6 +_,11 @@ + return blockstate.setValue(this.getShapeProperty(), flag1 ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH).setValue(WATERLOGGED, flag); } + /** @@ -39,7 +39,7 @@ public abstract Property getShapeProperty(); @Override -@@ -168,5 +_,15 @@ +@@ -167,5 +_,15 @@ @Override protected FluidState getFluidState(BlockState p_152158_) { return p_152158_.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(p_152158_); diff --git a/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch index 9d5cf4b55a..d82c7097d1 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch +++ b/patches/minecraft/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 -@@ -140,7 +_,7 @@ +@@ -137,7 +_,7 @@ boolean flag = false; if (i >= 5) { Item item = p_331014_.getItem(); diff --git a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch index e3f1bbc958..8aaf02dbf2 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch +++ b/patches/minecraft/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 -@@ -60,11 +_,12 @@ +@@ -66,11 +_,12 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.slf4j.Logger; @@ -15,7 +15,7 @@ private static final LoadingCache SHAPE_FULL_BLOCK_CACHE = CacheBuilder.newBuilder() .maximumSize(512L) .weakKeys() -@@ -186,6 +_,7 @@ +@@ -232,6 +_,7 @@ LOGGER.error("Block classes should end with Block and {} doesn't.", s); } } @@ -23,7 +23,7 @@ } public static boolean isExceptionForConnection(BlockState p_152464_) { -@@ -198,12 +_,19 @@ +@@ -244,12 +_,19 @@ || p_152464_.is(BlockTags.SHULKER_BOXES); } @@ -43,7 +43,7 @@ } else if (voxelshape == Shapes.empty()) { return true; } else { -@@ -291,9 +_,13 @@ +@@ -337,9 +_,13 @@ public static void dropResources( BlockState p_49882_, Level p_49883_, BlockPos p_49884_, @Nullable BlockEntity p_49885_, @Nullable Entity p_49886_, ItemStack p_49887_ ) { @@ -58,7 +58,7 @@ } } -@@ -321,7 +_,7 @@ +@@ -367,7 +_,7 @@ } private static void popResource(Level p_152441_, Supplier p_152442_, ItemStack p_152443_) { @@ -67,7 +67,7 @@ ItemEntity itementity = p_152442_.get(); itementity.setDefaultPickUpDelay(); p_152441_.addFreshEntity(itementity); -@@ -330,11 +_,12 @@ +@@ -375,11 +_,12 @@ } public void popExperience(ServerLevel p_49806_, BlockPos p_49807_, int p_49808_) { @@ -81,7 +81,7 @@ public float getExplosionResistance() { return this.explosionResistance; } -@@ -353,7 +_,8 @@ +@@ -398,7 +_,8 @@ public void playerDestroy(Level p_49827_, Player p_49828_, BlockPos p_49829_, BlockState p_49830_, @Nullable BlockEntity p_49831_, ItemStack p_49832_) { p_49828_.awardStat(Stats.BLOCK_MINED.get(this)); p_49828_.causeFoodExhaustion(0.005F); @@ -91,15 +91,15 @@ } public void setPlacedBy(Level p_49847_, BlockPos p_49848_, BlockState p_49849_, @Nullable LivingEntity p_49850_, ItemStack p_49851_) { -@@ -375,6 +_,7 @@ +@@ -420,6 +_,7 @@ p_49822_.setDeltaMovement(p_49822_.getDeltaMovement().multiply(1.0, 0.0, 1.0)); } -+ /** @deprecated Forge use {@link IForgeStateBlock#getFriction(Level, BlockPos, Entity)}*/ ++ /** @deprecated Forge: use {@link net.minecraftforge.common.extensions.IForgeBlockState#getFriction(LevelReader, BlockPos, Entity)}*/ public float getFriction() { return this.friction; } -@@ -445,7 +_,7 @@ +@@ -490,7 +_,7 @@ this.item = Item.byBlock(this); } @@ -108,7 +108,7 @@ } public boolean hasDynamicShape() { -@@ -497,5 +_,74 @@ +@@ -556,5 +_,74 @@ public int hashCode() { return System.identityHashCode(this.first) * 31 + System.identityHashCode(this.second); } diff --git a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch index 66fa8841cd..8375fe4cbc 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Blocks.java +++ b/net/minecraft/world/level/block/Blocks.java -@@ -758,7 +_,7 @@ +@@ -769,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( @@ -9,7 +9,7 @@ ); public static final Block DETECTOR_RAIL = register( "detector_rail", DetectorRailBlock::new, BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) -@@ -6585,14 +_,5 @@ +@@ -6697,14 +_,5 @@ private static Block register(String p_50796_, BlockBehaviour.Properties p_362760_) { return register(p_50796_, Block::new, p_362760_); diff --git a/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch b/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch index d56ea8805d..fe1638d74c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BucketPickup.java.patch @@ -6,7 +6,7 @@ -public interface BucketPickup { +public interface BucketPickup extends net.minecraftforge.common.extensions.IForgeBucketPickup { - ItemStack pickupBlock(@Nullable Player p_298551_, LevelAccessor p_152719_, BlockPos p_152720_, BlockState p_152721_); + ItemStack pickupBlock(@Nullable LivingEntity p_391402_, LevelAccessor p_152719_, BlockPos p_152720_, BlockState p_152721_); + /** @deprecated Forge: Use state-sensitive variant instead */ + @Deprecated diff --git a/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch deleted file mode 100644 index 500a78172f..0000000000 --- a/patches/minecraft/net/minecraft/world/level/block/BushBlock.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/world/level/block/BushBlock.java -+++ b/net/minecraft/world/level/block/BushBlock.java -@@ -12,7 +_,7 @@ - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.pathfinder.PathComputationType; - --public abstract class BushBlock extends Block { -+public abstract class BushBlock extends Block implements net.minecraftforge.common.IPlantable { - protected BushBlock(BlockBehaviour.Properties p_51021_) { - super(p_51021_); - } -@@ -43,6 +_,9 @@ - @Override - protected boolean canSurvive(BlockState p_51028_, LevelReader p_51029_, BlockPos p_51030_) { - BlockPos blockpos = p_51030_.below(); -+ if (p_51028_.getBlock() == this) { //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check. -+ return p_51029_.getBlockState(blockpos).canSustainPlant(p_51029_, blockpos, Direction.UP, this); -+ } - return this.mayPlaceOn(p_51029_.getBlockState(blockpos), p_51029_, blockpos); - } - -@@ -54,5 +_,11 @@ - @Override - protected boolean isPathfindable(BlockState p_51023_, PathComputationType p_51026_) { - return p_51026_ == PathComputationType.AIR && !this.hasCollision ? true : super.isPathfindable(p_51023_, p_51026_); -+ } -+ -+ @Override -+ public BlockState getPlant(BlockGetter world, BlockPos pos) { -+ BlockState state = world.getBlockState(pos); -+ return state.getBlock() == this ? state : defaultBlockState(); - } - } diff --git a/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch index 055dae677e..2600b9ede9 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CactusBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CactusBlock.java +++ b/net/minecraft/world/level/block/CactusBlock.java -@@ -21,7 +_,7 @@ +@@ -22,7 +_,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,7 @@ public static final MapCodec CODEC = simpleCodec(CactusBlock::new); public static final IntegerProperty AGE = BlockStateProperties.AGE_15; public static final int MAX_AGE = 15; -@@ -41,6 +_,7 @@ +@@ -45,6 +_,7 @@ @Override protected void tick(BlockState p_220908_, ServerLevel p_220909_, BlockPos p_220910_, RandomSource p_220911_) { @@ -17,24 +17,23 @@ if (!p_220908_.canSurvive(p_220909_, p_220910_)) { p_220909_.destroyBlock(p_220910_, true); } -@@ -58,6 +_,7 @@ - - if (i < 3) { - int j = p_220913_.getValue(AGE); -+ if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_220914_, blockpos, p_220913_, true)) { - if (j == 15) { - p_220914_.setBlockAndUpdate(blockpos, this.defaultBlockState()); - BlockState blockstate = p_220913_.setValue(AGE, Integer.valueOf(0)); -@@ -66,6 +_,8 @@ - } else { - p_220914_.setBlock(p_220915_, p_220913_.setValue(AGE, Integer.valueOf(j + 1)), 4); +@@ -63,6 +_,7 @@ } -+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_220914_, p_220915_, p_220913_); -+ } } + ++ if (!net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_220914_, blockpos, p_220913_, true)) return; + if (j == 8 && this.canSurvive(this.defaultBlockState(), p_220914_, p_220915_.above())) { + double d0 = i >= 3 ? 0.25 : 0.1; + if (p_220916_.nextDouble() <= d0) { +@@ -78,6 +_,7 @@ + if (j < 15) { + p_220914_.setBlock(p_220915_, p_220913_.setValue(AGE, j + 1), 260); + } ++ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_220914_, p_220915_, p_220913_); } } -@@ -108,7 +_,7 @@ + +@@ -119,7 +_,7 @@ } BlockState blockstate1 = p_51154_.getBlockState(p_51155_.below()); @@ -43,7 +42,7 @@ } @Override -@@ -124,5 +_,15 @@ +@@ -135,5 +_,15 @@ @Override protected boolean isPathfindable(BlockState p_51143_, PathComputationType p_51146_) { return false; diff --git a/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch index 4db887cbad..3d074f9d32 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/CampfireBlock.java +++ b/net/minecraft/world/level/block/CampfireBlock.java -@@ -287,7 +_,7 @@ +@@ -263,7 +_,7 @@ return true; } -- boolean flag = Shapes.joinIsNotEmpty(VIRTUAL_FENCE_POST, blockstate.getCollisionShape(p_51249_, p_51250_, CollisionContext.empty()), BooleanOp.AND); -+ boolean flag = Shapes.joinIsNotEmpty(VIRTUAL_FENCE_POST, blockstate.getCollisionShape(p_51249_, blockpos, CollisionContext.empty()), BooleanOp.AND); // FORGE: Fix MC-201374 +- boolean flag = Shapes.joinIsNotEmpty(SHAPE_VIRTUAL_POST, blockstate.getCollisionShape(p_51249_, p_51250_, CollisionContext.empty()), BooleanOp.AND); ++ boolean flag = Shapes.joinIsNotEmpty(SHAPE_VIRTUAL_POST, blockstate.getCollisionShape(p_51249_, blockpos, CollisionContext.empty()), BooleanOp.AND); // FORGE: Fix MC-201374 if (flag) { BlockState blockstate1 = p_51249_.getBlockState(blockpos.below()); return isLitCampfire(blockstate1); diff --git a/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch index 05a8241fdc..864c64fcfb 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ChestBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -360,7 +_,8 @@ +@@ -340,7 +_,8 @@ @Override protected BlockState mirror(BlockState p_51549_, Mirror p_51550_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/ChorusPlantBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ChorusPlantBlock.java.patch index 1f7dea618a..1364279a15 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ChorusPlantBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/ChorusPlantBlock.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/level/block/ChorusPlantBlock.java +++ b/net/minecraft/world/level/block/ChorusPlantBlock.java -@@ -50,7 +_,7 @@ +@@ -49,7 +_,7 @@ + BlockState blockstate4 = p_51711_.getBlockState(p_51712_.south()); BlockState blockstate5 = p_51711_.getBlockState(p_51712_.west()); Block block = p_312378_.getBlock(); - return p_312378_.trySetValue( -- DOWN, Boolean.valueOf(blockstate.is(block) || blockstate.is(Blocks.CHORUS_FLOWER) || blockstate.is(Blocks.END_STONE)) -+ DOWN, Boolean.valueOf(blockstate.is(block) || blockstate.is(Blocks.CHORUS_FLOWER) || blockstate.is(Blocks.END_STONE) || blockstate.is(net.minecraftforge.common.Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON)) - ) - .trySetValue(UP, Boolean.valueOf(blockstate1.is(block) || blockstate1.is(Blocks.CHORUS_FLOWER))) - .trySetValue(NORTH, Boolean.valueOf(blockstate2.is(block) || blockstate2.is(Blocks.CHORUS_FLOWER))) -@@ -74,7 +_,7 @@ +- return p_312378_.trySetValue(DOWN, blockstate.is(block) || blockstate.is(Blocks.CHORUS_FLOWER) || blockstate.is(Blocks.END_STONE)) ++ return p_312378_.trySetValue(DOWN, blockstate.is(block) || blockstate.is(Blocks.CHORUS_FLOWER) || blockstate.is(Blocks.END_STONE) || blockstate.is(net.minecraftforge.common.Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON)) + .trySetValue(UP, blockstate1.is(block) || blockstate1.is(Blocks.CHORUS_FLOWER)) + .trySetValue(NORTH, blockstate2.is(block) || blockstate2.is(Blocks.CHORUS_FLOWER)) + .trySetValue(EAST, blockstate3.is(block) || blockstate3.is(Blocks.CHORUS_FLOWER)) +@@ -72,7 +_,7 @@ p_364837_.scheduleTick(p_51732_, this, 1); return super.updateShape(p_51728_, p_369826_, p_364837_, p_51732_, p_51729_, p_51733_, p_51730_, p_368636_); } else { - boolean flag = p_51730_.is(this) || p_51730_.is(Blocks.CHORUS_FLOWER) || p_51729_ == Direction.DOWN && p_51730_.is(Blocks.END_STONE); + boolean flag = p_51730_.is(this) || p_51730_.is(Blocks.CHORUS_FLOWER) || p_51729_ == Direction.DOWN && (p_51730_.is(Blocks.END_STONE) || p_51730_.is(net.minecraftforge.common.Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON)); - return p_51728_.setValue(PROPERTY_BY_DIRECTION.get(p_51729_), Boolean.valueOf(flag)); + return p_51728_.setValue(PROPERTY_BY_DIRECTION.get(p_51729_), flag); } } -@@ -100,13 +_,13 @@ +@@ -98,13 +_,13 @@ } BlockState blockstate2 = p_51725_.getBlockState(blockpos.below()); diff --git a/patches/minecraft/net/minecraft/world/level/block/CocoaBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CocoaBlock.java.patch index 0915c0cae4..de814765d7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CocoaBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CocoaBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CocoaBlock.java +++ b/net/minecraft/world/level/block/CocoaBlock.java -@@ -64,10 +_,11 @@ +@@ -52,10 +_,11 @@ @Override protected void randomTick(BlockState p_221000_, ServerLevel p_221001_, BlockPos p_221002_, RandomSource p_221003_) { @@ -9,7 +9,7 @@ int i = p_221000_.getValue(AGE); - if (i < 2) { + if (i < 2 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_221001_, p_221002_, p_221000_, p_221001_.random.nextInt(5) == 0)) { - p_221001_.setBlock(p_221002_, p_221000_.setValue(AGE, Integer.valueOf(i + 1)), 2); + p_221001_.setBlock(p_221002_, p_221000_.setValue(AGE, i + 1), 2); + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_221001_, p_221002_, p_221000_); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch index 9e5c25509e..fdb34bc963 100644 --- a/patches/minecraft/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ b/patches/minecraft/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 -@@ -207,4 +_,16 @@ +@@ -200,4 +_,16 @@ protected void createBlockStateDefinition(StateDefinition.Builder p_51887_) { p_51887_.add(FACING, MODE, POWERED); } diff --git a/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch index 72095f6e91..a840561f75 100644 --- a/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/CropBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CropBlock.java +++ b/net/minecraft/world/level/block/CropBlock.java -@@ -54,7 +_,7 @@ +@@ -46,7 +_,7 @@ @Override protected boolean mayPlaceOn(BlockState p_52302_, BlockGetter p_52303_, BlockPos p_52304_) { @@ -9,7 +9,7 @@ } protected IntegerProperty getAgeProperty() { -@@ -88,8 +_,9 @@ +@@ -80,8 +_,9 @@ int i = this.getAge(p_221050_); if (i < this.getMaxAge()) { float f = getGrowthSpeed(this, p_221051_, p_221052_); @@ -20,7 +20,7 @@ } } } -@@ -117,9 +_,9 @@ +@@ -104,9 +_,9 @@ for (int j = -1; j <= 1; j++) { float f1 = 0.0F; BlockState blockstate = p_52274_.getBlockState(blockpos.offset(i, 0, j)); @@ -32,10 +32,10 @@ f1 = 3.0F; } } -@@ -164,7 +_,7 @@ +@@ -151,7 +_,7 @@ @Override - protected void entityInside(BlockState p_52277_, Level p_52278_, BlockPos p_52279_, Entity p_52280_) { + protected void entityInside(BlockState p_52277_, Level p_52278_, BlockPos p_52279_, Entity p_52280_, InsideBlockEffectApplier p_391246_) { - 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.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(serverlevel, p_52280_)) { serverlevel.destroyBlock(p_52279_, true, p_52280_); diff --git a/patches/minecraft/net/minecraft/world/level/block/DeadBushBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DeadBushBlock.java.patch deleted file mode 100644 index 0e25a00037..0000000000 --- a/patches/minecraft/net/minecraft/world/level/block/DeadBushBlock.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/block/DeadBushBlock.java -+++ b/net/minecraft/world/level/block/DeadBushBlock.java -@@ -9,7 +_,7 @@ - import net.minecraft.world.phys.shapes.CollisionContext; - import net.minecraft.world.phys.shapes.VoxelShape; - --public class DeadBushBlock extends BushBlock { -+public class DeadBushBlock extends BushBlock implements net.minecraftforge.common.IForgeShearable { - public static final MapCodec CODEC = simpleCodec(DeadBushBlock::new); - protected static final float AABB_OFFSET = 6.0F; - protected static final VoxelShape SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 13.0, 14.0); diff --git a/patches/minecraft/net/minecraft/world/level/block/DetectorRailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DetectorRailBlock.java.patch index 0e04437a76..08d6f4352e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DetectorRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DetectorRailBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DetectorRailBlock.java +++ b/net/minecraft/world/level/block/DetectorRailBlock.java -@@ -38,6 +_,10 @@ +@@ -39,6 +_,10 @@ public DetectorRailBlock(BlockBehaviour.Properties p_52431_) { super(true, p_52431_); @@ -8,10 +8,10 @@ + } + + protected void registerDefaultState() { - this.registerDefaultState( - this.stateDefinition - .any() -@@ -152,7 +_,10 @@ + this.registerDefaultState(this.stateDefinition.any().setValue(POWERED, false).setValue(SHAPE, RailShape.NORTH_SOUTH).setValue(WATERLOGGED, false)); + } + +@@ -147,7 +_,10 @@ return list.get(0).getCommandBlock().getSuccessCount(); } @@ -23,7 +23,7 @@ if (!list1.isEmpty()) { return AbstractContainerMenu.getRedstoneSignalFromContainer((Container)list1.get(0)); } -@@ -297,6 +_,6 @@ +@@ -292,6 +_,6 @@ @Override protected void createBlockStateDefinition(StateDefinition.Builder p_52469_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch index 8f2c5ac067..4ba66c754b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DiodeBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DiodeBlock.java +++ b/net/minecraft/world/level/block/DiodeBlock.java -@@ -176,6 +_,9 @@ +@@ -175,6 +_,9 @@ Direction direction = p_52583_.getValue(FACING); BlockPos blockpos = p_52582_.relative(direction.getOpposite()); Orientation orientation = ExperimentalRedstoneUtils.initialOrientation(p_52581_, direction.getOpposite(), Direction.UP); diff --git a/patches/minecraft/net/minecraft/world/level/block/DryVegetationBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DryVegetationBlock.java.patch new file mode 100644 index 0000000000..183ed08069 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/DryVegetationBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/DryVegetationBlock.java ++++ b/net/minecraft/world/level/block/DryVegetationBlock.java +@@ -13,7 +_,7 @@ + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public class DryVegetationBlock extends VegetationBlock { ++public class DryVegetationBlock extends VegetationBlock implements net.minecraftforge.common.IForgeShearable { + public static final MapCodec CODEC = simpleCodec(DryVegetationBlock::new); + private static final VoxelShape SHAPE = Block.column(12.0, 0.0, 13.0); + private static final int IDLE_SOUND_CHANCE = 150; diff --git a/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch index 8a35a67562..51d06f6c1f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FarmBlock.java.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/world/level/block/FarmBlock.java @@ -107,10 +_,7 @@ @Override - public void fallOn(Level p_153227_, BlockState p_153228_, BlockPos p_153229_, Entity p_153230_, float p_153231_) { + public void fallOn(Level p_153227_, BlockState p_153228_, BlockPos p_153229_, Entity p_153230_, double p_394537_) { if (p_153227_ instanceof ServerLevel serverlevel -- && p_153227_.random.nextFloat() < p_153231_ - 0.5F +- && p_153227_.random.nextFloat() < p_394537_ - 0.5 - && p_153230_ instanceof LivingEntity - && (p_153230_ instanceof Player || serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) - && p_153230_.getBbWidth() * p_153230_.getBbWidth() * p_153230_.getBbHeight() > 0.512F) { -+ && net.minecraftforge.common.ForgeHooks.onFarmlandTrample(serverlevel, p_153229_, Blocks.DIRT.defaultBlockState(), p_153231_, p_153230_)) { // Forge: Move logic to Entity#canTrample ++ && net.minecraftforge.common.ForgeHooks.onFarmlandTrample(serverlevel, p_153229_, Blocks.DIRT.defaultBlockState(), p_394537_, p_153230_)) { // Forge: Move logic to Entity#canTrample turnToDirt(p_153230_, p_153228_, p_153227_, p_153229_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/FenceGateBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FenceGateBlock.java.patch index 1e532e287e..d208aee5e4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FenceGateBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FenceGateBlock.java.patch @@ -1,32 +1,31 @@ --- a/net/minecraft/world/level/block/FenceGateBlock.java +++ b/net/minecraft/world/level/block/FenceGateBlock.java -@@ -55,6 +_,8 @@ - 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)); +@@ -59,6 +_,8 @@ + Util.mapValues(SHAPE_OCCLUSION, p_390935_ -> p_390935_.move(0.0, -0.1875, 0.0).optimize()) + ); private final WoodType type; + private final net.minecraft.sounds.SoundEvent openSound; + private final net.minecraft.sounds.SoundEvent closeSound; @Override public MapCodec codec() { -@@ -62,8 +_,14 @@ +@@ -66,8 +_,14 @@ } public FenceGateBlock(WoodType p_273340_, BlockBehaviour.Properties p_273352_) { - super(p_273352_.sound(p_273340_.soundType())); -- this.type = p_273340_; + this(p_273340_, p_273352_, p_273340_.fenceGateOpen(), p_273340_.fenceGateClose()); + } + + public FenceGateBlock(WoodType p_273340_, BlockBehaviour.Properties p_273352_, net.minecraft.sounds.SoundEvent openSound, net.minecraft.sounds.SoundEvent closeSound) { -+ super(p_273352_); -+ this.type = p_273340_; -+ this.openSound = openSound; -+ this.closeSound = closeSound; - this.registerDefaultState( - this.stateDefinition - .any() -@@ -183,7 +_,7 @@ ++ super(p_273352_); + this.type = p_273340_; ++ this.openSound = openSound; ++ this.closeSound = closeSound; + this.registerDefaultState(this.stateDefinition.any().setValue(OPEN, false).setValue(POWERED, false).setValue(IN_WALL, false)); + } + +@@ -165,7 +_,7 @@ p_53366_.playSound( p_53368_, p_53367_, @@ -35,7 +34,7 @@ SoundSource.BLOCKS, 1.0F, p_53366_.getRandom().nextFloat() * 0.1F + 0.9F -@@ -200,7 +_,7 @@ +@@ -182,7 +_,7 @@ p_368190_.playSound( null, p_311232_, @@ -44,7 +43,7 @@ SoundSource.BLOCKS, 1.0F, p_368190_.getRandom().nextFloat() * 0.1F + 0.9F -@@ -221,7 +_,7 @@ +@@ -203,7 +_,7 @@ p_53373_.playSound( null, p_53374_, diff --git a/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch index 12622a47ed..903de449ea 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch +++ b/patches/minecraft/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 -@@ -139,13 +_,13 @@ +@@ -117,13 +_,13 @@ protected BlockState getStateForPlacement(BlockGetter p_53471_, BlockPos p_53472_) { BlockPos blockpos = p_53472_.below(); BlockState blockstate = p_53471_.getBlockState(blockpos); @@ -11,49 +11,49 @@ for (Direction direction : Direction.values()) { BooleanProperty booleanproperty = PROPERTY_BY_DIRECTION.get(direction); if (booleanproperty != null) { -- blockstate1 = blockstate1.setValue(booleanproperty, Boolean.valueOf(this.canBurn(p_53471_.getBlockState(p_53472_.relative(direction))))); +- blockstate1 = blockstate1.setValue(booleanproperty, this.canBurn(p_53471_.getBlockState(p_53472_.relative(direction)))); + blockstate1 = blockstate1.setValue(booleanproperty, Boolean.valueOf(this.canCatchFire(p_53471_, p_53472_.relative(direction), direction.getOpposite()))); } } +@@ -149,7 +_,7 @@ + } + + BlockState blockstate = p_221161_.getBlockState(p_221162_.below()); +- boolean flag = blockstate.is(p_221161_.dimensionType().infiniburn()); ++ boolean flag = blockstate.isFireSource(p_221161_, p_221162_, Direction.UP); + int i = p_221160_.getValue(AGE); + if (!flag && p_221161_.isRaining() && this.isNearRain(p_221161_, p_221162_) && p_221163_.nextFloat() < 0.2F + i * 0.03F) { + p_221161_.removeBlock(p_221162_, false); @@ -170,7 +_,7 @@ - } + return; + } - BlockState blockstate = p_221161_.getBlockState(p_221162_.below()); -- boolean flag = blockstate.is(p_221161_.dimensionType().infiniburn()); -+ boolean flag = blockstate.isFireSource(p_221161_, p_221162_, Direction.UP); - 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); -@@ -191,7 +_,7 @@ - return; - } +- if (i == 15 && p_221163_.nextInt(4) == 0 && !this.canBurn(p_221161_.getBlockState(p_221162_.below()))) { ++ if (i == 15 && p_221163_.nextInt(4) == 0 && !this.canCatchFire(p_221161_, p_221162_.below(), Direction.UP)) { + p_221161_.removeBlock(p_221162_, false); + return; + } +@@ -178,12 +_,12 @@ -- if (i == 15 && p_221163_.nextInt(4) == 0 && !this.canBurn(p_221161_.getBlockState(p_221162_.below()))) { -+ if (i == 15 && p_221163_.nextInt(4) == 0 && !this.canCatchFire(p_221161_, p_221162_.below(), Direction.UP)) { - p_221161_.removeBlock(p_221162_, false); - return; - } -@@ -199,12 +_,12 @@ + boolean flag1 = p_221161_.getBiome(p_221162_).is(BiomeTags.INCREASED_FIRE_BURNOUT); + int k = flag1 ? -50 : 0; +- this.checkBurnOut(p_221161_, p_221162_.east(), 300 + k, p_221163_, i); +- this.checkBurnOut(p_221161_, p_221162_.west(), 300 + k, p_221163_, i); +- this.checkBurnOut(p_221161_, p_221162_.below(), 250 + k, p_221163_, i); +- this.checkBurnOut(p_221161_, p_221162_.above(), 250 + k, p_221163_, i); +- this.checkBurnOut(p_221161_, p_221162_.north(), 300 + k, p_221163_, i); +- this.checkBurnOut(p_221161_, p_221162_.south(), 300 + k, p_221163_, i); ++ this.checkBurnOut(p_221161_, p_221162_.east(), 300 + k, p_221163_, i, Direction.WEST); ++ this.checkBurnOut(p_221161_, p_221162_.west(), 300 + k, p_221163_, i, Direction.EAST); ++ this.checkBurnOut(p_221161_, p_221162_.below(), 250 + k, p_221163_, i, Direction.UP); ++ this.checkBurnOut(p_221161_, p_221162_.above(), 250 + k, p_221163_, i, Direction.DOWN); ++ this.checkBurnOut(p_221161_, p_221162_.north(), 300 + k, p_221163_, i, Direction.SOUTH); ++ this.checkBurnOut(p_221161_, p_221162_.south(), 300 + k, p_221163_, i, Direction.NORTH); + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); - boolean flag1 = p_221161_.getBiome(p_221162_).is(BiomeTags.INCREASED_FIRE_BURNOUT); - int k = flag1 ? -50 : 0; -- this.checkBurnOut(p_221161_, p_221162_.east(), 300 + k, p_221163_, i); -- this.checkBurnOut(p_221161_, p_221162_.west(), 300 + k, p_221163_, i); -- this.checkBurnOut(p_221161_, p_221162_.below(), 250 + k, p_221163_, i); -- this.checkBurnOut(p_221161_, p_221162_.above(), 250 + k, p_221163_, i); -- this.checkBurnOut(p_221161_, p_221162_.north(), 300 + k, p_221163_, i); -- this.checkBurnOut(p_221161_, p_221162_.south(), 300 + k, p_221163_, i); -+ this.checkBurnOut(p_221161_, p_221162_.east(), 300 + k, p_221163_, i, Direction.WEST); -+ this.checkBurnOut(p_221161_, p_221162_.west(), 300 + k, p_221163_, i, Direction.EAST); -+ this.checkBurnOut(p_221161_, p_221162_.below(), 250 + k, p_221163_, i, Direction.UP); -+ this.checkBurnOut(p_221161_, p_221162_.above(), 250 + k, p_221163_, i, Direction.DOWN); -+ this.checkBurnOut(p_221161_, p_221162_.north(), 300 + k, p_221163_, i, Direction.SOUTH); -+ this.checkBurnOut(p_221161_, p_221162_.south(), 300 + k, p_221163_, i, Direction.NORTH); - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); - - for (int l = -1; l <= 1; l++) { -@@ -247,33 +_,31 @@ + for (int l = -1; l <= 1; l++) { +@@ -227,33 +_,31 @@ || p_53429_.isRainingAt(p_53430_.south()); } @@ -87,12 +87,12 @@ - - Block block = blockstate.getBlock(); - if (block instanceof TntBlock) { -- TntBlock.explode(p_221151_, p_221152_); +- TntBlock.prime(p_221151_, p_221152_); - } } } -@@ -284,7 +_,7 @@ +@@ -264,7 +_,7 @@ private boolean isValidFireLocation(BlockGetter p_53486_, BlockPos p_53487_) { for (Direction direction : Direction.values()) { @@ -101,7 +101,7 @@ return true; } } -@@ -300,13 +_,14 @@ +@@ -280,13 +_,14 @@ for (Direction direction : Direction.values()) { BlockState blockstate = p_221157_.getBlockState(p_221158_.relative(direction)); @@ -117,7 +117,7 @@ @Override protected boolean canBurn(BlockState p_53489_) { return this.getIgniteOdds(p_53489_) > 0; -@@ -328,8 +_,21 @@ +@@ -308,8 +_,21 @@ } public void setFlammable(Block p_53445_, int p_53446_, int p_53447_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch index f87a51ddea..c1d3bf5f52 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FlowerPotBlock.java +++ b/net/minecraft/world/level/block/FlowerPotBlock.java -@@ -45,9 +_,31 @@ +@@ -44,9 +_,31 @@ } public FlowerPotBlock(Block p_53528_, BlockBehaviour.Properties p_53529_) { @@ -35,7 +35,7 @@ } @Override -@@ -60,7 +_,7 @@ +@@ -59,7 +_,7 @@ ItemStack p_329639_, BlockState p_328047_, Level p_328816_, BlockPos p_334572_, Player p_329206_, InteractionHand p_329142_, BlockHitResult p_330607_ ) { BlockState blockstate = (p_329639_.getItem() instanceof BlockItem blockitem @@ -44,7 +44,7 @@ : Blocks.AIR) .defaultBlockState(); if (blockstate.isAir()) { -@@ -86,7 +_,7 @@ +@@ -85,7 +_,7 @@ p_333787_.drop(itemstack, false); } @@ -53,7 +53,7 @@ p_334489_.gameEvent(p_333787_, GameEvent.BLOCK_CHANGE, p_330334_); return InteractionResult.SUCCESS; } -@@ -118,7 +_,7 @@ +@@ -117,7 +_,7 @@ } public Block getPotted() { @@ -62,7 +62,7 @@ } @Override -@@ -153,5 +_,24 @@ +@@ -152,5 +_,24 @@ } else { return p_376074_.is(Blocks.POTTED_CLOSED_EYEBLOSSOM) ? Blocks.POTTED_OPEN_EYEBLOSSOM.defaultBlockState() : p_376074_; } diff --git a/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch index 312a937551..4e47c3c6e6 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LeavesBlock.java.patch @@ -4,8 +4,8 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; --public class LeavesBlock extends Block implements SimpleWaterloggedBlock { -+public class LeavesBlock extends Block implements SimpleWaterloggedBlock, net.minecraftforge.common.IForgeShearable { - public static final MapCodec CODEC = simpleCodec(LeavesBlock::new); +-public abstract class LeavesBlock extends Block implements SimpleWaterloggedBlock { ++public abstract class LeavesBlock extends Block implements SimpleWaterloggedBlock, net.minecraftforge.common.IForgeShearable { public static final int DECAY_DISTANCE = 7; public static final IntegerProperty DISTANCE = BlockStateProperties.DISTANCE; + public static final BooleanProperty PERSISTENT = BlockStateProperties.PERSISTENT; diff --git a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch index 5713aaf3b8..0a778957e0 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -8,7 +8,7 @@ + @Deprecated // Use getFluid + private final FlowingFluid fluid; private final List stateCache; - public static final VoxelShape STABLE_SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0); + public static final VoxelShape SHAPE_STABLE = Block.column(16.0, 0.0, 8.0); public static final ImmutableList POSSIBLE_FLOW_DIRECTIONS = ImmutableList.of(Direction.DOWN, Direction.SOUTH, Direction.NORTH, Direction.EAST, Direction.WEST); @@ -63,6 +_,7 @@ return CODEC; @@ -21,7 +21,7 @@ @@ -75,6 +_,19 @@ this.stateCache.add(p_54694_.getFlowing(8, true)); - this.registerDefaultState(this.stateDefinition.any().setValue(LEVEL, Integer.valueOf(0))); + this.registerDefaultState(this.stateDefinition.any().setValue(LEVEL, 0)); + fluidStateCacheInitialized = true; + supplier = () -> p_54694_; + } diff --git a/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch index f7e3f4d67d..89ae290aa8 100644 --- a/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/MushroomBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/MushroomBlock.java +++ b/net/minecraft/world/level/block/MushroomBlock.java -@@ -83,7 +_,7 @@ +@@ -82,7 +_,7 @@ protected boolean canSurvive(BlockState p_54880_, LevelReader p_54881_, BlockPos p_54882_) { BlockPos blockpos = p_54882_.below(); BlockState blockstate = p_54881_.getBlockState(blockpos); @@ -9,7 +9,7 @@ } public boolean growMushroom(ServerLevel p_221774_, BlockPos p_221775_, BlockState p_221776_, RandomSource p_221777_) { -@@ -91,8 +_,10 @@ +@@ -90,8 +_,10 @@ if (optional.isEmpty()) { return false; } else { diff --git a/patches/minecraft/net/minecraft/world/level/block/NetherWartBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/NetherWartBlock.java.patch index 67f48fc3e1..7e84ccf5f1 100644 --- a/patches/minecraft/net/minecraft/world/level/block/NetherWartBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/NetherWartBlock.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/block/NetherWartBlock.java +++ b/net/minecraft/world/level/block/NetherWartBlock.java -@@ -55,9 +_,10 @@ +@@ -50,9 +_,10 @@ @Override protected void randomTick(BlockState p_221806_, ServerLevel p_221807_, BlockPos p_221808_, RandomSource p_221809_) { int i = p_221806_.getValue(AGE); - if (i < 3 && p_221809_.nextInt(10) == 0) { + if (i < 3 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_221807_, p_221808_, p_221806_, p_221809_.nextInt(10) == 0)) { - p_221806_ = p_221806_.setValue(AGE, Integer.valueOf(i + 1)); + p_221806_ = p_221806_.setValue(AGE, i + 1); p_221807_.setBlock(p_221808_, p_221806_, 2); + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_221807_, p_221808_, p_221806_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch index 691523a836..8312ec4e73 100644 --- a/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/NoteBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/NoteBlock.java +++ b/net/minecraft/world/level/block/NoteBlock.java -@@ -121,7 +_,9 @@ +@@ -115,7 +_,9 @@ @Override protected InteractionResult useWithoutItem(BlockState p_331116_, Level p_332131_, BlockPos p_333586_, Player p_329332_, BlockHitResult p_331978_) { if (!p_332131_.isClientSide) { @@ -11,7 +11,7 @@ p_332131_.setBlock(p_333586_, p_331116_, 3); this.playNote(p_329332_, p_331116_, p_332131_, p_333586_); p_329332_.awardStat(Stats.TUNE_NOTEBLOCK); -@@ -144,6 +_,9 @@ +@@ -138,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/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch index 923d5b94e6..a5fc424b97 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch +++ b/patches/minecraft/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 -@@ -126,7 +_,7 @@ +@@ -138,7 +_,7 @@ if (p_154256_.getType().is(EntityTypeTags.POWDER_SNOW_WALKABLE_MOBS)) { return true; } else { diff --git a/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch index 914f270ee4..9f081863ce 100644 --- a/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/PoweredRailBlock.java.patch @@ -22,10 +22,10 @@ + } + + protected void registerDefaultState() { - this.registerDefaultState( - this.stateDefinition - .any() -@@ -41,7 +_,7 @@ + this.registerDefaultState(this.stateDefinition.any().setValue(SHAPE, RailShape.NORTH_SOUTH).setValue(POWERED, false).setValue(WATERLOGGED, false)); + } + +@@ -35,7 +_,7 @@ int j = p_55221_.getY(); int k = p_55221_.getZ(); boolean flag = true; @@ -34,7 +34,7 @@ switch (railshape) { case NORTH_SOUTH: if (p_55223_) { -@@ -110,10 +_,10 @@ +@@ -104,10 +_,10 @@ protected boolean isSameRailWithPower(Level p_55226_, BlockPos p_55227_, boolean p_55228_, int p_55229_, RailShape p_55230_) { BlockState blockstate = p_55226_.getBlockState(p_55227_); @@ -47,7 +47,7 @@ if (p_55230_ != RailShape.EAST_WEST || railshape != RailShape.NORTH_SOUTH && railshape != RailShape.ASCENDING_NORTH && railshape != RailShape.ASCENDING_SOUTH) { if (p_55230_ != RailShape.NORTH_SOUTH -@@ -121,7 +_,7 @@ +@@ -115,7 +_,7 @@ if (!blockstate.getValue(POWERED)) { return false; } else { @@ -56,16 +56,16 @@ } } else { return false; -@@ -141,7 +_,7 @@ +@@ -135,7 +_,7 @@ if (flag1 != flag) { - p_55233_.setBlock(p_55234_, p_55232_.setValue(POWERED, Boolean.valueOf(flag1)), 3); + p_55233_.setBlock(p_55234_, p_55232_.setValue(POWERED, flag1), 3); p_55233_.updateNeighborsAt(p_55234_.below(), this); - if (p_55232_.getValue(SHAPE).isSlope()) { + if (p_55232_.getValue(getShapeProperty()).isSlope()) { p_55233_.updateNeighborsAt(p_55234_.above(), this); } } -@@ -173,6 +_,9 @@ +@@ -167,6 +_,9 @@ return p_55240_.setValue(SHAPE, RailShape.SOUTH_EAST); case NORTH_EAST: return p_55240_.setValue(SHAPE, RailShape.SOUTH_WEST); @@ -75,7 +75,7 @@ } case COUNTERCLOCKWISE_90: switch ((RailShape)p_55240_.getValue(SHAPE)) { -@@ -272,6 +_,10 @@ +@@ -266,6 +_,10 @@ @Override protected void createBlockStateDefinition(StateDefinition.Builder p_55243_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/RedStoneOreBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/RedStoneOreBlock.java.patch index 014f27c245..b9d8f1c263 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RedStoneOreBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/RedStoneOreBlock.java.patch @@ -9,7 +9,7 @@ this.tryDropExperience(p_221908_, p_221909_, p_221910_, UniformInt.of(1, 5)); } } -@@ -127,4 +_,10 @@ +@@ -119,4 +_,10 @@ protected void createBlockStateDefinition(StateDefinition.Builder p_55484_) { p_55484_.add(LIT); } diff --git a/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch index 667adbd201..7440149dbf 100644 --- a/patches/minecraft/net/minecraft/world/level/block/RedStoneWireBlock.java.patch +++ b/patches/minecraft/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 -@@ -264,7 +_,7 @@ +@@ -239,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; } -@@ -273,9 +_,14 @@ +@@ -248,9 +_,14 @@ } } diff --git a/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch index a0b98fc1dd..e1f462acdd 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SaplingBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SaplingBlock.java +++ b/net/minecraft/world/level/block/SaplingBlock.java -@@ -46,6 +_,7 @@ +@@ -45,6 +_,7 @@ @Override protected void randomTick(BlockState p_222011_, ServerLevel p_222012_, BlockPos p_222013_, RandomSource p_222014_) { diff --git a/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch index cd50666b90..b4e51f53e0 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SculkSensorBlock.java.patch +++ b/patches/minecraft/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 -@@ -296,8 +_,13 @@ +@@ -283,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/minecraft/net/minecraft/world/level/block/SculkShriekerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SculkShriekerBlock.java.patch index d478bf836d..fc175e4928 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SculkShriekerBlock.java.patch +++ b/patches/minecraft/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 -@@ -143,7 +_,7 @@ +@@ -128,7 +_,7 @@ @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_); @@ -9,7 +9,7 @@ this.tryDropExperience(p_222193_, p_222194_, p_222195_, ConstantInt.of(5)); } } -@@ -158,5 +_,10 @@ +@@ -143,5 +_,10 @@ (p_281134_, p_281135_, p_281136_, p_281137_) -> VibrationSystem.Ticker.tick(p_281134_, p_281137_.getVibrationData(), p_281137_.getVibrationUser()) ) : null; diff --git a/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch index a68fa05516..7dcffdd0b3 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SeagrassBlock.java.patch @@ -4,8 +4,8 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; --public class SeagrassBlock extends BushBlock implements BonemealableBlock, LiquidBlockContainer { -+public class SeagrassBlock extends BushBlock implements BonemealableBlock, LiquidBlockContainer, net.minecraftforge.common.IForgeShearable { +-public class SeagrassBlock extends VegetationBlock implements BonemealableBlock, LiquidBlockContainer { ++public class SeagrassBlock extends VegetationBlock implements BonemealableBlock, LiquidBlockContainer, net.minecraftforge.common.IForgeShearable { public static final MapCodec CODEC = simpleCodec(SeagrassBlock::new); - protected static final float AABB_OFFSET = 6.0F; - protected static final VoxelShape SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 12.0, 14.0); + private static final VoxelShape SHAPE = Block.column(12.0, 0.0, 12.0); + diff --git a/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch b/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch index 01c60379d2..8d6f058d57 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SoundType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SoundType.java +++ b/net/minecraft/world/level/block/SoundType.java -@@ -363,6 +_,7 @@ +@@ -372,6 +_,7 @@ private final SoundEvent hitSound; private final SoundEvent fallSound; diff --git a/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch index ebe0c83231..15a2c8980e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SpawnerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpawnerBlock.java +++ b/net/minecraft/world/level/block/SpawnerBlock.java -@@ -44,7 +_,7 @@ +@@ -39,9 +_,14 @@ @Override protected void spawnAfterBreak(BlockState p_222477_, ServerLevel p_222478_, BlockPos p_222479_, ItemStack p_222480_, boolean p_222481_) { super.spawnAfterBreak(p_222477_, p_222478_, p_222479_, p_222480_, p_222481_); @@ -9,14 +9,10 @@ int i = 15 + p_222478_.random.nextInt(15) + p_222478_.random.nextInt(15); this.popExperience(p_222478_, p_222479_, i); } -@@ -54,5 +_,10 @@ - public void appendHoverText(ItemStack p_255714_, Item.TooltipContext p_331610_, List p_255708_, TooltipFlag p_255667_) { - super.appendHoverText(p_255714_, p_331610_, p_255708_, p_255667_); - Spawner.appendHoverText(p_255714_, p_255708_, "SpawnData"); + } + + @Override -+ public int getExpDrop(BlockState state, net.minecraft.world.level.LevelReader world, net.minecraft.util.RandomSource randomSource, BlockPos pos, int fortune, int silktouch) { ++ public int getExpDrop(BlockState state, net.minecraft.world.level.LevelReader level, net.minecraft.util.RandomSource randomSource, BlockPos pos, int fortuneLevel, int silkTouchLevel) { + return 15 + randomSource.nextInt(15) + randomSource.nextInt(15); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch index c4e78d0895..4b053b12c7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SpongeBlock.java.patch @@ -15,5 +15,5 @@ - if (!fluidstate.is(FluidTags.WATER)) { + if (!spongeState.canBeHydrated(p_56808_, p_56809_, fluidstate, p_296944_)) { return BlockPos.TraversalNodeStatus.SKIP; - } else { - if (blockstate.getBlock() instanceof BucketPickup bucketpickup + } else if (blockstate.getBlock() instanceof BucketPickup bucketpickup + && !bucketpickup.pickupBlock(null, p_56808_, p_296944_, blockstate).isEmpty()) { diff --git a/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch index 951631520f..942774ce62 100644 --- a/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/StemBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/StemBlock.java +++ b/net/minecraft/world/level/block/StemBlock.java -@@ -79,9 +_,11 @@ +@@ -69,9 +_,11 @@ @Override protected void randomTick(BlockState p_222538_, ServerLevel p_222539_, BlockPos p_222540_, RandomSource p_222541_) { @@ -12,8 +12,8 @@ + if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_222539_, p_222540_, p_222538_, vanilla)) { int i = p_222538_.getValue(AGE); if (i < 7) { - p_222538_ = p_222538_.setValue(AGE, Integer.valueOf(i + 1)); -@@ -100,6 +_,7 @@ + p_222538_ = p_222538_.setValue(AGE, i + 1); +@@ -90,6 +_,7 @@ } } } @@ -21,7 +21,7 @@ } } } -@@ -132,5 +_,10 @@ +@@ -122,5 +_,10 @@ @Override protected void createBlockStateDefinition(StateDefinition.Builder p_57040_) { p_57040_.add(AGE); diff --git a/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch index dbacb3f45b..b3df9ca591 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch @@ -8,8 +8,8 @@ +public class SugarCaneBlock extends Block implements net.minecraftforge.common.IPlantable { public static final MapCodec CODEC = simpleCodec(SugarCaneBlock::new); public static final IntegerProperty AGE = BlockStateProperties.AGE_15; - protected static final float AABB_OFFSET = 6.0F; -@@ -58,12 +_,15 @@ + private static final VoxelShape SHAPE = Block.column(12.0, 0.0, 16.0); +@@ -57,12 +_,15 @@ if (i < 3) { int j = p_222548_.getValue(AGE); @@ -17,15 +17,15 @@ if (j == 15) { p_222549_.setBlockAndUpdate(p_222550_.above(), this.defaultBlockState()); + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_222549_, p_222550_.above(), this.defaultBlockState()); - p_222549_.setBlock(p_222550_, p_222548_.setValue(AGE, Integer.valueOf(0)), 4); + p_222549_.setBlock(p_222550_, p_222548_.setValue(AGE, 0), 260); } else { - p_222549_.setBlock(p_222550_, p_222548_.setValue(AGE, Integer.valueOf(j + 1)), 4); + p_222549_.setBlock(p_222550_, p_222548_.setValue(AGE, j + 1), 260); } + } } } } -@@ -88,6 +_,8 @@ +@@ -87,6 +_,8 @@ @Override protected boolean canSurvive(BlockState p_57175_, LevelReader p_57176_, BlockPos p_57177_) { @@ -34,7 +34,7 @@ BlockState blockstate = p_57176_.getBlockState(p_57177_.below()); if (blockstate.is(this)) { return true; -@@ -98,7 +_,7 @@ +@@ -97,7 +_,7 @@ for (Direction direction : Direction.Plane.HORIZONTAL) { BlockState blockstate1 = p_57176_.getBlockState(blockpos.relative(direction)); FluidState fluidstate = p_57176_.getFluidState(blockpos.relative(direction)); @@ -43,7 +43,7 @@ return true; } } -@@ -111,5 +_,15 @@ +@@ -110,5 +_,15 @@ @Override protected void createBlockStateDefinition(StateDefinition.Builder p_57186_) { p_57186_.add(AGE); diff --git a/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch index c692e418f2..a0fe047e75 100644 --- a/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/block/SweetBerryBushBlock.java +++ b/net/minecraft/world/level/block/SweetBerryBushBlock.java -@@ -68,10 +_,11 @@ +@@ -70,10 +_,11 @@ @Override protected void randomTick(BlockState p_222563_, ServerLevel p_222564_, BlockPos p_222565_, RandomSource p_222566_) { int i = p_222563_.getValue(AGE); - if (i < 3 && p_222566_.nextInt(5) == 0 && p_222564_.getRawBrightness(p_222565_.above(), 0) >= 9) { + if (i < 3 && p_222564_.getRawBrightness(p_222565_.above(), 0) >= 9 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_222564_, p_222565_, p_222563_, p_222566_.nextInt(5) == 0)) { - BlockState blockstate = p_222563_.setValue(AGE, Integer.valueOf(i + 1)); + BlockState blockstate = p_222563_.setValue(AGE, i + 1); p_222564_.setBlock(p_222565_, blockstate, 2); p_222564_.gameEvent(GameEvent.BLOCK_CHANGE, p_222565_, GameEvent.Context.of(blockstate)); + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_222564_, p_222565_, p_222563_); diff --git a/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch index 780d99540a..ae8704af63 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TallGrassBlock.java.patch @@ -4,8 +4,8 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; --public class TallGrassBlock extends BushBlock implements BonemealableBlock { -+public class TallGrassBlock extends BushBlock implements BonemealableBlock, net.minecraftforge.common.IForgeShearable { +-public class TallGrassBlock extends VegetationBlock implements BonemealableBlock { ++public class TallGrassBlock extends VegetationBlock implements BonemealableBlock, net.minecraftforge.common.IForgeShearable { public static final MapCodec CODEC = simpleCodec(TallGrassBlock::new); - protected static final float AABB_OFFSET = 6.0F; - protected static final VoxelShape SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 13.0, 14.0); + private static final VoxelShape SHAPE = Block.column(12.0, 0.0, 13.0); + diff --git a/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch index 407ebf6fde..bcc542a314 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch @@ -1,70 +1,70 @@ --- a/net/minecraft/world/level/block/TntBlock.java +++ b/net/minecraft/world/level/block/TntBlock.java -@@ -46,7 +_,7 @@ +@@ -47,7 +_,7 @@ + @Override protected void onPlace(BlockState p_57466_, Level p_57467_, BlockPos p_57468_, BlockState p_57469_, boolean p_57470_) { if (!p_57469_.is(p_57466_.getBlock())) { - if (p_57467_.hasNeighborSignal(p_57468_)) { -- explode(p_57467_, p_57468_); -+ onCaughtFire(p_57466_, p_57467_, p_57468_, null, null); +- if (p_57467_.hasNeighborSignal(p_57468_) && prime(p_57467_, p_57468_)) { ++ if (p_57467_.hasNeighborSignal(p_57468_) && onCaughtFire(p_57466_, p_57467_, p_57468_, null, null)) { p_57467_.removeBlock(p_57468_, false); } } @@ -55,7 +_,7 @@ + @Override protected void neighborChanged(BlockState p_57457_, Level p_57458_, BlockPos p_57459_, Block p_57460_, @Nullable Orientation p_362896_, boolean p_57462_) { - if (p_57458_.hasNeighborSignal(p_57459_)) { -- explode(p_57458_, p_57459_); -+ onCaughtFire(p_57457_, p_57458_, p_57459_, null, null); +- if (p_57458_.hasNeighborSignal(p_57459_) && prime(p_57458_, p_57459_)) { ++ if (p_57458_.hasNeighborSignal(p_57459_) && onCaughtFire(p_57457_, p_57458_, p_57459_, null, null)) { p_57458_.removeBlock(p_57459_, false); } } @@ -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)) { -- explode(p_57445_, p_57446_); + if (!p_57445_.isClientSide() && !p_57448_.getAbilities().instabuild && p_57447_.getValue(UNSTABLE)) { +- prime(p_57445_, p_57446_); + onCaughtFire(p_57447_, p_57445_, p_57446_, null, null); } return super.playerWillDestroy(p_57445_, p_57446_, p_57447_, p_57448_); @@ -79,10 +_,12 @@ - p_368198_.addFreshEntity(primedtnt); + } } + @Deprecated //Forge: Prefer using IForgeBlock#onCaughtFire - public static void explode(Level p_57434_, BlockPos p_57435_) { - explode(p_57434_, p_57435_, null); + public static boolean prime(Level p_392759_, BlockPos p_392607_) { + return prime(p_392759_, p_392607_, null); } + @Deprecated //Forge: Prefer using IForgeBlock#onCaughtFire - private static void explode(Level p_57437_, BlockPos p_57438_, @Nullable LivingEntity p_57439_) { - if (!p_57437_.isClientSide) { - PrimedTnt primedtnt = new PrimedTnt( -@@ -101,7 +_,7 @@ + private static boolean prime(Level p_396831_, BlockPos p_393566_, @Nullable LivingEntity p_395667_) { + if (p_396831_ instanceof ServerLevel serverlevel && serverlevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { + PrimedTnt primedtnt = new PrimedTnt(p_396831_, p_393566_.getX() + 0.5, p_393566_.getY(), p_393566_.getZ() + 0.5, p_395667_); +@@ -102,7 +_,7 @@ if (!p_329029_.is(Items.FLINT_AND_STEEL) && !p_329029_.is(Items.FIRE_CHARGE)) { return super.useItemOn(p_329029_, p_331413_, p_329038_, p_333168_, p_335932_, p_331663_, p_330020_); } else { -- explode(p_329038_, p_333168_, p_335932_); -+ onCaughtFire(p_331413_, p_329038_, p_333168_, p_330020_.getDirection(), p_335932_); - p_329038_.setBlock(p_333168_, Blocks.AIR.defaultBlockState(), 11); - Item item = p_329029_.getItem(); - if (p_329029_.is(Items.FLINT_AND_STEEL)) { -@@ -121,7 +_,7 @@ - BlockPos blockpos = p_57431_.getBlockPos(); +- if (prime(p_329038_, p_333168_, p_335932_)) { ++ if (onCaughtFire(p_331413_, p_329038_, p_333168_, p_330020_.getDirection(), p_335932_)) { + p_329038_.setBlock(p_333168_, Blocks.AIR.defaultBlockState(), 11); + Item item = p_329029_.getItem(); + if (p_329029_.is(Items.FLINT_AND_STEEL)) { +@@ -128,7 +_,7 @@ Entity entity = p_57432_.getOwner(); - 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); + if (p_57432_.isOnFire() + && p_57432_.mayInteract(serverlevel, blockpos) +- && prime(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); } } -@@ -135,5 +_,9 @@ +@@ -142,5 +_,9 @@ @Override protected void createBlockStateDefinition(StateDefinition.Builder p_57464_) { p_57464_.add(UNSTABLE); + } + -+ public void onCaughtFire(BlockState state, Level world, BlockPos pos, @Nullable net.minecraft.core.Direction face, @Nullable LivingEntity igniter) { -+ explode(world, pos, igniter); ++ public boolean onCaughtFire(BlockState state, Level level, BlockPos pos, @Nullable net.minecraft.core.Direction face, @Nullable LivingEntity igniter) { ++ return prime(level, pos, igniter); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch index 4c07ac0e03..4b74bd3eb0 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TrapDoorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TrapDoorBlock.java +++ b/net/minecraft/world/level/block/TrapDoorBlock.java -@@ -215,4 +_,14 @@ +@@ -199,4 +_,14 @@ protected BlockSetType getType() { return this.type; } diff --git a/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch index 85e4570058..299b61bfb7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TripWireBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/TripWireBlock.java +++ b/net/minecraft/world/level/block/TripWireBlock.java -@@ -114,7 +_,7 @@ +@@ -115,7 +_,7 @@ @Override public BlockState playerWillDestroy(Level p_57615_, BlockPos p_57616_, BlockState p_57617_, Player p_57618_) { - if (!p_57615_.isClientSide && !p_57618_.getMainHandItem().isEmpty() && p_57618_.getMainHandItem().is(Items.SHEARS)) { + if (!p_57615_.isClientSide && !p_57618_.getMainHandItem().isEmpty() && p_57618_.getMainHandItem().canPerformAction(net.minecraftforge.common.ToolActions.SHEARS_DISARM)) { - p_57615_.setBlock(p_57616_, p_57617_.setValue(DISARMED, Boolean.valueOf(true)), 4); + p_57615_.setBlock(p_57616_, p_57617_.setValue(DISARMED, true), 260); p_57615_.gameEvent(p_57618_, GameEvent.SHEAR, p_57616_); } diff --git a/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch index dd2d3624e4..56c130b84a 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TurtleEggBlock.java +++ b/net/minecraft/world/level/block/TurtleEggBlock.java -@@ -179,7 +_,7 @@ +@@ -171,7 +_,7 @@ if (p_57769_ instanceof Turtle || p_57769_ instanceof Bat) { return false; } else { diff --git a/patches/minecraft/net/minecraft/world/level/block/VegetationBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/VegetationBlock.java.patch new file mode 100644 index 0000000000..2a6ca59561 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/VegetationBlock.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/world/level/block/VegetationBlock.java ++++ b/net/minecraft/world/level/block/VegetationBlock.java +@@ -12,7 +_,7 @@ + import net.minecraft.world.level.block.state.BlockState; + import net.minecraft.world.level.pathfinder.PathComputationType; + +-public abstract class VegetationBlock extends Block { ++public abstract class VegetationBlock extends Block implements net.minecraftforge.common.IPlantable { + protected VegetationBlock(BlockBehaviour.Properties p_395394_) { + super(p_395394_); + } +@@ -43,6 +_,9 @@ + @Override + protected boolean canSurvive(BlockState p_397664_, LevelReader p_395119_, BlockPos p_393561_) { + BlockPos blockpos = p_393561_.below(); ++ if (p_397664_.getBlock() == this) { //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check. ++ return p_395119_.getBlockState(blockpos).canSustainPlant(p_395119_, blockpos, Direction.UP, this); ++ } + return this.mayPlaceOn(p_395119_.getBlockState(blockpos), p_395119_, blockpos); + } + +@@ -54,5 +_,11 @@ + @Override + protected boolean isPathfindable(BlockState p_392416_, PathComputationType p_395772_) { + return p_395772_ == PathComputationType.AIR && !this.hasCollision ? true : super.isPathfindable(p_392416_, p_395772_); ++ } ++ ++ @Override ++ public BlockState getPlant(BlockGetter world, BlockPos pos) { ++ BlockState state = world.getBlockState(pos); ++ return state.getBlock() == this ? state : defaultBlockState(); + } + } diff --git a/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch index 4d4a900f3b..57058efe9e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/VineBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/VineBlock.java +++ b/net/minecraft/world/level/block/VineBlock.java -@@ -25,7 +_,7 @@ +@@ -23,7 +_,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; @@ -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; -@@ -190,7 +_,7 @@ +@@ -172,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/minecraft/net/minecraft/world/level/block/WebBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/WebBlock.java.patch index da68452d1f..dd6b57ba4c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/WebBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/WebBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/WebBlock.java +++ b/net/minecraft/world/level/block/WebBlock.java -@@ -10,7 +_,7 @@ +@@ -11,7 +_,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index 0133fe59e0..f9ba0c15b7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/patches/minecraft/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 -@@ -53,6 +_,7 @@ - public static final int NUM_DATA_VALUES = 4; - public static final int BURN_TIME_STANDARD = 200; - public static final int BURN_COOL_SPEED = 2; +@@ -58,6 +_,7 @@ + private static final short DEFAULT_COOKING_TOTAL_TIME = 0; + private static final short DEFAULT_LIT_TIME_REMAINING = 0; + private static final short DEFAULT_LIT_TOTAL_TIME = 0; + private final RecipeType recipeType; protected NonNullList items = NonNullList.withSize(3, ItemStack.EMPTY); int litTimeRemaining; int litTotalTime; -@@ -105,6 +_,7 @@ +@@ -110,6 +_,7 @@ ) { super(p_154991_, p_154992_, p_154993_); this.quickCheck = RecipeManager.createCheck((RecipeType)p_154994_); @@ -16,22 +16,22 @@ } private boolean isLit() { -@@ -116,10 +_,10 @@ +@@ -121,10 +_,10 @@ super.loadAdditional(p_335441_, p_330623_); this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); ContainerHelper.loadAllItems(p_335441_, this.items, p_330623_); -- this.cookingTimer = p_335441_.getShort("cooking_time_spent"); -- this.cookingTotalTime = p_335441_.getShort("cooking_total_time"); -- this.litTimeRemaining = p_335441_.getShort("lit_time_remaining"); -- this.litTotalTime = p_335441_.getShort("lit_total_time"); -+ this.cookingTimer = p_335441_.getInt("cooking_time_spent"); -+ this.cookingTotalTime = p_335441_.getInt("cooking_total_time"); -+ this.litTimeRemaining = p_335441_.getInt("lit_time_remaining"); -+ this.litTotalTime = p_335441_.getInt("lit_total_time"); - CompoundTag compoundtag = p_335441_.getCompound("RecipesUsed"); - - for (String s : compoundtag.getAllKeys()) { -@@ -130,10 +_,10 @@ +- this.cookingTimer = p_335441_.getShortOr("cooking_time_spent", (short)0); +- this.cookingTotalTime = p_335441_.getShortOr("cooking_total_time", (short)0); +- this.litTimeRemaining = p_335441_.getShortOr("lit_time_remaining", (short)0); +- this.litTotalTime = p_335441_.getShortOr("lit_total_time", (short)0); ++ this.cookingTimer = p_335441_.getIntOr("cooking_time_spent", (short)0); ++ this.cookingTotalTime = p_335441_.getIntOr("cooking_total_time", (short)0); ++ this.litTimeRemaining = p_335441_.getIntOr("lit_time_remaining", (short)0); ++ this.litTotalTime = p_335441_.getIntOr("lit_total_time", (short)0); + this.recipesUsed.clear(); + this.recipesUsed.putAll(p_335441_.read("RecipesUsed", RECIPES_USED_CODEC).orElse(Map.of())); + } +@@ -132,10 +_,10 @@ @Override protected void saveAdditional(CompoundTag p_187452_, HolderLookup.Provider p_330192_) { super.saveAdditional(p_187452_, p_330192_); @@ -44,8 +44,8 @@ + p_187452_.putInt("lit_time_remaining", this.litTimeRemaining); + p_187452_.putInt("lit_total_time", this.litTotalTime); ContainerHelper.saveAllItems(p_187452_, this.items, p_330192_); - CompoundTag compoundtag = new CompoundTag(); - this.recipesUsed.forEach((p_360478_, p_360479_) -> compoundtag.putInt(p_360478_.location().toString(), p_360479_)); + p_187452_.store("RecipesUsed", RECIPES_USED_CODEC, this.recipesUsed); + } @@ -161,27 +_,31 @@ } @@ -121,7 +121,7 @@ } if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !p_267073_.get(1).isEmpty() && p_267073_.get(1).is(Items.BUCKET)) { -@@ -388,5 +_,34 @@ +@@ -388,6 +_,35 @@ for (ItemStack itemstack : this.items) { p_363325_.accountStack(itemstack); } @@ -155,4 +155,5 @@ + super.reviveCaps(); + this.handlers = net.minecraftforge.items.wrapper.SidedInvWrapper.create(this, Direction.UP, Direction.DOWN, Direction.NORTH); } - } + + @Override diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch index 3f6e5d5b07..d93c91dd80 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -166,4 +_,27 @@ +@@ -167,4 +_,27 @@ p_329140_.remove("lock"); p_329140_.remove("Items"); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch index 30276d9e45..29e6fb56b7 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -137,8 +_,8 @@ +@@ -138,8 +_,8 @@ for (int i1 = 0; i1 < 10 && blockpos.getY() <= l; i1++) { BlockState blockstate = p_155108_.getBlockState(blockpos); @@ -9,5 +9,5 @@ + int j1 = blockstate.getBeaconColorMultiplier(p_155108_, blockpos, p_155109_); + if (j1 != -1) { if (p_155111_.checkingBeamSections.size() <= 1) { - beaconblockentity$beaconbeamsection = new BeaconBlockEntity.BeaconBeamSection(j1); - p_155111_.checkingBeamSections.add(beaconblockentity$beaconbeamsection); + beaconbeamowner$section = new BeaconBeamOwner.Section(j1); + p_155111_.checkingBeamSections.add(beaconbeamowner$section); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch index 0dd2f6abf2..977f4949a2 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -26,7 +_,7 @@ +@@ -32,7 +_,7 @@ import net.minecraft.world.level.block.state.BlockState; import org.slf4j.Logger; -public abstract class BlockEntity { +public abstract class BlockEntity extends net.minecraftforge.common.capabilities.CapabilityProvider implements net.minecraftforge.common.extensions.IForgeBlockEntity { + private static final Codec> TYPE_CODEC = BuiltInRegistries.BLOCK_ENTITY_TYPE.byNameCodec(); private static final Logger LOGGER = LogUtils.getLogger(); private final BlockEntityType type; - @Nullable -@@ -37,10 +_,12 @@ +@@ -44,10 +_,12 @@ private DataComponentMap components = DataComponentMap.EMPTY; public BlockEntity(BlockEntityType p_155228_, BlockPos p_155229_, BlockState p_155230_) { @@ -22,7 +22,7 @@ } private void validateBlockState(BlockState p_345558_) { -@@ -50,7 +_,7 @@ +@@ -57,7 +_,7 @@ } public boolean isValidBlockState(BlockState p_345570_) { @@ -30,16 +30,17 @@ + return this.getType().isValid(p_345570_); } - public static BlockPos getPosFromTag(CompoundTag p_187473_) { -@@ -71,6 +_,7 @@ + public static BlockPos getPosFromTag(ChunkPos p_396083_, CompoundTag p_187473_) { +@@ -89,6 +_,8 @@ } protected void loadAdditional(CompoundTag p_331149_, HolderLookup.Provider p_333170_) { -+ if (getCapabilities() != null && p_331149_.contains("ForgeCaps")) deserializeCaps(p_333170_, p_331149_.getCompound("ForgeCaps")); ++ var caps = p_331149_.getCompound("ForgeCaps"); ++ if (getCapabilities() != null && caps.isPresent()) deserializeCaps(p_333170_, caps.get()); } public final void loadWithComponents(CompoundTag p_331756_, HolderLookup.Provider p_335164_) { -@@ -86,6 +_,7 @@ +@@ -101,6 +_,7 @@ } protected void saveAdditional(CompoundTag p_187471_, HolderLookup.Provider p_327783_) { @@ -47,7 +48,7 @@ } public final CompoundTag saveWithFullMetadata(HolderLookup.Provider p_331193_) { -@@ -208,6 +_,13 @@ +@@ -210,6 +_,13 @@ public void setRemoved() { this.remove = true; diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch index a230147e15..edd5661d5c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch +++ b/patches/minecraft/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 -@@ -171,15 +_,18 @@ +@@ -173,15 +_,18 @@ for (int i = 0; i < 3; i++) { p_155293_.set(i, potionbrewing.mix(itemstack, p_155293_.get(i))); } @@ -14,14 +14,14 @@ if (itemstack.isEmpty()) { itemstack = itemstack1; } else { - Containers.dropItemStack(p_155291_, (double)p_155292_.getX(), (double)p_155292_.getY(), (double)p_155292_.getZ(), itemstack1); + Containers.dropItemStack(p_155291_, p_155292_.getX(), p_155292_.getY(), p_155292_.getZ(), itemstack1); } + } else { + itemstack.shrink(1); } p_155293_.set(3, itemstack); -@@ -212,6 +_,9 @@ +@@ -214,6 +_,9 @@ if (p_59017_ == 3) { PotionBrewing potionbrewing = this.level != null ? this.level.potionBrewing() : PotionBrewing.EMPTY; return potionbrewing.isIngredient(p_59018_); @@ -31,7 +31,7 @@ } else { return p_59017_ == 4 ? p_59018_.is(ItemTags.BREWING_FUEL) -@@ -247,5 +_,34 @@ +@@ -249,5 +_,34 @@ @Override protected AbstractContainerMenu createMenu(int p_58990_, Inventory p_58991_) { return new BrewingStandMenu(p_58990_, p_58991_, this, this.dataAccess); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch index 6c4a0f7814..29033e2695 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java -@@ -158,4 +_,28 @@ +@@ -160,4 +_,28 @@ public void removeComponentsFromTag(CompoundTag p_329882_) { p_329882_.remove("Items"); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch index 1ad9ef06b5..959f93cb30 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -@@ -152,8 +_,8 @@ +@@ -149,8 +_,8 @@ BlockPos blockpos1 = p_155416_.offset(j1, k1, l1); BlockState blockstate = p_155415_.getBlockState(blockpos1); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch index 5aa7c3a45a..dadccc848b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -137,6 +_,7 @@ +@@ -138,6 +_,7 @@ } private static boolean ejectItems(Level p_155563_, BlockPos p_155564_, HopperBlockEntity p_329427_) { @@ -8,7 +8,7 @@ Container container = getAttachedContainer(p_155563_, p_155564_, p_329427_); if (container == null) { return false; -@@ -212,6 +_,8 @@ +@@ -213,6 +_,8 @@ } public static boolean suckInItems(Level p_155553_, Hopper p_155554_) { @@ -17,7 +17,7 @@ BlockPos blockpos = BlockPos.containing(p_155554_.getLevelX(), p_155554_.getLevelY() + 1.0, p_155554_.getLevelZ()); BlockState blockstate = p_155553_.getBlockState(blockpos); Container container = getSourceContainer(p_155553_, p_155554_, blockpos, blockstate); -@@ -473,5 +_,14 @@ +@@ -451,5 +_,14 @@ @Override protected AbstractContainerMenu createMenu(int p_59312_, Inventory p_59313_) { return new HopperMenu(p_59312_, p_59313_, this); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch index 4b77e2ce52..c68fd0e61c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -230,7 +_,7 @@ +@@ -234,7 +_,7 @@ @Override public boolean canPlaceItemThroughFace(int p_59663_, ItemStack p_59664_, @Nullable Direction p_59665_) { @@ -9,7 +9,7 @@ } @Override -@@ -254,6 +_,11 @@ +@@ -258,6 +_,11 @@ public boolean isClosed() { return this.animationStatus == ShulkerBoxBlockEntity.AnimationStatus.CLOSED; diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch index 56359d16a1..c4dd1c3fdc 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -281,6 +_,11 @@ +@@ -265,6 +_,11 @@ } } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java.patch index 379ca35827..18ad8c252e 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SpawnerBlockEntity.java @@ -30,6 +_,13 @@ - p_155771_.sendBlockUpdated(p_155772_, blockstate, blockstate, 4); + p_155771_.sendBlockUpdated(p_155772_, blockstate, blockstate, 260); } } + diff --git a/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch index 3d0170a312..b0ae6d3617 100644 --- a/patches/minecraft/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch +++ b/patches/minecraft/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 -@@ -189,6 +_,7 @@ +@@ -166,6 +_,7 @@ } if (p_60195_ == 0) { @@ -8,7 +8,7 @@ if (!this.moveBlocks(p_60193_, p_60194_, direction, true)) { return false; } -@@ -197,6 +_,7 @@ +@@ -174,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(); -@@ -244,6 +_,7 @@ +@@ -221,6 +_,7 @@ p_60193_.gameEvent(GameEvent.BLOCK_DEACTIVATE, p_60194_, GameEvent.Context.of(blockstate1)); } @@ -24,7 +24,7 @@ return true; } -@@ -384,6 +_,11 @@ +@@ -365,6 +_,11 @@ @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/minecraft/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch index 70dbd39e7d..3b3c2619c4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch +++ b/patches/minecraft/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 -@@ -116,7 +_,7 @@ +@@ -120,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/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch index 4ab8341f20..284fd2f60f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -171,7 +_,7 @@ - } - - protected void onRemove(BlockState p_60515_, Level p_60516_, BlockPos p_60517_, BlockState p_60518_, boolean p_60519_) { -- if (p_60515_.hasBlockEntity() && !p_60515_.is(p_60518_.getBlock())) { -+ if (p_60515_.hasBlockEntity() && (!p_60515_.is(p_60518_.getBlock()) || !p_60518_.hasBlockEntity())) { - p_60516_.removeBlockEntity(p_60517_); - } - } -@@ -180,7 +_,7 @@ +@@ -178,7 +_,7 @@ if (!p_310712_.isAir() && p_312709_.getBlockInteraction() != Explosion.BlockInteraction.TRIGGER_BLOCK) { Block block = p_310712_.getBlock(); boolean flag = p_312709_.getIndirectSourceEntity() instanceof Player; @@ -18,7 +9,7 @@ BlockEntity blockentity = p_310712_.hasBlockEntity() ? p_367589_.getBlockEntity(p_311490_) : null; LootParams.Builder lootparams$builder = new LootParams.Builder(p_367589_) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(p_311490_)) -@@ -195,8 +_,7 @@ +@@ -193,8 +_,7 @@ p_310712_.getDrops(lootparams$builder).forEach(p_309419_ -> p_311277_.accept(p_309419_, p_311490_)); } @@ -28,12 +19,12 @@ } } -@@ -342,12 +_,15 @@ +@@ -344,12 +_,15 @@ 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; +- return p_60467_.getDestroySpeed(p_60466_) / f / i; + int i = net.minecraftforge.common.ForgeHooks.isCorrectToolForDrops(p_60466_, p_60467_) ? 30 : 100; + return p_60467_.getDestroySpeed(p_60466_, p_60469_) / f / (float)i; } @@ -46,15 +37,16 @@ } protected void attack(BlockState p_60499_, Level p_60500_, BlockPos p_60501_, Player p_60502_) { -@@ -387,6 +_,7 @@ +@@ -385,6 +_,8 @@ return this.isRandomlyTicking; } -+ /** @deprecated Use more sensitive version {@link IForgeBlockState#getSoundType(IWorldReader, BlockPos, Entity) } */ ++ /** @deprecated Forge: Use more sensitive version {@link net.minecraftforge.common.extensions.IForgeBlockState#getSoundType(LevelReader, BlockPos, Entity) } */ ++ @Deprecated protected SoundType getSoundType(BlockState p_328629_) { return this.soundType; } -@@ -407,6 +_,10 @@ +@@ -405,6 +_,10 @@ return this.properties.destroyTime; } @@ -65,7 +57,7 @@ public abstract static class BlockStateBase extends StateHolder { private static final Direction[] DIRECTIONS = Direction.values(); private static final VoxelShape[] EMPTY_OCCLUSION_SHAPES = Util.make(new VoxelShape[DIRECTIONS.length], p_368402_ -> Arrays.fill(p_368402_, Shapes.empty())); -@@ -559,12 +_,14 @@ +@@ -557,12 +_,14 @@ return this.useShapeForLightOcclusion; } @@ -81,7 +73,7 @@ } public boolean ignitedByLava() { -@@ -577,9 +_,11 @@ +@@ -575,9 +_,11 @@ } public MapColor getMapColor(BlockGetter p_285002_, BlockPos p_285293_) { @@ -94,7 +86,7 @@ public BlockState rotate(Rotation p_60718_) { return this.getBlock().rotate(this.asState(), p_60718_); } -@@ -633,6 +_,8 @@ +@@ -631,6 +_,8 @@ } public PushReaction getPistonPushReaction() { @@ -103,12 +95,12 @@ return this.pushReaction; } -@@ -998,7 +_,7 @@ +@@ -996,7 +_,7 @@ BlockBehaviour.StateArgumentPredicate> isValidSpawn = (p_360542_, p_360543_, p_360544_, p_360545_) -> p_360542_.isFaceSturdy( - p_360543_, p_360544_, Direction.UP - ) -- && p_360542_.getLightEmission() < 14; -+ && p_360542_.getLightEmission(p_360543_, p_360544_) < 14; + p_360543_, p_360544_, Direction.UP + ) +- && p_360542_.getLightEmission() < 14; ++ && p_360542_.getLightEmission(p_360543_, p_360544_) < 14; BlockBehaviour.StatePredicate isRedstoneConductor = (p_360546_, p_360547_, p_360548_) -> p_360546_.isCollisionShapeFullBlock(p_360547_, p_360548_); BlockBehaviour.StatePredicate isSuffocating = (p_360539_, p_360540_, p_360541_) -> p_360539_.blocksMotion() && p_360539_.isCollisionShapeFullBlock(p_360540_, p_360541_); BlockBehaviour.StatePredicate isViewBlocking = this.isSuffocating; diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch index d953474d90..ed3911c5bb 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -327,23 +_,28 @@ +@@ -332,23 +_,28 @@ @Override public final void findBlockLightSources(BiConsumer p_285269_) { @@ -33,10 +33,10 @@ } } } -@@ -487,5 +_,10 @@ +@@ -492,5 +_,10 @@ } - public static record PackedTicks(List> blocks, List> fluids) { + public record PackedTicks(List> blocks, List> fluids) { + } + + @Nullable diff --git a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch index 545d205acb..43ec724c6e 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/patches/minecraft/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 -@@ -52,7 +_,7 @@ +@@ -53,7 +_,7 @@ import net.minecraft.world.ticks.TickContainerAccess; import org.slf4j.Logger; @@ -17,24 +17,25 @@ } public LevelChunk(ServerLevel p_196850_, ProtoChunk p_196851_, @Nullable LevelChunk.PostLoadProcessor p_196852_) { -@@ -294,14 +_,14 @@ - boolean flag2 = blockstate.hasBlockEntity(); - if (!this.level.isClientSide) { - blockstate.onRemove(this.level, p_62865_, p_62866_, p_62867_); -- } else if (!blockstate.is(block) && flag2) { -+ } else if ((!blockstate.is(block) || !p_62866_.hasBlockEntity()) && flag2) { - this.removeBlockEntity(p_62865_); +@@ -291,7 +_,7 @@ + profilerfiller.pop(); } +- boolean flag4 = !blockstate.is(block); ++ boolean flag4 = !blockstate.is(block) || !p_62866_.hasBlockEntity(); + boolean flag2 = (p_393998_ & 64) != 0; + boolean flag3 = (p_393998_ & 256) == 0; + if (flag4 && blockstate.hasBlockEntity()) { +@@ -312,7 +_,7 @@ if (!levelchunksection.getBlockState(j, k, l).is(block)) { return null; } else { -- if (!this.level.isClientSide) { -+ if (!this.level.isClientSide && !this.level.captureBlockSnapshots) { - p_62866_.onPlace(this.level, p_62865_, blockstate, p_62867_); +- if (!this.level.isClientSide && (p_393998_ & 512) == 0) { ++ if (!this.level.isClientSide && (p_393998_ & 512) == 0 && !this.level.captureBlockSnapshots) { + p_62866_.onPlace(this.level, p_62865_, blockstate, flag2); } -@@ -356,6 +_,12 @@ +@@ -367,6 +_,12 @@ @Nullable public BlockEntity getBlockEntity(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { BlockEntity blockentity = this.blockEntities.get(p_62868_); @@ -47,7 +48,7 @@ if (blockentity == null) { CompoundTag compoundtag = this.pendingBlockEntities.remove(p_62868_); if (compoundtag != null) { -@@ -373,9 +_,6 @@ +@@ -384,9 +_,6 @@ this.addAndRegisterBlockEntity(blockentity); } } @@ -57,7 +58,7 @@ } return blockentity; -@@ -389,6 +_,7 @@ +@@ -400,6 +_,7 @@ } this.updateBlockEntityTicker(p_156391_); @@ -65,7 +66,7 @@ } } -@@ -441,9 +_,14 @@ +@@ -452,9 +_,14 @@ public CompoundTag getBlockEntityNbtForSaving(BlockPos p_62932_, HolderLookup.Provider p_329605_) { BlockEntity blockentity = this.getBlockEntity(p_62932_); if (blockentity != null && !blockentity.isRemoved()) { @@ -80,7 +81,7 @@ } else { CompoundTag compoundtag = this.pendingBlockEntities.get(p_62932_); if (compoundtag != null) { -@@ -523,7 +_,7 @@ +@@ -530,7 +_,7 @@ p_187974_.accept((p_327409_, p_327410_, p_327411_) -> { BlockEntity blockentity = this.getBlockEntity(p_327409_, LevelChunk.EntityCreationType.IMMEDIATE); if (blockentity != null && p_327411_ != null && blockentity.getType() == p_327410_) { @@ -89,7 +90,7 @@ } }); } -@@ -633,6 +_,7 @@ +@@ -640,6 +_,7 @@ } public void clearAllBlockEntities() { @@ -97,7 +98,7 @@ this.blockEntities.values().forEach(BlockEntity::setRemoved); this.blockEntities.clear(); this.tickersInLevel.values().forEach(p_187966_ -> p_187966_.rebind(NULL_TICKER)); -@@ -640,6 +_,7 @@ +@@ -647,6 +_,7 @@ } public void registerAllBlockEntitiesAfterLevelLoad() { @@ -105,7 +106,7 @@ this.blockEntities.values().forEach(p_187988_ -> { if (this.level instanceof ServerLevel serverlevel) { this.addGameEventListener(p_187988_, serverlevel); -@@ -691,6 +_,24 @@ +@@ -698,6 +_,24 @@ return new LevelChunk.BoundTickingBlockEntity<>(p_156376_, p_156377_); } @@ -130,7 +131,7 @@ class BoundTickingBlockEntity implements TickingBlockEntity { private final T blockEntity; private final BlockEntityTicker ticker; -@@ -708,6 +_,7 @@ +@@ -715,6 +_,7 @@ if (LevelChunk.this.isTicking(blockpos)) { try { ProfilerFiller profilerfiller = Profiler.get(); @@ -138,7 +139,7 @@ profilerfiller.push(this::getType); BlockState blockstate = LevelChunk.this.getBlockState(blockpos); if (this.blockEntity.getType().isValid(blockstate)) { -@@ -729,6 +_,11 @@ +@@ -736,6 +_,11 @@ CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking block entity"); CrashReportCategory crashreportcategory = crashreport.addCategory("Block entity being ticked"); this.blockEntity.fillCrashReportCategory(crashreportcategory); @@ -150,7 +151,7 @@ throw new ReportedException(crashreport); } } -@@ -802,6 +_,33 @@ +@@ -809,6 +_,33 @@ public String toString() { return this.ticker + " "; } diff --git a/patches/minecraft/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch index 037905f5d5..915c230d20 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch +++ b/patches/minecraft/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 -@@ -95,8 +_,12 @@ +@@ -85,8 +_,12 @@ ListTag listtag = new ListTag(); p_156559_.getEntities().forEach(p_156567_ -> { CompoundTag compoundtag1 = new CompoundTag(); diff --git a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch index 3f4431941b..faeeb1392d 100644 --- a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch +++ b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -545,6 +_,14 @@ +@@ -541,6 +_,14 @@ } } diff --git a/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch b/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch index 15ca57d14f..1fa9fe6938 100644 --- a/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch +++ b/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch @@ -30,7 +30,7 @@ return true; } } -@@ -367,11 +_,13 @@ +@@ -369,11 +_,13 @@ class Callback implements EntityInLevelCallback { private final T entity; @@ -44,7 +44,7 @@ this.currentSectionKey = p_157615_; this.currentSection = p_157616_; } -@@ -390,9 +_,13 @@ +@@ -392,9 +_,13 @@ PersistentEntitySectionManager.this.removeSectionIfEmpty(this.currentSectionKey, this.currentSection); EntitySection entitysection = PersistentEntitySectionManager.this.sectionStorage.getOrCreateSection(i); entitysection.add(this.entity); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/Beardifier.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/Beardifier.java.patch index bd4a3f606c..c4a5f6f425 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/Beardifier.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/Beardifier.java.patch @@ -9,6 +9,6 @@ + objectlist.add(new Beardifier.Rigid(pieceBeardifierModifier.getBeardifierBox(), pieceBeardifierModifier.getTerrainAdjustment(), pieceBeardifierModifier.getGroundLevelDelta())); + } + } else - if (structurepiece instanceof PoolElementStructurePiece) { - PoolElementStructurePiece poolelementstructurepiece = (PoolElementStructurePiece)structurepiece; + if (structurepiece instanceof PoolElementStructurePiece poolelementstructurepiece) { StructureTemplatePool.Projection structuretemplatepool$projection = poolelementstructurepiece.getElement().getProjection(); + if (structuretemplatepool$projection == StructureTemplatePool.Projection.RIGID) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch index caf2754f6f..7f227935d9 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch @@ -1,32 +1,32 @@ --- a/net/minecraft/world/level/levelgen/PhantomSpawner.java +++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java -@@ -42,13 +_,18 @@ - for (ServerPlayer serverplayer : p_64576_.players()) { - if (!serverplayer.isSpectator()) { - BlockPos blockpos = serverplayer.blockPosition(); -- if (!p_64576_.dimensionType().hasSkyLight() || blockpos.getY() >= p_64576_.getSeaLevel() && p_64576_.canSeeSky(blockpos)) { - DifficultyInstance difficultyinstance = p_64576_.getCurrentDifficultyAt(blockpos); -+ var vanillaPosition = (!p_64576_.dimensionType().hasSkyLight() || blockpos.getY() >= p_64576_.getSeaLevel() && p_64576_.canSeeSky(blockpos)); -+ var count = 1 + randomsource.nextInt(difficultyinstance.getDifficulty().getId() + 1); -+ var event = net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnPhantom(serverplayer, count); -+ var eventResult = event.getResult(); -+ if (eventResult.isDenied()) continue; -+ if (vanillaPosition || eventResult.isAllowed()) { - if (difficultyinstance.isHarderThan(randomsource.nextFloat() * 3.0F)) { - ServerStatsCounter serverstatscounter = serverplayer.getStats(); - int j = Mth.clamp(serverstatscounter.getValue(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE); - int k = 24000; -- if (randomsource.nextInt(j) >= 72000) { -+ if (eventResult.isAllowed() || randomsource.nextInt(j) >= 72000) { - BlockPos blockpos1 = blockpos.above(20 + randomsource.nextInt(15)) - .east(-10 + randomsource.nextInt(21)) - .south(-10 + randomsource.nextInt(21)); -@@ -56,7 +_,7 @@ - FluidState fluidstate = p_64576_.getFluidState(blockpos1); - if (NaturalSpawner.isValidEmptySpawnBlock(p_64576_, blockpos1, blockstate, fluidstate, EntityType.PHANTOM)) { - SpawnGroupData spawngroupdata = null; -- int l = 1 + randomsource.nextInt(difficultyinstance.getDifficulty().getId() + 1); -+ int l = event.getPhantomsToSpawn(); +@@ -33,13 +_,18 @@ + for (ServerPlayer serverplayer : p_64576_.players()) { + if (!serverplayer.isSpectator()) { + BlockPos blockpos = serverplayer.blockPosition(); +- if (!p_64576_.dimensionType().hasSkyLight() || blockpos.getY() >= p_64576_.getSeaLevel() && p_64576_.canSeeSky(blockpos)) { + DifficultyInstance difficultyinstance = p_64576_.getCurrentDifficultyAt(blockpos); ++ var vanillaPosition = (!p_64576_.dimensionType().hasSkyLight() || blockpos.getY() >= p_64576_.getSeaLevel() && p_64576_.canSeeSky(blockpos)); ++ var count = 1 + randomsource.nextInt(difficultyinstance.getDifficulty().getId() + 1); ++ var event = net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnPhantom(serverplayer, count); ++ var eventResult = event.getResult(); ++ if (eventResult.isDenied()) continue; ++ if (vanillaPosition || eventResult.isAllowed()) { + if (difficultyinstance.isHarderThan(randomsource.nextFloat() * 3.0F)) { + ServerStatsCounter serverstatscounter = serverplayer.getStats(); + int i = Mth.clamp(serverstatscounter.getValue(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE); + int j = 24000; +- if (randomsource.nextInt(i) >= 72000) { ++ if (eventResult.isAllowed() || randomsource.nextInt(i) >= 72000) { + BlockPos blockpos1 = blockpos.above(20 + randomsource.nextInt(15)) + .east(-10 + randomsource.nextInt(21)) + .south(-10 + randomsource.nextInt(21)); +@@ -47,7 +_,7 @@ + FluidState fluidstate = p_64576_.getFluidState(blockpos1); + if (NaturalSpawner.isValidEmptySpawnBlock(p_64576_, blockpos1, blockstate, fluidstate, EntityType.PHANTOM)) { + SpawnGroupData spawngroupdata = null; +- int k = 1 + randomsource.nextInt(difficultyinstance.getDifficulty().getId() + 1); ++ int k = event.getPhantomsToSpawn(); - for (int i1 = 0; i1 < l; i1++) { - Phantom phantom = EntityType.PHANTOM.create(p_64576_, EntitySpawnReason.NATURAL); + for (int l = 0; l < k; l++) { + Phantom phantom = EntityType.PHANTOM.create(p_64576_, EntitySpawnReason.NATURAL); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/WorldDimensions.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/WorldDimensions.java.patch index 76f5e91a99..a2e8a52a41 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/WorldDimensions.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/WorldDimensions.java.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/world/level/levelgen/WorldDimensions.java +++ b/net/minecraft/world/level/levelgen/WorldDimensions.java -@@ -37,7 +_,8 @@ +@@ -37,7 +_,7 @@ public record WorldDimensions(Map, LevelStem> dimensions) { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( p_327457_ -> p_327457_.group( -- Codec.unboundedMap(ResourceKey.codec(Registries.LEVEL_STEM), LevelStem.CODEC) -+ // FORGE: Fix MC-197860 -+ new net.minecraftforge.common.LenientUnboundedMapCodec<>(ResourceKey.codec(Registries.LEVEL_STEM), LevelStem.CODEC) - .fieldOf("dimensions") - .forGetter(WorldDimensions::dimensions) - ) +- Codec.unboundedMap(ResourceKey.codec(Registries.LEVEL_STEM), LevelStem.CODEC).fieldOf("dimensions").forGetter(WorldDimensions::dimensions) ++ new net.minecraftforge.common.LenientUnboundedMapCodec<>(ResourceKey.codec(Registries.LEVEL_STEM), LevelStem.CODEC).fieldOf("dimensions").forGetter(WorldDimensions::dimensions) // FORGE: Fix MC-197860 + ) + .apply(p_327457_, p_327457_.stable(WorldDimensions::new)) + ); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch index 01df076a82..98244132c1 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/feature/Feature.java +++ b/net/minecraft/world/level/levelgen/feature/Feature.java -@@ -187,7 +_,9 @@ +@@ -189,7 +_,9 @@ } protected static boolean isStone(BlockState p_159748_) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/treedecorators/AlterGroundDecorator.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/treedecorators/AlterGroundDecorator.java.patch index d87cdec678..aacdc8fa61 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/treedecorators/AlterGroundDecorator.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/treedecorators/AlterGroundDecorator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/feature/treedecorators/AlterGroundDecorator.java +++ b/net/minecraft/world/level/levelgen/feature/treedecorators/AlterGroundDecorator.java -@@ -70,7 +_,9 @@ +@@ -59,7 +_,9 @@ for (int i = 2; i >= -3; i--) { BlockPos blockpos = p_225975_.above(i); if (Feature.isGrassOrDirt(p_225974_.level(), blockpos)) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/Structure.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/Structure.java.patch index dcdb501284..a4c8518628 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/Structure.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/Structure.java.patch @@ -65,5 +65,5 @@ + return this.modifiableStructureInfo().get().structureSettings(); + } - public static record GenerationContext( + public record GenerationContext( RegistryAccess registryAccess, diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch index 63803d46c0..7fe0db2309 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch +++ b/patches/minecraft/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 -@@ -92,6 +_,9 @@ +@@ -81,6 +_,9 @@ } public final CompoundTag createTag(StructurePieceSerializationContext p_192645_) { @@ -9,4 +9,4 @@ + } CompoundTag compoundtag = new CompoundTag(); compoundtag.putString("id", BuiltInRegistries.STRUCTURE_PIECE.getKey(this.getType()).toString()); - BoundingBox.CODEC + compoundtag.store("BB", BoundingBox.CODEC, this.boundingBox); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index 9ce0793b11..427a66b91d 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/patches/minecraft/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 -@@ -255,6 +_,10 @@ +@@ -253,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_ ) { -@@ -277,7 +_,7 @@ +@@ -275,7 +_,7 @@ int i1 = Integer.MIN_VALUE; int j1 = Integer.MIN_VALUE; @@ -20,7 +20,7 @@ BlockPos blockpos = structuretemplate$structureblockinfo.pos; if (boundingbox == null || boundingbox.isInside(blockpos)) { FluidState fluidstate = p_230332_.shouldApplyWaterlogging() ? p_230329_.getFluidState(blockpos) : null; -@@ -389,7 +_,7 @@ +@@ -385,7 +_,7 @@ } if (!p_230332_.isIgnoreEntities()) { @@ -29,7 +29,7 @@ } return true; -@@ -429,12 +_,21 @@ +@@ -425,12 +_,21 @@ ); } @@ -52,7 +52,7 @@ ) { List list = new ArrayList<>(); List list1 = new ArrayList<>(); -@@ -450,7 +_,7 @@ +@@ -446,7 +_,7 @@ while (structuretemplate$structureblockinfo1 != null && iterator.hasNext()) { structuretemplate$structureblockinfo1 = iterator.next() @@ -61,7 +61,7 @@ } if (structuretemplate$structureblockinfo1 != null) { -@@ -466,21 +_,27 @@ +@@ -462,21 +_,25 @@ return list1; } @@ -88,14 +88,12 @@ if (p_74529_ == null || p_74529_.isInside(blockpos)) { CompoundTag compoundtag = structuretemplate$structureentityinfo.nbt.copy(); - Vec3 vec3 = transform(structuretemplate$structureentityinfo.pos, p_74526_, p_74527_, p_74528_); -- Vec3 vec31 = vec3.add((double)p_74525_.getX(), (double)p_74525_.getY(), (double)p_74525_.getZ()); -+ //Vec3 vec3 = transform(structuretemplate$structureentityinfo.pos, p_74526_, p_74527_, p_74528_); -+ //Vec3 vec31 = vec3.add((double)p_74525_.getX(), (double)p_74525_.getY(), (double)p_74525_.getZ()); +- Vec3 vec31 = vec3.add(p_74525_.getX(), p_74525_.getY(), p_74525_.getZ()); + Vec3 vec31 = structuretemplate$structureentityinfo.pos; // FORGE: Position will have already been transformed by processEntityInfos ListTag listtag = new ListTag(); listtag.add(DoubleTag.valueOf(vec31.x)); listtag.add(DoubleTag.valueOf(vec31.y)); -@@ -500,6 +_,24 @@ +@@ -496,6 +_,24 @@ } } } diff --git a/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch index f7e65a762b..bc9d730f82 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -19,7 +19,7 @@ FluidState fluidstate1 = blockstate1.getFluidState(); if (blockstate1.isSolid() || this.isSourceBlockOfThisType(fluidstate1)) { @@ -252,6 +_,15 @@ - return this.getSource().defaultFluidState().setValue(FALLING, Boolean.valueOf(p_76069_)); + return this.getSource().defaultFluidState().setValue(FALLING, p_76069_); } + @Override diff --git a/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch index a6dcfeeecb..6568cf75f5 100644 --- a/patches/minecraft/net/minecraft/world/level/material/Fluid.java.patch +++ b/patches/minecraft/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 -@@ -21,7 +_,7 @@ +@@ -24,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,16 @@ public static final IdMapper FLUID_STATE_REGISTRY = new IdMapper<>(); protected final StateDefinition stateDefinition; private FluidState defaultFluidState; -@@ -109,5 +_,12 @@ +@@ -64,6 +_,8 @@ + } + + protected void entityInside(Level p_394813_, BlockPos p_394655_, Entity p_396881_, InsideBlockEffectApplier p_395108_) { ++ if (p_396881_.canFluidExtinguish(getFluidType())) ++ p_395108_.apply(net.minecraft.world.entity.InsideBlockEffectType.EXTINGUISH); + } + + @Nullable +@@ -132,5 +_,12 @@ @Deprecated public Holder.Reference builtInRegistryHolder() { return this.builtInRegistryHolder; diff --git a/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch b/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch index e5734d7dbb..20a715283c 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch +++ b/patches/minecraft/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 -@@ -22,7 +_,7 @@ +@@ -25,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; -@@ -114,6 +_,7 @@ +@@ -117,6 +_,7 @@ return this.getType() == p_192918_; } diff --git a/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch b/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch index 6c223f1836..6fef676e2a 100644 --- a/patches/minecraft/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/patches/minecraft/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 -@@ -88,7 +_,7 @@ - BlockState blockstate = p_367000_.getBlockState(blockpos); - if (blockstate.isAir()) { - if (this.hasFlammableNeighbours(p_367000_, blockpos)) { -- p_367000_.setBlockAndUpdate(blockpos, BaseFireBlock.getState(p_367000_, blockpos)); -+ p_367000_.setBlockAndUpdate(blockpos, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_367000_, blockpos, p_230573_, Blocks.FIRE.defaultBlockState())); +@@ -92,7 +_,7 @@ + BlockState blockstate = p_367000_.getBlockState(blockpos); + if (blockstate.isAir()) { + if (this.hasFlammableNeighbours(p_367000_, blockpos)) { +- p_367000_.setBlockAndUpdate(blockpos, BaseFireBlock.getState(p_367000_, blockpos)); ++ p_367000_.setBlockAndUpdate(blockpos, net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_367000_, blockpos, p_230573_, Blocks.FIRE.defaultBlockState())); + return; + } + } else if (blockstate.blocksMotion()) { +@@ -106,8 +_,8 @@ return; } - } else if (blockstate.blocksMotion()) { -@@ -102,8 +_,8 @@ - return; - } -- if (p_367000_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_367000_, blockpos1)) { -- p_367000_.setBlockAndUpdate(blockpos1.above(), BaseFireBlock.getState(p_367000_, blockpos1)); -+ if (p_367000_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_367000_, blockpos1, Direction.UP)) { -+ p_367000_.setBlockAndUpdate(blockpos1.above(), net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_367000_, blockpos1.above(), p_230573_, Blocks.FIRE.defaultBlockState())); +- if (p_367000_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_367000_, blockpos1)) { +- p_367000_.setBlockAndUpdate(blockpos1.above(), BaseFireBlock.getState(p_367000_, blockpos1)); ++ if (p_367000_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_367000_, blockpos1, Direction.UP)) { ++ p_367000_.setBlockAndUpdate(blockpos1.above(), net.minecraftforge.event.ForgeEventFactory.fireFluidPlaceBlockEvent(p_367000_, blockpos1.above(), p_230573_, Blocks.FIRE.defaultBlockState())); + } } } - } -@@ -112,7 +_,7 @@ +@@ -123,7 +_,7 @@ private boolean hasFlammableNeighbours(LevelReader p_76228_, BlockPos p_76229_) { for (Direction direction : Direction.values()) { @@ -29,7 +29,7 @@ return true; } } -@@ -120,10 +_,17 @@ +@@ -131,10 +_,17 @@ return false; } @@ -47,7 +47,7 @@ @Nullable @Override public ParticleOptions getDripParticle() { -@@ -195,7 +_,8 @@ +@@ -206,7 +_,8 @@ 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/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch index 97c2a809ff..f177aedaec 100644 --- a/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch +++ b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java -@@ -477,6 +_,16 @@ +@@ -474,6 +_,16 @@ for (int k = -1; k <= 1; k++) { if (i != 0 || k != 0) { PathType pathtype = p_334221_.getPathTypeFromState(p_336062_ + i, p_335259_ + j, p_336315_ + k); @@ -17,7 +17,7 @@ if (pathtype == PathType.DAMAGE_OTHER) { return PathType.DANGER_OTHER; } -@@ -503,6 +_,10 @@ +@@ -500,6 +_,10 @@ protected static PathType getPathTypeFromState(BlockGetter p_335222_, BlockPos p_331935_) { BlockState blockstate = p_335222_.getBlockState(p_331935_); Block block = blockstate.getBlock(); @@ -28,7 +28,7 @@ if (blockstate.isAir()) { return PathType.OPEN; } else if (blockstate.is(BlockTags.TRAPDOORS) || blockstate.is(Blocks.LILY_PAD) || blockstate.is(Blocks.BIG_DRIPLEAF)) { -@@ -517,6 +_,8 @@ +@@ -514,6 +_,8 @@ return PathType.COCOA; } else if (!blockstate.is(Blocks.WITHER_ROSE) && !blockstate.is(Blocks.POINTED_DRIPSTONE)) { FluidState fluidstate = blockstate.getFluidState(); @@ -37,7 +37,7 @@ if (fluidstate.is(FluidTags.LAVA)) { return PathType.LAVA; } else if (isBurningBlock(blockstate)) { -@@ -537,6 +_,8 @@ +@@ -534,6 +_,8 @@ if (!blockstate.isPathfindable(PathComputationType.LAND)) { return PathType.BLOCKED; } else { diff --git a/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch b/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch index c37fcb87d9..9ccc4bca23 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -108,6 +_,10 @@ +@@ -119,6 +_,10 @@ } int i = NbtUtils.getDataVersion(compoundtag, 1343); diff --git a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch index deb4ab7f62..4d2debffd9 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -481,6 +_,11 @@ +@@ -480,6 +_,11 @@ return this.getDataTag(true); } @@ -12,7 +12,7 @@ private Dynamic getDataTag(boolean p_310699_) throws IOException { this.checkLock(); return LevelStorageSource.readLevelDataTagFixed(p_310699_ ? this.levelDirectory.oldDataFile() : this.levelDirectory.dataFile(), LevelStorageSource.this.fixerUpper); -@@ -494,6 +_,7 @@ +@@ -493,6 +_,7 @@ CompoundTag compoundtag = p_78292_.createTag(p_78291_, p_78293_); CompoundTag compoundtag1 = new CompoundTag(); compoundtag1.put("Data", compoundtag); @@ -20,7 +20,7 @@ this.saveLevelData(compoundtag1); } -@@ -513,6 +_,10 @@ +@@ -512,6 +_,10 @@ public Optional getIconFile() { return !this.lock.isValid() ? Optional.empty() : Optional.of(this.levelDirectory.iconFile()); diff --git a/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch b/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch index ec56da0f0f..1d7bdb317b 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -20,8 +20,8 @@ LOGGER.warn("Failed to load player data for {}", p_329651_.getName().getString()); } @@ -82,5 +_,9 @@ - p_78436_.load(p_328937_); - return p_328937_; + p_78436_.load(p_391129_); + return p_391129_; }); + } + diff --git a/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch b/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch index a45927de2f..572f491100 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/PrimaryLevelData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/PrimaryLevelData.java +++ b/net/minecraft/world/level/storage/PrimaryLevelData.java -@@ -74,6 +_,7 @@ +@@ -73,6 +_,7 @@ private boolean wasModded; private final Set removedFeatureFlags; private final TimerQueue scheduledEvents; @@ -8,7 +8,7 @@ private PrimaryLevelData( @Nullable CompoundTag p_277888_, -@@ -200,7 +_,7 @@ +@@ -199,7 +_,7 @@ p_251864_, p_250651_, p_78538_ @@ -17,16 +17,16 @@ } @Override -@@ -273,6 +_,8 @@ - if (this.wanderingTraderId != null) { - p_78547_.putUUID("WanderingTraderId", this.wanderingTraderId); - } +@@ -267,6 +_,8 @@ + p_78547_.putInt("WanderingTraderSpawnDelay", this.wanderingTraderSpawnDelay); + p_78547_.putInt("WanderingTraderSpawnChance", this.wanderingTraderSpawnChance); + p_78547_.storeNullable("WanderingTraderId", UUIDUtil.CODEC, this.wanderingTraderId); + p_78547_.putString("forgeLifecycle", net.minecraftforge.common.ForgeHooks.encodeLifecycle(this.settings.getLifecycle())); + p_78547_.putBoolean("confirmedExperimentalSettings", this.confirmedExperimentalWarning); } private static ListTag stringCollectionToTag(Set p_277880_) { -@@ -571,6 +_,16 @@ +@@ -565,6 +_,16 @@ public LevelSettings getLevelSettings() { return this.settings.copy(); } diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch index 9d2d4c47d2..05a7554a0c 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/storage/loot/LootPool.java +++ b/net/minecraft/world/level/storage/loot/LootPool.java @@ -33,10 +_,13 @@ - LootItemCondition.DIRECT_CODEC.listOf().optionalFieldOf("conditions", List.of()).forGetter(p_297008_ -> p_297008_.conditions), - LootItemFunctions.ROOT_CODEC.listOf().optionalFieldOf("functions", List.of()).forGetter(p_297009_ -> p_297009_.functions), - NumberProviders.CODEC.fieldOf("rolls").forGetter(p_297004_ -> p_297004_.rolls), -- NumberProviders.CODEC.fieldOf("bonus_rolls").orElse(ConstantValue.exactly(0.0F)).forGetter(p_297006_ -> p_297006_.bonusRolls) -+ NumberProviders.CODEC.fieldOf("bonus_rolls").orElse(ConstantValue.exactly(0.0F)).forGetter(p_297006_ -> p_297006_.bonusRolls), -+ Codec.STRING.optionalFieldOf("name").forGetter(p -> p.name.filter(n -> !n.startsWith("custom#"))), -+ net.minecraftforge.common.crafting.conditions.ICondition.OPTIONAL_FEILD_CODEC.forGetter(p -> p.forge_condition) - ) - .apply(p_341975_, LootPool::new) + LootItemCondition.DIRECT_CODEC.listOf().optionalFieldOf("conditions", List.of()).forGetter(p_297008_ -> p_297008_.conditions), + LootItemFunctions.ROOT_CODEC.listOf().optionalFieldOf("functions", List.of()).forGetter(p_297009_ -> p_297009_.functions), + NumberProviders.CODEC.fieldOf("rolls").forGetter(p_297004_ -> p_297004_.rolls), +- NumberProviders.CODEC.fieldOf("bonus_rolls").orElse(ConstantValue.exactly(0.0F)).forGetter(p_297006_ -> p_297006_.bonusRolls) ++ NumberProviders.CODEC.fieldOf("bonus_rolls").orElse(ConstantValue.exactly(0.0F)).forGetter(p_297006_ -> p_297006_.bonusRolls), ++ Codec.STRING.optionalFieldOf("name").forGetter(p -> p.name.filter(n -> !n.startsWith("custom#"))), ++ net.minecraftforge.common.crafting.conditions.ICondition.OPTIONAL_FEILD_CODEC.forGetter(p -> p.forge_condition) + ) + .apply(p_341975_, LootPool::new) ); + public static final Codec CONDITIONAL_CODEC = net.minecraftforge.common.crafting.conditions.ConditionCodec.checkingDecode(CODEC, () -> lootPool().build()); private final List entries; diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch index 50da067952..5ecda0590e 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootTable.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/storage/loot/LootTable.java +++ b/net/minecraft/world/level/storage/loot/LootTable.java -@@ -38,7 +_,7 @@ - p_327557_ -> p_327557_.group( +@@ -40,7 +_,7 @@ + p_327557_ -> p_327557_.group( LootContextParamSets.CODEC.lenientOptionalFieldOf("type", DEFAULT_PARAM_SET).forGetter(p_297013_ -> p_297013_.paramSet), ResourceLocation.CODEC.optionalFieldOf("random_sequence").forGetter(p_297014_ -> p_297014_.randomSequence), - LootPool.CODEC.listOf().optionalFieldOf("pools", List.of()).forGetter(p_297012_ -> p_297012_.pools), @@ -9,7 +9,7 @@ LootItemFunctions.ROOT_CODEC.listOf().optionalFieldOf("functions", List.of()).forGetter(p_297010_ -> p_297010_.functions) ) .apply(p_327557_, LootTable::new) -@@ -53,7 +_,7 @@ +@@ -57,7 +_,7 @@ LootTable(ContextKeySet p_365565_, Optional p_298628_, List p_298771_, List p_301234_) { this.paramSet = p_365565_; this.randomSequence = p_298628_; @@ -18,7 +18,7 @@ this.functions = p_301234_; this.compositeFunction = LootItemFunctions.compose(p_301234_); } -@@ -76,10 +_,12 @@ +@@ -80,10 +_,12 @@ }; } @@ -31,7 +31,7 @@ public void getRandomItemsRaw(LootContext p_79132_, Consumer p_79133_) { LootContext.VisitedEntry visitedentry = LootContext.createVisitedEntry(this); if (p_79132_.pushVisitedElement(visitedentry)) { -@@ -96,15 +_,15 @@ +@@ -100,15 +_,15 @@ } public void getRandomItems(LootParams p_287748_, long p_287729_, Consumer p_287583_) { @@ -50,7 +50,7 @@ } public ObjectArrayList getRandomItems(LootParams p_345012_, RandomSource p_344559_) { -@@ -121,7 +_,8 @@ +@@ -125,7 +_,8 @@ private ObjectArrayList getRandomItems(LootContext p_230923_) { ObjectArrayList objectarraylist = new ObjectArrayList<>(); @@ -60,7 +60,7 @@ return objectarraylist; } -@@ -210,6 +_,68 @@ +@@ -214,6 +_,68 @@ public static LootTable.Builder lootTable() { return new LootTable.Builder(); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch index 25b4d13d5a..3c14722dfa 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java +++ b/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java -@@ -21,7 +_,7 @@ - public static final ContextKeySet EMPTY = register("empty", p_367081_ -> { - }); +@@ -20,7 +_,7 @@ + ); + public static final ContextKeySet EMPTY = register("empty", p_367081_ -> {}); public static final ContextKeySet CHEST = register( - "chest", p_360697_ -> p_360697_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) + "chest", p_360697_ -> p_360697_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY).optional(LootContextParams.ATTACKING_ENTITY) //Forge: Chest Minecarts can have killers. ); public static final ContextKeySet COMMAND = register( "command", p_360688_ -> p_360688_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) -@@ -30,7 +_,7 @@ +@@ -29,7 +_,7 @@ "selector", p_360687_ -> p_360687_.required(LootContextParams.ORIGIN).required(LootContextParams.THIS_ENTITY) ); public static final ContextKeySet FISHING = register( diff --git a/src/main/generated/data/minecraft/loot_table/blocks/bush.json b/src/main/generated/data/minecraft/loot_table/blocks/bush.json new file mode 100644 index 0000000000..f339200a8c --- /dev/null +++ b/src/main/generated/data/minecraft/loot_table/blocks/bush.json @@ -0,0 +1,42 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:any_of", + "terms": [ + { + "action": "shears_dig", + "condition": "forge:can_tool_perform_action" + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + } + ] + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:bush" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:blocks/bush" +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/loot_table/blocks/short_dry_grass.json b/src/main/generated/data/minecraft/loot_table/blocks/short_dry_grass.json new file mode 100644 index 0000000000..84f1103b9b --- /dev/null +++ b/src/main/generated/data/minecraft/loot_table/blocks/short_dry_grass.json @@ -0,0 +1,42 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:any_of", + "terms": [ + { + "action": "shears_dig", + "condition": "forge:can_tool_perform_action" + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + } + ] + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:short_dry_grass" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:blocks/short_dry_grass" +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/loot_table/blocks/tall_dry_grass.json b/src/main/generated/data/minecraft/loot_table/blocks/tall_dry_grass.json new file mode 100644 index 0000000000..0bf2a9912d --- /dev/null +++ b/src/main/generated/data/minecraft/loot_table/blocks/tall_dry_grass.json @@ -0,0 +1,42 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:any_of", + "terms": [ + { + "action": "shears_dig", + "condition": "forge:can_tool_perform_action" + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + } + ] + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:tall_dry_grass" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:blocks/tall_dry_grass" +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/recipe/lodestone.json b/src/main/generated/data/minecraft/recipe/lodestone.json index aabb2183d5..56532f2eed 100644 --- a/src/main/generated/data/minecraft/recipe/lodestone.json +++ b/src/main/generated/data/minecraft/recipe/lodestone.json @@ -2,7 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": "#c:ingots/netherite", + "#": "#c:ingots/iron", "S": "minecraft:chiseled_stone_bricks" }, "pattern": [ diff --git a/src/main/generated/pack.mcmeta b/src/main/generated/pack.mcmeta index c09f703a79..0551aca70f 100644 --- a/src/main/generated/pack.mcmeta +++ b/src/main/generated/pack.mcmeta @@ -3,6 +3,6 @@ "description": { "translate": "pack.forge.description" }, - "pack_format": 61 + "pack_format": 71 } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/ClientCommandHandler.java b/src/main/java/net/minecraftforge/client/ClientCommandHandler.java index 419ec568ed..22b90090d8 100644 --- a/src/main/java/net/minecraftforge/client/ClientCommandHandler.java +++ b/src/main/java/net/minecraftforge/client/ClientCommandHandler.java @@ -195,7 +195,7 @@ public class ClientCommandHandler { MutableComponent details = Component.literal("") .withStyle(ChatFormatting.GRAY) .withStyle((style) -> style - .withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, reader.getString()))); + .withClickEvent(new ClickEvent.SuggestCommand(reader.getString()))); if (position > 10) details.append("..."); @@ -211,7 +211,7 @@ public class ClientCommandHandler { mc.gui.getChat().addMessage( Component.translatable("command.failed") .withStyle(ChatFormatting.RED) - .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, message))) + .withStyle(style -> style.withHoverEvent(new HoverEvent.ShowText(message))) ); LOGGER.error("Error executing client command \"{}\"", command, generic); } diff --git a/src/main/java/net/minecraftforge/client/ClientForgeMod.java b/src/main/java/net/minecraftforge/client/ClientForgeMod.java index 57d2dc9688..5d7d8a09f8 100644 --- a/src/main/java/net/minecraftforge/client/ClientForgeMod.java +++ b/src/main/java/net/minecraftforge/client/ClientForgeMod.java @@ -6,16 +6,13 @@ package net.minecraftforge.client; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.resources.model.UnbakedGeometry; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.ModelEvent; import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; import net.minecraftforge.client.event.RegisterNamedRenderTypesEvent; -import net.minecraftforge.client.model.CompositeModel; import net.minecraftforge.client.model.DynamicFluidContainerModel; -import net.minecraftforge.client.model.ElementsModel; -import net.minecraftforge.client.model.EmptyModel; -import net.minecraftforge.client.model.ItemLayerModel; -import net.minecraftforge.client.model.SeparateTransformsModel; +import net.minecraftforge.client.model.ItemLayerGeometry; import net.minecraftforge.client.model.obj.ObjLoader; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -24,13 +21,10 @@ import net.minecraftforge.fml.common.Mod; public class ClientForgeMod { @SubscribeEvent public static void onRegisterGeometryLoaders(ModelEvent.RegisterGeometryLoaders event) { - event.register("empty", EmptyModel.LOADER); - event.register("elements", ElementsModel.Loader.INSTANCE); + event.register("empty", (json, ctx) -> UnbakedGeometry.EMPTY); event.register("obj", ObjLoader.INSTANCE); event.register("fluid_container", DynamicFluidContainerModel.Loader.INSTANCE); - event.register("composite", CompositeModel.Loader.INSTANCE); - event.register("item_layers", ItemLayerModel.Loader.INSTANCE); - event.register("separate_transforms", SeparateTransformsModel.Loader.INSTANCE); + event.register("item_layers", ItemLayerGeometry.Loader.INSTANCE); } @SubscribeEvent diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index d962042996..aea6e8bccd 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -5,21 +5,17 @@ package net.minecraftforge.client; -import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Either; import com.mojang.math.Transformation; -import net.minecraft.ChatFormatting; import net.minecraft.FileUtil; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; @@ -50,24 +46,18 @@ import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.ShaderDefines; -import net.minecraft.client.renderer.ShaderProgram; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.BlockElement; -import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.entity.state.HumanoidRenderState; 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.language.I18n; import net.minecraft.client.resources.metadata.animation.FrameSize; -import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelDebugName; import net.minecraft.client.resources.model.ModelManager; -import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.ResolvedModel; import net.minecraft.client.resources.model.SpriteGetter; +import net.minecraft.client.resources.model.UnbakedGeometry; import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.client.sounds.SoundEngine; import net.minecraft.core.BlockPos; @@ -131,9 +121,9 @@ import net.minecraftforge.client.extensions.common.IClientItemExtensions; import net.minecraftforge.client.extensions.common.IClientMobEffectExtensions; import net.minecraftforge.client.gui.ClientTooltipComponentManager; import net.minecraftforge.client.gui.ModMismatchDisconnectedScreen; +import net.minecraftforge.client.model.ForgeBlockModelData; import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.client.model.geometry.GeometryLoaderManager; -import net.minecraftforge.client.model.geometry.IUnbakedGeometry; import net.minecraftforge.client.textures.ForgeTextureMetadata; import net.minecraftforge.client.textures.TextureAtlasSpriteLoaderManager; import net.minecraftforge.common.ForgeI18n; @@ -143,7 +133,6 @@ import net.minecraftforge.fml.IExtensionPoint; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModLoader; import net.minecraftforge.fml.VersionChecker; -import net.minecraftforge.gametest.ForgeGameTestHooks; import net.minecraftforge.network.NetworkContext; import net.minecraftforge.network.NetworkInitialization; import net.minecraftforge.network.NetworkRegistry; @@ -425,17 +414,6 @@ public class ForgeHooksClient { }; } - public static boolean calculateFaceWithoutAO(BlockAndTintGetter getter, BlockState state, BlockPos pos, BakedQuad quad, boolean isFaceCubic, float[] brightness, int[] lightmap) { - if (quad.hasAmbientOcclusion()) - return false; - - BlockPos lightmapPos = isFaceCubic ? pos.relative(quad.getDirection()) : pos; - - brightness[0] = brightness[1] = brightness[2] = brightness[3] = getter.getShade(quad.getDirection(), quad.isShade()); - lightmap[0] = lightmap[1] = lightmap[2] = lightmap[3] = LevelRenderer.getLightColor(getter, state, lightmapPos); - return true; - } - private static int slotMainHand = 0; public static boolean shouldCauseReequipAnimation(@NotNull ItemStack from, @NotNull ItemStack to, int slot) { @@ -699,10 +677,6 @@ public class ForgeHooksClient { return MinecraftForge.EVENT_BUS.post(event) ? "" : event.getMessage(); } - public static final Supplier SHADER_UNLIT_TRANSLUCENT = Suppliers.memoize(() -> - new ShaderProgram(ResourceLocation.fromNamespaceAndPath("forge", "rendertype_entity_unlit_translucent"), DefaultVertexFormat.NEW_ENTITY, ShaderDefines.EMPTY) - ); - public static Font getTooltipFont(@NotNull ItemStack stack, Font fallbackFont) { Font stackFont = IClientItemExtensions.of(stack).getFont(stack, IClientItemExtensions.FontContext.TOOLTIP); return stackFont == null ? fallbackFont : stackFont; @@ -850,7 +824,6 @@ public class ForgeHooksClient { throw new IllegalStateException("Client hooks initialized more than once"); initializedClientHooks = true; - ForgeGameTestHooks.registerGametests(); ModLoader.get().postEvent(new RegisterClientReloadListenersEvent(resourceManager)); ModLoader.get().postEvent(new EntityRenderersEvent.RegisterLayerDefinitions()); ModLoader.get().postEvent(new EntityRenderersEvent.RegisterRenderers()); @@ -880,44 +853,44 @@ public class ForgeHooksClient { || ForgeEventFactoryClient.onScreenMouseDragPost(screen, mouseX, mouseY, mouseButton, dragX, dragY); } - public static BlockModel deserializeBlockModel(BlockModel model, List elements, JsonObject json, JsonDeserializationContext context) { - IUnbakedGeometry geometry = null; - if (json.has("loader")) { - var name = ResourceLocation.parse(GsonHelper.getAsString(json, "loader")); - var loader = GeometryLoaderManager.get(name); - if (loader == null) - throw new JsonParseException(String.format(Locale.ENGLISH, "Model loader '%s' not found. Registered loaders: %s", name, GeometryLoaderManager.getLoaderList())); + public static @Nullable UnbakedGeometry deserializeBlockModelGeometry(JsonObject json, JsonDeserializationContext context) { + var name = GsonHelper.getAsString(json, "loader", null); + if (name == null) + return null; - geometry = loader.read(json, context); + var loader = GeometryLoaderManager.get(ResourceLocation.parse(name)); + if (loader == null) + throw new JsonParseException(String.format(Locale.ENGLISH, "Model loader '%s' not found. Registered loaders: %s", name, GeometryLoaderManager.getLoaderList())); + + return loader.read(json, context); + } + + + @Nullable + public static ForgeBlockModelData deserializeBlockModel(JsonObject json, JsonDeserializationContext context) { + Optional renderType = Optional.empty(); + Optional renderTypeFast = Optional.empty(); + Optional> visibility = Optional.empty(); + + var transform = Optional.ofNullable(GsonHelper.getAsObject(json, "transform", null, context, Transformation.class)); + + var renderTypeName = GsonHelper.getAsString(json, "render_type", null); + if (renderTypeName != null) + renderType = Optional.of(ResourceLocation.parse(renderTypeName)); + + var renderTypeFastName = GsonHelper.getAsString(json, "render_type_fast", null); + if (renderTypeFastName != null) + renderTypeFast = Optional.of(ResourceLocation.parse(renderTypeFastName)); + + var visibilityJson = GsonHelper.getAsJsonObject(json, "visibility", null); + if (visibilityJson != null) { + var map = ImmutableMap.builder(); + for (var part : visibilityJson.entrySet()) + map.put(part.getKey(), part.getValue().getAsBoolean()); + visibility = Optional.of(map.build()); } - if (geometry != null) { - elements.clear(); - model.customData.setCustomGeometry(geometry); - } - - if (json.has("transform")) { - JsonElement transform = json.get("transform"); - model.customData.setRootTransform(context.deserialize(transform, Transformation.class)); - } - - if (json.has("render_type")) { - var renderTypeHintName = GsonHelper.getAsString(json, "render_type"); - model.customData.setRenderTypeHint(ResourceLocation.parse(renderTypeHintName)); - } - - if (json.has("render_type_fast")) { - var renderTypeHintName = GsonHelper.getAsString(json, "render_type_fast"); - model.customData.setRenderTypeFastHint(ResourceLocation.parse(renderTypeHintName)); - } - - if (json.has("visibility")) { - var visibility = GsonHelper.getAsJsonObject(json, "visibility"); - for (var part : visibility.entrySet()) - model.customData.visibilityData.setVisibilityState(part.getKey(), part.getValue().getAsBoolean()); - } - - return model; + return new ForgeBlockModelData(transform, renderType, renderTypeFast, visibility); } /** This is a dirty fucking hack, but it needs to send in the top most render type. */ @@ -944,9 +917,8 @@ public class ForgeHooksClient { return group; } - @Override - public BakedModel bake(ResourceLocation name, ModelState state) { - return parent.bake(name, state); + @Override public ResolvedModel getModel(ResourceLocation p_397309_) { + return parent.getModel(p_397309_); } @Override @@ -955,8 +927,8 @@ public class ForgeHooksClient { } @Override - public ModelDebugName rootName() { - return parent.rootName(); + public T compute(SharedOperationKey p_395456_) { + return parent.compute(p_395456_); } } } diff --git a/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java b/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java index 78ece0c236..561bcb10ef 100644 --- a/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java +++ b/src/main/java/net/minecraftforge/client/ForgeRenderTypes.java @@ -5,25 +5,37 @@ package net.minecraftforge.client; +import com.mojang.blaze3d.opengl.GlConst; +import com.mojang.blaze3d.opengl.GlTexture; +import com.mojang.blaze3d.pipeline.BlendFunction; +import com.mojang.blaze3d.pipeline.RenderPipeline; +import com.mojang.blaze3d.platform.DepthTestFunction; +import com.mojang.blaze3d.platform.DestFactor; +import com.mojang.blaze3d.platform.SourceFactor; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.textures.TextureFormat; + import net.minecraft.Util; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.client.renderer.RenderStateShard; import net.minecraft.client.renderer.RenderStateShard.TextureStateShard; import net.minecraft.client.renderer.RenderType; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.VertexFormat; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.TriState; -import net.minecraft.world.inventory.InventoryMenu; import net.minecraftforge.common.util.NonNullLazy; import net.minecraftforge.common.util.NonNullSupplier; +import net.minecraftforge.fml.earlydisplay.DisplayWindow; import java.util.function.Function; import java.util.function.Supplier; +import org.jetbrains.annotations.ApiStatus; +import org.lwjgl.opengl.GL30C; + public enum ForgeRenderTypes { ITEM_LAYERED_SOLID(()-> getItemLayeredSolid(blockAtlas())), ITEM_LAYERED_CUTOUT(()-> getItemLayeredCutout(blockAtlas())), @@ -34,10 +46,20 @@ public enum ForgeRenderTypes { ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(blockAtlas(), false)), TRANSLUCENT_ON_PARTICLES_TARGET(() -> getTranslucentParticlesTarget(blockAtlas())); + /** + * Controls the texture filtering state for certain {@link RenderType Render Types}. + * + * @see ForgeRenderTypes#getText + * @see ForgeRenderTypes#getTextIntensity + * @see ForgeRenderTypes#getTextPolygonOffset + * @see ForgeRenderTypes#getTextIntensityPolygonOffset + * @see ForgeRenderTypes#getTextSeeThrough + * @see ForgeRenderTypes#getTextIntensitySeeThrough + */ public static TriState enableTextTextureLinearFiltering = TriState.FALSE; @SuppressWarnings("deprecation") - private static final ResourceLocation blockAtlas() { + private static ResourceLocation blockAtlas() { return TextureAtlas.LOCATION_BLOCKS; } @@ -101,6 +123,8 @@ public enum ForgeRenderTypes { } /** + * @see #enableTextTextureLinearFiltering + * * @return Replacement of {@link RenderType#text(ResourceLocation)}, but with optional linear texture filtering. */ public static RenderType getText(ResourceLocation locationIn) { @@ -108,6 +132,8 @@ public enum ForgeRenderTypes { } /** + * @see #enableTextTextureLinearFiltering + * * @return Replacement of {@link RenderType#textIntensity(ResourceLocation)}, but with optional linear texture filtering. */ public static RenderType getTextIntensity(ResourceLocation locationIn) { @@ -115,6 +141,8 @@ public enum ForgeRenderTypes { } /** + * @see #enableTextTextureLinearFiltering + * * @return Replacement of {@link RenderType#textPolygonOffset(ResourceLocation)}, but with optional linear texture filtering. */ public static RenderType getTextPolygonOffset(ResourceLocation locationIn) { @@ -122,6 +150,8 @@ public enum ForgeRenderTypes { } /** + * @see #enableTextTextureLinearFiltering + * * @return Replacement of {@link RenderType#textIntensityPolygonOffset(ResourceLocation)}, but with optional linear texture filtering. */ public static RenderType getTextIntensityPolygonOffset(ResourceLocation locationIn) { @@ -129,6 +159,8 @@ public enum ForgeRenderTypes { } /** + * @see #enableTextTextureLinearFiltering + * * @return Replacement of {@link RenderType#textSeeThrough(ResourceLocation)}, but with optional linear texture filtering. */ public static RenderType getTextSeeThrough(ResourceLocation locationIn) { @@ -136,19 +168,34 @@ public enum ForgeRenderTypes { } /** + * @see #enableTextTextureLinearFiltering + * * @return Replacement of {@link RenderType#textIntensitySeeThrough(ResourceLocation)}, but with optional linear texture filtering. */ public static RenderType getTextIntensitySeeThrough(ResourceLocation locationIn) { - return Internal.TEXT_INTENSITY_SEETHROUGH.apply(locationIn); + return Internal.TEXT_INTENSITY_SEE_THROUGH.apply(locationIn); } /** - * @return A variation of {@link RenderType#translucent()} that uses {@link OutputStateShard#PARTICLES_TARGET} + * @see #enableTextTextureLinearFiltering + * + * @return A variation of {@link RenderType#translucent()} that uses {@link RenderStateShard.OutputStateShard#PARTICLES_TARGET} */ public static RenderType getTranslucentParticlesTarget(ResourceLocation locationIn) { return Internal.TRANSLUCENT_PARTICLES_TARGET.apply(locationIn); } + + /** + * Render type for rendering the early loading screen, not for modder consumption. + * + * @param window The early loading screen, so we can grab the buffer ID + */ + @ApiStatus.Internal + public static RenderType getLoadingOverlay(DisplayWindow window) { + return Internal.getLoadingOverlay(window); + } + // ---------------------------------------- // Implementation details below this line // ---------------------------------------- @@ -164,190 +211,269 @@ public enum ForgeRenderTypes { return renderTypeSupplier.get(); } - private static class Internal extends RenderType { - private static final ShaderStateShard RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER = new ShaderStateShard(ForgeHooksClient.SHADER_UNLIT_TRANSLUCENT.get()); - - private Internal(String name, VertexFormat fmt, VertexFormat.Mode glMode, int size, boolean doCrumbling, boolean depthSorting, Runnable onEnable, Runnable onDisable) { - super(name, fmt, glMode, size, doCrumbling, depthSorting, onEnable, onDisable); + // TODO: [VEN] Note that the names of these render types have been modified to match the names of their container constants, + // This was done for the sake of consistency, but it may be wrong. Need validation. + // Additionally, I am unsure if I have set all the flags correctly. Most of these don't have full docs on + // what they are meant to be used for, so I had to guess how to remap them to the new system. + private static abstract class Internal extends RenderType { + // TODO: [VEN] This is really just here because argument names are stripped I guess? Just as a weird doc thing? + private Internal(String name, int bufferSize, boolean affectsCrumbling, boolean sortOnUpload, Runnable setupState, Runnable clearState) { + super(name, bufferSize, affectsCrumbling, sortOnUpload, setupState, clearState); throw new IllegalStateException("This class must not be instantiated"); } public static Function UNSORTED_TRANSLUCENT = Util.memoize(Internal::unsortedTranslucent); private static RenderType unsortedTranslucent(ResourceLocation textureLocation) { - final boolean sortingEnabled = false; - CompositeState renderState = CompositeState.builder() - .setShaderState(RenderType.RENDERTYPE_ENTITY_TRANSLUCENT_SHADER) - .setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setCullState(NO_CULL) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true); - return create("forge_entity_unsorted_translucent", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, sortingEnabled, renderState); + return create("forge_unsorted_translucent", + TRANSIENT_BUFFER_SIZE, + true, + false, + RenderPipelines.ENTITY_TRANSLUCENT, + CompositeState.builder() + .setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false)) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); } - /* - private static final BiFunction ENTITY_TRANSLUCENT = Util.memoize((textureLocation, composite) -> { - RenderType.CompositeState rendertype$compositestate = RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_SHADER) - .setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setCullState(NO_CULL) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(composite); - return create("entity_translucent", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, rendertype$compositestate); - }); - */ + public static Function UNLIT_TRANSLUCENT_SORTED = Util.memoize(Internal::unlitTranslucentSorted); + private static RenderType unlitTranslucentSorted(ResourceLocation textureLocation) { + return create("forge_unlit_translucent_sorted", + TRANSIENT_BUFFER_SIZE, + true, + true, + RenderPipelines.ENTITY_TRANSLUCENT, + CompositeState.builder() + .setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false)) + .setLightmapState(NO_LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); + } - public static Function UNLIT_TRANSLUCENT_SORTED = Util.memoize(tex -> Internal.unlitTranslucent(tex, true)); - public static Function UNLIT_TRANSLUCENT_UNSORTED = Util.memoize(tex -> Internal.unlitTranslucent(tex, false)); - private static RenderType unlitTranslucent(ResourceLocation textureLocation, boolean sortingEnabled) { - CompositeState renderState = CompositeState.builder() - .setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER) - .setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setCullState(NO_CULL) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true); - return create("forge_entity_unlit_translucent", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, sortingEnabled, renderState); + public static Function UNLIT_TRANSLUCENT_UNSORTED = Util.memoize(Internal::unlitTranslucentUnsorted); + private static RenderType unlitTranslucentUnsorted(ResourceLocation textureLocation) { + return create("forge_unlit_translucent_sorted", + TRANSIENT_BUFFER_SIZE, + true, + false, + RenderPipelines.ENTITY_TRANSLUCENT, + CompositeState.builder() + .setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false)) + .setLightmapState(NO_LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true)); } public static Function LAYERED_ITEM_SOLID = Util.memoize(Internal::layeredItemSolid); private static RenderType layeredItemSolid(ResourceLocation locationIn) { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RenderType.RENDERTYPE_ENTITY_SOLID_SHADER) - .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false)) - .setTransparencyState(NO_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true); - return create("forge_item_entity_solid", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, rendertype$state); + return create( + "forge_layered_item_soild", + TRANSIENT_BUFFER_SIZE, + true, + false, + RenderPipelines.ENTITY_SOLID, + CompositeState.builder() + .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false)) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true) + ); } public static Function LAYERED_ITEM_CUTOUT = Util.memoize(Internal::layeredItemCutout); private static RenderType layeredItemCutout(ResourceLocation locationIn) { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RenderType.RENDERTYPE_ENTITY_CUTOUT_SHADER) - .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false)) - .setTransparencyState(NO_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true); - return create("forge_item_entity_cutout", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, rendertype$state); + return create( + "forge_layered_item_cutout", + TRANSIENT_BUFFER_SIZE, + true, + false, + RenderPipelines.ENTITY_CUTOUT, + CompositeState.builder() + .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false)) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true) + ); } public static Function LAYERED_ITEM_CUTOUT_MIPPED = Util.memoize(Internal::layeredItemCutoutMipped); private static RenderType layeredItemCutoutMipped(ResourceLocation locationIn) { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RenderType.RENDERTYPE_ENTITY_SMOOTH_CUTOUT_SHADER) - .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, true)) - .setTransparencyState(NO_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true); - return create("forge_item_entity_cutout_mipped", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, rendertype$state); + return create( + "forge_layered_item_cutout_mipped", + TRANSIENT_BUFFER_SIZE, + true, + false, + RenderPipelines.ENTITY_SMOOTH_CUTOUT, + CompositeState.builder() + .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, true)) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true) + ); } public static Function LAYERED_ITEM_TRANSLUCENT = Util.memoize(Internal::layeredItemTranslucent); private static RenderType layeredItemTranslucent(ResourceLocation locationIn) { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RenderType.RENDERTYPE_ENTITY_TRANSLUCENT_SHADER) - .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true); - return create("forge_item_entity_translucent_cull", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, rendertype$state); + return create( + "forge_layered_item_translucent", + TRANSIENT_BUFFER_SIZE, + true, + true, + RenderPipelines.ITEM_ENTITY_TRANSLUCENT_CULL, + CompositeState.builder() + .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false)) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true) + ); } public static Function TEXT = Util.memoize(Internal::getText); private static RenderType getText(ResourceLocation locationIn) { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_TEXT_SHADER) - .setTextureState(new CustomizableTextureState(locationIn, () -> ForgeRenderTypes.enableTextTextureLinearFiltering, () -> false)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .createCompositeState(false); - return create("forge_text", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, false, true, rendertype$state); + return create( + "forge_text", + SMALL_BUFFER_SIZE, + false, + true, + RenderPipelines.TEXT, + CompositeState.builder() + .setTextureState(new CustomizableTextureState(locationIn, false)) + .setLightmapState(LIGHTMAP) + .createCompositeState(false) + ); } public static Function TEXT_INTENSITY = Util.memoize(Internal::getTextIntensity); private static RenderType getTextIntensity(ResourceLocation locationIn) { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_TEXT_INTENSITY_SHADER) - .setTextureState(new CustomizableTextureState(locationIn, () -> ForgeRenderTypes.enableTextTextureLinearFiltering, () -> false)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .createCompositeState(false); - return create("text_intensity", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, false, true, rendertype$state); + return create( + "forge_text_intensity", + SMALL_BUFFER_SIZE, + false, + false, + RenderPipelines.TEXT_INTENSITY, + CompositeState.builder() + .setTextureState(new CustomizableTextureState(locationIn, false)) + .setLightmapState(LIGHTMAP) + .createCompositeState(false) + ); } public static Function TEXT_POLYGON_OFFSET = Util.memoize(Internal::getTextPolygonOffset); private static RenderType getTextPolygonOffset(ResourceLocation locationIn) { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_TEXT_SHADER) - .setTextureState(new CustomizableTextureState(locationIn, () -> ForgeRenderTypes.enableTextTextureLinearFiltering, () -> false)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setLayeringState(POLYGON_OFFSET_LAYERING) - .createCompositeState(false); - return create("text_intensity", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, false, true, rendertype$state); + return create( + "forge_text_polygon_offset", + TRANSIENT_BUFFER_SIZE, + false, + true, + RenderPipelines.TEXT_POLYGON_OFFSET, + CompositeState.builder() + .setTextureState(new CustomizableTextureState(locationIn, () -> enableTextTextureLinearFiltering, () -> false)) + .setLightmapState(LIGHTMAP) + .createCompositeState(false) + ); } public static Function TEXT_INTENSITY_POLYGON_OFFSET = Util.memoize(Internal::getTextIntensityPolygonOffset); private static RenderType getTextIntensityPolygonOffset(ResourceLocation locationIn) { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_TEXT_INTENSITY_SHADER) - .setTextureState(new CustomizableTextureState(locationIn, () -> ForgeRenderTypes.enableTextTextureLinearFiltering, () -> false)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setLayeringState(POLYGON_OFFSET_LAYERING) - .createCompositeState(false); - return create("text_intensity", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, false, true, rendertype$state); + return create( + "forge_text_intensity_polygon_offset", + TRANSIENT_BUFFER_SIZE, + false, + true, + RenderPipelines.TEXT_INTENSITY, + CompositeState.builder() + .setTextureState(new CustomizableTextureState(locationIn, false)) + .setLightmapState(LIGHTMAP) + .createCompositeState(false) + ); } - public static Function TEXT_SEETHROUGH = Util.memoize(Internal::getTextSeeThrough); + public static Function TEXT_SEE_THROUGH = Util.memoize(Internal::getTextSeeThrough); + /** + * Use {@link #TEXT_SEE_THROUGH} instead. + */ + @Deprecated + public static Function TEXT_SEETHROUGH = TEXT_SEE_THROUGH; private static RenderType getTextSeeThrough(ResourceLocation locationIn) { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_TEXT_SEE_THROUGH_SHADER) - .setTextureState(new CustomizableTextureState(locationIn, () -> ForgeRenderTypes.enableTextTextureLinearFiltering, () -> false)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setDepthTestState(NO_DEPTH_TEST) - .setWriteMaskState(COLOR_WRITE) - .createCompositeState(false); - return create("forge_text_see_through", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, false, true, rendertype$state); + return create( + "forge_text_see_through", + TRANSIENT_BUFFER_SIZE, + false, + false, + RenderPipelines.TEXT_SEE_THROUGH, + CompositeState.builder() + .setTextureState(new CustomizableTextureState(locationIn, false)) + .setLightmapState(LIGHTMAP) + .createCompositeState(false) + ); } - public static Function TEXT_INTENSITY_SEETHROUGH = Util.memoize(Internal::getTextIntensitySeeThrough); + public static Function TEXT_INTENSITY_SEE_THROUGH = Util.memoize(Internal::getTextIntensitySeeThrough); + /** + * Use {@link #TEXT_INTENSITY_SEE_THROUGH} instead. + */ + @Deprecated + public static Function TEXT_INTENSITY_SEETHROUGH = TEXT_INTENSITY_SEE_THROUGH; private static RenderType getTextIntensitySeeThrough(ResourceLocation locationIn) { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_TEXT_INTENSITY_SEE_THROUGH_SHADER) - .setTextureState(new CustomizableTextureState(locationIn, () -> ForgeRenderTypes.enableTextTextureLinearFiltering, () -> false)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setDepthTestState(NO_DEPTH_TEST) - .setWriteMaskState(COLOR_WRITE) - .createCompositeState(false); - return create("forge_text_see_through", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, false, true, rendertype$state); + return create( + "forge_text_intensity_see_through", + TRANSIENT_BUFFER_SIZE, + false, + true, + RenderPipelines.TEXT_INTENSITY_SEE_THROUGH, + CompositeState.builder() + .setTextureState(new CustomizableTextureState(locationIn, false)) + .setLightmapState(LIGHTMAP) + .createCompositeState(false) + ); } public static Function TRANSLUCENT_PARTICLES_TARGET = Util.memoize(Internal::getTranslucentParticlesTarget); private static RenderType getTranslucentParticlesTarget(ResourceLocation locationIn) { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_TRANSLUCENT_SHADER) - .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, true)) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setLightmapState(LIGHTMAP) - .setOutputState(PARTICLES_TARGET) - .createCompositeState(true); - return create("forge_translucent_particles_target", DefaultVertexFormat.BLOCK, VertexFormat.Mode.QUADS, 2097152, true, true, rendertype$state); + return create( + "forge_translucent_particles_target", + TRANSIENT_BUFFER_SIZE, + true, + true, + RenderPipelines.TRANSLUCENT_PARTICLE, + CompositeState.builder() + .setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false)) + .setOutputState(PARTICLES_TARGET) + .setLightmapState(LIGHTMAP) + .createCompositeState(true) + ); + } + + private static final RenderPipeline LOADING_PIPELINE = RenderPipeline.builder(RenderPipelines.GUI_TEXTURED_SNIPPET) + .withLocation("pipeline/forge/loading_overlay") + .withBlend(new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE)) + .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) + .withDepthWrite(false) + .build(); + + public static RenderType getLoadingOverlay(DisplayWindow window) { + return create( + "forge_loading_overlay", + TRANSIENT_BUFFER_SIZE, + false, + false, + LOADING_PIPELINE, + CompositeState.builder() + .setTextureState(new LoadingOverlayTextureState(window)) + .createCompositeState(false) + ); } } private static class CustomizableTextureState extends TextureStateShard { + // [VEN] Here to make init shorter + private static final Supplier BLUR_STATE = () -> enableTextTextureLinearFiltering; + private static final Supplier MIP_ON_STATE = () -> true; + private static final Supplier MIP_OFF_STATE = () -> false; + private CustomizableTextureState(ResourceLocation resLoc, boolean mipmap) { + this(resLoc, BLUR_STATE, mipmap ? MIP_ON_STATE : MIP_OFF_STATE); + } + private CustomizableTextureState(ResourceLocation resLoc, Supplier blur, Supplier mipmap) { super(resLoc, blur.get(), mipmap.get()); this.setupState = () -> { @@ -356,7 +482,25 @@ public enum ForgeRenderTypes { TextureManager manager = Minecraft.getInstance().getTextureManager(); var texture = manager.getTexture(resLoc); texture.setFilter(this.blur, this.mipmap); - RenderSystem.setShaderTexture(0, resLoc); + RenderSystem.setShaderTexture(0, texture.getTexture()); + }; + } + } + + private static class LoadingOverlayTextureState extends TextureStateShard { + private static final ResourceLocation LOADING_TEXTURE = ResourceLocation.fromNamespaceAndPath("forge", "loading_overlay"); + private final GlTexture texture; + + private LoadingOverlayTextureState(DisplayWindow window) { + super(LOADING_TEXTURE, TriState.DEFAULT, false); + this.texture = new GlTexture(LOADING_TEXTURE.toString(), TextureFormat.RGBA8, + window.context().width(), window.context().height(), 0, + window.getFramebufferTextureId()) {}; + + this.setupState = () -> { + GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MIN_FILTER, GlConst.GL_NEAREST); + GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MAG_FILTER, GlConst.GL_NEAREST); + RenderSystem.setShaderTexture(0, texture); }; } } diff --git a/src/main/java/net/minecraftforge/client/ItemDecoratorHandler.java b/src/main/java/net/minecraftforge/client/ItemDecoratorHandler.java index 0c2649372f..1a790516b0 100644 --- a/src/main/java/net/minecraftforge/client/ItemDecoratorHandler.java +++ b/src/main/java/net/minecraftforge/client/ItemDecoratorHandler.java @@ -14,8 +14,6 @@ import org.jetbrains.annotations.ApiStatus; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.mojang.blaze3d.systems.RenderSystem; - import net.minecraft.client.gui.Font; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -23,24 +21,21 @@ import net.minecraftforge.client.event.RegisterItemDecorationsEvent; import net.minecraftforge.fml.ModLoader; @ApiStatus.Internal -public final class ItemDecoratorHandler -{ +public final class ItemDecoratorHandler { private final List itemDecorators; private static Map DECORATOR_LOOKUP = ImmutableMap.of(); private static final ItemDecoratorHandler EMPTY = new ItemDecoratorHandler(); - private ItemDecoratorHandler() - { + private ItemDecoratorHandler() { this.itemDecorators = ImmutableList.of(); } - private ItemDecoratorHandler(List itemDecorators) - { + + private ItemDecoratorHandler(List itemDecorators) { this.itemDecorators = ImmutableList.copyOf(itemDecorators); } - public static void init() - { + public static void init() { var decorators = new HashMap>(); var event = new RegisterItemDecorationsEvent(decorators); ModLoader.get().postEventWrapContainerInModOrder(event); @@ -52,25 +47,23 @@ public final class ItemDecoratorHandler DECORATOR_LOOKUP = builder.build(); } - public static ItemDecoratorHandler of(ItemStack stack) - { + public static ItemDecoratorHandler of(ItemStack stack) { return DECORATOR_LOOKUP.getOrDefault(stack.getItem(), EMPTY); } - public void render(GuiGraphics guiGraphics, Font font, ItemStack stack, int xOffset, int yOffset) - { + public void render(GuiGraphics guiGraphics, Font font, ItemStack stack, int xOffset, int yOffset) { resetRenderState(); - for (IItemDecorator itemDecorator : itemDecorators) - { + for (IItemDecorator itemDecorator : itemDecorators) { if (itemDecorator.render(guiGraphics, font, stack, xOffset, yOffset)) resetRenderState(); } } - private void resetRenderState() - { + private void resetRenderState() { + /* RenderSystem.enableDepthTest(); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); + */ } } diff --git a/src/main/java/net/minecraftforge/client/PresetEditorManager.java b/src/main/java/net/minecraftforge/client/PresetEditorManager.java index ea6c8976b5..93acb55abd 100644 --- a/src/main/java/net/minecraftforge/client/PresetEditorManager.java +++ b/src/main/java/net/minecraftforge/client/PresetEditorManager.java @@ -7,8 +7,6 @@ package net.minecraftforge.client; import java.util.HashMap; import java.util.Map; -import java.util.Optional; - import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/net/minecraftforge/client/RenderTypeHelper.java b/src/main/java/net/minecraftforge/client/RenderTypeHelper.java index f57ea1b87e..0f2ced165d 100644 --- a/src/main/java/net/minecraftforge/client/RenderTypeHelper.java +++ b/src/main/java/net/minecraftforge/client/RenderTypeHelper.java @@ -9,7 +9,7 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Sheets; -import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.BlockStateModel; import net.minecraft.util.RandomSource; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; @@ -52,7 +52,7 @@ public final class RenderTypeHelper { * but removes the need to query the model again if the item is a {@link BlockItem}. */ @NotNull - public static RenderType getFallbackItemRenderType(ItemStack stack, BakedModel model) { + public static RenderType getFallbackItemRenderType(ItemStack stack, BlockStateModel model) { if (stack.getItem() instanceof BlockItem blockItem) { var renderTypes = model.getRenderTypes(blockItem.getBlock().defaultBlockState(), RandomSource.create(42), ModelData.EMPTY); if (renderTypes.contains(RenderType.translucent())) diff --git a/src/main/java/net/minecraftforge/client/event/ModelEvent.java b/src/main/java/net/minecraftforge/client/event/ModelEvent.java index 6d91ed482e..cc22b8fa2a 100644 --- a/src/main/java/net/minecraftforge/client/event/ModelEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ModelEvent.java @@ -149,17 +149,17 @@ public abstract class ModelEvent extends Event { * only on the {@linkplain LogicalSide#CLIENT logical client}.

*/ public static class RegisterGeometryLoaders extends ModelEvent implements IModBusEvent { - private final Map> loaders; + private final Map loaders; @ApiStatus.Internal - public RegisterGeometryLoaders(Map> loaders) { + public RegisterGeometryLoaders(Map loaders) { this.loaders = loaders; } /** * Registers a new geometry loader. */ - public void register(String name, IGeometryLoader loader) { + public void register(String name, IGeometryLoader loader) { @SuppressWarnings("removal") var namespace = ModLoadingContext.get().getActiveNamespace(); var key = ResourceLocation.fromNamespaceAndPath(namespace, name); diff --git a/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java b/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java index 1e4d5ad032..c95c2c711c 100644 --- a/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RecipesUpdatedEvent.java @@ -6,7 +6,6 @@ package net.minecraftforge.client.event; import net.minecraft.client.ClientRecipeBook; -import net.minecraft.world.item.crafting.RecipeManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; diff --git a/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java b/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java index c75ece2aa6..2ae39f21a1 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderArmEvent.java @@ -6,7 +6,6 @@ package net.minecraftforge.client.event; import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.world.entity.HumanoidArm; diff --git a/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java b/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java index 801edc482c..94d1163f18 100644 --- a/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java @@ -13,6 +13,7 @@ import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; @@ -30,42 +31,31 @@ import java.io.IOException; * @see Screenshot */ @Cancelable -public class ScreenshotEvent extends Event -{ +public class ScreenshotEvent extends Event { public static final Component DEFAULT_CANCEL_REASON = Component.literal("Screenshot canceled"); private final NativeImage image; private File screenshotFile; - private Component resultMessage = null; + private @Nullable Component resultMessage = null; @ApiStatus.Internal - public ScreenshotEvent(NativeImage image, File screenshotFile) - { + public ScreenshotEvent(NativeImage image, File screenshotFile) { this.image = image; this.screenshotFile = screenshotFile; - try - { + try { this.screenshotFile = screenshotFile.getCanonicalFile(); // FORGE: Fix errors on Windows with paths that include \.\ - } catch (IOException ignored) - { - } + } catch (IOException ignored) { } } - /** - * {@return the in-memory image of the screenshot} - */ - public NativeImage getImage() - { - return image; + /** @return the in-memory image of the screenshot */ + public NativeImage getImage() { + return this.image; } - /** - * @return the file where the screenshot will be saved to - */ - public File getScreenshotFile() - { - return screenshotFile; + /** @return the file where the screenshot will be saved to */ + public File getScreenshotFile() { + return this.screenshotFile; } /** @@ -73,40 +63,36 @@ public class ScreenshotEvent extends Event * * @param screenshotFile the new filepath */ - public void setScreenshotFile(File screenshotFile) - { + public void setScreenshotFile(File screenshotFile) { this.screenshotFile = screenshotFile; } - /** - * {@return the custom cancellation message, or {@code null} if no custom message is set} - */ - public Component getResultMessage() - { - return resultMessage; + /** @return the custom cancellation message, or {@code null} if no custom message is set */ + public @Nullable Component getResultMessage() { + return this.resultMessage; } /** * Sets the new custom cancellation message used to inform the player. + *

* It may be {@code null}, in which case the {@linkplain #DEFAULT_CANCEL_REASON default cancel reason} will be used. * * @param resultMessage the new result message */ - public void setResultMessage(Component resultMessage) - { + public void setResultMessage(Component resultMessage) { this.resultMessage = resultMessage; } /** * Returns the cancellation message to be used in informing the player. * - *

If there is no custom message given ({@link #getResultMessage()} returns {@code null}), then + *

If there is no custom message given ({@link #getResultMessage()} == {@code null}), then * the message will be the {@linkplain #DEFAULT_CANCEL_REASON default cancel reason message}.

* * @return the cancel message for the player */ - public Component getCancelMessage() - { - return getResultMessage() != null ? getResultMessage() : DEFAULT_CANCEL_REASON; + public Component getCancelMessage() { + var message = this.getResultMessage(); + return message != null ? message : DEFAULT_CANCEL_REASON; } } diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java b/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java deleted file mode 100644 index eae8395076..0000000000 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.extensions; - -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.ItemBlockRenderTypes; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.block.model.BakedQuad; -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.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.util.RandomSource; -import net.minecraft.world.item.ItemDisplayContext; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.ChunkRenderTypeSet; -import net.minecraftforge.client.RenderTypeHelper; -import net.minecraftforge.client.model.data.ModelData; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -/** - * Extension interface for {@link IForgeBakedModel}. - */ -@SuppressWarnings("deprecation") -public interface IForgeBakedModel { - private BakedModel self() { - return (BakedModel)this; - } - - /** - * A null {@link RenderType} is used for the breaking overlay as well as non-standard rendering, so models should return all their quads. - */ - @NotNull - default List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData data, @Nullable RenderType renderType) { - return self().getQuads(state, side, rand); - } - - default boolean useAmbientOcclusion(BlockState state) { - return self().useAmbientOcclusion(); - } - - default boolean useAmbientOcclusion(BlockState state, RenderType renderType) { - return self().useAmbientOcclusion(state); - } - - /** - * Applies a transform for the given {@link ItemTransforms.TransformType} and {@code applyLeftHandTransform}, and - * returns the model to be rendered. - */ - default BakedModel applyTransform(ItemDisplayContext transformType, PoseStack poseStack, boolean applyLeftHandTransform) { - self().getTransforms().getTransform(transformType).apply(applyLeftHandTransform, poseStack); - return self(); - } - - default @NotNull ModelData getModelData(@NotNull BlockAndTintGetter level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ModelData modelData) { - return modelData; - } - - default TextureAtlasSprite getParticleIcon(@NotNull ModelData data) { - return self().getParticleIcon(); - } - - /** - * Gets the set of {@link RenderType render types} to use when drawing this block in the level. - * Supported types are those returned by {@link RenderType#chunkBufferLayers()}. - *

- * By default, defers query to {@link ItemBlockRenderTypes}. - */ - default ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) { - return ItemBlockRenderTypes.getRenderLayers(state); - } - - /** - * 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)}. - *

- * By default, defers query to {@link ItemBlockRenderTypes}. - * - * @see #getRenderPasses(ItemStack, boolean) - */ - /* - default List getRenderTypes(ItemStack itemStack, boolean fabulous) { - 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)}. - *

- * By default, returns the model itself. - * - * @see #getRenderTypes(ItemStack, boolean) - */ - /* - default List getRenderPasses(ItemStack itemStack, boolean fabulous) { - return List.of(self()); - } - */ -} diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeBlockAndTintGetter.java b/src/main/java/net/minecraftforge/client/extensions/IForgeBlockAndTintGetter.java deleted file mode 100644 index f001231d91..0000000000 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeBlockAndTintGetter.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.extensions; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.BlockAndTintGetter; - -/** - * Extension interface for {@link BlockAndTintGetter}. - */ -public interface IForgeBlockAndTintGetter { - private BlockAndTintGetter self() { - return (BlockAndTintGetter)this; - } - - /** - * Computes the shade for a given normal. - * 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.getApproximateNearest(normalX, normalY, normalZ), shade); - } -} diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeBlockStateModel.java b/src/main/java/net/minecraftforge/client/extensions/IForgeBlockStateModel.java new file mode 100644 index 0000000000..63d13ec76d --- /dev/null +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeBlockStateModel.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.client.extensions; + +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.block.model.BlockModelPart; +import net.minecraft.client.renderer.block.model.BlockStateModel; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.client.ChunkRenderTypeSet; +import net.minecraftforge.client.model.data.ModelData; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import it.unimi.dsi.fastutil.objects.ObjectArrayList; + +import java.util.List; + +@SuppressWarnings("deprecation") +public interface IForgeBlockStateModel { + private BlockStateModel self() { + return (BlockStateModel)this; + } + + + default @NotNull ModelData getModelData(@NotNull BlockAndTintGetter level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ModelData modelData) { + return modelData; + } + + default TextureAtlasSprite particleIcon(@NotNull ModelData data) { + return self().particleIcon(); + } + + /** + * Gets the set of {@link RenderType render types} to use when drawing this block in the level. + * Supported types are those returned by {@link RenderType#chunkBufferLayers()}. + *

+ * By default, defers query to {@link ItemBlockRenderTypes}. + */ + @SuppressWarnings("removal") + default ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) { + return ItemBlockRenderTypes.getRenderLayers(state); + } + + /** + * Collects the parts of this model to render for the specified render type. + * Not all paths call this, or use a valid render type. So it is recommended to also implement a sane default in + * the normal {@link BlockStateModel#collectParts(RandomSource, List)} method. + */ + default List collectParts(RandomSource random, ModelData data, @Nullable RenderType renderType) { + List list = new ObjectArrayList<>(); + this.collectParts(random, list, data, renderType); + return list; + } + + /** + * Collects the parts of this model to render for the specified render type. + * Not all paths call this, or use a valid render type. So it is recommended to also implement a sane default in + * the normal {@link BlockStateModel#collectParts(RandomSource, List)} method. + */ + default void collectParts(RandomSource random, List dest, ModelData data, @Nullable RenderType renderType) { + self().collectParts(random, dest); + } +} diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeGpuTexture.java b/src/main/java/net/minecraftforge/client/extensions/IForgeGpuTexture.java new file mode 100644 index 0000000000..e9887fee60 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeGpuTexture.java @@ -0,0 +1,14 @@ +package net.minecraftforge.client.extensions; + +import com.mojang.blaze3d.textures.GpuTexture; + +public interface IForgeGpuTexture { + @SuppressWarnings("unused") + private GpuTexture self() { + return (GpuTexture) this; + } + + default boolean isStencilEnabled() { + return false; + } +} diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeVertexFormat.java b/src/main/java/net/minecraftforge/client/extensions/IForgeVertexFormat.java index 97608ed330..26e79177ee 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeVertexFormat.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeVertexFormat.java @@ -5,7 +5,6 @@ package net.minecraftforge.client.extensions; -import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.blaze3d.vertex.VertexFormatElement; diff --git a/src/main/java/net/minecraftforge/client/gui/ModListScreen.java b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java index 2be789d57a..d5c24b23fe 100644 --- a/src/main/java/net/minecraftforge/client/gui/ModListScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java @@ -159,9 +159,9 @@ public class ModListScreen extends Screen { } @Override - protected void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY) { + protected void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, int mouseX, int mouseY) { if (logoPath != null) { - RenderSystem.enableBlend(); + //RenderSystem.enableBlend(); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); // Draw the logo image inscribed in a rectangle with width entryWidth (minus some padding) and height 50 int headerHeight = 50; @@ -171,9 +171,9 @@ public class ModListScreen extends Screen { for (FormattedCharSequence line : lines) { if (line != null) { - RenderSystem.enableBlend(); + //RenderSystem.enableBlend(); guiGraphics.drawString(ModListScreen.this.font, line, left + PADDING, relativeY, 0xFFFFFF); - RenderSystem.disableBlend(); + //RenderSystem.disableBlend(); } relativeY += font.lineHeight; } @@ -409,7 +409,7 @@ public class ModListScreen extends Screen { if (logo != null) { - var texture = new DynamicTexture(logo) { + var texture = new DynamicTexture(() -> logoFile, logo); /* { @Override public void upload() { var pixels = this.getPixels(); @@ -420,6 +420,7 @@ public class ModListScreen extends Screen { } } }; + */ tm.register(LOGO, texture); var size = new Size2i(logo.getWidth(), logo.getHeight()); diff --git a/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java b/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java index 3d4d19fa6e..1e8905ffd3 100644 --- a/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/ModMismatchDisconnectedScreen.java @@ -5,6 +5,8 @@ package net.minecraftforge.client.gui; +import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -29,7 +31,6 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; -import net.minecraft.network.chat.HoverEvent.Action; import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.Style; import net.minecraft.network.chat.TextColor; @@ -227,8 +228,16 @@ public class ModMismatchDisconnectedScreen extends Screen { String modId = id.getNamespace(); String tooltipId = id.getPath().isEmpty() ? id.getNamespace() : id.toString(); return Component.literal(modName).withStyle(color % 2 == 0 ? ChatFormatting.GOLD : ChatFormatting.YELLOW) - .withStyle(s -> s.withHoverEvent(new HoverEvent(Action.SHOW_TEXT, Component.literal(tooltipId + (!presentModUrls.getOrDefault(modId, "").isEmpty() ? "\n" + ForgeI18n.parseMessage("fml.modmismatchscreen.homepage") : ""))))) - .withStyle(s -> s.withClickEvent(!presentModUrls.getOrDefault(modId, "").isEmpty() ? new ClickEvent(ClickEvent.Action.OPEN_URL, presentModUrls.get(modId)) : null)); + .withStyle(s -> s.withHoverEvent(new HoverEvent.ShowText(Component.literal(tooltipId + (!presentModUrls.getOrDefault(modId, "").isEmpty() ? "\n" + ForgeI18n.parseMessage("fml.modmismatchscreen.homepage") : ""))))) + .withStyle(s -> s.withClickEvent(openUrl(presentModUrls.getOrDefault(modId, "")))); + } + + private static ClickEvent.OpenUrl openUrl(String url) { + try { + return url.isEmpty() ? null : new ClickEvent.OpenUrl(new URI(url)); + } catch (URISyntaxException e) { + return null; + } } @Override @@ -242,7 +251,7 @@ public class ModMismatchDisconnectedScreen extends Screen { } @Override - protected void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY) { + protected void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, int mouseX, int mouseY) { int i = 0; for (Pair> line : lineTable) { diff --git a/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java b/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java index 647746010b..93231144f9 100644 --- a/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java +++ b/src/main/java/net/minecraftforge/client/gui/overlay/VanillaGuiOverlay.java @@ -50,7 +50,7 @@ public enum VanillaGuiOverlay { PORTAL("portal", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> { float f1 = Mth.lerp(partialTick, gui.getMinecraft().player.oSpinningEffectIntensity, gui.getMinecraft().player.spinningEffectIntensity); - if (f1 > 0.0F && !gui.getMinecraft().player.hasEffect(MobEffects.CONFUSION)) { + if (f1 > 0.0F && !gui.getMinecraft().player.hasEffect(MobEffects.NAUSEA)) { gui.setupOverlayRenderState(true, false); gui.renderPortalOverlay(guiGraphics, f1); } diff --git a/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java b/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java index 4249afc102..f57560a96e 100644 --- a/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ScrollPanel.java @@ -5,20 +5,20 @@ package net.minecraftforge.client.gui.widget; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; -import net.minecraft.client.renderer.CoreShaders; +import net.minecraft.client.renderer.RenderType; + import java.util.Collections; import java.util.List; /** * Abstract scroll panel class. + * TODO: [Forge][Rendering] ScrollPanel could potentially be replaced by AbstractScrollArea */ public abstract class ScrollPanel extends AbstractContainerEventHandler implements Renderable, NarratableEntry { private final Minecraft client; @@ -145,7 +145,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen /** * Draws the background of the scroll panel. This runs AFTER Scissors are enabled. */ - protected void drawBackground(GuiGraphics guiGraphics, Tesselator tess, float partialTick) { + protected void drawBackground(GuiGraphics guiGraphics, float partialTick) { // BufferBuilder worldr = tess.getBuilder(); if (this.client.level != null) { @@ -168,7 +168,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen * Draw anything special on the screen. Scissor (RenderSystem.enableScissor) is enabled * for anything that is rendered outside the view box. Do not mess with Scissor unless you support this. */ - protected abstract void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY); + protected abstract void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, int mouseX, int mouseY); protected boolean clickPanel(double mouseX, double mouseY, int button) { return false; @@ -262,18 +262,14 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen @Override public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { - Tesselator tess = Tesselator.getInstance(); + guiGraphics.enableScissor(left, top, width, height); - double scale = client.getWindow().getGuiScale(); - RenderSystem.enableScissor((int)(left * scale), (int)(client.getWindow().getHeight() - (bottom * scale)), - (int)(width * scale), (int)(height * scale)); - - this.drawBackground(guiGraphics, tess, partialTick); + this.drawBackground(guiGraphics, partialTick); int baseY = this.top + border - (int)this.scrollDistance; - this.drawPanel(guiGraphics, right, baseY, tess, mouseX, mouseY); + this.drawPanel(guiGraphics, right, baseY, mouseX, mouseY); - RenderSystem.disableDepthTest(); + guiGraphics.disableScissor(); int extraHeight = (this.getContentHeight() + border) - height; if (extraHeight > 0) { @@ -283,46 +279,25 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen if (barTop < this.top) barTop = this.top; - int barBgAlpha = this.barBgColor >> 24 & 0xff; - int barBgRed = this.barBgColor >> 16 & 0xff; - int barBgGreen = this.barBgColor >> 8 & 0xff; - int barBgBlue = this.barBgColor & 0xff; + var source = guiGraphics.getBufferSource(); + var buf = source.getBuffer(RenderType.gui()); + buf.addVertex(barLeft, this.bottom, 0.0F).setColor(barBgColor); + buf.addVertex(barLeft + barWidth, this.bottom, 0.0F).setColor(barBgColor); + buf.addVertex(barLeft + barWidth, this.top, 0.0F).setColor(barBgColor); + buf.addVertex(barLeft, this.top, 0.0F).setColor(barBgColor); - 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); - worldr.addVertex(barLeft + barWidth, this.top, 0.0F).setColor(barBgRed, barBgGreen, barBgBlue, barBgAlpha); - worldr.addVertex(barLeft, this.top, 0.0F).setColor(barBgRed, barBgGreen, barBgBlue, barBgAlpha); - BufferUploader.drawWithShader(worldr.buildOrThrow()); + buf = source.getBuffer(RenderType.gui()); + buf.addVertex(barLeft, barTop + barHeight, 0.0F).setColor(barColor); + buf.addVertex(barLeft + barWidth, barTop + barHeight, 0.0F).setColor(barColor); + buf.addVertex(barLeft + barWidth, barTop, 0.0F).setColor(barColor); + buf.addVertex(barLeft, barTop, 0.0F).setColor(barColor); - int barAlpha = this.barColor >> 24 & 0xff; - int barRed = this.barColor >> 16 & 0xff; - int barGreen = this.barColor >> 8 & 0xff; - int barBlue = this.barColor & 0xff; - - worldr = tess.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - worldr.addVertex(barLeft, barTop + barHeight, 0.0F).setColor(barRed, barGreen, barBlue, barAlpha); - worldr.addVertex(barLeft + barWidth, barTop + barHeight, 0.0F).setColor(barRed, barGreen, barBlue, barAlpha); - worldr.addVertex(barLeft + barWidth, barTop, 0.0F).setColor(barRed, barGreen, barBlue, barAlpha); - worldr.addVertex(barLeft, barTop, 0.0F).setColor(barRed, barGreen, barBlue, barAlpha); - BufferUploader.drawWithShader(worldr.buildOrThrow()); - - int barBorderAlpha = this.barBorderColor >> 24 & 0xff; - int barBorderRed = this.barBorderColor >> 16 & 0xff; - int barBorderGreen = this.barBorderColor >> 8 & 0xff; - int barBorderBlue = this.barBorderColor & 0xff; - - worldr = tess.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - worldr.addVertex(barLeft, barTop + barHeight - 1, 0.0F).setColor(barBorderRed, barBorderGreen, barBorderBlue, barBorderAlpha); - worldr.addVertex(barLeft + barWidth - 1, barTop + barHeight - 1, 0.0F).setColor(barBorderRed, barBorderGreen, barBorderBlue, barBorderAlpha); - worldr.addVertex(barLeft + barWidth - 1, barTop, 0.0F).setColor(barBorderRed, barBorderGreen, barBorderBlue, barBorderAlpha); - worldr.addVertex(barLeft, barTop, 0.0F).setColor(barBorderRed, barBorderGreen, barBorderBlue, barBorderAlpha); - BufferUploader.drawWithShader(worldr.buildOrThrow()); + buf = source.getBuffer(RenderType.gui()); + buf.addVertex(barLeft, barTop + barHeight - 1, 0.0F).setColor(barBorderColor); + buf.addVertex(barLeft + barWidth - 1, barTop + barHeight - 1, 0.0F).setColor(barBorderColor); + buf.addVertex(barLeft + barWidth - 1, barTop, 0.0F).setColor(barBorderColor); + buf.addVertex(barLeft, barTop, 0.0F).setColor(barBorderColor); } - - RenderSystem.disableBlend(); - RenderSystem.disableScissor(); } protected void drawGradientRect(GuiGraphics guiGraphics, int left, int top, int right, int bottom, int color1, int color2) { diff --git a/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java b/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java index 7daf985c5e..07bf48c033 100644 --- a/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java +++ b/src/main/java/net/minecraftforge/client/loading/ForgeLoadingOverlay.java @@ -5,23 +5,18 @@ package net.minecraftforge.client.loading; -import com.mojang.blaze3d.platform.GlConst; +import com.mojang.blaze3d.opengl.GlTexture; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.BufferUploader; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.Tesselator; -import com.mojang.blaze3d.vertex.VertexFormat; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.LoadingOverlay; -import net.minecraft.client.renderer.CoreShaders; import net.minecraft.client.renderer.RenderType; import net.minecraft.server.packs.resources.ReloadInstance; import net.minecraft.util.Mth; +import net.minecraftforge.client.ForgeRenderTypes; import net.minecraftforge.fml.StartupMessageManager; import net.minecraftforge.fml.earlydisplay.DisplayWindow; import net.minecraftforge.fml.loading.progress.ProgressMeter; -import org.jetbrains.annotations.NotNull; import org.joml.Matrix4f; import org.lwjgl.opengl.GL30C; @@ -38,18 +33,23 @@ import java.util.function.Supplier; * It is somewhat a copy of the superclass render method. */ public class ForgeLoadingOverlay extends LoadingOverlay { + private static final boolean ENABLE = Boolean.parseBoolean("forge.enableForgeLoadingOverlay"); private final Minecraft minecraft; private final ReloadInstance reload; private final DisplayWindow displayWindow; private final ProgressMeter progress; + private final RenderType earlyBuffer; public ForgeLoadingOverlay(final Minecraft mc, final ReloadInstance reloader, final Consumer> errorConsumer, DisplayWindow displayWindow) { super(mc, reloader, errorConsumer, false); this.minecraft = mc; this.reload = reloader; this.displayWindow = displayWindow; - displayWindow.addMojangTexture(mc.getTextureManager().getTexture(MOJANG_STUDIOS_LOGO_LOCATION).getId()); + var texture = mc.getTextureManager().getTexture(MOJANG_STUDIOS_LOGO_LOCATION); + var glTexture = (GlTexture)texture.getTexture(); + displayWindow.addMojangTexture(glTexture.glId()); this.progress = StartupMessageManager.prependProgressBar("Minecraft Progress", 100); + this.earlyBuffer = ForgeRenderTypes.getLoadingOverlay(displayWindow); } public static Supplier newInstance(Supplier mc, Supplier ri, Consumer> handler, DisplayWindow window) { @@ -58,6 +58,8 @@ public class ForgeLoadingOverlay extends LoadingOverlay { @Override protected boolean renderContents(GuiGraphics gui, float fade) { + if (!ENABLE) + return true; progress.setAbsolute(Mth.clamp((int)(this.reload.getActualProgress() * 100f), 0, 100)); int alpha = (int)(fade * 255); @@ -72,18 +74,21 @@ public class ForgeLoadingOverlay extends LoadingOverlay { RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, fade); Matrix4f pos = gui.pose().last().pose(); + /* RenderSystem.enableBlend(); RenderSystem.blendFunc(GlConst.GL_SRC_ALPHA, GlConst.GL_ONE_MINUS_SRC_ALPHA); RenderSystem.setShader(CoreShaders.POSITION_TEX_COLOR); RenderSystem.setShaderTexture(0, displayWindow.getFramebufferTextureId()); GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MIN_FILTER, GlConst.GL_NEAREST); GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MAG_FILTER, GlConst.GL_NEAREST); + */ - var buf = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + var buf = gui.getBufferSource().getBuffer(earlyBuffer); buf.addVertex(pos, 0, 0, 0f).setUv(0, 0).setColor(1f, 1f, 1f, fade); buf.addVertex(pos, 0, height, 0f).setUv(0, 1).setColor(1f, 1f, 1f, fade); buf.addVertex(pos, width, height, 0f).setUv(1, 1).setColor(1f, 1f, 1f, fade); buf.addVertex(pos, width, 0, 0f).setUv(1, 0).setColor(1f, 1f, 1f, fade); + /* BufferUploader.drawWithShader(buf.buildOrThrow()); // I dont know what exactly this does, but without it the screen flickers black. @@ -95,8 +100,10 @@ public class ForgeLoadingOverlay extends LoadingOverlay { logo.addVertex(pos, 0, 0, 0f).setUv(1, 1).setColor(1f, 1f, 1f, fade); logo.addVertex(pos, 0, 0, 0f).setUv(1, 0).setColor(1f, 1f, 1f, fade); + RenderSystem.defaultBlendFunc(); RenderSystem.disableBlend(); + */ RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1f); return false; diff --git a/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java b/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java deleted file mode 100644 index a3b62648dd..0000000000 --- a/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model; - -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.block.model.BakedQuad; -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.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.util.RandomSource; -import net.minecraft.world.item.ItemDisplayContext; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.ChunkRenderTypeSet; -import net.minecraftforge.client.model.data.ModelData; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -/** - * Wrapper for {@link BakedModel} which delegates all operations to its parent. - *

- * Useful for creating wrapper baked models which only override certain properties. - */ -public abstract class BakedModelWrapper implements BakedModel { - protected final T originalModel; - - public BakedModelWrapper(T originalModel) { - this.originalModel = originalModel; - } - - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand) { - return originalModel.getQuads(state, side, rand); - } - - @Override - public boolean useAmbientOcclusion() { - return originalModel.useAmbientOcclusion(); - } - - @Override - public boolean useAmbientOcclusion(BlockState state) { - return originalModel.useAmbientOcclusion(state); - } - - @Override - public boolean useAmbientOcclusion(BlockState state, RenderType renderType) { - return originalModel.useAmbientOcclusion(state, renderType); - } - - @Override - public boolean isGui3d() { - return originalModel.isGui3d(); - } - - @Override - public boolean usesBlockLight() { - return originalModel.usesBlockLight(); - } - - @Override - public TextureAtlasSprite getParticleIcon() { - return originalModel.getParticleIcon(); - } - - @Override - public ItemTransforms getTransforms() { - return originalModel.getTransforms(); - } - - @Override - public BakedModel applyTransform(ItemDisplayContext cameraTransformType, PoseStack poseStack, boolean applyLeftHandTransform) { - return originalModel.applyTransform(cameraTransformType, poseStack, applyLeftHandTransform); - } - - @Override - public TextureAtlasSprite getParticleIcon(@NotNull ModelData data) { - return originalModel.getParticleIcon(data); - } - - @NotNull - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData extraData, @Nullable RenderType renderType) { - return originalModel.getQuads(state, side, rand, extraData, renderType); - } - - @NotNull - @Override - public ModelData getModelData(@NotNull BlockAndTintGetter level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ModelData modelData) { - return originalModel.getModelData(level, pos, state, modelData); - } - - @Override - public ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) { - return originalModel.getRenderTypes(state, rand, data); - } -} diff --git a/src/main/java/net/minecraftforge/client/model/CompositeModel.java b/src/main/java/net/minecraftforge/client/model/CompositeModel.java deleted file mode 100644 index c6bc4e19c6..0000000000 --- a/src/main/java/net/minecraftforge/client/model/CompositeModel.java +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -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.Collection; -import java.util.Collections; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.function.Function; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.BlockModel; -import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.renderer.block.model.TextureSlots; -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.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.util.RandomSource; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.ChunkRenderTypeSet; -import net.minecraftforge.client.RenderTypeGroup; -import net.minecraftforge.client.model.data.ModelData; -import net.minecraftforge.client.model.data.ModelProperty; -import net.minecraftforge.client.model.geometry.IGeometryBakingContext; -import net.minecraftforge.client.model.geometry.IGeometryLoader; -import net.minecraftforge.client.model.geometry.IUnbakedGeometry; -import net.minecraftforge.client.model.geometry.UnbakedGeometryHelper; -import net.minecraftforge.common.util.ConcatenatedListView; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * A model composed of several named children. - *

- * These respect component visibility as specified in {@link IGeometryBakingContext} and can additionally be provided - * with an item-specific render ordering, for multi-pass arrangements. - */ -public class CompositeModel implements IUnbakedGeometry { - private final ImmutableMap children; - private final ImmutableList itemPasses; - - public CompositeModel(ImmutableMap children, ImmutableList itemPasses) { - this.children = children; - this.itemPasses = itemPasses; - } - - @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, TextureSlots textures, ModelState modelState) { - var particle = baker.sprites().maybeMissing(textures, "particle"); - - var rootTransform = context.getRootTransform(); - if (!rootTransform.isIdentity()) - modelState = UnbakedGeometryHelper.composeRootTransformIntoModelState(modelState, rootTransform); - - var bakedPartsBuilder = ImmutableMap.builder(); - for (var entry : children.entrySet()) { - var name = entry.getKey(); - if (!context.isComponentVisible(name, true)) - continue; - var model = entry.getValue(); - bakedPartsBuilder.put(name, model.bake(textures, baker, modelState, model.getAmbientOcclusion(), model.getGuiLight().lightLikeBlock(), model.getTransforms())); - } - var bakedParts = bakedPartsBuilder.build(); - - var itemPassesBuilder = ImmutableList.builder(); - for (String name : this.itemPasses) - { - var model = bakedParts.get(name); - if (model == null) - throw new IllegalStateException("Specified \"" + name + "\" in \"item_render_order\", but that is not a child of this model."); - itemPassesBuilder.add(model); - } - - return new Baked(context.isGui3d(), context.useBlockLight(), context.useAmbientOcclusion(), particle, context.getTransforms(), bakedParts, itemPassesBuilder.build()); - } - - @Override - public void resolveDependencies(UnbakedModel.Resolver resolver, IGeometryBakingContext context) { - children.values().forEach(child -> child.resolveDependencies(resolver)); - } - - @Override - public Set getConfigurableComponentNames() { - return children.keySet(); - } - - public static class Baked implements IDynamicBakedModel { - private final boolean isAmbientOcclusion; - private final boolean isGui3d; - private final boolean isSideLit; - private final TextureAtlasSprite particle; - private final ItemTransforms transforms; - private final ImmutableMap children; - private final 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.transforms = transforms; - this.itemPasses = itemPasses; - } - - @NotNull - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData data, @Nullable RenderType renderType) { - List> quadLists = new ArrayList<>(); - for (Map.Entry entry : children.entrySet()) { - if (renderType == null || (state != null && entry.getValue().getRenderTypes(state, rand, data).contains(renderType))) { - quadLists.add(entry.getValue().getQuads(state, side, rand, CompositeModel.Data.resolve(data, entry.getKey()), renderType)); - } - } - return ConcatenatedListView.of(quadLists); - } - - @Override - public @NotNull ModelData getModelData(@NotNull BlockAndTintGetter level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ModelData modelData) { - var builder = Data.builder(); - for (var entry : children.entrySet()) - builder.with(entry.getKey(), entry.getValue().getModelData(level, pos, state, Data.resolve(modelData, entry.getKey()))); - return modelData.derive().with(Data.PROPERTY, builder.build()).build(); - } - - @Override - public boolean useAmbientOcclusion() { - return isAmbientOcclusion; - } - - @Override - public boolean isGui3d() { - return isGui3d; - } - - @Override - public boolean usesBlockLight() { - return isSideLit; - } - - @Override - public TextureAtlasSprite getParticleIcon() { - return particle; - } - - @Override - public ItemTransforms getTransforms() { - return transforms; - } - - @Override - public ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) { - var sets = new ArrayList(); - for (Map.Entry entry : children.entrySet()) - sets.add(entry.getValue().getRenderTypes(state, rand, CompositeModel.Data.resolve(data, entry.getKey()))); - return ChunkRenderTypeSet.union(sets); - } - - @Nullable - public BakedModel getPart(String name) { - return children.get(name); - } - - 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, ItemTransforms cameraTransforms) { - return new Builder(isAmbientOcclusion, isGui3d, isSideLit, particle, cameraTransforms); - } - - public static class Builder { - private final boolean isAmbientOcclusion; - private final boolean isGui3d; - private final boolean isSideLit; - private final List children = new ArrayList<>(); - private final List quads = new ArrayList<>(); - private final ItemTransforms transforms; - private TextureAtlasSprite particle; - private RenderTypeGroup lastRenderTypes = RenderTypeGroup.EMPTY; - private RenderTypeGroup lastRenderTypesFast = RenderTypeGroup.EMPTY; - - 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.transforms = transforms; - } - - public void addLayer(BakedModel model) { - flushQuads(RenderTypeGroup.EMPTY, RenderTypeGroup.EMPTY); - children.add(model); - } - - private void addLayer(RenderTypeGroup renderTypes, List quads) { - this.addLayer(renderTypes, RenderTypeGroup.EMPTY, quads); - } - - private void addLayer(RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast, List quads) { - var modelBuilder = IModelBuilder.of(isAmbientOcclusion, isSideLit, isGui3d, transforms, particle, renderTypes, renderTypesFast); - quads.forEach(modelBuilder::addUnculledFace); - children.add(modelBuilder.build()); - } - - private void flushQuads(RenderTypeGroup renderTypes) { - this.flushQuads(renderTypes, RenderTypeGroup.EMPTY); - } - - private void flushQuads(RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast) { - if (!Objects.equals(renderTypes, lastRenderTypes)) { - if (!quads.isEmpty()) { - addLayer(lastRenderTypes, lastRenderTypesFast, quads); - quads.clear(); - } - lastRenderTypes = renderTypes; - lastRenderTypesFast = renderTypesFast; - } - } - - public Builder setParticle(TextureAtlasSprite particleSprite) { - this.particle = particleSprite; - return this; - } - - public Builder addQuads(RenderTypeGroup renderTypes, BakedQuad... quadsToAdd) { - return this.addQuads(renderTypes, RenderTypeGroup.EMPTY, quadsToAdd); - } - - public Builder addQuads(RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast, BakedQuad... quadsToAdd) { - flushQuads(renderTypes, renderTypesFast); - Collections.addAll(quads, quadsToAdd); - return this; - } - - public Builder addQuads(RenderTypeGroup renderTypes, Collection quadsToAdd) { - return this.addQuads(renderTypes, RenderTypeGroup.EMPTY, quadsToAdd); - } - - public Builder addQuads(RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast, Collection quadsToAdd) { - flushQuads(renderTypes, renderTypesFast); - quads.addAll(quadsToAdd); - return this; - } - - public BakedModel build() { - if (!quads.isEmpty()) { - addLayer(lastRenderTypes, lastRenderTypesFast, quads); - } - var childrenBuilder = ImmutableMap.builder(); - var itemPassesBuilder = ImmutableList.builder(); - int i = 0; - for (var model : this.children) { - childrenBuilder.put("model_" + (i++), model); - itemPassesBuilder.add(model); - } - return new Baked(isGui3d, isSideLit, isAmbientOcclusion, particle, transforms, childrenBuilder.build(), itemPassesBuilder.build()); - } - } - - } - - /** - * A model data container which stores data for child components. - */ - public static class Data { - public static final ModelProperty PROPERTY = new ModelProperty<>(); - - private final Map partData; - - private Data(Map partData) { - this.partData = partData; - } - - @Nullable - public ModelData get(String name) { - return partData.get(name); - } - - /** - * Helper to get the data from a {@link ModelData} instance. - * - * @param modelData The object to get data from - * @param name The name of the part to get data for - * @return The data for the part, or the one passed in if not found - */ - public static ModelData resolve(ModelData modelData, String name) { - var compositeData = modelData.get(PROPERTY); - if (compositeData == null) - return modelData; - var partData = compositeData.get(name); - return partData != null ? partData : modelData; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private final Map partData = new IdentityHashMap<>(); - - public Builder with(String name, ModelData data) { - partData.put(name, data); - return this; - } - - public Data build() { - return new Data(partData); - } - } - } - - public static final class Loader implements IGeometryLoader { - public static final Loader INSTANCE = new Loader(); - - private Loader() { } - - @Override - public CompositeModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) { - List itemPasses = new ArrayList<>(); - ImmutableMap.Builder childrenBuilder = ImmutableMap.builder(); - readChildren(jsonObject, "children", deserializationContext, childrenBuilder, itemPasses); - - var children = childrenBuilder.build(); - if (children.isEmpty()) - throw new JsonParseException("Composite model requires a \"children\" element with at least one element."); - - if (jsonObject.has("item_render_order")) { - itemPasses.clear(); - for (var element : jsonObject.getAsJsonArray("item_render_order")) - { - var name = element.getAsString(); - if (!children.containsKey(name)) - throw new JsonParseException("Specified \"" + name + "\" in \"item_render_order\", but that is not a child of this model."); - itemPasses.add(name); - } - } - - return new CompositeModel(children, ImmutableList.copyOf(itemPasses)); - } - - private void readChildren(JsonObject jsonObject, String name, JsonDeserializationContext deserializationContext, ImmutableMap.Builder children, List itemPasses) { - if (!jsonObject.has(name)) - return; - var childrenJsonObject = jsonObject.getAsJsonObject(name); - for (Map.Entry entry : childrenJsonObject.entrySet()) { - children.put(entry.getKey(), deserializationContext.deserialize(entry.getValue(), BlockModel.class)); - itemPasses.add(entry.getKey()); // We can do this because GSON preserves ordering during deserialization - } - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java b/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java index b86f6563ab..1e7c35eb41 100644 --- a/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java +++ b/src/main/java/net/minecraftforge/client/model/DynamicFluidContainerModel.java @@ -12,10 +12,12 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.TextureSlots; 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.Material; import net.minecraft.client.resources.model.ModelBaker; +import net.minecraft.client.resources.model.ModelDebugName; import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.QuadCollection; +import net.minecraft.client.resources.model.UnbakedGeometry; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.GsonHelper; import net.minecraft.world.level.material.Fluid; @@ -25,7 +27,6 @@ import net.minecraftforge.client.RenderTypeGroup; import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; import net.minecraftforge.client.model.geometry.IGeometryBakingContext; import net.minecraftforge.client.model.geometry.IGeometryLoader; -import net.minecraftforge.client.model.geometry.IUnbakedGeometry; import net.minecraftforge.client.model.geometry.StandaloneGeometryBakingContext; import net.minecraftforge.client.model.geometry.UnbakedGeometryHelper; import net.minecraftforge.registries.ForgeRegistries; @@ -42,7 +43,7 @@ import org.joml.Vector3f; * * @see Colors */ -public class DynamicFluidContainerModel implements IUnbakedGeometry { +public class DynamicFluidContainerModel implements UnbakedGeometry { // Depth offsets to prevent Z-fighting private static final Transformation FLUID_TRANSFORM = new Transformation(new Vector3f(), new Quaternionf(), new Vector3f(1, 1, 1.002f), new Quaternionf()); private static final Transformation COVER_TRANSFORM = new Transformation(new Vector3f(), new Quaternionf(), new Vector3f(1, 1, 1.004f), new Quaternionf()); @@ -63,6 +64,11 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry baseSprite, modelState); - modelBuilder.addQuads(normalRenderTypes, quads); + UnbakedGeometryHelper.bakeElements(unbaked, $ -> baseSprite, state, buf); } if (fluidMaskLocation != null && fluidSprite != null) { - TextureAtlasSprite templateSprite = sprites.get(fluidMaskLocation); + TextureAtlasSprite templateSprite = sprites.get(fluidMaskLocation, name); if (templateSprite != null) { // Fluid layer - var transformedState = new SimpleModelState(modelState.getRotation().compose(FLUID_TRANSFORM), modelState.isUvLocked()); + var transformedState = new SimpleModelState(transformation.compose(FLUID_TRANSFORM)); var unbaked = UnbakedGeometryHelper.createUnbakedItemMaskElements(1, templateSprite.contents()); // Use template as mask - var quads = UnbakedGeometryHelper.bakeElements(unbaked, $ -> fluidSprite, transformedState); // Bake with fluid texture var emissive = applyFluidLuminosity && fluid.getFluidType().getLightLevel() > 0; - var renderTypes = getLayerRenderTypes(emissive); - if (emissive) QuadTransformers.settingMaxEmissivity().processInPlace(quads); + var transformer = emissive ? QuadTransformers.settingMaxEmissivity() : QuadTransformers.empty(); - modelBuilder.addQuads(renderTypes, quads); + UnbakedGeometryHelper.bakeElements(unbaked, $ -> fluidSprite, transformedState, transformer, buf); // Bake with fluid texture } } @@ -131,29 +137,24 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry sprite, transformedState); // Bake with selected texture - modelBuilder.addQuads(normalRenderTypes, quads); + UnbakedGeometryHelper.bakeElements(unbaked, $ -> sprite, transformedState, buf); // Bake with selected texture } } - modelBuilder.setParticle(particleSprite); - return modelBuilder.build(); + return buf.build(); } - public static final class Loader implements IGeometryLoader { + public static final class Loader implements IGeometryLoader { public static final Loader INSTANCE = new Loader(); private Loader() { } @Override - public DynamicFluidContainerModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) { - if (!jsonObject.has("fluid")) - throw new RuntimeException("Bucket model requires 'fluid' value."); - - ResourceLocation fluidName = ResourceLocation.parse(jsonObject.get("fluid").getAsString()); + public UnbakedGeometry read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) { + var fluidName = ResourceLocation.parse(GsonHelper.getAsString(jsonObject, "fluid")); Fluid fluid = ForgeRegistries.FLUIDS.getValue(fluidName); diff --git a/src/main/java/net/minecraftforge/client/model/ElementsModel.java b/src/main/java/net/minecraftforge/client/model/ElementsModel.java deleted file mode 100644 index b92899e14d..0000000000 --- a/src/main/java/net/minecraftforge/client/model/ElementsModel.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.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 net.minecraft.client.renderer.block.model.BlockElement; -import net.minecraft.client.renderer.block.model.TextureSlots; -import net.minecraft.client.resources.model.ModelBaker; -import net.minecraft.client.resources.model.ModelState; -import net.minecraft.client.resources.model.SimpleBakedModel; -import net.minecraft.util.GsonHelper; -import net.minecraftforge.client.model.geometry.IGeometryBakingContext; -import net.minecraftforge.client.model.geometry.IGeometryLoader; -import net.minecraftforge.client.model.geometry.SimpleUnbakedGeometry; -import net.minecraftforge.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, TextureSlots textures, ModelState modelState) { - //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); - var sprites = baker.sprites(); - - for (var element : elements) { - for (var direction : element.faces.keySet()) { - var face = element.faces.get(direction); - var sprite = sprites.maybeMissing(textures, face.texture()); - var quad = SimpleBakedModel.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/minecraftforge/client/model/EmptyModel.java b/src/main/java/net/minecraftforge/client/model/EmptyModel.java deleted file mode 100644 index a2b835fcd4..0000000000 --- a/src/main/java/net/minecraftforge/client/model/EmptyModel.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model; - -import java.util.List; -import java.util.Map; -import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.renderer.block.model.TextureSlots; -import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; -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.Material; -import net.minecraft.client.resources.model.ModelBaker; -import net.minecraft.client.resources.model.ModelState; -import net.minecraft.client.resources.model.SimpleBakedModel; -import net.minecraftforge.client.RenderTypeGroup; -import net.minecraftforge.client.model.geometry.IGeometryBakingContext; -import net.minecraftforge.client.model.geometry.IGeometryLoader; -import net.minecraftforge.client.model.geometry.IUnbakedGeometry; -import net.minecraftforge.client.model.geometry.SimpleUnbakedGeometry; -import net.minecraftforge.client.textures.UnitTextureAtlasSprite; - -/** - * A completely empty model with no quads or texture dependencies. - *

- * You can access it as a {@link BakedModel}, an {@link IUnbakedGeometry} or an {@link IGeometryLoader}. - */ -public class EmptyModel extends SimpleUnbakedGeometry { - public static final BakedModel BAKED = new Baked(); - public static final EmptyModel INSTANCE = new EmptyModel(); - public static final IGeometryLoader LOADER = (json, ctx) -> INSTANCE; - - private EmptyModel() { } - - @Override - protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, TextureSlots textures, ModelState modelTransform) { - // NO-OP - } - - @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, TextureSlots spriteGetter, ModelState modelState) { - return BAKED; - } - - private static class Baked extends SimpleBakedModel { - private static final Material MISSING_TEXTURE = new Material(TextureAtlas.LOCATION_BLOCKS, MissingTextureAtlasSprite.getLocation()); - - public Baked() { - super(List.of(), Map.of(), false, false, false, UnitTextureAtlasSprite.INSTANCE, ItemTransforms.NO_TRANSFORMS, RenderTypeGroup.EMPTY, RenderTypeGroup.EMPTY); - } - - @Override - public TextureAtlasSprite getParticleIcon() { - return MISSING_TEXTURE.sprite(); - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/ForgeBlockModelData.java b/src/main/java/net/minecraftforge/client/model/ForgeBlockModelData.java new file mode 100644 index 0000000000..a231a87daf --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/ForgeBlockModelData.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.client.model; + +import java.util.Map; +import java.util.Optional; + +import com.mojang.math.Transformation; + +import net.minecraft.resources.ResourceLocation; + +public record ForgeBlockModelData( + Optional transform, + Optional renderType, + Optional renderTypeFast, + Optional> visibility +) { + public ForgeBlockModelData() { + this(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + } + + public ForgeBlockModelData merge(ForgeBlockModelData other) { + if (other == null) + return this; + + var vis = this.visibility(); + if (this.visibility().isPresent() && other.visibility().isPresent()) { + var map = Map.copyOf(this.visibility().get()); + map.putAll(other.visibility().get()); + vis = Optional.of(map); + } + + return new ForgeBlockModelData( + this.transform().isPresent() ? this.transform() : other.transform(), + this.renderType().isPresent() ? this.renderType() : other.renderType(), + this.renderTypeFast().isPresent() ? this.renderTypeFast() : other.renderTypeFast(), + vis.isPresent() ? vis : other.visibility() + ); + } + + public boolean full() { + return transform.isPresent() && renderType.isPresent() && renderTypeFast.isPresent() && visibility.isPresent(); + } +} diff --git a/src/main/java/net/minecraftforge/client/model/ForgeFaceData.java b/src/main/java/net/minecraftforge/client/model/ForgeFaceData.java index b0b41f2489..bf2a533296 100644 --- a/src/main/java/net/minecraftforge/client/model/ForgeFaceData.java +++ b/src/main/java/net/minecraftforge/client/model/ForgeFaceData.java @@ -18,11 +18,10 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.client.renderer.block.model.BlockElement; import net.minecraft.client.renderer.block.model.BlockElementFace; -import net.minecraft.util.ExtraCodecs; /** * Holds extra data that may be injected into a face.

- * Used by {@link ItemLayerModel}, {@link BlockElement} and {@link BlockElementFace} + * Used by {@link ItemLayerGeometry}, {@link BlockElement} and {@link BlockElementFace} * * @param color Color in ARGB format * @param blockLight Block Light for this face from 0-15 (inclusive) diff --git a/src/main/java/net/minecraftforge/client/model/IDynamicBakedModel.java b/src/main/java/net/minecraftforge/client/model/IDynamicBakedModel.java deleted file mode 100644 index 79452a6ca4..0000000000 --- a/src/main/java/net/minecraftforge/client/model/IDynamicBakedModel.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model; - -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.core.Direction; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.extensions.IForgeBakedModel; -import net.minecraftforge.client.model.data.ModelData; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -/** - * Convenience interface with default implementation of {@link IForgeBakedModel#getQuads(BlockState, Direction, RandomSource, ModelData, RenderType)}. - */ -public interface IDynamicBakedModel extends BakedModel { - @Override - default @NotNull List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand) { - return getQuads(state, side, rand, ModelData.EMPTY, null); - } - - // Force this to be overriden otherwise this introduces a default cycle between the two overloads. - @Override - @NotNull - List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData extraData, @Nullable RenderType renderType); -} diff --git a/src/main/java/net/minecraftforge/client/model/IModelBuilder.java b/src/main/java/net/minecraftforge/client/model/IModelBuilder.java index c79f2ee8db..0d8d4fd07d 100644 --- a/src/main/java/net/minecraftforge/client/model/IModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/IModelBuilder.java @@ -7,10 +7,13 @@ package net.minecraftforge.client.model; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.renderer.block.model.SimpleModelWrapper; +import net.minecraft.client.renderer.item.EmptyModel; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.SimpleBakedModel; +import net.minecraft.client.renderer.block.model.BlockModelPart; +import net.minecraft.client.resources.model.QuadCollection; import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.RenderTypeGroup; import java.util.List; @@ -18,9 +21,12 @@ import java.util.List; /** * 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)} + * Provides a generic base implementation via {@link #of(boolean, boolean, boolean, ItemTransforms, TextureAtlasSprite, RenderTypeGroup, RenderTypeGroup)} * and a quad-collecting alternative via {@link #collecting(List)}. + * + * @deprecated Use {@link net.minecraft.client.resources.model.QuadCollection} instead. */ +@Deprecated(forRemoval = true, since = "1.21.5") public interface IModelBuilder> { /** * Creates a new model builder that uses the provided attributes in the final baked model. @@ -70,10 +76,20 @@ public interface IModelBuilder> { T addUnculledFace(BakedQuad quad); - BakedModel build(); + BlockModelPart build(); class Simple implements IModelBuilder { - private final SimpleBakedModel.Builder builder; + private final QuadCollection.Builder builder; + + private final boolean hasAmbientOcclusion; + + // TODO: [VEN] These are UNUSED, and this is GOING TO BREAK. + private final boolean usesBlockLight; + private final boolean isGui3d; + private final ItemTransforms transforms; + private final TextureAtlasSprite particle; + private final RenderTypeGroup renderTypes; + private final RenderTypeGroup renderTypesFast; private Simple( boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d, @@ -86,8 +102,14 @@ public interface IModelBuilder> { boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d, ItemTransforms transforms, TextureAtlasSprite particle, RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast ) { - this.builder = new SimpleBakedModel.Builder(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms).particle(particle); - this.builder.renderTypes(renderTypes, renderTypesFast); + this.builder = new QuadCollection.Builder(); + this.hasAmbientOcclusion = hasAmbientOcclusion; + this.usesBlockLight = usesBlockLight; + this.isGui3d = isGui3d; + this.transforms = transforms; + this.particle = particle; + this.renderTypes = renderTypes; + this.renderTypesFast = renderTypesFast; } @Override @@ -103,12 +125,15 @@ public interface IModelBuilder> { } @Override - public BakedModel build() { - return builder.build(); + public BlockModelPart build() { + var quads = builder.build(); + // TODO: [VEN] Models will NOT be complete here!!!! + return new SimpleModelWrapper(quads, hasAmbientOcclusion, particle); } } class Collecting implements IModelBuilder { + private static final BlockModelPart EMPTY = new SimpleModelWrapper(QuadCollection.EMPTY, false, new TextureAtlasSprite(ResourceLocation.fromNamespaceAndPath("forge", "empty"), null, 0, 0, 0, 0) {}); private final List quads; private Collecting(List quads) { @@ -128,8 +153,8 @@ public interface IModelBuilder> { } @Override - public BakedModel build() { - return EmptyModel.BAKED; + public BlockModelPart build() { + return EMPTY; } } } diff --git a/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java b/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java index a9103c7216..222dfe498b 100644 --- a/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java +++ b/src/main/java/net/minecraftforge/client/model/IQuadTransformer.java @@ -8,8 +8,6 @@ package net.minecraftforge.client.model; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.VertexFormatElement; import net.minecraft.client.renderer.block.model.BakedQuad; - -import java.util.Arrays; import java.util.List; /** @@ -17,6 +15,7 @@ import java.util.List; * * @see QuadTransformers */ +@FunctionalInterface public interface IQuadTransformer { int STRIDE = DefaultVertexFormat.BLOCK.getVertexSize() / 4; int POSITION = findOffset(VertexFormatElement.POSITION); @@ -26,33 +25,14 @@ public interface IQuadTransformer { int UV2 = findOffset(VertexFormatElement.UV2); int NORMAL = findOffset(VertexFormatElement.NORMAL); - void processInPlace(BakedQuad quad); - - default void processInPlace(List quads) { - for (BakedQuad quad : quads) - processInPlace(quad); - } - - default BakedQuad process(BakedQuad quad) { - var copy = copy(quad); - processInPlace(copy); - return copy; - } + BakedQuad process(BakedQuad quad); default List process(List inputs) { - return inputs.stream().map(IQuadTransformer::copy).peek(this::processInPlace).toList(); + return inputs.stream().map(this::process).toList(); } default IQuadTransformer andThen(IQuadTransformer other) { - return quad -> { - processInPlace(quad); - other.processInPlace(quad); - }; - } - - 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.getLightEmission(), quad.hasAmbientOcclusion()); + return quad -> other.process(process(quad)); } private static int findOffset(VertexFormatElement element) { diff --git a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java b/src/main/java/net/minecraftforge/client/model/ItemLayerGeometry.java similarity index 62% rename from src/main/java/net/minecraftforge/client/model/ItemLayerModel.java rename to src/main/java/net/minecraftforge/client/model/ItemLayerGeometry.java index b7011d0346..aac7241062 100644 --- a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java +++ b/src/main/java/net/minecraftforge/client/model/ItemLayerGeometry.java @@ -10,14 +10,20 @@ import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.ItemModelGenerator; +import net.minecraft.client.renderer.block.model.SimpleUnbakedGeometry; import net.minecraft.client.renderer.block.model.TextureSlots; -import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.BlockElement; +import net.minecraft.client.renderer.block.model.BlockModelPart; import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.ModelBaker; +import net.minecraft.client.resources.model.ModelDebugName; import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.QuadCollection; +import net.minecraft.client.resources.model.UnbakedGeometry; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.ForgeRenderTypes; import net.minecraftforge.client.RenderTypeGroup; @@ -25,44 +31,48 @@ import net.minecraftforge.client.model.geometry.IGeometryBakingContext; import net.minecraftforge.client.model.geometry.IGeometryLoader; import net.minecraftforge.client.model.geometry.IUnbakedGeometry; import net.minecraftforge.client.model.geometry.UnbakedGeometryHelper; + +import java.util.ArrayList; +import java.util.List; + import org.jetbrains.annotations.Nullable; /** - * Forge reimplementation of vanilla's {@link ItemModelGenerator}, i.e. builtin/generated models with some tweaks: - * - Represented as {@link IUnbakedGeometry} so it can be baked as usual instead of being special-cased + * Forge version of vanilla's {@link ItemModelGenerator}, i.e. builtin/generated models with some tweaks: + * - Represented as {@link UnbakedGeometry} so it can be used in multiple root models * - Not limited to an arbitrary number of layers (5) - * - Support for per-layer render types + //* - Support for per-layer render types - Currently Doesn't work. TODO: [Forge][Model] Make a Model loader for this */ -public class ItemLayerModel implements IUnbakedGeometry { - @Nullable - private ImmutableList textures; +@SuppressWarnings("unused") +public class ItemLayerGeometry implements UnbakedGeometry { + private static final ItemLayerGeometry INSTANCE = new ItemLayerGeometry(Int2ObjectMaps.emptyMap(), Int2ObjectMaps.emptyMap()); + private final Int2ObjectMap renderTypeNames; private final Int2ObjectMap renderTypeFastNames; - private ItemLayerModel(@Nullable ImmutableList textures, Int2ObjectMap renderTypeNames) { - this(textures, renderTypeNames, new Int2ObjectOpenHashMap<>()); - } - - private ItemLayerModel(@Nullable ImmutableList textures, Int2ObjectMap renderTypeNames, Int2ObjectMap renderTypeFastNames) { - this.textures = textures; + private ItemLayerGeometry(Int2ObjectMap renderTypeNames, Int2ObjectMap renderTypeFastNames) { this.renderTypeNames = renderTypeNames; this.renderTypeFastNames = renderTypeFastNames; } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, TextureSlots spriteGetter, ModelState modelState) { - if (textures == null) { - ImmutableList.Builder builder = ImmutableList.builder(); - int i = 0; - Material material; - while ((material = spriteGetter.getMaterial("layer" + i++)) != null) { - builder.add(material); - } - textures = builder.build(); + public QuadCollection bake(TextureSlots textures, ModelBaker baker, ModelState state, ModelDebugName name) { + List elements = new ArrayList<>(); + + int i = 0; + while (true) { + var layer = "layer" + i++; + var material = textures.getMaterial(layer); + if (material == null) + break; + var contents = baker.sprites().get(material, name).contents(); + elements.addAll(ItemModelGenerator.processFrames(i, layer, contents)); } + return SimpleUnbakedGeometry.bake(elements, textures, baker.sprites(), state, name); + /* Material particleMaterial = spriteGetter.getMaterial("particle"); - var particle = baker.sprites().get(particleMaterial == null ? textures.get(0) : particleMaterial); + var particle = baker.sprites().get(particleMaterial == null ? textures.get(0) : particleMaterial, name); var rootTransform = context.getRootTransform(); if (!rootTransform.isIdentity()) modelState = UnbakedGeometryHelper.composeRootTransformIntoModelState(modelState, rootTransform); @@ -70,7 +80,7 @@ public class ItemLayerModel implements IUnbakedGeometry { var normalRenderTypes = new RenderTypeGroup(RenderType.translucent(), ForgeRenderTypes.ITEM_UNSORTED_TRANSLUCENT.get()); var builder = CompositeModel.Baked.builder(context, particle, context.getTransforms()); for (int i = 0; i < textures.size(); i++) { - var sprite = baker.sprites().get(textures.get(i)); + var sprite = baker.sprites().get(textures.get(i), name); var unbaked = UnbakedGeometryHelper.createUnbakedItemElements(i, sprite.contents()); var quads = UnbakedGeometryHelper.bakeElements(unbaked, $ -> sprite, modelState); var renderTypeName = renderTypeNames.get(i); @@ -81,16 +91,20 @@ public class ItemLayerModel implements IUnbakedGeometry { } return builder.build(); + */ } - public static final class Loader implements IGeometryLoader { + public static final class Loader implements IGeometryLoader { public static final Loader INSTANCE = new Loader(); @Override - public ItemLayerModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) { + public UnbakedGeometry read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) { + return ItemLayerGeometry.INSTANCE; + /* var renderTypeNames = readRenderTypeNames(jsonObject, "render_types"); var renderTypeFastNames = readRenderTypeNames(jsonObject, "render_types_fast"); - return new ItemLayerModel(null, renderTypeNames, renderTypeFastNames); + return new ItemLayerModel(renderTypeNames, renderTypeFastNames); + */ } private static Int2ObjectMap readRenderTypeNames(JsonObject jsonObject, String key) { @@ -107,18 +121,5 @@ public class ItemLayerModel implements IUnbakedGeometry { return renderTypeNames; } - - @Deprecated(forRemoval = true, since = "1.21.4") - protected void readLayerData(JsonObject jsonObject, String name, Int2ObjectOpenHashMap renderTypeNames, Int2ObjectMap layerData, boolean logWarning) { - if (!jsonObject.has(name)) - return; - - var fullbrightLayers = jsonObject.getAsJsonObject(name); - for (var entry : fullbrightLayers.entrySet()) { - int layer = Integer.parseInt(entry.getKey()); - var data = ForgeFaceData.read(entry.getValue(), ForgeFaceData.DEFAULT); - layerData.put(layer, data); - } - } } } diff --git a/src/main/java/net/minecraftforge/client/model/QuadTransformers.java b/src/main/java/net/minecraftforge/client/model/QuadTransformers.java index 2541e5f1b4..7772864796 100644 --- a/src/main/java/net/minecraftforge/client/model/QuadTransformers.java +++ b/src/main/java/net/minecraftforge/client/model/QuadTransformers.java @@ -21,8 +21,7 @@ import java.util.Arrays; * @see IQuadTransformer */ public final class QuadTransformers { - - private static final IQuadTransformer EMPTY = quad -> {}; + private static final IQuadTransformer EMPTY = quad -> quad; private static final IQuadTransformer[] EMISSIVE_TRANSFORMERS = Util.make(new IQuadTransformer[16], array -> { Arrays.setAll(array, i -> applyingLightmap(LightTexture.pack(i, i))); }); @@ -30,22 +29,20 @@ public final class QuadTransformers { /** * {@return a {@link BakedQuad} transformer that does nothing} */ - public static IQuadTransformer empty() - { + public static IQuadTransformer empty() { return EMPTY; } /** * {@return a new {@link BakedQuad} transformer that applies the specified {@link Transformation}} */ - public static IQuadTransformer applying(Transformation transform) - { + public static IQuadTransformer applying(Transformation transform) { if (transform.isIdentity()) return empty(); + return quad -> { - var vertices = quad.getVertices(); - for (int i = 0; i < 4; i++) - { + var vertices = Arrays.copyOf(quad.vertices(), quad.vertices().length); + for (int i = 0; i < 4; i++) { int offset = i * IQuadTransformer.STRIDE + IQuadTransformer.POSITION; float x = Float.intBitsToFloat(vertices[offset]); float y = Float.intBitsToFloat(vertices[offset + 1]); @@ -60,12 +57,10 @@ public final class QuadTransformers { vertices[offset + 2] = Float.floatToRawIntBits(pos.z()); } - for (int i = 0; i < 4; i++) - { + for (int i = 0; i < 4; i++) { int offset = i * IQuadTransformer.STRIDE + IQuadTransformer.NORMAL; int normalIn = vertices[offset]; - if ((normalIn & 0x00FFFFFF) != 0) // The ignored byte is padding and may be filled with user data - { + if ((normalIn & 0x00FFFFFF) != 0) { // The ignored byte is padding and may be filled with user data float x = ((byte) (normalIn & 0xFF)) / 127.0f; float y = ((byte) ((normalIn >> 8) & 0xFF)) / 127.0f; float z = ((byte) ((normalIn >> 16) & 0xFF)) / 127.0f; @@ -79,34 +74,34 @@ public final class QuadTransformers { (normalIn & 0xFF000000); // Restore padding, just in case } } + + return new BakedQuad(vertices, quad.tintIndex(), quad.direction(), quad.sprite(), quad.shade(), quad.lightEmission(), quad.ambientOcclusion()); }; } /** * @return A new {@link BakedQuad} transformer that applies the specified packed light value. */ - public static IQuadTransformer applyingLightmap(int packedLight) - { + public static IQuadTransformer applyingLightmap(int packedLight) { return quad -> { - var vertices = quad.getVertices(); + var vertices = Arrays.copyOf(quad.vertices(), quad.vertices().length); for (int i = 0; i < 4; i++) vertices[i * IQuadTransformer.STRIDE + IQuadTransformer.UV2] = packedLight; + return new BakedQuad(vertices, quad.tintIndex(), quad.direction(), quad.sprite(), quad.shade(), quad.lightEmission(), quad.ambientOcclusion()); }; } /** * @return A new {@link BakedQuad} transformer that applies the specified block and sky light values. */ - public static IQuadTransformer applyingLightmap(int blockLight, int skyLight) - { + public static IQuadTransformer applyingLightmap(int blockLight, int skyLight) { return applyingLightmap(LightTexture.pack(blockLight, skyLight)); } /** * @return A {@link BakedQuad} transformer that sets the lightmap to the given emissivity (0-15) */ - public static IQuadTransformer settingEmissivity(int emissivity) - { + public static IQuadTransformer settingEmissivity(int emissivity) { Preconditions.checkArgument(emissivity >= 0 && emissivity < 16, "Emissivity must be between 0 and 15."); return EMISSIVE_TRANSFORMERS[emissivity]; } @@ -114,8 +109,7 @@ public final class QuadTransformers { /** * @return A {@link BakedQuad} transformer that sets the lightmap to its max value */ - public static IQuadTransformer settingMaxEmissivity() - { + public static IQuadTransformer settingMaxEmissivity() { return EMISSIVE_TRANSFORMERS[15]; } @@ -123,13 +117,15 @@ public final class QuadTransformers { * @param color The color in ARGB format. * @return A {@link BakedQuad} transformer that sets the color to the specified value. */ - public static IQuadTransformer applyingColor(int color) - { + public static IQuadTransformer applyingColor(int color) { final int fixedColor = toABGR(color); return quad -> { - var vertices = quad.getVertices(); + var vertices = Arrays.copyOf(quad.vertices(), quad.vertices().length); + for (int i = 0; i < 4; i++) vertices[i * IQuadTransformer.STRIDE + IQuadTransformer.COLOR] = fixedColor; + + return new BakedQuad(vertices, quad.tintIndex(), quad.direction(), quad.sprite(), quad.shade(), quad.lightEmission(), quad.ambientOcclusion()); }; } @@ -140,8 +136,7 @@ public final class QuadTransformers { * @param blue The blue value (0-255) * @return A {@link BakedQuad} transformer that sets the color to the specified value. */ - public static IQuadTransformer applyingColor(int red, int green, int blue) - { + public static IQuadTransformer applyingColor(int red, int green, int blue) { return applyingColor(255, red, green, blue); } @@ -152,8 +147,7 @@ public final class QuadTransformers { * @param blue The blue value (0-255) * @return A {@link BakedQuad} transformer that sets the color to the specified value. */ - public static IQuadTransformer applyingColor(int alpha, int red, int green, int blue) - { + public static IQuadTransformer applyingColor(int alpha, int red, int green, int blue) { return applyingColor(alpha << 24 | red << 16 | green << 8 | blue); } @@ -163,14 +157,11 @@ public final class QuadTransformers { * @param argb ARGB color * @return ABGR color */ - public static int toABGR(int argb) - { + public static int toABGR(int argb) { return (argb & 0xFF00FF00) // alpha and green same spot | ((argb >> 16) & 0x000000FF) // red moves to blue | ((argb << 16) & 0x00FF0000); // blue moves to red } - private QuadTransformers() - { - } + private QuadTransformers() { } } diff --git a/src/main/java/net/minecraftforge/client/model/SeparateTransformsModel.java b/src/main/java/net/minecraftforge/client/model/SeparateTransformsModel.java deleted file mode 100644 index 262b3cfc2f..0000000000 --- a/src/main/java/net/minecraftforge/client/model/SeparateTransformsModel.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonObject; -import com.mojang.blaze3d.vertex.PoseStack; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.BlockModel; -import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.renderer.block.model.TextureSlots; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.BakedModel; -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.util.GsonHelper; -import net.minecraft.util.RandomSource; -import net.minecraft.world.item.ItemDisplayContext; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.ChunkRenderTypeSet; -import net.minecraftforge.client.model.data.ModelData; -import net.minecraftforge.client.model.geometry.IGeometryBakingContext; -import net.minecraftforge.client.model.geometry.IGeometryLoader; -import net.minecraftforge.client.model.geometry.IUnbakedGeometry; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * A model composed of multiple sub-models which are picked based on the {@link ItemDisplayContext} being used. - */ -public class SeparateTransformsModel implements IUnbakedGeometry { - private final BlockModel baseModel; - private final ImmutableMap perspectives; - - public SeparateTransformsModel(BlockModel baseModel, ImmutableMap perspectives) { - this.baseModel = baseModel; - this.perspectives = perspectives; - } - - - @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, TextureSlots textures, ModelState modelState) { - return new Baked( - context.useAmbientOcclusion(), - context.isGui3d(), - context.useBlockLight(), - baker.sprites().maybeMissing(textures, "particle"), - baseModel.bake(textures, baker, modelState), - ImmutableMap.copyOf(Maps.transformValues(perspectives, value -> { - return value.bake(textures, baker, modelState, context.useBlockLight(), value.getGuiLight().lightLikeBlock(), value.getTransforms()); - })) - ); - } - - @Override - public void resolveDependencies(UnbakedModel.Resolver resolver, IGeometryBakingContext context) { - baseModel.resolveDependencies(resolver); - perspectives.values().forEach(model -> model.resolveDependencies(resolver)); - } - - public static class Baked implements IDynamicBakedModel { - private final boolean isAmbientOcclusion; - private final boolean isGui3d; - private final boolean isSideLit; - private final TextureAtlasSprite particle; - private final BakedModel baseModel; - private final 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.baseModel = baseModel; - this.perspectives = perspectives; - } - - @NotNull - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData data, @Nullable RenderType renderType) { - return baseModel.getQuads(state, side, rand, data, renderType); - } - - @Override - public boolean useAmbientOcclusion() { - return isAmbientOcclusion; - } - - @Override - public boolean isGui3d() { - return isGui3d; - } - - @Override - public boolean usesBlockLight() { - return isSideLit; - } - - @Override - public TextureAtlasSprite getParticleIcon() { - return particle; - } - - @Override - public ItemTransforms getTransforms() { - return ItemTransforms.NO_TRANSFORMS; - } - - @Override - public BakedModel applyTransform(ItemDisplayContext cameraTransformType, PoseStack poseStack, boolean applyLeftHandTransform) { - if (perspectives.containsKey(cameraTransformType)) { - BakedModel p = perspectives.get(cameraTransformType); - return p.applyTransform(cameraTransformType, poseStack, applyLeftHandTransform); - } - return baseModel.applyTransform(cameraTransformType, poseStack, applyLeftHandTransform); - } - - @Override - public ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) { - return baseModel.getRenderTypes(state, rand, data); - } - } - - public static final class Loader implements IGeometryLoader { - public static final Loader INSTANCE = new Loader(); - - private Loader() { } - - @Override - public SeparateTransformsModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) { - BlockModel baseModel = deserializationContext.deserialize(GsonHelper.getAsJsonObject(jsonObject, "base"), BlockModel.class); - - JsonObject perspectiveData = GsonHelper.getAsJsonObject(jsonObject, "perspectives"); - - Map perspectives = new HashMap<>(); - for (ItemDisplayContext transform : ItemDisplayContext.values()) { - if (perspectiveData.has(transform.getSerializedName())) { - BlockModel perspectiveModel = deserializationContext.deserialize(GsonHelper.getAsJsonObject(perspectiveData, transform.getSerializedName()), BlockModel.class); - perspectives.put(transform, perspectiveModel); - } - } - - return new SeparateTransformsModel(baseModel, ImmutableMap.copyOf(perspectives)); - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/SimpleModelState.java b/src/main/java/net/minecraftforge/client/model/SimpleModelState.java index e22f7cbc09..cf61c4fcf3 100644 --- a/src/main/java/net/minecraftforge/client/model/SimpleModelState.java +++ b/src/main/java/net/minecraftforge/client/model/SimpleModelState.java @@ -11,8 +11,4 @@ import net.minecraft.client.resources.model.ModelState; /** * Simple implementation of {@link ModelState}. */ -public record SimpleModelState(Transformation getRotation, boolean isUvLocked) implements ModelState { - public SimpleModelState(Transformation transformation) { - this(transformation, false); - } -} +public record SimpleModelState(Transformation transformation) implements ModelState {} diff --git a/src/main/java/net/minecraftforge/client/model/data/ModelData.java b/src/main/java/net/minecraftforge/client/model/data/ModelData.java index db529b5a2d..add17e3107 100644 --- a/src/main/java/net/minecraftforge/client/model/data/ModelData.java +++ b/src/main/java/net/minecraftforge/client/model/data/ModelData.java @@ -6,14 +6,9 @@ package net.minecraftforge.client.model.data; import com.google.common.base.Preconditions; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.core.BlockPos; +import net.minecraft.client.renderer.block.model.BlockModelPart; import net.minecraft.core.Direction; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Nullable; @@ -23,15 +18,14 @@ import java.util.Map; import java.util.Set; /** - * A container for data to be passed to {@link BakedModel} instances. + * A container for data to be passed to {@link BlockModelPart} instances. *

* All objects stored in here MUST BE IMMUTABLE OR THREAD-SAFE. * Properties will be accessed from another thread. * * @see ModelProperty * @see BlockEntity#getModelData() - * @see BakedModel#getQuads(BlockState, Direction, RandomSource, ModelData, RenderType) - * @see BakedModel#getModelData(BlockAndTintGetter, BlockPos, BlockState, ModelData) + * @see BlockModelPart#getQuads(Direction) */ public final class ModelData { public static final ModelData EMPTY = ModelData.builder().build(); diff --git a/src/main/java/net/minecraftforge/client/model/data/MultipartModelData.java b/src/main/java/net/minecraftforge/client/model/data/MultipartModelData.java index eafbb24be2..e237020272 100644 --- a/src/main/java/net/minecraftforge/client/model/data/MultipartModelData.java +++ b/src/main/java/net/minecraftforge/client/model/data/MultipartModelData.java @@ -5,7 +5,7 @@ package net.minecraftforge.client.model.data; -import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.BlockModelPart; import org.jetbrains.annotations.Nullable; import java.util.IdentityHashMap; @@ -15,15 +15,15 @@ public class MultipartModelData { public static final ModelProperty PROPERTY = new ModelProperty<>(); - private final Map partData; + private final Map partData; - private MultipartModelData(Map partData) + private MultipartModelData(Map partData) { this.partData = partData; } @Nullable - public ModelData get(BakedModel model) + public ModelData get(BlockModelPart model) { return partData.get(model); } @@ -35,7 +35,7 @@ public class MultipartModelData * @param model The model to get data for * @return The data for the part, or the one passed in if not found */ - public static ModelData resolve(ModelData modelData, BakedModel model) + public static ModelData resolve(ModelData modelData, BlockModelPart model) { var multipartData = modelData.get(PROPERTY); if (multipartData == null) @@ -51,9 +51,9 @@ public class MultipartModelData public static final class Builder { - private final Map partData = new IdentityHashMap<>(); + private final Map partData = new IdentityHashMap<>(); - public Builder with(BakedModel model, ModelData data) + public Builder with(BlockModelPart model, ModelData data) { partData.put(model, data); return this; diff --git a/src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java b/src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java index 4581f17d94..02730b824f 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java +++ b/src/main/java/net/minecraftforge/client/model/generators/ConfiguredModel.java @@ -16,7 +16,9 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ObjectArrays; import com.google.gson.JsonObject; +import com.mojang.math.Quadrant; import net.minecraft.client.resources.model.BlockModelRotation; +import net.minecraft.util.Mth; import net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder.PartBuilder; import net.minecraftforge.client.model.generators.VariantBlockStateBuilder.PartialBlockstate; import org.jetbrains.annotations.Nullable; @@ -126,7 +128,17 @@ public final class ConfiguredModel { } static void checkRotation(int rotationX, int rotationY) { - Preconditions.checkArgument(BlockModelRotation.by(rotationX, rotationY) != null, "Invalid model rotation x=%d, y=%d", rotationX, rotationY); + Preconditions.checkArgument(quadrantFromDeg(rotationX) == null || quadrantFromDeg(rotationY) == null, "Invalid model rotation x=%d, y=%d", rotationX, rotationY); + } + + static @Nullable Quadrant quadrantFromDeg(int degrees) { + return switch (Mth.positiveModulo(degrees, 360)) { + case 0 -> Quadrant.R0; + case 90 -> Quadrant.R90; + case 180 -> Quadrant.R180; + case 270 -> Quadrant.R270; + default -> null; + }; } static void checkWeight(int weight) { diff --git a/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java index de5007af61..b50f0d4d45 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java @@ -19,10 +19,10 @@ import com.google.common.base.Preconditions; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import com.mojang.math.Quadrant; import com.mojang.math.Transformation; import com.mojang.serialization.JsonOps; -import net.minecraft.client.renderer.block.model.BlockFaceUV; import net.minecraft.client.renderer.block.model.BlockElement; import net.minecraft.client.renderer.block.model.BlockElementFace; import net.minecraft.client.renderer.block.model.BlockElementRotation; @@ -40,6 +40,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.VisibleForTesting; import org.joml.Quaternionf; import org.joml.Vector3f; +import org.joml.Vector3fc; /** * General purpose model builder, contains all the commonalities between item @@ -313,18 +314,18 @@ public class ModelBuilder> extends ModelFile { JsonObject transform = new JsonObject(); ItemTransform vec = e.getValue(); if (vec.equals(ItemTransform.NO_TRANSFORM)) continue; - var hasRightRotation = !vec.rightRotation.equals(ItemTransform.Deserializer.DEFAULT_ROTATION); - if (!vec.translation.equals(ItemTransform.Deserializer.DEFAULT_TRANSLATION)) { - transform.add("translation", serializeVector3f(e.getValue().translation)); + var hasRightRotation = !vec.rightRotation().equals(ItemTransform.Deserializer.DEFAULT_ROTATION); + if (!vec.translation().equals(ItemTransform.Deserializer.DEFAULT_TRANSLATION)) { + transform.add("translation", serializeVector3f(e.getValue().translation())); } - if (!vec.rotation.equals(ItemTransform.Deserializer.DEFAULT_ROTATION)) { - transform.add(hasRightRotation ? "left_rotation" : "rotation", serializeVector3f(vec.rotation)); + if (!vec.rotation().equals(ItemTransform.Deserializer.DEFAULT_ROTATION)) { + transform.add(hasRightRotation ? "left_rotation" : "rotation", serializeVector3f(vec.rotation())); } - if (!vec.scale.equals(ItemTransform.Deserializer.DEFAULT_SCALE)) { - transform.add("scale", serializeVector3f(e.getValue().scale)); + if (!vec.scale().equals(ItemTransform.Deserializer.DEFAULT_SCALE)) { + transform.add("scale", serializeVector3f(e.getValue().scale())); } if (hasRightRotation) { - transform.add("right_rotation", serializeVector3f(vec.rightRotation)); + transform.add("right_rotation", serializeVector3f(vec.rightRotation())); } display.add(e.getKey().getSerializedName(), transform); } @@ -343,44 +344,44 @@ public class ModelBuilder> extends ModelFile { JsonArray elements = new JsonArray(); this.elements.stream().map(ElementBuilder::build).forEach(part -> { JsonObject partObj = new JsonObject(); - partObj.add("from", serializeVector3f(part.from)); - partObj.add("to", serializeVector3f(part.to)); + partObj.add("from", serializeVector3f(part.from())); + partObj.add("to", serializeVector3f(part.to())); - if (part.rotation != null) { + if (part.rotation() != null) { JsonObject rotation = new JsonObject(); - rotation.add("origin", serializeVector3f(part.rotation.origin())); - rotation.addProperty("axis", part.rotation.axis().getSerializedName()); - rotation.addProperty("angle", part.rotation.angle()); - if (part.rotation.rescale()) { - rotation.addProperty("rescale", part.rotation.rescale()); + rotation.add("origin", serializeVector3f(part.rotation().origin())); + rotation.addProperty("axis", part.rotation().axis().getSerializedName()); + rotation.addProperty("angle", part.rotation().angle()); + if (part.rotation().rescale()) { + rotation.addProperty("rescale", part.rotation().rescale()); } partObj.add("rotation", rotation); } - if (!part.shade) { - partObj.addProperty("shade", part.shade); + if (!part.shade()) { + partObj.addProperty("shade", part.shade()); } JsonObject faces = new JsonObject(); for (Direction dir : Direction.values()) { - BlockElementFace face = part.faces.get(dir); + BlockElementFace face = part.faces().get(dir); if (face == null) continue; JsonObject faceObj = new JsonObject(); faceObj.addProperty("texture", serializeLocOrKey(face.texture())); - if (!Arrays.equals(face.uv().uvs, part.uvsByFace(dir))) - faceObj.add("uv", new Gson().toJsonTree(face.uv().uvs)); + if (!face.uvs().equals(part.faces().get(dir).uvs())) + faceObj.add("uv", new Gson().toJsonTree(new float[]{face.uvs().minU(), face.uvs().minV(), face.uvs().maxU(), face.uvs().maxV()})); if (face.cullForDirection() != null) faceObj.addProperty("cullface", face.cullForDirection().getSerializedName()); - if (face.uv().rotation != 0) - faceObj.addProperty("rotation", face.uv().rotation); + if (face.rotation() != Quadrant.R0) + faceObj.addProperty("rotation", face.rotation().ordinal()); if (face.tintIndex() != -1) faceObj.addProperty("tintindex", face.tintIndex()); - if (face.data() != null && !ForgeFaceData.DEFAULT.equals(face.data())) + if (!ForgeFaceData.DEFAULT.equals(face.data())) faceObj.add("forge_data", ForgeFaceData.CODEC.encodeStart(JsonOps.INSTANCE, face.data()).result().get()); faces.add(dir.getSerializedName(), faceObj); } - if (!part.faces.isEmpty()) + if (!part.faces().isEmpty()) partObj.add("faces", faces); elements.add(partObj); }); @@ -407,7 +408,7 @@ public class ModelBuilder> extends ModelFile { return ResourceLocation.parse(tex).toString(); } - private JsonArray serializeVector3f(Vector3f vec) { + private JsonArray serializeVector3f(Vector3fc vec) { JsonArray ret = new JsonArray(); ret.add(serializeFloat(vec.x())); ret.add(serializeFloat(vec.y())); @@ -734,7 +735,8 @@ public class ModelBuilder> extends ModelFile { BlockElementFace build() { if (this.texture == null) throw new IllegalStateException("A model face must have a texture"); - return new BlockElementFace(cullface, tintindex, texture, new BlockFaceUV(uvs, rotation.rotation), this.data); + // TODO: [Forge][Rendering[[VEN] This is probably wrong, but it was BLAZING FAST!!! to write! + return new BlockElementFace(cullface, tintindex, texture, new BlockElementFace.UVs(uvs[0], uvs[1], uvs[2], uvs[3]), Quadrant.values()[rotation.rotation], this.data); } public ElementBuilder end() { return ElementBuilder.this; } diff --git a/src/main/java/net/minecraftforge/client/model/geometry/BlockGeometryBakingContext.java b/src/main/java/net/minecraftforge/client/model/geometry/BlockGeometryBakingContext.java deleted file mode 100644 index 3f440a2eed..0000000000 --- a/src/main/java/net/minecraftforge/client/model/geometry/BlockGeometryBakingContext.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.geometry; - -import com.mojang.math.Transformation; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; -import net.minecraft.client.renderer.block.model.BlockModel; -import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.renderer.block.model.TextureSlots; -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.resources.ResourceLocation; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - -/** - * A {@linkplain IGeometryBakingContext geometry baking context} that is bound to a {@link BlockModel}. - *

- * Users should not be instantiating this themselves. - */ -public class BlockGeometryBakingContext implements IGeometryBakingContext { - public final BlockModel owner; - public final VisibilityData visibilityData = new VisibilityData(); - @Nullable - private IUnbakedGeometry customGeometry; - @Nullable - private Transformation rootTransform; - @Nullable - private ResourceLocation renderTypeHint; - @Nullable - private ResourceLocation renderTypeFastHint; - private boolean gui3d = true; - - @ApiStatus.Internal - public BlockGeometryBakingContext(BlockModel owner) { - this.owner = owner; - } - - public boolean hasCustomGeometry() { - return getCustomGeometry() != null; - } - - private BlockGeometryBakingContext parentContext() { - return owner.parent instanceof BlockModel block ? block.customData : null; - } - - @Nullable - public IUnbakedGeometry getCustomGeometry() { - if (customGeometry != null) - return customGeometry; - var pctx = parentContext(); - return pctx == null ? null : pctx.getCustomGeometry(); - } - - public void setCustomGeometry(IUnbakedGeometry geometry) { - this.customGeometry = geometry; - } - - @Override - public boolean isComponentVisible(String part, boolean fallback) { - var pctx = parentContext(); - if (pctx == null || visibilityData.hasCustomVisibility(part)) - return visibilityData.isVisible(part, fallback); - return pctx.isComponentVisible(part, fallback); - } - - @Override - public boolean isGui3d() { - return gui3d; - } - - @Override - public boolean useBlockLight() { - return owner.getGuiLight().lightLikeBlock(); - } - - @Override - public boolean useAmbientOcclusion() { - return owner.getAmbientOcclusion(); - } - - @Override - public ItemTransforms getTransforms() { - return owner.getTransforms(); - } - - @Override - public Transformation getRootTransform() { - if (rootTransform != null) - return rootTransform; - var pctx = parentContext(); - return pctx == null ? Transformation.identity() : pctx.getRootTransform(); - } - - public void setRootTransform(Transformation rootTransform) { - this.rootTransform = rootTransform; - } - - @Nullable - @Override - public ResourceLocation getRenderTypeHint() { - if (renderTypeHint != null) - return renderTypeHint; - var pctx = parentContext(); - return pctx == null ? null: pctx.getRenderTypeHint(); - } - - @Nullable - @Override - public ResourceLocation getRenderTypeFastHint() { - if (renderTypeFastHint != null) - return renderTypeFastHint; - var pctx = parentContext(); - return pctx == null ? null: pctx.getRenderTypeFastHint(); - } - - public void setRenderTypeHint(ResourceLocation renderTypeHint) { - this.renderTypeHint = renderTypeHint; - } - - public void setRenderTypeFastHint(ResourceLocation renderTypeFastHint) { - this.renderTypeFastHint = renderTypeFastHint; - } - - public void setGui3d(boolean gui3d) { - this.gui3d = gui3d; - } - - public void copyFrom(BlockGeometryBakingContext other) { - this.customGeometry = other.customGeometry; - this.rootTransform = other.rootTransform; - this.visibilityData.copyFrom(other.visibilityData); - this.renderTypeHint = other.renderTypeHint; - this.renderTypeFastHint = other.renderTypeFastHint; - this.gui3d = other.gui3d; - } - - public BakedModel bake(ModelBaker baker, TextureSlots textures, ModelState modelTransform) { - IUnbakedGeometry geometry = getCustomGeometry(); - if (geometry == null) - throw new IllegalStateException("Can not use custom baking without custom geometry"); - return geometry.bake(this, baker, textures, modelTransform); - } - - public static class VisibilityData { - private final Map data = new HashMap<>(); - - public boolean hasCustomVisibility(String part) { - return data.containsKey(part); - } - - public boolean isVisible(String part, boolean fallback) { - return data.getOrDefault(part, fallback); - } - - public void setVisibilityState(String partName, boolean type) { - data.put(partName, type); - } - - public void copyFrom(VisibilityData visibilityData) { - data.clear(); - data.putAll(visibilityData.data); - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java b/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java index cf76e90b5f..34e53f833d 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/GeometryLoaderManager.java @@ -21,14 +21,14 @@ import java.util.stream.Collectors; * Provides a lookup. */ public final class GeometryLoaderManager { - private static ImmutableMap> LOADERS; + private static ImmutableMap LOADERS; private static String LOADER_LIST; /** * Finds the {@link IGeometryLoader} for a given name, or null if not found. */ @Nullable - public static IGeometryLoader get(ResourceLocation name) { + public static IGeometryLoader get(ResourceLocation name) { return LOADERS.get(name); } @@ -41,7 +41,7 @@ public final class GeometryLoaderManager { @ApiStatus.Internal public static void init() { - var loaders = new HashMap>(); + var loaders = new HashMap(); var event = new ModelEvent.RegisterGeometryLoaders(loaders); ModLoader.get().postEventWrapContainerInModOrder(event); LOADERS = ImmutableMap.copyOf(loaders); diff --git a/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java b/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java index 065c32162b..bb9524a212 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/IGeometryBakingContext.java @@ -19,7 +19,6 @@ import org.jetbrains.annotations.Nullable; * {@linkplain RenderTypeGroup render types}. * * @see StandaloneGeometryBakingContext - * @see BlockGeometryBakingContext */ public interface IGeometryBakingContext { /** diff --git a/src/main/java/net/minecraftforge/client/model/geometry/IGeometryLoader.java b/src/main/java/net/minecraftforge/client/model/geometry/IGeometryLoader.java index 044e642fcb..bd86730144 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/IGeometryLoader.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/IGeometryLoader.java @@ -8,12 +8,14 @@ package net.minecraftforge.client.model.geometry; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; + +import net.minecraft.client.resources.model.UnbakedGeometry; import net.minecraft.server.packs.resources.ResourceManagerReloadListener; import net.minecraftforge.client.event.ModelEvent.RegisterGeometryLoaders; import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; /** - * A loader for custom {@linkplain IUnbakedGeometry model geometries}. + * A loader for custom {@linkplain UnbakedGeometry model geometries}. *

* If you do any caching, you should implement {@link ResourceManagerReloadListener} and register it with * {@link RegisterClientReloadListenersEvent}. @@ -21,6 +23,6 @@ import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; * @see RegisterGeometryLoaders * @see RegisterClientReloadListenersEvent */ -public interface IGeometryLoader> { - T read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) throws JsonParseException; +public interface IGeometryLoader { + UnbakedGeometry read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) throws JsonParseException; } diff --git a/src/main/java/net/minecraftforge/client/model/geometry/IUnbakedGeometry.java b/src/main/java/net/minecraftforge/client/model/geometry/IUnbakedGeometry.java index 568f6049db..f849d41281 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/IUnbakedGeometry.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/IUnbakedGeometry.java @@ -6,13 +6,13 @@ package net.minecraftforge.client.model.geometry; import java.util.Set; -import java.util.function.Function; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.TextureSlots; -import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.renderer.block.model.BlockModelPart; import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.ResolvableModel; import net.minecraft.client.resources.model.UnbakedModel; /** @@ -24,14 +24,14 @@ import net.minecraft.client.resources.model.UnbakedModel; * @see IGeometryBakingContext */ public interface IUnbakedGeometry> { - BakedModel bake(IGeometryBakingContext context, ModelBaker baker, TextureSlots spriteGetter, ModelState modelState); + BlockModelPart bake(IGeometryBakingContext context, ModelBaker baker, TextureSlots spriteGetter, ModelState modelState); /** * Resolve parents of nested {@link BlockModel}s which are later used in * {@link IUnbakedGeometry#bake(IGeometryBakingContext, ModelBaker, TextureSlots, ModelState)} * via {@link BlockModel#resolveParents(Function)} */ - default void resolveDependencies(UnbakedModel.Resolver resolver, IGeometryBakingContext context) { } + default void resolveDependencies(ResolvableModel.Resolver resolver, IGeometryBakingContext context) { } /** * {@return a set of all the components whose visibility may be configured via {@link IGeometryBakingContext}} diff --git a/src/main/java/net/minecraftforge/client/model/geometry/ModelContext.java b/src/main/java/net/minecraftforge/client/model/geometry/ModelContext.java new file mode 100644 index 0000000000..8e9c108b27 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/geometry/ModelContext.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.client.model.geometry; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +import com.mojang.math.Transformation; + +import net.minecraft.client.renderer.block.model.BlockModel; +import net.minecraft.client.renderer.block.model.ItemTransforms; +import net.minecraft.client.resources.model.ModelDiscovery.ModelWrapper; +import net.minecraft.client.resources.model.ResolvedModel; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.client.model.ForgeBlockModelData; + +@ApiStatus.Internal +public record ModelContext( + ResolvedModel self, + ResolvedModel parent, + @Nullable ForgeBlockModelData data, + boolean gui3d +) implements IGeometryBakingContext { + public ModelContext(ResolvedModel self) { + this(self, self.parent(), makeData(self, self.parent()), true); + } + + private static ForgeBlockModelData makeData(ResolvedModel self, ResolvedModel parent) { + var data = self.wrapped() instanceof BlockModel block ? block.forgeData() : null; + + var p = parent; + while (p != null && (data == null || !data.full())) { + if (p.wrapped() instanceof BlockModel block) { + if (data == null) + data = block.forgeData(); + else + data = data.merge(block.forgeData()); + } + p = (ModelWrapper)p.parent(); + } + + return data; + } + + @Override + public boolean isGui3d() { + return gui3d; + } + + public ModelContext withGui3d(boolean value) { + return new ModelContext(self, parent, data, value); + } + + @Override + public boolean useBlockLight() { + var value = self.wrapped().guiLight(); + return value != null && value.lightLikeBlock(); + } + + @Override + public boolean useAmbientOcclusion() { + return Boolean.TRUE.equals(self.wrapped().ambientOcclusion()); + } + + @Override + public ItemTransforms getTransforms() { + return self.wrapped().transforms(); + } + + @Override + public Transformation getRootTransform() { + return data == null ? Transformation.identity() : data.transform().orElse(Transformation.identity()); + } + + @Override + public @Nullable ResourceLocation getRenderTypeHint() { + return data == null ? null : data.renderType().orElse(null); + } + + @Override + public boolean isComponentVisible(String component, boolean fallback) { + if (data == null || data.visibility().isEmpty()) + return fallback; + return data.visibility().get().getOrDefault(component, fallback); + } +} diff --git a/src/main/java/net/minecraftforge/client/model/geometry/SimpleUnbakedGeometry.java b/src/main/java/net/minecraftforge/client/model/geometry/SimpleUnbakedGeometry.java deleted file mode 100644 index 95386a8d72..0000000000 --- a/src/main/java/net/minecraftforge/client/model/geometry/SimpleUnbakedGeometry.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.geometry; - -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.TextureSlots; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.ModelBaker; -import net.minecraft.client.resources.model.ModelState; -import net.minecraftforge.client.RenderTypeGroup; -import net.minecraftforge.client.model.IModelBuilder; - -/** - * Base class for implementations of {@link IUnbakedGeometry} which do not wish to handle model creation themselves, - * instead supplying {@linkplain BakedQuad baked quads} through a builder. - */ -public abstract class SimpleUnbakedGeometry> implements IUnbakedGeometry { - @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, TextureSlots textures, ModelState modelState) { - var particle = baker.sprites().maybeMissing(textures, "particle"); - - IModelBuilder builder = IModelBuilder.of(context.useAmbientOcclusion(), context.useBlockLight(), context.isGui3d(), - context.getTransforms(), particle, context.getRenderType(), context.getRenderTypeFast()); - - addQuads(context, builder, baker, textures, modelState); - - return builder.build(); - } - - protected abstract void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, TextureSlots textures, ModelState modelTransform); -} diff --git a/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java b/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java index 420468a7ff..7324076e2f 100644 --- a/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java +++ b/src/main/java/net/minecraftforge/client/model/geometry/UnbakedGeometryHelper.java @@ -5,12 +5,12 @@ package net.minecraftforge.client.model.geometry; +import com.mojang.math.Quadrant; import com.mojang.math.Transformation; import net.minecraft.Util; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockElement; import net.minecraft.client.renderer.block.model.BlockElementFace; -import net.minecraft.client.renderer.block.model.BlockFaceUV; import net.minecraft.client.renderer.block.model.FaceBakery; import net.minecraft.client.renderer.block.model.ItemModelGenerator; import net.minecraft.client.renderer.block.model.TextureSlots; @@ -20,10 +20,9 @@ import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.QuadCollection; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.inventory.InventoryMenu; -import net.minecraftforge.client.model.IModelBuilder; import net.minecraftforge.client.model.IQuadTransformer; import net.minecraftforge.client.model.QuadTransformers; import net.minecraftforge.client.model.SimpleModelState; @@ -32,9 +31,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import org.joml.Vector3f; -import java.util.ArrayList; import java.util.BitSet; -import java.util.HashMap; import java.util.List; import java.util.function.Function; import java.util.regex.Matcher; @@ -45,8 +42,6 @@ import java.util.regex.Pattern; */ @ApiStatus.Internal public class UnbakedGeometryHelper { - private static final FaceBakery FACE_BAKERY = new FaceBakery(); - /** * Explanation: * This takes anything that looks like a valid resourcepack texture location, and tries to extract a resourcelocation out of it. @@ -64,14 +59,17 @@ public class UnbakedGeometryHelper { private static final Pattern FILESYSTEM_PATH_TO_RESLOC = Pattern.compile("(?:.*[\\\\/]assets[\\\\/](?[a-z_-]+)[\\\\/]textures[\\\\/])?(?[a-z_\\\\/-]+)\\.png"); + private static final Material MISSING_MATERIAL = getMaterial(MissingTextureAtlasSprite.getLocation().toString()); + /** * Resolves a material that may have been defined with a filesystem path instead of a proper {@link ResourceLocation}. *

- * The target atlas will always be {@link InventoryMenu#BLOCK_ATLAS}. + * The target atlas will always be {@link TextureAtlas#LOCATION_BLOCKS}. */ public static Material resolveDirtyMaterial(@Nullable String tex, TextureSlots textures) { if (tex == null) - return new Material(TextureAtlas.LOCATION_BLOCKS, MissingTextureAtlasSprite.getLocation()); + return MISSING_MATERIAL; + if (tex.startsWith("#")) return textures.getMaterial(tex); @@ -84,10 +82,9 @@ public class UnbakedGeometryHelper { tex = namespace != null ? namespace + ":" + path : path; } - return new Material(TextureAtlas.LOCATION_BLOCKS, ResourceLocation.parse(tex)); + return getMaterial(tex); } - private static final ItemModelGenerator ITEM_MODEL_GENERATOR = new ItemModelGenerator(); /** * Creates a list of {@linkplain BlockElement block elements} in the shape of the specified sprite contents. * These can later be baked using the same, or another texture. @@ -95,7 +92,7 @@ public class UnbakedGeometryHelper { * The {@link Direction#NORTH} and {@link Direction#SOUTH} faces take up the whole surface. */ public static List createUnbakedItemElements(int layerIndex, SpriteContents spriteContents) { - return ITEM_MODEL_GENERATOR.processFrames(layerIndex, "layer" + layerIndex, spriteContents); + return ItemModelGenerator.processFrames(layerIndex, "layer" + layerIndex, spriteContents); } /** @@ -146,12 +143,9 @@ public class UnbakedGeometryHelper { // Create element elements.add(new BlockElement( - new Vector3f(16 * xStart / (float) width, 16 - 16 * yEnd / (float) height, 7.5F), - new Vector3f(16 * x / (float) width, 16 - 16 * y / (float) height, 8.5F), - Util.make(new HashMap<>(), map -> { - for (Direction direction : Direction.values()) - map.put(direction, new BlockElementFace(null, layerIndex, "layer" + layerIndex, new BlockFaceUV(null, 0))); - }) + new Vector3f(16 * xStart / (float) width, 16 - 16 * yEnd / (float) height, 7.5F), + new Vector3f(16 * x / (float) width, 16 - 16 * y / (float) height, 8.5F), + Util.makeEnumMap(Direction.class, dir -> new BlockElementFace(dir, layerIndex, "layer" + layerIndex, new BlockElementFace.UVs(0F, 0F, 16F, 16F), Quadrant.R0)) )); // Reset xStart @@ -163,37 +157,54 @@ public class UnbakedGeometryHelper { } /** - * Bakes a list of {@linkplain BlockElement block elements} and feeds the baked quads to a {@linkplain IModelBuilder model builder}. + * Bakes a list of {@linkplain BlockElement block elements} and returns a {@link QuadCollection}. */ - public static void bakeElements(IModelBuilder builder, List elements, Function spriteGetter, ModelState modelState) { - 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, element.lightEmission); + public static QuadCollection bakeElements(List elements, Function spriteGetter, ModelState modelState) { + return bakeElements(elements, spriteGetter, modelState, QuadTransformers.empty()); + } + + /** + * Bakes a list of {@linkplain BlockElement block elements} and returns a {@link QuadCollection}. + */ + public static QuadCollection bakeElements(List elements, Function spriteGetter, ModelState modelState, IQuadTransformer transformer) { + var builder = new QuadCollection.Builder(); + bakeElements(elements, spriteGetter, modelState, builder); + return builder.build(); + } + + /** + * Adds a list of {@linkplain BlockElement block elements} int a {@link QuadCollection.Builder}. + */ + public static void bakeElements(List elements, Function spriteGetter, ModelState modelState, QuadCollection.Builder builder) { + bakeElements(elements, spriteGetter, modelState, QuadTransformers.empty(), builder); + } + + /** + * Adds a list of {@linkplain BlockElement block elements} int a {@link QuadCollection.Builder}. + */ + public static void bakeElements(List elements, Function spriteGetter, ModelState modelState, IQuadTransformer transformer, QuadCollection.Builder builder) { + for (var element : elements) { + element.faces().forEach((side, face) -> { + var sprite = spriteGetter.apply(getMaterial(face.texture())); + var quad = bakeElementFace(element, face, sprite, side, modelState, element.lightEmission()); if (face.cullForDirection() == null) builder.addUnculledFace(quad); else - builder.addCulledFace(Direction.rotate(modelState.getRotation().getMatrix(), face.cullForDirection()), quad); + builder.addCulledFace(Direction.rotate(modelState.transformation().getMatrix(), face.cullForDirection()), quad); }); } } - /** - * Bakes a list of {@linkplain BlockElement block elements} and returns the list of baked quads. - */ - public static List bakeElements(List elements, Function spriteGetter, ModelState modelState) { - if (elements.isEmpty()) - return List.of(); - var list = new ArrayList(); - bakeElements(IModelBuilder.collecting(list), elements, spriteGetter, modelState); - return list; + @SuppressWarnings("deprecation") + private static Material getMaterial(String texture) { + return new Material(TextureAtlas.LOCATION_BLOCKS, ResourceLocation.parse(texture)); } /** * Turns a single {@link BlockElementFace} into a {@link BakedQuad}. */ public static BakedQuad bakeElementFace(BlockElement element, BlockElementFace face, TextureAtlasSprite sprite, Direction direction, ModelState state, int lightEmission) { - return FACE_BAKERY.bakeQuad(element.from, element.to, face, sprite, direction, state, element.rotation, element.shade, lightEmission); + return FaceBakery.bakeQuad(element.from(), element.to(), face, sprite, direction, state, element.rotation(), element.shade(), lightEmission); } /** @@ -208,7 +219,7 @@ public class UnbakedGeometryHelper { // 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)); + Transformation transform = modelState.transformation().applyOrigin(new Vector3f(.5F, .5F, .5F)); return QuadTransformers.applying(transform.compose(rootTransform).compose(transform.inverse())); } @@ -219,6 +230,6 @@ public class UnbakedGeometryHelper { // Move the origin of the root transform as if the negative corner were the block center to match the way the // ModelState transform is applied in the FaceBakery by moving the vertices to be centered on that corner rootTransform = rootTransform.applyOrigin(new Vector3f(-.5F, -.5F, -.5F)); - return new SimpleModelState(modelState.getRotation().compose(rootTransform), modelState.isUvLocked()); + return new SimpleModelState(modelState.transformation().compose(rootTransform)); } } diff --git a/src/main/java/net/minecraftforge/client/model/lighting/FlatQuadLighter.java b/src/main/java/net/minecraftforge/client/model/lighting/FlatQuadLighter.java deleted file mode 100644 index 94d54499f5..0000000000 --- a/src/main/java/net/minecraftforge/client/model/lighting/FlatQuadLighter.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.lighting; - -import net.minecraft.client.color.block.BlockColors; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; - -/** - * Implementation of {@link QuadLighter} that lights {@link BakedQuad quads} with flat lighting. - */ -public class FlatQuadLighter extends QuadLighter -{ - private static final Direction[] SIDES = Direction.values(); - - private static final float MAX_POSITION = 1f - 1e-2f; - private static final byte MAX_NORMAL = 127; - - private boolean isFullCube; - private final int[] packedLight = new int[7]; - - public FlatQuadLighter(BlockColors colors) - { - super(colors); - } - - @Override - protected void computeLightingAt(BlockAndTintGetter level, BlockPos pos, BlockState state) - { - isFullCube = Block.isShapeFullBlock(state.getCollisionShape(level, pos)); - for (Direction side : SIDES) - { - packedLight[side.ordinal()] = LevelRenderer.getLightColor(level, state, pos.relative(side)); - } - //Note: We can just use the LevelRenderer method as we know the state is the state at the given position - packedLight[6] = LevelRenderer.getLightColor(level, state, pos); - } - - @Override - protected float calculateBrightness(float[] position) - { - return 1.0f; // No shading in flat lighting - } - - @Override - protected int calculateLightmap(float[] position, byte[] normal) - { - if ((isFullCube || position[1] < -MAX_POSITION) && normal[1] <= -MAX_NORMAL) - return packedLight[Direction.DOWN.ordinal()]; - - if ((isFullCube || position[1] > MAX_POSITION) && normal[1] >= MAX_NORMAL) - return packedLight[Direction.UP.ordinal()]; - - if ((isFullCube || position[2] < -MAX_POSITION) && normal[2] <= -MAX_NORMAL) - return packedLight[Direction.NORTH.ordinal()]; - - if ((isFullCube || position[2] > MAX_POSITION) && normal[2] >= MAX_NORMAL) - return packedLight[Direction.SOUTH.ordinal()]; - - if ((isFullCube || position[0] < -MAX_POSITION) && normal[0] <= -MAX_NORMAL) - return packedLight[Direction.WEST.ordinal()]; - - if ((isFullCube || position[0] > MAX_POSITION) && normal[0] >= MAX_NORMAL) - return packedLight[Direction.EAST.ordinal()]; - - return packedLight[6]; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/lighting/ForgeModelBlockRenderer.java b/src/main/java/net/minecraftforge/client/model/lighting/ForgeModelBlockRenderer.java deleted file mode 100644 index 6aa86a7faa..0000000000 --- a/src/main/java/net/minecraftforge/client/model/lighting/ForgeModelBlockRenderer.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.lighting; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.Minecraft; -import net.minecraft.client.color.block.BlockColors; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.block.ModelBlockRenderer; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.model.data.ModelData; -import net.minecraftforge.common.ForgeConfig; - -import java.util.List; - -/** - * Wrapper around {@link ModelBlockRenderer} to allow rendering blocks via Forge's lighting pipeline. - */ -public class ForgeModelBlockRenderer extends ModelBlockRenderer { - private static final Direction[] SIDES = Direction.values(); - - private final ThreadLocal flatLighter, smoothLighter; - - public ForgeModelBlockRenderer(BlockColors colors) { - super(colors); - this.flatLighter = ThreadLocal.withInitial(() -> new FlatQuadLighter(colors)); - this.smoothLighter = ThreadLocal.withInitial(() -> new SmoothQuadLighter(colors)); - } - - @Override - public void tesselateWithoutAO(BlockAndTintGetter level, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, VertexConsumer vertexConsumer, boolean checkSides, RandomSource rand, long seed, int packedOverlay, ModelData modelData, RenderType renderType) { - if (ForgeConfig.CLIENT.experimentalForgeLightPipelineEnabled.get()) - render(vertexConsumer, flatLighter.get(), level, model, state, pos, poseStack, checkSides, rand, seed, packedOverlay, modelData, renderType); - else - super.tesselateWithoutAO(level, model, state, pos, poseStack, vertexConsumer, checkSides, rand, seed, packedOverlay, modelData, renderType); - } - - @Override - public void tesselateWithAO(BlockAndTintGetter level, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, VertexConsumer vertexConsumer, boolean checkSides, RandomSource rand, long seed, int packedOverlay, ModelData modelData, RenderType renderType) { - if (ForgeConfig.CLIENT.experimentalForgeLightPipelineEnabled.get()) - render(vertexConsumer, smoothLighter.get(), level, model, state, pos, poseStack, checkSides, rand, seed, packedOverlay, modelData, renderType); - else - super.tesselateWithAO(level, model, state, pos, poseStack, vertexConsumer, checkSides, rand, seed, packedOverlay, modelData, renderType); - } - - public static boolean render(VertexConsumer vertexConsumer, QuadLighter lighter, BlockAndTintGetter level, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, boolean checkSides, RandomSource rand, long seed, int packedOverlay, ModelData modelData, RenderType renderType) { - ForgeModelBlockRenderer renderer = (ForgeModelBlockRenderer)Minecraft.getInstance().getBlockRenderer().getModelRenderer(); - var pose = poseStack.last(); - var empty = true; - var smoothLighter = lighter instanceof SmoothQuadLighter; - QuadLighter flatLighter = null; - - rand.setSeed(seed); - List quads = model.getQuads(state, null, rand, modelData, renderType); - if (!quads.isEmpty()) { - empty = false; - lighter.setup(level, pos, state); - for (BakedQuad quad : quads) { - if (smoothLighter && !quad.hasAmbientOcclusion()) { - if (flatLighter == null) { - flatLighter = renderer.flatLighter.get(); - flatLighter.setup(level, pos, state); - } - flatLighter.process(vertexConsumer, pose, quad, packedOverlay); - } else { - lighter.process(vertexConsumer, pose, quad, packedOverlay); - } - } - } - var mutable = pos.mutable(); - - for (Direction side : SIDES) { - mutable.setWithOffset(pos, side); - if (checkSides && !Block.shouldRenderFace(level, pos, state, level.getBlockState(mutable), side)) - continue; - rand.setSeed(seed); - quads = model.getQuads(state, side, rand, modelData, renderType); - if (!quads.isEmpty()) { - if (empty) { - empty = false; - lighter.setup(level, pos, state); - } - - for (BakedQuad quad : quads) { - if (smoothLighter && !quad.hasAmbientOcclusion()) { - if (flatLighter == null) { - flatLighter = renderer.flatLighter.get(); - flatLighter.setup(level, pos, state); - } - flatLighter.process(vertexConsumer, pose, quad, packedOverlay); - } else { - lighter.process(vertexConsumer, pose, quad, packedOverlay); - } - } - } - } - - lighter.reset(); - if (flatLighter != null) - flatLighter.reset(); - - return !empty; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/lighting/QuadLighter.java b/src/main/java/net/minecraftforge/client/model/lighting/QuadLighter.java deleted file mode 100644 index 4bc200be75..0000000000 --- a/src/main/java/net/minecraftforge/client/model/lighting/QuadLighter.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.lighting; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.color.block.BlockColors; -import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.LightLayer; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.model.IQuadTransformer; - -import org.joml.Vector3f; - -import java.util.Objects; - -/** - * Base class for all quad lighting providers. - *

- * Contains all the shared elements needed for {@link BakedQuad} processing and defers lighting logic to inheritors. - * - * @see FlatQuadLighter - * @see SmoothQuadLighter - */ -public abstract class QuadLighter -{ - private static final float[] WHITE = new float[] { 1.0f, 1.0f, 1.0f }; - - private final BlockColors colors; - - private int currentHash = 0; - private BlockAndTintGetter level; - private BlockPos pos; - private BlockState state; - private int cachedTintIndex = -1; - private final float[] cachedTintColor = new float[3]; - - // Arrays used for quad processing, initialized once and then used repeatedly to avoid GC pressure - private final float[] brightness = new float[4]; - private final int[] lightmap = new int[4]; - private final float[][] positions = new float[4][3]; - private final byte[][] normals = new byte[4][3]; - private final int[] packedLightmaps = new int[4]; - - protected QuadLighter(BlockColors colors) - { - this.colors = colors; - } - - protected abstract void computeLightingAt(BlockAndTintGetter level, BlockPos pos, BlockState state); - - protected abstract float calculateBrightness(float[] position); - - protected abstract int calculateLightmap(float[] position, byte[] normal); - - public final void setup(BlockAndTintGetter level, BlockPos pos, BlockState state) - { - var hash = Objects.hash(level, pos, state); - if (this.level != null && this.currentHash == hash) - { - return; // If we are drawing a block at the same position as before, don't re-compute anything - } - this.currentHash = hash; - this.level = level; - this.pos = pos; - this.state = state; - this.cachedTintIndex = -1; - computeLightingAt(level, pos, state); - } - - public final void reset() - { - this.level = null; // Invalidates part of the state to force a re-computation - } - - public final void process(VertexConsumer consumer, PoseStack.Pose pose, BakedQuad quad, int overlay) - { - var vertices = quad.getVertices(); - for (int i = 0; i < 4; i++) - { - int offset = i * IQuadTransformer.STRIDE; - positions[i][0] = Float.intBitsToFloat(vertices[offset + IQuadTransformer.POSITION]); - positions[i][1] = Float.intBitsToFloat(vertices[offset + IQuadTransformer.POSITION + 1]); - positions[i][2] = Float.intBitsToFloat(vertices[offset + IQuadTransformer.POSITION + 2]); - int packedNormal = vertices[offset + IQuadTransformer.NORMAL]; - normals[i][0] = (byte) (packedNormal & 0xFF); - normals[i][1] = (byte) ((packedNormal >> 8) & 0xFF); - normals[i][2] = (byte) ((packedNormal >> 16) & 0xFF); - packedLightmaps[i] = vertices[offset + IQuadTransformer.UV2]; - } - if (normals[0][0] == 0 && normals[0][1] == 0 && normals[0][2] == 0) - { - Vector3f a = new Vector3f(positions[0]); - Vector3f ab = new Vector3f(positions[1]); - Vector3f ac = new Vector3f(positions[2]); - ac.sub(a); - ab.sub(a); - ab.cross(ac); - ab.normalize(); - for (int v = 0; v < 4; v++) - { - normals[v][0] = (byte) (ab.x() * 127); - normals[v][1] = (byte) (ab.y() * 127); - normals[v][2] = (byte) (ab.z() * 127); - } - } - - for (int i = 0; i < 4; i++) - { - var position = positions[i]; - var normal = normals[i]; - int packedLightmap = packedLightmaps[i]; - - var adjustedPosition = new float[] { - position[0] - 0.5f + ((normal[0] / 127f) * 0.5f), - position[1] - 0.5f + ((normal[1] / 127f) * 0.5f), - position[2] - 0.5f + ((normal[2] / 127f) * 0.5f) - }; - - var shade = level.getShade(normals[i][0] / 127f, normals[i][1] / 127f, normals[i][2] / 127f, quad.isShade()); - brightness[i] = calculateBrightness(adjustedPosition) * shade; - int newLightmap = calculateLightmap(adjustedPosition, normal); - lightmap[i] = Math.max(packedLightmap & 0xFFFF, newLightmap & 0xFFFF) | - (Math.max((packedLightmap >> 16) & 0xFFFF, (newLightmap >> 16) & 0xFFFF) << 16); - } - - var color = quad.isTinted() ? getColorFast(quad.getTintIndex()) : WHITE; - consumer.putBulkData(pose, quad, brightness, color[0], color[1], color[2], 1.0f, lightmap, overlay, true); - } - - private float[] getColorFast(int tintIndex) - { - if (tintIndex != cachedTintIndex) - { - var packedColor = colors.getColor(state, level, pos, tintIndex); - cachedTintIndex = tintIndex; - cachedTintColor[0] = ((packedColor >> 16) & 0xFF) / 255F; - cachedTintColor[1] = ((packedColor >> 8) & 0xFF) / 255F; - cachedTintColor[2] = (packedColor & 0xFF) / 255F; - } - return cachedTintColor; - } - - public static float calculateShade(float normalX, float normalY, float normalZ, boolean constantAmbientLight) - { - float yFactor = constantAmbientLight ? 0.9F : ((3.0F + normalY) / 4.0F); - return Math.min(normalX * normalX * 0.6F + normalY * normalY * yFactor + normalZ * normalZ * 0.8F, 1.0F); - } -} diff --git a/src/main/java/net/minecraftforge/client/model/lighting/SmoothQuadLighter.java b/src/main/java/net/minecraftforge/client/model/lighting/SmoothQuadLighter.java deleted file mode 100644 index 75205260ac..0000000000 --- a/src/main/java/net/minecraftforge/client/model/lighting/SmoothQuadLighter.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.client.model.lighting; - -import net.minecraft.client.color.block.BlockColors; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.util.Mth; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.shapes.Shapes; - -/** - * Implementation of {@link QuadLighter} that lights {@link BakedQuad baked quads} using ambient occlusion and - * light interpolation. - */ -public class SmoothQuadLighter extends QuadLighter { - private static final Direction[] SIDES = Direction.values(); - - private final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); - private final boolean[][][] t = new boolean[3][3][3]; - private final int[][][] s = new int[3][3][3]; - private final int[][][] b = new int[3][3][3]; - private final float[][][][] skyLight = new float[3][2][2][2]; - private final float[][][][] blockLight = new float[3][2][2][2]; - private final float[][][] ao = new float[3][3][3]; - - public SmoothQuadLighter(BlockColors colors) { - super(colors); - } - - @Override - protected void computeLightingAt(BlockAndTintGetter level, BlockPos origin, BlockState state) { - for (int x = 0; x <= 2; x++) { - for (int y = 0; y <= 2; y++) { - 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() < 15; - int brightness = LevelRenderer.getLightColor(level, neighborState, pos); - s[x][y][z] = LightTexture.sky(brightness); - b[x][y][z] = LightTexture.block(brightness); - ao[x][y][z] = neighborState.getShadeBrightness(level, pos); - } - } - } - - for (Direction side : SIDES) { - pos.setWithOffset(origin, side); - BlockState neighborState = level.getBlockState(pos); - - BlockState thisStateShape = state.canOcclude() && state.useShapeForLightOcclusion() ? state : Blocks.AIR.defaultBlockState(); - BlockState otherStateShape = neighborState.canOcclude() && neighborState.useShapeForLightOcclusion() ? neighborState : Blocks.AIR.defaultBlockState(); - - 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; - s[x][y][z] = Math.max(s[1][1][1] - 1, s[x][y][z]); - b[x][y][z] = Math.max(b[1][1][1] - 1, b[x][y][z]); - } - } - - for (int x = 0; x < 2; x++) { - for (int y = 0; y < 2; y++) { - for (int z = 0; z < 2; z++) { - int x1 = x * 2; - int y1 = y * 2; - int z1 = z * 2; - - int sxyz = s[x1][y1][z1]; - int bxyz = b[x1][y1][z1]; - boolean txyz = t[x1][y1][z1]; - - int sxz = s[x1][1][z1], sxy = s[x1][y1][1], syz = s[1][y1][z1]; - int bxz = b[x1][1][z1], bxy = b[x1][y1][1], byz = b[1][y1][z1]; - boolean txz = t[x1][1][z1], txy = t[x1][y1][1], tyz = t[1][y1][z1]; - - int sx = s[x1][1][1], sy = s[1][y1][1], sz = s[1][1][z1]; - int bx = b[x1][1][1], by = b[1][y1][1], bz = b[1][1][z1]; - boolean tx = t[x1][1][1], ty = t[1][y1][1], tz = t[1][1][z1]; - - skyLight[0][x][y][z] = combine(sx, sxz, sxy, txz || txy ? sxyz : sx, - tx, txz, txy, txz || txy ? txyz : tx); - blockLight[0][x][y][z] = combine(bx, bxz, bxy, txz || txy ? bxyz : bx, - tx, txz, txy, txz || txy ? txyz : tx); - - skyLight[1][x][y][z] = combine(sy, sxy, syz, txy || tyz ? sxyz : sy, - ty, txy, tyz, txy || tyz ? txyz : ty); - blockLight[1][x][y][z] = combine(by, bxy, byz, txy || tyz ? bxyz : by, - ty, txy, tyz, txy || tyz ? txyz : ty); - - skyLight[2][x][y][z] = combine(sz, syz, sxz, tyz || txz ? sxyz : sz, - tz, tyz, txz, tyz || txz ? txyz : tz); - blockLight[2][x][y][z] = combine(bz, byz, bxz, tyz || txz ? bxyz : bz, - tz, tyz, txz, tyz || txz ? txyz : tz); - } - } - } - } - - @Override - protected float calculateBrightness(float[] position) { - float x = position[0], y = position[1], z = position[2]; - int sx = x < 0 ? 1 : 2; - int sy = y < 0 ? 1 : 2; - int sz = z < 0 ? 1 : 2; - - if (x < 0) x++; - if (y < 0) y++; - if (z < 0) z++; - - float a = 0; - a += ao[sx - 1][sy - 1][sz - 1] * (1 - x) * (1 - y) * (1 - z); - a += ao[sx - 1][sy - 1][sz - 0] * (1 - x) * (1 - y) * (0 + z); - a += ao[sx - 1][sy - 0][sz - 1] * (1 - x) * (0 + y) * (1 - z); - a += ao[sx - 1][sy - 0][sz - 0] * (1 - x) * (0 + y) * (0 + z); - a += ao[sx - 0][sy - 1][sz - 1] * (0 + x) * (1 - y) * (1 - z); - a += ao[sx - 0][sy - 1][sz - 0] * (0 + x) * (1 - y) * (0 + z); - a += ao[sx - 0][sy - 0][sz - 1] * (0 + x) * (0 + y) * (1 - z); - a += ao[sx - 0][sy - 0][sz - 0] * (0 + x) * (0 + y) * (0 + z); - - a = Mth.clamp(a, 0, 1); - return a; - } - - @Override - protected int calculateLightmap(float[] position, byte[] normal) { - var block = (int) (calcLightmap(blockLight, position[0], position[1], position[2]) * 0xF0); - var sky = (int) (calcLightmap(skyLight, position[0], position[1], position[2]) * 0xF0); - return block | (sky << 16); - } - - private float combine(int c, int s1, int s2, int s3, boolean t0, boolean t1, boolean t2, boolean t3) { - if (c == 0 && !t0) c = Math.max(0, Math.max(s1, s2) - 1); - if (s1 == 0 && !t1) s1 = Math.max(0, c - 1); - if (s2 == 0 && !t2) s2 = Math.max(0, c - 1); - if (s3 == 0 && !t3) s3 = Math.max(0, Math.max(s1, s2) - 1); - return (c + s1 + s2 + s3) / (0xF * 4f); - } - - protected float calcLightmap(float[][][][] light, float x, float y, float z) { - x *= 2; - y *= 2; - z *= 2; - float l2 = x * x + y * y + z * z; - if (l2 > 6 - 2e-2f) { - float s = (float) Math.sqrt((6 - 2e-2f) / l2); - x *= s; - y *= s; - z *= s; - } - float ax = x > 0 ? x : -x; - float ay = y > 0 ? y : -y; - float az = z > 0 ? z : -z; - float e1 = 1 + 1e-4f; - if (ax > 2 - 1e-4f && ay <= e1 && az <= e1) - x = x < 0 ? -2 + 1e-4f : 2 - 1e-4f; - else if (ay > 2 - 1e-4f && az <= e1 && ax <= e1) - y = y < 0 ? -2 + 1e-4f : 2 - 1e-4f; - else if (az > 2 - 1e-4f && ax <= e1 && ay <= e1) - z = z < 0 ? -2 + 1e-4f : 2 - 1e-4f; - ax = x > 0 ? x : -x; - ay = y > 0 ? y : -y; - az = z > 0 ? z : -z; - if (ax <= e1 && ay + az > 3f - 1e-4f) { - float s = (3f - 1e-4f) / (ay + az); - y *= s; - z *= s; - } else if (ay <= e1 && az + ax > 3f - 1e-4f) { - float s = (3f - 1e-4f) / (az + ax); - z *= s; - x *= s; - } else if (az <= e1 && ax + ay > 3f - 1e-4f) { - float s = (3f - 1e-4f) / (ax + ay); - x *= s; - y *= s; - } else if (ax + ay + az > 4 - 1e-4f) { - float s = (4 - 1e-4f) / (ax + ay + az); - x *= s; - y *= s; - z *= s; - } - - float l = 0; - float s = 0; - - for (int ix = 0; ix <= 1; ix++) { - for (int iy = 0; iy <= 1; iy++) { - for (int iz = 0; iz <= 1; iz++) { - float vx = x * (1 - ix * 2); - float vy = y * (1 - iy * 2); - float vz = z * (1 - iz * 2); - - float s3 = vx + vy + vz + 4; - float sx = vy + vz + 3; - float sy = vz + vx + 3; - float sz = vx + vy + 3; - - float bx = (2 * vx + vy + vz + 6) / (s3 * sy * sz * (vx + 2)); - s += bx; - l += bx * light[0][ix][iy][iz]; - - float by = (2 * vy + vz + vx + 6) / (s3 * sz * sx * (vy + 2)); - s += by; - l += by * light[1][ix][iy][iz]; - - float bz = (2 * vz + vx + vy + 6) / (s3 * sx * sy * (vz + 2)); - s += bz; - l += bz * light[2][ix][iy][iz]; - } - } - } - - l /= s; - l = Mth.clamp(l, 0, 1); - return l; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/obj/ObjLoader.java b/src/main/java/net/minecraftforge/client/model/obj/ObjLoader.java index 67e1eef1ab..f772990695 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/ObjLoader.java +++ b/src/main/java/net/minecraftforge/client/model/obj/ObjLoader.java @@ -10,12 +10,21 @@ import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.TextureSlots; +import net.minecraft.client.resources.model.ModelBaker; +import net.minecraft.client.resources.model.ModelDebugName; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.QuadCollection; +import net.minecraft.client.resources.model.UnbakedGeometry; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManagerReloadListener; import net.minecraft.util.GsonHelper; +import net.minecraftforge.client.model.IModelBuilder; +import net.minecraftforge.client.model.geometry.IGeometryBakingContext; import net.minecraftforge.client.model.geometry.IGeometryLoader; +import net.minecraftforge.client.model.geometry.StandaloneGeometryBakingContext; import java.io.FileNotFoundException; import java.util.Map; @@ -26,8 +35,7 @@ import java.util.Map; * Allows the user to enable automatic face culling, toggle quad shading, flip UVs, render emissively and specify a * {@link ObjMaterialLibrary material library} override. */ -public class ObjLoader implements IGeometryLoader, ResourceManagerReloadListener -{ +public class ObjLoader implements IGeometryLoader, ResourceManagerReloadListener { public static ObjLoader INSTANCE = new ObjLoader(); private final Map modelCache = Maps.newConcurrentMap(); @@ -36,61 +44,72 @@ public class ObjLoader implements IGeometryLoader, ResourceManagerRelo private ResourceManager manager = Minecraft.getInstance().getResourceManager(); @Override - public void onResourceManagerReload(ResourceManager resourceManager) - { + public void onResourceManagerReload(ResourceManager resourceManager) { modelCache.clear(); materialCache.clear(); manager = resourceManager; } @Override - public ObjModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) - { - if (!jsonObject.has("model")) - throw new JsonParseException("OBJ Loader requires a 'model' key that points to a valid .OBJ model."); + public UnbakedGeometry read(JsonObject json, JsonDeserializationContext deserializationContext) { + var location = ResourceLocation.parse(GsonHelper.getAsString(json, "model")); - String modelLocation = jsonObject.get("model").getAsString(); + boolean automaticCulling = GsonHelper.getAsBoolean(json, "automatic_culling", true); + boolean shadeQuads = GsonHelper.getAsBoolean(json, "shade_quads", true); + boolean flipV = GsonHelper.getAsBoolean(json, "flip_v", false); + boolean emissiveAmbient = GsonHelper.getAsBoolean(json, "emissive_ambient", true); + String mtlOverride = GsonHelper.getAsString(json, "mtl_override", null); - boolean automaticCulling = GsonHelper.getAsBoolean(jsonObject, "automatic_culling", true); - boolean shadeQuads = GsonHelper.getAsBoolean(jsonObject, "shade_quads", true); - boolean flipV = GsonHelper.getAsBoolean(jsonObject, "flip_v", false); - boolean emissiveAmbient = GsonHelper.getAsBoolean(jsonObject, "emissive_ambient", true); - String mtlOverride = GsonHelper.getAsString(jsonObject, "mtl_override", null); + var settings = new ObjModel.ModelSettings(location, automaticCulling, shadeQuads, flipV, emissiveAmbient, mtlOverride); + var model = loadModel(settings); - return loadModel(new ObjModel.ModelSettings(ResourceLocation.parse(modelLocation), automaticCulling, shadeQuads, flipV, emissiveAmbient, mtlOverride)); + return new ObjGeometry(model); } - public ObjModel loadModel(ObjModel.ModelSettings settings) - { + public ObjModel loadModel(ObjModel.ModelSettings settings) { return modelCache.computeIfAbsent(settings, (data) -> { Resource resource = manager.getResource(settings.modelLocation()).orElseThrow(); - try (ObjTokenizer tokenizer = new ObjTokenizer(resource.open())) - { + try (ObjTokenizer tokenizer = new ObjTokenizer(resource.open())) { return ObjModel.parse(tokenizer, settings); - } catch (FileNotFoundException e) - { - throw new RuntimeException("Could not find OBJ model", e); - } catch (Exception e) - { + } catch (Exception e) { throw new RuntimeException("Could not read OBJ model", e); } }); } - public ObjMaterialLibrary loadMaterialLibrary(ResourceLocation materialLocation) - { + public ObjMaterialLibrary loadMaterialLibrary(ResourceLocation materialLocation) { return materialCache.computeIfAbsent(materialLocation, (location) -> { Resource resource = manager.getResource(location).orElseThrow(); - try (ObjTokenizer rdr = new ObjTokenizer(resource.open())) - { + try (ObjTokenizer rdr = new ObjTokenizer(resource.open())) { return new ObjMaterialLibrary(rdr); - } catch (FileNotFoundException e) - { - throw new RuntimeException("Could not find OBJ material library", e); - } catch (Exception e) - { + } catch (Exception e) { throw new RuntimeException("Could not read OBJ material library", e); } }); } + + private static class ObjGeometry implements UnbakedGeometry { + private final ObjModel model; + + public ObjGeometry(ObjModel model) { + this.model = model; + } + + @Override + public QuadCollection bake(TextureSlots slots, ModelBaker baker, ModelState state, ModelDebugName name) { + return bake(slots, baker, state, name, StandaloneGeometryBakingContext.INSTANCE); + } + + @Override + public QuadCollection bake(TextureSlots slots, ModelBaker baker, ModelState state, ModelDebugName name, IGeometryBakingContext context) { + var builder = new QuadCollection.Builder(); + + for (var part : model.getParts().values()) { + if (context.isComponentVisible(part.name(), true)) + part.bake(slots, baker, state, name, context, builder); + } + + return builder.build(); + } + } } diff --git a/src/main/java/net/minecraftforge/client/model/obj/ObjMaterialLibrary.java b/src/main/java/net/minecraftforge/client/model/obj/ObjMaterialLibrary.java index 6625068cdb..16a68f25c3 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/ObjMaterialLibrary.java +++ b/src/main/java/net/minecraftforge/client/model/obj/ObjMaterialLibrary.java @@ -6,6 +6,7 @@ package net.minecraftforge.client.model.obj; import com.google.common.collect.Maps; +import net.minecraft.client.resources.model.ModelDebugName; import org.joml.Vector4f; import java.io.IOException; diff --git a/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java b/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java index 64cf418208..58e9350961 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java +++ b/src/main/java/net/minecraftforge/client/model/obj/ObjModel.java @@ -15,14 +15,15 @@ import net.minecraft.client.renderer.block.model.TextureSlots; 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.ModelDebugName; import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.QuadCollection; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.phys.Vec2; import net.minecraftforge.client.model.IModelBuilder; import net.minecraftforge.client.model.geometry.IGeometryBakingContext; -import net.minecraftforge.client.model.geometry.SimpleUnbakedGeometry; import net.minecraftforge.client.model.geometry.UnbakedGeometryHelper; import net.minecraftforge.client.model.pipeline.QuadBakingVertexConsumer; import net.minecraftforge.client.model.renderable.CompositeRenderable; @@ -51,7 +52,7 @@ import java.util.stream.Collectors; * Supports positions, texture coordinates, normals and colors. The {@link ObjMaterialLibrary material library} * has support for numerous features, including support for {@link ResourceLocation} textures (non-standard). */ -public class ObjModel extends SimpleUnbakedGeometry { +public class ObjModel { private static final Vector4f COLOR_WHITE = new Vector4f(1, 1, 1, 1); private static final Vec2[] DEFAULT_COORDS = { new Vec2(0, 0), @@ -61,6 +62,7 @@ public class ObjModel extends SimpleUnbakedGeometry { }; private final Map parts = Maps.newLinkedHashMap(); + private final Map partsView = Collections.unmodifiableMap(parts); private final Set rootComponentNames = Collections.unmodifiableSet(parts.keySet()); private Set allComponentNames; @@ -87,6 +89,10 @@ public class ObjModel extends SimpleUnbakedGeometry { this.mtlOverride = settings.mtlOverride; } + public Map getParts() { + return partsView; + } + public static ObjModel parse(ObjTokenizer tokenizer, ModelSettings settings) throws IOException { var modelLocation = settings.modelLocation; var materialLibraryOverrideLocation = settings.mtlOverride; @@ -269,19 +275,10 @@ public class ObjModel extends SimpleUnbakedGeometry { }; } - @Override - protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, TextureSlots textures, ModelState modelTransform) { - for (var part : parts.values()) { - if (owner.isComponentVisible(part.name(), true)) - part.addQuads(owner, modelBuilder, baker, textures, modelTransform, modelLocation); - } - } - public Set getRootComponentNames() { return rootComponentNames; } - @Override public Set getConfigurableComponentNames() { if (allComponentNames != null) return allComponentNames; @@ -428,7 +425,7 @@ public class ObjModel extends SimpleUnbakedGeometry { return builder.get(); } - private class ModelObject { + public class ModelObject { public final String name; List meshes = Lists.newArrayList(); @@ -441,9 +438,9 @@ public class ObjModel extends SimpleUnbakedGeometry { return name; } - protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, TextureSlots textures, ModelState modelTransform, ResourceLocation modelLocation) { + public void bake(TextureSlots slots, ModelBaker baker, ModelState state, ModelDebugName name, IGeometryBakingContext context, QuadCollection.Builder builder) { for (var mesh : meshes) - mesh.addQuads(owner, modelBuilder, baker, textures, modelTransform, modelLocation); + mesh.bake(slots, baker, state, name, context, builder); } protected void bake(CompositeRenderable.PartBuilder builder, TextureSlots textures) { @@ -465,7 +462,7 @@ public class ObjModel extends SimpleUnbakedGeometry { } } - private class ModelGroup extends ModelObject { + public class ModelGroup extends ModelObject { final Map parts = Maps.newLinkedHashMap(); ModelGroup(String name) { @@ -473,12 +470,12 @@ public class ObjModel extends SimpleUnbakedGeometry { } @Override - public void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, TextureSlots spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { - super.addQuads(owner, modelBuilder, baker, spriteGetter, modelTransform, modelLocation); + public void bake(TextureSlots slots, ModelBaker baker, ModelState state, ModelDebugName name, IGeometryBakingContext context, QuadCollection.Builder builder) { + super.bake(slots, baker, state, name, context, builder); for (var part : parts.values()) { - if (owner.isComponentVisible(part.name(), true)) - part.addQuads(owner, modelBuilder, baker, spriteGetter, modelTransform, modelLocation); + if (context.isComponentVisible(part.name(), true)) + part.bake(slots, baker, state, name, context, builder); } } @@ -522,22 +519,25 @@ public class ObjModel extends SimpleUnbakedGeometry { this.smoothingGroup = currentSmoothingGroup; } - protected void addQuads(IGeometryBakingContext owner, IModelBuilder modelBuilder, ModelBaker baker, TextureSlots textures, ModelState modelTransform, ResourceLocation modelLocation) { + protected void bake(TextureSlots slots, ModelBaker baker, ModelState state, ModelDebugName name, IGeometryBakingContext context, QuadCollection.Builder builder) { if (mat == null) return; - var material = UnbakedGeometryHelper.resolveDirtyMaterial(mat.diffuseColorMap, textures); - var texture = baker.sprites().get(material); + + var material = UnbakedGeometryHelper.resolveDirtyMaterial(mat.diffuseColorMap, slots); + var texture = baker.sprites().get(material, name); int tintIndex = mat.diffuseTintIndex; Vector4f colorTint = mat.diffuseColor; - var rootTransform = owner.getRootTransform(); - var transform = rootTransform.isIdentity() ? modelTransform.getRotation() : modelTransform.getRotation().compose(rootTransform); + // TODO: [Forge][Rendering] Models contains the transforms so we shouldnt care about them here. + //var rootTransform = context.getRootTransform(); + //var transform = rootTransform.isIdentity() ? modelTransform.transformation() : modelTransform.transformation().compose(rootTransform); + var transform = Transformation.identity(); for (int[][] face : faces) { Pair quad = makeQuad(face, tintIndex, colorTint, mat.ambientColor, texture, transform); if (quad.getRight() == null) - modelBuilder.addUnculledFace(quad.getLeft()); + builder.addUnculledFace(quad.getLeft()); else - modelBuilder.addCulledFace(quad.getRight(), quad.getLeft()); + builder.addCulledFace(quad.getRight(), quad.getLeft()); } } diff --git a/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java b/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java index 4d2f4b2d0f..2d8a964b6b 100644 --- a/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java +++ b/src/main/java/net/minecraftforge/client/model/renderable/BakedModelRenderable.java @@ -8,10 +8,9 @@ package net.minecraftforge.client.model.renderable; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.BlockModelPart; +import net.minecraft.client.renderer.block.model.BlockStateModel; import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.core.Direction; import net.minecraft.util.RandomSource; import net.minecraft.util.Unit; @@ -20,6 +19,7 @@ import net.minecraftforge.client.model.data.ModelData; import org.jetbrains.annotations.Nullable; import org.joml.Vector4f; +import java.util.ArrayList; import java.util.Arrays; /** @@ -37,33 +37,39 @@ public class BakedModelRenderable implements IRenderable(); + model.collectParts(randomSource, parts, context.data(), null); + for (var part : parts) { + for (var direction : Direction.valuesView()) { + for (var quad : part.getQuads(direction)) { + buffer.putBulkData(poseStack.last(), quad, tint.x(), tint.y(), tint.z(), tint.w(), lightmap, overlay, true); + } + } } } diff --git a/src/main/java/net/minecraftforge/client/model/renderable/CompositeRenderable.java b/src/main/java/net/minecraftforge/client/model/renderable/CompositeRenderable.java index d6bc932bdc..224b74b815 100644 --- a/src/main/java/net/minecraftforge/client/model/renderable/CompositeRenderable.java +++ b/src/main/java/net/minecraftforge/client/model/renderable/CompositeRenderable.java @@ -23,42 +23,33 @@ import java.util.List; * * @see Builder */ -public class CompositeRenderable implements IRenderable -{ +public class CompositeRenderable implements IRenderable { private final List components = new ArrayList<>(); - private CompositeRenderable() - { - } + private CompositeRenderable() { } @Override - public void render(PoseStack poseStack, MultiBufferSource bufferSource, ITextureRenderTypeLookup textureRenderTypeLookup, int lightmap, int overlay, float partialTick, Transforms context) - { + public void render(PoseStack poseStack, MultiBufferSource bufferSource, ITextureRenderTypeLookup textureRenderTypeLookup, int lightmap, int overlay, float partialTick, Transforms context) { for (var component : components) component.render(poseStack, bufferSource, textureRenderTypeLookup, lightmap, overlay, context); } - public static Builder builder() - { + public static Builder builder() { return new Builder(); } - private static class Component - { + private static class Component { private final String name; private final List children = new ArrayList<>(); private final List meshes = new ArrayList<>(); - public Component(String name) - { + public Component(String name) { this.name = name; } - public void render(PoseStack poseStack, MultiBufferSource bufferSource, ITextureRenderTypeLookup textureRenderTypeLookup, int lightmap, int overlay, Transforms context) - { + public void render(PoseStack poseStack, MultiBufferSource bufferSource, ITextureRenderTypeLookup textureRenderTypeLookup, int lightmap, int overlay, Transforms context) { Matrix4f matrix = context.getTransform(name); - if (matrix != null) - { + if (matrix != null) { poseStack.pushPose(); poseStack.mulPose(matrix); } @@ -74,75 +65,60 @@ public class CompositeRenderable implements IRenderable quads = new ArrayList<>(); - public Mesh(ResourceLocation texture) - { + public Mesh(ResourceLocation texture) { this.texture = texture; } - public void render(PoseStack poseStack, MultiBufferSource bufferSource, ITextureRenderTypeLookup textureRenderTypeLookup, int lightmap, int overlay) - { + public void render(PoseStack poseStack, MultiBufferSource bufferSource, ITextureRenderTypeLookup textureRenderTypeLookup, int lightmap, int overlay) { var consumer = bufferSource.getBuffer(textureRenderTypeLookup.get(texture)); for (var quad : quads) - { consumer.putBulkData(poseStack.last(), quad, 1, 1, 1, 1, lightmap, overlay, true); - } } } - public static class Builder - { + public static class Builder { private final CompositeRenderable renderable = new CompositeRenderable(); - private Builder() - { - } + private Builder() { } - public PartBuilder child(String name) - { + public PartBuilder child(String name) { var child = new Component(name); renderable.components.add(child); return new PartBuilder<>(this, child); } - public CompositeRenderable get() - { + public CompositeRenderable get() { return renderable; } } - public static class PartBuilder - { + public static class PartBuilder { private final T parent; private final Component component; - private PartBuilder(T parent, Component component) - { + private PartBuilder(T parent, Component component) { this.parent = parent; this.component = component; } - public PartBuilder> child(String name) - { + public PartBuilder> child(String name) { var child = new Component(component.name + "/" + name); this.component.children.add(child); return new PartBuilder<>(this, child); } - public PartBuilder addMesh(ResourceLocation texture, List quads) - { + public PartBuilder addMesh(ResourceLocation texture, List quads) { var mesh = new Mesh(texture); mesh.quads.addAll(quads); component.meshes.add(mesh); return this; } - public T end() - { + public T end() { return parent; } } @@ -150,8 +126,7 @@ public class CompositeRenderable implements IRenderable parts) - { + public static Transforms of(ImmutableMap parts) { return new Transforms(parts); } private final ImmutableMap parts; - private Transforms(ImmutableMap parts) - { + private Transforms(ImmutableMap parts) { this.parts = parts; } @Nullable - public Matrix4f getTransform(String part) - { + public Matrix4f getTransform(String part) { return parts.get(part); } } diff --git a/src/main/java/net/minecraftforge/common/DungeonHooks.java b/src/main/java/net/minecraftforge/common/DungeonHooks.java index 755f9ab60b..9696286e3e 100644 --- a/src/main/java/net/minecraftforge/common/DungeonHooks.java +++ b/src/main/java/net/minecraftforge/common/DungeonHooks.java @@ -6,17 +6,17 @@ package net.minecraftforge.common; import java.util.ArrayList; -import java.util.Iterator; -import java.util.Random; import net.minecraft.util.RandomSource; -import net.minecraft.util.random.WeightedEntry; -import net.minecraft.util.random.WeightedRandom; +import net.minecraft.util.random.WeightedList; import net.minecraft.world.entity.EntityType; -public class DungeonHooks -{ - private static ArrayList dungeonMobs = new ArrayList(); +public class DungeonHooks { + private static WeightedList> dungeonMobs = WeightedList.>builder() + .add(EntityType.SKELETON, 100) + .add(EntityType.ZOMBIE, 200) + .add(EntityType.SPIDER, 100) + .build(); /** * Adds a mob to the possible list of creatures the spawner will create. @@ -35,23 +35,20 @@ public class DungeonHooks public static float addDungeonMob(EntityType type, int rarity) { if (rarity <= 0) - { throw new IllegalArgumentException("Rarity must be greater then zero"); - } - Iterator itr = dungeonMobs.iterator(); - while (itr.hasNext()) - { - DungeonMob mob = itr.next(); - if (type == mob.type) - { + var list = new ArrayList<>(dungeonMobs.unwrap()); + var itr = list.iterator(); + while (itr.hasNext()) { + var mob = itr.next(); + if (type == mob.value()) { itr.remove(); - rarity = mob.getWeight().asInt() + rarity; + rarity = mob.weight() + rarity; break; } } - dungeonMobs.add(new DungeonMob(rarity, type)); + dungeonMobs = WeightedList.>builder().addAll(list).add(type, rarity).build(); return rarity; } @@ -61,16 +58,16 @@ public class DungeonHooks * @param name The name of the mob to remove * @return The rarity of the removed mob, prior to being removed. */ - public static int removeDungeonMob(EntityType name) - { - for (DungeonMob mob : dungeonMobs) - { - if (name == mob.type) - { - dungeonMobs.remove(mob); - return mob.getWeight().asInt(); - } + public static int removeDungeonMob(EntityType name) { + var list = new ArrayList<>(dungeonMobs.unwrap()); + for (var mob : list) { + if (mob.value() != name) continue; + + list.remove(mob); + dungeonMobs = WeightedList.>builder().addAll(list).build(); + return mob.weight(); } + return 0; } @@ -79,33 +76,7 @@ public class DungeonHooks * @param rand World generation random number generator * @return The mob name */ - public static EntityType getRandomDungeonMob(RandomSource rand) - { - DungeonMob mob = WeightedRandom.getRandomItem(rand, dungeonMobs).orElseThrow(); - return mob.type; - } - - - public static class DungeonMob extends WeightedEntry.IntrusiveBase - { - public final EntityType type; - public DungeonMob(int weight, EntityType type) - { - super(weight); - this.type = type; - } - - @Override - public boolean equals(Object target) - { - return target instanceof DungeonMob && type.equals(((DungeonMob)target).type); - } - } - - static - { - addDungeonMob(EntityType.SKELETON, 100); - addDungeonMob(EntityType.ZOMBIE, 200); - addDungeonMob(EntityType.SPIDER, 100); + public static EntityType getRandomDungeonMob(RandomSource rand) { + return dungeonMobs.getRandomOrThrow(rand); } } diff --git a/src/main/java/net/minecraftforge/common/ForgeConfig.java b/src/main/java/net/minecraftforge/common/ForgeConfig.java index ba885cb181..42bbbcaf1b 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfig.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfig.java @@ -94,8 +94,6 @@ public class ForgeConfig { * Client specific configuration - only loaded clientside from forge-client.toml */ public static class Client { - public final BooleanValue experimentalForgeLightPipelineEnabled; - public final BooleanValue showLoadWarnings; public final BooleanValue allowMipmapLowering; @@ -104,11 +102,6 @@ public class ForgeConfig { builder.comment("Client only settings, mostly things related to rendering") .push("client"); - experimentalForgeLightPipelineEnabled = builder - .comment("EXPERIMENTAL: Enable the Forge block rendering pipeline - fixes the lighting of custom models.") - .translation("forge.configgui.forgeLightPipelineEnabled") - .define("experimentalForgeLightPipelineEnabled", false); - showLoadWarnings = builder .comment("When enabled, Forge will show any warnings that occurred during loading.") .translation("forge.configgui.showLoadWarnings") diff --git a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java index 285aa59a2c..c109a9bed1 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java @@ -10,7 +10,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; @@ -675,6 +674,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper path) { if (comment.stream().allMatch(String::isBlank)) { diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index 318759a5b5..2d15293e70 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -356,10 +356,12 @@ public final class ForgeHooks { lastEnd = end; String url = string.substring(start, end); MutableComponent link = Component.literal(url); + URI uri = null; try { // Add schema so client doesn't crash. - if ((new URI(url)).getScheme() == null) { + uri = new URI(url); + if (uri.getScheme() == null) { if (!allowMissingHeader) { if (ichat == null) ichat = Component.literal(url); @@ -368,6 +370,7 @@ public final class ForgeHooks { continue; } url = "http://" + url; + uri = new URI(url); } } catch (URISyntaxException e) { // Bad syntax bail out! @@ -377,7 +380,7 @@ public final class ForgeHooks { } // Set the click event and append the link. - ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_URL, url); + ClickEvent click = new ClickEvent.OpenUrl(uri); link.setStyle(link.getStyle().withClickEvent(click).withUnderlined(true).withColor(TextColor.fromLegacyFormat(ChatFormatting.BLUE))); if (ichat == null) ichat = Component.literal(""); @@ -406,7 +409,7 @@ public final class ForgeHooks { // Logic from tryHarvestBlock for pre-canceling the event boolean preCancelEvent = false; ItemStack itemstack = entityPlayer.getMainHandItem(); - if (!itemstack.isEmpty() && !itemstack.getItem().canAttackBlock(level.getBlockState(pos), level, pos, entityPlayer)) { + if (!itemstack.isEmpty() && !itemstack.canDestroyBlock(level.getBlockState(pos), level, pos, entityPlayer)) { preCancelEvent = true; } @@ -693,7 +696,7 @@ public final class ForgeHooks { return modId; } - public static boolean onFarmlandTrample(ServerLevel level, BlockPos pos, BlockState state, float fallDistance, Entity entity) { + public static boolean onFarmlandTrample(ServerLevel level, BlockPos pos, BlockState state, double fallDistance, Entity entity) { if (entity.canTrample(level, state, pos, fallDistance)) return !ForgeEventFactory.fireFarmlandTrampleEvent(level, pos, state, fallDistance, entity); return false; @@ -742,7 +745,7 @@ public final class ForgeHooks { * *

All loot-table generated loot should be passed to this function.

* - * @param lootTableId The ID of the loot table currently being queried + * @param table The loot table currently being queried * @param generatedLoot The loot generated by the loot table * @param context The loot context that generated the loot, unmodified * @return The modified list of drops @@ -816,27 +819,27 @@ public final class ForgeHooks { CompoundTag tag = null; try { CompoundTag rootTag = access.getDataTagRaw(false); - tag = rootTag.getCompound("fml"); + tag = rootTag.getCompoundOrEmpty("fml"); } catch (IOException e) { try { CompoundTag rootTag = access.getDataTagRaw(true); - tag = rootTag.getCompound("fml"); + tag = rootTag.getCompoundOrEmpty("fml"); } catch (IOException e2) { LOGGER.error(WORLDPERSISTENCE, "Failed to read level data.. ", e2); return; } } if (tag.contains("LoadingModList")) { - ListTag modList = tag.getList("LoadingModList", net.minecraft.nbt.Tag.TAG_COMPOUND); + ListTag modList = tag.getListOrEmpty("LoadingModList"); Map mismatchedVersions = new HashMap<>(modList.size()); Map missingVersions = new HashMap<>(modList.size()); for (int i = 0; i < modList.size(); i++) { - CompoundTag mod = modList.getCompound(i); - String modId = mod.getString("ModId"); + CompoundTag mod = modList.getCompoundOrEmpty(i); + String modId = mod.getStringOr("ModId", null); if (Objects.equals("minecraft", modId)) continue; - String modVersion = mod.getString("ModVersion"); + String modVersion = mod.getStringOr("ModVersion", null); final var previousVersion = new DefaultArtifactVersion(modVersion); ModList.get().getModContainerById(modId).ifPresentOrElse(container -> { final var loadingVersion = container.getModInfo().getVersion(); @@ -899,9 +902,9 @@ public final class ForgeHooks { if (tag.contains("Registries")) { Map snapshot = new HashMap<>(); - CompoundTag regs = tag.getCompound("Registries"); - for (String key : regs.getAllKeys()) - snapshot.put(ResourceLocation.parse(key), ForgeRegistry.Snapshot.read(regs.getCompound(key))); + CompoundTag regs = tag.getCompoundOrEmpty("Registries"); + for (String key : regs.keySet()) + snapshot.put(ResourceLocation.parse(key), ForgeRegistry.Snapshot.read(regs.getCompoundOrEmpty(key))); failedElements = GameData.injectSnapshot(snapshot, true, true); } @@ -993,7 +996,7 @@ public final class ForgeHooks { /** * Handles living entities being under water. This fires the {@link LivingBreatheEvent} and if the entity's air supply * is less than or equal to zero also the {@link LivingDrownEvent}. Additionally when the entity is under water it will - * dismount if {@link IForgeEntity#canBeRiddenUnderFluidType(FluidType, Entity)} returns false. + * dismount if {@link net.minecraftforge.common.extensions.IForgeEntity#canBeRiddenUnderFluidType(FluidType, Entity)} returns false. * * @param entity The living entity which is currently updated * @param consumeAirAmount The amount of air to consume when the entity is unable to breathe diff --git a/src/main/java/net/minecraftforge/common/ToolActions.java b/src/main/java/net/minecraftforge/common/ToolActions.java index 7f6debc832..577e6b2dff 100644 --- a/src/main/java/net/minecraftforge/common/ToolActions.java +++ b/src/main/java/net/minecraftforge/common/ToolActions.java @@ -8,6 +8,7 @@ package net.minecraftforge.common; import com.google.common.collect.Sets; import net.minecraftforge.common.extensions.IForgeBlock; import net.minecraftforge.common.extensions.IForgeItem; +import org.jetbrains.annotations.ApiStatus; import java.util.Set; import java.util.stream.Collectors; @@ -97,7 +98,10 @@ public class ToolActions /** * A tool action corresponding to the 'block' action of shields. + * + * @deprecated Completely overshadowed by {@link net.minecraft.core.component.DataComponents#BLOCKS_ATTACKS} */ + @Deprecated(forRemoval = true, since = "1.21.5") public static final ToolAction SHIELD_BLOCK = ToolAction.get("shield_block"); /** @@ -109,9 +113,15 @@ public class ToolActions public static final Set DEFAULT_AXE_ACTIONS = of(AXE_DIG, AXE_STRIP, AXE_SCRAPE, AXE_WAX_OFF); public static final Set DEFAULT_HOE_ACTIONS = of(HOE_DIG, HOE_TILL); public static final Set DEFAULT_SHOVEL_ACTIONS = of(SHOVEL_DIG, SHOVEL_FLATTEN); + /** @deprecated See {@link #PICKAXE_DIG} for details */ + @Deprecated(forRemoval = true, since = "1.21.5") public static final Set DEFAULT_PICKAXE_ACTIONS = of(PICKAXE_DIG); + /** @deprecated See {@link #SWORD_DIG} and {@link #SWORD_SWEEP} for details */ + @Deprecated(forRemoval = true, since = "1.21.5") public static final Set DEFAULT_SWORD_ACTIONS = of(SWORD_DIG, SWORD_SWEEP); public static final Set DEFAULT_SHEARS_ACTIONS = of(SHEARS_DIG, SHEARS_HARVEST, SHEARS_CARVE, SHEARS_DISARM); + /** @deprecated See {@link #SHIELD_BLOCK} for details */ + @Deprecated(forRemoval = true, since = "1.21.5") public static final Set DEFAULT_SHIELD_ACTIONS = of(SHIELD_BLOCK); public static final Set DEFAULT_FISHING_ROD_ACTIONS = of(FISHING_ROD_CAST); diff --git a/src/main/java/net/minecraftforge/common/VillagerTradingManager.java b/src/main/java/net/minecraftforge/common/VillagerTradingManager.java index bbf9aa6b3c..c6f538f8d2 100644 --- a/src/main/java/net/minecraftforge/common/VillagerTradingManager.java +++ b/src/main/java/net/minecraftforge/common/VillagerTradingManager.java @@ -5,6 +5,7 @@ package net.minecraftforge.common; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -12,6 +13,7 @@ import java.util.Map; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerTrades; import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; @@ -20,15 +22,13 @@ import net.minecraftforge.event.village.VillagerTradesEvent; import net.minecraftforge.event.village.WandererTradesEvent; import net.minecraftforge.event.server.ServerAboutToStartEvent; import net.minecraftforge.registries.ForgeRegistries; +import org.apache.commons.lang3.tuple.Pair; -public class VillagerTradingManager -{ +public class VillagerTradingManager { + private static final Map, Int2ObjectMap> VANILLA_TRADES = new HashMap<>(); + private static final List> WANDERER_TRADES = new ArrayList<>(); - private static final Map> VANILLA_TRADES = new HashMap<>(); - private static final Int2ObjectMap WANDERER_TRADES = new Int2ObjectOpenHashMap<>(); - - static - { + static { VillagerTrades.TRADES.forEach((key, value) -> { Int2ObjectMap copy = new Int2ObjectOpenHashMap<>(); for (var ent : value.int2ObjectEntrySet()) { @@ -36,50 +36,40 @@ public class VillagerTradingManager } VANILLA_TRADES.put(key, copy); }); - VillagerTrades.WANDERING_TRADER_TRADES.int2ObjectEntrySet().forEach(e -> WANDERER_TRADES.put(e.getIntKey(), Arrays.copyOf(e.getValue(), e.getValue().length))); + WANDERER_TRADES.addAll(VillagerTrades.WANDERING_TRADER_TRADES); } - static void loadTrades(ServerAboutToStartEvent e) - { + static void loadTrades(ServerAboutToStartEvent e) { postWandererEvent(); postVillagerEvents(); } - /** - * Posts the WandererTradesEvent. - */ - private static void postWandererEvent() - { - 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); - MinecraftForge.EVENT_BUS.post(new WandererTradesEvent(generic, rare)); - VillagerTrades.WANDERING_TRADER_TRADES.put(1, generic.toArray(new ItemListing[0])); - VillagerTrades.WANDERING_TRADER_TRADES.put(2, rare.toArray(new ItemListing[0])); + /** Posts the WandererTradesEvent. */ + private static void postWandererEvent() { + var event = MinecraftForge.EVENT_BUS.fire(new WandererTradesEvent(WANDERER_TRADES)); + VillagerTrades.WANDERING_TRADER_TRADES.clear(); + for (var pool : event.getPools()) + VillagerTrades.WANDERING_TRADER_TRADES.add(Pair.of(pool.getEntries().toArray(ItemListing[]::new), pool.getRolls())); } - /** - * Posts a VillagerTradesEvent for each registered profession. - */ - private static void postVillagerEvents() - { - for (VillagerProfession prof : ForgeRegistries.VILLAGER_PROFESSIONS) - { + /** Posts a VillagerTradesEvent for each registered profession. */ + private static void postVillagerEvents() { + // TODO [VillagerType][1.21.5] Villager Professions are stored as keys in vanilla now? Re-evaluate this. + for (VillagerProfession value : ForgeRegistries.VILLAGER_PROFESSIONS) { + var prof = ForgeRegistries.VILLAGER_PROFESSIONS.getResourceKey(value).orElseThrow(); Int2ObjectMap trades = VANILLA_TRADES.getOrDefault(prof, new Int2ObjectOpenHashMap<>()); Int2ObjectMap> mutableTrades = new Int2ObjectOpenHashMap<>(); for (int i = 1; i < 6; i++) - { mutableTrades.put(i, NonNullList.create()); - } - for (var entry : trades.int2ObjectEntrySet()) { + + for (var entry : trades.int2ObjectEntrySet()) Arrays.stream(entry.getValue()).forEach(mutableTrades.get(entry.getIntKey())::add); - } + MinecraftForge.EVENT_BUS.post(new VillagerTradesEvent(mutableTrades, prof)); Int2ObjectMap newTrades = new Int2ObjectOpenHashMap<>(); - for (var entry : mutableTrades.int2ObjectEntrySet()) { + for (var entry : mutableTrades.int2ObjectEntrySet()) newTrades.put(entry.getIntKey(), entry.getValue().toArray(new ItemListing[0])); - } + VillagerTrades.TRADES.put(prof, newTrades); } } diff --git a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java index 5a7e8aa86d..3883adde5f 100644 --- a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java +++ b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java @@ -5,6 +5,7 @@ package net.minecraftforge.common.brewing; +/* import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -12,7 +13,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.core.NonNullList; -/* public class BrewingRecipeRegistry { /** diff --git a/src/main/java/net/minecraftforge/common/command/EntitySelectorManager.java b/src/main/java/net/minecraftforge/common/command/EntitySelectorManager.java index 57bf6235b7..3ec0610c69 100644 --- a/src/main/java/net/minecraftforge/common/command/EntitySelectorManager.java +++ b/src/main/java/net/minecraftforge/common/command/EntitySelectorManager.java @@ -11,10 +11,8 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; import net.minecraft.commands.arguments.selector.EntitySelector; import net.minecraft.commands.arguments.selector.EntitySelectorParser; -import java.util.Arrays; import java.util.HashMap; import java.util.List; -import java.util.Map; /** * Allows modders to register custom entity selectors by assigning an {@link IEntitySelectorType} to a String token.
diff --git a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java index 80fc719e8a..525132c37b 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java +++ b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java @@ -9,14 +9,12 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; import com.google.gson.JsonArray; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.mojang.serialization.JsonOps; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.core.HolderLookup; -import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.crafting.conditions.ICondition; diff --git a/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java b/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java index d744d6881f..baad5397a5 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java +++ b/src/main/java/net/minecraftforge/common/crafting/ingredients/PartialNBTIngredient.java @@ -92,7 +92,7 @@ public class PartialNBTIngredient extends AbstractIngredient { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(builder -> builder.group( Ingredient.NON_AIR_HOLDER_SET_CODEC.fieldOf("items").forGetter(i -> i.values), - TagParser.AS_CODEC.fieldOf("nbt").forGetter(i -> i.nbt) + TagParser.FLATTENED_CODEC.fieldOf("nbt").forGetter(i -> i.nbt) ).apply(builder, PartialNBTIngredient::new) ); diff --git a/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java index 57c45daa01..3d33cc88c5 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeFluidTagsProvider.java @@ -8,9 +8,7 @@ package net.minecraftforge.common.data; import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.tags.FluidTagsProvider; -import net.minecraft.data.tags.IntrinsicHolderTagsProvider; import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.BlockTags; import net.minecraft.tags.FluidTags; import net.minecraft.tags.TagKey; import net.minecraft.world.level.material.Fluid; @@ -18,8 +16,6 @@ import net.minecraftforge.common.ForgeMod; import org.jetbrains.annotations.ApiStatus; import java.util.concurrent.CompletableFuture; -import java.util.function.Consumer; - import static net.minecraftforge.common.Tags.Fluids.*; @ApiStatus.Internal diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java index 527e295004..53b0da2c53 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java @@ -587,8 +587,11 @@ public interface IForgeBlock { * @param pos Block position in level * @param direction The direction that the fire is coming from * @param igniter The entity that lit the fire + * @return {@code true} if the block SHOULD BE REMOVED */ - default void onCaughtFire(BlockState state, Level level, BlockPos pos, @Nullable Direction direction, @Nullable LivingEntity igniter) {} + default boolean onCaughtFire(BlockState state, Level level, BlockPos pos, @Nullable Direction direction, @Nullable LivingEntity igniter) { + return false; + } /** * Called when fire is updating on a neighbor block. diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java index bc5aada321..ced2afc0d8 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java @@ -5,7 +5,6 @@ package net.minecraftforge.common.extensions; -import net.minecraft.client.resources.model.BakedModel; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; import net.minecraft.world.entity.player.Player; @@ -31,19 +30,16 @@ public interface IForgeBlockEntity extends ICapabilityProvider { } /** - * Called when you receive a TileEntityData packet for the location this - * TileEntity is currently in. On the client, the NetworkManager will always - * be the remote server. On the server, it will be whomever is responsible for + * Called when you receive a TileEntityData packet for the location this TileEntity is currently in. On the client, + * the NetworkManager will always be the remote server. On the server, it will be whomever is responsible for * sending the packet. * - * @param net The NetworkManager the packet originated from - * @param pkt The data packet + * @param connection The Connection the packet originated from + * @param pkt The data packet + * @param lookup The holder lookup provider */ default void onDataPacket(Connection connection, ClientboundBlockEntityDataPacket pkt, HolderLookup.Provider lookup) { - CompoundTag compoundtag = pkt.getTag(); - if (compoundtag != null) { - self().loadWithComponents(compoundtag, lookup); - } + this.self().loadWithComponents(pkt.getTag(), lookup); } /** diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java index 966cb0dc66..fac9e6576d 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java @@ -460,9 +460,10 @@ public interface IForgeBlockState { * @param pos Block position in level * @param face The face that the fire is coming from * @param igniter The entity that lit the fire + * @return {@code true} if the block SHOULD BE REMOVED */ - default void onCaughtFire(Level level, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) { - self().getBlock().onCaughtFire(self(), level, pos, face, igniter); + default boolean onCaughtFire(Level level, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) { + return self().getBlock().onCaughtFire(self(), level, pos, face, igniter); } /** diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java b/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java index 7e1e13dd75..0f47178776 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeEntity.java @@ -98,7 +98,7 @@ public interface IForgeEntity extends ICapabilitySerializable { * @param fallDistance The fall distance * @return {@code true} if this entity can trample, {@code false} otherwise */ - boolean canTrample(ServerLevel level, BlockState state, BlockPos pos, float fallDistance); + boolean canTrample(ServerLevel level, BlockState state, BlockPos pos, double fallDistance); /** * Returns The classification of this entity diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java b/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java index 57ee0c9cc0..31102ecfe8 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeGameTestHelper.java @@ -9,6 +9,7 @@ import java.util.Arrays; import java.util.Objects; import java.util.UUID; import java.util.function.Consumer; +import java.util.function.Function; import java.util.function.Supplier; import net.minecraft.core.Registry; @@ -49,6 +50,12 @@ public interface IForgeGameTestHelper { return (GameTestHelper) this; } + int getTickAsInt(); + + default GameTestAssertException throwing(String message) { + return new GameTestAssertException(Component.literal(message), this.getTickAsInt()); + } + default void say(String message) { this.say(message, Style.EMPTY); } @@ -73,14 +80,22 @@ public interface IForgeGameTestHelper { return ForgeI18n.getPattern(message) != null ? Component.translatable(message) : Component.literal(message); } + default void assertTrue(boolean value, String message) { + this.assertTrue(value, () -> message); + } + default void assertTrue(boolean value, Supplier message) { if (!value) - throw new GameTestAssertException(message.get()); + throw new GameTestAssertException(Component.literal(message.get()), this.getTickAsInt()); + } + + default void assertFalse(boolean value, String message) { + this.assertFalse(value, () -> message); } default void assertFalse(boolean value, Supplier message) { if (value) - throw new GameTestAssertException(message.get()); + throw new GameTestAssertException(Component.literal(message.get()), this.getTickAsInt()); } default void assertValueEqual(N expected, N actual, String name, String message) { @@ -89,7 +104,7 @@ public interface IForgeGameTestHelper { default void assertValueEqual(N expected, N actual, String name, Supplier message) { if (!Objects.equals(expected, actual)) - throw new GameTestAssertException("%s -- Expected %s to be %s, but was %s".formatted(message.get(), name, expected, actual)); + throw this.throwing("%s -- Expected %s to be %s, but was %s".formatted(message.get(), name, expected, actual)); } default void assertValueEqual(N[] expected, N[] actual, String name, String message) { @@ -98,7 +113,7 @@ public interface IForgeGameTestHelper { default void assertValueEqual(N[] expected, N[] actual, String name, Supplier message) { if (!Objects.deepEquals(expected, actual)) - throw new GameTestAssertException("%s -- Expected %s to be %s, but was %s".formatted(message.get(), name, Arrays.toString(expected), Arrays.toString(actual))); + throw this.throwing("%s -- Expected %s to be %s, but was %s".formatted(message.get(), name, Arrays.toString(expected), Arrays.toString(actual))); } default void assertValueNotEqual(N expected, N actual, String name, String message) { @@ -107,7 +122,7 @@ public interface IForgeGameTestHelper { default void assertValueNotEqual(N expected, N actual, String name, Supplier message) { if (Objects.equals(expected, actual)) - throw new GameTestAssertException("%s -- Expected %s to NOT be %s, but was".formatted(message.get(), name, expected)); + throw this.throwing("%s -- Expected %s to NOT be %s, but was".formatted(message.get(), name, expected)); } default void assertValueNotEqual(N[] expected, N[] actual, String name, String message) { @@ -116,7 +131,7 @@ public interface IForgeGameTestHelper { default void assertValueNotEqual(N[] expected, N[] actual, String name, Supplier message) { if (!Objects.deepEquals(expected, actual)) - throw new GameTestAssertException("%s -- Expected %s to NOT be %s, but was".formatted(message.get(), name, Arrays.toString(expected))); + throw this.throwing("%s -- Expected %s to NOT be %s, but was".formatted(message.get(), name, Arrays.toString(expected))); } default Registry registryLookup(ResourceKey> registryKey) { @@ -145,7 +160,7 @@ public interface IForgeGameTestHelper { var server = level.getServer(); var listener = new ServerGamePacketListenerImpl(server, connection, player, cookie); - var info = GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(server.registryAccess())); + var info = GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(server.registryAccess()), listener); connection.setupInboundProtocol(info, listener); return player; } @@ -258,13 +273,26 @@ public interface IForgeGameTestHelper { return new BoolFlag(name); } + default void fail(String message) { + self().fail(Component.literal(message)); + } + public static class Flag { private final String name; - @Nullable - protected T value = null; + private final Function thrower; + protected @Nullable T value = null; public Flag(String name) { + this(name, RuntimeException::new); + } + + public Flag(String name, Function thrower) { this.name = name; + this.thrower = thrower; + } + + protected final RuntimeException throwing(String message) { + return this.thrower.apply(message); } public void set(T value) { @@ -287,7 +315,7 @@ public interface IForgeGameTestHelper { public void assertUnset(Supplier message) { if (this.value != null) { String s = message != null ? message.get() + " -- " : ""; - throw new GameTestAssertException(s + "Expected " + name + " to be null, but was " + this.value); + throw this.throwing(s + "Expected " + name + " to be null, but was " + this.value); } } @@ -302,7 +330,7 @@ public interface IForgeGameTestHelper { public void assertSet(Supplier message) { if (this.value == null) { String s = message != null ? message.get() + " -- " : ""; - throw new GameTestAssertException(s + "Flag " + name + " was never set"); + throw this.throwing(s + "Flag " + name + " was never set"); } } @@ -318,7 +346,7 @@ public interface IForgeGameTestHelper { assertSet(message); if (expected != null && !expected.equals(this.value)) { String s = message != null ? message.get() + " -- " : ""; - throw new GameTestAssertException(s + "Expected " + name + " to be " + expected + ", but was " + this.value); + throw this.throwing(s + "Expected " + name + " to be " + expected + ", but was " + this.value); } } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java index f411ec8ca0..10c5b1a26a 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java @@ -228,18 +228,11 @@ public interface IForgeItem { } /** - * Called to tick this items in a players inventory, the indexes are the global slot index. + * Called to tick this items in a entitie's inventory, the slotIndex may be -1 for non player entities as they may not have a slot index. + * See {@link EntityEquipment#tick(Entity)} */ - default void onInventoryTick(ItemStack stack, Level level, Player player, int slotIndex, int selectedIndex) { - // For compatibility reasons we have to use non-local index values, I think this is a vanilla bug but lets maintain compatibility - var inv = player.getInventory(); - int vanillaIndex = slotIndex; - if (slotIndex >= inv.items.size()) { - vanillaIndex -= inv.items.size(); - if (vanillaIndex >= inv.armor.size()) - vanillaIndex -= inv.armor.size(); - } - stack.inventoryTick(level, player, vanillaIndex, selectedIndex == vanillaIndex); + default void inventoryTick(ItemStack stack, Level level, Entity entity, @Nullable EquipmentSlot slot, int slotIndex) { + stack.inventoryTick(level, entity, slot); } /** @@ -460,9 +453,11 @@ public interface IForgeItem { * @param entity The LivingEntity holding the shield * @param attacker The LivingEntity holding the ItemStack * @return True if this ItemStack can disable the shield in question. + * @deprecated Overriding this does nothing! Use {@link net.minecraft.core.component.DataComponents#WEAPON}. */ + @Deprecated(forRemoval = true, since = "1.21.5") default boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker) { - return attacker.canDisableShield(); + return attacker.getSecondsToDisableBlocking() > 0.0F; } /** diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java index dbcd1ecfa1..f4a07d73a2 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java @@ -223,13 +223,13 @@ public interface IForgeItemStack { } /** - * Called to tick this items in a players inventory, the indexes are the global slot index. + * Called to tick this items in a entitie's inventory, the slotIndex may be -1 for non player entities as they may not have a slot index. + * See {@link EntityEquipment#tick(Entity)} */ - default void onInventoryTick(Level level, Player player, int slotIndex, int selectedIndex) { - self().getItem().onInventoryTick(self(), level, player, slotIndex, selectedIndex); + default void inventoryTick(Level level, Entity entity, @Nullable EquipmentSlot slot, int slotIndex) { + self().getItem().inventoryTick(self(), level, entity, slot, slotIndex); } - /** * Called every tick from {@code Horse#playGallopSound(SoundEvent)} on the item in the * armor slot. diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeTransformation.java b/src/main/java/net/minecraftforge/common/extensions/IForgeTransformation.java index fe7f49ca77..246c8fc36f 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeTransformation.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeTransformation.java @@ -91,7 +91,7 @@ public interface IForgeTransformation { Transformation transform = self(); if (transform.isIdentity()) return Transformation.identity(); - Matrix4f ret = transform.getMatrix(); + Matrix4f ret = transform.getMatrixCopy(); Matrix4f tmp = new Matrix4f().translation(origin.x(), origin.y(), origin.z()); tmp.mul(ret, ret); tmp.translation(-origin.x(), -origin.y(), -origin.z()); diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeWeightedList.java b/src/main/java/net/minecraftforge/common/extensions/IForgeWeightedList.java new file mode 100644 index 0000000000..d2962986ab --- /dev/null +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeWeightedList.java @@ -0,0 +1,89 @@ +package net.minecraftforge.common.extensions; + +import net.minecraft.util.random.Weighted; +import net.minecraft.util.random.WeightedList; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.function.Predicate; + +public interface IForgeWeightedList { + private WeightedList self() { + return (WeightedList) this; + } + + /** + * Removes any existing elements from this list. If removal takes place, this will create a new list. + *

To check if the builder elements have changed, simply check if the old and new lists are equal.

+ * {@snippet : + * private static void test() { + * var list = WeightedList.builder().add("Hello, World!", 1).build(); + * + * // if builder has no removals + * assert list == list.removeIf(String::isEmpty); + * + * // if builder has removals + * assert list != list.removeIf(s -> s.equals("Hello, World!")); + * } + *} + * + * @param predicate The predicate to remove elements with + * @return The builder + * @apiNote This is an expensive operation and primarily exists to help port legacy systems that + * used older list-based systems from 1.21.4 and older. + * @see java.util.List#removeIf(Predicate) + */ + default WeightedList removeIf(Predicate predicate) { + var list = new ArrayList<>(this.self().unwrap()); + return list.removeIf(w -> predicate.test(w.value())) + ? WeightedList.builder().addAll(list).build() + : this.self(); + } + + interface Builder { + private WeightedList.Builder self() { + return (WeightedList.Builder) this; + } + + /** @see com.google.common.collect.ImmutableList.Builder#addAll(Iterable) */ + default WeightedList.Builder addAll(Iterable> iterable) { + for (var w : iterable) this.self().add(w.value(), w.weight()); + return this.self(); + } + + /** @see com.google.common.collect.ImmutableList.Builder#addAll(Iterator) */ + default WeightedList.Builder addAll(Iterator> iterator) { + return this.addAll(() -> iterator); + } + + /** + * Removes any existing elements from the builder. If removal takes place, this will create a new builder. + *

To check if the builder elements have changed, simply check if the old and new builders are equal.

+ * {@snippet : + * private static void test() { + * var builder = WeightedList.builder(); + * builder.add("Hello, World!", 1); + * + * // if builder has no removals + * assert builder == builder.removeIf(String::isEmpty); + * + * // if builder has removals + * assert builder != builder.removeIf(s -> s.equals("Hello, World!")); + * } + *} + * + * @param predicate The predicate to remove elements with + * @return The builder + * @apiNote This is an expensive operation and primarily exists to help port legacy systems + * that used the older arraylist-based building from 1.21.4 and older. + * @see IForgeWeightedList#removeIf(Predicate) + * @see java.util.List#removeIf(Predicate) + */ + default WeightedList.Builder removeIf(Predicate predicate) { + var list = new ArrayList<>(this.self().build().unwrap()); + return list.removeIf(w -> predicate.test(w.value())) + ? WeightedList.builder().addAll(list) + : this.self(); + } + } +} diff --git a/src/main/java/net/minecraftforge/common/util/INBTBuilder.java b/src/main/java/net/minecraftforge/common/util/INBTBuilder.java index cf52502ce6..7584d25d4d 100644 --- a/src/main/java/net/minecraftforge/common/util/INBTBuilder.java +++ b/src/main/java/net/minecraftforge/common/util/INBTBuilder.java @@ -8,7 +8,9 @@ package net.minecraftforge.common.util; import java.util.List; import java.util.UUID; +import net.minecraft.core.UUIDUtil; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.Tag; public interface INBTBuilder { @@ -63,9 +65,14 @@ public interface INBTBuilder { return this; } + /** @deprecated Use {@link #putByteArray(String, byte...)} */ + @Deprecated(forRemoval = true, since = "1.21.5") public Builder putByteArray(String key, List value) { - tag.putByteArray(key, value); - return this; + var array = new byte[value.size()]; + for (var i = 0; i < value.size(); i++) + array[i] = value.get(i); + + return this.putByteArray(key, array); } public Builder putIntArray(String key, int... value) { @@ -73,9 +80,14 @@ public interface INBTBuilder { return this; } + /** @deprecated Use {@link #putIntArray(String, int...)} */ + @Deprecated(forRemoval = true, since = "1.21.5") public Builder putIntArray(String key, List value) { - tag.putIntArray(key, value); - return this; + var array = new int[value.size()]; + for (var i = 0; i < value.size(); i++) + array[i] = value.get(i); + + return this.putIntArray(key, array); } public Builder putLongArray(String key, long... value) { @@ -83,9 +95,14 @@ public interface INBTBuilder { return this; } + /** @deprecated Use {@link #putLongArray(String, long...)} */ + @Deprecated(forRemoval = true, since = "1.21.5") public Builder putLongArray(String key, List value) { - tag.putLongArray(key, value); - return this; + var array = new long[value.size()]; + for (var i = 0; i < value.size(); i++) + array[i] = value.get(i); + + return this.putLongArray(key, array); } public Builder put(String key, boolean value) { @@ -99,7 +116,7 @@ public interface INBTBuilder { } public Builder put(String key, UUID value) { - tag.putUUID(key, value); + tag.putIntArray(key, UUIDUtil.uuidToIntArray(value)); return this; } } diff --git a/src/main/java/net/minecraftforge/common/util/JsonUtils.java b/src/main/java/net/minecraftforge/common/util/JsonUtils.java index ac0d47230c..cbb5beabff 100644 --- a/src/main/java/net/minecraftforge/common/util/JsonUtils.java +++ b/src/main/java/net/minecraftforge/common/util/JsonUtils.java @@ -24,20 +24,19 @@ import com.google.gson.JsonSerializer; import com.google.gson.JsonSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.serialization.JsonOps; import net.minecraft.nbt.TagParser; import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.GsonHelper; import org.jetbrains.annotations.Nullable; -public class JsonUtils -{ +public class JsonUtils { // http://stackoverflow.com/questions/7706772/deserializing-immutablelist-using-gson/21677349#21677349 - public enum ImmutableListTypeAdapter implements JsonDeserializer>, JsonSerializer> - { + public enum ImmutableListTypeAdapter implements JsonDeserializer>, JsonSerializer> { INSTANCE; @Override - public ImmutableList deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException - { + public ImmutableList deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { final Type[] typeArguments = ((ParameterizedType) type).getActualTypeArguments(); final Type parametrizedType = listOf(typeArguments[0]).getType(); final List list = context.deserialize(json, parametrizedType); @@ -45,8 +44,7 @@ public class JsonUtils } @Override - public JsonElement serialize(ImmutableList src, Type type, JsonSerializationContext context) - { + public JsonElement serialize(ImmutableList src, Type type, JsonSerializationContext context) { final Type[] typeArguments = ((ParameterizedType) type).getActualTypeArguments(); final Type parametrizedType = listOf(typeArguments[0]).getType(); return context.serialize(src, parametrizedType); @@ -54,18 +52,15 @@ public class JsonUtils } @SuppressWarnings({ "serial", "unchecked" }) - private static TypeToken> listOf(final Type arg) - { + private static TypeToken> listOf(final Type arg) { return new TypeToken>() {}.where(new TypeParameter() {}, (TypeToken) TypeToken.of(arg)); } - public enum ImmutableMapTypeAdapter implements JsonDeserializer>, JsonSerializer> - { + public enum ImmutableMapTypeAdapter implements JsonDeserializer>, JsonSerializer> { INSTANCE; @Override - public ImmutableMap deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException - { + public ImmutableMap deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { final Type[] typeArguments = ((ParameterizedType) type).getActualTypeArguments(); final Type parameterizedType = mapOf(typeArguments[1]).getType(); final Map map = context.deserialize(json, parameterizedType); @@ -73,8 +68,7 @@ public class JsonUtils } @Override - public JsonElement serialize(ImmutableMap src, Type type, JsonSerializationContext context) - { + public JsonElement serialize(ImmutableMap src, Type type, JsonSerializationContext context) { final Type[] typeArguments = ((ParameterizedType) type).getActualTypeArguments(); final Type parameterizedType = mapOf(typeArguments[1]).getType(); return context.serialize(src, parameterizedType); @@ -82,20 +76,14 @@ public class JsonUtils } @Nullable - public static CompoundTag readNBT(JsonObject json, String key) - { - if (net.minecraft.util.GsonHelper.isValidNode(json, key)) - { - try - { - return TagParser.parseTag(net.minecraft.util.GsonHelper.getAsString(json, key)); - } catch (CommandSyntaxException e) - { - throw new JsonSyntaxException("Malformed NBT tag", e); - } - } else - { + public static CompoundTag readNBT(JsonObject json, String key) { + if (!net.minecraft.util.GsonHelper.isValidNode(json, key)) return null; + + try { + return TagParser.parseCompoundFully(GsonHelper.getAsString(json, key)); + } catch (CommandSyntaxException e) { + throw new JsonSyntaxException("Malformed NBT tag", e); } } diff --git a/src/main/java/net/minecraftforge/common/util/LazyFunction.java b/src/main/java/net/minecraftforge/common/util/LazyFunction.java new file mode 100644 index 0000000000..b1f065f592 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/util/LazyFunction.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) Forge Development LLC and contributors + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.common.util; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Function; + +/** + * Proxy object for a value that is calculated on first access + * @param The type of the value + */ +public sealed interface LazyFunction extends Function permits LazyFunction.Fast, LazyFunction.Concurrent { + /** + * Constructs a lazy-initialized object + * @param function The function for the value, to be called the first time the value is needed. + */ + static LazyFunction of(@NotNull Function function) { + return new LazyFunction.Fast<>(function); + } + + /** + * Constructs a thread-safe lazy-initialized object + * @param function The function for the value, to be called the first time the value is needed. + */ + static LazyFunction concurrentOf(@NotNull Function function) { + return new LazyFunction.Concurrent<>(function); + } + + R get() throws IllegalStateException; + + /** Non-thread-safe implementation. */ + final class Fast implements LazyFunction { + private Function function; + private R instance; + + private Fast(Function function) { + this.function = function; + } + + @Override + public @Nullable R apply(T t) { + if (function != null) { + instance = function.apply(t); + function = null; + } + + return instance; + } + + @Override + public R get() throws IllegalStateException { + if (function != null) + throw new IllegalStateException("Cannot call get() before apply()"); + + return instance; + } + } + + /** Thread-safe implementation. */ + final class Concurrent implements LazyFunction { + private volatile Object lock = new Object(); + private volatile Function function; + private volatile R instance; + + private Concurrent(Function function) + { + this.function = function; + } + + @Override + public @Nullable R apply(T t) { + // Copy the lock to a local variable to prevent NPEs if the lock field is set to null between the + // null-check and the synchronization + Object localLock = this.lock; + if (function != null) + { + // localLock is not null here because supplier was non-null after we copied the lock and both of them + // are volatile + synchronized (localLock) + { + if (function != null) + { + instance = function.apply(t); + function = null; + this.lock = null; + } + } + } + return instance; + } + + @Override + public R get() throws IllegalStateException { + if (function != null) + throw new IllegalStateException("Cannot call get() before apply()"); + + return instance; + } + } +} diff --git a/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java b/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java index f1d4da68bf..25cca35e73 100644 --- a/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java +++ b/src/main/java/net/minecraftforge/common/util/LevelCapabilityData.java @@ -5,47 +5,47 @@ package net.minecraftforge.common.util; -import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.saveddata.SavedData; -import net.minecraft.world.level.storage.DimensionDataStorage; +import net.minecraft.world.level.saveddata.SavedDataType; import org.jetbrains.annotations.Nullable; +import com.mojang.serialization.codecs.RecordCodecBuilder; + +@SuppressWarnings("deprecation") public class LevelCapabilityData extends SavedData { - public static final String ID = "capabilities"; + public static final SavedDataType TYPE = new SavedDataType( + "capabilities", + LevelCapabilityData::new, + ctx -> + RecordCodecBuilder.create(b -> + b.group( + CompoundTag.CODEC.fieldOf("data").forGetter(i -> { + if (i.serializable == null) + return new CompoundTag(); + return i.serializable.serializeNBT(ctx.levelOrThrow().registryAccess()); + }) + ).apply(b, nbt -> new LevelCapabilityData(ctx, nbt)) + ), + null + ); + @Nullable private final INBTSerializable serializable; - private CompoundTag capNBT = null; - public LevelCapabilityData(@Nullable INBTSerializable serializable) { - this.serializable = serializable; + private LevelCapabilityData(SavedData.Context ctx) { + this.serializable = ctx.levelOrThrow().getCapabilityDispatcher(); } - @Override - public CompoundTag save(CompoundTag nbt, HolderLookup.Provider provider) { - if (serializable != null) - nbt = serializable.serializeNBT(provider); - return nbt; + private LevelCapabilityData(SavedData.Context ctx, CompoundTag data) { + this(ctx); + if (this.serializable != null) + this.serializable.deserializeNBT(ctx.levelOrThrow().registryAccess(), data); } @Override public boolean isDirty() { return true; } - - public static LevelCapabilityData compute(DimensionDataStorage data, @Nullable INBTSerializable caps) { - var factory = new Factory<>( - () -> new LevelCapabilityData(caps), - (tag, lookup) -> { - var ret = new LevelCapabilityData(caps); - if (caps != null) - caps.deserializeNBT(lookup, tag); - return ret; - }, - null - ); - - return data.computeIfAbsent(factory, ID); - } } diff --git a/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java b/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java index 96023cc804..cda2b25a69 100644 --- a/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java +++ b/src/main/java/net/minecraftforge/common/world/BiomeSpecialEffectsBuilder.java @@ -10,7 +10,7 @@ import java.util.Optional; import net.minecraft.core.Holder; import net.minecraft.sounds.Music; import net.minecraft.sounds.SoundEvent; -import net.minecraft.util.random.SimpleWeightedRandomList; +import net.minecraft.util.random.WeightedList; import net.minecraft.world.level.biome.AmbientAdditionsSettings; import net.minecraft.world.level.biome.AmbientMoodSettings; import net.minecraft.world.level.biome.AmbientParticleSettings; @@ -90,7 +90,7 @@ public class BiomeSpecialEffectsBuilder extends BiomeSpecialEffects.Builder { return this.ambientAdditionsSettings; } - public Optional> getBackgroundMusic() { + public Optional> getBackgroundMusic() { return this.backgroundMusic; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java b/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java index de68e41557..4657c29696 100644 --- a/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java +++ b/src/main/java/net/minecraftforge/common/world/ForgeBiomeModifiers.java @@ -13,11 +13,15 @@ import java.util.function.Function; import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.ListCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.Util; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; import net.minecraft.core.RegistryCodecs; +import net.minecraft.util.random.Weighted; +import net.minecraft.util.random.WeightedList; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.level.biome.Biome; @@ -155,15 +159,12 @@ public final class ForgeBiomeModifiers { * @param biomes Biomes to add mob spawns to. * @param spawners List of SpawnerDatas specifying EntityType, weight, and pack size. */ - public record AddSpawnsBiomeModifier(HolderSet biomes, List spawners) implements BiomeModifier { + public record AddSpawnsBiomeModifier(HolderSet biomes, WeightedList spawners) implements BiomeModifier { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(builder -> builder.group( Biome.LIST_CODEC.fieldOf("biomes").forGetter(AddSpawnsBiomeModifier::biomes), // Allow either a list or single spawner, attempting to decode the list format first. - Codec.either(SpawnerData.CODEC.listOf(), SpawnerData.CODEC).xmap( - either -> either.map(Function.identity(), List::of), // convert list/singleton to list when decoding - list -> list.size() == 1 ? Either.right(list.get(0)) : Either.left(list) // convert list to singleton/list when encoding - ).fieldOf("spawners").forGetter(AddSpawnsBiomeModifier::spawners) + WeightedList.codec(SpawnerData.CODEC).fieldOf("spawners").forGetter(AddSpawnsBiomeModifier::spawners) ).apply(builder, AddSpawnsBiomeModifier::new)); /** @@ -172,16 +173,18 @@ public final class ForgeBiomeModifiers { * @param spawner SpawnerData specifying EntityTYpe, weight, and pack size. * @return AddSpawnsBiomeModifier that adds a single spawn entry to the specified biomes. */ - public static AddSpawnsBiomeModifier singleSpawn(HolderSet biomes, SpawnerData spawner) { - return new AddSpawnsBiomeModifier(biomes, List.of(spawner)); + public static AddSpawnsBiomeModifier singleSpawn(HolderSet biomes, int weight, SpawnerData spawner) { + return new AddSpawnsBiomeModifier(biomes, WeightedList.of(List.of(new Weighted<>(spawner, weight)))); } @Override public void modify(Holder biome, Phase phase, Builder builder) { if (phase == Phase.ADD && this.biomes.contains(biome)) { var spawns = builder.getMobSpawnSettings(); - for (var spawner : this.spawners) - spawns.addSpawn(spawner.type.getCategory(), spawner); + for (var weighted : this.spawners.unwrap()) { + var spawner = weighted.value(); + spawns.addSpawn(spawner.type().getCategory(), weighted.weight(), spawner); + } } } @@ -216,7 +219,7 @@ public final class ForgeBiomeModifiers { if (phase == Phase.REMOVE && this.biomes.contains(biome)) { var spawns = builder.getMobSpawnSettings(); for (var category : MobCategory.values()) - spawns.getSpawner(category).removeIf(data -> this.entityTypes.contains(ForgeRegistries.ENTITY_TYPES.getHolder(data.type).get())); + spawns.getSpawner(category).removeIf(data -> this.entityTypes.contains(ForgeRegistries.ENTITY_TYPES.getHolder(data.type()).orElseThrow())); } } diff --git a/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java b/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java index 86a76bc3ec..41878130bd 100644 --- a/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java +++ b/src/main/java/net/minecraftforge/common/world/ForgeChunkManager.java @@ -6,563 +6,73 @@ package net.minecraftforge.common.world; import com.mojang.datafixers.util.Pair; -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; import java.util.Map; -import java.util.Objects; -import java.util.Optional; import java.util.UUID; -import java.util.function.BiConsumer; -import java.util.function.Function; -import javax.annotation.ParametersAreNonnullByDefault; import net.minecraft.world.entity.Entity; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.NbtUtils; import net.minecraft.core.BlockPos; -import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.ForcedChunksSavedData; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.TicketType; -import net.minecraftforge.fml.ModList; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.Unmodifiable; -@ParametersAreNonnullByDefault -public class ForgeChunkManager -{ - private static final Logger LOGGER = LogManager.getLogger(); - private static final TicketType> BLOCK = TicketType.create("forge:block", Comparator.comparing(info -> info)); - private static final TicketType> BLOCK_TICKING = TicketType.create("forge:block_ticking", Comparator.comparing(info -> info)); - private static final TicketType> ENTITY = TicketType.create("forge:entity", Comparator.comparing(info -> info)); - private static final TicketType> ENTITY_TICKING = TicketType.create("forge:entity_ticking", Comparator.comparing(info -> info)); - private static final Map callbacks = new HashMap<>(); - - /** - * Sets the forced chunk loading validation callback for the given mod. This allows for validating and removing no longer valid tickets on level load. - * - * @apiNote This method should be called from a {@link net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent} using one of the {@link - * net.minecraftforge.fml.event.lifecycle.ParallelDispatchEvent} enqueueWork methods. - */ - public static void setForcedChunkLoadingCallback(String modId, LoadingValidationCallback callback) - { - if (ModList.get().isLoaded(modId)) - callbacks.put(modId, callback); - else - LOGGER.warn("A mod attempted to set the forced chunk validation loading callback for an unloaded mod of id: {}", modId); +/** @deprecated Vanilla now handles all forced chunks using its new {@link TicketType} system. */ +@Deprecated(forRemoval = true, since = "1.21.5") +public class ForgeChunkManager { + private static T error() { + throw new UnsupportedOperationException("Mod used ForgeChnkManager when they should use vanilla's TicketType system, see Level.getChunkSource().addTicketWithRadius"); } - /** - * Checks if a level has any forced chunks. Mainly used for seeing if a level should continue ticking with no players in it. - */ - public static boolean hasForcedChunks(ServerLevel level) - { - ForcedChunksSavedData data = level.getDataStorage().get(ForcedChunksSavedData.factory(), "chunks"); - if (data == null) return false; - return !data.getChunks().isEmpty() || !data.getBlockForcedChunks().isEmpty() || !data.getEntityForcedChunks().isEmpty(); - } + /** @deprecated Use Vanilla's {@link TicketType} system */ + public static void setForcedChunkLoadingCallback(String modId, LoadingValidationCallback callback) { error(); } - /** - * Forces a chunk to be loaded for the given mod with the "owner" of the ticket being a given block position. - * - * @param add {@code true} to force the chunk, {@code false} to unforce the chunk. - * @param ticking {@code true} to make the chunk receive full chunk ticks even if there is no player nearby. - */ - public static boolean forceChunk(ServerLevel level, String modId, BlockPos owner, int chunkX, int chunkZ, boolean add, boolean ticking) - { - return forceChunk(level, modId, owner, chunkX, chunkZ, add, ticking, ticking ? BLOCK_TICKING : BLOCK, ForcedChunksSavedData::getBlockForcedChunks); - } + /** @deprecated Use Vanilla's {@link TicketType} system */ + public static boolean hasForcedChunks(ServerLevel level) { return error(); } - /** - * Forces a chunk to be loaded for the given mod with the "owner" of the ticket being the UUID of the given entity. - * - * @param add {@code true} to force the chunk, {@code false} to unforce the chunk. - * @param ticking {@code true} to make the chunk receive full chunk ticks even if there is no player nearby. - */ - public static boolean forceChunk(ServerLevel level, String modId, Entity owner, int chunkX, int chunkZ, boolean add, boolean ticking) - { - return forceChunk(level, modId, owner.getUUID(), chunkX, chunkZ, add, ticking); - } + /** @deprecated Use Vanilla's {@link TicketType} system */ + public static boolean forceChunk(ServerLevel level, String modId, BlockPos owner, int chunkX, int chunkZ, boolean add, boolean ticking) { return error(); } - /** - * Forces a chunk to be loaded for the given mod with the "owner" of the ticket being a given UUID. - * - * @param add {@code true} to force the chunk, {@code false} to unforce the chunk. - * @param ticking {@code true} to make the chunk receive full chunk ticks even if there is no player nearby. - */ - public static boolean forceChunk(ServerLevel level, String modId, UUID owner, int chunkX, int chunkZ, boolean add, boolean ticking) - { - return forceChunk(level, modId, owner, chunkX, chunkZ, add, ticking, ticking ? ENTITY_TICKING : ENTITY, ForcedChunksSavedData::getEntityForcedChunks); - } + /** @deprecated Use Vanilla's {@link TicketType} system */ + public static boolean forceChunk(ServerLevel level, String modId, Entity owner, int chunkX, int chunkZ, boolean add, boolean ticking) { return error(); } - /** - * Forces a chunk to be loaded for the given mod with the given "owner". - * - * @param add {@code true} to force the chunk, {@code false} to unforce the chunk. - * - * @implNote Based on {@link ServerLevel#setChunkForced(int, int, boolean)} - */ - private static > boolean forceChunk(ServerLevel level, String modId, T owner, int chunkX, int chunkZ, boolean add, boolean ticking, - TicketType> type, Function> ticketGetter) - { - if (!ModList.get().isLoaded(modId)) - { - LOGGER.warn("A mod attempted to force a chunk for an unloaded mod of id: {}", modId); - return false; - } - ForcedChunksSavedData saveData = level.getDataStorage().computeIfAbsent(ForcedChunksSavedData.factory(), "chunks"); - ChunkPos pos = new ChunkPos(chunkX, chunkZ); - long chunk = pos.toLong(); - TicketTracker tickets = ticketGetter.apply(saveData); - TicketOwner ticketOwner = new TicketOwner<>(modId, owner); - boolean success; - if (add) - { - success = tickets.add(ticketOwner, chunk, ticking); - if (success) - level.getChunk(chunkX, chunkZ); - } - else - { - success = tickets.remove(ticketOwner, chunk, ticking); - } - if (success) - { - saveData.setDirty(true); - forceChunk(level, pos, type, ticketOwner, add, ticking); - } - return success; - } - - /** - * Adds/Removes a ticket from the level's chunk provider with the proper levels to match the forced chunks. - * - * @param add {@code true} to force the chunk, {@code false} to unforce the chunk. - * @param ticking {@code true} to make the chunk receive full chunk ticks even if there is no player nearby. - * - * @implNote We use distance 2 for what we pass, as when using register/releaseTicket the ticket's level is set to 33 - distance and the level that forced chunks use - * is 31. - */ - private static > void forceChunk(ServerLevel level, ChunkPos pos, TicketType> type, TicketOwner owner, boolean add, - boolean ticking) - { - if (add) - level.getChunkSource().addRegionTicket(type, pos, 2, owner, ticking); - else - level.getChunkSource().removeRegionTicket(type, pos, 2, owner, ticking); - } - - /** - * Reinstates forge's forced chunks when vanilla initially loads a level and reinstates their forced chunks. This method also will validate all of forge's forced - * chunks using and registered {@link LoadingValidationCallback}. - * - * @apiNote Internal - */ - public static void reinstatePersistentChunks(ServerLevel level, ForcedChunksSavedData saveData) - { - if (!callbacks.isEmpty()) - { - //If we have any callbacks, gather all owned tickets by modid for both blocks and entities - Map>> blockTickets = gatherTicketsByModId(saveData.getBlockForcedChunks()); - Map>> entityTickets = gatherTicketsByModId(saveData.getEntityForcedChunks()); - //Fire the callbacks allowing them to remove any tickets they don't want anymore - for (Map.Entry entry : callbacks.entrySet()) - { - String modId = entry.getKey(); - boolean hasBlockTicket = blockTickets.containsKey(modId); - boolean hasEntityTicket = entityTickets.containsKey(modId); - if (hasBlockTicket || hasEntityTicket) - { - Map> ownedBlockTickets = hasBlockTicket ? Collections.unmodifiableMap(blockTickets.get(modId)) : Collections.emptyMap(); - Map> ownedEntityTickets = hasEntityTicket ? Collections.unmodifiableMap(entityTickets.get(modId)) : Collections.emptyMap(); - entry.getValue().validateTickets(level, new TicketHelper(saveData, modId, ownedBlockTickets, ownedEntityTickets)); - } - } - } - //Reinstate the chunks that we want to load - reinstatePersistentChunks(level, BLOCK, saveData.getBlockForcedChunks().chunks, false); - reinstatePersistentChunks(level, BLOCK_TICKING, saveData.getBlockForcedChunks().tickingChunks, true); - reinstatePersistentChunks(level, ENTITY, saveData.getEntityForcedChunks().chunks, false); - reinstatePersistentChunks(level, ENTITY_TICKING, saveData.getEntityForcedChunks().tickingChunks, true); - } - - /** - * Gathers tickets into a mod filtered map for use in providing all tickets a mod has registered to its {@link LoadingValidationCallback}. - */ - private static > Map>> gatherTicketsByModId(TicketTracker tickets) - { - Map>> modSortedOwnedChunks = new HashMap<>(); - gatherTicketsByModId(tickets.chunks, Pair::getFirst, modSortedOwnedChunks); - gatherTicketsByModId(tickets.tickingChunks, Pair::getSecond, modSortedOwnedChunks); - return modSortedOwnedChunks; - } - - /** - * Gathers tickets into a mod filtered map for use in providing all tickets a mod has registered to its {@link LoadingValidationCallback}. - */ - private static > void gatherTicketsByModId(Map, LongSet> tickets, Function, LongSet> typeGetter, - Map>> modSortedOwnedChunks) - { - for (Map.Entry, LongSet> entry : tickets.entrySet()) - { - Pair pair = modSortedOwnedChunks.computeIfAbsent(entry.getKey().modId, modId -> new HashMap<>()) - .computeIfAbsent(entry.getKey().owner, owner -> new Pair<>(new LongOpenHashSet(), new LongOpenHashSet())); - typeGetter.apply(pair).addAll(entry.getValue()); - } - } - - /** - * Adds back any persistent forced chunks to the level's chunk provider. - */ - private static > void reinstatePersistentChunks(ServerLevel level, TicketType> type, - Map, LongSet> tickets, boolean ticking) - { - for (Map.Entry, LongSet> entry : tickets.entrySet()) - { - for (long chunk : entry.getValue()) - { - forceChunk(level, new ChunkPos(chunk), type, entry.getKey(), true, ticking); - } - } - } - - /** - * Writes the forge forced chunks into the NBT compound. Format is List{modid, List{ChunkPos, List{BlockPos}, List{UUID}}} - * - * @apiNote Internal - */ - public static void writeForgeForcedChunks(CompoundTag nbt, TicketTracker blockForcedChunks, TicketTracker entityForcedChunks) - { - if (!blockForcedChunks.isEmpty() || !entityForcedChunks.isEmpty()) - { - Map> forcedEntries = new HashMap<>(); - writeForcedChunkOwners(forcedEntries, blockForcedChunks, "Blocks", Tag.TAG_COMPOUND, (pos, forcedBlocks) -> forcedBlocks.add(NbtUtils.writeBlockPos(pos))); - writeForcedChunkOwners(forcedEntries, entityForcedChunks, "Entities", Tag.TAG_INT_ARRAY, (uuid, forcedEntities) -> forcedEntities.add(NbtUtils.createUUID(uuid))); - ListTag forcedChunks = new ListTag(); - for (Map.Entry> entry : forcedEntries.entrySet()) - { - CompoundTag forcedEntry = new CompoundTag(); - forcedEntry.putString("Mod", entry.getKey()); - ListTag modForced = new ListTag(); - modForced.addAll(entry.getValue().values()); - forcedEntry.put("ModForced", modForced); - forcedChunks.add(forcedEntry); - } - nbt.put("ForgeForced", forcedChunks); - } - } - - private static > void writeForcedChunkOwners(Map> forcedEntries, TicketTracker tracker, - String listKey, int listType, BiConsumer ownerWriter) - { - writeForcedChunkOwners(forcedEntries, tracker.chunks, listKey,listType, ownerWriter); - writeForcedChunkOwners(forcedEntries, tracker.tickingChunks, "Ticking" + listKey, listType, ownerWriter); - } - - private static > void writeForcedChunkOwners(Map> forcedEntries, - Map, LongSet> forcedChunks, String listKey, int listType, BiConsumer ownerWriter) - { - for (Map.Entry, LongSet> entry : forcedChunks.entrySet()) - { - Long2ObjectMap modForced = forcedEntries.computeIfAbsent(entry.getKey().modId, modId -> new Long2ObjectOpenHashMap<>()); - for (long chunk : entry.getValue()) - { - CompoundTag modEntry = modForced.computeIfAbsent(chunk, chunkPos -> { - CompoundTag baseEntry = new CompoundTag(); - baseEntry.putLong("Chunk", chunkPos); - return baseEntry; - }); - ListTag ownerList = modEntry.getList(listKey, listType); - ownerWriter.accept(entry.getKey().owner, ownerList); - //Note: As getList returns a new list in the case the data is of the wrong type, - // we need to mimic was vanilla does in various places and put our list back in - // the CompoundNBT regardless. - modEntry.put(listKey, ownerList); - } - } - } - - /** - * Reads the forge forced chunks from the NBT compound. Format is List{modid, List{ChunkPos, List{BlockPos}, List{UUID}}} - * - * @apiNote Internal - */ - public static void readForgeForcedChunks(CompoundTag nbt, TicketTracker blockForcedChunks, TicketTracker entityForcedChunks) - { - ListTag forcedChunks = nbt.getList("ForgeForced", Tag.TAG_COMPOUND); - for (int i = 0; i < forcedChunks.size(); i++) - { - CompoundTag forcedEntry = forcedChunks.getCompound(i); - String modId = forcedEntry.getString("Mod"); - if (ModList.get().isLoaded(modId)) - { - ListTag modForced = forcedEntry.getList("ModForced", Tag.TAG_COMPOUND); - for (int j = 0; j < modForced.size(); j++) - { - CompoundTag modEntry = modForced.getCompound(j); - long chunkPos = modEntry.getLong("Chunk"); - readBlockForcedChunks(modId, chunkPos, modEntry, "Blocks", blockForcedChunks.chunks); - readBlockForcedChunks(modId, chunkPos, modEntry, "TickingBlocks", blockForcedChunks.tickingChunks); - readEntityForcedChunks(modId, chunkPos, modEntry, "Entities", entityForcedChunks.chunks); - readEntityForcedChunks(modId, chunkPos, modEntry, "TickingEntities", entityForcedChunks.tickingChunks); - } - } - else - { - LOGGER.warn("Found chunk loading data for mod {} which is currently not available or active - it will be removed from the level save.", modId); - } - } - } - - /** - * Reads the forge block forced chunks. - */ - private static void readBlockForcedChunks(String modId, long chunkPos, CompoundTag modEntry, String key, Map, LongSet> blockForcedChunks) - { - ListTag forcedBlocks = modEntry.getList(key, Tag.TAG_INT_ARRAY); - for (int k = 0; k < forcedBlocks.size(); k++) - { - var aint = forcedBlocks.getIntArray(k); - var pos = aint.length == 3 ? new BlockPos(aint[0], aint[1], aint[2]) : BlockPos.ZERO; - blockForcedChunks.computeIfAbsent(new TicketOwner<>(modId, pos), owner -> new LongOpenHashSet()).add(chunkPos); - } - } - - /** - * Reads the forge entity forced chunks. - */ - private static void readEntityForcedChunks(String modId, long chunkPos, CompoundTag modEntry, String key, Map, LongSet> entityForcedChunks) - { - ListTag forcedEntities = modEntry.getList(key, Tag.TAG_INT_ARRAY); - for (Tag uuid : forcedEntities) - { - entityForcedChunks.computeIfAbsent(new TicketOwner<>(modId, NbtUtils.loadUUID(uuid)), owner -> new LongOpenHashSet()).add(chunkPos); - } - } + /** @deprecated Use Vanilla's {@link TicketType} system */ + public static boolean forceChunk(ServerLevel level, String modId, UUID owner, int chunkX, int chunkZ, boolean add, boolean ticking) { return error(); } + /** @deprecated Use Vanilla's {@link TicketType} system */ @FunctionalInterface + @Deprecated(forRemoval = true, since = "1.21.5") public interface LoadingValidationCallback { - /** - * Called back when tickets are about to be loaded and reinstated to allow mods to invalidate and remove specific tickets that may no longer be valid. - * - * @param level The level - * @param ticketHelper Ticket helper to remove any invalid tickets. - */ void validateTickets(ServerLevel level, TicketHelper ticketHelper); } - /** - * Class to help mods remove no longer valid tickets. - */ - public static class TicketHelper - { - private final Map> blockTickets; - private final Map> entityTickets; - private final ForcedChunksSavedData saveData; - private final String modId; - - private TicketHelper(ForcedChunksSavedData saveData, String modId, Map> blockTickets, Map> entityTickets) - { - this.saveData = saveData; - this.modId = modId; - this.blockTickets = blockTickets; - this.entityTickets = entityTickets; - } - - /** - * Gets all "BLOCK" tickets this mod had registered and which block positions are forcing which chunks. First element of the pair is the non-fully ticking - * tickets, second element is the fully ticking tickets. - * - * @apiNote This map is unmodifiable and does not update to reflect removed tickets so it is safe to call the remove methods while iterating it. - */ - public Map> getBlockTickets() - { - return blockTickets; - } - - /** - * Gets all "ENTITY" tickets this mod had registered and which entity (UUID) is forcing which chunks. First element of the pair is the non-fully ticking - * tickets, second element is the fully ticking tickets. - * - * @apiNote This map is unmodifiable and does not update to reflect removed tickets so it is safe to call the remove methods while iterating it. - */ - public Map> getEntityTickets() - { - return entityTickets; - } - - /** - * Removes all tickets that a given block was responsible for; both ticking and not ticking. - * - * @param owner Block that was responsible. - */ - public void removeAllTickets(BlockPos owner) - { - removeAllTickets(saveData.getBlockForcedChunks(), owner); - } - - /** - * Removes all tickets that a given entity (UUID) was responsible for; both ticking and not ticking. - * - * @param owner Entity (UUID) that was responsible. - */ - public void removeAllTickets(UUID owner) - { - removeAllTickets(saveData.getEntityForcedChunks(), owner); - } - - /** - * Removes all tickets that a given owner was responsible for; both ticking and not ticking. - */ - private > void removeAllTickets(TicketTracker tickets, T owner) - { - TicketOwner ticketOwner = new TicketOwner<>(modId, owner); - if (tickets.chunks.containsKey(ticketOwner) || tickets.tickingChunks.containsKey(ticketOwner)) - { - tickets.chunks.remove(ticketOwner); - tickets.tickingChunks.remove(ticketOwner); - saveData.setDirty(true); - } - } - - /** - * Removes the ticket for the given chunk that a given block was responsible for. - * - * @param owner Block that was responsible. - * @param chunk Chunk to remove ticket of. - * @param ticking Whether or not the ticket to remove represents a ticking set of tickets or not. - */ - public void removeTicket(BlockPos owner, long chunk, boolean ticking) - { - removeTicket(saveData.getBlockForcedChunks(), owner, chunk, ticking); - } - - /** - * Removes the ticket for the given chunk that a given entity (UUID) was responsible for. - * - * @param owner Entity (UUID) that was responsible. - * @param chunk Chunk to remove ticket of. - * @param ticking Whether or not the ticket to remove represents a ticking set of tickets or not. - */ - public void removeTicket(UUID owner, long chunk, boolean ticking) - { - removeTicket(saveData.getEntityForcedChunks(), owner, chunk, ticking); - } - - private > void removeTicket(TicketTracker tickets, T owner, long chunk, boolean ticking) - { - if (tickets.remove(new TicketOwner<>(modId, owner), chunk, ticking)) - saveData.setDirty(true); - } + /** @deprecated Use Vanilla's {@link TicketType} system */ + @Deprecated(forRemoval = true, since = "1.21.5") + public static class TicketHelper { + private TicketHelper() { } + /** @deprecated Use Vanilla's {@link TicketType} system */ + public @Unmodifiable Map> getBlockTickets() { return error(); } + /** @deprecated Use Vanilla's {@link TicketType} system */ + public @Unmodifiable Map> getEntityTickets() { return error(); } + /** @deprecated Use Vanilla's {@link TicketType} system */ + public void removeAllTickets(BlockPos owner) { error(); } + /** @deprecated Use Vanilla's {@link TicketType} system */ + public void removeAllTickets(UUID owner) { error(); } + /** @deprecated Use Vanilla's {@link TicketType} system */ + public void removeTicket(BlockPos owner, long chunk, boolean ticking) { error(); } + /** @deprecated Use Vanilla's {@link TicketType} system */ + public void removeTicket(UUID owner, long chunk, boolean ticking) { error(); } } - /** - * Helper class to keep track of a ticket owner by modid and owner object - */ - public static class TicketOwner> implements Comparable> - { - private final String modId; - private final T owner; - - private TicketOwner(String modId, T owner) - { - this.modId = modId; - this.owner = owner; - } - - @Override - public int compareTo(TicketOwner other) - { - int res = modId.compareTo(other.modId); - return res == 0 ? owner.compareTo(other.owner) : res; - } - - @Override - public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TicketOwner that = (TicketOwner) o; - return Objects.equals(modId, that.modId) && Objects.equals(owner, that.owner); - } - - @Override - public int hashCode() - { - return Objects.hash(modId, owner); - } + /** @deprecated Use Vanilla's {@link TicketType} system */ + @Deprecated(forRemoval = true, since = "1.21.5") + public static class TicketOwner implements Comparable { + private TicketOwner() { } + @Override public int compareTo(TicketOwner o) { return error(); } } - /** - * Helper class to manage tracking and handling loaded tickets. - */ - public static class TicketTracker> - { - private final Map, LongSet> chunks = new HashMap<>(); - private final Map, LongSet> tickingChunks = new HashMap<>(); - - /** - * Gets an unmodifiable view of the tracked chunks. - */ - public Map, LongSet> getChunks() - { - return Collections.unmodifiableMap(chunks); - } - - /** - * Gets an unmodifiable view of the tracked fully ticking chunks. - */ - public Map, LongSet> getTickingChunks() - { - return Collections.unmodifiableMap(tickingChunks); - } - - /** - * Checks if this tracker is empty. - * - * @return {@code true} if there are no chunks or ticking chunks being tracked. - */ - public boolean isEmpty() - { - return chunks.isEmpty() && tickingChunks.isEmpty(); - } - - private Map, LongSet> getTickets(boolean ticking) - { - return ticking ? tickingChunks : chunks; - } - - /** - * @return {@code true} if the state changed. - */ - private boolean remove(TicketOwner owner, long chunk, boolean ticking) - { - Map, LongSet> tickets = getTickets(ticking); - if (tickets.containsKey(owner)) - { - LongSet ticketChunks = tickets.get(owner); - if (ticketChunks.remove(chunk)) - { - if (ticketChunks.isEmpty()) - tickets.remove(owner); - return true; - } - } - return false; - } - - /** - * @return {@code true} if the state changed. - */ - private boolean add(TicketOwner owner, long chunk, boolean ticking) - { - return getTickets(ticking).computeIfAbsent(owner, o -> new LongOpenHashSet()).add(chunk); - } + /** @deprecated Use Vanilla's {@link TicketType} system */ + @Deprecated(forRemoval = true, since = "1.21.5") + public static class TicketTracker { + public Map getChunks() { return error(); } + public boolean isEmpty() { return error(); } } } diff --git a/src/main/java/net/minecraftforge/common/world/MobSpawnSettingsBuilder.java b/src/main/java/net/minecraftforge/common/world/MobSpawnSettingsBuilder.java index ce17de0a6b..fba9361c46 100644 --- a/src/main/java/net/minecraftforge/common/world/MobSpawnSettingsBuilder.java +++ b/src/main/java/net/minecraftforge/common/world/MobSpawnSettingsBuilder.java @@ -9,54 +9,48 @@ import java.util.Collections; import java.util.List; import java.util.Set; +import net.minecraft.Util; +import net.minecraft.util.random.WeightedList; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.biome.MobSpawnSettings; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; -public class MobSpawnSettingsBuilder extends MobSpawnSettings.Builder -{ +public class MobSpawnSettingsBuilder extends MobSpawnSettings.Builder { private final Set typesView = Collections.unmodifiableSet(this.spawners.keySet()); private final Set> costView = Collections.unmodifiableSet(this.mobSpawnCosts.keySet()); - public MobSpawnSettingsBuilder(MobSpawnSettings orig) - { - orig.getSpawnerTypes().forEach(k -> { - spawners.get(k).clear(); - spawners.get(k).addAll(orig.getMobs(k).unwrap()); - }); + public MobSpawnSettingsBuilder(MobSpawnSettings orig) { + orig.getSpawnerTypes().forEach(k -> + spawners.put(k, WeightedList.builder().addAll(orig.getMobs(k).unwrap())) + ); orig.getEntityTypes().forEach(k -> mobSpawnCosts.put(k, orig.getMobSpawnCost(k))); creatureGenerationProbability = orig.getCreatureProbability(); } - public Set getSpawnerTypes() - { + public Set getSpawnerTypes() { return this.typesView; } - public List getSpawner(MobCategory type) - { + public WeightedList.Builder getSpawner(MobCategory type) { return this.spawners.get(type); } - public Set> getEntityTypes() - { + public Set> getEntityTypes() { return this.costView; } @Nullable - public MobSpawnSettings.MobSpawnCost getCost(EntityType type) - { + public MobSpawnSettings.MobSpawnCost getCost(EntityType type) { return this.mobSpawnCosts.get(type); } - public float getProbability() - { + public float getProbability() { return this.creatureGenerationProbability; } - public MobSpawnSettingsBuilder disablePlayerSpawn() - { + public MobSpawnSettingsBuilder disablePlayerSpawn() { return this; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/world/StructureSettingsBuilder.java b/src/main/java/net/minecraftforge/common/world/StructureSettingsBuilder.java index 18cb6bca5c..4356ef8353 100644 --- a/src/main/java/net/minecraftforge/common/world/StructureSettingsBuilder.java +++ b/src/main/java/net/minecraftforge/common/world/StructureSettingsBuilder.java @@ -9,9 +9,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; import net.minecraft.core.HolderSet; -import net.minecraft.util.random.WeightedRandomList; +import net.minecraft.util.random.Weighted; +import net.minecraft.util.random.WeightedList; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.MobSpawnSettings; @@ -20,9 +22,9 @@ import net.minecraft.world.level.levelgen.structure.Structure.StructureSettings; import net.minecraft.world.level.levelgen.structure.StructureSpawnOverride; import net.minecraft.world.level.levelgen.structure.TerrainAdjustment; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.UnmodifiableView; -public class StructureSettingsBuilder -{ +public class StructureSettingsBuilder { private HolderSet biomes; private final Map spawnOverrides; private GenerationStep.Decoration step; @@ -32,13 +34,11 @@ public class StructureSettingsBuilder * @param settings Existing StructureSettings. * @return A new builder with a copy of that StructureSettings's values. */ - public static StructureSettingsBuilder copyOf(StructureSettings settings) - { + public static StructureSettingsBuilder copyOf(StructureSettings settings) { return new StructureSettingsBuilder(settings.biomes(), settings.spawnOverrides(), settings.step(), settings.terrainAdaptation()); } - private StructureSettingsBuilder(HolderSet biomes, Map spawnOverrides, GenerationStep.Decoration step, TerrainAdjustment terrainAdaptation) - { + private StructureSettingsBuilder(HolderSet biomes, Map spawnOverrides, GenerationStep.Decoration step, TerrainAdjustment terrainAdaptation) { this.biomes = biomes; this.spawnOverrides = spawnOverrides.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> StructureSpawnOverrideBuilder.copyOf(entry.getValue()))); this.step = step; @@ -48,21 +48,18 @@ public class StructureSettingsBuilder /** * @return A new StructureSettings with the finalized values. */ - public StructureSettings build() - { + public StructureSettings build() { Map overrides = Collections.unmodifiableMap( this.spawnOverrides.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().build())) ); return new StructureSettings(this.biomes, overrides, this.step, this.terrainAdaptation); } - public HolderSet getBiomes() - { + public HolderSet getBiomes() { return biomes; } - public void setBiomes(HolderSet biomes) - { + public void setBiomes(HolderSet biomes) { this.biomes = biomes; } @@ -70,9 +67,7 @@ public class StructureSettingsBuilder * Gets a mutable builder for the spawn overrides of a given mob category or {@code null} if no overrides are defined for that category. * @param category Mob category */ - @Nullable - public StructureSpawnOverrideBuilder getSpawnOverrides(MobCategory category) - { + public @Nullable StructureSpawnOverrideBuilder getSpawnOverrides(MobCategory category) { return spawnOverrides.get(category); } @@ -80,8 +75,7 @@ public class StructureSettingsBuilder * Gets or creates a mutable builder for the spawn overrides of a given mob category. If the override needed to be created it will default to piece bounding. * @param category Mob category */ - public StructureSpawnOverrideBuilder getOrAddSpawnOverrides(MobCategory category) - { + public StructureSpawnOverrideBuilder getOrAddSpawnOverrides(MobCategory category) { return spawnOverrides.computeIfAbsent(category, c -> new StructureSpawnOverrideBuilder(StructureSpawnOverride.BoundingBoxType.PIECE, Collections.emptyList())); } @@ -89,32 +83,28 @@ public class StructureSettingsBuilder * Removes the spawn overrides for the given mob category. * @param category Mob category */ - public void removeSpawnOverrides(MobCategory category) - { + public void removeSpawnOverrides(MobCategory category) { this.spawnOverrides.remove(category); } /** * Gets the world generation decoration step the structure spawns during. */ - public GenerationStep.Decoration getDecorationStep() - { + public GenerationStep.Decoration getDecorationStep() { return step; } /** * Sets the world generation decoration step the structure spawns during. */ - public void setDecorationStep(GenerationStep.Decoration step) - { + public void setDecorationStep(GenerationStep.Decoration step) { this.step = step; } /** * Gets the way the structure adapts to the terrain during generation. */ - public TerrainAdjustment getTerrainAdaptation() - { + public TerrainAdjustment getTerrainAdaptation() { return terrainAdaptation; } @@ -122,28 +112,24 @@ public class StructureSettingsBuilder * Sets the way the structure adapts to the terrain during generation. * @param terrainAdaptation New terrain adjustment */ - public void setTerrainAdaptation(TerrainAdjustment terrainAdaptation) - { + public void setTerrainAdaptation(TerrainAdjustment terrainAdaptation) { this.terrainAdaptation = terrainAdaptation; } - public static class StructureSpawnOverrideBuilder - { + public static class StructureSpawnOverrideBuilder { private StructureSpawnOverride.BoundingBoxType boundingBox; - private final List spawns; - private final List spawnsView; + private final List> spawns; + private final List> spawnsView; /** * @param override Existing spawn override data. * @return A new builder with a copy of that StructureSpawnOverride's values. */ - public static StructureSpawnOverrideBuilder copyOf(StructureSpawnOverride override) - { + public static StructureSpawnOverrideBuilder copyOf(StructureSpawnOverride override) { return new StructureSpawnOverrideBuilder(override.boundingBox(), override.spawns().unwrap()); } - private StructureSpawnOverrideBuilder(StructureSpawnOverride.BoundingBoxType boundingBox, List spawns) - { + private StructureSpawnOverrideBuilder(StructureSpawnOverride.BoundingBoxType boundingBox, List> spawns) { this.boundingBox = boundingBox; this.spawns = new ArrayList<>(spawns); this.spawnsView = Collections.unmodifiableList(this.spawns); @@ -152,49 +138,45 @@ public class StructureSettingsBuilder /** * Gets the type of bounding box for this structures spawn overrides. */ - public StructureSpawnOverride.BoundingBoxType getBoundingBox() - { - return boundingBox; + public StructureSpawnOverride.BoundingBoxType getBoundingBox() { + return this.boundingBox; } /** - * Sets the way the structure checks for spawn overrides. Whether it is on a piece by piece basis or within the bounds of the overall structure. + * Sets the way the structure checks for spawn overrides. Whether it is on a piece by piece basis or within the + * bounds of the overall structure. */ - public void setBoundingBox(StructureSpawnOverride.BoundingBoxType boundingBox) - { + public void setBoundingBox(StructureSpawnOverride.BoundingBoxType boundingBox) { this.boundingBox = boundingBox; } - /** - * Unmodifiable view of the possible spawns. - */ - public List getSpawns() - { - return spawnsView; + /** @return An {@linkplain Collections#unmodifiableList(List) Unmodifiable view} of the possible spawns. */ + @UnmodifiableView + public List> getSpawns() { + return this.spawnsView; + } + + /** Adds a spawn to the overrides with a default weight of {@code 1}. */ + public void addSpawn(MobSpawnSettings.SpawnerData spawn) { + this.addSpawn(spawn, 1); + } + + /** Adds a spawn to the overrides. */ + public void addSpawn(MobSpawnSettings.SpawnerData spawn, int weight) { + this.spawns.add(new Weighted<>(Objects.requireNonNull(spawn), weight)); } /** - * Adds a spawn to the overrides. + * Removes all instances of a given spawn from the list of overrides. Use {@link #getSpawns()} to get instances + * of spawn data to remove. */ - public void addSpawn(MobSpawnSettings.SpawnerData spawn) - { - this.spawns.add(spawn); + public void removeSpawn(MobSpawnSettings.SpawnerData spawn) { + this.spawns.removeIf(s -> s.value().equals(spawn)); } - /** - * Removes a given spawn from the list of overrides. Use {@link #getSpawns()} to get instances of spawn data to remove. - */ - public void removeSpawn(MobSpawnSettings.SpawnerData spawn) - { - this.spawns.remove(spawn); - } - - /** - * @return A new StructureSpawnOverride with the finalized values. - */ - public StructureSpawnOverride build() - { - return new StructureSpawnOverride(boundingBox, WeightedRandomList.create(spawns)); + /** @return A new StructureSpawnOverride with the finalized values. */ + public StructureSpawnOverride build() { + return new StructureSpawnOverride(this.boundingBox, WeightedList.of(this.spawns)); } } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/energy/EnergyStorage.java b/src/main/java/net/minecraftforge/energy/EnergyStorage.java index 00ec285875..02c0247d47 100644 --- a/src/main/java/net/minecraftforge/energy/EnergyStorage.java +++ b/src/main/java/net/minecraftforge/energy/EnergyStorage.java @@ -91,8 +91,6 @@ public class EnergyStorage implements IEnergyStorage, INBTSerializable { @Override public void deserializeNBT(HolderLookup.Provider registryAccess, Tag nbt) { - if (!(nbt instanceof IntTag intNbt)) - throw new IllegalArgumentException("Can not deserialize to an instance that isn't the default implementation"); - this.energy = intNbt.getAsInt(); + this.energy = nbt.asInt().orElseThrow(() -> new IllegalArgumentException("Can not deserialize to an instance that isn't the default implementation")); } } diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index 493e076a29..77cfd97350 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -15,9 +15,8 @@ import java.util.function.BooleanSupplier; import java.util.function.Consumer; import net.minecraft.core.HolderLookup; -import net.minecraft.core.LayeredRegistryAccess; import net.minecraft.core.component.DataComponentMap; -import net.minecraft.server.RegistryLayer; +import net.minecraft.util.random.WeightedList; import net.minecraft.world.entity.*; import net.minecraft.world.item.Item; import net.minecraft.world.level.chunk.storage.SerializableChunkData; @@ -62,7 +61,6 @@ import net.minecraft.server.players.PlayerList; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.util.RandomSource; -import net.minecraft.util.random.WeightedRandomList; import net.minecraft.world.Container; import net.minecraft.world.Difficulty; import net.minecraft.world.DifficultyInstance; @@ -293,7 +291,7 @@ public final class ForgeEventFactory { /** * Specialized variant of {@link #checkSpawnPosition} for spawners, as they have slightly different checks. - * @see #CheckSpawnPosition + * @see #checkSpawnPosition(Mob, ServerLevelAccessor, EntitySpawnReason) * @implNote See in-line comments about custom spawn rules. */ public static boolean checkSpawnPositionSpawner(Mob mob, ServerLevelAccessor level, EntitySpawnReason spawnType, SpawnData spawnData, BaseSpawner spawner) { @@ -331,7 +329,7 @@ public final class ForgeEventFactory { * The only code that changes is the {@link Mob#finalizeSpawn} call. * @return The SpawnGroupData from this event, or null if it was canceled. The return value of this method has no bearing on if the entity will be spawned. * @see MobSpawnEvent.FinalizeSpawn - * @see Mob#finalizeSpawn(ServerLevelAccessor, DifficultyInstance, MobSpawnType, SpawnGroupData, CompoundTag) + * @see Mob#finalizeSpawn(ServerLevelAccessor, DifficultyInstance, EntitySpawnReason, SpawnGroupData) * @apiNote Callers do not need to check if the entity's spawn was cancelled, as the spawn will be blocked by Forge. * @implNote Changes to the signature of this method must be reflected in the method redirector coremod. */ @@ -507,7 +505,7 @@ public final class ForgeEventFactory { boolean isCanceled = post(new EntityMountEvent(entityMounting, entityBeingMounted, entityMounting.level(), isMounting)); if(isCanceled) { - entityMounting.absMoveTo(entityMounting.getX(), entityMounting.getY(), entityMounting.getZ(), entityMounting.yRotO, entityMounting.xRotO); + entityMounting.absSnapTo(entityMounting.getX(), entityMounting.getY(), entityMounting.getZ(), entityMounting.yRotO, entityMounting.xRotO); return false; } else return true; @@ -533,8 +531,8 @@ public final class ForgeEventFactory { post(new PlayerFlyableFallEvent(player, distance, multiplier)); } - public static boolean onPlayerSpawnSet(Player player, ResourceKey levelKey, BlockPos pos, boolean forced) { - return post(new PlayerSetSpawnEvent(player, levelKey, pos, forced)); + public static boolean onPlayerSpawnSet(ServerPlayer player, ServerPlayer.RespawnConfig config) { + return post(new PlayerSetSpawnEvent(player, config)); } public static PlayerSpawnPhantomsEvent onPlayerSpawnPhantom(Player player, int phantomsToSpawn) { @@ -623,7 +621,7 @@ public final class ForgeEventFactory { var canContinueSleep = evt.getResult(); if (canContinueSleep == Result.DEFAULT) - return !player.level().isDay(); + return !player.level().isBrightOutside(); else return canContinueSleep == Result.ALLOW; } @@ -829,12 +827,12 @@ public final class ForgeEventFactory { post(new TickEvent.ServerTickEvent.Post(haveTime, server)); } - public static WeightedRandomList getPotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedRandomList oldList) { + public static WeightedList getPotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedList oldList) { LevelEvent.PotentialSpawns event = new LevelEvent.PotentialSpawns(level, category, pos, oldList); if (post(event)) - return WeightedRandomList.create(); + return WeightedList.of(); //System.out.println("List: " + oldList.unwrap() + " " + event.getSpawnerDataList()); - return WeightedRandomList.create(event.getSpawnerDataList()); + return WeightedList.of(event.getSpawnerDataList()); } public static void onAdvancementEarned(Player player, AdvancementHolder holder) { @@ -913,8 +911,8 @@ public final class ForgeEventFactory { return fire(new LivingSwapItemsEvent.Hands(entity)); } - public static ShieldBlockEvent onShieldBlock(LivingEntity blocker, DamageSource source, float blocked) { - return fire(new ShieldBlockEvent(blocker, source, blocked)); + public static ShieldBlockEvent onShieldBlock(LivingEntity blocker, DamageSource source, float blocked, ItemStack blockedWith) { + return fire(new ShieldBlockEvent(blocker, source, blocked, blockedWith)); } public static void onEntityEnterSection(Entity entity, long packedOldPos, long packedNewPos) { @@ -925,7 +923,7 @@ public final class ForgeEventFactory { return post(new LivingEvent.LivingTickEvent(entity)); } - public static LivingFallEvent onLivingFall(LivingEntity entity, float distance, float damageMultiplier) { + public static LivingFallEvent onLivingFall(LivingEntity entity, double distance, float damageMultiplier) { return fire(new LivingFallEvent(entity, distance, damageMultiplier)); } @@ -1090,7 +1088,7 @@ public final class ForgeEventFactory { return fire(new LootingLevelEvent(target, cause, level)); } - public static boolean fireFarmlandTrampleEvent(ServerLevel level, BlockPos pos, BlockState state, float fallDistance, Entity entity) { + public static boolean fireFarmlandTrampleEvent(ServerLevel level, BlockPos pos, BlockState state, double fallDistance, Entity entity) { return post(new BlockEvent.FarmlandTrampleEvent(level, pos, state, fallDistance, entity)); } } diff --git a/src/main/java/net/minecraftforge/event/RegisterGameTestsEvent.java b/src/main/java/net/minecraftforge/event/RegisterGameTestsEvent.java deleted file mode 100644 index e2da795d20..0000000000 --- a/src/main/java/net/minecraftforge/event/RegisterGameTestsEvent.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.event; - -import net.minecraft.gametest.framework.GameTest; -import net.minecraft.gametest.framework.GameTestGenerator; -import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.IModBusEvent; -import net.minecraftforge.gametest.ForgeGameTestHooks; - -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Set; - -/** - * Game tests are registered on client or server startup. - * It is only run once for a given instance of the game if {@link ForgeGameTestHooks#isGametestEnabled} returns true. - * This is the preferred way to register your game tests. - *

- * Fired on the Mod bus, see {@link IModBusEvent}. - */ -public class RegisterGameTestsEvent extends Event implements IModBusEvent { - private final Set gameTestMethods; - - public RegisterGameTestsEvent(Set gameTestMethods) { - this.gameTestMethods = gameTestMethods; - } - - /** - * Registers an entire class to the game test registry. - * All methods annotated with {@link GameTest} or {@link GameTestGenerator} will be registered. - * If the set of enabled batches is non-empty, a method will only be registered if its - * {@link GameTest#batch() batch} is listed. - * - * @param testClass the test class to register to the game test registry - */ - public void register(Class testClass) { - Arrays.stream(testClass.getDeclaredMethods()).forEach(this::register); - } - - /** - * Registers a single method to the game test registry. - * The method will only be registered if it is annotated with {@link GameTest} or {@link GameTestGenerator}. - * If the set of enabled batches is non-empty, the method will only be registered if its - * {@link GameTest#batch() batch} is listed. - * - * @param testMethod the test method to register to the game test registry - */ - public void register(Method testMethod) { - this.gameTestMethods.add(testMethod); - } -} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java index 8ebbaaac6c..5381cb2734 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java @@ -14,9 +14,9 @@ import net.minecraft.world.entity.LivingEntity; /** * LivingFallEvent is fired when an Entity is set to be falling.
* This event is fired whenever an Entity is set to fall in - * {@link LivingEntity#causeFallDamage(float, float, DamageSource)}.
+ * {@link LivingEntity#causeFallDamage(double, float, DamageSource)}.
*
- * This event is fired via the {@link ForgeHooks#onLivingFall(LivingEntity, float, float)}.
+ * This event is fired via the {@link net.minecraftforge.event.ForgeEventFactory#onLivingFall(LivingEntity, double, float)}.
*
* {@link #distance} contains the distance the Entity is to fall. If this event is canceled, this value is set to 0.0F. *
@@ -28,19 +28,18 @@ import net.minecraft.world.entity.LivingEntity; * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ @Cancelable -public class LivingFallEvent extends LivingEvent -{ - private float distance; +public class LivingFallEvent extends LivingEvent { + private double distance; private float damageMultiplier; - public LivingFallEvent(LivingEntity entity, float distance, float damageMultiplier) - { + + public LivingFallEvent(LivingEntity entity, double distance, float damageMultiplier) { super(entity); - this.setDistance(distance); - this.setDamageMultiplier(damageMultiplier); + this.distance = distance; + this.damageMultiplier = damageMultiplier; } - public float getDistance() { return distance; } - public void setDistance(float distance) { this.distance = distance; } + public double getDistance() { return this.distance; } + public void setDistance(double distance) { this.distance = distance; } public float getDamageMultiplier() { return damageMultiplier; } public void setDamageMultiplier(float damageMultiplier) { this.damageMultiplier = damageMultiplier; } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/ShieldBlockEvent.java b/src/main/java/net/minecraftforge/event/entity/living/ShieldBlockEvent.java index 7b993dfe1f..b415852b44 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/ShieldBlockEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/ShieldBlockEvent.java @@ -8,6 +8,7 @@ package net.minecraftforge.event.entity.living; import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.eventbus.api.Cancelable; /** @@ -18,70 +19,56 @@ import net.minecraftforge.eventbus.api.Cancelable; * at least for players. */ @Cancelable -public class ShieldBlockEvent extends LivingEvent -{ +public class ShieldBlockEvent extends LivingEvent { private final DamageSource source; private final float originalBlocked; private float dmgBlocked; private boolean shieldTakesDamage = true; + private final ItemStack blockedWith; - public ShieldBlockEvent(LivingEntity blocker, DamageSource source, float blocked) - { + public ShieldBlockEvent(LivingEntity blocker, DamageSource source, float blocked, ItemStack blockedWith) { super(blocker); this.source = source; this.originalBlocked = blocked; this.dmgBlocked = blocked; + this.blockedWith = blockedWith; } - /** - * @return The damage source. - */ - public DamageSource getDamageSource() - { + /** @return The damage source. */ + public DamageSource getDamageSource() { return this.source; } - /** - * @return The original amount of damage blocked, which is the same as the original - * incoming damage value. - */ - public float getOriginalBlockedDamage() - { + /** @return The original amount of damage blocked, which is the same as the original incoming damage value. */ + public float getOriginalBlockedDamage() { return this.originalBlocked; } - /** - * @return The current amount of damage blocked, as a result of this event. - */ - public float getBlockedDamage() - { + /** @return The current amount of damage blocked, as a result of this event. */ + public float getBlockedDamage() { return this.dmgBlocked; } - /** - * Controls if {@link LivingEntity#hurtCurrentlyUsedShield} is called. - * @return If the shield item will take durability damage or not. - */ - public boolean shieldTakesDamage() - { + /** @return If the shield item will take durability damage or not. */ + public boolean shieldTakesDamage() { return this.shieldTakesDamage; } /** - * Set how much damage is blocked by this action.
- * Note that initially the blocked amount is the entire attack.
+ * Sets how much damage is blocked by this action. + *

Note that initially the blocked amount is the entire attack.

*/ - public void setBlockedDamage(float blocked) - { + public void setBlockedDamage(float blocked) { this.dmgBlocked = Mth.clamp(blocked, 0, this.originalBlocked); } - /** - * Set if the shield will take durability damage or not. - */ - public void setShieldTakesDamage(boolean damage) - { + /** Sets if the shield will take durability damage or not. */ + public void setShieldTakesDamage(boolean damage) { this.shieldTakesDamage = damage; } + /** @return The item that was used to block damage. */ + public ItemStack getBlockedWith() { + return this.blockedWith; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java index a0103f9e56..183627a7cb 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java @@ -6,48 +6,67 @@ package net.minecraftforge.event.entity.player; import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.Level; -import net.minecraft.world.entity.player.Player; import net.minecraft.core.BlockPos; import net.minecraftforge.eventbus.api.Cancelable; import org.jetbrains.annotations.Nullable; /** - * This event is fired when a player's spawn point is set or reset.
+ * This event is fired when a player's spawn point is set or reset. + *

* The event can be canceled, which will prevent the spawn point from being changed. */ @Cancelable -public class PlayerSetSpawnEvent extends PlayerEvent -{ - private final ResourceKey spawnLevel; - private final boolean forced; - @Nullable - private final BlockPos newSpawn; +public class PlayerSetSpawnEvent extends PlayerEvent { + private final @Nullable ServerPlayer.RespawnConfig config; - public PlayerSetSpawnEvent(Player player, ResourceKey spawnLevel, @Nullable BlockPos newSpawn, boolean forced) - { + @Deprecated(forRemoval = true, since = "1.21.5") + private final ResourceKey spawnLevel; + @Deprecated(forRemoval = true, since = "1.21.5") + private final boolean forced; + @Deprecated(forRemoval = true, since = "1.21.5") + private final @Nullable BlockPos newSpawn; + + public PlayerSetSpawnEvent(ServerPlayer player, @Nullable ServerPlayer.RespawnConfig config) { super(player); - this.spawnLevel = spawnLevel; - this.newSpawn = newSpawn; - this.forced = forced; + this.config = config; + + boolean hasConfig = config != null; + this.forced = hasConfig && config.forced(); + this.spawnLevel = hasConfig ? config.dimension() : Level.OVERWORLD; + this.newSpawn = hasConfig ? config.pos() : null; } - public boolean isForced() - { - return forced; + /** @return The config for the player respawn */ + public @Nullable ServerPlayer.RespawnConfig getConfig() { + return this.config; } /** - * The new spawn position, or null if the spawn position is being reset. + * @return If the new spawn point is forced + * @deprecated Use {@link ServerPlayer.RespawnConfig#forced()} via {@link #getConfig()} */ - @Nullable - public BlockPos getNewSpawn() - { - return newSpawn; + @Deprecated(forRemoval = true, since = "1.21.5") + public boolean isForced() { + return this.forced; } - public ResourceKey getSpawnLevel() - { - return spawnLevel; + /** + * @return The new spawn position, or {@code null} if the spawn position is being reset + * @deprecated Use {@link ServerPlayer.RespawnConfig#pos()} via {@link #getConfig()} + */ + @Deprecated(forRemoval = true, since = "1.21.5") + public @Nullable BlockPos getNewSpawn() { + return this.newSpawn; + } + + /** + * @return The new spawn dimension, defaulting to {@link Level#OVERWORLD} if it is {@code null} + * @deprecated Use {@link ServerPlayer.RespawnConfig#dimension()} via {@link #getConfig()} + */ + @Deprecated(forRemoval = true, since = "1.21.5") + public ResourceKey getSpawnLevel() { + return this.spawnLevel; } } diff --git a/src/main/java/net/minecraftforge/event/level/BlockEvent.java b/src/main/java/net/minecraftforge/event/level/BlockEvent.java index 7007698059..f1a39f0b23 100644 --- a/src/main/java/net/minecraftforge/event/level/BlockEvent.java +++ b/src/main/java/net/minecraftforge/event/level/BlockEvent.java @@ -337,9 +337,9 @@ public class BlockEvent extends Event { @Cancelable public static class FarmlandTrampleEvent extends BlockEvent { private final Entity entity; - private final float fallDistance; + private final double fallDistance; - public FarmlandTrampleEvent(ServerLevel level, BlockPos pos, BlockState state, float fallDistance, Entity entity) { + public FarmlandTrampleEvent(ServerLevel level, BlockPos pos, BlockState state, double fallDistance, Entity entity) { super(level, pos, state); this.entity = entity; this.fallDistance = fallDistance; @@ -349,7 +349,7 @@ public class BlockEvent extends Event { return entity; } - public float getFallDistance() { + public double getFallDistance() { return fallDistance; } diff --git a/src/main/java/net/minecraftforge/event/level/LevelEvent.java b/src/main/java/net/minecraftforge/event/level/LevelEvent.java index 8b5a7cec5e..f3bb055327 100644 --- a/src/main/java/net/minecraftforge/event/level/LevelEvent.java +++ b/src/main/java/net/minecraftforge/event/level/LevelEvent.java @@ -10,42 +10,44 @@ import java.util.Collections; import java.util.List; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.ReceivingLevelScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.ProgressListener; -import net.minecraft.util.random.WeightedRandomList; +import net.minecraft.util.random.Weighted; +import net.minecraft.util.random.WeightedList; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.StructureManager; import net.minecraft.world.level.biome.MobSpawnSettings; +import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.storage.ServerLevelData; -import net.minecraftforge.common.ForgeInternalHandler; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.LogicalSide; +import org.jetbrains.annotations.UnmodifiableView; /** * This event is fired whenever an event involving a {@link LevelAccessor} occurs. *

* All children of this event are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}. */ -public class LevelEvent extends Event -{ +public class LevelEvent extends Event { private final LevelAccessor level; - public LevelEvent(LevelAccessor level) - { + public LevelEvent(LevelAccessor level) { this.level = level; } /** * {@return the level this event is affecting} */ - public LevelAccessor getLevel() - { + public LevelAccessor getLevel() { return level; } @@ -59,26 +61,23 @@ public class LevelEvent extends Event * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * on both logical sides. **/ - public static class Load extends LevelEvent - { + public static class Load extends LevelEvent { public Load(LevelAccessor level) { super(level); } } /** * This event is fired whenever a level unloads. * This event is fired whenever a level unloads in - * {@link Minecraft#setLevel(ClientLevel)}, + * {@link Minecraft#setLevel(ClientLevel, ReceivingLevelScreen.Reason)}, * {@link MinecraftServer#stopServer()}, - * {@link Minecraft#clearLevel(Screen)}, and - * {@link ForgeInternalHandler#onDimensionUnload(Unload)}. + * {@link Minecraft#clearClientLevel(Screen)}. *

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

* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * on both logical sides. **/ - public static class Unload extends LevelEvent - { + public static class Unload extends LevelEvent { public Unload(LevelAccessor level) { super(level); } } @@ -92,8 +91,7 @@ public class LevelEvent extends Event * This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus} * only on the {@linkplain LogicalSide#SERVER logical server}. **/ - public static class Save extends LevelEvent - { + public static class Save extends LevelEvent { public Save(LevelAccessor level) { super(level); } } @@ -110,18 +108,15 @@ public class LevelEvent extends Event * @see ServerLevelData#isInitialized() */ @Cancelable - public static class CreateSpawnPosition extends LevelEvent - { + public static class CreateSpawnPosition extends LevelEvent { private final ServerLevelData settings; - public CreateSpawnPosition(LevelAccessor level, ServerLevelData settings) - { + public CreateSpawnPosition(LevelAccessor level, ServerLevelData settings) { super(level); this.settings = settings; } - public ServerLevelData getSettings() - { + public ServerLevelData getSettings() { return settings; } } @@ -131,22 +126,20 @@ public class LevelEvent extends Event * *

If an entry is added to the list, it needs to be a globally unique instance.

* - * The event is called in {@link net.minecraft.world.level.NaturalSpawner#mobsAt(ServerLevel, - * StructureManager, ChunkGenerator, MobCategory, RandomSource, BlockPos)}.

+ * The event is called in {@link net.minecraft.world.level.NaturalSpawner#mobsAt(ServerLevel, StructureManager, + * ChunkGenerator, MobCategory, BlockPos, Holder)}.

* *

This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. * Canceling the event will result in an empty list, meaning no entity will be spawned.

*/ @Cancelable - public static class PotentialSpawns extends LevelEvent - { + public static class PotentialSpawns extends LevelEvent { private final MobCategory mobcategory; private final BlockPos pos; - private final List list; - private final List view; + private final List> list; + private final @UnmodifiableView List> view; - public PotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedRandomList oldList) - { + public PotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedList oldList) { super(level); this.pos = pos; this.mobcategory = category; @@ -158,50 +151,39 @@ public class LevelEvent extends Event this.view = Collections.unmodifiableList(list); } - /** - * {@return the category of the mobs in the spawn list.} - */ - public MobCategory getMobCategory() - { - return mobcategory; + /** @return the category of the mobs in the spawn list. */ + public MobCategory getMobCategory() { + return this.mobcategory; } - /** - * {@return the block position where the chosen mob will be spawned.} - */ - public BlockPos getPos() - { - return pos; + /** @return the block position where the chosen mob will be spawned. */ + public BlockPos getPos() { + return this.pos; } - /** - * {@return the list of mobs that can potentially be spawned.} - */ - public List getSpawnerDataList() - { - return view; + /** @return the list of mobs that can potentially be spawned. */ + public @UnmodifiableView List> getSpawnerDataList() { + return this.view; } /** * Appends a SpawnerData entry to the spawn list. * - * @param data SpawnerData entry to be appended to the spawn list. + * @param data SpawnerData entry to be appended to the spawn list. + * @param weight The weight for the data entry to have in the list. */ - public void addSpawnerData(MobSpawnSettings.SpawnerData data) - { - list.add(data); + public void addSpawnerData(MobSpawnSettings.SpawnerData data, int weight) { + this.list.add(new Weighted<>(data, weight)); } /** - * Removes a SpawnerData entry from the spawn list. + * Removes all entries of the given SpawnerData from the spawn list. * * @param data SpawnerData entry to be removed from the spawn list. - * - * {@return {@code true} if the spawn list contained the specified element.} + * @return {@code true} if the spawn list contained the specified element. */ - public boolean removeSpawnerData(MobSpawnSettings.SpawnerData data) - { - return list.remove(data); + public boolean removeSpawnerData(MobSpawnSettings.SpawnerData data) { + return this.list.removeIf(weighted -> weighted.value().equals(data)); } } } diff --git a/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java b/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java index e270eaea95..ef699dd788 100644 --- a/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java +++ b/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java @@ -8,6 +8,7 @@ package net.minecraftforge.event.village; import java.util.List; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.entity.npc.VillagerData; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; @@ -16,35 +17,29 @@ import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.event.server.ServerAboutToStartEvent; /** - * VillagerTradesEvent is fired during the {@link ServerAboutToStartEvent}. It is used to gather the trade lists for each profession. - * It is fired on the {@link MinecraftForge#EVENT_BUS}. - * It is fired once for each registered villager profession. - * Villagers pick two trades from their trade map, based on their level. - * Villager level is increased by successful trades. - * The map is populated for levels 1-5 (inclusive), so Map#get will never return null for those keys. - * Levels outside of this range do nothing, as specified by {@link VillagerData#canLevelUp(int)} which is called before attempting to level up. - * To add trades to the merchant, simply add new trades to the list. {@link BasicItemListing} provides a default implementation. + * VillagerTradesEvent is fired during the {@link ServerAboutToStartEvent}. It is used to gather the trade lists for each profession. + *

It is fired on the {@link MinecraftForge#EVENT_BUS}.

+ *

It is fired once for each registered villager profession.

+ *

Villagers pick two trades from their trade map, based on their level.

+ *

Villager level is increased by successful trades.

+ *

The map is populated for levels 1-5 (inclusive), so getting a value will never return null for those keys.

+ *

Levels outside of this range do nothing, as specified by {@link VillagerData#canLevelUp(int)} which is called before attempting to level up.

+ *

To add trades to the merchant, simply add new trades to the list.

*/ -public class VillagerTradesEvent extends Event -{ - +public class VillagerTradesEvent extends Event { protected Int2ObjectMap> trades; - protected VillagerProfession type; + protected ResourceKey type; - public VillagerTradesEvent(Int2ObjectMap> trades, VillagerProfession type) - { + public VillagerTradesEvent(Int2ObjectMap> trades, ResourceKey type) { this.trades = trades; this.type = type; } - public Int2ObjectMap> getTrades() - { - return trades; + public Int2ObjectMap> getTrades() { + return this.trades; } - public VillagerProfession getType() - { - return type; + public ResourceKey getType() { + return this.type; } - } diff --git a/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java b/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java index 6c7c0cdac4..cb3c724b53 100644 --- a/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java +++ b/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java @@ -5,8 +5,13 @@ package net.minecraftforge.event.village; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import org.apache.commons.lang3.tuple.Pair; + +import net.minecraft.Util; import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Event; @@ -15,28 +20,39 @@ import net.minecraftforge.event.server.ServerAboutToStartEvent; /** * WandererTradesEvent is fired during the {@link ServerAboutToStartEvent}. It is used to gather the trade lists for the wandering merchant. * It is fired on the {@link MinecraftForge#EVENT_BUS}. - * The wandering merchant picks a few trades from {@code generic} and a single trade from {@code rare}. + * The wandering merchant picks {@link Pool#rolls} from each {@link Pool} * To add trades to the merchant, simply add new trades to the list. {@link BasicItemListing} provides a default implementation. */ -public class WandererTradesEvent extends Event -{ +public class WandererTradesEvent extends Event { + protected List pools; - protected List generic; - protected List rare; - - public WandererTradesEvent(List generic, List rare) - { - this.generic = generic; - this.rare = rare; + public WandererTradesEvent(List> pools) { + this.pools = pools.stream().map(Pool::new).collect(Util.toMutableList()); } - public List getGenericTrades() - { - return generic; + public List getPools() { + return pools; } - public List getRareTrades() - { - return rare; + public static class Pool { + private int rolls; + private List entries; + + public Pool(Pair data) { + this.rolls = data.getRight(); + this.entries = new ArrayList<>(Arrays.asList(data.getLeft())); + } + + public int getRolls() { + return this.rolls; + } + + public void setRolls(int value) { + this.rolls = value; + } + + public List getEntries() { + return this.entries; + } } } diff --git a/src/main/java/net/minecraftforge/fluids/FluidStack.java b/src/main/java/net/minecraftforge/fluids/FluidStack.java index 73e6c1d003..5e6970e921 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidStack.java +++ b/src/main/java/net/minecraftforge/fluids/FluidStack.java @@ -22,7 +22,9 @@ import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import java.util.Objects; import java.util.Optional; /** @@ -33,8 +35,7 @@ import java.util.Optional; * equal. * */ -public class FluidStack -{ +public class FluidStack { private static final Logger LOGGER = LogManager.getLogger(); public static final FluidStack EMPTY = new FluidStack(Fluids.EMPTY, 0); @@ -53,18 +54,14 @@ public class FluidStack private boolean isEmpty; private int amount; - private CompoundTag tag; - private Holder.Reference fluidDelegate; + private @Nullable CompoundTag tag; + private final Holder.Reference fluidDelegate; - public FluidStack(Fluid fluid, int amount) - { - if (fluid == null) - { + public FluidStack(Fluid fluid, int amount) { + if (fluid == null) { LOGGER.fatal("Null fluid supplied to fluidstack. Did you try and create a stack for an unregistered fluid?"); throw new IllegalArgumentException("Cannot create a fluidstack from a null fluid"); - } - else if (ForgeRegistries.FLUIDS.getKey(fluid) == null) - { + } else if (ForgeRegistries.FLUIDS.getKey(fluid) == null) { LOGGER.fatal("Failed attempt to create a FluidStack for an unregistered Fluid {} (type {})", ForgeRegistries.FLUIDS.getKey(fluid), fluid.getClass().getName()); throw new IllegalArgumentException("Cannot create a fluidstack from an unregistered fluid"); } @@ -74,18 +71,14 @@ public class FluidStack updateEmpty(); } - public FluidStack(Fluid fluid, int amount, CompoundTag nbt) - { + public FluidStack(Fluid fluid, int amount, CompoundTag nbt) { this(fluid, amount); if (nbt != null) - { tag = nbt.copy(); - } } - public FluidStack(FluidStack stack, int amount) - { + public FluidStack(FluidStack stack, int amount) { this(stack.getFluid(), amount, stack.tag); } @@ -93,51 +86,39 @@ public class FluidStack * This provides a safe method for retrieving a FluidStack - if the Fluid is invalid, the stack * will return as null. */ - public static FluidStack loadFluidStackFromNBT(CompoundTag nbt) - { + public static FluidStack loadFluidStackFromNBT(CompoundTag nbt) { if (nbt == null) - { return EMPTY; - } - if (!nbt.contains("FluidName", Tag.TAG_STRING)) - { - return EMPTY; - } - ResourceLocation fluidName = ResourceLocation.parse(nbt.getString("FluidName")); + var fluidNameString = nbt.getString("FluidName"); + if (fluidNameString.isEmpty()) + return EMPTY; + + ResourceLocation fluidName = ResourceLocation.parse(fluidNameString.get()); Fluid fluid = ForgeRegistries.FLUIDS.getValue(fluidName); if (fluid == null) - { return EMPTY; - } - FluidStack stack = new FluidStack(fluid, nbt.getInt("Amount")); - if (nbt.contains("Tag", Tag.TAG_COMPOUND)) - { - stack.tag = nbt.getCompound("Tag"); - } + FluidStack stack = new FluidStack(fluid, nbt.getIntOr("Amount", 0)); + + nbt.getCompound("Tag").ifPresent(tag -> stack.tag = tag); return stack; } - public CompoundTag writeToNBT(CompoundTag nbt) - { + public CompoundTag writeToNBT(CompoundTag nbt) { nbt.putString("FluidName", ForgeRegistries.FLUIDS.getKey(getFluid()).toString()); nbt.putInt("Amount", amount); if (tag != null) - { nbt.put("Tag", tag); - } return nbt; } - public final Fluid getFluid() - { + public final Fluid getFluid() { return isEmpty ? Fluids.EMPTY : fluidDelegate.get(); } - public final Fluid getRawFluid() - { + public final Fluid getRawFluid() { return fluidDelegate.get(); } @@ -149,13 +130,11 @@ public class FluidStack isEmpty = getRawFluid() == Fluids.EMPTY || amount <= 0; } - public int getAmount() - { + public int getAmount() { return isEmpty ? 0 : amount ; } - public void setAmount(int amount) - { + public void setAmount(int amount) { if (getRawFluid() == Fluids.EMPTY) throw new IllegalStateException("Can't modify the empty stack."); this.amount = amount; updateEmpty(); @@ -169,68 +148,60 @@ public class FluidStack setAmount(this.amount - amount); } - public boolean hasTag() - { + public boolean hasTag() { return tag != null; } - public CompoundTag getTag() - { + public CompoundTag getTag() { return tag; } - public void setTag(CompoundTag tag) - { + public void setTag(CompoundTag tag) { if (getRawFluid() == Fluids.EMPTY) throw new IllegalStateException("Can't modify the empty stack."); this.tag = tag; } - public CompoundTag getOrCreateTag() - { + public CompoundTag getOrCreateTag() { if (tag == null) setTag(new CompoundTag()); return tag; } - public CompoundTag getChildTag(String childName) - { + public @Nullable CompoundTag getChildTag(String childName) { if (tag == null) return null; - return tag.getCompound(childName); + return tag.getCompoundOrEmpty(childName); } - public CompoundTag getOrCreateChildTag(String childName) - { + public CompoundTag getOrCreateChildTag(String childName) { getOrCreateTag(); - CompoundTag child = tag.getCompound(childName); - if (!tag.contains(childName, Tag.TAG_COMPOUND)) - { + var optional = tag.getCompound(childName); + if (optional.isEmpty()) { + var child = new CompoundTag(); tag.put(childName, child); + return child; } - return child; + + return optional.get(); } - public void removeChildTag(String childName) - { + public void removeChildTag(String childName) { if (tag != null) tag.remove(childName); } - public Component getDisplayName() - { + public Component getDisplayName() { return this.getFluid().getFluidType().getDescription(this); } - public String getTranslationKey() - { + public String getTranslationKey() { return this.getFluid().getFluidType().getDescriptionId(this); } /** * @return A copy of this FluidStack */ - public FluidStack copy() - { + public FluidStack copy() { return new FluidStack(getFluid(), amount, tag); } @@ -241,21 +212,18 @@ public class FluidStack * The FluidStack for comparison * @return true if the Fluids (IDs and NBT Tags) are the same */ - public boolean isFluidEqual(@NotNull FluidStack other) - { + public boolean isFluidEqual(@NotNull FluidStack other) { return getFluid() == other.getFluid() && isFluidStackTagEqual(other); } - private boolean isFluidStackTagEqual(FluidStack other) - { + private boolean isFluidStackTagEqual(FluidStack other) { return tag == null ? other.tag == null : other.tag != null && tag.equals(other.tag); } /** * Determines if the NBT Tags are equal. Useful if the FluidIDs are known to be equal. */ - public static boolean areFluidStackTagsEqual(@NotNull FluidStack stack1, @NotNull FluidStack stack2) - { + public static boolean areFluidStackTagsEqual(@NotNull FluidStack stack1, @NotNull FluidStack stack2) { return stack1.isFluidStackTagEqual(stack2); } @@ -264,8 +232,7 @@ public class FluidStack * * @return true if this FluidStack contains the other FluidStack (same fluid and >= amount) */ - public boolean containsFluid(@NotNull FluidStack other) - { + public boolean containsFluid(@NotNull FluidStack other) { return isFluidEqual(other) && amount >= other.amount; } @@ -276,8 +243,7 @@ public class FluidStack * - the FluidStack for comparison * @return true if the two FluidStacks are exactly the same */ - public boolean isFluidStackIdentical(FluidStack other) - { + public boolean isFluidStackIdentical(FluidStack other) { return isFluidEqual(other) && amount == other.amount; } @@ -289,14 +255,12 @@ public class FluidStack * The ItemStack for comparison * @return true if the Fluids (IDs and NBT Tags) are the same */ - public boolean isFluidEqual(@NotNull ItemStack other) - { + public boolean isFluidEqual(@NotNull ItemStack other) { return FluidUtil.getFluidContained(other).map(this::isFluidEqual).orElse(false); } @Override - public final int hashCode() - { + public final int hashCode() { int code = 1; code = 31*code + getFluid().hashCode(); if (tag != null) @@ -310,12 +274,7 @@ public class FluidStack * This is included for use in data structures. */ @Override - public final boolean equals(Object o) - { - if (!(o instanceof FluidStack)) - { - return false; - } - return isFluidEqual((FluidStack) o); + public final boolean equals(Object o) { + return o instanceof FluidStack stack && isFluidEqual(stack); } } diff --git a/src/main/java/net/minecraftforge/fluids/FluidType.java b/src/main/java/net/minecraftforge/fluids/FluidType.java index 2696bbcf70..9fae7e0bf3 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidType.java +++ b/src/main/java/net/minecraftforge/fluids/FluidType.java @@ -456,14 +456,14 @@ public class FluidType { * Returns a sound to play when a certain action is performed at a * position. If no sound is present, then the sound will be {@code null}. * - * @param player the player listening to the sound + * @param entity the entity listening to the sound * @param getter the getter which can get the fluid * @param pos the position of the fluid * @param action the action being performed * @return the sound to play when performing the action */ @Nullable - public SoundEvent getSound(@Nullable Player player, BlockGetter getter, BlockPos pos, SoundAction action) { + public SoundEvent getSound(@Nullable LivingEntity entity, BlockGetter getter, BlockPos pos, SoundAction action) { return this.getSound(action); } @@ -784,7 +784,7 @@ public class FluidType { * @param stack the stack holding the fluid being placed * @return {@code true} if this fluid should be vaporized on placement, {@code false} otherwise * - * @see BucketItem#emptyContents(Player, Level, BlockPos, BlockHitResult) + * @see BucketItem#emptyContents(LivingEntity, Level, BlockPos, BlockHitResult) */ public boolean isVaporizedOnPlacement(Level level, BlockPos pos, FluidStack stack) { if (level.dimensionType().ultraWarm()) { @@ -798,16 +798,16 @@ public class FluidType { * *

Note: The fluid will already have been drained from the stack. * - * @param player the player placing the fluid, may be {@code null} for blocks like dispensers + * @param entity the player placing the fluid, may be {@code null} for blocks like dispensers * @param level the level the fluid is vaporized in * @param pos the position the fluid is vaporized at * @param stack the stack holding the fluid being vaporized * - * @see BucketItem#emptyContents(Player, Level, BlockPos, BlockHitResult) + * @see BucketItem#emptyContents(LivingEntity, Level, BlockPos, BlockHitResult) */ - public void onVaporize(@Nullable Player player, Level level, BlockPos pos, FluidStack stack) { - SoundEvent sound = this.getSound(player, level, pos, SoundActions.FLUID_VAPORIZE); - level.playSound(player, pos, sound != null ? sound : SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (level.random.nextFloat() - level.random.nextFloat()) * 0.8F); + public void onVaporize(@Nullable LivingEntity entity, Level level, BlockPos pos, FluidStack stack) { + SoundEvent sound = this.getSound(entity, level, pos, SoundActions.FLUID_VAPORIZE); + level.playSound(entity, pos, sound != null ? sound : SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (level.random.nextFloat() - level.random.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) level.addAlwaysVisibleParticle(ParticleTypes.LARGE_SMOKE, (double) pos.getX() + Math.random(), (double) pos.getY() + Math.random(), (double) pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D); diff --git a/src/main/java/net/minecraftforge/gametest/ForgeGameTestHooks.java b/src/main/java/net/minecraftforge/gametest/ForgeGameTestHooks.java index 1c088378da..48d8f5ffd1 100644 --- a/src/main/java/net/minecraftforge/gametest/ForgeGameTestHooks.java +++ b/src/main/java/net/minecraftforge/gametest/ForgeGameTestHooks.java @@ -6,10 +6,12 @@ package net.minecraftforge.gametest; import net.minecraft.SharedConstants; -import net.minecraft.gametest.framework.GameTest; -import net.minecraft.gametest.framework.GameTestRegistry; -import net.minecraft.gametest.framework.TestFunction; -import net.minecraftforge.event.RegisterGameTestsEvent; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.gametest.framework.GameTestHelper; +import net.minecraft.gametest.framework.GameTestInstance; +import net.minecraft.gametest.framework.TestData; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModLoader; import net.minecraftforge.fml.common.Mod; @@ -17,6 +19,7 @@ import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.fml.util.ObfuscationReflectionHelper; import net.minecraftforge.forgespi.language.ModFileScanData; import net.minecraftforge.forgespi.language.ModFileScanData.AnnotationData; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.ApiStatus; @@ -24,23 +27,25 @@ import org.jetbrains.annotations.Nullable; import org.objectweb.asm.Type; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.Locale; +import java.util.Map; import java.util.Set; import java.util.stream.Collectors; /** * Internal class used to glue mods into the game test framework. - * Modders should use the supplied annotations and {@link RegisterGameTestsEvent} + * Modders should use the supplied annotations and DeferredRegister */ +@SuppressWarnings("unused") @ApiStatus.Internal public class ForgeGameTestHooks { private static boolean registeredGametests = false; private static final Logger LOGGER = LogManager.getLogger(); private static final Type GAME_TEST_HOLDER = Type.getType(GameTestHolder.class); - private static final String DEFAULT_BATCH = getDefaultBatch(); public static boolean isGametestEnabled() { return !FMLLoader.isProduction() && (SharedConstants.IS_RUNNING_IN_IDE || isGametestServer() || Boolean.getBoolean("forge.enableGameTest")); @@ -50,6 +55,7 @@ public class ForgeGameTestHooks { return !FMLLoader.isProduction() && Boolean.getBoolean("forge.gameTestServer"); } +/* @SuppressWarnings("deprecation") public static void registerGametests() { if (!registeredGametests && isGametestEnabled() && ModLoader.isLoadingStateValid()) { @@ -112,6 +118,10 @@ public class ForgeGameTestHooks { if (!shouldPrefix) return null; + return getPrefix(cls); + } + + private static String getPrefix(Class cls) { var prefix = cls.getAnnotation(GameTestPrefix.class); if (prefix != null) return prefix.value(); @@ -120,73 +130,70 @@ public class ForgeGameTestHooks { if (holder != null && !holder.value().isEmpty()) return holder.value(); - var mod = method.getDeclaringClass().getAnnotation(Mod.class); + var mod = cls.getAnnotation(Mod.class); if (mod != null) return mod.value(); return cls.getSimpleName().toLowerCase(Locale.ENGLISH); } - public static String getTestTemplate(Method method, GameTest meta, String testName) { - // If we have a ':' assume we specified the exact template path - if (meta.template().indexOf(':') != -1) - return meta.template(); - - String template = null; - - if (meta.template().isEmpty()) - template = testName; - else - template = getPrefixed(method, meta.template()); - - var cls = method.getDeclaringClass(); - - var holder = cls.getAnnotation(GameTestHolder.class); - if (holder != null && !holder.namespace().isEmpty()) - return holder.namespace() + ':' + template; - - var mod = cls.getAnnotation(Mod.class); - if (mod != null) - return mod.value() + ':' + template; - - return template; + private static ResourceLocation key(String namespace, String path) { + return path.indexOf(':') == -1 ? ResourceLocation.parse(path) : ResourceLocation.fromNamespaceAndPath(namespace, path); } - private static String getDefaultBatch() { - try { - return (String)ObfuscationReflectionHelper.findMethod(GameTest.class, "m_177043" + '_').getDefaultValue(); - } catch (Exception e) { - e.printStackTrace(); // Should never happen, but just in case. - return "defaultBatch"; + public static Map gatherTests(Class root) { + String prefix = getPrefix(root); + var seen = new HashSet(); + + Class cls = root; + while (cls != Object.class) { + for (var method : cls.getDeclaredMethods()) { + if (cls != root && Modifier.isStatic(method.getModifiers())) + continue; + + var gametest = method.getAnnotation(GameTest.class); + if (gametest == null) + continue; + + var owner = method.getDeclaringClass().getName() + "." + method.getName(); + + if (method.getParameterCount() != 1 || method.getParameterTypes()[0] != GameTestHelper.class) + throw new IllegalStateException("Invalid @GameTest function " + owner + " incorrect arguments"); + + var testName = key(prefix, gametest.name().isEmpty() ? method.getName() : gametest.name()); + if (!seen.add(testName)) { + if (!Modifier.isStatic(method.getModifiers())) + continue; + throw new IllegalStateException("Failed to register test, already seen " + testName + ", for " + owner); + } + + if (gametest.type() == GameTest.Type.FUNCTION) { + var funcName = key(prefix, gametest.function()); + var func = BuiltInRegistries.TEST_FUNCTION.get(funcName).orElse(null); + + if (func == null) + throw new IllegalStateException("Could not find referenced function `" + funcName + "` for " + owner); + + var data = getTestData(prefix, owner, gametest.data()); + + + } else if (gametest.type() == GameTest.Type.BLOCK) { + + } else { + throw new IllegalStateException("Could not determine GameTest type for " + root.getName() + " -> " + gametest.type()); + } + + + + + } + cls = cls.getSuperclass(); } } - public static String getTestBatch(Method method, GameTest gametest) { - var batch = gametest.batch(); - - if (DEFAULT_BATCH.equals(batch)) { - var prefix = getPrefix(method); - return prefix == null ? batch : prefix; - } - - return getPrefixed(method, batch.toLowerCase(Locale.ENGLISH)); - } - - public static void addTest(Collection functions, Set classes, Set filters, TestFunction func) { - boolean allowed = filters.isEmpty() || filters.stream().anyMatch(f -> f.equals(func.batchName()) || func.batchName().startsWith(f + '.')); - if (!allowed) - return; - - functions.add(func); - - var batch = func.batchName(); - classes.add(batch); - - int idx = batch.lastIndexOf('.'); - while (idx != -1) { - batch = batch.substring(0, idx); - idx = batch.lastIndexOf('.'); - classes.add(batch); - } + private static TestData getTestData(String prefix, String owner, GameTest.Data data) { + var envName = key(prefix, data.environment()); + var env = BuiltInRegistries.TEST_ENVIRONMENT } +*/ } diff --git a/src/main/java/net/minecraftforge/gametest/GameTest.java b/src/main/java/net/minecraftforge/gametest/GameTest.java new file mode 100644 index 0000000000..f357e41896 --- /dev/null +++ b/src/main/java/net/minecraftforge/gametest/GameTest.java @@ -0,0 +1,44 @@ +package net.minecraftforge.gametest; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import net.minecraft.world.level.block.Rotation; + +@Retention(RUNTIME) +@Target(METHOD) +public @interface GameTest { + String name() default ""; + String function() default ""; + Type type() default Type.BLOCK; + Data data() default @Data; + + + + int rotationSteps() default 0; + + + public enum Type { + BLOCK, + FUNCTION; + } + + /** + * Annotation definitions for {@link net.minecraft.gametest.framework.TestData} + */ + public @interface Data { + String environment() default ""; + String structure() default "forge:empty3x3"; + int maxTicks() default Integer.MAX_VALUE; + int setupTicks() default 0; + boolean required() default false; + Rotation rotation() default Rotation.NONE; + boolean manualOnly() default false; + int maxAttempts() default 1; + int requiredSuccesses() default 1; + boolean skyAccess() default false; + } +} diff --git a/src/main/java/net/minecraftforge/gametest/GameTestHolder.java b/src/main/java/net/minecraftforge/gametest/GameTestHolder.java index df24e27fed..728165ad1c 100644 --- a/src/main/java/net/minecraftforge/gametest/GameTestHolder.java +++ b/src/main/java/net/minecraftforge/gametest/GameTestHolder.java @@ -5,9 +5,6 @@ package net.minecraftforge.gametest; -import net.minecraft.gametest.framework.GameTest; -import net.minecraft.gametest.framework.GameTestGenerator; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerArmorInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerEquipmentInvWrapper.java similarity index 70% rename from src/main/java/net/minecraftforge/items/wrapper/PlayerArmorInvWrapper.java rename to src/main/java/net/minecraftforge/items/wrapper/PlayerEquipmentInvWrapper.java index 43ad2bc577..83aca517b5 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerArmorInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/PlayerEquipmentInvWrapper.java @@ -10,39 +10,32 @@ import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; -public class PlayerArmorInvWrapper extends RangedWrapper -{ +public class PlayerEquipmentInvWrapper extends RangedWrapper { private final Inventory inventoryPlayer; - public PlayerArmorInvWrapper(Inventory inv) - { - super(new InvWrapper(inv), inv.items.size(), inv.items.size() + inv.armor.size()); + public PlayerEquipmentInvWrapper(Inventory inv) { + super(new InvWrapper(inv), inv.getNonEquipmentItems().size(), inv.getNonEquipmentItems().size() + inv.getEquipment().size()); inventoryPlayer = inv; } @Override @NotNull - public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) - { + public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { EquipmentSlot equ = null; - for (EquipmentSlot s : EquipmentSlot.values()) - { - if (s.getType() == EquipmentSlot.Type.HUMANOID_ARMOR && s.getIndex() == slot) - { + for (EquipmentSlot s : EquipmentSlot.values()) { + if (s.getType() == EquipmentSlot.Type.HUMANOID_ARMOR && s.getIndex() == slot) { equ = s; break; } } + // check if it's valid for the armor slot if (equ != null && slot < 4 && !stack.isEmpty() && stack.canEquip(equ, getInventoryPlayer().player)) - { return super.insertItem(slot, stack, simulate); - } return stack; } - public Inventory getInventoryPlayer() - { + public Inventory getInventoryPlayer() { return inventoryPlayer; } } diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerInvWrapper.java deleted file mode 100644 index e02b8ca446..0000000000 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerInvWrapper.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.items.wrapper; - -import net.minecraft.world.entity.player.Inventory; - -public class PlayerInvWrapper extends CombinedInvWrapper -{ - public PlayerInvWrapper(Inventory inv) - { - super(new PlayerMainInvWrapper(inv), new PlayerArmorInvWrapper(inv), new PlayerOffhandInvWrapper(inv)); - } -} diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java index f6755dab39..34ecf7a208 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java @@ -18,7 +18,7 @@ public class PlayerMainInvWrapper extends RangedWrapper { private final Inventory inventoryPlayer; public PlayerMainInvWrapper(Inventory inv) { - super(new InvWrapper(inv), 0, inv.items.size()); + super(new InvWrapper(inv), 0, inv.getNonEquipmentItems().size()); inventoryPlayer = inv; } diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerOffhandInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerOffhandInvWrapper.java deleted file mode 100644 index 44e1c134a1..0000000000 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerOffhandInvWrapper.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.minecraftforge.items.wrapper; - -import net.minecraft.world.entity.player.Inventory; - -public class PlayerOffhandInvWrapper extends RangedWrapper -{ - public PlayerOffhandInvWrapper(Inventory inv) - { - super(new InvWrapper(inv), inv.items.size() + inv.armor.size(), - inv.items.size() + inv.armor.size() + inv.offhand.size()); - } -} diff --git a/src/main/java/net/minecraftforge/items/wrapper/RangedWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/RangedWrapper.java index 38c5e610e9..1a12d12b3c 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/RangedWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/RangedWrapper.java @@ -15,13 +15,11 @@ import org.jetbrains.annotations.NotNull; * Shifting of slot indices is handled automatically for you. */ public class RangedWrapper implements IItemHandlerModifiable { - private final IItemHandlerModifiable compose; private final int minSlot; private final int maxSlot; - public RangedWrapper(IItemHandlerModifiable compose, int minSlot, int maxSlotExclusive) - { + public RangedWrapper(IItemHandlerModifiable compose, int minSlot, int maxSlotExclusive) { Preconditions.checkArgument(maxSlotExclusive > minSlot, "Max slot must be greater than min slot"); this.compose = compose; this.minSlot = minSlot; @@ -29,81 +27,60 @@ public class RangedWrapper implements IItemHandlerModifiable { } @Override - public int getSlots() - { + public int getSlots() { return maxSlot - minSlot; } @Override @NotNull - public ItemStack getStackInSlot(int slot) - { + public ItemStack getStackInSlot(int slot) { if (checkSlot(slot)) - { return compose.getStackInSlot(slot + minSlot); - } return ItemStack.EMPTY; } @Override @NotNull - public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) - { + public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { if (checkSlot(slot)) - { return compose.insertItem(slot + minSlot, stack, simulate); - } return stack; } @Override @NotNull - public ItemStack extractItem(int slot, int amount, boolean simulate) - { + public ItemStack extractItem(int slot, int amount, boolean simulate) { if (checkSlot(slot)) - { return compose.extractItem(slot + minSlot, amount, simulate); - } return ItemStack.EMPTY; } @Override - public void setStackInSlot(int slot, @NotNull ItemStack stack) - { + public void setStackInSlot(int slot, @NotNull ItemStack stack) { if (checkSlot(slot)) - { compose.setStackInSlot(slot + minSlot, stack); - } } @Override - public int getSlotLimit(int slot) - { + public int getSlotLimit(int slot) { if (checkSlot(slot)) - { return compose.getSlotLimit(slot + minSlot); - } return 0; } @Override - public boolean isItemValid(int slot, @NotNull ItemStack stack) - { + public boolean isItemValid(int slot, @NotNull ItemStack stack) { if (checkSlot(slot)) - { return compose.isItemValid(slot + minSlot, stack); - } return false; } - private boolean checkSlot(int localSlot) - { + private boolean checkSlot(int localSlot) { return localSlot + minSlot < maxSlot; } - } diff --git a/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java b/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java index 2f30e09ec9..af7945f255 100644 --- a/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java +++ b/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java @@ -16,8 +16,6 @@ import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.commands.synchronization.ArgumentTypeInfos; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.registries.VanillaRegistries; -import net.minecraft.gametest.framework.TestClassNameArgument; -import net.minecraft.gametest.framework.TestFunctionArgument; import net.minecraft.network.protocol.Packet; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundCommandsPacket; @@ -78,9 +76,6 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter { CommandBuildContext commandBuildContext = Commands.createValidationContext(VanillaRegistries.createLookup()); RootCommandNode root = packet.getRoot(commandBuildContext); RootCommandNode newRoot = CommandTreeCleaner.cleanArgumentTypes(root, argType -> { - if (argType instanceof TestFunctionArgument || argType instanceof TestClassNameArgument) - return false; // Vanilla connections should not have gametest on, so we should filter these out always - ArgumentTypeInfo info = ArgumentTypeInfos.byClass(argType); ResourceLocation id = BuiltInRegistries.COMMAND_ARGUMENT_TYPE.getKey(info); return id != null && (id.getNamespace().equals("minecraft") || id.getNamespace().equals("brigadier")); diff --git a/src/main/java/net/minecraftforge/network/packets/SpawnEntity.java b/src/main/java/net/minecraftforge/network/packets/SpawnEntity.java index 61faef0494..60b7e7a0c6 100644 --- a/src/main/java/net/minecraftforge/network/packets/SpawnEntity.java +++ b/src/main/java/net/minecraftforge/network/packets/SpawnEntity.java @@ -139,7 +139,7 @@ public class SpawnEntity { * Entity#recreateFromPacket and LivingEntity#recreateFromPacket does. */ e.syncPacketPositionCodec(msg.posX, msg.posY, msg.posZ); - e.absMoveTo(msg.posX, msg.posY, msg.posZ, (msg.yaw * 360) / 256.0F, (msg.pitch * 360) / 256.0F); + e.absSnapTo(msg.posX, msg.posY, msg.posZ, (msg.yaw * 360) / 256.0F, (msg.pitch * 360) / 256.0F); e.setYHeadRot((msg.headYaw * 360) / 256.0F); e.setYBodyRot((msg.headYaw * 360) / 256.0F); diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java index 74e672ee8c..0fc39de7a7 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java @@ -896,27 +896,22 @@ public class ForgeRegistry implements IForgeRegistryInternal, IForgeRegist if (nbt == null) return ret; - ListTag list = nbt.getList("ids", 10); - for (Tag tag : list) { - CompoundTag comp = (CompoundTag) tag; - ret.ids.put(ResourceLocation.parse(comp.getString("K")), comp.getInt("V")); - } + nbt.getListOrEmpty("ids").compoundStream().forEach(comp -> + ret.ids.put(ResourceLocation.parse(comp.getString("K").orElseThrow()), comp.getIntOr("V", 0)) + ); - list = nbt.getList("aliases", 10); - for (Tag tag : list) { - CompoundTag comp = (CompoundTag) tag; - ret.aliases.put(ResourceLocation.parse(comp.getString("K")), ResourceLocation.parse(comp.getString("V"))); - } + nbt.getListOrEmpty("aliases").compoundStream().forEach(comp -> + ret.aliases.put(ResourceLocation.parse(comp.getString("K").orElseThrow()), ResourceLocation.parse(comp.getString("V").orElseThrow())) + ); - list = nbt.getList("overrides", 10); - for (Tag tag : list) { - CompoundTag comp = (CompoundTag) tag; - ret.overrides.put(ResourceLocation.parse(comp.getString("K")), comp.getString("V")); - } + nbt.getListOrEmpty("overrides").compoundStream().forEach(comp -> + ret.overrides.put(ResourceLocation.parse(comp.getString("K").orElseThrow()), comp.getString("V").orElseThrow()) + ); - int[] blocked = nbt.getIntArray("blocked"); - for (int i : blocked) - ret.blocked.add(i); + nbt.getIntArray("blocked").ifPresent(blocked -> { + for (int i : blocked) + ret.blocked.add(i); + }); return ret; } diff --git a/src/main/java/net/minecraftforge/registries/GameData.java b/src/main/java/net/minecraftforge/registries/GameData.java index c19e2cddec..c60899431b 100644 --- a/src/main/java/net/minecraftforge/registries/GameData.java +++ b/src/main/java/net/minecraftforge/registries/GameData.java @@ -264,9 +264,11 @@ public class GameData { LOGGER.debug(REGISTRIES, "Freezing registries"); for (var reg : BuiltInRegistries.REGISTRY) { if (reg instanceof NamespacedWrapper named) { - // This is called after we fire our register events, but before doesn't load any tags. + // This is called after we fire our register events, but before the game loads any tags. // So lets skip the validation for this pass and just make every unbound tag empty // Tags will be bound later when tag data is reloaded/synced + if (named.isFrozen()) + named.unfreeze(); named.bindAllUnboundTagsToEmpty(); named.freeze(); } else if (reg instanceof MappedRegistry maped) diff --git a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java index ee7afcfaad..0bf0edcd69 100644 --- a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java +++ b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java @@ -238,12 +238,12 @@ class NamespacedWrapper extends MappedRegistry implements ILockableRegistr void validateWrite() { if (this.frozen) - throw new IllegalStateException("Registry is already frozen"); + throw new IllegalStateException("Registry " + this.key().location() + " is already frozen"); } void validateWrite(ResourceKey key) { if (this.frozen) - throw new IllegalStateException("Registry is already frozen (trying to add key " + key + ")"); + throw new IllegalStateException("Registry " + this.key().location() + " is already frozen (trying to add key " + key + ")"); } protected Holder.Reference getOrCreateHolderOrThrow(ResourceKey key) { diff --git a/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java b/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java index 15762289e3..5e71ee7615 100644 --- a/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java +++ b/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java @@ -14,7 +14,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import net.minecraft.core.Holder; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; -import net.minecraft.gametest.framework.GameTestServer; import net.minecraft.network.Connection; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.handshake.ClientIntent; @@ -22,7 +21,6 @@ import net.minecraft.network.protocol.handshake.ClientIntentionPacket; import net.minecraft.network.protocol.login.ClientboundLoginDisconnectPacket; import net.minecraft.world.level.storage.LevelResource; import net.minecraftforge.common.world.StructureModifier; -import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.common.util.LogicalSidedProvider; import net.minecraftforge.common.world.BiomeModifier; import net.minecraftforge.network.ConnectionType; @@ -36,10 +34,10 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; import net.minecraft.server.MinecraftServer; -import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.config.ConfigTracker; import net.minecraftforge.fml.config.ModConfig; +import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.event.server.ServerAboutToStartEvent; import net.minecraftforge.event.server.ServerStartedEvent; import net.minecraftforge.event.server.ServerStartingEvent; @@ -49,7 +47,6 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.GameData; import org.jetbrains.annotations.ApiStatus; -@SuppressWarnings("deprecation") @ApiStatus.Internal public class ServerLifecycleHooks { private static final Logger LOGGER = LogManager.getLogger(); @@ -81,12 +78,8 @@ public class ServerLifecycleHooks { } public static boolean handleServerStarting(final MinecraftServer server) { - DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, ()->()->{ + if (FMLEnvironment.dist.isDedicatedServer()) LanguageHook.loadLanguagesOnServer(server); - // GameTestServer requires the gametests to be registered earlier, so it is done in main and should not be done twice. - if (!(server instanceof GameTestServer)) - net.minecraftforge.gametest.ForgeGameTestHooks.registerGametests(); - }); PermissionAPI.initializePermissionAPI(); return !MinecraftForge.EVENT_BUS.post(new ServerStartingEvent(server)); } diff --git a/src/main/java/net/minecraftforge/server/command/ConfigCommand.java b/src/main/java/net/minecraftforge/server/command/ConfigCommand.java index 0000502db7..39b067adfc 100644 --- a/src/main/java/net/minecraftforge/server/command/ConfigCommand.java +++ b/src/main/java/net/minecraftforge/server/command/ConfigCommand.java @@ -46,7 +46,7 @@ public class ConfigCommand { context.getSource().sendSuccess(() -> Component.translatable("commands.config.getwithtype", modId, type, Component.literal(f.getName()).withStyle(ChatFormatting.UNDERLINE). - withStyle((style) -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, f.getAbsolutePath()))) + withStyle((style) -> style.withClickEvent(new ClickEvent.OpenFile(f.getAbsolutePath()))) ), true); } else { context.getSource().sendSuccess(() -> Component.translatable("commands.config.noconfig", modId, type), diff --git a/src/main/java/net/minecraftforge/server/command/TagsCommand.java b/src/main/java/net/minecraftforge/server/command/TagsCommand.java index 5e9029c112..8eb0bd5a14 100644 --- a/src/main/java/net/minecraftforge/server/command/TagsCommand.java +++ b/src/main/java/net/minecraftforge/server/command/TagsCommand.java @@ -198,9 +198,8 @@ class TagsCommand { if (count > 0) { // Highlight the count text, make it clickable, and append page counters containsComponent = ComponentUtils.wrapInSquareBrackets(containsComponent.withStyle(s -> s .withColor(ChatFormatting.GREEN) - .withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, allElementNames)) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - Component.translatable(copyHoverText))))); + .withClickEvent(new ClickEvent.CopyToClipboard(allElementNames)) + .withHoverEvent(new HoverEvent.ShowText(Component.translatable(copyHoverText))))); containsComponent = Component.translatable("commands.forge.tags.page_info", containsComponent, actualPage, totalPages); } diff --git a/src/main/java/net/minecraftforge/server/permission/events/PermissionGatherEvent.java b/src/main/java/net/minecraftforge/server/permission/events/PermissionGatherEvent.java index 7befee60fb..53ead36f48 100644 --- a/src/main/java/net/minecraftforge/server/permission/events/PermissionGatherEvent.java +++ b/src/main/java/net/minecraftforge/server/permission/events/PermissionGatherEvent.java @@ -14,7 +14,6 @@ import net.minecraftforge.server.permission.handler.IPermissionHandlerFactory; import net.minecraftforge.server.permission.nodes.PermissionNode; import java.util.*; -import java.util.function.Function; /** * Fired to gather information for the permissions API, such as the {@link IPermissionHandler} and {@link PermissionNode}s. diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index c0763e1d1d..5204576891 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -6,47 +6,39 @@ public net.minecraft.client.Options$FieldAccess public net.minecraft.client.color.item.ItemTintSources f_371619_ # ID_MAPPER #group protected net.minecraft.client.data.models.BlockModelGenerators *() protected net.minecraft.client.data.models.BlockModelGenerators m_372042_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;)V # registerSimpleItemModel -protected net.minecraft.client.data.models.BlockModelGenerators m_372049_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createSculkCatalyst$61 protected net.minecraft.client.data.models.BlockModelGenerators m_372065_()V # createCartographyTable -protected net.minecraft.client.data.models.BlockModelGenerators m_372079_(Lnet/minecraft/world/level/block/Block;II)Lnet/minecraft/resources/ResourceLocation; # lambda$createCropBlock$17 +protected net.minecraft.client.data.models.BlockModelGenerators m_372079_(Lnet/minecraft/world/level/block/Block;I)Lnet/minecraft/resources/ResourceLocation; # lambda$createCropBlock$25 protected net.minecraft.client.data.models.BlockModelGenerators m_372090_()V # createPitcherCrop -protected net.minecraft.client.data.models.BlockModelGenerators m_372114_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/data/models/blockstates/Condition$TerminalCondition;Lnet/minecraft/client/data/models/blockstates/VariantProperties$Rotation;)V # addSlotStateAndRotationVariants +protected net.minecraft.client.data.models.BlockModelGenerators m_372114_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/renderer/block/model/multipart/Condition;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # addSlotStateAndRotationVariants protected net.minecraft.client.data.models.BlockModelGenerators m_372121_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createWeightedPressurePlate -protected net.minecraft.client.data.models.BlockModelGenerators m_372122_(Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createSoulFire$32 protected net.minecraft.client.data.models.BlockModelGenerators m_372128_()V # createSmithingTable protected net.minecraft.client.data.models.BlockModelGenerators m_372129_()V # createPetrifiedOakSlab protected net.minecraft.client.data.models.BlockModelGenerators m_372134_()V # createFarmland -protected net.minecraft.client.data.models.BlockModelGenerators m_372137_(Ljava/lang/String;I)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createBambooModels$14 protected net.minecraft.client.data.models.BlockModelGenerators m_372151_()V # createIronBars protected net.minecraft.client.data.models.BlockModelGenerators m_372158_()V # createBookshelf -protected net.minecraft.client.data.models.BlockModelGenerators m_372187_(Lnet/minecraft/world/level/block/Block;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createHangingMoss$60 -protected net.minecraft.client.data.models.BlockModelGenerators m_372188_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createAxisAlignedPillarBlock +protected net.minecraft.client.data.models.BlockModelGenerators m_372188_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createAxisAlignedPillarBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372190_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;)V # createMultiface protected net.minecraft.client.data.models.BlockModelGenerators m_372196_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # copyTrapdoorModel protected net.minecraft.client.data.models.BlockModelGenerators m_372199_()V # createStructureBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372209_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/level/block/Block;Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModelWithBlockTexture -protected net.minecraft.client.data.models.BlockModelGenerators m_372211_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$new$4 +protected net.minecraft.client.data.models.BlockModelGenerators m_372211_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$14 protected net.minecraft.client.data.models.BlockModelGenerators m_372231_()Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createRotatedPillar protected net.minecraft.client.data.models.BlockModelGenerators m_372234_(Lnet/minecraft/world/level/block/Block;)V # createRotatedMirroredVariantBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_372247_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createTrapdoor +protected net.minecraft.client.data.models.BlockModelGenerators m_372247_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createTrapdoor protected net.minecraft.client.data.models.BlockModelGenerators m_372261_()V # createBamboo protected net.minecraft.client.data.models.BlockModelGenerators m_372277_()V # createSnifferEgg -protected net.minecraft.client.data.models.BlockModelGenerators m_372283_(Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createFire$24 -protected net.minecraft.client.data.models.BlockModelGenerators m_372285_()Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createColumnWithFacing -protected net.minecraft.client.data.models.BlockModelGenerators m_372302_(Lnet/minecraft/resources/ResourceLocation;)[Lnet/minecraft/client/data/models/blockstates/Variant; # createRotatedVariants +protected net.minecraft.client.data.models.BlockModelGenerators m_372283_(Lnet/minecraft/client/renderer/block/model/Variant;)Lnet/minecraft/client/renderer/block/model/Variant; # lambda$static$0 +protected net.minecraft.client.data.models.BlockModelGenerators m_372285_(Lnet/minecraft/world/level/block/Block;)V # createLeafLitter +protected net.minecraft.client.data.models.BlockModelGenerators m_372302_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createButton protected net.minecraft.client.data.models.BlockModelGenerators m_372307_()V # createMangrovePropagule protected net.minecraft.client.data.models.BlockModelGenerators m_372310_()V # createPointedDripstone -protected net.minecraft.client.data.models.BlockModelGenerators m_372311_(Ljava/lang/Integer;)Lnet/minecraft/resources/ResourceLocation; # lambda$createSnifferEgg$47 -protected net.minecraft.client.data.models.BlockModelGenerators m_372312_(Lnet/minecraft/core/FrontAndTop;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createCrafterBlock$21 -protected net.minecraft.client.data.models.BlockModelGenerators m_372325_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/util/function/BiConsumer;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createMirroredColumnGenerator -protected net.minecraft.client.data.models.BlockModelGenerators m_372336_(Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createSoulFire$33 -protected net.minecraft.client.data.models.BlockModelGenerators m_372346_()Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createTorchHorizontalDispatch -protected net.minecraft.client.data.models.BlockModelGenerators m_372364_(Lnet/minecraft/world/level/block/state/properties/BooleanProperty;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createBooleanModelDispatch +protected net.minecraft.client.data.models.BlockModelGenerators m_372325_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/renderer/block/model/Variant;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/util/function/BiConsumer;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createMirroredColumnGenerator +protected net.minecraft.client.data.models.BlockModelGenerators m_372364_(Lnet/minecraft/world/level/block/state/properties/BooleanProperty;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createBooleanModelDispatch protected net.minecraft.client.data.models.BlockModelGenerators m_372368_()V # createJigsaw protected net.minecraft.client.data.models.BlockModelGenerators m_372383_()V # createAmethystClusters protected net.minecraft.client.data.models.BlockModelGenerators m_372396_([Lnet/minecraft/world/level/block/Block;)V # createCampfires protected net.minecraft.client.data.models.BlockModelGenerators m_372397_(Lnet/minecraft/world/level/block/Block;)V # createLantern -protected net.minecraft.client.data.models.BlockModelGenerators m_372399_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/MultiVariantGenerator; # createSimpleBlock +protected net.minecraft.client.data.models.BlockModelGenerators m_372399_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/MultiVariantGenerator; # createSimpleBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372406_()V # createObserver protected net.minecraft.client.data.models.BlockModelGenerators m_372418_()V # createDaylightDetector protected net.minecraft.client.data.models.BlockModelGenerators m_372455_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TexturedModel$Provider;Lnet/minecraft/client/data/models/model/TexturedModel$Provider;)V # createRotatedPillarWithHorizontalVariant @@ -55,239 +47,241 @@ protected net.minecraft.client.data.models.BlockModelGenerators m_372503_(Lnet/m protected net.minecraft.client.data.models.BlockModelGenerators m_372507_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/Item;)V # createAirLikeBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372519_()V # createGrindstone protected net.minecraft.client.data.models.BlockModelGenerators m_372527_(Lnet/minecraft/world/level/block/Block;)V # registerSimpleFlatItemModel -protected net.minecraft.client.data.models.BlockModelGenerators m_372530_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createBarrel$15 -protected net.minecraft.client.data.models.BlockModelGenerators m_372543_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/world/level/block/entity/vault/VaultState;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createVault$38 +protected net.minecraft.client.data.models.BlockModelGenerators m_372530_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createBarrel$23 protected net.minecraft.client.data.models.BlockModelGenerators m_372545_()V # createLightBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372548_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createCoral -protected net.minecraft.client.data.models.BlockModelGenerators m_372570_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createCreakingHeart$6 -protected net.minecraft.client.data.models.BlockModelGenerators m_372582_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/MultiVariantGenerator; # createRotatedVariant -protected net.minecraft.client.data.models.BlockModelGenerators m_372599_()Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createFacingDispatch +protected net.minecraft.client.data.models.BlockModelGenerators m_372570_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createMossyCarpet$49 protected net.minecraft.client.data.models.BlockModelGenerators m_372620_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # copyCopperBulbModel -protected net.minecraft.client.data.models.BlockModelGenerators m_372638_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$new$3 -protected net.minecraft.client.data.models.BlockModelGenerators m_372644_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/blockstates/Variant;)V # createGrassLikeBlock +protected net.minecraft.client.data.models.BlockModelGenerators m_372638_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$13 +protected net.minecraft.client.data.models.BlockModelGenerators m_372644_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)V # createGrassLikeBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372663_()V # createFrostedIce protected net.minecraft.client.data.models.BlockModelGenerators m_372681_(Lnet/minecraft/client/data/models/model/TexturedModel$Provider;[Lnet/minecraft/world/level/block/Block;)V # createColoredBlockWithStateRotations protected net.minecraft.client.data.models.BlockModelGenerators m_372696_()V # createEndPortalFrame -protected net.minecraft.client.data.models.BlockModelGenerators m_372705_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createOrientableTrapdoor -protected net.minecraft.client.data.models.BlockModelGenerators m_372711_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createDoor +protected net.minecraft.client.data.models.BlockModelGenerators m_372705_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createOrientableTrapdoor +protected net.minecraft.client.data.models.BlockModelGenerators m_372711_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createDoor protected net.minecraft.client.data.models.BlockModelGenerators m_372719_()V # createChorusFlower protected net.minecraft.client.data.models.BlockModelGenerators m_372720_()V # createCocoa -protected net.minecraft.client.data.models.BlockModelGenerators m_372723_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$new$0 +protected net.minecraft.client.data.models.BlockModelGenerators m_372723_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$10 protected net.minecraft.client.data.models.BlockModelGenerators m_372724_()V # createSmallDripleaf protected net.minecraft.client.data.models.BlockModelGenerators m_372726_(Lnet/minecraft/world/level/block/Block;)V # createMultiface -protected net.minecraft.client.data.models.BlockModelGenerators m_372728_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/blockstates/Condition$TerminalCondition;Lnet/minecraft/world/level/block/state/properties/BooleanProperty;)V # lambda$createMultifaceBlockStates$55 protected net.minecraft.client.data.models.BlockModelGenerators m_372729_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;)V # createGrowingPlant protected net.minecraft.client.data.models.BlockModelGenerators m_372730_()V # createBeds protected net.minecraft.client.data.models.BlockModelGenerators m_372737_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;)V # createCrossBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372739_()V # createNetherPortalBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372745_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createNetherRoots -protected net.minecraft.client.data.models.BlockModelGenerators m_372746_(Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/model/TextureMapping; # lambda$createCommandBlock$13 +protected net.minecraft.client.data.models.BlockModelGenerators m_372746_(Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/model/TextureMapping; # lambda$createCommandBlock$21 protected net.minecraft.client.data.models.BlockModelGenerators m_372768_(Lnet/minecraft/world/level/block/Block;)V # createAmethystCluster protected net.minecraft.client.data.models.BlockModelGenerators m_372788_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # copyDoorModel -protected net.minecraft.client.data.models.BlockModelGenerators m_372818_(Lnet/minecraft/world/level/block/Block;)Ljava/util/List; # createTopFireModels -protected net.minecraft.client.data.models.BlockModelGenerators m_372820_(Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createFire$25 -protected net.minecraft.client.data.models.BlockModelGenerators m_372825_(Ljava/lang/Integer;Ljava/lang/Integer;)Lnet/minecraft/resources/ResourceLocation; # createTurtleEggModel +protected net.minecraft.client.data.models.BlockModelGenerators m_372818_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/MultiVariant; # createTopFireModels +protected net.minecraft.client.data.models.BlockModelGenerators m_372820_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$1 +protected net.minecraft.client.data.models.BlockModelGenerators m_372825_(II)Lnet/minecraft/client/renderer/block/model/Variant; # createTurtleEggModel protected net.minecraft.client.data.models.BlockModelGenerators m_372827_()V # createMuddyMangroveRoots protected net.minecraft.client.data.models.BlockModelGenerators m_372830_(Lnet/minecraft/world/level/block/Block;)V # createFlowerBed protected net.minecraft.client.data.models.BlockModelGenerators m_372831_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # copyModel -protected net.minecraft.client.data.models.BlockModelGenerators m_372841_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/MultiVariantGenerator; # createRotatedVariant protected net.minecraft.client.data.models.BlockModelGenerators m_372857_()V # createSweetBerryBush protected net.minecraft.client.data.models.BlockModelGenerators m_372870_()V # createSculkCatalyst protected net.minecraft.client.data.models.BlockModelGenerators m_372876_()V # createBigDripLeafBlock protected net.minecraft.client.data.models.BlockModelGenerators m_372882_(Lnet/minecraft/client/data/models/model/TexturedModel$Provider;[Lnet/minecraft/world/level/block/Block;)V # createColoredBlockWithRandomRotations -protected net.minecraft.client.data.models.BlockModelGenerators m_372883_(Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createFire$28 protected net.minecraft.client.data.models.BlockModelGenerators m_372884_()V # createLever -protected net.minecraft.client.data.models.BlockModelGenerators m_372888_(Lnet/minecraft/core/FrontAndTop;Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # applyRotation -protected net.minecraft.client.data.models.BlockModelGenerators m_372890_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createStems$10 +protected net.minecraft.client.data.models.BlockModelGenerators m_372888_(Lnet/minecraft/core/FrontAndTop;)Lnet/minecraft/client/renderer/block/model/VariantMutator; # applyRotation protected net.minecraft.client.data.models.BlockModelGenerators m_372908_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Z)V # createChest protected net.minecraft.client.data.models.BlockModelGenerators m_372933_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;)V # createPlantWithDefaultItem protected net.minecraft.client.data.models.BlockModelGenerators m_372942_()V # createStonecutter protected net.minecraft.client.data.models.BlockModelGenerators m_372944_(Lnet/minecraft/world/level/block/Block;)V # createCreakingHeart -protected net.minecraft.client.data.models.BlockModelGenerators m_372948_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/util/function/BiConsumer;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createNorthWestMirroredCubeGenerator +protected net.minecraft.client.data.models.BlockModelGenerators m_372948_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/renderer/block/model/Variant;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/util/function/BiConsumer;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createNorthWestMirroredCubeGenerator protected net.minecraft.client.data.models.BlockModelGenerators m_372954_()V # createSmoothStoneSlab protected net.minecraft.client.data.models.BlockModelGenerators m_372958_()V # createDirtPath protected net.minecraft.client.data.models.BlockModelGenerators m_372959_()V # createComparator protected net.minecraft.client.data.models.BlockModelGenerators m_372960_(Lnet/minecraft/world/level/block/Block;)V # createTintedDoublePlant protected net.minecraft.client.data.models.BlockModelGenerators m_372976_(Lnet/minecraft/world/level/block/Block;)V # createAzalea -protected net.minecraft.client.data.models.BlockModelGenerators m_372983_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/resources/ResourceLocation;Lcom/mojang/datafixers/util/Pair;)V # lambda$createChiseledBookshelf$62 protected net.minecraft.client.data.models.BlockModelGenerators m_373004_(Lnet/minecraft/world/level/block/Block;)V # createCommandBlock protected net.minecraft.client.data.models.BlockModelGenerators m_373008_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/DyeColor;)V # createShulkerBox protected net.minecraft.client.data.models.BlockModelGenerators m_373026_(Lnet/minecraft/world/item/Item;)V # registerSimpleFlatItemModel -protected net.minecraft.client.data.models.BlockModelGenerators m_373031_(Ljava/lang/Integer;Ljava/lang/Integer;)Ljava/util/List; # lambda$createTurtleEgg$46 protected net.minecraft.client.data.models.BlockModelGenerators m_373035_(Lnet/minecraft/world/level/block/Block;)V # createItemWithGrassTint protected net.minecraft.client.data.models.BlockModelGenerators m_373046_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/level/block/Block;Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModelWithBlockTextureAndOverlay -protected net.minecraft.client.data.models.BlockModelGenerators m_373060_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$new$2 -protected net.minecraft.client.data.models.BlockModelGenerators m_373061_(Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createFire$26 +protected net.minecraft.client.data.models.BlockModelGenerators m_373060_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$12 protected net.minecraft.client.data.models.BlockModelGenerators m_373071_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;Lnet/minecraft/client/data/models/model/TextureMapping;)V # createCrossBlock protected net.minecraft.client.data.models.BlockModelGenerators m_373072_(Lnet/minecraft/world/level/block/Block;)V # createParticleOnlyBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_373079_(Lnet/minecraft/world/level/block/Block;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createBrushableBlock$5 protected net.minecraft.client.data.models.BlockModelGenerators m_373089_(Lnet/minecraft/world/item/Item;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModel protected net.minecraft.client.data.models.BlockModelGenerators m_373098_()V # createCaveVines -protected net.minecraft.client.data.models.BlockModelGenerators m_373127_(Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createFire$27 -protected net.minecraft.client.data.models.BlockModelGenerators m_373150_(Lnet/minecraft/resources/ResourceLocation;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createSnowBlocks$42 -protected net.minecraft.client.data.models.BlockModelGenerators m_373154_(Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createFire$29 protected net.minecraft.client.data.models.BlockModelGenerators m_373159_()V # createComposter -protected net.minecraft.client.data.models.BlockModelGenerators m_373167_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$static$52 protected net.minecraft.client.data.models.BlockModelGenerators m_373171_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Ljava/util/function/BiFunction;)V # createCraftingTableLike protected net.minecraft.client.data.models.BlockModelGenerators m_373177_()V # createTrialSpawner protected net.minecraft.client.data.models.BlockModelGenerators m_373181_()V # createVine protected net.minecraft.client.data.models.BlockModelGenerators m_373188_()V # createInfestedStone protected net.minecraft.client.data.models.BlockModelGenerators m_373195_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/renderer/special/SpecialModelRenderer$Unbaked;)V # generateSimpleSpecialItemModel -protected net.minecraft.client.data.models.BlockModelGenerators m_373216_(Lnet/minecraft/world/level/block/Block;)Ljava/util/List; # createFloorFireModels +protected net.minecraft.client.data.models.BlockModelGenerators m_373216_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/MultiVariant; # createFloorFireModels protected net.minecraft.client.data.models.BlockModelGenerators m_373228_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/BlockModelGenerators$BlockFamilyProvider; # family -protected net.minecraft.client.data.models.BlockModelGenerators m_373247_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createFurnace$19 +protected net.minecraft.client.data.models.BlockModelGenerators m_373247_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createFurnace$27 protected net.minecraft.client.data.models.BlockModelGenerators m_373255_()V # createPumpkins -protected net.minecraft.client.data.models.BlockModelGenerators m_373266_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createPressurePlate -protected net.minecraft.client.data.models.BlockModelGenerators m_373285_(Lnet/minecraft/world/level/block/state/properties/Property;Ljava/lang/Comparable;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createEmptyOrFullDispatch +protected net.minecraft.client.data.models.BlockModelGenerators m_373266_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createPressurePlate +protected net.minecraft.client.data.models.BlockModelGenerators m_373285_(Lnet/minecraft/world/level/block/state/properties/Property;Ljava/lang/Comparable;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createEmptyOrFullDispatch protected net.minecraft.client.data.models.BlockModelGenerators m_373293_()V # createTripwire protected net.minecraft.client.data.models.BlockModelGenerators m_373303_(Lnet/minecraft/world/level/block/Block;)V # createMossyCarpet protected net.minecraft.client.data.models.BlockModelGenerators m_373329_()V # createSculkSensor protected net.minecraft.client.data.models.BlockModelGenerators m_373330_()V # createPistonHeads -protected net.minecraft.client.data.models.BlockModelGenerators m_373332_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createStairs +protected net.minecraft.client.data.models.BlockModelGenerators m_373332_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createStairs protected net.minecraft.client.data.models.BlockModelGenerators m_373333_()V # createBanners protected net.minecraft.client.data.models.BlockModelGenerators m_373336_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;)V # createCrossBlockWithDefaultItem protected net.minecraft.client.data.models.BlockModelGenerators m_373340_()V # createSnowBlocks -protected net.minecraft.client.data.models.BlockModelGenerators m_373341_(Lnet/minecraft/core/Direction;Lnet/minecraft/world/level/block/state/properties/DripstoneThickness;)Lnet/minecraft/client/data/models/blockstates/Variant; # createPointedDripstoneVariant +protected net.minecraft.client.data.models.BlockModelGenerators m_373341_(Lnet/minecraft/core/Direction;Lnet/minecraft/world/level/block/state/properties/DripstoneThickness;)Lnet/minecraft/client/data/models/MultiVariant; # createPointedDripstoneVariant protected net.minecraft.client.data.models.BlockModelGenerators m_373342_(Lnet/minecraft/world/level/block/Block;)V # createDispenserBlock protected net.minecraft.client.data.models.BlockModelGenerators m_373358_()V # createSculkShrieker -protected net.minecraft.client.data.models.BlockModelGenerators m_373367_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createRotatedPillarWithHorizontalVariant +protected net.minecraft.client.data.models.BlockModelGenerators m_373367_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createRotatedPillarWithHorizontalVariant protected net.minecraft.client.data.models.BlockModelGenerators m_373371_(Lnet/minecraft/world/level/block/Block;)V # createNonTemplateModelBlock protected net.minecraft.client.data.models.BlockModelGenerators m_373393_()V # createRedstoneTorch -protected net.minecraft.client.data.models.BlockModelGenerators m_373406_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;)V # createAxisAlignedPillarBlockCustomModel -protected net.minecraft.client.data.models.BlockModelGenerators m_373407_(Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createSoulFire$34 -protected net.minecraft.client.data.models.BlockModelGenerators m_373410_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$new$1 +protected net.minecraft.client.data.models.BlockModelGenerators m_373406_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;)V # createAxisAlignedPillarBlockCustomModel +protected net.minecraft.client.data.models.BlockModelGenerators m_373410_(Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$static$11 protected net.minecraft.client.data.models.BlockModelGenerators m_373413_(Lnet/minecraft/world/level/block/Block;)V # createMultifaceBlockStates protected net.minecraft.client.data.models.BlockModelGenerators m_373423_()V # createGrassBlocks protected net.minecraft.client.data.models.BlockModelGenerators m_373424_()V # createChiseledBookshelf protected net.minecraft.client.data.models.BlockModelGenerators m_373437_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createNonTemplateModelBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_373442_(Ljava/lang/Integer;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createSweetBerryBush$44 -protected net.minecraft.client.data.models.BlockModelGenerators m_373454_(Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/model/TextureMapping; # lambda$createChorusFlower$20 -protected net.minecraft.client.data.models.BlockModelGenerators m_373455_(Ljava/util/List;Ljava/util/function/UnaryOperator;)Ljava/util/List; # wrapModels +protected net.minecraft.client.data.models.BlockModelGenerators m_373454_(Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/model/TextureMapping; # lambda$createChorusFlower$28 protected net.minecraft.client.data.models.BlockModelGenerators m_373466_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;)V # registerSimpleItemModel -protected net.minecraft.client.data.models.BlockModelGenerators m_373467_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # createPistonVariant +protected net.minecraft.client.data.models.BlockModelGenerators m_373467_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/model/TextureMapping;)V # createPistonVariant protected net.minecraft.client.data.models.BlockModelGenerators m_373468_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/color/item/ItemTintSource;)V # registerSimpleTintedItemModel protected net.minecraft.client.data.models.BlockModelGenerators m_373481_(Lnet/minecraft/world/level/block/Block;)V # createMushroomBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_373512_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createGrassBlocks$35 +protected net.minecraft.client.data.models.BlockModelGenerators m_373512_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createGrassBlocks$31 protected net.minecraft.client.data.models.BlockModelGenerators m_373523_()V # createRepeater protected net.minecraft.client.data.models.BlockModelGenerators m_373526_()V # createRedstoneLamp -protected net.minecraft.client.data.models.BlockModelGenerators m_373538_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/world/level/block/state/properties/SculkSensorPhase;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createSculkSensor$39 protected net.minecraft.client.data.models.BlockModelGenerators m_373558_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TexturedModel$Provider;)V # createFurnace -protected net.minecraft.client.data.models.BlockModelGenerators m_373573_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createSlab -protected net.minecraft.client.data.models.BlockModelGenerators m_373577_(Lnet/minecraft/client/data/models/blockstates/PropertyDispatch$C4;Lnet/minecraft/world/level/block/state/properties/DoubleBlockHalf;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/PropertyDispatch$C4; # configureDoorHalf +protected net.minecraft.client.data.models.BlockModelGenerators m_373573_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createSlab protected net.minecraft.client.data.models.BlockModelGenerators m_373578_()V # createPitcherPlant -protected net.minecraft.client.data.models.BlockModelGenerators m_373590_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$static$50 protected net.minecraft.client.data.models.BlockModelGenerators m_373608_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;)V # createPlant protected net.minecraft.client.data.models.BlockModelGenerators m_373622_(Lnet/minecraft/world/level/block/Block;Ljava/util/function/Function;)V # createBeeNest protected net.minecraft.client.data.models.BlockModelGenerators m_373634_()V # createScaffolding protected net.minecraft.client.data.models.BlockModelGenerators m_373643_()V # createVault -protected net.minecraft.client.data.models.BlockModelGenerators m_373651_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/data/models/blockstates/Condition$TerminalCondition;Lnet/minecraft/client/data/models/blockstates/VariantProperties$Rotation;Lcom/mojang/datafixers/util/Pair;)V # lambda$addSlotStateAndRotationVariants$63 -protected net.minecraft.client.data.models.BlockModelGenerators m_373660_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/util/function/BiConsumer;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createPillarBlockUVLocked -protected net.minecraft.client.data.models.BlockModelGenerators m_373673_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createButton +protected net.minecraft.client.data.models.BlockModelGenerators m_373660_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/util/function/BiConsumer;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createPillarBlockUVLocked protected net.minecraft.client.data.models.BlockModelGenerators m_373680_(Lnet/minecraft/world/level/block/Block;)V # createCopperBulb protected net.minecraft.client.data.models.BlockModelGenerators m_373694_()V # createCauldrons protected net.minecraft.client.data.models.BlockModelGenerators m_373697_()V # createSoulFire -protected net.minecraft.client.data.models.BlockModelGenerators m_373701_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createWall +protected net.minecraft.client.data.models.BlockModelGenerators m_373701_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createWall protected net.minecraft.client.data.models.BlockModelGenerators m_373707_(Lnet/minecraft/world/level/block/Block;)V # createPottedAzalea protected net.minecraft.client.data.models.BlockModelGenerators m_373721_(Lnet/minecraft/world/level/block/Block;)V # createNonTemplateHorizontalBlock protected net.minecraft.client.data.models.BlockModelGenerators m_373723_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createGlassBlocks protected net.minecraft.client.data.models.BlockModelGenerators m_373729_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TexturedModel$Provider;)V # createHorizontallyRotatedBlock protected net.minecraft.client.data.models.BlockModelGenerators m_373730_(Lnet/minecraft/world/level/block/Block;Ljava/lang/String;Lnet/minecraft/client/data/models/model/ModelTemplate;Ljava/util/function/Function;)Lnet/minecraft/resources/ResourceLocation; # createSuffixedVariant -protected net.minecraft.client.data.models.BlockModelGenerators m_373738_(Ljava/util/function/Function;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createSnifferEgg$48 -protected net.minecraft.client.data.models.BlockModelGenerators m_373743_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$wrapModels$23 -protected net.minecraft.client.data.models.BlockModelGenerators m_373750_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createMossyCarpet$58 -protected net.minecraft.client.data.models.BlockModelGenerators m_373795_(ILjava/lang/String;Lnet/minecraft/client/data/models/model/TextureMapping;)Lnet/minecraft/resources/ResourceLocation; # createTurtleEggModel +protected net.minecraft.client.data.models.BlockModelGenerators m_373795_(ILjava/lang/String;Lnet/minecraft/client/data/models/model/TextureMapping;)Lnet/minecraft/client/renderer/block/model/Variant; # createTurtleEggModel protected net.minecraft.client.data.models.BlockModelGenerators m_373801_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModelWithBlockTexture -protected net.minecraft.client.data.models.BlockModelGenerators m_373808_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/util/function/BiConsumer;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createMirroredCubeGenerator +protected net.minecraft.client.data.models.BlockModelGenerators m_373808_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/renderer/block/model/Variant;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/util/function/BiConsumer;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createMirroredCubeGenerator protected net.minecraft.client.data.models.BlockModelGenerators m_373813_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/SkullBlock$Type;Lnet/minecraft/resources/ResourceLocation;)V # createHead protected net.minecraft.client.data.models.BlockModelGenerators m_373825_(Lnet/minecraft/world/level/block/Block;)V # createAnvil protected net.minecraft.client.data.models.BlockModelGenerators m_373827_()V # createTallSeagrass protected net.minecraft.client.data.models.BlockModelGenerators m_373843_()V # createHeads protected net.minecraft.client.data.models.BlockModelGenerators m_373844_()V # createLightningRod -protected net.minecraft.client.data.models.BlockModelGenerators m_373857_([ILnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createCrossBlock$9 protected net.minecraft.client.data.models.BlockModelGenerators m_373862_()V # createFire protected net.minecraft.client.data.models.BlockModelGenerators m_373864_()V # createBrewingStand protected net.minecraft.client.data.models.BlockModelGenerators m_373879_()V # createMagmaBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_373894_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createCopperBulb$22 -protected net.minecraft.client.data.models.BlockModelGenerators m_373901_(Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createSoulFire$30 -protected net.minecraft.client.data.models.BlockModelGenerators m_373907_([ILit/unimi/dsi/fastutil/ints/Int2ObjectMap;Lnet/minecraft/world/level/block/Block;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createCropBlock$18 protected net.minecraft.client.data.models.BlockModelGenerators m_373916_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/properties/Property;[I)V # createCropBlock protected net.minecraft.client.data.models.BlockModelGenerators m_373929_()V # createSunflower -protected net.minecraft.client.data.models.BlockModelGenerators m_373935_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createTrialSpawner$37 protected net.minecraft.client.data.models.BlockModelGenerators m_373936_()V # createLilyPad -protected net.minecraft.client.data.models.BlockModelGenerators m_373941_(Lnet/minecraft/world/level/block/Block;)Ljava/util/List; # createSideFireModels +protected net.minecraft.client.data.models.BlockModelGenerators m_373941_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/MultiVariant; # createSideFireModels protected net.minecraft.client.data.models.BlockModelGenerators m_373945_()V # createTurtleEgg -protected net.minecraft.client.data.models.BlockModelGenerators m_373948_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$static$54 -protected net.minecraft.client.data.models.BlockModelGenerators m_373958_()Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createHorizontalFacingDispatch -protected net.minecraft.client.data.models.BlockModelGenerators m_373961_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createGrassBlocks$36 -protected net.minecraft.client.data.models.BlockModelGenerators m_373973_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$static$53 +protected net.minecraft.client.data.models.BlockModelGenerators m_373961_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createGrassBlocks$32 protected net.minecraft.client.data.models.BlockModelGenerators m_373974_()V # createBell -protected net.minecraft.client.data.models.BlockModelGenerators m_373976_()Lnet/minecraft/client/data/models/blockstates/PropertyDispatch; # createHorizontalFacingDispatchAlt protected net.minecraft.client.data.models.BlockModelGenerators m_373984_(Lnet/minecraft/world/level/block/Block;)V # createPassiveRail -protected net.minecraft.client.data.models.BlockModelGenerators m_373986_(Lnet/minecraft/core/FrontAndTop;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createJigsaw$66 protected net.minecraft.client.data.models.BlockModelGenerators m_373989_(Lnet/minecraft/world/level/block/Block;)V # createRotatableColumn protected net.minecraft.client.data.models.BlockModelGenerators m_374000_(Lnet/minecraft/world/level/block/Block;)V # createRotatedVariantBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_374002_(Lnet/minecraft/data/BlockFamily;)V # lambda$run$67 +protected net.minecraft.client.data.models.BlockModelGenerators m_374002_(Lnet/minecraft/data/BlockFamily;)V # lambda$run$58 protected net.minecraft.client.data.models.BlockModelGenerators m_374004_()V # createCalibratedSculkSensor protected net.minecraft.client.data.models.BlockModelGenerators m_374006_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # createPumpkinVariant protected net.minecraft.client.data.models.BlockModelGenerators m_374030_()V # createChests -protected net.minecraft.client.data.models.BlockModelGenerators m_374031_(Ljava/lang/Comparable;Lnet/minecraft/client/data/models/blockstates/Variant;Lnet/minecraft/client/data/models/blockstates/Variant;Ljava/lang/Comparable;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createEmptyOrFullDispatch$16 -protected net.minecraft.client.data.models.BlockModelGenerators m_374032_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Ljava/lang/Boolean;Lnet/minecraft/world/level/block/state/properties/RailShape;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createActiveRail$12 -protected net.minecraft.client.data.models.BlockModelGenerators m_374036_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/blockstates/Condition$TerminalCondition;)V # lambda$createMultifaceBlockStates$56 +protected net.minecraft.client.data.models.BlockModelGenerators m_374031_(Ljava/lang/Comparable;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Ljava/lang/Comparable;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createEmptyOrFullDispatch$24 protected net.minecraft.client.data.models.BlockModelGenerators m_374041_(Lnet/minecraft/world/level/block/Block;Ljava/lang/String;)V # registerSimpleFlatItemModel protected net.minecraft.client.data.models.BlockModelGenerators m_374042_(Lnet/minecraft/world/level/block/Block;)V # createTrapdoor -protected net.minecraft.client.data.models.BlockModelGenerators m_374064_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TexturedModel$Provider;)Lnet/minecraft/resources/ResourceLocation; # lambda$createCreakingHeart$8 -protected net.minecraft.client.data.models.BlockModelGenerators m_374071_(Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createTripwireHook$45 -protected net.minecraft.client.data.models.BlockModelGenerators m_374076_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$static$49 -protected net.minecraft.client.data.models.BlockModelGenerators m_374126_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)V # createDoubleBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_374134_(I)Ljava/util/List; # createBambooModels +protected net.minecraft.client.data.models.BlockModelGenerators m_374126_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)V # createDoubleBlock +protected net.minecraft.client.data.models.BlockModelGenerators m_374134_(I)Lnet/minecraft/client/data/models/MultiVariant; # createBambooModels protected net.minecraft.client.data.models.BlockModelGenerators m_374141_(Lnet/minecraft/world/level/block/Block;)V # createBrushableBlock protected net.minecraft.client.data.models.BlockModelGenerators m_374146_(Lnet/minecraft/world/level/block/Block;)V # createHangingMoss protected net.minecraft.client.data.models.BlockModelGenerators m_374177_()V # createCrafterBlock -protected net.minecraft.client.data.models.BlockModelGenerators m_374200_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$static$51 protected net.minecraft.client.data.models.BlockModelGenerators m_374216_(Lnet/minecraft/world/level/block/Block;)V # createOrientableTrapdoor protected net.minecraft.client.data.models.BlockModelGenerators m_374249_()V # createChorusPlant protected net.minecraft.client.data.models.BlockModelGenerators m_374256_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createFullAndCarpetBlocks -protected net.minecraft.client.data.models.BlockModelGenerators m_374262_(Lnet/minecraft/client/data/models/blockstates/Variant;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createSoulFire$31 protected net.minecraft.client.data.models.BlockModelGenerators m_374265_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;)V # createAirLikeBlock protected net.minecraft.client.data.models.BlockModelGenerators m_374268_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/DyeColor;)V # createBanner -protected net.minecraft.client.data.models.BlockModelGenerators m_374271_(Lnet/minecraft/world/level/block/state/properties/StructureMode;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createStructureBlock$43 protected net.minecraft.client.data.models.BlockModelGenerators m_374273_()V # createNetherrack protected net.minecraft.client.data.models.BlockModelGenerators m_374284_()V # createInfestedDeepslate protected net.minecraft.client.data.models.BlockModelGenerators m_374293_()V # createPistons -protected net.minecraft.client.data.models.BlockModelGenerators m_374299_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createFence +protected net.minecraft.client.data.models.BlockModelGenerators m_374299_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createFence protected net.minecraft.client.data.models.BlockModelGenerators m_374303_(Lnet/minecraft/world/level/block/Block;)V # createNyliumBlock protected net.minecraft.client.data.models.BlockModelGenerators m_374308_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createCandleAndCandleCake -protected net.minecraft.client.data.models.BlockModelGenerators m_374309_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createCreakingHeart$7 -protected net.minecraft.client.data.models.BlockModelGenerators m_374312_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createMossyCarpet$57 +protected net.minecraft.client.data.models.BlockModelGenerators m_374312_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createMossyCarpet$50 protected net.minecraft.client.data.models.BlockModelGenerators m_374339_()V # createRedstoneWire protected net.minecraft.client.data.models.BlockModelGenerators m_374347_()V # createBarrel protected net.minecraft.client.data.models.BlockModelGenerators m_374348_()V # createRespawnAnchor -protected net.minecraft.client.data.models.BlockModelGenerators m_374353_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/resources/ResourceLocation; # createParticleOnlyBlockModel +protected net.minecraft.client.data.models.BlockModelGenerators m_374353_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/MultiVariant; # createParticleOnlyBlockModel protected net.minecraft.client.data.models.BlockModelGenerators m_374355_()V # createFrogspawnBlock protected net.minecraft.client.data.models.BlockModelGenerators m_374363_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;)V # createDoublePlantWithDefaultItem -protected net.minecraft.client.data.models.BlockModelGenerators m_374364_(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/world/level/block/state/properties/SculkSensorPhase;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createCalibratedSculkSensor$40 protected net.minecraft.client.data.models.BlockModelGenerators m_374369_(Lnet/minecraft/world/level/block/Block;Ljava/lang/String;)V # registerTwoLayerFlatItemModel -protected net.minecraft.client.data.models.BlockModelGenerators m_374379_(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createRepeater$41 protected net.minecraft.client.data.models.BlockModelGenerators m_374411_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/item/DyeColor;)V # createBed protected net.minecraft.client.data.models.BlockModelGenerators m_374412_()V # createTripwireHook -protected net.minecraft.client.data.models.BlockModelGenerators m_374415_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createCustomFence +protected net.minecraft.client.data.models.BlockModelGenerators m_374415_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createCustomFence protected net.minecraft.client.data.models.BlockModelGenerators m_374416_()V # createHopper protected net.minecraft.client.data.models.BlockModelGenerators m_374434_(Lnet/minecraft/world/level/block/Block;)V # createDoor -protected net.minecraft.client.data.models.BlockModelGenerators m_374436_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/blockstates/Condition$TerminalCondition;Lnet/minecraft/core/Direction;)V # lambda$createMossyCarpet$59 -protected net.minecraft.client.data.models.BlockModelGenerators m_374440_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createCopperBulb +protected net.minecraft.client.data.models.BlockModelGenerators m_374440_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createCopperBulb protected net.minecraft.client.data.models.BlockModelGenerators m_374454_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createCoralFans protected net.minecraft.client.data.models.BlockModelGenerators m_374464_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/Block;)V # createNormalTorch protected net.minecraft.client.data.models.BlockModelGenerators m_374484_()V # createSeaPickle protected net.minecraft.client.data.models.BlockModelGenerators m_374486_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;)V # createDoublePlant protected net.minecraft.client.data.models.BlockModelGenerators m_374496_(Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/client/data/models/BlockModelGenerators$WoodProvider; # woodProvider -protected net.minecraft.client.data.models.BlockModelGenerators m_374498_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;Z)Lnet/minecraft/client/data/models/blockstates/BlockStateGenerator; # createFenceGate -protected net.minecraft.client.data.models.BlockModelGenerators m_374503_([Lnet/minecraft/resources/ResourceLocation;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createRespawnAnchor$65 +protected net.minecraft.client.data.models.BlockModelGenerators m_374498_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Z)Lnet/minecraft/client/data/models/blockstates/BlockModelDefinitionGenerator; # createFenceGate protected net.minecraft.client.data.models.BlockModelGenerators m_374511_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;Lnet/minecraft/world/level/block/state/properties/Property;[I)V # createCrossBlock protected net.minecraft.client.data.models.BlockModelGenerators m_374514_(Lnet/minecraft/world/level/block/Block;)V # createActiveRail -protected net.minecraft.client.data.models.BlockModelGenerators m_374516_(Lnet/minecraft/world/level/block/Block;Ljava/lang/Integer;Lnet/minecraft/world/level/block/state/properties/DoubleBlockHalf;)Lnet/minecraft/client/data/models/blockstates/Variant; # lambda$createPitcherCrop$11 -protected net.minecraft.client.data.models.BlockModelGenerators m_374532_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/data/models/blockstates/Condition$TerminalCondition;Lnet/minecraft/client/data/models/blockstates/VariantProperties$Rotation;Lnet/minecraft/world/level/block/state/properties/BooleanProperty;Lnet/minecraft/client/data/models/model/ModelTemplate;Z)V # addBookSlotModel -protected net.minecraft.client.data.models.BlockModelGenerators m_374541_(Lnet/minecraft/client/data/models/model/ModelTemplate;Ljava/lang/String;Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/client/data/models/BlockModelGenerators$BookSlotModelCacheKey;)Lnet/minecraft/resources/ResourceLocation; # lambda$addBookSlotModel$64 +protected net.minecraft.client.data.models.BlockModelGenerators m_374532_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/renderer/block/model/multipart/Condition;Lnet/minecraft/client/renderer/block/model/VariantMutator;Lnet/minecraft/world/level/block/state/properties/BooleanProperty;Lnet/minecraft/client/data/models/model/ModelTemplate;Z)V # addBookSlotModel +protected net.minecraft.client.data.models.BlockModelGenerators m_374541_(Lnet/minecraft/client/data/models/model/ModelTemplate;Ljava/lang/String;Lnet/minecraft/client/data/models/model/TextureMapping;Lnet/minecraft/client/data/models/BlockModelGenerators$BookSlotModelCacheKey;)Lnet/minecraft/resources/ResourceLocation; # lambda$addBookSlotModel$56 protected net.minecraft.client.data.models.BlockModelGenerators m_374546_()V # createCakeBlock +protected net.minecraft.client.data.models.BlockModelGenerators m_382772_(Ljava/lang/String;I)Lnet/minecraft/util/random/Weighted; # lambda$createBambooModels$22 +protected net.minecraft.client.data.models.BlockModelGenerators m_382773_(Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSweetBerryBush$41 +protected net.minecraft.client.data.models.BlockModelGenerators m_382774_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/world/level/block/entity/vault/VaultState;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createVault$34 +protected net.minecraft.client.data.models.BlockModelGenerators m_382775_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/data/models/MultiVariant;Lcom/mojang/datafixers/util/Pair;)V # lambda$createChiseledBookshelf$54 +protected net.minecraft.client.data.models.BlockModelGenerators m_382776_(Lnet/minecraft/world/level/block/Block;Ljava/lang/String;Lnet/minecraft/client/data/models/model/TextureMapping;)V # lambda$createCreakingHeartModel$16 +protected net.minecraft.client.data.models.BlockModelGenerators m_382777_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;Lnet/minecraft/world/level/block/state/properties/Property;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # lambda$createMultifaceBlockStates$46 +protected net.minecraft.client.data.models.BlockModelGenerators m_382778_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/world/level/block/state/properties/SculkSensorPhase;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSculkSensor$35 +protected net.minecraft.client.data.models.BlockModelGenerators m_382779_([ILnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/BlockModelGenerators$PlantType;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createCrossBlock$17 +protected net.minecraft.client.data.models.BlockModelGenerators m_382780_(Ljava/util/function/Function;Lnet/minecraft/world/level/block/state/StateHolder;Lcom/google/common/collect/ImmutableMap$Builder;Lnet/minecraft/core/Direction;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # lambda$selectMultifaceProperties$45 +protected net.minecraft.client.data.models.BlockModelGenerators m_382781_(Lnet/minecraft/world/level/block/Block;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createBrushableBlock$15 +protected net.minecraft.client.data.models.BlockModelGenerators m_382782_(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createRepeater$37 +protected net.minecraft.client.data.models.BlockModelGenerators m_382783_(Lnet/minecraft/client/renderer/block/model/Variant;)Lnet/minecraft/util/random/Weighted; # lambda$variants$9 +protected net.minecraft.client.data.models.BlockModelGenerators m_382784_(Lnet/minecraft/client/data/models/MultiVariant;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSnowBlocks$38 +protected net.minecraft.client.data.models.BlockModelGenerators m_382785_(Lnet/minecraft/world/level/block/Block;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createHangingMoss$52 +protected net.minecraft.client.data.models.BlockModelGenerators m_382786_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$3 +protected net.minecraft.client.data.models.BlockModelGenerators m_382787_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$2 +protected net.minecraft.client.data.models.BlockModelGenerators m_382788_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Ljava/lang/Boolean;Lnet/minecraft/world/level/block/state/properties/RailShape;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createActiveRail$20 +protected net.minecraft.client.data.models.BlockModelGenerators m_382789_([Lnet/minecraft/resources/ResourceLocation;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createRespawnAnchor$57 +protected net.minecraft.client.data.models.BlockModelGenerators m_382790_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Ljava/lang/Boolean;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createMangrovePropagule$30 +protected net.minecraft.client.data.models.BlockModelGenerators m_382791_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;Lnet/minecraft/world/level/block/state/properties/Property;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # lambda$createMossyCarpet$48 +protected net.minecraft.client.data.models.BlockModelGenerators m_382792_(Ljava/lang/Integer;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createTurtleEgg$43 +protected net.minecraft.client.data.models.BlockModelGenerators m_382793_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;Lnet/minecraft/world/level/block/state/properties/Property;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # lambda$createMossyCarpet$51 +protected net.minecraft.client.data.models.BlockModelGenerators m_382794_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$4 +protected net.minecraft.client.data.models.BlockModelGenerators m_382795_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/renderer/block/model/multipart/Condition;Lnet/minecraft/client/renderer/block/model/VariantMutator;Lcom/mojang/datafixers/util/Pair;)V # lambda$addSlotStateAndRotationVariants$55 +protected net.minecraft.client.data.models.BlockModelGenerators m_382796_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/world/level/block/state/properties/SculkSensorPhase;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createCalibratedSculkSensor$36 +protected net.minecraft.client.data.models.BlockModelGenerators m_382797_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/model/TextureMapping;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createStems$18 +protected net.minecraft.client.data.models.BlockModelGenerators m_382798_(Lnet/minecraft/world/level/block/Block;Ljava/lang/Integer;Lnet/minecraft/world/level/block/state/properties/DoubleBlockHalf;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createPitcherCrop$19 +protected net.minecraft.client.data.models.BlockModelGenerators m_382799_([ILit/unimi/dsi/fastutil/ints/Int2ObjectMap;Lnet/minecraft/world/level/block/Block;Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createCropBlock$26 +protected net.minecraft.client.data.models.BlockModelGenerators m_382800_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$8 +protected net.minecraft.client.data.models.BlockModelGenerators m_382801_(Lnet/minecraft/client/data/models/blockstates/MultiPartGenerator;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;Lnet/minecraft/world/level/block/state/properties/Property;Lnet/minecraft/client/renderer/block/model/VariantMutator;)V # lambda$createMultifaceBlockStates$47 +protected net.minecraft.client.data.models.BlockModelGenerators m_382802_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$7 +protected net.minecraft.client.data.models.BlockModelGenerators m_382803_(Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createTripwireHook$42 +protected net.minecraft.client.data.models.BlockModelGenerators m_382804_(Lnet/minecraft/world/level/block/state/properties/StructureMode;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createStructureBlock$39 +protected net.minecraft.client.data.models.BlockModelGenerators m_382805_(Ljava/lang/Integer;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSnifferEgg$44 +protected net.minecraft.client.data.models.BlockModelGenerators m_382806_(Ljava/util/Map;Lnet/minecraft/world/level/block/state/properties/TestBlockMode;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createTestBlock$40 +protected net.minecraft.client.data.models.BlockModelGenerators m_382807_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$5 +protected net.minecraft.client.data.models.BlockModelGenerators m_382808_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createSculkCatalyst$53 +protected net.minecraft.client.data.models.BlockModelGenerators m_382809_(Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # lambda$static$6 +protected net.minecraft.client.data.models.BlockModelGenerators m_382810_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createCopperBulb$29 +protected net.minecraft.client.data.models.BlockModelGenerators m_382811_(Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/client/data/models/MultiVariant;Lnet/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState;Ljava/lang/Boolean;)Lnet/minecraft/client/data/models/MultiVariant; # lambda$createTrialSpawner$33 +protected net.minecraft.client.data.models.BlockModelGenerators m_384704_(Lnet/minecraft/world/level/block/state/StateHolder;Ljava/util/function/Function;)Ljava/util/Map; # selectMultifaceProperties +protected net.minecraft.client.data.models.BlockModelGenerators m_384866_()Lnet/minecraft/client/data/models/blockstates/ConditionBuilder; # condition +protected net.minecraft.client.data.models.BlockModelGenerators m_385280_(Lnet/minecraft/client/renderer/block/model/Variant;)Lnet/minecraft/client/data/models/MultiVariant; # variant +protected net.minecraft.client.data.models.BlockModelGenerators m_385381_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/data/models/MultiVariant; # plainVariant +protected net.minecraft.client.data.models.BlockModelGenerators m_385921_([Lnet/minecraft/client/renderer/block/model/Variant;)Lnet/minecraft/client/data/models/MultiVariant; # variants +protected net.minecraft.client.data.models.BlockModelGenerators m_386106_()V # createTestBlock +protected net.minecraft.client.data.models.BlockModelGenerators m_386644_([Lnet/minecraft/client/data/models/blockstates/ConditionBuilder;)Lnet/minecraft/client/renderer/block/model/multipart/Condition; # or +protected net.minecraft.client.data.models.BlockModelGenerators m_387650_(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/renderer/block/model/Variant; # plainModel +protected net.minecraft.client.data.models.BlockModelGenerators m_388125_(Lnet/minecraft/client/renderer/block/model/Variant;Lnet/minecraft/client/renderer/block/model/Variant;)Lnet/minecraft/client/data/models/MultiVariant; # createRotatedVariants +protected net.minecraft.client.data.models.BlockModelGenerators m_388369_(Lnet/minecraft/client/data/models/model/TexturedModel$Provider;Lnet/minecraft/world/level/block/Block;Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation; # createCreakingHeartModel +protected net.minecraft.client.data.models.BlockModelGenerators m_388485_(Lnet/minecraft/world/level/block/Block;Lnet/minecraft/client/data/models/MultiVariant;Ljava/util/function/Function;Lnet/minecraft/client/data/models/MultiVariant;Ljava/util/function/Function;Lnet/minecraft/client/data/models/MultiVariant;Ljava/util/function/Function;Lnet/minecraft/client/data/models/MultiVariant;Ljava/util/function/Function;)V # createSegmentedBlock +protected net.minecraft.client.data.models.BlockModelGenerators m_389054_(Lnet/minecraft/client/renderer/block/model/Variant;)Lnet/minecraft/client/data/models/MultiVariant; # createRotatedVariants #endgroup protected net.minecraft.client.data.models.BlockModelGenerators f_371124_ # itemModelOutput protected net.minecraft.client.data.models.BlockModelGenerators f_371133_ # modelOutput @@ -317,7 +311,7 @@ protected net.minecraft.client.data.models.ItemModelGenerators m_372771_(Lnet/mi protected net.minecraft.client.data.models.ItemModelGenerators m_372861_(Lnet/minecraft/world/item/Item;)V # generatePotion protected net.minecraft.client.data.models.ItemModelGenerators m_372885_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/resources/ResourceLocation; # generateLayeredItem protected net.minecraft.client.data.models.ItemModelGenerators m_372915_(Lnet/minecraft/world/item/Item;Lnet/minecraft/client/color/item/ItemTintSource;)V # generateItemWithTintedOverlay -protected net.minecraft.client.data.models.ItemModelGenerators m_372919_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceKey;Ljava/lang/String;Z)V # generateTrimmableItem +protected net.minecraft.client.data.models.ItemModelGenerators m_372919_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/resources/ResourceLocation;Z)V # generateTrimmableItem protected net.minecraft.client.data.models.ItemModelGenerators m_372969_(Lnet/minecraft/world/item/Item;Ljava/lang/String;Lnet/minecraft/client/data/models/model/ModelTemplate;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModel protected net.minecraft.client.data.models.ItemModelGenerators m_373030_(Lnet/minecraft/world/item/Item;)V # generateShield protected net.minecraft.client.data.models.ItemModelGenerators m_373037_(Lnet/minecraft/world/item/Item;)V # generateStandardCompassItem @@ -337,7 +331,6 @@ protected net.minecraft.client.data.models.ItemModelGenerators m_374089_(Lnet/mi protected net.minecraft.client.data.models.ItemModelGenerators m_374190_(Lnet/minecraft/world/item/Item;)V # generateFishingRod protected net.minecraft.client.data.models.ItemModelGenerators m_374289_(Lnet/minecraft/world/item/Item;)V # generateBrush protected net.minecraft.client.data.models.ItemModelGenerators m_374337_(Lnet/minecraft/world/item/Item;Lnet/minecraft/world/item/Item;Lnet/minecraft/client/data/models/model/ModelTemplate;)V # generateFlatItem -protected net.minecraft.client.data.models.ItemModelGenerators m_374345_(Lnet/minecraft/world/item/Item;II)V # generateSpawnEgg protected net.minecraft.client.data.models.ItemModelGenerators m_374365_(Lnet/minecraft/world/item/Item;)V # generateRecoveryCompassItem #endgroup protected net.minecraft.client.data.models.ItemModelGenerators f_370758_ # modelOutput @@ -373,10 +366,52 @@ public net.minecraft.client.particle.ParticleEngine m_272137_(Lnet/minecraft/cor public net.minecraft.client.particle.ParticleEngine$SpriteParticleRegistration public net.minecraft.client.player.LocalPlayer m_9242_()I # getPermissionLevel public net.minecraft.client.renderer.LevelRenderer m_109817_()Z # shouldShowEntityOutlines +#group public net.minecraft.client.renderer.RenderPipelines * +public net.minecraft.client.renderer.RenderPipelines f_379621_ # GUI_TEXTURED_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_380033_ # DEBUG_FILLED_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_380078_ # TERRAIN_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_380180_ # TEXT_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_380191_ # PARTICLE_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_380221_ # FOG_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_380403_ # END_PORTAL_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_380564_ # OUTLINE_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_380734_ # MATRICES_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_380747_ # MATRICES_COLOR_FOG_OFFSET_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_381014_ # CLOUDS_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_381310_ # WEATHER_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_381389_ # PIPELINES_BY_LOCATION +public net.minecraft.client.renderer.RenderPipelines f_381438_ # MATRICES_COLOR_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_381970_ # MATRICES_COLOR_FOG_LIGHT_DIR_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_381976_ # ENTITY_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_382307_ # FOG_NO_COLOR_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_382486_ # LINES_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_382492_ # MATRICES_COLOR_FOG_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_382524_ # GUI_SNIPPET +public net.minecraft.client.renderer.RenderPipelines f_382587_ # BEACON_BEAM_SNIPPET +#endgroup +public net.minecraft.client.renderer.RenderStateShard f_110117_ # NO_LAYERING +public net.minecraft.client.renderer.RenderStateShard f_110119_ # VIEW_OFFSET_Z_LAYERING +public net.minecraft.client.renderer.RenderStateShard f_110123_ # MAIN_TARGET +public net.minecraft.client.renderer.RenderStateShard f_110124_ # OUTLINE_TARGET +public net.minecraft.client.renderer.RenderStateShard f_110125_ # TRANSLUCENT_TARGET +public net.minecraft.client.renderer.RenderStateShard f_110126_ # PARTICLES_TARGET +public net.minecraft.client.renderer.RenderStateShard f_110127_ # WEATHER_TARGET +public net.minecraft.client.renderer.RenderStateShard f_110129_ # ITEM_ENTITY_TARGET +public net.minecraft.client.renderer.RenderStateShard f_110130_ # DEFAULT_LINE protected-f net.minecraft.client.renderer.RenderStateShard f_110131_ # setupState +public net.minecraft.client.renderer.RenderStateShard f_110145_ # BLOCK_SHEET_MIPPED +public net.minecraft.client.renderer.RenderStateShard f_110146_ # BLOCK_SHEET +public net.minecraft.client.renderer.RenderStateShard f_110147_ # NO_TEXTURE +public net.minecraft.client.renderer.RenderStateShard f_110148_ # DEFAULT_TEXTURING +public net.minecraft.client.renderer.RenderStateShard f_110150_ # GLINT_TEXTURING +public net.minecraft.client.renderer.RenderStateShard f_110151_ # ENTITY_GLINT_TEXTURING +public net.minecraft.client.renderer.RenderStateShard f_110152_ # LIGHTMAP +public net.minecraft.client.renderer.RenderStateShard f_110153_ # NO_LIGHTMAP +public net.minecraft.client.renderer.RenderStateShard f_110154_ # OVERLAY +public net.minecraft.client.renderer.RenderStateShard f_110155_ # NO_OVERLAY +public net.minecraft.client.renderer.RenderStateShard f_347557_ # VIEW_OFFSET_Z_LAYERING_FORWARD +public net.minecraft.client.renderer.RenderStateShard f_381391_ # ARMOR_ENTITY_GLINT_TEXTURING public net.minecraft.client.renderer.RenderStateShard$BooleanStateShard -public net.minecraft.client.renderer.RenderStateShard$CullStateShard -public net.minecraft.client.renderer.RenderStateShard$DepthTestStateShard public net.minecraft.client.renderer.RenderStateShard$EmptyTextureStateShard public net.minecraft.client.renderer.RenderStateShard$LayeringStateShard public net.minecraft.client.renderer.RenderStateShard$LightmapStateShard @@ -384,24 +419,29 @@ public net.minecraft.client.renderer.RenderStateShard$MultiTextureStateShard public net.minecraft.client.renderer.RenderStateShard$OffsetTexturingStateShard public net.minecraft.client.renderer.RenderStateShard$OutputStateShard public net.minecraft.client.renderer.RenderStateShard$OverlayStateShard -public net.minecraft.client.renderer.RenderStateShard$ShaderStateShard public net.minecraft.client.renderer.RenderStateShard$TextureStateShard protected-f net.minecraft.client.renderer.RenderStateShard$TextureStateShard f_110329_ # blur protected-f net.minecraft.client.renderer.RenderStateShard$TextureStateShard f_110330_ # mipmap public net.minecraft.client.renderer.RenderStateShard$TexturingStateShard -public net.minecraft.client.renderer.RenderStateShard$TransparencyStateShard -public net.minecraft.client.renderer.RenderStateShard$WriteMaskStateShard -public net.minecraft.client.renderer.RenderType m_173215_(Ljava/lang/String;Lcom/mojang/blaze3d/vertex/VertexFormat;Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;IZZLnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType; # create +public net.minecraft.client.renderer.RenderType m_173209_(Ljava/lang/String;ILcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType; # create +public net.minecraft.client.renderer.RenderType m_173215_(Ljava/lang/String;IZZLcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType; # create +public net.minecraft.client.renderer.RenderType$CompositeRenderType public net.minecraft.client.renderer.RenderType$CompositeState -public net.minecraft.client.renderer.block.model.BlockElement m_111320_(Lnet/minecraft/core/Direction;)[F # uvsByFace +public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder ()V # constructor +public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110669_(Lnet/minecraft/client/renderer/RenderStateShard$LayeringStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setLayeringState +public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110671_(Lnet/minecraft/client/renderer/RenderStateShard$LightmapStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setLightmapState +public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110673_(Lnet/minecraft/client/renderer/RenderStateShard$LineStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setLineState +public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110675_(Lnet/minecraft/client/renderer/RenderStateShard$OutputStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setOutputState +public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110677_(Lnet/minecraft/client/renderer/RenderStateShard$OverlayStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setOverlayState +public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110683_(Lnet/minecraft/client/renderer/RenderStateShard$TexturingStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setTexturingState +public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110689_(Lnet/minecraft/client/renderer/RenderType$OutlineProperty;)Lnet/minecraft/client/renderer/RenderType$CompositeState; # createCompositeState +public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_110691_(Z)Lnet/minecraft/client/renderer/RenderType$CompositeState; # createCompositeState +public net.minecraft.client.renderer.RenderType$CompositeState$CompositeStateBuilder m_173290_(Lnet/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard;)Lnet/minecraft/client/renderer/RenderType$CompositeState$CompositeStateBuilder; # setTextureState public net.minecraft.client.renderer.block.model.BlockElement$Deserializer public net.minecraft.client.renderer.block.model.BlockElement$Deserializer ()V # constructor public net.minecraft.client.renderer.block.model.BlockElementFace$Deserializer public net.minecraft.client.renderer.block.model.BlockElementFace$Deserializer ()V # constructor -public net.minecraft.client.renderer.block.model.BlockFaceUV$Deserializer -public net.minecraft.client.renderer.block.model.BlockFaceUV$Deserializer ()V # constructor public net.minecraft.client.renderer.block.model.BlockModel f_111418_ # parent -public net.minecraft.client.renderer.block.model.BlockModel f_111424_ # hasAmbientOcclusion public net.minecraft.client.renderer.block.model.BlockModel f_370667_ # textureSlots public net.minecraft.client.renderer.block.model.ItemModelGenerator m_111638_(ILjava/lang/String;Lnet/minecraft/client/renderer/texture/SpriteContents;)Ljava/util/List; # processFrames public net.minecraft.client.renderer.block.model.ItemTransform$Deserializer @@ -418,17 +458,14 @@ public net.minecraft.client.renderer.blockentity.SkullBlockRenderer f_112519_ # public net.minecraft.client.renderer.entity.EntityRenderDispatcher f_114362_ # renderers public net.minecraft.client.renderer.entity.EntityRenderers m_174036_(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/client/renderer/entity/EntityRendererProvider;)V # register public net.minecraft.client.renderer.entity.ItemRenderer m_115162_(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Ljava/util/List;[III)V # renderQuadList -public net.minecraft.client.renderer.entity.ItemRenderer m_115189_(Lnet/minecraft/client/resources/model/BakedModel;[IIILcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;)V # renderModelLists public net.minecraft.client.renderer.entity.LivingEntityRenderer m_115326_(Lnet/minecraft/client/renderer/entity/layers/RenderLayer;)Z # addLayer protected net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer m_117078_(Lnet/minecraft/client/renderer/entity/state/HumanoidRenderState;Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/client/model/HumanoidModel; # getArmorModel -public net.minecraft.client.renderer.item.BlockModelWrapper f_371418_ # model public net.minecraft.client.renderer.texture.SpriteContents f_243731_ # byMipLevel default net.minecraft.client.renderer.texture.SpriteContents f_244575_ # animatedTexture default net.minecraft.client.renderer.texture.SpriteContents m_245088_()I # getFrameCount public net.minecraft.client.resources.ClientPackSource m_246691_(Ljava/nio/file/Path;)Lnet/minecraft/server/packs/VanillaPackResources; # createVanillaPackSource protected net.minecraft.client.resources.TextureAtlasHolder f_118884_ # textureAtlas -public net.minecraft.client.resources.model.SimpleBakedModel m_373830_(Lnet/minecraft/client/renderer/block/model/BlockElement;Lnet/minecraft/client/renderer/block/model/BlockElementFace;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/core/Direction;Lnet/minecraft/client/resources/model/ModelState;)Lnet/minecraft/client/renderer/block/model/BakedQuad; # bakeFace -public net.minecraft.client.resources.model.SimpleBakedModel$Builder (ZZZLnet/minecraft/client/renderer/block/model/ItemTransforms;)V # constructor +public net.minecraft.client.resources.model.ModelDiscovery$ModelWrapper public net.minecraft.client.sounds.SoundEngine f_120217_ # soundManager public net.minecraft.commands.CommandSourceStack f_81288_ # source public net.minecraft.commands.arguments.selector.EntitySelectorParser m_121229_()V # finalizePredicates @@ -476,7 +513,6 @@ public net.minecraft.data.tags.IntrinsicHolderTagsProvider$IntrinsicTagAppender protected net.minecraft.data.tags.TagsProvider f_126543_ # builders public-f net.minecraft.data.tags.TagsProvider m_6055_()Ljava/lang/String; # getName public net.minecraft.data.tags.TagsProvider$TagAppender -public net.minecraft.gametest.framework.GameTestServer (Ljava/lang/Thread;Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Lnet/minecraft/server/packs/repository/PackRepository;Lnet/minecraft/server/WorldStem;Ljava/util/Collection;Lnet/minecraft/core/BlockPos;)V # constructor public net.minecraft.resources.ResourceLocation m_135835_(C)Z # validNamespaceChar public net.minecraft.resources.ResourceLocation m_135841_(Ljava/lang/String;)Z # isValidPath public net.minecraft.resources.ResourceLocation m_135843_(Ljava/lang/String;)Z # isValidNamespace @@ -502,7 +538,6 @@ public net.minecraft.world.damagesource.DamageSource (Lnet/minecraft/core/ #endgroup protected net.minecraft.world.entity.Entity f_19843_ # ENTITY_COUNTER public net.minecraft.world.entity.Entity m_20078_()Ljava/lang/String; # getEncodeId -public net.minecraft.world.entity.ExperienceOrb f_20770_ # value public net.minecraft.world.entity.Mob f_21345_ # goalSelector public net.minecraft.world.entity.Mob f_21346_ # targetSelector public net.minecraft.world.entity.ai.memory.MemoryModuleType (Ljava/util/Optional;)V # constructor @@ -525,7 +560,6 @@ public net.minecraft.world.entity.npc.VillagerTrades$SuspiciousStewForEmerald public net.minecraft.world.entity.npc.VillagerTrades$TippedArrowForItemsAndEmeralds public net.minecraft.world.entity.npc.VillagerTrades$TreasureMapForEmeralds public net.minecraft.world.entity.npc.VillagerTrades$TypeSpecificTrade -public net.minecraft.world.entity.npc.VillagerType (Ljava/lang/String;)V # constructor public net.minecraft.world.entity.player.Player m_6915_()V # closeContainer protected net.minecraft.world.entity.projectile.Projectile (Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V # constructor private-f net.minecraft.world.entity.raid.Raid$RaiderType f_37813_ # VALUES @@ -551,7 +585,6 @@ public net.minecraft.world.item.CreativeModeTabs f_256968_ # INGREDIENTS public net.minecraft.world.item.CreativeModeTabs f_257028_ # REDSTONE_BLOCKS public net.minecraft.world.item.CreativeModeTabs f_257039_ # INVENTORY #group public net.minecraft.world.item.Item -public net.minecraft.world.item.DiggerItem (Lnet/minecraft/world/item/ToolMaterial;Lnet/minecraft/tags/TagKey;FFLnet/minecraft/world/item/Item$Properties;)V # constructor #endgroup private-f net.minecraft.world.item.ItemDisplayContext f_268735_ # id public net.minecraft.world.item.ItemStackLinkedSet f_260558_ # TYPE_AND_TAG @@ -576,6 +609,7 @@ protected net.minecraft.world.level.biome.BiomeGenerationSettings$PlainBuilder f protected net.minecraft.world.level.biome.BiomeGenerationSettings$PlainBuilder m_255276_(I)V # addFeatureStepsUpTo #group protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder * protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_371299_ # backgroundMusicVolume +protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_380225_ # dryFoliageColorOverride protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48005_ # fogColor protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48006_ # waterColor protected net.minecraft.world.level.biome.BiomeSpecialEffects$Builder f_48007_ # waterFogColor @@ -602,6 +636,7 @@ public net.minecraft.world.level.block.BaseCoralWallFanBlock (Lnet/minecra public net.minecraft.world.level.block.BigDripleafBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.BigDripleafStemBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.BlastFurnaceBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.BushBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.ButtonBlock (Lnet/minecraft/world/level/block/state/properties/BlockSetType;ILnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CactusBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CakeBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -617,11 +652,11 @@ public net.minecraft.world.level.block.CoralWallFanBlock (Lnet/minecraft/w public net.minecraft.world.level.block.CraftingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CreakingHeartBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.CropBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.DeadBushBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.DecoratedPotBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.DirtPathBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.DispenserBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.DoorBlock (Lnet/minecraft/world/level/block/state/properties/BlockSetType;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.DryVegetationBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.EnchantingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.EndGatewayBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.EndPortalBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -629,6 +664,7 @@ public net.minecraft.world.level.block.EndRodBlock (Lnet/minecraft/world/l public net.minecraft.world.level.block.EnderChestBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.FarmBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.FletchingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.FlowerBedBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.FungusBlock (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.FurnaceBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.GrindstoneBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -647,7 +683,6 @@ public net.minecraft.world.level.block.LoomBlock (Lnet/minecraft/world/lev public net.minecraft.world.level.block.MangroveRootsBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.NetherWartBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.NyliumBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor -public net.minecraft.world.level.block.PinkPetalsBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.PlayerHeadBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.PlayerWallHeadBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.PoweredRailBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -662,6 +697,7 @@ public net.minecraft.world.level.block.SaplingBlock (Lnet/minecraft/world/ public net.minecraft.world.level.block.ScaffoldingBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.SeaPickleBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.SeagrassBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.ShortDryGrassBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.SkullBlock (Lnet/minecraft/world/level/block/SkullBlock$Type;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.SmithingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.SmokerBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -674,6 +710,7 @@ public net.minecraft.world.level.block.StemBlock (Lnet/minecraft/resources public net.minecraft.world.level.block.StructureBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.StructureVoidBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.SugarCaneBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor +public net.minecraft.world.level.block.TallDryGrassBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.TallGrassBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.TorchBlock (Lnet/minecraft/core/particles/SimpleParticleType;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.TransparentBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor diff --git a/src/main/resources/coremods/finalize_spawn_targets.json b/src/main/resources/coremods/finalize_spawn_targets.json index 13f2ba0830..fcca4a9b81 100644 --- a/src/main/resources/coremods/finalize_spawn_targets.json +++ b/src/main/resources/coremods/finalize_spawn_targets.json @@ -70,7 +70,7 @@ { "class": "net/minecraft/world/entity/npc/CatSpawner", "methods": [ - "spawnCat(Lnet/minecraft/core/BlockPos;Lnet/minecraft/server/level/ServerLevel;)I" + "spawnCat(Lnet/minecraft/core/BlockPos;Lnet/minecraft/server/level/ServerLevel;Z)V" ] }, { @@ -82,7 +82,7 @@ { "class": "net/minecraft/world/entity/raid/Raid", "methods": [ - "joinRaid(ILnet/minecraft/world/entity/raid/Raider;Lnet/minecraft/core/BlockPos;Z)V" + "joinRaid(Lnet/minecraft/server/level/ServerLevel;ILnet/minecraft/world/entity/raid/Raider;Lnet/minecraft/core/BlockPos;Z)V" ] }, { @@ -107,7 +107,7 @@ { "class": "net/minecraft/world/level/levelgen/PhantomSpawner", "methods": [ - "tick(Lnet/minecraft/server/level/ServerLevel;ZZ)I" + "tick(Lnet/minecraft/server/level/ServerLevel;ZZ)V" ] }, { diff --git a/src/test/generated/mdk_datagen/pack.mcmeta b/src/test/generated/mdk_datagen/pack.mcmeta index e6a650030c..8b20d76544 100644 --- a/src/test/generated/mdk_datagen/pack.mcmeta +++ b/src/test/generated/mdk_datagen/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "${mod_id} resources", - "pack_format": 46 + "pack_format": 55 } } \ No newline at end of file diff --git a/src/test/generated/test_helper_mod/pack.mcmeta b/src/test/generated/test_helper_mod/pack.mcmeta index 6b178df5a7..262d049729 100644 --- a/src/test/generated/test_helper_mod/pack.mcmeta +++ b/src/test/generated/test_helper_mod/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "Forge tests resource pack", - "pack_format": 46 + "pack_format": 55 } } \ No newline at end of file diff --git a/src/test/java/net/minecraftforge/debug/client/AdditionalModelTest.java b/src/test/java/net/minecraftforge/debug/client/AdditionalModelTest.java index 0b921a94fe..b68adf920d 100644 --- a/src/test/java/net/minecraftforge/debug/client/AdditionalModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/AdditionalModelTest.java @@ -16,6 +16,7 @@ import net.minecraft.client.model.CowModel; import net.minecraft.client.model.PigModel; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.block.ModelBlockRenderer; import net.minecraft.client.renderer.entity.LivingEntityRenderer; import net.minecraft.client.renderer.entity.layers.RenderLayer; import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; @@ -23,18 +24,19 @@ import net.minecraft.client.renderer.entity.state.PigRenderState; import net.minecraft.client.renderer.item.BlockModelWrapper; import net.minecraft.client.renderer.item.ItemStackRenderState; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.core.registries.Registries; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.animal.Cow; import net.minecraft.world.entity.animal.Pig; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemDisplayContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockBehaviour; @@ -48,6 +50,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.RegistryObject; @@ -71,6 +74,7 @@ public class AdditionalModelTest extends BaseTestMod { private static final DeferredRegister BLOCKS = DeferredRegister.create(Registries.BLOCK, MODID); private static final RegistryObject PIG_HEAD = BLOCKS.register("pig_head", () -> new Block(BlockBehaviour.Properties.of().setId(BLOCKS.key("pig_head")))); private static final RegistryObject COW_HEAD = BLOCKS.register("cow_head", () -> new Block(BlockBehaviour.Properties.of().setId(BLOCKS.key("cow_head")))); + private static final StateDefinition COW_HEAD_STATE = new StateDefinition.Builder(Blocks.AIR).create(Block::defaultBlockState, BlockState::new); private static final DeferredRegister ITEMS = DeferredRegister.create(Registries.ITEM, MODID); private static final RegistryObject PIG_HEAD_ITEM = ITEMS.register("pig_head", () -> new Item(new Item.Properties().setId(ITEMS.key("pig_head")))); @@ -100,13 +104,10 @@ public class AdditionalModelTest extends BaseTestMod { @SubscribeEvent public void onRegisterAdditional(ModelEvent.RegisterModelStateDefinitions event) { // Our fake blocks are only created during data gen, so we have to add a fake mapper - event.register(rl("cow_head"), - new StateDefinition.Builder(Blocks.AIR) - .create(Block::defaultBlockState, BlockState::new) - ); + event.register(rl("cow_head"), COW_HEAD_STATE); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void item_model(GameTestHelper helper) { var manager = Minecraft.getInstance().getModelManager(); @@ -121,21 +122,18 @@ public class AdditionalModelTest extends BaseTestMod { helper.succeed(); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void block_model(GameTestHelper helper) { var manager = Minecraft.getInstance().getModelManager(); - var key = new ModelResourceLocation(rl("cow_head"), ""); - var model = manager.getModel(key); - - if (model == null || model == manager.getMissingModel()) - helper.fail("Failed to retreive " + key + " block model"); + var model = manager.getBlockModelShaper().getBlockModel(COW_HEAD_STATE.any()); + helper.assertValueNotEqual(manager.getMissingBlockStateModel(), model, MODID, "Failed to retreive block model"); helper.succeed(); } // An example on how to render both the item and block model variants - //@SubscribeEvent + @SubscribeEvent public void onAddLayers(EntityRenderersEvent.AddLayers event) { // Pigs get a block on their head, this is a test of going through the ItemModel loader LivingEntityRenderer pig = event.getEntityRenderer(EntityType.PIG); @@ -144,6 +142,7 @@ public class AdditionalModelTest extends BaseTestMod { public void render(PoseStack stack, MultiBufferSource source, int light, PigRenderState state, float xRot, float yRot) { this.getParentModel().getAnyDescendantWithName("head").ifPresent(part -> { var manager = Minecraft.getInstance().getModelManager(); + var resolver = Minecraft.getInstance().getItemModelResolver(); stack.pushPose(); this.getParentModel().root().translateAndRotate(stack); part.translateAndRotate(stack); @@ -151,11 +150,8 @@ public class AdditionalModelTest extends BaseTestMod { stack.translate(0, -1, -0.5); var model = manager.getItemModel(rl("pig_head")); - if (model instanceof BlockModelWrapper wrapper) { - var itemState = new ItemStackRenderState(); - itemState.newLayer().setupBlockModel(wrapper.model, RenderType.solid()); - itemState.render(stack, source, light, light); - } + var renderState = new ItemStackRenderState(); + model.update(renderState, new ItemStack(Items.STONE), resolver, ItemDisplayContext.FIXED, null, null, 0); stack.popPose(); }); } @@ -169,7 +165,6 @@ public class AdditionalModelTest extends BaseTestMod { public void render(PoseStack stack, MultiBufferSource source, int light, LivingEntityRenderState state, float xRot, float yRot) { this.getParentModel().getAnyDescendantWithName("head").ifPresent(part -> { var manager = Minecraft.getInstance().getModelManager(); - var renderer = Minecraft.getInstance().getBlockRenderer().getModelRenderer(); stack.pushPose(); @@ -179,11 +174,10 @@ public class AdditionalModelTest extends BaseTestMod { stack.translate(-0.5, -0.5, -0.5); stack.translate(0, -1, -0.5); - var ml = new ModelResourceLocation(rl("cow_head"), ""); - var model = manager.getModel(ml); + var model = manager.getBlockModelShaper().getBlockModel(COW_HEAD_STATE.any()); var consumer = source.getBuffer(RenderType.solid()); - renderer.renderModel(stack.last(), consumer, null, model, 1.0F, 1.0F, 1.0F, light, OverlayTexture.NO_OVERLAY, ModelData.EMPTY, null); + ModelBlockRenderer.renderModel(stack.last(), consumer, model, 1.0F, 1.0F, 1.0F, light, OverlayTexture.NO_OVERLAY, ModelData.EMPTY, null); stack.popPose(); }); } @@ -209,7 +203,7 @@ public class AdditionalModelTest extends BaseTestMod { public void run() { ModelTemplates.CUBE_ALL.create(PIG_HEAD.get(), TextureMapping.cube(Blocks.COBBLESTONE), this.modelOutput); var cow = ModelTemplates.CUBE_ALL.create(COW_HEAD.get(), TextureMapping.cube(Blocks.BEDROCK), this.modelOutput); - this.blockStateOutput.accept(createSimpleBlock(COW_HEAD.get(), cow)); + this.blockStateOutput.accept(createSimpleBlock(COW_HEAD.get(), plainVariant(cow))); } }; } diff --git a/src/test/java/net/minecraftforge/debug/client/LateBoundIdMapperTest.java b/src/test/java/net/minecraftforge/debug/client/LateBoundIdMapperTest.java index b3df94d73f..6757c0bf6e 100644 --- a/src/test/java/net/minecraftforge/debug/client/LateBoundIdMapperTest.java +++ b/src/test/java/net/minecraftforge/debug/client/LateBoundIdMapperTest.java @@ -8,13 +8,13 @@ package net.minecraftforge.debug.client; import net.minecraft.client.color.item.ItemTintSource; import net.minecraft.client.color.item.ItemTintSources; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.test.BaseTestMod; import javax.annotation.Nullable; @@ -37,7 +37,7 @@ public class LateBoundIdMapperTest extends BaseTestMod { return ResourceLocation.fromNamespaceAndPath(MODID, path); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void compound(GameTestHelper helper) { var ID_MAPPER = ItemTintSources.ID_MAPPER; diff --git a/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java b/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java index 7110283d9d..430fb74922 100644 --- a/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java +++ b/src/test/java/net/minecraftforge/debug/client/ModelRenderLayerTest.java @@ -5,26 +5,19 @@ package net.minecraftforge.debug.client; -import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.data.models.BlockModelGenerators; import net.minecraft.client.data.models.ItemModelGenerators; import net.minecraft.client.data.models.model.ItemModelUtils; -import net.minecraft.client.data.models.model.ModelLocationUtils; import net.minecraft.client.data.models.model.ModelTemplates; import net.minecraft.client.data.models.model.TextureMapping; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.core.registries.Registries; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; -import net.minecraft.gametest.framework.GameTest; -import net.minecraft.gametest.framework.GameTestAssertException; import net.minecraft.gametest.framework.GameTestHelper; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -33,16 +26,17 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.SaplingBlock; import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.TintedParticleLeavesBlock; import net.minecraft.world.level.block.grower.TreeGrower; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.MapColor; import net.minecraft.world.level.material.PushReaction; -import net.minecraftforge.client.ChunkRenderTypeSet; import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.RegistryObject; @@ -81,7 +75,8 @@ public class ModelRenderLayerTest extends BaseTestMod { private static final String OLD_LEAVES_NAME = "old_leaves"; private static final BlockBehaviour.StatePredicate FALSE = (state, level, pos) -> false; public static final RegistryObject OLD_LEAVES = BLOCKS.register(OLD_LEAVES_NAME, - () -> new LeavesBlock( + () -> new TintedParticleLeavesBlock( + 0.01F, BlockBehaviour.Properties.of() .setId(BLOCKS.key(OLD_LEAVES_NAME)) .mapColor(MapColor.PLANT) @@ -101,10 +96,6 @@ public class ModelRenderLayerTest extends BaseTestMod { public static final RegistryObject ITEM = ITEMS.register(BLOCK_NAME, () -> new BlockItem(BLOCK.get(), new Item.Properties().setId(ITEMS.key(BLOCK_NAME)))); public static final RegistryObject OLD_LEAVES_ITEM = ITEMS.register(OLD_LEAVES_NAME, () -> new BlockItem(OLD_LEAVES.get(), new Item.Properties().setId(ITEMS.key(OLD_LEAVES_NAME)))); - private static ResourceLocation rl(String path) { - return ResourceLocation.fromNamespaceAndPath(MODID, path); - } - public ModelRenderLayerTest(FMLJavaModLoadingContext context) { super(context); testItem(lookup -> new ItemStack(ITEM.get())); @@ -116,15 +107,12 @@ public class ModelRenderLayerTest extends BaseTestMod { event.getGenerator().addProvider(event.includeClient(), new ModelProvider(out)); } - @SuppressWarnings("resource") - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void type_from_model(GameTestHelper helper) { var manager = Minecraft.getInstance().getModelManager(); - var key = new ModelResourceLocation(rl(BLOCK_NAME), "stage=0"); - var model = manager.getModel(key); - if (model == manager.getMissingModel()) - helper.fail("Failed to retreive block model for" + key); + var model = manager.getBlockModelShaper().getBlockModel(BLOCK.get().defaultBlockState()); + helper.assertValueNotEqual(manager.getMissingBlockStateModel(), model, BLOCK_NAME, "Failed to retreive block model"); var state = BLOCK.get().defaultBlockState(); var random = helper.getLevel().random; @@ -142,15 +130,15 @@ public class ModelRenderLayerTest extends BaseTestMod { helper.succeed(); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void old_leaves_render_type(GameTestHelper helper) { var manager = Minecraft.getInstance().getModelManager(); - var key = rl(OLD_LEAVES_NAME); - var models = manager.getModels().entrySet().stream().filter(ml -> ml.getKey().id().equals(key)).map(Map.Entry::getValue).findAny(); - var model = models.orElseThrow(() -> new GameTestAssertException("Failed to retrieve any block models for " + key)); var state = OLD_LEAVES.get().defaultBlockState(); + var model = manager.getBlockModelShaper().getBlockModel(state); + helper.assertValueNotEqual(manager.getMissingBlockStateModel(), model, OLD_LEAVES_NAME, "Failed to retreive block model"); + var random = helper.getLevel().random; boolean originalRenderState = ItemBlockRenderTypes.isFancy(); helper.addCleanup(passed -> ItemBlockRenderTypes.setFancy(originalRenderState)); @@ -191,7 +179,7 @@ public class ModelRenderLayerTest extends BaseTestMod { json.addProperty("render_type_fast", "minecraft:solid"); this.modelOutput.accept(name, () -> json); }); - this.blockStateOutput.accept(createSimpleBlock(BLOCK.get(), cutout)); + this.blockStateOutput.accept(createSimpleBlock(BLOCK.get(), variant(plainModel(cutout)))); var item = ModelTemplates.FLAT_ITEM.create(ITEM.get(), TextureMapping.layer0(Blocks.ACACIA_SAPLING), this.modelOutput); this.itemModelOutput.accept(ITEM.get(), ItemModelUtils.plainModel(item)); @@ -203,7 +191,7 @@ public class ModelRenderLayerTest extends BaseTestMod { json.addProperty("render_type", "minecraft:cutout_mipped"); this.modelOutput.accept(name, () -> json); }); - this.blockStateOutput.accept(createSimpleBlock(OLD_LEAVES.get(), oldLeavesCutout)); + this.blockStateOutput.accept(createSimpleBlock(OLD_LEAVES.get(), variant(plainModel(oldLeavesCutout)))); this.itemModelOutput.accept(OLD_LEAVES_ITEM.get(), ItemModelUtils.plainModel(oldLeavesCutout)); } diff --git a/src/test/java/net/minecraftforge/debug/gameplay/block/ChorusBlockPlacementTest.java b/src/test/java/net/minecraftforge/debug/gameplay/block/ChorusBlockPlacementTest.java index e059fce8d2..80f35eed5f 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/block/ChorusBlockPlacementTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/block/ChorusBlockPlacementTest.java @@ -7,18 +7,16 @@ package net.minecraftforge.debug.gameplay.block; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; -import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.common.Tags; import net.minecraftforge.common.data.BlockTagsProvider; import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -37,7 +35,7 @@ public class ChorusBlockPlacementTest extends BaseTestMod { super(context); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void custom_placeable_block(GameTestHelper helper) { var custom = helper.setAssertAndGetBlock(BlockPos.ZERO, BLOCK.get()); helper.assertTrue(custom.is(Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON), () -> "Block %s is not placeable on chorus".formatted(custom.getBlock())); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java b/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java index f406bf4642..bab7d4e81e 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/crafting/ConditionalRecipeTest.java @@ -17,7 +17,6 @@ import net.minecraft.data.recipes.RecipeProvider; import net.minecraft.data.recipes.SimpleCookingRecipeBuilder; import net.minecraft.data.recipes.SingleItemRecipeBuilder; import net.minecraft.data.tags.ItemTagsProvider; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; @@ -41,6 +40,7 @@ import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.test.BaseTestMod; @@ -79,7 +79,7 @@ public class ConditionalRecipeTest extends BaseTestMod { helper.succeed(); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void shaped_false_conditions(GameTestHelper helper) { assertFalse(helper, RecipeType.CRAFTING, SimpleCraftingContainer.builder() .pattern( @@ -92,7 +92,7 @@ public class ConditionalRecipeTest extends BaseTestMod { ); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void shaped_true_conditions(GameTestHelper helper) { assertTrue(helper, RecipeType.CRAFTING, SimpleCraftingContainer.builder() .pattern( @@ -105,7 +105,7 @@ public class ConditionalRecipeTest extends BaseTestMod { ); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void shapeless_false_conditions(GameTestHelper helper) { assertFalse(helper, RecipeType.CRAFTING, SimpleCraftingContainer.builder() .pattern("XXX") @@ -114,7 +114,7 @@ public class ConditionalRecipeTest extends BaseTestMod { ); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void shapeless_true_conditions(GameTestHelper helper) { assertTrue(helper, RecipeType.CRAFTING, SimpleCraftingContainer.builder() .pattern("XXXX") @@ -123,27 +123,27 @@ public class ConditionalRecipeTest extends BaseTestMod { ); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void cooking_false_conditions(GameTestHelper helper) { assertFalse(helper, RecipeType.SMELTING, new SingleRecipeInput(new ItemStack(Blocks.DIRT))); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void cooking_true_conditions(GameTestHelper helper) { assertTrue(helper, RecipeType.SMELTING, new SingleRecipeInput(new ItemStack(Blocks.BEE_NEST))); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void single_item_false_conditions(GameTestHelper helper) { assertFalse(helper, RecipeType.STONECUTTING, new SingleRecipeInput(new ItemStack(Blocks.DIRT))); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void single_item_true_conditions(GameTestHelper helper) { assertTrue(helper, RecipeType.STONECUTTING, new SingleRecipeInput(new ItemStack(Blocks.REDSTONE_ORE))); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void conditional_recipe_choice(GameTestHelper helper) { assertFalse(helper, RecipeType.CRAFTING, SimpleCraftingContainer.builder() .pattern("XXX") @@ -159,7 +159,7 @@ public class ConditionalRecipeTest extends BaseTestMod { ); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void tag_empty_condition_with_populated_tag(GameTestHelper helper) { assertFalse(helper, RecipeType.CRAFTING, SimpleCraftingContainer.builder() .pattern("XXX") @@ -168,7 +168,7 @@ public class ConditionalRecipeTest extends BaseTestMod { ); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void tag_empty_condition_with_empty_tag(GameTestHelper helper) { assertTrue(helper, RecipeType.CRAFTING, SimpleCraftingContainer.builder() .pattern("XXX") diff --git a/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java b/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java index c5bb059c27..2e3351d393 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/crafting/CustomIngredientsTest.java @@ -21,7 +21,6 @@ import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.RecipeProvider; import net.minecraft.data.recipes.ShapedRecipeBuilder; import net.minecraft.data.tags.ItemTagsProvider; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceKey; @@ -46,6 +45,7 @@ import net.minecraftforge.common.util.INBTBuilder; import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.test.BaseTestMod; @@ -131,7 +131,7 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { return ret; } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void partial_nbt(GameTestHelper helper) { var both = named().merge(damaged()); var wood = stack(Items.WOODEN_PICKAXE); @@ -174,7 +174,7 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { assertRecipeMiss(helper, RecipeType.CRAFTING, container.apply(diamond_tag)); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void compound(GameTestHelper helper) { Function container = (stack) -> SimpleCraftingContainer.builder() @@ -190,7 +190,7 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { assertRecipeMiss(helper, RecipeType.CRAFTING, container.apply(stack(Items.REDSTONE))); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void strict(GameTestHelper helper) { Function container = (stack) -> SimpleCraftingContainer.builder() @@ -203,7 +203,7 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { assertRecipeMiss(helper, RecipeType.CRAFTING, container.apply(named(Items.NETHERITE_PICKAXE))); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void intersection(GameTestHelper helper) { Function container = (stack) -> SimpleCraftingContainer.builder() @@ -219,7 +219,7 @@ public class CustomIngredientsTest extends BaseTestMod implements INBTBuilder { } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void difference(GameTestHelper helper) { Function container = (stack) -> SimpleCraftingContainer.builder() diff --git a/src/test/java/net/minecraftforge/debug/gameplay/crafting/TagsTest.java b/src/test/java/net/minecraftforge/debug/gameplay/crafting/TagsTest.java index c6e487ef7c..78853592a3 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/crafting/TagsTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/crafting/TagsTest.java @@ -5,7 +5,6 @@ package net.minecraftforge.debug.gameplay.crafting; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; @@ -13,6 +12,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.test.BaseTestMod; @@ -25,7 +25,7 @@ public class TagsTest extends BaseTestMod { super(context); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void cobble_in_legacy(GameTestHelper helper) throws ReflectiveOperationException { var cobble = new ItemStack(Items.COBBLESTONE); var forgeCobbleTag = ItemTags.create(ResourceLocation.fromNamespaceAndPath("forge", "cobblestone")); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java b/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java index 3e319e37e8..8c4d234288 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/criterion/CriterionTest.java @@ -17,8 +17,6 @@ import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.data.tags.TagsProvider; -import net.minecraft.gametest.framework.GameTest; -import net.minecraft.gametest.framework.GameTestAssertException; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -38,6 +36,7 @@ import net.minecraftforge.event.level.BlockEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -61,16 +60,15 @@ public final class CriterionTest extends BaseTestMod { MinecraftForge.EVENT_BUS.addListener(this::onBlockBreak); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void test_custom_criterion(GameTestHelper helper) { var advancement = helper.getLevel().getServer().getAdvancements().get(TEST_ADVANCEMENT_ID); - if (advancement == null) - throw new GameTestAssertException("No advancement is present"); + helper.assertTrue(advancement != null, () -> "No advancement is present"); var center = new BlockPos(1, 1, 1); helper.setBlock(center, Blocks.GLASS); - helper.assertBlock(center, block -> block == Blocks.GLASS, "Failed to set glass block"); + helper.assertBlock(center, block -> block == Blocks.GLASS, block -> Component.literal("Failed to set glass block, was " + block.getDescriptionId())); var player = helper.makeMockServerPlayer(); player.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.DIAMOND_SWORD)); @@ -79,7 +77,7 @@ public final class CriterionTest extends BaseTestMod { helper.assertFalse(player.getAdvancements().revoke(advancement, TEST_CRITERION_ID), "Advancement was granted to player in invalid conditions (breaking glass with diamond sword)"); helper.setBlock(center, Blocks.DIRT); - helper.assertBlock(center, block -> block == Blocks.DIRT, "Failed to set dirt block"); + helper.assertBlock(center, block -> block == Blocks.DIRT, block -> Component.literal("Failed to set dirt block, was " + block.getDescriptionId())); player.gameMode.destroyBlock(helper.absolutePos(center)); helper.assertFalse(player.getAdvancements().revoke(advancement, TEST_CRITERION_ID), "Advancement was granted to player in invalid conditions (breaking dirt with diamond sword)"); @@ -87,13 +85,13 @@ public final class CriterionTest extends BaseTestMod { player.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.COD)); helper.setBlock(center, Blocks.DIRT); - helper.assertBlock(center, block -> block == Blocks.DIRT, "Failed to set dirt block"); + helper.assertBlock(center, block -> block == Blocks.DIRT, block -> Component.literal("Failed to set dirt block, was " + block.getDescriptionId())); player.gameMode.destroyBlock(helper.absolutePos(center)); helper.assertFalse(player.getAdvancements().revoke(advancement, TEST_CRITERION_ID), "Advancement was granted to player in invalid conditions (breaking dirt with cod)"); helper.setBlock(center, Blocks.GLASS); - helper.assertBlock(center, block -> block == Blocks.GLASS, "Failed to set glass block"); + helper.assertBlock(center, block -> block == Blocks.GLASS, block -> Component.literal("Failed to set glass block, was " + block.getDescriptionId())); player.gameMode.destroyBlock(helper.absolutePos(center)); helper.assertTrue(player.getAdvancements().revoke(advancement, TEST_CRITERION_ID), "Advancement was not granted to player in correct conditions (breaking glass with cod)"); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/item/GatherComponentsEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/item/GatherComponentsEventTest.java index 2d770f732b..c0641a8554 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/item/GatherComponentsEventTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/item/GatherComponentsEventTest.java @@ -6,7 +6,6 @@ package net.minecraftforge.debug.gameplay.item; import net.minecraft.core.component.DataComponents; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.world.food.Foods; import net.minecraft.world.item.Items; @@ -15,6 +14,7 @@ import net.minecraftforge.event.GatherComponentsEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.test.BaseTestMod; @@ -35,7 +35,7 @@ public class GatherComponentsEventTest extends BaseTestMod { } } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void onTestForFood(GameTestHelper helper) { helper.assertTrue(Items.IRON_NUGGET.components().has(DataComponents.FOOD), "Iron Nugget is not edible, failed to apply DataComponents.FOOD to it."); helper.assertFalse(Items.IRON_INGOT.components().has(DataComponents.FOOD), "Iron Ingot is edible, should not have DataComponents.FOOD"); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/item/ItemCapabilityTest.java b/src/test/java/net/minecraftforge/debug/gameplay/item/ItemCapabilityTest.java index b83bbbcffc..724c273501 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/item/ItemCapabilityTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/item/ItemCapabilityTest.java @@ -5,12 +5,10 @@ package net.minecraftforge.debug.gameplay.item; -import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import net.minecraft.core.Direction; import net.minecraft.core.component.DataComponentType; import net.minecraft.core.registries.Registries; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; @@ -20,7 +18,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.util.ExtraCodecs; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -31,6 +28,7 @@ import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.RegistryObject; @@ -67,7 +65,7 @@ public class ItemCapabilityTest extends BaseTestMod { } } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void testItemCap(GameTestHelper helper) { helper.registerEventListener(ItemCapabilityTest.class); @@ -96,7 +94,7 @@ public class ItemCapabilityTest extends BaseTestMod { helper.assertValueEqual( storage.get() == null ? -1 : storage.get().getEnergyStored(), 11, - "Value did not Sync to client" + Component.literal("Value did not Sync to client") ); helper.succeed(); @@ -143,12 +141,10 @@ public class ItemCapabilityTest extends BaseTestMod { } public static final class MyProvider implements ICapabilityProvider { - private final ItemStack stack; private final EnergyStorage storage; private final LazyOptional storageLazyOptional; public MyProvider(ItemStack stack) { - this.stack = stack; this.storage = new MyEnergyStorage(1000, 10, 10, stack.getOrDefault(STORAGE.get(), 10), storage -> { stack.set(STORAGE.get(), storage.getEnergyStored()); }); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/item/PreventItemDamageTest.java b/src/test/java/net/minecraftforge/debug/gameplay/item/PreventItemDamageTest.java index abf3870717..db87007fb2 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/item/PreventItemDamageTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/item/PreventItemDamageTest.java @@ -8,7 +8,6 @@ package net.minecraftforge.debug.gameplay.item; import net.minecraft.commands.arguments.EntityAnchorArgument; import net.minecraft.core.BlockPos; import net.minecraft.core.registries.Registries; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -24,6 +23,7 @@ import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -46,7 +46,7 @@ public class PreventItemDamageTest extends BaseTestMod { this.testItem(lookup -> FAKE_SHIELD.get().getDefaultInstance()); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void player_fake_shield_took_modified_damage(GameTestHelper helper) { helper.makeFloor(); @@ -62,8 +62,7 @@ public class PreventItemDamageTest extends BaseTestMod { helper.addEventListener(event -> { if (event.getEntity() != player) return; - if (event.getItem() != shield) - helper.fail("Player is using an item, but it's not the fake shield! Check the game test impl."); + helper.assertTrue(event.getItem() == shield, () -> "Player is using an item, but it's not the fake shield! Check the game test impl."); // Artificially pass 5 seconds from start of the shield // This is because the first 5 ticks, the player is still vulnerable @@ -73,8 +72,7 @@ public class PreventItemDamageTest extends BaseTestMod { helper.addEventListener(event -> { if (event.getEntity() != player) return; - if (event.getOriginal() != shield) - helper.fail("Player destroyed an item, but it's not the fake shield! Check the game test impl."); + helper.assertTrue(event.getOriginal() == shield, () -> "Player destroyed an item, but it's not the fake shield! Check the game test impl."); firedPlayerDestroyItem.set(true); }); @@ -107,7 +105,7 @@ public class PreventItemDamageTest extends BaseTestMod { helper.succeed(); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void fake_shield_damage_item_impl(GameTestHelper helper) { helper.makeFloor(); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/item/ShieldDisablingTest.java b/src/test/java/net/minecraftforge/debug/gameplay/item/ShieldDisablingTest.java index cd0fb7a7c0..ad04772d3a 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/item/ShieldDisablingTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/item/ShieldDisablingTest.java @@ -9,7 +9,6 @@ import net.minecraft.Util; import net.minecraft.commands.arguments.EntityAnchorArgument; import net.minecraft.core.BlockPos; import net.minecraft.core.registries.Registries; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.world.InteractionHand; import net.minecraft.world.damagesource.DamageSource; @@ -22,6 +21,7 @@ import net.minecraft.world.level.GameType; import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.test.BaseTestMod; @@ -36,7 +36,7 @@ public final class ShieldDisablingTest extends BaseTestMod { super(context); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void player_shield_disabled_by_axe(GameTestHelper helper) { player_shield_disabled_common(helper, h -> Util.make( h.spawnWithNoFreeWill(EntityType.HUSK, new BlockPos(2, 0, 2)), @@ -44,7 +44,7 @@ public final class ShieldDisablingTest extends BaseTestMod { )); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void player_shield_disabled_by_warden(GameTestHelper helper) { player_shield_disabled_common(helper, h -> h.spawnWithNoFreeWill(EntityType.WARDEN, new BlockPos(2, 0, 2))); } diff --git a/src/test/java/net/minecraftforge/debug/gameplay/level/ForcedChunkLoadingTest.java b/src/test/java/net/minecraftforge/debug/gameplay/level/ForcedChunkLoadingTest.java index 4909d316f5..b0f829e017 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/level/ForcedChunkLoadingTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/level/ForcedChunkLoadingTest.java @@ -7,19 +7,15 @@ package net.minecraftforge.debug.gameplay.level; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; -import net.minecraft.server.level.ChunkLevel; -import net.minecraft.server.level.FullChunkStatus; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.TicketType; +import net.minecraft.network.chat.Component; import net.minecraft.util.RandomSource; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.test.BaseTestMod; -import org.jetbrains.annotations.Nullable; @GameTestHolder("forge." + ForcedChunkLoadingTest.MOD_ID) @Mod(ForcedChunkLoadingTest.MOD_ID) @@ -32,7 +28,7 @@ public class ForcedChunkLoadingTest extends BaseTestMod { private static final int MAX_CHUNK_LOCATION_ATTEMPTS = 5; - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void force_far_away_chunk(GameTestHelper helper) { var random = RandomSource.create(); var level = helper.getLevel(); @@ -52,18 +48,19 @@ public class ForcedChunkLoadingTest extends BaseTestMod { } if (chunk == null) { - helper.fail("Failed to find a far away chunk that is not already ticking after " + MAX_CHUNK_LOCATION_ATTEMPTS + " attempts"); + helper.fail(Component.literal("Failed to find a far away chunk that is not already ticking after " + MAX_CHUNK_LOCATION_ATTEMPTS + " attempts")); return; } else if (attempts > 1) { helper.say("WARNING: Finding a far away chunk took " + attempts + " attempts.", ChatFormatting.YELLOW); } var pos = chunk.getPos(); + var posLong = pos.toLong(); helper.say("Attempting to force far away chunk: " + pos, ChatFormatting.YELLOW); - chunkSource.chunkMap.getDistanceManager().addRegionTicket(TicketType.FORCED, pos, ChunkLevel.byStatus(FullChunkStatus.FULL), pos, true); + chunkSource.updateChunkForced(pos, true); helper.runAfterDelay(20, () -> { - helper.assertTrue(chunkSource.chunkMap.getDistanceManager().shouldForceTicks(pos.toLong()), "Chunk is not ticketed as a forced loaded chunk"); + helper.assertTrue(chunkSource.chunkMap.getDistanceManager().shouldForceTicks(posLong), "Chunk is not ticketed as a force loaded chunk"); helper.assertTrue(chunkSource.chunkMap.getDistanceManager().inEntityTickingRange(pos.toLong()), "Forced chunk cannot tick entities"); helper.assertTrue(chunkSource.chunkMap.getDistanceManager().inBlockTickingRange(pos.toLong()), "Forced chunk cannot tick blocks"); helper.assertTrue(chunkSource.hasChunk(pos.x, pos.z), "Chunk is not loaded despite being ticketed as a force loaded chunk"); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java index bb5b2e998e..10a251b9d5 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/ConditionalLootPools.java @@ -10,8 +10,8 @@ import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.loot.BlockLootSubProvider; import net.minecraft.data.loot.LootTableProvider; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; +import net.minecraft.network.chat.Component; import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; @@ -27,6 +27,7 @@ import net.minecraftforge.test.BaseTestMod; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.common.crafting.conditions.IConditionBuilder; import net.minecraftforge.data.event.GatherDataEvent; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -53,11 +54,11 @@ public class ConditionalLootPools extends BaseTestMod { event.getGenerator().addProvider(event.includeServer(), new LootProvider(event.getGenerator().getPackOutput(), event.getLookupProvider())); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void test_true_false(GameTestHelper helper) { var center = new BlockPos(1, 1, 1); helper.setBlock(center, TEST_BLOCK.get()); - helper.assertBlock(center, block -> block == TEST_BLOCK.get(), "Failed to set block"); + helper.assertBlock(center, block -> block == TEST_BLOCK.get(), block -> Component.literal("Failed to set block, was " + block.getDescriptionId())); var player = helper.makeMockServerPlayer(); player.gameMode.destroyBlock(helper.absolutePos(center)); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java index ff5c4968ca..184e8dd73f 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java @@ -10,15 +10,16 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.advancements.critereon.DataComponentMatchers; import net.minecraft.advancements.critereon.EnchantmentPredicate; -import net.minecraft.advancements.critereon.ItemEnchantmentsPredicate; import net.minecraft.advancements.critereon.ItemPredicate; -import net.minecraft.advancements.critereon.ItemSubPredicates; import net.minecraft.advancements.critereon.MinMaxBounds; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup; import net.minecraft.core.RegistrySetBuilder; import net.minecraft.core.component.DataComponents; +import net.minecraft.core.component.predicates.DataComponentPredicates; +import net.minecraft.core.component.predicates.EnchantmentsPredicate; import net.minecraft.core.registries.Registries; import net.minecraft.util.ExtraCodecs; import net.minecraft.world.level.block.Block; @@ -28,7 +29,6 @@ import net.minecraft.data.PackOutput; import net.minecraft.data.loot.BlockLootSubProvider; import net.minecraft.data.loot.LootTableProvider; import net.minecraft.data.registries.RegistryPatchGenerator; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -67,6 +67,7 @@ import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.test.BaseTestMod; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.data.event.GatherDataEvent; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.registries.DeferredRegister; @@ -135,7 +136,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { } // Tests the Enchantment condition, as well as the ability to completely override the returned values. - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void smellting(GameTestHelper helper) { var player = helper.makeMockServerPlayer(); var center = new BlockPos(1, 1, 1); @@ -162,7 +163,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { } // Tests the table name condition by duplicating the drops for our test block, but not for anything else. - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void condition_table_name(GameTestHelper helper) { var center = new BlockPos(1, 1, 1); var player = helper.makeMockServerPlayer(); @@ -181,7 +182,7 @@ public class GlobalLootModifiersTest extends BaseTestMod { } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void silk_reentrant(GameTestHelper helper) { var center = new BlockPos(1, 1, 1); var player = helper.makeMockServerPlayer(); @@ -218,11 +219,14 @@ public class GlobalLootModifiersTest extends BaseTestMod { new LootItemCondition[]{ MatchTool.toolMatches( ItemPredicate.Builder.item() - .withSubPredicate( - ItemSubPredicates.ENCHANTMENTS, - ItemEnchantmentsPredicate.enchantments(List.of( - new EnchantmentPredicate(smelt, MinMaxBounds.Ints.atLeast(1)) - )) + .withComponents( + DataComponentMatchers.Builder.components() + .partial( + DataComponentPredicates.ENCHANTMENTS, + EnchantmentsPredicate.enchantments(List.of( + new EnchantmentPredicate(smelt, MinMaxBounds.Ints.atLeast(1)) + )) + ).build() ) ).build() }) diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootEventsTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootEventsTest.java index be2dc79057..e834036c74 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootEventsTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootEventsTest.java @@ -17,8 +17,8 @@ import net.minecraft.core.HolderLookup; import net.minecraft.data.PackOutput; import net.minecraft.data.loot.BlockLootSubProvider; import net.minecraft.data.loot.LootTableProvider; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; +import net.minecraft.network.chat.Component; import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; @@ -35,6 +35,7 @@ import net.minecraftforge.event.LootTableLoadEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -63,11 +64,11 @@ public class LootEventsTest extends BaseTestMod { event.getGenerator().addProvider(event.includeServer(), new LootProvider(out, lookup)); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void test_load_table(GameTestHelper helper) { var center = new BlockPos(1, 1, 1); helper.setBlock(center, TEST_BLOCK.get()); - helper.assertBlock(center, block -> block == TEST_BLOCK.get(), "Failed to set block"); + helper.assertBlock(center, block -> block == TEST_BLOCK.get(), block -> Component.literal("Failed to set block, was " + block.getDescriptionId())); var player = helper.makeMockServerPlayer(); player.gameMode.destroyBlock(helper.absolutePos(center)); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/ShearsLootTests.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/ShearsLootTests.java index 6db182654a..07d4054ef2 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/ShearsLootTests.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/ShearsLootTests.java @@ -9,7 +9,6 @@ import org.jetbrains.annotations.Nullable; import net.minecraft.core.BlockPos; import net.minecraft.core.component.DataComponents; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.Item; @@ -24,6 +23,7 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -46,7 +46,7 @@ public class ShearsLootTests extends BaseTestMod { this.testItem(lookup -> MODDED_SHEARS.get().getDefaultInstance()); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void test_shears_drop_blocks(GameTestHelper helper) { Test[] tests = { //leaves diff --git a/src/test/java/net/minecraftforge/debug/gameplay/redstone/UpdateOrder.java b/src/test/java/net/minecraftforge/debug/gameplay/redstone/UpdateOrder.java index 65e66ec431..c467f56b38 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/redstone/UpdateOrder.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/redstone/UpdateOrder.java @@ -6,16 +6,15 @@ package net.minecraftforge.debug.gameplay.redstone; import net.minecraft.core.BlockPos; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.entity.BarrelBlockEntity; import net.minecraft.world.level.block.entity.ChestBlockEntity; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.test.BaseTestMod; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; /** @@ -34,11 +33,11 @@ public class UpdateOrder extends BaseTestMod { super(context); } - @GameTest(template = "update_order:update_order", rotationSteps = 0) + @GameTest(data = @GameTest.Data( structure = "update_order:update_order" ), rotationSteps = 0) public static void south(GameTestHelper helper) { var chestPos = new BlockPos(0, 1, 0); helper.assertBlockPresent(Blocks.CHEST, chestPos); - var chest = helper.getBlockEntity(chestPos); + var chest = helper.getBlockEntity(chestPos, ChestBlockEntity.class); chest.setItem(0, new ItemStack(Items.DIRT)); helper.runAfterDelay(PISTON_DELAY, () -> { @@ -48,11 +47,11 @@ public class UpdateOrder extends BaseTestMod { }); } - @GameTest(template = "update_order:update_order", rotationSteps = 1) + @GameTest(data = @GameTest.Data( structure = "update_order:update_order" ), rotationSteps = 1) public static void west(GameTestHelper helper) { var chestPos = new BlockPos(0, 1, 0); helper.assertBlockPresent(Blocks.CHEST, chestPos); - var chest = helper.getBlockEntity(chestPos); + var chest = helper.getBlockEntity(chestPos, ChestBlockEntity.class); chest.setItem(0, new ItemStack(Items.DIRT)); helper.runAfterDelay(PISTON_DELAY, () -> { @@ -62,11 +61,11 @@ public class UpdateOrder extends BaseTestMod { }); } - @GameTest(template = "update_order:update_order", rotationSteps = 2) + @GameTest(data = @GameTest.Data( structure = "update_order:update_order" ), rotationSteps = 2) public static void north(GameTestHelper helper) { var chestPos = new BlockPos(0, 1, 0); helper.assertBlockPresent(Blocks.CHEST, chestPos); - var chest = helper.getBlockEntity(chestPos); + var chest = helper.getBlockEntity(chestPos, ChestBlockEntity.class); chest.setItem(0, new ItemStack(Items.DIRT)); helper.runAfterDelay(4, () -> { @@ -76,11 +75,11 @@ public class UpdateOrder extends BaseTestMod { }); } - @GameTest(template = "update_order:update_order", rotationSteps = 3) + @GameTest(data = @GameTest.Data( structure = "update_order:update_order" ), rotationSteps = 3) public static void east(GameTestHelper helper) { var chestPos = new BlockPos(0, 1, 0); helper.assertBlockPresent(Blocks.CHEST, chestPos); - var chest = helper.getBlockEntity(chestPos); + var chest = helper.getBlockEntity(chestPos, ChestBlockEntity.class); chest.setItem(0, new ItemStack(Items.DIRT)); helper.runAfterDelay(PISTON_DELAY, () -> { @@ -90,7 +89,7 @@ public class UpdateOrder extends BaseTestMod { }); } - @GameTest(template = "update_order:upward_update") + @GameTest(data = @GameTest.Data( structure = "update_order:upward_update")) public static void up(GameTestHelper helper) { var chestPos = new BlockPos(0, 1, 2); var expectedPos = new BlockPos(2, 1, 0); @@ -98,7 +97,7 @@ public class UpdateOrder extends BaseTestMod { helper.assertBlockPresent(Blocks.BARREL, chestPos); helper.assertBlockPresent(Blocks.AIR, expectedPos); helper.assertBlockPresent(Blocks.AIR, unexpectedPos); - var chest = helper.getBlockEntity(chestPos); + var chest = helper.getBlockEntity(chestPos, ChestBlockEntity.class); chest.setItem(0, new ItemStack(Items.DIRT)); helper.runAfterDelay(10, () -> { // There are a lot of things happening, give it a few ticks diff --git a/src/test/java/net/minecraftforge/debug/gameplay/villager/VillagerTypeTestMod.java b/src/test/java/net/minecraftforge/debug/gameplay/villager/VillagerTypeTestMod.java index 82b179bf03..6b3233f700 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/villager/VillagerTypeTestMod.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/villager/VillagerTypeTestMod.java @@ -8,8 +8,8 @@ package net.minecraftforge.debug.gameplay.villager; import net.minecraft.core.Holder; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; +import net.minecraft.network.chat.Component; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.npc.Villager; import net.minecraft.world.entity.npc.VillagerTrades; @@ -20,6 +20,7 @@ import net.minecraft.world.level.biome.Biomes; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.RegistryObject; @@ -34,7 +35,7 @@ public class VillagerTypeTestMod extends BaseTestMod { private static final DeferredRegister VILLAGER_TYPES = DeferredRegister.create(Registries.VILLAGER_TYPE, MOD_ID); - private static final RegistryObject TEST_VILLAGER_TYPE = VILLAGER_TYPES.register("test_villager_type", () -> new VillagerType("test_villager_type")); + private static final RegistryObject TEST_VILLAGER_TYPE = VILLAGER_TYPES.register("test_villager_type", () -> new VillagerType()); public VillagerTypeTestMod(FMLJavaModLoadingContext context) { super(context); @@ -42,34 +43,34 @@ public class VillagerTypeTestMod extends BaseTestMod { } private void onCommonSetup(final FMLCommonSetupEvent event) { - event.enqueueWork(() -> VillagerType.registerBiomeType(Biomes.PLAINS, TEST_VILLAGER_TYPE.get())); + event.enqueueWork(() -> VillagerType.registerBiomeType(Biomes.PLAINS, TEST_VILLAGER_TYPE.getKey())); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void biome_type(GameTestHelper helper) { RegistryAccess access = helper.getLevel().registryAccess(); VillagerType type = access.lookupOrThrow(Registries.VILLAGER_TYPE).getValue(TEST_VILLAGER_TYPE.getId()); if (type == null) helper.fail("Failed to find test_villager_type"); - helper.assertValueEqual(type, TEST_VILLAGER_TYPE.get(), "Loaded entry does not contain expected value"); + helper.assertValueEqual(type, TEST_VILLAGER_TYPE.get(), Component.literal("Loaded entry does not contain expected value")); Holder biome = access.lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.PLAINS); - helper.assertValueEqual(VillagerType.byBiome(biome), TEST_VILLAGER_TYPE.get(), "VillagerType.byBiome did not return the expected value"); + helper.assertValueEqual(VillagerType.byBiome(biome), TEST_VILLAGER_TYPE.get(), Component.literal("VillagerType.byBiome did not return the expected value")); helper.succeed(); } /** Test verifies NPE not thrown when looking up a villager type in the trade that doesn't contain that type.*/ - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void emeralds_for_villager_type(GameTestHelper helper) { - var trade = new VillagerTrades.EmeraldsForVillagerTypeItem(1, 12, 30, Map.of(TEST_VILLAGER_TYPE.get(), Items.DIRT)); + var trade = new VillagerTrades.EmeraldsForVillagerTypeItem(1, 12, 30, Map.of(TEST_VILLAGER_TYPE.getKey(), Items.DIRT)); var rnd = helper.getLevel().getRandom(); // Should be a successful trade for dirt for our test villager - var test = new Villager(EntityType.VILLAGER, helper.getLevel(), TEST_VILLAGER_TYPE.get()); + var test = new Villager(EntityType.VILLAGER, helper.getLevel(), TEST_VILLAGER_TYPE.getKey()); var test_offer = trade.getOffer(test, rnd); helper.assertFalse(test_offer == null, "Failed to retreive trade value for test profession"); - helper.assertValueEqual(test_offer.getItemCostA().itemStack().getItem(), Items.DIRT, "Offer did not return the expected item"); + helper.assertValueEqual(test_offer.getItemCostA().itemStack().getItem(), Items.DIRT, Component.literal("Offer did not return the expected item")); var plains = new Villager(EntityType.VILLAGER, helper.getLevel(), VillagerType.PLAINS); // This will NPE on unpatched code, we need to test that it returns null correctly diff --git a/src/test/java/net/minecraftforge/debug/loading/sort/ModLoadSortingTest.java b/src/test/java/net/minecraftforge/debug/loading/sort/ModLoadSortingTest.java index c5ad22ceca..52b350ff5e 100644 --- a/src/test/java/net/minecraftforge/debug/loading/sort/ModLoadSortingTest.java +++ b/src/test/java/net/minecraftforge/debug/loading/sort/ModLoadSortingTest.java @@ -9,10 +9,10 @@ import org.slf4j.Logger; import com.mojang.logging.LogUtils; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.test.BaseTestMod; @@ -32,13 +32,13 @@ public class ModLoadSortingTest extends BaseTestMod { beforeHasInit = ModLoadSortingBefore.hasInit; } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void ran_after_parent(GameTestHelper helper) { helper.assertTrue(afterHasInit, "Mod constructor was fired before dependency finished"); helper.succeed(); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void ran_before_child(GameTestHelper helper) { helper.assertFalse(beforeHasInit, "Mod constructor was fired before dependency finished"); helper.succeed(); diff --git a/src/test/java/net/minecraftforge/debug/modules/automatic/AutomaticModuleMod.java b/src/test/java/net/minecraftforge/debug/modules/automatic/AutomaticModuleMod.java index a996baa498..ca8c50a5fb 100644 --- a/src/test/java/net/minecraftforge/debug/modules/automatic/AutomaticModuleMod.java +++ b/src/test/java/net/minecraftforge/debug/modules/automatic/AutomaticModuleMod.java @@ -5,10 +5,10 @@ package net.minecraftforge.debug.modules.automatic; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.test.BaseTestMod; @@ -21,7 +21,7 @@ public class AutomaticModuleMod extends BaseTestMod { super(context); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void correct_name(GameTestHelper helper) throws ReflectiveOperationException { var mod = AutomaticModuleMod.class.getModule(); if ("net.minecraftforge.debug.modules.automatic".equals(mod.getName())) diff --git a/src/test/java/net/minecraftforge/debug/modules/closedtest/ClosedTestsMod.java b/src/test/java/net/minecraftforge/debug/modules/closedtest/ClosedTestsMod.java index 2da347ff3c..3bf492522d 100644 --- a/src/test/java/net/minecraftforge/debug/modules/closedtest/ClosedTestsMod.java +++ b/src/test/java/net/minecraftforge/debug/modules/closedtest/ClosedTestsMod.java @@ -13,11 +13,11 @@ import net.minecraftforge.debug.modules.closed.api.PublicUtils; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.test.BaseTestMod; import net.minecraftforge.test.ManifestProvider; import net.minecraftforge.test.ModuleProvider; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; @Mod(ClosedTestsMod.MODID) @@ -57,7 +57,7 @@ public class ClosedTestsMod extends BaseTestMod { * This attempted to access a class and method that IS exported by ClosedMod * Should succeed with no issues */ - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void can_reflect_exported(GameTestHelper helper) throws ReflectiveOperationException { var method = PublicUtils.class.getDeclaredMethod("publicMethod"); method.invoke(null); @@ -69,7 +69,7 @@ public class ClosedTestsMod extends BaseTestMod { * It is NOT exported/opened by ClosedMod * Should succeed with no exceptions */ - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void can_reflect_opened_internal(GameTestHelper helper) throws ReflectiveOperationException { try { var cls = Class.forName("net.minecraftforge.debug.modules.closed.internala.InternalA"); @@ -85,7 +85,7 @@ public class ClosedTestsMod extends BaseTestMod { * This is NOT opened by us, and is NOT exported by ClosedTest * This should error with IllegalAccessException because java is enforcing access control. */ - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void cant_reflect_internal(GameTestHelper helper) throws ReflectiveOperationException { try { var cls = Class.forName("net.minecraftforge.debug.modules.closed.internalb.InternalB"); diff --git a/src/test/java/net/minecraftforge/debug/network/PacketTest.java b/src/test/java/net/minecraftforge/debug/network/PacketTest.java index aad1b54c60..a3d34b2436 100644 --- a/src/test/java/net/minecraftforge/debug/network/PacketTest.java +++ b/src/test/java/net/minecraftforge/debug/network/PacketTest.java @@ -10,9 +10,9 @@ import org.slf4j.Logger; import com.mojang.logging.LogUtils; import io.netty.channel.embedded.EmbeddedChannel; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.chat.Component; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; import net.minecraft.resources.ResourceLocation; @@ -24,6 +24,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.network.Channel.VersionTest; import net.minecraftforge.network.ChannelBuilder; @@ -48,7 +49,7 @@ public class PacketTest extends BaseTestMod { TestChannel.registerMessages(); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void send_to_player(GameTestHelper helper) { // Send a test packet directly to a player ServerPlayer target = mockPlayer(helper); @@ -56,8 +57,8 @@ public class PacketTest extends BaseTestMod { try { var distro = PacketDistributor.PLAYER.with(target); TestChannel.CHANNEL.send(new TestPacket("player target"), distro); - helper.assertValueEqual(count(target), 1, "Target packet count"); - helper.assertValueEqual(count(bystander), 0, "Bystander packet count"); + helper.assertValueEqual(count(target), 1, Component.literal("Target packet count")); + helper.assertValueEqual(count(bystander), 0, Component.literal("Bystander packet count")); helper.succeed(); } finally { @@ -66,7 +67,7 @@ public class PacketTest extends BaseTestMod { } } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void send_to_nearby(GameTestHelper helper) { // Send a test packet to all players near a target point @@ -74,14 +75,14 @@ public class PacketTest extends BaseTestMod { ServerPlayer bystander = mockPlayer(helper); try { var center = helper.absoluteVec(Vec3.ZERO); - target.moveTo(center); // Move to center - bystander.moveTo(center.add(0, 10, 0)); // Move 10 blocks away + target.snapTo(center); // Move to center + bystander.snapTo(center.add(0, 10, 0)); // Move 10 blocks away var point = new PacketDistributor.TargetPoint(center.x(), center.y(), center.z(), 1/* Only within 1 block */, helper.getLevel().dimension()); var distro = PacketDistributor.NEAR.with(point); TestChannel.CHANNEL.send(new TestPacket("point target"), distro); - helper.assertValueEqual(count(target), 1, "Target packet count"); - helper.assertValueEqual(count(bystander), 0, "Bystander packet count"); + helper.assertValueEqual(count(target), 1, Component.literal("Target packet count")); + helper.assertValueEqual(count(bystander), 0, Component.literal("Bystander packet count")); helper.succeed(); } finally { @@ -90,7 +91,7 @@ public class PacketTest extends BaseTestMod { } } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void send_to_all(GameTestHelper helper) { // Send a test packet to all players ServerPlayer target = mockPlayer(helper); @@ -99,8 +100,8 @@ public class PacketTest extends BaseTestMod { var distro = PacketDistributor.ALL.noArg(); TestChannel.CHANNEL.send(new TestPacket("everyone!"), distro); - helper.assertValueEqual(count(target), 1, "Target packet count"); - helper.assertValueEqual(count(bystander), 1, "Bystander packet count"); + helper.assertValueEqual(count(target), 1, Component.literal("Target packet count")); + helper.assertValueEqual(count(bystander), 1, Component.literal("Bystander packet count")); helper.succeed(); } finally { diff --git a/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java b/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java index 2b00080d80..e21d28eac3 100644 --- a/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java +++ b/src/test/java/net/minecraftforge/debug/registries/NetworkDatapackRegistryTest.java @@ -17,8 +17,8 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.client.Minecraft; import net.minecraft.core.Registry; import net.minecraft.core.RegistrySetBuilder; -import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider; @@ -26,6 +26,7 @@ import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.registries.DataPackRegistryEvent; import net.minecraftforge.test.BaseTestMod; @@ -63,7 +64,7 @@ public class NetworkDatapackRegistryTest extends BaseTestMod { ); } - @GameTest(template = "forge:empty3x3x3") + @GameTest public static void client_has_registry(GameTestHelper helper) { if (FMLLoader.getDist().isDedicatedServer()) LOGGER.info("client_has_registry test skipped as we're on dedicated server"); @@ -81,7 +82,7 @@ public class NetworkDatapackRegistryTest extends BaseTestMod { var entry = reg.get().getValue(TEST_ENTRY); if (entry == null) helper.fail("Failed to find " + TEST_ENTRY); - helper.assertValueEqual(entry.value, TEST_VALUE, "Loaded entry does not contain expected value"); + helper.assertValueEqual(entry.value, TEST_VALUE, Component.literal("Loaded entry does not contain expected value")); } public static record DataObject(ResourceLocation value) { diff --git a/src/test/java/net/minecraftforge/test/BaseTestMod.java b/src/test/java/net/minecraftforge/test/BaseTestMod.java index aae036e92c..455cc9e5b6 100644 --- a/src/test/java/net/minecraftforge/test/BaseTestMod.java +++ b/src/test/java/net/minecraftforge/test/BaseTestMod.java @@ -8,26 +8,37 @@ package net.minecraftforge.test; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.function.Function; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.core.HolderLookup; +import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; +import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.CreativeModeTab.TabVisibility; import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.gametest.ForgeGameTestHooks; +import net.minecraftforge.gametest.GameTest; import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.RegisterEvent; public abstract class BaseTestMod { private List> testItems = new ArrayList<>(); protected final IEventBus modBus; + private final Map>, DeferredRegister> dataRegistries = new HashMap<>(); public BaseTestMod(FMLJavaModLoadingContext context) { this(context, true); @@ -41,6 +52,8 @@ public abstract class BaseTestMod { modBus.register(this); + boolean hasGameTest = false; + Class cls = getClass(); while (cls != BaseTestMod.class) { for (var field : cls.getDeclaredFields()) { @@ -48,11 +61,43 @@ public abstract class BaseTestMod { field.setAccessible(true); DeferredRegister dr = getField(field, null); dr.register(modBus); - } + var key = dr.getRegistryKey(); + if (VanillaRegistries.DATAPACK_REGISTRY_KEYS.contains(key)) + dataRegistries.put(key, dr); + } } + + if (!hasGameTest) { + for (var method : cls.getDeclaredMethods()) { + if (method.getAnnotation(GameTest.class) != null) { + hasGameTest = true; + break; + } + } + } + cls = cls.getSuperclass(); } + + //if (!dataRegistries.isEmpty()) + // modBus.addListener(this::generateDataPacks); + } + + + protected String modid() { + return modid(this.getClass()); + } + + protected static String smodid() { + return modid(StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass()); + } + + private static String modid(Class cls) { + var mod = cls.getAnnotation(Mod.class); + if (mod == null) + throw new IllegalStateException("Could not find @Mod on " + cls.getName()); + return mod.value(); } protected static ResourceLocation rl(String namespace, String path) { @@ -81,6 +126,22 @@ public abstract class BaseTestMod { } } + /* + @SubscribeEvent + protected void onRegister(RegisterEvent event) { + if (event.getRegistryKey() != Registries.TEST_INSTANCE && event.getRegistryKey() != Registries.TEST_FUNCTION) + return; + + var tests = ForgeGameTestHooks.gatherTests(getClass()); + + + } + + private void generateDataPacks(GatherDataEvent event) { + + } + */ + @SuppressWarnings("unchecked") protected static R getField(Field field, Object instance) { try {