diff --git a/.github/workflows/build-prs.yml b/.github/workflows/build-prs.yml index 9d70bf8a29..1f945197d9 100644 --- a/.github/workflows/build-prs.yml +++ b/.github/workflows/build-prs.yml @@ -27,10 +27,16 @@ jobs: # GradleUtils will append the branch name to the version, # but for that we need a properly checked out branch - - name: Create branch for commit + - name: Create branch for commit (PR) + if: ${{ github.event_name == 'pull_request' }} run: git switch -C pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.ref }} + - name: Create branch for commit + if: ${{ github.event_name != 'pull_request' }} + run: + git switch -C ${{ github.ref_name }} + - name: Setup JDK 21 uses: neoforged/actions/setup-java@main with: @@ -48,10 +54,13 @@ jobs: run: ./gradlew assemble checkFormatting - name: Run JCC + if: ${{ ! startsWith(github.event.pull_request.head.ref, 'port/') && ! startsWith(github.ref_name, 'port/') && ! startsWith(github.event.pull_request.base.ref, 'port/') }} run: ./gradlew checkJarCompatibility - name: Upload JCC + if: ${{ ! startsWith(github.event.pull_request.head.ref, 'port/') && ! startsWith(github.ref_name, 'port/') && ! startsWith(github.event.pull_request.base.ref, 'port/') }} uses: neoforged/action-jar-compatibility/upload@v1 - name: Publish artifacts - uses: neoforged/action-pr-publishing/upload@v1 \ No newline at end of file + if: ${{ github.event_name == 'pull_request' }} + uses: neoforged/action-pr-publishing/upload@v1 diff --git a/.github/workflows/publish-jcc.yml b/.github/workflows/publish-jcc.yml index f4c78789bc..477bf720c7 100644 --- a/.github/workflows/publish-jcc.yml +++ b/.github/workflows/publish-jcc.yml @@ -11,7 +11,7 @@ on: jobs: publish-jcc: - if: true + if: ${{ ! startsWith(github.event.workflow_run.head_branch, 'port/') }} uses: neoforged/actions/.github/workflows/publish-jcc.yml@main with: beta_version_pattern: .*-beta.* diff --git a/coremods/src/main/java/net/neoforged/neoforge/coremods/MethodRedirector.java b/coremods/src/main/java/net/neoforged/neoforge/coremods/MethodRedirector.java index 8db3d7486d..d3bb0616c8 100644 --- a/coremods/src/main/java/net/neoforged/neoforge/coremods/MethodRedirector.java +++ b/coremods/src/main/java/net/neoforged/neoforge/coremods/MethodRedirector.java @@ -32,13 +32,13 @@ public class MethodRedirector implements ITransformer { new MethodRedirection( Opcodes.INVOKEVIRTUAL, "finalizeSpawn", - "(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;", + "(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;", "finalize_spawn_targets.json", methodInsnNode -> new MethodInsnNode( Opcodes.INVOKESTATIC, "net/neoforged/neoforge/event/EventHooks", "finalizeMobSpawn", - "(Lnet/minecraft/world/entity/Mob;Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;", + "(Lnet/minecraft/world/entity/Mob;Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;", false))); public MethodRedirector() { diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index eea2cf6d4b..80f55cebf7 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -22,7 +22,7 @@ Contributing to NeoForge - Run `gradlew :tests:runGameTestServer` or `Tests: GameTestServer` from IDE - Run `gradlew :tests:runGameTestClient` or `Tests: GameTestClient` from IDE - If possible, write an automated test under the tests project. See [NEOGAMETESTS.md](NEOGAMETESTS.md) for more info. -10. Run `gradlew unpackSourcePatches` to generate patch-files from the patched sources +10. Run `gradlew genPatches` to generate patch-files from the patched sources 11. Run `gradlew applyAllFormatting` to automatically format sources 12. Check correct formatting with `gradlew spotlessCheck` 13. Commit & Push diff --git a/gradle.properties b/gradle.properties index 270ebe4a68..c08cddfd9f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,10 +9,10 @@ org.gradle.debug=false java_version=21 -minecraft_version=1.21.1 -neoform_version=20240808.144430 +minecraft_version=1.21.2 +neoform_version=20241022.151510 # on snapshot versions, used to prefix the version -neoforge_snapshot_next_stable=22.0 +neoforge_snapshot_next_stable=21.3 mergetool_version=2.0.0 accesstransformers_version=10.0.1 @@ -30,7 +30,7 @@ jetbrains_annotations_version=24.0.1 slf4j_api_version=2.0.7 apache_maven_artifact_version=3.8.5 jarjar_version=0.4.1 -fancy_mod_loader_version=4.0.24 +fancy_mod_loader_version=4.0.29 mojang_logging_version=1.1.1 log4j_version=2.22.1 guava_version=31.1.2-jre diff --git a/patches/com/mojang/blaze3d/pipeline/RenderTarget.java.patch b/patches/com/mojang/blaze3d/pipeline/RenderTarget.java.patch deleted file mode 100644 index da006f8e16..0000000000 --- a/patches/com/mojang/blaze3d/pipeline/RenderTarget.java.patch +++ /dev/null @@ -1,57 +0,0 @@ ---- a/com/mojang/blaze3d/pipeline/RenderTarget.java -+++ b/com/mojang/blaze3d/pipeline/RenderTarget.java -@@ -104,7 +_,10 @@ - GlStateManager._texParameter(3553, 34892, 0); - GlStateManager._texParameter(3553, 10242, 33071); - GlStateManager._texParameter(3553, 10243, 33071); -+ if (!stencilEnabled) - GlStateManager._texImage2D(3553, 0, 6402, this.width, this.height, 0, 6402, 5126, null); -+ else -+ GlStateManager._texImage2D(3553, 0, org.lwjgl.opengl.GL30.GL_DEPTH32F_STENCIL8, this.width, this.height, 0, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL, org.lwjgl.opengl.GL30.GL_FLOAT_32_UNSIGNED_INT_24_8_REV, null); - } - - this.setFilterMode(9728, true); -@@ -115,7 +_,14 @@ - GlStateManager._glBindFramebuffer(36160, this.frameBufferId); - GlStateManager._glFramebufferTexture2D(36160, 36064, 3553, this.colorTextureId, 0); - if (this.useDepth) { -+ if(!stencilEnabled) - GlStateManager._glFramebufferTexture2D(36160, 36096, 3553, this.depthBufferId, 0); -+ else if(net.neoforged.neoforge.common.NeoForgeConfig.CLIENT.useCombinedDepthStencilAttachment.get()) { -+ GlStateManager._glFramebufferTexture2D(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL_ATTACHMENT, 3553, this.depthBufferId, 0); -+ } else { -+ GlStateManager._glFramebufferTexture2D(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_DEPTH_ATTACHMENT, 3553, this.depthBufferId, 0); -+ GlStateManager._glFramebufferTexture2D(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER, org.lwjgl.opengl.GL30.GL_STENCIL_ATTACHMENT, 3553, this.depthBufferId, 0); -+ } - } - - this.checkStatus(); -@@ -257,5 +_,28 @@ - - public int getDepthTextureId() { - return this.depthBufferId; -+ } -+ -+ // Neo: Injected stencil control -+ private boolean stencilEnabled = false; -+ -+ /** -+ * Attempts to enable 8 bits of stencil buffer on this FrameBuffer. -+ * Modders must call this directly to set things up. -+ * This is to prevent the default cause where graphics cards do not support stencil bits. -+ * Make sure to call this on the main render thread! -+ */ -+ public void enableStencil() { -+ if(stencilEnabled) return; -+ stencilEnabled = true; -+ this.resize(viewWidth, viewHeight, net.minecraft.client.Minecraft.ON_OSX); -+ } -+ -+ /** -+ * Returns whether this FBO has been successfully initialized with stencil bits. -+ * If not, and a modder wishes it to be, they must call enableStencil. -+ */ -+ public boolean isStencilEnabled() { -+ return this.stencilEnabled; - } - } diff --git a/patches/com/mojang/blaze3d/platform/GlStateManager.java.patch b/patches/com/mojang/blaze3d/platform/GlStateManager.java.patch index 4eb7c902e9..88bb511647 100644 --- a/patches/com/mojang/blaze3d/platform/GlStateManager.java.patch +++ b/patches/com/mojang/blaze3d/platform/GlStateManager.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/platform/GlStateManager.java +++ b/com/mojang/blaze3d/platform/GlStateManager.java -@@ -945,4 +_,53 @@ +@@ -1009,4 +_,53 @@ return INSTANCE.height; } } diff --git a/patches/com/mojang/blaze3d/platform/Window.java.patch b/patches/com/mojang/blaze3d/platform/Window.java.patch index edf8e76920..f211b35fad 100644 --- a/patches/com/mojang/blaze3d/platform/Window.java.patch +++ b/patches/com/mojang/blaze3d/platform/Window.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/platform/Window.java +++ b/com/mojang/blaze3d/platform/Window.java -@@ -86,7 +_,8 @@ +@@ -90,7 +_,8 @@ GLFW.glfwWindowHint(139267, 2); GLFW.glfwWindowHint(139272, 204801); GLFW.glfwWindowHint(139270, 1); @@ -10,7 +10,7 @@ if (monitor != null) { VideoMode videomode = monitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty()); this.windowedX = this.x = monitor.getX() + videomode.getWidth() / 2 - this.width / 2; -@@ -98,6 +_,7 @@ +@@ -102,6 +_,7 @@ this.windowedX = this.x = aint1[0]; this.windowedY = this.y = aint[0]; } @@ -18,7 +18,7 @@ GLFW.glfwMakeContextCurrent(this.window); GL.createCapabilities(); -@@ -256,6 +_,7 @@ +@@ -269,6 +_,7 @@ GLFW.glfwGetFramebufferSize(this.window, aint, aint1); this.framebufferWidth = aint[0] > 0 ? aint[0] : 1; this.framebufferHeight = aint1[0] > 0 ? aint1[0] : 1; diff --git a/patches/com/mojang/blaze3d/systems/RenderSystem.java.patch b/patches/com/mojang/blaze3d/systems/RenderSystem.java.patch index 3a0ac77ee0..756e40c7c9 100644 --- a/patches/com/mojang/blaze3d/systems/RenderSystem.java.patch +++ b/patches/com/mojang/blaze3d/systems/RenderSystem.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/systems/RenderSystem.java +++ b/com/mojang/blaze3d/systems/RenderSystem.java -@@ -932,4 +_,14 @@ +@@ -822,4 +_,14 @@ void accept(it.unimi.dsi.fastutil.ints.IntConsumer p_157488_, int p_157489_); } } diff --git a/patches/com/mojang/blaze3d/vertex/PoseStack.java.patch b/patches/com/mojang/blaze3d/vertex/PoseStack.java.patch index a21f52da74..c3b47049f8 100644 --- a/patches/com/mojang/blaze3d/vertex/PoseStack.java.patch +++ b/patches/com/mojang/blaze3d/vertex/PoseStack.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/vertex/PoseStack.java +++ b/com/mojang/blaze3d/vertex/PoseStack.java -@@ -13,7 +_,7 @@ +@@ -14,7 +_,7 @@ import org.joml.Vector3f; @OnlyIn(Dist.CLIENT) diff --git a/patches/com/mojang/blaze3d/vertex/VertexConsumer.java.patch b/patches/com/mojang/blaze3d/vertex/VertexConsumer.java.patch index 7648e30906..30c19c43bf 100644 --- a/patches/com/mojang/blaze3d/vertex/VertexConsumer.java.patch +++ b/patches/com/mojang/blaze3d/vertex/VertexConsumer.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/vertex/VertexConsumer.java +++ b/com/mojang/blaze3d/vertex/VertexConsumer.java -@@ -12,7 +_,7 @@ +@@ -13,7 +_,7 @@ import org.lwjgl.system.MemoryStack; @OnlyIn(Dist.CLIENT) @@ -10,19 +10,19 @@ VertexConsumer setColor(int p_350535_, int p_350875_, int p_350886_, int p_350775_); @@ -131,11 +_,14 @@ - f5 = p_331397_[l] * p_85992_ * 255.0F; + f5 = p_331397_[i1] * p_85992_ * 255.0F; } -- int i1 = FastColor.ARGB32.color(k, (int)f3, (int)f4, (int)f5); -- int j1 = p_331378_[l]; +- int j1 = ARGB.color(k, (int)f3, (int)f4, (int)f5); +- int k1 = LightTexture.lightCoordsWithEmission(p_331378_[i1], l); + // Neo: also apply alpha that's coming from the baked quad + int vertexAlpha = p_331268_ ? (int)((p_331416_ * (float) (bytebuffer.get(15) & 255) / 255.0F) * 255) : k; -+ int i1 = FastColor.ARGB32.color(vertexAlpha, (int)f3, (int)f4, (int)f5); -+ int j1 = applyBakedLighting(p_331378_[l], bytebuffer); ++ int j1 = ARGB.color(vertexAlpha, (int)f3, (int)f4, (int)f5); ++ int k1 = applyBakedLighting(LightTexture.lightCoordsWithEmission(p_331378_[i1], l), bytebuffer); float f10 = bytebuffer.getFloat(16); float f9 = bytebuffer.getFloat(20); Vector3f vector3f1 = matrix4f.transformPosition(f, f1, f2, new Vector3f()); + applyBakedNormals(vector3f, bytebuffer, p_85988_.normal()); - this.addVertex(vector3f1.x(), vector3f1.y(), vector3f1.z(), i1, f10, f9, p_85993_, j1, vector3f.x(), vector3f.y(), vector3f.z()); + this.addVertex(vector3f1.x(), vector3f1.y(), vector3f1.z(), j1, f10, f9, p_85993_, k1, vector3f.x(), vector3f.y(), vector3f.z()); } } diff --git a/patches/com/mojang/blaze3d/vertex/VertexFormat.java.patch b/patches/com/mojang/blaze3d/vertex/VertexFormat.java.patch index a6debaffd6..792970ee3a 100644 --- a/patches/com/mojang/blaze3d/vertex/VertexFormat.java.patch +++ b/patches/com/mojang/blaze3d/vertex/VertexFormat.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/vertex/VertexFormat.java +++ b/com/mojang/blaze3d/vertex/VertexFormat.java -@@ -237,4 +_,28 @@ +@@ -220,4 +_,28 @@ }; } } diff --git a/patches/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java.patch b/patches/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java.patch index 0757213ad6..b9cb377a05 100644 --- a/patches/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java.patch +++ b/patches/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java +++ b/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java -@@ -127,7 +_,7 @@ +@@ -128,7 +_,7 @@ private void drawIcons(GuiGraphics p_282966_) { int i = this.numberOfPendingInvites; int j = 24; diff --git a/patches/net/minecraft/SharedConstants.java.patch b/patches/net/minecraft/SharedConstants.java.patch index c0e578e4f8..d36ef831de 100644 --- a/patches/net/minecraft/SharedConstants.java.patch +++ b/patches/net/minecraft/SharedConstants.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java -@@ -118,7 +_,8 @@ +@@ -117,7 +_,8 @@ public static final boolean USE_WORKFLOWS_HOOKS = false; public static final boolean USE_DEVONLY = false; public static boolean CHECK_DATA_FIXER_SCHEMA = true; @@ -10,7 +10,7 @@ public static final int WORLD_RESOLUTION = 16; public static final int MAX_CHAT_LENGTH = 256; public static final int MAX_USER_INPUT_COMMAND_LENGTH = 32500; -@@ -171,6 +_,7 @@ +@@ -170,6 +_,7 @@ } static { diff --git a/patches/net/minecraft/Util.java.patch b/patches/net/minecraft/Util.java.patch index e74d02220d..06262a76e0 100644 --- a/patches/net/minecraft/Util.java.patch +++ b/patches/net/minecraft/Util.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java -@@ -267,8 +_,8 @@ +@@ -264,8 +_,8 @@ .getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().getDataVersion().getVersion())) .getChoiceType(p_137552_, p_137553_); } catch (IllegalArgumentException illegalargumentexception) { @@ -11,7 +11,7 @@ throw illegalargumentexception; } } -@@ -526,20 +_,20 @@ +@@ -630,20 +_,20 @@ public static void logAndPauseIfInIde(String p_143786_) { LOGGER.error(p_143786_); diff --git a/patches/net/minecraft/advancements/AdvancementRewards.java.patch b/patches/net/minecraft/advancements/AdvancementRewards.java.patch index 2b4fd0ad19..34bfaa4c01 100644 --- a/patches/net/minecraft/advancements/AdvancementRewards.java.patch +++ b/patches/net/minecraft/advancements/AdvancementRewards.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/AdvancementRewards.java +++ b/net/minecraft/advancements/AdvancementRewards.java -@@ -40,6 +_,7 @@ +@@ -41,6 +_,7 @@ LootParams lootparams = new LootParams.Builder(p_9990_.serverLevel()) .withParameter(LootContextParams.THIS_ENTITY, p_9990_) .withParameter(LootContextParams.ORIGIN, p_9990_.position()) diff --git a/patches/net/minecraft/client/Camera.java.patch b/patches/net/minecraft/client/Camera.java.patch index 5af6f8da3e..df73884274 100644 --- a/patches/net/minecraft/client/Camera.java.patch +++ b/patches/net/minecraft/client/Camera.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Camera.java +++ b/net/minecraft/client/Camera.java -@@ -42,6 +_,7 @@ +@@ -44,6 +_,7 @@ private float eyeHeightOld; private float partialTickTime; public static final float FOG_DISTANCE_SCALE = 0.083333336F; @@ -8,20 +8,20 @@ public void setup(BlockGetter p_90576_, Entity p_90577_, boolean p_90578_, boolean p_90579_, float p_90580_) { this.initialized = true; -@@ -49,7 +_,10 @@ - this.entity = p_90577_; - this.detached = p_90578_; - this.partialTickTime = p_90580_; -- this.setRotation(p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_)); -+ var cameraSetup = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.ViewportEvent.ComputeCameraAngles( -+ this, p_90580_, p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_), 0) -+ ); -+ this.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll()); - this.setPosition( - Mth.lerp((double)p_90580_, p_90577_.xo, p_90577_.getX()), - Mth.lerp((double)p_90580_, p_90577_.yo, p_90577_.getY()) + (double)Mth.lerp(p_90580_, this.eyeHeightOld, this.eyeHeight), -@@ -57,11 +_,11 @@ - ); +@@ -62,7 +_,10 @@ + this.setRotation(p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_)); + this.setPosition(newminecartbehavior.getCartLerpPosition(p_90580_).add(vec3)); + } else { +- this.setRotation(p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_)); ++ var cameraSetup = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.ViewportEvent.ComputeCameraAngles( ++ this, p_90580_, p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_), 0) ++ ); ++ this.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll()); + this.setPosition( + Mth.lerp((double)p_90580_, p_90577_.xo, p_90577_.getX()), + Mth.lerp((double)p_90580_, p_90577_.yo, p_90577_.getY()) + (double)Mth.lerp(p_90580_, this.eyeHeightOld, this.eyeHeight), +@@ -72,11 +_,11 @@ + if (p_90578_) { if (p_90579_) { - this.setRotation(this.yRot + 180.0F, -this.xRot); @@ -34,7 +34,7 @@ } else if (p_90577_ instanceof LivingEntity && ((LivingEntity)p_90577_).isSleeping()) { Direction direction = ((LivingEntity)p_90577_).getBedOrientation(); this.setRotation(direction != null ? direction.toYRot() - 180.0F : 0.0F, 0.0F); -@@ -102,10 +_,17 @@ +@@ -117,10 +_,17 @@ this.setPosition(new Vec3(this.position.x + (double)vector3f.x, this.position.y + (double)vector3f.y, this.position.z + (double)vector3f.z)); } @@ -53,7 +53,7 @@ FORWARDS.rotate(this.rotation, this.forwards); UP.rotate(this.rotation, this.up); LEFT.rotate(this.rotation, this.left); -@@ -221,6 +_,17 @@ +@@ -236,6 +_,17 @@ public float getPartialTickTime() { return this.partialTickTime; diff --git a/patches/net/minecraft/client/ClientRecipeBook.java.patch b/patches/net/minecraft/client/ClientRecipeBook.java.patch index 774d2198da..8d6b3ae4cf 100644 --- a/patches/net/minecraft/client/ClientRecipeBook.java.patch +++ b/patches/net/minecraft/client/ClientRecipeBook.java.patch @@ -1,20 +1,19 @@ --- a/net/minecraft/client/ClientRecipeBook.java +++ b/net/minecraft/client/ClientRecipeBook.java -@@ -65,7 +_,7 @@ - Recipe recipe = recipeholder.value(); - if (!recipe.isSpecial() && !recipe.isIncomplete()) { - RecipeBookCategories recipebookcategories = getCategory(recipeholder); -- String s = recipe.getGroup(); -+ String s = recipe.getGroup().isEmpty() ? recipeholder.id().toString() : recipe.getGroup(); // FORGE: Group value defaults to the recipe's ID if the recipe's explicit group is empty. - if (s.isEmpty()) { - map.computeIfAbsent(recipebookcategories, p_90645_ -> Lists.newArrayList()).add(ImmutableList.of(recipeholder)); - } else { -@@ -125,6 +_,8 @@ - } else if (recipetype == RecipeType.SMITHING) { - return RecipeBookCategories.SMITHING; - } else { -+ RecipeBookCategories categories = net.neoforged.neoforge.client.RecipeBookManager.findCategories((RecipeType) recipetype, p_301136_); -+ if (categories != null) return categories; - LOGGER.warn( - "Unknown recipe category: {}/{}", - LogUtils.defer(() -> BuiltInRegistries.RECIPE_TYPE.getKey(recipe.getType())), +@@ -74,6 +_,16 @@ + .collect(ImmutableList.toImmutableList()) + ); + } ++ // Neo: Do the same for modded search categories. ++ for (var entry : net.neoforged.neoforge.client.RecipeBookManager.getSearchCategories().entrySet()) { ++ map1.put( ++ entry.getKey(), ++ entry.getValue() ++ .stream() ++ .flatMap(category -> map1.getOrDefault(category, List.of()).stream()) ++ .collect(ImmutableList.toImmutableList()) ++ ); ++ } + + this.collectionsByTab = Map.copyOf(map1); + this.allCollections = builder.build(); diff --git a/patches/net/minecraft/client/KeyboardHandler.java.patch b/patches/net/minecraft/client/KeyboardHandler.java.patch index 2c5ce4a44e..2470d92b3a 100644 --- a/patches/net/minecraft/client/KeyboardHandler.java.patch +++ b/patches/net/minecraft/client/KeyboardHandler.java.patch @@ -1,53 +1,49 @@ --- a/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java -@@ -407,9 +_,13 @@ - Screen.wrapScreenError(() -> { - if (p_90897_ == 1 || p_90897_ == 2) { +@@ -426,12 +_,20 @@ + if (screen != null) { + try { + if (p_90897_ != 1 && p_90897_ != 2) { +- if (p_90897_ == 0 && screen.keyReleased(p_90895_, p_90896_, p_90898_)) { ++ if (p_90897_ == 0 && ( ++ net.neoforged.neoforge.client.ClientHooks.onScreenKeyReleasedPre(screen, p_90895_, p_90896_, p_90898_) || ++ screen.keyReleased(p_90895_, p_90896_, p_90898_) || ++ net.neoforged.neoforge.client.ClientHooks.onScreenKeyReleasedPost(screen, p_90895_, p_90896_, p_90898_)) ++ ) { + return; + } + } else { screen.afterKeyboardAction(); -- aboolean[0] = screen.keyPressed(p_90895_, p_90896_, p_90898_); -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenKeyPressedPre(screen, p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = screen.keyPressed(p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenKeyPressedPost(screen, p_90895_, p_90896_, p_90898_); - } else if (p_90897_ == 0) { -- aboolean[0] = screen.keyReleased(p_90895_, p_90896_, p_90898_); -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenKeyReleasedPre(screen, p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = screen.keyReleased(p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenKeyReleasedPost(screen, p_90895_, p_90896_, p_90898_); +- if (screen.keyPressed(p_90895_, p_90896_, p_90898_)) { ++ if ( ++ net.neoforged.neoforge.client.ClientHooks.onScreenKeyPressedPre(screen, p_90895_, p_90896_, p_90898_) || ++ screen.keyPressed(p_90895_, p_90896_, p_90898_) || ++ net.neoforged.neoforge.client.ClientHooks.onScreenKeyPressedPost(screen, p_90895_, p_90896_, p_90898_) ++ ) { + return; + } } - }, "keyPressed event handler", screen.getClass().getCanonicalName()); - if (aboolean[0]) { -@@ -478,22 +_,27 @@ +@@ -516,10 +_,20 @@ + if (screen != null && this.minecraft.getOverlay() == null) { + try { + if (Character.isBmpCodePoint(p_90891_)) { +- screen.charTyped((char)p_90891_, p_90892_); ++ if (net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPre(screen, (char)p_90891_, p_90892_)) return; ++ if (screen.charTyped((char)p_90891_, p_90892_)) return; ++ net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPost(screen, (char)p_90891_, p_90892_); + } else if (Character.isValidCodePoint(p_90891_)) { +- screen.charTyped(Character.highSurrogate(p_90891_), p_90892_); +- screen.charTyped(Character.lowSurrogate(p_90891_), p_90892_); ++ if (!net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPre(screen, Character.highSurrogate(p_90891_), p_90892_)) { ++ if (!screen.charTyped(Character.highSurrogate(p_90891_), p_90892_)) { ++ net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPost(screen, Character.highSurrogate(p_90891_), p_90892_); ++ } ++ } ++ if (!net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPre(screen, Character.lowSurrogate(p_90891_), p_90892_)) { ++ if (!screen.charTyped(Character.lowSurrogate(p_90891_), p_90892_)) { ++ net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPost(screen, Character.lowSurrogate(p_90891_), p_90892_); ++ } ++ } } - } - } -+ net.neoforged.neoforge.client.ClientHooks.onKeyInput(p_90895_, p_90896_, p_90897_, p_90898_); - } - } - - private void charTyped(long p_90890_, int p_90891_, int p_90892_) { - if (p_90890_ == this.minecraft.getWindow().getWindow()) { -- GuiEventListener guieventlistener = this.minecraft.screen; -+ Screen guieventlistener = this.minecraft.screen; - if (guieventlistener != null && this.minecraft.getOverlay() == null) { - if (Character.charCount(p_90891_) == 1) { -- Screen.wrapScreenError( -- () -> guieventlistener.charTyped((char)p_90891_, p_90892_), "charTyped event handler", guieventlistener.getClass().getCanonicalName() -- ); -+ Screen.wrapScreenError(() -> { -+ if (net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPre(guieventlistener, (char)p_90891_, p_90892_)) return; -+ if (guieventlistener.charTyped((char)p_90891_, p_90892_)) return; -+ net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPost(guieventlistener, (char)p_90891_, p_90892_); -+ }, "charTyped event handler", guieventlistener.getClass().getCanonicalName()); - } else { - for (char c0 : Character.toChars(p_90891_)) { -- Screen.wrapScreenError( -- () -> guieventlistener.charTyped(c0, p_90892_), "charTyped event handler", guieventlistener.getClass().getCanonicalName() -- ); -+ Screen.wrapScreenError(() -> { -+ if (net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPre(guieventlistener, c0, p_90892_)) return; -+ if (guieventlistener.charTyped(c0, p_90892_)) return; -+ net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPost(guieventlistener, c0, p_90892_); -+ }, "charTyped event handler", guieventlistener.getClass().getCanonicalName()); - } - } - } + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.forThrowable(throwable, "charTyped event handler"); diff --git a/patches/net/minecraft/client/Minecraft.java.patch b/patches/net/minecraft/client/Minecraft.java.patch index 13ff259e92..d73618ac55 100644 --- a/patches/net/minecraft/client/Minecraft.java.patch +++ b/patches/net/minecraft/client/Minecraft.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java -@@ -254,7 +_,7 @@ +@@ -253,7 +_,7 @@ import org.slf4j.Logger; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ static Minecraft instance; private static final Logger LOGGER = LogUtils.getLogger(); public static final boolean ON_OSX = Util.getPlatform() == Util.OS.OSX; -@@ -435,7 +_,6 @@ +@@ -437,7 +_,6 @@ } }, Util.nonCriticalIoPool()); LOGGER.info("Setting user: {}", this.user.getName()); @@ -17,10 +17,10 @@ this.demo = p_91084_.game.demo; this.allowsMultiplayer = !p_91084_.game.disableMultiplayer; this.allowsChat = !p_91084_.game.disableChat; -@@ -476,15 +_,15 @@ +@@ -488,15 +_,15 @@ + LOGGER.error("Couldn't set icon", (Throwable)ioexception); } - this.window.setFramerateLimit(this.options.framerateLimit().get()); + // FORGE: Move mouse and keyboard handler setup further below this.mouseHandler = new MouseHandler(this); - this.mouseHandler.setup(this.window.getWindow()); @@ -29,13 +29,13 @@ RenderSystem.initRenderer(this.options.glDebugVerbosity, false); this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight()); this.mainRenderTarget.setClearColor(0.0F, 0.0F, 0.0F, 0.0F); - this.mainRenderTarget.clear(ON_OSX); + this.mainRenderTarget.clear(); this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); + net.neoforged.neoforge.client.loading.ClientModLoader.begin(this, this.resourcePackRepository, this.resourceManager); this.resourcePackRepository.reload(); this.options.loadSelectedResourcePacks(this.resourcePackRepository); this.languageManager = new LanguageManager(this.options.languageCode, p_344151_ -> { -@@ -554,6 +_,7 @@ +@@ -582,6 +_,7 @@ ); this.resourceManager.registerReloadListener(this.entityRenderDispatcher); this.particleEngine = new ParticleEngine(this.level, this.textureManager); @@ -43,12 +43,13 @@ this.resourceManager.registerReloadListener(this.particleEngine); this.paintingTextures = new PaintingTextureManager(this.textureManager); this.resourceManager.registerReloadListener(this.paintingTextures); -@@ -566,10 +_,14 @@ +@@ -591,11 +_,15 @@ + this.resourceManager.registerReloadListener(this.guiSprites); this.gameRenderer = new GameRenderer(this, this.entityRenderDispatcher.getItemInHandRenderer(), this.resourceManager, this.renderBuffers); - this.resourceManager.registerReloadListener(this.gameRenderer.createReloadListener()); this.levelRenderer = new LevelRenderer(this, this.entityRenderDispatcher, this.blockEntityRenderDispatcher, this.renderBuffers); + net.neoforged.fml.ModLoader.postEvent(new net.neoforged.neoforge.client.event.RenderLevelStageEvent.RegisterStageEvent()); this.resourceManager.registerReloadListener(this.levelRenderer); + this.resourceManager.registerReloadListener(this.levelRenderer.getCloudRenderer()); this.gpuWarnlistManager = new GpuWarnlistManager(); this.resourceManager.registerReloadListener(this.gpuWarnlistManager); this.resourceManager.registerReloadListener(this.regionalCompliancies); @@ -58,7 +59,7 @@ this.gui = new Gui(this); this.debugRenderer = new DebugRenderer(this); RealmsClient realmsclient = RealmsClient.create(this); -@@ -594,6 +_,7 @@ +@@ -620,6 +_,7 @@ this.options.fullscreen().set(this.window.isFullscreen()); } @@ -66,7 +67,7 @@ this.window.updateVsync(this.options.enableVsync().get()); this.window.updateRawMouseInput(this.options.rawMouseInput().get()); this.window.setDefaultErrorCallback(); -@@ -614,16 +_,18 @@ +@@ -641,16 +_,18 @@ GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS); Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay); this.setOverlay( @@ -88,8 +89,8 @@ + ).get() ); this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.path()); - } -@@ -663,6 +_,8 @@ + this.framerateLimitTracker = new FramerateLimitTracker(this.options, this); +@@ -696,6 +_,8 @@ runnable = () -> this.setScreen(screen); } @@ -98,7 +99,7 @@ return runnable; } -@@ -711,7 +_,7 @@ +@@ -744,7 +_,7 @@ private String createTitle() { StringBuilder stringbuilder = new StringBuilder("Minecraft"); if (checkModStatus().shouldReportAsModified()) { @@ -107,7 +108,7 @@ } stringbuilder.append(" "); -@@ -743,7 +_,7 @@ +@@ -776,7 +_,7 @@ } private void rollbackResourcePacks(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299846_) { @@ -116,24 +117,16 @@ this.clearResourcePacksOnError(p_91240_, null, p_299846_); } else { Util.throwAsRuntime(p_91240_); -@@ -871,13 +_,13 @@ - - if (p_91333_.getSaveFile() != null) { - Bootstrap.realStdoutPrintln("#@!@# Game crashed! Crash report saved to: #@!@# " + p_91333_.getSaveFile().toAbsolutePath()); -- System.exit(-1); -+ net.neoforged.neoforge.server.ServerLifecycleHooks.handleExit(-1); - } else if (p_91333_.saveToFile(path1, ReportType.CRASH)) { - Bootstrap.realStdoutPrintln("#@!@# Game crashed! Crash report saved to: #@!@# " + path1.toAbsolutePath()); -- System.exit(-1); -+ net.neoforged.neoforge.server.ServerLifecycleHooks.handleExit(-1); - } else { - Bootstrap.realStdoutPrintln("#@?@# Game crashed! Crash report could not be saved. #@?@#"); -- System.exit(-2); -+ net.neoforged.neoforge.server.ServerLifecycleHooks.handleExit(-2); +@@ -935,7 +_,7 @@ + p_307414_.soundManager.emergencyShutdown(); } + +- System.exit(i); ++ net.neoforged.neoforge.server.ServerLifecycleHooks.handleExit(i); } -@@ -1006,9 +_,7 @@ + public boolean isEnforceUnicode() { +@@ -1062,9 +_,7 @@ LOGGER.error("setScreen called from non-game thread"); } @@ -144,7 +137,7 @@ this.setLastInputType(InputType.NONE); } -@@ -1025,6 +_,19 @@ +@@ -1081,6 +_,19 @@ } } @@ -164,20 +157,20 @@ this.screen = p_91153_; if (this.screen != null) { this.screen.added(); -@@ -1170,9 +_,11 @@ +@@ -1234,9 +_,11 @@ this.mouseHandler.handleAccumulatedMovement(); - this.profiler.pop(); + profilerfiller.pop(); if (!this.noRender) { -+ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePre(this.timer); - this.profiler.popPush("gameRenderer"); - this.gameRenderer.render(this.timer, p_91384_); - this.profiler.pop(); -+ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePost(this.timer); ++ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePre(this.deltaTracker); + profilerfiller.popPush("gameRenderer"); + this.gameRenderer.render(this.deltaTracker, p_91384_); + profilerfiller.pop(); ++ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePost(this.deltaTracker); } - if (this.fpsPieResults != null) { -@@ -1203,9 +_,13 @@ - this.profiler.pop(); + profilerfiller.push("blit"); +@@ -1264,9 +_,13 @@ + profilerfiller.pop(); this.window.setErrorSection("Post render"); this.frames++; - this.pause = this.hasSingleplayerServer() @@ -188,10 +181,10 @@ + this.pause = pause; + net.neoforged.neoforge.client.ClientHooks.onClientPauseChangePost(pause); + } - this.timer.updatePauseState(this.pause); - this.timer.updateFrozenState(!this.isLevelRunningNormally()); - long k = Util.getNanos(); -@@ -1298,10 +_,12 @@ + this.deltaTracker.updatePauseState(this.pause); + this.deltaTracker.updateFrozenState(!this.isLevelRunningNormally()); + long l = Util.getNanos(); +@@ -1358,10 +_,12 @@ this.window.setGuiScale((double)i); if (this.screen != null) { this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); @@ -199,12 +192,12 @@ } RenderTarget rendertarget = this.getMainRenderTarget(); - rendertarget.resize(this.window.getWidth(), this.window.getHeight(), ON_OSX); + rendertarget.resize(this.window.getWidth(), this.window.getHeight()); + if (this.gameRenderer != null) this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight()); this.mouseHandler.setIgnoreFirstMove(); } -@@ -1569,6 +_,7 @@ +@@ -1502,6 +_,7 @@ } public void stop() { @@ -212,7 +205,7 @@ this.running = false; } -@@ -1598,9 +_,17 @@ +@@ -1531,9 +_,17 @@ BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockPos blockpos = blockhitresult.getBlockPos(); if (!this.level.getBlockState(blockpos).isAir()) { @@ -232,7 +225,7 @@ this.player.swing(InteractionHand.MAIN_HAND); } } -@@ -1628,6 +_,8 @@ +@@ -1561,6 +_,8 @@ return false; } else { boolean flag = false; @@ -241,7 +234,7 @@ switch (this.hitResult.getType()) { case ENTITY: this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity()); -@@ -1648,8 +_,10 @@ +@@ -1581,8 +_,10 @@ } this.player.resetAttackStrengthTicker(); @@ -252,7 +245,7 @@ this.player.swing(InteractionHand.MAIN_HAND); return flag; } -@@ -1665,6 +_,11 @@ +@@ -1598,6 +_,11 @@ } for (InteractionHand interactionhand : InteractionHand.values()) { @@ -264,35 +257,35 @@ ItemStack itemstack = this.player.getItemInHand(interactionhand); if (!itemstack.isItemEnabled(this.level.enabledFeatures())) { return; -@@ -1685,7 +_,7 @@ +@@ -1618,7 +_,7 @@ } - if (interactionresult.consumesAction()) { -- if (interactionresult.shouldSwing()) { -+ if (interactionresult.shouldSwing() && inputEvent.shouldSwingHand()) { + if (interactionresult instanceof InteractionResult.Success interactionresult$success2) { +- if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT) { ++ if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { this.player.swing(interactionhand); } -@@ -1697,7 +_,7 @@ +@@ -1630,7 +_,7 @@ int i = itemstack.getCount(); InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult); - if (interactionresult1.consumesAction()) { -- if (interactionresult1.shouldSwing()) { -+ if (interactionresult1.shouldSwing() && inputEvent.shouldSwingHand()) { + if (interactionresult1 instanceof InteractionResult.Success interactionresult$success) { +- if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT) { ++ if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { this.player.swing(interactionhand); if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.gameMode.hasInfiniteItems())) { this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand); -@@ -1713,6 +_,9 @@ +@@ -1646,6 +_,9 @@ } } + if (itemstack.isEmpty() && (this.hitResult == null || this.hitResult.getType() == HitResult.Type.MISS)) + net.neoforged.neoforge.common.CommonHooks.onEmptyClick(this.player, interactionhand); + - if (!itemstack.isEmpty()) { - InteractionResult interactionresult2 = this.gameMode.useItem(this.player, interactionhand); - if (interactionresult2.consumesAction()) { -@@ -1735,6 +_,8 @@ + if (!itemstack.isEmpty() + && this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) { + if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) { +@@ -1666,6 +_,8 @@ public void tick() { this.clientTickCount++; @@ -301,32 +294,32 @@ if (this.level != null && !this.pause) { this.level.tickRateManager().tick(); } -@@ -1826,6 +_,7 @@ +@@ -1764,6 +_,7 @@ this.tutorial.tick(); + net.neoforged.neoforge.event.EventHooks.fireLevelTickPre(this.level, () -> true); try { this.level.tick(() -> true); - } catch (Throwable throwable) { -@@ -1839,6 +_,7 @@ + } catch (Throwable throwable1) { +@@ -1777,6 +_,7 @@ - throw new ReportedException(crashreport); + throw new ReportedException(crashreport1); } + net.neoforged.neoforge.event.EventHooks.fireLevelTickPost(this.level, () -> true); } - this.profiler.popPush("animateTick"); -@@ -1858,6 +_,8 @@ - this.profiler.popPush("keyboard"); + profilerfiller.popPush("animateTick"); +@@ -1801,6 +_,8 @@ + profilerfiller.popPush("keyboard"); this.keyboardHandler.tick(); - this.profiler.pop(); + profilerfiller.pop(); + + net.neoforged.neoforge.client.ClientHooks.fireClientTickPost(); } private boolean isLevelRunningNormally() { -@@ -2056,7 +_,8 @@ +@@ -2000,7 +_,8 @@ } public void setLevel(ClientLevel p_91157_, ReceivingLevelScreen.Reason p_341652_) { @@ -336,7 +329,7 @@ this.level = p_91157_; this.updateLevelInEngines(p_91157_); if (!this.isLocalServer) { -@@ -2093,6 +_,7 @@ +@@ -2037,6 +_,7 @@ IntegratedServer integratedserver = this.singleplayerServer; this.singleplayerServer = null; this.gameRenderer.resetData(); @@ -344,15 +337,15 @@ this.gameMode = null; this.narrator.clear(); this.clientLevelTeardownInProgress = true; -@@ -2100,6 +_,7 @@ +@@ -2044,6 +_,7 @@ try { this.updateScreenAndTick(p_320248_); if (this.level != null) { + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.LevelEvent.Unload(this.level)); if (integratedserver != null) { - this.profiler.push("waitForServer"); - -@@ -2258,6 +_,7 @@ + ProfilerFiller profilerfiller = Profiler.get(); + profilerfiller.push("waitForServer"); +@@ -2204,6 +_,7 @@ private void pickBlock() { if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { @@ -360,7 +353,7 @@ boolean flag = this.player.getAbilities().instabuild; BlockEntity blockentity = null; HitResult.Type hitresult$type = this.hitResult.getType(); -@@ -2270,7 +_,7 @@ +@@ -2216,7 +_,7 @@ } Block block = blockstate.getBlock(); @@ -369,7 +362,7 @@ if (itemstack.isEmpty()) { return; } -@@ -2284,7 +_,7 @@ +@@ -2230,7 +_,7 @@ } Entity entity = ((EntityHitResult)this.hitResult).getEntity(); @@ -378,7 +371,7 @@ if (itemstack == null) { return; } -@@ -2794,6 +_,10 @@ +@@ -2757,6 +_,10 @@ public void updateMaxMipLevel(int p_91313_) { this.modelManager.updateMaxMipLevel(p_91313_); diff --git a/patches/net/minecraft/client/MouseHandler.java.patch b/patches/net/minecraft/client/MouseHandler.java.patch index 01b53bd435..48d9f7cb68 100644 --- a/patches/net/minecraft/client/MouseHandler.java.patch +++ b/patches/net/minecraft/client/MouseHandler.java.patch @@ -1,42 +1,42 @@ --- a/net/minecraft/client/MouseHandler.java +++ b/net/minecraft/client/MouseHandler.java -@@ -79,6 +_,7 @@ +@@ -85,6 +_,7 @@ this.activeButton = -1; } + if (net.neoforged.neoforge.client.ClientHooks.onMouseButtonPre(p_91532_, p_91533_, p_91534_)) return; - boolean[] aboolean = new boolean[]{false}; if (this.minecraft.getOverlay() == null) { if (this.minecraft.screen == null) { -@@ -91,13 +_,21 @@ - Screen screen = this.minecraft.screen; - if (flag) { + if (!this.mouseGrabbed && flag) { +@@ -98,7 +_,12 @@ screen.afterMouseAction(); -- Screen.wrapScreenError( -- () -> aboolean[0] = screen.mouseClicked(d0, d1, i), "mouseClicked event handler", screen.getClass().getCanonicalName() -- ); -+ Screen.wrapScreenError(() -> { -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenMouseClickedPre(screen, d0, d1, i); -+ if (!aboolean[0]) { -+ aboolean[0] = screen.mouseClicked(d0, d1, i); -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenMouseClickedPost(screen, d0, d1, i, aboolean[0]); -+ } -+ }, "mouseClicked event handler", screen.getClass().getCanonicalName()); + + try { +- if (screen.mouseClicked(d0, d1, i)) { ++ boolean flag2; ++ if ( ++ net.neoforged.neoforge.client.ClientHooks.onScreenMouseClickedPre(screen, d0, d1, i) || ++ (flag2 = screen.mouseClicked(d0, d1, i)) | ++ net.neoforged.neoforge.client.ClientHooks.onScreenMouseClickedPost(screen, d0, d1, i, flag2) ++ ) { + return; + } + } catch (Throwable throwable1) { +@@ -112,7 +_,12 @@ + } } else { -- Screen.wrapScreenError( -- () -> aboolean[0] = screen.mouseReleased(d0, d1, i), "mouseReleased event handler", screen.getClass().getCanonicalName() -- ); -+ Screen.wrapScreenError(() -> { -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenMouseReleasedPre(screen, d0, d1, i); -+ if (!aboolean[0]) { -+ aboolean[0] = screen.mouseReleased(d0, d1, i); -+ aboolean[0] = net.neoforged.neoforge.client.ClientHooks.onScreenMouseReleasedPost(screen, d0, d1, i, aboolean[0]); -+ } -+ }, "mouseReleased event handler", screen.getClass().getCanonicalName()); - } - } - } -@@ -120,6 +_,7 @@ + try { +- if (screen.mouseReleased(d0, d1, i)) { ++ boolean flag2; ++ if ( ++ net.neoforged.neoforge.client.ClientHooks.onScreenMouseReleasedPre(screen, d0, d1, i) || ++ (flag2 = screen.mouseReleased(d0, d1, i)) | ++ net.neoforged.neoforge.client.ClientHooks.onScreenMouseReleasedPost(screen, d0, d1, i, flag2) ++ ) { + return; + } + } catch (Throwable throwable) { +@@ -146,6 +_,7 @@ } } } @@ -44,7 +44,7 @@ } } -@@ -133,7 +_,11 @@ +@@ -160,7 +_,11 @@ if (this.minecraft.screen != null) { double d3 = this.xpos * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth(); double d4 = this.ypos * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getScreenHeight(); @@ -56,31 +56,29 @@ + } this.minecraft.screen.afterMouseAction(); } else if (this.minecraft.player != null) { - if (this.accumulatedScrollX != 0.0 && Math.signum(d1) != Math.signum(this.accumulatedScrollX)) { -@@ -155,6 +_,7 @@ - this.accumulatedScrollX -= (double)j; - this.accumulatedScrollY -= (double)i; - int k = i == 0 ? -j : i; + Vector2i vector2i = this.scrollWheelHandler.onMouseScroll(d1, d2); +@@ -169,6 +_,7 @@ + } + + int i = vector2i.y == 0 ? -vector2i.x : vector2i.y; + if (net.neoforged.neoforge.client.ClientHooks.onMouseScroll(this, d1, d2)) return; if (this.minecraft.player.isSpectator()) { if (this.minecraft.gui.getSpectatorGui().isMenuActive()) { - this.minecraft.gui.getSpectatorGui().onMouseScrolled(-k); -@@ -244,9 +_,11 @@ - double d5 = this.accumulatedDY - * (double)this.minecraft.getWindow().getGuiScaledHeight() + this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i); +@@ -280,7 +_,11 @@ / (double)this.minecraft.getWindow().getScreenHeight(); -- Screen.wrapScreenError( -- () -> screen.mouseDragged(d2, d3, this.activeButton, d4, d5), "mouseDragged event handler", screen.getClass().getCanonicalName() -- ); -+ Screen.wrapScreenError(() -> { -+ if (net.neoforged.neoforge.client.ClientHooks.onScreenMouseDragPre(screen, d2, d3, this.activeButton, d4, d5)) return; -+ if (screen.mouseDragged(d2, d3, this.activeButton, d4, d5)) return; -+ net.neoforged.neoforge.client.ClientHooks.onScreenMouseDragPost(screen, d2, d3, this.activeButton, d4, d5); -+ }, "mouseDragged event handler", screen.getClass().getCanonicalName()); - } - screen.afterMouseMove(); -@@ -262,12 +_,13 @@ + try { +- screen.mouseDragged(d2, d3, this.activeButton, d4, d5); ++ if (!net.neoforged.neoforge.client.ClientHooks.onScreenMouseDragPre(screen, d2, d3, this.activeButton, d4, d5)) { ++ if (!screen.mouseDragged(d2, d3, this.activeButton, d4, d5)) { ++ net.neoforged.neoforge.client.ClientHooks.onScreenMouseDragPost(screen, d2, d3, this.activeButton, d4, d5); ++ } ++ } + } catch (Throwable throwable) { + CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler"); + screen.fillCrashDetails(crashreport1); +@@ -304,12 +_,13 @@ } private void turnPlayer(double p_316356_) { @@ -96,7 +94,7 @@ double d5 = this.smoothTurnX.getNewDeltaValue(this.accumulatedDX * d4, p_316356_ * d4); double d6 = this.smoothTurnY.getNewDeltaValue(this.accumulatedDY * d4, p_316356_ * d4); d0 = d5; -@@ -313,6 +_,14 @@ +@@ -355,6 +_,14 @@ public double ypos() { return this.ypos; diff --git a/patches/net/minecraft/client/Options.java.patch b/patches/net/minecraft/client/Options.java.patch index 63cda73a1e..ba0680da72 100644 --- a/patches/net/minecraft/client/Options.java.patch +++ b/patches/net/minecraft/client/Options.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java -@@ -727,9 +_,10 @@ +@@ -746,9 +_,10 @@ } }, new OptionInstance.LazyEnum<>( @@ -12,7 +12,7 @@ && !Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().contains(p_232011_) ? Optional.empty() : Optional.of(p_232011_), -@@ -799,7 +_,7 @@ +@@ -822,7 +_,7 @@ this.incompatibleResourcePacks.clear(); for (Pack pack : p_275268_.getSelectedPacks()) { @@ -21,7 +21,7 @@ this.resourcePacks.add(pack.getId()); if (!pack.getCompatibility().isCompatible()) { this.incompatibleResourcePacks.add(pack.getId()); -@@ -1099,6 +_,7 @@ +@@ -1130,6 +_,7 @@ } public Options(Minecraft p_92138_, File p_92139_) { @@ -29,7 +29,7 @@ this.minecraft = p_92138_; this.optionsFile = new File(p_92139_, "options.txt"); boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L; -@@ -1236,11 +_,21 @@ +@@ -1264,11 +_,21 @@ this.onboardAccessibility = p_168428_.process("onboardAccessibility", this.onboardAccessibility); p_168428_.process("menuBackgroundBlurriness", this.menuBackgroundBlurriness); @@ -53,7 +53,7 @@ } } -@@ -1258,6 +_,9 @@ +@@ -1286,6 +_,9 @@ } public void load() { @@ -63,7 +63,7 @@ try { if (!this.optionsFile.exists()) { return; -@@ -1285,7 +_,8 @@ +@@ -1313,7 +_,8 @@ } } @@ -73,7 +73,7 @@ new Options.FieldAccess() { @Nullable private String getValueOrNull(String p_168459_) { -@@ -1460,6 +_,7 @@ +@@ -1484,6 +_,7 @@ } public ClientInformation buildPlayerInformation() { @@ -81,7 +81,7 @@ int i = 0; for (PlayerModelPart playermodelpart : this.modelParts) { -@@ -1535,6 +_,23 @@ +@@ -1555,6 +_,23 @@ } p_92146_.setSelected(set); diff --git a/patches/net/minecraft/client/RecipeBookCategories.java.patch b/patches/net/minecraft/client/RecipeBookCategories.java.patch deleted file mode 100644 index 71ddc27bf7..0000000000 --- a/patches/net/minecraft/client/RecipeBookCategories.java.patch +++ /dev/null @@ -1,59 +0,0 @@ ---- a/net/minecraft/client/RecipeBookCategories.java -+++ b/net/minecraft/client/RecipeBookCategories.java -@@ -12,7 +_,7 @@ - import net.neoforged.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public enum RecipeBookCategories { -+public enum RecipeBookCategories implements net.neoforged.fml.common.asm.enumextension.IExtensibleEnum { - CRAFTING_SEARCH(new ItemStack(Items.COMPASS)), - CRAFTING_BUILDING_BLOCKS(new ItemStack(Blocks.BRICKS)), - CRAFTING_REDSTONE(new ItemStack(Items.REDSTONE)), -@@ -38,20 +_,20 @@ - public static final List CRAFTING_CATEGORIES = ImmutableList.of( - CRAFTING_SEARCH, CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE - ); -- public static final Map> AGGREGATE_CATEGORIES = ImmutableMap.of( -- CRAFTING_SEARCH, -- ImmutableList.of(CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE), -- FURNACE_SEARCH, -- ImmutableList.of(FURNACE_FOOD, FURNACE_BLOCKS, FURNACE_MISC), -- BLAST_FURNACE_SEARCH, -- ImmutableList.of(BLAST_FURNACE_BLOCKS, BLAST_FURNACE_MISC), -- SMOKER_SEARCH, -- ImmutableList.of(SMOKER_FOOD) -- ); -+ public static final Map> AGGREGATE_CATEGORIES = net.neoforged.neoforge.client.RecipeBookManager.getAggregateCategories(); -+ @Deprecated // Neo: Empty for custom categories. Use the getter. - private final List itemIcons; -+ private final java.util.function.Supplier> itemIconsSupplier; - -+ @net.neoforged.fml.common.asm.enumextension.ReservedConstructor - private RecipeBookCategories(ItemStack... p_92267_) { - this.itemIcons = ImmutableList.copyOf(p_92267_); -+ this.itemIconsSupplier = () -> this.itemIcons; -+ } -+ -+ private RecipeBookCategories(java.util.function.Supplier> itemIconsSupplier) { -+ this.itemIcons = List.of(); -+ this.itemIconsSupplier = net.neoforged.neoforge.common.util.Lazy.of(itemIconsSupplier); - } - - public static List getCategories(RecipeBookType p_92270_) { -@@ -60,10 +_,15 @@ - case FURNACE -> FURNACE_CATEGORIES; - case BLAST_FURNACE -> BLAST_FURNACE_CATEGORIES; - case SMOKER -> SMOKER_CATEGORIES; -+ default -> net.neoforged.neoforge.client.RecipeBookManager.getCustomCategoriesOrEmpty(p_92270_); - }; - } - - public List getIconItems() { -- return this.itemIcons; -+ return this.itemIconsSupplier.get(); -+ } -+ -+ public static net.neoforged.fml.common.asm.enumextension.ExtensionInfo getExtensionInfo() { -+ return net.neoforged.fml.common.asm.enumextension.ExtensionInfo.nonExtended(RecipeBookCategories.class); - } - } diff --git a/patches/net/minecraft/client/color/item/ItemColors.java.patch b/patches/net/minecraft/client/color/item/ItemColors.java.patch index 491886484d..afe4aac398 100644 --- a/patches/net/minecraft/client/color/item/ItemColors.java.patch +++ b/patches/net/minecraft/client/color/item/ItemColors.java.patch @@ -10,8 +10,8 @@ public static ItemColors createDefault(BlockColors p_92684_) { ItemColors itemcolors = new ItemColors(); -@@ -105,17 +_,20 @@ - : FastColor.ARGB32.opaque(p_329710_.getOrDefault(DataComponents.MAP_COLOR, MapItemColor.DEFAULT).rgb()), +@@ -101,17 +_,20 @@ + (p_359075_, p_359076_) -> p_359076_ == 0 ? -1 : ARGB.opaque(p_359075_.getOrDefault(DataComponents.MAP_COLOR, MapItemColor.DEFAULT).rgb()), Items.FILLED_MAP ); + net.neoforged.neoforge.client.ClientHooks.onItemColorsInit(itemcolors, p_92684_); diff --git a/patches/net/minecraft/client/gui/Font.java.patch b/patches/net/minecraft/client/gui/Font.java.patch index 57718aa4e8..92bc34f85a 100644 --- a/patches/net/minecraft/client/gui/Font.java.patch +++ b/patches/net/minecraft/client/gui/Font.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/Font.java +++ b/net/minecraft/client/gui/Font.java -@@ -31,7 +_,7 @@ +@@ -33,7 +_,7 @@ import org.joml.Vector3f; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ private static final float EFFECT_DEPTH = 0.01F; private static final Vector3f SHADOW_OFFSET = new Vector3f(0.0F, 0.0F, 0.03F); public static final int ALPHA_CUTOFF = 8; -@@ -326,6 +_,8 @@ +@@ -309,6 +_,8 @@ public StringSplitter getSplitter() { return this.splitter; } diff --git a/patches/net/minecraft/client/gui/Gui.java.patch b/patches/net/minecraft/client/gui/Gui.java.patch index dc1055a582..57ea34601f 100644 --- a/patches/net/minecraft/client/gui/Gui.java.patch +++ b/patches/net/minecraft/client/gui/Gui.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/Gui.java +++ b/net/minecraft/client/gui/Gui.java -@@ -69,6 +_,9 @@ +@@ -71,6 +_,9 @@ import net.neoforged.api.distmarker.OnlyIn; import org.joml.Matrix4fStack; @@ -10,8 +10,8 @@ @OnlyIn(Dist.CLIENT) public class Gui { private static final ResourceLocation CROSSHAIR_SPRITE = ResourceLocation.withDefaultNamespace("hud/crosshair"); -@@ -158,9 +_,21 @@ - private long healthBlinkTime; +@@ -175,9 +_,21 @@ + private int lastBubblePopSoundPlayed; private float autosaveIndicatorValue; private float lastAutosaveIndicatorValue; + /** Neo: This is empty and unused, rendering goes through {@link #layerManager} instead. */ @@ -32,7 +32,7 @@ public Gui(Minecraft p_232355_) { this.minecraft = p_232355_; this.debugOverlay = new DebugScreenOverlay(p_232355_); -@@ -170,27 +_,40 @@ +@@ -187,27 +_,40 @@ this.bossOverlay = new BossHealthOverlay(p_232355_); this.subtitleOverlay = new SubtitleOverlay(p_232355_); this.resetTitleTimes(); @@ -90,18 +90,18 @@ } public void resetTitleTimes() { -@@ -201,7 +_,9 @@ +@@ -217,7 +_,9 @@ + } public void render(GuiGraphics p_282884_, DeltaTracker p_348630_) { - RenderSystem.enableDepthTest(); - this.layers.render(p_282884_, p_348630_); + leftHeight = 39; + rightHeight = 39; + this.layerManager.render(p_282884_, p_348630_); - RenderSystem.disableDepthTest(); } -@@ -262,8 +_,12 @@ + private void renderCameraOverlays(GuiGraphics p_316735_, DeltaTracker p_348538_) { +@@ -289,8 +_,12 @@ } if (i > 8) { @@ -115,7 +115,7 @@ int j; if (this.animateOverlayMessageColor) { j = Mth.hsvToArgb(f / 50.0F, 0.7F, 0.6F, i); -@@ -323,9 +_,19 @@ +@@ -350,9 +_,19 @@ private void renderChat(GuiGraphics p_316307_, DeltaTracker p_348631_) { if (!this.chat.isChatFocused()) { Window window = this.minecraft.getWindow(); @@ -135,7 +135,7 @@ } } -@@ -441,6 +_,8 @@ +@@ -449,6 +_,8 @@ List list = Lists.newArrayListWithExpectedSize(collection.size()); for (MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { @@ -143,16 +143,16 @@ + if (!renderer.isVisibleInGui(mobeffectinstance)) continue; Holder holder = mobeffectinstance.getEffect(); if (mobeffectinstance.showIcon()) { - int i = p_282812_.guiWidth(); -@@ -471,6 +_,7 @@ + int k = p_282812_.guiWidth(); +@@ -480,6 +_,7 @@ } } -+ if (renderer.renderGuiIcon(mobeffectinstance, this, p_282812_, i, j, 0, f)) continue; ++ if (renderer.renderGuiIcon(mobeffectinstance, this, p_282812_, k, l, 0, f)) continue; TextureAtlasSprite textureatlassprite = mobeffecttexturemanager.get(holder); - int l1 = i; - int i1 = j; -@@ -488,29 +_,59 @@ + int l1 = k; + int k1 = l; +@@ -495,29 +_,59 @@ } } @@ -215,7 +215,7 @@ this.spectatorGui.renderTooltip(p_316628_); } } -@@ -633,18 +_,23 @@ +@@ -632,18 +_,23 @@ } private void renderSelectedItemName(GuiGraphics p_283501_) { @@ -223,7 +223,7 @@ + } + + public void renderSelectedItemName(GuiGraphics p_283501_, int yShift) { - this.minecraft.getProfiler().push("selectedItemName"); + Profiler.get().push("selectedItemName"); if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) { MutableComponent mutablecomponent = Component.empty() .append(this.lastToolHighlight.getHoverName()) @@ -242,31 +242,31 @@ if (!this.minecraft.gameMode.canHurtPlayer()) { k += 14; } -@@ -655,7 +_,13 @@ +@@ -654,7 +_,13 @@ } if (l > 0) { -- p_283501_.drawStringWithBackdrop(this.getFont(), mutablecomponent, j, k, i, FastColor.ARGB32.color(l, -1)); +- p_283501_.drawStringWithBackdrop(this.getFont(), mutablecomponent, j, k, i, ARGB.color(l, -1)); + Font font = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(lastToolHighlight).getFont(lastToolHighlight, net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.FontContext.SELECTED_ITEM_NAME); + if (font == null) { -+ p_283501_.drawStringWithBackdrop(this.getFont(), highlightTip, j, k, i, FastColor.ARGB32.color(l, -1)); ++ p_283501_.drawStringWithBackdrop(this.getFont(), highlightTip, j, k, i, ARGB.color(l, -1)); + } else { + j = (p_283501_.guiWidth() - font.width(highlightTip)) / 2; -+ p_283501_.drawStringWithBackdrop(font, highlightTip, j, k, i, FastColor.ARGB32.color(l, -1)); ++ p_283501_.drawStringWithBackdrop(font, highlightTip, j, k, i, ARGB.color(l, -1)); + } } } -@@ -663,7 +_,7 @@ +@@ -662,7 +_,7 @@ } private void renderDemoOverlay(GuiGraphics p_281825_, DeltaTracker p_348679_) { - if (this.minecraft.isDemo()) { + if (this.minecraft.isDemo() && !this.getDebugOverlay().showDebugScreen()) { // Neo: Hide demo timer when F3 debug overlay is open; fixes MC-271166 - this.minecraft.getProfiler().push("demo"); + Profiler.get().push("demo"); Component component; if (this.minecraft.level.getGameTime() >= 120500L) { -@@ -778,7 +_,15 @@ +@@ -774,7 +_,15 @@ return (int)Math.ceil((double)p_93013_ / 10.0); } @@ -282,7 +282,7 @@ Player player = this.getCameraPlayer(); if (player != null) { int i = Mth.ceil(player.getHealth()); -@@ -803,35 +_,62 @@ +@@ -798,31 +_,59 @@ this.random.setSeed((long)(this.tickCount * 312871)); int l = p_283143_.guiWidth() / 2 - 91; int i1 = p_283143_.guiWidth() / 2 + 91; @@ -299,12 +299,12 @@ k2 = this.tickCount % Mth.ceil(f + 5.0F); } - -- this.minecraft.getProfiler().push("armor"); +- Profiler.get().push("armor"); - renderArmor(p_283143_, player, j1, l1, i2, l); -- this.minecraft.getProfiler().popPush("health"); -+ this.minecraft.getProfiler().push("health"); +- Profiler.get().popPush("health"); ++ Profiler.get().push("health"); this.renderHearts(p_283143_, player, l, j1, i2, k2, f, i, k, k1, flag); -+ this.minecraft.getProfiler().pop(); ++ Profiler.get().pop(); + } + } + @@ -312,9 +312,9 @@ + Player player = this.getCameraPlayer(); + if (player != null) { + int l = p_283143_.guiWidth() / 2 - 91; -+ this.minecraft.getProfiler().push("armor"); ++ Profiler.get().push("armor"); + renderArmor(p_283143_, player, p_283143_.guiHeight() - leftHeight + 10, 1, 0, l); -+ this.minecraft.getProfiler().pop(); ++ Profiler.get().pop(); + if (player.getArmorValue() > 0) { + leftHeight += 10; + } @@ -327,61 +327,57 @@ LivingEntity livingentity = this.getPlayerVehicleWithHealth(); int l2 = this.getVehicleMaxHearts(livingentity); if (l2 == 0) { -- this.minecraft.getProfiler().popPush("food"); -+ this.minecraft.getProfiler().push("food"); +- Profiler.get().popPush("food"); ++ Profiler.get().push("food"); + int i1 = p_283143_.guiWidth() / 2 + 91; + int j1 = p_283143_.guiHeight() - rightHeight; this.renderFood(p_283143_, player, j1, i1); - j2 -= 10; + rightHeight += 10; -+ this.minecraft.getProfiler().pop(); ++ Profiler.get().pop(); } -- -- this.minecraft.getProfiler().popPush("air"); + } + } -+ + +- Profiler.get().popPush("air"); +- this.renderAirBubbles(p_283143_, player, l2, j2, i1); + private void renderAirLevel(GuiGraphics p_283143_) { + Player player = this.getCameraPlayer(); + if (player != null) { + int i1 = p_283143_.guiWidth() / 2 + 91; -+ -+ this.minecraft.getProfiler().push("air"); - int i3 = player.getMaxAirSupply(); - int j3 = Math.min(player.getAirSupply(), i3); - if (player.isEyeInFluid(FluidTags.WATER) || j3 < i3) { -- int k3 = this.getVisibleVehicleHeartRows(l2) - 1; -- j2 -= k3 * 10; -+ int j2 = p_283143_.guiHeight() - rightHeight; - int l3 = Mth.ceil((double)(j3 - 2) * 10.0 / (double)i3); - int i4 = Mth.ceil((double)j3 * 10.0 / (double)i3) - l3; - RenderSystem.enableBlend(); -@@ -845,6 +_,7 @@ ++ int j2 = p_283143_.guiHeight() - rightHeight; ++ Profiler.get().push("air"); ++ this.renderAirBubbles(p_283143_, player, 10, j2, i1); + Profiler.get().pop(); + } + } +@@ -936,6 +_,8 @@ + p_381066_.blitSprite(RenderType::guiTextured, AIR_EMPTY_SPRITE, k1, p_381100_ + l1, 9, 9); } - - RenderSystem.disableBlend(); -+ rightHeight += 10; } ++ ++ rightHeight += 10; + } + } - this.minecraft.getProfiler().pop(); -@@ -984,7 +_,7 @@ +@@ -1003,7 +_,7 @@ if (i != 0) { int j = (int)Math.ceil((double)livingentity.getHealth()); - this.minecraft.getProfiler().popPush("mountHealth"); + Profiler.get().popPush("mountHealth"); - int k = p_283368_.guiHeight() - 39; + int k = p_283368_.guiHeight() - rightHeight; int l = p_283368_.guiWidth() / 2 + 91; int i1 = k; - int j1 = 0; -@@ -1007,6 +_,7 @@ + +@@ -1024,6 +_,7 @@ } i1 -= 10; + rightHeight += 10; - j1 += 20; } - -@@ -1163,7 +_,7 @@ + } + } +@@ -1190,7 +_,7 @@ this.toolHighlightTimer = 0; } else if (this.lastToolHighlight.isEmpty() || !itemstack.is(this.lastToolHighlight.getItem()) @@ -390,7 +386,7 @@ this.toolHighlightTimer = (int)(40.0 * this.minecraft.options.notificationDisplayTime().get()); } else if (this.toolHighlightTimer > 0) { this.toolHighlightTimer--; -@@ -1292,8 +_,17 @@ +@@ -1319,8 +_,17 @@ } } @@ -409,7 +405,7 @@ CONTAINER( ResourceLocation.withDefaultNamespace("hud/heart/container"), ResourceLocation.withDefaultNamespace("hud/heart/container_blinking"), -@@ -1409,8 +_,13 @@ +@@ -1436,8 +_,13 @@ } else { gui$hearttype = NORMAL; } diff --git a/patches/net/minecraft/client/gui/GuiGraphics.java.patch b/patches/net/minecraft/client/gui/GuiGraphics.java.patch index 9ce42c48e9..caca78e363 100644 --- a/patches/net/minecraft/client/gui/GuiGraphics.java.patch +++ b/patches/net/minecraft/client/gui/GuiGraphics.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/GuiGraphics.java +++ b/net/minecraft/client/gui/GuiGraphics.java -@@ -56,7 +_,7 @@ +@@ -53,7 +_,7 @@ import org.joml.Vector2ic; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ public static final float MAX_GUI_Z = 10000.0F; public static final float MIN_GUI_Z = -10000.0F; private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2; -@@ -268,6 +_,11 @@ +@@ -227,6 +_,11 @@ } public int drawString(Font p_283343_, @Nullable String p_281896_, int p_283569_, int p_283418_, int p_281560_, boolean p_282130_) { @@ -18,10 +18,10 @@ + + // Forge: Add float variant for x,y coordinates, with a string as input + public int drawString(Font p_283343_, @Nullable String p_281896_, float p_283569_, float p_283418_, int p_281560_, boolean p_282130_) { - if (p_281896_ == null) { - return 0; - } else { -@@ -294,6 +_,11 @@ + return p_281896_ == null + ? 0 + : p_283343_.drawInBatch( +@@ -248,6 +_,11 @@ } public int drawString(Font p_282636_, FormattedCharSequence p_281596_, int p_281586_, int p_282816_, int p_281743_, boolean p_282394_) { @@ -30,13 +30,14 @@ + + // Forge: Add float variant for x,y coordinates, with a formatted char sequence as input + public int drawString(Font p_282636_, FormattedCharSequence p_281596_, float p_281586_, float p_282816_, int p_281743_, boolean p_282394_) { - int i = p_282636_.drawInBatch( + return p_282636_.drawInBatch( p_281596_, (float)p_281586_, -@@ -873,19 +_,26 @@ - } - +@@ -870,10 +_,15 @@ + this.renderItemCount(p_282005_, p_283349_, p_282641_, p_282146_, p_282803_); + this.renderItemCooldown(p_283349_, p_282641_, p_282146_); this.pose.popPose(); ++ // TODO 1.21.2: This probably belongs in one of the sub-methods. + net.neoforged.neoforge.client.ItemDecoratorHandler.of(p_283349_).render(this, p_282005_, p_283349_, p_282641_, p_282146_); } } @@ -45,56 +46,93 @@ public void renderTooltip(Font p_282308_, ItemStack p_282781_, int p_282687_, int p_282292_) { + this.tooltipStack = p_282781_; - this.renderTooltip(p_282308_, Screen.getTooltipFromItem(this.minecraft, p_282781_), p_282781_.getTooltipImage(), p_282687_, p_282292_); + this.renderTooltip( + p_282308_, + Screen.getTooltipFromItem(this.minecraft, p_282781_), +@@ -882,6 +_,17 @@ + p_282292_, + p_282781_.get(DataComponents.TOOLTIP_STYLE) + ); + this.tooltipStack = ItemStack.EMPTY; + } + + public void renderTooltip(Font font, List textComponents, Optional tooltipComponent, ItemStack stack, int mouseX, int mouseY) { ++ renderTooltip(font, textComponents, tooltipComponent, stack, mouseX, mouseY, null); ++ } ++ ++ public void renderTooltip(Font font, List textComponents, Optional tooltipComponent, ItemStack stack, int mouseX, int mouseY, @Nullable ResourceLocation backgroundTexture) { + this.tooltipStack = stack; -+ this.renderTooltip(font, textComponents, tooltipComponent, mouseX, mouseY); ++ this.renderTooltip(font, textComponents, tooltipComponent, mouseX, mouseY, backgroundTexture); + this.tooltipStack = ItemStack.EMPTY; } public void renderTooltip(Font p_283128_, List p_282716_, Optional p_281682_, int p_283678_, int p_281696_) { -- List list = p_282716_.stream() +@@ -891,11 +_,7 @@ + public void renderTooltip( + Font p_371715_, List p_371741_, Optional p_371604_, int p_371500_, int p_371755_, @Nullable ResourceLocation p_371766_ + ) { +- List list = p_371741_.stream() - .map(Component::getVisualOrderText) - .map(ClientTooltipComponent::create) - .collect(Util.toMutableList()); -- p_281682_.ifPresent(p_337410_ -> list.add(list.isEmpty() ? 0 : 1, ClientTooltipComponent.create(p_337410_))); -+ List list = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponents(this.tooltipStack, p_282716_, p_281682_, p_283678_, guiWidth(), guiHeight(), p_283128_); - this.renderTooltipInternal(p_283128_, list, p_283678_, p_281696_, DefaultTooltipPositioner.INSTANCE); +- p_371604_.ifPresent(p_337410_ -> list.add(list.isEmpty() ? 0 : 1, ClientTooltipComponent.create(p_337410_))); ++ List list = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponents(this.tooltipStack, p_371741_, p_371604_, p_371500_, guiWidth(), guiHeight(), p_371715_); + this.renderTooltipInternal(p_371715_, list, p_371500_, p_371755_, DefaultTooltipPositioner.INSTANCE, p_371766_); } -@@ -894,7 +_,22 @@ +@@ -908,13 +_,14 @@ } public void renderComponentTooltip(Font p_282739_, List p_281832_, int p_282191_, int p_282446_) { -- this.renderTooltip(p_282739_, Lists.transform(p_281832_, Component::getVisualOrderText), p_282191_, p_282446_); -+ List components = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponents(this.tooltipStack, p_281832_, p_282191_, guiWidth(), guiHeight(), p_282739_); -+ this.renderTooltipInternal(p_282739_, components, p_282191_, p_282446_, DefaultTooltipPositioner.INSTANCE); +- this.renderComponentTooltip(p_282739_, p_281832_, p_282191_, p_282446_, null); ++ this.renderComponentTooltip(p_282739_, p_281832_, p_282191_, p_282446_, (ResourceLocation) null); + } + + public void renderComponentTooltip(Font p_371677_, List p_371519_, int p_371314_, int p_371389_, @Nullable ResourceLocation p_371458_) { ++ List components = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponents(this.tooltipStack, p_371519_, p_371314_, guiWidth(), guiHeight(), p_371677_); + this.renderTooltipInternal( + p_371677_, +- p_371519_.stream().map(Component::getVisualOrderText).map(ClientTooltipComponent::create).toList(), ++ components, + p_371314_, + p_371389_, + DefaultTooltipPositioner.INSTANCE, +@@ -922,6 +_,28 @@ + ); + } + ++ public void renderComponentTooltip(Font font, List tooltips, int mouseX, int mouseY, ItemStack stack) { ++ renderComponentTooltip(font, tooltips, mouseX, mouseY, stack, null); + } + -+ public void renderComponentTooltip(Font font, List tooltips, int mouseX, int mouseY, ItemStack stack) { ++ public void renderComponentTooltip(Font font, List tooltips, int mouseX, int mouseY, ItemStack stack, @Nullable ResourceLocation backgroundTexture) { + this.tooltipStack = stack; + List components = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponents(stack, tooltips, mouseX, guiWidth(), guiHeight(), font); -+ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE); ++ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, backgroundTexture); + this.tooltipStack = ItemStack.EMPTY; + } + + public void renderComponentTooltipFromElements(Font font, List> elements, int mouseX, int mouseY, ItemStack stack) { ++ renderComponentTooltipFromElements(font, elements, mouseX, mouseY, stack, null); ++ } ++ ++ public void renderComponentTooltipFromElements(Font font, List> elements, int mouseX, int mouseY, ItemStack stack, @Nullable ResourceLocation backgroundTexture) { + this.tooltipStack = stack; + List components = net.neoforged.neoforge.client.ClientHooks.gatherTooltipComponentsFromElements(stack, elements, mouseX, guiWidth(), guiHeight(), font); -+ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE); ++ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, backgroundTexture); + this.tooltipStack = ItemStack.EMPTY; - } - ++ } ++ public void renderTooltip(Font p_282192_, List p_282297_, int p_281680_, int p_283325_) { -@@ -915,11 +_,13 @@ - - private void renderTooltipInternal(Font p_282675_, List p_282615_, int p_283230_, int p_283417_, ClientTooltipPositioner p_282442_) { + this.renderTooltip(p_282192_, p_282297_, p_281680_, p_283325_, null); + } +@@ -954,41 +_,45 @@ + @Nullable ResourceLocation p_371327_ + ) { if (!p_282615_.isEmpty()) { + net.neoforged.neoforge.client.event.RenderTooltipEvent.Pre preEvent = net.neoforged.neoforge.client.ClientHooks.onRenderTooltipPre(this.tooltipStack, this, p_283230_, p_283417_, guiWidth(), guiHeight(), p_282615_, p_282675_, p_282442_); + if (preEvent.isCanceled()) return; ++ int i = 0; int j = p_282615_.size() == 1 ? -2 : 0; @@ -104,35 +142,41 @@ if (k > i) { i = k; } -@@ -929,18 +_,19 @@ + +- j += clienttooltipcomponent.getHeight(p_282675_); ++ j += clienttooltipcomponent.getHeight(preEvent.getFont()); + } int i2 = i; int j2 = j; -- Vector2ic vector2ic = p_282442_.positionTooltip(this.guiWidth(), this.guiHeight(), p_283230_, p_283417_, i2, j2); +- Vector2ic vector2ic = p_282442_.positionTooltip(this.guiWidth(), this.guiHeight(), p_283230_, p_283417_, i, j); + Vector2ic vector2ic = p_282442_.positionTooltip(this.guiWidth(), this.guiHeight(), preEvent.getX(), preEvent.getY(), i2, j2); int l = vector2ic.x(); int i1 = vector2ic.y(); this.pose.pushPose(); int j1 = 400; -- this.drawManaged(() -> TooltipRenderUtil.renderTooltipBackground(this, l, i1, i2, j2, 400)); -+ net.neoforged.neoforge.client.event.RenderTooltipEvent.Color colorEvent = net.neoforged.neoforge.client.ClientHooks.onRenderTooltipColor(this.tooltipStack, this, l, i1, preEvent.getFont(), p_282615_); -+ this.drawManaged(() -> TooltipRenderUtil.renderTooltipBackground(this, l, i1, i2, j2, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd(), colorEvent.getBorderStart(), colorEvent.getBorderEnd())); +- TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, 400, p_371327_); ++ var textureEvent = net.neoforged.neoforge.client.ClientHooks.onRenderTooltipTexture(this.tooltipStack, this, l, i1, preEvent.getFont(), p_282615_, p_371327_); ++ TooltipRenderUtil.renderTooltipBackground(this, l, i1, i, j, 400, textureEvent.getTexture()); this.pose.translate(0.0F, 0.0F, 400.0F); int k1 = i1; for (int l1 = 0; l1 < p_282615_.size(); l1++) { ClientTooltipComponent clienttooltipcomponent1 = p_282615_.get(l1); - clienttooltipcomponent1.renderText(p_282675_, l, k1, this.pose.last().pose(), this.bufferSource); +- k1 += clienttooltipcomponent1.getHeight(p_282675_) + (l1 == 0 ? 2 : 0); + clienttooltipcomponent1.renderText(preEvent.getFont(), l, k1, this.pose.last().pose(), this.bufferSource); - k1 += clienttooltipcomponent1.getHeight() + (l1 == 0 ? 2 : 0); ++ k1 += clienttooltipcomponent1.getHeight(preEvent.getFont()) + (l1 == 0 ? 2 : 0); } -@@ -948,7 +_,7 @@ + k1 = i1; for (int k2 = 0; k2 < p_282615_.size(); k2++) { ClientTooltipComponent clienttooltipcomponent2 = p_282615_.get(k2); -- clienttooltipcomponent2.renderImage(p_282675_, l, k1, this); -+ clienttooltipcomponent2.renderImage(preEvent.getFont(), l, k1, this); - k1 += clienttooltipcomponent2.getHeight() + (k2 == 0 ? 2 : 0); +- clienttooltipcomponent2.renderImage(p_282675_, l, k1, i2, j2, this); +- k1 += clienttooltipcomponent2.getHeight(p_282675_) + (k2 == 0 ? 2 : 0); ++ clienttooltipcomponent2.renderImage(preEvent.getFont(), l, k1, i2, j2, this); ++ k1 += clienttooltipcomponent2.getHeight(preEvent.getFont()) + (k2 == 0 ? 2 : 0); } + this.pose.popPose(); diff --git a/patches/net/minecraft/client/gui/MapRenderer.java.patch b/patches/net/minecraft/client/gui/MapRenderer.java.patch deleted file mode 100644 index 756bcda934..0000000000 --- a/patches/net/minecraft/client/gui/MapRenderer.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/client/gui/MapRenderer.java -+++ b/net/minecraft/client/gui/MapRenderer.java -@@ -122,6 +_,10 @@ - - for (MapDecoration mapdecoration : this.data.getDecorations()) { - if (!p_93294_ || mapdecoration.renderOnFrame()) { -+ if (net.neoforged.neoforge.client.gui.map.MapDecorationRendererManager.render(mapdecoration, p_93292_, p_93293_, data, MapRenderer.this.decorationTextures, p_93294_, p_93295_, k)) { -+ k++; -+ continue; -+ } - p_93292_.pushPose(); - p_93292_.translate(0.0F + (float)mapdecoration.x() / 2.0F + 64.0F, 0.0F + (float)mapdecoration.y() / 2.0F + 64.0F, -0.02F); - p_93292_.mulPose(Axis.ZP.rotationDegrees((float)(mapdecoration.rot() * 360) / 16.0F)); diff --git a/patches/net/minecraft/client/gui/components/AbstractButton.java.patch b/patches/net/minecraft/client/gui/components/AbstractButton.java.patch index 5d141a2e4f..56d0a21b54 100644 --- a/patches/net/minecraft/client/gui/components/AbstractButton.java.patch +++ b/patches/net/minecraft/client/gui/components/AbstractButton.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/gui/components/AbstractButton.java +++ b/net/minecraft/client/gui/components/AbstractButton.java -@@ -34,7 +_,7 @@ - RenderSystem.enableDepthTest(); - p_281670_.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight()); - p_281670_.setColor(1.0F, 1.0F, 1.0F, 1.0F); +@@ -39,7 +_,7 @@ + this.getHeight(), + ARGB.white(this.alpha) + ); - int i = this.active ? 16777215 : 10526880; + int i = getFGColor(); this.renderString(p_281670_, minecraft.font, i | Mth.ceil(this.alpha * 255.0F) << 24); diff --git a/patches/net/minecraft/client/gui/components/AbstractWidget.java.patch b/patches/net/minecraft/client/gui/components/AbstractWidget.java.patch index 0f5ac718d8..256cef46f4 100644 --- a/patches/net/minecraft/client/gui/components/AbstractWidget.java.patch +++ b/patches/net/minecraft/client/gui/components/AbstractWidget.java.patch @@ -27,7 +27,7 @@ return true; } } -@@ -253,6 +_,19 @@ +@@ -257,6 +_,19 @@ @Override public void setFocused(boolean p_93693_) { this.focused = p_93693_; diff --git a/patches/net/minecraft/client/gui/components/BossHealthOverlay.java.patch b/patches/net/minecraft/client/gui/components/BossHealthOverlay.java.patch index 4bc398fffe..2e911a86df 100644 --- a/patches/net/minecraft/client/gui/components/BossHealthOverlay.java.patch +++ b/patches/net/minecraft/client/gui/components/BossHealthOverlay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/BossHealthOverlay.java +++ b/net/minecraft/client/gui/components/BossHealthOverlay.java -@@ -63,13 +_,16 @@ +@@ -66,13 +_,16 @@ for (LerpingBossEvent lerpingbossevent : this.events.values()) { int k = i / 2 - 91; diff --git a/patches/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch b/patches/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch index d47bc31435..3b4f7e321d 100644 --- a/patches/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch +++ b/patches/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch @@ -1,25 +1,24 @@ --- a/net/minecraft/client/gui/components/DebugScreenOverlay.java +++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java -@@ -135,8 +_,15 @@ +@@ -141,8 +_,14 @@ + Entity entity = this.minecraft.getCameraEntity(); this.block = entity.pick(20.0, 0.0F, false); this.liquid = entity.pick(20.0, 0.0F, true); - p_281427_.drawManaged(() -> { -- this.drawGameInformation(p_281427_); -- this.drawSystemInformation(p_281427_); -+ final List gameInformation = this.collectGameInformationText(); -+ final List systemInformation = this.collectSystemInformationText(); +- this.drawGameInformation(p_281427_); +- this.drawSystemInformation(p_281427_); + -+ var event = new net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent.DebugText(minecraft.getWindow(), p_281427_, minecraft.getTimer(), gameInformation, systemInformation); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event); ++ final List gameInformation = this.collectGameInformationText(); ++ final List systemInformation = this.collectSystemInformationText(); ++ var event = new net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent.DebugText(minecraft.getWindow(), p_281427_, minecraft.getDeltaTracker(), gameInformation, systemInformation); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event); ++ this.renderLines(p_281427_, gameInformation, true); ++ this.renderLines(p_281427_, systemInformation, false); + -+ this.renderLines(p_281427_, gameInformation, true); -+ this.renderLines(p_281427_, systemInformation, false); -+ - if (this.renderFpsCharts) { - int i = p_281427_.guiWidth(); - int j = i / 2; -@@ -161,7 +_,11 @@ - this.minecraft.getProfiler().pop(); + this.profilerPieChart.setBottomOffset(10); + if (this.renderFpsCharts) { + int i = p_281427_.guiWidth(); +@@ -175,7 +_,11 @@ + profilerfiller.pop(); } - protected void drawGameInformation(GuiGraphics p_281525_) { @@ -31,7 +30,7 @@ List list = this.getGameInformation(); list.add(""); boolean flag = this.minecraft.getSingleplayerServer() != null; -@@ -176,11 +_,25 @@ +@@ -190,11 +_,25 @@ + (this.renderNetworkCharts ? " visible" : " hidden") ); list.add("For help: press F3 + Q"); @@ -58,7 +57,7 @@ this.renderLines(p_281261_, list, false); } -@@ -509,6 +_,13 @@ +@@ -523,6 +_,13 @@ GlUtil.getRenderer(), GlUtil.getOpenGLVersion() ); @@ -72,7 +71,7 @@ if (this.minecraft.showOnlyReducedInfo()) { return list; } else { -@@ -545,6 +_,7 @@ +@@ -559,6 +_,7 @@ list.add(""); list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()))); diff --git a/patches/net/minecraft/client/gui/components/toasts/ToastComponent.java.patch b/patches/net/minecraft/client/gui/components/toasts/ToastComponent.java.patch deleted file mode 100644 index 7c7e69a6d3..0000000000 --- a/patches/net/minecraft/client/gui/components/toasts/ToastComponent.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/client/gui/components/toasts/ToastComponent.java -+++ b/net/minecraft/client/gui/components/toasts/ToastComponent.java -@@ -99,6 +_,7 @@ - } - - public void addToast(Toast p_94923_) { -+ if (net.neoforged.neoforge.client.ClientHooks.onToastAdd(p_94923_)) return; - this.queued.add(p_94923_); - } - diff --git a/patches/net/minecraft/client/gui/components/toasts/ToastManager.java.patch b/patches/net/minecraft/client/gui/components/toasts/ToastManager.java.patch new file mode 100644 index 0000000000..f5bd0bffbc --- /dev/null +++ b/patches/net/minecraft/client/gui/components/toasts/ToastManager.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/gui/components/toasts/ToastManager.java ++++ b/net/minecraft/client/gui/components/toasts/ToastManager.java +@@ -107,6 +_,7 @@ + } + + public void addToast(Toast p_362712_) { ++ if (net.neoforged.neoforge.client.ClientHooks.onToastAdd(p_362712_)) return; + this.queued.add(p_362712_); + } + diff --git a/patches/net/minecraft/client/gui/screens/LoadingOverlay.java.patch b/patches/net/minecraft/client/gui/screens/LoadingOverlay.java.patch index 3729b1ae51..b607643c50 100644 --- a/patches/net/minecraft/client/gui/screens/LoadingOverlay.java.patch +++ b/patches/net/minecraft/client/gui/screens/LoadingOverlay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/LoadingOverlay.java +++ b/net/minecraft/client/gui/screens/LoadingOverlay.java -@@ -133,6 +_,7 @@ +@@ -123,6 +_,7 @@ } if (this.fadeOutStart == -1L && this.reload.isDone() && (!this.fadeIn || f1 >= 2.0F)) { @@ -8,7 +8,7 @@ try { this.reload.checkExceptions(); this.onFinish.accept(Optional.empty()); -@@ -140,7 +_,6 @@ +@@ -130,7 +_,6 @@ this.onFinish.accept(Optional.of(throwable)); } diff --git a/patches/net/minecraft/client/gui/screens/PauseScreen.java.patch b/patches/net/minecraft/client/gui/screens/PauseScreen.java.patch index 7016a2712f..b8a1613d4e 100644 --- a/patches/net/minecraft/client/gui/screens/PauseScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/PauseScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/PauseScreen.java +++ b/net/minecraft/client/gui/screens/PauseScreen.java -@@ -96,6 +_,7 @@ +@@ -97,6 +_,7 @@ } else { gridlayout$rowhelper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this))); } diff --git a/patches/net/minecraft/client/gui/screens/Screen.java.patch b/patches/net/minecraft/client/gui/screens/Screen.java.patch index cc93b39e1c..e7d7751d22 100644 --- a/patches/net/minecraft/client/gui/screens/Screen.java.patch +++ b/patches/net/minecraft/client/gui/screens/Screen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/Screen.java +++ b/net/minecraft/client/gui/screens/Screen.java -@@ -116,6 +_,7 @@ +@@ -115,6 +_,7 @@ } } @@ -8,7 +8,7 @@ @Override public void render(GuiGraphics p_281549_, int p_281550_, int p_282878_, float p_282465_) { this.renderBackground(p_281549_, p_281550_, p_282878_, p_282465_); -@@ -201,7 +_,7 @@ +@@ -200,7 +_,7 @@ } public void onClose() { @@ -17,7 +17,7 @@ } protected T addRenderableWidget(T p_169406_) { -@@ -242,7 +_,7 @@ +@@ -241,7 +_,7 @@ return p_282833_.getTooltipLines( Item.TooltipContext.of(p_281881_.level), p_281881_.player, @@ -26,7 +26,7 @@ ); } -@@ -312,8 +_,11 @@ +@@ -311,8 +_,11 @@ this.width = p_96608_; this.height = p_96609_; if (!this.initialized) { @@ -38,7 +38,7 @@ } else { this.repositionElements(); } -@@ -326,8 +_,11 @@ +@@ -325,8 +_,11 @@ protected void rebuildWidgets() { this.clearWidgets(); this.clearFocus(); @@ -50,15 +50,15 @@ } @Override -@@ -354,6 +_,7 @@ +@@ -353,6 +_,7 @@ - this.renderBlurredBackground(p_294317_); + this.renderBlurredBackground(); this.renderMenuBackground(p_283688_); + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.ScreenEvent.BackgroundRendered(this, p_283688_)); } - protected void renderBlurredBackground(float p_330683_) { -@@ -467,6 +_,10 @@ + protected void renderBlurredBackground() { +@@ -458,6 +_,10 @@ public void onFilesDrop(List p_96591_) { } @@ -69,7 +69,7 @@ private void scheduleNarration(long p_169381_, boolean p_169382_) { this.nextNarrationTime = Util.getMillis() + p_169381_; if (p_169382_) { -@@ -643,5 +_,13 @@ +@@ -642,5 +_,13 @@ this.index = p_169425_; this.priority = p_169426_; } diff --git a/patches/net/minecraft/client/gui/screens/TitleScreen.java.patch b/patches/net/minecraft/client/gui/screens/TitleScreen.java.patch index b4069b5603..2038b23682 100644 --- a/patches/net/minecraft/client/gui/screens/TitleScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/TitleScreen.java.patch @@ -1,22 +1,34 @@ --- a/net/minecraft/client/gui/screens/TitleScreen.java +++ b/net/minecraft/client/gui/screens/TitleScreen.java -@@ -114,11 +_,14 @@ +@@ -114,11 +_,17 @@ int i = this.font.width(COPYRIGHT_TEXT); int j = this.width - i - 2; int k = 24; - int l = this.height / 4 + 48; + int l = this.height / 4 + 32; if (this.minecraft.isDemo()) { - this.createDemoMenuOptions(l, 24); + l = this.createDemoMenuOptions(l, 24); } else { - this.createNormalMenuOptions(l, 24); + l = this.createNormalMenuOptions(l, 24); ++ int modsOffset = SharedConstants.IS_RUNNING_IN_IDE ? 2 : -100; ++ int modsWidth = SharedConstants.IS_RUNNING_IN_IDE ? 98 : 200; + this.addRenderableWidget(new net.neoforged.neoforge.client.gui.widget.ModsButton(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.neoforged.neoforge.client.gui.ModListScreen(this))) -+ .pos(this.width / 2 - 100, l + 24 * 3).size(200, 20))); -+ l += 22; // Move down Options, Quit, Language, and Accessibility buttons to make room for mods button ++ .pos(this.width / 2 + modsOffset, l + 24).size(modsWidth, 20))); ++ if (!SharedConstants.IS_RUNNING_IN_IDE) ++ l += 24; // Move down Options, Quit, Language, and Accessibility buttons to make room for mods button (in-dev the test world button "handles" this) } - SpriteIconButton spriteiconbutton = this.addRenderableWidget( -@@ -285,6 +_,7 @@ + l = this.createTestWorldButton(l, 24); +@@ -160,7 +_,7 @@ + if (SharedConstants.IS_RUNNING_IN_IDE) { + this.addRenderableWidget( + Button.builder(Component.literal("Create Test World"), p_372504_ -> CreateWorldScreen.testWorld(this.minecraft, this)) +- .bounds(this.width / 2 - 100, p_373114_ += p_372852_, 200, 20) ++ .bounds(this.width / 2 - 100, p_373114_ += p_372852_, 98, 20) // Neo: reduce button width to fit the mods button next to it + .build() + ); + } +@@ -304,6 +_,7 @@ if ((i & -67108864) != 0) { super.render(p_282860_, p_281753_, p_283539_, p_282628_); this.logoRenderer.renderLogo(p_282860_, this.width, f); @@ -24,7 +36,7 @@ if (this.splash != null && !this.minecraft.options.hideSplashTexts().get()) { this.splash.render(p_282860_, this.width, this.font, i); } -@@ -300,7 +_,13 @@ +@@ -319,7 +_,13 @@ s = s + I18n.get("menu.modded"); } @@ -37,5 +49,5 @@ + p_282860_.drawString(this.font, brd, this.width - font.width(brd), this.height - (10 + (brdline + 1) * (this.font.lineHeight + 1)), 16777215 | i) + ); if (this.realmsNotificationsEnabled() && f >= 1.0F) { - RenderSystem.enableDepthTest(); this.realmsNotificationsScreen.render(p_282860_, p_281753_, p_283539_, p_282628_); + } diff --git a/patches/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch b/patches/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch index 01da559bba..f74b6000ef 100644 --- a/patches/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch +++ b/patches/net/minecraft/client/gui/screens/advancements/AdvancementTab.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java -@@ -37,6 +_,7 @@ +@@ -38,6 +_,7 @@ private int maxY = Integer.MIN_VALUE; private float fade; private boolean centered; @@ -8,7 +8,7 @@ public AdvancementTab( Minecraft p_97145_, AdvancementsScreen p_97146_, AdvancementTabType p_97147_, int p_97148_, AdvancementNode p_300867_, DisplayInfo p_97150_ -@@ -53,6 +_,15 @@ +@@ -54,6 +_,15 @@ this.addWidget(this.root, p_300867_.holder()); } @@ -24,7 +24,7 @@ public AdvancementTabType getType() { return this.type; } -@@ -146,8 +_,8 @@ +@@ -147,8 +_,8 @@ return null; } else { for (AdvancementTabType advancementtabtype : AdvancementTabType.values()) { diff --git a/patches/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch b/patches/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch index 62e7224528..fbce35ac1f 100644 --- a/patches/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch +++ b/patches/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementTabType.java -@@ -71,6 +_,7 @@ +@@ -72,6 +_,7 @@ private final AdvancementTabType.Sprites selectedSprites; private final AdvancementTabType.Sprites unselectedSprites; diff --git a/patches/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch b/patches/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch index 3e9f5ae794..30052bef01 100644 --- a/patches/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java -@@ -49,6 +_,7 @@ +@@ -51,6 +_,7 @@ @Nullable private AdvancementTab selectedTab; private boolean isScrolling; @@ -8,7 +8,7 @@ public AdvancementsScreen(ClientAdvancements p_97340_) { this(p_97340_, null); -@@ -73,6 +_,16 @@ +@@ -75,6 +_,16 @@ this.advancements.setSelectedTab(this.selectedTab == null ? null : this.selectedTab.getRootNode().holder(), true); } @@ -25,7 +25,7 @@ this.layout.addToFooter(Button.builder(CommonComponents.GUI_DONE, p_331557_ -> this.onClose()).width(200).build()); this.layout.visitWidgets(p_332019_ -> { AbstractWidget abstractwidget = this.addRenderableWidget(p_332019_); -@@ -106,7 +_,7 @@ +@@ -108,7 +_,7 @@ int j = (this.height - 140) / 2; for (AdvancementTab advancementtab : this.tabs.values()) { @@ -34,7 +34,7 @@ this.advancements.setSelectedTab(advancementtab.getRootNode().holder(), true); break; } -@@ -132,6 +_,11 @@ +@@ -134,6 +_,11 @@ super.render(p_282589_, p_282255_, p_283354_, p_283123_); int i = (this.width - 252) / 2; int j = (this.height - 140) / 2; @@ -46,8 +46,8 @@ this.renderInside(p_282589_, p_282255_, p_283354_, i, j); this.renderWindow(p_282589_, i, j); this.renderTooltips(p_282589_, p_282255_, p_283354_, i, j); -@@ -180,10 +_,12 @@ - p_283395_.blit(WINDOW_LOCATION, p_281890_, p_282532_, 0, 0, 252, 140); +@@ -181,10 +_,12 @@ + p_283395_.blit(RenderType::guiTextured, WINDOW_LOCATION, p_281890_, p_282532_, 0.0F, 0.0F, 252, 140, 256, 256); if (this.tabs.size() > 1) { for (AdvancementTab advancementtab : this.tabs.values()) { + if (advancementtab.getPage() == tabPage) @@ -59,7 +59,7 @@ advancementtab1.drawIcon(p_283395_, p_281890_, p_282532_); } } -@@ -203,7 +_,7 @@ +@@ -202,7 +_,7 @@ if (this.tabs.size() > 1) { for (AdvancementTab advancementtab : this.tabs.values()) { diff --git a/patches/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch index d00c918adb..be4ec4baf1 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java +++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java -@@ -91,7 +_,12 @@ +@@ -107,7 +_,12 @@ public void render(GuiGraphics p_283479_, int p_283661_, int p_281248_, float p_281886_) { int i = this.leftPos; int j = this.topPos; @@ -11,56 +11,26 @@ + for (net.minecraft.client.gui.components.Renderable renderable : this.renderables) { + renderable.render(p_283479_, p_283661_, p_281248_, p_281886_); + } - RenderSystem.disableDepthTest(); p_283479_.pose().pushPose(); p_283479_.pose().translate((float)i, (float)j, 0.0F); -@@ -105,15 +_,12 @@ - - if (this.isHovering(slot, (double)p_283661_, (double)p_281248_) && slot.isActive()) { - this.hoveredSlot = slot; -- int l = slot.x; -- int i1 = slot.y; -- if (this.hoveredSlot.isHighlightable()) { -- renderSlotHighlight(p_283479_, l, i1, 0); -- } -+ this.renderSlotHighlight(p_283479_, slot, p_283661_, p_281248_, p_281886_); - } + Slot slot = this.hoveredSlot; +@@ -120,6 +_,7 @@ } this.renderLabels(p_283479_, p_283661_, p_281248_); + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.ContainerScreenEvent.Render.Foreground(this, p_283479_, p_283661_, p_281248_)); ItemStack itemstack = this.draggingItem.isEmpty() ? this.menu.getCarried() : this.draggingItem; if (!itemstack.isEmpty()) { - int l1 = 8; -@@ -156,13 +_,25 @@ - } - - public static void renderSlotHighlight(GuiGraphics p_283692_, int p_281453_, int p_281915_, int p_283504_) { -- p_283692_.fillGradient(RenderType.guiOverlay(), p_281453_, p_281915_, p_281453_ + 16, p_281915_ + 16, -2130706433, -2130706433, p_283504_); -+ renderSlotHighlight(p_283692_, p_281453_, p_281915_, p_283504_, -2130706433); -+ } -+ public static void renderSlotHighlight(GuiGraphics p_283692_, int p_281453_, int p_281915_, int p_283504_, int color) { -+ p_283692_.fillGradient(RenderType.guiOverlay(), p_281453_, p_281915_, p_281453_ + 16, p_281915_ + 16, color, color, p_283504_); -+ } -+ -+ /** -+ * Renders a highlight for the given slot to indicate the mouse is currently hovering over it. -+ */ -+ protected void renderSlotHighlight(GuiGraphics guiGraphics, Slot slot, int mouseX, int mouseY, float partialTick) { -+ if (slot.isHighlightable()) { -+ renderSlotHighlight(guiGraphics, slot.x, slot.y, 0, getSlotColor(slot.index)); -+ } - } - - protected void renderTooltip(GuiGraphics p_283594_, int p_282171_, int p_281909_) { - if (this.menu.getCarried().isEmpty() && this.hoveredSlot != null && this.hoveredSlot.hasItem()) { - ItemStack itemstack = this.hoveredSlot.getItem(); -- p_283594_.renderTooltip(this.font, this.getTooltipFromContainerItem(itemstack), itemstack.getTooltipImage(), p_282171_, p_281909_); -+ p_283594_.renderTooltip(this.font, this.getTooltipFromContainerItem(itemstack), itemstack.getTooltipImage(), itemstack, p_282171_, p_281909_); - } - } - -@@ -174,7 +_,8 @@ + int k = 8; +@@ -202,6 +_,7 @@ + this.font, + this.getTooltipFromContainerItem(itemstack), + itemstack.getTooltipImage(), ++ itemstack, + p_282171_, + p_281909_, + itemstack.get(DataComponents.TOOLTIP_STYLE) +@@ -222,7 +_,8 @@ p_282567_.pose().pushPose(); p_282567_.pose().translate(0.0F, 0.0F, 232.0F); p_282567_.renderItem(p_281330_, p_281772_, p_281689_); @@ -70,7 +40,7 @@ p_282567_.pose().popPose(); } -@@ -233,6 +_,14 @@ +@@ -281,6 +_,14 @@ p_281607_.fill(i, j, i + 16, j + 16, -2130706433); } @@ -85,7 +55,7 @@ int j1 = p_282613_.x + p_282613_.y * this.imageWidth; if (p_282613_.isFake()) { p_281607_.renderFakeItem(itemstack, i, j, j1); -@@ -241,9 +_,6 @@ +@@ -289,9 +_,6 @@ } p_281607_.renderItemDecorations(this.font, itemstack, i, j, s); @@ -95,17 +65,17 @@ } private void recalculateQuickCraftRemaining() { -@@ -282,7 +_,8 @@ +@@ -329,7 +_,8 @@ if (super.mouseClicked(p_97748_, p_97749_, p_97750_)) { return true; } else { - boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_97750_) && this.minecraft.gameMode.hasInfiniteItems(); + InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97750_); + boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey); - Slot slot = this.findSlot(p_97748_, p_97749_); + Slot slot = this.getHoveredSlot(p_97748_, p_97749_); long i = Util.getMillis(); this.doubleclick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == p_97750_; -@@ -293,6 +_,7 @@ +@@ -340,6 +_,7 @@ int j = this.leftPos; int k = this.topPos; boolean flag1 = this.hasClickedOutside(p_97748_, p_97749_, j, k, p_97750_); @@ -113,7 +83,7 @@ int l = -1; if (slot != null) { l = slot.index; -@@ -318,7 +_,7 @@ +@@ -365,7 +_,7 @@ } } else if (!this.isQuickCrafting) { if (this.menu.getCarried().isEmpty()) { @@ -122,7 +92,7 @@ this.slotClicked(slot, l, p_97750_, ClickType.CLONE); } else { boolean flag2 = l != -999 -@@ -346,7 +_,7 @@ +@@ -393,7 +_,7 @@ this.quickCraftingType = 0; } else if (p_97750_ == 1) { this.quickCraftingType = 1; @@ -131,12 +101,12 @@ this.quickCraftingType = 2; } } -@@ -425,10 +_,13 @@ +@@ -472,10 +_,13 @@ @Override public boolean mouseReleased(double p_97812_, double p_97813_, int p_97814_) { + super.mouseReleased(p_97812_, p_97813_, p_97814_); //Forge, Call parent to release buttons - Slot slot = this.findSlot(p_97812_, p_97813_); + Slot slot = this.getHoveredSlot(p_97812_, p_97813_); int i = this.leftPos; int j = this.topPos; boolean flag = this.hasClickedOutside(p_97812_, p_97813_, i, j, p_97814_); @@ -145,7 +115,7 @@ int k = -1; if (slot != null) { k = slot.index; -@@ -445,7 +_,7 @@ +@@ -492,7 +_,7 @@ if (slot2 != null && slot2.mayPickup(this.minecraft.player) && slot2.hasItem() @@ -154,7 +124,7 @@ && AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) { this.slotClicked(slot2, slot2.index, p_97814_, ClickType.QUICK_MOVE); } -@@ -509,7 +_,7 @@ +@@ -556,7 +_,7 @@ this.slotClicked(null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT); } else if (!this.menu.getCarried().isEmpty()) { @@ -163,7 +133,7 @@ this.slotClicked(slot, k, p_97814_, ClickType.CLONE); } else { boolean flag1 = k != -999 -@@ -568,34 +_,39 @@ +@@ -636,34 +_,39 @@ @Override public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) { @@ -210,7 +180,7 @@ this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, i, ClickType.SWAP); return true; } -@@ -633,6 +_,18 @@ +@@ -701,6 +_,18 @@ @Override public T getMenu() { return this.menu; diff --git a/patches/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch index 525825a442..37ccae8839 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java -@@ -112,6 +_,8 @@ - private boolean hasClickedOutside; +@@ -115,6 +_,8 @@ private final Set> visibleTags = new HashSet<>(); private final boolean displayOperatorCreativeTab; + private final EffectsInInventory effects; + private final List pages = new java.util.ArrayList<>(); + private net.neoforged.neoforge.client.gui.CreativeTabsScreenPage currentPage = new net.neoforged.neoforge.client.gui.CreativeTabsScreenPage(new java.util.ArrayList<>()); public CreativeModeInventoryScreen(LocalPlayer p_346290_, FeatureFlagSet p_260074_, boolean p_259569_) { super(new CreativeModeInventoryScreen.ItemPickerMenu(p_346290_), p_346290_.getInventory(), CommonComponents.EMPTY); -@@ -147,9 +_,11 @@ +@@ -151,9 +_,11 @@ return false; } else { if (p_345591_ != null) { @@ -24,7 +24,7 @@ } return true; -@@ -159,7 +_,7 @@ +@@ -163,7 +_,7 @@ private void refreshCurrentTabContents(Collection p_261591_) { int i = this.menu.getRowIndexForScroll(this.scrollOffs); this.menu.items.clear(); @@ -33,7 +33,7 @@ this.refreshSearchResults(); } else { this.menu.items.addAll(p_261591_); -@@ -326,6 +_,34 @@ +@@ -337,6 +_,34 @@ protected void init() { if (this.minecraft.gameMode.hasInfiniteItems()) { super.init(); @@ -68,7 +68,7 @@ this.searchBox = new EditBox(this.font, this.leftPos + 82, this.topPos + 6, 80, 9, Component.translatable("itemGroup.search")); this.searchBox.setMaxLength(50); this.searchBox.setBordered(false); -@@ -372,7 +_,7 @@ +@@ -383,7 +_,7 @@ public boolean charTyped(char p_98521_, int p_98522_) { if (this.ignoreTextInput) { return false; @@ -77,7 +77,7 @@ return false; } else { String s = this.searchBox.getValue(); -@@ -391,7 +_,7 @@ +@@ -402,7 +_,7 @@ @Override public boolean keyPressed(int p_98547_, int p_98548_, int p_98549_) { this.ignoreTextInput = false; @@ -86,7 +86,7 @@ if (this.minecraft.options.keyChat.matches(p_98547_, p_98548_)) { this.ignoreTextInput = true; this.selectTab(CreativeModeTabs.searchTab()); -@@ -427,6 +_,7 @@ +@@ -438,6 +_,7 @@ } private void refreshSearchResults() { @@ -94,7 +94,7 @@ this.menu.items.clear(); this.visibleTags.clear(); String s = this.searchBox.getValue(); -@@ -439,10 +_,10 @@ +@@ -450,10 +_,10 @@ SearchTree searchtree; if (s.startsWith("#")) { s = s.substring(1); @@ -107,7 +107,7 @@ } this.menu.items.addAll(searchtree.search(s.toLowerCase(Locale.ROOT))); -@@ -470,7 +_,8 @@ +@@ -481,7 +_,8 @@ @Override protected void renderLabels(GuiGraphics p_283168_, int p_281774_, int p_281466_) { if (selectedTab.showTitle()) { @@ -117,7 +117,7 @@ } } -@@ -480,7 +_,7 @@ +@@ -491,7 +_,7 @@ double d0 = p_98531_ - (double)this.leftPos; double d1 = p_98532_ - (double)this.topPos; @@ -126,7 +126,7 @@ if (this.checkTabClicked(creativemodetab, d0, d1)) { return true; } -@@ -502,7 +_,7 @@ +@@ -513,7 +_,7 @@ double d1 = p_98623_ - (double)this.topPos; this.scrolling = false; @@ -135,7 +135,7 @@ if (this.checkTabClicked(creativemodetab, d0, d1)) { this.selectTab(creativemodetab); return true; -@@ -520,6 +_,7 @@ +@@ -531,6 +_,7 @@ private void selectTab(CreativeModeTab p_98561_) { CreativeModeTab creativemodetab = selectedTab; selectedTab = p_98561_; @@ -143,7 +143,7 @@ this.quickCraftSlots.clear(); this.menu.items.clear(); this.clearDraggingState(); -@@ -596,13 +_,15 @@ +@@ -607,13 +_,15 @@ this.originalSlots = null; } @@ -160,9 +160,9 @@ this.refreshSearchResults(); } else { -@@ -665,18 +_,27 @@ - public void render(GuiGraphics p_283000_, int p_281317_, int p_282770_, float p_281295_) { +@@ -679,18 +_,27 @@ super.render(p_283000_, p_281317_, p_282770_, p_281295_); + this.effects.render(p_283000_, p_281317_, p_282770_, p_281295_); - for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { - if (this.checkTabHovering(p_283000_, creativemodetab, p_281317_, p_282770_)) { @@ -194,7 +194,7 @@ this.renderTooltip(p_283000_, p_281317_, p_282770_); } -@@ -684,10 +_,10 @@ +@@ -703,10 +_,10 @@ public List getTooltipFromContainerItem(ItemStack p_281769_) { boolean flag = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot; boolean flag1 = selectedTab.getType() == CreativeModeTab.Type.CATEGORY; @@ -207,7 +207,7 @@ if (flag1 && flag) { return list; } else { -@@ -703,7 +_,7 @@ +@@ -722,7 +_,7 @@ int i = 1; for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { @@ -216,7 +216,7 @@ list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE)); } } -@@ -714,7 +_,7 @@ +@@ -733,7 +_,7 @@ @Override protected void renderBg(GuiGraphics p_282663_, float p_282504_, int p_282089_, int p_282249_) { @@ -225,20 +225,20 @@ if (creativemodetab != selectedTab) { this.renderTabButton(p_282663_, creativemodetab); } -@@ -726,10 +_,11 @@ +@@ -747,10 +_,11 @@ int k = this.topPos + 18; int i = k + 112; if (selectedTab.canScroll()) { - ResourceLocation resourcelocation = this.canScroll() ? SCROLLER_SPRITE : SCROLLER_DISABLED_SPRITE; + ResourceLocation resourcelocation = selectedTab.getScrollerSprite(); // this.canScroll() ? SCROLLER_SPRITE : SCROLLER_DISABLED_SPRITE; - p_282663_.blitSprite(resourcelocation, j, k + (int)((float)(i - k - 17) * this.scrollOffs), 12, 15); + p_282663_.blitSprite(RenderType::guiTextured, resourcelocation, j, k + (int)((float)(i - k - 17) * this.scrollOffs), 12, 15); } + if (currentPage.getVisibleTabs().contains(selectedTab)) //Forge: only display tab selection when the selected tab is on the current page this.renderTabButton(p_282663_, selectedTab); if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) { InventoryScreen.renderEntityInInventoryFollowsMouse( -@@ -748,7 +_,7 @@ +@@ -769,7 +_,7 @@ } private int getTabX(CreativeModeTab p_260136_) { @@ -247,7 +247,7 @@ int j = 27; int k = 27 * i; if (p_260136_.isAlignedRight()) { -@@ -760,7 +_,7 @@ +@@ -781,7 +_,7 @@ private int getTabY(CreativeModeTab p_260181_) { int i = 0; @@ -256,7 +256,7 @@ i -= 32; } else { i += this.imageHeight; -@@ -788,8 +_,8 @@ +@@ -809,8 +_,8 @@ protected void renderTabButton(GuiGraphics p_283590_, CreativeModeTab p_283489_) { boolean flag = p_283489_ == selectedTab; @@ -267,15 +267,15 @@ int j = this.leftPos + this.getTabX(p_283489_); int k = this.topPos - (flag1 ? 28 : -(this.imageHeight - 4)); ResourceLocation[] aresourcelocation; -@@ -799,6 +_,7 @@ +@@ -820,6 +_,7 @@ aresourcelocation = flag ? SELECTED_BOTTOM_TABS : UNSELECTED_BOTTOM_TABS; } + //PATCH 1.20.2: Deal with custom tab backgrounds, and deal with transparency. - p_283590_.blitSprite(aresourcelocation[Mth.clamp(i, 0, aresourcelocation.length)], j, k, 26, 32); + p_283590_.blitSprite(RenderType::guiTextured, aresourcelocation[Mth.clamp(i, 0, aresourcelocation.length)], j, k, 26, 32); p_283590_.pose().pushPose(); p_283590_.pose().translate(0.0F, 0.0F, 100.0F); -@@ -840,6 +_,14 @@ +@@ -861,6 +_,14 @@ } } @@ -290,7 +290,7 @@ @OnlyIn(Dist.CLIENT) static class CustomCreativeSlot extends Slot { public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) { -@@ -1024,6 +_,22 @@ +@@ -1042,6 +_,22 @@ @Override public boolean mayPickup(Player p_98665_) { return this.target.mayPickup(p_98665_); diff --git a/patches/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch similarity index 64% rename from patches/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch rename to patches/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch index e194f8c32f..c3288a4316 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java.patch @@ -1,10 +1,10 @@ ---- a/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java -+++ b/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java -@@ -47,12 +_,17 @@ +--- a/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java ++++ b/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java +@@ -48,12 +_,16 @@ Collection collection = this.minecraft.player.getActiveEffects(); if (!collection.isEmpty() && j >= 32) { boolean flag = j >= 120; -+ var event = net.neoforged.neoforge.client.ClientHooks.onScreenPotionSize(this, j, !flag, i); ++ var event = net.neoforged.neoforge.client.ClientHooks.onScreenPotionSize(screen, j, !flag, i); + if (event.isCanceled()) return; + flag = !event.isCompact(); + i = event.getHorizontalOffset(); @@ -14,41 +14,40 @@ } - Iterable iterable = Ordering.natural().sortedCopy(collection); -+ + Iterable iterable = collection.stream().filter(net.neoforged.neoforge.client.ClientHooks::shouldRenderEffect).sorted().collect(java.util.stream.Collectors.toList()); - this.renderBackgrounds(p_281945_, i, k, iterable, flag); - this.renderIcons(p_281945_, i, k, iterable, flag); + this.renderBackgrounds(p_376884_, i, k, iterable, flag); + this.renderIcons(p_376884_, i, k, iterable, flag); if (flag) { -@@ -74,6 +_,8 @@ +@@ -75,6 +_,8 @@ this.getEffectName(mobeffectinstance), MobEffectUtil.formatDuration(mobeffectinstance, 1.0F, this.minecraft.level.tickRateManager().tickrate()) ); + // Neo: Allow mods to adjust the tooltip shown when hovering a mob effect. -+ list = net.neoforged.neoforge.client.ClientHooks.getEffectTooltip(this, mobeffectinstance, list); - p_281945_.renderTooltip(this.font, list, Optional.empty(), p_282601_, p_282335_); ++ list = net.neoforged.neoforge.client.ClientHooks.getEffectTooltip(screen, mobeffectinstance, list); + p_376884_.renderTooltip(this.screen.getFont(), list, Optional.empty(), p_376869_, p_376740_); } } -@@ -99,6 +_,11 @@ - int i = this.topPos; +@@ -100,6 +_,11 @@ + int i = this.screen.topPos; - for (MobEffectInstance mobeffectinstance : p_282642_) { + for (MobEffectInstance mobeffectinstance : p_376215_) { + var renderer = net.neoforged.neoforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance); -+ if (renderer.renderInventoryIcon(mobeffectinstance, this, p_282745_, p_282521_ + (p_281536_ ? 6 : 7), i, 0)) { -+ i += p_282291_; ++ if (renderer.renderInventoryIcon(mobeffectinstance, screen, p_376734_, p_376350_ + (p_376312_ ? 6 : 7), i, 0)) { ++ i += p_376678_; + continue; + } Holder holder = mobeffectinstance.getEffect(); TextureAtlasSprite textureatlassprite = mobeffecttexturemanager.get(holder); - p_282745_.blit(p_282521_ + (p_281536_ ? 6 : 7), i + 7, 0, 18, 18, textureatlassprite); -@@ -110,6 +_,11 @@ - int i = this.topPos; + p_376734_.blitSprite(RenderType::guiTextured, textureatlassprite, p_376350_ + (p_376312_ ? 6 : 7), i + 7, 18, 18); +@@ -111,6 +_,11 @@ + int i = this.screen.topPos; - for (MobEffectInstance mobeffectinstance : p_281986_) { + for (MobEffectInstance mobeffectinstance : p_376910_) { + var renderer = net.neoforged.neoforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance); -+ if (renderer.renderInventoryText(mobeffectinstance, this, p_281462_, p_283484_, i, 0)) { -+ i += p_282057_; ++ if (renderer.renderInventoryText(mobeffectinstance, screen, p_376227_, p_376372_, i, 0)) { ++ i += p_376395_; + continue; + } Component component = this.getEffectName(mobeffectinstance); - p_281462_.drawString(this.font, component, p_283484_ + 10 + 18, i + 6, 16777215); + p_376227_.drawString(this.screen.getFont(), component, p_376372_ + 10 + 18, i + 6, 16777215); Component component1 = MobEffectUtil.formatDuration(mobeffectinstance, 1.0F, this.minecraft.level.tickRateManager().tickrate()); diff --git a/patches/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch index 9e0e4bfeca..66f9e706cc 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java +++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java -@@ -115,7 +_,7 @@ +@@ -113,7 +_,7 @@ int l1 = 86 - this.font.width(s); FormattedText formattedtext = EnchantmentNames.getInstance().getRandomName(this.font, l1); int i2 = 6839882; - if ((k < l + 1 || this.minecraft.player.experienceLevel < k1) && !this.minecraft.player.getAbilities().instabuild) { + if (((k < l + 1 || this.minecraft.player.experienceLevel < k1) && !this.minecraft.player.getAbilities().instabuild) || this.menu.enchantClue[l] == -1) { // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels - RenderSystem.enableBlend(); - p_282430_.blitSprite(ENCHANTMENT_SLOT_DISABLED_SPRITE, i1, j + 14 + 19 * l, 108, 19); - p_282430_.blitSprite(DISABLED_LEVEL_SPRITES[l], i1 + 1, j + 15 + 19 * l, 16, 16); -@@ -181,13 +_,16 @@ + p_282430_.blitSprite(RenderType::guiTextured, ENCHANTMENT_SLOT_DISABLED_SPRITE, i1, j + 14 + 19 * l, 108, 19); + p_282430_.blitSprite(RenderType::guiTextured, DISABLED_LEVEL_SPRITES[l], i1 + 1, j + 15 + 19 * l, 16, 16); + p_282430_.drawWordWrap(this.font, formattedtext, j1, j + 16 + 19 * l, l1, (i2 & 16711422) >> 1); +@@ -179,13 +_,16 @@ .registryAccess() - .registryOrThrow(Registries.ENCHANTMENT) - .getHolder(this.menu.enchantClue[j]); + .lookupOrThrow(Registries.ENCHANTMENT) + .get(this.menu.enchantClue[j]); - if (!optional.isEmpty()) { + if (true) { int l = this.menu.levelClue[j]; diff --git a/patches/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch index 74155da1f7..0b4bbf6b6e 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java +++ b/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java -@@ -15,7 +_,7 @@ +@@ -16,7 +_,7 @@ private static final Vector3f TEXT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F); private static final int TEXTURE_WIDTH = 16; private static final int TEXTURE_HEIGHT = 16; diff --git a/patches/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch b/patches/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch index bca6c08814..75ffaa276e 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/MerchantScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/MerchantScreen.java +++ b/net/minecraft/client/gui/screens/inventory/MerchantScreen.java -@@ -236,7 +_,12 @@ +@@ -233,7 +_,12 @@ p_281357_.renderItemDecorations(this.font, p_283466_, p_282403_, p_283601_); } else { p_281357_.renderItemDecorations(this.font, p_282046_, p_282403_, p_283601_, p_282046_.getCount() == 1 ? "1" : null); @@ -9,8 +9,8 @@ + p_281357_.pose().pushPose(); + p_281357_.pose().translate(0.0F, 0.0F, 200.0F); + String count = p_283466_.getCount() == 1 ? "1" : String.valueOf(p_283466_.getCount()); -+ font.drawInBatch(count, (float) (p_282403_ + 14) + 19 - 2 - font.width(count), (float)p_283601_ + 6 + 3, 0xFFFFFF, true, p_281357_.pose().last().pose(), p_281357_.bufferSource(), net.minecraft.client.gui.Font.DisplayMode.NORMAL, 0, 15728880, false); ++ p_281357_.drawString(font, count, (float) (p_282403_ + 14) + 19 - 2 - font.width(count), (float)p_283601_ + 6 + 3, 0xFFFFFF, true); + p_281357_.pose().popPose(); p_281357_.pose().pushPose(); p_281357_.pose().translate(0.0F, 0.0F, 300.0F); - p_281357_.blitSprite(DISCOUNT_STRIKETHRUOGH_SPRITE, p_282403_ + 7, p_283601_ + 12, 0, 9, 2); + p_281357_.blitSprite(RenderType::guiTextured, DISCOUNT_STRIKETHRUOGH_SPRITE, p_282403_ + 7, p_283601_ + 12, 9, 2); diff --git a/patches/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch b/patches/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch index 65910b0a9d..fd3626d82c 100644 --- a/patches/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch +++ b/patches/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch @@ -1,11 +1,15 @@ --- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java +++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java -@@ -22,6 +_,8 @@ - } else if (p_169951_ instanceof ClientActivePlayersTooltip.ActivePlayersTooltip clientactiveplayerstooltip$activeplayerstooltip) { - return new ClientActivePlayersTooltip(clientactiveplayerstooltip$activeplayerstooltip); - } else { -+ ClientTooltipComponent result = net.neoforged.neoforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(p_169951_); -+ if (result != null) return result; - throw new IllegalArgumentException("Unknown TooltipComponent"); - } +@@ -25,7 +_,11 @@ + case ClientActivePlayersTooltip.ActivePlayersTooltip clientactiveplayerstooltip$activeplayerstooltip -> new ClientActivePlayersTooltip( + clientactiveplayerstooltip$activeplayerstooltip + ); +- default -> throw new IllegalArgumentException("Unknown TooltipComponent"); ++ default -> { ++ ClientTooltipComponent result = net.neoforged.neoforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(p_169951_); ++ if (result != null) yield result; ++ throw new IllegalArgumentException("Unknown TooltipComponent"); ++ } + }); } + diff --git a/patches/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java.patch b/patches/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java.patch deleted file mode 100644 index 2a218d1fac..0000000000 --- a/patches/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- a/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java -+++ b/net/minecraft/client/gui/screens/inventory/tooltip/TooltipRenderUtil.java -@@ -17,16 +_,22 @@ - private static final int BORDER_COLOR_BOTTOM = 1344798847; - - public static void renderTooltipBackground(GuiGraphics p_282666_, int p_281901_, int p_281846_, int p_281559_, int p_283336_, int p_283422_) { -+ renderTooltipBackground(p_282666_, p_281901_, p_281846_, p_281559_, p_283336_, p_283422_, BACKGROUND_COLOR, BACKGROUND_COLOR, BORDER_COLOR_TOP, BORDER_COLOR_BOTTOM); -+ } -+ -+ // Forge: Allow specifying colors for the inner border gradient and a gradient instead of a single color for the background and outer border -+ public static void renderTooltipBackground(GuiGraphics p_282666_, int p_281901_, int p_281846_, int p_281559_, int p_283336_, int p_283422_, int backgroundTop, int backgroundBottom, int borderTop, int borderBottom) -+ { - int i = p_281901_ - 3; - int j = p_281846_ - 3; - int k = p_281559_ + 3 + 3; - int l = p_283336_ + 3 + 3; -- renderHorizontalLine(p_282666_, i, j - 1, k, p_283422_, -267386864); -- renderHorizontalLine(p_282666_, i, j + l, k, p_283422_, -267386864); -- renderRectangle(p_282666_, i, j, k, l, p_283422_, -267386864); -- renderVerticalLine(p_282666_, i - 1, j, l, p_283422_, -267386864); -- renderVerticalLine(p_282666_, i + k, j, l, p_283422_, -267386864); -- renderFrameGradient(p_282666_, i, j + 1, k, l, p_283422_, 1347420415, 1344798847); -+ renderHorizontalLine(p_282666_, i, j - 1, k, p_283422_, backgroundTop); -+ renderHorizontalLine(p_282666_, i, j + l, k, p_283422_, backgroundBottom); -+ renderRectangle(p_282666_, i, j, k, l, p_283422_, backgroundTop, backgroundBottom); -+ renderVerticalLineGradient(p_282666_, i - 1, j, l, p_283422_, backgroundTop, backgroundBottom); -+ renderVerticalLineGradient(p_282666_, i + k, j, l, p_283422_, backgroundTop, backgroundBottom); -+ renderFrameGradient(p_282666_, i, j + 1, k, l, p_283422_, borderTop, borderBottom); - } - - private static void renderFrameGradient( -@@ -52,7 +_,16 @@ - p_282981_.fill(p_282028_, p_282141_, p_282028_ + p_281771_, p_282141_ + 1, p_282734_, p_281979_); - } - -+ /** -+ * @deprecated Forge: Use gradient overload instead -+ */ -+ @Deprecated - private static void renderRectangle(GuiGraphics p_281392_, int p_282294_, int p_283353_, int p_282640_, int p_281964_, int p_283211_, int p_282349_) { -- p_281392_.fill(p_282294_, p_283353_, p_282294_ + p_282640_, p_283353_ + p_281964_, p_283211_, p_282349_); -+ renderRectangle(p_281392_, p_282294_, p_283353_, p_282640_, p_281964_, p_283211_, p_282349_, p_282349_); -+ } -+ -+ // Forge: Allow specifying a gradient instead of a single color for the background -+ private static void renderRectangle(GuiGraphics p_281392_, int p_282294_, int p_283353_, int p_282640_, int p_281964_, int p_283211_, int p_282349_, int colorTo) { -+ p_281392_.fillGradient(p_282294_, p_283353_, p_282294_ + p_282640_, p_283353_ + p_281964_, p_283211_, p_282349_, colorTo); - } - } diff --git a/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch b/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch index d0f6315ff6..789a7732ae 100644 --- a/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch +++ b/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java.patch @@ -3,9 +3,9 @@ @@ -158,6 +_,7 @@ ) .build(); - this.resetButton = Button.builder(RESET_BUTTON_TITLE, p_346334_ -> { + this.resetButton = Button.builder(RESET_BUTTON_TITLE, p_359096_ -> { + this.key.setToDefault(); - KeyBindsList.this.minecraft.options.setKey(p_345998_, p_345998_.getDefaultKey()); + p_345998_.setKey(p_345998_.getDefaultKey()); KeyBindsList.this.resetMappingAndUpdateButtons(); }).bounds(0, 0, 50, 20).createNarration(p_344899_ -> Component.translatable("narrator.controls.reset", p_345196_)).build(); @@ -210,7 +_,7 @@ diff --git a/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch b/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch index 99b5c71de5..2698680313 100644 --- a/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java.patch @@ -46,13 +46,13 @@ + if (this.selectedKey != null) { + if (p_94715_ == 256) { + this.selectedKey.setKeyModifierAndCode(net.neoforged.neoforge.client.settings.KeyModifier.NONE, InputConstants.UNKNOWN); - this.options.setKey(this.selectedKey, InputConstants.UNKNOWN); + this.selectedKey.setKey(InputConstants.UNKNOWN); + lastPressedKey = InputConstants.UNKNOWN; + lastPressedModifier = InputConstants.UNKNOWN; + isLastKeyHeldDown = false; + isLastModifierHeldDown = false; } else { -- this.options.setKey(this.selectedKey, InputConstants.getKey(p_345810_, p_345447_)); +- this.selectedKey.setKey(InputConstants.getKey(p_345810_, p_345447_)); - } + var key = InputConstants.getKey(p_94715_, p_94716_); + if (lastPressedKey.equals(key)) { @@ -67,13 +67,13 @@ + net.neoforged.neoforge.client.settings.KeyModifier.getKeyModifier(lastPressedModifier), + lastPressedKey + ); -+ this.options.setKey(this.selectedKey, lastPressedKey); ++ this.selectedKey.setKey(lastPressedKey); + } else { + this.selectedKey.setKeyModifierAndCode( + net.neoforged.neoforge.client.settings.KeyModifier.NONE, + lastPressedModifier + ); -+ this.options.setKey(this.selectedKey, lastPressedModifier); ++ this.selectedKey.setKey(lastPressedModifier); + } + lastPressedKey = InputConstants.UNKNOWN; + lastPressedModifier = InputConstants.UNKNOWN; diff --git a/patches/net/minecraft/client/gui/screens/recipebook/GhostSlots.java.patch b/patches/net/minecraft/client/gui/screens/recipebook/GhostSlots.java.patch new file mode 100644 index 0000000000..126f6d6156 --- /dev/null +++ b/patches/net/minecraft/client/gui/screens/recipebook/GhostSlots.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/gui/screens/recipebook/GhostSlots.java ++++ b/net/minecraft/client/gui/screens/recipebook/GhostSlots.java +@@ -69,7 +_,7 @@ + if (ghostslots$ghostslot != null) { + ItemStack itemstack = ghostslots$ghostslot.getItem(this.slotSelectTime.currentIndex()); + p_363721_.renderComponentTooltip( +- p_365392_.font, Screen.getTooltipFromItem(p_365392_, itemstack), p_363797_, p_363310_, itemstack.get(DataComponents.TOOLTIP_STYLE) ++ p_365392_.font, Screen.getTooltipFromItem(p_365392_, itemstack), p_363797_, p_363310_, itemstack, itemstack.get(DataComponents.TOOLTIP_STYLE) + ); + } + } diff --git a/patches/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch b/patches/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch index 0eb3a5d0c1..46ae50aa8f 100644 --- a/patches/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch +++ b/patches/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java.patch @@ -1,20 +1,12 @@ --- a/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java +++ b/net/minecraft/client/gui/screens/recipebook/RecipeBookComponent.java -@@ -115,7 +_,7 @@ - this.initFilterButtonTextures(); - this.tabButtons.clear(); - -- for (RecipeBookCategories recipebookcategories : RecipeBookCategories.getCategories(this.menu.getRecipeBookType())) { -+ for(RecipeBookCategories recipebookcategories : this.menu.getRecipeBookCategories()) { - this.tabButtons.add(new RecipeBookTabButton(recipebookcategories)); - } - -@@ -297,7 +_,7 @@ - } - - if (itemstack != null && this.minecraft.screen != null) { -- p_282776_.renderComponentTooltip(this.minecraft.font, Screen.getTooltipFromItem(this.minecraft, itemstack), p_282948_, p_283050_); -+ p_282776_.renderComponentTooltip(this.minecraft.font, Screen.getTooltipFromItem(this.minecraft, itemstack), p_282948_, p_283050_, itemstack); - } - } - +@@ -268,7 +_,8 @@ + + for (RecipeBookTabButton recipebooktabbutton : this.tabButtons) { + ExtendedRecipeBookCategory extendedrecipebookcategory = recipebooktabbutton.getCategory(); +- if (extendedrecipebookcategory instanceof SearchRecipeBookCategory) { ++ // Neo: Add support for modded search categories. ++ if (extendedrecipebookcategory instanceof SearchRecipeBookCategory || net.neoforged.neoforge.client.RecipeBookManager.getSearchCategories().containsKey(extendedrecipebookcategory)) { + recipebooktabbutton.visible = true; + recipebooktabbutton.setPosition(i, j + 27 * l++); + } else if (recipebooktabbutton.updateVisibility(this.book)) { diff --git a/patches/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch b/patches/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch index 1c369de99a..55fa739634 100644 --- a/patches/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch +++ b/patches/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch @@ -1,25 +1,25 @@ --- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java +++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java -@@ -118,6 +_,7 @@ - public static void openFresh(Minecraft p_232897_, @Nullable Screen p_232898_) { - queueLoadScreen(p_232897_, PREPARING_WORLD_DATA); - PackRepository packrepository = new PackRepository(new ServerPacksSource(p_232897_.directoryValidator())); +@@ -169,6 +_,7 @@ + ) { + queueLoadScreen(p_372818_, PREPARING_WORLD_DATA); + PackRepository packrepository = new PackRepository(new ServerPacksSource(p_372818_.directoryValidator())); + net.neoforged.neoforge.resource.ResourcePackLoader.populatePackRepository(packrepository, net.minecraft.server.packs.PackType.SERVER_DATA, false); WorldLoader.InitConfig worldloader$initconfig = createDefaultLoadConfig(packrepository, WorldDataConfiguration.DEFAULT); CompletableFuture completablefuture = WorldLoader.load( worldloader$initconfig, -@@ -243,6 +_,10 @@ - WorldCreationContext worldcreationcontext = this.uiState.getSettings(); - LevelSettings levelsettings = this.createLevelSettings(flag); - WorldData worlddata = new PrimaryLevelData(levelsettings, worldcreationcontext.options(), p_250577_, p_249994_); -+ if(worlddata.worldGenSettingsLifecycle() != Lifecycle.stable()) { +@@ -307,6 +_,10 @@ + SystemToast.onPackCopyFailure(this.minecraft, s); + return false; + } else { ++ if (p_374211_.worldGenSettingsLifecycle() != Lifecycle.stable()) { + // Neo: set experimental settings confirmation flag so user is not shown warning on next open -+ ((PrimaryLevelData)worlddata).withConfirmedWarning(true); ++ ((PrimaryLevelData)p_374211_).withConfirmedWarning(true); + } this.minecraft .createWorldOpenFlows() - .createLevelFromExistingSettings(optional.get(), worldcreationcontext.dataPackResources(), p_249152_, worlddata); -@@ -428,7 +_,7 @@ + .createLevelFromExistingSettings(optional.get(), worldcreationcontext.dataPackResources(), p_249152_, p_374211_); +@@ -491,7 +_,7 @@ if (p_269627_) { p_270552_.accept(this.uiState.getSettings().dataConfiguration()); } else { @@ -28,7 +28,7 @@ } }, Component.translatable("dataPack.validation.failed"), -@@ -547,6 +_,7 @@ +@@ -605,6 +_,7 @@ if (path != null) { if (this.tempDataPackRepository == null) { this.tempDataPackRepository = ServerPacksSource.createPackRepository(path, this.packValidator); diff --git a/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch b/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch index d7e34577d4..deb2ee6006 100644 --- a/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch +++ b/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationContext.java -@@ -74,6 +_,10 @@ +@@ -95,6 +_,10 @@ ); } + public WorldCreationContext withDataConfiguration(WorldDataConfiguration dataConfiguration) { -+ return new WorldCreationContext(this.options, this.datapackDimensions, this.selectedDimensions, this.worldgenRegistries, this.dataPackResources, dataConfiguration); ++ return new WorldCreationContext(this.options, this.datapackDimensions, this.selectedDimensions, this.worldgenRegistries, this.dataPackResources, dataConfiguration, this.initialWorldCreationOptions); + } + public RegistryAccess.Frozen worldgenLoadContext() { diff --git a/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch b/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch index b1747f20d9..c362174fd4 100644 --- a/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch +++ b/patches/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java -@@ -225,7 +_,7 @@ +@@ -236,7 +_,7 @@ @Nullable public PresetEditor getPresetEditor() { Holder holder = this.getWorldType().preset(); diff --git a/patches/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch b/patches/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch index 9dc24fd572..37bde45b2d 100644 --- a/patches/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch +++ b/patches/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java -@@ -65,7 +_,7 @@ +@@ -66,7 +_,7 @@ import org.slf4j.Logger; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final UUID WORLD_PACK_ID = UUID.fromString("640a6a92-b6cb-48a0-b391-831586500359"); private final Minecraft minecraft; -@@ -210,7 +_,10 @@ +@@ -215,7 +_,10 @@ component1 = Component.translatable("selectWorld.backupWarning.customized"); } else { component = Component.translatable("selectWorld.backupQuestion.experimental"); @@ -21,7 +21,7 @@ } this.minecraft.setScreen(new BackupConfirmScreen(p_307323_, (p_307085_, p_307086_) -> { -@@ -377,10 +_,19 @@ +@@ -381,10 +_,19 @@ WorldData worlddata = p_330774_.worldData(); boolean flag = worlddata.worldGenOptions().isOldCustomizedWorld(); boolean flag1 = worlddata.worldGenSettingsLifecycle() != Lifecycle.stable(); diff --git a/patches/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch b/patches/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch index 93857dce7b..bd2c7fd8b2 100644 --- a/patches/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch +++ b/patches/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java.patch @@ -8,15 +8,15 @@ static final Logger LOGGER = LogUtils.getLogger(); static final Component FROM_NEWER_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.fromNewerVersion1").withStyle(ChatFormatting.RED); static final Component FROM_NEWER_TOOLTIP_2 = Component.translatable("selectWorld.tooltip.fromNewerVersion2").withStyle(ChatFormatting.RED); -@@ -405,6 +_,7 @@ - RenderSystem.enableBlend(); - p_281612_.blit(this.icon.textureLocation(), p_282820_, p_283181_, 0.0F, 0.0F, 32, 32, 32, 32); - RenderSystem.disableBlend(); +@@ -403,6 +_,7 @@ + p_281612_.drawString(this.minecraft.font, s1, p_282820_ + 32 + 3, p_283181_ + 9 + 3, -8355712, false); + p_281612_.drawString(this.minecraft.font, component, p_282820_ + 32 + 3, p_283181_ + 9 + 9 + 3, -8355712, false); + p_281612_.blit(RenderType::guiTextured, this.icon.textureLocation(), p_282820_, p_283181_, 0.0F, 0.0F, 32, 32, 32, 32); + renderExperimentalWarning(p_281612_, p_283204_, p_283025_, p_283181_, p_282820_); if (this.minecraft.options.touchscreen().get() || p_283396_) { p_281612_.fill(p_282820_, p_283181_, p_282820_ + 32, p_283181_ + 32, -1601138544); int j = p_283204_ - p_282820_; -@@ -511,6 +_,7 @@ +@@ -509,6 +_,7 @@ this.doDeleteWorld(); } @@ -24,7 +24,7 @@ this.minecraft.setScreen(this.screen); }, Component.translatable("selectWorld.deleteQuestion"), -@@ -647,6 +_,19 @@ +@@ -645,6 +_,19 @@ public String getLevelName() { return this.summary.getLevelName(); @@ -34,7 +34,7 @@ + private void renderExperimentalWarning(GuiGraphics guiGraphics, int mouseX, int mouseY, int top, int left) { + if (this.summary.getSettings() != null && this.summary.getSettings().getLifecycle().equals(com.mojang.serialization.Lifecycle.experimental())) { + int leftStart = left + WorldSelectionList.this.getRowWidth(); -+ guiGraphics.blit(WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32); ++ guiGraphics.blit(RenderType::guiTextured, WorldSelectionList.FORGE_EXPERIMENTAL_WARNING_ICON, leftStart - 36, top, 0.0F, 0.0F, 32, 32, 32, 32); + if (WorldSelectionList.this.getEntryAtPosition(mouseX, mouseY) == this && mouseX > leftStart - 36 && mouseX < leftStart) { + var font = Minecraft.getInstance().font; + List tooltip = font.split(Component.translatable("neoforge.experimentalsettings.tooltip"), 200); diff --git a/patches/net/minecraft/client/main/Main.java.patch b/patches/net/minecraft/client/main/Main.java.patch index 4f5d0f090e..c66fe4ba49 100644 --- a/patches/net/minecraft/client/main/Main.java.patch +++ b/patches/net/minecraft/client/main/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/main/Main.java +++ b/net/minecraft/client/main/Main.java -@@ -111,7 +_,7 @@ +@@ -120,7 +_,7 @@ CrashReport.preload(); logger = LogUtils.getLogger(); s1 = "Bootstrap"; diff --git a/patches/net/minecraft/client/model/HumanoidModel.java.patch b/patches/net/minecraft/client/model/HumanoidModel.java.patch index b067ead7de..5d2e521e41 100644 --- a/patches/net/minecraft/client/model/HumanoidModel.java.patch +++ b/patches/net/minecraft/client/model/HumanoidModel.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/client/model/HumanoidModel.java +++ b/net/minecraft/client/model/HumanoidModel.java -@@ -306,6 +_,8 @@ +@@ -257,6 +_,8 @@ case BRUSH: this.rightArm.xRot = this.rightArm.xRot * 0.5F - (float) (Math.PI / 5); this.rightArm.yRot = 0.0F; + default: -+ this.rightArmPose.applyTransform(this, p_102876_, net.minecraft.world.entity.HumanoidArm.RIGHT); ++ p_362238_.applyTransform(this, p_364666_, net.minecraft.world.entity.HumanoidArm.RIGHT); } } -@@ -348,6 +_,8 @@ +@@ -299,6 +_,8 @@ case BRUSH: this.leftArm.xRot = this.leftArm.xRot * 0.5F - (float) (Math.PI / 5); this.leftArm.yRot = 0.0F; + default: -+ this.leftArmPose.applyTransform(this, p_102879_, net.minecraft.world.entity.HumanoidArm.LEFT); ++ p_361463_.applyTransform(this, p_361741_, net.minecraft.world.entity.HumanoidArm.LEFT); } } -@@ -446,7 +_,7 @@ +@@ -376,7 +_,7 @@ } @OnlyIn(Dist.CLIENT) @@ -27,7 +27,7 @@ EMPTY(false), ITEM(false), BLOCK(false), -@@ -459,13 +_,31 @@ +@@ -389,13 +_,31 @@ BRUSH(false); private final boolean twoHanded; @@ -50,7 +50,7 @@ return this.twoHanded; + } + -+ public void applyTransform(HumanoidModel model, T entity, net.minecraft.world.entity.HumanoidArm arm) { ++ public void applyTransform(HumanoidModel model, T entity, net.minecraft.world.entity.HumanoidArm arm) { + if (this.forgeArmPose != null) this.forgeArmPose.applyTransform(model, entity, arm); + } + diff --git a/patches/net/minecraft/client/model/HierarchicalModel.java.patch b/patches/net/minecraft/client/model/Model.java.patch similarity index 52% rename from patches/net/minecraft/client/model/HierarchicalModel.java.patch rename to patches/net/minecraft/client/model/Model.java.patch index b9e5a58ff6..8dfabd2621 100644 --- a/patches/net/minecraft/client/model/HierarchicalModel.java.patch +++ b/patches/net/minecraft/client/model/Model.java.patch @@ -1,48 +1,51 @@ ---- a/net/minecraft/client/model/HierarchicalModel.java -+++ b/net/minecraft/client/model/HierarchicalModel.java -@@ -27,6 +_,10 @@ - super(p_170623_); +--- a/net/minecraft/client/model/Model.java ++++ b/net/minecraft/client/model/Model.java +@@ -28,6 +_,10 @@ + this.allParts = p_368583_.getAllParts().toList(); } + protected static net.neoforged.neoforge.client.entity.animation.json.AnimationHolder getAnimation(ResourceLocation key) { + return net.neoforged.neoforge.client.entity.animation.json.AnimationLoader.INSTANCE.getAnimationHolder(key); + } + - @Override - public void renderToBuffer(PoseStack p_170625_, VertexConsumer p_170626_, int p_170627_, int p_170628_, int p_350603_) { - this.root().render(p_170625_, p_170626_, p_170627_, p_170628_, p_350603_); -@@ -44,18 +_,34 @@ - this.animate(p_233382_, p_233383_, p_233384_, 1.0F); + public final RenderType renderType(ResourceLocation p_103120_) { + return this.renderType.apply(p_103120_); + } +@@ -64,12 +_,20 @@ + this.animate(p_364820_, p_361968_, p_362503_, 1.0F); } + protected void animate(AnimationState animationState, net.neoforged.neoforge.client.entity.animation.json.AnimationHolder animation, float ageInTicks) { + this.animate(animationState, animation.get(), ageInTicks); + } + - protected void animateWalk(AnimationDefinition p_268159_, float p_268057_, float p_268347_, float p_268138_, float p_268165_) { - long i = (long)(p_268057_ * 50.0F * p_268138_); - float f = Math.min(p_268347_ * p_268165_, 1.0F); - KeyframeAnimations.animate(this, p_268159_, i, f, ANIMATION_VECTOR_CACHE); + protected void animateWalk(AnimationDefinition p_362453_, float p_365353_, float p_364840_, float p_362983_, float p_361956_) { + long i = (long)(p_365353_ * 50.0F * p_362983_); + float f = Math.min(p_364840_ * p_361956_, 1.0F); + KeyframeAnimations.animate(this, p_362453_, i, f, ANIMATION_VECTOR_CACHE); } + protected void animateWalk(net.neoforged.neoforge.client.entity.animation.json.AnimationHolder animation, float limbSwing, float limbSwingAmount, float maxAnimationSpeed, float animationScaleFactor) { + this.animateWalk(animation.get(), limbSwing, limbSwingAmount, maxAnimationSpeed, animationScaleFactor); + } + - protected void animate(AnimationState p_233386_, AnimationDefinition p_233387_, float p_233388_, float p_233389_) { - p_233386_.updateTime(p_233388_, p_233389_); - p_233386_.ifStarted(p_233392_ -> KeyframeAnimations.animate(this, p_233387_, p_233392_.getAccumulatedTime(), 1.0F, ANIMATION_VECTOR_CACHE)); + protected void animate(AnimationState p_364413_, AnimationDefinition p_361459_, float p_361947_, float p_362164_) { + p_364413_.ifStarted( + p_361743_ -> KeyframeAnimations.animate( +@@ -78,8 +_,16 @@ + ); } + protected void animate(AnimationState animationState, net.neoforged.neoforge.client.entity.animation.json.AnimationHolder animation, float ageInTicks, float speed) { + this.animate(animationState, animation.get(), ageInTicks, speed); + } + - protected void applyStatic(AnimationDefinition p_288996_) { - KeyframeAnimations.animate(this, p_288996_, 0L, 1.0F, ANIMATION_VECTOR_CACHE); + protected void applyStatic(AnimationDefinition p_362055_) { + KeyframeAnimations.animate(this, p_362055_, 0L, 1.0F, ANIMATION_VECTOR_CACHE); + } + + protected void applyStatic(net.neoforged.neoforge.client.entity.animation.json.AnimationHolder animation) { + this.applyStatic(animation.get()); } - } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/net/minecraft/client/model/geom/LayerDefinitions.java.patch b/patches/net/minecraft/client/model/geom/LayerDefinitions.java.patch index 2bb68d9584..de5171aeea 100644 --- a/patches/net/minecraft/client/model/geom/LayerDefinitions.java.patch +++ b/patches/net/minecraft/client/model/geom/LayerDefinitions.java.patch @@ -1,18 +1,9 @@ --- a/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java -@@ -316,7 +_,7 @@ - LayerDefinition layerdefinition22 = ChestRaftModel.createBodyModel(); - - for (Boat.Type boat$type : Boat.Type.values()) { -- if (boat$type == Boat.Type.BAMBOO) { -+ if (boat$type.isRaft()) { - builder.put(ModelLayers.createBoatModelName(boat$type), layerdefinition21); - builder.put(ModelLayers.createChestBoatModelName(boat$type), layerdefinition22); - } else { -@@ -329,6 +_,7 @@ - WoodType.values().forEach(p_171114_ -> builder.put(ModelLayers.createSignModelName(p_171114_), layerdefinition23)); - LayerDefinition layerdefinition24 = HangingSignRenderer.createHangingSignLayer(); - WoodType.values().forEach(p_247864_ -> builder.put(ModelLayers.createHangingSignModelName(p_247864_), layerdefinition24)); +@@ -454,6 +_,7 @@ + builder.put(ModelLayers.createWallSignModelName(p_359128_), layerdefinition54); + builder.put(ModelLayers.createHangingSignModelName(p_359128_), layerdefinition55); + }); + net.neoforged.neoforge.client.ClientHooks.loadLayerDefinitions(builder); ImmutableMap immutablemap = builder.build(); List list = ModelLayers.getKnownLocations().filter(p_171117_ -> !immutablemap.containsKey(p_171117_)).collect(Collectors.toList()); diff --git a/patches/net/minecraft/client/model/geom/ModelLayers.java.patch b/patches/net/minecraft/client/model/geom/ModelLayers.java.patch index cbb66bf895..9b9691073a 100644 --- a/patches/net/minecraft/client/model/geom/ModelLayers.java.patch +++ b/patches/net/minecraft/client/model/geom/ModelLayers.java.patch @@ -1,36 +1,18 @@ --- a/net/minecraft/client/model/geom/ModelLayers.java +++ b/net/minecraft/client/model/geom/ModelLayers.java -@@ -213,27 +_,33 @@ +@@ -301,15 +_,18 @@ } - public static ModelLayerLocation createRaftModelName(Boat.Type p_252002_) { -- return createLocation("raft/" + p_252002_.getName(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_252002_.getName()); -+ return new ModelLayerLocation(location.withPrefix("raft/"), "main"); - } - - public static ModelLayerLocation createChestRaftModelName(Boat.Type p_248520_) { -- return createLocation("chest_raft/" + p_248520_.getName(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_248520_.getName()); -+ return new ModelLayerLocation(location.withPrefix("chest_raft/"), "main"); - } - - public static ModelLayerLocation createBoatModelName(Boat.Type p_171290_) { -- return createLocation("boat/" + p_171290_.getName(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_171290_.getName()); -+ return new ModelLayerLocation(location.withPrefix("boat/"), "main"); - } - - public static ModelLayerLocation createChestBoatModelName(Boat.Type p_233551_) { -- return createLocation("chest_boat/" + p_233551_.getName(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_233551_.getName()); -+ return new ModelLayerLocation(location.withPrefix("chest_boat/"), "main"); + public static ModelLayerLocation createStandingSignModelName(WoodType p_171292_) { +- return createLocation("sign/standing/" + p_171292_.name(), "main"); ++ ResourceLocation location = ResourceLocation.parse(p_171292_.name()); ++ return new ModelLayerLocation(location.withPrefix("sign/standing/"), "main"); } - public static ModelLayerLocation createSignModelName(WoodType p_171292_) { -- return createLocation("sign/" + p_171292_.name(), "main"); -+ ResourceLocation location = ResourceLocation.parse(p_171292_.name()); -+ return new ModelLayerLocation(location.withPrefix("sign/"), "main"); + public static ModelLayerLocation createWallSignModelName(WoodType p_360963_) { +- return createLocation("sign/wall/" + p_360963_.name(), "main"); ++ ResourceLocation location = ResourceLocation.parse(p_360963_.name()); ++ return new ModelLayerLocation(location.withPrefix("sign/wall/"), "main"); } public static ModelLayerLocation createHangingSignModelName(WoodType p_252225_) { diff --git a/patches/net/minecraft/client/multiplayer/ClientChunkCache.java.patch b/patches/net/minecraft/client/multiplayer/ClientChunkCache.java.patch index 8729039cea..768dd4d9eb 100644 --- a/patches/net/minecraft/client/multiplayer/ClientChunkCache.java.patch +++ b/patches/net/minecraft/client/multiplayer/ClientChunkCache.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/multiplayer/ClientChunkCache.java +++ b/net/minecraft/client/multiplayer/ClientChunkCache.java -@@ -63,6 +_,7 @@ +@@ -65,6 +_,7 @@ int i = this.storage.getIndex(p_295783_.x, p_295783_.z); LevelChunk levelchunk = this.storage.getChunk(i); if (isValidChunk(levelchunk, p_295783_.x, p_295783_.z)) { + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkEvent.Unload(levelchunk)); - this.storage.replace(i, levelchunk, null); + this.storage.drop(i, levelchunk); } } -@@ -123,6 +_,7 @@ +@@ -125,6 +_,7 @@ } this.level.onChunkLoaded(chunkpos); diff --git a/patches/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch b/patches/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch index 8bc8fe4f9c..0cafb8a7b2 100644 --- a/patches/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch +++ b/patches/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientCommonPacketListenerImpl.java -@@ -88,6 +_,10 @@ +@@ -84,6 +_,10 @@ protected final Map serverCookies; protected Map customReportDetails; protected ServerLinks serverLinks; @@ -11,8 +11,8 @@ protected ClientCommonPacketListenerImpl(Minecraft p_295454_, Connection p_294773_, CommonListenerCookie p_294647_) { this.minecraft = p_295454_; -@@ -100,6 +_,8 @@ - this.strictErrorHandling = p_294647_.strictErrorHandling(); +@@ -95,6 +_,8 @@ + this.serverCookies = p_294647_.serverCookies(); this.customReportDetails = p_294647_.customReportDetails(); this.serverLinks = p_294647_.serverLinks(); + // Neo: Set the connection type based on the cookie from the previous phase. @@ -20,7 +20,7 @@ } @Override -@@ -149,6 +_,33 @@ +@@ -142,6 +_,33 @@ @Override public void handleCustomPayload(ClientboundCustomPayloadPacket p_295727_) { @@ -54,7 +54,7 @@ CustomPacketPayload custompacketpayload = p_295727_.payload(); if (!(custompacketpayload instanceof DiscardedPayload)) { PacketUtils.ensureRunningOnSameThread(p_295727_, this, this.minecraft); -@@ -285,6 +_,8 @@ +@@ -278,6 +_,8 @@ } public void send(Packet p_295097_) { @@ -63,7 +63,7 @@ this.connection.send(p_295097_); } -@@ -292,6 +_,9 @@ +@@ -285,6 +_,9 @@ public void onDisconnect(DisconnectionDetails p_350760_) { this.telemetryManager.onDisconnect(); this.minecraft.disconnect(this.createDisconnectScreen(p_350760_), this.isTransferring); @@ -73,7 +73,7 @@ LOGGER.warn("Client disconnected with reason: {}", p_350760_.reason().getString()); } -@@ -415,5 +_,10 @@ +@@ -409,5 +_,10 @@ @OnlyIn(Dist.CLIENT) static record PendingRequest(UUID id, URL url, String hash) { } diff --git a/patches/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch b/patches/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch index 5f8469c35d..d26216aa13 100644 --- a/patches/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch +++ b/patches/net/minecraft/client/multiplayer/ClientConfigurationPacketListenerImpl.java.patch @@ -31,9 +31,9 @@ new ClientPacketListener( this.minecraft, this.connection, -@@ -137,12 +_,19 @@ +@@ -136,12 +_,19 @@ + this.serverCookies, this.chatState, - this.strictErrorHandling, this.customReportDetails, - this.serverLinks + this.serverLinks, @@ -53,7 +53,7 @@ } @Override -@@ -154,5 +_,51 @@ +@@ -153,5 +_,51 @@ public void onDisconnect(DisconnectionDetails p_351005_) { super.onDisconnect(p_351005_); this.minecraft.clearDownloadedResourcePacks(); diff --git a/patches/net/minecraft/client/multiplayer/ClientLevel.java.patch b/patches/net/minecraft/client/multiplayer/ClientLevel.java.patch index e3eabb22b7..a1d3332be3 100644 --- a/patches/net/minecraft/client/multiplayer/ClientLevel.java.patch +++ b/patches/net/minecraft/client/multiplayer/ClientLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientLevel.java +++ b/net/minecraft/client/multiplayer/ClientLevel.java -@@ -121,6 +_,7 @@ +@@ -126,6 +_,7 @@ p_194170_.put( BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(p_194168_ -> this.calculateBlockTint(p_194168_, BiomeColors.WATER_COLOR_RESOLVER)) ); @@ -8,16 +8,16 @@ } ); private final ClientChunkCache chunkSource; -@@ -128,6 +_,8 @@ - private int serverSimulationDistance; - private final BlockStatePredictionHandler blockStatePredictionHandler = new BlockStatePredictionHandler(); +@@ -135,6 +_,8 @@ + private final int seaLevel; + private boolean tickDayTime; private static final Set MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT); + private final it.unimi.dsi.fastutil.ints.Int2ObjectMap> partEntities = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>(); + private final net.neoforged.neoforge.client.model.data.ModelDataManager modelDataManager = new net.neoforged.neoforge.client.model.data.ModelDataManager(this); public void handleBlockChangedAck(int p_233652_) { this.blockStatePredictionHandler.endPredictionsUpTo(p_233652_, this); -@@ -157,10 +_,15 @@ +@@ -164,10 +_,15 @@ @Override public boolean setBlock(BlockPos p_233643_, BlockState p_233644_, int p_233645_, int p_233646_) { if (this.blockStatePredictionHandler.isPredicting()) { @@ -33,37 +33,37 @@ } return flag; -@@ -192,6 +_,7 @@ - this.serverSimulationDistance = p_205510_; +@@ -201,6 +_,7 @@ + this.serverSimulationDistance = p_363776_; this.updateSkyBrightness(); this.prepareWeather(); + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.LevelEvent.Load(this)); } public void queueLightUpdate(Runnable p_194172_) { -@@ -238,7 +_,7 @@ +@@ -244,7 +_,7 @@ private void tickTime() { - this.setGameTime(this.levelData.getGameTime() + 1L); - if (this.levelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { -- this.setDayTime(this.levelData.getDayTime() + 1L); -+ this.setDayTime(this.levelData.getDayTime() + advanceDaytime()); + this.clientLevelData.setGameTime(this.clientLevelData.getGameTime() + 1L); + if (this.tickDayTime) { +- this.clientLevelData.setDayTime(this.clientLevelData.getDayTime() + 1L); ++ this.clientLevelData.setDayTime(this.clientLevelData.getDayTime() + advanceDaytime()); } } -@@ -282,7 +_,11 @@ +@@ -283,7 +_,11 @@ p_104640_.setOldPosAndRot(); p_104640_.tickCount++; - this.getProfiler().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString()); + Profiler.get().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString()); - p_104640_.tick(); + // Neo: Permit cancellation of Entity#tick via EntityTickEvent.Pre + if (!net.neoforged.neoforge.event.EventHooks.fireEntityTickPre(p_104640_).isCanceled()) { + p_104640_.tick(); + net.neoforged.neoforge.event.EventHooks.fireEntityTickPost(p_104640_); + } - this.getProfiler().pop(); + Profiler.get().pop(); for (Entity entity : p_104640_.getPassengers()) { -@@ -330,8 +_,10 @@ +@@ -335,8 +_,10 @@ } public void addEntity(Entity p_104741_) { @@ -74,7 +74,7 @@ } public void removeEntity(int p_171643_, Entity.RemovalReason p_171644_) { -@@ -502,6 +_,13 @@ +@@ -507,6 +_,13 @@ float p_263349_, long p_263408_ ) { @@ -88,7 +88,7 @@ if (p_263381_ == this.minecraft.player) { this.playSound(p_263372_, p_263404_, p_263365_, p_263335_.value(), p_263417_, p_263416_, p_263349_, false, p_263408_); } -@@ -511,6 +_,12 @@ +@@ -516,6 +_,12 @@ public void playSeededSound( @Nullable Player p_263514_, Entity p_263536_, Holder p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_ ) { @@ -101,7 +101,7 @@ if (p_263514_ == this.minecraft.player) { this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_263518_.value(), p_263487_, p_263538_, p_263524_, p_263536_, p_263509_)); } -@@ -1033,6 +_,7 @@ +@@ -1045,6 +_,7 @@ } public void setDifficulty(Difficulty p_104852_) { @@ -109,7 +109,7 @@ this.difficulty = p_104852_; } -@@ -1069,14 +_,75 @@ +@@ -1081,14 +_,75 @@ if (p_171712_ instanceof AbstractClientPlayer) { ClientLevel.this.players.add((AbstractClientPlayer)p_171712_); } diff --git a/patches/net/minecraft/client/multiplayer/ClientPacketListener.java.patch b/patches/net/minecraft/client/multiplayer/ClientPacketListener.java.patch index c244326521..a1ad4df3f6 100644 --- a/patches/net/minecraft/client/multiplayer/ClientPacketListener.java.patch +++ b/patches/net/minecraft/client/multiplayer/ClientPacketListener.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientPacketListener.java +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java -@@ -344,6 +_,7 @@ +@@ -367,6 +_,7 @@ private final ChunkBatchSizeCalculator chunkBatchSizeCalculator = new ChunkBatchSizeCalculator(); private final PingDebugMonitor pingDebugMonitor; private final DebugSampleSubscriber debugSampleSubscriber; @@ -8,17 +8,17 @@ @Nullable private LevelLoadStatusManager levelLoadStatusManager; private boolean serverEnforcesSecureChat; -@@ -366,7 +_,8 @@ +@@ -388,7 +_,8 @@ p_253924_.gui.getChat().restoreState(p_295121_.chatState()); } - this.potionBrewing = PotionBrewing.bootstrap(this.enabledFeatures); + this.connectionType = p_295121_.connectionType(); + this.potionBrewing = PotionBrewing.bootstrap(this.enabledFeatures, this.registryAccess); + this.fuelValues = FuelValues.vanillaBurnTimes(p_295121_.receivedRegistries(), this.enabledFeatures); } - public ClientSuggestionProvider getSuggestionsProvider() { -@@ -427,12 +_,13 @@ +@@ -451,12 +_,13 @@ this.minecraft.debugRenderer.clear(); this.minecraft.player.resetPos(); @@ -33,9 +33,9 @@ this.minecraft.player.setReducedDebugInfo(p_105030_.reducedDebugInfo()); this.minecraft.player.setShowDeathScreen(p_105030_.showDeathScreen()); this.minecraft.player.setDoLimitedCrafting(p_105030_.doLimitedCrafting()); -@@ -828,7 +_,8 @@ +@@ -900,7 +_,8 @@ + this.serverCookies, chatcomponent$state, - this.strictErrorHandling, this.customReportDetails, - this.serverLinks + this.serverLinks, @@ -43,7 +43,7 @@ ) ) ); -@@ -1142,7 +_,7 @@ +@@ -1217,7 +_,7 @@ localplayer1 = this.minecraft.gameMode.createPlayer(this.level, localplayer.getStats(), localplayer.getRecipeBook()); } @@ -52,15 +52,15 @@ localplayer1.setId(localplayer.getId()); this.minecraft.player = localplayer1; if (flag) { -@@ -1164,6 +_,7 @@ +@@ -1245,6 +_,7 @@ + localplayer1.getAttributes().assignBaseValues(localplayer.getAttributes()); } - localplayer1.resetPos(); + net.neoforged.neoforge.client.ClientHooks.firePlayerRespawn(this.minecraft.gameMode, localplayer, localplayer1, localplayer1.connection.connection); this.level.addEntity(localplayer1); - localplayer1.setYRot(-180.0F); localplayer1.input = new KeyboardInput(this.minecraft.options); -@@ -1306,10 +_,7 @@ + this.minecraft.gameMode.adjustPlayer(localplayer1); +@@ -1391,10 +_,7 @@ PacketUtils.ensureRunningOnSameThread(p_104976_, this, this.minecraft); BlockPos blockpos = p_104976_.getPos(); this.minecraft.level.getBlockEntity(blockpos, p_104976_.getType()).ifPresent(p_337415_ -> { @@ -72,7 +72,7 @@ if (p_337415_ instanceof CommandBlockEntity && this.minecraft.screen instanceof CommandBlockEditScreen) { ((CommandBlockEditScreen)this.minecraft.screen).updateGui(); -@@ -1420,9 +_,15 @@ +@@ -1505,9 +_,15 @@ } } @@ -89,7 +89,7 @@ } @Override -@@ -1471,7 +_,9 @@ +@@ -1555,7 +_,9 @@ @Override public void handleCommands(ClientboundCommandsPacket p_104990_) { PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft); @@ -100,28 +100,33 @@ } @Override -@@ -1493,6 +_,7 @@ - ClientRecipeBook clientrecipebook = this.minecraft.player.getRecipeBook(); - clientrecipebook.setupCollections(this.recipeManager.getOrderedRecipes(), this.minecraft.level.registryAccess()); - this.searchTrees.updateRecipes(clientrecipebook, this.registryAccess); -+ net.neoforged.neoforge.client.ClientHooks.onRecipesUpdated(this.recipeManager); +@@ -1574,6 +_,11 @@ + public void handleUpdateRecipes(ClientboundUpdateRecipesPacket p_105132_) { + PacketUtils.ensureRunningOnSameThread(p_105132_, this, this.minecraft); + this.recipes = new ClientRecipeContainer(p_105132_.itemSets(), p_105132_.stonecutterRecipes()); ++ ++ // Neo: abuse recipe sync to overwrite fuel values with datamap values after their sync (tag update doesn't fire on initial sync and the constructor is too early) ++ if (this.connectionType.isNeoForge()) { ++ this.fuelValues = net.neoforged.neoforge.common.DataMapHooks.populateFuelValues(this.registryAccess, this.enabledFeatures); ++ } } @Override -@@ -1595,8 +_,10 @@ - TagCollector tagcollector = new TagCollector(); - p_294888_.getTags().forEach(tagcollector::append); - tagcollector.updateTags(this.registryAccess, this.connection.isMemoryConnection()); -- List list = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); -- this.searchTrees.updateCreativeTags(list); +@@ -1698,8 +_,11 @@ + }); + list.forEach(Registry.PendingTags::apply); + this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures); +- List list1 = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); +- this.searchTrees.updateCreativeTags(list1); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.TagsUpdatedEvent(this.registryAccess, true, flag)); + CreativeModeTabs.allTabs().stream().filter(net.minecraft.world.item.CreativeModeTab::hasSearchBar).forEach(tab -> { -+ List list = List.copyOf(tab.getDisplayItems()); -+ this.searchTrees.updateCreativeTags(list, net.neoforged.neoforge.client.CreativeModeTabSearchRegistry.getTagSearchKey(tab)); ++ List stacks = List.copyOf(tab.getDisplayItems()); ++ this.searchTrees.updateCreativeTags(stacks, net.neoforged.neoforge.client.CreativeModeTabSearchRegistry.getTagSearchKey(tab)); + }); } @Override -@@ -2407,6 +_,8 @@ +@@ -2526,6 +_,8 @@ } public void sendChat(String p_249888_) { @@ -130,7 +135,7 @@ Instant instant = Instant.now(); long i = Crypt.SaltSupplier.getLong(); LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.lastSeenMessages.generateAndApplyUpdate(); -@@ -2416,6 +_,7 @@ +@@ -2535,6 +_,7 @@ } public void sendCommand(String p_250092_) { @@ -138,7 +143,7 @@ SignableCommand signablecommand = SignableCommand.of(this.parseCommand(p_250092_)); if (signablecommand.arguments().isEmpty()) { this.send(new ServerboundChatCommandPacket(p_250092_)); -@@ -2490,6 +_,10 @@ +@@ -2622,6 +_,10 @@ public Scoreboard scoreboard() { return this.scoreboard; diff --git a/patches/net/minecraft/client/multiplayer/CommonListenerCookie.java.patch b/patches/net/minecraft/client/multiplayer/CommonListenerCookie.java.patch index 40db5789ae..da0f788ed2 100644 --- a/patches/net/minecraft/client/multiplayer/CommonListenerCookie.java.patch +++ b/patches/net/minecraft/client/multiplayer/CommonListenerCookie.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/multiplayer/CommonListenerCookie.java +++ b/net/minecraft/client/multiplayer/CommonListenerCookie.java -@@ -26,6 +_,28 @@ +@@ -25,6 +_,27 @@ + Map serverCookies, @Nullable ChatComponent.State chatState, - @Deprecated(forRemoval = true) boolean strictErrorHandling, Map customReportDetails, - ServerLinks serverLinks + ServerLinks serverLinks, + net.neoforged.neoforge.network.connection.ConnectionType connectionType ) { + /** -+ * @deprecated Use {@link #CommonListenerCookie(GameProfile, WorldSessionTelemetryManager, RegistryAccess.Frozen, FeatureFlagSet, String, ServerData, Screen, Map, ChatComponent.State, boolean, Map, ServerLinks, net.neoforged.neoforge.network.connection.ConnectionType)} ++ * @deprecated Use {@link #CommonListenerCookie(GameProfile, WorldSessionTelemetryManager, RegistryAccess.Frozen, FeatureFlagSet, String, ServerData, Screen, Map, ChatComponent.State, Map, ServerLinks, net.neoforged.neoforge.network.connection.ConnectionType)} + * instead,to indicate whether the connection is modded. + */ + @Deprecated @@ -23,10 +23,9 @@ + @Nullable Screen postDisconnectScreen, + Map serverCookies, + @Nullable ChatComponent.State chatState, -+ @Deprecated(forRemoval = true) boolean strictErrorHandling, + Map customReportDetails, + ServerLinks serverLinks + ) { -+ this(localGameProfile, telemetryManager, receivedRegistries, enabledFeatures, serverBrand, serverData, postDisconnectScreen, serverCookies, chatState, strictErrorHandling, customReportDetails, serverLinks, net.neoforged.neoforge.network.connection.ConnectionType.OTHER); ++ this(localGameProfile, telemetryManager, receivedRegistries, enabledFeatures, serverBrand, serverData, postDisconnectScreen, serverCookies, chatState, customReportDetails, serverLinks, net.neoforged.neoforge.network.connection.ConnectionType.OTHER); + } } diff --git a/patches/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch b/patches/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch index 40bda7642f..4a88a77d66 100644 --- a/patches/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch +++ b/patches/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java +++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java -@@ -119,11 +_,12 @@ +@@ -120,11 +_,12 @@ } else if (blockstate.isAir()) { return false; } else { @@ -15,7 +15,7 @@ } return flag; -@@ -142,6 +_,7 @@ +@@ -143,6 +_,7 @@ BlockState blockstate = this.minecraft.level.getBlockState(p_105270_); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate, 1.0F); this.startPrediction(this.minecraft.level, p_233757_ -> { @@ -23,7 +23,7 @@ this.destroyBlock(p_105270_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233757_); }); -@@ -151,15 +_,19 @@ +@@ -152,15 +_,19 @@ this.connection .send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, p_105271_)); } @@ -43,7 +43,7 @@ if (flag && blockstate1.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105270_) >= 1.0F) { this.destroyBlock(p_105270_); } else { -@@ -171,7 +_,7 @@ +@@ -172,7 +_,7 @@ this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage()); } @@ -52,7 +52,7 @@ }); } -@@ -202,6 +_,7 @@ +@@ -203,6 +_,7 @@ BlockState blockstate1 = this.minecraft.level.getBlockState(p_105284_); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate1, 1.0F); this.startPrediction(this.minecraft.level, p_233753_ -> { @@ -60,7 +60,7 @@ this.destroyBlock(p_105284_); return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_, p_233753_); }); -@@ -214,7 +_,7 @@ +@@ -215,7 +_,7 @@ } else { this.destroyProgress = this.destroyProgress + blockstate.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105284_); if (this.destroyTicks % 4.0F == 0.0F) { @@ -69,7 +69,7 @@ this.minecraft .getSoundManager() .play( -@@ -231,6 +_,7 @@ +@@ -232,6 +_,7 @@ this.destroyTicks++; this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate, Mth.clamp(this.destroyProgress, 0.0F, 1.0F)); @@ -77,7 +77,7 @@ if (this.destroyProgress >= 1.0F) { this.isDestroying = false; this.startPrediction(this.minecraft.level, p_233739_ -> { -@@ -269,7 +_,7 @@ +@@ -270,7 +_,7 @@ private boolean sameDestroyTarget(BlockPos p_105282_) { ItemStack itemstack = this.minecraft.player.getMainHandItem(); @@ -86,7 +86,7 @@ } private void ensureHasSentCarriedItem() { -@@ -297,12 +_,23 @@ +@@ -298,12 +_,23 @@ private InteractionResult performUseItemOn(LocalPlayer p_233747_, InteractionHand p_233748_, BlockHitResult p_233749_) { BlockPos blockpos = p_233749_.getBlockPos(); ItemStack itemstack = p_233747_.getItemInHand(p_233748_); @@ -95,7 +95,7 @@ + return event.getCancellationResult(); + } if (this.localPlayerMode == GameType.SPECTATOR) { - return InteractionResult.SUCCESS; + return InteractionResult.CONSUME; } else { - boolean flag = !p_233747_.getMainHandItem().isEmpty() || !p_233747_.getOffhandItem().isEmpty(); + UseOnContext useoncontext = new UseOnContext(p_233747_, p_233748_, p_233749_); @@ -112,20 +112,20 @@ BlockState blockstate = this.minecraft.level.getBlockState(blockpos); if (!this.connection.isFeatureEnabled(blockstate.getBlock().requiredFeatures())) { return InteractionResult.FAIL; -@@ -323,8 +_,10 @@ +@@ -324,8 +_,10 @@ } } -- if (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack.getItem())) { +- if (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack)) { - UseOnContext useoncontext = new UseOnContext(p_233747_, p_233748_, p_233749_); + if (event.getUseItem().isFalse()) { + return InteractionResult.PASS; + } -+ if (event.getUseItem().isTrue() || (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack.getItem()))) { - InteractionResult interactionresult1; ++ if (event.getUseItem().isTrue() || (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack))) { + InteractionResult interactionresult2; if (this.localPlayerMode.isCreative()) { int i = itemstack.getCount(); -@@ -358,10 +_,17 @@ +@@ -359,6 +_,11 @@ mutableobject.setValue(InteractionResult.PASS); return serverbounduseitempacket; } else { @@ -134,22 +134,25 @@ + mutableobject.setValue(cancelResult); + return serverbounduseitempacket; + } - InteractionResultHolder interactionresultholder = itemstack.use(this.minecraft.level, p_233722_, p_233723_); - ItemStack itemstack1 = interactionresultholder.getObject(); + InteractionResult interactionresult = itemstack.use(this.minecraft.level, p_233722_, p_233723_); + ItemStack itemstack1; + if (interactionresult instanceof InteractionResult.Success interactionresult$success) { +@@ -371,6 +_,8 @@ + if (itemstack1 != itemstack) { p_233722_.setItemInHand(p_233723_, itemstack1); + if (itemstack1.isEmpty()) + net.neoforged.neoforge.event.EventHooks.onPlayerDestroyItem(p_233722_, itemstack, p_233723_); } - mutableobject.setValue(interactionresultholder.getResult()); -@@ -400,6 +_,9 @@ + mutableobject.setValue(interactionresult); +@@ -409,6 +_,9 @@ this.ensureHasSentCarriedItem(); Vec3 vec3 = p_105233_.getLocation().subtract(p_105232_.getX(), p_105232_.getY(), p_105232_.getZ()); this.connection.send(ServerboundInteractPacket.createInteractionPacket(p_105232_, p_105231_.isShiftKeyDown(), p_105234_, vec3)); + if (this.localPlayerMode == GameType.SPECTATOR) return InteractionResult.PASS; // don't fire for spectators to match non-specific EntityInteract + InteractionResult cancelResult = net.neoforged.neoforge.common.CommonHooks.onInteractEntityAt(p_105231_, p_105232_, p_105233_, p_105234_); + if(cancelResult != null) return cancelResult; - return this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105232_.interactAt(p_105231_, vec3, p_105234_); + return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : p_105232_.interactAt(p_105231_, vec3, p_105234_)); } diff --git a/patches/net/minecraft/client/multiplayer/PlayerInfo.java.patch b/patches/net/minecraft/client/multiplayer/PlayerInfo.java.patch index 1609a2b5e2..27972460ce 100644 --- a/patches/net/minecraft/client/multiplayer/PlayerInfo.java.patch +++ b/patches/net/minecraft/client/multiplayer/PlayerInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/PlayerInfo.java +++ b/net/minecraft/client/multiplayer/PlayerInfo.java -@@ -85,6 +_,7 @@ +@@ -86,6 +_,7 @@ } protected void setGameMode(GameType p_105318_) { diff --git a/patches/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch b/patches/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch index 70a7eabfac..1010c8ad04 100644 --- a/patches/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch +++ b/patches/net/minecraft/client/multiplayer/SessionSearchTrees.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/multiplayer/SessionSearchTrees.java +++ b/net/minecraft/client/multiplayer/SessionSearchTrees.java -@@ -60,7 +_,7 @@ - List list = p_346233_.getCollections(); - Registry registry = p_345600_.registryOrThrow(Registries.ITEM); - Item.TooltipContext item$tooltipcontext = Item.TooltipContext.of(p_345600_); +@@ -65,7 +_,7 @@ + Registry registry = registryaccess.lookupOrThrow(Registries.ITEM); + Item.TooltipContext item$tooltipcontext = Item.TooltipContext.of(registryaccess); + ContextMap contextmap = SlotDisplayContext.fromLevel(p_379752_); - TooltipFlag tooltipflag = TooltipFlag.Default.NORMAL; + TooltipFlag tooltipflag = net.neoforged.neoforge.client.ClientTooltipFlag.of(TooltipFlag.Default.NORMAL); CompletableFuture completablefuture = this.recipeSearch; this.recipeSearch = CompletableFuture.supplyAsync( () -> new FullTextSearchTree<>( -@@ -86,44 +_,60 @@ +@@ -92,44 +_,60 @@ } public void updateCreativeTags(List p_346121_) { diff --git a/patches/net/minecraft/client/multiplayer/TagCollector.java.patch b/patches/net/minecraft/client/multiplayer/TagCollector.java.patch deleted file mode 100644 index db75c16b16..0000000000 --- a/patches/net/minecraft/client/multiplayer/TagCollector.java.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- a/net/minecraft/client/multiplayer/TagCollector.java -+++ b/net/minecraft/client/multiplayer/TagCollector.java -@@ -44,5 +_,6 @@ - this.applyTags(p_326147_, p_326446_ -> true); - refreshBuiltInTagDependentData(); - } -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.TagsUpdatedEvent(p_326147_, true, p_326486_)); - } - } diff --git a/patches/net/minecraft/client/particle/BreakingItemParticle.java.patch b/patches/net/minecraft/client/particle/BreakingItemParticle.java.patch index dc96475e87..3d9b32361f 100644 --- a/patches/net/minecraft/client/particle/BreakingItemParticle.java.patch +++ b/patches/net/minecraft/client/particle/BreakingItemParticle.java.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/client/particle/BreakingItemParticle.java +++ b/net/minecraft/client/particle/BreakingItemParticle.java -@@ -33,7 +_,8 @@ +@@ -33,7 +_,7 @@ protected BreakingItemParticle(ClientLevel p_105665_, double p_105666_, double p_105667_, double p_105668_, ItemStack p_105669_) { super(p_105665_, p_105666_, p_105667_, p_105668_, 0.0, 0.0, 0.0); - this.setSprite(Minecraft.getInstance().getItemRenderer().getModel(p_105669_, p_105665_, null, 0).getParticleIcon()); -+ var model = Minecraft.getInstance().getItemRenderer().getModel(p_105669_, p_105665_, null, 0); -+ this.setSprite(model.getOverrides().resolve(model, p_105669_, p_105665_, null, 0).getParticleIcon(net.neoforged.neoforge.client.model.data.ModelData.EMPTY)); ++ this.setSprite(Minecraft.getInstance().getItemRenderer().getModel(p_105669_, p_105665_, null, 0).getParticleIcon(net.neoforged.neoforge.client.model.data.ModelData.EMPTY)); this.gravity = 1.0F; this.quadSize /= 2.0F; this.uo = this.random.nextFloat() * 3.0F; diff --git a/patches/net/minecraft/client/particle/ItemPickupParticle.java.patch b/patches/net/minecraft/client/particle/ItemPickupParticle.java.patch index b0309a1a4e..fbf0a1e746 100644 --- a/patches/net/minecraft/client/particle/ItemPickupParticle.java.patch +++ b/patches/net/minecraft/client/particle/ItemPickupParticle.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/particle/ItemPickupParticle.java +++ b/net/minecraft/client/particle/ItemPickupParticle.java -@@ -103,4 +_,11 @@ +@@ -102,4 +_,11 @@ this.targetYOld = this.targetY; this.targetZOld = this.targetZ; } diff --git a/patches/net/minecraft/client/particle/ParticleEngine.java.patch b/patches/net/minecraft/client/particle/ParticleEngine.java.patch index ffbb1d2839..de43669f57 100644 --- a/patches/net/minecraft/client/particle/ParticleEngine.java.patch +++ b/patches/net/minecraft/client/particle/ParticleEngine.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/particle/ParticleEngine.java +++ b/net/minecraft/client/particle/ParticleEngine.java -@@ -81,11 +_,11 @@ - ParticleRenderType.CUSTOM +@@ -77,11 +_,11 @@ + ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT, ParticleRenderType.CUSTOM ); protected ClientLevel level; - private final Map> particles = Maps.newIdentityHashMap(); @@ -14,8 +14,8 @@ private final Queue particlesToAdd = Queues.newArrayDeque(); private final Map spriteSets = Maps.newHashMap(); private final TextureAtlas textureAtlas; -@@ -216,10 +_,14 @@ - this.register(ParticleTypes.OMINOUS_SPAWNING, FlyStraightTowardsParticle.OminousSpawnProvider::new); +@@ -214,10 +_,14 @@ + this.register(ParticleTypes.BLOCK_CRUMBLE, new TerrainParticle.CrumblingProvider()); } + /** @deprecated Register via {@link net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent} */ @@ -30,7 +30,7 @@ public void register(ParticleType p_273423_, ParticleProvider.Sprite p_273134_) { this.register( p_273423_, -@@ -236,10 +_,12 @@ +@@ -234,10 +_,12 @@ ); } @@ -44,7 +44,7 @@ } @Override -@@ -365,7 +_,7 @@ +@@ -357,7 +_,7 @@ private Particle makeParticle( T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_ ) { @@ -53,7 +53,7 @@ return particleprovider == null ? null : particleprovider.createParticle(p_107396_, this.level, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_); -@@ -441,11 +_,20 @@ +@@ -433,17 +_,27 @@ } } @@ -74,8 +74,7 @@ + if (particlerendertype == ParticleRenderType.NO_RENDER || !renderTypePredicate.test(particlerendertype)) continue; Queue queue = this.particles.get(particlerendertype); if (queue != null && !queue.isEmpty()) { - RenderSystem.setShader(GameRenderer::getParticleShader); -@@ -453,6 +_,7 @@ + Tesselator tesselator = Tesselator.getInstance(); BufferBuilder bufferbuilder = particlerendertype.begin(tesselator, this.textureManager); if (bufferbuilder != null) { for (Particle particle : queue) { @@ -83,7 +82,7 @@ try { particle.render(bufferbuilder, p_107340_, p_107341_); } catch (Throwable throwable) { -@@ -484,7 +_,7 @@ +@@ -475,7 +_,7 @@ } public void destroy(BlockPos p_107356_, BlockState p_107357_) { @@ -92,7 +91,7 @@ VoxelShape voxelshape = p_107357_.getShape(this.level, p_107356_); double d0 = 0.25; voxelshape.forAllBoxes( -@@ -516,7 +_,7 @@ +@@ -507,7 +_,7 @@ d6 - 0.5, p_107357_, p_107356_ @@ -101,7 +100,7 @@ ); } } -@@ -561,12 +_,28 @@ +@@ -552,12 +_,28 @@ d0 = (double)i + aabb.maxX + 0.1F; } diff --git a/patches/net/minecraft/client/particle/ParticleRenderType.java.patch b/patches/net/minecraft/client/particle/ParticleRenderType.java.patch index 4a648c99e5..e3d114e526 100644 --- a/patches/net/minecraft/client/particle/ParticleRenderType.java.patch +++ b/patches/net/minecraft/client/particle/ParticleRenderType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/particle/ParticleRenderType.java +++ b/net/minecraft/client/particle/ParticleRenderType.java -@@ -43,6 +_,11 @@ +@@ -44,6 +_,11 @@ public String toString() { return "PARTICLE_SHEET_OPAQUE"; } @@ -12,19 +12,7 @@ }; ParticleRenderType PARTICLE_SHEET_TRANSLUCENT = new ParticleRenderType() { @Override -@@ -72,6 +_,11 @@ - public String toString() { - return "PARTICLE_SHEET_LIT"; - } -+ -+ @Override -+ public boolean isTranslucent() { -+ return false; -+ } - }; - ParticleRenderType CUSTOM = new ParticleRenderType() { - @Override -@@ -101,4 +_,9 @@ +@@ -89,4 +_,9 @@ @Nullable BufferBuilder begin(Tesselator p_350949_, TextureManager p_107437_); diff --git a/patches/net/minecraft/client/player/AbstractClientPlayer.java.patch b/patches/net/minecraft/client/player/AbstractClientPlayer.java.patch index 48705c0461..6e8a8c5540 100644 --- a/patches/net/minecraft/client/player/AbstractClientPlayer.java.patch +++ b/patches/net/minecraft/client/player/AbstractClientPlayer.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/player/AbstractClientPlayer.java +++ b/net/minecraft/client/player/AbstractClientPlayer.java -@@ -96,6 +_,6 @@ +@@ -91,6 +_,6 @@ } } -- return Mth.lerp(Minecraft.getInstance().options.fovEffectScale().get().floatValue(), 1.0F, f); -+ return net.neoforged.neoforge.client.ClientHooks.getFieldOfViewModifier(this, f); +- return Mth.lerp(p_366686_, 1.0F, f); ++ return net.neoforged.neoforge.client.ClientHooks.getFieldOfViewModifier(this, f, p_366686_); } } diff --git a/patches/net/minecraft/client/player/LocalPlayer.java.patch b/patches/net/minecraft/client/player/LocalPlayer.java.patch index 632b558ef9..d772181669 100644 --- a/patches/net/minecraft/client/player/LocalPlayer.java.patch +++ b/patches/net/minecraft/client/player/LocalPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/LocalPlayer.java +++ b/net/minecraft/client/player/LocalPlayer.java -@@ -297,6 +_,7 @@ +@@ -302,6 +_,7 @@ ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_108701_ ? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS : ServerboundPlayerActionPacket.Action.DROP_ITEM; @@ -8,7 +8,7 @@ ItemStack itemstack = this.getInventory().removeFromSelected(p_108701_); this.connection.send(new ServerboundPlayerActionPacket(serverboundplayeractionpacket$action, BlockPos.ZERO, Direction.DOWN)); return !itemstack.isEmpty(); -@@ -489,7 +_,14 @@ +@@ -482,7 +_,14 @@ @Override public void playSound(SoundEvent p_108651_, float p_108652_, float p_108653_) { @@ -24,7 +24,7 @@ } @Override -@@ -682,6 +_,7 @@ +@@ -676,6 +_,7 @@ && (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING)); float f = (float)this.getAttributeValue(Attributes.SNEAKING_SPEED); this.input.tick(this.isMovingSlowly(), f); @@ -32,7 +32,7 @@ this.minecraft.getTutorial().onInput(this.input); if (this.isUsingItem() && !this.isPassenger()) { this.input.leftImpulse *= 0.2F; -@@ -710,7 +_,7 @@ +@@ -704,7 +_,7 @@ boolean flag4 = this.canStartSprinting(); boolean flag5 = this.isPassenger() ? this.getVehicle().onGround() : this.onGround(); boolean flag6 = !flag1 && !flag2; @@ -41,7 +41,7 @@ if (this.sprintTriggerTime <= 0 && !this.minecraft.options.keySprint.isDown()) { this.sprintTriggerTime = 7; } else { -@@ -718,15 +_,15 @@ +@@ -712,15 +_,15 @@ } } @@ -55,12 +55,12 @@ - boolean flag8 = flag7 || this.horizontalCollision && !this.minorHorizontalCollision || this.isInWater() && !this.isUnderWater(); + boolean flag8 = flag7 || this.horizontalCollision && !this.minorHorizontalCollision || this.isInWater() && !this.isUnderWater() || (this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)) && !this.canStartSwimming()); if (this.isSwimming()) { -- if (!this.onGround() && !this.input.shiftKeyDown && flag7 || !this.isInWater()) { -+ if (!this.onGround() && !this.input.shiftKeyDown && flag7 || !(this.isInWater() || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)))) { +- if (!this.onGround() && !this.input.keyPresses.shift() && flag7 || !this.isInWater()) { ++ if (!this.onGround() && !this.input.keyPresses.shift() && flag7 || !(this.isInWater() || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)))) { this.setSprinting(false); } } else if (flag8) { -@@ -735,7 +_,7 @@ +@@ -729,7 +_,7 @@ } boolean flag9 = false; @@ -69,34 +69,18 @@ if (this.minecraft.gameMode.isAlwaysFlying()) { if (!abilities.flying) { abilities.flying = true; -@@ -760,14 +_,15 @@ - - if (this.input.jumping && !flag9 && !flag && !abilities.flying && !this.isPassenger() && !this.onClimbable()) { - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.CHEST); -- if (itemstack.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(itemstack) && this.tryToStartFallFlying()) { -+ if (itemstack.canElytraFly(this) && this.tryToStartFallFlying()) { - this.connection.send(new ServerboundPlayerCommandPacket(this, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING)); - } - } - - this.wasFallFlying = this.isFallFlying(); -- if (this.isInWater() && this.input.shiftKeyDown && this.isAffectedByFluids()) { -- this.goDownInWater(); -+ net.neoforged.neoforge.fluids.FluidType fluidType = this.getMaxHeightFluidType(); -+ if ((this.isInWater() || (!fluidType.isAir() && this.canSwimInFluidType(fluidType))) && this.input.shiftKeyDown && this.isAffectedByFluids()) { -+ this.sinkInFluid(this.isInWater() ? net.neoforged.neoforge.common.NeoForgeMod.WATER_TYPE.value() : fluidType); - } - - if (this.isEyeInFluid(FluidTags.WATER)) { -@@ -875,6 +_,7 @@ +@@ -866,6 +_,10 @@ @Override public void rideTick() { super.rideTick(); -+ if (this.wantsToStopRiding() && this.isPassenger()) this.input.shiftKeyDown = false; ++ if (this.wantsToStopRiding() && this.isPassenger()) { ++ Input input = this.input.keyPresses; ++ this.input.keyPresses = new Input(input.forward(), input.backward(), input.left(), input.right(), input.jump(), false, input.sprint()); ++ } this.handsBusy = false; - if (this.getControlledVehicle() instanceof Boat boat) { - boat.setInput(this.input.left, this.input.right, this.input.up, this.input.down); -@@ -1061,7 +_,7 @@ + if (this.getControlledVehicle() instanceof AbstractBoat abstractboat) { + abstractboat.setInput( +@@ -1063,7 +_,7 @@ } private boolean hasEnoughFoodToStartSprinting() { diff --git a/patches/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch b/patches/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch index 641642c10f..285c14a5b2 100644 --- a/patches/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch +++ b/patches/net/minecraft/client/renderer/DimensionSpecialEffects.java.patch @@ -9,7 +9,7 @@ private static final Object2ObjectMap EFFECTS = Util.make(new Object2ObjectArrayMap<>(), p_108881_ -> { DimensionSpecialEffects.OverworldEffects dimensionspecialeffects$overworldeffects = new DimensionSpecialEffects.OverworldEffects(); p_108881_.defaultReturnValue(dimensionspecialeffects$overworldeffects); -@@ -37,7 +_,7 @@ +@@ -36,7 +_,7 @@ } public static DimensionSpecialEffects forType(DimensionType p_108877_) { @@ -17,4 +17,4 @@ + return net.neoforged.neoforge.client.DimensionSpecialEffectsManager.getForType(p_108877_.effectsLocation()); } - @Nullable + public boolean isSunriseOrSunset(float p_365312_) { diff --git a/patches/net/minecraft/client/renderer/EffectInstance.java.patch b/patches/net/minecraft/client/renderer/EffectInstance.java.patch deleted file mode 100644 index 8ceff68f59..0000000000 --- a/patches/net/minecraft/client/renderer/EffectInstance.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/client/renderer/EffectInstance.java -+++ b/net/minecraft/client/renderer/EffectInstance.java -@@ -58,7 +_,8 @@ - private final EffectProgram fragmentProgram; - - public EffectInstance(ResourceProvider p_331011_, String p_108942_) throws IOException { -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("shaders/program/" + p_108942_ + ".json"); -+ ResourceLocation rl = ResourceLocation.tryParse(p_108942_); -+ ResourceLocation resourcelocation = ResourceLocation.fromNamespaceAndPath(rl.getNamespace(), "shaders/program/" + rl.getPath() + ".json"); - this.name = p_108942_; - Resource resource = p_331011_.getResourceOrThrow(resourcelocation); - -@@ -150,7 +_,8 @@ - } else { - EffectProgram effectprogram; - if (program == null) { -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("shaders/program/" + p_172569_ + p_172568_.getExtension()); -+ ResourceLocation rl = ResourceLocation.tryParse(p_172569_); -+ ResourceLocation resourcelocation = ResourceLocation.fromNamespaceAndPath(rl.getNamespace(), "shaders/program/" + rl.getPath() + p_172568_.getExtension()); - Resource resource = p_330579_.getResourceOrThrow(resourcelocation); - - try (InputStream inputstream = resource.open()) { diff --git a/patches/net/minecraft/client/renderer/FogRenderer.java.patch b/patches/net/minecraft/client/renderer/FogRenderer.java.patch index 25aa279988..f2443a835c 100644 --- a/patches/net/minecraft/client/renderer/FogRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/FogRenderer.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/client/renderer/FogRenderer.java +++ b/net/minecraft/client/renderer/FogRenderer.java -@@ -197,6 +_,12 @@ - fogBlue = fogBlue * (1.0F - f7) + fogBlue * f9 * f7; +@@ -196,7 +_,7 @@ + f2 = f2 * (1.0F - f10) + f2 * f12 * f10; } -+ Vector3f fogColor = net.neoforged.neoforge.client.ClientHooks.getFogColor(p_109019_, p_109020_, p_109021_, p_109022_, p_109023_, fogRed, fogGreen, fogBlue); -+ -+ fogRed = fogColor.x(); -+ fogGreen = fogColor.y(); -+ fogBlue = fogColor.z(); -+ - RenderSystem.clearColor(fogRed, fogGreen, fogBlue, 0.0F); +- return new Vector4f(f, f1, f2, 1.0F); ++ return net.neoforged.neoforge.client.ClientHooks.getFogColor(p_363451_, p_364931_, p_363033_, p_363851_, p_363957_, f, f1, f2); } -@@ -273,6 +_,7 @@ - RenderSystem.setShaderFogStart(fogrenderer$fogdata.start); - RenderSystem.setShaderFogEnd(fogrenderer$fogdata.end); - RenderSystem.setShaderFogShape(fogrenderer$fogdata.shape); -+ net.neoforged.neoforge.client.ClientHooks.onFogRender(p_234174_, fogtype, p_234173_, p_234177_, p_234175_, fogrenderer$fogdata.start, fogrenderer$fogdata.end, fogrenderer$fogdata.shape); + public static boolean toggleFog() { +@@ -274,9 +_,9 @@ + fogrenderer$fogdata.shape = FogShape.CYLINDER; + } + +- return new FogParameters( ++ return net.neoforged.neoforge.client.ClientHooks.onFogRender(p_234174_, fogtype, p_234173_, p_234177_, p_234175_, new FogParameters( + fogrenderer$fogdata.start, fogrenderer$fogdata.end, fogrenderer$fogdata.shape, p_365467_.x, p_365467_.y, p_365467_.z, p_365467_.w +- ); ++ )); + } } - public static void levelFogColor() { diff --git a/patches/net/minecraft/client/renderer/GameRenderer.java.patch b/patches/net/minecraft/client/renderer/GameRenderer.java.patch index 7d1c353a22..db82c7ecba 100644 --- a/patches/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/GameRenderer.java.patch @@ -1,32 +1,24 @@ --- a/net/minecraft/client/renderer/GameRenderer.java +++ b/net/minecraft/client/renderer/GameRenderer.java -@@ -311,6 +_,8 @@ - this.loadEffect(ResourceLocation.withDefaultNamespace("shaders/post/spider.json")); +@@ -158,6 +_,8 @@ + this.setPostEffect(ResourceLocation.withDefaultNamespace("spider")); } else if (p_109107_ instanceof EnderMan) { - this.loadEffect(ResourceLocation.withDefaultNamespace("shaders/post/invert.json")); + this.setPostEffect(ResourceLocation.withDefaultNamespace("invert")); + } else { + net.neoforged.neoforge.client.ClientHooks.loadEntityShader(p_109107_, this); } } -@@ -714,6 +_,7 @@ - ) - ); - this.loadBlurEffect(p_250719_); -+ net.neoforged.fml.ModLoader.postEvent(new net.neoforged.neoforge.client.event.RegisterShadersEvent(p_250719_, list1)); - } catch (IOException ioexception) { - list1.forEach(p_172729_ -> p_172729_.getFirst().close()); - throw new RuntimeException("could not reload shaders", ioexception); -@@ -872,7 +_,7 @@ - d0 *= Mth.lerp(this.minecraft.options.fovEffectScale().get(), 1.0, 0.85714287F); +@@ -312,7 +_,7 @@ + f *= Mth.lerp(f2, 1.0F, 0.85714287F); } -- return d0; -+ return net.neoforged.neoforge.client.ClientHooks.getFieldOfView(this, p_109142_, p_109143_, d0, p_109144_); +- return f; ++ return net.neoforged.neoforge.client.ClientHooks.getFieldOfView(this, p_109142_, p_109143_, f, p_109144_); } } -@@ -888,6 +_,10 @@ +@@ -328,6 +_,10 @@ return; } @@ -37,48 +29,37 @@ f2 /= (float)livingentity.hurtDuration; f2 = Mth.sin(f2 * f2 * f2 * f2 * (float) Math.PI); float f3 = livingentity.getHurtDir(); -@@ -1036,12 +_,12 @@ +@@ -474,12 +_,12 @@ (float)((double)window.getHeight() / window.getGuiScale()), 0.0F, 1000.0F, - 21000.0F + net.neoforged.neoforge.client.ClientHooks.getGuiFarPlane() ); - RenderSystem.setProjectionMatrix(matrix4f, VertexSorting.ORTHOGRAPHIC_Z); + RenderSystem.setProjectionMatrix(matrix4f, ProjectionType.ORTHOGRAPHIC); Matrix4fStack matrix4fstack = RenderSystem.getModelViewStack(); matrix4fstack.pushMatrix(); - matrix4fstack.translation(0.0F, 0.0F, -11000.0F); + matrix4fstack.translation(0.0F, 0.0F, 10000F - net.neoforged.neoforge.client.ClientHooks.getGuiFarPlane()); - RenderSystem.applyModelViewMatrix(); Lighting.setupFor3DItems(); GuiGraphics guigraphics = new GuiGraphics(this.minecraft, this.renderBuffers.bufferSource()); -@@ -1070,7 +_,8 @@ - - if (this.minecraft.getOverlay() != null) { - try { -- this.minecraft.getOverlay().render(guigraphics, i, j, p_348648_.getRealtimeDeltaTicks()); -+ // Neo: Fix https://bugs.mojang.com/browse/MC-273464 -+ this.minecraft.getOverlay().render(guigraphics, i, j, p_348648_.getGameTimeDeltaPartialTick(false)); - } catch (Throwable throwable2) { - CrashReport crashreport = CrashReport.forThrowable(throwable2, "Rendering overlay"); - CrashReportCategory crashreportcategory = crashreport.addCategory("Overlay render details"); -@@ -1079,7 +_,9 @@ + if (flag && p_109096_ && this.minecraft.level != null) { +@@ -505,7 +_,8 @@ } } else if (flag && this.minecraft.screen != null) { try { -- this.minecraft.screen.renderWithTooltip(guigraphics, i, j, p_348648_.getRealtimeDeltaTicks()); +- this.minecraft.screen.renderWithTooltip(guigraphics, i, j, p_348648_.getGameTimeDeltaTicks()); + // Neo: Wrap Screen#render to allow for GUI Layers and ScreenEvent.Render.[Pre/Post] -+ // Also fixes https://bugs.mojang.com/browse/MC-273464 -+ net.neoforged.neoforge.client.ClientHooks.drawScreen(this.minecraft.screen, guigraphics, i, j, p_348648_.getGameTimeDeltaPartialTick(false)); ++ net.neoforged.neoforge.client.ClientHooks.drawScreen(this.minecraft.screen, guigraphics, i, j, p_348648_.getGameTimeDeltaTicks()); } catch (Throwable throwable1) { CrashReport crashreport1 = CrashReport.forThrowable(throwable1, "Rendering screen"); CrashReportCategory crashreportcategory1 = crashreport1.addCategory("Screen render details"); -@@ -1259,6 +_,8 @@ - .levelRenderer - .prepareCullFrustum(camera.getPosition(), matrix4f1, this.getProjectionMatrix(Math.max(d0, (double)this.minecraft.options.fov().get().intValue()))); - this.minecraft.levelRenderer.renderLevel(p_348589_, flag, camera, this, this.lightTexture, matrix4f1, matrix4f); -+ this.minecraft.getProfiler().popPush("neoforge_render_last"); +@@ -687,6 +_,8 @@ + this.minecraft.levelRenderer.prepareCullFrustum(camera.getPosition(), matrix4f2, matrix4f1); + this.minecraft.getMainRenderTarget().bindWrite(true); + this.minecraft.levelRenderer.renderLevel(this.resourcePool, p_348589_, flag, camera, this, this.lightTexture, matrix4f2, matrix4f); ++ profilerfiller.popPush("neoforge_render_last"); + net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_LEVEL, this.minecraft.levelRenderer, null, matrix4f1, matrix4f, this.minecraft.levelRenderer.getTicks(), camera, this.minecraft.levelRenderer.getFrustum()); - this.minecraft.getProfiler().popPush("hand"); + profilerfiller.popPush("hand"); if (this.renderHand) { - RenderSystem.clear(256, Minecraft.ON_OSX); + RenderSystem.clear(256); diff --git a/patches/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch b/patches/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch index d66d2a4c3a..1bf5aead8b 100644 --- a/patches/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch +++ b/patches/net/minecraft/client/renderer/ItemBlockRenderTypes.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/client/renderer/ItemBlockRenderTypes.java +++ b/net/minecraft/client/renderer/ItemBlockRenderTypes.java -@@ -20,6 +_,7 @@ +@@ -18,6 +_,7 @@ @OnlyIn(Dist.CLIENT) public class ItemBlockRenderTypes { + @Deprecated - private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_353020_ -> { + private static final Map TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_378824_ -> { RenderType rendertype = RenderType.tripwire(); - p_353020_.put(Blocks.TRIPWIRE, rendertype); -@@ -335,6 +_,7 @@ - p_353020_.put(Blocks.BUBBLE_COLUMN, rendertype3); - p_353020_.put(Blocks.TINTED_GLASS, rendertype3); + p_378824_.put(Blocks.TRIPWIRE, rendertype); +@@ -340,6 +_,7 @@ + p_378824_.put(Blocks.BUBBLE_COLUMN, rendertype3); + p_378824_.put(Blocks.TINTED_GLASS, rendertype3); }); + @Deprecated private static final Map TYPE_BY_FLUID = Util.make(Maps.newHashMap(), p_109290_ -> { RenderType rendertype = RenderType.translucent(); p_109290_.put(Fluids.FLOWING_WATER, rendertype); -@@ -342,6 +_,8 @@ +@@ -347,6 +_,8 @@ }); private static boolean renderCutout; @@ -25,7 +25,7 @@ public static RenderType getChunkRenderType(BlockState p_109283_) { Block block = p_109283_.getBlock(); if (block instanceof LeavesBlock) { -@@ -352,6 +_,8 @@ +@@ -357,6 +_,8 @@ } } @@ -34,25 +34,23 @@ public static RenderType getMovingBlockRenderType(BlockState p_109294_) { Block block = p_109294_.getBlock(); if (block instanceof LeavesBlock) { -@@ -366,6 +_,8 @@ +@@ -371,11 +_,15 @@ } } -+ /** @deprecated Forge: Use {@link net.neoforged.neoforge.client.RenderTypeHelper#getEntityRenderType(RenderType, boolean)} while iterating through {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.neoforged.neoforge.client.model.data.ModelData)}. */ ++ /** @deprecated Forge: Use {@link net.neoforged.neoforge.client.RenderTypeHelper#getEntityRenderType(RenderType)} while iterating through {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.neoforged.neoforge.client.model.data.ModelData)}. */ + @Deprecated // Note: this method does NOT support model-based render types - public static RenderType getRenderType(BlockState p_109285_, boolean p_109286_) { - RenderType rendertype = getChunkRenderType(p_109285_); - if (rendertype == RenderType.translucent()) { -@@ -379,6 +_,8 @@ - } + public static RenderType getRenderType(BlockState p_366653_) { + RenderType rendertype = getChunkRenderType(p_366653_); + return rendertype == RenderType.translucent() ? Sheets.translucentItemSheet() : Sheets.cutoutBlockSheet(); } -+ /** @deprecated Forge: Use {@link net.minecraft.client.resources.model.BakedModel#getRenderPasses(ItemStack, boolean)} and {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(ItemStack, boolean)}. */ ++ /** @deprecated Forge: Use {@link net.minecraft.client.resources.model.BakedModel#getRenderPasses(ItemStack)} and {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(ItemStack)}. */ + @Deprecated // Note: this method does NOT support model-based render types - public static RenderType getRenderType(ItemStack p_109280_, boolean p_109281_) { - Item item = p_109280_.getItem(); - if (item instanceof BlockItem) { -@@ -396,5 +_,78 @@ + public static RenderType getRenderType(ItemStack p_366701_) { + if (p_366701_.getItem() instanceof BlockItem blockitem) { + Block block = blockitem.getBlock(); +@@ -392,5 +_,78 @@ public static void setFancy(boolean p_109292_) { renderCutout = p_109292_; diff --git a/patches/net/minecraft/client/renderer/ItemInHandRenderer.java.patch b/patches/net/minecraft/client/renderer/ItemInHandRenderer.java.patch index 8497dbd1cc..50e02aa55f 100644 --- a/patches/net/minecraft/client/renderer/ItemInHandRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/ItemInHandRenderer.java.patch @@ -1,6 +1,20 @@ --- a/net/minecraft/client/renderer/ItemInHandRenderer.java +++ b/net/minecraft/client/renderer/ItemInHandRenderer.java -@@ -226,7 +_,7 @@ +@@ -168,11 +_,11 @@ + ResourceLocation resourcelocation = this.minecraft.player.getSkin().texture(); + if (p_109365_ == HumanoidArm.RIGHT) { + playerrenderer.renderRightHand( +- p_109362_, p_109363_, p_109364_, resourcelocation, this.minecraft.player.isModelPartShown(PlayerModelPart.RIGHT_SLEEVE) ++ p_109362_, p_109363_, p_109364_, resourcelocation, this.minecraft.player.isModelPartShown(PlayerModelPart.RIGHT_SLEEVE), this.minecraft.player + ); + } else { + playerrenderer.renderLeftHand( +- p_109362_, p_109363_, p_109364_, resourcelocation, this.minecraft.player.isModelPartShown(PlayerModelPart.LEFT_SLEEVE) ++ p_109362_, p_109363_, p_109364_, resourcelocation, this.minecraft.player.isModelPartShown(PlayerModelPart.LEFT_SLEEVE), this.minecraft.player + ); + } + +@@ -234,7 +_,7 @@ p_109367_.translate(-0.5F, -0.5F, 0.0F); p_109367_.scale(0.0078125F, 0.0078125F, 0.0078125F); MapId mapid = p_109370_.get(DataComponents.MAP_ID); @@ -9,7 +23,20 @@ VertexConsumer vertexconsumer = p_109368_.getBuffer(mapitemsaveddata == null ? MAP_BACKGROUND : MAP_BACKGROUND_CHECKERBOARD); Matrix4f matrix4f = p_109367_.last().pose(); vertexconsumer.addVertex(matrix4f, -7.0F, 135.0F, 0.0F).setColor(-1).setUv(0.0F, 1.0F).setLight(p_109369_); -@@ -334,12 +_,14 @@ +@@ -271,10 +_,10 @@ + ResourceLocation resourcelocation = abstractclientplayer.getSkin().texture(); + if (flag) { + playerrenderer.renderRightHand( +- p_109347_, p_109348_, p_109349_, resourcelocation, abstractclientplayer.isModelPartShown(PlayerModelPart.RIGHT_SLEEVE) ++ p_109347_, p_109348_, p_109349_, resourcelocation, abstractclientplayer.isModelPartShown(PlayerModelPart.RIGHT_SLEEVE), abstractclientplayer + ); + } else { +- playerrenderer.renderLeftHand(p_109347_, p_109348_, p_109349_, resourcelocation, abstractclientplayer.isModelPartShown(PlayerModelPart.LEFT_SLEEVE)); ++ playerrenderer.renderLeftHand(p_109347_, p_109348_, p_109349_, resourcelocation, abstractclientplayer.isModelPartShown(PlayerModelPart.LEFT_SLEEVE), abstractclientplayer); + } + } + +@@ -347,12 +_,14 @@ if (iteminhandrenderer$handrenderselection.renderMainHand) { float f4 = interactionhand == InteractionHand.MAIN_HAND ? f : 0.0F; float f5 = 1.0F - Mth.lerp(p_109315_, this.oMainHandHeight, this.mainHandHeight); @@ -24,11 +51,11 @@ this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.offHandItem, f7, p_109316_, p_109317_, p_109319_); } -@@ -399,13 +_,13 @@ +@@ -412,13 +_,13 @@ if (flag && !p_109372_.isInvisible()) { this.renderPlayerArm(p_109379_, p_109380_, p_109381_, p_109378_, p_109376_, humanoidarm); } -- } else if (p_109377_.is(Items.FILLED_MAP)) { +- } else if (p_109377_.has(DataComponents.MAP_ID)) { + } else if (p_109377_.getItem() instanceof MapItem) { if (flag && this.offHandItem.isEmpty()) { this.renderTwoHandedMap(p_109379_, p_109380_, p_109381_, p_109374_, p_109378_, p_109376_); @@ -40,7 +67,7 @@ boolean flag1 = CrossbowItem.isCharged(p_109377_); boolean flag2 = humanoidarm == HumanoidArm.RIGHT; int i = flag2 ? 1 : -1; -@@ -455,6 +_,7 @@ +@@ -468,6 +_,7 @@ ); } else { boolean flag3 = humanoidarm == HumanoidArm.RIGHT; @@ -48,7 +75,7 @@ if (p_109372_.isUsingItem() && p_109372_.getUseItemRemainingTicks() > 0 && p_109372_.getUsedItemHand() == p_109375_) { int k = flag3 ? 1 : -1; switch (p_109377_.getUseAnimation()) { -@@ -569,8 +_,16 @@ +@@ -582,8 +_,16 @@ this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F); } else { float f = localplayer.getAttackStrengthScale(1.0F); diff --git a/patches/net/minecraft/client/renderer/LevelEventHandler.java.patch b/patches/net/minecraft/client/renderer/LevelEventHandler.java.patch new file mode 100644 index 0000000000..9babaa65c3 --- /dev/null +++ b/patches/net/minecraft/client/renderer/LevelEventHandler.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/client/renderer/LevelEventHandler.java ++++ b/net/minecraft/client/renderer/LevelEventHandler.java +@@ -435,8 +_,8 @@ + break; + case 2001: + BlockState blockstate1 = Block.stateById(p_360434_); +- if (!blockstate1.isAir()) { +- SoundType soundtype = blockstate1.getSoundType(); ++ if (!blockstate1.isAir() && !net.neoforged.neoforge.client.extensions.common.IClientBlockExtensions.of(blockstate1).playBreakSound(blockstate1, this.level, p_362181_)) { ++ SoundType soundtype = blockstate1.getSoundType(this.level, p_362181_, null); + this.level + .playLocalSound( + p_362181_, soundtype.getBreakSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F, false diff --git a/patches/net/minecraft/client/renderer/LevelRenderer.java.patch b/patches/net/minecraft/client/renderer/LevelRenderer.java.patch index 82e084e8b4..f5f9a14c0d 100644 --- a/patches/net/minecraft/client/renderer/LevelRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -1,229 +1,241 @@ --- a/net/minecraft/client/renderer/LevelRenderer.java +++ b/net/minecraft/client/renderer/LevelRenderer.java -@@ -233,6 +_,10 @@ - private int rainSoundTime; - private final float[] rainSizeX = new float[1024]; - private final float[] rainSizeZ = new float[1024]; +@@ -485,7 +_,7 @@ + RenderSystem.clear(16640); + }); + if (!flag1) { +- this.addSkyPass(framegraphbuilder, p_109604_, f, fogparameters1); ++ this.addSkyPass(framegraphbuilder, p_109604_, f, fogparameters1, p_254120_, p_323920_); + } + + this.addMainPass(framegraphbuilder, frustum, p_109604_, p_254120_, p_323920_, fogparameters, p_109603_, flag2, p_348530_, profilerfiller); +@@ -494,7 +_,7 @@ + postchain1.addToFrame(framegraphbuilder, i, j, this.targets); + } + +- this.addParticlesPass(framegraphbuilder, p_109604_, p_109606_, f, fogparameters); ++ this.addParticlesPass(framegraphbuilder, p_109604_, p_109606_, f, fogparameters, frustum, p_254120_, p_323920_); + CloudStatus cloudstatus = this.minecraft.options.getCloudsType(); + if (cloudstatus != CloudStatus.OFF) { + float f2 = this.level.effects().getCloudHeight(); +@@ -505,7 +_,7 @@ + } + } + +- this.addWeatherPass(framegraphbuilder, p_109606_, p_109604_.getPosition(), f, fogparameters); ++ this.addWeatherPass(framegraphbuilder, p_109606_, p_109604_.getPosition(), f, fogparameters, p_254120_, p_323920_, p_109604_); + if (postchain != null) { + postchain.addToFrame(framegraphbuilder, i, j, this.targets); + } +@@ -576,7 +_,9 @@ + double d2 = vec3.z(); + p_362234_.push("terrain"); + this.renderSectionLayer(RenderType.solid(), d0, d1, d2, p_362420_, p_361272_); ++ this.minecraft.getModelManager().getAtlas(net.minecraft.client.renderer.texture.TextureAtlas.LOCATION_BLOCKS).setBlurMipmap(false, this.minecraft.options.mipmapLevels().get() > 0); // Neo: fix flickering leaves when mods mess up the blurMipmap settings + this.renderSectionLayer(RenderType.cutoutMipped(), d0, d1, d2, p_362420_, p_361272_); ++ this.minecraft.getModelManager().getAtlas(net.minecraft.client.renderer.texture.TextureAtlas.LOCATION_BLOCKS).restoreLastBlurMipmap(); + this.renderSectionLayer(RenderType.cutout(), d0, d1, d2, p_362420_, p_361272_); + if (this.level.effects().constantAmbientLight()) { + Lighting.setupNetherLevel(); +@@ -608,6 +_,7 @@ + p_362234_.popPush("entities"); + this.renderEntities(posestack, multibuffersource$buffersource, p_363453_, p_360931_, this.visibleEntities); + multibuffersource$buffersource.endLastBatch(); ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_ENTITIES, this, posestack, p_362420_, p_361272_, this.ticks, p_363453_, p_366590_); + this.checkPoseStack(posestack); + p_362234_.popPush("blockentities"); + this.renderBlockEntities(posestack, multibuffersource$buffersource, multibuffersource$buffersource1, p_363453_, f); +@@ -624,6 +_,7 @@ + multibuffersource$buffersource.endBatch(Sheets.hangingSignSheet()); + multibuffersource$buffersource.endBatch(Sheets.chestSheet()); + this.renderBuffers.outlineBufferSource().endOutlineBatch(); ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_BLOCK_ENTITIES, this, posestack, p_362420_, p_361272_, this.ticks, p_363453_, p_366590_); + if (p_363964_) { + this.renderBlockOutline(p_363453_, multibuffersource$buffersource, posestack, false); + } +@@ -644,6 +_,11 @@ + multibuffersource$buffersource1.endBatch(); + this.checkPoseStack(posestack); + multibuffersource$buffersource.endBatch(RenderType.waterMask()); ++ // Neo: in Fast/Fancy, render solid particles before translucent geometry so they don't disappear underwater (MC-161917) ++ if (this.targets.particles == null) { ++ p_362234_.popPush("solid_particles"); ++ this.minecraft.particleEngine.render(this.minecraft.gameRenderer.lightTexture(), p_363453_, f, p_366590_, type -> !type.isTranslucent()); ++ } + multibuffersource$buffersource.endBatch(); + if (resourcehandle1 != null) { + resourcehandle1.get().setClearColor(0.0F, 0.0F, 0.0F, 0.0F); +@@ -664,7 +_,15 @@ + }); + } + + /** -+ * Neo: Indicates whether outline effect post-processing was requested for the current frame outside of vanilla codepaths ++ * @deprecated Neo: use {@link #addParticlesPass(FrameGraphBuilder, Camera, LightTexture, float, FogParameters, Frustum, Matrix4f, Matrix4f)} instead + */ -+ private boolean outlineEffectRequested = false; ++ @Deprecated + private void addParticlesPass(FrameGraphBuilder p_363357_, Camera p_365299_, LightTexture p_364308_, float p_364282_, FogParameters p_362149_) { ++ addParticlesPass(p_363357_, p_365299_, p_364308_, p_364282_, p_362149_, this.capturedFrustum != null ? this.capturedFrustum : this.cullingFrustum, RenderSystem.getModelViewMatrix(), RenderSystem.getProjectionMatrix()); ++ } ++ ++ private void addParticlesPass(FrameGraphBuilder p_363357_, Camera p_365299_, LightTexture p_364308_, float p_364282_, FogParameters p_362149_, Frustum frustum, Matrix4f modelViewMatrix, Matrix4f projectionMatrix) { + FramePass framepass = p_363357_.addPass("particles"); + if (this.targets.particles != null) { + this.targets.particles = framepass.readsAndWrites(this.targets.particles); +@@ -684,7 +_,8 @@ + } - public LevelRenderer(Minecraft p_234245_, EntityRenderDispatcher p_234246_, BlockEntityRenderDispatcher p_234247_, RenderBuffers p_234248_) { - this.minecraft = p_234245_; -@@ -256,6 +_,8 @@ + RenderStateShard.PARTICLES_TARGET.setupRenderState(); +- this.minecraft.particleEngine.render(p_364308_, p_365299_, p_364282_); ++ this.minecraft.particleEngine.render(p_364308_, p_365299_, p_364282_, frustum, resourcehandle1 == null ? type -> type.isTranslucent() : type -> true); // Neo: only render translucent particles here in Fast/Fancy ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, null, modelViewMatrix, projectionMatrix, this.ticks, p_365299_, getFrustum()); + RenderStateShard.PARTICLES_TARGET.clearRenderState(); + }); } +@@ -713,11 +_,20 @@ + resourcehandle.get().clear(); + } - private void renderSnowAndRain(LightTexture p_109704_, float p_109705_, double p_109706_, double p_109707_, double p_109708_) { -+ if (level.effects().renderSnowAndRain(level, ticks, p_109705_, p_109704_, p_109706_, p_109707_, p_109708_)) -+ return; - float f = this.minecraft.level.getRainLevel(p_109705_); - if (!(f <= 0.0F)) { - p_109704_.turnOnLightLayer(); -@@ -418,6 +_,8 @@ ++ if (!level.effects().renderClouds(level, ticks, p_365209_, p_362985_.x, p_362985_.y, p_362985_.z, p_362864_, p_360602_)) + this.cloudRenderer.render(p_362342_, p_364196_, p_362337_, p_362864_, p_360602_, p_362985_, p_365209_); + }); } - public void tickRain(Camera p_109694_) { -+ if (level.effects().tickRain(level, ticks, p_109694_)) -+ return; - float f = this.minecraft.level.getRainLevel(1.0F) / (Minecraft.useFancyGraphics() ? 1.0F : 2.0F); - if (!(f <= 0.0F)) { - RandomSource randomsource = RandomSource.create((long)this.ticks * 312987231L); -@@ -942,9 +_,11 @@ - RenderSystem.clear(16640, Minecraft.ON_OSX); - float f1 = p_109605_.getRenderDistance(); - boolean flag1 = this.minecraft.level.effects().isFoggyAt(Mth.floor(d0), Mth.floor(d1)) || this.minecraft.gui.getBossOverlay().shouldCreateWorldFog(); -+ FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f1, flag1, f); - profilerfiller.popPush("sky"); - RenderSystem.setShader(GameRenderer::getPositionShader); - this.renderSky(p_254120_, p_323920_, f, p_109604_, flag1, () -> FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f1, flag1, f)); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY, this, null, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - profilerfiller.popPush("fog"); - FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f1, 32.0F), flag1, f); - profilerfiller.popPush("terrain_setup"); -@@ -953,7 +_,9 @@ - this.compileSections(p_109604_); - profilerfiller.popPush("terrain"); - this.renderSectionLayer(RenderType.solid(), d0, d1, d2, p_254120_, p_323920_); -+ this.minecraft.getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).setBlurMipmap(false, this.minecraft.options.mipmapLevels().get() > 0); // Neo: fix flickering leaves when mods mess up the blurMipmap settings - this.renderSectionLayer(RenderType.cutoutMipped(), d0, d1, d2, p_254120_, p_323920_); -+ this.minecraft.getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).restoreLastBlurMipmap(); - this.renderSectionLayer(RenderType.cutout(), d0, d1, d2, p_254120_, p_323920_); - if (this.level.effects().constantAmbientLight()) { - Lighting.setupNetherLevel(); -@@ -996,7 +_,7 @@ - || p_109604_.isDetached() - || p_109604_.getEntity() instanceof LivingEntity && ((LivingEntity)p_109604_.getEntity()).isSleeping() ++ /** ++ * @deprecated Neo: use {@link #addWeatherPass(FrameGraphBuilder, LightTexture, Vec3, float, FogParameters, Matrix4f, Matrix4f, Camera)} instead ++ */ ++ @Deprecated + private void addWeatherPass(FrameGraphBuilder p_364025_, LightTexture p_361536_, Vec3 p_360771_, float p_362434_, FogParameters p_360974_) { ++ addWeatherPass(p_364025_, p_361536_, p_360771_, p_362434_, p_360974_, RenderSystem.getModelViewMatrix(), RenderSystem.getProjectionMatrix(), this.minecraft.gameRenderer.getMainCamera()); ++ } ++ ++ private void addWeatherPass(FrameGraphBuilder p_364025_, LightTexture p_361536_, Vec3 p_360771_, float p_362434_, FogParameters p_360974_, Matrix4f modelViewMatrix, Matrix4f projectionMatrix, Camera camera) { + int i = this.minecraft.options.getEffectiveRenderDistance() * 16; + float f = this.minecraft.gameRenderer.getDepthFar(); + FramePass framepass = p_364025_.addPass("weather"); +@@ -731,6 +_,7 @@ + RenderSystem.setShaderFog(p_360974_); + RenderStateShard.WEATHER_TARGET.setupRenderState(); + this.weatherEffectRenderer.render(this.minecraft.level, p_361536_, this.ticks, p_362434_, p_360771_); ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, null, modelViewMatrix, projectionMatrix, this.ticks, camera, getFrustum()); + this.worldBorderRenderer.render(this.level.getWorldBorder(), p_360771_, (double)i, (double)f); + RenderStateShard.WEATHER_TARGET.clearRenderState(); + }); +@@ -775,11 +_,14 @@ + || p_363510_.isDetached() + || p_363510_.getEntity() instanceof LivingEntity && ((LivingEntity)p_363510_.getEntity()).isSleeping() ) -- && (!(entity instanceof LocalPlayer) || p_109604_.getEntity() == entity)) { -+ && (!(entity instanceof LocalPlayer) || p_109604_.getEntity() == entity || (entity == minecraft.player && !minecraft.player.isSpectator()))) { // Neo: render local player entity when it is not the camera entity - this.renderedEntities++; - if (entity.tickCount == 0) { - entity.xOld = entity.getX(); -@@ -1012,6 +_,9 @@ - int i = entity.getTeamColor(); - outlinebuffersource.setColor(FastColor.ARGB32.red(i), FastColor.ARGB32.green(i), FastColor.ARGB32.blue(i), 255); - } else { -+ if (this.shouldShowEntityOutlines() && entity.hasCustomOutlineRendering(this.minecraft.player)) { // FORGE: allow custom outline rendering -+ flag2 = true; -+ } - multibuffersource = multibuffersource$buffersource; +- && (!(entity instanceof LocalPlayer) || p_363510_.getEntity() == entity)) { ++ && (!(entity instanceof LocalPlayer) || p_363510_.getEntity() == entity || (entity == minecraft.player && !minecraft.player.isSpectator()))) { // Neo: render local player entity when it is not the camera entity + p_363380_.add(entity); + if (flag1 && this.minecraft.shouldEntityAppearGlowing(entity)) { + flag = true; } ++ else if (flag1 && entity.hasCustomOutlineRendering(this.minecraft.player)) { // FORGE: allow custom outline rendering ++ flag = true; ++ } + } + } + } +@@ -825,10 +_,12 @@ + double d1 = vec3.y(); + double d2 = vec3.z(); -@@ -1027,12 +_,14 @@ - multibuffersource$buffersource.endBatch(RenderType.entityCutout(TextureAtlas.LOCATION_BLOCKS)); - multibuffersource$buffersource.endBatch(RenderType.entityCutoutNoCull(TextureAtlas.LOCATION_BLOCKS)); - multibuffersource$buffersource.endBatch(RenderType.entitySmoothCutout(TextureAtlas.LOCATION_BLOCKS)); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_ENTITIES, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - profilerfiller.popPush("blockentities"); - ++ Frustum frustum = getFrustum(); for (SectionRenderDispatcher.RenderSection sectionrenderdispatcher$rendersection : this.visibleSections) { List list = sectionrenderdispatcher$rendersection.getCompiled().getRenderableBlockEntities(); if (!list.isEmpty()) { - for (BlockEntity blockentity1 : list) { -+ if (!net.neoforged.neoforge.client.ClientHooks.isBlockEntityRendererVisible(blockEntityRenderDispatcher, blockentity1, frustum)) continue; - BlockPos blockpos4 = blockentity1.getBlockPos(); - MultiBufferSource multibuffersource1 = multibuffersource$buffersource; - posestack.pushPose(); -@@ -1051,6 +_,9 @@ - }; - } - } -+ if (this.shouldShowEntityOutlines() && blockentity1.hasCustomOutlineRendering(this.minecraft.player)) { // Neo: allow custom outline rendering -+ flag2 = true; -+ } - - this.blockEntityRenderDispatcher.render(blockentity1, f, posestack, multibuffersource1); - posestack.popPose(); -@@ -1060,9 +_,13 @@ + for (BlockEntity blockentity : list) { ++ if (!net.neoforged.neoforge.client.ClientHooks.isBlockEntityRendererVisible(blockEntityRenderDispatcher, blockentity, frustum)) continue; + BlockPos blockpos = blockentity.getBlockPos(); + MultiBufferSource multibuffersource = p_363819_; + p_362832_.pushPose(); +@@ -856,6 +_,7 @@ synchronized (this.globalBlockEntities) { - for (BlockEntity blockentity : this.globalBlockEntities) { -+ if (!net.neoforged.neoforge.client.ClientHooks.isBlockEntityRendererVisible(blockEntityRenderDispatcher, blockentity, frustum)) continue; - BlockPos blockpos3 = blockentity.getBlockPos(); - posestack.pushPose(); - posestack.translate((double)blockpos3.getX() - d0, (double)blockpos3.getY() - d1, (double)blockpos3.getZ() - d2); -+ if (this.shouldShowEntityOutlines() && blockentity.hasCustomOutlineRendering(this.minecraft.player)) { // Neo: allow custom outline rendering -+ flag2 = true; -+ } - this.blockEntityRenderDispatcher.render(blockentity, f, posestack, multibuffersource$buffersource); - posestack.popPose(); - } -@@ -1080,11 +_,17 @@ - multibuffersource$buffersource.endBatch(Sheets.hangingSignSheet()); - multibuffersource$buffersource.endBatch(Sheets.chestSheet()); - this.renderBuffers.outlineBufferSource().endOutlineBatch(); -+ // Neo: handle outline effect requests outside glowing entities -+ if (this.outlineEffectRequested) { -+ flag2 |= this.shouldShowEntityOutlines(); -+ this.outlineEffectRequested = false; -+ } - if (flag2) { - this.entityEffect.process(p_348530_.getGameTimeDeltaTicks()); - this.minecraft.getMainRenderTarget().bindWrite(false); - } - -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_BLOCK_ENTITIES, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - profilerfiller.popPush("destroyProgress"); - - for (Entry> entry : this.destructionProgress.long2ObjectEntrySet()) { -@@ -1102,9 +_,10 @@ - VertexConsumer vertexconsumer1 = new SheetedDecalTextureGenerator( - this.renderBuffers.crumblingBufferSource().getBuffer(ModelBakery.DESTROY_TYPES.get(k)), posestack$pose1, 1.0F + for (BlockEntity blockentity1 : this.globalBlockEntities) { ++ if (!net.neoforged.neoforge.client.ClientHooks.isBlockEntityRendererVisible(blockEntityRenderDispatcher, blockentity1, frustum)) continue; + BlockPos blockpos1 = blockentity1.getBlockPos(); + p_362832_.pushPose(); + p_362832_.translate((double)blockpos1.getX() - d0, (double)blockpos1.getY() - d1, (double)blockpos1.getZ() - d2); +@@ -883,9 +_,10 @@ + VertexConsumer vertexconsumer = new SheetedDecalTextureGenerator( + p_365216_.getBuffer(ModelBakery.DESTROY_TYPES.get(i)), posestack$pose, 1.0F ); -+ net.neoforged.neoforge.client.model.data.ModelData modelData = level.getModelData(blockpos2); ++ net.neoforged.neoforge.client.model.data.ModelData modelData = level.getModelData(blockpos); this.minecraft .getBlockRenderer() -- .renderBreakingTexture(this.level.getBlockState(blockpos2), blockpos2, this.level, posestack, vertexconsumer1); -+ .renderBreakingTexture(this.level.getBlockState(blockpos2), blockpos2, this.level, posestack, vertexconsumer1, modelData); - posestack.popPose(); +- .renderBreakingTexture(this.level.getBlockState(blockpos), blockpos, this.level, p_363901_, vertexconsumer); ++ .renderBreakingTexture(this.level.getBlockState(blockpos), blockpos, this.level, p_363901_, vertexconsumer, modelData); + p_363901_.popPose(); } } -@@ -1116,10 +_,13 @@ - profilerfiller.popPush("outline"); - BlockPos blockpos1 = ((BlockHitResult)hitresult).getBlockPos(); - BlockState blockstate = this.level.getBlockState(blockpos1); -+ if (!net.neoforged.neoforge.client.ClientHooks.onDrawHighlight(this, p_109604_, hitresult, p_348530_, posestack, multibuffersource$buffersource)) - if (!blockstate.isAir() && this.level.getWorldBorder().isWithinBounds(blockpos1)) { - VertexConsumer vertexconsumer2 = multibuffersource$buffersource.getBuffer(RenderType.lines()); - this.renderHitOutline(posestack, vertexconsumer2, p_109604_.getEntity(), d0, d1, d2, blockpos1, blockstate); - } -+ } else if (hitresult != null && hitresult.getType() == HitResult.Type.ENTITY) { -+ net.neoforged.neoforge.client.ClientHooks.onDrawHighlight(this, p_109604_, hitresult, p_348530_, posestack, multibuffersource$buffersource); - } - - this.minecraft.debugRenderer.render(posestack, multibuffersource$buffersource, d0, d1, d2); -@@ -1147,9 +_,13 @@ - this.particlesTarget.copyDepthFrom(this.minecraft.getMainRenderTarget()); - RenderStateShard.PARTICLES_TARGET.setupRenderState(); - profilerfiller.popPush("particles"); -- this.minecraft.particleEngine.render(p_109606_, p_109604_, f); -+ this.minecraft.particleEngine.render(p_109606_, p_109604_, f, frustum, type -> true); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - RenderStateShard.PARTICLES_TARGET.clearRenderState(); - } else { -+ // Neo: render solid particles before translucent geometry to match order of chunk render types, fixes solid particles disappearing underwater in Fast/Fancy (MC-161917) -+ profilerfiller.popPush("solid_particles"); -+ this.minecraft.particleEngine.render(p_109606_, p_109604_, f, frustum, type -> !type.isTranslucent()); - profilerfiller.popPush("translucent"); - if (this.translucentTarget != null) { - this.translucentTarget.clear(Minecraft.ON_OSX); -@@ -1161,7 +_,8 @@ - profilerfiller.popPush("string"); - this.renderSectionLayer(RenderType.tripwire(), d0, d1, d2, p_254120_, p_323920_); - profilerfiller.popPush("particles"); -- this.minecraft.particleEngine.render(p_109606_, p_109604_, f); -+ this.minecraft.particleEngine.render(p_109606_, p_109604_, f, frustum, type -> type.isTranslucent()); // Neo: only render translucent particles at this stage -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_PARTICLES, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - } - - if (this.minecraft.options.getCloudsType() != CloudStatus.OFF) { -@@ -1177,6 +_,7 @@ - RenderStateShard.WEATHER_TARGET.setupRenderState(); - profilerfiller.popPush("weather"); - this.renderSnowAndRain(p_109606_, f, d0, d1, d2); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - this.renderWorldBorder(p_109604_); - RenderStateShard.WEATHER_TARGET.clearRenderState(); - this.transparencyChain.process(p_348530_.getGameTimeDeltaTicks()); -@@ -1185,6 +_,7 @@ - RenderSystem.depthMask(false); - profilerfiller.popPush("weather"); - this.renderSnowAndRain(p_109606_, f, d0, d1, d2); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, this, posestack, p_254120_, p_323920_, this.ticks, p_109604_, frustum); - this.renderWorldBorder(p_109604_); - RenderSystem.depthMask(true); +@@ -897,8 +_,9 @@ + if (blockhitresult.getType() != HitResult.Type.MISS) { + BlockPos blockpos = blockhitresult.getBlockPos(); + BlockState blockstate = this.level.getBlockState(blockpos); ++ if (!net.neoforged.neoforge.client.ClientHooks.onDrawHighlight(this, p_363911_, blockhitresult, this.minecraft.getDeltaTracker(), p_361893_, p_362782_, p_361698_)) + if (!blockstate.isAir() && this.level.getWorldBorder().isWithinBounds(blockpos)) { +- boolean flag = ItemBlockRenderTypes.getChunkRenderType(blockstate).sortOnUpload(); ++ boolean flag = net.neoforged.neoforge.client.ClientHooks.isInTranslucentBlockOutlinePass(this.level, blockpos, blockstate); + if (flag != p_361698_) { + return; + } +@@ -1026,6 +_,7 @@ + compiledshaderprogram.clear(); + VertexBuffer.unbind(); + zone.close(); ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(p_294513_, this, p_294782_, p_324517_, this.ticks, this.minecraft.gameRenderer.getMainCamera(), this.getFrustum()); + p_294513_.clearRenderState(); } -@@ -1293,6 +_,7 @@ - shaderinstance.clear(); - VertexBuffer.unbind(); - this.minecraft.getProfiler().pop(); -+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(p_294513_, this, p_294782_, p_324517_, this.ticks, this.minecraft.gameRenderer.getMainCamera(), this.getFrustum()); - p_294513_.clearRenderState(); - } - -@@ -1543,6 +_,8 @@ } - - public void renderSky(Matrix4f p_254034_, Matrix4f p_324386_, float p_202426_, Camera p_202427_, boolean p_202428_, Runnable p_202429_) { -+ if (level.effects().renderSky(level, ticks, p_202426_, p_254034_, p_202427_, p_324386_, p_202428_, p_202429_)) -+ return; - p_202429_.run(); - if (!p_202428_) { - FogType fogtype = p_202427_.getFluidInCamera(); -@@ -1666,6 +_,8 @@ +@@ -1066,7 +_,15 @@ + } } - public void renderClouds(PoseStack p_254145_, Matrix4f p_254537_, Matrix4f p_324366_, float p_254364_, double p_253843_, double p_253663_, double p_253795_) { -+ if (level.effects().renderClouds(level, ticks, p_254364_, p_254145_, p_253843_, p_253663_, p_253795_, p_254537_, p_324366_)) -+ return; - float f = this.level.effects().getCloudHeight(); - if (!Float.isNaN(f)) { - float f1 = 12.0F; -@@ -2488,6 +_,31 @@ - this.viewArea.setDirty(p_109502_, p_109503_, p_109504_, p_109505_); - } ++ /** ++ * @deprecated Neo: use {@link #addSkyPass(FrameGraphBuilder, Camera, float, FogParameters, Matrix4f, Matrix4f)} instead ++ */ ++ @Deprecated + private void addSkyPass(FrameGraphBuilder p_362870_, Camera p_362177_, float p_363799_, FogParameters p_364999_) { ++ addSkyPass(p_362870_, p_362177_, p_363799_, p_364999_, RenderSystem.getModelViewMatrix(), RenderSystem.getProjectionMatrix()); ++ } ++ ++ private void addSkyPass(FrameGraphBuilder p_362870_, Camera p_362177_, float p_363799_, FogParameters p_364999_, Matrix4f modelViewMatrix, Matrix4f projectionMatrix) { + FogType fogtype = p_362177_.getFluidInCamera(); + if (fogtype != FogType.POWDER_SNOW && fogtype != FogType.LAVA && !this.doesMobEffectBlockSky(p_362177_)) { + DimensionSpecialEffects dimensionspecialeffects = this.level.effects(); +@@ -1075,6 +_,7 @@ + FramePass framepass = p_362870_.addPass("sky"); + this.targets.main = framepass.readsAndWrites(this.targets.main); + framepass.executes(() -> { ++ if (!level.effects().renderSky(level, ticks, p_363799_, modelViewMatrix, p_362177_, projectionMatrix, () -> RenderSystem.setShaderFog(p_364999_))) { + RenderSystem.setShaderFog(p_364999_); + RenderStateShard.MAIN_TARGET.setupRenderState(); + PoseStack posestack = new PoseStack(); +@@ -1102,6 +_,8 @@ + this.skyRenderer.renderDarkDisc(posestack); + } + } ++ } ++ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY, this, null, modelViewMatrix, projectionMatrix, this.ticks, p_362177_, getFrustum()); + }); + } + } +@@ -1413,7 +_,7 @@ + } else { + int i = p_109538_.getBrightness(LightLayer.SKY, p_109540_); + int j = p_109538_.getBrightness(LightLayer.BLOCK, p_109540_); +- int k = p_109539_.getLightEmission(); ++ int k = p_109539_.getLightEmission(p_109538_, p_109540_); + if (j < k) { + j = k; + } +@@ -1475,5 +_,22 @@ + public CloudRenderer getCloudRenderer() { + return this.cloudRenderer; ++ } ++ + public Frustum getFrustum() { + return this.capturedFrustum != null ? this.capturedFrustum : this.cullingFrustum; + } @@ -239,36 +251,5 @@ + synchronized (this.globalBlockEntities) { + this.globalBlockEntities.forEach(blockEntityConsumer); + } -+ } -+ -+ /** -+ * Neo: Request outline effect post-processing to be enabled for the current frame. Must be called before block -+ * entities are done rendering, ideally early during the frame -+ */ -+ public void requestOutlineEffect() { -+ this.outlineEffectRequested = true; -+ } -+ - public void playJukeboxSong(Holder p_350918_, BlockPos p_350830_) { - if (this.level != null) { - this.stopJukeboxSong(p_350830_); -@@ -3008,8 +_,8 @@ - break; - case 2001: - BlockState blockstate1 = Block.stateById(p_234307_); -- if (!blockstate1.isAir()) { -- SoundType soundtype = blockstate1.getSoundType(); -+ if (!blockstate1.isAir() && !net.neoforged.neoforge.client.extensions.common.IClientBlockExtensions.of(blockstate1).playBreakSound(blockstate1, this.level, p_234306_)) { -+ SoundType soundtype = blockstate1.getSoundType(this.level, p_234306_, null); - this.level - .playLocalSound( - p_234306_, soundtype.getBreakSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F, false -@@ -3495,7 +_,7 @@ - } else { - int i = p_109538_.getBrightness(LightLayer.SKY, p_109540_); - int j = p_109538_.getBrightness(LightLayer.BLOCK, p_109540_); -- int k = p_109539_.getLightEmission(); -+ int k = p_109539_.getLightEmission(p_109538_, p_109540_); - if (j < k) { - j = k; - } + } + } diff --git a/patches/net/minecraft/client/renderer/LightTexture.java.patch b/patches/net/minecraft/client/renderer/LightTexture.java.patch index 72db3bdff6..da6b2dc076 100644 --- a/patches/net/minecraft/client/renderer/LightTexture.java.patch +++ b/patches/net/minecraft/client/renderer/LightTexture.java.patch @@ -1,19 +1,10 @@ --- a/net/minecraft/client/renderer/LightTexture.java +++ b/net/minecraft/client/renderer/LightTexture.java -@@ -129,6 +_,8 @@ - } - } - -+ clientlevel.effects().adjustLightmapColors(clientlevel, p_109882_, f, f7, f8, j, i, vector3f1); -+ - if (f5 > 0.0F) { - float f13 = Math.max(vector3f1.x(), Math.max(vector3f1.y(), vector3f1.z())); - if (f13 < 1.0F) { -@@ -186,7 +_,7 @@ +@@ -141,7 +_,7 @@ } public static int block(int p_109884_) { -- return p_109884_ >> 4 & 65535; +- return p_109884_ >>> 4 & 15; + return (p_109884_ & 0xFFFF) >> 4; // Forge: Fix fullbright quads showing dark artifacts. Reported as MC-169806 } diff --git a/patches/net/minecraft/client/renderer/MapRenderer.java.patch b/patches/net/minecraft/client/renderer/MapRenderer.java.patch new file mode 100644 index 0000000000..8d0c96067c --- /dev/null +++ b/patches/net/minecraft/client/renderer/MapRenderer.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/client/renderer/MapRenderer.java ++++ b/net/minecraft/client/renderer/MapRenderer.java +@@ -42,6 +_,10 @@ + + for (MapRenderState.MapDecorationRenderState maprenderstate$mapdecorationrenderstate : p_360365_.decorations) { + if (!p_362262_ || maprenderstate$mapdecorationrenderstate.renderOnFrame) { ++ if (net.neoforged.neoforge.client.gui.map.MapDecorationRendererManager.render(maprenderstate$mapdecorationrenderstate, p_362483_, p_363581_, p_360365_, MapRenderer.this.decorationTextures, p_362262_, p_364872_, i)) { ++ i++; ++ continue; ++ } + p_362483_.pushPose(); + p_362483_.translate( + (float)maprenderstate$mapdecorationrenderstate.x / 2.0F + 64.0F, (float)maprenderstate$mapdecorationrenderstate.y / 2.0F + 64.0F, -0.02F +@@ -116,6 +_,7 @@ + + private MapRenderState.MapDecorationRenderState extractDecorationRenderState(MapDecoration p_364175_) { + MapRenderState.MapDecorationRenderState maprenderstate$mapdecorationrenderstate = new MapRenderState.MapDecorationRenderState(); ++ maprenderstate$mapdecorationrenderstate.type = p_364175_.type(); + maprenderstate$mapdecorationrenderstate.atlasSprite = this.decorationTextures.get(p_364175_); + maprenderstate$mapdecorationrenderstate.x = p_364175_.x(); + maprenderstate$mapdecorationrenderstate.y = p_364175_.y(); diff --git a/patches/net/minecraft/client/renderer/PanoramaRenderer.java.patch b/patches/net/minecraft/client/renderer/PanoramaRenderer.java.patch deleted file mode 100644 index 4111b68d7d..0000000000 --- a/patches/net/minecraft/client/renderer/PanoramaRenderer.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/renderer/PanoramaRenderer.java -+++ b/net/minecraft/client/renderer/PanoramaRenderer.java -@@ -30,6 +_,8 @@ - p_334063_.blit(PANORAMA_OVERLAY, 0, 0, p_333839_, p_333923_, 0.0F, 0.0F, 16, 128, 16, 128); - p_334063_.setColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.disableBlend(); -+ // Neo: disable depth test again to prevent issues with extended far plane values for screen layers and HUD layers -+ RenderSystem.disableDepthTest(); - } - - private static float wrap(float p_249058_, float p_249548_) { diff --git a/patches/net/minecraft/client/renderer/PostChain.java.patch b/patches/net/minecraft/client/renderer/PostChain.java.patch deleted file mode 100644 index 7dbfffbbf7..0000000000 --- a/patches/net/minecraft/client/renderer/PostChain.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/client/renderer/PostChain.java -+++ b/net/minecraft/client/renderer/PostChain.java -@@ -156,7 +_,8 @@ - throw new ChainedJsonException("Render target '" + s4 + "' can't be used as depth buffer"); - } - -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("textures/effect/" + s4 + ".png"); -+ ResourceLocation rl = ResourceLocation.tryParse(s4); -+ ResourceLocation resourcelocation = ResourceLocation.fromNamespaceAndPath(rl.getNamespace(), "textures/effect/" + rl.getPath() + ".png"); - this.resourceProvider - .getResource(resourcelocation) - .orElseThrow(() -> new ChainedJsonException("Render target or texture '" + s4 + "' does not exist")); -@@ -257,6 +_,7 @@ - public void addTempTarget(String p_110039_, int p_110040_, int p_110041_) { - RenderTarget rendertarget = new TextureTarget(p_110040_, p_110041_, true, Minecraft.ON_OSX); - rendertarget.setClearColor(0.0F, 0.0F, 0.0F, 0.0F); -+ if (screenTarget.isStencilEnabled()) { rendertarget.enableStencil(); } - this.customRenderTargets.put(p_110039_, rendertarget); - if (p_110040_ == this.screenWidth && p_110041_ == this.screenHeight) { - this.fullSizedTargets.add(rendertarget); diff --git a/patches/net/minecraft/client/renderer/RenderBuffers.java.patch b/patches/net/minecraft/client/renderer/RenderBuffers.java.patch index 97da5ee8f4..ad6b76cc6e 100644 --- a/patches/net/minecraft/client/renderer/RenderBuffers.java.patch +++ b/patches/net/minecraft/client/renderer/RenderBuffers.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/renderer/RenderBuffers.java +++ b/net/minecraft/client/renderer/RenderBuffers.java -@@ -37,6 +_,7 @@ - put((Object2ObjectLinkedOpenHashMap)p_349871_, RenderType.waterMask()); - ModelBakery.DESTROY_TYPES.forEach(p_173062_ -> put(p_349871_, p_173062_)); +@@ -35,6 +_,7 @@ + put((Object2ObjectLinkedOpenHashMap)p_366352_, RenderType.entityGlint()); + put((Object2ObjectLinkedOpenHashMap)p_366352_, RenderType.waterMask()); }); + net.neoforged.fml.ModLoader.postEvent(new net.neoforged.neoforge.client.event.RegisterRenderBuffersEvent(sequencedmap)); - this.crumblingBufferSource = MultiBufferSource.immediate(new ByteBufferBuilder(1536)); this.bufferSource = MultiBufferSource.immediateWithBuffers(sequencedmap, new ByteBufferBuilder(786432)); this.outlineBufferSource = new OutlineBufferSource(this.bufferSource); + SequencedMap sequencedmap1 = Util.make( diff --git a/patches/net/minecraft/client/renderer/RenderType.java.patch b/patches/net/minecraft/client/renderer/RenderType.java.patch index 568f074649..3186edd211 100644 --- a/patches/net/minecraft/client/renderer/RenderType.java.patch +++ b/patches/net/minecraft/client/renderer/RenderType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/RenderType.java +++ b/net/minecraft/client/renderer/RenderType.java -@@ -968,7 +_,7 @@ +@@ -1098,7 +_,7 @@ } public static RenderType text(ResourceLocation p_110498_) { @@ -9,7 +9,7 @@ } public static RenderType textBackground() { -@@ -976,19 +_,19 @@ +@@ -1106,19 +_,19 @@ } public static RenderType textIntensity(ResourceLocation p_173238_) { @@ -33,7 +33,7 @@ } public static RenderType textBackgroundSeeThrough() { -@@ -996,7 +_,7 @@ +@@ -1126,7 +_,7 @@ } public static RenderType textIntensitySeeThrough(ResourceLocation p_173241_) { @@ -42,7 +42,7 @@ } public static RenderType lightning() { -@@ -1453,5 +_,17 @@ +@@ -1622,5 +_,17 @@ public String toString() { return this.name; } diff --git a/patches/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch b/patches/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch index ca33ed7840..901854e375 100644 --- a/patches/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/ScreenEffectRenderer.java.patch @@ -55,7 +55,7 @@ + } + + public static void renderFluid(Minecraft p_110726_, PoseStack p_110727_, ResourceLocation texture) { - RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShader(CoreShaders.POSITION_TEX); - RenderSystem.setShaderTexture(0, UNDERWATER_LOCATION); + RenderSystem.setShaderTexture(0, texture); BlockPos blockpos = BlockPos.containing(p_110726_.player.getX(), p_110726_.player.getEyeY(), p_110726_.player.getZ()); diff --git a/patches/net/minecraft/client/renderer/ShaderInstance.java.patch b/patches/net/minecraft/client/renderer/ShaderInstance.java.patch deleted file mode 100644 index 2192fa0913..0000000000 --- a/patches/net/minecraft/client/renderer/ShaderInstance.java.patch +++ /dev/null @@ -1,57 +0,0 @@ ---- a/net/minecraft/client/renderer/ShaderInstance.java -+++ b/net/minecraft/client/renderer/ShaderInstance.java -@@ -94,10 +_,14 @@ - @Nullable - public final Uniform CHUNK_OFFSET; - -+ @Deprecated // FORGE: Use the ResourceLocation variant below - public ShaderInstance(ResourceProvider p_173336_, String p_173337_, VertexFormat p_173338_) throws IOException { -- this.name = p_173337_; -+ this(p_173336_, ResourceLocation.parse(p_173337_), p_173338_); -+ } -+ public ShaderInstance(ResourceProvider p_173336_, ResourceLocation shaderLocation, VertexFormat p_173338_) throws IOException { -+ this.name = shaderLocation.getNamespace().equals("minecraft") ? shaderLocation.getPath() : shaderLocation.toString(); - this.vertexFormat = p_173338_; -- ResourceLocation resourcelocation = ResourceLocation.withDefaultNamespace("shaders/core/" + p_173337_ + ".json"); -+ ResourceLocation resourcelocation = ResourceLocation.fromNamespaceAndPath(shaderLocation.getNamespace(), "shaders/core/" + shaderLocation.getPath() + ".json"); - - try (Reader reader = p_173336_.openAsReader(resourcelocation)) { - JsonObject jsonobject = GsonHelper.parse(reader); -@@ -177,8 +_,10 @@ - Program program1 = p_173342_.getPrograms().get(p_173343_); - Program program; - if (program1 == null) { -- String s = "shaders/core/" + p_173343_ + p_173342_.getExtension(); -- Resource resource = p_173341_.getResourceOrThrow(ResourceLocation.withDefaultNamespace(s)); -+ ResourceLocation loc = ResourceLocation.parse(p_173343_); -+ String s = "shaders/core/" + loc.getPath() + p_173342_.getExtension(); -+ ResourceLocation resourcelocation = ResourceLocation.fromNamespaceAndPath(loc.getNamespace(), s); -+ Resource resource = p_173341_.getResourceOrThrow(resourcelocation); - - try (InputStream inputstream = resource.open()) { - final String s1 = FileUtil.getFullResourcePath(s); -@@ -187,11 +_,11 @@ - - @Override - public String applyImport(boolean p_173374_, String p_173375_) { -- p_173375_ = FileUtil.normalizeResourcePath((p_173374_ ? s1 : "shaders/include/") + p_173375_); -- if (!this.importedPaths.add(p_173375_)) { -+ // FORGE: use the mod's namespace to look up resources if specified -+ ResourceLocation resourcelocation = net.neoforged.neoforge.client.ClientHooks.getShaderImportLocation(s1, p_173374_, p_173375_); -+ if (!this.importedPaths.add(resourcelocation.toString())) { - return null; - } else { -- ResourceLocation resourcelocation = ResourceLocation.parse(p_173375_); - - try { - String s2; -@@ -201,7 +_,8 @@ - - return s2; - } catch (IOException ioexception) { -- ShaderInstance.LOGGER.error("Could not open GLSL import {}: {}", p_173375_, ioexception.getMessage()); -+ // FORGE: specify the namespace of the failed import in case of duplicates from multiple mods -+ ShaderInstance.LOGGER.error("Could not open GLSL import {}: {}", resourcelocation, ioexception.getMessage()); - return "#error " + ioexception.getMessage(); - } - } diff --git a/patches/net/minecraft/client/renderer/ShaderManager.java.patch b/patches/net/minecraft/client/renderer/ShaderManager.java.patch new file mode 100644 index 0000000000..4e634d23e7 --- /dev/null +++ b/patches/net/minecraft/client/renderer/ShaderManager.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/renderer/ShaderManager.java ++++ b/net/minecraft/client/renderer/ShaderManager.java +@@ -169,7 +_,7 @@ + ShaderManager.CompilationCache shadermanager$compilationcache = new ShaderManager.CompilationCache(p_366597_); + Map map = new HashMap<>(); + +- for (ShaderProgram shaderprogram : CoreShaders.getProgramsToPreload()) { ++ for (ShaderProgram shaderprogram : net.neoforged.neoforge.client.CoreShaderManager.getProgramsToPreload()) { + try { + shadermanager$compilationcache.programs.put(shaderprogram, Optional.of(shadermanager$compilationcache.compileProgram(shaderprogram))); + } catch (ShaderManager.CompilationException shadermanager$compilationexception) { diff --git a/patches/net/minecraft/client/renderer/Sheets.java.patch b/patches/net/minecraft/client/renderer/Sheets.java.patch index b2ff568d8a..cb01eb86db 100644 --- a/patches/net/minecraft/client/renderer/Sheets.java.patch +++ b/patches/net/minecraft/client/renderer/Sheets.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/Sheets.java +++ b/net/minecraft/client/renderer/Sheets.java -@@ -146,11 +_,13 @@ +@@ -141,11 +_,13 @@ } private static Material createSignMaterial(WoodType p_173386_) { @@ -16,7 +16,7 @@ } public static Material getSignMaterial(WoodType p_173382_) { -@@ -209,6 +_,23 @@ +@@ -204,6 +_,23 @@ case SINGLE: default: return p_110773_; diff --git a/patches/net/minecraft/client/renderer/WeatherEffectRenderer.java.patch b/patches/net/minecraft/client/renderer/WeatherEffectRenderer.java.patch new file mode 100644 index 0000000000..180f282591 --- /dev/null +++ b/patches/net/minecraft/client/renderer/WeatherEffectRenderer.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/client/renderer/WeatherEffectRenderer.java ++++ b/net/minecraft/client/renderer/WeatherEffectRenderer.java +@@ -61,6 +_,8 @@ + } + + public void render(Level p_364994_, LightTexture p_363130_, int p_363664_, float p_361655_, Vec3 p_363375_) { ++ if (((ClientLevel) p_364994_).effects().renderSnowAndRain((ClientLevel) p_364994_, p_363664_, p_361655_, p_363130_, p_363375_.x, p_363375_.y, p_363375_.z)) ++ return; + float f = p_364994_.getRainLevel(p_361655_); + if (!(f <= 0.0F)) { + int i = Minecraft.useFancyGraphics() ? 10 : 5; +@@ -201,6 +_,8 @@ + } + + public void tickRainParticles(ClientLevel p_361823_, Camera p_364990_, int p_361788_, ParticleStatus p_363302_) { ++ if (p_361823_.effects().tickRain(p_361823_, p_361788_, p_364990_)) ++ return; + float f = p_361823_.getRainLevel(1.0F) / (Minecraft.useFancyGraphics() ? 1.0F : 2.0F); + if (!(f <= 0.0F)) { + RandomSource randomsource = RandomSource.create((long)p_361788_ * 312987231L); diff --git a/patches/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch b/patches/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch index b393006515..5ee7f47292 100644 --- a/patches/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch +++ b/patches/net/minecraft/client/renderer/block/BlockRenderDispatcher.java.patch @@ -91,8 +91,8 @@ this.modelRenderer .renderModel( p_110914_.last(), -- p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_, false)), -+ p_110915_.getBuffer(renderType != null ? renderType : net.neoforged.neoforge.client.RenderTypeHelper.getEntityRenderType(rt, false)), +- p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_)), ++ p_110915_.getBuffer(renderType != null ? renderType : net.neoforged.neoforge.client.RenderTypeHelper.getEntityRenderType(rt)), p_110913_, bakedmodel, f, diff --git a/patches/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch b/patches/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch index 5eab04bb47..f2ca146f9c 100644 --- a/patches/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/block/LiquidBlockRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/LiquidBlockRenderer.java +++ b/net/minecraft/client/renderer/block/LiquidBlockRenderer.java -@@ -38,6 +_,7 @@ +@@ -37,6 +_,7 @@ this.waterIcons[0] = Minecraft.getInstance().getModelManager().getBlockModelShaper().getBlockModel(Blocks.WATER.defaultBlockState()).getParticleIcon(); this.waterIcons[1] = ModelBakery.WATER_FLOW.sprite(); this.waterOverlay = ModelBakery.WATER_OVERLAY.sprite(); @@ -20,7 +20,7 @@ float f = (float)(i >> 16 & 0xFF) / 255.0F; float f1 = (float)(i >> 8 & 0xFF) / 255.0F; float f2 = (float)(i & 0xFF) / 255.0F; -@@ -181,15 +_,15 @@ +@@ -180,15 +_,15 @@ float f57 = f4 * f; float f29 = f4 * f1; float f30 = f4 * f2; @@ -44,7 +44,7 @@ } } -@@ -202,10 +_,10 @@ +@@ -201,10 +_,10 @@ float f46 = f3 * f; float f48 = f3 * f1; float f50 = f3 * f2; @@ -59,8 +59,8 @@ } int j = this.getLightColor(p_234370_, p_234371_); -@@ -260,10 +_,9 @@ - && !isFaceOccludedByNeighbor(p_234370_, p_234371_, direction, Math.max(f44, f45), p_234370_.getBlockState(p_234371_.relative(direction)))) { +@@ -258,10 +_,9 @@ + if (flag7 && !isFaceOccludedByNeighbor(direction, Math.max(f44, f45), p_234370_.getBlockState(p_234371_.relative(direction)))) { BlockPos blockpos = p_234371_.relative(direction); TextureAtlasSprite textureatlassprite2 = atextureatlassprite[1]; - if (!flag) { @@ -73,7 +73,7 @@ } } -@@ -276,15 +_,15 @@ +@@ -274,15 +_,15 @@ float f33 = f4 * f32 * f; float f34 = f4 * f32 * f1; float f35 = f4 * f32 * f2; @@ -98,7 +98,7 @@ } } } -@@ -325,6 +_,26 @@ +@@ -323,6 +_,26 @@ private float getHeight(BlockAndTintGetter p_203157_, Fluid p_203158_, BlockPos p_203159_) { BlockState blockstate = p_203157_.getBlockState(p_203159_); return this.getHeight(p_203157_, p_203158_, p_203159_, blockstate, blockstate.getFluidState()); diff --git a/patches/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch b/patches/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch index 94bd0b01f0..49d5af1f7a 100644 --- a/patches/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/block/ModelBlockRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/ModelBlockRenderer.java +++ b/net/minecraft/client/renderer/block/ModelBlockRenderer.java -@@ -40,6 +_,7 @@ +@@ -39,6 +_,7 @@ this.blockColors = p_110999_; } @@ -8,34 +8,34 @@ public void tesselateBlock( BlockAndTintGetter p_234380_, BakedModel p_234381_, -@@ -52,15 +_,35 @@ +@@ -51,14 +_,35 @@ long p_234388_, int p_234389_ ) { - boolean flag = Minecraft.useAmbientOcclusion() && p_234382_.getLightEmission() == 0 && p_234381_.useAmbientOcclusion(); + tesselateBlock(p_234380_, p_234381_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234387_, p_234388_, p_234389_, net.neoforged.neoforge.client.model.data.ModelData.EMPTY, null); + } ++ + public void tesselateBlock( -+ BlockAndTintGetter p_234380_, -+ BakedModel p_234381_, -+ BlockState p_234382_, -+ BlockPos p_234383_, -+ PoseStack p_234384_, -+ VertexConsumer p_234385_, -+ boolean p_234386_, -+ RandomSource p_234387_, -+ long p_234388_, -+ int p_234389_, -+ net.neoforged.neoforge.client.model.data.ModelData modelData, -+ net.minecraft.client.renderer.RenderType renderType ++ BlockAndTintGetter p_234380_, ++ BakedModel p_234381_, ++ BlockState p_234382_, ++ BlockPos p_234383_, ++ PoseStack p_234384_, ++ VertexConsumer p_234385_, ++ boolean p_234386_, ++ RandomSource p_234387_, ++ long p_234388_, ++ int p_234389_, ++ net.neoforged.neoforge.client.model.data.ModelData modelData, ++ net.minecraft.client.renderer.RenderType renderType + ) { + boolean flag = Minecraft.useAmbientOcclusion() && switch(p_234381_.useAmbientOcclusion(p_234382_, modelData, renderType)) { + case TRUE -> true; + case DEFAULT -> p_234382_.getLightEmission(p_234380_, p_234383_) == 0; + case FALSE -> false; + }; - Vec3 vec3 = p_234382_.getOffset(p_234380_, p_234383_); - p_234384_.translate(vec3.x, vec3.y, vec3.z); + p_234384_.translate(p_234382_.getOffset(p_234383_)); try { if (flag) { @@ -47,7 +47,7 @@ } } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating block model"); -@@ -71,6 +_,7 @@ +@@ -69,6 +_,7 @@ } } @@ -55,12 +55,13 @@ public void tesselateWithAO( BlockAndTintGetter p_234391_, BakedModel p_234392_, -@@ -83,6 +_,22 @@ +@@ -81,6 +_,23 @@ long p_234399_, int p_234400_ ) { + tesselateWithAO(p_234391_, p_234392_, p_234393_, p_234394_, p_234395_, p_234396_, p_234397_, p_234398_, p_234399_, p_234400_, net.neoforged.neoforge.client.model.data.ModelData.EMPTY, null); + } ++ + public void tesselateWithAO( + BlockAndTintGetter p_234391_, + BakedModel p_234392_, @@ -78,7 +79,7 @@ float[] afloat = new float[DIRECTIONS.length * 2]; BitSet bitset = new BitSet(3); ModelBlockRenderer.AmbientOcclusionFace modelblockrenderer$ambientocclusionface = new ModelBlockRenderer.AmbientOcclusionFace(); -@@ -90,7 +_,7 @@ +@@ -88,10 +_,10 @@ for (Direction direction : DIRECTIONS) { p_234398_.setSeed(p_234399_); @@ -86,8 +87,12 @@ + List list = p_234392_.getQuads(p_234393_, direction, p_234398_, modelData, renderType); if (!list.isEmpty()) { blockpos$mutableblockpos.setWithOffset(p_234394_, direction); - if (!p_234397_ || Block.shouldRenderFace(p_234393_, p_234391_, p_234394_, direction, blockpos$mutableblockpos)) { -@@ -102,7 +_,7 @@ +- if (!p_234397_ || Block.shouldRenderFace(p_234393_, p_234391_.getBlockState(blockpos$mutableblockpos), direction)) { ++ if (!p_234397_ || Block.shouldRenderFace(p_234391_, p_234394_, p_234393_, p_234391_.getBlockState(blockpos$mutableblockpos), direction)) { + this.renderModelFaceAO( + p_234391_, p_234393_, p_234394_, p_234395_, p_234396_, list, afloat, bitset, modelblockrenderer$ambientocclusionface, p_234400_ + ); +@@ -100,7 +_,7 @@ } p_234398_.setSeed(p_234399_); @@ -96,7 +101,7 @@ if (!list1.isEmpty()) { this.renderModelFaceAO( p_234391_, p_234393_, p_234394_, p_234395_, p_234396_, list1, afloat, bitset, modelblockrenderer$ambientocclusionface, p_234400_ -@@ -110,6 +_,7 @@ +@@ -108,6 +_,7 @@ } } @@ -104,12 +109,13 @@ public void tesselateWithoutAO( BlockAndTintGetter p_234402_, BakedModel p_234403_, -@@ -122,12 +_,28 @@ +@@ -120,15 +_,32 @@ long p_234410_, int p_234411_ ) { + tesselateWithoutAO(p_234402_, p_234403_, p_234404_, p_234405_, p_234406_, p_234407_, p_234408_, p_234409_, p_234410_, p_234411_, net.neoforged.neoforge.client.model.data.ModelData.EMPTY, null); + } ++ + public void tesselateWithoutAO( + BlockAndTintGetter p_234402_, + BakedModel p_234403_, @@ -133,8 +139,12 @@ + List list = p_234403_.getQuads(p_234404_, direction, p_234409_, modelData, renderType); if (!list.isEmpty()) { blockpos$mutableblockpos.setWithOffset(p_234405_, direction); - if (!p_234408_ || Block.shouldRenderFace(p_234404_, p_234402_, p_234405_, direction, blockpos$mutableblockpos)) { -@@ -138,7 +_,7 @@ +- if (!p_234408_ || Block.shouldRenderFace(p_234404_, p_234402_.getBlockState(blockpos$mutableblockpos), direction)) { ++ if (!p_234408_ || Block.shouldRenderFace(p_234402_, p_234405_, p_234404_, p_234402_.getBlockState(blockpos$mutableblockpos), direction)) { + int i = LevelRenderer.getLightColor(p_234402_, p_234404_, blockpos$mutableblockpos); + this.renderModelFaceFlat(p_234402_, p_234404_, p_234405_, i, p_234411_, false, p_234406_, p_234407_, list, bitset); + } +@@ -136,7 +_,7 @@ } p_234409_.setSeed(p_234410_); @@ -143,7 +153,7 @@ if (!list1.isEmpty()) { this.renderModelFaceFlat(p_234402_, p_234404_, p_234405_, -1, p_234411_, true, p_234406_, p_234407_, list1, bitset); } -@@ -158,6 +_,7 @@ +@@ -156,6 +_,7 @@ ) { for (BakedQuad bakedquad : p_111018_) { this.calculateShape(p_111013_, p_111014_, p_111015_, bakedquad.getVertices(), bakedquad.getDirection(), p_111019_, p_111020_); @@ -151,7 +161,7 @@ p_111021_.calculate(p_111013_, p_111014_, p_111015_, bakedquad.getDirection(), p_111019_, p_111020_, bakedquad.isShade()); this.putQuadData( p_111013_, -@@ -323,6 +_,7 @@ +@@ -321,6 +_,7 @@ } } @@ -159,7 +169,7 @@ public void renderModel( PoseStack.Pose p_111068_, VertexConsumer p_111069_, -@@ -334,16 +_,32 @@ +@@ -332,16 +_,32 @@ int p_111075_, int p_111076_ ) { @@ -194,30 +204,27 @@ } private static void renderQuadList( -@@ -724,22 +_,22 @@ +@@ -722,19 +_,19 @@ int l = modelblockrenderer$cache.getLightColor(blockstate3, p_111168_, blockpos$mutableblockpos); float f3 = modelblockrenderer$cache.getShadeBrightness(blockstate3, p_111168_, blockpos$mutableblockpos); BlockState blockstate4 = p_111168_.getBlockState( -- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[0]).move(p_111171_) +- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[0]).move(p_366875_) + blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[0]) // Neo: remove move() to avoid oversampling (MC-43968) ); - boolean flag = !blockstate4.isViewBlocking(p_111168_, blockpos$mutableblockpos) - || blockstate4.getLightBlock(p_111168_, blockpos$mutableblockpos) == 0; + boolean flag = !blockstate4.isViewBlocking(p_111168_, blockpos$mutableblockpos) || blockstate4.getLightBlock() == 0; BlockState blockstate5 = p_111168_.getBlockState( -- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[1]).move(p_111171_) +- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[1]).move(p_366875_) + blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[1]) // Neo: remove move() to avoid oversampling (MC-43968) ); - boolean flag1 = !blockstate5.isViewBlocking(p_111168_, blockpos$mutableblockpos) - || blockstate5.getLightBlock(p_111168_, blockpos$mutableblockpos) == 0; + boolean flag1 = !blockstate5.isViewBlocking(p_111168_, blockpos$mutableblockpos) || blockstate5.getLightBlock() == 0; BlockState blockstate6 = p_111168_.getBlockState( -- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[2]).move(p_111171_) +- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[2]).move(p_366875_) + blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[2]) // Neo: remove move() to avoid oversampling (MC-43968) ); - boolean flag2 = !blockstate6.isViewBlocking(p_111168_, blockpos$mutableblockpos) - || blockstate6.getLightBlock(p_111168_, blockpos$mutableblockpos) == 0; + boolean flag2 = !blockstate6.isViewBlocking(p_111168_, blockpos$mutableblockpos) || blockstate6.getLightBlock() == 0; BlockState blockstate7 = p_111168_.getBlockState( -- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[3]).move(p_111171_) +- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[3]).move(p_366875_) + blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[3]) // Neo: remove move() to avoid oversampling (MC-43968) ); - boolean flag3 = !blockstate7.isViewBlocking(p_111168_, blockpos$mutableblockpos) - || blockstate7.getLightBlock(p_111168_, blockpos$mutableblockpos) == 0; + boolean flag3 = !blockstate7.isViewBlocking(p_111168_, blockpos$mutableblockpos) || blockstate7.getLightBlock() == 0; + float f4; diff --git a/patches/net/minecraft/client/renderer/block/model/BakedOverrides.java.patch b/patches/net/minecraft/client/renderer/block/model/BakedOverrides.java.patch new file mode 100644 index 0000000000..60cb1a713d --- /dev/null +++ b/patches/net/minecraft/client/renderer/block/model/BakedOverrides.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/client/renderer/block/model/BakedOverrides.java ++++ b/net/minecraft/client/renderer/block/model/BakedOverrides.java +@@ -29,7 +_,15 @@ + this.properties = new ResourceLocation[0]; + } + ++ /** ++ * @deprecated Neo: Use {@link #BakedOverrides(ModelBaker, List, java.util.function.Function)} ++ */ ++ @Deprecated + public BakedOverrides(ModelBaker p_371950_, List p_371198_) { ++ this(p_371950_, p_371198_, p_371950_.getModelTextureGetter()); ++ } ++ ++ public BakedOverrides(ModelBaker p_371950_, List p_371198_, java.util.function.Function spriteGetter) { + this.properties = p_371198_.stream() + .flatMap(p_371945_ -> p_371945_.predicates().stream()) + .map(ItemOverride.Predicate::property) +@@ -45,7 +_,7 @@ + + for (int j = p_371198_.size() - 1; j >= 0; j--) { + ItemOverride itemoverride = p_371198_.get(j); +- BakedModel bakedmodel = p_371950_.bake(itemoverride.model(), BlockModelRotation.X0_Y0); ++ BakedModel bakedmodel = p_371950_.bake(itemoverride.model(), BlockModelRotation.X0_Y0, spriteGetter); + BakedOverrides.PropertyMatcher[] abakedoverrides$propertymatcher = itemoverride.predicates().stream().map(p_371644_ -> { + int k = object2intmap.getInt(p_371644_.property()); + return new BakedOverrides.PropertyMatcher(k, p_371644_.value()); +@@ -80,6 +_,10 @@ + } + + return null; ++ } ++ ++ public com.google.common.collect.ImmutableList getOverrides() { ++ return com.google.common.collect.ImmutableList.copyOf(overrides); + } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/net/minecraft/client/renderer/block/model/BakedQuad.java.patch b/patches/net/minecraft/client/renderer/block/model/BakedQuad.java.patch index fb47f0c8ce..4c6541f542 100644 --- a/patches/net/minecraft/client/renderer/block/model/BakedQuad.java.patch +++ b/patches/net/minecraft/client/renderer/block/model/BakedQuad.java.patch @@ -1,29 +1,30 @@ --- a/net/minecraft/client/renderer/block/model/BakedQuad.java +++ b/net/minecraft/client/renderer/block/model/BakedQuad.java -@@ -12,13 +_,19 @@ - protected final Direction direction; +@@ -13,14 +_,20 @@ protected final TextureAtlasSprite sprite; private final boolean shade; + private final int lightEmission; + private final boolean hasAmbientOcclusion; - public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_) { -+ this(p_111298_, p_111299_, p_111300_, p_111301_, p_111302_, true); + public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, int p_361140_) { ++ this(p_111298_, p_111299_, p_111300_, p_111301_, p_111302_, p_361140_, true); + } + -+ public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, boolean hasAmbientOcclusion) { ++ public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, int p_361140_, boolean hasAmbientOcclusion) { this.vertices = p_111298_; this.tintIndex = p_111299_; this.direction = p_111300_; this.sprite = p_111301_; this.shade = p_111302_; + this.lightEmission = p_361140_; + this.hasAmbientOcclusion = hasAmbientOcclusion; } public TextureAtlasSprite getSprite() { -@@ -43,5 +_,13 @@ +@@ -49,5 +_,13 @@ - public boolean isShade() { - return this.shade; + public int getLightEmission() { + return this.lightEmission; + } + + /** diff --git a/patches/net/minecraft/client/renderer/block/model/BlockElement.java.patch b/patches/net/minecraft/client/renderer/block/model/BlockElement.java.patch index eb9ddf9135..c19fb03a3e 100644 --- a/patches/net/minecraft/client/renderer/block/model/BlockElement.java.patch +++ b/patches/net/minecraft/client/renderer/block/model/BlockElement.java.patch @@ -1,41 +1,44 @@ --- a/net/minecraft/client/renderer/block/model/BlockElement.java +++ b/net/minecraft/client/renderer/block/model/BlockElement.java -@@ -29,16 +_,23 @@ - public final Map faces; +@@ -30,6 +_,7 @@ public final BlockElementRotation rotation; public final boolean shade; + public final int lightEmission; + private net.neoforged.neoforge.client.model.ExtraFaceData faceData; - public BlockElement( - Vector3f p_253626_, Vector3f p_254426_, Map p_254454_, @Nullable BlockElementRotation p_254229_, boolean p_253661_ + public BlockElement(Vector3f p_253626_, Vector3f p_254426_, Map p_254454_) { + this(p_253626_, p_254426_, p_254454_, null, true, 0); +@@ -43,6 +_,10 @@ + boolean p_361372_, + int p_361908_ ) { -+ this(p_253626_, p_254426_, p_254454_, p_254229_, p_253661_, net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT); ++ this(p_361324_, p_363867_, p_362722_, p_360926_, p_361372_, p_361908_, net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT); + } + -+ public BlockElement(Vector3f p_253626_, Vector3f p_254426_, Map p_254454_, @Nullable BlockElementRotation p_254229_, boolean p_253661_, net.neoforged.neoforge.client.model.ExtraFaceData faceData) { - this.from = p_253626_; - this.to = p_254426_; - this.faces = p_254454_; - this.rotation = p_254229_; - this.shade = p_253661_; ++ public BlockElement(Vector3f p_361324_, Vector3f p_363867_, Map p_362722_, @Nullable BlockElementRotation p_360926_, boolean p_361372_, int p_361908_, net.neoforged.neoforge.client.model.ExtraFaceData faceData) { + this.from = p_361324_; + this.to = p_363867_; + this.faces = p_362722_; +@@ -50,6 +_,8 @@ + this.shade = p_361372_; + this.lightEmission = p_361908_; this.fillUvs(); + this.setFaceData(faceData); + this.faces.values().forEach(face -> face.parent().setValue(this)); } private void fillUvs() { -@@ -80,7 +_,9 @@ - throw new JsonParseException("Expected shade to be a Boolean"); - } else { - boolean flag = GsonHelper.getAsBoolean(jsonobject, "shade", true); -- return new BlockElement(vector3f, vector3f1, map, blockelementrotation, flag); -+ if (jsonobject.has("forge_data")) throw new JsonParseException("forge_data should be replaced by neoforge_data"); // TODO 1.22: Remove +@@ -104,7 +_,8 @@ + } + } + +- return new BlockElement(vector3f, vector3f1, map, blockelementrotation, flag, i); + var faceData = net.neoforged.neoforge.client.model.ExtraFaceData.read(jsonobject.get("neoforge_data"), net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT); -+ return new BlockElement(vector3f, vector3f1, map, blockelementrotation, flag, faceData); ++ return new BlockElement(vector3f, vector3f1, map, blockelementrotation, flag, i, faceData); } } -@@ -191,5 +_,13 @@ +@@ -215,5 +_,13 @@ return new Vector3f(afloat[0], afloat[1], afloat[2]); } } diff --git a/patches/net/minecraft/client/renderer/block/model/BlockModel.java.patch b/patches/net/minecraft/client/renderer/block/model/BlockModel.java.patch index b587befb12..767bdb3611 100644 --- a/patches/net/minecraft/client/renderer/block/model/BlockModel.java.patch +++ b/patches/net/minecraft/client/renderer/block/model/BlockModel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/block/model/BlockModel.java +++ b/net/minecraft/client/renderer/block/model/BlockModel.java -@@ -77,9 +_,10 @@ +@@ -72,9 +_,10 @@ public BlockModel parent; @Nullable protected ResourceLocation parentLocation; @@ -11,8 +11,8 @@ + return GsonHelper.fromJson(net.neoforged.neoforge.client.model.ExtendedBlockModelDeserializer.INSTANCE, p_111462_, BlockModel.class); } - public static BlockModel fromString(String p_111464_) { -@@ -104,10 +_,15 @@ + public BlockModel( +@@ -95,10 +_,15 @@ this.overrides = p_273099_; } @@ -28,42 +28,50 @@ public boolean hasAmbientOcclusion() { if (this.hasAmbientOcclusion != null) { return this.hasAmbientOcclusion; -@@ -136,6 +_,10 @@ - return this.overrides.isEmpty() ? ItemOverrides.EMPTY : new ItemOverrides(p_250138_, p_251800_, this.overrides); - } +@@ -132,10 +_,18 @@ -+ public ItemOverrides getOverrides(ModelBaker p_250138_, BlockModel p_251800_, Function spriteGetter) { -+ return this.overrides.isEmpty() ? ItemOverrides.EMPTY : new ItemOverrides(p_250138_, p_251800_, this.overrides, spriteGetter); -+ } -+ - @Override - public Collection getDependencies() { - Set set = Sets.newHashSet(); -@@ -184,6 +_,10 @@ - blockmodel.parent = (BlockModel)unbakedmodel; + this.parent = blockmodel; } - ++ + if (customData.hasCustomGeometry()) { -+ customData.getCustomGeometry().resolveParents(p_249059_, customData); ++ customData.getCustomGeometry().resolveDependencies(p_361203_, customData); + } -+ - this.overrides.forEach(p_247932_ -> { - UnbakedModel unbakedmodel1 = p_249059_.apply(p_247932_.getModel()); - if (!Objects.equals(unbakedmodel1, this)) { -@@ -198,6 +_,12 @@ } - public BakedModel bake( -+ ModelBaker p_249720_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, boolean p_111455_ -+ ) { -+ return net.neoforged.neoforge.client.model.geometry.UnbakedGeometryHelper.bake(this, p_249720_, p_111451_, p_111452_, p_111453_, p_111455_); -+ } + @Override + public BakedModel bake(ModelBaker p_252120_, Function p_250023_, ModelState p_251130_) { ++ var customGeometry = this.customData.getCustomGeometry(); ++ if (customGeometry != null) { ++ return customGeometry.bake(this.customData, p_252120_, p_250023_, p_251130_, this.overrides); ++ } + return this.bake(p_250023_, p_251130_, true); + } + +@@ -146,6 +_,10 @@ + } else { + SimpleBakedModel.Builder simplebakedmodel$builder = new SimpleBakedModel.Builder(this, p_111455_).particle(textureatlassprite); + ++ if (!this.customData.getRootTransform().isIdentity()) { ++ p_111453_ = net.neoforged.neoforge.client.model.geometry.UnbakedGeometryHelper.composeRootTransformIntoModelState(p_111453_, this.customData.getRootTransform()); ++ } + -+ public BakedModel bakeVanilla( - ModelBaker p_249720_, BlockModel p_111451_, Function p_111452_, ModelState p_111453_, boolean p_111455_ - ) { - TextureAtlasSprite textureatlassprite = p_111452_.apply(this.getMaterial("particle")); -@@ -288,7 +_,18 @@ + for (BlockElement blockelement : this.getElements()) { + for (Direction direction : blockelement.faces.keySet()) { + BlockElementFace blockelementface = blockelement.faces.get(direction); +@@ -161,7 +_,11 @@ + } + } + +- return simplebakedmodel$builder.build(); ++ var renderTypes = net.neoforged.neoforge.client.RenderTypeGroup.EMPTY; ++ if (this.customData.getRenderTypeHint() != null) { ++ renderTypes = this.customData.getRenderType(this.customData.getRenderTypeHint()); ++ } ++ return simplebakedmodel$builder.build(renderTypes); + } + } + +@@ -229,7 +_,18 @@ ItemTransform itemtransform5 = this.getTransform(ItemDisplayContext.GUI); ItemTransform itemtransform6 = this.getTransform(ItemDisplayContext.GROUND); ItemTransform itemtransform7 = this.getTransform(ItemDisplayContext.FIXED); @@ -83,12 +91,14 @@ } private ItemTransform getTransform(ItemDisplayContext p_270662_) { -@@ -407,6 +_,8 @@ +@@ -347,6 +_,10 @@ + public boolean lightLikeBlock() { return this == SIDE; - } ++ } + -+ public String getSerializedName() { return name; } ++ public String getSerializedName() { ++ return name; + } } - - @OnlyIn(Dist.CLIENT) + } diff --git a/patches/net/minecraft/client/renderer/block/model/FaceBakery.java.patch b/patches/net/minecraft/client/renderer/block/model/FaceBakery.java.patch index e24c70720e..71b9c9943e 100644 --- a/patches/net/minecraft/client/renderer/block/model/FaceBakery.java.patch +++ b/patches/net/minecraft/client/renderer/block/model/FaceBakery.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/client/renderer/block/model/FaceBakery.java +++ b/net/minecraft/client/renderer/block/model/FaceBakery.java -@@ -57,7 +_,14 @@ +@@ -58,7 +_,14 @@ this.recalculateWinding(aint, direction); } -- return new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_); +- return new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, p_364857_); + net.neoforged.neoforge.client.ClientHooks.fillNormal(aint, direction); + var data = p_111603_.faceData(); -+ var quad = new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, data.ambientOcclusion()); ++ var quad = new BakedQuad(aint, p_111603_.tintIndex(), direction, p_111604_, p_111608_, p_364857_, data.ambientOcclusion()); + if (!net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT.equals(data)) { + net.neoforged.neoforge.client.model.QuadTransformers.applyingLightmap(data.blockLight(), data.skyLight()).processInPlace(quad); + net.neoforged.neoforge.client.model.QuadTransformers.applyingColor(data.color()).processInPlace(quad); diff --git a/patches/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch b/patches/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch deleted file mode 100644 index 13a802c111..0000000000 --- a/patches/net/minecraft/client/renderer/block/model/ItemOverrides.java.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/net/minecraft/client/renderer/block/model/ItemOverrides.java -+++ b/net/minecraft/client/renderer/block/model/ItemOverrides.java -@@ -31,7 +_,15 @@ - this.properties = new ResourceLocation[0]; - } - -+ /** -+ * @deprecated Forge: Use {@link #ItemOverrides(ModelBaker, UnbakedModel, List, java.util.function.Function)} -+ */ -+ @Deprecated - public ItemOverrides(ModelBaker p_251211_, BlockModel p_111741_, List p_111743_) { -+ this(p_251211_, p_111741_, p_111743_, p_251211_.getModelTextureGetter()); -+ } -+ -+ public ItemOverrides(ModelBaker p_251211_, UnbakedModel p_111741_, List p_111743_, java.util.function.Function spriteGetter) { - this.properties = p_111743_.stream() - .flatMap(ItemOverride::getPredicates) - .map(ItemOverride.Predicate::getProperty) -@@ -47,7 +_,7 @@ - - for (int j = p_111743_.size() - 1; j >= 0; j--) { - ItemOverride itemoverride = p_111743_.get(j); -- BakedModel bakedmodel = this.bakeModel(p_251211_, p_111741_, itemoverride); -+ BakedModel bakedmodel = this.bakeModel(p_251211_, p_111741_, itemoverride, spriteGetter); - ItemOverrides.PropertyMatcher[] aitemoverrides$propertymatcher = itemoverride.getPredicates().map(p_173477_ -> { - int k = object2intmap.getInt(p_173477_.getProperty()); - return new ItemOverrides.PropertyMatcher(k, p_173477_.getValue()); -@@ -59,9 +_,9 @@ - } - - @Nullable -- private BakedModel bakeModel(ModelBaker p_249483_, BlockModel p_251965_, ItemOverride p_250816_) { -+ private BakedModel bakeModel(ModelBaker p_249483_, UnbakedModel p_251965_, ItemOverride p_250816_, java.util.function.Function spriteGetter) { - UnbakedModel unbakedmodel = p_249483_.getModel(p_250816_.getModel()); -- return Objects.equals(unbakedmodel, p_251965_) ? null : p_249483_.bake(p_250816_.getModel(), BlockModelRotation.X0_Y0); -+ return Objects.equals(unbakedmodel, p_251965_) ? null : p_249483_.bake(p_250816_.getModel(), BlockModelRotation.X0_Y0, spriteGetter); - } - - @Nullable -@@ -93,6 +_,10 @@ - } - - return p_173465_; -+ } -+ -+ public com.google.common.collect.ImmutableList getOverrides() { -+ return com.google.common.collect.ImmutableList.copyOf(overrides); - } - - @OnlyIn(Dist.CLIENT) diff --git a/patches/net/minecraft/client/renderer/block/model/MultiVariant.java.patch b/patches/net/minecraft/client/renderer/block/model/MultiVariant.java.patch index 438e617781..bd74eaf20d 100644 --- a/patches/net/minecraft/client/renderer/block/model/MultiVariant.java.patch +++ b/patches/net/minecraft/client/renderer/block/model/MultiVariant.java.patch @@ -1,11 +1,17 @@ --- a/net/minecraft/client/renderer/block/model/MultiVariant.java +++ b/net/minecraft/client/renderer/block/model/MultiVariant.java -@@ -68,7 +_,7 @@ - WeightedBakedModel.Builder weightedbakedmodel$builder = new WeightedBakedModel.Builder(); +@@ -45,12 +_,12 @@ + public BakedModel bake(ModelBaker p_249016_, Function p_111851_, ModelState p_111852_) { + if (this.variants.size() == 1) { + Variant variant1 = this.variants.getFirst(); +- return p_249016_.bake(variant1.getModelLocation(), variant1); ++ return p_249016_.bake(variant1.getModelLocation(), variant1, p_111851_); + } else { + SimpleWeightedRandomList.Builder builder = SimpleWeightedRandomList.builder(); - for (Variant variant : this.getVariants()) { + for (Variant variant : this.variants) { - BakedModel bakedmodel = p_249016_.bake(variant.getModelLocation(), variant); + BakedModel bakedmodel = p_249016_.bake(variant.getModelLocation(), variant, p_111851_); - weightedbakedmodel$builder.add(bakedmodel, variant.getWeight()); + builder.add(bakedmodel, variant.getWeight()); } diff --git a/patches/net/minecraft/client/renderer/blockentity/BannerRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/BannerRenderer.java.patch index c526f18760..81cc3164d7 100644 --- a/patches/net/minecraft/client/renderer/blockentity/BannerRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/BannerRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/blockentity/BannerRenderer.java +++ b/net/minecraft/client/renderer/blockentity/BannerRenderer.java -@@ -139,4 +_,11 @@ +@@ -141,4 +_,11 @@ int i = p_332728_.getTextureDiffuseColor(); p_332732_.render(p_332737_, p_332704_.buffer(p_332758_, RenderType::entityNoOutline), p_332821_, p_332828_, i); } diff --git a/patches/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch index a79e270319..dc78f074c0 100644 --- a/patches/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/ChestRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/blockentity/ChestRenderer.java +++ b/net/minecraft/client/renderer/blockentity/ChestRenderer.java -@@ -128,7 +_,7 @@ +@@ -66,7 +_,7 @@ f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; int i = neighborcombineresult.apply(new BrightnessCombiner<>()).applyAsInt(p_112367_); @@ -9,10 +9,10 @@ VertexConsumer vertexconsumer = material.buffer(p_112366_, RenderType::entityCutout); if (flag1) { if (chesttype == ChestType.LEFT) { -@@ -159,5 +_,15 @@ - p_112372_.render(p_112370_, p_112371_, p_112376_, p_112377_); - p_112373_.render(p_112370_, p_112371_, p_112376_, p_112377_); - p_112374_.render(p_112370_, p_112371_, p_112376_, p_112377_); +@@ -85,5 +_,15 @@ + private void render(PoseStack p_112370_, VertexConsumer p_112371_, ChestModel p_364178_, float p_112375_, int p_112376_, int p_112377_) { + p_364178_.setupAnim(p_112375_); + p_364178_.renderToBuffer(p_112370_, p_112371_, p_112376_, p_112377_); + } + + protected Material getMaterial(T blockEntity, ChestType chestType) { diff --git a/patches/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java.patch index 35f7d56236..90b0eb6aad 100644 --- a/patches/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java +++ b/net/minecraft/client/renderer/blockentity/EnchantTableRenderer.java @@ -53,4 +_,10 @@ - this.bookModel.render(p_112420_, vertexconsumer, p_112422_, p_112423_, -1); + this.bookModel.renderToBuffer(p_112420_, vertexconsumer, p_112422_, p_112423_); p_112420_.popPose(); } + diff --git a/patches/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java.patch index 4bd585503f..b1bd51f952 100644 --- a/patches/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java.patch @@ -1,13 +1,15 @@ --- a/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java +++ b/net/minecraft/client/renderer/blockentity/ShulkerBoxRenderer.java -@@ -56,4 +_,10 @@ - this.model.renderToBuffer(p_112480_, vertexconsumer, p_112482_, p_112483_); +@@ -55,6 +_,12 @@ p_112480_.popPose(); } -+ + + @Override + public net.minecraft.world.phys.AABB getRenderBoundingBox(ShulkerBoxBlockEntity blockEntity) { + net.minecraft.core.BlockPos pos = blockEntity.getBlockPos(); + return new net.minecraft.world.phys.AABB(pos.getX() - 0.5, pos.getY() - 0.5, pos.getZ() - 0.5, pos.getX() + 1.5, pos.getY() + 1.5, pos.getZ() + 1.5); + } - } ++ + @OnlyIn(Dist.CLIENT) + static class ShulkerBoxModel extends Model { + private final ModelPart lid; diff --git a/patches/net/minecraft/client/renderer/blockentity/SignRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/SignRenderer.java.patch index e4756dda94..23ffcf89c2 100644 --- a/patches/net/minecraft/client/renderer/blockentity/SignRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/SignRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/blockentity/SignRenderer.java +++ b/net/minecraft/client/renderer/blockentity/SignRenderer.java -@@ -250,6 +_,15 @@ +@@ -251,6 +_,15 @@ return LayerDefinition.create(meshdefinition, 64, 32); } @@ -14,5 +14,5 @@ + } + @OnlyIn(Dist.CLIENT) - public static final class SignModel extends Model { - public final ModelPart root; + static record Models(Model standing, Model wall) { + } diff --git a/patches/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java.patch b/patches/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java.patch index 351d861b08..7a43c83c08 100644 --- a/patches/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java +++ b/net/minecraft/client/renderer/blockentity/SpawnerRenderer.java @@ -57,4 +_,10 @@ - p_312703_.render(p_312223_, 0.0, 0.0, 0.0, 0.0F, p_311943_, p_312805_, p_312394_, p_311996_); + p_312703_.render(p_312223_, 0.0, 0.0, 0.0, p_311943_, p_312805_, p_312394_, p_311996_); p_312805_.popPose(); } + diff --git a/patches/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java.patch b/patches/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java.patch index 33e437bf17..83ea06baae 100644 --- a/patches/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java.patch +++ b/patches/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java.patch @@ -1,47 +1,42 @@ --- a/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java +++ b/net/minecraft/client/renderer/chunk/SectionRenderDispatcher.java -@@ -441,14 +_,15 @@ +@@ -393,9 +_,10 @@ public SectionRenderDispatcher.RenderSection.CompileTask createCompileTask(RenderRegionCache p_295324_) { - boolean flag = this.cancelTasks(); -- RenderChunkRegion renderchunkregion = p_295324_.createRegion(SectionRenderDispatcher.this.level, SectionPos.of(this.origin)); + this.cancelTasks(); +- RenderChunkRegion renderchunkregion = p_295324_.createRegion(SectionRenderDispatcher.this.level, SectionPos.of(this.sectionNode)); + var additionalRenderers = net.neoforged.neoforge.client.ClientHooks.gatherAdditionalRenderers(this.origin, SectionRenderDispatcher.this.level); -+ RenderChunkRegion renderchunkregion = p_295324_.createRegion(SectionRenderDispatcher.this.level, SectionPos.of(this.origin), additionalRenderers.isEmpty()); - boolean flag1 = this.compiled.get() == SectionRenderDispatcher.CompiledSection.UNCOMPILED; - if (flag1 && flag) { - this.initialCompilationCancelCount.incrementAndGet(); - } - - this.lastRebuildTask = new SectionRenderDispatcher.RenderSection.RebuildTask( -- this.getDistToPlayerSqr(), renderchunkregion, !flag1 || this.initialCompilationCancelCount.get() > 2 -+ this.getDistToPlayerSqr(), renderchunkregion, !flag1 || this.initialCompilationCancelCount.get() > 2, additionalRenderers - ); ++ RenderChunkRegion renderchunkregion = p_295324_.createRegion(SectionRenderDispatcher.this.level, SectionPos.of(this.sectionNode), additionalRenderers.isEmpty()); + boolean flag = this.compiled.get() != SectionRenderDispatcher.CompiledSection.UNCOMPILED; +- this.lastRebuildTask = new SectionRenderDispatcher.RenderSection.RebuildTask(renderchunkregion, flag); ++ this.lastRebuildTask = new SectionRenderDispatcher.RenderSection.RebuildTask(renderchunkregion, flag, additionalRenderers); return this.lastRebuildTask; } -@@ -523,10 +_,17 @@ + +@@ -464,10 +_,17 @@ class RebuildTask extends SectionRenderDispatcher.RenderSection.CompileTask { @Nullable - protected RenderChunkRegion region; + protected volatile RenderChunkRegion region; + private final List additionalRenderers; + @Deprecated - public RebuildTask(double p_294400_, @Nullable RenderChunkRegion p_294382_, boolean p_295207_) { -+ this(p_294400_, p_294382_, p_295207_, List.of()); + public RebuildTask(@Nullable RenderChunkRegion p_294382_, boolean p_295207_) { ++ this(p_294382_, p_295207_, List.of()); + } + -+ public RebuildTask(double p_294400_, @Nullable RenderChunkRegion p_294382_, boolean p_295207_, List additionalRenderers) { - super(p_294400_, p_295207_); ++ public RebuildTask(@Nullable RenderChunkRegion p_294382_, boolean p_295207_, List additionalRenderers) { + super(p_295207_); this.region = p_294382_; + this.additionalRenderers = additionalRenderers; } @Override -@@ -552,7 +_,7 @@ - } else { - SectionPos sectionpos = SectionPos.of(RenderSection.this.origin); - SectionCompiler.Results sectioncompiler$results = SectionRenderDispatcher.this.sectionCompiler -- .compile(sectionpos, renderchunkregion, RenderSection.this.createVertexSorting(), p_296138_); -+ .compile(sectionpos, renderchunkregion, RenderSection.this.createVertexSorting(), p_296138_, this.additionalRenderers); - RenderSection.this.updateGlobalBlockEntities(sectioncompiler$results.globalBlockEntities); - if (this.isCancelled.get()) { - sectioncompiler$results.release(); +@@ -498,7 +_,7 @@ + SectionCompiler.Results sectioncompiler$results; + try (Zone zone = Profiler.get().zone("Compile Section")) { + sectioncompiler$results = SectionRenderDispatcher.this.sectionCompiler +- .compile(sectionpos, renderchunkregion, RenderSection.this.createVertexSorting(), p_296138_); ++ .compile(sectionpos, renderchunkregion, RenderSection.this.createVertexSorting(), p_296138_, this.additionalRenderers); + } + + SectionRenderDispatcher.TranslucencyPointOfView sectionrenderdispatcher$translucencypointofview = SectionRenderDispatcher.TranslucencyPointOfView.of( diff --git a/patches/net/minecraft/client/renderer/culling/Frustum.java.patch b/patches/net/minecraft/client/renderer/culling/Frustum.java.patch index 92a6b521cb..9dc2e4adad 100644 --- a/patches/net/minecraft/client/renderer/culling/Frustum.java.patch +++ b/patches/net/minecraft/client/renderer/culling/Frustum.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/renderer/culling/Frustum.java +++ b/net/minecraft/client/renderer/culling/Frustum.java -@@ -70,6 +_,8 @@ +@@ -71,6 +_,8 @@ } public boolean isVisible(AABB p_113030_) { + // FORGE: exit early for infinite bounds, these would otherwise fail in the intersection test at certain camera angles (GH-9321) + if (p_113030_.isInfinite()) return true; - return this.cubeInFrustum(p_113030_.minX, p_113030_.minY, p_113030_.minZ, p_113030_.maxX, p_113030_.maxY, p_113030_.maxZ); + int i = this.cubeInFrustum(p_113030_.minX, p_113030_.minY, p_113030_.minZ, p_113030_.maxX, p_113030_.maxY, p_113030_.maxZ); + return i == -2 || i == -1; } - diff --git a/patches/net/minecraft/client/renderer/entity/BoatRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/BoatRenderer.java.patch deleted file mode 100644 index efa87185cc..0000000000 --- a/patches/net/minecraft/client/renderer/entity/BoatRenderer.java.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/BoatRenderer.java -+++ b/net/minecraft/client/renderer/entity/BoatRenderer.java -@@ -45,7 +_,7 @@ - private ListModel createBoatModel(EntityRendererProvider.Context p_248834_, Boat.Type p_249317_, boolean p_250093_) { - ModelLayerLocation modellayerlocation = p_250093_ ? ModelLayers.createChestBoatModelName(p_249317_) : ModelLayers.createBoatModelName(p_249317_); - ModelPart modelpart = p_248834_.bakeLayer(modellayerlocation); -- if (p_249317_ == Boat.Type.BAMBOO) { -+ if (p_249317_.isRaft()) { - return (ListModel)(p_250093_ ? new ChestRaftModel(modelpart) : new RaftModel(modelpart)); - } else { - return (ListModel)(p_250093_ ? new ChestBoatModel(modelpart) : new BoatModel(modelpart)); -@@ -54,8 +_,8 @@ - - private static ResourceLocation getTextureLocation(Boat.Type p_234566_, boolean p_234567_) { - return p_234567_ -- ? ResourceLocation.withDefaultNamespace("textures/entity/chest_boat/" + p_234566_.getName() + ".png") -- : ResourceLocation.withDefaultNamespace("textures/entity/boat/" + p_234566_.getName() + ".png"); -+ ? ResourceLocation.parse(p_234566_.getName()).withPrefix("textures/entity/chest_boat/").withSuffix(".png") -+ : ResourceLocation.parse(p_234566_.getName()).withPrefix("textures/entity/boat/").withSuffix(".png"); - } - - public void render(Boat p_113929_, float p_113930_, float p_113931_, PoseStack p_113932_, MultiBufferSource p_113933_, int p_113934_) { -@@ -77,7 +_,7 @@ - p_113932_.mulPose(new Quaternionf().setAngleAxis(p_113929_.getBubbleAngle(p_113931_) * (float) (Math.PI / 180.0), 1.0F, 0.0F, 1.0F)); - } - -- Pair> pair = this.boatResources.get(p_113929_.getVariant()); -+ Pair> pair = getModelWithLocation(p_113929_); - ResourceLocation resourcelocation = pair.getFirst(); - ListModel listmodel = pair.getSecond(); - p_113932_.scale(-1.0F, -1.0F, 1.0F); -@@ -96,7 +_,12 @@ - super.render(p_113929_, p_113930_, p_113931_, p_113932_, p_113933_, p_113934_); - } - -+ @Deprecated // forge: override getModelWithLocation to change the texture / model - public ResourceLocation getTextureLocation(Boat p_113927_) { -- return this.boatResources.get(p_113927_.getVariant()).getFirst(); -+ return getModelWithLocation(p_113927_).getFirst(); -+ } -+ -+ public Pair> getModelWithLocation(Boat boat) { -+ return this.boatResources.get(boat.getVariant()); - } - } diff --git a/patches/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch b/patches/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch index d1dd832f9d..49c5906036 100644 --- a/patches/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch +++ b/patches/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java +++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java -@@ -222,12 +_,12 @@ +@@ -243,12 +_,12 @@ ) { AABB aabb = p_114444_.getBoundingBox().move(-p_114444_.getX(), -p_114444_.getY(), -p_114444_.getZ()); - LevelRenderer.renderLineBox(p_114442_, p_114443_, aabb, p_353064_, p_353059_, p_353042_, 1.0F); + ShapeRenderer.renderLineBox(p_114442_, p_114443_, aabb, p_353064_, p_353059_, p_353042_, 1.0F); - if (p_114444_ instanceof EnderDragon) { + if (p_114444_.isMultipartEntity()) { double d0 = -Mth.lerp((double)p_114445_, p_114444_.xOld, p_114444_.getX()); @@ -15,18 +15,18 @@ p_114442_.pushPose(); double d3 = d0 + Mth.lerp((double)p_114445_, enderdragonpart.xOld, enderdragonpart.getX()); double d4 = d1 + Mth.lerp((double)p_114445_, enderdragonpart.yOld, enderdragonpart.getY()); -@@ -467,6 +_,10 @@ +@@ -474,6 +_,10 @@ return this.itemInHandRenderer; } -+ public Map> getSkinMap() { ++ public Map> getSkinMap() { + return java.util.Collections.unmodifiableMap(playerRenderers); + } + @Override public void onResourceManagerReload(ResourceManager p_174004_) { EntityRendererProvider.Context entityrendererprovider$context = new EntityRendererProvider.Context( -@@ -474,5 +_,6 @@ +@@ -481,5 +_,6 @@ ); this.renderers = EntityRenderers.createEntityRenderers(entityrendererprovider$context); this.playerRenderers = EntityRenderers.createPlayerRenderers(entityrendererprovider$context); diff --git a/patches/net/minecraft/client/renderer/entity/EntityRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/EntityRenderer.java.patch index 86142b3674..2e7b86b284 100644 --- a/patches/net/minecraft/client/renderer/entity/EntityRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/EntityRenderer.java.patch @@ -1,25 +1,33 @@ --- a/net/minecraft/client/renderer/entity/EntityRenderer.java +++ b/net/minecraft/client/renderer/entity/EntityRenderer.java -@@ -94,8 +_,11 @@ - } +@@ -105,6 +_,8 @@ } -- if (this.shouldShowName(p_114485_)) { -- this.renderNameTag(p_114485_, p_114485_.getDisplayName(), p_114488_, p_114489_, p_114490_, p_114487_); -+ // Neo: Post the RenderNameTagEvent and conditionally wrap #renderNameTag based on the result. -+ var event = new net.neoforged.neoforge.client.event.RenderNameTagEvent(p_114485_, p_114485_.getDisplayName(), this, p_114488_, p_114489_, p_114490_, p_114487_); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event); -+ if (event.canRender().isTrue() || event.canRender().isDefault() && this.shouldShowName(p_114485_)) { -+ this.renderNameTag(p_114485_, event.getContent(), p_114488_, p_114489_, p_114490_, p_114487_); + if (p_364816_.nameTag != null) { ++ var event = new net.neoforged.neoforge.client.event.RenderNameTagEvent.DoRender(p_364816_, p_364816_.nameTag, this, p_114488_, p_114489_, p_114490_, p_364816_.partialTick); ++ if (!net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event).isCanceled()) + this.renderNameTag(p_364816_, p_364816_.nameTag, p_114488_, p_114489_, p_114490_); } } +@@ -270,7 +_,12 @@ + } -@@ -181,7 +_,7 @@ + p_361028_.distanceToCameraSq = this.entityRenderDispatcher.distanceToSqr(p_362104_); +- boolean flag = p_361028_.distanceToCameraSq < 4096.0 && this.shouldShowName(p_362104_, p_361028_.distanceToCameraSq); ++ boolean flag = p_361028_.distanceToCameraSq < 4096.0; ++ if (flag) { ++ var event = new net.neoforged.neoforge.client.event.RenderNameTagEvent.CanRender(p_362104_, p_361028_, p_362104_.getDisplayName(), this, p_362204_); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event); ++ flag = event.canRender().isTrue() || (event.canRender().isDefault() && this.shouldShowName(p_362104_, p_361028_.distanceToCameraSq)); ++ } + if (flag) { + p_361028_.nameTag = this.getNameTag(p_362104_); + p_361028_.nameTagAttachment = p_362104_.getAttachments().getNullable(EntityAttachment.NAME_TAG, 0, p_362104_.getYRot(p_362204_)); +@@ -302,5 +_,7 @@ + } - protected void renderNameTag(T p_114498_, Component p_114499_, PoseStack p_114500_, MultiBufferSource p_114501_, int p_114502_, float p_316698_) { - double d0 = this.entityRenderDispatcher.distanceToSqr(p_114498_); -- if (!(d0 > 4096.0)) { -+ if (net.neoforged.neoforge.client.ClientHooks.isNameplateInRenderDistance(p_114498_, d0)) { - Vec3 vec3 = p_114498_.getAttachments().getNullable(EntityAttachment.NAME_TAG, 0, p_114498_.getViewYRot(p_316698_)); - if (vec3 != null) { - boolean flag = !p_114498_.isDiscrete(); + p_361028_.displayFireAnimation = p_362104_.displayFireAnimation(); ++ ++ p_361028_.partialTick = p_362204_; + } + } diff --git a/patches/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch index 836cad28ab..0e7a50f641 100644 --- a/patches/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/client/renderer/entity/FallingBlockRenderer.java +++ b/net/minecraft/client/renderer/entity/FallingBlockRenderer.java -@@ -34,6 +_,8 @@ - p_114637_.pushPose(); - BlockPos blockpos = BlockPos.containing(p_114634_.getX(), p_114634_.getBoundingBox().maxY, p_114634_.getZ()); - p_114637_.translate(-0.5, 0.0, -0.5); -+ var model = this.dispatcher.getBlockModel(blockstate); -+ for (var renderType : model.getRenderTypes(blockstate, RandomSource.create(blockstate.getSeed(p_114634_.getStartPos())), net.neoforged.neoforge.client.model.data.ModelData.EMPTY)) - this.dispatcher - .getModelRenderer() - .tesselateBlock( -@@ -42,11 +_,13 @@ - blockstate, - blockpos, - p_114637_, -- p_114638_.getBuffer(ItemBlockRenderTypes.getMovingBlockRenderType(blockstate)), -+ p_114638_.getBuffer(net.neoforged.neoforge.client.RenderTypeHelper.getMovingBlockRenderType(renderType)), - false, - RandomSource.create(), - blockstate.getSeed(p_114634_.getStartPos()), -- OverlayTexture.NO_OVERLAY -+ OverlayTexture.NO_OVERLAY, -+ net.neoforged.neoforge.client.model.data.ModelData.EMPTY, -+ renderType - ); - p_114637_.popPose(); - super.render(p_114634_, p_114635_, p_114636_, p_114637_, p_114638_, p_114639_); +@@ -36,6 +_,8 @@ + if (blockstate.getRenderShape() == RenderShape.MODEL) { + p_114637_.pushPose(); + p_114637_.translate(-0.5, 0.0, -0.5); ++ var model = this.dispatcher.getBlockModel(blockstate); ++ for (var renderType : model.getRenderTypes(blockstate, RandomSource.create(blockstate.getSeed(p_361300_.startBlockPos)), net.neoforged.neoforge.client.model.data.ModelData.EMPTY)) + this.dispatcher + .getModelRenderer() + .tesselateBlock( +@@ -44,11 +_,13 @@ + blockstate, + p_361300_.blockPos, + p_114637_, +- p_114638_.getBuffer(ItemBlockRenderTypes.getMovingBlockRenderType(blockstate)), ++ p_114638_.getBuffer(net.neoforged.neoforge.client.RenderTypeHelper.getMovingBlockRenderType(renderType)), + false, + RandomSource.create(), + blockstate.getSeed(p_361300_.startBlockPos), +- OverlayTexture.NO_OVERLAY ++ OverlayTexture.NO_OVERLAY, ++ net.neoforged.neoforge.client.model.data.ModelData.EMPTY, ++ renderType + ); + p_114637_.popPose(); + super.render(p_361300_, p_114637_, p_114638_, p_114639_); diff --git a/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch index 77ce7e708d..6747d9fda7 100644 --- a/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/entity/FishingHookRenderer.java +++ b/net/minecraft/client/renderer/entity/FishingHookRenderer.java -@@ -64,7 +_,7 @@ +@@ -63,7 +_,7 @@ private Vec3 getPlayerHandPos(Player p_340935_, float p_340872_, float p_341261_) { int i = p_340935_.getMainArm() == HumanoidArm.RIGHT ? 1 : -1; ItemStack itemstack = p_340935_.getMainHandItem(); diff --git a/patches/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch new file mode 100644 index 0000000000..fa5624769b --- /dev/null +++ b/patches/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java ++++ b/net/minecraft/client/renderer/entity/HumanoidMobRenderer.java +@@ -40,7 +_,7 @@ + p_362998_.isCrouching = p_365104_.isCrouching(); + p_362998_.isFallFlying = p_365104_.isFallFlying(); + p_362998_.isVisuallySwimming = p_365104_.isVisuallySwimming(); +- p_362998_.isPassenger = p_365104_.isPassenger(); ++ p_362998_.isPassenger = p_365104_.isPassenger() && (p_365104_.getVehicle() != null && p_365104_.getVehicle().shouldRiderSit()); + p_362998_.speedValue = 1.0F; + if (p_362998_.isFallFlying) { + p_362998_.speedValue = (float)p_365104_.getDeltaMovement().lengthSqr(); diff --git a/patches/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch index 7412c8c3ed..52951841f3 100644 --- a/patches/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/ItemEntityRenderer.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/client/renderer/entity/ItemEntityRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemEntityRenderer.java -@@ -45,7 +_,8 @@ - BakedModel bakedmodel = this.itemRenderer.getModel(itemstack, p_115036_.level(), null, p_115036_.getId()); - boolean flag = bakedmodel.isGui3d(); - float f = 0.25F; -- float f1 = Mth.sin(((float)p_115036_.getAge() + p_115038_) / 10.0F + p_115036_.bobOffs) * 0.1F + 0.1F; -+ boolean shouldBob = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).shouldBobAsEntity(itemstack); -+ float f1 = shouldBob ? Mth.sin(((float)p_115036_.getAge() + p_115038_) / 10.0F + p_115036_.bobOffs) * 0.1F + 0.1F : 0; - float f2 = bakedmodel.getTransforms().getTransform(ItemDisplayContext.GROUND).scale.y(); - p_115039_.translate(0.0F, f1 + 0.25F * f2, 0.0F); - float f3 = p_115036_.getSpin(p_115038_); -@@ -100,9 +_,10 @@ +@@ -54,7 +_,8 @@ + this.random.setSeed((long)getSeedForItemStack(itemstack)); + boolean flag = bakedmodel.isGui3d(); + float f = 0.25F; +- float f1 = Mth.sin(p_362172_.ageInTicks / 10.0F + p_362172_.bobOffset) * 0.1F + 0.1F; ++ boolean shouldBob = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).shouldBobAsEntity(itemstack); ++ float f1 = shouldBob ? Mth.sin(p_362172_.ageInTicks / 10.0F + p_362172_.bobOffset) * 0.1F + 0.1F : 0; + float f2 = bakedmodel.getTransforms().getTransform(ItemDisplayContext.GROUND).scale.y(); + p_115030_.translate(0.0F, f1 + 0.25F * f2, 0.0F); + float f3 = ItemEntity.getSpin(p_362172_.ageInTicks, p_362172_.bobOffset); +@@ -110,9 +_,10 @@ p_323733_.translate(f3, f4, f5); } diff --git a/patches/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch index d2db3be4a8..7fe0bf497d 100644 --- a/patches/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/ItemFrameRenderer.java.patch @@ -1,50 +1,27 @@ --- a/net/minecraft/client/renderer/entity/ItemFrameRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemFrameRenderer.java -@@ -84,25 +_,25 @@ - } - - if (!itemstack.isEmpty()) { -- MapId mapid = p_115076_.getFramedMapId(itemstack); -+ MapItemSavedData mapitemsaveddata = MapItem.getSavedData(itemstack, p_115076_.level()); - if (flag) { - p_115079_.translate(0.0F, 0.0F, 0.5F); - } else { - p_115079_.translate(0.0F, 0.0F, 0.4375F); - } +@@ -100,6 +_,7 @@ -- int j = mapid != null ? p_115076_.getRotation() % 4 * 2 : p_115076_.getRotation(); -+ int j = mapitemsaveddata != null ? p_115076_.getRotation() % 4 * 2 : p_115076_.getRotation(); + int j = mapid != null ? p_364723_.rotation % 4 * 2 : p_364723_.rotation; p_115079_.mulPose(Axis.ZP.rotationDegrees((float)j * 360.0F / 8.0F)); -- if (mapid != null) { -+ if (!net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderItemInFrameEvent(p_115076_, this, p_115079_, p_115080_, p_115081_)).isCanceled()) { -+ if (mapitemsaveddata != null) { ++ if (!net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderItemInFrameEvent(p_364723_, this, p_115079_, p_115080_, p_115081_)).isCanceled()) { + if (mapid != null) { p_115079_.mulPose(Axis.ZP.rotationDegrees(180.0F)); - float f = 0.0078125F; - p_115079_.scale(0.0078125F, 0.0078125F, 0.0078125F); - p_115079_.translate(-64.0F, -64.0F, 0.0F); -- MapItemSavedData mapitemsaveddata = MapItem.getSavedData(mapid, p_115076_.level()); - p_115079_.translate(0.0F, 0.0F, -1.0F); - if (mapitemsaveddata != null) { - int i = this.getLightVal(p_115076_, 15728850, p_115081_); -- Minecraft.getInstance().gameRenderer.getMapRenderer().render(p_115079_, p_115080_, mapid, mapitemsaveddata, true, i); -+ Minecraft.getInstance().gameRenderer.getMapRenderer().render(p_115079_, p_115080_, p_115076_.getFramedMapId(itemstack), mapitemsaveddata, true, i); - } - } else { - int k = this.getLightVal(p_115076_, 15728880, p_115081_); -@@ -110,6 +_,7 @@ - this.itemRenderer - .renderStatic(itemstack, ItemDisplayContext.FIXED, k, OverlayTexture.NO_OVERLAY, p_115079_, p_115080_, p_115076_.level(), p_115076_.getId()); + float f2 = 0.0078125F; +@@ -113,6 +_,7 @@ + p_115079_.scale(0.5F, 0.5F, 0.5F); + this.itemRenderer.render(itemstack, ItemDisplayContext.FIXED, false, p_115079_, p_115080_, k, OverlayTexture.NO_OVERLAY, p_364723_.itemModel); } + } } p_115079_.popPose(); -@@ -121,7 +_,7 @@ - - private ModelResourceLocation getFrameModelResourceLoc(T p_174213_, ItemStack p_174214_) { - boolean flag = p_174213_.getType() == EntityType.GLOW_ITEM_FRAME; -- if (p_174214_.is(Items.FILLED_MAP)) { -+ if (p_174214_.getItem() instanceof MapItem) { - return flag ? GLOW_MAP_FRAME_LOCATION : MAP_FRAME_LOCATION; - } else { - return flag ? GLOW_FRAME_LOCATION : FRAME_LOCATION; +@@ -161,7 +_,7 @@ + if (!p_362907_.itemStack.isEmpty()) { + MapId mapid = p_363125_.getFramedMapId(itemstack); + if (mapid != null) { +- MapItemSavedData mapitemsaveddata = p_363125_.level().getMapData(mapid); ++ MapItemSavedData mapitemsaveddata = net.minecraft.world.item.MapItem.getSavedData(itemstack, p_363125_.level()); + if (mapitemsaveddata != null) { + this.mapRenderer.extractRenderState(mapid, mapitemsaveddata, p_362907_.mapRenderState); + p_362907_.mapId = mapid; diff --git a/patches/net/minecraft/client/renderer/entity/ItemRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/ItemRenderer.java.patch index 67b1f7c54f..a53ce7e08e 100644 --- a/patches/net/minecraft/client/renderer/entity/ItemRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/ItemRenderer.java.patch @@ -1,63 +1,54 @@ --- a/net/minecraft/client/renderer/entity/ItemRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemRenderer.java -@@ -70,7 +_,7 @@ - public ItemRenderer(Minecraft p_266926_, TextureManager p_266774_, ModelManager p_266850_, ItemColors p_267016_, BlockEntityWithoutLevelRenderer p_267049_) { - this.minecraft = p_266926_; - this.textureManager = p_266774_; -- this.itemModelShaper = new ItemModelShaper(p_266850_); -+ this.itemModelShaper = new net.neoforged.neoforge.client.model.RegistryAwareItemModelShaper(p_266850_); - this.blockEntityRenderer = p_267049_; - - for (Item item : BuiltInRegistries.ITEM) { -@@ -120,7 +_,7 @@ - } +@@ -156,7 +_,7 @@ + float p_371782_ + ) { + p_371635_.pushPose(); +- p_371384_.getTransforms().getTransform(p_371250_).apply(p_371248_, p_371635_); ++ p_371384_ = net.neoforged.neoforge.client.ClientHooks.handleCameraTransforms(p_371635_, p_371384_, p_371250_, p_371248_); + p_371635_.translate(-0.5F, -0.5F, p_371782_); + this.renderItem(p_371318_, p_371250_, p_371635_, p_371946_, p_371752_, p_371508_, p_371384_, p_371718_); + p_371635_.popPose(); +@@ -173,7 +_,8 @@ + boolean p_364829_ + ) { + if (!p_363970_.isCustomRenderer() && (!p_361397_.is(Items.TRIDENT) || p_364829_)) { +- RenderType rendertype = ItemBlockRenderTypes.getRenderType(p_361397_); ++ for (var model : p_363970_.getRenderPasses(p_361397_)) { ++ for (var rendertype : model.getRenderTypes(p_361397_)) { + VertexConsumer vertexconsumer; + if (hasAnimatedTexture(p_361397_) && p_361397_.hasFoil()) { + PoseStack.Pose posestack$pose = p_360423_.last().copy(); +@@ -188,9 +_,11 @@ + vertexconsumer = getFoilBuffer(p_360415_, rendertype, true, p_361397_.hasFoil()); } -- p_115151_.getTransforms().getTransform(p_270188_).apply(p_115146_, p_115147_); -+ p_115151_ = net.neoforged.neoforge.client.ClientHooks.handleCameraTransforms(p_115147_, p_115151_, p_270188_, p_115146_); - p_115147_.translate(-0.5F, -0.5F, -0.5F); - if (!p_115151_.isCustomRenderer() && (!p_115144_.is(Items.TRIDENT) || flag)) { - boolean flag1; -@@ -131,7 +_,8 @@ - flag1 = true; - } - -- RenderType rendertype = ItemBlockRenderTypes.getRenderType(p_115144_, flag1); -+ for (var model : p_115151_.getRenderPasses(p_115144_, flag1)) { -+ for (var rendertype : model.getRenderTypes(p_115144_, flag1)) { - VertexConsumer vertexconsumer; - if (hasAnimatedTexture(p_115144_) && p_115144_.hasFoil()) { - PoseStack.Pose posestack$pose = p_115147_.last().copy(); -@@ -148,9 +_,11 @@ - vertexconsumer = getFoilBuffer(p_115148_, rendertype, true, p_115144_.hasFoil()); - } - -- this.renderModelLists(p_115151_, p_115144_, p_115149_, p_115150_, p_115147_, vertexconsumer); -+ this.renderModelLists(model, p_115144_, p_115149_, p_115150_, p_115147_, vertexconsumer); -+ } -+ } - } else { -- this.blockEntityRenderer.renderByItem(p_115144_, p_270188_, p_115147_, p_115148_, p_115149_, p_115150_); -+ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(p_115144_).getCustomRenderer().renderByItem(p_115144_, p_270188_, p_115147_, p_115148_, p_115149_, p_115150_); - } +- this.renderModelLists(p_363970_, p_361397_, p_361265_, p_364771_, p_360423_, vertexconsumer); ++ this.renderModelLists(model, p_361397_, p_361265_, p_364771_, p_360423_, vertexconsumer); ++ } ++ } + } else { +- this.blockEntityRenderer.renderByItem(p_361397_, p_361627_, p_360423_, p_360415_, p_361265_, p_364771_); ++ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(p_361397_).getCustomRenderer().renderByItem(p_361397_, p_361627_, p_360423_, p_360415_, p_361265_, p_364771_); + } + } - p_115147_.popPose(); -@@ -203,7 +_,7 @@ - float f1 = (float)FastColor.ARGB32.red(i) / 255.0F; - float f2 = (float)FastColor.ARGB32.green(i) / 255.0F; - float f3 = (float)FastColor.ARGB32.blue(i) / 255.0F; +@@ -238,7 +_,7 @@ + float f1 = (float)ARGB.red(i) / 255.0F; + float f2 = (float)ARGB.green(i) / 255.0F; + float f3 = (float)ARGB.blue(i) / 255.0F; - p_115164_.putBulkData(posestack$pose, bakedquad, f1, f2, f3, f, p_115167_, p_115168_); + p_115164_.putBulkData(posestack$pose, bakedquad, f1, f2, f3, f, p_115167_, p_115168_, true); // Neo: pass readExistingColor=true } } -@@ -256,5 +_,9 @@ - @Override - public void onResourceManagerReload(ResourceManager p_115105_) { - this.itemModelShaper.rebuildCache(); +@@ -294,5 +_,9 @@ + ClientLevel clientlevel = p_372942_ instanceof ClientLevel ? (ClientLevel)p_372942_ : null; + BakedModel bakedmodel = p_373094_.overrides().findOverride(p_372923_, clientlevel, p_373099_, p_372933_); + return bakedmodel == null ? p_373094_ : bakedmodel; + } + + public BlockEntityWithoutLevelRenderer getBlockEntityRenderer() { -+ return blockEntityRenderer; ++ return blockEntityRenderer; } } diff --git a/patches/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch index 77ec112179..8322d59b63 100644 --- a/patches/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch @@ -1,38 +1,36 @@ --- a/net/minecraft/client/renderer/entity/LivingEntityRenderer.java +++ b/net/minecraft/client/renderer/entity/LivingEntityRenderer.java -@@ -50,14 +_,16 @@ +@@ -69,6 +_,7 @@ } - public void render(T p_115308_, float p_115309_, float p_115310_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { -+ if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderLivingEvent.Pre(p_115308_, this, p_115310_, p_115311_, p_115312_, p_115313_)).isCanceled()) return; + public void render(S p_361886_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { ++ if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderLivingEvent.Pre(p_361886_, this, p_361886_.partialTick, p_115311_, p_115312_, p_115313_)).isCanceled()) return; p_115311_.pushPose(); - this.model.attackTime = this.getAttackAnim(p_115308_, p_115310_); -- this.model.riding = p_115308_.isPassenger(); -+ boolean shouldSit = p_115308_.isPassenger() && (p_115308_.getVehicle() != null && p_115308_.getVehicle().shouldRiderSit()); -+ this.model.riding = shouldSit; - this.model.young = p_115308_.isBaby(); - float f = Mth.rotLerp(p_115310_, p_115308_.yBodyRotO, p_115308_.yBodyRot); - float f1 = Mth.rotLerp(p_115310_, p_115308_.yHeadRotO, p_115308_.yHeadRot); - float f2 = f1 - f; -- if (p_115308_.isPassenger() && p_115308_.getVehicle() instanceof LivingEntity livingentity) { -+ if (shouldSit && p_115308_.getVehicle() instanceof LivingEntity livingentity) { - f = Mth.rotLerp(p_115310_, livingentity.yBodyRotO, livingentity.yBodyRot); - f2 = f1 - f; - float f7 = Mth.wrapDegrees(f2); -@@ -101,7 +_,7 @@ - p_115311_.translate(0.0F, -1.501F, 0.0F); - float f4 = 0.0F; - float f5 = 0.0F; -- if (!p_115308_.isPassenger() && p_115308_.isAlive()) { -+ if (!shouldSit && p_115308_.isAlive()) { - f4 = p_115308_.walkAnimation.speed(p_115310_); - f5 = p_115308_.walkAnimation.position(p_115310_); - if (p_115308_.isBaby()) { -@@ -134,6 +_,7 @@ + if (p_361886_.hasPose(Pose.SLEEPING)) { + Direction direction = p_361886_.bedOrientation; +@@ -104,6 +_,7 @@ p_115311_.popPose(); - super.render(p_115308_, p_115309_, p_115310_, p_115311_, p_115312_, p_115313_); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderLivingEvent.Post(p_115308_, this, p_115310_, p_115311_, p_115312_, p_115313_)); + super.render(p_361886_, p_115311_, p_115312_, p_115313_); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderLivingEvent.Post(p_361886_, this, p_361886_.partialTick, p_115311_, p_115312_, p_115313_)); } - @Nullable + protected boolean shouldRenderLayers(S p_364697_) { +@@ -201,7 +_,7 @@ + protected boolean shouldShowName(T p_363517_, double p_365448_) { + if (p_363517_.isDiscrete()) { + float f = 32.0F; +- if (p_365448_ >= 1024.0) { ++ if (!net.neoforged.neoforge.client.ClientHooks.isNameplateInRenderDistance(p_363517_, p_365448_)) { + return false; + } + } +@@ -284,7 +_,7 @@ + + p_360515_.isFullyFrozen = p_362733_.isFullyFrozen(); + p_360515_.isBaby = p_362733_.isBaby(); +- p_360515_.isInWater = p_362733_.isInWater(); ++ p_360515_.isInWater = p_362733_.isInWater() || p_362733_.isInFluidType((fluidType, height) -> p_362733_.canSwimInFluidType(fluidType)); + p_360515_.isAutoSpinAttack = p_362733_.isAutoSpinAttack(); + p_360515_.hasRedOverlay = p_362733_.hurtTime > 0 || p_362733_.deathTime > 0; + ItemStack itemstack1 = p_362733_.getItemBySlot(EquipmentSlot.HEAD); diff --git a/patches/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch b/patches/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch deleted file mode 100644 index d64f1997de..0000000000 --- a/patches/net/minecraft/client/renderer/entity/layers/ElytraLayer.java.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/layers/ElytraLayer.java -+++ b/net/minecraft/client/renderer/entity/layers/ElytraLayer.java -@@ -45,7 +_,7 @@ - float p_116960_ - ) { - ItemStack itemstack = p_116954_.getItemBySlot(EquipmentSlot.CHEST); -- if (itemstack.is(Items.ELYTRA)) { -+ if (shouldRender(itemstack, p_116954_)) { - ResourceLocation resourcelocation; - if (p_116954_ instanceof AbstractClientPlayer abstractclientplayer) { - PlayerSkin playerskin = abstractclientplayer.getSkin(); -@@ -54,10 +_,10 @@ - } else if (playerskin.capeTexture() != null && abstractclientplayer.isModelPartShown(PlayerModelPart.CAPE)) { - resourcelocation = playerskin.capeTexture(); - } else { -- resourcelocation = WINGS_LOCATION; -+ resourcelocation = getElytraTexture(itemstack, p_116954_); - } - } else { -- resourcelocation = WINGS_LOCATION; -+ resourcelocation = getElytraTexture(itemstack, p_116954_); - } - - p_116951_.pushPose(); -@@ -68,5 +_,30 @@ - this.elytraModel.renderToBuffer(p_116951_, vertexconsumer, p_116953_, OverlayTexture.NO_OVERLAY); - p_116951_.popPose(); - } -+ } -+ -+ /** -+ * Determines if the ElytraLayer should render. -+ * ItemStack and Entity are provided for modder convenience, -+ * For example, using the same ElytraLayer for multiple custom Elytra. -+ * -+ * @param stack The Elytra ItemStack -+ * @param entity The entity being rendered. -+ * @return If the ElytraLayer should render. -+ */ -+ public boolean shouldRender(ItemStack stack, T entity) { -+ return stack.getItem() == Items.ELYTRA; -+ } -+ -+ /** -+ * Gets the texture to use with this ElytraLayer. -+ * This assumes the vanilla Elytra model. -+ * -+ * @param stack The Elytra ItemStack. -+ * @param entity The entity being rendered. -+ * @return The texture. -+ */ -+ public ResourceLocation getElytraTexture(ItemStack stack, T entity) { -+ return WINGS_LOCATION; - } - } diff --git a/patches/net/minecraft/client/renderer/entity/layers/EquipmentLayerRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/layers/EquipmentLayerRenderer.java.patch new file mode 100644 index 0000000000..d9bc50306b --- /dev/null +++ b/patches/net/minecraft/client/renderer/entity/layers/EquipmentLayerRenderer.java.patch @@ -0,0 +1,45 @@ +--- a/net/minecraft/client/renderer/entity/layers/EquipmentLayerRenderer.java ++++ b/net/minecraft/client/renderer/entity/layers/EquipmentLayerRenderer.java +@@ -65,21 +_,26 @@ + int p_371309_, + @Nullable ResourceLocation p_371587_ + ) { ++ p_371731_ = getArmorModelHook(p_371670_, p_371854_, p_371731_); + List list = this.equipmentModels.get(p_371639_).getLayers(p_371854_); + if (!list.isEmpty()) { +- int i = p_371670_.is(ItemTags.DYEABLE) ? DyedItemColor.getOrDefault(p_371670_, 0) : 0; ++ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions extensions = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(p_371670_); ++ int i = extensions.getDefaultDyeColor(p_371670_); + boolean flag = p_371670_.hasFoil(); + ++ int idx = 0; + for (EquipmentModel.Layer equipmentmodel$layer : list) { +- int j = getColorForLayer(equipmentmodel$layer, i); ++ int j = extensions.getArmorLayerTintColor(p_371670_, equipmentmodel$layer, idx, i); + if (j != 0) { + ResourceLocation resourcelocation = equipmentmodel$layer.usePlayerTexture() && p_371587_ != null + ? p_371587_ + : this.layerTextureLookup.apply(new EquipmentLayerRenderer.LayerTextureKey(p_371854_, equipmentmodel$layer)); ++ resourcelocation = net.neoforged.neoforge.client.ClientHooks.getArmorTexture(p_371670_, p_371854_, equipmentmodel$layer, resourcelocation); + VertexConsumer vertexconsumer = ItemRenderer.getArmorFoilBuffer(p_371286_, RenderType.armorCutoutNoCull(resourcelocation), flag); + p_371731_.renderToBuffer(p_371767_, vertexconsumer, p_371309_, OverlayTexture.NO_OVERLAY, j); + flag = false; + } ++ idx++; + } + + ArmorTrim armortrim = p_371670_.get(DataComponents.TRIM); +@@ -99,6 +_,13 @@ + } else { + return -1; + } ++ } ++ ++ /** ++ * Hook to allow item-sensitive armor model. for HumanoidArmorLayer. ++ */ ++ protected net.minecraft.client.model.Model getArmorModelHook(ItemStack itemStack, EquipmentModel.LayerType layerType, Model model) { ++ return net.neoforged.neoforge.client.ClientHooks.getArmorModel(itemStack, layerType, model); + } + + @OnlyIn(Dist.CLIENT) diff --git a/patches/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch b/patches/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch deleted file mode 100644 index b6db566e31..0000000000 --- a/patches/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java.patch +++ /dev/null @@ -1,105 +0,0 @@ ---- a/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java -+++ b/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java -@@ -54,34 +_,47 @@ - float p_117104_, - float p_117105_ - ) { -- this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.CHEST, p_117098_, this.getArmorModel(EquipmentSlot.CHEST)); -- this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.LEGS, p_117098_, this.getArmorModel(EquipmentSlot.LEGS)); -- this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.FEET, p_117098_, this.getArmorModel(EquipmentSlot.FEET)); -- this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.HEAD, p_117098_, this.getArmorModel(EquipmentSlot.HEAD)); -+ this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.CHEST, p_117098_, this.getArmorModel(EquipmentSlot.CHEST), p_117100_, p_117101_, p_117102_, p_117103_, p_117104_, p_117105_); -+ this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.LEGS, p_117098_, this.getArmorModel(EquipmentSlot.LEGS), p_117100_, p_117101_, p_117102_, p_117103_, p_117104_, p_117105_); -+ this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.FEET, p_117098_, this.getArmorModel(EquipmentSlot.FEET), p_117100_, p_117101_, p_117102_, p_117103_, p_117104_, p_117105_); -+ this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.HEAD, p_117098_, this.getArmorModel(EquipmentSlot.HEAD), p_117100_, p_117101_, p_117102_, p_117103_, p_117104_, p_117105_); - } - -+ /** @deprecated Neo: use {@link #renderArmorPiece(PoseStack, MultiBufferSource, LivingEntity, EquipmentSlot, int, HumanoidModel, float, float, float, float, float, float)} instead. */ -+ @Deprecated - private void renderArmorPiece(PoseStack p_117119_, MultiBufferSource p_117120_, T p_117121_, EquipmentSlot p_117122_, int p_117123_, A p_117124_) { -+ this.renderArmorPiece(p_117119_, p_117120_, p_117121_, p_117122_, p_117123_, p_117124_, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F); -+ } -+ -+ private void renderArmorPiece(PoseStack p_117119_, MultiBufferSource p_117120_, T p_117121_, EquipmentSlot p_117122_, int p_117123_, A p_117124_, float limbSwing, float limbSwingAmount, float partialTick, float ageInTicks, float netHeadYaw, float headPitch) { - ItemStack itemstack = p_117121_.getItemBySlot(p_117122_); - if (itemstack.getItem() instanceof ArmorItem armoritem) { - if (armoritem.getEquipmentSlot() == p_117122_) { - this.getParentModel().copyPropertiesTo(p_117124_); - this.setPartVisibility(p_117124_, p_117122_); -+ net.minecraft.client.model.Model model = getArmorModelHook(p_117121_, itemstack, p_117122_, p_117124_); - boolean flag = this.usesInnerModel(p_117122_); - ArmorMaterial armormaterial = armoritem.getMaterial().value(); -- int i = itemstack.is(ItemTags.DYEABLE) ? FastColor.ARGB32.opaque(DyedItemColor.getOrDefault(itemstack, -6265536)) : -1; - -- for (ArmorMaterial.Layer armormaterial$layer : armormaterial.layers()) { -- int j = armormaterial$layer.dyeable() ? i : -1; -- this.renderModel(p_117119_, p_117120_, p_117123_, p_117124_, j, armormaterial$layer.texture(flag)); -+ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions extensions = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack); -+ extensions.setupModelAnimations(p_117121_, itemstack, p_117122_, model, limbSwing, limbSwingAmount, partialTick, ageInTicks, netHeadYaw, headPitch); -+ int fallbackColor = extensions.getDefaultDyeColor(itemstack); -+ for (int layerIdx = 0; layerIdx < armormaterial.layers().size(); layerIdx++) { -+ ArmorMaterial.Layer armormaterial$layer = armormaterial.layers().get(layerIdx); -+ int j = extensions.getArmorLayerTintColor(itemstack, p_117121_, armormaterial$layer, layerIdx, fallbackColor); -+ if (j != 0) { -+ var texture = net.neoforged.neoforge.client.ClientHooks.getArmorTexture(p_117121_, itemstack, armormaterial$layer, flag, p_117122_); -+ this.renderModel(p_117119_, p_117120_, p_117123_, model, j, texture); -+ } - } - - ArmorTrim armortrim = itemstack.get(DataComponents.TRIM); - if (armortrim != null) { -- this.renderTrim(armoritem.getMaterial(), p_117119_, p_117120_, p_117123_, armortrim, p_117124_, flag); -+ this.renderTrim(armoritem.getMaterial(), p_117119_, p_117120_, p_117123_, armortrim, model, flag); - } - - if (itemstack.hasFoil()) { -- this.renderGlint(p_117119_, p_117120_, p_117123_, p_117124_); -+ this.renderGlint(p_117119_, p_117120_, p_117123_, model); - } - } - } -@@ -111,6 +_,9 @@ - } - - private void renderModel(PoseStack p_289664_, MultiBufferSource p_289689_, int p_289681_, A p_289658_, int p_350798_, ResourceLocation p_324344_) { -+ renderModel(p_289664_, p_289689_, p_289681_, (net.minecraft.client.model.Model) p_289658_, p_350798_, p_324344_); -+ } -+ private void renderModel(PoseStack p_289664_, MultiBufferSource p_289689_, int p_289681_, net.minecraft.client.model.Model p_289658_, int p_350798_, ResourceLocation p_324344_) { - VertexConsumer vertexconsumer = p_289689_.getBuffer(RenderType.armorCutoutNoCull(p_324344_)); - p_289658_.renderToBuffer(p_289664_, vertexconsumer, p_289681_, OverlayTexture.NO_OVERLAY, p_350798_); - } -@@ -118,6 +_,11 @@ - private void renderTrim( - Holder p_323506_, PoseStack p_289687_, MultiBufferSource p_289643_, int p_289683_, ArmorTrim p_289692_, A p_289663_, boolean p_289651_ - ) { -+ renderTrim(p_323506_, p_289687_, p_289643_, p_289683_, p_289692_, (net.minecraft.client.model.Model) p_289663_, p_289651_); -+ } -+ private void renderTrim( -+ Holder p_323506_, PoseStack p_289687_, MultiBufferSource p_289643_, int p_289683_, ArmorTrim p_289692_, net.minecraft.client.model.Model p_289663_, boolean p_289651_ -+ ) { - TextureAtlasSprite textureatlassprite = this.armorTrimAtlas - .getSprite(p_289651_ ? p_289692_.innerTexture(p_323506_) : p_289692_.outerTexture(p_323506_)); - VertexConsumer vertexconsumer = textureatlassprite.wrap(p_289643_.getBuffer(Sheets.armorTrimsSheet(p_289692_.pattern().value().decal()))); -@@ -125,6 +_,9 @@ - } - - private void renderGlint(PoseStack p_289673_, MultiBufferSource p_289654_, int p_289649_, A p_289659_) { -+ renderGlint(p_289673_, p_289654_, p_289649_, (net.minecraft.client.model.Model) p_289659_); -+ } -+ private void renderGlint(PoseStack p_289673_, MultiBufferSource p_289654_, int p_289649_, net.minecraft.client.model.Model p_289659_) { - p_289659_.renderToBuffer(p_289673_, p_289654_.getBuffer(RenderType.armorEntityGlint()), p_289649_, OverlayTexture.NO_OVERLAY); - } - -@@ -134,5 +_,12 @@ - - private boolean usesInnerModel(EquipmentSlot p_117129_) { - return p_117129_ == EquipmentSlot.LEGS; -+ } -+ -+ /** -+ * Hook to allow item-sensitive armor model. for HumanoidArmorLayer. -+ */ -+ protected net.minecraft.client.model.Model getArmorModelHook(T entity, ItemStack itemStack, EquipmentSlot slot, A model) { -+ return net.neoforged.neoforge.client.ClientHooks.getArmorModel(entity, itemStack, slot, model); - } - } diff --git a/patches/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch index 7f8084039e..d2fb4f4901 100644 --- a/patches/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/player/PlayerRenderer.java.patch @@ -1,47 +1,66 @@ --- a/net/minecraft/client/renderer/entity/player/PlayerRenderer.java +++ b/net/minecraft/client/renderer/entity/player/PlayerRenderer.java -@@ -68,7 +_,9 @@ - - public void render(AbstractClientPlayer p_117788_, float p_117789_, float p_117790_, PoseStack p_117791_, MultiBufferSource p_117792_, int p_117793_) { - this.setModelProperties(p_117788_); -+ if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderPlayerEvent.Pre(p_117788_, this, p_117790_, p_117791_, p_117792_, p_117793_)).isCanceled()) return; - super.render(p_117788_, p_117789_, p_117790_, p_117791_, p_117792_, p_117793_); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderPlayerEvent.Post(p_117788_, this, p_117790_, p_117791_, p_117792_, p_117793_)); - } - - public Vec3 getRenderOffset(AbstractClientPlayer p_117785_, float p_117786_) { -@@ -140,9 +_,11 @@ - if (useanim == UseAnim.BRUSH) { - return HumanoidModel.ArmPose.BRUSH; - } -- } else if (!p_117795_.swinging && itemstack.is(Items.CROSSBOW) && CrossbowItem.isCharged(itemstack)) { -+ } else if (!p_117795_.swinging && itemstack.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(itemstack)) { +@@ -127,6 +_,9 @@ + } else if (!p_363098_.swinging && p_364742_.holdsChargedCrossbow) { return HumanoidModel.ArmPose.CROSSBOW_HOLD; } -+ HumanoidModel.ArmPose forgeArmPose = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).getArmPose(p_117795_, p_117796_, itemstack); -+ if (forgeArmPose != null) return forgeArmPose; ++ if (p_364742_.customArmPose != null) { ++ return p_364742_.customArmPose; ++ } return HumanoidModel.ArmPose.ITEM; } -@@ -185,10 +_,12 @@ +@@ -141,6 +_,13 @@ + p_117799_.scale(0.9375F, 0.9375F, 0.9375F); } - public void renderRightHand(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, AbstractClientPlayer p_117774_) { -+ if(!net.neoforged.neoforge.client.ClientHooks.renderSpecificFirstPersonArm(p_117771_, p_117772_, p_117773_, p_117774_, HumanoidArm.RIGHT)) - this.renderHand(p_117771_, p_117772_, p_117773_, p_117774_, this.model.rightArm, this.model.rightSleeve); ++ @Override ++ public void render(PlayerRenderState p_361886_, PoseStack p_115311_, MultiBufferSource p_115312_, int p_115313_) { ++ if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderPlayerEvent.Pre(p_361886_, this, p_361886_.partialTick, p_115311_, p_115312_, p_115313_)).isCanceled()) return; ++ super.render(p_361886_, p_115311_, p_115312_, p_115313_); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.RenderPlayerEvent.Post(p_361886_, this, p_361886_.partialTick, p_115311_, p_115312_, p_115313_)); ++ } ++ + protected void renderNameTag(PlayerRenderState p_363185_, Component p_117809_, PoseStack p_117810_, MultiBufferSource p_117811_, int p_117812_) { + p_117810_.pushPose(); + if (p_363185_.scoreText != null) { +@@ -217,7 +_,8 @@ + ItemStack itemstack = p_364516_.getItemInHand(p_364304_); + p_360817_.isEmpty = itemstack.isEmpty(); + p_360817_.useAnimation = !itemstack.isEmpty() ? itemstack.getUseAnimation() : null; +- p_360817_.holdsChargedCrossbow = itemstack.is(Items.CROSSBOW) && CrossbowItem.isCharged(itemstack); ++ p_360817_.holdsChargedCrossbow = itemstack.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(itemstack); ++ p_360817_.customArmPose = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).getArmPose(p_364516_, p_364304_, itemstack); } - public void renderLeftHand(PoseStack p_117814_, MultiBufferSource p_117815_, int p_117816_, AbstractClientPlayer p_117817_) { -+ if(!net.neoforged.neoforge.client.ClientHooks.renderSpecificFirstPersonArm(p_117814_, p_117815_, p_117816_, p_117817_, HumanoidArm.LEFT)) - this.renderHand(p_117814_, p_117815_, p_117816_, p_117817_, this.model.leftArm, this.model.leftSleeve); + private static void extractCapeState(AbstractClientPlayer p_364691_, PlayerRenderState p_360814_, float p_364460_) { +@@ -247,11 +_,29 @@ + : null; + } + ++ /** ++ * @deprecated Neo: use {@link #renderRightHand(PoseStack, MultiBufferSource, int, ResourceLocation, boolean, AbstractClientPlayer)} instead ++ */ ++ @Deprecated + public void renderRightHand(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, ResourceLocation p_363694_, boolean p_366898_) { ++ this.renderRightHand(p_117771_, p_117772_, p_117773_, p_363694_, p_366898_, net.minecraft.client.Minecraft.getInstance().player); ++ } ++ ++ public void renderRightHand(PoseStack p_117771_, MultiBufferSource p_117772_, int p_117773_, ResourceLocation p_363694_, boolean p_366898_, AbstractClientPlayer player) { ++ if(!net.neoforged.neoforge.client.ClientHooks.renderSpecificFirstPersonArm(p_117771_, p_117772_, p_117773_, player, HumanoidArm.RIGHT)) + this.renderHand(p_117771_, p_117772_, p_117773_, p_363694_, this.model.rightArm, p_366898_); + } + ++ /** ++ * @deprecated Neo: use {@link #renderLeftHand(PoseStack, MultiBufferSource, int, ResourceLocation, boolean, AbstractClientPlayer)} instead ++ */ ++ @Deprecated + public void renderLeftHand(PoseStack p_117814_, MultiBufferSource p_117815_, int p_117816_, ResourceLocation p_361745_, boolean p_366730_) { ++ this.renderLeftHand(p_117814_, p_117815_, p_117816_, p_361745_, p_366730_, net.minecraft.client.Minecraft.getInstance().player); ++ } ++ ++ public void renderLeftHand(PoseStack p_117814_, MultiBufferSource p_117815_, int p_117816_, ResourceLocation p_361745_, boolean p_366730_, AbstractClientPlayer player) { ++ if(!net.neoforged.neoforge.client.ClientHooks.renderSpecificFirstPersonArm(p_117814_, p_117815_, p_117816_, player, HumanoidArm.LEFT)) + this.renderHand(p_117814_, p_117815_, p_117816_, p_361745_, this.model.leftArm, p_366730_); } -@@ -230,7 +_,7 @@ - } - } else if (f > 0.0F) { - super.setupRotations(p_117802_, p_117803_, p_117804_, p_117805_, p_117806_, p_320048_); -- float f4 = p_117802_.isInWater() ? -90.0F - f1 : -90.0F; -+ float f4 = p_117802_.isInWater() || p_117802_.isInFluidType((fluidType, height) -> p_117802_.canSwimInFluidType(fluidType)) ? -90.0F - p_117802_.getXRot() : -90.0F; - float f5 = Mth.lerp(f, 0.0F, f4); - p_117803_.mulPose(Axis.XP.rotationDegrees(f5)); - if (p_117802_.isVisuallySwimming()) { diff --git a/patches/net/minecraft/client/renderer/entity/state/EntityRenderState.java.patch b/patches/net/minecraft/client/renderer/entity/state/EntityRenderState.java.patch new file mode 100644 index 0000000000..a9fd80707c --- /dev/null +++ b/patches/net/minecraft/client/renderer/entity/state/EntityRenderState.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/renderer/entity/state/EntityRenderState.java ++++ b/net/minecraft/client/renderer/entity/state/EntityRenderState.java +@@ -27,6 +_,7 @@ + public Vec3 nameTagAttachment; + @Nullable + public EntityRenderState.LeashState leashState; ++ public float partialTick; + + @OnlyIn(Dist.CLIENT) + public static class LeashState { diff --git a/patches/net/minecraft/client/renderer/entity/state/PlayerRenderState.java.patch b/patches/net/minecraft/client/renderer/entity/state/PlayerRenderState.java.patch new file mode 100644 index 0000000000..870f5bd850 --- /dev/null +++ b/patches/net/minecraft/client/renderer/entity/state/PlayerRenderState.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/renderer/entity/state/PlayerRenderState.java ++++ b/net/minecraft/client/renderer/entity/state/PlayerRenderState.java +@@ -52,5 +_,7 @@ + @Nullable + public ItemUseAnimation useAnimation; + public boolean holdsChargedCrossbow; ++ @Nullable ++ public net.minecraft.client.model.HumanoidModel.ArmPose customArmPose; + } + } diff --git a/patches/net/minecraft/client/renderer/state/MapRenderState.java.patch b/patches/net/minecraft/client/renderer/state/MapRenderState.java.patch new file mode 100644 index 0000000000..2ac034ae3d --- /dev/null +++ b/patches/net/minecraft/client/renderer/state/MapRenderState.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/client/renderer/state/MapRenderState.java ++++ b/net/minecraft/client/renderer/state/MapRenderState.java +@@ -17,6 +_,7 @@ + + @OnlyIn(Dist.CLIENT) + public static class MapDecorationRenderState { ++ public net.minecraft.core.Holder type; + @Nullable + public TextureAtlasSprite atlasSprite; + public byte x; diff --git a/patches/net/minecraft/client/renderer/texture/AbstractTexture.java.patch b/patches/net/minecraft/client/renderer/texture/AbstractTexture.java.patch index 8990e16bac..ce14e13dcf 100644 --- a/patches/net/minecraft/client/renderer/texture/AbstractTexture.java.patch +++ b/patches/net/minecraft/client/renderer/texture/AbstractTexture.java.patch @@ -1,9 +1,25 @@ --- a/net/minecraft/client/renderer/texture/AbstractTexture.java +++ b/net/minecraft/client/renderer/texture/AbstractTexture.java -@@ -36,6 +_,20 @@ - GlStateManager._texParameter(3553, 10240, j); - } +@@ -15,9 +_,13 @@ + public static final int NOT_ASSIGNED = -1; + protected int id = -1; + protected boolean defaultBlur; ++ protected boolean blur; ++ protected boolean mipmap; + public void setFilter(boolean p_117961_, boolean p_117962_) { + RenderSystem.assertOnRenderThreadOrInit(); ++ this.blur = p_117961_; ++ this.mipmap = p_117962_; + int i; + int j; + if (p_117961_) { +@@ -31,6 +_,20 @@ + this.bind(); + GlStateManager._texParameter(3553, 10241, i); + GlStateManager._texParameter(3553, 10240, j); ++ } ++ + // FORGE: This seems to have been stripped out, but we need it + private boolean lastBlur; + private boolean lastMipmap; @@ -16,8 +32,6 @@ + + public void restoreLastBlurMipmap() { + setFilter(this.lastBlur, this.lastMipmap); -+ } -+ + } + public int getId() { - RenderSystem.assertOnRenderThreadOrInit(); - if (this.id == -1) { diff --git a/patches/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch b/patches/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch index 5835dfec53..c6a51c60f1 100644 --- a/patches/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch +++ b/patches/net/minecraft/client/renderer/texture/MipmapGenerator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/texture/MipmapGenerator.java +++ b/net/minecraft/client/renderer/texture/MipmapGenerator.java -@@ -25,12 +_,15 @@ +@@ -26,12 +_,15 @@ anativeimage[0] = p_251300_[0]; boolean flag = hasTransparentPixel(anativeimage[0]); @@ -17,7 +17,7 @@ int j = nativeimage1.getWidth(); int k = nativeimage1.getHeight(); -@@ -48,6 +_,7 @@ +@@ -49,6 +_,7 @@ ) ); } diff --git a/patches/net/minecraft/client/renderer/texture/TextureAtlas.java.patch b/patches/net/minecraft/client/renderer/texture/TextureAtlas.java.patch index 6fe9f37fe1..ffc654c26a 100644 --- a/patches/net/minecraft/client/renderer/texture/TextureAtlas.java.patch +++ b/patches/net/minecraft/client/renderer/texture/TextureAtlas.java.patch @@ -9,7 +9,7 @@ } @Override -@@ -172,5 +_,9 @@ +@@ -168,5 +_,9 @@ public void updateFilter(SpriteLoader.Preparations p_251993_) { this.setFilter(false, p_251993_.mipLevel() > 0); diff --git a/patches/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch b/patches/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch index 3c47d4cccc..3dbb3049e4 100644 --- a/patches/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch +++ b/patches/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch @@ -12,6 +12,6 @@ + y += this.contents.animatedTexture.getFrameY(frameIndex) * this.contents.height; + } + -+ return this.contents.getOriginalImage().getPixelRGBA(x, y); ++ return this.contents.getOriginalImage().getPixel(x, y); + } } diff --git a/patches/net/minecraft/client/resources/language/ClientLanguage.java.patch b/patches/net/minecraft/client/resources/language/ClientLanguage.java.patch index 86f9a1dabe..22eb7edb6f 100644 --- a/patches/net/minecraft/client/resources/language/ClientLanguage.java.patch +++ b/patches/net/minecraft/client/resources/language/ClientLanguage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/language/ClientLanguage.java +++ b/net/minecraft/client/resources/language/ClientLanguage.java -@@ -22,36 +_,50 @@ +@@ -22,23 +_,32 @@ public class ClientLanguage extends Language { private static final Logger LOGGER = LogUtils.getLogger(); private final Map storage; @@ -19,8 +19,8 @@ } public static ClientLanguage loadFrom(ResourceManager p_265765_, List p_265743_, boolean p_265470_) { - Map map = Maps.newHashMap(); -+ Map componentMap = Maps.newHashMap(); + Map map = new HashMap<>(); ++ Map componentMap = new HashMap<>(); for (String s : p_265743_) { String s1 = String.format(Locale.ROOT, "lang/%s.json", s); @@ -34,11 +34,12 @@ } catch (Exception exception) { LOGGER.warn("Skipped language file: {}:{} ({})", s2, s1, exception.toString()); } - } +@@ -46,13 +_,18 @@ } -- return new ClientLanguage(ImmutableMap.copyOf(map), p_265470_); -+ return new ClientLanguage(ImmutableMap.copyOf(map), p_265470_, ImmutableMap.copyOf(componentMap)); + DeprecatedTranslationsInfo.loadFromDefaultResource().applyToMap(map); +- return new ClientLanguage(Map.copyOf(map), p_265470_); ++ return new ClientLanguage(Map.copyOf(map), p_265470_, Map.copyOf(componentMap)); } + @Deprecated @@ -54,7 +55,7 @@ } catch (IOException ioexception) { LOGGER.warn("Failed to load translations for {} from pack {}", p_235036_, resource.sourcePackId(), ioexception); } -@@ -76,5 +_,15 @@ +@@ -77,5 +_,15 @@ @Override public FormattedCharSequence getVisualOrder(FormattedText p_118925_) { return FormattedBidiReorder.reorder(p_118925_, this.defaultRightToLeft); diff --git a/patches/net/minecraft/client/resources/model/BakedModel.java.patch b/patches/net/minecraft/client/resources/model/BakedModel.java.patch index 6f162f2274..15490942f9 100644 --- a/patches/net/minecraft/client/resources/model/BakedModel.java.patch +++ b/patches/net/minecraft/client/resources/model/BakedModel.java.patch @@ -24,5 +24,5 @@ + @Deprecated + default ItemTransforms getTransforms() { return ItemTransforms.NO_TRANSFORMS; } - ItemOverrides getOverrides(); - } + default BakedOverrides overrides() { + return BakedOverrides.EMPTY; diff --git a/patches/net/minecraft/client/resources/model/DelegateBakedModel.java.patch b/patches/net/minecraft/client/resources/model/DelegateBakedModel.java.patch new file mode 100644 index 0000000000..5c8eacbbe9 --- /dev/null +++ b/patches/net/minecraft/client/resources/model/DelegateBakedModel.java.patch @@ -0,0 +1,75 @@ +--- a/net/minecraft/client/resources/model/DelegateBakedModel.java ++++ b/net/minecraft/client/resources/model/DelegateBakedModel.java +@@ -20,16 +_,27 @@ + } + + @Override ++ @Deprecated + public List getQuads(@Nullable BlockState p_371320_, @Nullable Direction p_371369_, RandomSource p_371947_) { + return this.parent.getQuads(p_371320_, p_371369_, p_371947_); + } + + @Override ++ public List getQuads(@Nullable BlockState p_371320_, @Nullable Direction p_371369_, RandomSource p_371947_, net.neoforged.neoforge.client.model.data.ModelData modelData, @org.jetbrains.annotations.Nullable net.minecraft.client.renderer.RenderType renderType) { ++ return this.parent.getQuads(p_371320_, p_371369_, p_371947_, modelData, renderType); ++ } ++ ++ @Override + public boolean useAmbientOcclusion() { + return this.parent.useAmbientOcclusion(); + } + + @Override ++ public net.neoforged.neoforge.common.util.TriState useAmbientOcclusion(BlockState state, net.neoforged.neoforge.client.model.data.ModelData modelData, net.minecraft.client.renderer.RenderType renderType) { ++ return this.parent.useAmbientOcclusion(state, modelData, renderType); ++ } ++ ++ @Override + public boolean isGui3d() { + return this.parent.isGui3d(); + } +@@ -45,12 +_,44 @@ + } + + @Override ++ @Deprecated + public TextureAtlasSprite getParticleIcon() { + return this.parent.getParticleIcon(); + } + + @Override ++ public TextureAtlasSprite getParticleIcon(net.neoforged.neoforge.client.model.data.ModelData modelData) { ++ return this.parent.getParticleIcon(modelData); ++ } ++ ++ @Override ++ @Deprecated + public ItemTransforms getTransforms() { + return this.parent.getTransforms(); ++ } ++ ++ @Override ++ public BakedModel applyTransform(net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack poseStack, boolean applyLeftHandTransform) { ++ return this.parent.applyTransform(transformType, poseStack, applyLeftHandTransform); ++ } ++ ++ @Override ++ public net.neoforged.neoforge.client.model.data.ModelData getModelData(net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, BlockState state, net.neoforged.neoforge.client.model.data.ModelData modelData) { ++ return this.parent.getModelData(level, pos, state, modelData); ++ } ++ ++ @Override ++ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, net.neoforged.neoforge.client.model.data.ModelData data) { ++ return this.parent.getRenderTypes(state, rand, data); ++ } ++ ++ @Override ++ public List getRenderTypes(net.minecraft.world.item.ItemStack itemStack) { ++ return this.parent.getRenderTypes(itemStack); ++ } ++ ++ @Override ++ public List getRenderPasses(net.minecraft.world.item.ItemStack itemStack) { ++ return this.parent.getRenderPasses(itemStack); + } + } diff --git a/patches/net/minecraft/client/resources/model/ItemModel.java.patch b/patches/net/minecraft/client/resources/model/ItemModel.java.patch new file mode 100644 index 0000000000..10d96b4e0a --- /dev/null +++ b/patches/net/minecraft/client/resources/model/ItemModel.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/client/resources/model/ItemModel.java ++++ b/net/minecraft/client/resources/model/ItemModel.java +@@ -29,11 +_,11 @@ + + @Override + public BakedModel bake(ModelBaker p_371426_, Function p_371750_, ModelState p_371674_) { +- BakedModel bakedmodel = p_371426_.bake(this.id, p_371674_); ++ BakedModel bakedmodel = p_371426_.bake(this.id, p_371674_, p_371750_); + if (this.overrides.isEmpty()) { + return bakedmodel; + } else { +- BakedOverrides bakedoverrides = new BakedOverrides(p_371426_, this.overrides); ++ BakedOverrides bakedoverrides = new BakedOverrides(p_371426_, this.overrides, p_371750_); + return new ItemModel.BakedModelWithOverrides(bakedmodel, bakedoverrides); + } + } diff --git a/patches/net/minecraft/client/resources/model/ModelBaker.java.patch b/patches/net/minecraft/client/resources/model/ModelBaker.java.patch index 7535b116b1..36016793f0 100644 --- a/patches/net/minecraft/client/resources/model/ModelBaker.java.patch +++ b/patches/net/minecraft/client/resources/model/ModelBaker.java.patch @@ -1,17 +1,14 @@ --- a/net/minecraft/client/resources/model/ModelBaker.java +++ b/net/minecraft/client/resources/model/ModelBaker.java -@@ -6,9 +_,13 @@ +@@ -5,6 +_,10 @@ import net.neoforged.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -public interface ModelBaker { +public interface ModelBaker extends net.neoforged.neoforge.client.extensions.IModelBakerExtension { - UnbakedModel getModel(ResourceLocation p_252194_); - + /** + * @deprecated Forge: Use {@link #bake(ResourceLocation, ModelState, java.util.function.Function)} instead. + */ + @Deprecated - @Nullable BakedModel bake(ResourceLocation p_250776_, ModelState p_251280_); } diff --git a/patches/net/minecraft/client/resources/model/ModelBakery.java.patch b/patches/net/minecraft/client/resources/model/ModelBakery.java.patch index cf11be4790..ed116d3ffe 100644 --- a/patches/net/minecraft/client/resources/model/ModelBakery.java.patch +++ b/patches/net/minecraft/client/resources/model/ModelBakery.java.patch @@ -1,25 +1,12 @@ --- a/net/minecraft/client/resources/model/ModelBakery.java +++ b/net/minecraft/client/resources/model/ModelBakery.java -@@ -117,6 +_,12 @@ - p_252014_.popPush("special"); - this.loadSpecialItemModelAndDependencies(ItemRenderer.TRIDENT_IN_HAND_MODEL); - this.loadSpecialItemModelAndDependencies(ItemRenderer.SPYGLASS_IN_HAND_MODEL); -+ Set additionalModels = new HashSet<>(); -+ net.neoforged.neoforge.client.ClientHooks.onRegisterAdditionalModels(additionalModels); -+ for (ModelResourceLocation rl : additionalModels) { -+ UnbakedModel unbakedmodel = this.getModel(rl.id()); -+ this.registerModelAndLoadDependencies(rl, unbakedmodel); -+ } - this.topLevelModels.values().forEach(p_247954_ -> p_247954_.resolveParents(this::getModel)); - p_252014_.pop(); - } -@@ -246,14 +_,30 @@ +@@ -94,25 +_,46 @@ } @Override -+ @Nullable ++ @org.jetbrains.annotations.Nullable + public UnbakedModel getTopLevelModel(ModelResourceLocation location) { -+ return topLevelModels.get(location); ++ return topModels.get(location); + } + + @Override @@ -45,22 +32,17 @@ ModelBakery.this.bakedCache.put(modelbakery$bakedcachekey, bakedmodel1); return bakedmodel1; } -@@ -261,13 +_,19 @@ + } - @Nullable BakedModel bakeUncached(UnbakedModel p_352386_, ModelState p_352194_) { + return bakeUncached(p_352386_, p_352194_, this.modelTextureGetter); + } + + @Override -+ @Nullable + public BakedModel bakeUncached(UnbakedModel p_352386_, ModelState p_352194_, Function sprites) { - if (p_352386_ instanceof BlockModel blockmodel && blockmodel.getRootModel() == ModelBakery.GENERATION_MARKER) { - return ModelBakery.ITEM_MODEL_GENERATOR -- .generateBlockModel(this.modelTextureGetter, blockmodel) -- .bake(this, blockmodel, this.modelTextureGetter, p_352194_, false); -+ .generateBlockModel(sprites, blockmodel) -+ .bake(this, blockmodel, sprites, p_352194_, false); + if (p_352386_ instanceof BlockModel blockmodel && blockmodel.getRootModel() == SpecialModels.GENERATED_MARKER) { +- return ModelBakery.ITEM_MODEL_GENERATOR.generateBlockModel(this.modelTextureGetter, blockmodel).bake(this.modelTextureGetter, p_352194_, false); ++ return ModelBakery.ITEM_MODEL_GENERATOR.generateBlockModel(sprites, blockmodel).bake(sprites, p_352194_, false); } - return p_352386_.bake(this, this.modelTextureGetter, p_352194_); diff --git a/patches/net/minecraft/client/resources/model/ModelDiscovery.java.patch b/patches/net/minecraft/client/resources/model/ModelDiscovery.java.patch new file mode 100644 index 0000000000..7c9de8482a --- /dev/null +++ b/patches/net/minecraft/client/resources/model/ModelDiscovery.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/client/resources/model/ModelDiscovery.java ++++ b/net/minecraft/client/resources/model/ModelDiscovery.java +@@ -49,6 +_,7 @@ + }); + set.add(ItemRenderer.TRIDENT_MODEL); + set.add(ItemRenderer.SPYGLASS_MODEL); ++ net.neoforged.neoforge.client.ClientHooks.onRegisterAdditionalModels(set); + return set; + } + +@@ -77,6 +_,15 @@ + } + } + ); ++ // Neo: ensure standalone models registered in ModelEvent.RegisterAdditional are loaded ++ var it = set.iterator(); ++ while (it.hasNext()) { ++ ModelResourceLocation mrl = it.next(); ++ if (mrl.getVariant().equals(ModelResourceLocation.STANDALONE_VARIANT)) { ++ registerTopModel(mrl, getBlockModel(mrl.id())); ++ it.remove(); ++ } ++ } + if (!set.isEmpty()) { + LOGGER.warn("Missing mandatory models: {}", set.stream().map(p_370354_ -> "\n\t" + p_370354_).collect(Collectors.joining())); + } diff --git a/patches/net/minecraft/client/resources/model/ModelManager.java.patch b/patches/net/minecraft/client/resources/model/ModelManager.java.patch index dd6edb6544..2795dad254 100644 --- a/patches/net/minecraft/client/resources/model/ModelManager.java.patch +++ b/patches/net/minecraft/client/resources/model/ModelManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/model/ModelManager.java +++ b/net/minecraft/client/resources/model/ModelManager.java -@@ -63,13 +_,14 @@ +@@ -71,13 +_,14 @@ TextureAtlas.LOCATION_BLOCKS, ResourceLocation.withDefaultNamespace("blocks") ); @@ -16,15 +16,15 @@ public ModelManager(TextureManager p_119406_, BlockColors p_119407_, int p_119408_) { this.blockColors = p_119407_; -@@ -100,6 +_,7 @@ - Executor p_249221_ +@@ -102,6 +_,7 @@ + public final CompletableFuture reload( + PreparableReloadListener.PreparationBarrier p_249079_, ResourceManager p_251134_, Executor p_250550_, Executor p_249221_ ) { - p_250336_.startTick(); + net.neoforged.neoforge.client.model.geometry.GeometryLoaderManager.init(); - CompletableFuture> completablefuture = loadBlockModels(p_251134_, p_250550_); - CompletableFuture>> completablefuture1 = loadBlockStates(p_251134_, p_250550_); - CompletableFuture completablefuture2 = completablefuture.thenCombineAsync( -@@ -218,6 +_,8 @@ + UnbakedModel unbakedmodel = MissingBlockModel.missingModel(); + BlockStateModelLoader blockstatemodelloader = new BlockStateModelLoader(unbakedmodel); + CompletableFuture> completablefuture = loadBlockModels(p_251134_, p_250550_); +@@ -258,6 +_,8 @@ .collect(Collectors.joining("\n")) ) ); @@ -32,17 +32,17 @@ + net.neoforged.neoforge.client.ClientHooks.onModifyBakingResult(p_248945_.getBakedTopLevelModels(), p_250646_, p_248945_); p_252136_.popPush("dispatch"); Map map = p_248945_.getBakedTopLevelModels(); - BakedModel bakedmodel = map.get(ModelBakery.MISSING_MODEL_VARIANT); -@@ -247,6 +_,8 @@ + BakedModel bakedmodel = map.get(MissingBlockModel.VARIANT); +@@ -289,6 +_,8 @@ this.bakedRegistry = modelbakery.getBakedTopLevelModels(); - this.modelGroups = modelbakery.getModelGroups(); + this.modelGroups = p_248996_.modelGroups; this.missingModel = p_248996_.missingModel; + this.modelBakery = modelbakery; + net.neoforged.neoforge.client.ClientHooks.onModelBake(this, this.bakedRegistry, modelbakery); p_251960_.popPush("cache"); this.blockModelShaper.replaceCache(p_248996_.modelCache); p_251960_.pop(); -@@ -272,6 +_,7 @@ +@@ -313,6 +_,7 @@ } public TextureAtlas getAtlas(ResourceLocation p_119429_) { @@ -50,7 +50,7 @@ return this.atlases.getAtlas(p_119429_); } -@@ -282,6 +_,10 @@ +@@ -323,6 +_,10 @@ public void updateMaxMipLevel(int p_119411_) { this.maxMipmapLevels = p_119411_; diff --git a/patches/net/minecraft/client/resources/model/ModelResourceLocation.java.patch b/patches/net/minecraft/client/resources/model/ModelResourceLocation.java.patch index ff24a3eafd..85d4fc00bc 100644 --- a/patches/net/minecraft/client/resources/model/ModelResourceLocation.java.patch +++ b/patches/net/minecraft/client/resources/model/ModelResourceLocation.java.patch @@ -8,7 +8,7 @@ public ModelResourceLocation(ResourceLocation id, String variant) { variant = lowercaseVariant(variant); -@@ -21,6 +_,14 @@ +@@ -17,6 +_,14 @@ public static ModelResourceLocation inventory(ResourceLocation p_352141_) { return new ModelResourceLocation(p_352141_, "inventory"); diff --git a/patches/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch b/patches/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch index 8404abbec3..012bbbffab 100644 --- a/patches/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch +++ b/patches/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch @@ -1,29 +1,16 @@ --- a/net/minecraft/client/resources/model/MultiPartBakedModel.java +++ b/net/minecraft/client/resources/model/MultiPartBakedModel.java -@@ -20,7 +_,7 @@ - import org.apache.commons.lang3.tuple.Pair; +@@ -16,7 +_,7 @@ + import net.neoforged.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) --public class MultiPartBakedModel implements BakedModel { -+public class MultiPartBakedModel implements BakedModel, net.neoforged.neoforge.client.model.IDynamicBakedModel { - private final List, BakedModel>> selectors; - protected final boolean hasAmbientOcclusion; - protected final boolean isGui3d; -@@ -29,10 +_,12 @@ - protected final ItemTransforms transforms; - protected final ItemOverrides overrides; +-public class MultiPartBakedModel extends DelegateBakedModel { ++public class MultiPartBakedModel extends DelegateBakedModel implements net.neoforged.neoforge.client.model.IDynamicBakedModel { + private final List selectors; private final Map selectorCache = new Reference2ObjectOpenHashMap<>(); -+ private final BakedModel defaultModel; - public MultiPartBakedModel(List, BakedModel>> p_119462_) { +@@ -33,11 +_,7 @@ this.selectors = p_119462_; - BakedModel bakedmodel = p_119462_.iterator().next().getRight(); -+ this.defaultModel = bakedmodel; - this.hasAmbientOcclusion = bakedmodel.useAmbientOcclusion(); - this.isGui3d = bakedmodel.isGui3d(); - this.usesBlockLight = bakedmodel.usesBlockLight(); -@@ -41,11 +_,7 @@ - this.overrides = bakedmodel.getOverrides(); } - @Override @@ -35,14 +22,14 @@ BitSet bitset = this.selectorCache.get(p_235050_); if (bitset == null) { bitset = new BitSet(); -@@ -59,17 +_,28 @@ +@@ -50,19 +_,47 @@ this.selectorCache.put(p_235050_, bitset); } + return bitset; + } -- List list = Lists.newArrayList(); +- List list = new ArrayList<>(); + // FORGE: Implement our overloads (here and below) so child models can have custom logic + @Override + public List getQuads(@Nullable BlockState p_235050_, @Nullable Direction p_235051_, RandomSource p_235052_, net.neoforged.neoforge.client.model.data.ModelData modelData, @org.jetbrains.annotations.Nullable net.minecraft.client.renderer.RenderType renderType) { @@ -50,29 +37,25 @@ + return Collections.emptyList(); + } else { + BitSet bitset = getSelectors(p_235050_); -+ List> list = Lists.newArrayList(); - long k = p_235052_.nextLong(); ++ List> list = new ArrayList<>(); + long j = p_235052_.nextLong(); - for (int j = 0; j < bitset.length(); j++) { - if (bitset.get(j)) { -- list.addAll(this.selectors.get(j).getRight().getQuads(p_235050_, p_235051_, RandomSource.create(k))); -+ var model = this.selectors.get(j).getRight(); -+ if (renderType == null || model.getRenderTypes(p_235050_, p_235052_, modelData).contains(renderType)) // FORGE: Only put quad data if the model is using the render type passed -+ list.add(model.getQuads(p_235050_, p_235051_, RandomSource.create(k), net.neoforged.neoforge.client.model.data.MultipartModelData.resolve(modelData, model), renderType)); + for (int k = 0; k < bitset.length(); k++) { + if (bitset.get(k)) { +- p_235052_.setSeed(j); +- list.addAll(this.selectors.get(k).model.getQuads(p_235050_, p_235051_, p_235052_)); ++ ++ var model = this.selectors.get(k).model; ++ if (renderType == null || model.getRenderTypes(p_235050_, p_235052_, modelData).contains(renderType)) { // FORGE: Only put quad data if the model is using the render type passed ++ p_235052_.setSeed(j); ++ list.add(model.getQuads(p_235050_, p_235051_, p_235052_, net.neoforged.neoforge.client.model.data.MultipartModelData.resolve(modelData, model), renderType)); ++ } } } - return list; + return net.neoforged.neoforge.common.util.ConcatenatedListView.of(list); } - } - -@@ -79,6 +_,16 @@ - } - - @Override -+ public net.neoforged.neoforge.common.util.TriState useAmbientOcclusion(BlockState state, net.neoforged.neoforge.client.model.data.ModelData modelData, net.minecraft.client.renderer.RenderType renderType) { -+ return this.defaultModel.useAmbientOcclusion(state, modelData, renderType); + } + + @Override @@ -80,43 +63,14 @@ + return net.neoforged.neoforge.client.model.data.MultipartModelData.create(selectors, getSelectors(state), level, pos, state, modelData); + } + -+ @Override - public boolean isGui3d() { - return this.isGui3d; - } -@@ -94,13 +_,35 @@ - } - - @Override -+ @Deprecated - public TextureAtlasSprite getParticleIcon() { - return this.particleIcon; - } - - @Override -+ public TextureAtlasSprite getParticleIcon(net.neoforged.neoforge.client.model.data.ModelData modelData) { -+ return this.defaultModel.getParticleIcon(modelData); -+ } -+ -+ @Deprecated -+ @Override - public ItemTransforms getTransforms() { - return this.transforms; -+ } -+ -+ @Override -+ public BakedModel applyTransform(net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack poseStack, boolean applyLeftHandTransform) { -+ return this.defaultModel.applyTransform(transformType, poseStack, applyLeftHandTransform); -+ } -+ + @Override // FORGE: Get render types based on the selectors matched by the given block state + public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(@org.jetbrains.annotations.NotNull BlockState state, @org.jetbrains.annotations.NotNull RandomSource rand, @org.jetbrains.annotations.NotNull net.neoforged.neoforge.client.model.data.ModelData data) { + var renderTypeSets = new java.util.LinkedList(); + var selectors = getSelectors(state); + for (int i = 0; i < selectors.length(); i++) + if (selectors.get(i)) -+ renderTypeSets.add(this.selectors.get(i).getRight().getRenderTypes(state, rand, data)); ++ renderTypeSets.add(this.selectors.get(i).model.getRenderTypes(state, rand, data)); + return net.neoforged.neoforge.client.ChunkRenderTypeSet.union(renderTypeSets); } - @Override + @OnlyIn(Dist.CLIENT) diff --git a/patches/net/minecraft/client/resources/model/SimpleBakedModel.java.patch b/patches/net/minecraft/client/resources/model/SimpleBakedModel.java.patch index b477646b9c..41044226e2 100644 --- a/patches/net/minecraft/client/resources/model/SimpleBakedModel.java.patch +++ b/patches/net/minecraft/client/resources/model/SimpleBakedModel.java.patch @@ -1,76 +1,68 @@ --- a/net/minecraft/client/resources/model/SimpleBakedModel.java +++ b/net/minecraft/client/resources/model/SimpleBakedModel.java -@@ -26,7 +_,12 @@ +@@ -25,7 +_,11 @@ + protected final boolean usesBlockLight; protected final TextureAtlasSprite particleIcon; protected final ItemTransforms transforms; - protected final ItemOverrides overrides; -+ protected final net.neoforged.neoforge.client.ChunkRenderTypeSet blockRenderTypes; -+ protected final List itemRenderTypes; -+ protected final List fabulousItemRenderTypes; ++ @Nullable protected final net.neoforged.neoforge.client.ChunkRenderTypeSet blockRenderTypes; ++ @Nullable protected final List itemRenderTypes; -+ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, ItemOverrides, net.neoforged.neoforge.client.RenderTypeGroup) variant with RenderTypeGroup} **/ ++ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, net.neoforged.neoforge.client.RenderTypeGroup) variant with RenderTypeGroup} **/ + @Deprecated public SimpleBakedModel( List p_119489_, Map> p_119490_, -@@ -37,6 +_,20 @@ - ItemTransforms p_119495_, - ItemOverrides p_119496_ +@@ -35,6 +_,19 @@ + TextureAtlasSprite p_119494_, + ItemTransforms p_119495_ ) { -+ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, p_119496_, net.neoforged.neoforge.client.RenderTypeGroup.EMPTY); ++ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, net.neoforged.neoforge.client.RenderTypeGroup.EMPTY); + } + + public SimpleBakedModel( -+ List p_119489_, -+ Map> p_119490_, -+ boolean p_119491_, -+ boolean p_119492_, -+ boolean p_119493_, -+ TextureAtlasSprite p_119494_, -+ ItemTransforms p_119495_, -+ ItemOverrides p_119496_, -+ net.neoforged.neoforge.client.RenderTypeGroup renderTypes ++ List p_119489_, ++ Map> p_119490_, ++ boolean p_119491_, ++ boolean p_119492_, ++ boolean p_119493_, ++ TextureAtlasSprite p_119494_, ++ ItemTransforms p_119495_, ++ net.neoforged.neoforge.client.RenderTypeGroup renderTypes + ) { this.unculledFaces = p_119489_; this.culledFaces = p_119490_; this.hasAmbientOcclusion = p_119491_; -@@ -45,6 +_,9 @@ +@@ -42,6 +_,8 @@ + this.usesBlockLight = p_119492_; this.particleIcon = p_119494_; this.transforms = p_119495_; - this.overrides = p_119496_; + this.blockRenderTypes = !renderTypes.isEmpty() ? net.neoforged.neoforge.client.ChunkRenderTypeSet.of(renderTypes.block()) : null; + this.itemRenderTypes = !renderTypes.isEmpty() ? List.of(renderTypes.entity()) : null; -+ this.fabulousItemRenderTypes = !renderTypes.isEmpty() ? List.of(renderTypes.entityFabulous()) : null; } @Override -@@ -87,6 +_,25 @@ - return this.overrides; +@@ -79,6 +_,20 @@ + return this.transforms; } + @Override -+ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(@org.jetbrains.annotations.NotNull BlockState state, @org.jetbrains.annotations.NotNull RandomSource rand, @org.jetbrains.annotations.NotNull net.neoforged.neoforge.client.model.data.ModelData data) { ++ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, net.neoforged.neoforge.client.model.data.ModelData data) { + if (blockRenderTypes != null) + return blockRenderTypes; + return BakedModel.super.getRenderTypes(state, rand, data); + } + + @Override -+ public List getRenderTypes(net.minecraft.world.item.ItemStack itemStack, boolean fabulous) { -+ if (!fabulous) { -+ if (itemRenderTypes != null) -+ return itemRenderTypes; -+ } else { -+ if (fabulousItemRenderTypes != null) -+ return fabulousItemRenderTypes; -+ } -+ return BakedModel.super.getRenderTypes(itemStack, fabulous); ++ public List getRenderTypes(net.minecraft.world.item.ItemStack itemStack) { ++ if (itemRenderTypes != null) ++ return itemRenderTypes; ++ return BakedModel.super.getRenderTypes(itemStack); + } + @OnlyIn(Dist.CLIENT) public static class Builder { - private final List unculledFaces = Lists.newArrayList(); -@@ -133,7 +_,13 @@ + private final ImmutableList.Builder unculledFaces = ImmutableList.builder(); +@@ -124,7 +_,13 @@ return this; } @@ -84,12 +76,12 @@ if (this.particleIcon == null) { throw new RuntimeException("Missing particle!"); } else { -@@ -145,7 +_,8 @@ +@@ -136,7 +_,8 @@ + this.usesBlockLight, this.isGui3d, this.particleIcon, - this.transforms, -- this.overrides -+ this.overrides, +- this.transforms ++ this.transforms, + renderTypes ); } diff --git a/patches/net/minecraft/client/resources/model/WeightedBakedModel.java.patch b/patches/net/minecraft/client/resources/model/WeightedBakedModel.java.patch index 3483772f34..ecca5f2753 100644 --- a/patches/net/minecraft/client/resources/model/WeightedBakedModel.java.patch +++ b/patches/net/minecraft/client/resources/model/WeightedBakedModel.java.patch @@ -1,67 +1,30 @@ --- a/net/minecraft/client/resources/model/WeightedBakedModel.java +++ b/net/minecraft/client/resources/model/WeightedBakedModel.java -@@ -17,7 +_,7 @@ +@@ -12,7 +_,7 @@ import net.neoforged.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) --public class WeightedBakedModel implements BakedModel { -+public class WeightedBakedModel implements BakedModel, net.neoforged.neoforge.client.model.IDynamicBakedModel { - private final int totalWeight; - private final List> list; - private final BakedModel wrapped; -@@ -29,9 +_,10 @@ +-public class WeightedBakedModel extends DelegateBakedModel { ++public class WeightedBakedModel extends DelegateBakedModel implements net.neoforged.neoforge.client.model.IDynamicBakedModel { + private final SimpleWeightedRandomList list; + + public WeightedBakedModel(SimpleWeightedRandomList p_371780_) { +@@ -20,8 +_,15 @@ + this.list = p_371780_; } - @Override +- @Override - public List getQuads(@Nullable BlockState p_235058_, @Nullable Direction p_235059_, RandomSource p_235060_) { -+ // FORGE: Implement our overloads (here and below) so child models can have custom logic +- return this.list.getRandomValue(p_235060_).map(p_370367_ -> p_370367_.getQuads(p_235058_, p_235059_, p_235060_)).orElse(Collections.emptyList()); ++ @Override // FORGE: Implement our overload so child models can have custom logic + public List getQuads(@Nullable BlockState p_235058_, @Nullable Direction p_235059_, RandomSource p_235060_, net.neoforged.neoforge.client.model.data.ModelData modelData, @org.jetbrains.annotations.Nullable net.minecraft.client.renderer.RenderType renderType) { - return WeightedRandom.getWeightedItem(this.list, Math.abs((int)p_235060_.nextLong()) % this.totalWeight) -- .map(p_337442_ -> p_337442_.data().getQuads(p_235058_, p_235059_, p_235060_)) -+ .map(p_235065_ -> p_235065_.data().getQuads(p_235058_, p_235059_, p_235060_, modelData, renderType)) - .orElse(Collections.emptyList()); - } - -@@ -41,6 +_,11 @@ - } - - @Override -+ public net.neoforged.neoforge.common.util.TriState useAmbientOcclusion(BlockState state, net.neoforged.neoforge.client.model.data.ModelData modelData, net.minecraft.client.renderer.RenderType renderType) { -+ return this.wrapped.useAmbientOcclusion(state, modelData, renderType); -+ } -+ -+ @Override - public boolean isGui3d() { - return this.wrapped.isGui3d(); - } -@@ -61,8 +_,30 @@ - } - - @Override -+ public TextureAtlasSprite getParticleIcon(net.neoforged.neoforge.client.model.data.ModelData modelData) { -+ return this.wrapped.getParticleIcon(modelData); -+ } -+ -+ @Override - public ItemTransforms getTransforms() { - return this.wrapped.getTransforms(); -+ } -+ -+ @Override -+ public BakedModel applyTransform(net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack poseStack, boolean applyLeftHandTransform) { -+ return this.wrapped.applyTransform(transformType, poseStack, applyLeftHandTransform); ++ return this.list.getRandomValue(p_235060_).map(p_370367_ -> p_370367_.getQuads(p_235058_, p_235059_, p_235060_, modelData, renderType)).orElse(Collections.emptyList()); + } + + @Override // FORGE: Get render types based on the active weighted model -+ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(@org.jetbrains.annotations.NotNull BlockState state, @org.jetbrains.annotations.NotNull RandomSource rand, @org.jetbrains.annotations.NotNull net.neoforged.neoforge.client.model.data.ModelData data) { -+ return WeightedRandom.getWeightedItem(this.list, Math.abs((int)rand.nextLong()) % this.totalWeight) -+ .map((p_235065_) -> p_235065_.data().getRenderTypes(state, rand, data)) -+ .orElse(net.neoforged.neoforge.client.ChunkRenderTypeSet.none()); -+ } -+ -+ @Override -+ public net.neoforged.neoforge.client.model.data.ModelData getModelData(net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos, BlockState state, net.neoforged.neoforge.client.model.data.ModelData modelData) { -+ return this.wrapped.getModelData(level, pos, state, modelData); ++ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, net.neoforged.neoforge.client.model.data.ModelData data) { ++ return list.getRandomValue(rand) ++ .map(model -> model.getRenderTypes(state, rand, data)) ++ .orElse(net.neoforged.neoforge.client.ChunkRenderTypeSet.none()); } - - @Override + } diff --git a/patches/net/minecraft/client/server/IntegratedServer.java.patch b/patches/net/minecraft/client/server/IntegratedServer.java.patch index 2c8e4f62cc..8d9e76bd8e 100644 --- a/patches/net/minecraft/client/server/IntegratedServer.java.patch +++ b/patches/net/minecraft/client/server/IntegratedServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/server/IntegratedServer.java +++ b/net/minecraft/client/server/IntegratedServer.java -@@ -73,10 +_,12 @@ +@@ -71,10 +_,12 @@ this.setPvpAllowed(true); this.setFlightAllowed(true); this.initializeKeyPair(); @@ -13,7 +13,7 @@ return true; } -@@ -225,6 +_,7 @@ +@@ -218,6 +_,7 @@ @Override public void halt(boolean p_120053_) { diff --git a/patches/net/minecraft/client/sounds/MusicManager.java.patch b/patches/net/minecraft/client/sounds/MusicManager.java.patch index 9772e14aed..578bcd60a4 100644 --- a/patches/net/minecraft/client/sounds/MusicManager.java.patch +++ b/patches/net/minecraft/client/sounds/MusicManager.java.patch @@ -15,5 +15,5 @@ + } + if (this.currentMusic != null) { - if (!music.getEvent().value().getLocation().equals(this.currentMusic.getLocation()) && music.replaceCurrentMusic()) { + if (!music.getEvent().value().location().equals(this.currentMusic.getLocation()) && music.replaceCurrentMusic()) { this.minecraft.getSoundManager().stop(this.currentMusic); diff --git a/patches/net/minecraft/commands/CommandSourceStack.java.patch b/patches/net/minecraft/commands/CommandSourceStack.java.patch index 6065370948..09ebb7cb46 100644 --- a/patches/net/minecraft/commands/CommandSourceStack.java.patch +++ b/patches/net/minecraft/commands/CommandSourceStack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/CommandSourceStack.java +++ b/net/minecraft/commands/CommandSourceStack.java -@@ -43,7 +_,7 @@ +@@ -46,7 +_,7 @@ import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; diff --git a/patches/net/minecraft/commands/Commands.java.patch b/patches/net/minecraft/commands/Commands.java.patch index e345615137..17ef4a8463 100644 --- a/patches/net/minecraft/commands/Commands.java.patch +++ b/patches/net/minecraft/commands/Commands.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -214,7 +_,7 @@ +@@ -219,7 +_,7 @@ JfrCommand.register(this.dispatcher); } @@ -9,7 +9,7 @@ TestCommand.register(this.dispatcher); RaidCommand.register(this.dispatcher, p_230944_); DebugPathCommand.register(this.dispatcher); -@@ -248,6 +_,7 @@ +@@ -253,6 +_,7 @@ if (p_230943_.includeIntegrated) { PublishCommand.register(this.dispatcher); } @@ -17,7 +17,7 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -265,6 +_,16 @@ +@@ -270,6 +_,16 @@ public void performCommand(ParseResults p_242844_, String p_242841_) { CommandSourceStack commandsourcestack = p_242844_.getContext().getSource(); @@ -31,10 +31,10 @@ + } + p_242844_ = event.getParseResults(); + - commandsourcestack.getServer().getProfiler().push(() -> "/" + p_242841_); + Profiler.get().push(() -> "/" + p_242841_); ContextChain contextchain = finishParsing(p_242844_, p_242841_, commandsourcestack); -@@ -362,7 +_,8 @@ +@@ -367,7 +_,8 @@ Map, CommandNode> map = Maps.newHashMap(); RootCommandNode rootcommandnode = new RootCommandNode<>(); map.put(this.dispatcher.getRoot(), rootcommandnode); diff --git a/patches/net/minecraft/commands/arguments/ResourceKeyArgument.java.patch b/patches/net/minecraft/commands/arguments/ResourceKeyArgument.java.patch new file mode 100644 index 0000000000..6fa16e9d47 --- /dev/null +++ b/patches/net/minecraft/commands/arguments/ResourceKeyArgument.java.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/commands/arguments/ResourceKeyArgument.java ++++ b/net/minecraft/commands/arguments/ResourceKeyArgument.java +@@ -49,6 +_,9 @@ + private static final DynamicCommandExceptionType ERROR_INVALID_ADVANCEMENT = new DynamicCommandExceptionType( + p_378835_ -> Component.translatableEscape("advancement.advancementNotFound", p_378835_) + ); ++ private static final com.mojang.brigadier.exceptions.SimpleCommandExceptionType ERROR_NO_RECIPES_ON_CLIENT = new com.mojang.brigadier.exceptions.SimpleCommandExceptionType( ++ Component.translatable("commands.neoforge.vanilla.resource_key.no_recipes_on_client") ++ ); + final ResourceKey> registryKey; + + public ResourceKeyArgument(ResourceKey> p_212367_) { +@@ -91,6 +_,9 @@ + } + + public static RecipeHolder getRecipe(CommandContext p_380134_, String p_379840_) throws CommandSyntaxException { ++ if (p_380134_.getSource().getUnsidedLevel().isClientSide()) { ++ throw ERROR_NO_RECIPES_ON_CLIENT.create(); ++ } + RecipeManager recipemanager = p_380134_.getSource().getServer().getRecipeManager(); + ResourceKey> resourcekey = getRegistryKey(p_380134_, p_379840_, Registries.RECIPE, ERROR_INVALID_RECIPE); + return recipemanager.byKey(resourcekey).orElseThrow(() -> ERROR_INVALID_RECIPE.create(resourcekey.location())); +@@ -98,7 +_,7 @@ + + public static AdvancementHolder getAdvancement(CommandContext p_379729_, String p_379326_) throws CommandSyntaxException { + ResourceKey resourcekey = getRegistryKey(p_379729_, p_379326_, Registries.ADVANCEMENT, ERROR_INVALID_ADVANCEMENT); +- AdvancementHolder advancementholder = p_379729_.getSource().getServer().getAdvancements().get(resourcekey.location()); ++ AdvancementHolder advancementholder = p_379729_.getSource().getAdvancement(resourcekey.location()); + if (advancementholder == null) { + throw ERROR_INVALID_ADVANCEMENT.create(resourcekey.location()); + } else { diff --git a/patches/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch b/patches/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch deleted file mode 100644 index 676795818b..0000000000 --- a/patches/net/minecraft/commands/arguments/ResourceLocationArgument.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/commands/arguments/ResourceLocationArgument.java -+++ b/net/minecraft/commands/arguments/ResourceLocationArgument.java -@@ -29,7 +_,7 @@ - - public static AdvancementHolder getAdvancement(CommandContext p_106988_, String p_106989_) throws CommandSyntaxException { - ResourceLocation resourcelocation = getId(p_106988_, p_106989_); -- AdvancementHolder advancementholder = p_106988_.getSource().getServer().getAdvancements().get(resourcelocation); -+ AdvancementHolder advancementholder = p_106988_.getSource().getAdvancement(resourcelocation); - if (advancementholder == null) { - throw ERROR_UNKNOWN_ADVANCEMENT.create(resourcelocation); - } else { -@@ -38,7 +_,7 @@ - } - - public static RecipeHolder getRecipe(CommandContext p_106995_, String p_106996_) throws CommandSyntaxException { -- RecipeManager recipemanager = p_106995_.getSource().getServer().getRecipeManager(); -+ RecipeManager recipemanager = p_106995_.getSource().getRecipeManager(); - ResourceLocation resourcelocation = getId(p_106995_, p_106996_); - return recipemanager.byKey(resourcelocation).orElseThrow(() -> ERROR_UNKNOWN_RECIPE.create(resourcelocation)); - } diff --git a/patches/net/minecraft/core/Holder.java.patch b/patches/net/minecraft/core/Holder.java.patch index f4b396b691..4cb8ce7c06 100644 --- a/patches/net/minecraft/core/Holder.java.patch +++ b/patches/net/minecraft/core/Holder.java.patch @@ -9,7 +9,7 @@ T value(); boolean isBound(); -@@ -220,6 +_,14 @@ +@@ -229,6 +_,14 @@ } } @@ -24,7 +24,7 @@ void bindTags(Collection> p_205770_) { this.tags = Set.copyOf(p_205770_); } -@@ -232,6 +_,33 @@ +@@ -241,6 +_,33 @@ @Override public String toString() { return "Reference{" + this.key + "=" + this.value + "}"; diff --git a/patches/net/minecraft/core/HolderLookup.java.patch b/patches/net/minecraft/core/HolderLookup.java.patch index d954817172..aa44414fdb 100644 --- a/patches/net/minecraft/core/HolderLookup.java.patch +++ b/patches/net/minecraft/core/HolderLookup.java.patch @@ -4,17 +4,24 @@ return this.listTags().map(HolderSet.Named::key); } -- public interface Provider { -+ public interface Provider extends net.neoforged.neoforge.common.extensions.IHolderLookupProviderExtension { - Stream>> listRegistries(); +- public interface Provider extends HolderGetter.Provider { ++ public interface Provider extends HolderGetter.Provider, net.neoforged.neoforge.common.extensions.IHolderLookupProviderExtension { + Stream>> listRegistryKeys(); - Optional> lookup(ResourceKey> p_256285_); -@@ -96,6 +_,11 @@ + default Stream> listRegistries() { +@@ -96,6 +_,18 @@ }; } ++ /** ++ * {@return the data map value attached with the object with the key, or {@code null} if there's no attached value} ++ * ++ * @param type the type of the data map ++ * @param key the object to get the value for ++ * @param the data type ++ */ + @org.jetbrains.annotations.Nullable -+ default A getData(net.neoforged.neoforge.registries.datamaps.DataMapType attachment, ResourceKey key) { ++ default A getData(net.neoforged.neoforge.registries.datamaps.DataMapType type, ResourceKey key) { + return null; + } + diff --git a/patches/net/minecraft/core/HolderSet.java.patch b/patches/net/minecraft/core/HolderSet.java.patch index a557fdb28d..6c2a44d7f0 100644 --- a/patches/net/minecraft/core/HolderSet.java.patch +++ b/patches/net/minecraft/core/HolderSet.java.patch @@ -9,7 +9,7 @@ Stream> stream(); int size(); -@@ -174,6 +_,9 @@ +@@ -182,6 +_,9 @@ void bind(List> p_205836_) { this.contents = List.copyOf(p_205836_); @@ -19,7 +19,7 @@ } public TagKey key() { -@@ -208,6 +_,11 @@ +@@ -225,6 +_,11 @@ @Override public boolean canSerializeIn(HolderOwner p_256542_) { return this.owner.canSerializeIn(p_256542_); diff --git a/patches/net/minecraft/core/MappedRegistry.java.patch b/patches/net/minecraft/core/MappedRegistry.java.patch index e7f390bb75..08874566bd 100644 --- a/patches/net/minecraft/core/MappedRegistry.java.patch +++ b/patches/net/minecraft/core/MappedRegistry.java.patch @@ -1,28 +1,15 @@ --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -31,7 +_,7 @@ +@@ -30,7 +_,7 @@ + import net.minecraft.tags.TagLoader; import net.minecraft.util.RandomSource; - import org.slf4j.Logger; -public class MappedRegistry implements WritableRegistry { +public class MappedRegistry extends net.neoforged.neoforge.registries.BaseMappedRegistry implements WritableRegistry { - private static final Logger LOGGER = LogUtils.getLogger(); - final ResourceKey> key; + private final ResourceKey> key; private final ObjectList> byId = new ObjectArrayList<>(256); -@@ -75,6 +_,12 @@ - public Stream> listTags() { - return MappedRegistry.this.getTags().map(Pair::getSecond); - } -+ -+ @Override -+ @org.jetbrains.annotations.Nullable -+ public A getData(net.neoforged.neoforge.registries.datamaps.DataMapType type, ResourceKey key) { -+ return MappedRegistry.this.getData(type, key); -+ } - }; - private final Object tagAdditionLock = new Object(); - -@@ -114,9 +_,17 @@ + private final Reference2IntMap toId = Util.make(new Reference2IntOpenHashMap<>(), p_304142_ -> p_304142_.defaultReturnValue(-1)); +@@ -86,9 +_,17 @@ @Override public Holder.Reference register(ResourceKey p_256252_, T p_256591_, RegistrationInfo p_326235_) { @@ -38,77 +25,89 @@ + throw new IllegalStateException(String.format(java.util.Locale.ENGLISH, "Invalid id %d - maximum id range of %d exceeded.", i, this.getMaxId())); + if (this.byLocation.containsKey(p_256252_.location())) { - Util.pauseInIde(new IllegalStateException("Adding duplicate key '" + p_256252_ + "' to registry")); - } -@@ -135,16 +_,18 @@ - reference.bindKey(p_256252_); - } else { - reference = this.byKey.computeIfAbsent(p_256252_, p_258168_ -> Holder.Reference.createStandAlone(this.holderOwner(), (ResourceKey)p_258168_)); -+ // Forge: Bind the value immediately so it can be queried while the registry is not frozen -+ reference.bindValue(p_256591_); - } + throw (IllegalStateException)Util.pauseInIde(new IllegalStateException("Adding duplicate key '" + p_256252_ + "' to registry")); + } else if (this.byValue.containsKey(p_256591_)) { +@@ -104,16 +_,18 @@ + reference.bindKey(p_256252_); + } else { + reference = this.byKey.computeIfAbsent(p_256252_, p_367800_ -> Holder.Reference.createStandAlone(this, (ResourceKey)p_367800_)); ++ // Forge: Bind the value immediately so it can be queried while the registry is not frozen ++ reference.bindValue(p_256591_); + } - this.byKey.put(p_256252_, reference); - this.byLocation.put(p_256252_.location(), reference); - this.byValue.put(p_256591_, reference); -- int i = this.byId.size(); - this.byId.add(reference); - this.toId.put(p_256591_, i); - this.registrationInfos.put(p_256252_, p_326235_); - this.registryLifecycle = this.registryLifecycle.add(p_326235_.lifecycle()); -+ this.addCallbacks.forEach(addCallback -> addCallback.onAdd(this, i, p_256252_, p_256591_)); - return reference; + this.byKey.put(p_256252_, reference); + this.byLocation.put(p_256252_.location(), reference); + this.byValue.put(p_256591_, reference); +- int i = this.byId.size(); + this.byId.add(reference); + this.toId.put(p_256591_, i); + this.registrationInfos.put(p_256252_, p_326235_); + this.registryLifecycle = this.registryLifecycle.add(p_326235_.lifecycle()); ++ this.addCallbacks.forEach(addCallback -> addCallback.onAdd(this, i, p_256252_, p_256591_)); + return reference; + } } - -@@ -168,7 +_,7 @@ +@@ -138,7 +_,7 @@ @Nullable @Override - public T get(@Nullable ResourceKey p_122714_) { + public T getValue(@Nullable ResourceKey p_122714_) { - return getValueFromNullable(this.byKey.get(p_122714_)); + return getValueFromNullable(this.byKey.get(resolve(p_122714_))); } @Nullable -@@ -184,12 +_,12 @@ +@@ -154,12 +_,12 @@ @Override - public Optional> getHolder(ResourceLocation p_316743_) { + public Optional> get(ResourceLocation p_316743_) { - return Optional.ofNullable(this.byLocation.get(p_316743_)); + return Optional.ofNullable(this.byLocation.get(resolve(p_316743_))); } @Override - public Optional> getHolder(ResourceKey p_205905_) { + public Optional> get(ResourceKey p_205905_) { - return Optional.ofNullable(this.byKey.get(p_205905_)); + return Optional.ofNullable(this.byKey.get(resolve(p_205905_))); } @Override -@@ -204,7 +_,7 @@ +@@ -174,12 +_,12 @@ } Holder.Reference getOrCreateHolderOrThrow(ResourceKey p_248831_) { -- return this.byKey.computeIfAbsent(p_248831_, p_258169_ -> { +- return this.byKey.computeIfAbsent(p_248831_, p_367801_ -> { + return this.byKey.computeIfAbsent(resolve(p_248831_), p_258169_ -> { if (this.unregisteredIntrusiveHolders != null) { throw new IllegalStateException("This registry can't create new holders without value"); } else { -@@ -237,7 +_,7 @@ +- this.validateWrite((ResourceKey)p_367801_); +- return Holder.Reference.createStandAlone(this, (ResourceKey)p_367801_); ++ this.validateWrite((ResourceKey)p_258169_); ++ return Holder.Reference.createStandAlone(this, (ResourceKey)p_258169_); + } + }); + } +@@ -207,7 +_,7 @@ @Nullable @Override - public T get(@Nullable ResourceLocation p_122739_) { + public T getValue(@Nullable ResourceLocation p_122739_) { - Holder.Reference reference = this.byLocation.get(p_122739_); + Holder.Reference reference = this.byLocation.get(p_122739_ != null ? resolve(p_122739_) : null); return getValueFromNullable(reference); } -@@ -321,13 +_,18 @@ +@@ -269,13 +_,23 @@ return this.byKey.containsKey(p_175392_); } + /** @deprecated Forge: For internal use only. Use the Register events when registering values. */ + @Deprecated -+ public void unfreeze() { ++ @Override ++ public void unfreeze(boolean clearTags) { ++ if (clearTags) { ++ // unbind tags which were bound by the previous freeze ++ this.allTags = MappedRegistry.TagSet.unbound(); ++ } + this.frozen = false; + } + @@ -122,7 +121,7 @@ List list = this.byKey .entrySet() .stream() -@@ -343,8 +_,10 @@ +@@ -291,11 +_,15 @@ throw new IllegalStateException("Some intrusive holders were not registered: " + this.unregisteredIntrusiveHolders.values()); } @@ -132,12 +131,18 @@ } + this.bakeCallbacks.forEach(bakeCallback -> bakeCallback.onBake(this)); - return this; - } -@@ -440,5 +_,53 @@ - @Override - public HolderLookup.RegistryLookup asLookup() { - return this.lookup; + if (this.allTags.isBound()) { +- throw new IllegalStateException("Tags already present before freezing"); ++ // Neo: we freeze/unfreeze the registry to apply snapshots and tags need to be preserved in those cases ++ //throw new IllegalStateException("Tags already present before freezing"); ++ return this; + } else { + List list1 = this.frozenTags + .entrySet() +@@ -450,6 +_,54 @@ + } + }; + } + } + + @Override @@ -151,7 +156,7 @@ + this.byLocation.clear(); + this.byKey.clear(); + this.byValue.clear(); -+ this.tags.clear(); ++ this.allTags = MappedRegistry.TagSet.unbound(); + if (unregisteredIntrusiveHolders != null) { + unregisteredIntrusiveHolders.clear(); + unregisteredIntrusiveHolders = null; @@ -175,16 +180,17 @@ + + @Override + public int getId(ResourceLocation name) { -+ return getId(get(name)); ++ return getId(getValue(name)); + } + + @Override + public int getId(ResourceKey key) { -+ return getId(get(key)); ++ return getId(getValue(key)); + } + + @Override + public boolean containsValue(T value) { + return byValue.containsKey(value); } - } + + interface TagSet { diff --git a/patches/net/minecraft/core/Registry.java.patch b/patches/net/minecraft/core/Registry.java.patch index 7276d4d687..b12790d266 100644 --- a/patches/net/minecraft/core/Registry.java.patch +++ b/patches/net/minecraft/core/Registry.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/core/Registry.java +++ b/net/minecraft/core/Registry.java -@@ -22,7 +_,7 @@ +@@ -21,7 +_,7 @@ import net.minecraft.util.ExtraCodecs; import net.minecraft.util.RandomSource; --public interface Registry extends Keyable, IdMap { -+public interface Registry extends Keyable, IdMap, net.neoforged.neoforge.registries.IRegistryExtension { +-public interface Registry extends Keyable, HolderLookup.RegistryLookup, IdMap { ++public interface Registry extends Keyable, HolderLookup.RegistryLookup, IdMap, net.neoforged.neoforge.registries.IRegistryExtension { + @Override ResourceKey> key(); - default Codec byNameCodec() { @@ -48,7 +_,7 @@ } diff --git a/patches/net/minecraft/core/RegistrySetBuilder.java.patch b/patches/net/minecraft/core/RegistrySetBuilder.java.patch index 163a1531b2..0acf4974e8 100644 --- a/patches/net/minecraft/core/RegistrySetBuilder.java.patch +++ b/patches/net/minecraft/core/RegistrySetBuilder.java.patch @@ -22,7 +22,7 @@ - RegistrySetBuilder.LazyHolder lazyholder = new RegistrySetBuilder.LazyHolder<>(p_312323_, resourcekey); - lazyholder.supplier = () -> cloner.clone((T)p_311506_.value(), p_312725_, p_311797_.getValue()); - return lazyholder; -+ Optional> lookup = p_312725_.lookup(p_311836_); ++ Optional> lookup = p_312725_.lookup(p_311836_); + Lifecycle lifecycle; + if (lookup.isPresent()) { + HolderLookup.RegistryLookup registrylookup1 = lookup.get(); @@ -43,16 +43,16 @@ return lookupFromMap(p_311836_, lifecycle, p_312323_, map); } } -@@ -236,7 +_,7 @@ +@@ -235,7 +_,7 @@ + List list = new ArrayList<>(); RegistrySetBuilder.UniversalLookup registrysetbuilder$universallookup = new RegistrySetBuilder.UniversalLookup(registrysetbuilder$universalowner); Builder> builder = ImmutableMap.builder(); - p_255995_.registries() -- .forEach(p_258197_ -> builder.put(p_258197_.key().location(), RegistrySetBuilder.wrapContextLookup(p_258197_.value().asLookup()))); -+ .forEach(p_258197_ -> builder.put(p_258197_.key().location(), net.neoforged.neoforge.common.CommonHooks.wrapRegistryLookup(p_258197_.value().asLookup()))); +- p_255995_.registries().forEach(p_367807_ -> builder.put(p_367807_.key().location(), RegistrySetBuilder.wrapContextLookup(p_367807_.value()))); ++ p_255995_.registries().forEach(p_367807_ -> builder.put(p_367807_.key().location(), net.neoforged.neoforge.common.CommonHooks.wrapRegistryLookup(p_367807_.value()))); p_256495_.forEach(p_256603_ -> builder.put(p_256603_.location(), registrysetbuilder$universallookup)); return new RegistrySetBuilder.BuildState( registrysetbuilder$universalowner, registrysetbuilder$universallookup, builder.build(), new HashMap<>(), list -@@ -260,6 +_,11 @@ +@@ -259,6 +_,11 @@ @Override public HolderGetter lookup(ResourceKey> p_255961_) { return (HolderGetter)BuildState.this.registries.getOrDefault(p_255961_.location(), BuildState.this.lookup); diff --git a/patches/net/minecraft/core/component/DataComponentHolder.java.patch b/patches/net/minecraft/core/component/DataComponentHolder.java.patch index c1264738ba..d8a88115de 100644 --- a/patches/net/minecraft/core/component/DataComponentHolder.java.patch +++ b/patches/net/minecraft/core/component/DataComponentHolder.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/core/component/DataComponentHolder.java +++ b/net/minecraft/core/component/DataComponentHolder.java -@@ -2,7 +_,7 @@ - +@@ -3,7 +_,7 @@ + import java.util.stream.Stream; import javax.annotation.Nullable; -public interface DataComponentHolder { diff --git a/patches/net/minecraft/core/component/PatchedDataComponentMap.java.patch b/patches/net/minecraft/core/component/PatchedDataComponentMap.java.patch index 041019ddac..dfea9ede8a 100644 --- a/patches/net/minecraft/core/component/PatchedDataComponentMap.java.patch +++ b/patches/net/minecraft/core/component/PatchedDataComponentMap.java.patch @@ -8,7 +8,7 @@ this.ensureMapOwnership(); T t = this.prototype.get((DataComponentType)p_330791_); Optional optional; -@@ -192,6 +_,10 @@ +@@ -197,6 +_,10 @@ } return i; diff --git a/patches/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch b/patches/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch index f2a00c2abf..df2a666f9c 100644 --- a/patches/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch +++ b/patches/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch @@ -1,31 +1,42 @@ --- a/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java -@@ -35,21 +_,22 @@ +@@ -29,27 +_,33 @@ double d2 = vec3.y() + (double)((float)direction.getStepY() * 1.125F); double d3 = vec3.z() + (double)direction.getStepZ() * d0; BlockPos blockpos = p_302460_.pos().relative(direction); -+ Boat boat = (Boat)(this.isChestBoat ? new ChestBoat(serverlevel, d1, d2, d3) : new Boat(serverlevel, d1, d2, d3)); -+ EntityType.createDefaultStackConfig(serverlevel, p_123376_, null).accept(boat); -+ boat.setVariant(this.type); -+ boat.setYRot(direction.toYRot()); ++ AbstractBoat abstractboat = this.type.create(serverlevel, EntitySpawnReason.DISPENSER); ++ if (abstractboat != null) { ++ EntityType.createDefaultStackConfig(serverlevel, p_123376_, null).accept(abstractboat); ++ abstractboat.setYRot(direction.toYRot()); ++ serverlevel.addFreshEntity(abstractboat); ++ } double d4; - if (serverlevel.getFluidState(blockpos).is(FluidTags.WATER)) { -+ if (boat.canBoatInFluid(serverlevel.getFluidState(blockpos))) { ++ if (canBoatInFluid(abstractboat, serverlevel.getFluidState(blockpos))) { d4 = 1.0; } else { - if (!serverlevel.getBlockState(blockpos).isAir() || !serverlevel.getFluidState(blockpos.below()).is(FluidTags.WATER)) { -+ if (!serverlevel.getBlockState(blockpos).isAir() || !boat.canBoatInFluid(serverlevel.getFluidState(blockpos.below()))) { ++ if (!serverlevel.getBlockState(blockpos).isAir() || !canBoatInFluid(abstractboat, serverlevel.getFluidState(blockpos.below()))) { return this.defaultDispenseItemBehavior.dispense(p_302460_, p_123376_); } d4 = 0.0; } -- Boat boat = (Boat)(this.isChestBoat ? new ChestBoat(serverlevel, d1, d2 + d4, d3) : new Boat(serverlevel, d1, d2 + d4, d3)); -- EntityType.createDefaultStackConfig(serverlevel, p_123376_, null).accept(boat); -- boat.setVariant(this.type); -- boat.setYRot(direction.toYRot()); -+ boat.setPos(d1, d2 + d4, d3); - serverlevel.addFreshEntity(boat); - p_123376_.shrink(1); +- AbstractBoat abstractboat = this.type.create(serverlevel, EntitySpawnReason.DISPENSER); + if (abstractboat != null) { + abstractboat.setInitialPos(d1, d2 + d4, d3); +- EntityType.createDefaultStackConfig(serverlevel, p_123376_, null).accept(abstractboat); +- abstractboat.setYRot(direction.toYRot()); +- serverlevel.addFreshEntity(abstractboat); + p_123376_.shrink(1); + } + return p_123376_; ++ } ++ ++ private static boolean canBoatInFluid(@org.jetbrains.annotations.Nullable AbstractBoat boat, net.minecraft.world.level.material.FluidState fluid) { ++ return boat != null ? boat.canBoatInFluid(fluid) : fluid.is(FluidTags.WATER); + } + + @Override diff --git a/patches/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/patches/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index 9f0b115a25..e65ba52405 100644 --- a/patches/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/patches/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,28 +1,28 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -231,7 +_,7 @@ - DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_338251_.getItem(); - BlockPos blockpos = p_338850_.pos().relative(p_338850_.state().getValue(DispenserBlock.FACING)); - Level level = p_338850_.level(); +@@ -192,7 +_,7 @@ + DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_338735_.getItem(); + BlockPos blockpos = p_338297_.pos().relative(p_338297_.state().getValue(DispenserBlock.FACING)); + Level level = p_338297_.level(); - if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null)) { -+ if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null, p_338251_)) { - dispensiblecontaineritem.checkExtraContent(null, level, p_338251_, blockpos); - return this.consumeWithRemainder(p_338850_, p_338251_, new ItemStack(Items.BUCKET)); ++ if (dispensiblecontaineritem.emptyContents(null, level, blockpos, null, p_338735_)) { + dispensiblecontaineritem.checkExtraContent(null, level, p_338735_, blockpos); + return this.consumeWithRemainder(p_338297_, p_338735_, new ItemStack(Items.BUCKET)); } else { -@@ -279,12 +_,13 @@ +@@ -240,12 +_,13 @@ if (BaseFireBlock.canBePlacedAt(serverlevel, blockpos, direction)) { serverlevel.setBlockAndUpdate(blockpos, BaseFireBlock.getState(serverlevel, blockpos)); serverlevel.gameEvent(null, GameEvent.BLOCK_PLACE, blockpos); - } else if (CampfireBlock.canLight(blockstate) || CandleBlock.canLight(blockstate) || CandleCakeBlock.canLight(blockstate)) { - serverlevel.setBlockAndUpdate(blockpos, blockstate.setValue(BlockStateProperties.LIT, Boolean.valueOf(true))); -+ } else if (blockstate.getToolModifiedState(new net.minecraft.world.item.context.UseOnContext(p_338494_.level(), null, net.minecraft.world.InteractionHand.MAIN_HAND, p_338444_, new net.minecraft.world.phys.BlockHitResult(blockpos.getCenter(), direction.getOpposite(), blockpos, false)), net.neoforged.neoforge.common.ItemAbilities.FIRESTARTER_LIGHT, false) instanceof BlockState blockstate2) { ++ } else if (blockstate.getToolModifiedState(new net.minecraft.world.item.context.UseOnContext(serverlevel, null, net.minecraft.world.InteractionHand.MAIN_HAND, p_338526_, new net.minecraft.world.phys.BlockHitResult(blockpos.getCenter(), direction.getOpposite(), blockpos, false)), net.neoforged.neoforge.common.ItemAbilities.FIRESTARTER_LIGHT, false) instanceof BlockState blockstate2) { + serverlevel.setBlockAndUpdate(blockpos, blockstate2); serverlevel.gameEvent(null, GameEvent.BLOCK_CHANGE, blockpos); - } else if (blockstate.getBlock() instanceof TntBlock) { - TntBlock.explode(serverlevel, blockpos); - serverlevel.removeBlock(blockpos, false); -+ } else if (blockstate.isFlammable(serverlevel, blockpos, p_338494_.state().getValue(DispenserBlock.FACING).getOpposite())) { -+ blockstate.onCaughtFire(serverlevel, blockpos, p_338494_.state().getValue(DispenserBlock.FACING).getOpposite(), null); ++ } else if (blockstate.isFlammable(serverlevel, blockpos, p_338386_.state().getValue(DispenserBlock.FACING).getOpposite())) { ++ blockstate.onCaughtFire(serverlevel, blockpos, p_338386_.state().getValue(DispenserBlock.FACING).getOpposite(), null); + if (blockstate.getBlock() instanceof TntBlock) + serverlevel.removeBlock(blockpos, false); } else { diff --git a/patches/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch b/patches/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch new file mode 100644 index 0000000000..0959113dde --- /dev/null +++ b/patches/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java ++++ b/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java +@@ -26,6 +_,8 @@ + } else { + LivingEntity livingentity = list.getFirst(); + EquipmentSlot equipmentslot = livingentity.getEquipmentSlotForItem(p_371227_); ++ // Neo: Respect IItemExtension#canEquip in dispenseArmor ++ if (!p_371227_.canEquip(equipmentslot, livingentity)) return false; + ItemStack itemstack = p_371227_.split(1); + livingentity.setItemSlot(equipmentslot, itemstack); + if (livingentity instanceof Mob mob) { diff --git a/patches/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch b/patches/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch new file mode 100644 index 0000000000..866bbb8217 --- /dev/null +++ b/patches/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java ++++ b/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java +@@ -34,7 +_,7 @@ + BlockState blockstate = serverlevel.getBlockState(blockpos); + double d3; + if (blockstate.is(BlockTags.RAILS)) { +- if (getRailShape(blockstate).isSlope()) { ++ if (getRailShape(blockstate, serverlevel, blockpos).isSlope()) { + d3 = 0.6; + } else { + d3 = 0.1; +@@ -49,7 +_,7 @@ + return this.defaultDispenseItemBehavior.dispense(p_374045_, p_374580_); + } + +- if (direction != Direction.DOWN && getRailShape(blockstate1).isSlope()) { ++ if (direction != Direction.DOWN && getRailShape(blockstate1, serverlevel, blockpos.below()).isSlope()) { + d3 = -0.4; + } else { + d3 = -0.9; +@@ -68,8 +_,8 @@ + return p_374580_; + } + +- private static RailShape getRailShape(BlockState p_374571_) { +- return p_374571_.getBlock() instanceof BaseRailBlock baserailblock ? p_374571_.getValue(baserailblock.getShapeProperty()) : RailShape.NORTH_SOUTH; ++ private static RailShape getRailShape(BlockState p_374571_, ServerLevel level, BlockPos pos) { ++ return p_374571_.getBlock() instanceof BaseRailBlock baserailblock ? baserailblock.getRailDirection(p_374571_, level, pos, null) : RailShape.NORTH_SOUTH; + } + + @Override diff --git a/patches/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch b/patches/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch index 0ab8226972..1e9b2b01cd 100644 --- a/patches/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch +++ b/patches/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch @@ -4,22 +4,19 @@ ServerLevel serverlevel = p_302443_.level(); if (!serverlevel.isClientSide()) { BlockPos blockpos = p_302443_.pos().relative(p_302443_.state().getValue(DispenserBlock.FACING)); -- this.setSuccess(tryShearBeehive(serverlevel, blockpos) || tryShearLivingEntity(serverlevel, blockpos)); +- this.setSuccess(tryShearBeehive(serverlevel, blockpos) || tryShearLivingEntity(serverlevel, blockpos, p_123581_)); + this.setSuccess(net.neoforged.neoforge.common.CommonHooks.tryDispenseShearsHarvestBlock(p_302443_, p_123581_, serverlevel, blockpos) || tryShearBeehive(serverlevel, blockpos) || tryShearLivingEntity(serverlevel, blockpos, p_123581_)); if (this.isSuccess()) { p_123581_.hurtAndBreak(1, serverlevel, null, p_348118_ -> { }); -@@ -51,10 +_,11 @@ - return false; - } +@@ -53,8 +_,9 @@ -- private static boolean tryShearLivingEntity(ServerLevel p_123583_, BlockPos p_123584_) { -+ private static boolean tryShearLivingEntity(ServerLevel p_123583_, BlockPos p_123584_, ItemStack stack) { + private static boolean tryShearLivingEntity(ServerLevel p_123583_, BlockPos p_123584_, ItemStack p_372883_) { for (LivingEntity livingentity : p_123583_.getEntitiesOfClass(LivingEntity.class, new AABB(p_123584_), EntitySelector.NO_SPECTATORS)) { - if (livingentity instanceof Shearable shearable && shearable.readyForShearing()) { -- shearable.shear(SoundSource.BLOCKS); -+ if (livingentity instanceof net.neoforged.neoforge.common.IShearable shearable && shearable.isShearable(null, stack, p_123583_, p_123584_)) { -+ shearable.onSheared(null, stack, p_123583_, p_123584_) +- shearable.shear(p_123583_, SoundSource.BLOCKS, p_372883_); ++ if (livingentity instanceof net.neoforged.neoforge.common.IShearable shearable && shearable.isShearable(null, p_372883_, p_123583_, p_123584_)) { ++ shearable.onSheared(null, p_372883_, p_123583_, p_123584_) + .forEach(drop -> shearable.spawnShearedDrop(p_123583_, p_123584_, drop)); p_123583_.gameEvent(null, GameEvent.SHEAR, p_123584_); return true; diff --git a/patches/net/minecraft/core/particles/ItemParticleOption.java.patch b/patches/net/minecraft/core/particles/ItemParticleOption.java.patch index ba30506ce6..33a8473c99 100644 --- a/patches/net/minecraft/core/particles/ItemParticleOption.java.patch +++ b/patches/net/minecraft/core/particles/ItemParticleOption.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/particles/ItemParticleOption.java +++ b/net/minecraft/core/particles/ItemParticleOption.java -@@ -24,7 +_,7 @@ +@@ -25,7 +_,7 @@ throw new IllegalArgumentException("Empty stacks are not allowed"); } else { this.type = p_123705_; diff --git a/patches/net/minecraft/core/registries/BuiltInRegistries.java.patch b/patches/net/minecraft/core/registries/BuiltInRegistries.java.patch index e693d8f2a9..d6ad5ccf02 100644 --- a/patches/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/patches/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -356,6 +_,10 @@ - }); +@@ -373,6 +_,10 @@ + ((MappedRegistry)p_365443_).bindAllTagsToEmpty(); } + public static java.util.Set getVanillaRegistrationOrder() { diff --git a/patches/net/minecraft/core/registries/Registries.java.patch b/patches/net/minecraft/core/registries/Registries.java.patch index 1d5ce37612..6e9682548e 100644 --- a/patches/net/minecraft/core/registries/Registries.java.patch +++ b/patches/net/minecraft/core/registries/Registries.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/registries/Registries.java +++ b/net/minecraft/core/registries/Registries.java -@@ -249,10 +_,10 @@ +@@ -257,10 +_,10 @@ } public static String elementsDirPath(ResourceKey> p_350960_) { diff --git a/patches/net/minecraft/data/DataProvider.java.patch b/patches/net/minecraft/data/DataProvider.java.patch index 24c9736040..07f5c14860 100644 --- a/patches/net/minecraft/data/DataProvider.java.patch +++ b/patches/net/minecraft/data/DataProvider.java.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/data/DataProvider.java +++ b/net/minecraft/data/DataProvider.java -@@ -24,6 +_,8 @@ +@@ -28,6 +_,9 @@ public interface DataProvider { ToIntFunction FIXED_ORDER_FIELDS = Util.make(new Object2IntOpenHashMap<>(), p_236070_ -> { + // Neo: conditions go first + p_236070_.put("neoforge:conditions", -1); ++ p_236070_.put("neoforge:ingredient_type", 0); p_236070_.put("type", 0); p_236070_.put("parent", 1); p_236070_.defaultReturnValue(2); diff --git a/patches/net/minecraft/data/Main.java.patch b/patches/net/minecraft/data/Main.java.patch index 4f188c8e33..4e6c37a6e7 100644 --- a/patches/net/minecraft/data/Main.java.patch +++ b/patches/net/minecraft/data/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/Main.java +++ b/net/minecraft/data/Main.java -@@ -77,8 +_,15 @@ +@@ -86,8 +_,15 @@ OptionSpec optionspec6 = optionparser.accepts("all", "Include all generators"); OptionSpec optionspec7 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated"); OptionSpec optionspec8 = optionparser.accepts("input", "Input folder").withRequiredArg(); @@ -17,7 +17,7 @@ Path path = Paths.get(optionspec7.value(optionset)); boolean flag = optionset.has(optionspec6); boolean flag1 = flag || optionset.has(optionspec2); -@@ -86,9 +_,16 @@ +@@ -95,9 +_,16 @@ boolean flag3 = flag || optionset.has(optionspec3); boolean flag4 = flag || optionset.has(optionspec4); boolean flag5 = flag || optionset.has(optionspec5); @@ -36,7 +36,7 @@ flag1, flag2, flag3, -@@ -98,6 +_,7 @@ +@@ -107,6 +_,7 @@ true ); datagenerator.run(); diff --git a/patches/net/minecraft/data/loot/BlockLootSubProvider.java.patch b/patches/net/minecraft/data/loot/BlockLootSubProvider.java.patch index 95cf157be3..2bd05fb51a 100644 --- a/patches/net/minecraft/data/loot/BlockLootSubProvider.java.patch +++ b/patches/net/minecraft/data/loot/BlockLootSubProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/BlockLootSubProvider.java +++ b/net/minecraft/data/loot/BlockLootSubProvider.java -@@ -655,12 +_,16 @@ +@@ -684,12 +_,16 @@ protected abstract void generate(); @@ -14,7 +14,7 @@ Set> set = new HashSet<>(); - for (Block block : BuiltInRegistries.BLOCK) { -+ for(Block block : getKnownBlocks()) { ++ for (Block block : getKnownBlocks()) { if (block.isEnabled(this.enabledFeatures)) { - ResourceKey resourcekey = block.getLootTable(); - if (resourcekey != BuiltInLootTables.EMPTY && set.add(resourcekey)) { + block.getLootTable() + .ifPresent( diff --git a/patches/net/minecraft/data/loot/EntityLootSubProvider.java.patch b/patches/net/minecraft/data/loot/EntityLootSubProvider.java.patch index 0513593438..6ec12bdeab 100644 --- a/patches/net/minecraft/data/loot/EntityLootSubProvider.java.patch +++ b/patches/net/minecraft/data/loot/EntityLootSubProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/EntityLootSubProvider.java +++ b/net/minecraft/data/loot/EntityLootSubProvider.java -@@ -96,12 +_,16 @@ +@@ -104,12 +_,16 @@ public abstract void generate(); @@ -13,18 +13,9 @@ this.generate(); Set> set = new HashSet<>(); - BuiltInRegistries.ENTITY_TYPE -- .holders() +- .listElements() + this.getKnownEntityTypes() + .map(EntityType::builtInRegistryHolder) .forEach( - p_266624_ -> { - EntityType entitytype = p_266624_.value(); -@@ -151,7 +_,7 @@ - } - } - -- protected static boolean canHaveLootTable(EntityType p_249029_) { -+ protected boolean canHaveLootTable(EntityType p_249029_) { - return SPECIAL_LOOT_TABLE_TYPES.contains(p_249029_) || p_249029_.getCategory() != MobCategory.MISC; - } - + p_367828_ -> { + EntityType entitytype = p_367828_.value(); diff --git a/patches/net/minecraft/data/loot/LootTableProvider.java.patch b/patches/net/minecraft/data/loot/LootTableProvider.java.patch index 8a8f1bc25a..d68c2594ba 100644 --- a/patches/net/minecraft/data/loot/LootTableProvider.java.patch +++ b/patches/net/minecraft/data/loot/LootTableProvider.java.patch @@ -1,29 +1,29 @@ --- a/net/minecraft/data/loot/LootTableProvider.java +++ b/net/minecraft/data/loot/LootTableProvider.java -@@ -62,33 +_,24 @@ +@@ -62,34 +_,24 @@ private CompletableFuture run(CachedOutput p_324447_, HolderLookup.Provider p_323978_) { WritableRegistry writableregistry = new MappedRegistry<>(Registries.LOOT_TABLE, Lifecycle.experimental()); Map map = new Object2ObjectOpenHashMap<>(); -- this.subProviders.forEach(p_344197_ -> p_344197_.provider().apply(p_323978_).generate((p_339366_, p_339367_) -> { -- ResourceLocation resourcelocation = sequenceIdForLootTable(p_339366_); +- this.subProviders.forEach(p_344197_ -> p_344197_.provider().apply(p_323978_).generate((p_380827_, p_380828_) -> { +- ResourceLocation resourcelocation = sequenceIdForLootTable(p_380827_); + getTables().forEach(p_329847_ -> p_329847_.provider().apply(p_323978_).generate((p_335199_, p_335200_) -> { + ResourceLocation resourcelocation = sequenceIdForLootTable(p_335199_); ResourceLocation resourcelocation1 = map.put(RandomSequence.seedForKey(resourcelocation), resourcelocation); if (resourcelocation1 != null) { -- Util.logAndPauseIfInIde("Loot table random sequence seed collision on " + resourcelocation1 + " and " + p_339366_.location()); +- Util.logAndPauseIfInIde("Loot table random sequence seed collision on " + resourcelocation1 + " and " + p_380827_.location()); + Util.logAndPauseIfInIde("Loot table random sequence seed collision on " + resourcelocation1 + " and " + p_335199_.location()); } -- p_339367_.setRandomSequence(resourcelocation); -- LootTable loottable = p_339367_.setParamSet(p_344197_.paramSet).build(); -- writableregistry.register(p_339366_, loottable, RegistrationInfo.BUILT_IN); +- p_380828_.setRandomSequence(resourcelocation); +- LootTable loottable = p_380828_.setParamSet(p_344197_.paramSet).build(); +- writableregistry.register(p_380827_, loottable, RegistrationInfo.BUILT_IN); + p_335200_.setRandomSequence(resourcelocation); + LootTable loottable = p_335200_.setParamSet(p_329847_.paramSet).build(); + writableregistry.register(p_335199_, loottable, RegistrationInfo.BUILT_IN); })); writableregistry.freeze(); ProblemReporter.Collector problemreporter$collector = new ProblemReporter.Collector(); - HolderGetter.Provider holdergetter$provider = new RegistryAccess.ImmutableRegistryAccess(List.of(writableregistry)).freeze().asGetterLookup(); + HolderGetter.Provider holdergetter$provider = new RegistryAccess.ImmutableRegistryAccess(List.of(writableregistry)).freeze(); ValidationContext validationcontext = new ValidationContext(problemreporter$collector, LootContextParamSets.ALL_PARAMS, holdergetter$provider); - for (ResourceKey resourcekey : Sets.difference(this.requiredTables, writableregistry.registryKeySet())) { @@ -31,17 +31,18 @@ - } + validate(writableregistry, validationcontext, problemreporter$collector); -- writableregistry.holders() +- writableregistry.listElements() - .forEach( -- p_339369_ -> p_339369_.value() +- p_380823_ -> p_380823_.value() - .validate( -- validationcontext.setParams(p_339369_.value().getParamSet()).enterElement("{" + p_339369_.key().location() + "}", p_339369_.key()) +- validationcontext.setContextKeySet(p_380823_.value().getParamSet()) +- .enterElement("{" + p_380823_.key().location() + "}", p_380823_.key()) - ) - ); Multimap multimap = problemreporter$collector.get(); if (!multimap.isEmpty()) { multimap.forEach((p_124446_, p_124447_) -> LOGGER.warn("Found validation problem in {}: {}", p_124446_, p_124447_)); -@@ -101,6 +_,20 @@ +@@ -102,6 +_,20 @@ return DataProvider.saveStable(p_324447_, p_323978_, LootTable.DIRECT_CODEC, loottable, path); }).toArray(CompletableFuture[]::new)); } @@ -56,8 +57,8 @@ + problemreporter$collector.report("Missing built-in table: " + resourcekey.location()); + } + -+ writableregistry.holders().forEach(p_335195_ -> { -+ p_335195_.value().validate(validationcontext.setParams(p_335195_.value().getParamSet()).enterElement("{" + p_335195_.key().location() + "}", p_335195_.key())); ++ writableregistry.listElements().forEach(p_335195_ -> { ++ p_335195_.value().validate(validationcontext.setContextKeySet(p_335195_.value().getParamSet()).enterElement("{" + p_335195_.key().location() + "}", p_335195_.key())); + }); } diff --git a/patches/net/minecraft/data/recipes/RecipeOutput.java.patch b/patches/net/minecraft/data/recipes/RecipeOutput.java.patch index 17b3c42df4..18206b3385 100644 --- a/patches/net/minecraft/data/recipes/RecipeOutput.java.patch +++ b/patches/net/minecraft/data/recipes/RecipeOutput.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/data/recipes/RecipeOutput.java +++ b/net/minecraft/data/recipes/RecipeOutput.java @@ -6,8 +_,10 @@ - import net.minecraft.resources.ResourceLocation; + import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.crafting.Recipe; -public interface RecipeOutput { -- void accept(ResourceLocation p_312249_, Recipe p_312328_, @Nullable AdvancementHolder p_312176_); +- void accept(ResourceKey> p_380042_, Recipe p_312328_, @Nullable AdvancementHolder p_312176_); +public interface RecipeOutput extends net.neoforged.neoforge.common.extensions.IRecipeOutputExtension { -+ default void accept(ResourceLocation p_312249_, Recipe p_312328_, @Nullable AdvancementHolder p_312176_) { ++ default void accept(ResourceKey> p_312249_, Recipe p_312328_, @Nullable AdvancementHolder p_312176_) { + accept(p_312249_, p_312328_, p_312176_, new net.neoforged.neoforge.common.conditions.ICondition[0]); + } Advancement.Builder advancement(); - } + diff --git a/patches/net/minecraft/data/recipes/RecipeProvider.java.patch b/patches/net/minecraft/data/recipes/RecipeProvider.java.patch index ec1d44e063..27eb2f31a7 100644 --- a/patches/net/minecraft/data/recipes/RecipeProvider.java.patch +++ b/patches/net/minecraft/data/recipes/RecipeProvider.java.patch @@ -1,69 +1,53 @@ --- a/net/minecraft/data/recipes/RecipeProvider.java +++ b/net/minecraft/data/recipes/RecipeProvider.java -@@ -84,18 +_,18 @@ - this.buildRecipes( - new RecipeOutput() { - @Override -- public void accept(ResourceLocation p_312039_, Recipe p_312254_, @Nullable AdvancementHolder p_311794_) { -+ public void accept(ResourceLocation p_312039_, Recipe p_312254_, @Nullable AdvancementHolder p_311794_, net.neoforged.neoforge.common.conditions.ICondition... conditions) { - if (!set.add(p_312039_)) { - throw new IllegalStateException("Duplicate recipe " + p_312039_); - } else { -- list.add(DataProvider.saveStable(p_324494_, p_324248_, Recipe.CODEC, p_312254_, RecipeProvider.this.recipePathProvider.json(p_312039_))); -+ list.add(DataProvider.saveStable(p_324494_, p_324248_, Recipe.CONDITIONAL_CODEC, Optional.of(new net.neoforged.neoforge.common.conditions.WithConditions<>(p_312254_, conditions)), RecipeProvider.this.recipePathProvider.json(p_312039_))); - if (p_311794_ != null) { - list.add( - DataProvider.saveStable( - p_324494_, - p_324248_, -- Advancement.CODEC, -- p_311794_.value(), -+ Advancement.CONDITIONAL_CODEC, -+ Optional.of(new net.neoforged.neoforge.common.conditions.WithConditions<>(p_311794_.value(), conditions)), - RecipeProvider.this.advancementPathProvider.json(p_311794_.id()) - ) - ); -@@ -107,18 +_,26 @@ - public Advancement.Builder advancement() { - return Advancement.Builder.recipeAdvancement().parent(RecipeBuilder.ROOT_RECIPE_ADVANCEMENT); - } -- } -+ }, p_324248_ - ); - return CompletableFuture.allOf(list.toArray(CompletableFuture[]::new)); +@@ -566,8 +_,7 @@ } - protected CompletableFuture buildAdvancement(CachedOutput p_253674_, HolderLookup.Provider p_323646_, AdvancementHolder p_301116_) { -- return DataProvider.saveStable(p_253674_, p_323646_, Advancement.CODEC, p_301116_.value(), this.advancementPathProvider.json(p_301116_.id())); -- } -- -- protected abstract void buildRecipes(RecipeOutput p_301172_); -- -- protected static void generateForEnabledBlockFamilies(RecipeOutput p_301146_, FeatureFlagSet p_251836_) { -+ return buildAdvancement(p_253674_, p_323646_, p_301116_, new net.neoforged.neoforge.common.conditions.ICondition[0]); -+ } -+ -+ protected CompletableFuture buildAdvancement(CachedOutput p_253674_, HolderLookup.Provider p_323646_, AdvancementHolder p_301116_, net.neoforged.neoforge.common.conditions.ICondition... conditions) { -+ return DataProvider.saveStable(p_253674_, p_323646_, Advancement.CONDITIONAL_CODEC, Optional.of(new net.neoforged.neoforge.common.conditions.WithConditions<>(p_301116_.value(), conditions)), this.advancementPathProvider.json(p_301116_.id())); -+ } -+ -+ protected void buildRecipes(RecipeOutput recipeOutput, HolderLookup.Provider holderLookup) { -+ buildRecipes(recipeOutput); -+ } -+ -+ protected void buildRecipes(RecipeOutput p_301172_) {} -+ -+ protected void generateForEnabledBlockFamilies(RecipeOutput p_301146_, FeatureFlagSet p_251836_) { - BlockFamilies.getAllFamilies().filter(BlockFamily::shouldGenerateRecipe).forEach(p_313461_ -> generateRecipes(p_301146_, p_313461_, p_251836_)); - } - -@@ -611,8 +_,7 @@ - } - - protected static void waxRecipes(RecipeOutput p_301254_, FeatureFlagSet p_313879_) { + protected void waxRecipes(FeatureFlagSet p_313879_) { - HoneycombItem.WAXABLES - .get() + net.neoforged.neoforge.common.DataMapHooks.INVERSE_WAXABLES_DATAMAP .forEach( - (p_337490_, p_337491_) -> { - if (p_337491_.requiredFeatures().isSubsetOf(p_313879_)) { + (p_359424_, p_359425_) -> { + if (p_359425_.requiredFeatures().isSubsetOf(p_313879_)) { +@@ -756,13 +_,13 @@ + final List> list = new ArrayList<>(); + RecipeOutput recipeoutput = new RecipeOutput() { + @Override +- public void accept(ResourceKey> p_380360_, Recipe p_362882_, @Nullable AdvancementHolder p_364507_) { ++ public void accept(ResourceKey> p_380360_, Recipe p_362882_, @Nullable AdvancementHolder p_364507_, net.neoforged.neoforge.common.conditions.ICondition... conditions) { + if (!set.add(p_380360_)) { + throw new IllegalStateException("Duplicate recipe " + p_380360_.location()); + } else { +- this.saveRecipe(p_380360_, p_362882_); ++ this.saveRecipe(p_380360_, p_362882_, conditions); + if (p_364507_ != null) { +- this.saveAdvancement(p_364507_); ++ this.saveAdvancement(p_364507_, conditions); + } + } + } +@@ -781,15 +_,21 @@ + } + + private void saveRecipe(ResourceKey> p_380099_, Recipe p_364792_) { ++ saveRecipe(p_380099_, p_364792_, new net.neoforged.neoforge.common.conditions.ICondition[0]); ++ } ++ private void saveRecipe(ResourceKey> p_380099_, Recipe p_364792_, net.neoforged.neoforge.common.conditions.ICondition... conditions) { + list.add( +- DataProvider.saveStable(p_364823_, p_364211_, Recipe.CODEC, p_364792_, packoutput$pathprovider.json(p_380099_.location())) ++ DataProvider.saveStable(p_364823_, p_364211_, Recipe.CONDITIONAL_CODEC, Optional.of(new net.neoforged.neoforge.common.conditions.WithConditions<>(p_364792_, conditions)), packoutput$pathprovider.json(p_380099_.location())) + ); + } + + private void saveAdvancement(AdvancementHolder p_363148_) { ++ saveAdvancement(p_363148_, new net.neoforged.neoforge.common.conditions.ICondition[0]); ++ } ++ private void saveAdvancement(AdvancementHolder p_363148_, net.neoforged.neoforge.common.conditions.ICondition... conditions) { + list.add( + DataProvider.saveStable( +- p_364823_, p_364211_, Advancement.CODEC, p_363148_.value(), packoutput$pathprovider1.json(p_363148_.id()) ++ p_364823_, p_364211_, Advancement.CONDITIONAL_CODEC, Optional.of(new net.neoforged.neoforge.common.conditions.WithConditions<>(p_363148_.value(), conditions)), packoutput$pathprovider1.json(p_363148_.id()) + ) + ); + } diff --git a/patches/net/minecraft/data/recipes/ShapedRecipeBuilder.java.patch b/patches/net/minecraft/data/recipes/ShapedRecipeBuilder.java.patch index 2d994e43aa..e14eb5413d 100644 --- a/patches/net/minecraft/data/recipes/ShapedRecipeBuilder.java.patch +++ b/patches/net/minecraft/data/recipes/ShapedRecipeBuilder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/recipes/ShapedRecipeBuilder.java +++ b/net/minecraft/data/recipes/ShapedRecipeBuilder.java -@@ -25,6 +_,7 @@ +@@ -28,6 +_,7 @@ private final RecipeCategory category; private final Item result; private final int count; @@ -8,14 +8,15 @@ private final List rows = Lists.newArrayList(); private final Map key = Maps.newLinkedHashMap(); private final Map> criteria = new LinkedHashMap<>(); -@@ -33,9 +_,14 @@ +@@ -36,10 +_,15 @@ private boolean showNotification = true; - public ShapedRecipeBuilder(RecipeCategory p_249996_, ItemLike p_251475_, int p_248948_) { -+ this(p_249996_, new ItemStack(p_251475_, p_248948_)); + private ShapedRecipeBuilder(HolderGetter p_365072_, RecipeCategory p_249996_, ItemLike p_251475_, int p_248948_) { ++ this(p_365072_, p_249996_, new ItemStack(p_251475_, p_248948_)); + } + -+ public ShapedRecipeBuilder(RecipeCategory p_249996_, ItemStack result) { ++ private ShapedRecipeBuilder(HolderGetter p_365072_, RecipeCategory p_249996_, ItemStack result) { + this.items = p_365072_; this.category = p_249996_; - this.result = p_251475_.asItem(); - this.count = p_248948_; @@ -24,19 +25,19 @@ + this.resultStack = result; } - public static ShapedRecipeBuilder shaped(RecipeCategory p_250853_, ItemLike p_249747_) { -@@ -46,6 +_,10 @@ - return new ShapedRecipeBuilder(p_251325_, p_250636_, p_249081_); + public static ShapedRecipeBuilder shaped(HolderGetter p_364036_, RecipeCategory p_250853_, ItemLike p_249747_) { +@@ -50,6 +_,10 @@ + return new ShapedRecipeBuilder(p_365019_, p_251325_, p_250636_, p_249081_); } -+ public static ShapedRecipeBuilder shaped(RecipeCategory p_251325_, ItemStack result) { -+ return new ShapedRecipeBuilder(p_251325_, result); ++ public static ShapedRecipeBuilder shaped(HolderGetter p_365019_, RecipeCategory p_251325_, ItemStack result) { ++ return new ShapedRecipeBuilder(p_365019_, p_251325_, result); + } + public ShapedRecipeBuilder define(Character p_206417_, TagKey p_206418_) { - return this.define(p_206417_, Ingredient.of(p_206418_)); + return this.define(p_206417_, Ingredient.of(this.items.getOrThrow(p_206418_))); } -@@ -106,7 +_,7 @@ +@@ -110,7 +_,7 @@ Objects.requireNonNullElse(this.group, ""), RecipeBuilder.determineBookCategory(this.category), shapedrecipepattern, @@ -44,4 +45,4 @@ + this.resultStack, this.showNotification ); - p_301098_.accept(p_126142_, shapedrecipe, advancement$builder.build(p_126142_.withPrefix("recipes/" + this.category.getFolderName() + "/"))); + p_301098_.accept(p_380072_, shapedrecipe, advancement$builder.build(p_380072_.location().withPrefix("recipes/" + this.category.getFolderName() + "/"))); diff --git a/patches/net/minecraft/data/recipes/ShapelessRecipeBuilder.java.patch b/patches/net/minecraft/data/recipes/ShapelessRecipeBuilder.java.patch deleted file mode 100644 index 27ab5b58ad..0000000000 --- a/patches/net/minecraft/data/recipes/ShapelessRecipeBuilder.java.patch +++ /dev/null @@ -1,46 +0,0 @@ ---- a/net/minecraft/data/recipes/ShapelessRecipeBuilder.java -+++ b/net/minecraft/data/recipes/ShapelessRecipeBuilder.java -@@ -22,15 +_,21 @@ - private final RecipeCategory category; - private final Item result; - private final int count; -+ private final ItemStack resultStack; // Neo: add stack result support - private final NonNullList ingredients = NonNullList.create(); - private final Map> criteria = new LinkedHashMap<>(); - @Nullable - private String group; - - public ShapelessRecipeBuilder(RecipeCategory p_250837_, ItemLike p_251897_, int p_252227_) { -+ this(p_250837_, new ItemStack(p_251897_, p_252227_)); -+ } -+ -+ public ShapelessRecipeBuilder(RecipeCategory p_250837_, ItemStack result) { - this.category = p_250837_; -- this.result = p_251897_.asItem(); -- this.count = p_252227_; -+ this.result = result.getItem(); -+ this.count = result.getCount(); -+ this.resultStack = result; - } - - public static ShapelessRecipeBuilder shapeless(RecipeCategory p_250714_, ItemLike p_249659_) { -@@ -41,6 +_,10 @@ - return new ShapelessRecipeBuilder(p_252339_, p_250836_, p_249928_); - } - -+ public static ShapelessRecipeBuilder shapeless(RecipeCategory p_252339_, ItemStack result) { -+ return new ShapelessRecipeBuilder(p_252339_, result); -+ } -+ - public ShapelessRecipeBuilder requires(TagKey p_206420_) { - return this.requires(Ingredient.of(p_206420_)); - } -@@ -95,7 +_,7 @@ - ShapelessRecipe shapelessrecipe = new ShapelessRecipe( - Objects.requireNonNullElse(this.group, ""), - RecipeBuilder.determineBookCategory(this.category), -- new ItemStack(this.result, this.count), -+ this.resultStack, - this.ingredients - ); - p_301215_.accept(p_126206_, shapelessrecipe, advancement$builder.build(p_126206_.withPrefix("recipes/" + this.category.getFolderName() + "/"))); diff --git a/patches/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java.patch b/patches/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java.patch index fb0bc660cf..38432d6166 100644 --- a/patches/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java.patch +++ b/patches/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java +++ b/net/minecraft/data/recipes/SimpleCookingRecipeBuilder.java -@@ -28,6 +_,7 @@ +@@ -29,6 +_,7 @@ private final RecipeCategory category; private final CookingBookCategory bookCategory; private final Item result; @@ -8,7 +8,7 @@ private final Ingredient ingredient; private final float experience; private final int cookingTime; -@@ -45,9 +_,22 @@ +@@ -46,9 +_,22 @@ int p_250189_, AbstractCookingRecipe.Factory p_311960_ ) { @@ -32,7 +32,7 @@ this.ingredient = p_250362_; this.experience = p_251204_; this.cookingTime = p_250189_; -@@ -86,6 +_,38 @@ +@@ -87,6 +_,38 @@ return new SimpleCookingRecipeBuilder(p_250319_, CookingBookCategory.FOOD, p_250377_, p_248930_, p_252329_, p_250482_, SmokingRecipe::new); } @@ -71,12 +71,12 @@ public SimpleCookingRecipeBuilder unlockedBy(String p_176792_, Criterion p_300970_) { this.criteria.put(p_176792_, p_300970_); return this; -@@ -111,7 +_,7 @@ +@@ -112,7 +_,7 @@ this.criteria.forEach(advancement$builder::addCriterion); AbstractCookingRecipe abstractcookingrecipe = this.factory .create( - Objects.requireNonNullElse(this.group, ""), this.bookCategory, this.ingredient, new ItemStack(this.result), this.experience, this.cookingTime + Objects.requireNonNullElse(this.group, ""), this.bookCategory, this.ingredient, this.stackResult, this.experience, this.cookingTime ); - p_301266_.accept(p_126264_, abstractcookingrecipe, advancement$builder.build(p_126264_.withPrefix("recipes/" + this.category.getFolderName() + "/"))); - } + p_301266_.accept( + p_380371_, abstractcookingrecipe, advancement$builder.build(p_380371_.location().withPrefix("recipes/" + this.category.getFolderName() + "/")) diff --git a/patches/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch b/patches/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch index 53007c8fe3..6619051d3d 100644 --- a/patches/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch +++ b/patches/net/minecraft/data/registries/RegistriesDatapackGenerator.java.patch @@ -48,10 +48,10 @@ + var conditionalCodec = net.neoforged.neoforge.common.conditions.ConditionalOps.createConditionalCodecWithConditions(p_256449_.elementCodec()); return p_256492_.lookup(resourcekey) .map( - p_349921_ -> { + p_367836_ -> { PackOutput.PathProvider packoutput$pathprovider = this.output.createRegistryElementsPathProvider(resourcekey); return CompletableFuture.allOf( - p_349921_.listElements() + p_367836_.listElements() + .filter(holder -> this.namespacePredicate.test(holder.key().location().getNamespace())) .map( p_256105_ -> dumpValue( diff --git a/patches/net/minecraft/data/registries/RegistryPatchGenerator.java.patch b/patches/net/minecraft/data/registries/RegistryPatchGenerator.java.patch index 29eceb38e7..d7b34a0cb0 100644 --- a/patches/net/minecraft/data/registries/RegistryPatchGenerator.java.patch +++ b/patches/net/minecraft/data/registries/RegistryPatchGenerator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/registries/RegistryPatchGenerator.java +++ b/net/minecraft/data/registries/RegistryPatchGenerator.java -@@ -20,7 +_,7 @@ +@@ -21,7 +_,7 @@ p_311522_ -> { RegistryAccess.Frozen registryaccess$frozen = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); Cloner.Factory cloner$factory = new Cloner.Factory(); diff --git a/patches/net/minecraft/data/registries/VanillaRegistries.java.patch b/patches/net/minecraft/data/registries/VanillaRegistries.java.patch index 94e1887dfc..2831c7f25b 100644 --- a/patches/net/minecraft/data/registries/VanillaRegistries.java.patch +++ b/patches/net/minecraft/data/registries/VanillaRegistries.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/data/registries/VanillaRegistries.java +++ b/net/minecraft/data/registries/VanillaRegistries.java -@@ -68,6 +_,7 @@ - .add(Registries.ENCHANTMENT, Enchantments::bootstrap) +@@ -72,6 +_,7 @@ .add(Registries.ENCHANTMENT_PROVIDER, VanillaEnchantmentProviders::bootstrap) - .add(Registries.JUKEBOX_SONG, JukeboxSongs::bootstrap); + .add(Registries.JUKEBOX_SONG, JukeboxSongs::bootstrap) + .add(Registries.INSTRUMENT, Instruments::bootstrap); + public static final List>> DATAPACK_REGISTRY_KEYS = BUILDER.getEntryKeys(); private static void validateThatAllBiomeFeaturesHaveBiomeFilter(HolderLookup.Provider p_256242_) { diff --git a/patches/net/minecraft/gametest/framework/GameTestInfo.java.patch b/patches/net/minecraft/gametest/framework/GameTestInfo.java.patch index 6d77cc9d23..2081e074ab 100644 --- a/patches/net/minecraft/gametest/framework/GameTestInfo.java.patch +++ b/patches/net/minecraft/gametest/framework/GameTestInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestInfo.java +++ b/net/minecraft/gametest/framework/GameTestInfo.java -@@ -264,6 +_,7 @@ +@@ -268,6 +_,7 @@ BlockPos blockpos = this.getOrCalculateNorthwestCorner(); this.structureBlockEntity = StructureUtils.prepareTestStructure(this, blockpos, this.getRotation(), this.level); this.structureBlockPos = this.structureBlockEntity.getBlockPos(); diff --git a/patches/net/minecraft/gametest/framework/GameTestServer.java.patch b/patches/net/minecraft/gametest/framework/GameTestServer.java.patch index 162c353781..e648ea2aa8 100644 --- a/patches/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/patches/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -151,6 +_,7 @@ +@@ -155,6 +_,7 @@ public boolean initServer() { this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, 1) { }); @@ -8,7 +8,7 @@ this.loadLevel(); ServerLevel serverlevel = this.overworld(); this.testBatches = Lists.newArrayList(GameTestBatchFactory.fromTestFunction(this.testFunctions, serverlevel)); -@@ -158,6 +_,7 @@ +@@ -162,6 +_,7 @@ int i = 20000000; serverlevel.setWeatherParameters(20000000, 20000000, false, false); LOGGER.info("Started game test server"); diff --git a/patches/net/minecraft/gametest/framework/TestCommand.java.patch b/patches/net/minecraft/gametest/framework/TestCommand.java.patch index 9bfb27eae4..7bc73f3e4e 100644 --- a/patches/net/minecraft/gametest/framework/TestCommand.java.patch +++ b/patches/net/minecraft/gametest/framework/TestCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/TestCommand.java +++ b/net/minecraft/gametest/framework/TestCommand.java -@@ -361,7 +_,7 @@ +@@ -363,7 +_,7 @@ } else { BlockPos blockpos1 = blockpos.subtract(optional.get()); String s = blockpos1.getX() + ", " + blockpos1.getY() + ", " + blockpos1.getZ(); diff --git a/patches/net/minecraft/locale/Language.java.patch b/patches/net/minecraft/locale/Language.java.patch index 9f3cb451af..6ca12f12ea 100644 --- a/patches/net/minecraft/locale/Language.java.patch +++ b/patches/net/minecraft/locale/Language.java.patch @@ -1,19 +1,20 @@ --- a/net/minecraft/locale/Language.java +++ b/net/minecraft/locale/Language.java -@@ -36,8 +_,10 @@ - private static Language loadDefault() { - Builder builder = ImmutableMap.builder(); - BiConsumer biconsumer = builder::put; +@@ -36,9 +_,11 @@ + DeprecatedTranslationsInfo deprecatedtranslationsinfo = DeprecatedTranslationsInfo.loadFromDefaultResource(); + Map map = new HashMap<>(); + BiConsumer biconsumer = map::put; - parseTranslations(biconsumer, "/assets/minecraft/lang/en_us.json"); -- final Map map = builder.build(); + Map componentMap = new java.util.HashMap<>(); + parseTranslations(biconsumer, componentMap::put, "/assets/minecraft/lang/en_us.json"); -+ final Map map = new java.util.HashMap<>(builder.build()); + deprecatedtranslationsinfo.applyToMap(map); +- final Map map1 = Map.copyOf(map); ++ final Map map1 = map; // Neo keep the map mutable to make LanguageHook work + net.neoforged.neoforge.server.LanguageHook.captureLanguageMap(map, componentMap); return new Language() { @Override public String getOrDefault(String p_128127_, String p_265421_) { -@@ -64,21 +_,51 @@ +@@ -65,21 +_,51 @@ ) .isPresent(); } @@ -66,14 +67,14 @@ String s = UNSUPPORTED_FORMAT_PATTERN.matcher(GsonHelper.convertToString(entry.getValue(), entry.getKey())).replaceAll("%$1s"); p_128110_.accept(entry.getKey(), s); } -@@ -90,6 +_,13 @@ +@@ -91,6 +_,13 @@ public static void inject(Language p_128115_) { instance = p_128115_; + } + + // Neo: All helpers methods below are injected by Neo to ease modder's usage of Language -+ public Map getLanguageData() { return ImmutableMap.of(); } ++ public Map getLanguageData() { return com.google.common.collect.ImmutableMap.of(); } + + public @org.jetbrains.annotations.Nullable net.minecraft.network.chat.Component getComponent(String key) { + return null; diff --git a/patches/net/minecraft/network/FriendlyByteBuf.java.patch b/patches/net/minecraft/network/FriendlyByteBuf.java.patch index 5f72bfa0a5..b6e2de94ff 100644 --- a/patches/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/patches/net/minecraft/network/FriendlyByteBuf.java.patch @@ -9,7 +9,7 @@ public static final int DEFAULT_NBT_QUOTA = 2097152; private final ByteBuf source; public static final short MAX_STRING_LENGTH = 32767; -@@ -1588,5 +_,10 @@ +@@ -1623,5 +_,10 @@ @Override public boolean release(int p_130347_) { return this.source.release(p_130347_); diff --git a/patches/net/minecraft/network/codec/ByteBufCodecs.java.patch b/patches/net/minecraft/network/codec/ByteBufCodecs.java.patch index b05fe14e4a..ac8e4a2731 100644 --- a/patches/net/minecraft/network/codec/ByteBufCodecs.java.patch +++ b/patches/net/minecraft/network/codec/ByteBufCodecs.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/network/codec/ByteBufCodecs.java +++ b/net/minecraft/network/codec/ByteBufCodecs.java -@@ -463,7 +_,11 @@ +@@ -487,7 +_,11 @@ ) { return new StreamCodec() { - private IdMap getRegistryOrThrow(RegistryFriendlyByteBuf p_330361_) { -- return p_320353_.apply(p_330361_.registryAccess().registryOrThrow(p_319942_)); -+ var registry = p_330361_.registryAccess().registryOrThrow(p_319942_); + private IdMap getRegistryOrThrow(RegistryFriendlyByteBuf p_362297_) { +- return p_320353_.apply(p_362297_.registryAccess().lookupOrThrow(p_319942_)); ++ var registry = p_362297_.registryAccess().lookupOrThrow(p_319942_); + if (net.neoforged.neoforge.registries.RegistryManager.isNonSyncedBuiltInRegistry(registry)) { + throw new IllegalStateException("Cannot use ID syncing for non-synced built-in registry: " + registry.key()); + } + return p_320353_.apply(registry); } - public R decode(RegistryFriendlyByteBuf p_331253_) { -@@ -520,8 +_,25 @@ + public R decode(RegistryFriendlyByteBuf p_340887_) { +@@ -544,8 +_,25 @@ private static final int NAMED_SET = -1; private final StreamCodec> holderCodec = ByteBufCodecs.holderRegistry(p_332137_); @@ -27,31 +27,31 @@ + return (H) holderSet; + } + - public HolderSet decode(RegistryFriendlyByteBuf p_340887_) { - int i = VarInt.read(p_340887_) - 1; + public HolderSet decode(RegistryFriendlyByteBuf p_376912_) { + int i = VarInt.read(p_376912_) - 1; + // Neo: Co-opt negative VarInt values within the HolderSet codec as an HolderSetType id. + // Vanilla uses 0 for tag and [1, Integer.MAX_VALUE] for list size [0, Integer.MAX_VALUE - 1]. + // So we may encode the registry id for custom holder set types in [Integer.MIN_VALUE + 1, -1] (local variable i must not be underflow). + // The registry id for custom holder set types is (-1 - network id), while local variable i is (network id - 1), so the registry id would be (-2 - i). + if (i < -1) { -+ return this.holderSetCodec(net.neoforged.neoforge.registries.NeoForgeRegistries.HOLDER_SET_TYPES.byIdOrThrow(-2 - i)).decode(p_340887_); ++ return this.holderSetCodec(net.neoforged.neoforge.registries.NeoForgeRegistries.HOLDER_SET_TYPES.byIdOrThrow(-2 - i)).decode(p_376912_); + } if (i == -1) { - Registry registry = p_340887_.registryAccess().registryOrThrow(p_332137_); - return registry.getTag(TagKey.create(p_332137_, ResourceLocation.STREAM_CODEC.decode(p_340887_))).orElseThrow(); -@@ -537,6 +_,15 @@ + Registry registry = p_376912_.registryAccess().lookupOrThrow(p_332137_); + return registry.get(TagKey.create(p_332137_, ResourceLocation.STREAM_CODEC.decode(p_376912_))).orElseThrow(); +@@ -561,6 +_,15 @@ } - public void encode(RegistryFriendlyByteBuf p_341009_, HolderSet p_340834_) { + public void encode(RegistryFriendlyByteBuf p_376382_, HolderSet p_376430_) { + // Neo: Co-opt negative VarInt values within the HolderSet codec as an HolderSetType id. + // Vanilla uses 0 for tag and [1, Integer.MAX_VALUE] for list size [0, Integer.MAX_VALUE - 1] (local variable i in decode() must not be underflow). + // So we may encode the registry id for custom holder set types in [Integer.MIN_VALUE + 1, -1]. + // The network id for custom holder set types is (-1 - registry id) -+ if (p_341009_.getConnectionType().isNeoForge() && p_340834_ instanceof net.neoforged.neoforge.registries.holdersets.ICustomHolderSet customHolderSet) { -+ VarInt.write(p_341009_, -1 - net.neoforged.neoforge.registries.NeoForgeRegistries.HOLDER_SET_TYPES.getId(customHolderSet.type())); -+ this.holderSetCodec(customHolderSet.type()).encode(p_341009_, cast(customHolderSet)); ++ if (p_376382_.getConnectionType().isNeoForge() && p_376430_ instanceof net.neoforged.neoforge.registries.holdersets.ICustomHolderSet customHolderSet) { ++ VarInt.write(p_376382_, -1 - net.neoforged.neoforge.registries.NeoForgeRegistries.HOLDER_SET_TYPES.getId(customHolderSet.type())); ++ this.holderSetCodec(customHolderSet.type()).encode(p_376382_, cast(customHolderSet)); + return; + } - Optional> optional = p_340834_.unwrapKey(); + Optional> optional = p_376430_.unwrapKey(); if (optional.isPresent()) { - VarInt.write(p_341009_, 0); + VarInt.write(p_376382_, 0); diff --git a/patches/net/minecraft/network/protocol/common/ClientCommonPacketListener.java.patch b/patches/net/minecraft/network/protocol/common/ClientCommonPacketListener.java.patch index f9a18764ed..1b6b85fcf9 100644 --- a/patches/net/minecraft/network/protocol/common/ClientCommonPacketListener.java.patch +++ b/patches/net/minecraft/network/protocol/common/ClientCommonPacketListener.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/network/protocol/common/ClientCommonPacketListener.java +++ b/net/minecraft/network/protocol/common/ClientCommonPacketListener.java -@@ -3,7 +_,7 @@ - import net.minecraft.network.ClientboundPacketListener; +@@ -2,7 +_,7 @@ + import net.minecraft.network.protocol.cookie.ClientCookiePacketListener; --public interface ClientCommonPacketListener extends ClientCookiePacketListener, ClientboundPacketListener { -+public interface ClientCommonPacketListener extends ClientCookiePacketListener, ClientboundPacketListener, net.neoforged.neoforge.common.extensions.IClientCommonPacketListenerExtension { +-public interface ClientCommonPacketListener extends ClientCookiePacketListener { ++public interface ClientCommonPacketListener extends ClientCookiePacketListener, net.neoforged.neoforge.common.extensions.IClientCommonPacketListenerExtension { void handleKeepAlive(ClientboundKeepAlivePacket p_295236_); void handlePing(ClientboundPingPacket p_296451_); diff --git a/patches/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch b/patches/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch index f17a187ea5..f36844e8e2 100644 --- a/patches/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch +++ b/patches/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java +++ b/net/minecraft/network/protocol/common/ClientboundCustomPayloadPacket.java -@@ -60,12 +_,16 @@ +@@ -62,12 +_,16 @@ ), p_333492_ -> { } diff --git a/patches/net/minecraft/network/protocol/common/ServerCommonPacketListener.java.patch b/patches/net/minecraft/network/protocol/common/ServerCommonPacketListener.java.patch index bb57676d72..c503189ba1 100644 --- a/patches/net/minecraft/network/protocol/common/ServerCommonPacketListener.java.patch +++ b/patches/net/minecraft/network/protocol/common/ServerCommonPacketListener.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/network/protocol/common/ServerCommonPacketListener.java +++ b/net/minecraft/network/protocol/common/ServerCommonPacketListener.java -@@ -3,7 +_,7 @@ +@@ -2,7 +_,7 @@ + import net.minecraft.network.protocol.cookie.ServerCookiePacketListener; - import net.minecraft.network.protocol.game.ServerPacketListener; --public interface ServerCommonPacketListener extends ServerCookiePacketListener, ServerPacketListener { -+public interface ServerCommonPacketListener extends ServerCookiePacketListener, ServerPacketListener, net.neoforged.neoforge.common.extensions.IServerCommonPacketListenerExtension { +-public interface ServerCommonPacketListener extends ServerCookiePacketListener { ++public interface ServerCommonPacketListener extends ServerCookiePacketListener, net.neoforged.neoforge.common.extensions.IServerCommonPacketListenerExtension { void handleKeepAlive(ServerboundKeepAlivePacket p_296457_); void handlePong(ServerboundPongPacket p_294309_); diff --git a/patches/net/minecraft/network/protocol/game/ServerGamePacketListener.java.patch b/patches/net/minecraft/network/protocol/game/ServerGamePacketListener.java.patch index 141ddf719f..f24f3d2b43 100644 --- a/patches/net/minecraft/network/protocol/game/ServerGamePacketListener.java.patch +++ b/patches/net/minecraft/network/protocol/game/ServerGamePacketListener.java.patch @@ -4,8 +4,8 @@ import net.minecraft.network.protocol.common.ServerCommonPacketListener; import net.minecraft.network.protocol.ping.ServerPingPacketListener; --public interface ServerGamePacketListener extends ServerPingPacketListener, ServerCommonPacketListener { -+public interface ServerGamePacketListener extends ServerPingPacketListener, ServerCommonPacketListener, net.neoforged.neoforge.common.extensions.IServerGamePacketListenerExtension { +-public interface ServerGamePacketListener extends ServerCommonPacketListener, ServerPingPacketListener { ++public interface ServerGamePacketListener extends ServerCommonPacketListener, ServerPingPacketListener, net.neoforged.neoforge.common.extensions.IServerGamePacketListenerExtension { @Override default ConnectionProtocol protocol() { return ConnectionProtocol.PLAY; diff --git a/patches/net/minecraft/resources/RegistryDataLoader.java.patch b/patches/net/minecraft/resources/RegistryDataLoader.java.patch index 13d15f4bb3..4a24d6d0f3 100644 --- a/patches/net/minecraft/resources/RegistryDataLoader.java.patch +++ b/patches/net/minecraft/resources/RegistryDataLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/RegistryDataLoader.java +++ b/net/minecraft/resources/RegistryDataLoader.java -@@ -100,7 +_,7 @@ +@@ -112,7 +_,7 @@ public static final List> DIMENSION_REGISTRIES = List.of( new RegistryDataLoader.RegistryData<>(Registries.LEVEL_STEM, LevelStem.CODEC) ); @@ -9,16 +9,16 @@ new RegistryDataLoader.RegistryData<>(Registries.BIOME, Biome.NETWORK_CODEC), new RegistryDataLoader.RegistryData<>(Registries.CHAT_TYPE, ChatType.DIRECT_CODEC), new RegistryDataLoader.RegistryData<>(Registries.TRIM_PATTERN, TrimPattern.DIRECT_CODEC), -@@ -112,7 +_,7 @@ - new RegistryDataLoader.RegistryData<>(Registries.BANNER_PATTERN, BannerPattern.DIRECT_CODEC), +@@ -125,7 +_,7 @@ new RegistryDataLoader.RegistryData<>(Registries.ENCHANTMENT, Enchantment.DIRECT_CODEC), - new RegistryDataLoader.RegistryData<>(Registries.JUKEBOX_SONG, JukeboxSong.DIRECT_CODEC) + new RegistryDataLoader.RegistryData<>(Registries.JUKEBOX_SONG, JukeboxSong.DIRECT_CODEC), + new RegistryDataLoader.RegistryData<>(Registries.INSTRUMENT, Instrument.DIRECT_CODEC) - ); + )); // Neo: Keep the list so custom registries can be added later - public static RegistryAccess.Frozen load(ResourceManager p_252046_, RegistryAccess p_249916_, List> p_250344_) { - return load((p_321412_, p_321413_) -> p_321412_.loadFromResources(p_252046_, p_321413_), p_249916_, p_250344_); -@@ -204,11 +_,16 @@ + public static RegistryAccess.Frozen load( + ResourceManager p_364116_, List> p_321716_, List> p_365382_ +@@ -247,11 +_,16 @@ Resource p_326141_, RegistrationInfo p_326033_ ) throws IOException { @@ -37,7 +37,7 @@ } } -@@ -221,7 +_,7 @@ +@@ -264,7 +_,7 @@ ) { String s = Registries.elementsDirPath(p_321557_.key()); FileToIdConverter filetoidconverter = FileToIdConverter.json(s); @@ -46,8 +46,8 @@ for (Entry entry : filetoidconverter.listMatchingResources(p_321535_).entrySet()) { ResourceLocation resourcelocation = entry.getKey(); -@@ -304,13 +_,20 @@ - void apply(RegistryDataLoader.Loader p_321864_, RegistryOps.RegistryInfoLookup p_321656_); +@@ -354,13 +_,20 @@ + public static record NetworkedRegistryData(List elements, TagNetworkSerialization.NetworkPayload tags) { } - public static record RegistryData(ResourceKey> key, Codec elementCodec, boolean requiredNonEmpty) { diff --git a/patches/net/minecraft/server/Bootstrap.java.patch b/patches/net/minecraft/server/Bootstrap.java.patch index 1aaee96a57..e775eb5eea 100644 --- a/patches/net/minecraft/server/Bootstrap.java.patch +++ b/patches/net/minecraft/server/Bootstrap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Bootstrap.java +++ b/net/minecraft/server/Bootstrap.java -@@ -52,6 +_,8 @@ +@@ -53,6 +_,8 @@ CauldronInteraction.bootStrap(); BuiltInRegistries.bootStrap(); CreativeModeTabs.validate(); @@ -9,7 +9,7 @@ wrapStreams(); bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis()); } -@@ -117,7 +_,6 @@ +@@ -119,7 +_,6 @@ Commands.validate(); } diff --git a/patches/net/minecraft/server/Main.java.patch b/patches/net/minecraft/server/Main.java.patch index 786a375e82..e32cfe17d8 100644 --- a/patches/net/minecraft/server/Main.java.patch +++ b/patches/net/minecraft/server/Main.java.patch @@ -86,14 +86,14 @@ LOGGER.error("Failed to load world data from {}", levelstoragesource$leveldirectory.oldDataFile(), ioexception); LOGGER.error( @@ -214,6 +_,9 @@ - worlddimensions = dedicatedserverproperties.createDimensions(p_307161_.datapackWorldgen()); + worlddimensions = dedicatedserverproperties.createDimensions(p_359487_.datapackWorldgen()); } + // Neo: Do a write-read-cycle to inject modded dimensions on first start of a dedicated server into its generated world dimensions list. -+ var registryOps = net.minecraft.resources.RegistryOps.create(net.minecraft.nbt.NbtOps.INSTANCE, p_307161_.datapackWorldgen()); ++ var registryOps = net.minecraft.resources.RegistryOps.create(net.minecraft.nbt.NbtOps.INSTANCE, p_359487_.datapackWorldgen()); + worlddimensions = WorldDimensions.CODEC.encoder().encodeStart(registryOps, worlddimensions).flatMap((writtenPayloadWithModdedDimensions) -> WorldDimensions.CODEC.decoder().parse(registryOps, writtenPayloadWithModdedDimensions)).resultOrPartial(LOGGER::error).orElse(worlddimensions); WorldDimensions.Complete worlddimensions$complete = worlddimensions.bake(registry); - Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_307161_.datapackWorldgen().allRegistriesLifecycle()); + Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_359487_.datapackWorldgen().allRegistriesLifecycle()); return new WorldLoader.DataLoadOutput<>( @@ -246,24 +_,22 @@ diff --git a/patches/net/minecraft/server/MinecraftServer.java.patch b/patches/net/minecraft/server/MinecraftServer.java.patch index cebd24b556..f6874df74e 100644 --- a/patches/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -264,7 +_,7 @@ +@@ -275,7 +_,7 @@ public static S spin(Function p_129873_) { AtomicReference atomicreference = new AtomicReference<>(); @@ -9,16 +9,19 @@ thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> LOGGER.error("Uncaught exception in server thread", p_177910_)); if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); -@@ -315,7 +_,7 @@ +@@ -325,9 +_,9 @@ this.structureTemplateManager = new StructureTemplateManager(p_236726_.resourceManager(), p_236724_, p_236728_, holdergetter); this.serverThread = p_236723_; this.executor = Util.backgroundExecutor(); - this.potionBrewing = PotionBrewing.bootstrap(this.worldData.enabledFeatures()); + this.potionBrewing = PotionBrewing.bootstrap(this.worldData.enabledFeatures(), this.registryAccess()); + this.resources.managers.getRecipeManager().finalizeRecipeLoading(this.worldData.enabledFeatures()); +- this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures()); ++ this.fuelValues = net.neoforged.neoforge.common.DataMapHooks.populateFuelValues(this.registries.compositeAccess(), this.worldData.enabledFeatures()); + this.tickFrame = TracyClient.createDiscontinuousFrame("Server Tick"); } } - -@@ -372,6 +_,7 @@ +@@ -385,6 +_,7 @@ this.readScoreboard(dimensiondatastorage); this.commandStorage = new CommandStorage(dimensiondatastorage); WorldBorder worldborder = serverlevel.getWorldBorder(); @@ -26,7 +29,7 @@ if (!serverleveldata.isInitialized()) { try { setInitialSpawn(serverlevel, serverleveldata, worldoptions.generateBonusChest(), flag); -@@ -421,6 +_,7 @@ +@@ -434,6 +_,7 @@ ); worldborder.addListener(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.getWorldBorder())); this.levels.put(resourcekey1, serverlevel1); @@ -34,15 +37,15 @@ } } -@@ -432,6 +_,7 @@ +@@ -445,6 +_,7 @@ p_177898_.setSpawn(BlockPos.ZERO.above(80), 0.0F); } else { ServerChunkCache serverchunkcache = p_177897_.getChunkSource(); + if (net.neoforged.neoforge.event.EventHooks.onCreateWorldSpawn(p_177897_, p_177898_)) return; ChunkPos chunkpos = new ChunkPos(serverchunkcache.randomState().sampler().findSpawnPosition()); int i = serverchunkcache.getGenerator().getSpawnHeight(p_177897_); - if (i < p_177897_.getMinBuildHeight()) { -@@ -513,6 +_,7 @@ + if (i < p_177897_.getMinY()) { +@@ -526,6 +_,7 @@ ChunkPos chunkpos = new ChunkPos(k); serverlevel1.getChunkSource().updateChunkForced(chunkpos, true); } @@ -50,7 +53,7 @@ } } -@@ -620,6 +_,7 @@ +@@ -633,6 +_,7 @@ for (ServerLevel serverlevel2 : this.getAllLevels()) { if (serverlevel2 != null) { try { @@ -58,7 +61,7 @@ serverlevel2.close(); } catch (IOException ioexception1) { LOGGER.error("Exception closing the level", (Throwable)ioexception1); -@@ -666,9 +_,11 @@ +@@ -679,9 +_,11 @@ throw new IllegalStateException("Failed to initialize server"); } @@ -70,16 +73,16 @@ while (this.running) { long i; -@@ -714,6 +_,8 @@ +@@ -734,6 +_,8 @@ this.isReady = true; JvmProfiler.INSTANCE.onServerTick(this.smoothedTickTimeMillis); } + net.neoforged.neoforge.server.ServerLifecycleHooks.handleServerStopping(this); + net.neoforged.neoforge.server.ServerLifecycleHooks.expectServerStopped(); // Forge: Has to come before MinecraftServer#onServerCrash to avoid race conditions - } catch (Throwable throwable1) { - LOGGER.error("Encountered an unexpected exception", throwable1); - CrashReport crashreport = constructOrExtractCrashReport(throwable1); -@@ -725,6 +_,7 @@ + } catch (Throwable throwable2) { + LOGGER.error("Encountered an unexpected exception", throwable2); + CrashReport crashreport = constructOrExtractCrashReport(throwable2); +@@ -745,6 +_,7 @@ LOGGER.error("We were unable to save this crash report to disk."); } @@ -87,7 +90,7 @@ this.onServerCrash(crashreport); } finally { try { -@@ -737,6 +_,7 @@ +@@ -757,6 +_,7 @@ this.services.profileCache().clearExecutor(); } @@ -95,9 +98,9 @@ this.onServerExit(); } } -@@ -901,11 +_,13 @@ - public void tickServer(BooleanSupplier p_129871_) { - long i = Util.getNanos(); +@@ -947,11 +_,13 @@ + } + this.tickCount++; + net.neoforged.neoforge.event.EventHooks.fireServerTickPre(p_129871_, this); this.tickRateManager.tick(); @@ -109,15 +112,15 @@ } this.ticksUntilAutosave--; -@@ -927,6 +_,7 @@ - this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float)j / (float)TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F; +@@ -969,6 +_,7 @@ + this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float)k / (float)TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F; this.logTickMethodTime(i); - this.profiler.pop(); + profilerfiller.pop(); + net.neoforged.neoforge.event.EventHooks.fireServerTickPost(p_129871_, this); } - private void logTickMethodTime(long p_321837_) { -@@ -935,6 +_,16 @@ + private void autoSave() { +@@ -987,6 +_,16 @@ } } @@ -134,7 +137,7 @@ private int computeNextAutosaveInterval() { float f; if (this.tickRateManager.isSprinting()) { -@@ -966,7 +_,8 @@ +@@ -1018,7 +_,8 @@ Optional.of(serverstatus$players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), @@ -144,45 +147,45 @@ ); } -@@ -996,7 +_,8 @@ +@@ -1049,7 +_,8 @@ this.getFunctions().tick(); - this.profiler.popPush("levels"); + profilerfiller.popPush("levels"); - for (ServerLevel serverlevel : this.getAllLevels()) { -+ for(ServerLevel serverlevel : this.getWorldArray()) { ++ for (ServerLevel serverlevel : this.getWorldArray()) { + long tickStart = Util.getNanos(); - this.profiler.push(() -> serverlevel + " " + serverlevel.dimension().location()); + profilerfiller.push(() -> serverlevel + " " + serverlevel.dimension().location()); if (this.tickCount % 20 == 0) { - this.profiler.push("timeSync"); -@@ -1005,6 +_,7 @@ + profilerfiller.push("timeSync"); +@@ -1058,6 +_,7 @@ } - this.profiler.push("tick"); + profilerfiller.push("tick"); + net.neoforged.neoforge.event.EventHooks.fireLevelTickPre(serverlevel, p_129954_); try { serverlevel.tick(p_129954_); -@@ -1013,16 +_,18 @@ +@@ -1066,16 +_,18 @@ serverlevel.fillReportDetails(crashreport); throw new ReportedException(crashreport); } + net.neoforged.neoforge.event.EventHooks.fireLevelTickPost(serverlevel, p_129954_); - this.profiler.pop(); - this.profiler.pop(); + profilerfiller.pop(); + profilerfiller.pop(); + perWorldTickTimes.computeIfAbsent(serverlevel.dimension(), k -> new long[100])[this.tickCount % 100] = Util.getNanos() - tickStart; } - this.profiler.popPush("connection"); - this.getConnection().tick(); - this.profiler.popPush("players"); + profilerfiller.popPush("connection"); + this.tickConnection(); + profilerfiller.popPush("players"); this.playerList.tick(); - if (SharedConstants.IS_RUNNING_IN_IDE && this.tickRateManager.runsNormally()) { + if (net.neoforged.neoforge.gametest.GameTestHooks.isGametestEnabled() && this.tickRateManager.runsNormally()) { GameTestTicker.SINGLETON.tick(); } -@@ -1043,11 +_,17 @@ +@@ -1100,11 +_,17 @@ } private void synchronizeTime(ServerLevel p_276371_) { @@ -205,7 +208,7 @@ } public void forceTimeSynchronization() { -@@ -1118,7 +_,7 @@ +@@ -1176,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -214,7 +217,7 @@ } public SystemReport fillSystemReport(SystemReport p_177936_) { -@@ -1441,7 +_,7 @@ +@@ -1492,7 +_,7 @@ public CompletableFuture reloadResources(Collection p_129862_) { CompletableFuture completablefuture = CompletableFuture.supplyAsync( @@ -223,15 +226,17 @@ this ) .thenCompose( -@@ -1478,6 +_,7 @@ +@@ -1532,7 +_,8 @@ this.getPlayerList().reloadResources(); this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary()); this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager); +- this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures()); ++ this.fuelValues = net.neoforged.neoforge.common.DataMapHooks.populateFuelValues(this.registries.compositeAccess(), this.worldData.enabledFeatures()); + this.getPlayerList().getPlayers().forEach(this.getPlayerList()::sendPlayerPermissionLevel); //Forge: Fix newly added/modified commands not being sent to the client when commands reload. }, this ); -@@ -1495,8 +_,10 @@ +@@ -1550,8 +_,10 @@ FeatureFlagSet featureflagset = p_249869_ ? FeatureFlagSet.of() : p_341632_.enabledFeatures(); FeatureFlagSet featureflagset1 = p_249869_ ? FeatureFlags.REGISTRY.allFlags() : p_341632_.enabledFeatures(); p_248681_.reload(); @@ -243,7 +248,7 @@ } else { Set set = Sets.newLinkedHashSet(); -@@ -1542,6 +_,8 @@ +@@ -1597,6 +_,8 @@ set.add("vanilla"); } @@ -252,7 +257,7 @@ return configureRepositoryWithSelection(p_248681_, set, featureflagset, true); } } -@@ -1712,6 +_,31 @@ +@@ -1763,6 +_,31 @@ public abstract boolean isSingleplayerOwner(GameProfile p_129840_); @@ -284,7 +289,7 @@ public void dumpServerProperties(Path p_177911_) throws IOException { } -@@ -1873,6 +_,10 @@ +@@ -1921,6 +_,10 @@ public WorldData getWorldData() { return this.worldData; diff --git a/patches/net/minecraft/server/PlayerAdvancements.java.patch b/patches/net/minecraft/server/PlayerAdvancements.java.patch index c1dd7151ec..75e257181e 100644 --- a/patches/net/minecraft/server/PlayerAdvancements.java.patch +++ b/patches/net/minecraft/server/PlayerAdvancements.java.patch @@ -16,9 +16,9 @@ + net.neoforged.neoforge.event.EventHooks.onAdvancementProgressedEvent(this.player, p_300979_, advancementprogress, p_135990_, net.neoforged.neoforge.event.entity.player.AdvancementEvent.AdvancementProgressEvent.ProgressType.GRANT); if (!flag1 && advancementprogress.isDone()) { p_300979_.value().rewards().grant(this.player); - p_300979_.value().display().ifPresent(p_352686_ -> { - if (p_352686_.shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { - this.playerList.broadcastSystemMessage(p_352686_.getType().createAnnouncement(p_300979_, this.player), false); + p_300979_.value().display().ifPresent(p_375474_ -> { + if (p_375474_.shouldAnnounceChat() && this.player.serverLevel().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) { + this.playerList.broadcastSystemMessage(p_375474_.getType().createAnnouncement(p_300979_, this.player), false); } + net.neoforged.neoforge.event.EventHooks.onAdvancementEarnedEvent(this.player, p_300979_); }); diff --git a/patches/net/minecraft/server/ReloadableServerRegistries.java.patch b/patches/net/minecraft/server/ReloadableServerRegistries.java.patch new file mode 100644 index 0000000000..ff31d3b5cf --- /dev/null +++ b/patches/net/minecraft/server/ReloadableServerRegistries.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/ReloadableServerRegistries.java ++++ b/net/minecraft/server/ReloadableServerRegistries.java +@@ -61,8 +_,16 @@ + () -> { + WritableRegistry writableregistry = new MappedRegistry<>(p_335741_.registryKey(), Lifecycle.experimental()); + Map map = new HashMap<>(); ++ Map> optionalMap = new HashMap<>(); + String s = Registries.elementsDirPath(p_335741_.registryKey()); +- SimpleJsonResourceReloadListener.scanDirectory(p_335893_, s, p_336173_, p_335741_.codec(), map); ++ SimpleJsonResourceReloadListener.scanDirectory(p_335893_, s, p_336173_, p_335741_.conditionalCodec(), optionalMap); ++ optionalMap.forEach((rl, optionalEntry) -> { ++ optionalEntry.ifPresent(entry -> p_335741_.idSetter().accept(entry, rl)); ++ T value = optionalEntry.orElse(p_335741_.defaultValue()); ++ if (value instanceof LootTable lootTable) value = (T) net.neoforged.neoforge.event.EventHooks.loadLootTable(rl, lootTable); ++ if (value != null) ++ map.put(rl, value); ++ }); + map.forEach( + (p_335721_, p_335683_) -> writableregistry.register( + ResourceKey.create(p_335741_.registryKey(), p_335721_), (T)p_335683_, DEFAULT_REGISTRATION_INFO diff --git a/patches/net/minecraft/server/ReloadableServerResources.java.patch b/patches/net/minecraft/server/ReloadableServerResources.java.patch index cf23f14fbc..4af3bf71c6 100644 --- a/patches/net/minecraft/server/ReloadableServerResources.java.patch +++ b/patches/net/minecraft/server/ReloadableServerResources.java.patch @@ -1,19 +1,21 @@ --- a/net/minecraft/server/ReloadableServerResources.java +++ b/net/minecraft/server/ReloadableServerResources.java -@@ -49,6 +_,8 @@ - this.commands = new Commands(p_206858_, CommandBuildContext.simple(this.registryLookup, p_250695_)); - this.advancements = new ServerAdvancementManager(this.registryLookup); +@@ -41,6 +_,9 @@ + this.commands = new Commands(p_206858_, CommandBuildContext.simple(p_361583_, p_250695_)); + this.advancements = new ServerAdvancementManager(p_361583_); this.functionLibrary = new ServerFunctionLibrary(p_206859_, this.commands.getDispatcher()); -+ // Neo: Create context object -+ this.context = new net.neoforged.neoforge.common.conditions.ConditionContext(this.tagManager); ++ // Neo: Store registries and create context object ++ this.registryLookup = p_361583_; ++ this.context = new net.neoforged.neoforge.common.conditions.ConditionContext(this.postponedTags); } public ServerFunctionLibrary getFunctionLibrary() { -@@ -75,6 +_,24 @@ - return List.of(this.tagManager, this.recipes, this.functionLibrary, this.advancements); +@@ -67,6 +_,25 @@ + return List.of(this.recipes, this.functionLibrary, this.advancements); } -+ private final net.neoforged.neoforge.common.conditions.ICondition.IContext context; ++ private final HolderLookup.Provider registryLookup; ++ private final net.neoforged.neoforge.common.conditions.ConditionContext context; + + /** + * Exposes the current condition context for usage in other reload listeners.
@@ -34,12 +36,12 @@ public static CompletableFuture loadResources( ResourceManager p_248588_, LayeredRegistryAccess p_335667_, -@@ -90,14 +_,27 @@ +@@ -83,10 +_,24 @@ ReloadableServerResources reloadableserverresources = new ReloadableServerResources( - p_335211_.compositeAccess(), p_250212_, p_249301_, p_251126_ + p_359514_.layers(), p_359514_.lookupWithUpdatedTags(), p_250212_, p_249301_, p_363739_, p_251126_ ); + List listeners = new java.util.ArrayList<>(reloadableserverresources.listeners()); -+ listeners.addAll(net.neoforged.neoforge.event.EventHooks.onResourceReload(reloadableserverresources, p_335211_.compositeAccess())); ++ listeners.addAll(net.neoforged.neoforge.event.EventHooks.onResourceReload(reloadableserverresources, p_359514_.layers().compositeAccess())); + listeners.forEach(rl -> { + if (rl instanceof net.neoforged.neoforge.resource.ContextAwareReloadListener srl) srl.injectContext(reloadableserverresources.context, reloadableserverresources.registryLookup); + }); @@ -48,26 +50,22 @@ + p_248588_, listeners, p_249136_, p_249601_, DATA_RELOAD_INITIAL_TASK, LOGGER.isDebugEnabled() ) .done() - .whenComplete( - (p_323178_, p_323179_) -> reloadableserverresources.registryLookup - .missingTagAccessPolicy(ReloadableServerResources.MissingTagAccessPolicy.FAIL) - ) + .thenRun(() -> { + // Clear context after reload completes ++ reloadableserverresources.context.clear(); + listeners.forEach(rl -> { + if (rl instanceof net.neoforged.neoforge.resource.ContextAwareReloadListener srl) { -+ srl.injectContext(net.neoforged.neoforge.common.conditions.ICondition.IContext.EMPTY, RegistryAccess.EMPTY); ++ srl.injectContext(net.neoforged.neoforge.common.conditions.ICondition.IContext.EMPTY, net.minecraft.core.RegistryAccess.EMPTY); + } + }); + }) .thenApply(p_214306_ -> reloadableserverresources); } ); -@@ -107,6 +_,7 @@ - this.tagManager.getResult().forEach(p_335204_ -> updateRegistryTags(this.fullRegistryHolder.get(), (TagManager.LoadResult)p_335204_)); - AbstractFurnaceBlockEntity.invalidateCache(); - Blocks.rebuildCache(); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.TagsUpdatedEvent(this.fullRegistryHolder.get(), false, false)); - } +@@ -94,5 +_,6 @@ - private static void updateRegistryTags(RegistryAccess p_206871_, TagManager.LoadResult p_206872_) { + public void updateStaticRegistryTags() { + this.postponedTags.forEach(Registry.PendingTags::apply); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.TagsUpdatedEvent(registryLookup, false, false)); + } + } diff --git a/patches/net/minecraft/server/ServerAdvancementManager.java.patch b/patches/net/minecraft/server/ServerAdvancementManager.java.patch deleted file mode 100644 index 2448b6d2a0..0000000000 --- a/patches/net/minecraft/server/ServerAdvancementManager.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/server/ServerAdvancementManager.java -+++ b/net/minecraft/server/ServerAdvancementManager.java -@@ -39,11 +_,15 @@ - } - - protected void apply(Map p_136034_, ResourceManager p_136035_, ProfilerFiller p_136036_) { -- RegistryOps registryops = this.registries.createSerializationContext(JsonOps.INSTANCE); -+ RegistryOps registryops = this.makeConditionalOps(); // Neo: add condition context - Builder builder = ImmutableMap.builder(); - p_136034_.forEach((p_337529_, p_337530_) -> { - try { -- Advancement advancement = Advancement.CODEC.parse(registryops, p_337530_).getOrThrow(JsonParseException::new); -+ Advancement advancement = net.neoforged.neoforge.common.conditions.ICondition.getWithWithConditionsCodec(Advancement.CONDITIONAL_CODEC, registryops, p_337530_).orElse(null); -+ if (advancement == null) { -+ LOGGER.debug("Skipping loading advancement {} as its conditions were not met", p_337529_); -+ return; -+ } - this.validate(p_337529_, advancement); - builder.put(p_337529_, new AdvancementHolder(p_337529_, advancement)); - } catch (Exception exception) { diff --git a/patches/net/minecraft/server/WorldLoader.java.patch b/patches/net/minecraft/server/WorldLoader.java.patch index 67180986ab..807b389724 100644 --- a/patches/net/minecraft/server/WorldLoader.java.patch +++ b/patches/net/minecraft/server/WorldLoader.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/WorldLoader.java +++ b/net/minecraft/server/WorldLoader.java -@@ -33,7 +_,7 @@ - CloseableResourceManager closeableresourcemanager = pair.getSecond(); - LayeredRegistryAccess layeredregistryaccess = RegistryLayer.createRegistryAccess(); - LayeredRegistryAccess layeredregistryaccess1 = loadAndReplaceLayer( -- closeableresourcemanager, layeredregistryaccess, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES -+ closeableresourcemanager, layeredregistryaccess, RegistryLayer.WORLDGEN, net.neoforged.neoforge.registries.DataPackRegistriesHooks.getDataPackRegistries() +@@ -41,7 +_,7 @@ ); - RegistryAccess.Frozen registryaccess$frozen = layeredregistryaccess1.getAccessForLoading(RegistryLayer.DIMENSIONS); - RegistryAccess.Frozen registryaccess$frozen1 = RegistryDataLoader.load( + RegistryAccess.Frozen registryaccess$frozen = layeredregistryaccess.getAccessForLoading(RegistryLayer.WORLDGEN); + List> list1 = TagLoader.buildUpdatedLookups(registryaccess$frozen, list); +- RegistryAccess.Frozen registryaccess$frozen1 = RegistryDataLoader.load(closeableresourcemanager, list1, RegistryDataLoader.WORLDGEN_REGISTRIES); ++ RegistryAccess.Frozen registryaccess$frozen1 = RegistryDataLoader.load(closeableresourcemanager, list1, net.neoforged.neoforge.registries.DataPackRegistriesHooks.getDataPackRegistries()); + List> list2 = Stream.concat(list1.stream(), registryaccess$frozen1.listRegistries()).toList(); + RegistryAccess.Frozen registryaccess$frozen2 = RegistryDataLoader.load(closeableresourcemanager, list2, RegistryDataLoader.DIMENSION_REGISTRIES); + WorldDataConfiguration worlddataconfiguration = pair.getFirst(); diff --git a/patches/net/minecraft/server/commands/SpreadPlayersCommand.java.patch b/patches/net/minecraft/server/commands/SpreadPlayersCommand.java.patch index 9f297b76ee..f61c49d353 100644 --- a/patches/net/minecraft/server/commands/SpreadPlayersCommand.java.patch +++ b/patches/net/minecraft/server/commands/SpreadPlayersCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/SpreadPlayersCommand.java +++ b/net/minecraft/server/commands/SpreadPlayersCommand.java -@@ -259,15 +_,22 @@ +@@ -259,16 +_,23 @@ spreadplayerscommand$position = p_138732_[i++]; } @@ -11,7 +11,8 @@ - (double)Mth.floor(spreadplayerscommand$position.z) + 0.5, - Set.of(), - entity.getYRot(), -- entity.getXRot() +- entity.getXRot(), +- true + net.neoforged.neoforge.event.entity.EntityTeleportEvent.SpreadPlayersCommand event = net.neoforged.neoforge.event.EventHooks.onEntityTeleportSpreadPlayersCommand(entity, + (double)Mth.floor(spreadplayerscommand$position.x) + 0.5, + spreadplayerscommand$position.getSpawnY(p_138731_, p_138733_), @@ -25,7 +26,8 @@ + event.getTargetZ(), + Set.of(), + entity.getYRot(), -+ entity.getXRot() ++ entity.getXRot(), ++ true + ); + } double d2 = Double.MAX_VALUE; diff --git a/patches/net/minecraft/server/commands/TeleportCommand.java.patch b/patches/net/minecraft/server/commands/TeleportCommand.java.patch index 2fe8f7c34f..70d1b71cd5 100644 --- a/patches/net/minecraft/server/commands/TeleportCommand.java.patch +++ b/patches/net/minecraft/server/commands/TeleportCommand.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/commands/TeleportCommand.java +++ b/net/minecraft/server/commands/TeleportCommand.java -@@ -270,6 +_,14 @@ +@@ -278,6 +_,14 @@ float p_139023_, - @Nullable TeleportCommand.LookAt p_139024_ + @Nullable LookAt p_380216_ ) throws CommandSyntaxException { + net.neoforged.neoforge.event.entity.EntityTeleportEvent.TeleportCommand event = net.neoforged.neoforge.event.EventHooks.onEntityTeleportCommand(p_139016_, p_139018_, p_139019_, p_139020_); + if (event.isCanceled()) { diff --git a/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch index fededefd4f..1085bf08f8 100644 --- a/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -80,6 +_,8 @@ +@@ -79,6 +_,8 @@ @Nullable private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker; private final ServerLinks serverLinks; @@ -9,7 +9,7 @@ public DedicatedServer( Thread p_214789_, -@@ -103,6 +_,7 @@ +@@ -102,6 +_,7 @@ Thread thread = new Thread("Server console handler") { @Override public void run() { @@ -17,7 +17,7 @@ BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); String s1; -@@ -185,11 +_,13 @@ +@@ -184,11 +_,13 @@ long i = Util.getNanos(); SkullBlockEntity.setup(this.services, this); GameProfileCache.setUsesAuthentication(this.usesAuthentication()); @@ -31,7 +31,7 @@ if (dedicatedserverproperties.announcePlayerAchievements != null) { this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS).set(dedicatedserverproperties.announcePlayerAchievements, this); } -@@ -217,6 +_,12 @@ +@@ -216,6 +_,12 @@ LOGGER.info("JMX monitoring enabled"); } @@ -44,7 +44,7 @@ return true; } } -@@ -295,6 +_,10 @@ +@@ -277,6 +_,10 @@ if (this.queryThreadGs4 != null) { this.queryThreadGs4.stop(); } @@ -55,7 +55,7 @@ } @Override -@@ -548,7 +_,12 @@ +@@ -530,7 +_,12 @@ @Override public void stopServer() { diff --git a/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch b/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch index f99e3d3db3..b9a564b407 100644 --- a/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch +++ b/patches/net/minecraft/server/dedicated/DedicatedServerProperties.java.patch @@ -8,4 +8,4 @@ + public final boolean onlineMode = this.get("online-mode", !net.minecraft.SharedConstants.IS_RUNNING_IN_IDE); public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false); public final String serverIp = this.get("server-ip", ""); - public final boolean spawnAnimals = this.get("spawn-animals", true); + public final boolean pvp = this.get("pvp", true); diff --git a/patches/net/minecraft/server/dedicated/ServerWatchdog.java.patch b/patches/net/minecraft/server/dedicated/ServerWatchdog.java.patch index 0068d1268c..4045f347c1 100644 --- a/patches/net/minecraft/server/dedicated/ServerWatchdog.java.patch +++ b/patches/net/minecraft/server/dedicated/ServerWatchdog.java.patch @@ -1,19 +1,41 @@ --- a/net/minecraft/server/dedicated/ServerWatchdog.java +++ b/net/minecraft/server/dedicated/ServerWatchdog.java -@@ -49,14 +_,14 @@ - ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean(); - ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true); - StringBuilder stringbuilder = new StringBuilder(); -- Error error = new Error("Watchdog"); -+ Error error = new Error(String.format(java.util.Locale.ENGLISH, "ServerHangWatchdog detected that a single server tick took %.2f seconds (should be max 0.05)", k / 1000F)); // Forge: don't just make a crash report with a seemingly-inexplicable Error +@@ -46,7 +_,13 @@ + String.format(Locale.ROOT, "%.2f", this.server.tickRateManager().millisecondsPerTick() / (float)TimeUtil.MILLISECONDS_PER_SECOND) + ); + LOGGER.error(LogUtils.FATAL_MARKER, "Considering it to be crashed, server will forcibly shutdown."); +- CrashReport crashreport = createWatchdogCrashReport("Watching Server", this.server.getRunningThread().threadId()); ++ // Neo: don't just make a crash report with a seemingly-inexplicable Error ++ String message = String.format( ++ Locale.ROOT, ++ "ServerWatchdog detected that a single server tick took %.2f seconds (should be max %.2f)", ++ (float)k / (float)TimeUtil.NANOSECONDS_PER_SECOND, ++ this.server.tickRateManager().millisecondsPerTick() / (float)TimeUtil.MILLISECONDS_PER_SECOND); ++ CrashReport crashreport = createWatchdogCrashReport("Watching Server", this.server.getRunningThread().threadId(), message); + this.server.fillSystemReport(crashreport.getSystemReport()); + CrashReportCategory crashreportcategory = crashreport.addCategory("Performance stats"); + crashreportcategory.setDetail( +@@ -77,17 +_,21 @@ + } - for (ThreadInfo threadinfo : athreadinfo) { - if (threadinfo.getThreadId() == this.server.getRunningThread().getId()) { - error.setStackTrace(threadinfo.getStackTrace()); - } + public static CrashReport createWatchdogCrashReport(String p_363165_, long p_364052_) { ++ return createWatchdogCrashReport(p_363165_, p_364052_, "Watchdog"); ++ } ++ ++ public static CrashReport createWatchdogCrashReport(String p_363165_, long p_364052_, String message) { + ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean(); + ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true); + StringBuilder stringbuilder = new StringBuilder(); +- Error error = new Error("Watchdog"); ++ Error error = new Error(message); -- stringbuilder.append(threadinfo); -+ stringbuilder.append(net.neoforged.neoforge.logging.ThreadInfoUtil.getEntireStacktrace(threadinfo)); - stringbuilder.append("\n"); - } + for (ThreadInfo threadinfo : athreadinfo) { + if (threadinfo.getThreadId() == p_364052_) { + error.setStackTrace(threadinfo.getStackTrace()); + } + +- stringbuilder.append(threadinfo); ++ stringbuilder.append(net.neoforged.neoforge.logging.ThreadInfoUtil.getEntireStacktrace(threadinfo)); + stringbuilder.append("\n"); + } diff --git a/patches/net/minecraft/server/level/ChunkMap.java.patch b/patches/net/minecraft/server/level/ChunkMap.java.patch index 947e62b315..d6dcc91909 100644 --- a/patches/net/minecraft/server/level/ChunkMap.java.patch +++ b/patches/net/minecraft/server/level/ChunkMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -395,6 +_,7 @@ +@@ -400,6 +_,7 @@ this.modified = true; } @@ -8,7 +8,7 @@ return p_140179_; } } -@@ -508,8 +_,11 @@ +@@ -529,8 +_,11 @@ } else { ChunkAccess chunkaccess = p_140183_.getLatestChunk(); if (this.pendingUnloads.remove(p_140182_, p_140183_) && chunkaccess != null) { @@ -20,15 +20,23 @@ } this.save(chunkaccess); -@@ -756,6 +_,7 @@ - - this.level.getProfiler().incrementCounter("chunkSave"); - CompoundTag compoundtag = ChunkSerializer.write(this.level, p_140259_); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkDataEvent.Save(p_140259_, p_140259_.getLevel() != null ? p_140259_.getLevel() : this.level, compoundtag)); - this.write(chunkpos, compoundtag).exceptionally(p_351776_ -> { - this.level.getServer().reportChunkSaveFailure(p_351776_, this.storageInfo(), chunkpos); - return null; -@@ -817,9 +_,11 @@ +@@ -579,6 +_,7 @@ + Profiler.get().incrementCounter("chunkLoad"); + if (p_372662_.isPresent()) { + ChunkAccess chunkaccess = p_372662_.get().read(this.level, this.poiManager, this.storageInfo(), p_140418_); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkDataEvent.Load(chunkaccess, p_372662_.get())); + this.markPosition(p_140418_, chunkaccess.getPersistedStatus().getChunkType()); + return chunkaccess; + } else { +@@ -780,6 +_,7 @@ + Profiler.get().incrementCounter("chunkSave"); + this.activeChunkWrites.incrementAndGet(); + SerializableChunkData serializablechunkdata = SerializableChunkData.copyOf(this.level, p_140259_); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkDataEvent.Save(p_140259_, this.level, serializablechunkdata)); + CompletableFuture completablefuture = CompletableFuture.supplyAsync(serializablechunkdata::write, Util.backgroundExecutor()); + this.write(chunkpos, completablefuture::join).handle((p_381690_, p_381691_) -> { + if (p_381691_ != null) { +@@ -846,9 +_,11 @@ private static void markChunkPendingToSend(ServerPlayer p_295834_, LevelChunk p_296281_) { p_295834_.connection.chunkSender.markChunkPendingToSend(p_296281_); @@ -40,7 +48,7 @@ p_294215_.connection.chunkSender.dropChunk(p_294215_, p_294758_); } -@@ -1018,6 +_,7 @@ +@@ -1059,6 +_,7 @@ this.playerMap.unIgnorePlayer(p_140185_); } @@ -48,7 +56,7 @@ this.updateChunkTracking(p_140185_); } } -@@ -1069,7 +_,7 @@ +@@ -1110,7 +_,7 @@ } protected void addEntity(Entity p_140200_) { @@ -57,7 +65,7 @@ EntityType entitytype = p_140200_.getType(); int i = entitytype.clientTrackingRange() * 16; if (i != 0) { -@@ -1313,5 +_,20 @@ +@@ -1354,5 +_,20 @@ this.updatePlayer(serverplayer); } } @@ -74,7 +82,7 @@ + * Use this method to schedule tasks for loading chunks in your whenCompleteAsync method call so the tasks gets processed properly over time and not leak. + * See {@link net.neoforged.neoforge.server.command.generation.GenerationTask#enqueueChunks} as an example usage of this method. + */ -+ public void scheduleOnMainThreadMailbox(ChunkTaskPriorityQueueSorter.Message msg) { -+ mainThreadMailbox.tell(msg); ++ public void scheduleOnMainThreadMailbox(Runnable runnable) { ++ mainThreadExecutor.schedule(runnable); } } diff --git a/patches/net/minecraft/server/level/DistanceManager.java.patch b/patches/net/minecraft/server/level/DistanceManager.java.patch index b2ff618cbf..fb0d048821 100644 --- a/patches/net/minecraft/server/level/DistanceManager.java.patch +++ b/patches/net/minecraft/server/level/DistanceManager.java.patch @@ -1,15 +1,14 @@ --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -54,6 +_,8 @@ +@@ -50,6 +_,7 @@ + final Executor mainThreadExecutor; private long ticketTickCounter; private int simulationDistance = 10; - + private final Long2ObjectOpenHashMap>> forcedTickets = new Long2ObjectOpenHashMap<>(); -+ + protected DistanceManager(Executor p_140774_, Executor p_140775_) { - ProcessorHandle processorhandle = ProcessorHandle.of("player ticket throttler", p_140775_::execute); - ChunkTaskPriorityQueueSorter chunktaskpriorityqueuesorter = new ChunkTaskPriorityQueueSorter(ImmutableList.of(processorhandle), p_140774_, 4); -@@ -152,6 +_,10 @@ + TaskScheduler taskscheduler = TaskScheduler.wrapExecutor("player ticket throttler", p_140775_); +@@ -150,6 +_,10 @@ if (p_140786_.getTicketLevel() < i) { this.ticketTracker.update(p_140785_, p_140786_.getTicketLevel(), true); } @@ -20,7 +19,7 @@ } void removeTicket(long p_140819_, Ticket p_140820_) { -@@ -164,6 +_,13 @@ +@@ -162,6 +_,13 @@ } this.ticketTracker.update(p_140819_, getTicketLevelAt(sortedarrayset), false); @@ -34,7 +33,7 @@ } public void addTicket(TicketType p_140793_, ChunkPos p_140794_, int p_140795_, T p_140796_) { -@@ -176,14 +_,20 @@ +@@ -174,14 +_,20 @@ } public void addRegionTicket(TicketType p_140841_, ChunkPos p_140842_, int p_140843_, T p_140844_) { @@ -57,10 +56,10 @@ long i = p_140851_.toLong(); this.removeTicket(i, ticket); this.tickingTicketsTracker.removeTicket(i, ticket); -@@ -267,6 +_,11 @@ +@@ -270,6 +_,11 @@ public String getDebugStatus() { - return this.ticketThrottler.getDebugStatus(); + return this.ticketDispatcher.getDebugStatus(); + } + + public boolean shouldForceTicks(long chunkPos) { diff --git a/patches/net/minecraft/server/level/GenerationChunkHolder.java.patch b/patches/net/minecraft/server/level/GenerationChunkHolder.java.patch index cf83f0dc4d..e34a1b6f11 100644 --- a/patches/net/minecraft/server/level/GenerationChunkHolder.java.patch +++ b/patches/net/minecraft/server/level/GenerationChunkHolder.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/level/GenerationChunkHolder.java +++ b/net/minecraft/server/level/GenerationChunkHolder.java -@@ -33,6 +_,7 @@ - private final AtomicReferenceArray>> futures = new AtomicReferenceArray<>(CHUNK_STATUSES.size()); +@@ -34,6 +_,7 @@ private final AtomicReference task = new AtomicReference<>(); private final AtomicInteger generationRefCount = new AtomicInteger(); + private volatile CompletableFuture generationSaveSyncFuture = CompletableFuture.completedFuture(null); + public net.minecraft.world.level.chunk.LevelChunk currentlyLoading; // Forge: Used to bypass future chain when loading chunks. public GenerationChunkHolder(ChunkPos p_347689_) { diff --git a/patches/net/minecraft/server/level/ServerChunkCache.java.patch b/patches/net/minecraft/server/level/ServerChunkCache.java.patch index a52a220bb9..d56419a092 100644 --- a/patches/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/patches/net/minecraft/server/level/ServerChunkCache.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -45,7 +_,7 @@ - import net.minecraft.world.level.storage.DimensionDataStorage; +@@ -52,7 +_,7 @@ import net.minecraft.world.level.storage.LevelStorageSource; + import org.slf4j.Logger; -public class ServerChunkCache extends ChunkSource { +public class ServerChunkCache extends ChunkSource implements net.neoforged.neoforge.common.extensions.IServerChunkCacheExtension { - private static final List CHUNK_STATUSES = ChunkStatus.getStatusList(); + private static final Logger LOGGER = LogUtils.getLogger(); private final DistanceManager distanceManager; public final ServerLevel level; -@@ -150,6 +_,10 @@ +@@ -165,6 +_,10 @@ } } @@ -20,7 +20,7 @@ profilerfiller.incrementCounter("getChunkCacheMiss"); CompletableFuture> completablefuture = this.getChunkFutureMainThread(p_8360_, p_8361_, p_330876_, p_8363_); this.mainThreadProcessor.managedBlock(completablefuture::isDone); -@@ -184,6 +_,7 @@ +@@ -199,6 +_,7 @@ if (chunkholder == null) { return null; } else { @@ -28,16 +28,16 @@ ChunkAccess chunkaccess1 = chunkholder.getChunkIfPresent(ChunkStatus.FULL); if (chunkaccess1 != null) { this.storeInCache(i, chunkaccess1, ChunkStatus.FULL); -@@ -356,7 +_,7 @@ - for (ServerChunkCache.ChunkAndHolder serverchunkcache$chunkandholder : list) { - LevelChunk levelchunk1 = serverchunkcache$chunkandholder.chunk; - ChunkPos chunkpos = levelchunk1.getPos(); -- if (this.level.isNaturalSpawningAllowed(chunkpos) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkpos)) { -+ if ((this.level.isNaturalSpawningAllowed(chunkpos) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkpos)) || this.distanceManager.shouldForceTicks(chunkpos.toLong())) { - levelchunk1.incrementInhabitedTime(j); - if (flag1 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkpos)) { - NaturalSpawner.spawnForChunk(this.level, levelchunk1, naturalspawner$spawnstate, this.spawnFriendlies, this.spawnEnemies, flag); -@@ -435,11 +_,17 @@ +@@ -384,7 +_,7 @@ + private void collectTickingChunks(List p_363421_) { + this.chunkMap.forEachSpawnCandidateChunk(p_381767_ -> { + LevelChunk levelchunk = p_381767_.getTickingChunk(); +- if (levelchunk != null && this.level.isNaturalSpawningAllowed(p_381767_.getPos())) { ++ if (levelchunk != null && this.level.isNaturalSpawningAllowed(p_381767_.getPos()) || this.distanceManager.shouldForceTicks(p_381767_.getPos().toLong())) { + p_363421_.add(levelchunk); + } + }); +@@ -480,11 +_,17 @@ } public void addRegionTicket(TicketType p_8388_, ChunkPos p_8389_, int p_8390_, T p_8391_) { diff --git a/patches/net/minecraft/server/level/ServerEntity.java.patch b/patches/net/minecraft/server/level/ServerEntity.java.patch index bdf1f7cbee..8df4830e9a 100644 --- a/patches/net/minecraft/server/level/ServerEntity.java.patch +++ b/patches/net/minecraft/server/level/ServerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -101,9 +_,9 @@ +@@ -104,9 +_,9 @@ if (this.entity instanceof ItemFrame itemframe && this.tickCount % 10 == 0) { ItemStack itemstack = itemframe.getItem(); @@ -12,7 +12,7 @@ if (mapitemsaveddata != null) { for (ServerPlayer serverplayer : this.level.players()) { mapitemsaveddata.tickCarriedBy(serverplayer, itemstack); -@@ -233,22 +_,25 @@ +@@ -274,22 +_,25 @@ public void removePairing(ServerPlayer p_8535_) { this.entity.stopSeenByPlayer(p_8535_); p_8535_.connection.send(new ClientboundRemoveEntitiesPacket(this.entity.getId())); diff --git a/patches/net/minecraft/server/level/ServerLevel.java.patch b/patches/net/minecraft/server/level/ServerLevel.java.patch index 411052eadc..64e787851b 100644 --- a/patches/net/minecraft/server/level/ServerLevel.java.patch +++ b/patches/net/minecraft/server/level/ServerLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -199,7 +_,7 @@ +@@ -202,7 +_,7 @@ private final List customSpawners; @Nullable private EndDragonFight dragonFight; @@ -9,15 +9,15 @@ private final StructureManager structureManager; private final StructureCheck structureCheck; private final boolean tickTime; -@@ -232,7 +_,6 @@ - ); +@@ -225,7 +_,6 @@ + super(p_215002_, p_215003_, p_214999_.registryAccess(), p_215004_.type(), false, p_215006_, p_215007_, p_214999_.getMaxChainedNeighborUpdates()); this.tickTime = p_215009_; this.server = p_214999_; - this.customSpawners = p_215008_; this.serverLevelData = p_215002_; ChunkGenerator chunkgenerator = p_215004_.generator(); boolean flag = p_214999_.forceSynchronousWrites(); -@@ -298,6 +_,11 @@ +@@ -291,6 +_,11 @@ this.randomSequences = Objects.requireNonNullElseGet( p_288977_, () -> this.getDataStorage().computeIfAbsent(RandomSequences.factory(i), "random_sequences") ); @@ -29,7 +29,7 @@ } @Deprecated -@@ -342,7 +_,7 @@ +@@ -336,7 +_,7 @@ if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { long j = this.levelData.getDayTime() + 24000L; @@ -38,7 +38,7 @@ } this.wakeUpAllPlayers(); -@@ -380,7 +_,7 @@ +@@ -374,7 +_,7 @@ this.handlingTick = false; profilerfiller.pop(); @@ -47,27 +47,27 @@ if (flag1) { this.resetEmptyTime(); } -@@ -412,7 +_,9 @@ - } +@@ -407,7 +_,9 @@ + } - profilerfiller.push("tick"); -- this.guardEntityTick(this::tickNonPassenger, p_308566_); -+ if (!p_308566_.isRemoved() && !(p_308566_ instanceof net.neoforged.neoforge.entity.PartEntity)) { -+ this.guardEntityTick(this::tickNonPassenger, p_308566_); -+ } - profilerfiller.pop(); - } - } -@@ -438,7 +_,7 @@ - this.serverLevelData.setGameTime(i); + profilerfiller.push("tick"); +- this.guardEntityTick(this::tickNonPassenger, p_359620_); ++ if (!p_359620_.isRemoved() && !(p_359620_ instanceof net.neoforged.neoforge.entity.PartEntity)) { ++ this.guardEntityTick(this::tickNonPassenger, p_359620_); ++ } + profilerfiller.pop(); + } + } +@@ -436,7 +_,7 @@ this.serverLevelData.getScheduledEvents().tick(this.server, i); - if (this.levelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { + Profiler.get().pop(); + if (this.serverLevelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { - this.setDayTime(this.levelData.getDayTime() + 1L); + this.setDayTime(this.levelData.getDayTime() + advanceDaytime()); } } } -@@ -542,6 +_,7 @@ +@@ -534,6 +_,7 @@ BlockPos blockpos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, p_295060_); BlockPos blockpos1 = blockpos.below(); Biome biome = this.getBiome(blockpos).value(); @@ -75,7 +75,7 @@ if (biome.shouldFreeze(this, blockpos1)) { this.setBlockAndUpdate(blockpos1, Blocks.ICE.defaultBlockState()); } -@@ -714,15 +_,19 @@ +@@ -706,15 +_,19 @@ .broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel), this.dimension()); } @@ -99,9 +99,9 @@ } } -@@ -758,7 +_,11 @@ +@@ -751,7 +_,11 @@ p_8648_.tickCount++; - this.getProfiler().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8648_.getType()).toString()); + profilerfiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_8648_.getType()).toString()); profilerfiller.incrementCounter("tickNonPassenger"); - p_8648_.tick(); + // Neo: Permit cancellation of Entity#tick via EntityTickEvent.Pre @@ -109,10 +109,10 @@ + p_8648_.tick(); + net.neoforged.neoforge.event.EventHooks.fireEntityTickPost(p_8648_); + } - this.getProfiler().pop(); + profilerfiller.pop(); for (Entity entity : p_8648_.getPassengers()) { -@@ -807,6 +_,7 @@ +@@ -800,6 +_,7 @@ } else { this.entityManager.autoSave(); } @@ -120,7 +120,7 @@ } } -@@ -896,6 +_,7 @@ +@@ -894,6 +_,7 @@ } private void addPlayer(ServerPlayer p_8854_) { @@ -128,7 +128,7 @@ Entity entity = this.getEntities().get(p_8854_.getUUID()); if (entity != null) { LOGGER.warn("Force-added player with duplicate UUID {}", p_8854_.getUUID()); -@@ -903,7 +_,8 @@ +@@ -901,7 +_,8 @@ this.removePlayerImmediately((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -138,7 +138,7 @@ } private boolean addEntity(Entity p_8873_) { -@@ -911,7 +_,12 @@ +@@ -909,7 +_,12 @@ LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityType.getKey(p_8873_.getType())); return false; } else { @@ -152,7 +152,7 @@ } } -@@ -959,6 +_,12 @@ +@@ -957,6 +_,12 @@ float p_263390_, long p_263403_ ) { @@ -165,7 +165,7 @@ this.server .getPlayerList() .broadcast( -@@ -976,6 +_,12 @@ +@@ -974,6 +_,12 @@ public void playSeededSound( @Nullable Player p_263545_, Entity p_263544_, Holder p_263491_, SoundSource p_263542_, float p_263530_, float p_263520_, long p_263490_ ) { @@ -178,7 +178,7 @@ this.server .getPlayerList() .broadcast( -@@ -1019,6 +_,7 @@ +@@ -1032,6 +_,7 @@ @Override public void gameEvent(Holder p_316597_, Vec3 p_215042_, GameEvent.Context p_215043_) { @@ -186,24 +186,43 @@ this.gameEventDispatcher.post(p_316597_, p_215042_, p_215043_); } -@@ -1057,11 +_,16 @@ +@@ -1070,6 +_,7 @@ @Override public void updateNeighborsAt(BlockPos p_215045_, Block p_215046_) { + net.neoforged.neoforge.event.EventHooks.onNeighborNotify(this, p_215045_, this.getBlockState(p_215045_), java.util.EnumSet.allOf(Direction.class), false).isCanceled(); - this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215045_, p_215046_, null); + this.updateNeighborsAt(p_215045_, p_215046_, ExperimentalRedstoneUtils.initialOrientation(this, null, null)); } +@@ -1080,6 +_,10 @@ + @Override - public void updateNeighborsAtExceptFromFacing(BlockPos p_215052_, Block p_215053_, Direction p_215054_) { + public void updateNeighborsAtExceptFromFacing(BlockPos p_215052_, Block p_215053_, Direction p_215054_, @Nullable Orientation p_365231_) { + java.util.EnumSet directions = java.util.EnumSet.allOf(Direction.class); + directions.remove(p_215054_); + if (net.neoforged.neoforge.event.EventHooks.onNeighborNotify(this, p_215052_, this.getBlockState(p_215052_), directions, false).isCanceled()) + return; - this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215052_, p_215053_, p_215054_); + this.neighborUpdater.updateNeighborsAtExceptFromFacing(p_215052_, p_215053_, p_215054_, p_365231_); } -@@ -1713,8 +_,8 @@ +@@ -1125,7 +_,7 @@ + Explosion.BlockInteraction explosion$blockinteraction = switch (p_255827_) { + case NONE -> Explosion.BlockInteraction.KEEP; + case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); +- case MOB -> this.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ case MOB -> net.neoforged.neoforge.event.EventHooks.canEntityGrief(this, p_256039_) + ? this.getDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) + : Explosion.BlockInteraction.KEEP; + case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); +@@ -1133,6 +_,7 @@ + }; + Vec3 vec3 = new Vec3(p_256067_, p_256370_, p_256153_); + ServerExplosion serverexplosion = new ServerExplosion(this, p_256039_, p_255778_, p_256002_, vec3, p_256045_, p_255686_, explosion$blockinteraction); ++ if (net.neoforged.neoforge.event.EventHooks.onExplosionStart(this, serverexplosion)) return; + serverexplosion.explode(); + ParticleOptions particleoptions = serverexplosion.isSmall() ? p_312436_ : p_312391_; + +@@ -1740,8 +_,8 @@ ServerLevel.this.navigatingMobs.add(mob); } @@ -214,7 +233,7 @@ ServerLevel.this.dragonParts.put(enderdragonpart.getId(), enderdragonpart); } } -@@ -1733,24 +_,106 @@ +@@ -1760,24 +_,106 @@ if (ServerLevel.this.isUpdatingNavigations) { String s = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( diff --git a/patches/net/minecraft/server/level/ServerPlayer.java.patch b/patches/net/minecraft/server/level/ServerPlayer.java.patch index 9ead220877..a0e3dd567a 100644 --- a/patches/net/minecraft/server/level/ServerPlayer.java.patch +++ b/patches/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 -@@ -252,6 +_,10 @@ +@@ -278,6 +_,10 @@ } private void broadcastDataValue(AbstractContainerMenu p_143455_, int p_143456_, int p_143457_) { @@ -11,7 +11,7 @@ ServerPlayer.this.connection.send(new ClientboundContainerSetDataPacket(p_143455_.containerId, p_143456_, p_143457_)); } }; -@@ -606,6 +_,11 @@ +@@ -768,6 +_,11 @@ this.connection.send(new ClientboundSetExperiencePacket(this.experienceProgress, this.totalExperience, this.experienceLevel)); } @@ -23,15 +23,15 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } -@@ -657,6 +_,7 @@ +@@ -850,6 +_,7 @@ @Override public void die(DamageSource p_9035_) { this.gameEvent(GameEvent.ENTITY_DIE); + if (net.neoforged.neoforge.common.CommonHooks.onLivingDeath(this, p_9035_)) return; - boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); + boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); if (flag) { Component component = this.getCombatTracker().getDeathMessage(); -@@ -826,7 +_,7 @@ +@@ -1019,7 +_,7 @@ return BedBlock.findStandUpPosition(EntityType.PLAYER, p_348505_, p_348607_, blockstate.getValue(BedBlock.FACING), p_348481_) .map(p_348148_ -> ServerPlayer.RespawnPosAngle.of(p_348148_, p_348607_)); } else if (!p_348513_) { @@ -40,37 +40,37 @@ } else { boolean flag = block.isPossibleToRespawnInThis(blockstate); BlockState blockstate1 = p_348505_.getBlockState(p_348607_.above()); -@@ -854,6 +_,7 @@ +@@ -1046,6 +_,7 @@ + @Nullable - @Override - public Entity changeDimension(DimensionTransition p_350472_) { -+ if (!net.neoforged.neoforge.common.CommonHooks.onTravelToDimension(this, p_350472_.newLevel().dimension())) return null; + public ServerPlayer teleport(TeleportTransition p_379854_) { ++ if (!net.neoforged.neoforge.common.CommonHooks.onTravelToDimension(this, p_379854_.newLevel().dimension())) return null; if (this.isRemoved()) { return null; } else { -@@ -877,7 +_,7 @@ +@@ -1073,7 +_,7 @@ PlayerList playerlist = this.server.getPlayerList(); playerlist.sendPlayerPermissionLevel(this); serverlevel1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); - this.unsetRemoved(); + this.revive(); - serverlevel1.getProfiler().push("moving"); + ProfilerFiller profilerfiller = Profiler.get(); + profilerfiller.push("moving"); if (resourcekey == Level.OVERWORLD && serverlevel.dimension() == Level.NETHER) { - this.enteredNetherPosition = this.position(); -@@ -895,10 +_,12 @@ +@@ -1093,10 +_,12 @@ playerlist.sendLevelInfo(this, serverlevel); playerlist.sendAllPlayerInfo(this); playerlist.sendActivePlayerEffects(this); + // TODO 1.21: Play custom teleport sound - p_350472_.postDimensionTransition().onTransition(this); + p_379854_.postTeleportTransition().onTransition(this); this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; -+ net.neoforged.neoforge.event.EventHooks.firePlayerChangedDimensionEvent(this, resourcekey, p_350472_.newLevel().dimension()); ++ net.neoforged.neoforge.event.EventHooks.firePlayerChangedDimensionEvent(this, resourcekey, p_379854_.newLevel().dimension()); return this; } } -@@ -934,6 +_,15 @@ +@@ -1137,6 +_,15 @@ @Override public Either startSleepInBed(BlockPos p_9115_) { @@ -86,7 +86,7 @@ Direction direction = this.level().getBlockState(p_9115_).getValue(HorizontalDirectionalBlock.FACING); if (this.isSleeping() || !this.isAlive()) { return Either.left(Player.BedSleepingProblem.OTHER_PROBLEM); -@@ -962,7 +_,21 @@ +@@ -1165,7 +_,21 @@ return Either.left(Player.BedSleepingProblem.NOT_SAFE); } } @@ -109,7 +109,7 @@ Either either = super.startSleepInBed(p_9115_).ifRight(p_9029_ -> { this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); -@@ -984,6 +_,7 @@ +@@ -1187,6 +_,7 @@ } private boolean bedInRange(BlockPos p_9117_, Direction p_9118_) { @@ -117,7 +117,7 @@ return this.isReachableBedBlock(p_9117_) || this.isReachableBedBlock(p_9117_.relative(p_9118_.getOpposite())); } -@@ -1074,11 +_,19 @@ +@@ -1277,11 +_,19 @@ @Override public OptionalInt openMenu(@Nullable MenuProvider p_9033_) { @@ -137,7 +137,7 @@ } this.nextContainerCounter(); -@@ -1090,10 +_,16 @@ +@@ -1293,10 +_,16 @@ return OptionalInt.empty(); } else { @@ -154,7 +154,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1115,6 +_,7 @@ +@@ -1318,6 +_,7 @@ this.connection.send(new ClientboundHorseScreenOpenPacket(this.containerCounter, i, p_9059_.getId())); this.containerMenu = new HorseInventoryMenu(this.containerCounter, this.getInventory(), p_9060_, p_9059_, i); this.initMenu(this.containerMenu); @@ -162,7 +162,7 @@ } @Override -@@ -1143,6 +_,7 @@ +@@ -1346,6 +_,7 @@ public void doCloseContainer() { this.containerMenu.removed(this); this.inventoryMenu.transferState(this.containerMenu); @@ -170,7 +170,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -1375,6 +_,15 @@ +@@ -1569,6 +_,15 @@ this.setShoulderEntityLeft(p_9016_.getShoulderEntityLeft()); this.setShoulderEntityRight(p_9016_.getShoulderEntityRight()); this.setLastDeathLocation(p_9016_.getLastDeathLocation()); @@ -186,7 +186,7 @@ } @Override -@@ -1469,6 +_,8 @@ +@@ -1674,6 +_,8 @@ public boolean setGameMode(GameType p_143404_) { boolean flag = this.isSpectator(); @@ -195,15 +195,15 @@ if (!this.gameMode.changeGameModeForPlayer(p_143404_)) { return false; } else { -@@ -1617,6 +_,7 @@ +@@ -1848,6 +_,7 @@ public void setCamera(@Nullable Entity p_9214_) { Entity entity = this.getCamera(); this.camera = (Entity)(p_9214_ == null ? this : p_9214_); + while (this.camera instanceof net.neoforged.neoforge.entity.PartEntity partEntity) this.camera = partEntity.getParent(); // Neo: fix MC-46486 if (entity != this.camera) { if (this.camera.level() instanceof ServerLevel serverlevel) { - this.teleportTo(serverlevel, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot()); -@@ -1653,7 +_,11 @@ + this.teleportTo(serverlevel, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot(), false); +@@ -1884,7 +_,11 @@ @Nullable public Component getTabListDisplayName() { @@ -215,8 +215,8 @@ + return this.tabListDisplayName; } - @Override -@@ -1710,6 +_,7 @@ + public int getTabListOrder() { +@@ -1933,6 +_,7 @@ } public void setRespawnPosition(ResourceKey p_9159_, @Nullable BlockPos p_9160_, float p_9161_, boolean p_9162_, boolean p_9163_) { @@ -224,7 +224,7 @@ if (p_9160_ != null) { boolean flag = p_9160_.equals(this.respawnPosition) && p_9159_.equals(this.respawnDimension); if (p_9163_ && !flag) { -@@ -1767,6 +_,8 @@ +@@ -1990,6 +_,8 @@ if (itementity == null) { return null; } else { @@ -233,7 +233,7 @@ this.level().addFreshEntity(itementity); ItemStack itemstack = itementity.getItem(); if (p_9087_) { -@@ -1781,6 +_,75 @@ +@@ -2039,6 +_,75 @@ } } @@ -309,7 +309,7 @@ public TextFilter getTextFilter() { return this.textFilter; } -@@ -1841,9 +_,12 @@ +@@ -2099,9 +_,12 @@ public boolean drop(boolean p_182295_) { Inventory inventory = this.getInventory(); @@ -322,13 +322,4 @@ + return net.neoforged.neoforge.common.CommonHooks.onPlayerTossEvent(this, itemstack, true) != null; } - public boolean allowsListing() { -@@ -1958,7 +_,7 @@ - this.awardStat(Stats.ITEM_BROKEN.get(p_348565_)); - } - -- static record RespawnPosAngle(Vec3 position, float yaw) { -+ public static record RespawnPosAngle(Vec3 position, float yaw) { - public static ServerPlayer.RespawnPosAngle of(Vec3 p_348670_, BlockPos p_348504_) { - return new ServerPlayer.RespawnPosAngle(p_348670_, calculateLookAtYaw(p_348670_, p_348504_)); - } + @Override diff --git a/patches/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 82bca3b23f..1d50dd049e 100644 --- a/patches/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/patches/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -72,7 +_,10 @@ +@@ -70,7 +_,10 @@ protected void setGameModeForPlayer(GameType p_9274_, @Nullable GameType p_9275_) { this.previousGameModeForPlayer = p_9275_; this.gameModeForPlayer = p_9274_; @@ -11,7 +11,7 @@ } public GameType getGameModeForPlayer() { -@@ -133,6 +_,10 @@ +@@ -131,6 +_,10 @@ } public void handleBlockBreakAction(BlockPos p_215120_, ServerboundPlayerActionPacket.Action p_215121_, Direction p_215122_, int p_215123_, int p_215124_) { @@ -21,8 +21,8 @@ + } if (!this.player.canInteractWithBlock(p_215120_, 1.0)) { this.debugLogging(p_215120_, false, p_215124_, "too far"); - } else if (p_215120_.getY() >= p_215123_) { -@@ -171,6 +_,7 @@ + } else if (p_215120_.getY() > p_215123_) { +@@ -169,6 +_,7 @@ blockstate, p_348149_ -> this.player.onEquippedItemBroken(p_348149_, EquipmentSlot.MAINHAND) ); @@ -30,7 +30,7 @@ blockstate.attack(this.level, p_215120_, this.player); f = blockstate.getDestroyProgress(this.player, this.player.level(), p_215120_); } -@@ -238,7 +_,8 @@ +@@ -236,7 +_,8 @@ public boolean destroyBlock(BlockPos p_9281_) { BlockState blockstate1 = this.level.getBlockState(p_9281_); @@ -40,7 +40,7 @@ return false; } else { BlockEntity blockentity = this.level.getBlockEntity(p_9281_); -@@ -250,26 +_,45 @@ +@@ -248,26 +_,45 @@ return false; } else { BlockState blockstate = block.playerWillDestroy(this.level, p_9281_, blockstate1, this.player); @@ -91,16 +91,16 @@ } public InteractionResult useItem(ServerPlayer p_9262_, Level p_9263_, ItemStack p_9264_, InteractionHand p_9265_) { -@@ -278,6 +_,8 @@ - } else if (p_9262_.getCooldowns().isOnCooldown(p_9264_.getItem())) { +@@ -276,6 +_,8 @@ + } else if (p_9262_.getCooldowns().isOnCooldown(p_9264_)) { return InteractionResult.PASS; } else { + InteractionResult cancelResult = net.neoforged.neoforge.common.CommonHooks.onItemRightClick(p_9262_, p_9265_); + if (cancelResult != null) return cancelResult; int i = p_9264_.getCount(); int j = p_9264_.getDamageValue(); - InteractionResultHolder interactionresultholder = p_9264_.use(p_9263_, p_9262_, p_9265_); -@@ -309,7 +_,10 @@ + InteractionResult interactionresult = p_9264_.use(p_9263_, p_9262_, p_9265_); +@@ -313,7 +_,10 @@ BlockState blockstate = p_9267_.getBlockState(blockpos); if (!blockstate.getBlock().isEnabled(p_9267_.enabledFeatures())) { return InteractionResult.FAIL; @@ -112,7 +112,7 @@ MenuProvider menuprovider = blockstate.getMenuProvider(p_9267_, blockpos); if (menuprovider != null) { p_9266_.openMenu(menuprovider); -@@ -318,10 +_,15 @@ +@@ -322,10 +_,15 @@ return InteractionResult.PASS; } } else { @@ -127,17 +127,17 @@ ItemStack itemstack = p_9268_.copy(); - if (!flag1) { + if (event.getUseBlock().isTrue() || (event.getUseBlock().isDefault() && !flag1)) { - ItemInteractionResult iteminteractionresult = blockstate.useItemOn(p_9266_.getItemInHand(p_9269_), p_9267_, p_9266_, p_9269_, p_9270_); - if (iteminteractionresult.consumesAction()) { + InteractionResult interactionresult = blockstate.useItemOn(p_9266_.getItemInHand(p_9269_), p_9267_, p_9266_, p_9269_, p_9270_); + if (interactionresult.consumesAction()) { CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(p_9266_, blockpos, itemstack); -@@ -337,8 +_,8 @@ +@@ -341,8 +_,8 @@ } } -- if (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_.getItem())) { +- if (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_)) { - UseOnContext useoncontext = new UseOnContext(p_9266_, p_9269_, p_9270_); -+ if (event.getUseItem().isTrue() || (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_.getItem()))) { ++ if (event.getUseItem().isTrue() || (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_))) { + if (event.getUseItem().isFalse()) return InteractionResult.PASS; - InteractionResult interactionresult1; + InteractionResult interactionresult2; if (this.isCreative()) { int i = p_9268_.getCount(); diff --git a/patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch b/patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch index bc534702f9..0754746778 100644 --- a/patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch +++ b/patches/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -42,6 +_,10 @@ +@@ -43,6 +_,10 @@ private boolean closed = false; private int latency; private volatile boolean suspendFlushingOnServerThread = false; @@ -11,7 +11,7 @@ public ServerCommonPacketListenerImpl(MinecraftServer p_295057_, Connection p_294822_, CommonListenerCookie p_301980_) { this.server = p_295057_; -@@ -49,6 +_,8 @@ +@@ -50,6 +_,8 @@ this.keepAliveTime = Util.getMillis(); this.latency = p_301980_.latency(); this.transferred = p_301980_.transferred(); @@ -20,7 +20,7 @@ } private void close() { -@@ -83,6 +_,32 @@ +@@ -90,6 +_,32 @@ @Override public void handleCustomPayload(ServerboundCustomPayloadPacket p_294276_) { @@ -53,7 +53,7 @@ } @Override -@@ -141,7 +_,10 @@ +@@ -148,7 +_,10 @@ this.send(p_294278_, null); } @@ -64,7 +64,7 @@ if (p_295099_.isTerminal()) { this.close(); } -@@ -183,7 +_,41 @@ +@@ -190,7 +_,41 @@ return this.latency; } diff --git a/patches/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/patches/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 303149aeec..74247bc5af 100644 --- a/patches/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/patches/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -12,7 +12,7 @@ this.send(new ClientboundMoveVehiclePacket(entity)); return; } -@@ -462,6 +_,23 @@ +@@ -463,6 +_,23 @@ } } @@ -36,7 +36,7 @@ private boolean noBlocksAround(Entity p_9794_) { return p_9794_.level() .getBlockStates(p_9794_.getBoundingBox().inflate(0.0625).expandTowards(0.0, -0.55, 0.0)) -@@ -927,7 +_,7 @@ +@@ -930,7 +_,7 @@ && !flag1 && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR && !this.server.isFlightAllowed() @@ -45,7 +45,7 @@ && !this.player.hasEffect(MobEffects.LEVITATION) && !flag && !flag3 -@@ -1031,8 +_,10 @@ +@@ -1041,8 +_,10 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { ItemStack itemstack = this.player.getItemInHand(InteractionHand.OFF_HAND); @@ -58,16 +58,16 @@ this.player.stopUsingItem(); } -@@ -1060,7 +_,7 @@ +@@ -1070,7 +_,7 @@ .handleBlockBreakAction( - blockpos, serverboundplayeractionpacket$action, p_9889_.getDirection(), this.player.level().getMaxBuildHeight(), p_9889_.getSequence() + blockpos, serverboundplayeractionpacket$action, p_9889_.getDirection(), this.player.level().getMaxY(), p_9889_.getSequence() ); - this.player.connection.ackBlockChangesUpTo(p_9889_.getSequence()); + this.player.connection.ackBlockChangesUpTo =p_9889_.getSequence(); return; default: throw new IllegalArgumentException("Invalid player action"); -@@ -1079,7 +_,7 @@ +@@ -1089,7 +_,7 @@ @Override public void handleUseItemOn(ServerboundUseItemOnPacket p_9930_) { PacketUtils.ensureRunningOnSameThread(p_9930_, this, this.player.serverLevel()); @@ -76,7 +76,7 @@ ServerLevel serverlevel = this.player.serverLevel(); InteractionHand interactionhand = p_9930_.getHand(); ItemStack itemstack = this.player.getItemInHand(interactionhand); -@@ -1231,8 +_,9 @@ +@@ -1242,8 +_,9 @@ } CompletableFuture completablefuture = this.filterTextPacket(playerchatmessage.signedContent()); @@ -87,7 +87,7 @@ PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent(component).filter(p_300785_.mask()); this.broadcastChatMessage(playerchatmessage1); }); -@@ -1561,7 +_,11 @@ +@@ -1569,7 +_,11 @@ @Override public void onInteraction(InteractionHand p_143682_, Vec3 p_143683_) { @@ -100,7 +100,7 @@ } @Override -@@ -1753,13 +_,15 @@ +@@ -1785,13 +_,15 @@ @Override public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket p_9887_) { PacketUtils.ensureRunningOnSameThread(p_9887_, this, this.player.serverLevel()); @@ -117,7 +117,7 @@ } @Override -@@ -1812,7 +_,7 @@ +@@ -1844,7 +_,7 @@ this.connection .setupInboundProtocol( ConfigurationProtocols.SERVERBOUND, @@ -126,7 +126,7 @@ ); } } -@@ -1847,6 +_,7 @@ +@@ -1879,6 +_,7 @@ @Override public void handleCustomPayload(ServerboundCustomPayloadPacket p_333887_) { diff --git a/patches/net/minecraft/server/packs/repository/PackRepository.java.patch b/patches/net/minecraft/server/packs/repository/PackRepository.java.patch index ded59feb90..fce53d7223 100644 --- a/patches/net/minecraft/server/packs/repository/PackRepository.java.patch +++ b/patches/net/minecraft/server/packs/repository/PackRepository.java.patch @@ -25,7 +25,7 @@ } return ImmutableMap.copyOf(map); -@@ -77,11 +_,12 @@ +@@ -82,11 +_,12 @@ } public List rebuildSelected(Collection p_10518_) { @@ -40,7 +40,7 @@ } } -@@ -93,7 +_,7 @@ +@@ -98,7 +_,7 @@ } public Collection getAvailableIds() { @@ -49,7 +49,7 @@ } public Collection getAvailablePacks() { -@@ -101,7 +_,7 @@ +@@ -106,7 +_,7 @@ } public Collection getSelectedIds() { @@ -58,7 +58,7 @@ } public FeatureFlagSet getRequestedFeatureFlags() { -@@ -115,6 +_,10 @@ +@@ -120,6 +_,10 @@ @Nullable public Pack getPack(String p_10508_) { return this.available.get(p_10508_); diff --git a/patches/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch b/patches/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch index 00214f465c..3745422f2c 100644 --- a/patches/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch +++ b/patches/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java.patch @@ -1,11 +1,42 @@ --- a/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java +++ b/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java -@@ -49,4 +_,8 @@ +@@ -41,13 +_,15 @@ + + protected Map prepare(ResourceManager p_10771_, ProfilerFiller p_10772_) { + Map map = new HashMap<>(); +- scanDirectory(p_10771_, this.directory, this.ops, this.codec, map); ++ // Neo: add condition context ++ scanDirectory(p_10771_, this.directory, this.makeConditionalOps(), this.codec, map); + return map; + } + + public static void scanDirectory( + ResourceManager p_279308_, String p_279131_, DynamicOps p_371830_, Codec p_371493_, Map p_279404_ + ) { ++ var conditionalCodec = net.neoforged.neoforge.common.conditions.ConditionalOps.createConditionalCodec(p_371493_); + FileToIdConverter filetoidconverter = FileToIdConverter.json(p_279131_); + + for (Entry entry : filetoidconverter.listMatchingResources(p_279308_).entrySet()) { +@@ -55,8 +_,10 @@ + ResourceLocation resourcelocation1 = filetoidconverter.fileToId(resourcelocation); + + try (Reader reader = entry.getValue().openAsReader()) { +- p_371493_.parse(p_371830_, JsonParser.parseReader(reader)).ifSuccess(p_371454_ -> { +- if (p_279404_.putIfAbsent(resourcelocation1, (T)p_371454_) != null) { ++ conditionalCodec.parse(p_371830_, JsonParser.parseReader(reader)).ifSuccess(p_371454_ -> { ++ if (p_371454_.isEmpty()) { ++ LOGGER.debug("Skipping loading data file '{}' from '{}' as its conditions were not met", resourcelocation1, resourcelocation); ++ } else if (p_279404_.putIfAbsent(resourcelocation1, p_371454_.get()) != null) { + throw new IllegalStateException("Duplicate data file ignored with ID " + resourcelocation1); + } + }).ifError(p_371566_ -> LOGGER.error("Couldn't parse data file '{}' from '{}': {}", resourcelocation1, resourcelocation, p_371566_)); +@@ -64,5 +_,9 @@ + LOGGER.error("Couldn't parse data file '{}' from '{}'", resourcelocation1, resourcelocation, jsonparseexception); } } - } ++ } + + protected ResourceLocation getPreparedPath(ResourceLocation rl) { + return rl.withPath(this.directory + "/" + rl.getPath() + ".json"); -+ } + } } diff --git a/patches/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java.patch b/patches/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java.patch index 2d1ba1e6ae..afdb34f2fe 100644 --- a/patches/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java.patch +++ b/patches/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java +++ b/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java -@@ -4,7 +_,7 @@ - import java.util.concurrent.Executor; +@@ -5,7 +_,7 @@ + import net.minecraft.util.profiling.Profiler; import net.minecraft.util.profiling.ProfilerFiller; -public abstract class SimplePreparableReloadListener implements PreparableReloadListener { +public abstract class SimplePreparableReloadListener extends net.neoforged.neoforge.resource.ContextAwareReloadListener implements PreparableReloadListener { @Override public final CompletableFuture reload( - PreparableReloadListener.PreparationBarrier p_10780_, + PreparableReloadListener.PreparationBarrier p_10780_, ResourceManager p_10781_, Executor p_10784_, Executor p_10785_ diff --git a/patches/net/minecraft/server/players/PlayerList.java.patch b/patches/net/minecraft/server/players/PlayerList.java.patch index 1e598eb735..a3c0ab6718 100644 --- a/patches/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/net/minecraft/server/players/PlayerList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -128,6 +_,7 @@ +@@ -129,6 +_,7 @@ private boolean allowCommandsForAllPlayers; private static final boolean ALLOW_LOGOUTIVATOR = false; private int sendAllPlayerInfoIn; @@ -8,7 +8,7 @@ public PlayerList(MinecraftServer p_203842_, LayeredRegistryAccess p_251844_, PlayerDataStorage p_203844_, int p_203845_) { this.server = p_203842_; -@@ -177,7 +_,7 @@ +@@ -178,7 +_,7 @@ p_11263_.loadGameTypes(optional1.orElse(null)); ServerGamePacketListenerImpl servergamepacketlistenerimpl = new ServerGamePacketListenerImpl(this.server, p_11262_, p_11263_, p_301988_); p_11262_.setupInboundProtocol( @@ -17,23 +17,23 @@ ); GameRules gamerules = serverlevel1.getGameRules(); boolean flag = gamerules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN); -@@ -201,6 +_,7 @@ +@@ -202,6 +_,7 @@ servergamepacketlistenerimpl.send(new ClientboundChangeDifficultyPacket(leveldata.getDifficulty(), leveldata.isDifficultyLocked())); servergamepacketlistenerimpl.send(new ClientboundPlayerAbilitiesPacket(p_11263_.getAbilities())); - servergamepacketlistenerimpl.send(new ClientboundSetCarriedItemPacket(p_11263_.getInventory().selected)); + servergamepacketlistenerimpl.send(new ClientboundSetHeldSlotPacket(p_11263_.getInventory().selected)); + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.OnDatapackSyncEvent(this, p_11263_)); - servergamepacketlistenerimpl.send(new ClientboundUpdateRecipesPacket(this.server.getRecipeManager().getOrderedRecipes())); - this.sendPlayerPermissionLevel(p_11263_); - p_11263_.getStats().markAllDirty(); -@@ -265,6 +_,7 @@ - } - + RecipeManager recipemanager = this.server.getRecipeManager(); + servergamepacketlistenerimpl.send( + new ClientboundUpdateRecipesPacket(recipemanager.getSynchronizedItemProperties(), recipemanager.getSynchronizedStonecutterRecipes()) +@@ -236,6 +_,7 @@ + p_11263_.loadAndSpawnEnderpearls(optional1); + p_11263_.loadAndSpawnParentVehicle(optional1); p_11263_.initInventoryMenu(); + net.neoforged.neoforge.event.EventHooks.firePlayerLoggedIn( p_11263_ ); } protected void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) { -@@ -330,6 +_,7 @@ +@@ -301,6 +_,7 @@ optional = Optional.of(compoundtag); p_11225_.load(compoundtag); LOGGER.debug("loading single player"); @@ -41,7 +41,7 @@ } else { optional = this.playerIo.load(p_11225_); } -@@ -338,6 +_,7 @@ +@@ -309,6 +_,7 @@ } protected void save(ServerPlayer p_11277_) { @@ -49,7 +49,7 @@ this.playerIo.save(p_11277_); ServerStatsCounter serverstatscounter = this.stats.get(p_11277_.getUUID()); if (serverstatscounter != null) { -@@ -351,6 +_,7 @@ +@@ -322,6 +_,7 @@ } public void remove(ServerPlayer p_11287_) { @@ -57,37 +57,37 @@ ServerLevel serverlevel = p_11287_.serverLevel(); p_11287_.awardStat(Stats.LEAVE_GAME); this.save(p_11287_); -@@ -440,13 +_,20 @@ +@@ -416,13 +_,20 @@ this.players.remove(p_11237_); p_11237_.serverLevel().removePlayerImmediately(p_11237_, p_348558_); - DimensionTransition dimensiontransition = p_11237_.findRespawnPositionAndUseSpawnBlock(p_11238_, DimensionTransition.DO_NOTHING); + TeleportTransition teleporttransition = p_11237_.findRespawnPositionAndUseSpawnBlock(!p_11238_, TeleportTransition.DO_NOTHING); + + // Neo: Allow changing the respawn position of players. The local dimension transition is updated with the new target. -+ var event = net.neoforged.neoforge.event.EventHooks.firePlayerRespawnPositionEvent(p_11237_, dimensiontransition, p_11238_); -+ dimensiontransition = event.getDimensionTransition(); ++ var event = net.neoforged.neoforge.event.EventHooks.firePlayerRespawnPositionEvent(p_11237_, teleporttransition, p_11238_); ++ teleporttransition = event.getTeleportTransition(); + - ServerLevel serverlevel = dimensiontransition.newLevel(); + ServerLevel serverlevel = teleporttransition.newLevel(); ServerPlayer serverplayer = new ServerPlayer(this.server, serverlevel, p_11237_.getGameProfile(), p_11237_.clientInformation()); serverplayer.connection = p_11237_.connection; serverplayer.restoreFrom(p_11237_, p_11238_); serverplayer.setId(p_11237_.getId()); serverplayer.setMainArm(p_11237_.getMainArm()); -- if (!dimensiontransition.missingRespawnBlock()) { +- if (!teleporttransition.missingRespawnBlock()) { + + // Neo: Allow the event to control if the original spawn position is copied + if (event.copyOriginalSpawnPosition()) { serverplayer.copyRespawnPosition(p_11237_); } -@@ -477,6 +_,7 @@ +@@ -453,6 +_,7 @@ this.playersByUUID.put(serverplayer.getUUID(), serverplayer); serverplayer.initInventoryMenu(); serverplayer.setHealth(serverplayer.getHealth()); + net.neoforged.neoforge.event.EventHooks.firePlayerRespawnEvent(serverplayer, p_11238_); - if (!p_11238_) { - BlockPos blockpos = BlockPos.containing(dimensiontransition.pos()); - BlockState blockstate = serverlevel.getBlockState(blockpos); -@@ -582,6 +_,7 @@ + BlockPos blockpos = serverplayer.getRespawnPosition(); + ServerLevel serverlevel2 = this.server.getLevel(serverplayer.getRespawnDimension()); + if (!p_11238_ && blockpos != null && serverlevel2 != null) { +@@ -559,6 +_,7 @@ } public void op(GameProfile p_11254_) { @@ -95,7 +95,7 @@ this.ops.add(new ServerOpListEntry(p_11254_, this.server.getOperatorUserPermissionLevel(), this.ops.canBypassPlayerLimit(p_11254_))); ServerPlayer serverplayer = this.getPlayer(p_11254_.getId()); if (serverplayer != null) { -@@ -590,6 +_,7 @@ +@@ -567,6 +_,7 @@ } public void deop(GameProfile p_11281_) { @@ -103,7 +103,7 @@ this.ops.remove(p_11281_); ServerPlayer serverplayer = this.getPlayer(p_11281_.getId()); if (serverplayer != null) { -@@ -682,8 +_,12 @@ +@@ -659,8 +_,12 @@ public void sendLevelInfo(ServerPlayer p_11230_, ServerLevel p_11231_) { WorldBorder worldborder = this.server.overworld().getWorldBorder(); p_11230_.connection.send(new ClientboundInitializeBorderPacket(worldborder)); @@ -116,7 +116,7 @@ p_11230_.connection.send(new ClientboundSetDefaultSpawnPositionPacket(p_11231_.getSharedSpawnPos(), p_11231_.getSharedSpawnAngle())); if (p_11231_.isRaining()) { p_11230_.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); -@@ -808,13 +_,6 @@ +@@ -785,13 +_,6 @@ if (serverstatscounter == null) { File file1 = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR).toFile(); File file2 = new File(file1, uuid + ".json"); @@ -130,7 +130,7 @@ serverstatscounter = new ServerStatsCounter(this.server, file2); this.stats.put(uuid, serverstatscounter); -@@ -832,6 +_,8 @@ +@@ -809,6 +_,8 @@ this.advancements.put(uuid, playeradvancements); } @@ -139,7 +139,7 @@ playeradvancements.setPlayer(p_11297_); return playeradvancements; } -@@ -859,7 +_,7 @@ +@@ -836,7 +_,7 @@ } public List getPlayers() { @@ -148,11 +148,11 @@ } @Nullable -@@ -876,6 +_,7 @@ +@@ -853,6 +_,7 @@ playeradvancements.reload(this.server.getAdvancements()); } + net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.OnDatapackSyncEvent(this, null)); this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries))); - ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(this.server.getRecipeManager().getOrderedRecipes()); - + RecipeManager recipemanager = this.server.getRecipeManager(); + ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket( diff --git a/patches/net/minecraft/stats/RecipeBookSettings.java.patch b/patches/net/minecraft/stats/RecipeBookSettings.java.patch index 193097328f..a778f73da6 100644 --- a/patches/net/minecraft/stats/RecipeBookSettings.java.patch +++ b/patches/net/minecraft/stats/RecipeBookSettings.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/stats/RecipeBookSettings.java +++ b/net/minecraft/stats/RecipeBookSettings.java -@@ -11,7 +_,7 @@ - import net.minecraft.world.inventory.RecipeBookType; - - public final class RecipeBookSettings { +@@ -14,7 +_,7 @@ + public static final StreamCodec STREAM_CODEC = StreamCodec.ofMember( + RecipeBookSettings::write, RecipeBookSettings::read + ); - private static final Map> TAG_FIELDS = ImmutableMap.of( + private static final Map> TAG_FIELDS = net.neoforged.neoforge.common.CommonHooks.buildRecipeBookTypeTagFields(ImmutableMap.of( RecipeBookType.CRAFTING, Pair.of("isGuiOpen", "isFilteringCraftable"), RecipeBookType.FURNACE, -@@ -20,7 +_,7 @@ +@@ -23,7 +_,7 @@ Pair.of("isBlastingFurnaceGuiOpen", "isBlastingFurnaceFilteringCraftable"), RecipeBookType.SMOKER, Pair.of("isSmokerGuiOpen", "isSmokerFilteringCraftable") @@ -18,13 +18,13 @@ private final Map states; private RecipeBookSettings(Map p_12730_) { -@@ -54,7 +_,8 @@ - public static RecipeBookSettings read(FriendlyByteBuf p_12753_) { - Map map = Maps.newEnumMap(RecipeBookType.class); +@@ -72,7 +_,8 @@ + private static RecipeBookSettings read(FriendlyByteBuf p_12753_) { + Map map = new EnumMap<>(RecipeBookType.class); - for (RecipeBookType recipebooktype : RecipeBookType.values()) { + // Neo: filter out modded RecipeBookTypes when connected to a vanilla server + for (RecipeBookType recipebooktype : net.neoforged.neoforge.common.CommonHooks.getFilteredRecipeBookTypeValues()) { boolean flag = p_12753_.readBoolean(); boolean flag1 = p_12753_.readBoolean(); - map.put(recipebooktype, new RecipeBookSettings.TypeSettings(flag, flag1)); + if (flag || flag1) { diff --git a/patches/net/minecraft/tags/BlockTags.java.patch b/patches/net/minecraft/tags/BlockTags.java.patch index d4f91e54c6..53e8b18d50 100644 --- a/patches/net/minecraft/tags/BlockTags.java.patch +++ b/patches/net/minecraft/tags/BlockTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/BlockTags.java +++ b/net/minecraft/tags/BlockTags.java -@@ -196,4 +_,8 @@ +@@ -198,4 +_,8 @@ private static TagKey create(String p_203847_) { return TagKey.create(Registries.BLOCK, ResourceLocation.withDefaultNamespace(p_203847_)); } diff --git a/patches/net/minecraft/tags/ItemTags.java.patch b/patches/net/minecraft/tags/ItemTags.java.patch index 8a9759eb48..9dd688d2d9 100644 --- a/patches/net/minecraft/tags/ItemTags.java.patch +++ b/patches/net/minecraft/tags/ItemTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/ItemTags.java +++ b/net/minecraft/tags/ItemTags.java -@@ -159,4 +_,8 @@ +@@ -183,4 +_,8 @@ private static TagKey bind(String p_203855_) { return TagKey.create(Registries.ITEM, ResourceLocation.withDefaultNamespace(p_203855_)); } diff --git a/patches/net/minecraft/tags/TagEntry.java.patch b/patches/net/minecraft/tags/TagEntry.java.patch index 3be0c67f65..bbfb68721b 100644 --- a/patches/net/minecraft/tags/TagEntry.java.patch +++ b/patches/net/minecraft/tags/TagEntry.java.patch @@ -18,7 +18,7 @@ + public interface Lookup { @Nullable - T element(ResourceLocation p_215956_); + T element(ResourceLocation p_215956_, boolean p_379371_); - - @Nullable Collection tag(ResourceLocation p_215957_); diff --git a/patches/net/minecraft/tags/TagLoader.java.patch b/patches/net/minecraft/tags/TagLoader.java.patch index 6e7fa7b78f..e18606c9a5 100644 --- a/patches/net/minecraft/tags/TagLoader.java.patch +++ b/patches/net/minecraft/tags/TagLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/TagLoader.java +++ b/net/minecraft/tags/TagLoader.java -@@ -57,6 +_,7 @@ +@@ -64,6 +_,7 @@ String s = resource.sourcePackId(); tagfile.entries().forEach(p_215997_ -> list.add(new TagLoader.EntryWithSource(p_215997_, s))); @@ -8,43 +8,35 @@ } catch (Exception exception) { LOGGER.error("Couldn't read tag list {} from {} in data pack {}", resourcelocation1, resourcelocation, resource.sourcePackId(), exception); } -@@ -67,16 +_,17 @@ - } - - private Either, Collection> build(TagEntry.Lookup p_215979_, List p_215980_) { -- Builder builder = ImmutableSet.builder(); -+ var builder = new java.util.LinkedHashSet(); // Set must retain insertion order, some tag consumers rely on this being the case (see NeoForge#256) +@@ -78,7 +_,8 @@ List list = new ArrayList<>(); for (TagLoader.EntryWithSource tagloader$entrywithsource : p_215980_) { -- if (!tagloader$entrywithsource.entry().build(p_215979_, builder::add)) { -+ if (!tagloader$entrywithsource.entry().build(p_215979_, tagloader$entrywithsource.remove() ? builder::remove : builder::add)) { +- if (!tagloader$entrywithsource.entry().build(p_215979_, sequencedset::add)) { ++ if (!tagloader$entrywithsource.entry().build(p_215979_, tagloader$entrywithsource.remove() ? sequencedset::remove : sequencedset::add)) { + if (!tagloader$entrywithsource.remove()) // Treat all removals as optional at runtime. If it was missing, then it could of never been added. list.add(tagloader$entrywithsource); } } - -- return list.isEmpty() ? Either.right(builder.build()) : Either.left(list); -+ return list.isEmpty() ? Either.right(List.copyOf(builder)) : Either.left(list); - } - - public Map> build(Map> p_203899_) { -@@ -104,7 +_,7 @@ - p_215977_ -> LOGGER.error( +@@ -111,7 +_,7 @@ + p_359633_ -> LOGGER.error( "Couldn't load tag {} as it is missing following references: {}", - p_284682_, -- p_215977_.stream().map(Objects::toString).collect(Collectors.joining(", ")) -+ p_215977_.stream().map(Objects::toString).collect(Collectors.joining("\n\t", "\n\t", "")) + p_359645_, +- p_359633_.stream().map(Objects::toString).collect(Collectors.joining(", ")) ++ p_359633_.stream().map(Objects::toString).collect(Collectors.joining("\n\t", "\n\t", "")) ) ) - .ifRight(p_216001_ -> map.put(p_284682_, (Collection)p_216001_)) -@@ -116,7 +_,8 @@ - return this.build(this.load(p_203901_)); + .ifRight(p_364232_ -> map.put(p_359645_, (List)p_364232_)) +@@ -183,7 +_,11 @@ + } } - public static record EntryWithSource(TagEntry entry, String source) { + public static record EntryWithSource(TagEntry entry, String source, boolean remove) { -+ public EntryWithSource(TagEntry entry, String source) { this(entry, source, false); } ++ public EntryWithSource(TagEntry entry, String source) { ++ this(entry, source, false); ++ } ++ @Override public String toString() { return this.entry + " (from " + this.source + ")"; diff --git a/patches/net/minecraft/util/SpawnUtil.java.patch b/patches/net/minecraft/util/SpawnUtil.java.patch index 9b3eea749e..558cc70a2a 100644 --- a/patches/net/minecraft/util/SpawnUtil.java.patch +++ b/patches/net/minecraft/util/SpawnUtil.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/util/SpawnUtil.java +++ b/net/minecraft/util/SpawnUtil.java -@@ -35,7 +_,7 @@ +@@ -36,7 +_,7 @@ && moveToPossibleSpawnPosition(p_216406_, p_216410_, blockpos$mutableblockpos, p_216411_)) { - T t = (T)p_216404_.create(p_216406_, null, blockpos$mutableblockpos, p_216405_, false, false); + T t = (T)p_216404_.create(p_216406_, null, blockpos$mutableblockpos, p_364255_, false, false); if (t != null) { -- if (t.checkSpawnRules(p_216406_, p_216405_) && t.checkSpawnObstruction(p_216406_)) { -+ if (net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(t, p_216406_, p_216405_)) { +- if (t.checkSpawnRules(p_216406_, p_364255_) && t.checkSpawnObstruction(p_216406_)) { ++ if (net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(t, p_216406_, p_364255_)) { p_216406_.addFreshEntityWithPassengers(t); return Optional.of(t); } diff --git a/patches/net/minecraft/util/context/ContextMap.java.patch b/patches/net/minecraft/util/context/ContextMap.java.patch new file mode 100644 index 0000000000..86160aa256 --- /dev/null +++ b/patches/net/minecraft/util/context/ContextMap.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/util/context/ContextMap.java ++++ b/net/minecraft/util/context/ContextMap.java +@@ -73,7 +_,7 @@ + + public ContextMap create(ContextKeySet p_381168_) { + Set> set = Sets.difference(this.params.keySet(), p_381168_.allowed()); +- if (!set.isEmpty()) { ++ if (false && !set.isEmpty()) { + throw new IllegalArgumentException("Parameters not allowed in this parameter set: " + set); + } else { + Set> set1 = Sets.difference(p_381168_.required(), this.params.keySet()); diff --git a/patches/net/minecraft/util/datafix/DataFixers.java.patch b/patches/net/minecraft/util/datafix/DataFixers.java.patch index b6fe2020c6..7d19c8c1d7 100644 --- a/patches/net/minecraft/util/datafix/DataFixers.java.patch +++ b/patches/net/minecraft/util/datafix/DataFixers.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/datafix/DataFixers.java +++ b/net/minecraft/util/datafix/DataFixers.java -@@ -1292,10 +_,35 @@ +@@ -1307,10 +_,35 @@ Schema schema199 = p_14514_.addSchema(3800, SAME_NAMESPACED); UnaryOperator unaryoperator2 = createRenamer(Map.of("minecraft:scute", "minecraft:turtle_scute")); p_14514_.addFixer(ItemRenameFix.create(schema199, "Rename scute item to turtle_scute", unaryoperator2)); @@ -24,7 +24,7 @@ + // Neo: rename neo attributes to new MC attributes + // Happens in 24w03a + Schema neoSchema3804 = p_14514_.addSchema(3804, SAME_NAMESPACED); -+ p_14514_.addFixer(new AttributesRename( ++ p_14514_.addFixer(new AttributesRenameLegacy( + neoSchema3804, + "(Neo) Rename reach attributes to vanilla", + createRenamer(ImmutableMap.of( @@ -36,15 +36,15 @@ Schema schema201 = p_14514_.addSchema(3807, V3807::new); p_14514_.addFixer(new AddNewChoices(schema201, "Added Vault", References.BLOCK_ENTITY)); Schema schema202 = p_14514_.addSchema(3807, 1, SAME_NAMESPACED); -@@ -1316,6 +_,18 @@ - p_14514_.addFixer( - new AttributesRename(schema209, "Rename jump strength attribute", createRenamer("minecraft:horse.jump_strength", "minecraft:generic.jump_strength")) +@@ -1333,6 +_,18 @@ + schema209, "Rename jump strength attribute", createRenamer("minecraft:horse.jump_strength", "minecraft:generic.jump_strength") + ) ); + + // Neo: rename neo attributes to new MC attributes + // Happens in 24w06a + Schema neoSchema3815 = p_14514_.addSchema(3815, SAME_NAMESPACED); -+ p_14514_.addFixer(new AttributesRename( ++ p_14514_.addFixer(new AttributesRenameLegacy( + neoSchema3815, + "(Neo) Rename gravity attribute to vanilla", + createRenamer( diff --git a/patches/net/minecraft/util/thread/BlockableEventLoop.java.patch b/patches/net/minecraft/util/thread/BlockableEventLoop.java.patch index 39297f647a..3a19f55b67 100644 --- a/patches/net/minecraft/util/thread/BlockableEventLoop.java.patch +++ b/patches/net/minecraft/util/thread/BlockableEventLoop.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/util/thread/BlockableEventLoop.java +++ b/net/minecraft/util/thread/BlockableEventLoop.java -@@ -56,10 +_,15 @@ +@@ -59,10 +_,15 @@ } public CompletableFuture submitAsync(Runnable p_18690_) { diff --git a/patches/net/minecraft/world/effect/MobEffect.java.patch b/patches/net/minecraft/world/effect/MobEffect.java.patch index c8eef70796..135584ef6b 100644 --- a/patches/net/minecraft/world/effect/MobEffect.java.patch +++ b/patches/net/minecraft/world/effect/MobEffect.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffect.java +++ b/net/minecraft/world/effect/MobEffect.java -@@ -35,7 +_,7 @@ +@@ -36,7 +_,7 @@ import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; @@ -9,7 +9,7 @@ public static final Codec> CODEC = BuiltInRegistries.MOB_EFFECT.holderByNameCodec(); public static final StreamCodec> STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.MOB_EFFECT); private static final int AMBIENT_ALPHA = Mth.floor(38.25F); -@@ -130,6 +_,18 @@ +@@ -133,6 +_,18 @@ return this; } @@ -28,19 +28,11 @@ public MobEffect setBlendDuration(int p_316265_) { this.blendDurationTicks = p_316265_; return this; -@@ -181,8 +_,24 @@ +@@ -184,8 +_,16 @@ return this.requiredFeatures; } - static record AttributeTemplate(ResourceLocation id, double amount, AttributeModifier.Operation operation) { -+ /** -+ * Neo: Allowing mods to define client behavior for their MobEffects -+ * @deprecated Use {@link net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent} instead -+ */ -+ @Deprecated(forRemoval = true, since = "1.21") -+ public void initializeClient(java.util.function.Consumer consumer) { -+ } -+ + static record AttributeTemplate(ResourceLocation id, double amount, AttributeModifier.Operation operation, @Nullable it.unimi.dsi.fastutil.ints.Int2DoubleFunction curve) { + + public AttributeTemplate(ResourceLocation id, double amount, AttributeModifier.Operation operation) { diff --git a/patches/net/minecraft/world/effect/MobEffectInstance.java.patch b/patches/net/minecraft/world/effect/MobEffectInstance.java.patch index 0c314eaa46..2e4c275007 100644 --- a/patches/net/minecraft/world/effect/MobEffectInstance.java.patch +++ b/patches/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -1,42 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectInstance.java +++ b/net/minecraft/world/effect/MobEffectInstance.java -@@ -80,6 +_,7 @@ - this.visible = p_19532_; - this.showIcon = p_19533_; - this.hiddenEffect = p_316863_; -+ this.effect.value().fillEffectCures(this.cures, this); - } - - public MobEffectInstance(MobEffectInstance p_19543_) { -@@ -97,6 +_,8 @@ - p_324529_.showIcon(), - p_324529_.hiddenEffect().map(p_323227_ -> new MobEffectInstance(p_324441_, p_323227_)).orElse(null) - ); -+ this.cures.clear(); -+ p_324529_.cures().ifPresent(this.cures::addAll); - } - - private MobEffectInstance.Details asDetails() { -@@ -106,7 +_,8 @@ - this.isAmbient(), - this.isVisible(), - this.showIcon(), -- Optional.ofNullable(this.hiddenEffect).map(MobEffectInstance::asDetails) -+ Optional.ofNullable(this.hiddenEffect).map(MobEffectInstance::asDetails), -+ Optional.of(this.getCures()).filter(cures -> !cures.isEmpty()) - ); - } - -@@ -124,6 +_,8 @@ - this.ambient = p_19549_.ambient; - this.visible = p_19549_.visible; - this.showIcon = p_19549_.showIcon; -+ this.cures.clear(); -+ this.cures.addAll(p_19549_.cures); - } - - public boolean update(MobEffectInstance p_19559_) { -@@ -324,11 +_,11 @@ +@@ -327,11 +_,11 @@ .compareFalseFirst(this.isAmbient(), p_19566_.isAmbient()) .compareFalseFirst(this.isInfiniteDuration(), p_19566_.isInfiniteDuration()) .compare(this.getDuration(), p_19566_.getDuration()) @@ -50,77 +14,3 @@ .result(); } -@@ -348,6 +_,15 @@ - this.blendState.setImmediate(this); - } - -+ private final java.util.Set cures = com.google.common.collect.Sets.newIdentityHashSet(); -+ -+ /** -+ * {@return the {@link net.neoforged.neoforge.common.EffectCure}s which can cure the {@link MobEffect} held by this {@link MobEffectInstance}} -+ */ -+ public java.util.Set getCures() { -+ return cures; -+ } -+ - static class BlendState { - private float factor; - private float factorPreviousFrame; -@@ -395,8 +_,7 @@ - } - - static record Details( -- int amplifier, int duration, boolean ambient, boolean showParticles, boolean showIcon, Optional hiddenEffect -- ) { -+ int amplifier, int duration, boolean ambient, boolean showParticles, boolean showIcon, Optional hiddenEffect, Optional> cures) { - public static final MapCodec MAP_CODEC = MapCodec.recursive( - "MobEffectInstance.Details", - p_323465_ -> RecordCodecBuilder.mapCodec( -@@ -407,12 +_,14 @@ - Codec.BOOL.optionalFieldOf("show_particles", Boolean.valueOf(true)).forGetter(MobEffectInstance.Details::showParticles), - Codec.BOOL.optionalFieldOf("show_icon").forGetter(p_323788_ -> Optional.of(p_323788_.showIcon())), - p_323465_.optionalFieldOf("hidden_effect").forGetter(MobEffectInstance.Details::hiddenEffect) -+ // Neo: Add additional serialization logic for custom EffectCure(s) -+ , net.neoforged.neoforge.common.util.NeoForgeExtraCodecs.setOf(net.neoforged.neoforge.common.EffectCure.CODEC).optionalFieldOf("neoforge:cures").forGetter(MobEffectInstance.Details::cures) - ) - .apply(p_324063_, MobEffectInstance.Details::create) - ) - ); -- public static final StreamCodec STREAM_CODEC = StreamCodec.recursive( -- p_329990_ -> StreamCodec.composite( -+ public static final StreamCodec STREAM_CODEC = StreamCodec.recursive( -+ p_329990_ -> net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs.composite( - ByteBufCodecs.VAR_INT, - MobEffectInstance.Details::amplifier, - ByteBufCodecs.VAR_INT, -@@ -425,6 +_,12 @@ - MobEffectInstance.Details::showIcon, - p_329990_.apply(ByteBufCodecs::optional), - MobEffectInstance.Details::hiddenEffect, -+ // Neo: Add additional serialization logic for custom EffectCure(s) -+ net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs.connectionAware( -+ ByteBufCodecs.optional(net.neoforged.neoforge.common.EffectCure.STREAM_CODEC.apply(ByteBufCodecs.collection(java.util.HashSet::new))), -+ net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs.uncheckedUnit(Optional.empty()) -+ ), -+ MobEffectInstance.Details::cures, - MobEffectInstance.Details::new - ) - ); -@@ -434,5 +_,17 @@ - ) { - return new MobEffectInstance.Details(p_323657_, p_324205_, p_324263_, p_324000_, p_323607_.orElse(p_324000_), p_324604_); - } -+ -+ private static MobEffectInstance.Details create( -+ int p_323657_, int p_324205_, boolean p_324263_, boolean p_324000_, Optional p_323607_, Optional p_324604_, Optional> cures -+ ) { -+ return new MobEffectInstance.Details(p_323657_, p_324205_, p_324263_, p_324000_, p_323607_.orElse(p_324000_), p_324604_, cures); -+ } -+ -+ @Deprecated -+ Details(int amplifier, int duration, boolean ambient, boolean showParticles, boolean showIcon, Optional hiddenEffect) { -+ this(amplifier, duration, ambient, showParticles, showIcon, hiddenEffect, Optional.empty()); -+ } -+ - } - } diff --git a/patches/net/minecraft/world/effect/PoisonMobEffect.java.patch b/patches/net/minecraft/world/effect/PoisonMobEffect.java.patch index 39db38e109..d2c1139e5e 100644 --- a/patches/net/minecraft/world/effect/PoisonMobEffect.java.patch +++ b/patches/net/minecraft/world/effect/PoisonMobEffect.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/effect/PoisonMobEffect.java +++ b/net/minecraft/world/effect/PoisonMobEffect.java -@@ -10,7 +_,12 @@ +@@ -11,7 +_,12 @@ @Override - public boolean applyEffectTick(LivingEntity p_296276_, int p_296233_) { + public boolean applyEffectTick(ServerLevel p_376442_, LivingEntity p_296276_, int p_296233_) { if (p_296276_.getHealth() > 1.0F) { -- p_296276_.hurt(p_296276_.damageSources().magic(), 1.0F); +- p_296276_.hurtServer(p_376442_, p_296276_.damageSources().magic(), 1.0F); + // Neo: Replace DamageSources#magic() with neoforge:poison to allow differentiating poison damage. + // Fallback to minecraft:magic in client code when connecting to a vanilla server. + // LivingEntity#hurt(DamageSource) will no-op in client code immediately, but the holder is resolved before the no-op. + var dTypeReg = p_296276_.damageSources().damageTypes; -+ var dType = dTypeReg.getHolder(net.neoforged.neoforge.common.NeoForgeMod.POISON_DAMAGE).orElse(dTypeReg.getHolderOrThrow(net.minecraft.world.damagesource.DamageTypes.MAGIC)); -+ p_296276_.hurt(new net.minecraft.world.damagesource.DamageSource(dType), 1.0F); ++ var dType = dTypeReg.get(net.neoforged.neoforge.common.NeoForgeMod.POISON_DAMAGE).orElse(dTypeReg.getOrThrow(net.minecraft.world.damagesource.DamageTypes.MAGIC)); ++ p_296276_.hurtServer(p_376442_, new net.minecraft.world.damagesource.DamageSource(dType), 1.0F); } return true; diff --git a/patches/net/minecraft/world/entity/Entity.java.patch b/patches/net/minecraft/world/entity/Entity.java.patch index b4441b2352..15f8303a24 100644 --- a/patches/net/minecraft/world/entity/Entity.java.patch +++ b/patches/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 -@@ -128,7 +_,7 @@ +@@ -136,7 +_,7 @@ import net.minecraft.world.scores.Team; import org.slf4j.Logger; --public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, CommandSource, ScoreHolder { -+public abstract class Entity extends net.neoforged.neoforge.attachment.AttachmentHolder implements SyncedDataHolder, Nameable, EntityAccess, CommandSource, ScoreHolder, net.neoforged.neoforge.common.extensions.IEntityExtension { +-public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder { ++public abstract class Entity extends net.neoforged.neoforge.attachment.AttachmentHolder implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, net.neoforged.neoforge.common.extensions.IEntityExtension { private static final Logger LOGGER = LogUtils.getLogger(); public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -149,6 +_,7 @@ +@@ -157,6 +_,7 @@ private static final double LAVA_SLOW_FLOW_SCALE = 0.0023333333333333335; public static final String UUID_TAG = "UUID"; private static double viewScale = 1.0; @@ -17,7 +17,7 @@ private final EntityType type; private int id = ENTITY_COUNTER.incrementAndGet(); public boolean blocksBuilding; -@@ -194,8 +_,10 @@ +@@ -201,8 +_,10 @@ public int tickCount; private int remainingFireTicks = -this.getFireImmuneTicks(); protected boolean wasTouchingWater; @@ -28,7 +28,7 @@ private final Set> fluidOnEyes = new HashSet<>(); public int invulnerableTime; protected boolean firstTick = true; -@@ -263,7 +_,10 @@ +@@ -271,7 +_,10 @@ this.defineSynchedData(synchedentitydata$builder); this.entityData = synchedentitydata$builder.build(); this.setPos(0.0, 0.0, 0.0); @@ -39,7 +39,7 @@ } public boolean isColliding(BlockPos p_20040_, BlockState p_20041_) { -@@ -467,7 +_,7 @@ +@@ -478,7 +_,7 @@ if (this.isInLava()) { this.lavaHurt(); @@ -48,36 +48,22 @@ } this.checkBelowWorld(); -@@ -673,7 +_,7 @@ - double d1 = vec3.x; - double d2 = vec3.y; - double d3 = vec3.z; -- this.flyDist = this.flyDist + (float)(vec3.length() * 0.6); -+ this.flyDist = (float)((double)this.flyDist + vec3.length() * 0.6D); - BlockPos blockpos1 = this.getOnPos(); - BlockState blockstate1 = this.level().getBlockState(blockpos1); - boolean flag1 = this.isStateClimbable(blockstate1); -@@ -717,16 +_,16 @@ - this.setRemainingFireTicks(-this.getFireImmuneTicks()); - } - -- if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { -+ if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble() || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { - this.playEntityOnFireExtinguishedSound(); - } +@@ -760,12 +_,12 @@ + this.setRemainingFireTicks(-this.getFireImmuneTicks()); } -- if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { -+ if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble() || this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { - this.setRemainingFireTicks(-this.getFireImmuneTicks()); +- if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { ++ if (this.wasOnFire && (this.isInPowderSnow || this.isInWaterRainOrBubble()|| this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { + this.playEntityOnFireExtinguishedSound(); } + } -- this.level().getProfiler().pop(); -+ this.level.getProfiler().pop(); +- if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { ++ if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble()|| this.isInFluidType((fluidType, height) -> this.canFluidExtinguish(fluidType)))) { + this.setRemainingFireTicks(-this.getFireImmuneTicks()); } } - } -@@ -812,9 +_,7 @@ +@@ -845,9 +_,7 @@ return blockpos; } else { BlockState blockstate = this.level().getBlockState(blockpos); @@ -88,7 +74,7 @@ ? blockpos.atY(Mth.floor(this.position.y - (double)p_216987_)) : blockpos; } -@@ -1076,19 +_,19 @@ +@@ -1129,19 +_,19 @@ return !blockstate.is(BlockTags.INSIDE_STEP_SOUND_BLOCKS) && !blockstate.is(BlockTags.COMBINATION_STEP_SOUND_BLOCKS) ? p_278049_ : blockpos; } @@ -114,7 +100,7 @@ this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch()); } -@@ -1241,20 +_,23 @@ +@@ -1294,20 +_,23 @@ public void updateSwimming() { if (this.isSwimming()) { @@ -135,7 +121,7 @@ - double d0 = this.level().dimensionType().ultraWarm() ? 0.007 : 0.0023333333333333335; - boolean flag = this.updateFluidHeightAndDoFluidPushing(FluidTags.LAVA, d0); - return this.isInWater() || flag; -+ if (this.isInFluidType() && !(this.getVehicle() instanceof Boat)) { ++ if (this.isInFluidType() && !(this.getVehicle() instanceof AbstractBoat)) { + this.fallDistance *= this.forgeFluidTypeHeight.object2DoubleEntrySet().stream().filter(e -> !e.getKey().isAir() && !e.getKey().isVanilla()).map(e -> this.getFluidFallDistanceModifier(e.getKey())).min(Float::compare).orElse(1F); + if (this.isInFluidType((fluidType, height) -> !fluidType.isAir() && !fluidType.isVanilla() && this.canFluidExtinguish(fluidType))) this.clearFire(); + } @@ -143,15 +129,15 @@ } void updateInWaterStateAndDoWaterCurrentPushing() { -@@ -1279,6 +_,7 @@ +@@ -1332,6 +_,7 @@ private void updateFluidOnEyes() { this.wasEyeInWater = this.isEyeInFluid(FluidTags.WATER); this.fluidOnEyes.clear(); + this.forgeFluidTypeOnEyes = net.neoforged.neoforge.common.NeoForgeMod.EMPTY_TYPE.value(); double d0 = this.getEyeY(); - if (this.getVehicle() instanceof Boat boat && !boat.isUnderWater() && boat.getBoundingBox().maxY >= d0 && boat.getBoundingBox().minY <= d0) { - return; -@@ -1288,7 +_,7 @@ + if (this.getVehicle() instanceof AbstractBoat abstractboat + && !abstractboat.isUnderWater() +@@ -1344,7 +_,7 @@ FluidState fluidstate = this.level().getFluidState(blockpos); double d1 = (double)((float)blockpos.getY() + fluidstate.getHeight(this.level(), blockpos)); if (d1 > d0) { @@ -160,7 +146,7 @@ } } -@@ -1333,12 +_,13 @@ +@@ -1389,12 +_,13 @@ } public boolean canSpawnSprintParticle() { @@ -175,7 +161,7 @@ if (blockstate.getRenderShape() != RenderShape.INVISIBLE) { Vec3 vec3 = this.getDeltaMovement(); BlockPos blockpos1 = this.blockPosition(); -@@ -1352,16 +_,19 @@ +@@ -1408,16 +_,19 @@ d1 = Mth.clamp(d1, (double)blockpos.getZ(), (double)blockpos.getZ() + 1.0); } @@ -197,7 +183,7 @@ } public void moveRelative(float p_19921_, Vec3 p_19922_) { -@@ -1704,6 +_,10 @@ +@@ -1796,6 +_,10 @@ p_20241_.put("Tags", listtag); } @@ -208,7 +194,7 @@ this.addAdditionalSaveData(p_20241_); if (this.isVehicle()) { ListTag listtag1 = new ListTag(); -@@ -1784,6 +_,8 @@ +@@ -1877,6 +_,8 @@ this.setGlowingTag(p_20259_.getBoolean("Glowing")); this.setTicksFrozen(p_20259_.getInt("TicksFrozen")); this.hasVisualFire = p_20259_.getBoolean("HasVisualFire"); @@ -217,16 +203,16 @@ if (p_20259_.contains("Tags", 9)) { this.tags.clear(); ListTag listtag3 = p_20259_.getList("Tags", 8); -@@ -1868,6 +_,8 @@ +@@ -1959,6 +_,8 @@ } else { - ItemEntity itementity = new ItemEntity(this.level(), this.getX(), this.getY() + (double)p_19986_, this.getZ(), p_19985_); + ItemEntity itementity = new ItemEntity(p_376141_, this.getX(), this.getY() + (double)p_376881_, this.getZ(), p_376472_); itementity.setDefaultPickUpDelay(); + if (captureDrops() != null) captureDrops().add(itementity); + else - this.level().addFreshEntity(itementity); + p_376141_.addFreshEntity(itementity); return itementity; } -@@ -1935,7 +_,11 @@ +@@ -2026,7 +_,11 @@ public void rideTick() { this.setDeltaMovement(Vec3.ZERO); @@ -239,7 +225,7 @@ if (this.isPassenger()) { this.getVehicle().positionRider(this); } -@@ -1993,6 +_,7 @@ +@@ -2086,6 +_,7 @@ } } @@ -247,7 +233,7 @@ if (p_19967_ || this.canRide(p_19966_) && p_19966_.canAddPassenger(this)) { if (this.isPassenger()) { this.stopRiding(); -@@ -2024,6 +_,7 @@ +@@ -2117,6 +_,7 @@ public void removeVehicle() { if (this.vehicle != null) { Entity entity = this.vehicle; @@ -255,7 +241,7 @@ this.vehicle = null; entity.removePassenger(this); } -@@ -2073,6 +_,8 @@ +@@ -2166,6 +_,8 @@ return this.passengers.isEmpty(); } @@ -264,7 +250,7 @@ protected boolean couldAcceptPassenger() { return true; } -@@ -2257,7 +_,7 @@ +@@ -2354,7 +_,7 @@ } public boolean isVisuallyCrawling() { @@ -273,16 +259,16 @@ } public void setSwimming(boolean p_20283_) { -@@ -2366,7 +_,7 @@ +@@ -2467,7 +_,7 @@ this.igniteForSeconds(8.0F); } -- this.hurt(this.damageSources().lightningBolt(), 5.0F); +- this.hurtServer(p_19927_, this.damageSources().lightningBolt(), 5.0F); + this.hurt(this.damageSources().lightningBolt(), p_19928_.getDamage()); } public void onAboveBubbleCol(boolean p_20313_) { -@@ -2461,7 +_,7 @@ +@@ -2562,7 +_,7 @@ } protected Component getTypeName() { @@ -291,10 +277,10 @@ } public boolean is(Entity p_20356_) { -@@ -2516,10 +_,11 @@ +@@ -2617,10 +_,11 @@ } - public boolean isInvulnerableTo(DamageSource p_20122_) { + protected final boolean isInvulnerableToBase(DamageSource p_20122_) { - return this.isRemoved() + boolean isVanillaInvulnerable = this.isRemoved() || this.invulnerable && !p_20122_.is(DamageTypeTags.BYPASSES_INVULNERABILITY) && !p_20122_.isCreativePlayer() @@ -304,15 +290,15 @@ } public boolean isInvulnerable() { -@@ -2544,6 +_,7 @@ +@@ -2645,6 +_,7 @@ @Nullable - public Entity changeDimension(DimensionTransition p_350951_) { -+ if (!net.neoforged.neoforge.common.CommonHooks.onTravelToDimension(this, p_350951_.newLevel().dimension())) return null; + public Entity teleport(TeleportTransition p_379899_) { ++ if (!net.neoforged.neoforge.common.CommonHooks.onTravelToDimension(this, p_379899_.newLevel().dimension())) return null; if (this.level() instanceof ServerLevel serverlevel && !this.isRemoved()) { - ServerLevel serverlevel1 = p_350951_.newLevel(); - List list = this.getPassengers(); -@@ -2667,6 +_,7 @@ + ServerLevel serverlevel1 = p_379899_.newLevel(); + boolean flag = serverlevel1.dimension() != serverlevel.dimension(); +@@ -2852,6 +_,7 @@ return this.stringUUID; } @@ -320,7 +306,7 @@ public boolean isPushedByFluid() { return true; } -@@ -2783,6 +_,8 @@ +@@ -2960,6 +_,8 @@ EntityDimensions entitydimensions = this.dimensions; Pose pose = this.getPose(); EntityDimensions entitydimensions1 = this.getDimensions(pose); @@ -329,20 +315,26 @@ this.dimensions = entitydimensions1; this.eyeHeight = entitydimensions1.eyeHeight(); this.reapplyPosition(); -@@ -3110,7 +_,12 @@ +@@ -3265,9 +_,17 @@ return Mth.lerp(p_352259_, this.yRotO, this.yRot); } -+ @Deprecated // Neo: Use no parameter version instead ++ @Deprecated // Forge: Use no parameter version instead, only for vanilla Tags public boolean updateFluidHeightAndDoFluidPushing(TagKey p_204032_, double p_204033_) { -+ return this.updateFluidHeightAndDoFluidPushing(); ++ this.updateFluidHeightAndDoFluidPushing(); ++ if(p_204032_ == FluidTags.WATER) return this.isInFluidType(net.neoforged.neoforge.common.NeoForgeMod.WATER_TYPE.value()); ++ else if (p_204032_ == FluidTags.LAVA) return this.isInFluidType(net.neoforged.neoforge.common.NeoForgeMod.LAVA_TYPE.value()); ++ else return false; + } + -+ public boolean updateFluidHeightAndDoFluidPushing() { ++ public void updateFluidHeightAndDoFluidPushing() { if (this.touchingUnloadedChunk()) { - return false; +- return false; ++ return; } else { -@@ -3127,25 +_,36 @@ + AABB aabb = this.getBoundingBox().deflate(0.001); + int i = Mth.floor(aabb.minX); +@@ -3282,25 +_,36 @@ Vec3 vec3 = Vec3.ZERO; int k1 = 0; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); @@ -363,10 +355,9 @@ + if (!fluidType.isAir()) { double d1 = (double)((float)i2 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos)); if (d1 >= aabb.minY) { -- flag1 = true; + flag1 = true; - d0 = Math.max(d1 - aabb.minY, d0); - if (flag) { -+ flag1 = fluidType.actsLikeWater(); + if (interimCalcs == null) { + interimCalcs = new it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap<>(); + } @@ -387,7 +378,7 @@ } } } -@@ -3153,26 +_,30 @@ +@@ -3308,27 +_,30 @@ } } @@ -421,13 +412,14 @@ } - this.fluidHeight.put(p_204032_, d0); +- return flag1; + this.setFluidTypeHeight(fluidType, interim.fluidHeight); + }); + } - return flag1; } } -@@ -3186,7 +_,10 @@ + +@@ -3341,7 +_,10 @@ return !this.level().hasChunksAt(i, k, j, l); } @@ -438,7 +430,7 @@ return this.fluidHeight.getDouble(p_204037_); } -@@ -3323,6 +_,7 @@ +@@ -3478,6 +_,7 @@ this.levelCallback.onMove(); } @@ -446,9 +438,9 @@ } public void checkDespawn() { -@@ -3449,6 +_,128 @@ +@@ -3603,6 +_,128 @@ - public boolean mayInteract(Level p_146843_, BlockPos p_146844_) { + public boolean mayInteract(ServerLevel p_376870_, BlockPos p_146844_) { return true; + } + @@ -486,7 +478,7 @@ + + // Neo: Set the default behavior for trampling on Farmland + @Override -+ public boolean canTrample(BlockState state, BlockPos pos, float fallDistance) { ++ public boolean canTrample(ServerLevel level, BlockState state, BlockPos pos, float fallDistance) { + return level.random.nextFloat() < fallDistance - 0.5F + && this instanceof LivingEntity + && (this instanceof Player || net.neoforged.neoforge.event.EventHooks.canEntityGrief(level, this)) diff --git a/patches/net/minecraft/world/entity/EntityType.java.patch b/patches/net/minecraft/world/entity/EntityType.java.patch index 1f3f299099..4439873672 100644 --- a/patches/net/minecraft/world/entity/EntityType.java.patch +++ b/patches/net/minecraft/world/entity/EntityType.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -834,6 +_,10 @@ +@@ -1088,6 +_,10 @@ private final float spawnDimensionsScale; private final FeatureFlagSet requiredFeatures; @@ -8,14 +8,14 @@ + private final java.util.function.ToIntFunction> trackingRangeSupplier; + private final java.util.function.ToIntFunction> updateIntervalSupplier; + - private static EntityType register(String p_20635_, EntityType.Builder p_20636_) { - return Registry.register(BuiltInRegistries.ENTITY_TYPE, p_20635_, p_20636_.build(p_20635_)); + private static EntityType register(ResourceKey> p_368669_, EntityType.Builder p_368714_) { + return Registry.register(BuiltInRegistries.ENTITY_TYPE, p_368669_, p_368714_.build(p_368669_)); } -@@ -860,6 +_,26 @@ - int p_273451_, +@@ -1124,6 +_,28 @@ + Optional> p_368696_, FeatureFlagSet p_273518_ ) { -+ this(p_273268_, p_272918_, p_273417_, p_273389_, p_273556_, p_272654_, p_273631_, p_272946_, p_338404_, p_272895_, p_273451_, p_273518_, EntityType::defaultTrackDeltasSupplier, EntityType::defaultTrackingRangeSupplier, EntityType::defaultUpdateIntervalSupplier); ++ this(p_273268_, p_272918_, p_273417_, p_273389_, p_273556_, p_272654_, p_273631_, p_272946_, p_338404_, p_272895_, p_273451_, p_368582_, p_368696_, p_273518_, EntityType::defaultTrackDeltasSupplier, EntityType::defaultTrackingRangeSupplier, EntityType::defaultUpdateIntervalSupplier); + } + + public EntityType( @@ -30,6 +30,8 @@ + float p_338404_, + int p_272895_, + int p_273451_, ++ String p_368582_, ++ Optional> p_368696_, + FeatureFlagSet p_273518_, + final java.util.function.Predicate> trackDeltasSupplier, + final java.util.function.ToIntFunction> trackingRangeSupplier, @@ -38,9 +40,9 @@ this.factory = p_273268_; this.category = p_272918_; this.canSpawnFarFromPlayer = p_272654_; -@@ -872,6 +_,9 @@ - this.clientTrackingRange = p_272895_; - this.updateInterval = p_273451_; +@@ -1138,6 +_,9 @@ + this.descriptionId = p_368582_; + this.lootTable = p_368696_; this.requiredFeatures = p_273518_; + this.trackDeltasSupplier = trackDeltasSupplier; + this.trackingRangeSupplier = trackingRangeSupplier; @@ -48,10 +50,10 @@ } @Nullable -@@ -958,6 +_,15 @@ +@@ -1228,6 +_,15 @@ mob.yHeadRot = mob.getYRot(); mob.yBodyRot = mob.getYRot(); - mob.finalizeSpawn(p_262637_, p_262637_.getCurrentDifficultyAt(mob.blockPosition()), p_262666_, null); + mob.finalizeSpawn(p_262637_, p_262637_.getCurrentDifficultyAt(mob.blockPosition()), p_360546_, null); + + if (mob.isSpawnCancelled()) { + // Neo: Discard mob, spawn was cancelled @@ -64,7 +66,7 @@ mob.playAmbientSound(); } -@@ -1149,14 +_,23 @@ +@@ -1410,14 +_,23 @@ } public int clientTrackingRange() { @@ -88,8 +90,8 @@ return this != PLAYER && this != LLAMA_SPIT && this != WITHER -@@ -1192,6 +_,8 @@ - return this.builtInRegistryHolder; +@@ -1469,6 +_,8 @@ + return (p_375561_, p_375562_) -> new ChestRaft(p_375561_, p_375562_, p_376648_); } + public Stream>> getTags() {return this.builtInRegistryHolder().tags();} @@ -97,9 +99,9 @@ public static class Builder { private final EntityType.EntityFactory factory; private final MobCategory category; -@@ -1207,6 +_,10 @@ - private EntityAttachments.Builder attachments = EntityAttachments.builder(); - private FeatureFlagSet requiredFeatures = FeatureFlags.VANILLA_SET; +@@ -1488,6 +_,10 @@ + ); + private DependantName, String> descriptionId = p_367918_ -> Util.makeDescriptionId("entity", p_367918_.location()); + private java.util.function.Predicate> velocityUpdateSupplier = EntityType::defaultTrackDeltasSupplier; + private java.util.function.ToIntFunction> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier; @@ -108,32 +110,32 @@ private Builder(EntityType.EntityFactory p_20696_, MobCategory p_20697_) { this.factory = p_20696_; this.category = p_20697_; -@@ -1314,6 +_,21 @@ +@@ -1600,6 +_,21 @@ return this; } + public EntityType.Builder setUpdateInterval(int interval) { -+ this.updateIntervalSupplier = t->interval; -+ return this; ++ this.updateIntervalSupplier = t->interval; ++ return this; + } + + public EntityType.Builder setTrackingRange(int range) { -+ this.trackingRangeSupplier = t->range; -+ return this; ++ this.trackingRangeSupplier = t->range; ++ return this; + } + + public EntityType.Builder setShouldReceiveVelocityUpdates(boolean value) { -+ this.velocityUpdateSupplier = t->value; -+ return this; ++ this.velocityUpdateSupplier = t->value; ++ return this; + } + - public EntityType build(String p_20713_) { + public EntityType build(ResourceKey> p_368626_) { if (this.serialize) { - Util.fetchChoiceType(References.ENTITY_TREE, p_20713_); -@@ -1331,7 +_,10 @@ - this.spawnDimensionsScale, - this.clientTrackingRange, + Util.fetchChoiceType(References.ENTITY_TREE, p_368626_.location().toString()); +@@ -1619,7 +_,10 @@ this.updateInterval, + this.descriptionId.get(p_368626_), + this.lootTable.get(p_368626_), - this.requiredFeatures + this.requiredFeatures, + velocityUpdateSupplier, diff --git a/patches/net/minecraft/world/entity/ExperienceOrb.java.patch b/patches/net/minecraft/world/entity/ExperienceOrb.java.patch index d81cfa82bb..9a5df1bf49 100644 --- a/patches/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/patches/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -112,7 +_,8 @@ - this.move(MoverType.SELF, this.getDeltaMovement()); +@@ -113,7 +_,8 @@ + this.applyEffectsFromBlocks(); float f = 0.98F; if (this.onGround()) { - f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; @@ -10,7 +10,7 @@ } this.setDeltaMovement(this.getDeltaMovement().multiply((double)f, 0.98, (double)f)); -@@ -133,7 +_,7 @@ +@@ -134,7 +_,7 @@ private void scanForEntities() { if (this.followingPlayer == null || this.followingPlayer.distanceToSqr(this) > 64.0) { @@ -19,7 +19,7 @@ } if (this.level() instanceof ServerLevel) { -@@ -228,6 +_,7 @@ +@@ -232,6 +_,7 @@ public void playerTouch(Player p_20792_) { if (p_20792_ instanceof ServerPlayer serverplayer) { if (p_20792_.takeXpDelay == 0) { @@ -27,7 +27,7 @@ p_20792_.takeXpDelay = 2; p_20792_.take(this, 1); int i = this.repairPlayerItems(serverplayer, this.value); -@@ -247,7 +_,7 @@ +@@ -251,7 +_,7 @@ Optional optional = EnchantmentHelper.getRandomItemWith(EnchantmentEffectComponents.REPAIR_WITH_XP, p_344821_, ItemStack::isDamaged); if (optional.isPresent()) { ItemStack itemstack = optional.get().itemStack(); diff --git a/patches/net/minecraft/world/entity/LightningBolt.java.patch b/patches/net/minecraft/world/entity/LightningBolt.java.patch index f74497ef94..8a59dc341c 100644 --- a/patches/net/minecraft/world/entity/LightningBolt.java.patch +++ b/patches/net/minecraft/world/entity/LightningBolt.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LightningBolt.java +++ b/net/minecraft/world/entity/LightningBolt.java -@@ -38,6 +_,7 @@ +@@ -39,6 +_,7 @@ private ServerPlayer cause; private final Set hitEntities = Sets.newHashSet(); private int blocksSetOnFire; diff --git a/patches/net/minecraft/world/entity/LivingEntity.java.patch b/patches/net/minecraft/world/entity/LivingEntity.java.patch index b22fc4915b..ebb7a0cbf9 100644 --- a/patches/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -132,7 +_,7 @@ +@@ -137,7 +_,7 @@ import net.minecraft.world.scores.Scoreboard; import org.slf4j.Logger; @@ -9,22 +9,43 @@ private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; private static final ResourceLocation SPEED_MODIFIER_POWDER_SNOW_ID = ResourceLocation.withDefaultNamespace("powder_snow"); -@@ -254,6 +_,14 @@ - private boolean skipDropExperience; - private final Reference2ObjectMap> activeLocationDependentEnchantments = new Reference2ObjectArrayMap<>(); +@@ -179,13 +_,18 @@ + public static final float EXTRA_RENDER_CULLING_SIZE_WITH_BIG_HAT = 0.5F; + public static final float DEFAULT_BABY_SCALE = 0.5F; + public static final String ATTRIBUTES_FIELD = "attributes"; +- public static final Predicate PLAYER_NOT_WEARING_DISGUISE_ITEM = p_379074_ -> { ++ public static final java.util.function.BiPredicate PLAYER_NOT_WEARING_DISGUISE_ITEM_FOR_TARGET = (p_379074_, target) -> { + if (p_379074_ instanceof Player player) { + ItemStack itemstack = player.getItemBySlot(EquipmentSlot.HEAD); +- return !itemstack.is(ItemTags.GAZE_DISGUISE_EQUIPMENT); ++ return !itemstack.isGazeDisguise(player, target); + } else { + return true; + } ++ }; ++ /** @deprecated Neo: use {@link #PLAYER_NOT_WEARING_DISGUISE_ITEM_FOR_TARGET} with target info instead */ ++ @Deprecated ++ public static final Predicate PLAYER_NOT_WEARING_DISGUISE_ITEM = p_379074_ -> { ++ return PLAYER_NOT_WEARING_DISGUISE_ITEM_FOR_TARGET.test(p_379074_, null); + }; + private final AttributeMap attributes; + private final CombatTracker combatTracker = new CombatTracker(this); +@@ -268,6 +_,14 @@ + EquipmentSlot.class + ); protected float appliedScale = 1.0F; + /** + * This field stores information about damage dealt to this entity. + * a new {@link net.neoforged.neoforge.common.damagesource.DamageContainer} is instantiated + * via {@link #hurt(DamageSource, float)} after invulnerability checks, and is removed from + * the stack before the method's return. -+ **/ ++ **/ + @Nullable + protected java.util.Stack damageContainers = new java.util.Stack<>(); protected LivingEntity(EntityType p_20966_, Level p_20967_) { super(p_20966_, p_20967_); -@@ -320,7 +_,9 @@ +@@ -334,7 +_,9 @@ .add(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE) .add(Attributes.WATER_MOVEMENT_EFFICIENCY) .add(Attributes.MOVEMENT_EFFICIENCY) @@ -35,17 +56,17 @@ } @Override -@@ -348,7 +_,8 @@ +@@ -362,7 +_,8 @@ float f = (float)Mth.ceil((double)this.fallDistance - d7); double d4 = Math.min((double)(0.2F + f / 15.0F), 2.5); int i = (int)(150.0 * d4); -- ((ServerLevel)this.level()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, p_20992_), d0, d1, d2, i, 0.0, 0.0, 0.0, 0.15F); +- serverlevel.sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, p_20992_), d0, d1, d2, i, 0.0, 0.0, 0.0, 0.15F); + if (!p_20992_.addLandingEffects((ServerLevel) this.level(), p_20993_, p_20992_, this, i)) + ((ServerLevel)this.level()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, p_20992_).setPos(p_20993_), d0, d1, d2, i, 0.0, 0.0, 0.0, 0.15F); } } -@@ -358,6 +_,7 @@ +@@ -372,6 +_,7 @@ } } @@ -53,7 +74,7 @@ public final boolean canBreatheUnderwater() { return this.getType().is(EntityTypeTags.CAN_BREATHE_UNDER_WATER); } -@@ -403,6 +_,9 @@ +@@ -418,6 +_,9 @@ } } @@ -63,7 +84,7 @@ if (this.isEyeInFluid(FluidTags.WATER) && !this.level().getBlockState(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())).is(Blocks.BUBBLE_COLUMN)) { boolean flag1 = !this.canBreatheUnderwater() -@@ -441,7 +_,7 @@ +@@ -456,7 +_,7 @@ } } @@ -72,16 +93,16 @@ this.extinguishFire(); } -@@ -772,7 +_,7 @@ +@@ -787,7 +_,7 @@ Holder holder = iterator.next(); MobEffectInstance mobeffectinstance = this.activeEffects.get(holder); if (!mobeffectinstance.tick(this, () -> this.onEffectUpdated(mobeffectinstance, true, null))) { - if (!this.level().isClientSide) { + if (!this.level().isClientSide && !net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.entity.living.MobEffectEvent.Expired(this, mobeffectinstance)).isCanceled()) { iterator.remove(); - this.onEffectRemoved(mobeffectinstance); + this.onEffectsRemoved(List.of(mobeffectinstance)); } -@@ -817,8 +_,9 @@ +@@ -832,8 +_,9 @@ List list = this.activeEffects .values() .stream() @@ -93,7 +114,7 @@ .toList(); this.entityData.set(DATA_EFFECT_PARTICLES, list); this.entityData.set(DATA_EFFECT_AMBIENCE_ID, areAllEffectsAmbient(this.activeEffects.values())); -@@ -858,6 +_,7 @@ +@@ -873,6 +_,7 @@ } } @@ -101,18 +122,23 @@ return d0; } -@@ -899,7 +_,9 @@ - - boolean flag; - for (flag = false; iterator.hasNext(); flag = true) { -- this.onEffectRemoved(iterator.next()); -+ MobEffectInstance effect = iterator.next(); -+ if(net.neoforged.neoforge.event.EventHooks.onEffectRemoved(this, effect, null)) continue; -+ this.onEffectRemoved(effect); - iterator.remove(); - } - -@@ -929,11 +_,12 @@ +@@ -908,8 +_,13 @@ + } else if (this.activeEffects.isEmpty()) { + return false; + } else { +- Map, MobEffectInstance> map = Maps.newHashMap(this.activeEffects); +- this.activeEffects.clear(); ++ Map, MobEffectInstance> map = new java.util.HashMap<>(this.activeEffects.size()); ++ for (Map.Entry, MobEffectInstance> entry : this.activeEffects.entrySet()) { ++ if (!net.neoforged.neoforge.event.EventHooks.onEffectRemoved(this, entry.getValue())) { ++ map.put(entry.getKey(), entry.getValue()); ++ } ++ } ++ map.keySet().forEach(this.activeEffects::remove); + this.onEffectsRemoved(map.values()); + return true; + } +@@ -937,11 +_,12 @@ } public boolean addEffect(MobEffectInstance p_147208_, @Nullable Entity p_147209_) { @@ -126,7 +152,7 @@ if (mobeffectinstance == null) { this.activeEffects.put(p_147208_.getEffect(), p_147208_); this.onEffectAdded(p_147208_, p_147209_); -@@ -949,6 +_,14 @@ +@@ -957,6 +_,14 @@ } } @@ -141,7 +167,7 @@ public boolean canBeAffected(MobEffectInstance p_21197_) { if (this.getType().is(EntityTypeTags.IMMUNE_TO_INFESTED)) { return !p_21197_.is(MobEffects.INFESTED); -@@ -962,7 +_,7 @@ +@@ -970,7 +_,7 @@ } public void forceAddEffect(MobEffectInstance p_147216_, @Nullable Entity p_147217_) { @@ -150,15 +176,15 @@ MobEffectInstance mobeffectinstance = this.activeEffects.put(p_147216_.getEffect(), p_147216_); if (mobeffectinstance == null) { this.onEffectAdded(p_147216_, p_147217_); -@@ -983,6 +_,7 @@ +@@ -991,6 +_,7 @@ } public boolean removeEffect(Holder p_316570_) { -+ if (net.neoforged.neoforge.event.EventHooks.onEffectRemoved(this, p_316570_, null)) return false; ++ if (net.neoforged.neoforge.event.EventHooks.onEffectRemoved(this, p_316570_)) return false; MobEffectInstance mobeffectinstance = this.removeEffectNoUpdate(p_316570_); if (mobeffectinstance != null) { - this.onEffectRemoved(mobeffectinstance); -@@ -1061,6 +_,8 @@ + this.onEffectsRemoved(List.of(mobeffectinstance)); +@@ -1072,6 +_,8 @@ } public void heal(float p_21116_) { @@ -167,71 +193,75 @@ float f = this.getHealth(); if (f > 0.0F) { this.setHealth(f + p_21116_); -@@ -1090,23 +_,30 @@ - } else if (p_21016_.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { +@@ -1099,11 +_,14 @@ + } else if (p_376460_.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; } else { -+ this.damageContainers.push(new net.neoforged.neoforge.common.damagesource.DamageContainer(p_21016_, p_21017_)); ++ this.damageContainers.push(new net.neoforged.neoforge.common.damagesource.DamageContainer(p_376460_, p_376610_)); + if (net.neoforged.neoforge.common.CommonHooks.onEntityIncomingDamage(this, this.damageContainers.peek())) return false; - if (this.isSleeping() && !this.level().isClientSide) { + if (this.isSleeping()) { this.stopSleeping(); } this.noActionTime = 0; -+ p_21017_ = this.damageContainers.peek().getNewDamage(); //Neo: enforce damage container as source of truth for damage amount - float f = p_21017_; ++ p_376610_ = this.damageContainers.peek().getNewDamage(); //Neo: enforce damage container as source of truth for damage amount + if (p_376610_ < 0.0F) { + p_376610_ = 0.0F; + } +@@ -1111,15 +_,19 @@ + float f = p_376610_; boolean flag = false; float f1 = 0.0F; -- if (p_21017_ > 0.0F && this.isDamageSourceBlocked(p_21016_)) { -- this.hurtCurrentlyUsedShield(p_21017_); -- f1 = p_21017_; -- p_21017_ = 0.0F; +- if (p_376610_ > 0.0F && this.isDamageSourceBlocked(p_376460_)) { +- this.hurtCurrentlyUsedShield(p_376610_); +- f1 = p_376610_; +- p_376610_ = 0.0F; + net.neoforged.neoforge.event.entity.living.LivingShieldBlockEvent ev; -+ if (p_21017_ > 0.0F && (ev = net.neoforged.neoforge.common.CommonHooks.onDamageBlock(this, this.damageContainers.peek(), this.isDamageSourceBlocked(p_21016_))).getBlocked()) { ++ if (p_376610_ > 0.0F && (ev = net.neoforged.neoforge.common.CommonHooks.onDamageBlock(this, this.damageContainers.peek(), this.isDamageSourceBlocked(p_376460_))).getBlocked()) { + this.damageContainers.peek().setBlockedDamage(ev); -+ if(ev.shieldDamage() > 0) { ++ if (ev.shieldDamage() > 0) { + this.hurtCurrentlyUsedShield(ev.shieldDamage()); + } + f1 = ev.getBlockedDamage(); -+ p_21017_ = ev.getDamageContainer().getNewDamage(); - if (!p_21016_.is(DamageTypeTags.IS_PROJECTILE) && p_21016_.getDirectEntity() instanceof LivingEntity livingentity) { ++ p_376610_ = ev.getDamageContainer().getNewDamage(); + if (!p_376460_.is(DamageTypeTags.IS_PROJECTILE) && p_376460_.getDirectEntity() instanceof LivingEntity livingentity) { this.blockUsingShield(livingentity); } - flag = true; -+ flag = p_21017_ <= 0; ++ flag = p_376610_ <= 0; } - if (p_21016_.is(DamageTypeTags.IS_FREEZING) && this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { -@@ -1118,10 +_,12 @@ - p_21017_ *= 0.75F; + if (p_376460_.is(DamageTypeTags.IS_FREEZING) && this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { +@@ -1135,10 +_,12 @@ + if (Float.isNaN(p_376610_) || Float.isInfinite(p_376610_)) { + p_376610_ = Float.MAX_VALUE; } ++ this.damageContainers.peek().setNewDamage(p_376610_); //update container with vanilla changes -+ this.damageContainers.peek().setNewDamage(p_21017_); //update container with vanilla changes - this.walkAnimation.setSpeed(1.5F); boolean flag1 = true; - if ((float)this.invulnerableTime > 10.0F && !p_21016_.is(DamageTypeTags.BYPASSES_COOLDOWN)) { - if (p_21017_ <= this.lastHurt) { + if ((float)this.invulnerableTime > 10.0F && !p_376460_.is(DamageTypeTags.BYPASSES_COOLDOWN)) { + if (p_376610_ <= this.lastHurt) { + this.damageContainers.pop(); return false; } -@@ -1130,12 +_,13 @@ +@@ -1147,12 +_,13 @@ flag1 = false; } else { - this.lastHurt = p_21017_; + this.lastHurt = p_376610_; - this.invulnerableTime = 20; + this.invulnerableTime = this.damageContainers.peek().getPostAttackInvulnerabilityTicks(); - this.actuallyHurt(p_21016_, p_21017_); + this.actuallyHurt(p_376221_, p_376460_, p_376610_); this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -+ p_21017_ = this.damageContainers.peek().getNewDamage(); //update local with container value - Entity entity = p_21016_.getEntity(); ++ p_376610_ = this.damageContainers.peek().getNewDamage(); //update local with container value + Entity entity = p_376460_.getEntity(); if (entity != null) { if (entity instanceof LivingEntity livingentity1 -@@ -1147,9 +_,9 @@ +@@ -1164,9 +_,9 @@ if (entity instanceof Player player1) { this.lastHurtByPlayerTime = 100; this.lastHurtByPlayer = player1; @@ -243,40 +273,24 @@ this.lastHurtByPlayer = player; } else { this.lastHurtByPlayer = null; -@@ -1220,6 +_,7 @@ - CriteriaTriggers.PLAYER_HURT_ENTITY.trigger((ServerPlayer)entity, this, p_21016_, f, p_21017_, flag); +@@ -1237,6 +_,7 @@ + CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverplayer1, this, p_376460_, f, p_376610_, flag); } + this.damageContainers.pop(); return flag2; } } -@@ -1240,7 +_,7 @@ - +@@ -1259,7 +_,7 @@ for (InteractionHand interactionhand : InteractionHand.values()) { ItemStack itemstack1 = this.getItemInHand(interactionhand); -- if (itemstack1.is(Items.TOTEM_OF_UNDYING)) { -+ if (itemstack1.is(Items.TOTEM_OF_UNDYING) && net.neoforged.neoforge.common.CommonHooks.onLivingUseTotem(this, p_21263_, itemstack1, interactionhand)) { + deathprotection = itemstack1.get(DataComponents.DEATH_PROTECTION); +- if (deathprotection != null) { ++ if (deathprotection != null && net.neoforged.neoforge.common.CommonHooks.onLivingUseTotem(this, p_21263_, itemstack1, interactionhand)) { itemstack = itemstack1.copy(); itemstack1.shrink(1); break; -@@ -1249,13 +_,13 @@ - - if (itemstack != null) { - if (this instanceof ServerPlayer serverplayer) { -- serverplayer.awardStat(Stats.ITEM_USED.get(Items.TOTEM_OF_UNDYING)); -+ serverplayer.awardStat(Stats.ITEM_USED.get(Items.TOTEM_OF_UNDYING), 1); - CriteriaTriggers.USED_TOTEM.trigger(serverplayer, itemstack); - this.gameEvent(GameEvent.ITEM_INTERACT_FINISH); - } - - this.setHealth(1.0F); -- this.removeAllEffects(); -+ this.removeEffectsCuredBy(net.neoforged.neoforge.common.EffectCures.PROTECTED_BY_TOTEM); - this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 900, 1)); - this.addEffect(new MobEffectInstance(MobEffects.ABSORPTION, 100, 1)); - this.addEffect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 800, 0)); -@@ -1326,6 +_,7 @@ +@@ -1343,6 +_,7 @@ } public void die(DamageSource p_21014_) { @@ -284,45 +298,45 @@ if (!this.isRemoved() && !this.dead) { Entity entity = p_21014_.getEntity(); LivingEntity livingentity = this.getKillCredit(); -@@ -1361,7 +_,7 @@ - if (!this.level().isClientSide) { +@@ -1378,7 +_,7 @@ + if (this.level() instanceof ServerLevel serverlevel) { boolean flag = false; if (p_21269_ instanceof WitherBoss) { -- if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), p_21269_)) { +- if (serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, p_21269_)) { BlockPos blockpos = this.blockPosition(); BlockState blockstate = Blocks.WITHER_ROSE.defaultBlockState(); if (this.level().getBlockState(blockpos).isAir() && blockstate.canSurvive(this.level(), blockpos)) { -@@ -1379,6 +_,7 @@ +@@ -1396,6 +_,7 @@ } protected void dropAllDeathLoot(ServerLevel p_348524_, DamageSource p_21192_) { + this.captureDrops(new java.util.ArrayList<>()); boolean flag = this.lastHurtByPlayerTime > 0; if (this.shouldDropLoot() && p_348524_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - this.dropFromLootTable(p_21192_, flag); -@@ -1387,6 +_,10 @@ + this.dropFromLootTable(p_348524_, p_21192_, flag); +@@ -1404,6 +_,10 @@ - this.dropEquipment(); - this.dropExperience(p_21192_.getEntity()); + this.dropEquipment(p_348524_); + this.dropExperience(p_348524_, p_21192_.getEntity()); + + Collection drops = captureDrops(null); + if (!net.neoforged.neoforge.common.CommonHooks.onLivingDrops(this, p_21192_, drops, lastHurtByPlayerTime > 0)) + drops.forEach(e -> level().addFreshEntity(e)); } - protected void dropEquipment() { -@@ -1399,7 +_,8 @@ + protected void dropEquipment(ServerLevel p_376330_) { +@@ -1415,7 +_,8 @@ this.isAlwaysExperienceDropper() - || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT) + || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && p_376909_.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT) )) { -- ExperienceOrb.award(serverlevel, this.position(), this.getExperienceReward(serverlevel, p_345346_)); -+ int reward = net.neoforged.neoforge.event.EventHooks.getExperienceDrop(this, this.lastHurtByPlayer, this.getExperienceReward(serverlevel, p_345346_)); +- ExperienceOrb.award(p_376909_, this.position(), this.getExperienceReward(p_376909_, p_345346_)); ++ int reward = net.neoforged.neoforge.event.EventHooks.getExperienceDrop(this, this.lastHurtByPlayer, this.getExperienceReward(p_376909_, p_345346_)); + ExperienceOrb.award((ServerLevel) this.level(), this.position(), reward); } } -@@ -1440,6 +_,11 @@ +@@ -1496,6 +_,11 @@ } public void knockback(double p_147241_, double p_147242_, double p_147243_) { @@ -334,7 +348,7 @@ p_147241_ *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); if (!(p_147241_ <= 0.0)) { this.hasImpulse = true; -@@ -1521,15 +_,9 @@ +@@ -1569,15 +_,9 @@ } else { BlockPos blockpos = this.blockPosition(); BlockState blockstate = this.getInBlockState(); @@ -353,7 +367,27 @@ } } -@@ -1558,6 +_,11 @@ +@@ -1595,10 +_,18 @@ + return !this.isRemoved() && this.getHealth() > 0.0F; + } + ++ /** @deprecated Neo: use {@link #isLookingAtMe(LivingEntity, double, boolean, boolean, java.util.function.BiPredicate, DoubleSupplier...)} instead */ ++ @Deprecated + public boolean isLookingAtMe( + LivingEntity p_379420_, double p_379671_, boolean p_380253_, boolean p_380067_, Predicate p_380351_, DoubleSupplier... p_380073_ + ) { +- if (!p_380351_.test(p_379420_)) { ++ return isLookingAtMe(p_379420_, p_379671_, p_380253_, p_380067_, (observer, target) -> p_380351_.test(observer), p_380073_); ++ } ++ ++ public boolean isLookingAtMe( ++ LivingEntity p_379420_, double p_379671_, boolean p_380253_, boolean p_380067_, java.util.function.BiPredicate p_380351_, DoubleSupplier... p_380073_ ++ ) { ++ if (!p_380351_.test(p_379420_, this)) { + return false; + } else { + Vec3 vec3 = p_379420_.getViewVector(1.0F).normalize(); +@@ -1630,6 +_,11 @@ @Override public boolean causeFallDamage(float p_147187_, float p_147188_, DamageSource p_147189_) { @@ -365,7 +399,7 @@ boolean flag = super.causeFallDamage(p_147187_, p_147188_, p_147189_); int i = this.calculateFallDamage(p_147187_, p_147188_); if (i > 0) { -@@ -1585,9 +_,10 @@ +@@ -1657,9 +_,10 @@ int i = Mth.floor(this.getX()); int j = Mth.floor(this.getY() - 0.2F); int k = Mth.floor(this.getZ()); @@ -378,7 +412,7 @@ this.playSound(soundtype.getFallSound(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F); } } -@@ -1616,6 +_,8 @@ +@@ -1688,6 +_,8 @@ if (!(p_330394_ <= 0.0F)) { int i = (int)Math.max(1.0F, p_330394_ / 4.0F); @@ -386,8 +420,8 @@ + if (true) return; //Neo: Invalidates the loop. Armor damage happens in common hook. for (EquipmentSlot equipmentslot : p_331314_) { ItemStack itemstack = this.getItemBySlot(equipmentslot); - if (itemstack.getItem() instanceof ArmorItem && itemstack.canBeHurtBy(p_330843_)) { -@@ -1648,6 +_,7 @@ + Equippable equippable = itemstack.get(DataComponents.EQUIPPABLE); +@@ -1721,6 +_,7 @@ p_21194_ = Math.max(f / 25.0F, 0.0F); float f2 = f1 - p_21194_; if (f2 > 0.0F && f2 < 3.4028235E37F) { @@ -395,7 +429,7 @@ if (this instanceof ServerPlayer) { ((ServerPlayer)this).awardStat(Stats.DAMAGE_RESISTED, Math.round(f2 * 10.0F)); } else if (p_21193_.getEntity() instanceof ServerPlayer) { -@@ -1670,6 +_,7 @@ +@@ -1743,6 +_,7 @@ if (f3 > 0.0F) { p_21194_ = CombatRules.getDamageAfterMagicAbsorb(p_21194_, f3); @@ -403,10 +437,10 @@ } return p_21194_; -@@ -1679,11 +_,14 @@ +@@ -1752,11 +_,14 @@ - protected void actuallyHurt(DamageSource p_21240_, float p_21241_) { - if (!this.isInvulnerableTo(p_21240_)) { + protected void actuallyHurt(ServerLevel p_376745_, DamageSource p_21240_, float p_21241_) { + if (!this.isInvulnerableTo(p_376745_, p_21240_)) { - p_21241_ = this.getDamageAfterArmorAbsorb(p_21240_, p_21241_); - p_21241_ = this.getDamageAfterMagicAbsorb(p_21240_, p_21241_); - float f1 = Math.max(p_21241_ - this.getAbsorptionAmount(), 0.0F); @@ -423,7 +457,7 @@ if (f > 0.0F && f < 3.4028235E37F && p_21240_.getEntity() instanceof ServerPlayer serverplayer) { serverplayer.awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f * 10.0F)); } -@@ -1691,9 +_,10 @@ +@@ -1764,9 +_,10 @@ if (f1 != 0.0F) { this.getCombatTracker().recordDamage(p_21240_, f1); this.setHealth(this.getHealth() - f1); @@ -435,7 +469,7 @@ } } -@@ -1747,6 +_,8 @@ +@@ -1820,6 +_,8 @@ } public void swing(InteractionHand p_21012_, boolean p_21013_) { @@ -444,7 +478,7 @@ if (!this.swinging || this.swingTime >= this.getCurrentSwingDuration() / 2 || this.swingTime < 0) { this.swingTime = -1; this.swinging = true; -@@ -1859,8 +_,10 @@ +@@ -1933,8 +_,10 @@ private void swapHandItems() { ItemStack itemstack = this.getItemBySlot(EquipmentSlot.OFFHAND); @@ -457,7 +491,7 @@ } @Override -@@ -2064,15 +_,18 @@ +@@ -2152,15 +_,18 @@ } this.hasImpulse = true; @@ -478,42 +512,54 @@ } protected float getWaterSlowDown() { -@@ -2097,7 +_,8 @@ - } - +@@ -2184,7 +_,7 @@ + public void travel(Vec3 p_21280_) { + if (this.isControlledByLocalInstance()) { FluidState fluidstate = this.level().getFluidState(this.blockPosition()); -- if (this.isInWater() && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { +- if ((this.isInWater() || this.isInLava()) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { + if ((this.isInWater() || (this.isInFluidType(fluidstate) && fluidstate.getFluidType() != net.neoforged.neoforge.common.NeoForgeMod.LAVA_TYPE.value())) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { -+ if (this.isInWater() || (this.isInFluidType(fluidstate) && !this.moveInFluid(fluidstate, p_21280_, d0))) { - double d9 = this.getY(); - float f4 = this.isSprinting() ? 0.9F : this.getWaterSlowDown(); - float f5 = 0.02F; -@@ -2115,6 +_,7 @@ - f4 = 0.96F; - } + this.travelInFluid(p_21280_); + } else if (this.isFallFlying()) { + this.travelFallFlying(); +@@ -2196,7 +_,7 @@ + + private void travelInAir(Vec3 p_362457_) { + BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); +- float f = this.onGround() ? this.level().getBlockState(blockpos).getBlock().getFriction() : 1.0F; ++ float f = this.onGround() ? this.level().getBlockState(blockpos).getFriction(this.level(), blockpos, this) : 1.0F; + float f1 = f * 0.91F; + Vec3 vec3 = this.handleRelativeFrictionAndCalculateMovement(p_362457_, f); + double d0 = vec3.y; +@@ -2219,11 +_,19 @@ + } + } -+ f5 *= (float)this.getAttributeValue(net.neoforged.neoforge.common.NeoForgeMod.SWIM_SPEED); - this.moveRelative(f5, p_21280_); - this.move(MoverType.SELF, this.getDeltaMovement()); - Vec3 vec36 = this.getDeltaMovement(); -@@ -2128,6 +_,7 @@ - if (this.horizontalCollision && this.isFree(vec32.x, vec32.y + 0.6F - this.getY() + d9, vec32.z)) { - this.setDeltaMovement(vec32.x, 0.3F, vec32.z); - } -+ } - } else if (this.isInLava() && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) { - double d8 = this.getY(); - this.moveRelative(0.02F, p_21280_); -@@ -2190,7 +_,7 @@ - } - } else { - BlockPos blockpos = this.getBlockPosBelowThatAffectsMyMovement(); -- float f2 = this.level().getBlockState(blockpos).getBlock().getFriction(); -+ float f2 = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getFriction(level(), this.getBlockPosBelowThatAffectsMyMovement(), this); - float f3 = this.onGround() ? f2 * 0.91F : 0.91F; - Vec3 vec35 = this.handleRelativeFrictionAndCalculateMovement(p_21280_, f2); - double d2 = vec35.y; -@@ -2284,7 +_,7 @@ ++ /** ++ * @deprecated Neo: use {@link #travelInFluid(Vec3, FluidState)} instead ++ */ ++ @Deprecated + private void travelInFluid(Vec3 p_365480_) { ++ travelInFluid(p_365480_, net.minecraft.world.level.material.Fluids.EMPTY.defaultFluidState()); ++ } ++ ++ private void travelInFluid(Vec3 p_365480_, FluidState fluidState) { + boolean flag = this.getDeltaMovement().y <= 0.0; + double d0 = this.getY(); + double d1 = this.getEffectiveGravity(); +- if (this.isInWater()) { ++ if (this.isInWater() || (this.isInFluidType(fluidState) && !this.moveInFluid(fluidState, p_365480_, d1))) { + float f = this.isSprinting() ? 0.9F : this.getWaterSlowDown(); + float f1 = 0.02F; + float f2 = (float)this.getAttributeValue(Attributes.WATER_MOVEMENT_EFFICIENCY); +@@ -2240,6 +_,7 @@ + f = 0.96F; + } + ++ f1 *= (float)this.getAttributeValue(net.neoforged.neoforge.common.NeoForgeMod.SWIM_SPEED); + this.moveRelative(f1, p_365480_); + this.move(MoverType.SELF, this.getDeltaMovement()); + Vec3 vec3 = this.getDeltaMovement(); +@@ -2389,7 +_,7 @@ double d0 = Mth.clamp(p_21298_.x, -0.15F, 0.15F); double d1 = Mth.clamp(p_21298_.z, -0.15F, 0.15F); double d2 = Math.max(p_21298_.y, -0.15F); @@ -522,7 +568,7 @@ d2 = 0.0; } -@@ -2466,6 +_,7 @@ +@@ -2574,6 +_,7 @@ }; ItemStack itemstack1 = this.getItemBySlot(equipmentslot); if (this.equipmentHasChanged(itemstack, itemstack1)) { @@ -530,8 +576,8 @@ if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -@@ -2637,6 +_,9 @@ - this.level().getProfiler().push("jump"); +@@ -2733,6 +_,9 @@ + profilerfiller.push("jump"); if (this.jumping && this.isAffectedByFluids()) { double d3; + net.neoforged.neoforge.fluids.FluidType fluidType = this.getMaxHeightFluidType(); @@ -540,7 +586,7 @@ if (this.isInLava()) { d3 = this.getFluidHeight(FluidTags.LAVA); } else { -@@ -2647,15 +_,17 @@ +@@ -2743,15 +_,17 @@ double d4 = this.getFluidJumpThreshold(); if (!flag || this.onGround() && !(d3 > d4)) { if (!this.isInLava() || this.onGround() && !(d3 > d4)) { @@ -560,16 +606,7 @@ } } else { this.noJumpDelay = 0; -@@ -2720,6 +_,8 @@ - boolean flag = this.getSharedFlag(7); - if (flag && !this.onGround() && !this.isPassenger() && !this.hasEffect(MobEffects.LEVITATION)) { - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.CHEST); -+ flag = itemstack.canElytraFly(this) && itemstack.elytraFlightTick(this, this.fallFlyTicks); -+ if (false) //Neo: Moved to ElytraItem - if (itemstack.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(itemstack)) { - flag = true; - int i = this.fallFlyTicks + 1; -@@ -2979,8 +_,11 @@ +@@ -3104,8 +_,11 @@ private void updatingUsingItem() { if (this.isUsingItem()) { @@ -583,7 +620,7 @@ this.updateUsingItem(this.useItem); } else { this.stopUsingItem(); -@@ -2989,12 +_,15 @@ +@@ -3114,8 +_,11 @@ } protected void updateUsingItem(ItemStack p_147201_) { @@ -591,16 +628,12 @@ + this.useItemRemaining = net.neoforged.neoforge.event.EventHooks.onItemUseTick(this, p_147201_, this.getUseItemRemainingTicks()); + if (this.getUseItemRemainingTicks() > 0) p_147201_.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); - if (this.shouldTriggerItemUseEffects()) { - this.triggerItemUseEffects(p_147201_, 5); - } - - if (--this.useItemRemaining == 0 && !this.level().isClientSide && !p_147201_.useOnRelease()) { + if (--this.useItemRemaining <= 0 && !this.level().isClientSide && !p_147201_.useOnRelease()) { this.completeUsingItem(); } } -@@ -3029,8 +_,10 @@ +@@ -3143,8 +_,10 @@ public void startUsingItem(InteractionHand p_21159_) { ItemStack itemstack = this.getItemInHand(p_21159_); if (!itemstack.isEmpty() && !this.isUsingItem()) { @@ -612,17 +645,17 @@ if (!this.level().isClientSide) { this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(2, p_21159_ == InteractionHand.OFF_HAND); -@@ -3111,7 +_,8 @@ +@@ -3207,7 +_,8 @@ + this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { - this.triggerItemUseEffects(this.useItem, 16); - ItemStack itemstack = this.useItem.finishUsingItem(this.level(), this); + ItemStack copy = this.useItem.copy(); + ItemStack itemstack = net.neoforged.neoforge.event.EventHooks.onItemUseFinish(this, copy, getUseItemRemainingTicks(), this.useItem.finishUsingItem(this.level(), this)); if (itemstack != this.useItem) { this.setItemInHand(interactionhand, itemstack); } -@@ -3136,7 +_,11 @@ +@@ -3235,7 +_,11 @@ public void releaseUsingItem() { if (!this.useItem.isEmpty()) { @@ -634,7 +667,7 @@ if (this.useItem.useOnRelease()) { this.updatingUsingItem(); } -@@ -3146,6 +_,7 @@ +@@ -3245,6 +_,7 @@ } public void stopUsingItem() { @@ -642,16 +675,16 @@ if (!this.level().isClientSide) { boolean flag = this.isUsingItem(); this.setLivingEntityFlag(1, false); -@@ -3161,7 +_,7 @@ - public boolean isBlocking() { +@@ -3265,7 +_,7 @@ + public ItemStack getItemBlockingWith() { if (this.isUsingItem() && !this.useItem.isEmpty()) { Item item = this.useItem.getItem(); -- return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem, this) - this.useItemRemaining >= 5; -+ return !this.useItem.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHIELD_BLOCK) ? false : item.getUseDuration(this.useItem, this) - this.useItemRemaining >= 5; - } else { - return false; - } -@@ -3302,8 +_,8 @@ +- if (item.getUseAnimation(this.useItem) != ItemUseAnimation.BLOCK) { ++ if (!this.useItem.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHIELD_BLOCK)) { + return null; + } else { + return item.getUseDuration(this.useItem, this) - this.useItemRemaining < 5 ? null : this.useItem; +@@ -3410,8 +_,8 @@ } BlockState blockstate = this.level().getBlockState(p_21141_); @@ -662,11 +695,11 @@ } this.setPose(Pose.SLEEPING); -@@ -3318,15 +_,17 @@ +@@ -3426,15 +_,17 @@ } private boolean checkBedExists() { -- return this.getSleepingPos().map(p_352707_ -> this.level().getBlockState(p_352707_).getBlock() instanceof BedBlock).orElse(false); +- return this.getSleepingPos().map(p_381383_ -> this.level().getBlockState(p_381383_).getBlock() instanceof BedBlock).orElse(false); + // Neo: Overwrite the vanilla instanceof BedBlock check with isBed and fire the CanContinueSleepingEvent. + boolean hasBed = this.getSleepingPos().map(pos -> this.level().getBlockState(pos).isBed(this.level(), pos, this)).orElse(false); + return net.neoforged.neoforge.event.EventHooks.canEntityContinueSleeping(this, hasBed ? null : Player.BedSleepingProblem.NOT_POSSIBLE_HERE); @@ -683,7 +716,7 @@ Vec3 vec31 = BedBlock.findStandUpPosition(this.getType(), this.level(), p_261435_, direction, this.getYRot()).orElseGet(() -> { BlockPos blockpos = p_261435_.above(); return new Vec3((double)blockpos.getX() + 0.5, (double)blockpos.getY() + 0.1, (double)blockpos.getZ() + 0.5); -@@ -3347,7 +_,9 @@ +@@ -3455,7 +_,9 @@ @Nullable public Direction getBedOrientation() { BlockPos blockpos = this.getSleepingPos().orElse(null); @@ -694,7 +727,7 @@ } @Override -@@ -3356,11 +_,11 @@ +@@ -3464,7 +_,7 @@ } public ItemStack getProjectile(ItemStack p_21272_) { @@ -702,61 +735,17 @@ + return net.neoforged.neoforge.common.CommonHooks.getProjectile(this, p_21272_, ItemStack.EMPTY); } - public final ItemStack eat(Level p_21067_, ItemStack p_21068_) { -- FoodProperties foodproperties = p_21068_.get(DataComponents.FOOD); -+ FoodProperties foodproperties = p_21068_.getFoodProperties(this); - return foodproperties != null ? this.eat(p_21067_, p_21068_, foodproperties) : p_21068_; - } - -@@ -3411,6 +_,38 @@ - return p_320526_ == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND; + private static byte entityEventForEquipmentBreak(EquipmentSlot p_21267_) { +@@ -3519,6 +_,8 @@ } -+ /** -+ * Neo: Removes all potion effects that have the given {@link net.neoforged.neoforge.common.EffectCure} in their set of cures -+ * @param cure the EffectCure being used -+ */ -+ public boolean removeEffectsCuredBy(net.neoforged.neoforge.common.EffectCure cure) { -+ if (this.level().isClientSide) -+ return false; -+ boolean ret = false; -+ Iterator itr = this.activeEffects.values().iterator(); -+ while (itr.hasNext()) { -+ MobEffectInstance effect = itr.next(); -+ if (effect.getCures().contains(cure) && !net.neoforged.neoforge.event.EventHooks.onEffectRemoved(this, effect, cure)) { -+ this.onEffectRemoved(effect); -+ itr.remove(); -+ ret = true; -+ this.effectsDirty = true; -+ } -+ } -+ return ret; -+ } -+ -+ /** -+ * Neo: Returns true if the entity's rider (EntityPlayer) should face forward when mounted. -+ * currently only used in vanilla code by pigs. -+ * -+ * @param player The player who is riding the entity. -+ * @return If the player should orient the same direction as this entity. -+ */ -+ public boolean shouldRiderFaceForward(Player player) { -+ return this instanceof net.minecraft.world.entity.animal.Pig; -+ } -+ - @Override - public AABB getBoundingBoxForCulling() { - if (this.getItemBySlot(EquipmentSlot.HEAD).is(Items.DRAGON_HEAD)) { -@@ -3422,6 +_,8 @@ - } - - public EquipmentSlot getEquipmentSlotForItem(ItemStack p_147234_) { + public final EquipmentSlot getEquipmentSlotForItem(ItemStack p_147234_) { + final EquipmentSlot slot = p_147234_.getEquipmentSlot(); + if (slot != null) return slot; // FORGE: Allow modders to set a non-default equipment slot for a stack; e.g. a non-armor chestplate-slot item - Equipable equipable = Equipable.get(p_147234_); - if (equipable != null) { - EquipmentSlot equipmentslot = equipable.getEquipmentSlot(); -@@ -3507,7 +_,7 @@ + Equippable equippable = p_147234_.get(DataComponents.EQUIPPABLE); + return equippable != null && this.canUseSlot(equippable.slot()) ? equippable.slot() : EquipmentSlot.MAINHAND; + } +@@ -3604,7 +_,7 @@ } public boolean canDisableShield() { diff --git a/patches/net/minecraft/world/entity/Mob.java.patch b/patches/net/minecraft/world/entity/Mob.java.patch index 5ed8d6f87e..715ee233ce 100644 --- a/patches/net/minecraft/world/entity/Mob.java.patch +++ b/patches/net/minecraft/world/entity/Mob.java.patch @@ -1,16 +1,18 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -131,6 +_,9 @@ +@@ -135,6 +_,11 @@ private Leashable.LeashData leashData; private BlockPos restrictCenter = BlockPos.ZERO; private float restrictRadius = -1.0F; + @Nullable -+ private MobSpawnType spawnType; ++ private EntitySpawnReason spawnType; + private boolean spawnCancelled = false; ++ /** Neo: Prevent immediate spawning from conversions to capture conversion results for events */ ++ protected boolean preventConversionSpawns = false; protected Mob(EntityType p_21368_, Level p_21369_) { super(p_21368_, p_21369_); -@@ -237,7 +_,10 @@ +@@ -241,7 +_,10 @@ } public void setTarget(@Nullable LivingEntity p_21544_) { @@ -22,7 +24,7 @@ } @Override -@@ -346,6 +_,12 @@ +@@ -344,6 +_,12 @@ if (!this.level().isClientSide && this.tickCount % 5 == 0) { this.updateControlFlags(); } @@ -30,12 +32,12 @@ + // Neo: Animal armor tick patch + if (this.canUseSlot(EquipmentSlot.BODY)) { + ItemStack stack = this.getBodyArmorItem(); -+ if (isBodyArmorItem(stack)) stack.onAnimalArmorTick(level(), this); ++ if (stack.has(DataComponents.EQUIPPABLE)) stack.onAnimalArmorTick(level(), this); + } } protected void updateControlFlags() { -@@ -425,6 +_,9 @@ +@@ -423,6 +_,9 @@ if (this.isNoAi()) { p_21484_.putBoolean("NoAI", this.isNoAi()); } @@ -45,14 +47,14 @@ } @Override -@@ -484,6 +_,14 @@ +@@ -482,6 +_,14 @@ } this.setNoAi(p_21450_.getBoolean("NoAI")); + + if (p_21450_.contains("neoforge:spawn_type")) { + try { -+ this.spawnType = MobSpawnType.valueOf(p_21450_.getString("neoforge:spawn_type")); ++ this.spawnType = EntitySpawnReason.valueOf(p_21450_.getString("neoforge:spawn_type")); + } catch (Exception ex) { + p_21450_.remove("neoforge:spawn_type"); + } @@ -60,24 +62,22 @@ } @Override -@@ -539,7 +_,7 @@ +@@ -534,7 +_,7 @@ && this.canPickUpLoot() && this.isAlive() && !this.dead -- && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ && net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this)) { +- && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ && net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, this)) { Vec3i vec3i = this.getPickupReach(); for (ItemEntity itementity : this.level() -@@ -666,6 +_,10 @@ - - private double getApproximateAttackDamageWithItem(ItemStack p_330413_) { - ItemAttributeModifiers itemattributemodifiers = p_330413_.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); -+ +@@ -666,6 +_,8 @@ + private double getApproximateAttributeWith(ItemStack p_371461_, Holder p_371421_, EquipmentSlot p_371891_) { + double d0 = this.getAttributes().hasAttribute(p_371421_) ? this.getAttributeBaseValue(p_371421_) : 0.0; + ItemAttributeModifiers itemattributemodifiers = p_371461_.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); + // Neo: Respect gameplay modifiers -+ itemattributemodifiers = p_330413_.getAttributeModifiers(); -+ - return itemattributemodifiers.compute(this.getAttributeBaseValue(Attributes.ATTACK_DAMAGE), EquipmentSlot.MAINHAND); ++ itemattributemodifiers = p_371461_.getAttributeModifiers(); + return itemattributemodifiers.compute(d0, p_371891_); } @@ -701,6 +_,7 @@ @@ -88,7 +88,7 @@ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { this.discard(); } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { -@@ -1133,6 +_,11 @@ +@@ -1127,6 +_,11 @@ } } @@ -98,17 +98,25 @@ + @Deprecated + @org.jetbrains.annotations.ApiStatus.OverrideOnly @Nullable - public SpawnGroupData finalizeSpawn(ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, MobSpawnType p_21436_, @Nullable SpawnGroupData p_21437_) { - RandomSource randomsource = p_21434_.getRandom(); -@@ -1144,6 +_,7 @@ + public SpawnGroupData finalizeSpawn( + ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, EntitySpawnReason p_363352_, @Nullable SpawnGroupData p_21437_ +@@ -1140,6 +_,7 @@ } this.setLeftHanded(randomsource.nextFloat() < 0.05F); -+ this.spawnType = p_21436_; ++ this.spawnType = p_363352_; return p_21437_; } -@@ -1470,14 +_,24 @@ +@@ -1281,6 +_,7 @@ + } else { + p_371709_.type().convert(this, t, p_371709_); + p_371266_.finalizeConversion(t); ++ if (!preventConversionSpawns) + if (this.level() instanceof ServerLevel serverlevel) { + serverlevel.addFreshEntity(t); + } +@@ -1452,14 +_,24 @@ } @Override @@ -135,19 +143,19 @@ public void removeFreeWill() { this.removeAllGoals(p_351790_ -> true); @@ -1503,5 +_,40 @@ - public ItemStack getPickResult() { - SpawnEggItem spawneggitem = SpawnEggItem.byId(this.getType()); - return spawneggitem == null ? null : new ItemStack(spawneggitem); + @VisibleForTesting + public float[] getArmorDropChances() { + return this.armorDropChances; + } + + /** -+ * Returns the type of spawn that created this mob, if applicable. -+ * If it could not be determined, this will return null. -+ *

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

++ * This is set via {@link Mob#finalizeSpawn}, so you should not call this from within that method, instead using the parameter. ++ */ + @Nullable -+ public final MobSpawnType getSpawnType() { ++ public final EntitySpawnReason getSpawnType() { + return this.spawnType; + } + diff --git a/patches/net/minecraft/world/entity/Shearable.java.patch b/patches/net/minecraft/world/entity/Shearable.java.patch index 251e6be55b..58aef72f93 100644 --- a/patches/net/minecraft/world/entity/Shearable.java.patch +++ b/patches/net/minecraft/world/entity/Shearable.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/Shearable.java +++ b/net/minecraft/world/entity/Shearable.java -@@ -2,8 +_,20 @@ - +@@ -4,8 +_,20 @@ import net.minecraft.sounds.SoundSource; + import net.minecraft.world.item.ItemStack; -public interface Shearable { +/** @@ -11,13 +11,13 @@ +@Deprecated +public interface Shearable extends net.neoforged.neoforge.common.IShearable { + /** -+ * @deprecated Neo: Use {@link net.neoforged.neoforge.common.IShearable#onSheared(net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos, int)} instead. ++ * @deprecated Neo: Use {@link net.neoforged.neoforge.common.IShearable#onSheared(net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos)} instead. + */ + @Deprecated - void shear(SoundSource p_21749_); + void shear(ServerLevel p_376429_, SoundSource p_21749_, ItemStack p_372963_); + /** -+ * @deprecated Neo: Use {@link net.neoforged.neoforge.common.IShearable#isShearable(net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos)} instead. ++ * @deprecated Neo: Use {@link net.neoforged.neoforge.common.IShearable#isShearable(net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos)} instead. + */ + @Deprecated boolean readyForShearing(); diff --git a/patches/net/minecraft/world/entity/SpawnPlacements.java.patch b/patches/net/minecraft/world/entity/SpawnPlacements.java.patch index 0be5926d4c..4717f19fc6 100644 --- a/patches/net/minecraft/world/entity/SpawnPlacements.java.patch +++ b/patches/net/minecraft/world/entity/SpawnPlacements.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/SpawnPlacements.java +++ b/net/minecraft/world/entity/SpawnPlacements.java -@@ -46,6 +_,10 @@ +@@ -47,6 +_,10 @@ public class SpawnPlacements { private static final Map, SpawnPlacements.Data> DATA_BY_TYPE = Maps.newHashMap(); @@ -11,13 +11,13 @@ private static void register( EntityType p_21755_, SpawnPlacementType p_321847_, Heightmap.Types p_21757_, SpawnPlacements.SpawnPredicate p_21758_ ) { -@@ -73,7 +_,13 @@ - EntityType p_217075_, ServerLevelAccessor p_217076_, MobSpawnType p_217077_, BlockPos p_217078_, RandomSource p_217079_ +@@ -74,7 +_,13 @@ + EntityType p_217075_, ServerLevelAccessor p_217076_, EntitySpawnReason p_361433_, BlockPos p_217078_, RandomSource p_217079_ ) { SpawnPlacements.Data spawnplacements$data = DATA_BY_TYPE.get(p_217075_); -- return spawnplacements$data == null || ((SpawnPredicate)spawnplacements$data.predicate).test(p_217075_, p_217076_, p_217077_, p_217078_, p_217079_); -+ boolean vanillaResult = spawnplacements$data == null || spawnplacements$data.predicate.test((EntityType)p_217075_, p_217076_, p_217077_, p_217078_, p_217079_); -+ return net.neoforged.neoforge.event.EventHooks.checkSpawnPlacements(p_217075_, p_217076_, p_217077_, p_217078_, p_217079_, vanillaResult); +- return spawnplacements$data == null || ((SpawnPredicate)spawnplacements$data.predicate).test(p_217075_, p_217076_, p_361433_, p_217078_, p_217079_); ++ boolean vanillaResult = spawnplacements$data == null || spawnplacements$data.predicate.test((EntityType)p_217075_, p_217076_, p_361433_, p_217078_, p_217079_); ++ return net.neoforged.neoforge.event.EventHooks.checkSpawnPlacements(p_217075_, p_217076_, p_361433_, p_217078_, p_217079_, vanillaResult); + } + + // Neo: Added to allow for checking if an entity has a spawn placement @@ -26,10 +26,10 @@ } static { -@@ -168,5 +_,16 @@ +@@ -183,5 +_,16 @@ @FunctionalInterface public interface SpawnPredicate { - boolean test(EntityType p_217081_, ServerLevelAccessor p_217082_, MobSpawnType p_217083_, BlockPos p_217084_, RandomSource p_217085_); + boolean test(EntityType p_217081_, ServerLevelAccessor p_217082_, EntitySpawnReason p_363558_, BlockPos p_217084_, RandomSource p_217085_); + } + + /** diff --git a/patches/net/minecraft/world/entity/TamableAnimal.java.patch b/patches/net/minecraft/world/entity/TamableAnimal.java.patch index e55032dd54..f7af6e6974 100644 --- a/patches/net/minecraft/world/entity/TamableAnimal.java.patch +++ b/patches/net/minecraft/world/entity/TamableAnimal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/TamableAnimal.java +++ b/net/minecraft/world/entity/TamableAnimal.java -@@ -220,11 +_,15 @@ +@@ -221,13 +_,16 @@ @Override public void die(DamageSource p_21809_) { @@ -9,11 +9,13 @@ + super.die(p_21809_); + + if (this.dead) - if (!this.level().isClientSide && this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES) && this.getOwner() instanceof ServerPlayer) { -- this.getOwner().sendSystemMessage(this.getCombatTracker().getDeathMessage()); -+ this.getOwner().sendSystemMessage(deathMessage); + if (this.level() instanceof ServerLevel serverlevel + && serverlevel.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES) + && this.getOwner() instanceof ServerPlayer serverplayer) { +- serverplayer.sendSystemMessage(this.getCombatTracker().getDeathMessage()); ++ serverplayer.sendSystemMessage(deathMessage); } - +- - super.die(p_21809_); } diff --git a/patches/net/minecraft/world/entity/ai/attributes/Attributes.java.patch b/patches/net/minecraft/world/entity/ai/attributes/Attributes.java.patch index ebf3e8fe30..af4927ccd1 100644 --- a/patches/net/minecraft/world/entity/ai/attributes/Attributes.java.patch +++ b/patches/net/minecraft/world/entity/ai/attributes/Attributes.java.patch @@ -1,22 +1,21 @@ --- a/net/minecraft/world/entity/ai/attributes/Attributes.java +++ b/net/minecraft/world/entity/ai/attributes/Attributes.java -@@ -54,7 +_,8 @@ - "generic.jump_strength", new RangedAttribute("attribute.name.generic.jump_strength", 0.42F, 0.0, 32.0).setSyncable(true) +@@ -45,7 +_,7 @@ + "jump_strength", new RangedAttribute("attribute.name.jump_strength", 0.42F, 0.0, 32.0).setSyncable(true) ); public static final Holder KNOCKBACK_RESISTANCE = register( -- "generic.knockback_resistance", new RangedAttribute("attribute.name.generic.knockback_resistance", 0.0, 0.0, 1.0) -+ // Neo: Convert Knockback Resistance to percent-based for more appropriate display using IAttributeExtension. -+ "generic.knockback_resistance", new net.neoforged.neoforge.common.PercentageAttribute("attribute.name.generic.knockback_resistance", 0.0, 0.0, 1.0) +- "knockback_resistance", new RangedAttribute("attribute.name.knockback_resistance", 0.0, 0.0, 1.0) ++ "knockback_resistance", new net.neoforged.neoforge.common.PercentageAttribute("attribute.name.knockback_resistance", 0.0, 0.0, 1.0) ); - public static final Holder LUCK = register( - "generic.luck", new RangedAttribute("attribute.name.generic.luck", 0.0, -1024.0, 1024.0).setSyncable(true) -@@ -72,7 +_,8 @@ - "generic.movement_efficiency", new RangedAttribute("attribute.name.generic.movement_efficiency", 0.0, 0.0, 1.0).setSyncable(true) + public static final Holder LUCK = register("luck", new RangedAttribute("attribute.name.luck", 0.0, -1024.0, 1024.0).setSyncable(true)); + public static final Holder MAX_ABSORPTION = register( +@@ -61,7 +_,8 @@ + "movement_efficiency", new RangedAttribute("attribute.name.movement_efficiency", 0.0, 0.0, 1.0).setSyncable(true) ); public static final Holder MOVEMENT_SPEED = register( -- "generic.movement_speed", new RangedAttribute("attribute.name.generic.movement_speed", 0.7, 0.0, 1024.0).setSyncable(true) +- "movement_speed", new RangedAttribute("attribute.name.movement_speed", 0.7, 0.0, 1024.0).setSyncable(true) + // Neo: Convert Movement Speed to percent-based for more appropriate display using IAttributeExtension. Use a scale factor of 1000 since movement speed has 0.001 units. -+ "generic.movement_speed", new net.neoforged.neoforge.common.PercentageAttribute("attribute.name.generic.movement_speed", 0.7, 0.0, 1024.0, 1000).setSyncable(true) ++ "movement_speed", new net.neoforged.neoforge.common.PercentageAttribute("attribute.name.movement_speed", 0.7, 0.0, 1024.0, 1000).setSyncable(true) ); public static final Holder OXYGEN_BONUS = register( - "generic.oxygen_bonus", new RangedAttribute("attribute.name.generic.oxygen_bonus", 0.0, 0.0, 1024.0).setSyncable(true) + "oxygen_bonus", new RangedAttribute("attribute.name.oxygen_bonus", 0.0, 0.0, 1024.0).setSyncable(true) diff --git a/patches/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch b/patches/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch index 6497c6493e..26208739b5 100644 --- a/patches/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch +++ b/patches/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java +++ b/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java -@@ -174,11 +_,12 @@ +@@ -177,11 +_,12 @@ .build(); public static AttributeSupplier getSupplier(EntityType p_22298_) { diff --git a/patches/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java.patch b/patches/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java.patch index dfe2740ab3..d88adceb0b 100644 --- a/patches/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java.patch +++ b/patches/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java.patch @@ -1,26 +1,21 @@ --- a/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java +++ b/net/minecraft/world/entity/ai/behavior/GiveGiftToHero.java -@@ -31,6 +_,8 @@ +@@ -22,6 +_,8 @@ private static final int MIN_TIME_BETWEEN_GIFTS = 600; private static final int MAX_TIME_BETWEEN_GIFTS = 6600; private static final int TIME_TO_DELAY_FOR_HEAD_TO_FINISH_TURNING = 20; + /** @deprecated Neo: use the {@link net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps#RAID_HERO_GIFTS data map} instead */ + @Deprecated - private static final Map> GIFTS = Util.make(Maps.newHashMap(), p_23020_ -> { - p_23020_.put(VillagerProfession.ARMORER, BuiltInLootTables.ARMORER_GIFT); - p_23020_.put(VillagerProfession.BUTCHER, BuiltInLootTables.BUTCHER_GIFT); -@@ -121,8 +_,12 @@ - return ImmutableList.of(new ItemStack(Items.POPPY)); + private static final Map> GIFTS = ImmutableMap.>builder() + .put(VillagerProfession.ARMORER, BuiltInLootTables.ARMORER_GIFT) + .put(VillagerProfession.BUTCHER, BuiltInLootTables.BUTCHER_GIFT) +@@ -112,7 +_,8 @@ + return BuiltInLootTables.BABY_VILLAGER_GIFT; } else { - VillagerProfession villagerprofession = p_23010_.getVillagerData().getProfession(); -- if (GIFTS.containsKey(villagerprofession)) { -- LootTable loottable = p_23010_.level().getServer().reloadableRegistries().getLootTable(GIFTS.get(villagerprofession)); -+ LootTable loottable = null; + VillagerProfession villagerprofession = p_372869_.getVillagerData().getProfession(); +- return GIFTS.getOrDefault(villagerprofession, BuiltInLootTables.UNEMPLOYED_GIFT); + var gift = net.minecraft.core.registries.BuiltInRegistries.VILLAGER_PROFESSION.wrapAsHolder(villagerprofession).getData(net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps.RAID_HERO_GIFTS); -+ if (gift != null) { -+ loottable = p_23010_.level().getServer().reloadableRegistries().getLootTable(gift.lootTable()); -+ } -+ if (loottable != null) { - LootParams lootparams = new LootParams.Builder((ServerLevel)p_23010_.level()) - .withParameter(LootContextParams.ORIGIN, p_23010_.position()) - .withParameter(LootContextParams.THIS_ENTITY, p_23010_) ++ return gift != null ? gift.lootTable() : BuiltInLootTables.UNEMPLOYED_GIFT; + } + } + diff --git a/patches/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch b/patches/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch index daa170bb51..88d24ac346 100644 --- a/patches/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch +++ b/patches/net/minecraft/world/entity/ai/behavior/StartAttacking.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/behavior/StartAttacking.java +++ b/net/minecraft/world/entity/ai/behavior/StartAttacking.java -@@ -30,7 +_,11 @@ - if (!p_258774_.canAttack(livingentity)) { +@@ -28,7 +_,11 @@ + if (!p_375685_.canAttack(livingentity)) { return false; } else { - p_258778_.set(livingentity); -+ net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent changeTargetEvent = net.neoforged.neoforge.common.CommonHooks.onLivingChangeTarget(p_258774_, livingentity, net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); ++ net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent changeTargetEvent = net.neoforged.neoforge.common.CommonHooks.onLivingChangeTarget(p_375685_, livingentity, net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); + if (changeTargetEvent.isCanceled() || changeTargetEvent.getNewAboutToBeSetTarget() == null) + return false; + diff --git a/patches/net/minecraft/world/entity/ai/behavior/Swim.java.patch b/patches/net/minecraft/world/entity/ai/behavior/Swim.java.patch index b9fd7fcb35..f1d7a4d423 100644 --- a/patches/net/minecraft/world/entity/ai/behavior/Swim.java.patch +++ b/patches/net/minecraft/world/entity/ai/behavior/Swim.java.patch @@ -3,7 +3,7 @@ @@ -14,7 +_,7 @@ } - public static boolean shouldSwim(Mob p_316787_) { + public static boolean shouldSwim(T p_316787_) { - return p_316787_.isInWater() && p_316787_.getFluidHeight(FluidTags.WATER) > p_316787_.getFluidJumpThreshold() || p_316787_.isInLava(); + return p_316787_.isInWater() && p_316787_.getFluidHeight(FluidTags.WATER) > p_316787_.getFluidJumpThreshold() || p_316787_.isInLava() || p_316787_.isInFluidType((fluidType, height) -> p_316787_.canSwimInFluidType(fluidType) && height > p_316787_.getFluidJumpThreshold()); } diff --git a/patches/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch b/patches/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch index a0d2d9d38f..a0ffc786d8 100644 --- a/patches/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch +++ b/patches/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch @@ -4,8 +4,8 @@ if (!super.canUse()) { return false; } else { -- return !this.mob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) -+ return !net.neoforged.neoforge.common.CommonHooks.canEntityDestroy(this.mob.level(), this.doorPos, this.mob) +- return !getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ return !net.neoforged.neoforge.common.CommonHooks.canEntityDestroy(getServerLevel(this.mob.level()), this.doorPos, this.mob) ? false : this.isValidDifficulty(this.mob.level().getDifficulty()) && !this.isOpen(); } diff --git a/patches/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/patches/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch index f817b98919..64b9d0f7b7 100644 --- a/patches/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ b/patches/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -4,8 +4,8 @@ if (this.eatAnimationTick == this.adjustedTickDelay(4)) { BlockPos blockpos = this.mob.blockPosition(); if (IS_TALL_GRASS.test(this.level.getBlockState(blockpos))) { -- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level, this.mob)) { +- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.level), this.mob)) { this.level.destroyBlock(blockpos, false); } @@ -13,8 +13,8 @@ } else { BlockPos blockpos1 = blockpos.below(); if (this.level.getBlockState(blockpos1).is(Blocks.GRASS_BLOCK)) { -- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level, this.mob)) { +- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.level), this.mob)) { this.level.levelEvent(2001, blockpos1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); this.level.setBlock(blockpos1, Blocks.DIRT.defaultBlockState(), 2); } diff --git a/patches/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/patches/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch index 276d4f5010..ecb4345b77 100644 --- a/patches/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch +++ b/patches/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -4,8 +4,8 @@ @Override public boolean canUse() { -- if (!this.removerMob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.removerMob.level(), this.removerMob)) { +- if (!getServerLevel(this.removerMob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.removerMob.level()), this.removerMob)) { return false; } else if (this.nextStartTick > 0) { this.nextStartTick--; diff --git a/patches/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/patches/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch index 8461aee220..6643b3f1ff 100644 --- a/patches/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch +++ b/patches/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -232,10 +_,10 @@ +@@ -249,10 +_,10 @@ Vec3 vec3 = this.getTempMobPos(); this.maxDistanceToWaypoint = this.mob.getBbWidth() > 0.75F ? this.mob.getBbWidth() / 2.0F : 0.75F - this.mob.getBbWidth() / 2.0F; Vec3i vec3i = this.path.getNextNodePos(); diff --git a/patches/net/minecraft/world/entity/ai/village/VillageSiege.java.patch b/patches/net/minecraft/world/entity/ai/village/VillageSiege.java.patch index 075cd89a91..5dc790e07c 100644 --- a/patches/net/minecraft/world/entity/ai/village/VillageSiege.java.patch +++ b/patches/net/minecraft/world/entity/ai/village/VillageSiege.java.patch @@ -16,7 +16,7 @@ Zombie zombie; try { - zombie = new Zombie(p_27017_); -+ zombie = EntityType.ZOMBIE.create(p_27017_); //Forge: Direct Initialization is deprecated, use EntityType. - zombie.finalizeSpawn(p_27017_, p_27017_.getCurrentDifficultyAt(zombie.blockPosition()), MobSpawnType.EVENT, null); ++ zombie = EntityType.ZOMBIE.create(p_27017_, EntitySpawnReason.EVENT); //Forge: Direct Initialization is deprecated, use EntityType. + zombie.finalizeSpawn(p_27017_, p_27017_.getCurrentDifficultyAt(zombie.blockPosition()), EntitySpawnReason.EVENT, null); } catch (Exception exception) { LOGGER.warn("Failed to create zombie for village siege at {}", vec3, exception); diff --git a/patches/net/minecraft/world/entity/animal/Animal.java.patch b/patches/net/minecraft/world/entity/animal/Animal.java.patch index 3885074970..7c60f97e17 100644 --- a/patches/net/minecraft/world/entity/animal/Animal.java.patch +++ b/patches/net/minecraft/world/entity/animal/Animal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Animal.java +++ b/net/minecraft/world/entity/animal/Animal.java -@@ -201,6 +_,17 @@ +@@ -221,6 +_,17 @@ public void spawnChildFromBreeding(ServerLevel p_27564_, Animal p_27565_) { AgeableMob ageablemob = this.getBreedOffspring(p_27564_, p_27565_); diff --git a/patches/net/minecraft/world/entity/animal/Bee.java.patch b/patches/net/minecraft/world/entity/animal/Bee.java.patch index 79c82f584d..3e5e904026 100644 --- a/patches/net/minecraft/world/entity/animal/Bee.java.patch +++ b/patches/net/minecraft/world/entity/animal/Bee.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java -@@ -487,7 +_,7 @@ - return false; +@@ -498,7 +_,7 @@ + if (this.hivePos == null) { + return null; } else { - BlockEntity blockentity = this.level().getBlockEntity(this.hivePos); -- return blockentity != null && blockentity.getType() == BlockEntityType.BEEHIVE; -+ return blockentity instanceof BeehiveBlockEntity; +- return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null); ++ return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos) instanceof BeehiveBlockEntity hive ? hive : null; } } -@@ -636,8 +_,18 @@ +@@ -644,8 +_,18 @@ } @Override diff --git a/patches/net/minecraft/world/entity/animal/Cat.java.patch b/patches/net/minecraft/world/entity/animal/Cat.java.patch index 2a68e762b1..45b5cd9505 100644 --- a/patches/net/minecraft/world/entity/animal/Cat.java.patch +++ b/patches/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,18 +1,17 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java -@@ -368,9 +_,9 @@ +@@ -373,9 +_,9 @@ } } else if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) { if (!this.level().isClientSide()) { - this.usePlayerItem(p_28153_, p_28154_, itemstack); -- FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); -+ FoodProperties foodproperties = itemstack.getFoodProperties(this); + FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); this.heal(foodproperties != null ? (float)foodproperties.nutrition() : 1.0F); + this.usePlayerItem(p_28153_, p_28154_, itemstack); + this.playEatingSound(); } - return InteractionResult.sidedSuccess(this.level().isClientSide()); -@@ -430,7 +_,7 @@ +@@ -437,7 +_,7 @@ } private void tryToTame(Player p_333858_) { diff --git a/patches/net/minecraft/world/entity/animal/Fox.java.patch b/patches/net/minecraft/world/entity/animal/Fox.java.patch index b84f34716a..c70597662c 100644 --- a/patches/net/minecraft/world/entity/animal/Fox.java.patch +++ b/patches/net/minecraft/world/entity/animal/Fox.java.patch @@ -1,16 +1,18 @@ --- a/net/minecraft/world/entity/animal/Fox.java +++ b/net/minecraft/world/entity/animal/Fox.java -@@ -677,13 +_,16 @@ +@@ -671,13 +_,18 @@ @Override protected void dropAllDeathLoot(ServerLevel p_348640_, DamageSource p_28536_) { + super.dropAllDeathLoot(p_348640_, p_28536_); + } -+ protected void dropEquipment() { // Forge: move extra drops to dropEquipment to allow them to be captured by LivingDropsEvent -+ super.dropEquipment(); ++ ++ @Override ++ protected void dropEquipment(ServerLevel p_348640_) { // Forge: move extra drops to dropEquipment to allow them to be captured by LivingDropsEvent ++ super.dropEquipment(p_348640_); ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemstack.isEmpty()) { - this.spawnAtLocation(itemstack); + this.spawnAtLocation(p_348640_, itemstack); this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); } @@ -18,9 +20,9 @@ } public static boolean isPathClear(Fox p_28472_, LivingEntity p_28473_) { -@@ -842,6 +_,17 @@ +@@ -837,6 +_,17 @@ protected void breed() { - ServerLevel serverlevel = (ServerLevel)this.level; + ServerLevel serverlevel = this.level; Fox fox = (Fox)this.animal.getBreedOffspring(serverlevel, this.partner); + final net.neoforged.neoforge.event.entity.living.BabyEntitySpawnEvent event = new net.neoforged.neoforge.event.entity.living.BabyEntitySpawnEvent(animal, partner, fox); + final boolean cancelled = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event).isCanceled(); @@ -36,16 +38,16 @@ if (fox != null) { ServerPlayer serverplayer = this.animal.getLoveCause(); ServerPlayer serverplayer1 = this.partner.getLoveCause(); -@@ -919,7 +_,7 @@ +@@ -914,7 +_,7 @@ } protected void onReachedTarget() { -- if (Fox.this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(Fox.this.level(), Fox.this)) { +- if (getServerLevel(Fox.this.level()).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(Fox.this.level()), Fox.this)) { BlockState blockstate = Fox.this.level().getBlockState(this.blockPos); if (blockstate.is(Blocks.SWEET_BERRY_BUSH)) { this.pickSweetBerries(blockstate); -@@ -978,7 +_,7 @@ +@@ -973,7 +_,7 @@ @Override public boolean canUse() { diff --git a/patches/net/minecraft/world/entity/animal/MushroomCow.java.patch b/patches/net/minecraft/world/entity/animal/MushroomCow.java.patch index fa6f17678a..373b37a15a 100644 --- a/patches/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/patches/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -1,40 +1,23 @@ --- a/net/minecraft/world/entity/animal/MushroomCow.java +++ b/net/minecraft/world/entity/animal/MushroomCow.java -@@ -108,7 +_,7 @@ - - this.playSound(soundevent, 1.0F, 1.0F); - return InteractionResult.sidedSuccess(this.level().isClientSide); -- } else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { -+ } else if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { // Neo: Shear logic is handled by IShearable - this.shear(SoundSource.PLAYERS); - this.gameEvent(GameEvent.SHEAR, p_28941_); - if (!this.level().isClientSide) { -@@ -165,8 +_,10 @@ - public void shear(SoundSource p_28924_) { - this.level().playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, p_28924_, 1.0F, 1.0F); - if (!this.level().isClientSide()) { -+ if (!net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.COW, (timer) -> {})) return; - Cow cow = EntityType.COW.create(this.level()); - if (cow != null) { -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, cow); - ((ServerLevel)this.level()).sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0); - this.discard(); - cow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -@@ -185,10 +_,13 @@ - this.level().addFreshEntity(cow); - - for (int i = 0; i < 5; i++) { -- this.level() -- .addFreshEntity( -- new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock())) -- ); +@@ -166,11 +_,19 @@ + @Override + public void shear(ServerLevel p_376375_, SoundSource p_28924_, ItemStack p_373092_) { + p_376375_.playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, p_28924_, 1.0F, 1.0F); ++ if (!net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.COW, (timer) -> {})) return; + this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), p_381482_ -> { ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381482_); + p_376375_.sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0); + this.dropFromShearingLootTable(p_376375_, BuiltInLootTables.SHEAR_MOOSHROOM, p_373092_, (p_381483_, p_381484_) -> { + for (int i = 0; i < p_381484_.getCount(); i++) { +- p_381483_.addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), p_381484_.copyWithCount(1))); + // Neo: Change from addFreshEntity to spawnAtLocation to ensure captureDrops can capture this, we also need to unset the default pickup delay from the item + // Vanilla uses this.getY(1.0) for the y-level, which is this.getY() + this.getBbHeight() * 1.0, so we pass the BB height as the Y-offset. -+ ItemEntity item = spawnAtLocation(new ItemStack(this.getVariant().blockState.getBlock()), this.getBbHeight()); ++ ItemEntity item = spawnAtLocation(p_381483_, p_381484_.copyWithCount(1), this.getBbHeight()); + if (item != null) { + // addFreshEntity does not incur a pickup delay, while spawnAtLocation sets the default pickup delay. + item.setNoPickUpDelay(); + } } - } - } + }); + }); diff --git a/patches/net/minecraft/world/entity/animal/Ocelot.java.patch b/patches/net/minecraft/world/entity/animal/Ocelot.java.patch index 357c44260d..6e9ec371d4 100644 --- a/patches/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/patches/net/minecraft/world/entity/animal/Ocelot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Ocelot.java +++ b/net/minecraft/world/entity/animal/Ocelot.java -@@ -160,7 +_,7 @@ +@@ -159,7 +_,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && p_29021_.distanceToSqr(this) < 9.0) { this.usePlayerItem(p_29021_, p_29022_, itemstack); if (!this.level().isClientSide) { diff --git a/patches/net/minecraft/world/entity/animal/Parrot.java.patch b/patches/net/minecraft/world/entity/animal/Parrot.java.patch index 0fbb41823f..ba8eca84e8 100644 --- a/patches/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/patches/net/minecraft/world/entity/animal/Parrot.java.patch @@ -10,10 +10,10 @@ }; + /** @deprecated Neo: use the {@link net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps#PARROT_IMITATIONS data map} instead */ + @Deprecated - static final Map, SoundEvent> MOB_SOUND_MAP = Util.make(Maps.newHashMap(), p_326764_ -> { - p_326764_.put(EntityType.BLAZE, SoundEvents.PARROT_IMITATE_BLAZE); - p_326764_.put(EntityType.BOGGED, SoundEvents.PARROT_IMITATE_BOGGED); -@@ -257,7 +_,7 @@ + static final Map, SoundEvent> MOB_SOUND_MAP = Util.make(Maps.newHashMap(), p_379158_ -> { + p_379158_.put(EntityType.BLAZE, SoundEvents.PARROT_IMITATE_BLAZE); + p_379158_.put(EntityType.BOGGED, SoundEvents.PARROT_IMITATE_BOGGED); +@@ -261,7 +_,7 @@ } if (!this.level().isClientSide) { @@ -22,19 +22,19 @@ this.tame(p_29414_); this.level().broadcastEntityEvent(this, (byte)7); } else { -@@ -321,7 +_,10 @@ +@@ -325,7 +_,10 @@ public static SoundEvent getAmbient(Level p_218239_, RandomSource p_218240_) { if (p_218239_.getDifficulty() != Difficulty.PEACEFUL && p_218240_.nextInt(1000) == 0) { - List> list = Lists.newArrayList(MOB_SOUND_MAP.keySet()); + final var entities = new java.util.HashSet<>(MOB_SOUND_MAP.keySet()); -+ final var registry = p_218239_.registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.ENTITY_TYPE); -+ registry.getDataMap(net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps.PARROT_IMITATIONS).keySet().forEach(key -> entities.add(registry.get(key))); ++ final var registry = p_218239_.registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.ENTITY_TYPE); ++ registry.getDataMap(net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps.PARROT_IMITATIONS).keySet().forEach(key -> entities.add(registry.getValue(key))); + List> list = Lists.newArrayList(entities); return getImitatedSound(list.get(p_218240_.nextInt(list.size()))); } else { return SoundEvents.PARROT_AMBIENT; -@@ -329,7 +_,9 @@ +@@ -333,7 +_,9 @@ } private static SoundEvent getImitatedSound(EntityType p_29409_) { diff --git a/patches/net/minecraft/world/entity/animal/Pig.java.patch b/patches/net/minecraft/world/entity/animal/Pig.java.patch index 6346151346..35f07ef1d6 100644 --- a/patches/net/minecraft/world/entity/animal/Pig.java.patch +++ b/patches/net/minecraft/world/entity/animal/Pig.java.patch @@ -1,19 +1,18 @@ --- a/net/minecraft/world/entity/animal/Pig.java +++ b/net/minecraft/world/entity/animal/Pig.java -@@ -206,7 +_,7 @@ +@@ -207,13 +_,14 @@ @Override public void thunderHit(ServerLevel p_29473_, LightningBolt p_29474_) { - if (p_29473_.getDifficulty() != Difficulty.PEACEFUL) { + if (p_29473_.getDifficulty() != Difficulty.PEACEFUL && net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.ZOMBIFIED_PIGLIN, (timer) -> {})) { - ZombifiedPiglin zombifiedpiglin = EntityType.ZOMBIFIED_PIGLIN.create(p_29473_); - if (zombifiedpiglin != null) { - zombifiedpiglin.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); -@@ -219,6 +_,7 @@ + ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, false, true), p_381485_ -> { + if (this.getMainHandItem().isEmpty()) { + p_381485_.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); } - zombifiedpiglin.setPersistenceRequired(); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, zombifiedpiglin); - p_29473_.addFreshEntity(zombifiedpiglin); - this.discard(); - } else { + p_381485_.setPersistenceRequired(); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381485_); + }); + if (zombifiedpiglin == null) { + super.thunderHit(p_29473_, p_29474_); diff --git a/patches/net/minecraft/world/entity/animal/Rabbit.java.patch b/patches/net/minecraft/world/entity/animal/Rabbit.java.patch index 867d550ac7..987d78e676 100644 --- a/patches/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/patches/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/Rabbit.java +++ b/net/minecraft/world/entity/animal/Rabbit.java -@@ -530,7 +_,7 @@ +@@ -531,7 +_,7 @@ @Override public boolean canUse() { if (this.nextStartTick <= 0) { -- if (!this.rabbit.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.rabbit.level(), this.rabbit)) { +- if (!getServerLevel(this.rabbit).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.rabbit.level()), this.rabbit)) { return false; } -@@ -585,7 +_,7 @@ +@@ -586,7 +_,7 @@ @Override protected boolean isValidTarget(LevelReader p_29785_, BlockPos p_29786_) { BlockState blockstate = p_29785_.getBlockState(p_29786_); diff --git a/patches/net/minecraft/world/entity/animal/Sheep.java.patch b/patches/net/minecraft/world/entity/animal/Sheep.java.patch index 4871c860c8..e22cf4c2d2 100644 --- a/patches/net/minecraft/world/entity/animal/Sheep.java.patch +++ b/patches/net/minecraft/world/entity/animal/Sheep.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/Sheep.java +++ b/net/minecraft/world/entity/animal/Sheep.java -@@ -212,7 +_,7 @@ +@@ -156,7 +_,7 @@ @Override public InteractionResult mobInteract(Player p_29853_, InteractionHand p_29854_) { ItemStack itemstack = p_29853_.getItemInHand(p_29854_); - if (itemstack.is(Items.SHEARS)) { + if (false && itemstack.is(Items.SHEARS)) { // Neo: Shear logic is handled by IShearable - if (!this.level().isClientSide && this.readyForShearing()) { - this.shear(SoundSource.PLAYERS); + if (this.level() instanceof ServerLevel serverlevel && this.readyForShearing()) { + this.shear(serverlevel, SoundSource.PLAYERS, itemstack); this.gameEvent(GameEvent.SHEAR, p_29853_); diff --git a/patches/net/minecraft/world/entity/animal/SnowGolem.java.patch b/patches/net/minecraft/world/entity/animal/SnowGolem.java.patch index 19b14ba776..04e835e62a 100644 --- a/patches/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/patches/net/minecraft/world/entity/animal/SnowGolem.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/animal/SnowGolem.java +++ b/net/minecraft/world/entity/animal/SnowGolem.java -@@ -92,7 +_,7 @@ - this.hurt(this.damageSources().onFire(), 1.0F); +@@ -95,7 +_,7 @@ + this.hurtServer(serverlevel, this.damageSources().onFire(), 1.0F); } -- if (!this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this)) { +- if (!serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, this)) { return; } -@@ -127,7 +_,7 @@ +@@ -136,7 +_,7 @@ @Override protected InteractionResult mobInteract(Player p_29920_, InteractionHand p_29921_) { ItemStack itemstack = p_29920_.getItemInHand(p_29921_); - if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { + if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { // Neo: Shear logic is handled by IShearable - this.shear(SoundSource.PLAYERS); - this.gameEvent(GameEvent.SHEAR, p_29920_); - if (!this.level().isClientSide) { + if (this.level() instanceof ServerLevel serverlevel) { + this.shear(serverlevel, SoundSource.PLAYERS, itemstack); + this.gameEvent(GameEvent.SHEAR, p_29920_); diff --git a/patches/net/minecraft/world/entity/animal/Wolf.java.patch b/patches/net/minecraft/world/entity/animal/Wolf.java.patch index 5a316c46eb..ebd287da6b 100644 --- a/patches/net/minecraft/world/entity/animal/Wolf.java.patch +++ b/patches/net/minecraft/world/entity/animal/Wolf.java.patch @@ -1,29 +1,28 @@ --- a/net/minecraft/world/entity/animal/Wolf.java +++ b/net/minecraft/world/entity/animal/Wolf.java -@@ -419,10 +_,11 @@ - if (!this.level().isClientSide || this.isBaby() && this.isFood(itemstack)) { - if (this.isTame()) { - if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) { -- itemstack.consume(1, p_30412_); -- FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); -+ FoodProperties foodproperties = itemstack.getFoodProperties(this); - float f = foodproperties != null ? (float)foodproperties.nutrition() : 1.0F; - this.heal(2.0F * f); -+ itemstack.consume(1, p_30412_); -+ this.gameEvent(GameEvent.EAT); // Neo: add EAT game event - return InteractionResult.sidedSuccess(this.level().isClientSide()); - } else { - if (item instanceof DyeItem dyeitem && this.isOwnedBy(p_30412_)) { -@@ -440,7 +_,7 @@ - this.setBodyArmorItem(itemstack.copyWithCount(1)); - itemstack.consume(1, p_30412_); - return InteractionResult.SUCCESS; -- } else if (itemstack.is(Items.SHEARS) -+ } else if (itemstack.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHEARS_REMOVE_ARMOR) - && this.isOwnedBy(p_30412_) - && this.hasArmor() - && (!EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) || p_30412_.isCreative())) { -@@ -488,7 +_,7 @@ +@@ -403,10 +_,11 @@ + Item item = itemstack.getItem(); + if (this.isTame()) { + if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) { +- this.usePlayerItem(p_30412_, p_30413_, itemstack); + FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); + float f = foodproperties != null ? (float)foodproperties.nutrition() : 1.0F; + this.heal(2.0F * f); ++ this.usePlayerItem(p_30412_, p_30413_, itemstack); ++ this.gameEvent(GameEvent.EAT); // Neo: add EAT game event + return InteractionResult.SUCCESS; + } else { + if (item instanceof DyeItem dyeitem && this.isOwnedBy(p_30412_)) { +@@ -424,7 +_,7 @@ + this.setBodyArmorItem(itemstack.copyWithCount(1)); + itemstack.consume(1, p_30412_); + return InteractionResult.SUCCESS; +- } else if (itemstack.is(Items.SHEARS) ++ } else if (itemstack.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHEARS_REMOVE_ARMOR) + && this.isOwnedBy(p_30412_) + && this.isWearingBodyArmor() + && (!EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) || p_30412_.isCreative())) { +@@ -471,7 +_,7 @@ } private void tryToTame(Player p_333736_) { diff --git a/patches/net/minecraft/world/entity/animal/allay/Allay.java.patch b/patches/net/minecraft/world/entity/animal/allay/Allay.java.patch index bd58fe31d2..f0ede9df6e 100644 --- a/patches/net/minecraft/world/entity/animal/allay/Allay.java.patch +++ b/patches/net/minecraft/world/entity/animal/allay/Allay.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -368,9 +_,9 @@ - public boolean wantsToPickUp(ItemStack p_218387_) { +@@ -369,9 +_,9 @@ + public boolean wantsToPickUp(ServerLevel p_376111_, ItemStack p_218387_) { ItemStack itemstack = this.getItemInHand(InteractionHand.MAIN_HAND); return !itemstack.isEmpty() -- && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) +- && p_376111_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && this.inventory.canAddItem(p_218387_) - && this.allayConsidersItemEqual(itemstack, p_218387_); + && this.allayConsidersItemEqual(itemstack, p_218387_) -+ && net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this); ++ && net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_376111_, this); } private boolean allayConsidersItemEqual(ItemStack p_252278_, ItemStack p_250405_) { diff --git a/patches/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch b/patches/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch index e76537d399..d2768ffcd2 100644 --- a/patches/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch +++ b/patches/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -300,7 +_,7 @@ +@@ -305,7 +_,7 @@ @Override public InteractionResult mobInteract(Player p_316559_, InteractionHand p_316119_) { ItemStack itemstack = p_316559_.getItemInHand(p_316119_); - if (itemstack.is(Items.BRUSH) && this.brushOffScute()) { + if (itemstack.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.BRUSH_BRUSH) && this.brushOffScute()) { itemstack.hurtAndBreak(16, p_316559_, getSlotForHand(p_316119_)); - return InteractionResult.sidedSuccess(this.level().isClientSide); + return InteractionResult.SUCCESS; } else { diff --git a/patches/net/minecraft/world/entity/animal/camel/Camel.java.patch b/patches/net/minecraft/world/entity/animal/camel/Camel.java.patch index 9f451f4188..40ce1b83d0 100644 --- a/patches/net/minecraft/world/entity/animal/camel/Camel.java.patch +++ b/patches/net/minecraft/world/entity/animal/camel/Camel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/camel/Camel.java +++ b/net/minecraft/world/entity/animal/camel/Camel.java -@@ -286,6 +_,7 @@ +@@ -289,6 +_,7 @@ this.dashCooldown = 55; this.setDashing(true); this.hasImpulse = true; diff --git a/patches/net/minecraft/world/entity/animal/frog/Tadpole.java.patch b/patches/net/minecraft/world/entity/animal/frog/Tadpole.java.patch index 637cf5cae4..90a3bb4745 100644 --- a/patches/net/minecraft/world/entity/animal/frog/Tadpole.java.patch +++ b/patches/net/minecraft/world/entity/animal/frog/Tadpole.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -225,8 +_,10 @@ +@@ -228,8 +_,10 @@ + } private void ageUp() { ++ if (!net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.FROG, (timer) -> {})) return; if (this.level() instanceof ServerLevel serverlevel) { -+ if (!net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.FROG, (timer) -> {})) return; - Frog frog = EntityType.FROG.create(this.level()); - if (frog != null) { -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, frog); - frog.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); - frog.finalizeSpawn(serverlevel, this.level().getCurrentDifficultyAt(frog.blockPosition()), MobSpawnType.CONVERSION, null); - frog.setNoAi(this.isNoAi()); + this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), p_381493_ -> { ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381493_); + p_381493_.finalizeSpawn(serverlevel, this.level().getCurrentDifficultyAt(p_381493_.blockPosition()), EntitySpawnReason.CONVERSION, null); + p_381493_.setPersistenceRequired(); + p_381493_.fudgePositionAfterSizeChange(this.getDimensions(this.getPose())); diff --git a/patches/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/patches/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index 4f8118febd..c011008d18 100644 --- a/patches/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/patches/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -396,9 +_,9 @@ +@@ -405,9 +_,9 @@ protected void playStepSound(BlockPos p_30584_, BlockState p_30585_) { if (!p_30585_.liquid()) { BlockState blockstate = this.level().getBlockState(p_30584_.above()); @@ -12,7 +12,7 @@ } if (this.isVehicle() && this.canGallop) { -@@ -816,6 +_,7 @@ +@@ -823,6 +_,7 @@ this.setDeltaMovement(vec3.x, d0, vec3.z); this.setIsJumping(true); this.hasImpulse = true; @@ -20,10 +20,10 @@ if (p_275435_.z > 0.0) { float f = Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)); float f1 = Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)); -@@ -1118,6 +_,11 @@ +@@ -1127,6 +_,11 @@ this.randomizeAttributes(p_30555_.getRandom()); - return super.finalizeSpawn(p_30555_, p_30556_, p_30557_, p_30558_); + return super.finalizeSpawn(p_30555_, p_30556_, p_363523_, p_30558_); + } + + // Neo: Inventory getter diff --git a/patches/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch b/patches/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch index e3a7684a92..ca3ab0b2c6 100644 --- a/patches/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch +++ b/patches/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch @@ -6,7 +6,7 @@ ServerLevel serverlevel = (ServerLevel)this.horse.level(); + // Forge: Trigger the trap in a tick task to avoid crashes when mods add goals to skeleton horses + // (MC-206338/Forge PR #7509) -+ serverlevel.getServer().tell(new net.minecraft.server.TickTask(serverlevel.getServer().getTickCount(), () -> { ++ serverlevel.getServer().schedule(new net.minecraft.server.TickTask(serverlevel.getServer().getTickCount(), () -> { + if (!this.horse.isAlive()) return; DifficultyInstance difficultyinstance = serverlevel.getCurrentDifficultyAt(this.horse.blockPosition()); this.horse.setTrap(false); diff --git a/patches/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch b/patches/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch index cfa11ac57e..8c8aa4cdca 100644 --- a/patches/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch +++ b/patches/net/minecraft/world/entity/animal/sniffer/Sniffer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -299,7 +_,7 @@ +@@ -288,7 +_,7 @@ if (this.tickCount % 10 == 0) { this.level() .playLocalSound( diff --git a/patches/net/minecraft/world/entity/boss/EnderDragonPart.java.patch b/patches/net/minecraft/world/entity/boss/EnderDragonPart.java.patch index 1eda2ad745..c00f4cdd13 100644 --- a/patches/net/minecraft/world/entity/boss/EnderDragonPart.java.patch +++ b/patches/net/minecraft/world/entity/boss/EnderDragonPart.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/EnderDragonPart.java +++ b/net/minecraft/world/entity/boss/EnderDragonPart.java -@@ -13,13 +_,13 @@ +@@ -14,13 +_,13 @@ import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.item.ItemStack; diff --git a/patches/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/patches/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index 5e9f360c55..b807a36c3f 100644 --- a/patches/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/patches/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -103,6 +_,14 @@ +@@ -101,6 +_,14 @@ + this.setHealth(this.getMaxHealth()); this.noPhysics = true; - this.noCulling = true; this.phaseManager = new EnderDragonPhaseManager(this); + this.setId(ENTITY_COUNTER.getAndAdd(this.subEntities.length + 1) + 1); // Forge: Fix MC-158205: Make sure part ids are successors of parent mob id + } @@ -15,49 +15,52 @@ } public void setDragonFight(EndDragonFight p_287736_) { -@@ -170,8 +_,12 @@ - return adouble; +@@ -149,8 +_,15 @@ + p_326491_.define(DATA_PHASE, EnderDragonPhase.HOVERING.getId()); } -+ @org.jetbrains.annotations.Nullable private Player unlimitedLastHurtByPlayer = null; ++ @org.jetbrains.annotations.Nullable ++ private Player unlimitedLastHurtByPlayer = null; ++ @Override public void aiStep() { + // lastHurtByPlayer is cleared after 100 ticks, capture it indefinitely in unlimitedLastHurtByPlayer for LivingExperienceDropEvent + if (this.lastHurtByPlayer != null) this.unlimitedLastHurtByPlayer = lastHurtByPlayer; + if (this.unlimitedLastHurtByPlayer != null && this.unlimitedLastHurtByPlayer.isRemoved()) this.unlimitedLastHurtByPlayer = null; ++ this.processFlappingMovement(); if (this.level().isClientSide) { this.setHealth(this.getHealth()); -@@ -475,7 +_,7 @@ +@@ -445,7 +_,7 @@ BlockPos blockpos = new BlockPos(k1, l1, i2); - BlockState blockstate = this.level().getBlockState(blockpos); + BlockState blockstate = p_376795_.getBlockState(blockpos); if (!blockstate.isAir() && !blockstate.is(BlockTags.DRAGON_TRANSPARENT)) { -- if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { -+ if (net.neoforged.neoforge.common.CommonHooks.canEntityDestroy(this.level(), blockpos, this) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { - flag1 = this.level().removeBlock(blockpos, false) || flag1; +- if (p_376795_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { ++ if (net.neoforged.neoforge.common.CommonHooks.canEntityDestroy(p_376795_, blockpos, this) && !blockstate.is(BlockTags.DRAGON_IMMUNE)) { + flag1 = p_376795_.removeBlock(blockpos, false) || flag1; } else { flag = true; -@@ -569,7 +_,8 @@ +@@ -538,7 +_,8 @@ - if (this.level() instanceof ServerLevel) { - if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && flag) { -- ExperienceOrb.award((ServerLevel)this.level(), this.position(), Mth.floor((float)i * 0.08F)); + if (this.level() instanceof ServerLevel serverlevel) { + if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- ExperienceOrb.award(serverlevel, this.position(), Mth.floor((float)i * 0.08F)); + int award = net.neoforged.neoforge.event.EventHooks.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.floor((float)i * 0.08F)); + ExperienceOrb.award((ServerLevel) this.level(), this.position(), award); } if (this.dragonDeathTime == 1 && !this.isSilent()) { -@@ -580,7 +_,8 @@ +@@ -549,7 +_,8 @@ this.move(MoverType.SELF, new Vec3(0.0, 0.1F, 0.0)); - if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel) { - if (flag) { -- ExperienceOrb.award((ServerLevel)this.level(), this.position(), Mth.floor((float)i * 0.2F)); + if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel serverlevel1) { + if (serverlevel1.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- ExperienceOrb.award(serverlevel1, this.position(), Mth.floor((float)i * 0.2F)); + int award = net.neoforged.neoforge.event.EventHooks.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.floor((float)i * 0.2F)); + ExperienceOrb.award((ServerLevel) this.level(), this.position(), award); } if (this.dragonFight != null) { -@@ -912,8 +_,19 @@ +@@ -860,8 +_,19 @@ } @Override diff --git a/patches/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/patches/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index a2b0f70b58..5e036c641e 100644 --- a/patches/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/patches/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -322,7 +_,7 @@ +@@ -320,7 +_,7 @@ if (this.destroyBlocksTick > 0) { this.destroyBlocksTick--; -- if (this.destroyBlocksTick == 0 && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (this.destroyBlocksTick == 0 && net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this)) { +- if (this.destroyBlocksTick == 0 && p_376675_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (this.destroyBlocksTick == 0 && net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_376675_, this)) { boolean flag = false; int l = Mth.floor(this.getBbWidth() / 2.0F + 1.0F); int i1 = Mth.floor(this.getBbHeight()); -@@ -331,7 +_,7 @@ +@@ -329,7 +_,7 @@ this.getBlockX() - l, this.getBlockY(), this.getBlockZ() - l, this.getBlockX() + l, this.getBlockY() + i1, this.getBlockZ() + l )) { - BlockState blockstate = this.level().getBlockState(blockpos); + BlockState blockstate = p_376675_.getBlockState(blockpos); - if (canDestroy(blockstate)) { + if (blockstate.canEntityDestroy(this.level(), blockpos, this) && net.neoforged.neoforge.event.EventHooks.onEntityDestroyBlock(this, blockpos, blockstate)) { - flag = this.level().destroyBlock(blockpos, true, this) || flag; + flag = p_376675_.destroyBlock(blockpos, true, this) || flag; } } -@@ -350,6 +_,10 @@ +@@ -348,6 +_,10 @@ } } @@ -29,7 +29,7 @@ public static boolean canDestroy(BlockState p_31492_) { return !p_31492_.isAir() && !p_31492_.is(BlockTags.WITHER_IMMUNE); } -@@ -495,6 +_,7 @@ +@@ -493,6 +_,7 @@ @Override public void checkDespawn() { diff --git a/patches/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/patches/net/minecraft/world/entity/decoration/ArmorStand.java.patch deleted file mode 100644 index d99faa6be3..0000000000 --- a/patches/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/decoration/ArmorStand.java -+++ b/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -73,7 +_,7 @@ - public static final EntityDataAccessor DATA_LEFT_LEG_POSE = SynchedEntityData.defineId(ArmorStand.class, EntityDataSerializers.ROTATIONS); - public static final EntityDataAccessor DATA_RIGHT_LEG_POSE = SynchedEntityData.defineId(ArmorStand.class, EntityDataSerializers.ROTATIONS); - private static final Predicate RIDABLE_MINECARTS = p_31582_ -> p_31582_ instanceof AbstractMinecart -- && ((AbstractMinecart)p_31582_).getMinecartType() == AbstractMinecart.Type.RIDEABLE; -+ && ((AbstractMinecart)p_31582_).canBeRidden(); - private final NonNullList handItems = NonNullList.withSize(2, ItemStack.EMPTY); - private final NonNullList armorItems = NonNullList.withSize(4, ItemStack.EMPTY); - private boolean invisible; diff --git a/patches/net/minecraft/world/entity/decoration/HangingEntity.java.patch b/patches/net/minecraft/world/entity/decoration/HangingEntity.java.patch index 91ec6e8b64..830741b8a3 100644 --- a/patches/net/minecraft/world/entity/decoration/HangingEntity.java.patch +++ b/patches/net/minecraft/world/entity/decoration/HangingEntity.java.patch @@ -1,13 +1,11 @@ --- a/net/minecraft/world/entity/decoration/HangingEntity.java +++ b/net/minecraft/world/entity/decoration/HangingEntity.java -@@ -57,8 +_,8 @@ +@@ -58,7 +_,7 @@ if (!this.level().noCollision(this)) { return false; } else { -- boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).allMatch(p_352810_ -> { -- BlockState blockstate = this.level().getBlockState(p_352810_); -+ boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).filter(pos -> !net.minecraft.world.level.block.Block.canSupportCenter(this.level(), pos, this.direction)).allMatch(p_350100_ -> { -+ BlockState blockstate = this.level().getBlockState(p_350100_); +- boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).allMatch(p_381503_ -> { ++ boolean flag = BlockPos.betweenClosedStream(this.calculateSupportBox()).filter(pos -> !net.minecraft.world.level.block.Block.canSupportCenter(this.level(), pos, this.direction)).allMatch(p_381503_ -> { + BlockState blockstate = this.level().getBlockState(p_381503_); return blockstate.isSolid() || DiodeBlock.isDiode(blockstate); }); - return !flag ? false : this.level().getEntities(this, this.getBoundingBox(), HANGING_ENTITY).isEmpty(); diff --git a/patches/net/minecraft/world/entity/decoration/ItemFrame.java.patch b/patches/net/minecraft/world/entity/decoration/ItemFrame.java.patch index 6500489e01..788a8be1de 100644 --- a/patches/net/minecraft/world/entity/decoration/ItemFrame.java.patch +++ b/patches/net/minecraft/world/entity/decoration/ItemFrame.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/net/minecraft/world/entity/decoration/ItemFrame.java -@@ -212,7 +_,7 @@ +@@ -225,7 +_,7 @@ private void removeFramedMap(ItemStack p_31811_) { MapId mapid = this.getFramedMapId(p_31811_); if (mapid != null) { @@ -8,4 +8,4 @@ + MapItemSavedData mapitemsaveddata = MapItem.getSavedData(p_31811_, this.level()); if (mapitemsaveddata != null) { mapitemsaveddata.removedFromFrame(this.pos, this.getId()); - mapitemsaveddata.setDirty(true); + } diff --git a/patches/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/patches/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index c8eae9d0bb..a8174886eb 100644 --- a/patches/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/patches/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -138,7 +_,7 @@ - if (!this.level().isClientSide && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { +@@ -148,7 +_,7 @@ + if (this.level() instanceof ServerLevel serverlevel && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { BlockPos blockpos = this.blockPosition(); boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock; - boolean flag1 = flag && this.level().getFluidState(blockpos).is(FluidTags.WATER); @@ -9,7 +9,7 @@ double d0 = this.getDeltaMovement().lengthSqr(); if (flag && d0 > 1.0) { BlockHitResult blockhitresult = this.level() -@@ -147,7 +_,7 @@ +@@ -157,7 +_,7 @@ new Vec3(this.xo, this.yo, this.zo), this.position(), ClipContext.Block.COLLIDER, ClipContext.Fluid.SOURCE_ONLY, this ) ); diff --git a/patches/net/minecraft/world/entity/item/ItemEntity.java.patch b/patches/net/minecraft/world/entity/item/ItemEntity.java.patch index 71d2564a7f..0b105e1548 100644 --- a/patches/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/patches/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -45,8 +45,8 @@ if (this.isInWater() && this.getFluidHeight(FluidTags.WATER) > 0.1F) { this.setUnderwaterMovement(); } else if (this.isInLava() && this.getFluidHeight(FluidTags.LAVA) > 0.1F) { -@@ -153,7 +_,8 @@ - this.move(MoverType.SELF, this.getDeltaMovement()); +@@ -154,7 +_,8 @@ + this.applyEffectsFromBlocks(); float f = 0.98F; if (this.onGround()) { - f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; @@ -55,7 +55,7 @@ } this.setDeltaMovement(this.getDeltaMovement().multiply((double)f, 0.98, (double)f)); -@@ -185,7 +_,15 @@ +@@ -186,7 +_,15 @@ } } @@ -72,16 +72,16 @@ this.discard(); } } -@@ -282,7 +_,7 @@ - this.health = (int)((float)this.health - p_32014_); - this.gameEvent(GameEvent.ENTITY_DAMAGE, p_32013_.getEntity()); +@@ -294,7 +_,7 @@ + this.health = (int)((float)this.health - p_376562_); + this.gameEvent(GameEvent.ENTITY_DAMAGE, p_376452_.getEntity()); if (this.health <= 0) { - this.getItem().onDestroyed(this); -+ this.getItem().onDestroyed(this, p_32013_); ++ this.getItem().onDestroyed(this, p_376452_); this.discard(); } -@@ -295,6 +_,7 @@ +@@ -312,6 +_,7 @@ p_32050_.putShort("Health", (short)this.health); p_32050_.putShort("Age", (short)this.age); p_32050_.putShort("PickupDelay", (short)this.pickupDelay); @@ -89,7 +89,7 @@ if (this.thrower != null) { p_32050_.putUUID("Thrower", this.thrower); } -@@ -315,6 +_,9 @@ +@@ -332,6 +_,9 @@ if (p_32034_.contains("PickupDelay")) { this.pickupDelay = p_32034_.getShort("PickupDelay"); } @@ -99,7 +99,7 @@ if (p_32034_.hasUUID("Owner")) { this.target = p_32034_.getUUID("Owner"); -@@ -343,7 +_,22 @@ +@@ -360,7 +_,22 @@ ItemStack itemstack = this.getItem(); Item item = itemstack.getItem(); int i = itemstack.getCount(); @@ -123,7 +123,7 @@ p_32040_.take(this, i); if (itemstack.isEmpty()) { this.discard(); -@@ -398,6 +_,15 @@ +@@ -415,6 +_,15 @@ this.target = p_266724_; } @@ -139,7 +139,7 @@ public void setThrower(Entity p_306324_) { this.thrower = p_306324_.getUUID(); this.cachedThrower = p_306324_; -@@ -437,7 +_,7 @@ +@@ -454,7 +_,7 @@ public void makeFakeItem() { this.setNeverPickUp(); @@ -147,4 +147,4 @@ + this.age = getItem().getEntityLifespan(this.level()) - 1; } - public float getSpin(float p_32009_) { + public static float getSpin(float p_32009_, float p_361295_) { diff --git a/patches/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/patches/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch index 688628b355..02972fce45 100644 --- a/patches/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/patches/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/AbstractSkeleton.java +++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java -@@ -157,7 +_,7 @@ +@@ -161,7 +_,7 @@ if (this.level() != null && !this.level().isClientSide) { this.goalSelector.removeGoal(this.meleeGoal); this.goalSelector.removeGoal(this.bowGoal); @@ -9,7 +9,7 @@ if (itemstack.is(Items.BOW)) { int i = this.getHardAttackInterval(); if (this.level().getDifficulty() != Difficulty.HARD) { -@@ -182,9 +_,11 @@ +@@ -186,9 +_,11 @@ @Override public void performRangedAttack(LivingEntity p_32141_, float p_32142_) { diff --git a/patches/net/minecraft/world/entity/monster/Bogged.java.patch b/patches/net/minecraft/world/entity/monster/Bogged.java.patch index c77e1925c1..11982e8674 100644 --- a/patches/net/minecraft/world/entity/monster/Bogged.java.patch +++ b/patches/net/minecraft/world/entity/monster/Bogged.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/Bogged.java +++ b/net/minecraft/world/entity/monster/Bogged.java -@@ -74,7 +_,7 @@ +@@ -70,7 +_,7 @@ @Override protected InteractionResult mobInteract(Player p_330736_, InteractionHand p_331786_) { ItemStack itemstack = p_330736_.getItemInHand(p_331786_); - if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { + if (false && itemstack.is(Items.SHEARS) && this.readyForShearing()) { // Neo: Shear logic is handled by IShearable - this.shear(SoundSource.PLAYERS); - this.gameEvent(GameEvent.SHEAR, p_330736_); - if (!this.level().isClientSide) { + if (this.level() instanceof ServerLevel serverlevel) { + this.shear(serverlevel, SoundSource.PLAYERS, itemstack); + this.gameEvent(GameEvent.SHEAR, p_330736_); diff --git a/patches/net/minecraft/world/entity/monster/EnderMan.java.patch b/patches/net/minecraft/world/entity/monster/EnderMan.java.patch index a46e783702..7ef7212218 100644 --- a/patches/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/patches/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -16,16 +16,17 @@ } @Override -@@ -214,7 +_,7 @@ +@@ -213,7 +_,8 @@ + } + + boolean isBeingStaredBy(Player p_380267_) { +- return this.isLookingAtMe(p_380267_, 0.025, true, false, LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM, new DoubleSupplier[]{this::getEyeY}); ++ return this.isLookingAtMe(p_380267_, 0.025, true, false, LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM_FOR_TARGET, new DoubleSupplier[]{this::getEyeY}) && ++ !net.neoforged.neoforge.common.CommonHooks.shouldSuppressEnderManAnger(this, p_380267_); + } - boolean isLookingAtMe(Player p_32535_) { - ItemStack itemstack = p_32535_.getInventory().armor.get(3); -- if (itemstack.is(Blocks.CARVED_PUMPKIN.asItem())) { -+ if (net.neoforged.neoforge.common.CommonHooks.shouldSuppressEnderManAnger(this, p_32535_, itemstack)) { - return false; - } else { - Vec3 vec3 = p_32535_.getViewVector(1.0F).normalize(); -@@ -301,8 +_,10 @@ + @Override +@@ -291,8 +_,10 @@ boolean flag = blockstate.blocksMotion(); boolean flag1 = blockstate.getFluidState().is(FluidTags.WATER); if (flag && !flag1) { @@ -37,16 +38,16 @@ if (flag2) { this.level().gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(this)); if (!this.isSilent()) { -@@ -459,7 +_,7 @@ +@@ -449,7 +_,7 @@ if (this.enderman.getCarriedBlock() == null) { return false; } else { -- return !this.enderman.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) -+ return !net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.enderman.level(), this.enderman) +- return !getServerLevel(this.enderman).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ return !net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.enderman.level()), this.enderman) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(2000)) == 0; } -@@ -479,7 +_,7 @@ +@@ -469,7 +_,7 @@ BlockState blockstate2 = this.enderman.getCarriedBlock(); if (blockstate2 != null) { blockstate2 = Block.updateFromNeighbourShapes(blockstate2, this.enderman.level(), blockpos); @@ -55,7 +56,7 @@ level.setBlock(blockpos, blockstate2, 3); level.gameEvent(GameEvent.BLOCK_PLACE, blockpos, GameEvent.Context.of(this.enderman, blockstate2)); this.enderman.setCarriedBlock(null); -@@ -491,6 +_,7 @@ +@@ -481,6 +_,7 @@ return p_32562_.isAir() && !p_32563_.isAir() && !p_32563_.is(Blocks.BEDROCK) @@ -63,12 +64,12 @@ && p_32563_.isCollisionShapeFullBlock(p_32559_, p_32564_) && p_32561_.canSurvive(p_32559_, p_32560_) && p_32559_.getEntities(this.enderman, AABB.unitCubeFromLowerCorner(Vec3.atLowerCornerOf(p_32560_))).isEmpty(); -@@ -602,7 +_,7 @@ +@@ -592,7 +_,7 @@ if (this.enderman.getCarriedBlock() != null) { return false; } else { -- return !this.enderman.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) -+ return !net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.enderman.level(), this.enderman) +- return !getServerLevel(this.enderman).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ return !net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.enderman.level()), this.enderman) ? false : this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0; } diff --git a/patches/net/minecraft/world/entity/monster/Evoker.java.patch b/patches/net/minecraft/world/entity/monster/Evoker.java.patch index a0a972ccac..06281a6dab 100644 --- a/patches/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/patches/net/minecraft/world/entity/monster/Evoker.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/Evoker.java +++ b/net/minecraft/world/entity/monster/Evoker.java -@@ -305,7 +_,7 @@ - return false; - } else if (Evoker.this.tickCount < this.nextAttackTickCount) { - return false; -- } else if (!Evoker.this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ } else if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(Evoker.this.level(), Evoker.this)) { +@@ -306,7 +_,7 @@ return false; } else { - List list = Evoker.this.level() + ServerLevel serverlevel = getServerLevel(Evoker.this.level()); +- if (!serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, Evoker.this)) { + return false; + } else { + List list = serverlevel.getNearbyEntities( diff --git a/patches/net/minecraft/world/entity/monster/Husk.java.patch b/patches/net/minecraft/world/entity/monster/Husk.java.patch index f36b13b010..44bb6a9ace 100644 --- a/patches/net/minecraft/world/entity/monster/Husk.java.patch +++ b/patches/net/minecraft/world/entity/monster/Husk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Husk.java +++ b/net/minecraft/world/entity/monster/Husk.java -@@ -70,6 +_,7 @@ +@@ -71,6 +_,7 @@ @Override protected void doUnderWaterConversion() { diff --git a/patches/net/minecraft/world/entity/monster/Monster.java.patch b/patches/net/minecraft/world/entity/monster/Monster.java.patch index 48606282bc..87f0f303cf 100644 --- a/patches/net/minecraft/world/entity/monster/Monster.java.patch +++ b/patches/net/minecraft/world/entity/monster/Monster.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Monster.java +++ b/net/minecraft/world/entity/monster/Monster.java -@@ -136,11 +_,11 @@ +@@ -137,11 +_,11 @@ @Override public ItemStack getProjectile(ItemStack p_33038_) { if (p_33038_.getItem() instanceof ProjectileWeaponItem) { diff --git a/patches/net/minecraft/world/entity/monster/Pillager.java.patch b/patches/net/minecraft/world/entity/monster/Pillager.java.patch index f08cd904f2..ea74e23dd8 100644 --- a/patches/net/minecraft/world/entity/monster/Pillager.java.patch +++ b/patches/net/minecraft/world/entity/monster/Pillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Pillager.java +++ b/net/minecraft/world/entity/monster/Pillager.java -@@ -116,7 +_,7 @@ +@@ -119,7 +_,7 @@ public AbstractIllager.IllagerArmPose getArmPose() { if (this.isChargingCrossbow()) { return AbstractIllager.IllagerArmPose.CROSSBOW_CHARGE; diff --git a/patches/net/minecraft/world/entity/monster/Ravager.java.patch b/patches/net/minecraft/world/entity/monster/Ravager.java.patch index f22f60a281..aabe0a1c02 100644 --- a/patches/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/patches/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,11 +1,20 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -134,7 +_,7 @@ - this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Mth.lerp(0.1, d1, d0)); - } +@@ -144,7 +_,7 @@ -- if (this.horizontalCollision && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (this.horizontalCollision && net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this)) { + if (this.level() instanceof ServerLevel serverlevel + && this.horizontalCollision +- && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ && net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, this)) { boolean flag = false; AABB aabb = this.getBoundingBox().inflate(0.2); +@@ -227,7 +_,7 @@ + private void roar() { + if (this.isAlive()) { + if (this.level() instanceof ServerLevel serverlevel) { +- Predicate predicate = serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ++ Predicate predicate = net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, this) + ? ROAR_TARGET_WITH_GRIEFING + : ROAR_TARGET_WITHOUT_GRIEFING; + diff --git a/patches/net/minecraft/world/entity/monster/Shulker.java.patch b/patches/net/minecraft/world/entity/monster/Shulker.java.patch index f7260e87d4..7cef3df234 100644 --- a/patches/net/minecraft/world/entity/monster/Shulker.java.patch +++ b/patches/net/minecraft/world/entity/monster/Shulker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Shulker.java +++ b/net/minecraft/world/entity/monster/Shulker.java -@@ -392,6 +_,12 @@ +@@ -395,6 +_,12 @@ && this.level().noCollision(this, new AABB(blockpos1).deflate(1.0E-6))) { Direction direction = this.findAttachableSurface(blockpos1); if (direction != null) { diff --git a/patches/net/minecraft/world/entity/monster/Silverfish.java.patch b/patches/net/minecraft/world/entity/monster/Silverfish.java.patch index 41ef0fa648..01211fe0cd 100644 --- a/patches/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/patches/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/entity/monster/Silverfish.java +++ b/net/minecraft/world/entity/monster/Silverfish.java -@@ -140,7 +_,7 @@ +@@ -143,7 +_,7 @@ return false; } else { RandomSource randomsource = this.mob.getRandom(); -- if (this.mob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && randomsource.nextInt(reducedTickDelay(10)) == 0) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.mob.level(), this.mob) && randomsource.nextInt(reducedTickDelay(10)) == 0) { +- if (getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && randomsource.nextInt(reducedTickDelay(10)) == 0) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(this.mob.level()), this.mob) && randomsource.nextInt(reducedTickDelay(10)) == 0) { this.selectedDirection = Direction.getRandom(randomsource); BlockPos blockpos = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5, this.mob.getZ()).relative(this.selectedDirection); BlockState blockstate = this.mob.level().getBlockState(blockpos); -@@ -211,7 +_,7 @@ +@@ -214,7 +_,7 @@ BlockState blockstate = level.getBlockState(blockpos1); Block block = blockstate.getBlock(); if (block instanceof InfestedBlock) { -- if (level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(level, this.silverfish)) { +- if (getServerLevel(level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (net.neoforged.neoforge.event.EventHooks.canEntityGrief(getServerLevel(level), this.silverfish)) { level.destroyBlock(blockpos1, true, this.silverfish); } else { level.setBlock(blockpos1, ((InfestedBlock)block).hostStateByInfested(level.getBlockState(blockpos1)), 3); diff --git a/patches/net/minecraft/world/entity/monster/Skeleton.java.patch b/patches/net/minecraft/world/entity/monster/Skeleton.java.patch index 499e41ec19..2b3815fc32 100644 --- a/patches/net/minecraft/world/entity/monster/Skeleton.java.patch +++ b/patches/net/minecraft/world/entity/monster/Skeleton.java.patch @@ -1,13 +1,12 @@ --- a/net/minecraft/world/entity/monster/Skeleton.java +++ b/net/minecraft/world/entity/monster/Skeleton.java -@@ -86,7 +_,9 @@ +@@ -89,7 +_,9 @@ } protected void doFreezeConversion() { -- this.convertTo(EntityType.STRAY, true); + if (!net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.STRAY, (timer) -> this.conversionTime = timer)) return; -+ Stray stray = this.convertTo(EntityType.STRAY, true); -+ if (stray != null) net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, stray); - if (!this.isSilent()) { - this.level().levelEvent(null, 1048, this.blockPosition(), 0); - } + this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), p_381508_ -> { ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381508_); + if (!this.isSilent()) { + this.level().levelEvent(null, 1048, this.blockPosition(), 0); + } diff --git a/patches/net/minecraft/world/entity/monster/Slime.java.patch b/patches/net/minecraft/world/entity/monster/Slime.java.patch index 27fde65da4..7f975fbff1 100644 --- a/patches/net/minecraft/world/entity/monster/Slime.java.patch +++ b/patches/net/minecraft/world/entity/monster/Slime.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java -@@ -139,6 +_,8 @@ +@@ -146,6 +_,8 @@ float f = this.getDimensions(this.getPose()).width() * 2.0F; float f1 = f / 2.0F; @@ -9,31 +9,33 @@ for (int i = 0; (float)i < f * 16.0F; i++) { float f2 = this.random.nextFloat() * (float) (Math.PI * 2); float f3 = this.random.nextFloat() * 0.5F + 0.5F; -@@ -204,6 +_,8 @@ - int j = i / 2; +@@ -210,15 +_,24 @@ int k = 2 + this.random.nextInt(3); + PlayerTeam playerteam = this.getTeam(); + var children = new java.util.ArrayList(); // Neo: Children list for MobSplitEvent. + ++ this.preventConversionSpawns = true; for (int l = 0; l < k; l++) { float f2 = ((float)(l % 2) - 0.5F) * f1; float f3 = ((float)(l / 2) - 0.5F) * f1; -@@ -218,8 +_,13 @@ - slime.setInvulnerable(this.isInvulnerable()); - slime.setSize(j, true); - slime.moveTo(this.getX() + (double)f2, this.getY() + 0.5, this.getZ() + (double)f3, this.random.nextFloat() * 360.0F, 0.0F); -- this.level().addFreshEntity(slime); -+ -+ children.add(slime); // Neo: Record the slime until after event firing. - } +- this.convertTo( ++ Slime slime = this.convertTo( + this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, playerteam), EntitySpawnReason.TRIGGERED, p_381514_ -> { + p_381514_.setSize(j, true); + p_381514_.moveTo(this.getX() + (double)f2, this.getY() + 0.5, this.getZ() + (double)f3, this.random.nextFloat() * 360.0F, 0.0F); + } + ); ++ children.add(slime); // Neo: Record the slime until after event firing. + } ++ this.preventConversionSpawns = false; + + if (!net.neoforged.neoforge.event.EventHooks.onMobSplit(this, children).isCanceled()) { + children.forEach(this.level()::addFreshEntity); } } -@@ -334,6 +_,7 @@ +@@ -327,6 +_,7 @@ Vec3 vec3 = this.getDeltaMovement(); this.setDeltaMovement(vec3.x, (double)this.getJumpPower(), vec3.z); this.hasImpulse = true; @@ -41,7 +43,7 @@ } @Nullable -@@ -363,6 +_,12 @@ +@@ -358,6 +_,12 @@ public EntityDimensions getDefaultDimensions(Pose p_316359_) { return super.getDefaultDimensions(p_316359_).scale((float)this.getSize()); } diff --git a/patches/net/minecraft/world/entity/monster/Zombie.java.patch b/patches/net/minecraft/world/entity/monster/Zombie.java.patch index 01af2edaa6..08f332ee7f 100644 --- a/patches/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/patches/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 -@@ -259,6 +_,7 @@ +@@ -257,6 +_,7 @@ } protected void doUnderWaterConversion() { @@ -8,15 +8,27 @@ this.convertToZombieType(EntityType.DROWNED); if (!this.isSilent()) { this.level().levelEvent(null, 1040, this.blockPosition(), 0); -@@ -270,6 +_,7 @@ - if (zombie != null) { - zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()); - zombie.setCanBreakDoors(zombie.supportsBreakDoorGoal() && this.canBreakDoors()); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, zombie); - } +@@ -267,7 +_,10 @@ + this.convertTo( + p_34311_, + ConversionParams.single(this, true, true), +- p_381517_ -> p_381517_.handleAttributes(p_381517_.level().getCurrentDifficultyAt(p_381517_.blockPosition()).getSpecialMultiplier()) ++ p_381517_ -> { ++ p_381517_.handleAttributes(p_381517_.level().getCurrentDifficultyAt(p_381517_.blockPosition()).getSpecialMultiplier()); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381517_); ++ } + ); } -@@ -406,7 +_,7 @@ +@@ -287,6 +_,7 @@ + p_370686_.setGossips(p_371444_.getGossips().store(NbtOps.INSTANCE)); + p_370686_.setTradeOffers(p_371444_.getOffers().copy()); + p_370686_.setVillagerXp(p_371444_.getVillagerXp()); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(p_371444_, p_370686_); + if (!this.isSilent()) { + p_371466_.levelEvent(null, 1026, this.blockPosition(), 0); + } +@@ -437,7 +_,7 @@ @Override public boolean killedEntity(ServerLevel p_219160_, LivingEntity p_219161_) { boolean flag = super.killedEntity(p_219160_, p_219161_); @@ -25,11 +37,3 @@ if (p_219160_.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { return flag; } -@@ -423,6 +_,7 @@ - zombievillager.setGossips(villager.getGossips().store(NbtOps.INSTANCE)); - zombievillager.setTradeOffers(villager.getOffers().copy()); - zombievillager.setVillagerXp(villager.getVillagerXp()); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(p_219161_, zombievillager); - if (!this.isSilent()) { - p_219160_.levelEvent(null, 1026, this.blockPosition(), 0); - } diff --git a/patches/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/patches/net/minecraft/world/entity/monster/ZombieVillager.java.patch index 08521a528a..bf52e0c706 100644 --- a/patches/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/patches/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -141,7 +_,7 @@ +@@ -143,7 +_,7 @@ if (!this.level().isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); this.villagerConversionTime -= i; @@ -9,11 +9,12 @@ this.finishConversion((ServerLevel)this.level()); } } -@@ -246,6 +_,7 @@ - if (!this.isSilent()) { - p_34399_.levelEvent(null, 1027, this.blockPosition(), 0); +@@ -250,6 +_,8 @@ + if (!this.isSilent()) { + p_34399_.levelEvent(null, 1027, this.blockPosition(), 0); + } ++ ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_375894_); } -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, villager); - } + ); } - diff --git a/patches/net/minecraft/world/entity/monster/creaking/Creaking.java.patch b/patches/net/minecraft/world/entity/monster/creaking/Creaking.java.patch new file mode 100644 index 0000000000..8718946d79 --- /dev/null +++ b/patches/net/minecraft/world/entity/monster/creaking/Creaking.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/entity/monster/creaking/Creaking.java ++++ b/net/minecraft/world/entity/monster/creaking/Creaking.java +@@ -230,7 +_,8 @@ + + return true; + } else { +- Predicate predicate = this.isActive() ? LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM : p_380174_ -> true; ++ // Neo: provide entity being looked at to disguise check ++ java.util.function.BiPredicate predicate = this.isActive() ? LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM_FOR_TARGET : (p_380174_, target) -> true; + + for (Player player : list) { + if (!player.isCreative() diff --git a/patches/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch b/patches/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch index 14a4f5a41d..4c3ea3d287 100644 --- a/patches/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch +++ b/patches/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -1,19 +1,23 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -161,7 +_,7 @@ +@@ -166,7 +_,7 @@ HoglinAi.updateActivity(this); if (this.isConverting()) { this.timeInOverworld++; - if (this.timeInOverworld > 300) { + if (this.timeInOverworld > 300 && net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.ZOGLIN, (timer) -> this.timeInOverworld = timer)) { this.makeSound(SoundEvents.HOGLIN_CONVERTED_TO_ZOMBIFIED); - this.finishConversion((ServerLevel)this.level()); + this.finishConversion(); } -@@ -259,6 +_,7 @@ - Zoglin zoglin = this.convertTo(EntityType.ZOGLIN, true); - if (zoglin != null) { - zoglin.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, zoglin); - } +@@ -266,7 +_,10 @@ + this.convertTo( + EntityType.ZOGLIN, + ConversionParams.single(this, true, false), +- p_371903_ -> p_371903_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)) ++ p_371903_ -> { ++ p_371903_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_371903_); ++ } + ); } diff --git a/patches/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch b/patches/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch index 36ab4f9ccd..d33c44975b 100644 --- a/patches/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch +++ b/patches/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch @@ -1,19 +1,23 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java -@@ -82,7 +_,7 @@ +@@ -84,7 +_,7 @@ this.timeInOverworld = 0; } - if (this.timeInOverworld > 300) { + if (this.timeInOverworld > 300 && net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.ZOMBIFIED_PIGLIN, (timer) -> this.timeInOverworld = timer)) { this.playConvertedSound(); - this.finishConversion((ServerLevel)this.level()); - } -@@ -96,6 +_,7 @@ - ZombifiedPiglin zombifiedpiglin = this.convertTo(EntityType.ZOMBIFIED_PIGLIN, true); - if (zombifiedpiglin != null) { - zombifiedpiglin.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, zombifiedpiglin); + this.finishConversion(p_376586_); } +@@ -103,7 +_,10 @@ + this.convertTo( + EntityType.ZOMBIFIED_PIGLIN, + ConversionParams.single(this, true, true), +- p_371722_ -> p_371722_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)) ++ p_371722_ -> { ++ p_371722_.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_371722_); ++ } + ); } diff --git a/patches/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/patches/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index 8bb786c6e0..fc04171127 100644 --- a/patches/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/patches/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -349,7 +_,7 @@ +@@ -355,7 +_,7 @@ } else if (this.isChargingCrossbow()) { return PiglinArmPose.CROSSBOW_CHARGE; } else { -- return this.isAggressive() && this.isHolding(Items.CROSSBOW) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; -+ return this.isAggressive() && this.isHolding(is -> is.getItem() instanceof net.minecraft.world.item.CrossbowItem) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; +- return this.isHolding(Items.CROSSBOW) && CrossbowItem.isCharged(this.getWeaponItem()) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; ++ return this.isHolding(is -> is.getItem() instanceof net.minecraft.world.item.CrossbowItem) && CrossbowItem.isCharged(this.getWeaponItem()) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT; } } -@@ -390,7 +_,7 @@ +@@ -392,7 +_,7 @@ } protected void holdInOffHand(ItemStack p_34786_) { @@ -18,12 +18,12 @@ this.setItemSlot(EquipmentSlot.OFFHAND, p_34786_); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -400,7 +_,7 @@ +@@ -402,7 +_,7 @@ @Override - public boolean wantsToPickUp(ItemStack p_34777_) { -- return this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); -+ return net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); + public boolean wantsToPickUp(ServerLevel p_376232_, ItemStack p_34777_) { +- return p_376232_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); ++ return net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_376232_, this) && this.canPickUpLoot() && PiglinAi.wantsToPickup(this, p_34777_); } protected boolean canReplaceCurrentItem(ItemStack p_34788_) { diff --git a/patches/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/patches/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch index 3aa8dcc2a5..6aa8151c99 100644 --- a/patches/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch +++ b/patches/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java -@@ -377,7 +_,7 @@ +@@ -375,7 +_,7 @@ ItemStack itemstack = p_34868_.getItemInHand(InteractionHand.OFF_HAND); p_34868_.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); if (p_34868_.isAdult()) { @@ -9,7 +9,7 @@ if (p_34869_ && flag) { throwItems(p_34868_, getBarterResponseItems(p_34868_)); } else if (!flag) { -@@ -461,7 +_,7 @@ +@@ -459,7 +_,7 @@ return false; } else if (isAdmiringDisabled(p_34858_) && p_34858_.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; @@ -18,7 +18,7 @@ return isNotHoldingLovedItemInOffHand(p_34858_); } else { boolean flag = p_34858_.canAddToInventory(p_34859_); -@@ -551,7 +_,7 @@ +@@ -549,7 +_,7 @@ } protected static boolean canAdmire(Piglin p_34910_, ItemStack p_34911_) { @@ -26,17 +26,17 @@ + return !isAdmiringDisabled(p_34910_) && !isAdmiringItem(p_34910_) && p_34910_.isAdult() && p_34911_.isPiglinCurrency(); } - protected static void wasHurtBy(Piglin p_34838_, LivingEntity p_34839_) { -@@ -641,7 +_,7 @@ - public static boolean isWearingGold(LivingEntity p_34809_) { - for (ItemStack itemstack : p_34809_.getArmorAndBodyArmorSlots()) { - Item item = itemstack.getItem(); -- if (item instanceof ArmorItem && ((ArmorItem)item).getMaterial().is(ArmorMaterials.GOLD)) { -+ if (itemstack.makesPiglinsNeutral(p_34809_)) { + protected static void wasHurtBy(ServerLevel p_376829_, Piglin p_34838_, LivingEntity p_34839_) { +@@ -638,7 +_,7 @@ + + public static boolean isWearingSafeArmor(LivingEntity p_371788_) { + for (ItemStack itemstack : p_371788_.getArmorAndBodyArmorSlots()) { +- if (itemstack.is(ItemTags.PIGLIN_SAFE_ARMOR)) { ++ if (itemstack.makesPiglinsNeutral(p_371788_)) { return true; } } -@@ -792,7 +_,7 @@ +@@ -790,7 +_,7 @@ } private static boolean hasCrossbow(LivingEntity p_34919_) { diff --git a/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch b/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch index 29b127e428..62dfc9f67e 100644 --- a/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch +++ b/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch @@ -3,9 +3,9 @@ @@ -11,7 +_,7 @@ public static BehaviorControl create() { return BehaviorBuilder.create( - p_259197_ -> p_259197_.group(p_259197_.absent(MemoryModuleType.ADMIRING_ITEM)).apply(p_259197_, p_259512_ -> (p_352826_, p_352827_, p_352828_) -> { -- if (!p_352827_.getOffhandItem().isEmpty() && !p_352827_.getOffhandItem().is(Items.SHIELD)) { -+ if (!p_352827_.getOffhandItem().isEmpty() && !p_352827_.getOffhandItem().canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHIELD_BLOCK)) { - PiglinAi.stopHoldingOffHandItem(p_352827_, true); + p_259197_ -> p_259197_.group(p_259197_.absent(MemoryModuleType.ADMIRING_ITEM)).apply(p_259197_, p_259512_ -> (p_381534_, p_381535_, p_381536_) -> { +- if (!p_381535_.getOffhandItem().isEmpty() && !p_381535_.getOffhandItem().is(Items.SHIELD)) { ++ if (!p_381535_.getOffhandItem().isEmpty() && !p_381535_.getOffhandItem().canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHIELD_BLOCK)) { + PiglinAi.stopHoldingOffHandItem(p_381534_, p_381535_, true); return true; } else { diff --git a/patches/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/patches/net/minecraft/world/entity/npc/AbstractVillager.java.patch index 043791fc34..961d41fffc 100644 --- a/patches/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ b/patches/net/minecraft/world/entity/npc/AbstractVillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -127,6 +_,7 @@ +@@ -129,6 +_,7 @@ if (this.tradingPlayer instanceof ServerPlayer) { CriteriaTriggers.TRADE.trigger((ServerPlayer)this.tradingPlayer, this, p_35274_.getResult()); } @@ -8,7 +8,7 @@ } protected abstract void rewardTradeXp(MerchantOffer p_35299_); -@@ -183,13 +_,6 @@ +@@ -185,13 +_,6 @@ } this.readInventoryFromTag(p_35290_, this.registryAccess()); @@ -16,9 +16,9 @@ - - @Nullable - @Override -- public Entity changeDimension(DimensionTransition p_350994_) { +- public Entity teleport(TeleportTransition p_379715_) { - this.stopTrading(); -- return super.changeDimension(p_350994_); +- return super.teleport(p_379715_); } protected void stopTrading() { diff --git a/patches/net/minecraft/world/entity/npc/CatSpawner.java.patch b/patches/net/minecraft/world/entity/npc/CatSpawner.java.patch index c0cbf518d6..f15338a740 100644 --- a/patches/net/minecraft/world/entity/npc/CatSpawner.java.patch +++ b/patches/net/minecraft/world/entity/npc/CatSpawner.java.patch @@ -5,7 +5,7 @@ return 0; } else { + cat.moveTo(p_35334_, 0.0F, 0.0F); // Fix MC-147659: Some witch huts spawn the incorrect cat - cat.finalizeSpawn(p_35335_, p_35335_.getCurrentDifficultyAt(p_35334_), MobSpawnType.NATURAL, null); + cat.finalizeSpawn(p_35335_, p_35335_.getCurrentDifficultyAt(p_35334_), EntitySpawnReason.NATURAL, null); - cat.moveTo(p_35334_, 0.0F, 0.0F); p_35335_.addFreshEntityWithPassengers(cat); return 1; diff --git a/patches/net/minecraft/world/entity/npc/Villager.java.patch b/patches/net/minecraft/world/entity/npc/Villager.java.patch index f206fb91fd..308d4a20d0 100644 --- a/patches/net/minecraft/world/entity/npc/Villager.java.patch +++ b/patches/net/minecraft/world/entity/npc/Villager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/Villager.java +++ b/net/minecraft/world/entity/npc/Villager.java -@@ -322,7 +_,7 @@ +@@ -313,7 +_,7 @@ @Override public InteractionResult mobInteract(Player p_35472_, InteractionHand p_35473_) { ItemStack itemstack = p_35472_.getItemInHand(p_35473_); @@ -9,7 +9,7 @@ return super.mobInteract(p_35472_, p_35473_); } else if (this.isBaby()) { this.setUnhappy(); -@@ -742,8 +_,9 @@ +@@ -719,8 +_,9 @@ @Override protected Component getTypeName() { @@ -20,32 +20,28 @@ ); } -@@ -799,7 +_,7 @@ +@@ -781,10 +_,11 @@ @Override public void thunderHit(ServerLevel p_35409_, LightningBolt p_35410_) { - if (p_35409_.getDifficulty() != Difficulty.PEACEFUL) { + if (p_35409_.getDifficulty() != Difficulty.PEACEFUL && net.neoforged.neoforge.event.EventHooks.canLivingConvert(this, EntityType.WITCH, (timer) -> {})) { LOGGER.info("Villager {} was struck by lightning {}.", this, p_35410_); - Witch witch = EntityType.WITCH.create(p_35409_); - if (witch != null) { -@@ -812,6 +_,7 @@ - } - - witch.setPersistenceRequired(); -+ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, witch); - p_35409_.addFreshEntityWithPassengers(witch); + Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), p_381540_ -> { + p_381540_.finalizeSpawn(p_35409_, p_35409_.getCurrentDifficultyAt(p_381540_.blockPosition()), EntitySpawnReason.CONVERSION, null); ++ net.neoforged.neoforge.event.EventHooks.onLivingConvert(this, p_381540_); + p_381540_.setPersistenceRequired(); this.releaseAllPois(); - this.discard(); -@@ -831,7 +_,10 @@ + }); +@@ -804,7 +_,10 @@ @Override - public boolean wantsToPickUp(ItemStack p_35543_) { + public boolean wantsToPickUp(ServerLevel p_376823_, ItemStack p_35543_) { Item item = p_35543_.getItem(); -- return (WANTED_ITEMS.contains(item) || this.getVillagerData().getProfession().requestedItems().contains(item)) -+ // Neo: Patched so that Farmer Villagers will pick up SpecialPlantable items. Also fixes MC-274244 by making "minecraft:villager_plantable_seeds" tagged items also be picked up by Farmer Villagers to be planted later. -+ boolean isFarmerDesiredSeed = (p_35543_.is(ItemTags.VILLAGER_PLANTABLE_SEEDS) || (p_35543_.getItem() instanceof net.neoforged.neoforge.common.SpecialPlantable specialPlantable && specialPlantable.villagerCanPlantItem(this))) +- return (p_35543_.is(ItemTags.VILLAGER_PICKS_UP) || this.getVillagerData().getProfession().requestedItems().contains(item)) ++ // Neo: Allow Farmer Villagers to pick up SpecialPlantable items. ++ boolean isFarmerDesiredSeed = (p_35543_.getItem() instanceof net.neoforged.neoforge.common.SpecialPlantable specialPlantable && specialPlantable.villagerCanPlantItem(this)) + && this.getVillagerData().getProfession().secondaryPoi().stream().anyMatch(secondaryPoi -> secondaryPoi.defaultBlockState().is(net.neoforged.neoforge.common.Tags.Blocks.VILLAGER_FARMLANDS)); -+ return (WANTED_ITEMS.contains(item) || this.getVillagerData().getProfession().requestedItems().contains(item) || isFarmerDesiredSeed) ++ return (p_35543_.is(ItemTags.VILLAGER_PICKS_UP) || this.getVillagerData().getProfession().requestedItems().contains(item) || isFarmerDesiredSeed) && this.getInventory().canAddItem(p_35543_); } diff --git a/patches/net/minecraft/world/entity/player/Inventory.java.patch b/patches/net/minecraft/world/entity/player/Inventory.java.patch index 661a168207..17c929ae65 100644 --- a/patches/net/minecraft/world/entity/player/Inventory.java.patch +++ b/patches/net/minecraft/world/entity/player/Inventory.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java -@@ -133,7 +_,7 @@ +@@ -132,7 +_,7 @@ for (int k = 0; k < 9; k++) { int l = (this.selected + k) % 9; @@ -9,7 +9,7 @@ return l; } } -@@ -214,11 +_,15 @@ +@@ -204,11 +_,15 @@ } public void tick() { @@ -26,7 +26,7 @@ } } } -@@ -268,6 +_,8 @@ +@@ -258,6 +_,8 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Adding item to inventory"); CrashReportCategory crashreportcategory = crashreport.addCategory("Item being added"); diff --git a/patches/net/minecraft/world/entity/player/Player.java.patch b/patches/net/minecraft/world/entity/player/Player.java.patch index b56eec23b3..a4bdc8c832 100644 --- a/patches/net/minecraft/world/entity/player/Player.java.patch +++ b/patches/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -113,7 +_,8 @@ +@@ -117,7 +_,8 @@ import net.minecraft.world.scores.Team; import org.slf4j.Logger; @@ -10,7 +10,7 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final HumanoidArm DEFAULT_MAIN_HAND = HumanoidArm.RIGHT; public static final int DEFAULT_MODEL_CUSTOMIZATION = 0; -@@ -193,6 +_,10 @@ +@@ -197,6 +_,10 @@ public Entity currentExplosionCause; private boolean ignoreFallDamageFromCurrentImpulse; private int currentImpulseContextResetGraceTime; @@ -21,7 +21,7 @@ public Player(Level p_250508_, BlockPos p_250289_, float p_251702_, GameProfile p_252153_) { super(EntityType.PLAYER, p_250508_); -@@ -229,7 +_,8 @@ +@@ -233,7 +_,8 @@ .add(Attributes.SUBMERGED_MINING_SPEED) .add(Attributes.SNEAKING_SPEED) .add(Attributes.MINING_EFFICIENCY) @@ -31,7 +31,7 @@ } @Override -@@ -245,6 +_,7 @@ +@@ -249,6 +_,7 @@ @Override public void tick() { @@ -39,7 +39,7 @@ this.noPhysics = this.isSpectator(); if (this.isSpectator()) { this.setOnGround(false); -@@ -260,7 +_,7 @@ +@@ -264,7 +_,7 @@ this.sleepCounter = 100; } @@ -48,20 +48,20 @@ this.stopSleepInBed(false, true); } } else if (this.sleepCounter > 0) { -@@ -291,7 +_,11 @@ +@@ -295,7 +_,11 @@ } if (!this.isSleeping()) { - this.awardStat(Stats.TIME_SINCE_REST); + // Neo: Advance TIME_SINCE_REST if (a) vanilla daytime handling in effect, or (b) days are shorter, or (c) dayTime has ticked, or (d) dayTime advances are off and we need to ignore day length -+ if (level().getDayTimeFraction() < 0 || level().getDayTimeFraction() >= 1 || lastDayTimeTick != level().getDayTime() || !level().getGameRules().getRule(GameRules.RULE_DAYLIGHT).get()) { ++ if (level().getDayTimeFraction() < 0 || level().getDayTimeFraction() >= 1 || lastDayTimeTick != level().getDayTime() || !serverplayer.serverLevel().getGameRules().getRule(GameRules.RULE_DAYLIGHT).get()) { + lastDayTimeTick = level().getDayTime(); + this.awardStat(Stats.TIME_SINCE_REST); + } } } -@@ -318,6 +_,7 @@ +@@ -325,6 +_,7 @@ if (this.currentImpulseContextResetGraceTime > 0) { this.currentImpulseContextResetGraceTime--; } @@ -69,7 +69,7 @@ } @Override -@@ -397,6 +_,10 @@ +@@ -427,6 +_,10 @@ } protected void updatePlayerPose() { @@ -80,7 +80,7 @@ if (this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.SWIMMING)) { Pose pose; if (this.isFallFlying()) { -@@ -630,6 +_,7 @@ +@@ -654,6 +_,7 @@ @Override public void die(DamageSource p_36152_) { @@ -88,7 +88,7 @@ super.die(p_36152_); this.reapplyPosition(); if (!this.isSpectator() && this.level() instanceof ServerLevel serverlevel) { -@@ -684,7 +_,7 @@ +@@ -711,7 +_,7 @@ @Nullable public ItemEntity drop(ItemStack p_36177_, boolean p_36178_) { @@ -97,20 +97,23 @@ } @Nullable -@@ -726,7 +_,12 @@ - } +@@ -723,7 +_,15 @@ + return null; } -+ @Deprecated //Use location sensitive version below ++ /** ++ * @deprecated Neo: {@link #getDestroySpeed(BlockState, BlockPos)} instead ++ */ ++ @Deprecated public float getDestroySpeed(BlockState p_36282_) { -+ return getDigSpeed(p_36282_, null); ++ return getDestroySpeed(p_36282_, null); + } + -+ public float getDigSpeed(BlockState p_36282_, @Nullable BlockPos pos) { ++ public float getDestroySpeed(BlockState p_36282_, @Nullable BlockPos pos) { float f = this.inventory.getDestroySpeed(p_36282_); if (f > 1.0F) { f += (float)this.getAttributeValue(Attributes.MINING_EFFICIENCY); -@@ -754,13 +_,19 @@ +@@ -752,13 +_,19 @@ f /= 5.0F; } @@ -130,18 +133,17 @@ @Override public void readAdditionalSaveData(CompoundTag p_36215_) { super.readAdditionalSaveData(p_36215_); -@@ -872,7 +_,9 @@ - this.removeEntitiesOnShoulder(); - } - -- if (p_36154_.scalesWithDifficulty()) { -+ p_36155_ = Math.max(0.0F, p_36154_.type().scaling().getScalingFunction().scaleDamage(p_36154_, this, p_36155_, this.level().getDifficulty())); -+ -+ if (false && p_36154_.scalesWithDifficulty()) { - if (this.level().getDifficulty() == Difficulty.PEACEFUL) { - p_36155_ = 0.0F; +@@ -867,7 +_,8 @@ + return false; + } else { + this.removeEntitiesOnShoulder(); +- if (p_376171_.scalesWithDifficulty()) { ++ p_376389_ = Math.max(0.0F, p_376171_.type().scaling().getScalingFunction().scaleDamage(p_376171_, this, p_376389_, this.level().getDifficulty())); ++ if (false && p_376171_.scalesWithDifficulty()) { + if (p_376451_.getDifficulty() == Difficulty.PEACEFUL) { + p_376389_ = 0.0F; } -@@ -926,7 +_,7 @@ +@@ -922,7 +_,7 @@ @Override protected void hurtCurrentlyUsedShield(float p_36383_) { @@ -150,7 +152,7 @@ if (!this.level().isClientSide) { this.awardStat(Stats.ITEM_USED.get(this.useItem.getItem())); } -@@ -934,7 +_,13 @@ +@@ -930,7 +_,13 @@ if (p_36383_ >= 3.0F) { int i = 1 + Mth.floor(p_36383_); InteractionHand interactionhand = this.getUsedItemHand(); @@ -165,10 +167,10 @@ if (this.useItem.isEmpty()) { if (interactionhand == InteractionHand.MAIN_HAND) { this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); -@@ -952,11 +_,14 @@ +@@ -948,11 +_,14 @@ @Override - protected void actuallyHurt(DamageSource p_36312_, float p_36313_) { - if (!this.isInvulnerableTo(p_36312_)) { + protected void actuallyHurt(ServerLevel p_376500_, DamageSource p_36312_, float p_36313_) { + if (!this.isInvulnerableTo(p_376500_, p_36312_)) { - p_36313_ = this.getDamageAfterArmorAbsorb(p_36312_, p_36313_); - p_36313_ = this.getDamageAfterMagicAbsorb(p_36312_, p_36313_); - float f1 = Math.max(p_36313_ - this.getAbsorptionAmount(), 0.0F); @@ -185,7 +187,7 @@ if (f > 0.0F && f < 3.4028235E37F) { this.awardStat(Stats.DAMAGE_ABSORBED, Math.round(f * 10.0F)); } -@@ -970,7 +_,9 @@ +@@ -966,7 +_,9 @@ } this.gameEvent(GameEvent.ENTITY_DAMAGE); @@ -195,7 +197,7 @@ } } -@@ -1014,6 +_,8 @@ +@@ -1010,6 +_,8 @@ return InteractionResult.PASS; } else { @@ -204,7 +206,7 @@ ItemStack itemstack = this.getItemInHand(p_36159_); ItemStack itemstack1 = itemstack.copy(); InteractionResult interactionresult = p_36158_.interact(this, p_36159_); -@@ -1022,6 +_,9 @@ +@@ -1018,6 +_,9 @@ itemstack.setCount(itemstack1.getCount()); } @@ -214,7 +216,7 @@ return interactionresult; } else { if (!itemstack.isEmpty() && p_36158_ instanceof LivingEntity) { -@@ -1033,6 +_,7 @@ +@@ -1029,6 +_,7 @@ if (interactionresult1.consumesAction()) { this.level().gameEvent(GameEvent.ENTITY_INTERACT, p_36158_.position(), GameEvent.Context.of(this)); if (itemstack.isEmpty() && !this.abilities.instabuild) { @@ -222,7 +224,7 @@ this.setItemInHand(p_36159_, ItemStack.EMPTY); } -@@ -1062,6 +_,7 @@ +@@ -1058,6 +_,7 @@ } @Override @@ -230,7 +232,7 @@ protected Vec3 maybeBackOffFromEdge(Vec3 p_36201_, MoverType p_36202_) { float f = this.maxUpStep(); if (!this.abilities.flying -@@ -1111,6 +_,7 @@ +@@ -1107,6 +_,7 @@ } } @@ -238,7 +240,7 @@ private boolean isAboveGround(float p_341626_) { return this.onGround() || this.fallDistance < p_341626_ && !this.canFallAtLeast(0.0, 0.0, p_341626_ - this.fallDistance); } -@@ -1132,6 +_,7 @@ +@@ -1128,6 +_,7 @@ } public void attack(Entity p_36347_) { @@ -246,7 +248,7 @@ if (p_36347_.isAttackable()) { if (!p_36347_.skipAttackInteraction(this)) { float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); -@@ -1141,7 +_,6 @@ +@@ -1137,7 +_,6 @@ float f2 = this.getAttackStrengthScale(0.5F); f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -254,7 +256,7 @@ if (p_36347_.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && p_36347_ instanceof Projectile projectile && projectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, this, true)) { -@@ -1170,19 +_,28 @@ +@@ -1166,20 +_,31 @@ && !this.isPassenger() && p_36347_ instanceof LivingEntity && !this.isSprinting(); @@ -269,26 +271,27 @@ float f3 = f + f1; boolean flag2 = false; - double d0 = (double)(this.walkDist - this.walkDistO); -- if (flag4 && !flag1 && !flag && this.onGround() && d0 < (double)this.getSpeed()) { +- if (flag3 && !flag1 && !flag && this.onGround()) { + // Neo: Replace !flag1 (!isCriticalHit) with the logic from the CriticalHitEvent. + boolean critBlocksSweep = critEvent.isCriticalHit() && critEvent.disableSweep(); -+ if (flag4 && !critBlocksSweep && !flag && this.onGround() && d0 < (double)this.getSpeed()) { ++ if (flag3 && !critBlocksSweep && !flag && this.onGround()) { + double d0 = this.getKnownMovement().horizontalDistanceSqr(); + double d1 = (double)this.getSpeed() * 2.5; +- if (d0 < Mth.square(d1) && this.getItemInHand(InteractionHand.MAIN_HAND).is(ItemTags.SWORDS)) { + // Neo: Make sweep attacks check SWORD_SWEEP instead of instanceof SwordItem. - ItemStack itemstack1 = this.getItemInHand(InteractionHand.MAIN_HAND); -- if (itemstack1.getItem() instanceof SwordItem) { -- flag2 = true; -- } -+ flag2 = itemstack1.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SWORD_SWEEP); ++ if (d0 < Mth.square(d1) && this.getItemInHand(InteractionHand.MAIN_HAND).canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SWORD_SWEEP)) { + flag2 = true; + } } -+ + + // Neo: Fire the SweepAttackEvent and overwrite the value of flag2 (the local controlling if a sweep will occur). + var sweepEvent = net.neoforged.neoforge.common.CommonHooks.fireSweepAttack(this, p_36347_, flag2); + flag2 = sweepEvent.isSweeping(); - ++ float f6 = 0.0F; if (p_36347_ instanceof LivingEntity livingentity) { -@@ -1217,11 +_,12 @@ + f6 = livingentity.getHealth(); +@@ -1213,11 +_,12 @@ for (LivingEntity livingentity2 : this.level() .getEntitiesOfClass(LivingEntity.class, p_36347_.getBoundingBox().inflate(1.0, 0.25, 1.0))) { @@ -302,7 +305,7 @@ float f5 = this.getEnchantedDamage(livingentity2, f7, damagesource) * f2; livingentity2.knockback( 0.4F, -@@ -1268,11 +_,12 @@ +@@ -1264,11 +_,12 @@ this.setLastHurtMob(p_36347_); Entity entity = p_36347_; @@ -317,7 +320,7 @@ if (this.level() instanceof ServerLevel serverlevel1) { if (entity instanceof LivingEntity livingentity3) { flag5 = itemstack.hurtEnemy(livingentity3, this); -@@ -1287,6 +_,7 @@ +@@ -1283,6 +_,7 @@ } if (itemstack.isEmpty()) { @@ -325,7 +328,7 @@ if (itemstack == this.getMainHandItem()) { this.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY); } else { -@@ -1311,6 +_,7 @@ +@@ -1307,6 +_,7 @@ .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); } } @@ -333,15 +336,6 @@ } } } -@@ -1325,7 +_,7 @@ - } - - public void disableShield() { -- this.getCooldowns().addCooldown(Items.SHIELD, 100); -+ this.getCooldowns().addCooldown(this.getUseItem().getItem(), 100); - this.stopUsingItem(); - this.level().broadcastEntityEvent(this, (byte)30); - } @@ -1391,6 +_,7 @@ } @@ -350,7 +344,7 @@ super.stopSleeping(); if (this.level() instanceof ServerLevel && p_36227_) { ((ServerLevel)this.level()).updateSleepingPlayerList(); -@@ -1503,7 +_,8 @@ +@@ -1496,7 +_,8 @@ @Override public boolean causeFallDamage(float p_150093_, float p_150094_, DamageSource p_150095_) { @@ -360,16 +354,7 @@ return false; } else { if (p_150093_ >= 2.0F) { -@@ -1535,7 +_,7 @@ - public boolean tryToStartFallFlying() { - if (!this.onGround() && !this.isFallFlying() && !this.isInWater() && !this.hasEffect(MobEffects.LEVITATION)) { - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.CHEST); -- if (itemstack.is(Items.ELYTRA) && ElytraItem.isFlyEnabled(itemstack)) { -+ if (itemstack.canElytraFly(this)) { - this.startFallFlying(); - return true; - } -@@ -1564,13 +_,13 @@ +@@ -1555,13 +_,13 @@ protected void playStepSound(BlockPos p_282121_, BlockState p_282194_) { if (this.isInWater()) { this.waterSwimSound(); @@ -385,7 +370,7 @@ } else { super.playStepSound(blockpos, blockstate); } -@@ -1601,6 +_,10 @@ +@@ -1592,6 +_,10 @@ } public void giveExperiencePoints(int p_36291_) { @@ -396,7 +381,7 @@ this.increaseScore(p_36291_); this.experienceProgress = this.experienceProgress + (float)p_36291_ / (float)this.getXpNeededForNextLevel(); this.totalExperience = Mth.clamp(this.totalExperience + p_36291_, 0, Integer.MAX_VALUE); -@@ -1628,7 +_,7 @@ +@@ -1619,7 +_,7 @@ } public void onEnchantmentPerformed(ItemStack p_36172_, int p_36173_) { @@ -405,7 +390,7 @@ if (this.experienceLevel < 0) { this.experienceLevel = 0; this.experienceProgress = 0.0F; -@@ -1639,6 +_,10 @@ +@@ -1630,6 +_,10 @@ } public void giveExperienceLevels(int p_36276_) { @@ -413,10 +398,10 @@ + if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event).isCanceled()) return; + p_36276_ = event.getLevels(); + - this.experienceLevel += p_36276_; + this.experienceLevel = IntMath.saturatedAdd(this.experienceLevel, p_36276_); if (this.experienceLevel < 0) { this.experienceLevel = 0; -@@ -1847,7 +_,11 @@ +@@ -1833,7 +_,11 @@ @Override public Component getDisplayName() { @@ -429,7 +414,7 @@ return this.decorateDisplayNameComponent(mutablecomponent); } -@@ -2009,21 +_,21 @@ +@@ -1997,21 +_,21 @@ if (!(p_36349_.getItem() instanceof ProjectileWeaponItem)) { return ItemStack.EMPTY; } else { @@ -456,19 +441,7 @@ } } } -@@ -2047,7 +_,10 @@ - } - - if (!this.level().isClientSide()) { -- this.getInventory().add(optional.get().copy()); -+ ItemStack container = optional.get().copy(); -+ if (!getInventory().add(container)) { -+ drop(container, false); -+ } - } - } - -@@ -2201,5 +_,41 @@ +@@ -2172,5 +_,41 @@ public Component getMessage() { return this.message; } diff --git a/patches/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/patches/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index 38e7f69f2b..f84027025e 100644 --- a/patches/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/patches/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -188,7 +_,7 @@ +@@ -189,7 +_,7 @@ this.shakeTime--; } @@ -9,14 +9,20 @@ this.clearFire(); } -@@ -224,7 +_,9 @@ - } - } +@@ -269,11 +_,15 @@ -- if (hitresult != null && !flag) { -+ if (hitresult != null && hitresult.getType() != HitResult.Type.MISS && !flag) { -+ if (net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult)) + if (entityhitresult == null) { + if (this.isAlive() && p_371761_.getType() != HitResult.Type.MISS) { ++ if (net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, p_371761_)) + break; - ProjectileDeflection projectiledeflection = this.hitTargetOrDeflectSelf(hitresult); + this.hitTargetOrDeflectSelf(p_371761_); this.hasImpulse = true; - if (projectiledeflection != ProjectileDeflection.NONE) { + } + break; +- } else if (this.isAlive() && !this.noPhysics) { ++ } else if (this.isAlive() && !this.noPhysics && entityhitresult.getType() != HitResult.Type.MISS) { ++ if (net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, entityhitresult)) ++ break; + ProjectileDeflection projectiledeflection = this.hitTargetOrDeflectSelf(entityhitresult); + this.hasImpulse = true; + if (this.getPierceLevel() > 0 && projectiledeflection == ProjectileDeflection.NONE) { diff --git a/patches/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch b/patches/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch index 44a57f04bc..e90d9725f3 100644 --- a/patches/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch +++ b/patches/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch @@ -1,11 +1,21 @@ --- a/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +++ b/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -@@ -78,7 +_,7 @@ - } - +@@ -76,7 +_,8 @@ + if (this.level().isClientSide || (entity == null || !entity.isRemoved()) && this.level().hasChunkAt(this.blockPosition())) { HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType()); + Vec3 vec3; - if (hitresult.getType() != HitResult.Type.MISS) { -+ if (hitresult.getType() != HitResult.Type.MISS && !net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult)) { ++ boolean impacted = hitresult.getType() != HitResult.Type.MISS && !net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult); ++ if (impacted) { + vec3 = hitresult.getLocation(); + } else { + vec3 = this.position().add(this.getDeltaMovement()); +@@ -90,7 +_,7 @@ + this.igniteForSeconds(1.0F); + } + +- if (hitresult.getType() != HitResult.Type.MISS && this.isAlive()) { ++ if (hitresult.getType() != HitResult.Type.MISS && this.isAlive() && impacted) { this.hitTargetOrDeflectSelf(hitresult); } diff --git a/patches/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/patches/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch index 930e57708d..68e0563672 100644 --- a/patches/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/patches/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -177,6 +_,13 @@ +@@ -182,6 +_,13 @@ } } @@ -11,6 +11,6 @@ + } + } + - private void explode() { - this.level().broadcastEntityEvent(this, (byte)17); + private void explode(ServerLevel p_376529_) { + p_376529_.broadcastEntityEvent(this, (byte)17); this.gameEvent(GameEvent.EXPLODE, this.getOwner()); diff --git a/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch b/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch index aadfd8768b..1a83a15f1e 100644 --- a/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java -@@ -240,8 +_,8 @@ +@@ -245,8 +_,8 @@ private boolean shouldStopFishing(Player p_37137_) { ItemStack itemstack = p_37137_.getMainHandItem(); ItemStack itemstack1 = p_37137_.getOffhandItem(); @@ -11,7 +11,7 @@ if (!p_37137_.isRemoved() && p_37137_.isAlive() && (flag || flag1) && !(this.distanceToSqr(p_37137_) > 1024.0)) { return false; } else { -@@ -252,7 +_,7 @@ +@@ -257,7 +_,7 @@ private void checkCollision() { HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); @@ -20,7 +20,7 @@ } @Override -@@ -441,6 +_,7 @@ +@@ -446,6 +_,7 @@ Player player = this.getPlayerOwner(); if (!this.level().isClientSide && player != null && !this.shouldStopFishing(player)) { int i = 0; @@ -28,7 +28,7 @@ if (this.hookedIn != null) { this.pullEntity(this.hookedIn); CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, Collections.emptyList()); -@@ -451,10 +_,17 @@ +@@ -456,10 +_,17 @@ .withParameter(LootContextParams.ORIGIN, this.position()) .withParameter(LootContextParams.TOOL, p_37157_) .withParameter(LootContextParams.THIS_ENTITY, this) @@ -46,7 +46,7 @@ CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer)player, p_37157_, this, list); for (ItemStack itemstack : list) { -@@ -480,6 +_,7 @@ +@@ -485,6 +_,7 @@ } this.discard(); diff --git a/patches/net/minecraft/world/entity/projectile/LargeFireball.java.patch b/patches/net/minecraft/world/entity/projectile/LargeFireball.java.patch index f9dc490f9c..ca9675d4f1 100644 --- a/patches/net/minecraft/world/entity/projectile/LargeFireball.java.patch +++ b/patches/net/minecraft/world/entity/projectile/LargeFireball.java.patch @@ -3,10 +3,10 @@ @@ -29,7 +_,8 @@ protected void onHit(HitResult p_37218_) { super.onHit(p_37218_); - if (!this.level().isClientSide) { -- boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + if (this.level() instanceof ServerLevel serverlevel) { +- boolean flag = serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + // TODO 1.19.3: The creation of Level.ExplosionInteraction means this code path will fire EntityMobGriefingEvent twice. Should we try and fix it? -SS -+ boolean flag = net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), this.getOwner()); ++ boolean flag = net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, this.getOwner()); this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float)this.explosionPower, flag, Level.ExplosionInteraction.MOB); this.discard(); } diff --git a/patches/net/minecraft/world/entity/projectile/Projectile.java.patch b/patches/net/minecraft/world/entity/projectile/Projectile.java.patch index 5309585dd0..b772c7043c 100644 --- a/patches/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/patches/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -284,7 +_,7 @@ +@@ -375,7 +_,7 @@ Entity entity = this.getOwner(); return entity instanceof Player - ? entity.mayInteract(p_150167_, p_150168_) -- : entity == null || p_150167_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -+ : entity == null || net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_150167_, entity); + ? entity.mayInteract(p_376318_, p_150168_) +- : entity == null || p_376318_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); ++ : entity == null || net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_376318_, entity); } - public boolean mayBreak(Level p_307481_) { + public boolean mayBreak(ServerLevel p_376471_) { diff --git a/patches/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch b/patches/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch index 0a939444db..19a4a507c2 100644 --- a/patches/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch +++ b/patches/net/minecraft/world/entity/projectile/ProjectileUtil.java.patch @@ -9,7 +9,7 @@ if (d0 == 0.0) { entity = entity1; vec3 = vec31; -@@ -153,8 +_,13 @@ +@@ -155,8 +_,13 @@ } } diff --git a/patches/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch b/patches/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch index d78a8d8f20..471a8a36e3 100644 --- a/patches/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch +++ b/patches/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/ShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/ShulkerBullet.java -@@ -218,7 +_,7 @@ - } +@@ -228,7 +_,7 @@ + this.handlePortal(); + } - HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); -- if (hitresult.getType() != HitResult.Type.MISS) { -+ if (hitresult.getType() != HitResult.Type.MISS && !net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult)) { - this.hitTargetOrDeflectSelf(hitresult); - } +- if (hitresult != null && this.isAlive() && hitresult.getType() != HitResult.Type.MISS) { ++ if (hitresult != null && this.isAlive() && hitresult.getType() != HitResult.Type.MISS && !net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult)) { + this.hitTargetOrDeflectSelf(hitresult); } + diff --git a/patches/net/minecraft/world/entity/projectile/SmallFireball.java.patch b/patches/net/minecraft/world/entity/projectile/SmallFireball.java.patch index 5f4cf7048f..2a65c9d0c1 100644 --- a/patches/net/minecraft/world/entity/projectile/SmallFireball.java.patch +++ b/patches/net/minecraft/world/entity/projectile/SmallFireball.java.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/world/entity/projectile/SmallFireball.java @@ -51,7 +_,7 @@ super.onHitBlock(p_37384_); - if (!this.level().isClientSide) { + if (this.level() instanceof ServerLevel serverlevel) { Entity entity = this.getOwner(); -- if (!(entity instanceof Mob) || this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (!(entity instanceof Mob) || net.neoforged.neoforge.event.EventHooks.canEntityGrief(this.level(), entity)) { +- if (!(entity instanceof Mob) || serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (!(entity instanceof Mob) || net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, entity)) { BlockPos blockpos = p_37384_.getBlockPos().relative(p_37384_.getDirection()); if (this.level().isEmptyBlock(blockpos)) { this.level().setBlockAndUpdate(blockpos, BaseFireBlock.getState(this.level(), blockpos)); diff --git a/patches/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch b/patches/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch index 8db754738d..0f2f4b2c73 100644 --- a/patches/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch +++ b/patches/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/projectile/ThrowableProjectile.java +++ b/net/minecraft/world/entity/projectile/ThrowableProjectile.java -@@ -42,7 +_,7 @@ - public void tick() { - super.tick(); +@@ -48,7 +_,7 @@ + this.applyInertia(); HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); + Vec3 vec3; - if (hitresult.getType() != HitResult.Type.MISS) { + if (hitresult.getType() != HitResult.Type.MISS && !net.neoforged.neoforge.event.EventHooks.onProjectileImpact(this, hitresult)) { - this.hitTargetOrDeflectSelf(hitresult); - } - + vec3 = hitresult.getLocation(); + } else { + vec3 = this.position().add(this.getDeltaMovement()); diff --git a/patches/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/patches/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch index 483428eed1..81b0d29e99 100644 --- a/patches/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/patches/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -1,28 +1,31 @@ --- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -66,6 +_,8 @@ - +@@ -126,6 +_,8 @@ + Vec3 vec3 = this.oldPosition(); if (entity instanceof ServerPlayer serverplayer) { if (serverplayer.connection.isAcceptingMessages()) { + net.neoforged.neoforge.event.entity.EntityTeleportEvent.EnderPearl event = net.neoforged.neoforge.event.EventHooks.onEnderPearlLand(serverplayer, this.getX(), this.getY(), this.getZ(), this, 5.0F, p_37504_); + if (!event.isCanceled()) { // Don't indent to lower patch size if (this.random.nextFloat() < 0.05F && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { - Endermite endermite = EntityType.ENDERMITE.create(serverlevel); + Endermite endermite = EntityType.ENDERMITE.create(serverlevel, EntitySpawnReason.TRIGGERED); if (endermite != null) { -@@ -76,13 +_,14 @@ +@@ -140,16 +_,17 @@ - entity.changeDimension( - new DimensionTransition( -- serverlevel, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING -+ serverlevel, event.getTarget(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING + ServerPlayer serverplayer1 = serverplayer.teleport( + new TeleportTransition( +- serverlevel, vec3, Vec3.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING ++ serverlevel, event.getTarget(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), TeleportTransition.DO_NOTHING ) ); - entity.resetFallDistance(); - serverplayer.resetCurrentImpulseContext(); -- entity.hurt(this.damageSources().fall(), 5.0F); -+ entity.hurt(this.damageSources().fall(), event.getAttackDamage()); - this.playSound(serverlevel, this.position()); + if (serverplayer1 != null) { + serverplayer1.resetFallDistance(); + serverplayer1.resetCurrentImpulseContext(); +- serverplayer1.hurtServer(serverplayer.serverLevel(), this.damageSources().enderPearl(), 5.0F); ++ serverplayer1.hurtServer(serverplayer.serverLevel(), this.damageSources().fall(), event.getAttackDamage()); + } + + this.playSound(serverlevel, vec3); + } //Forge: End } } else { - entity.changeDimension( + Entity entity1 = entity.teleport( diff --git a/patches/net/minecraft/world/entity/raid/Raid.java.patch b/patches/net/minecraft/world/entity/raid/Raid.java.patch index 2175381fab..1518312f9e 100644 --- a/patches/net/minecraft/world/entity/raid/Raid.java.patch +++ b/patches/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -503,7 +_,7 @@ +@@ -493,7 +_,7 @@ int k = 0; for (int l = 0; l < j; l++) { -- Raider raider = raid$raidertype.entityType.create(this.level); -+ Raider raider = raid$raidertype.entityTypeSupplier.get().create(this.level); +- Raider raider = raid$raidertype.entityType.create(this.level, EntitySpawnReason.EVENT); ++ Raider raider = raid$raidertype.entityTypeSupplier.get().create(this.level, EntitySpawnReason.EVENT); if (raider == null) { break; } -@@ -515,7 +_,7 @@ +@@ -505,7 +_,7 @@ } this.joinRaid(i, raider, p_37756_, false); @@ -17,8 +17,8 @@ + if (raid$raidertype.entityTypeSupplier.get() == EntityType.RAVAGER) { Raider raider1 = null; if (i == this.getNumGroups(Difficulty.NORMAL)) { - raider1 = EntityType.PILLAGER.create(this.level); -@@ -834,7 +_,7 @@ + raider1 = EntityType.PILLAGER.create(this.level, EntitySpawnReason.EVENT); +@@ -828,7 +_,7 @@ } } @@ -27,7 +27,7 @@ VINDICATOR(EntityType.VINDICATOR, new int[]{0, 0, 2, 0, 1, 4, 2, 5}), EVOKER(EntityType.EVOKER, new int[]{0, 0, 0, 0, 0, 1, 1, 2}), PILLAGER(EntityType.PILLAGER, new int[]{0, 4, 3, 3, 4, 4, 4, 2}), -@@ -842,12 +_,26 @@ +@@ -836,12 +_,26 @@ RAVAGER(EntityType.RAVAGER, new int[]{0, 0, 0, 1, 0, 1, 0, 2}); static final Raid.RaiderType[] VALUES = values(); diff --git a/patches/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch b/patches/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch new file mode 100644 index 0000000000..c389491313 --- /dev/null +++ b/patches/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch @@ -0,0 +1,65 @@ +--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java ++++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java +@@ -45,7 +_,7 @@ + import net.minecraft.world.phys.shapes.Shapes; + import net.minecraft.world.phys.shapes.VoxelShape; + +-public abstract class AbstractBoat extends VehicleEntity implements Leashable { ++public abstract class AbstractBoat extends VehicleEntity implements Leashable, net.neoforged.neoforge.common.extensions.IAbstractBoatExtension { + private static final EntityDataAccessor DATA_ID_PADDLE_LEFT = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor DATA_ID_PADDLE_RIGHT = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor DATA_ID_BUBBLE_TIME = SynchedEntityData.defineId(AbstractBoat.class, EntityDataSerializers.INT); +@@ -478,7 +_,7 @@ + for (int i2 = i1; i2 < j1; i2++) { + blockpos$mutableblockpos.set(l1, k1, i2); + FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); +- if (fluidstate.is(FluidTags.WATER)) { ++ if (this.canBoatInFluid(fluidstate)) { + f = Math.max(f, fluidstate.getHeight(this.level(), blockpos$mutableblockpos)); + } + +@@ -524,7 +_,7 @@ + voxelshape, + BooleanOp.AND + )) { +- f += blockstate.getBlock().getFriction(); ++ f += blockstate.getFriction(this.level(), blockpos$mutableblockpos, this); + k1++; + } + } +@@ -553,7 +_,7 @@ + for (int i2 = i1; i2 < j1; i2++) { + blockpos$mutableblockpos.set(k1, l1, i2); + FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); +- if (fluidstate.is(FluidTags.WATER)) { ++ if (this.canBoatInFluid(fluidstate)) { + float f = (float)l1 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos); + this.waterLevel = Math.max((double)f, this.waterLevel); + flag |= aabb.minY < (double)f; +@@ -583,7 +_,7 @@ + for (int i2 = i1; i2 < j1; i2++) { + blockpos$mutableblockpos.set(k1, l1, i2); + FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); +- if (fluidstate.is(FluidTags.WATER) ++ if (this.canBoatInFluid(fluidstate) + && d0 < (double)((float)blockpos$mutableblockpos.getY() + fluidstate.getHeight(this.level(), blockpos$mutableblockpos))) { + if (!fluidstate.isSource()) { + return AbstractBoat.Status.UNDER_FLOWING_WATER; +@@ -790,7 +_,7 @@ + if (!this.isPassenger()) { + if (p_376924_) { + this.resetFallDistance(); +- } else if (!this.level().getFluidState(this.blockPosition().below()).is(FluidTags.WATER) && p_376661_ < 0.0) { ++ } else if (!this.canBoatInFluid(this.level().getFluidState(this.blockPosition().below())) && p_376661_ < 0.0) { + this.fallDistance -= (float)p_376661_; + } + } +@@ -814,7 +_,7 @@ + + @Override + protected boolean canAddPassenger(Entity p_376443_) { +- return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER); ++ return this.getPassengers().size() < this.getMaxPassengers() && !this.canBoatInFluid(this.getEyeInFluidType()); + } + + protected int getMaxPassengers() { diff --git a/patches/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/patches/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch index 283ba48c69..3360a92b16 100644 --- a/patches/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -1,307 +1,13 @@ --- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -45,7 +_,7 @@ - import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.Vec3; +@@ -430,8 +_,8 @@ --public abstract class AbstractMinecart extends VehicleEntity { -+public abstract class AbstractMinecart extends VehicleEntity implements net.neoforged.neoforge.common.extensions.IAbstractMinecartExtension { - private static final Vec3 LOWERED_PASSENGER_ATTACHMENT = new Vec3(0.0, 0.0, 0.0); - private static final EntityDataAccessor DATA_ID_DISPLAY_BLOCK = SynchedEntityData.defineId(AbstractMinecart.class, EntityDataSerializers.INT); - private static final EntityDataAccessor DATA_ID_DISPLAY_OFFSET = SynchedEntityData.defineId(AbstractMinecart.class, EntityDataSerializers.INT); -@@ -63,6 +_,7 @@ - private double lerpYRot; - private double lerpXRot; - private Vec3 targetDeltaMovement = Vec3.ZERO; -+ private boolean canBePushed = true; - private static final Map> EXITS = Util.make(Maps.newEnumMap(RailShape.class), p_38135_ -> { - Vec3i vec3i = Direction.WEST.getNormal(); - Vec3i vec3i1 = Direction.EAST.getNormal(); -@@ -83,6 +_,7 @@ - p_38135_.put(RailShape.NORTH_WEST, Pair.of(vec3i2, vec3i)); - p_38135_.put(RailShape.NORTH_EAST, Pair.of(vec3i2, vec3i1)); - }); -+ private static net.neoforged.neoforge.common.IMinecartCollisionHandler COLLISIONS = null; - - protected AbstractMinecart(EntityType p_38087_, Level p_38088_) { - super(p_38087_, p_38088_); -@@ -97,6 +_,14 @@ - this.zo = p_38094_; - } - -+ public net.neoforged.neoforge.common.IMinecartCollisionHandler getCollisionHandler() { -+ return COLLISIONS; -+ } -+ -+ public static void registerCollisionHandler(@Nullable net.neoforged.neoforge.common.IMinecartCollisionHandler handler) { -+ COLLISIONS = handler; -+ } -+ - public static AbstractMinecart createMinecart( - ServerLevel p_305794_, - double p_38121_, -@@ -139,7 +_,7 @@ - - @Override - public boolean isPushable() { -- return true; -+ return canBePushed; - } - - @Override -@@ -271,9 +_,9 @@ - BlockPos blockpos = new BlockPos(i, j, k); - BlockState blockstate = this.level().getBlockState(blockpos); - this.onRails = BaseRailBlock.isRail(blockstate); -- if (this.onRails) { -+ if (canUseRail() && this.onRails) { - this.moveAlongTrack(blockpos, blockstate); -- if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { -+ if (blockstate.getBlock() instanceof PoweredRailBlock && ((PoweredRailBlock) blockstate.getBlock()).isActivatorRail()) { - this.activateMinecart(i, j, k, blockstate.getValue(PoweredRailBlock.POWERED)); - } - } else { -@@ -298,8 +_,11 @@ - } - - this.setRot(this.getYRot(), this.getXRot()); -- if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01) { -- List list = this.level().getEntities(this, this.getBoundingBox().inflate(0.2F, 0.0, 0.2F), EntitySelector.pushableBy(this)); -+ AABB box; -+ if (getCollisionHandler() != null) box = getCollisionHandler().getMinecartCollisionBox(this); -+ else box = this.getBoundingBox().inflate(0.2F, 0.0D, 0.2F); -+ if (canBeRidden() && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) { -+ List list = this.level().getEntities(this, box, EntitySelector.pushableBy(this)); - if (!list.isEmpty()) { - for (Entity entity1 : list) { - if (!(entity1 instanceof Player) -@@ -314,7 +_,7 @@ - } - } - } else { -- for (Entity entity : this.level().getEntities(this, this.getBoundingBox().inflate(0.2F, 0.0, 0.2F))) { -+ for(Entity entity : this.level().getEntities(this, box)) { - if (!this.hasPassenger(entity) && entity.isPushable() && entity instanceof AbstractMinecart) { - entity.push(this); - } -@@ -339,16 +_,23 @@ - } - - protected void comeOffTrack() { -- double d0 = this.getMaxSpeed(); -+ double d0 = this.onGround() ? this.getMaxSpeed() : getMaxSpeedAirLateral(); - Vec3 vec3 = this.getDeltaMovement(); - this.setDeltaMovement(Mth.clamp(vec3.x, -d0, d0), vec3.y, Mth.clamp(vec3.z, -d0, d0)); - if (this.onGround()) { - this.setDeltaMovement(this.getDeltaMovement().scale(0.5)); - } - -+ if (getMaxSpeedAirVertical() > 0 && getDeltaMovement().y > getMaxSpeedAirVertical()) { -+ if(Math.abs(getDeltaMovement().x) < 0.3f && Math.abs(getDeltaMovement().z) < 0.3f) -+ setDeltaMovement(new Vec3(getDeltaMovement().x, 0.15f, getDeltaMovement().z)); -+ else -+ setDeltaMovement(new Vec3(getDeltaMovement().x, getMaxSpeedAirVertical(), getDeltaMovement().z)); -+ } -+ - this.move(MoverType.SELF, this.getDeltaMovement()); - if (!this.onGround()) { -- this.setDeltaMovement(this.getDeltaMovement().scale(0.95)); -+ this.setDeltaMovement(this.getDeltaMovement().scale(getDragAir())); - } - } - -@@ -361,18 +_,19 @@ - d1 = (double)p_38156_.getY(); - boolean flag = false; - boolean flag1 = false; -- if (p_38157_.is(Blocks.POWERED_RAIL)) { -+ BaseRailBlock baserailblock = (BaseRailBlock) p_38157_.getBlock(); -+ if (baserailblock instanceof PoweredRailBlock && !((PoweredRailBlock) baserailblock).isActivatorRail()) { - flag = p_38157_.getValue(PoweredRailBlock.POWERED); - flag1 = !flag; - } - -- double d3 = 0.0078125; -+ double d3 = getSlopeAdjustment(); - if (this.isInWater()) { - d3 *= 0.2; - } - - Vec3 vec31 = this.getDeltaMovement(); -- RailShape railshape = p_38157_.getValue(((BaseRailBlock)p_38157_.getBlock()).getShapeProperty()); -+ RailShape railshape = ((BaseRailBlock)p_38157_.getBlock()).getRailDirection(p_38157_, this.level(), p_38156_, this); - switch (railshape) { - case ASCENDING_EAST: - this.setDeltaMovement(vec31.add(-d3, 0.0, 0.0)); -@@ -418,7 +_,7 @@ - } - } - -- if (flag1) { -+ if (flag1 && shouldDoRailFunctions()) { - double d22 = this.getDeltaMovement().horizontalDistance(); - if (d22 < 0.03) { - this.setDeltaMovement(Vec3.ZERO); -@@ -447,10 +_,7 @@ - d0 = d23 + d4 * d14; - d2 = d10 + d5 * d14; - this.setPos(d0, d1, d2); -- double d24 = this.isVehicle() ? 0.75 : 1.0; -- double d25 = this.getMaxSpeed(); -- vec31 = this.getDeltaMovement(); -- this.move(MoverType.SELF, new Vec3(Mth.clamp(d24 * vec31.x, -d25, d25), 0.0, Mth.clamp(d24 * vec31.z, -d25, d25))); -+ this.moveMinecartOnRail(p_38156_); - if (vec3i.getY() != 0 && Mth.floor(this.getX()) - p_38156_.getX() == vec3i.getX() && Mth.floor(this.getZ()) - p_38156_.getZ() == vec3i.getZ()) { - this.setPos(this.getX(), this.getY() + (double)vec3i.getY(), this.getZ()); - } else if (vec3i1.getY() != 0 && Mth.floor(this.getX()) - p_38156_.getX() == vec3i1.getX() && Mth.floor(this.getZ()) - p_38156_.getZ() == vec3i1.getZ() -@@ -480,7 +_,10 @@ - this.setDeltaMovement(d26 * (double)(j - p_38156_.getX()), vec35.y, d26 * (double)(i - p_38156_.getZ())); - } - -- if (flag) { -+ if (shouldDoRailFunctions()) -+ baserailblock.onMinecartPass(p_38157_, level(), p_38156_, this); -+ -+ if (flag && shouldDoRailFunctions()) { - Vec3 vec36 = this.getDeltaMovement(); - double d27 = vec36.horizontalDistance(); - if (d27 > 0.01) { -@@ -544,7 +_,7 @@ - - BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); - if (BaseRailBlock.isRail(blockstate)) { -- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); -+ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), new BlockPos(i, j, k), this); - p_38098_ = (double)j; - if (railshape.isAscending()) { - p_38098_ = (double)(j + 1); -@@ -583,7 +_,7 @@ - - BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); - if (BaseRailBlock.isRail(blockstate)) { + public Vec3 getRedstoneDirection(BlockPos p_361470_) { + BlockState blockstate = this.level().getBlockState(p_361470_); +- if (blockstate.is(Blocks.POWERED_RAIL) && blockstate.getValue(PoweredRailBlock.POWERED)) { - RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); -+ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), new BlockPos(i, j, k), this); - Pair pair = exits(railshape); - Vec3i vec3i = pair.getFirst(); - Vec3i vec3i1 = pair.getSecond(); -@@ -647,6 +_,10 @@ - - @Override - public void push(Entity p_38165_) { -+ if (getCollisionHandler() != null) { -+ getCollisionHandler().onEntityCollision(this, p_38165_); -+ return; -+ } - if (!this.level().isClientSide) { - if (!p_38165_.noPhysics && !this.noPhysics) { - if (!this.hasPassenger(p_38165_)) { -@@ -685,13 +_,11 @@ - - Vec3 vec32 = this.getDeltaMovement(); - Vec3 vec33 = p_38165_.getDeltaMovement(); -- if (((AbstractMinecart)p_38165_).getMinecartType() == AbstractMinecart.Type.FURNACE -- && this.getMinecartType() != AbstractMinecart.Type.FURNACE) { -+ if (((AbstractMinecart)p_38165_).isPoweredCart() && !this.isPoweredCart()) { - this.setDeltaMovement(vec32.multiply(0.2, 1.0, 0.2)); - this.push(vec33.x - d0, 0.0, vec33.z - d1); - p_38165_.setDeltaMovement(vec33.multiply(0.95, 1.0, 0.95)); -- } else if (((AbstractMinecart)p_38165_).getMinecartType() != AbstractMinecart.Type.FURNACE -- && this.getMinecartType() == AbstractMinecart.Type.FURNACE) { -+ } else if (!((AbstractMinecart)p_38165_).isPoweredCart() && this.isPoweredCart()) { - p_38165_.setDeltaMovement(vec33.multiply(0.2, 1.0, 0.2)); - p_38165_.push(vec32.x + d0, 0.0, vec32.z + d1); - this.setDeltaMovement(vec32.multiply(0.95, 1.0, 0.95)); -@@ -789,6 +_,93 @@ - - public void setCustomDisplay(boolean p_38139_) { - this.getEntityData().set(DATA_ID_CUSTOM_DISPLAY, p_38139_); -+ } -+ -+ // Neo: Controls whether a Minecrart is allowed on Rails or not -+ private boolean canUseRail = true; -+ -+ @Override -+ public boolean canUseRail() { -+ return canUseRail; -+ } -+ -+ @Override -+ public void setCanUseRail(boolean value) { -+ this.canUseRail = value; -+ } -+ -+ // Neo: Controls the rail speed cap -+ private float currentSpeedCapOnRail = getMaxCartSpeedOnRail(); -+ -+ @Override -+ public float getCurrentCartSpeedCapOnRail() { -+ return currentSpeedCapOnRail; -+ } -+ -+ @Override -+ public void setCurrentCartSpeedCapOnRail(float value) { -+ currentSpeedCapOnRail = Math.min(value, getMaxCartSpeedOnRail()); -+ } -+ -+ @Override -+ public double getMaxSpeedWithRail() { //Non-default because getMaximumSpeed is protected -+ if (!canUseRail()) return getMaxSpeed(); -+ BlockPos pos = this.getCurrentRailPosition(); -+ BlockState state = this.level().getBlockState(pos); -+ if (!state.is(BlockTags.RAILS)) return getMaxSpeed(); -+ -+ float railMaxSpeed = ((BaseRailBlock)state.getBlock()).getRailMaxSpeed(state, this.level(), pos, this); -+ return Math.min(railMaxSpeed, getCurrentCartSpeedCapOnRail()); -+ } -+ -+ // Neo: Controls the horizontal air speed cap -+ @org.jetbrains.annotations.Nullable -+ private Float maxSpeedAirLateral = null; -+ -+ @Override -+ public float getMaxSpeedAirLateral() { -+ return maxSpeedAirLateral == null ? (float) this.getMaxSpeed() : maxSpeedAirLateral; -+ } -+ -+ @Override -+ public void setMaxSpeedAirLateral(float value) { -+ maxSpeedAirLateral = value; -+ } -+ -+ // Neo: Controls the vertical air speed cap -+ private float maxSpeedAirVertical = DEFAULT_MAX_SPEED_AIR_VERTICAL; -+ -+ @Override -+ public float getMaxSpeedAirVertical() { -+ return maxSpeedAirVertical; -+ } -+ -+ @Override -+ public void setMaxSpeedAirVertical(float value) { -+ maxSpeedAirVertical = value; -+ } -+ -+ // Neo: Controls the drag effect when Minecart is in air -+ private double dragAir = DEFAULT_AIR_DRAG; -+ -+ @Override -+ public double getDragAir() { -+ return dragAir; -+ } -+ -+ @Override -+ public void setDragAir(double value) { -+ dragAir = value; -+ } -+ -+ // Neo: Applies the movement speed to the Minecart -+ @Override -+ public void moveMinecartOnRail(BlockPos pos) { //Non-default because getMaximumSpeed is protected -+ AbstractMinecart mc = this; -+ double d24 = mc.isVehicle() ? 0.75D : 1.0D; -+ double d25 = mc.getMaxSpeedWithRail(); -+ Vec3 vec3d1 = mc.getDeltaMovement(); -+ mc.move(MoverType.SELF, new Vec3(Mth.clamp(d24 * vec3d1.x, -d25, d25), 0.0D, Mth.clamp(d24 * vec3d1.z, -d25, d25))); - } - - @Override ++ if (blockstate.getBlock() instanceof PoweredRailBlock poweredRail && !poweredRail.isActivatorRail() && blockstate.getValue(PoweredRailBlock.POWERED)) { ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), p_361470_, this); + if (railshape == RailShape.EAST_WEST) { + if (this.isRedstoneConductor(p_361470_.west())) { + return new Vec3(1.0, 0.0, 0.0); diff --git a/patches/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch b/patches/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch index cec5eec538..15d33613e4 100644 --- a/patches/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -@@ -95,6 +_,8 @@ +@@ -93,6 +_,8 @@ @Override public InteractionResult interact(Player p_38232_, InteractionHand p_38233_) { diff --git a/patches/net/minecraft/world/entity/vehicle/Boat.java.patch b/patches/net/minecraft/world/entity/vehicle/Boat.java.patch deleted file mode 100644 index fbd6f23a2c..0000000000 --- a/patches/net/minecraft/world/entity/vehicle/Boat.java.patch +++ /dev/null @@ -1,193 +0,0 @@ ---- a/net/minecraft/world/entity/vehicle/Boat.java -+++ b/net/minecraft/world/entity/vehicle/Boat.java -@@ -52,7 +_,7 @@ - import net.minecraft.world.phys.shapes.Shapes; - import net.minecraft.world.phys.shapes.VoxelShape; - --public class Boat extends VehicleEntity implements Leashable, VariantHolder { -+public class Boat extends VehicleEntity implements Leashable, VariantHolder, net.neoforged.neoforge.common.extensions.IBoatExtension { - private static final EntityDataAccessor DATA_ID_TYPE = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.INT); - private static final EntityDataAccessor DATA_ID_PADDLE_LEFT = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.BOOLEAN); - private static final EntityDataAccessor DATA_ID_PADDLE_RIGHT = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.BOOLEAN); -@@ -157,7 +_,7 @@ - } - } - -- return new Vec3(0.0, this.getVariant() == Boat.Type.BAMBOO ? (double)(p_295933_.height() * 0.8888889F) : (double)(p_295933_.height() / 3.0F), (double)f) -+ return new Vec3(0.0, this.getVariant().isRaft() ? (double)(p_295933_.height() * 0.8888889F) : (double)(p_295933_.height() / 3.0F), (double)f) - .yRot(-this.getYRot() * (float) (Math.PI / 180.0)); - } - -@@ -212,7 +_,8 @@ - case DARK_OAK -> Items.DARK_OAK_BOAT; - case MANGROVE -> Items.MANGROVE_BOAT; - case BAMBOO -> Items.BAMBOO_RAFT; -- default -> Items.OAK_BOAT; -+ case OAK -> Items.OAK_BOAT; -+ default -> this.getVariant().boatItem.get(); - }; - } - -@@ -498,7 +_,7 @@ - for (int i2 = i1; i2 < j1; i2++) { - blockpos$mutableblockpos.set(l1, k1, i2); - FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); -- if (fluidstate.is(FluidTags.WATER)) { -+ if (this.canBoatInFluid(fluidstate)) { - f = Math.max(f, fluidstate.getHeight(this.level(), blockpos$mutableblockpos)); - } - -@@ -544,7 +_,7 @@ - voxelshape, - BooleanOp.AND - )) { -- f += blockstate.getBlock().getFriction(); -+ f += blockstate.getFriction(this.level(), blockpos$mutableblockpos, this); - k1++; - } - } -@@ -573,7 +_,7 @@ - for (int i2 = i1; i2 < j1; i2++) { - blockpos$mutableblockpos.set(k1, l1, i2); - FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); -- if (fluidstate.is(FluidTags.WATER)) { -+ if (this.canBoatInFluid(fluidstate)) { - float f = (float)l1 + fluidstate.getHeight(this.level(), blockpos$mutableblockpos); - this.waterLevel = Math.max((double)f, this.waterLevel); - flag |= aabb.minY < (double)f; -@@ -603,7 +_,7 @@ - for (int i2 = i1; i2 < j1; i2++) { - blockpos$mutableblockpos.set(k1, l1, i2); - FluidState fluidstate = this.level().getFluidState(blockpos$mutableblockpos); -- if (fluidstate.is(FluidTags.WATER) -+ if (this.canBoatInFluid(fluidstate) - && d0 < (double)((float)blockpos$mutableblockpos.getY() + fluidstate.getHeight(this.level(), blockpos$mutableblockpos))) { - if (!fluidstate.isSource()) { - return Boat.Status.UNDER_FLOWING_WATER; -@@ -832,14 +_,15 @@ - } - - for (int j = 0; j < 2; j++) { -- this.spawnAtLocation(Items.STICK); -+ // Neo: allow dropping material-specific sticks instead of just generic wooden sticks -+ this.spawnAtLocation(this.getVariant().getSticks()); - } - } - } - } - - this.resetFallDistance(); -- } else if (!this.level().getFluidState(this.blockPosition().below()).is(FluidTags.WATER) && p_38307_ < 0.0) { -+ } else if (!this.canBoatInFluid(this.level().getFluidState(this.blockPosition().below())) && p_38307_ < 0.0D) { - this.fallDistance -= (float)p_38307_; - } - } -@@ -871,7 +_,7 @@ - - @Override - protected boolean canAddPassenger(Entity p_38390_) { -- return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER); -+ return this.getPassengers().size() < this.getMaxPassengers() && !this.canBoatInFluid(this.getEyeInFluidType()); - } - - protected int getMaxPassengers() { -@@ -914,7 +_,9 @@ - IN_AIR; - } - -- public static enum Type implements StringRepresentable { -+ @net.neoforged.fml.common.asm.enumextension.NamedEnum(1) -+ @net.neoforged.fml.common.asm.enumextension.NetworkedEnum(net.neoforged.fml.common.asm.enumextension.NetworkedEnum.NetworkCheck.CLIENTBOUND) -+ public static enum Type implements StringRepresentable, net.neoforged.fml.common.asm.enumextension.IExtensibleEnum { - OAK(Blocks.OAK_PLANKS, "oak"), - SPRUCE(Blocks.SPRUCE_PLANKS, "spruce"), - BIRCH(Blocks.BIRCH_PLANKS, "birch"), -@@ -923,16 +_,59 @@ - CHERRY(Blocks.CHERRY_PLANKS, "cherry"), - DARK_OAK(Blocks.DARK_OAK_PLANKS, "dark_oak"), - MANGROVE(Blocks.MANGROVE_PLANKS, "mangrove"), -- BAMBOO(Blocks.BAMBOO_PLANKS, "bamboo"); -+ BAMBOO(Blocks.BAMBOO_PLANKS, "bamboo", true); - - private final String name; -+ /** @deprecated Neo: Will be {@link Blocks#AIR} for modded boat types, use {@link #planksSupplier} instead */ -+ @Deprecated - private final Block planks; -+ private final java.util.function.Supplier planksSupplier; -+ final java.util.function.Supplier boatItem; -+ final java.util.function.Supplier chestBoatItem; -+ private final java.util.function.Supplier stickItem; -+ private final boolean raft; - public static final StringRepresentable.EnumCodec CODEC = StringRepresentable.fromEnum(Boat.Type::values); - private static final IntFunction BY_ID = ByIdMap.continuous(Enum::ordinal, values(), ByIdMap.OutOfBoundsStrategy.ZERO); - -+ @net.neoforged.fml.common.asm.enumextension.ReservedConstructor - private Type(Block p_38427_, String p_38428_) { -+ this(p_38427_, p_38428_, false); -+ } -+ -+ @net.neoforged.fml.common.asm.enumextension.ReservedConstructor -+ private Type(Block p_38427_, String p_38428_, boolean raft) { - this.name = p_38428_; - this.planks = p_38427_; -+ this.planksSupplier = () -> p_38427_; -+ this.boatItem = () -> Items.AIR; -+ this.chestBoatItem = () -> Items.AIR; -+ this.stickItem = () -> Items.STICK; -+ this.raft = raft; -+ } -+ -+ /** -+ * @param planks A supplier of the block to be dropped when the boat is destroyed by fall damage -+ * @param name The name of this boat type -+ * @param boatItem A supplier of the item to be dropped when a normal boat or raft of this type is picked up -+ * @param chestBoatItem A supplier of the item to be dropped when a chest boat or raft of this type is picked up -+ * @param stickItem A supplier of the stick item to be dropped when the boat is destroyed by fall damage -+ * @param raft Whether this boat type is a "standard" boat or a raft -+ */ -+ private Type( -+ java.util.function.Supplier planks, -+ String name, -+ java.util.function.Supplier boatItem, -+ java.util.function.Supplier chestBoatItem, -+ java.util.function.Supplier stickItem, -+ boolean raft -+ ) { -+ this.name = name; -+ this.planks = Blocks.AIR; -+ this.planksSupplier = planks; -+ this.boatItem = boatItem; -+ this.chestBoatItem = chestBoatItem; -+ this.stickItem = stickItem; -+ this.raft = raft; - } - - @Override -@@ -945,7 +_,15 @@ - } - - public Block getPlanks() { -- return this.planks; -+ return this.planksSupplier.get(); -+ } -+ -+ public Item getSticks() { -+ return this.stickItem.get(); -+ } -+ -+ public boolean isRaft() { -+ return this.raft; - } - - @Override -@@ -959,6 +_,10 @@ - - public static Boat.Type byName(String p_38433_) { - return CODEC.byName(p_38433_, OAK); -+ } -+ -+ public static net.neoforged.fml.common.asm.enumextension.ExtensionInfo getExtensionInfo() { -+ return net.neoforged.fml.common.asm.enumextension.ExtensionInfo.nonExtended(Boat.Type.class); - } - } - } diff --git a/patches/net/minecraft/world/entity/vehicle/ChestBoat.java.patch b/patches/net/minecraft/world/entity/vehicle/ChestBoat.java.patch deleted file mode 100644 index 97fcd4d1aa..0000000000 --- a/patches/net/minecraft/world/entity/vehicle/ChestBoat.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/entity/vehicle/ChestBoat.java -+++ b/net/minecraft/world/entity/vehicle/ChestBoat.java -@@ -122,7 +_,8 @@ - case DARK_OAK -> Items.DARK_OAK_CHEST_BOAT; - case MANGROVE -> Items.MANGROVE_CHEST_BOAT; - case BAMBOO -> Items.BAMBOO_CHEST_RAFT; -- default -> Items.OAK_CHEST_BOAT; -+ case OAK -> Items.OAK_CHEST_BOAT; -+ default -> this.getVariant().chestBoatItem.get(); - }; - } - diff --git a/patches/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch b/patches/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch index 43ebd7d918..1b7edd673f 100644 --- a/patches/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java -@@ -107,6 +_,9 @@ +@@ -105,6 +_,9 @@ - this.setLootTable(null); + this.setContainerLootTable(null); LootParams.Builder lootparams$builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position()); + // Neo: set the chest to attacking_entity for loot context. + if (this instanceof AbstractMinecartContainer entityContainer) diff --git a/patches/net/minecraft/world/entity/vehicle/Minecart.java.patch b/patches/net/minecraft/world/entity/vehicle/Minecart.java.patch index dcdbc9be2f..8a977d39af 100644 --- a/patches/net/minecraft/world/entity/vehicle/Minecart.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/Minecart.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/vehicle/Minecart.java +++ b/net/minecraft/world/entity/vehicle/Minecart.java -@@ -19,6 +_,8 @@ +@@ -22,6 +_,8 @@ @Override public InteractionResult interact(Player p_38483_, InteractionHand p_38484_) { + InteractionResult ret = super.interact(p_38483_, p_38484_); + if (ret.consumesAction()) return ret; - if (p_38483_.isSecondaryUseActive()) { - return InteractionResult.PASS; - } else if (this.isVehicle()) { + if (!p_38483_.isSecondaryUseActive() && !this.isVehicle() && (this.level().isClientSide || p_38483_.startRiding(this))) { + this.playerRotationOffset = this.rotationOffset; + if (!this.level().isClientSide) { diff --git a/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch b/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch index fa2e6954e2..febb3543af 100644 --- a/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java +++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java -@@ -85,6 +_,8 @@ +@@ -82,6 +_,8 @@ @Override public InteractionResult interact(Player p_38522_, InteractionHand p_38523_) { diff --git a/patches/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch b/patches/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch index 2d4d876d57..08ca00da50 100644 --- a/patches/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/MinecartFurnace.java.patch @@ -1,23 +1,11 @@ --- a/net/minecraft/world/entity/vehicle/MinecartFurnace.java +++ b/net/minecraft/world/entity/vehicle/MinecartFurnace.java -@@ -116,6 +_,8 @@ +@@ -104,6 +_,8 @@ @Override public InteractionResult interact(Player p_38562_, InteractionHand p_38563_) { + InteractionResult ret = super.interact(p_38562_, p_38563_); + if (ret.consumesAction()) return ret; ItemStack itemstack = p_38562_.getItemInHand(p_38563_); - if (INGREDIENT.test(itemstack) && this.fuel + 3600 <= 32000) { + if (itemstack.is(ItemTags.FURNACE_MINECART_FUEL) && this.fuel + 3600 <= 32000) { itemstack.consume(1, p_38562_); -@@ -128,6 +_,11 @@ - } - - return InteractionResult.sidedSuccess(this.level().isClientSide); -+ } -+ -+ @Override -+ public float getMaxCartSpeedOnRail() { -+ return 0.2f; - } - - @Override diff --git a/patches/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch b/patches/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch index 4a73b0baf6..253ad729aa 100644 --- a/patches/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch +++ b/patches/net/minecraft/world/entity/vehicle/MinecartSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/MinecartSpawner.java +++ b/net/minecraft/world/entity/vehicle/MinecartSpawner.java -@@ -17,6 +_,11 @@ +@@ -18,6 +_,11 @@ public void broadcastEvent(Level p_150342_, BlockPos p_150343_, int p_150344_) { p_150342_.broadcastEntityEvent(MinecartSpawner.this, (byte)p_150344_); } diff --git a/patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch b/patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch new file mode 100644 index 0000000000..999ad24235 --- /dev/null +++ b/patches/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch @@ -0,0 +1,57 @@ +--- a/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java +@@ -170,7 +_,7 @@ + + public void adjustToRails(BlockPos p_360495_, BlockState p_362772_, boolean p_366683_) { + if (BaseRailBlock.isRail(p_362772_)) { +- RailShape railshape = p_362772_.getValue(((BaseRailBlock)p_362772_.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)p_362772_.getBlock()).getRailDirection(p_362772_, this.level(), p_360495_, this.minecart); + Pair pair = AbstractMinecart.exits(railshape); + Vec3 vec3 = new Vec3(pair.getFirst()).scale(0.5); + Vec3 vec31 = new Vec3(pair.getSecond()).scale(0.5); +@@ -258,11 +_,11 @@ + if (flag) { + this.minecart.resetFallDistance(); + this.minecart.setOldPosAndRot(); +- if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { ++ if (blockstate.getBlock() instanceof PoweredRailBlock poweredRail && poweredRail.isActivatorRail()) { + this.minecart.activateMinecart(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockstate.getValue(PoweredRailBlock.POWERED)); + } + +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), blockpos, this.minecart);; + Vec3 vec31 = this.calculateTrackSpeed(p_376236_, vec3.horizontal(), newminecartbehavior$trackiteration, blockpos, blockstate, railshape); + if (newminecartbehavior$trackiteration.firstIteration) { + newminecartbehavior$trackiteration.movementLeft = vec31.horizontalDistance(); +@@ -393,7 +_,7 @@ + } + + private Vec3 calculateHaltTrackSpeed(Vec3 p_360517_, BlockState p_362923_) { +- if (p_362923_.is(Blocks.POWERED_RAIL) && !p_362923_.getValue(PoweredRailBlock.POWERED)) { ++ if (p_362923_.getBlock() instanceof PoweredRailBlock poweredRail && !poweredRail.isActivatorRail() && !p_362923_.getValue(PoweredRailBlock.POWERED)) { + return p_360517_.length() < 0.03 ? Vec3.ZERO : p_360517_.scale(0.5); + } else { + return p_360517_; +@@ -401,7 +_,7 @@ + } + + private Vec3 calculateBoostTrackSpeed(Vec3 p_363053_, BlockPos p_361792_, BlockState p_361859_) { +- if (p_361859_.is(Blocks.POWERED_RAIL) && p_361859_.getValue(PoweredRailBlock.POWERED)) { ++ if (p_361859_.getBlock() instanceof PoweredRailBlock poweredRail && !poweredRail.isActivatorRail() && p_361859_.getValue(PoweredRailBlock.POWERED)) { + if (p_363053_.length() > 0.01) { + return p_363053_.normalize().scale(p_363053_.length() + 0.06); + } else { +@@ -450,10 +_,11 @@ + } + + this.minecart.move(MoverType.SELF, vec36.subtract(vec3)); +- BlockState blockstate = this.level().getBlockState(BlockPos.containing(vec36)); ++ BlockPos railPos = BlockPos.containing(vec36); ++ BlockState blockstate = this.level().getBlockState(railPos); + if (flag) { + if (BaseRailBlock.isRail(blockstate)) { +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), railPos, this.minecart);; + if (this.restAtVShape(p_361660_, railshape)) { + return 0.0; + } diff --git a/patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch b/patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch new file mode 100644 index 0000000000..d8e36d27ee --- /dev/null +++ b/patches/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch @@ -0,0 +1,55 @@ +--- a/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java ++++ b/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java +@@ -97,7 +_,7 @@ + this.minecart.setOnRails($$4); + if ($$4) { + this.moveAlongTrack(serverlevel); +- if (blockstate.is(Blocks.ACTIVATOR_RAIL)) { ++ if (blockstate.getBlock() instanceof PoweredRailBlock poweredRail && poweredRail.isActivatorRail()) { + this.minecart.activateMinecart(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockstate.getValue(PoweredRailBlock.POWERED)); + } + } else { +@@ -148,7 +_,7 @@ + d1 = (double)blockpos.getY(); + boolean flag = false; + boolean flag1 = false; +- if (blockstate.is(Blocks.POWERED_RAIL)) { ++ if (blockstate.getBlock() instanceof PoweredRailBlock poweredRail && !poweredRail.isActivatorRail()) { + flag = blockstate.getValue(PoweredRailBlock.POWERED); + flag1 = !flag; + } +@@ -159,7 +_,7 @@ + } + + Vec3 vec31 = this.getDeltaMovement(); +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), blockpos, this.minecart);; + switch (railshape) { + case ASCENDING_EAST: + this.setDeltaMovement(vec31.add(-d3, 0.0, 0.0)); +@@ -317,9 +_,10 @@ + j--; + } + +- BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); ++ BlockPos railPos = new BlockPos(i, j, k); ++ BlockState blockstate = this.level().getBlockState(railPos); + if (BaseRailBlock.isRail(blockstate)) { +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), railPos, this.minecart); + p_363435_ = (double)j; + if (railshape.isSlope()) { + p_363435_ = (double)(j + 1); +@@ -356,9 +_,10 @@ + j--; + } + +- BlockState blockstate = this.level().getBlockState(new BlockPos(i, j, k)); ++ BlockPos railPos = new BlockPos(i, j, k); ++ BlockState blockstate = this.level().getBlockState(railPos); + if (BaseRailBlock.isRail(blockstate)) { +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, this.level(), railPos, this.minecart); + Pair pair = AbstractMinecart.exits(railshape); + Vec3i vec3i = pair.getFirst(); + Vec3i vec3i1 = pair.getSecond(); diff --git a/patches/net/minecraft/world/food/FoodProperties.java.patch b/patches/net/minecraft/world/food/FoodProperties.java.patch deleted file mode 100644 index feb3b0712a..0000000000 --- a/patches/net/minecraft/world/food/FoodProperties.java.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- a/net/minecraft/world/food/FoodProperties.java -+++ b/net/minecraft/world/food/FoodProperties.java -@@ -49,6 +_,22 @@ - return (int)(this.eatSeconds * 20.0F); - } - -+ public boolean equals(Object otherObject) {// Neo: Fix MC-272643 -+ if(otherObject == this) return true; -+ if (!(otherObject instanceof FoodProperties other)) return false; -+ boolean ans = nutrition == other.nutrition && -+ saturation == other.saturation && -+ canAlwaysEat == other.canAlwaysEat && -+ eatSeconds == other.eatSeconds; -+ if (!ans) return false; -+ if (!effects.equals(other.effects)) return false; -+ ItemStack selfContainer = usingConvertsTo.orElse(null); -+ ItemStack otherContainer = other.usingConvertsTo.orElse(null); -+ if (selfContainer == otherContainer) return true; -+ if (selfContainer == null || otherContainer == null) return false; -+ return selfContainer.getCount() == otherContainer.getCount() && ItemStack.isSameItemSameComponents(selfContainer, otherContainer); -+ } -+ - public static class Builder { - private int nutrition; - private float saturationModifier; -@@ -77,11 +_,18 @@ - return this; - } - -+ // Neo: Use supplier method instead -+ @Deprecated - public FoodProperties.Builder effect(MobEffectInstance p_38763_, float p_38764_) { - this.effects.add(new FoodProperties.PossibleEffect(p_38763_, p_38764_)); - return this; - } - -+ public FoodProperties.Builder effect(java.util.function.Supplier effectIn, float probability) { -+ this.effects.add(new FoodProperties.PossibleEffect(effectIn, probability)); -+ return this; -+ } -+ - public FoodProperties.Builder usingConvertsTo(ItemLike p_347650_) { - this.usingConvertsTo = Optional.of(new ItemStack(p_347650_)); - return this; -@@ -93,7 +_,7 @@ - } - } - -- public static record PossibleEffect(MobEffectInstance effect, float probability) { -+ public static record PossibleEffect(java.util.function.Supplier effectSupplier, float probability) { - public static final Codec CODEC = RecordCodecBuilder.create( - p_337893_ -> p_337893_.group( - MobEffectInstance.CODEC.fieldOf("effect").forGetter(FoodProperties.PossibleEffect::effect), -@@ -109,8 +_,12 @@ - FoodProperties.PossibleEffect::new - ); - -+ private PossibleEffect(MobEffectInstance effect, float probability) { -+ this(() -> effect, probability); -+ } -+ - public MobEffectInstance effect() { -- return new MobEffectInstance(this.effect); -+ return new MobEffectInstance(this.effectSupplier.get()); - } - } - } diff --git a/patches/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/patches/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index 5840b2258f..d23a1d7689 100644 --- a/patches/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/patches/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 -@@ -511,6 +_,11 @@ +@@ -559,6 +_,11 @@ } private boolean tryItemClickBehaviourOverride(Player p_249615_, ClickAction p_250300_, Slot p_249384_, ItemStack p_251073_, ItemStack p_252026_) { diff --git a/patches/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch b/patches/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch index aa475430e7..9581ed49d1 100644 --- a/patches/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch +++ b/patches/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java +++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java -@@ -167,7 +_,7 @@ +@@ -142,7 +_,7 @@ } protected boolean isFuel(ItemStack p_38989_) { -- return AbstractFurnaceBlockEntity.isFuel(p_38989_); -+ return p_38989_.getBurnTime(this.recipeType) > 0; +- return this.level.fuelValues().isFuel(p_38989_); ++ return p_38989_.getBurnTime(this.recipeType, this.level.fuelValues()) > 0; } public float getBurnProgress() { diff --git a/patches/net/minecraft/world/inventory/AnvilMenu.java.patch b/patches/net/minecraft/world/inventory/AnvilMenu.java.patch index 255c825995..f8446bf46c 100644 --- a/patches/net/minecraft/world/inventory/AnvilMenu.java.patch +++ b/patches/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -6,11 +6,11 @@ + float breakChance = net.neoforged.neoforge.common.CommonHooks.onAnvilRepair(p_150474_, p_150475_, AnvilMenu.this.inputSlots.getItem(0), AnvilMenu.this.inputSlots.getItem(1)); + - this.inputSlots.setItem(0, ItemStack.EMPTY); if (this.repairItemCountCost > 0) { ItemStack itemstack = this.inputSlots.getItem(1); + if (!itemstack.isEmpty() && itemstack.getCount() > this.repairItemCountCost) { @@ -95,7 +_,7 @@ - this.cost.set(0); + this.inputSlots.setItem(0, ItemStack.EMPTY); this.access.execute((p_150479_, p_150480_) -> { BlockState blockstate = p_150479_.getBlockState(p_150480_); - if (!p_150474_.hasInfiniteMaterials() && blockstate.is(BlockTags.ANVIL) && p_150474_.getRandom().nextFloat() < 0.12F) { @@ -18,7 +18,7 @@ BlockState blockstate1 = AnvilBlock.damage(blockstate); if (blockstate1 == null) { p_150479_.removeBlock(p_150480_, false); -@@ -124,8 +_,10 @@ +@@ -125,8 +_,10 @@ j += (long)itemstack.getOrDefault(DataComponents.REPAIR_COST, Integer.valueOf(0)).intValue() + (long)itemstack2.getOrDefault(DataComponents.REPAIR_COST, Integer.valueOf(0)).intValue(); this.repairItemCountCost = 0; @@ -27,10 +27,10 @@ if (!itemstack2.isEmpty()) { - boolean flag = itemstack2.has(DataComponents.STORED_ENCHANTMENTS); + flag = itemstack2.has(DataComponents.STORED_ENCHANTMENTS); - if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) { + if (itemstack1.isDamageableItem() && itemstack.isValidRepairItem(itemstack2)) { int l2 = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4); if (l2 <= 0) { -@@ -176,8 +_,10 @@ +@@ -177,8 +_,10 @@ int j2 = entry.getIntValue(); j2 = i2 == j2 ? j2 + 1 : Math.max(j2, i2); Enchantment enchantment = holder.value(); @@ -43,15 +43,15 @@ flag1 = true; } -@@ -228,6 +_,7 @@ +@@ -229,6 +_,7 @@ i += k; itemstack1.remove(DataComponents.CUSTOM_NAME); } + if (flag && !itemstack1.isBookEnchantable(itemstack2)) itemstack1 = ItemStack.EMPTY; - int k2 = (int)Mth.clamp(j + (long)i, 0L, 2147483647L); + int k2 = i <= 0 ? 0 : (int)Mth.clamp(j + (long)i, 0L, 2147483647L); this.cost.set(k2); -@@ -297,5 +_,12 @@ +@@ -302,5 +_,12 @@ public int getCost() { return this.cost.get(); diff --git a/patches/net/minecraft/world/inventory/BeaconMenu.java.patch b/patches/net/minecraft/world/inventory/BeaconMenu.java.patch index 8df10e8f26..9c42af6e5a 100644 --- a/patches/net/minecraft/world/inventory/BeaconMenu.java.patch +++ b/patches/net/minecraft/world/inventory/BeaconMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/BeaconMenu.java +++ b/net/minecraft/world/inventory/BeaconMenu.java -@@ -98,10 +_,8 @@ +@@ -87,10 +_,8 @@ } slot.onQuickCraft(itemstack1, itemstack); diff --git a/patches/net/minecraft/world/inventory/BrewingStandMenu.java.patch b/patches/net/minecraft/world/inventory/BrewingStandMenu.java.patch index 9b9d7142ef..f562eb3218 100644 --- a/patches/net/minecraft/world/inventory/BrewingStandMenu.java.patch +++ b/patches/net/minecraft/world/inventory/BrewingStandMenu.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/BrewingStandMenu.java +++ b/net/minecraft/world/inventory/BrewingStandMenu.java -@@ -41,9 +_,9 @@ +@@ -42,9 +_,9 @@ this.brewingStand = p_39095_; this.brewingStandData = p_39096_; PotionBrewing potionbrewing = p_39094_.player.level().potionBrewing(); @@ -13,7 +13,7 @@ this.ingredientSlot = this.addSlot(new BrewingStandMenu.IngredientsSlot(potionbrewing, p_39095_, 3, 79, 17)); this.addSlot(new BrewingStandMenu.FuelSlot(p_39095_, 4, 17, 17)); this.addDataSlots(p_39096_); -@@ -81,7 +_,7 @@ +@@ -73,7 +_,7 @@ if (!this.moveItemStackTo(itemstack1, 3, 4, false)) { return ItemStack.EMPTY; } @@ -22,7 +22,7 @@ if (!this.moveItemStackTo(itemstack1, 0, 3, false)) { return ItemStack.EMPTY; } -@@ -158,13 +_,20 @@ +@@ -150,13 +_,20 @@ } static class PotionSlot extends Slot { @@ -44,7 +44,7 @@ } @Override -@@ -176,14 +_,20 @@ +@@ -168,14 +_,20 @@ public void onTake(Player p_150499_, ItemStack p_150500_) { Optional> optional = p_150500_.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).potion(); if (optional.isPresent() && p_150499_ instanceof ServerPlayer serverplayer) { diff --git a/patches/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/patches/net/minecraft/world/inventory/EnchantmentMenu.java.patch index 817bb84ff8..a60216de04 100644 --- a/patches/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/patches/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -9,10 +9,10 @@ } @Override -@@ -101,23 +_,24 @@ +@@ -91,23 +_,24 @@ if (!itemstack.isEmpty() && itemstack.isEnchantable()) { this.access.execute((p_344366_, p_344367_) -> { - IdMap> idmap = p_344366_.registryAccess().registryOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); + IdMap> idmap = p_344366_.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap(); - int j = 0; + float j = 0; @@ -37,7 +37,7 @@ } for (int l = 0; l < 3; l++) { -@@ -163,14 +_,10 @@ +@@ -153,14 +_,10 @@ List list = this.getEnchantmentList(p_347276_.registryAccess(), itemstack, p_39466_, this.costs[p_39466_]); if (!list.isEmpty()) { p_39465_.onEnchantmentPerformed(itemstack, i); @@ -56,7 +56,7 @@ itemstack1.consume(i, p_39465_); if (itemstack1.isEmpty()) { -@@ -249,7 +_,7 @@ +@@ -239,7 +_,7 @@ if (!this.moveItemStackTo(itemstack1, 2, 38, true)) { return ItemStack.EMPTY; } diff --git a/patches/net/minecraft/world/inventory/GrindstoneMenu.java.patch b/patches/net/minecraft/world/inventory/GrindstoneMenu.java.patch index 9c769897c2..fce1cf6462 100644 --- a/patches/net/minecraft/world/inventory/GrindstoneMenu.java.patch +++ b/patches/net/minecraft/world/inventory/GrindstoneMenu.java.patch @@ -37,10 +37,10 @@ private int getExperienceAmount(Level p_39632_) { + if (xp > -1) return xp; - int l = 0; - l += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(0)); - l += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(1)); -@@ -125,6 +_,8 @@ + int i = 0; + i += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(0)); + i += this.getExperienceFromItem(GrindstoneMenu.this.repairSlots.getItem(1)); +@@ -116,6 +_,8 @@ } private void createResult() { @@ -49,7 +49,7 @@ this.resultSlots.setItem(0, this.computeResult(this.repairSlots.getItem(0), this.repairSlots.getItem(1))); this.broadcastChanges(); } -@@ -155,7 +_,7 @@ +@@ -146,7 +_,7 @@ int k = p_332686_.getMaxDamage() - p_332686_.getDamageValue(); int l = j + k + i * 5 / 100; int i1 = 1; @@ -58,7 +58,7 @@ if (p_332723_.getMaxStackSize() < 2 || !ItemStack.matches(p_332723_, p_332686_)) { return ItemStack.EMPTY; } -@@ -167,6 +_,7 @@ +@@ -158,6 +_,7 @@ if (itemstack.isDamageableItem()) { itemstack.set(DataComponents.MAX_DAMAGE, i); itemstack.setDamageValue(Math.max(i - l, 0)); diff --git a/patches/net/minecraft/world/inventory/RecipeBookMenu.java.patch b/patches/net/minecraft/world/inventory/RecipeBookMenu.java.patch deleted file mode 100644 index c9e4cd5ce6..0000000000 --- a/patches/net/minecraft/world/inventory/RecipeBookMenu.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/inventory/RecipeBookMenu.java -+++ b/net/minecraft/world/inventory/RecipeBookMenu.java -@@ -43,6 +_,10 @@ - - public abstract int getSize(); - -+ public java.util.List getRecipeBookCategories() { -+ return net.minecraft.client.RecipeBookCategories.getCategories(this.getRecipeBookType()); -+ } -+ - public abstract RecipeBookType getRecipeBookType(); - - public abstract boolean shouldMoveToInventory(int p_150635_); diff --git a/patches/net/minecraft/world/inventory/ResultSlot.java.patch b/patches/net/minecraft/world/inventory/ResultSlot.java.patch index 19f87b4820..4f84a5e0a2 100644 --- a/patches/net/minecraft/world/inventory/ResultSlot.java.patch +++ b/patches/net/minecraft/world/inventory/ResultSlot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/ResultSlot.java +++ b/net/minecraft/world/inventory/ResultSlot.java -@@ -47,6 +_,7 @@ +@@ -51,6 +_,7 @@ protected void checkTakeAchievements(ItemStack p_40185_) { if (this.removeCount > 0) { p_40185_.onCraftedBy(this.player.level(), this.player, this.removeCount); @@ -8,12 +8,12 @@ } if (this.container instanceof RecipeCraftingHolder recipecraftingholder) { -@@ -63,7 +_,9 @@ +@@ -86,7 +_,9 @@ CraftingInput craftinginput = craftinginput$positioned.input(); int i = craftinginput$positioned.left(); int j = craftinginput$positioned.top(); + net.neoforged.neoforge.common.CommonHooks.setCraftingPlayer(p_150638_); - NonNullList nonnulllist = p_150638_.level().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, craftinginput, p_150638_.level()); + NonNullList nonnulllist = this.getRemainingItems(craftinginput, p_150638_.level()); + net.neoforged.neoforge.common.CommonHooks.setCraftingPlayer(null); for (int k = 0; k < craftinginput.height(); k++) { diff --git a/patches/net/minecraft/world/item/ArmorItem.java.patch b/patches/net/minecraft/world/item/ArmorItem.java.patch deleted file mode 100644 index 5f30afe02d..0000000000 --- a/patches/net/minecraft/world/item/ArmorItem.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/ArmorItem.java -+++ b/net/minecraft/world/item/ArmorItem.java -@@ -49,6 +_,8 @@ - } else { - LivingEntity livingentity = list.get(0); - EquipmentSlot equipmentslot = livingentity.getEquipmentSlotForItem(p_40400_); -+ // Neo: Respect IItemExtension#canEquip in dispenseArmor -+ if (!p_40400_.canEquip(equipmentslot, livingentity)) return false; - ItemStack itemstack = p_40400_.split(1); - livingentity.setItemSlot(equipmentslot, itemstack); - if (livingentity instanceof Mob) { diff --git a/patches/net/minecraft/world/item/AxeItem.java.patch b/patches/net/minecraft/world/item/AxeItem.java.patch index 9f9732d1ac..1edab2016b 100644 --- a/patches/net/minecraft/world/item/AxeItem.java.patch +++ b/patches/net/minecraft/world/item/AxeItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/AxeItem.java +++ b/net/minecraft/world/item/AxeItem.java -@@ -60,7 +_,7 @@ +@@ -62,7 +_,7 @@ if (playerHasShieldUseIntent(p_40529_)) { return InteractionResult.PASS; } else { @@ -9,7 +9,7 @@ if (optional.isEmpty()) { return InteractionResult.PASS; } else { -@@ -85,20 +_,19 @@ +@@ -87,20 +_,19 @@ return p_345141_.getHand().equals(InteractionHand.MAIN_HAND) && player.getOffhandItem().is(Items.SHIELD) && !player.isSecondaryUseActive(); } @@ -34,7 +34,7 @@ if (optional2.isPresent()) { p_308922_.playSound(p_309192_, p_308899_, SoundEvents.AXE_WAX_OFF, SoundSource.BLOCKS, 1.0F, 1.0F); p_308922_.levelEvent(p_309192_, 3004, p_308899_, 0); -@@ -110,8 +_,19 @@ +@@ -112,8 +_,19 @@ } } @@ -46,7 +46,7 @@ + private Optional getStripped(BlockState p_150691_) { return Optional.ofNullable(STRIPPABLES.get(p_150691_.getBlock())) - .map(p_150689_ -> p_150689_.defaultBlockState().setValue(RotatedPillarBlock.AXIS, p_150691_.getValue(RotatedPillarBlock.AXIS))); + .map(p_360012_ -> p_360012_.defaultBlockState().setValue(RotatedPillarBlock.AXIS, p_150691_.getValue(RotatedPillarBlock.AXIS))); + } + + @Override diff --git a/patches/net/minecraft/world/item/BlockItem.java.patch b/patches/net/minecraft/world/item/BlockItem.java.patch index eed7cf8eb1..95447e9649 100644 --- a/patches/net/minecraft/world/item/BlockItem.java.patch +++ b/patches/net/minecraft/world/item/BlockItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -82,11 +_,11 @@ +@@ -79,11 +_,11 @@ } } @@ -14,33 +14,18 @@ SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F -@@ -99,10 +_,16 @@ +@@ -96,8 +_,14 @@ } } + @Deprecated //Forge: Use more sensitive version {@link BlockItem#getPlaceSound(BlockState, IBlockReader, BlockPos, Entity) } protected SoundEvent getPlaceSound(BlockState p_40588_) { return p_40588_.getSoundType().getPlaceSound(); - } - ++ } ++ + //Forge: Sensitive version of BlockItem#getPlaceSound + protected SoundEvent getPlaceSound(BlockState state, Level world, BlockPos pos, Player entity) { + return state.getSoundType(world, pos, entity).getPlaceSound(); -+ } -+ - @Nullable - public BlockPlaceContext updatePlacementContext(BlockPlaceContext p_40609_) { - return p_40609_; -@@ -193,6 +_,12 @@ - - public void registerBlocks(Map p_40607_, Item p_40608_) { - p_40607_.put(this.getBlock(), p_40608_); -+ } -+ -+ /** @deprecated Neo: To be removed without replacement since registry replacement is not a feature anymore. */ -+ @Deprecated(forRemoval = true, since = "1.21.1") -+ public void removeFromBlockToItemMap(Map blockToItemMap, Item itemIn) { -+ blockToItemMap.remove(this.getBlock()); } - @Override + @Nullable diff --git a/patches/net/minecraft/world/item/BowItem.java.patch b/patches/net/minecraft/world/item/BowItem.java.patch index 88e532ec9c..0264038cb5 100644 --- a/patches/net/minecraft/world/item/BowItem.java.patch +++ b/patches/net/minecraft/world/item/BowItem.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/item/BowItem.java +++ b/net/minecraft/world/item/BowItem.java -@@ -28,6 +_,8 @@ - ItemStack itemstack = player.getProjectile(p_40667_); - if (!itemstack.isEmpty()) { +@@ -32,6 +_,8 @@ + return false; + } else { int i = this.getUseDuration(p_40667_, p_40669_) - p_40670_; + i = net.neoforged.neoforge.event.EventHooks.onArrowLoose(p_40667_, p_40668_, player, i, !itemstack.isEmpty()); -+ if (i < 0) return; ++ if (i < 0) return false; float f = getPowerForTime(i); - if (!((double)f < 0.1)) { - List list = draw(p_40667_, itemstack, player); -@@ -82,6 +_,10 @@ - public InteractionResultHolder use(Level p_40672_, Player p_40673_, InteractionHand p_40674_) { + if ((double)f < 0.1) { + return false; +@@ -89,6 +_,10 @@ + public InteractionResult use(Level p_40672_, Player p_40673_, InteractionHand p_40674_) { ItemStack itemstack = p_40673_.getItemInHand(p_40674_); boolean flag = !p_40673_.getProjectile(itemstack).isEmpty(); + -+ InteractionResultHolder ret = net.neoforged.neoforge.event.EventHooks.onArrowNock(itemstack, p_40672_, p_40673_, p_40674_, flag); ++ InteractionResult ret = net.neoforged.neoforge.event.EventHooks.onArrowNock(itemstack, p_40672_, p_40673_, p_40674_, flag); + if (ret != null) return ret; + if (!p_40673_.hasInfiniteMaterials() && !flag) { - return InteractionResultHolder.fail(itemstack); + return InteractionResult.FAIL; } else { diff --git a/patches/net/minecraft/world/item/BrushItem.java.patch b/patches/net/minecraft/world/item/BrushItem.java.patch index 34e228180c..7b051f9c2b 100644 --- a/patches/net/minecraft/world/item/BrushItem.java.patch +++ b/patches/net/minecraft/world/item/BrushItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BrushItem.java +++ b/net/minecraft/world/item/BrushItem.java -@@ -142,4 +_,9 @@ +@@ -143,4 +_,9 @@ }; } } diff --git a/patches/net/minecraft/world/item/BucketItem.java.patch b/patches/net/minecraft/world/item/BucketItem.java.patch index c87fec7ce4..911b51c960 100644 --- a/patches/net/minecraft/world/item/BucketItem.java.patch +++ b/patches/net/minecraft/world/item/BucketItem.java.patch @@ -10,7 +10,7 @@ ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, p_40704_, itemstack3); if (!p_40703_.isClientSide) { @@ -72,8 +_,8 @@ - return InteractionResultHolder.fail(itemstack); + return InteractionResult.FAIL; } else { BlockState blockstate = p_40703_.getBlockState(blockpos); - BlockPos blockpos2 = blockstate.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? blockpos : blockpos1; diff --git a/patches/net/minecraft/world/item/BundleItem.java.patch b/patches/net/minecraft/world/item/BundleItem.java.patch index 945917f07c..ff5bc70598 100644 --- a/patches/net/minecraft/world/item/BundleItem.java.patch +++ b/patches/net/minecraft/world/item/BundleItem.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/item/BundleItem.java +++ b/net/minecraft/world/item/BundleItem.java -@@ -38,7 +_,7 @@ - +@@ -61,7 +_,7 @@ @Override public boolean overrideStackedOnOther(ItemStack p_150733_, Slot p_150734_, ClickAction p_150735_, Player p_150736_) { -- if (p_150735_ != ClickAction.SECONDARY) { -+ if (p_150733_.getCount() != 1 || p_150735_ != ClickAction.SECONDARY) { + BundleContents bundlecontents = p_150733_.get(DataComponents.BUNDLE_CONTENTS); +- if (bundlecontents == null) { ++ if (bundlecontents == null || p_150733_.getCount() != 1) { return false; } else { - BundleContents bundlecontents = p_150733_.get(DataComponents.BUNDLE_CONTENTS); -@@ -71,6 +_,7 @@ + ItemStack itemstack = p_150734_.getItem(); +@@ -100,6 +_,7 @@ public boolean overrideOtherStackedOnMe( ItemStack p_150742_, ItemStack p_150743_, Slot p_150744_, ClickAction p_150745_, Player p_150746_, SlotAccess p_150747_ ) { + if (p_150742_.getCount() != 1) return false; - if (p_150745_ == ClickAction.SECONDARY && p_150744_.allowModification(p_150746_)) { - BundleContents bundlecontents = p_150742_.get(DataComponents.BUNDLE_CONTENTS); - if (bundlecontents == null) { + if (p_150745_ == ClickAction.PRIMARY && p_150743_.isEmpty()) { + toggleSelectedItem(p_150742_, -1); + return false; diff --git a/patches/net/minecraft/world/item/ChorusFruitItem.java.patch b/patches/net/minecraft/world/item/ChorusFruitItem.java.patch deleted file mode 100644 index 1080f1730c..0000000000 --- a/patches/net/minecraft/world/item/ChorusFruitItem.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/world/item/ChorusFruitItem.java -+++ b/net/minecraft/world/item/ChorusFruitItem.java -@@ -34,7 +_,9 @@ - } - - Vec3 vec3 = p_40714_.position(); -- if (p_40714_.randomTeleport(d0, d1, d2, true)) { -+ net.neoforged.neoforge.event.entity.EntityTeleportEvent.ChorusFruit event = net.neoforged.neoforge.event.EventHooks.onChorusFruitTeleport(p_40714_, d0, d1, d2); -+ if (event.isCanceled()) return itemstack; -+ if (p_40714_.randomTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) { - p_40713_.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(p_40714_)); - SoundSource soundsource; - SoundEvent soundevent; diff --git a/patches/net/minecraft/world/item/CrossbowItem.java.patch b/patches/net/minecraft/world/item/CrossbowItem.java.patch index b21064d1c6..6cb5f7be7d 100644 --- a/patches/net/minecraft/world/item/CrossbowItem.java.patch +++ b/patches/net/minecraft/world/item/CrossbowItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/CrossbowItem.java +++ b/net/minecraft/world/item/CrossbowItem.java -@@ -181,6 +_,7 @@ +@@ -184,6 +_,7 @@ Level p_40888_, LivingEntity p_40889_, InteractionHand p_40890_, ItemStack p_40891_, float p_40892_, float p_40893_, @Nullable LivingEntity p_331602_ ) { if (p_40888_ instanceof ServerLevel serverlevel) { diff --git a/patches/net/minecraft/world/item/DyeColor.java.patch b/patches/net/minecraft/world/item/DyeColor.java.patch index 641da94185..ff5a295142 100644 --- a/patches/net/minecraft/world/item/DyeColor.java.patch +++ b/patches/net/minecraft/world/item/DyeColor.java.patch @@ -15,7 +15,7 @@ this.textColor = p_41051_; + this.dyesTag = net.minecraft.tags.ItemTags.create(net.minecraft.resources.ResourceLocation.fromNamespaceAndPath("c", "dyes/" + p_41047_)); + this.dyedTag = net.minecraft.tags.ItemTags.create(net.minecraft.resources.ResourceLocation.fromNamespaceAndPath("c", "dyed/" + p_41047_)); - this.textureDiffuseColor = FastColor.ARGB32.opaque(p_41048_); + this.textureDiffuseColor = ARGB.opaque(p_41048_); this.fireworkColor = p_41050_; } @@ -102,5 +_,35 @@ diff --git a/patches/net/minecraft/world/item/ElytraItem.java.patch b/patches/net/minecraft/world/item/ElytraItem.java.patch deleted file mode 100644 index 7dedbef32a..0000000000 --- a/patches/net/minecraft/world/item/ElytraItem.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/net/minecraft/world/item/ElytraItem.java -+++ b/net/minecraft/world/item/ElytraItem.java -@@ -31,6 +_,25 @@ - } - - @Override -+ public boolean canElytraFly(ItemStack stack, net.minecraft.world.entity.LivingEntity entity) { -+ return ElytraItem.isFlyEnabled(stack); -+ } -+ -+ @Override -+ public boolean elytraFlightTick(ItemStack stack, net.minecraft.world.entity.LivingEntity entity, int flightTicks) { -+ if (!entity.level().isClientSide) { -+ int nextFlightTick = flightTicks + 1; -+ if (nextFlightTick % 10 == 0) { -+ if (nextFlightTick % 20 == 0) { -+ stack.hurtAndBreak(1, entity, net.minecraft.world.entity.EquipmentSlot.CHEST); -+ } -+ entity.gameEvent(net.minecraft.world.level.gameevent.GameEvent.ELYTRA_GLIDE); -+ } -+ } -+ return true; -+ } -+ -+ @Override - public Holder getEquipSound() { - return SoundEvents.ARMOR_EQUIP_ELYTRA; - } diff --git a/patches/net/minecraft/world/item/FishingRodItem.java.patch b/patches/net/minecraft/world/item/FishingRodItem.java.patch index 250a7e3a03..7bad48b3a4 100644 --- a/patches/net/minecraft/world/item/FishingRodItem.java.patch +++ b/patches/net/minecraft/world/item/FishingRodItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/FishingRodItem.java +++ b/net/minecraft/world/item/FishingRodItem.java -@@ -24,7 +_,11 @@ +@@ -25,7 +_,11 @@ if (p_41291_.fishing != null) { if (!p_41290_.isClientSide) { int i = p_41291_.fishing.retrieve(itemstack); @@ -12,10 +12,10 @@ } p_41290_.playSound( -@@ -65,5 +_,10 @@ - @Override - public int getEnchantmentValue() { - return 1; +@@ -61,5 +_,10 @@ + } + + return InteractionResult.SUCCESS; + } + + @Override diff --git a/patches/net/minecraft/world/item/FlintAndSteelItem.java.patch b/patches/net/minecraft/world/item/FlintAndSteelItem.java.patch index 3a550060cb..aac6bbeee3 100644 --- a/patches/net/minecraft/world/item/FlintAndSteelItem.java.patch +++ b/patches/net/minecraft/world/item/FlintAndSteelItem.java.patch @@ -21,7 +21,7 @@ p_41297_.getItemInHand().hurtAndBreak(1, player, LivingEntity.getSlotForHand(p_41297_.getHand())); @@ -56,5 +_,10 @@ - return InteractionResult.sidedSuccess(level.isClientSide()); + return InteractionResult.SUCCESS; } + } + diff --git a/patches/net/minecraft/world/item/HoneyBottleItem.java.patch b/patches/net/minecraft/world/item/HoneyBottleItem.java.patch deleted file mode 100644 index ae550d2576..0000000000 --- a/patches/net/minecraft/world/item/HoneyBottleItem.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/HoneyBottleItem.java -+++ b/net/minecraft/world/item/HoneyBottleItem.java -@@ -28,7 +_,7 @@ - } - - if (!p_41349_.isClientSide) { -- p_41350_.removeEffect(MobEffects.POISON); -+ p_41350_.removeEffectsCuredBy(net.neoforged.neoforge.common.EffectCures.HONEY); - } - - if (p_41348_.isEmpty()) { diff --git a/patches/net/minecraft/world/item/Item.java.patch b/patches/net/minecraft/world/item/Item.java.patch index 4054c635cd..85a8aab6d7 100644 --- a/patches/net/minecraft/world/item/Item.java.patch +++ b/patches/net/minecraft/world/item/Item.java.patch @@ -1,19 +1,25 @@ --- a/net/minecraft/world/item/Item.java +++ b/net/minecraft/world/item/Item.java -@@ -56,9 +_,9 @@ +@@ -70,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import org.slf4j.Logger; -public class Item implements FeatureElement, ItemLike { +public class Item implements FeatureElement, ItemLike, net.neoforged.neoforge.common.extensions.IItemExtension { + public static final Codec> CODEC = BuiltInRegistries.ITEM + .holderByNameCodec() + .validate( +@@ -79,7 +_,7 @@ + : DataResult.success(p_381630_) + ); private static final Logger LOGGER = LogUtils.getLogger(); - public static final Map BY_BLOCK = Maps.newHashMap(); + public static final Map BY_BLOCK = net.neoforged.neoforge.registries.GameData.getBlockItemMap(); public static final ResourceLocation BASE_ATTACK_DAMAGE_ID = ResourceLocation.withDefaultNamespace("base_attack_damage"); public static final ResourceLocation BASE_ATTACK_SPEED_ID = ResourceLocation.withDefaultNamespace("base_attack_speed"); public static final int DEFAULT_MAX_STACK_SIZE = 64; -@@ -89,12 +_,13 @@ - this.components = p_41383_.buildAndValidateComponents(); +@@ -110,7 +_,7 @@ + this.components = p_41383_.buildAndValidateComponents(Component.translatable(this.descriptionId), p_41383_.effectiveModel()); this.craftingRemainingItem = p_41383_.craftingRemainingItem; this.requiredFeatures = p_41383_.requiredFeatures; - if (SharedConstants.IS_RUNNING_IN_IDE) { @@ -21,13 +27,7 @@ String s = this.getClass().getSimpleName(); if (!s.endsWith("Item")) { LOGGER.error("Item classes should end with Item and {} doesn't.", s); - } - } -+ this.canRepair = p_41383_.canRepair; - } - - @Deprecated -@@ -106,6 +_,15 @@ +@@ -127,6 +_,15 @@ return this.components; } @@ -37,13 +37,13 @@ + if (!net.neoforged.neoforge.internal.RegistrationEvents.canModifyComponents()) throw new IllegalStateException("Default components cannot be modified now!"); + var builder = DataComponentMap.builder().addAll(components); + patch.entrySet().forEach(entry -> builder.set((DataComponentType)entry.getKey(), entry.getValue().orElse(null))); -+ components = Properties.COMPONENT_INTERNER.intern(Properties.validateComponents(builder.build())); ++ components = Properties.validateComponents(builder.build()); + } + public int getDefaultMaxStackSize() { return this.components.getOrDefault(DataComponents.MAX_STACK_SIZE, 1); } -@@ -113,6 +_,8 @@ +@@ -134,6 +_,8 @@ public void onUseTick(Level p_41428_, LivingEntity p_41429_, ItemStack p_41430_, int p_41431_) { } @@ -52,25 +52,7 @@ public void onDestroyed(ItemEntity p_150887_) { } -@@ -139,7 +_,7 @@ - - public InteractionResultHolder use(Level p_41432_, Player p_41433_, InteractionHand p_41434_) { - ItemStack itemstack = p_41433_.getItemInHand(p_41434_); -- FoodProperties foodproperties = itemstack.get(DataComponents.FOOD); -+ FoodProperties foodproperties = itemstack.getFoodProperties(p_41433_); - if (foodproperties != null) { - if (p_41433_.canEat(foodproperties.canAlwaysEat())) { - p_41433_.startUsingItem(p_41434_); -@@ -153,7 +_,7 @@ - } - - public ItemStack finishUsingItem(ItemStack p_41409_, Level p_41410_, LivingEntity p_41411_) { -- FoodProperties foodproperties = p_41409_.get(DataComponents.FOOD); -+ FoodProperties foodproperties = p_41409_.getFoodProperties(p_41411_); - return foodproperties != null ? p_41411_.eat(p_41410_, p_41409_, foodproperties) : p_41409_; - } - -@@ -162,12 +_,13 @@ +@@ -181,12 +_,13 @@ } public int getBarWidth(ItemStack p_150900_) { @@ -86,109 +68,49 @@ return Mth.hsvToRgb(f / 3.0F, 1.0F, 1.0F); } -@@ -240,10 +_,12 @@ - } - - @Nullable -+ @Deprecated // Use ItemStack sensitive version. - public final Item getCraftingRemainingItem() { - return this.craftingRemainingItem; +@@ -243,6 +_,7 @@ + return BuiltInRegistries.ITEM.wrapAsHolder(this).getRegisteredName(); } + @Deprecated // Use ItemStack sensitive version. - public boolean hasCraftingRemainingItem() { - return this.craftingRemainingItem != null; + public final ItemStack getCraftingRemainder() { + return this.craftingRemainingItem == null ? ItemStack.EMPTY : new ItemStack(this.craftingRemainingItem); } -@@ -267,7 +_,7 @@ - } - - public int getUseDuration(ItemStack p_41454_, LivingEntity p_344979_) { -- FoodProperties foodproperties = p_41454_.get(DataComponents.FOOD); -+ FoodProperties foodproperties = p_41454_.getFoodProperties(null); - return foodproperties != null ? foodproperties.eatDurationTicks() : 0; - } - -@@ -299,6 +_,8 @@ - return p_41436_.clip(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, p_41438_, p_41437_)); - } - -+ /** @deprecated Neo: Use ItemStack sensitive version. */ -+ @Deprecated - public int getEnchantmentValue() { - return 0; - } -@@ -307,13 +_,23 @@ - return false; - } - -+ /** -+ * @deprecated Neo: Use {@link Item#getDefaultAttributeModifiers(ItemStack)} -+ */ - @Deprecated - public ItemAttributeModifiers getDefaultAttributeModifiers() { - return ItemAttributeModifiers.EMPTY; +@@ -302,7 +_,12 @@ } -+ protected final boolean canRepair; -+ -+ @Override -+ public boolean isRepairable(ItemStack stack) { -+ return canRepair && isDamageable(stack); -+ } -+ public boolean useOnRelease(ItemStack p_41464_) { - return false; + return p_41464_.getItem() == Items.CROSSBOW; ++ } ++ ++ @Override ++ public boolean isRepairable(ItemStack stack) { ++ return stack.has(DataComponents.REPAIRABLE) && isDamageable(stack); } public ItemStack getDefaultInstance() { -@@ -341,13 +_,22 @@ +@@ -322,7 +_,7 @@ return this.requiredFeatures; } - public static class Properties { -+ /** -+ * Neo: Allowing mods to define client behavior for their Items -+ * @deprecated Use {@link net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent} instead -+ */ -+ @Deprecated(forRemoval = true, since = "1.21") -+ public void initializeClient(java.util.function.Consumer consumer) { -+ } -+ + public static class Properties implements net.neoforged.neoforge.common.extensions.IItemPropertiesExtensions { - private static final Interner COMPONENT_INTERNER = Interners.newStrongInterner(); - @Nullable - private DataComponentMap.Builder components; - @Nullable - Item craftingRemainingItem; - FeatureFlagSet requiredFeatures = FeatureFlags.VANILLA_SET; -+ private boolean canRepair = true; - - public Item.Properties food(FoodProperties p_41490_) { - return this.component(DataComponents.FOOD, p_41490_); -@@ -381,12 +_,18 @@ - return this.component(DataComponents.JUKEBOX_PLAYABLE, new JukeboxPlayable(new EitherHolder<>(p_350862_), true)); - } - -+ public Item.Properties setNoRepair() { -+ canRepair = false; -+ return this; -+ } -+ - public Item.Properties requiredFeatures(FeatureFlag... p_250948_) { - this.requiredFeatures = FeatureFlags.REGISTRY.subset(p_250948_); - return this; + private static final DependantName BLOCK_DESCRIPTION_ID = p_371954_ -> Util.makeDescriptionId("block", p_371954_.location()); + private static final DependantName ITEM_DESCRIPTION_ID = p_371511_ -> Util.makeDescriptionId("item", p_371511_.location()); + private final DataComponentMap.Builder components = DataComponentMap.builder().addAll(DataComponents.COMMON_ITEM_COMPONENTS); +@@ -438,6 +_,7 @@ } public Item.Properties component(DataComponentType p_330871_, T p_330323_) { + net.neoforged.neoforge.common.CommonHooks.validateComponent(p_330323_); - if (this.components == null) { - this.components = DataComponentMap.builder().addAll(DataComponents.COMMON_ITEM_COMPONENTS); - } -@@ -401,6 +_,10 @@ + this.components.set(p_330871_, p_330323_); + return this; + } +@@ -448,6 +_,10 @@ - DataComponentMap buildAndValidateComponents() { - DataComponentMap datacomponentmap = this.buildComponents(); + DataComponentMap buildAndValidateComponents(Component p_371796_, ResourceLocation p_371450_) { + DataComponentMap datacomponentmap = this.components.set(DataComponents.ITEM_NAME, p_371796_).set(DataComponents.ITEM_MODEL, p_371450_).build(); + return validateComponents(datacomponentmap); + } + @@ -196,7 +118,7 @@ if (datacomponentmap.has(DataComponents.DAMAGE) && datacomponentmap.getOrDefault(DataComponents.MAX_STACK_SIZE, 1) > 1) { throw new IllegalStateException("Item cannot have both durability and be stackable"); } else { -@@ -441,6 +_,14 @@ +@@ -484,6 +_,14 @@ @Nullable MapItemSavedData mapData(MapId p_339670_); @@ -211,7 +133,7 @@ static Item.TooltipContext of(@Nullable final Level p_339599_) { return p_339599_ == null ? EMPTY : new Item.TooltipContext() { @Override -@@ -456,6 +_,11 @@ +@@ -499,6 +_,11 @@ @Override public MapItemSavedData mapData(MapId p_339628_) { return p_339599_.getMapData(p_339628_); diff --git a/patches/net/minecraft/world/item/ItemStack.java.patch b/patches/net/minecraft/world/item/ItemStack.java.patch index 7f753b99da..6842e3538e 100644 --- a/patches/net/minecraft/world/item/ItemStack.java.patch +++ b/patches/net/minecraft/world/item/ItemStack.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -92,7 +_,7 @@ +@@ -97,7 +_,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; -public final class ItemStack implements DataComponentHolder { +public final class ItemStack implements DataComponentHolder, net.neoforged.neoforge.common.extensions.IItemStackExtension, net.neoforged.neoforge.common.MutableDataComponentHolder { - public static final Codec> ITEM_NON_AIR_CODEC = BuiltInRegistries.ITEM - .holderByNameCodec() - .validate( -@@ -234,6 +_,10 @@ + public static final Codec CODEC = Codec.lazyInitialized( + () -> RecordCodecBuilder.create( + p_381569_ -> p_381569_.group( +@@ -233,6 +_,10 @@ return !this.isEmpty() ? this.components.asPatch() : DataComponentPatch.EMPTY; } @@ -20,7 +20,7 @@ public ItemStack(ItemLike p_41599_) { this(p_41599_, 1); } -@@ -339,7 +_,7 @@ +@@ -338,7 +_,7 @@ } public boolean is(Holder p_220166_) { @@ -29,19 +29,20 @@ } public boolean is(HolderSet p_298683_) { -@@ -351,13 +_,26 @@ +@@ -350,13 +_,27 @@ } public InteractionResult useOn(UseOnContext p_41662_) { + var e = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent(p_41662_, net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent.UsePhase.ITEM_AFTER_BLOCK)); -+ if (e.isCanceled()) return e.getCancellationResult().result(); ++ if (e.isCanceled()) return e.getCancellationResult(); + if (!p_41662_.getLevel().isClientSide) return net.neoforged.neoforge.common.CommonHooks.onPlaceItemIntoWorld(p_41662_); + return onItemUse(p_41662_, (c) -> getItem().useOn(p_41662_)); + } + ++ @Override + public InteractionResult onItemUseFirst(UseOnContext p_41662_) { + var e = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent(p_41662_, net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent.UsePhase.ITEM_BEFORE_BLOCK)); -+ if (e.isCanceled()) return e.getCancellationResult().result(); ++ if (e.isCanceled()) return e.getCancellationResult(); + return onItemUse(p_41662_, (c) -> getItem().onItemUseFirst(this, p_41662_)); + } + @@ -54,10 +55,10 @@ Item item = this.getItem(); - InteractionResult interactionresult = item.useOn(p_41662_); + InteractionResult interactionresult = callback.apply(p_41662_); - if (player != null && interactionresult.indicateItemUse()) { - player.awardStat(Stats.ITEM_USED.get(item)); - } -@@ -382,7 +_,8 @@ + if (player != null + && interactionresult instanceof InteractionResult.Success interactionresult$success + && interactionresult$success.wasItemInteraction()) { +@@ -410,7 +_,8 @@ if (this.isEmpty()) { throw new IllegalStateException("Cannot encode empty ItemStack"); } else { @@ -67,7 +68,7 @@ } } -@@ -390,7 +_,8 @@ +@@ -418,7 +_,8 @@ if (this.isEmpty()) { throw new IllegalStateException("Cannot encode empty ItemStack"); } else { @@ -77,7 +78,7 @@ } } -@@ -399,7 +_,7 @@ +@@ -427,7 +_,7 @@ } public int getMaxStackSize() { @@ -86,7 +87,7 @@ } public boolean isStackable() { -@@ -411,23 +_,28 @@ +@@ -439,19 +_,19 @@ } public boolean isDamaged() { @@ -109,28 +110,46 @@ + return this.getItem().getMaxDamage(this); } + public boolean isBroken() { +@@ -463,6 +_,11 @@ + } + public void hurtAndBreak(int p_220158_, ServerLevel p_346256_, @Nullable ServerPlayer p_220160_, Consumer p_348596_) { + this.hurtAndBreak(p_220158_, p_346256_, (LivingEntity) p_220160_, p_348596_); + } + + public void hurtAndBreak(int p_220158_, ServerLevel p_346256_, @Nullable LivingEntity p_220160_, Consumer p_348596_) { - if (this.isDamageableItem()) { -+ p_220158_ = getItem().damageItem(this, p_220158_, p_220160_, p_348596_); - if (p_220160_ == null || !p_220160_.hasInfiniteMaterials()) { - if (p_220158_ > 0) { - p_220158_ = EnchantmentHelper.processDurabilityChange(p_346256_, this, p_220158_); -@@ -436,8 +_,8 @@ - } - } ++ p_220158_ = getItem().damageItem(this, p_220158_, p_220160_, p_348596_); + int i = this.processDurabilityChange(p_220158_, p_346256_, p_220160_); + if (i != 0) { + this.applyDamage(this.getDamageValue() + i, p_220160_, p_348596_); +@@ -470,6 +_,10 @@ + } -- if (p_220160_ != null && p_220158_ != 0) { -- CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(p_220160_, this, this.getDamageValue() + p_220158_); -+ if (p_220160_ instanceof ServerPlayer sp && p_220158_ != 0) { -+ CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(sp, this, this.getDamageValue() + p_220158_); - } + private int processDurabilityChange(int p_361290_, ServerLevel p_361409_, @Nullable ServerPlayer p_364940_) { ++ return processDurabilityChange(p_361290_, p_361409_, (LivingEntity) p_364940_); ++ } ++ ++ private int processDurabilityChange(int p_361290_, ServerLevel p_361409_, @Nullable LivingEntity p_364940_) { + if (!this.isDamageableItem()) { + return 0; + } else if (p_364940_ != null && p_364940_.hasInfiniteMaterials()) { +@@ -480,8 +_,12 @@ + } - int i = this.getDamageValue() + p_220158_; -@@ -456,7 +_,7 @@ + private void applyDamage(int p_361754_, @Nullable ServerPlayer p_364853_, Consumer p_360895_) { +- if (p_364853_ != null) { +- CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(p_364853_, this, p_361754_); ++ applyDamage(p_361754_, (LivingEntity) p_364853_, p_360895_); ++ } ++ ++ private void applyDamage(int p_361754_, @Nullable LivingEntity p_364853_, Consumer p_360895_) { ++ if (p_364853_ instanceof ServerPlayer serverPlayer) { ++ CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(serverPlayer, this, p_361754_); + } + + this.setDamageValue(p_361754_); +@@ -510,7 +_,7 @@ this.hurtAndBreak( p_41623_, serverlevel, @@ -139,16 +158,16 @@ p_348383_ -> p_41624_.onEquippedItemBroken(p_348383_, p_319898_) ); } -@@ -728,7 +_,7 @@ - return List.of(); - } else { - List list = Lists.newArrayList(); -- MutableComponent mutablecomponent = Component.empty().append(this.getHoverName()).withStyle(this.getRarity().color()); -+ MutableComponent mutablecomponent = Component.empty().append(this.getHoverName()).withStyle(this.getRarity().getStyleModifier()); - if (this.has(DataComponents.CUSTOM_NAME)) { - mutablecomponent.withStyle(ChatFormatting.ITALIC); - } -@@ -752,7 +_,9 @@ +@@ -785,7 +_,7 @@ + } + + public Component getStyledHoverName() { +- MutableComponent mutablecomponent = Component.empty().append(this.getHoverName()).withStyle(this.getRarity().color()); ++ MutableComponent mutablecomponent = Component.empty().append(this.getHoverName()).withStyle(this.getRarity().getStyleModifier()); + if (this.has(DataComponents.CUSTOM_NAME)) { + mutablecomponent.withStyle(ChatFormatting.ITALIC); + } +@@ -826,7 +_,9 @@ this.addToTooltip(DataComponents.ENCHANTMENTS, p_339637_, consumer, p_41653_); this.addToTooltip(DataComponents.DYED_COLOR, p_339637_, consumer, p_41653_); this.addToTooltip(DataComponents.LORE, p_339637_, consumer, p_41653_); @@ -157,9 +176,9 @@ + net.neoforged.neoforge.common.util.AttributeUtil.addAttributeTooltips(this, consumer, + net.neoforged.neoforge.common.util.AttributeTooltipContext.of(p_41652_, p_339637_, p_41653_)); this.addToTooltip(DataComponents.UNBREAKABLE, p_339637_, consumer, p_41653_); - AdventureModePredicate adventuremodepredicate = this.get(DataComponents.CAN_BREAK); - if (adventuremodepredicate != null && adventuremodepredicate.showInTooltip()) { -@@ -784,10 +_,15 @@ + this.addToTooltip(DataComponents.OMINOUS_BOTTLE_AMPLIFIER, p_339637_, consumer, p_41653_); + this.addToTooltip(DataComponents.SUSPICIOUS_STEW_EFFECTS, p_339637_, consumer, p_41653_); +@@ -860,10 +_,15 @@ list.add(DISABLED_ITEM_TOOLTIP); } @@ -175,7 +194,7 @@ private void addAttributeTooltips(Consumer p_330796_, @Nullable Player p_330530_) { ItemAttributeModifiers itemattributemodifiers = this.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); if (itemattributemodifiers.showInTooltip()) { -@@ -897,6 +_,17 @@ +@@ -973,6 +_,17 @@ return !this.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY).isEmpty(); } @@ -193,50 +212,34 @@ public ItemEnchantments getEnchantments() { return this.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY); } -@@ -922,6 +_,12 @@ +@@ -998,14 +_,26 @@ } public void forEachModifier(EquipmentSlotGroup p_348610_, BiConsumer, AttributeModifier> p_348516_) { + // Neo: Reflect real attribute modifiers when doing iteration + this.getAttributeModifiers().forEach(p_348610_, p_348516_); -+ + if (false) { + // Start disabled vanilla code -+ ItemAttributeModifiers itemattributemodifiers = this.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); - if (!itemattributemodifiers.modifiers().isEmpty()) { - itemattributemodifiers.forEach(p_348610_, p_348516_); -@@ -929,10 +_,19 @@ - this.getItem().getDefaultAttributeModifiers().forEach(p_348610_, p_348516_); - } - + itemattributemodifiers.forEach(p_348610_, p_348516_); + // end disabled vanilla code + } -+ EnchantmentHelper.forEachModifier(this, p_348610_, p_348516_); } public void forEachModifier(EquipmentSlot p_332001_, BiConsumer, AttributeModifier> p_330882_) { + // Neo: Reflect real attribute modifiers when doing iteration + this.getAttributeModifiers().forEach(p_332001_, p_330882_); -+ + if (false) { + // Start disabled vanilla code -+ ItemAttributeModifiers itemattributemodifiers = this.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); - if (!itemattributemodifiers.modifiers().isEmpty()) { - itemattributemodifiers.forEach(p_332001_, p_330882_); -@@ -940,6 +_,9 @@ - this.getItem().getDefaultAttributeModifiers().forEach(p_332001_, p_330882_); - } - + itemattributemodifiers.forEach(p_332001_, p_330882_); + // end disabled vanilla code + } -+ EnchantmentHelper.forEachModifier(this, p_332001_, p_330882_); } -@@ -951,7 +_,7 @@ +@@ -1017,7 +_,7 @@ MutableComponent mutablecomponent1 = ComponentUtils.wrapInSquareBrackets(mutablecomponent); if (!this.isEmpty()) { @@ -245,7 +248,7 @@ .withStyle(p_220170_ -> p_220170_.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new HoverEvent.ItemStackInfo(this)))); } -@@ -1014,6 +_,8 @@ +@@ -1085,6 +_,8 @@ this.getItem().onUseTick(p_41732_, p_41733_, this, p_41734_); } @@ -254,11 +257,11 @@ public void onDestroyed(ItemEntity p_150925_) { this.getItem().onDestroyed(p_150925_); } -@@ -1031,6 +_,7 @@ +@@ -1094,6 +_,7 @@ } public boolean canBeHurtBy(DamageSource p_335431_) { + if (!getItem().canBeHurtBy(this, p_335431_)) return false; - return !this.has(DataComponents.FIRE_RESISTANT) || !p_335431_.is(DamageTypeTags.IS_FIRE); + DamageResistant damageresistant = this.get(DataComponents.DAMAGE_RESISTANT); + return damageresistant == null || !damageresistant.isResistantTo(p_335431_); } - } diff --git a/patches/net/minecraft/world/item/ItemUseAnimation.java.patch b/patches/net/minecraft/world/item/ItemUseAnimation.java.patch new file mode 100644 index 0000000000..bae3e76080 --- /dev/null +++ b/patches/net/minecraft/world/item/ItemUseAnimation.java.patch @@ -0,0 +1,24 @@ +--- a/net/minecraft/world/item/ItemUseAnimation.java ++++ b/net/minecraft/world/item/ItemUseAnimation.java +@@ -8,7 +_,10 @@ + import net.minecraft.util.ByIdMap; + import net.minecraft.util.StringRepresentable; + +-public enum ItemUseAnimation implements StringRepresentable { ++@net.neoforged.fml.common.asm.enumextension.IndexedEnum ++@net.neoforged.fml.common.asm.enumextension.NamedEnum(1) ++@net.neoforged.fml.common.asm.enumextension.NetworkedEnum(net.neoforged.fml.common.asm.enumextension.NetworkedEnum.NetworkCheck.BIDIRECTIONAL) ++public enum ItemUseAnimation implements StringRepresentable, net.neoforged.fml.common.asm.enumextension.IExtensibleEnum { + NONE(0, "none"), + EAT(1, "eat"), + DRINK(2, "drink"), +@@ -38,5 +_,9 @@ + @Override + public String getSerializedName() { + return this.name; ++ } ++ ++ public static net.neoforged.fml.common.asm.enumextension.ExtensionInfo getExtensionInfo() { ++ return net.neoforged.fml.common.asm.enumextension.ExtensionInfo.nonExtended(ItemUseAnimation.class); + } + } diff --git a/patches/net/minecraft/world/item/Items.java.patch b/patches/net/minecraft/world/item/Items.java.patch index 5967553b88..98327eb50c 100644 --- a/patches/net/minecraft/world/item/Items.java.patch +++ b/patches/net/minecraft/world/item/Items.java.patch @@ -1,32 +1,27 @@ --- a/net/minecraft/world/item/Items.java +++ b/net/minecraft/world/item/Items.java -@@ -2092,11 +_,25 @@ +@@ -2326,11 +_,19 @@ } public static Item registerBlock(Block p_252092_, Block... p_248886_) { -- BlockItem blockitem = new BlockItem(p_252092_, new Item.Properties()); -+ BlockItem blockitem = new BlockItem(p_252092_, new Item.Properties()) { -+ @Override -+ public void registerBlocks(java.util.Map map, Item self) { -+ super.registerBlocks(map, self); -+ for (Block b : p_248886_) { -+ map.put(b, self); -+ } -+ } - +- Item item = registerBlock(p_252092_); +- - for (Block block : p_248886_) { -- Item.BY_BLOCK.put(block, blockitem); +- Item.BY_BLOCK.put(block, item); - } -+ /** @deprecated Neo: To be removed without replacement since registry replacement is not a feature anymore. */ -+ @Deprecated(forRemoval = true, since = "1.21.1") -+ @Override -+ public void removeFromBlockToItemMap(java.util.Map map, Item self) { -+ super.removeFromBlockToItemMap(map, self); -+ for (Block b : p_248886_) { -+ map.remove(b); -+ } -+ } -+ }; ++ Item item = registerItem( ++ blockIdToItemId(p_252092_.builtInRegistryHolder().key()), ++ p -> new BlockItem(p_252092_, p) { ++ @Override ++ public void registerBlocks(java.util.Map map, Item self) { ++ super.registerBlocks(map, self); ++ for (Block block : p_248886_) { ++ map.put(block, self); ++ } ++ } ++ }, ++ new Item.Properties().useBlockDescriptionPrefix() ++ ); - return registerBlock(blockitem); + return item; } diff --git a/patches/net/minecraft/world/item/MapItem.java.patch b/patches/net/minecraft/world/item/MapItem.java.patch index 159280f4f4..f5c15dc15d 100644 --- a/patches/net/minecraft/world/item/MapItem.java.patch +++ b/patches/net/minecraft/world/item/MapItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MapItem.java +++ b/net/minecraft/world/item/MapItem.java -@@ -57,6 +_,16 @@ +@@ -56,6 +_,16 @@ @Nullable public static MapItemSavedData getSavedData(ItemStack p_42854_, Level p_42855_) { diff --git a/patches/net/minecraft/world/item/MilkBucketItem.java.patch b/patches/net/minecraft/world/item/MilkBucketItem.java.patch deleted file mode 100644 index 416fad27ba..0000000000 --- a/patches/net/minecraft/world/item/MilkBucketItem.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/MilkBucketItem.java -+++ b/net/minecraft/world/item/MilkBucketItem.java -@@ -24,7 +_,7 @@ - } - - if (!p_42924_.isClientSide) { -- p_42925_.removeAllEffects(); -+ p_42925_.removeEffectsCuredBy(net.neoforged.neoforge.common.EffectCures.MILK); - } - - if (p_42925_ instanceof Player player) { diff --git a/patches/net/minecraft/world/item/MinecartItem.java.patch b/patches/net/minecraft/world/item/MinecartItem.java.patch index a28feeaef1..da2d05fb93 100644 --- a/patches/net/minecraft/world/item/MinecartItem.java.patch +++ b/patches/net/minecraft/world/item/MinecartItem.java.patch @@ -1,29 +1,11 @@ --- a/net/minecraft/world/item/MinecartItem.java +++ b/net/minecraft/world/item/MinecartItem.java -@@ -33,7 +_,7 @@ - BlockPos blockpos = p_302448_.pos().relative(direction); - BlockState blockstate = serverlevel.getBlockState(blockpos); +@@ -34,7 +_,7 @@ + } else { + ItemStack itemstack = p_42943_.getItemInHand(); RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock - ? blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()) -+ ? ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, serverlevel, blockpos, null) - : RailShape.NORTH_SOUTH; - double d3; - if (blockstate.is(BlockTags.RAILS)) { -@@ -49,7 +_,7 @@ - - BlockState blockstate1 = serverlevel.getBlockState(blockpos.below()); - RailShape railshape1 = blockstate1.getBlock() instanceof BaseRailBlock -- ? blockstate1.getValue(((BaseRailBlock)blockstate1.getBlock()).getShapeProperty()) -+ ? ((BaseRailBlock)blockstate1.getBlock()).getRailDirection(blockstate1, serverlevel, blockpos.below(), null) - : RailShape.NORTH_SOUTH; - if (direction != Direction.DOWN && railshape1.isAscending()) { - d3 = -0.4; -@@ -90,7 +_,7 @@ - ItemStack itemstack = p_42943_.getItemInHand(); - if (level instanceof ServerLevel serverlevel) { - RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock -- ? blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()) + ? ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, level, blockpos, null) - : RailShape.NORTH_SOUTH; - double d0 = 0.0; - if (railshape.isAscending()) { + : RailShape.NORTH_SOUTH; + double d0 = 0.0; + if (railshape.isSlope()) { diff --git a/patches/net/minecraft/world/item/PickaxeItem.java.patch b/patches/net/minecraft/world/item/PickaxeItem.java.patch index f6f3418534..52ad2444bf 100644 --- a/patches/net/minecraft/world/item/PickaxeItem.java.patch +++ b/patches/net/minecraft/world/item/PickaxeItem.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/PickaxeItem.java +++ b/net/minecraft/world/item/PickaxeItem.java @@ -6,4 +_,9 @@ - public PickaxeItem(Tier p_42961_, Item.Properties p_42964_) { - super(p_42961_, BlockTags.MINEABLE_WITH_PICKAXE, p_42964_); + public PickaxeItem(ToolMaterial p_362209_, float p_364146_, float p_361793_, Item.Properties p_42964_) { + super(p_362209_, BlockTags.MINEABLE_WITH_PICKAXE, p_364146_, p_361793_, p_42964_); } + + @Override diff --git a/patches/net/minecraft/world/item/ProjectileWeaponItem.java.patch b/patches/net/minecraft/world/item/ProjectileWeaponItem.java.patch index 06d8d4276e..9747fe189d 100644 --- a/patches/net/minecraft/world/item/ProjectileWeaponItem.java.patch +++ b/patches/net/minecraft/world/item/ProjectileWeaponItem.java.patch @@ -43,7 +43,7 @@ public static ItemStack getHeldProjectile(LivingEntity p_43011_, Predicate p_43012_) { if (p_43012_.test(p_43011_.getItemInHand(InteractionHand.OFF_HAND))) { return p_43011_.getItemInHand(InteractionHand.OFF_HAND); -@@ -92,7 +_,7 @@ +@@ -91,7 +_,7 @@ abstractarrow.setCritArrow(true); } @@ -52,7 +52,7 @@ } protected static List draw(ItemStack p_331565_, ItemStack p_330406_, LivingEntity p_330823_) { -@@ -115,7 +_,8 @@ +@@ -114,7 +_,8 @@ } protected static ItemStack useAmmo(ItemStack p_331207_, ItemStack p_331434_, LivingEntity p_330302_, boolean p_330934_) { @@ -62,7 +62,7 @@ ? EnchantmentHelper.processAmmoUse(serverlevel, p_331207_, p_331434_, 1) : 0; if (i > p_331434_.getCount()) { -@@ -132,5 +_,20 @@ +@@ -131,5 +_,20 @@ return itemstack; } diff --git a/patches/net/minecraft/world/item/ShearsItem.java.patch b/patches/net/minecraft/world/item/ShearsItem.java.patch index 6f0ad827e7..1ce63f102e 100644 --- a/patches/net/minecraft/world/item/ShearsItem.java.patch +++ b/patches/net/minecraft/world/item/ShearsItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ShearsItem.java +++ b/net/minecraft/world/item/ShearsItem.java -@@ -54,20 +_,57 @@ +@@ -59,20 +_,57 @@ || p_43080_.is(BlockTags.WOOL); } @@ -19,9 +19,9 @@ + // Call onSheared on both sides (mirrors vanilla shear()) + List drops = target.onSheared(player, stack, entity.level(), pos); + // Spawn drops on the server side using spawnShearedDrop to retain vanilla mob-specific behavior -+ if (!isClient) { ++ if (entity.level() instanceof net.minecraft.server.level.ServerLevel serverLevel) { + for(ItemStack drop : drops) { -+ target.spawnShearedDrop(entity.level(), pos, drop); ++ target.spawnShearedDrop(serverLevel, pos, drop); + } + } + // Call GameEvent.SHEAR on both sides @@ -31,7 +31,7 @@ + stack.hurtAndBreak(1, player, LivingEntity.getSlotForHand(hand)); + } + // Return sided success if the entity was shearable -+ return InteractionResult.sidedSuccess(isClient); ++ return InteractionResult.SUCCESS; + } + } + return InteractionResult.PASS; diff --git a/patches/net/minecraft/world/item/ShieldItem.java.patch b/patches/net/minecraft/world/item/ShieldItem.java.patch index e22dccf461..812ecb68f1 100644 --- a/patches/net/minecraft/world/item/ShieldItem.java.patch +++ b/patches/net/minecraft/world/item/ShieldItem.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/ShieldItem.java +++ b/net/minecraft/world/item/ShieldItem.java -@@ -58,4 +_,9 @@ - public EquipmentSlot getEquipmentSlot() { - return EquipmentSlot.OFFHAND; +@@ -43,4 +_,9 @@ + p_43100_.startUsingItem(p_43101_); + return InteractionResult.CONSUME; } + + @Override diff --git a/patches/net/minecraft/world/item/SpawnEggItem.java.patch b/patches/net/minecraft/world/item/SpawnEggItem.java.patch index 039545cc2e..b3a50e656b 100644 --- a/patches/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/patches/net/minecraft/world/item/SpawnEggItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/SpawnEggItem.java +++ b/net/minecraft/world/item/SpawnEggItem.java -@@ -42,11 +_,14 @@ +@@ -41,11 +_,14 @@ private final int highlightColor; private final EntityType defaultType; @@ -15,7 +15,7 @@ BY_ID.put(p_43207_, this); } -@@ -134,6 +_,8 @@ +@@ -133,6 +_,8 @@ @Nullable public static SpawnEggItem byId(@Nullable EntityType p_43214_) { @@ -24,7 +24,7 @@ return BY_ID.get(p_43214_); } -@@ -143,12 +_,12 @@ +@@ -142,12 +_,12 @@ public EntityType getType(ItemStack p_330335_) { CustomData customdata = p_330335_.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY); @@ -39,7 +39,7 @@ } public Optional spawnOffspringFromSpawnEgg( -@@ -179,5 +_,9 @@ +@@ -178,5 +_,9 @@ } } } diff --git a/patches/net/minecraft/world/item/StandingAndWallBlockItem.java.patch b/patches/net/minecraft/world/item/StandingAndWallBlockItem.java.patch deleted file mode 100644 index c119b7fac0..0000000000 --- a/patches/net/minecraft/world/item/StandingAndWallBlockItem.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/world/item/StandingAndWallBlockItem.java -+++ b/net/minecraft/world/item/StandingAndWallBlockItem.java -@@ -50,4 +_,11 @@ - super.registerBlocks(p_43252_, p_43253_); - p_43252_.put(this.wallBlock, p_43253_); - } -+ -+ /** @deprecated Neo: To be removed without replacement since registry replacement is not a feature anymore. */ -+ @Deprecated(forRemoval = true, since = "1.21.1") -+ public void removeFromBlockToItemMap(Map blockToItemMap, Item itemIn) { -+ super.removeFromBlockToItemMap(blockToItemMap, itemIn); -+ blockToItemMap.remove(this.wallBlock); -+ } - } diff --git a/patches/net/minecraft/world/item/SwordItem.java.patch b/patches/net/minecraft/world/item/SwordItem.java.patch index bcff559cf7..d7c8b39eb1 100644 --- a/patches/net/minecraft/world/item/SwordItem.java.patch +++ b/patches/net/minecraft/world/item/SwordItem.java.patch @@ -1,32 +1,20 @@ --- a/net/minecraft/world/item/SwordItem.java +++ b/net/minecraft/world/item/SwordItem.java -@@ -21,11 +_,25 @@ - super(p_43269_, p_43272_.component(DataComponents.TOOL, createToolProperties())); +@@ -12,6 +_,13 @@ + super(p_361460_.applySwordProperties(p_43272_, p_362481_, p_364182_)); } + /** -+ * Neo: Allow modded Swords to set exactly what Tool data component to use for their sword. ++ * Neo: Allow modded Swords to set exactly what properties to use for their sword. + */ -+ public SwordItem(Tier tier, Item.Properties properties, Tool toolComponentData) { -+ super(tier, properties.component(DataComponents.TOOL, toolComponentData)); ++ public SwordItem(Item.Properties properties) { ++ super(properties); + } + - public static Tool createToolProperties() { - return new Tool(List.of(Tool.Rule.minesAndDrops(List.of(Blocks.COBWEB), 15.0F), Tool.Rule.overrideSpeed(BlockTags.SWORD_EFFICIENT, 1.5F)), 1.0F, 2); - } - - public static ItemAttributeModifiers createAttributes(Tier p_330371_, int p_331976_, float p_332104_) { -+ return createAttributes(p_330371_, (float)p_331976_, p_332104_); -+ } -+ -+ /** -+ * Neo: Method overload to allow giving a float for damage instead of an int. -+ */ -+ public static ItemAttributeModifiers createAttributes(Tier p_330371_, float p_331976_, float p_332104_) { - return ItemAttributeModifiers.builder() - .add( - Attributes.ATTACK_DAMAGE, -@@ -55,5 +_,10 @@ + @Override + public boolean canAttackBlock(BlockState p_43291_, Level p_43292_, BlockPos p_43293_, Player p_43294_) { + return !p_43294_.isCreative(); +@@ -25,5 +_,10 @@ @Override public void postHurtEnemy(ItemStack p_345553_, LivingEntity p_345771_, LivingEntity p_346282_) { p_345553_.hurtAndBreak(1, p_346282_, EquipmentSlot.MAINHAND); diff --git a/patches/net/minecraft/world/item/Tiers.java.patch b/patches/net/minecraft/world/item/Tiers.java.patch deleted file mode 100644 index 48dc1da1b8..0000000000 --- a/patches/net/minecraft/world/item/Tiers.java.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- a/net/minecraft/world/item/Tiers.java -+++ b/net/minecraft/world/item/Tiers.java -@@ -61,4 +_,6 @@ - public Ingredient getRepairIngredient() { - return this.repairIngredient.get(); - } -+ -+ @org.jetbrains.annotations.Nullable public net.minecraft.tags.TagKey getTag() { return net.neoforged.neoforge.common.CommonHooks.getTagFromVanillaTier(this); } - } diff --git a/patches/net/minecraft/world/item/TridentItem.java.patch b/patches/net/minecraft/world/item/TridentItem.java.patch index 1f32d6ec83..5cd4365e49 100644 --- a/patches/net/minecraft/world/item/TridentItem.java.patch +++ b/patches/net/minecraft/world/item/TridentItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/TridentItem.java +++ b/net/minecraft/world/item/TridentItem.java -@@ -160,4 +_,9 @@ +@@ -161,4 +_,9 @@ throwntrident.pickup = AbstractArrow.Pickup.ALLOWED; return throwntrident; } diff --git a/patches/net/minecraft/world/item/UseAnim.java.patch b/patches/net/minecraft/world/item/UseAnim.java.patch deleted file mode 100644 index 3f78819ea3..0000000000 --- a/patches/net/minecraft/world/item/UseAnim.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/world/item/UseAnim.java -+++ b/net/minecraft/world/item/UseAnim.java -@@ -10,5 +_,10 @@ - CROSSBOW, - SPYGLASS, - TOOT_HORN, -- BRUSH; -+ BRUSH, -+ /** -+ * Items with custom arm animation should return this in `Item#getUseAnimation` -+ * to prevent vanilla from also trying to animate same item -+ */ -+ CUSTOM - } diff --git a/patches/net/minecraft/world/item/alchemy/PotionContents.java.patch b/patches/net/minecraft/world/item/alchemy/PotionContents.java.patch index 90c51e7d35..f5c53ac620 100644 --- a/patches/net/minecraft/world/item/alchemy/PotionContents.java.patch +++ b/patches/net/minecraft/world/item/alchemy/PotionContents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/alchemy/PotionContents.java +++ b/net/minecraft/world/item/alchemy/PotionContents.java -@@ -173,6 +_,10 @@ +@@ -201,6 +_,10 @@ p_331296_.accept(CommonComponents.EMPTY); p_331296_.accept(Component.translatable("potion.whenDrank").withStyle(ChatFormatting.DARK_PURPLE)); diff --git a/patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch b/patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch new file mode 100644 index 0000000000..4e1c2927dc --- /dev/null +++ b/patches/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java ++++ b/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java +@@ -56,7 +_,9 @@ + } + + Vec3 vec3 = p_366884_.position(); +- if (p_366884_.randomTeleport(d0, d1, d2, true)) { ++ var event = net.neoforged.neoforge.event.EventHooks.onItemConsumptionTeleport(p_366884_, p_366476_, d0, d1, d2); ++ if (event.isCanceled()) return false; ++ if (p_366884_.randomTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) { + p_366648_.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(p_366884_)); + SoundSource soundsource; + SoundEvent soundevent; diff --git a/patches/net/minecraft/world/item/crafting/AbstractCookingRecipe.java.patch b/patches/net/minecraft/world/item/crafting/AbstractCookingRecipe.java.patch new file mode 100644 index 0000000000..305a1d580b --- /dev/null +++ b/patches/net/minecraft/world/item/crafting/AbstractCookingRecipe.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/crafting/AbstractCookingRecipe.java ++++ b/net/minecraft/world/item/crafting/AbstractCookingRecipe.java +@@ -75,7 +_,7 @@ + Codec.STRING.optionalFieldOf("group", "").forGetter(SingleItemRecipe::group), + CookingBookCategory.CODEC.fieldOf("category").orElse(CookingBookCategory.MISC).forGetter(AbstractCookingRecipe::category), + Ingredient.CODEC.fieldOf("ingredient").forGetter(SingleItemRecipe::input), +- ItemStack.STRICT_SINGLE_ITEM_CODEC.fieldOf("result").forGetter(SingleItemRecipe::result), ++ ItemStack.CODEC.fieldOf("result").forGetter(SingleItemRecipe::result), + Codec.FLOAT.fieldOf("experience").orElse(0.0F).forGetter(AbstractCookingRecipe::experience), + Codec.INT.fieldOf("cookingtime").orElse(p_379669_).forGetter(AbstractCookingRecipe::cookingTime) + ) diff --git a/patches/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch b/patches/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch index 7628e93377..2a92e339c3 100644 --- a/patches/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch +++ b/patches/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java.patch @@ -1,13 +1,11 @@ --- a/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java +++ b/net/minecraft/world/item/crafting/BannerDuplicateRecipe.java -@@ -79,8 +_,8 @@ +@@ -84,7 +_,7 @@ for (int i = 0; i < nonnulllist.size(); i++) { ItemStack itemstack = p_345377_.getItem(i); if (!itemstack.isEmpty()) { -- if (itemstack.getItem().hasCraftingRemainingItem()) { -- nonnulllist.set(i, new ItemStack(itemstack.getItem().getCraftingRemainingItem())); -+ if (itemstack.hasCraftingRemainingItem()) { -+ nonnulllist.set(i, itemstack.getCraftingRemainingItem()); +- ItemStack itemstack1 = itemstack.getItem().getCraftingRemainder(); ++ ItemStack itemstack1 = itemstack.getCraftingRemainder(); + if (!itemstack1.isEmpty()) { + nonnulllist.set(i, itemstack1); } else if (!itemstack.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY).layers().isEmpty()) { - nonnulllist.set(i, itemstack.copyWithCount(1)); - } diff --git a/patches/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch b/patches/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch index d801583d1e..ccfed826ab 100644 --- a/patches/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch +++ b/patches/net/minecraft/world/item/crafting/BookCloningRecipe.java.patch @@ -1,13 +1,11 @@ --- a/net/minecraft/world/item/crafting/BookCloningRecipe.java +++ b/net/minecraft/world/item/crafting/BookCloningRecipe.java -@@ -83,8 +_,8 @@ +@@ -88,7 +_,7 @@ for (int i = 0; i < nonnulllist.size(); i++) { ItemStack itemstack = p_344763_.getItem(i); -- if (itemstack.getItem().hasCraftingRemainingItem()) { -- nonnulllist.set(i, new ItemStack(itemstack.getItem().getCraftingRemainingItem())); -+ if (itemstack.hasCraftingRemainingItem()) { -+ nonnulllist.set(i, itemstack.getCraftingRemainingItem()); +- ItemStack itemstack1 = itemstack.getItem().getCraftingRemainder(); ++ ItemStack itemstack1 = itemstack.getCraftingRemainder(); + if (!itemstack1.isEmpty()) { + nonnulllist.set(i, itemstack1); } else if (itemstack.getItem() instanceof WrittenBookItem) { - nonnulllist.set(i, itemstack.copyWithCount(1)); - break; diff --git a/patches/net/minecraft/world/item/crafting/CraftingRecipe.java.patch b/patches/net/minecraft/world/item/crafting/CraftingRecipe.java.patch new file mode 100644 index 0000000000..7ba401edc6 --- /dev/null +++ b/patches/net/minecraft/world/item/crafting/CraftingRecipe.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/crafting/CraftingRecipe.java ++++ b/net/minecraft/world/item/crafting/CraftingRecipe.java +@@ -23,7 +_,7 @@ + NonNullList nonnulllist = NonNullList.withSize(p_380223_.size(), ItemStack.EMPTY); + + for (int i = 0; i < nonnulllist.size(); i++) { +- Item item = p_380223_.getItem(i).getItem(); ++ ItemStack item = p_380223_.getItem(i); + nonnulllist.set(i, item.getCraftingRemainder()); + } + diff --git a/patches/net/minecraft/world/item/crafting/Ingredient.java.patch b/patches/net/minecraft/world/item/crafting/Ingredient.java.patch index 9699025400..f80d5c47b2 100644 --- a/patches/net/minecraft/world/item/crafting/Ingredient.java.patch +++ b/patches/net/minecraft/world/item/crafting/Ingredient.java.patch @@ -1,127 +1,71 @@ --- a/net/minecraft/world/item/crafting/Ingredient.java +++ b/net/minecraft/world/item/crafting/Ingredient.java -@@ -29,15 +_,54 @@ +@@ -24,18 +_,20 @@ + import net.minecraft.world.level.ItemLike; public final class Ingredient implements Predicate { - public static final Ingredient EMPTY = new Ingredient(Stream.empty()); -- public static final StreamCodec CONTENTS_STREAM_CODEC = ItemStack.LIST_STREAM_CODEC -- .map(p_319730_ -> fromValues(p_319730_.stream().map(Ingredient.ItemValue::new)), p_319731_ -> Arrays.asList(p_319731_.getItems())); -+ public static final StreamCodec CONTENTS_STREAM_CODEC = new StreamCodec<>() { -+ private static final StreamCodec CUSTOM_INGREDIENT_CODEC = net.minecraft.network.codec.ByteBufCodecs.registry(net.neoforged.neoforge.registries.NeoForgeRegistries.Keys.INGREDIENT_TYPES) -+ .dispatch(c -> c.getType(), t -> t.streamCodec()); -+ -+ @Override -+ public void encode(RegistryFriendlyByteBuf buf, Ingredient ingredient) { -+ if (ingredient.isSimple()) { -+ ItemStack.LIST_STREAM_CODEC.encode(buf, Arrays.asList(ingredient.getItems())); -+ } else { -+ buf.writeVarInt(-1); -+ CUSTOM_INGREDIENT_CODEC.encode(buf, ingredient.customIngredient); -+ } -+ } -+ -+ @Override -+ public Ingredient decode(RegistryFriendlyByteBuf buf) { -+ var size = buf.readVarInt(); -+ if (size == -1) { -+ return new Ingredient(CUSTOM_INGREDIENT_CODEC.decode(buf)); -+ } -+ return fromValues(Stream.generate(() -> ItemStack.STREAM_CODEC.decode(buf)).limit(size).map(Ingredient.ItemValue::new)); -+ } -+ }; - private final Ingredient.Value[] values; +- public static final StreamCodec CONTENTS_STREAM_CODEC = ByteBufCodecs.holderSet(Registries.ITEM) +- .map(Ingredient::new, p_360055_ -> p_360055_.values); +- public static final StreamCodec> OPTIONAL_CONTENTS_STREAM_CODEC = ByteBufCodecs.holderSet(Registries.ITEM) ++ public static final StreamCodec CONTENTS_STREAM_CODEC = net.neoforged.neoforge.common.crafting.IngredientCodecs.streamCodec(ByteBufCodecs.holderSet(Registries.ITEM) ++ .map(Ingredient::new, p_360055_ -> p_360055_.getValuesForSync())); ++ public static final StreamCodec> OPTIONAL_CONTENTS_STREAM_CODEC = net.neoforged.neoforge.common.crafting.IngredientCodecs.optionalStreamCodec(ByteBufCodecs.holderSet(Registries.ITEM) + .map( + p_360058_ -> p_360058_.size() == 0 ? Optional.empty() : Optional.of(new Ingredient((HolderSet)p_360058_)), +- p_360056_ -> p_360056_.map(p_360062_ -> p_360062_.values).orElse(HolderSet.direct()) +- ); ++ p_360056_ -> p_360056_.map(p_360062_ -> p_360062_.getValuesForSync()).orElse(HolderSet.direct()) ++ )); + public static final Codec> NON_AIR_HOLDER_SET_CODEC = HolderSetCodec.create(Registries.ITEM, Item.CODEC, false); +- public static final Codec CODEC = ExtraCodecs.nonEmptyHolderSet(NON_AIR_HOLDER_SET_CODEC).xmap(Ingredient::new, p_360061_ -> p_360061_.values); ++ public static final Codec CODEC = net.neoforged.neoforge.common.crafting.IngredientCodecs.codec(ExtraCodecs.nonEmptyHolderSet(NON_AIR_HOLDER_SET_CODEC).xmap(Ingredient::new, p_360061_ -> p_360061_.values)); + private final HolderSet values; @Nullable - private ItemStack[] itemStacks; - @Nullable - private IntList stackingIds; -- public static final Codec CODEC = codec(true); -- public static final Codec CODEC_NONEMPTY = codec(false); + private List> items; + @Nullable + private net.neoforged.neoforge.common.crafting.ICustomIngredient customIngredient = null; -+ -+ /** -+ * This codec allows both the {@code {...}} and {@code [{...}, {...}, ...]} syntax. -+ * {@code []} is allowed for empty ingredients, and will only match empty stacks. -+ */ -+ public static final Codec CODEC = net.neoforged.neoforge.common.crafting.CraftingHelper.makeIngredientCodec(true); -+ /** -+ * Same as {@link #CODEC} except that empty ingredients ({@code []}) are not allowed. -+ */ -+ public static final Codec CODEC_NONEMPTY = net.neoforged.neoforge.common.crafting.CraftingHelper.makeIngredientCodec(false); -+ /** -+ * This is a codec that only allows the {@code {...}} syntax. -+ * Array ingredients are serialized using the CompoundIngredient custom ingredient type: -+ * {@code { "type": "neoforge:compound", "ingredients": [{...}, {...}, ...] }}. -+ */ -+ public static final com.mojang.serialization.MapCodec MAP_CODEC_NONEMPTY = net.neoforged.neoforge.common.crafting.CraftingHelper.makeIngredientMapCodec(); -+ public static final Codec> LIST_CODEC = MAP_CODEC_NONEMPTY.codec().listOf(); -+ public static final Codec> LIST_CODEC_NONEMPTY = LIST_CODEC.validate(list -> list.isEmpty() ? DataResult.error(() -> "Item array cannot be empty, at least one item must be defined") : DataResult.success(list)); - private Ingredient(Stream p_43907_) { - this.values = p_43907_.toArray(Ingredient.Value[]::new); -@@ -47,9 +_,19 @@ - this.values = p_301044_; + private Ingredient(HolderSet p_365027_) { + p_365027_.unwrap().ifRight(p_360057_ -> { +@@ -48,19 +_,31 @@ + this.values = p_365027_; } + public Ingredient(net.neoforged.neoforge.common.crafting.ICustomIngredient customIngredient) { -+ this(new Value[0]); ++ this.values = HolderSet.empty(); + this.customIngredient = customIngredient; + } + - public ItemStack[] getItems() { - if (this.itemStacks == null) { -- this.itemStacks = Arrays.stream(this.values).flatMap(p_43916_ -> p_43916_.getItems().stream()).distinct().toArray(ItemStack[]::new); -+ // Neo: vanilla used Stream.distinct() here which has basically no effect as ItemStack does not override hashCode() and equals(). -+ // Using ItemStackLinkedSet::createTypeAndComponentsSet instead for a real distinct result. -+ final Stream stream = this.customIngredient == null -+ ? Arrays.stream(this.values).flatMap(value -> value.getItems().stream()) -+ : this.customIngredient.getItems(); -+ this.itemStacks = stream.collect(java.util.stream.Collectors.toCollection(net.minecraft.world.item.ItemStackLinkedSet::createTypeAndComponentsSet)).toArray(ItemStack[]::new); + public static boolean testOptionalIngredient(Optional p_362504_, ItemStack p_363604_) { + return p_362504_.map(p_360060_ -> p_360060_.test(p_363604_)).orElseGet(p_363604_::isEmpty); + } + + public List> items() { + if (this.items == null) { +- this.items = ImmutableList.copyOf(this.values); ++ if (this.customIngredient != null) { ++ this.items = this.customIngredient.items().toList(); ++ } else { ++ this.items = ImmutableList.copyOf(this.values); ++ } } - return this.itemStacks; -@@ -58,6 +_,8 @@ - public boolean test(@Nullable ItemStack p_43914_) { - if (p_43914_ == null) { - return false; -+ } else if (this.customIngredient != null) { -+ return this.customIngredient.test(p_43914_); - } else if (this.isEmpty()) { - return p_43914_.isEmpty(); - } else { -@@ -86,13 +_,65 @@ - return this.stackingIds; + return this.items; } -+ /** -+ * Returns {@code true} if this ingredient is explicitly chosen to be empty, i.e. using {@code []}. -+ */ - public boolean isEmpty() { -- return this.values.length == 0; -+ return this.values.length == 0 && !isCustom(); -+ } -+ -+ /** -+ * Returns {@code true} if this ingredient has an empty stack list. -+ * Unlike {@link #isEmpty()}, this will catch "accidentally empty" ingredients, -+ * for example a tag ingredient that has an empty tag. -+ */ -+ public boolean hasNoItems() { -+ ItemStack[] items = getItems(); -+ if (items.length == 0) -+ return true; -+ if (items.length == 1) { -+ // If we potentially added a barrier due to the ingredient being an empty tag, try and check if it is the stack we added -+ ItemStack item = items[0]; -+ return item.getItem() == net.minecraft.world.item.Items.BARRIER && item.getHoverName() instanceof net.minecraft.network.chat.MutableComponent hoverName && hoverName.getString().startsWith("Empty Tag: "); + public boolean test(ItemStack p_43914_) { ++ if (this.customIngredient != null) { ++ return this.customIngredient.test(p_43914_); + } -+ return false; - } + List> list = this.items(); + + for (int i = 0; i < list.size(); i++) { +@@ -74,7 +_,49 @@ @Override public boolean equals(Object p_301003_) { -- return p_301003_ instanceof Ingredient ingredient ? Arrays.equals((Object[])this.values, (Object[])ingredient.values) : false; -+ return p_301003_ instanceof Ingredient ingredient ? java.util.Objects.equals(this.customIngredient, ingredient.customIngredient) && Arrays.equals((Object[])this.values, (Object[])ingredient.values) : false; +- return p_301003_ instanceof Ingredient ingredient ? Objects.equals(this.values, ingredient.values) : false; ++ return p_301003_ instanceof Ingredient ingredient ? java.util.Objects.equals(this.customIngredient, ingredient.customIngredient) && Objects.equals(this.values, ingredient.values) : false; + } + + @Override @@ -129,20 +73,30 @@ + if (this.customIngredient != null) { + return this.customIngredient.hashCode(); + } -+ return Arrays.hashCode(this.values); ++ return this.values.hashCode(); + } + + /** -+ * Retrieves the underlying values of this ingredient. -+ * If this is a {@linkplain #isCustom custom ingredient}, an exception is thrown. -+ */ -+ public Value[] getValues() { ++ * Retrieves the underlying values of this ingredient. ++ * If this is a {@linkplain #isCustom custom ingredient}, an exception is thrown. ++ */ ++ public HolderSet getValues() { + if (isCustom()) { + throw new IllegalStateException("Cannot retrieve values from custom ingredient!"); + } + return this.values; + } + ++ /** ++ * Retrieves the holder set to use for syncing {@linkplain #isSimple() simple} ingredients ++ */ ++ private HolderSet getValuesForSync() { ++ if (isCustom()) { ++ return HolderSet.direct(this.items()); ++ } ++ return this.values; ++ } ++ + public boolean isSimple() { + return this.customIngredient == null || this.customIngredient.isSimple(); + } @@ -156,79 +110,14 @@ + return this.customIngredient != null; } - public static Ingredient fromValues(Stream p_43939_) { -@@ -120,6 +_,7 @@ - return fromValues(Stream.of(new Ingredient.TagValue(p_204133_))); + public static Ingredient of(ItemLike p_364285_) { +@@ -94,6 +_,9 @@ } -+ @Deprecated // Neo: We take over the codec creation entirely to support custom ingredients - see CraftingHelper - private static Codec codec(boolean p_301074_) { - Codec codec = Codec.list(Ingredient.Value.CODEC) - .comapFlatMap( -@@ -144,10 +_,11 @@ - } - - public static record ItemValue(ItemStack item) implements Ingredient.Value { -- static final Codec CODEC = RecordCodecBuilder.create( -+ static final com.mojang.serialization.MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec( - p_330109_ -> p_330109_.group(ItemStack.SIMPLE_ITEM_CODEC.fieldOf("item").forGetter(p_300919_ -> p_300919_.item)) - .apply(p_330109_, Ingredient.ItemValue::new) - ); -+ static final Codec CODEC = MAP_CODEC.codec(); - - @Override - public boolean equals(Object p_301316_) { -@@ -156,6 +_,12 @@ - : ingredient$itemvalue.item.getItem().equals(this.item.getItem()) && ingredient$itemvalue.item.getCount() == this.item.getCount(); - } - -+ // Neo: Add a hashCode() implementation that matches equals() -+ @Override -+ public int hashCode() { -+ return 31 * item.getItem().hashCode() + item.getCount(); + public SlotDisplay display() { ++ if (this.customIngredient != null) { ++ return this.customIngredient.display(); + } -+ - @Override - public Collection getItems() { - return Collections.singleton(this.item); -@@ -163,10 +_,11 @@ - } - - public static record TagValue(TagKey tag) implements Ingredient.Value { -- static final Codec CODEC = RecordCodecBuilder.create( -+ static final com.mojang.serialization.MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec( - p_301118_ -> p_301118_.group(TagKey.codec(Registries.ITEM).fieldOf("tag").forGetter(p_301154_ -> p_301154_.tag)) - .apply(p_301118_, Ingredient.TagValue::new) - ); -+ static final Codec CODEC = MAP_CODEC.codec(); - - @Override - public boolean equals(Object p_301162_) { -@@ -181,12 +_,18 @@ - list.add(new ItemStack(holder)); - } - -+ if (list.isEmpty()) { -+ net.minecraft.world.item.ItemStack itemStack = new net.minecraft.world.item.ItemStack(net.minecraft.world.level.block.Blocks.BARRIER); -+ itemStack.set(net.minecraft.core.component.DataComponents.CUSTOM_NAME, net.minecraft.network.chat.Component.literal("Empty Tag: " + this.tag.location())); -+ list.add(itemStack); -+ } - return list; - } - } - -+ // Neo: Do not extend this interface. For custom ingredient behaviors see ICustomIngredient. - public interface Value { -- Codec CODEC = Codec.xor(Ingredient.ItemValue.CODEC, Ingredient.TagValue.CODEC) -+ com.mojang.serialization.MapCodec MAP_CODEC = net.neoforged.neoforge.common.util.NeoForgeExtraCodecs.xor(Ingredient.ItemValue.MAP_CODEC, Ingredient.TagValue.MAP_CODEC) - .xmap(p_300956_ -> p_300956_.map(p_300932_ -> p_300932_, p_301313_ -> p_301313_), p_301304_ -> { - if (p_301304_ instanceof Ingredient.TagValue ingredient$tagvalue) { - return Either.right(ingredient$tagvalue); -@@ -196,6 +_,7 @@ - throw new UnsupportedOperationException("This is neither an item value nor a tag value."); - } - }); -+ Codec CODEC = MAP_CODEC.codec(); - - Collection getItems(); - } + return (SlotDisplay)this.values + .unwrap() + .map(SlotDisplay.TagSlotDisplay::new, p_380837_ -> new SlotDisplay.Composite(p_380837_.stream().map(Ingredient::displayForSingleItem).toList())); diff --git a/patches/net/minecraft/world/item/crafting/Recipe.java.patch b/patches/net/minecraft/world/item/crafting/Recipe.java.patch index 4c7128f14c..7a084590af 100644 --- a/patches/net/minecraft/world/item/crafting/Recipe.java.patch +++ b/patches/net/minecraft/world/item/crafting/Recipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/Recipe.java +++ b/net/minecraft/world/item/crafting/Recipe.java -@@ -15,6 +_,7 @@ +@@ -14,6 +_,7 @@ public interface Recipe { Codec> CODEC = BuiltInRegistries.RECIPE_SERIALIZER.byNameCodec().dispatch(Recipe::getSerializer, RecipeSerializer::codec); @@ -8,23 +8,3 @@ StreamCodec> STREAM_CODEC = ByteBufCodecs.registry(Registries.RECIPE_SERIALIZER) .dispatch(Recipe::getSerializer, RecipeSerializer::streamCodec); -@@ -30,9 +_,9 @@ - NonNullList nonnulllist = NonNullList.withSize(p_345383_.size(), ItemStack.EMPTY); - - for (int i = 0; i < nonnulllist.size(); i++) { -- Item item = p_345383_.getItem(i).getItem(); -+ ItemStack item = p_345383_.getItem(i); - if (item.hasCraftingRemainingItem()) { -- nonnulllist.set(i, new ItemStack(item.getCraftingRemainingItem())); -+ nonnulllist.set(i, item.getCraftingRemainingItem()); - } - } - -@@ -65,6 +_,6 @@ - - default boolean isIncomplete() { - NonNullList nonnulllist = this.getIngredients(); -- return nonnulllist.isEmpty() || nonnulllist.stream().anyMatch(p_151268_ -> p_151268_.getItems().length == 0); -+ return nonnulllist.isEmpty() || nonnulllist.stream().anyMatch(Ingredient::hasNoItems); - } - } diff --git a/patches/net/minecraft/world/item/crafting/RecipeManager.java.patch b/patches/net/minecraft/world/item/crafting/RecipeManager.java.patch deleted file mode 100644 index c4f01d12d0..0000000000 --- a/patches/net/minecraft/world/item/crafting/RecipeManager.java.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/net/minecraft/world/item/crafting/RecipeManager.java -+++ b/net/minecraft/world/item/crafting/RecipeManager.java -@@ -50,16 +_,22 @@ - this.hasErrors = false; - Builder, RecipeHolder> builder = ImmutableMultimap.builder(); - com.google.common.collect.ImmutableMap.Builder> builder1 = ImmutableMap.builder(); -- RegistryOps registryops = this.registries.createSerializationContext(JsonOps.INSTANCE); -+ RegistryOps registryops = this.makeConditionalOps(); // Neo: add condition context - - for (Entry entry : p_44037_.entrySet()) { - ResourceLocation resourcelocation = entry.getKey(); -+ if (resourcelocation.getPath().startsWith("_")) continue; //Forge: filter anything beginning with "_" as it's used for metadata. - - try { -- Recipe recipe = Recipe.CODEC.parse(registryops, entry.getValue()).getOrThrow(JsonParseException::new); -+ var decoded = Recipe.CONDITIONAL_CODEC.parse(registryops, entry.getValue()).getOrThrow(JsonParseException::new); -+ decoded.ifPresentOrElse(r -> { -+ Recipe recipe = r.carrier(); - RecipeHolder recipeholder = new RecipeHolder<>(resourcelocation, recipe); - builder.put(recipe.getType(), recipeholder); - builder1.put(resourcelocation, recipeholder); -+ }, () -> { -+ LOGGER.debug("Skipping loading recipe {} as its conditions were not met", resourcelocation); -+ }); - } catch (IllegalArgumentException | JsonParseException jsonparseexception) { - LOGGER.error("Parsing error loading recipe {}", resourcelocation, jsonparseexception); - } diff --git a/patches/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch b/patches/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch index 5838660aab..91780eb1f2 100644 --- a/patches/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch +++ b/patches/net/minecraft/world/item/crafting/RepairItemRecipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/RepairItemRecipe.java +++ b/net/minecraft/world/item/crafting/RepairItemRecipe.java -@@ -47,7 +_,9 @@ +@@ -46,7 +_,9 @@ && p_336139_.has(DataComponents.MAX_DAMAGE) && p_335795_.has(DataComponents.MAX_DAMAGE) && p_336139_.has(DataComponents.DAMAGE) diff --git a/patches/net/minecraft/world/item/crafting/ShapedRecipe.java.patch b/patches/net/minecraft/world/item/crafting/ShapedRecipe.java.patch deleted file mode 100644 index 520c71a87f..0000000000 --- a/patches/net/minecraft/world/item/crafting/ShapedRecipe.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/crafting/ShapedRecipe.java -+++ b/net/minecraft/world/item/crafting/ShapedRecipe.java -@@ -84,7 +_,7 @@ - @Override - public boolean isIncomplete() { - NonNullList nonnulllist = this.getIngredients(); -- return nonnulllist.isEmpty() || nonnulllist.stream().filter(p_151277_ -> !p_151277_.isEmpty()).anyMatch(p_151273_ -> p_151273_.getItems().length == 0); -+ return nonnulllist.isEmpty() || nonnulllist.stream().filter(p_151277_ -> !p_151277_.isEmpty()).anyMatch(Ingredient::hasNoItems); - } - - public static class Serializer implements RecipeSerializer { diff --git a/patches/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch b/patches/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch index 9d6f735dea..cd823dd075 100644 --- a/patches/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch +++ b/patches/net/minecraft/world/item/crafting/ShapedRecipePattern.java.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipePattern.java +++ b/net/minecraft/world/item/crafting/ShapedRecipePattern.java -@@ -20,7 +_,30 @@ +@@ -21,8 +_,31 @@ import net.minecraft.world.item.ItemStack; public final class ShapedRecipePattern { + /** @deprecated Neo: use {@link #getMaxWidth} and {@link #getMaxHeight} */ @Deprecated private static final int MAX_SIZE = 3; + public static final char EMPTY_SLOT = ' '; + static int maxWidth = 3; + static int maxHeight = 3; + @@ -31,7 +32,7 @@ public static final MapCodec MAP_CODEC = ShapedRecipePattern.Data.MAP_CODEC .flatXmap( ShapedRecipePattern::unpack, -@@ -214,16 +_,16 @@ +@@ -206,16 +_,16 @@ public static record Data(Map key, List pattern) { private static final Codec> PATTERN_CODEC = Codec.STRING.listOf().comapFlatMap(p_312085_ -> { diff --git a/patches/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/patches/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch index 67d0abb76e..9e0f171250 100644 --- a/patches/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch +++ b/patches/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -18,12 +_,14 @@ - final CraftingBookCategory category; - final ItemStack result; - final NonNullList ingredients; +@@ -24,12 +_,14 @@ + final List ingredients; + @Nullable + private PlacementInfo placementInfo; + private final boolean isSimple; - public ShapelessRecipe(String p_249640_, CraftingBookCategory p_249390_, ItemStack p_252071_, NonNullList p_250689_) { + public ShapelessRecipe(String p_249640_, CraftingBookCategory p_249390_, ItemStack p_252071_, List p_361103_) { this.group = p_249640_; this.category = p_249390_; this.result = p_252071_; - this.ingredients = p_250689_; -+ this.isSimple = p_250689_.stream().allMatch(Ingredient::isSimple); + this.ingredients = p_361103_; ++ this.isSimple = p_361103_.stream().allMatch(Ingredient::isSimple); } @Override -@@ -54,6 +_,12 @@ +@@ -59,6 +_,12 @@ public boolean matches(CraftingInput p_346123_, Level p_44263_) { if (p_346123_.ingredientCount() != this.ingredients.size()) { return false; @@ -28,19 +28,12 @@ } else { return p_346123_.size() == 1 && this.ingredients.size() == 1 ? this.ingredients.getFirst().test(p_346123_.getItem(0)) -@@ -81,12 +_,12 @@ - .fieldOf("ingredients") - .flatXmap( - p_301021_ -> { -- Ingredient[] aingredient = p_301021_.stream().filter(p_300883_ -> !p_300883_.isEmpty()).toArray(Ingredient[]::new); -+ Ingredient[] aingredient = p_301021_.toArray(Ingredient[]::new); // Neo skip the empty check and immediately create the array. - if (aingredient.length == 0) { - return DataResult.error(() -> "No ingredients for shapeless recipe"); - } else { -- return aingredient.length > 9 -- ? DataResult.error(() -> "Too many ingredients for shapeless recipe") -+ return aingredient.length > ShapedRecipePattern.maxHeight * ShapedRecipePattern.maxWidth -+ ? DataResult.error(() -> "Too many ingredients for shapeless recipe. The maximum is: %s".formatted(ShapedRecipePattern.maxHeight * ShapedRecipePattern.maxWidth)) - : DataResult.success(NonNullList.of(Ingredient.EMPTY, aingredient)); - } - }, +@@ -87,7 +_,7 @@ + Codec.STRING.optionalFieldOf("group", "").forGetter(p_301127_ -> p_301127_.group), + CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(p_301133_ -> p_301133_.category), + ItemStack.STRICT_CODEC.fieldOf("result").forGetter(p_301142_ -> p_301142_.result), +- Ingredient.CODEC.listOf(1, 9).fieldOf("ingredients").forGetter(p_360071_ -> p_360071_.ingredients) ++ Codec.lazyInitialized(() -> Ingredient.CODEC.listOf(1, ShapedRecipePattern.maxHeight * ShapedRecipePattern.maxWidth)).fieldOf("ingredients").forGetter(p_360071_ -> p_360071_.ingredients) + ) + .apply(p_360072_, ShapelessRecipe::new) + ); diff --git a/patches/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch b/patches/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch deleted file mode 100644 index 8ad7cc1c6d..0000000000 --- a/patches/net/minecraft/world/item/crafting/ShulkerBoxColoring.java.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/world/item/crafting/ShulkerBoxColoring.java -+++ b/net/minecraft/world/item/crafting/ShulkerBoxColoring.java -@@ -24,7 +_,7 @@ - if (Block.byItem(itemstack.getItem()) instanceof ShulkerBoxBlock) { - i++; - } else { -- if (!(itemstack.getItem() instanceof DyeItem)) { -+ if (!itemstack.is(net.neoforged.neoforge.common.Tags.Items.DYES)) { - return false; - } - -@@ -42,7 +_,7 @@ - - public ItemStack assemble(CraftingInput p_346433_, HolderLookup.Provider p_335717_) { - ItemStack itemstack = ItemStack.EMPTY; -- DyeItem dyeitem = (DyeItem)Items.WHITE_DYE; -+ net.minecraft.world.item.DyeColor dyecolor = net.minecraft.world.item.DyeColor.WHITE; - - for (int i = 0; i < p_346433_.size(); i++) { - ItemStack itemstack1 = p_346433_.getItem(i); -@@ -50,13 +_,14 @@ - Item item = itemstack1.getItem(); - if (Block.byItem(item) instanceof ShulkerBoxBlock) { - itemstack = itemstack1; -- } else if (item instanceof DyeItem) { -- dyeitem = (DyeItem)item; -+ } else { -+ net.minecraft.world.item.DyeColor tmp = net.minecraft.world.item.DyeColor.getColor(itemstack1); -+ if (tmp != null) dyecolor = tmp; - } - } - } - -- Block block = ShulkerBoxBlock.getBlockByColor(dyeitem.getDyeColor()); -+ Block block = ShulkerBoxBlock.getBlockByColor(dyecolor); - return itemstack.transmuteCopy(block, 1); - } - diff --git a/patches/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch b/patches/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch deleted file mode 100644 index 090c3de77e..0000000000 --- a/patches/net/minecraft/world/item/crafting/SimpleCookingSerializer.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SimpleCookingSerializer.java -+++ b/net/minecraft/world/item/crafting/SimpleCookingSerializer.java -@@ -20,7 +_,7 @@ - Codec.STRING.optionalFieldOf("group", "").forGetter(p_300832_ -> p_300832_.group), - CookingBookCategory.CODEC.fieldOf("category").orElse(CookingBookCategory.MISC).forGetter(p_300828_ -> p_300828_.category), - Ingredient.CODEC_NONEMPTY.fieldOf("ingredient").forGetter(p_300833_ -> p_300833_.ingredient), -- ItemStack.STRICT_SINGLE_ITEM_CODEC.fieldOf("result").forGetter(p_300827_ -> p_300827_.result), -+ ItemStack.CODEC.fieldOf("result").forGetter(p_300827_ -> p_300827_.result), - Codec.FLOAT.fieldOf("experience").orElse(0.0F).forGetter(p_300826_ -> p_300826_.experience), - Codec.INT.fieldOf("cookingtime").orElse(p_44331_).forGetter(p_300834_ -> p_300834_.cookingTime) - ) diff --git a/patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch b/patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch deleted file mode 100644 index fbf57bcd12..0000000000 --- a/patches/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -+++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -@@ -60,7 +_,7 @@ - - @Override - public boolean isIncomplete() { -- return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::isEmpty); -+ return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::hasNoItems); - } - - public static class Serializer implements RecipeSerializer { diff --git a/patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch deleted file mode 100644 index e2e5dadbda..0000000000 --- a/patches/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -+++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -89,7 +_,7 @@ - - @Override - public boolean isIncomplete() { -- return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::isEmpty); -+ return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::hasNoItems); - } - - public static class Serializer implements RecipeSerializer { diff --git a/patches/net/minecraft/world/item/enchantment/Enchantment.java.patch b/patches/net/minecraft/world/item/enchantment/Enchantment.java.patch index 86a3a016cf..be865c9992 100644 --- a/patches/net/minecraft/world/item/enchantment/Enchantment.java.patch +++ b/patches/net/minecraft/world/item/enchantment/Enchantment.java.patch @@ -43,7 +43,7 @@ public boolean canEnchant(ItemStack p_44689_) { return this.definition.supportedItems().contains(p_44689_.getItemHolder()); } -@@ -504,12 +_,26 @@ +@@ -511,12 +_,26 @@ return new Enchantment.Builder(p_345873_); } @@ -70,7 +70,7 @@ public Builder(Enchantment.EnchantmentDefinition p_345317_) { this.definition = p_345317_; } -@@ -562,6 +_,16 @@ +@@ -569,6 +_,16 @@ return this; } @@ -87,7 +87,7 @@ private List getEffectsList(DataComponentType> p_344770_) { return (List)this.effectLists.computeIfAbsent(p_344770_, p_346247_ -> { ArrayList arraylist = new ArrayList<>(); -@@ -572,7 +_,9 @@ +@@ -579,7 +_,9 @@ public Enchantment build(ResourceLocation p_344988_) { return new Enchantment( diff --git a/patches/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch b/patches/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch index f04fd8c5f6..3fee255d5d 100644 --- a/patches/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch +++ b/patches/net/minecraft/world/item/enchantment/EnchantmentHelper.java.patch @@ -20,7 +20,7 @@ ItemEnchantments itemenchantments = p_44845_.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY); return itemenchantments.getLevel(p_346179_); } -@@ -122,6 +_,12 @@ +@@ -128,6 +_,12 @@ public static void runIterationOnItem(ItemStack p_345425_, EnchantmentHelper.EnchantmentVisitor p_345023_) { ItemEnchantments itemenchantments = p_345425_.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY); @@ -33,7 +33,7 @@ for (Entry> entry : itemenchantments.entrySet()) { p_345023_.accept(entry.getKey(), entry.getIntValue()); } -@@ -132,6 +_,10 @@ +@@ -138,6 +_,10 @@ ) { if (!p_44852_.isEmpty()) { ItemEnchantments itemenchantments = p_44852_.get(DataComponents.ENCHANTMENTS); @@ -44,7 +44,7 @@ if (itemenchantments != null && !itemenchantments.isEmpty()) { EnchantedItemInUse enchantediteminuse = new EnchantedItemInUse(p_44852_, p_345566_, p_345792_); -@@ -417,6 +_,12 @@ +@@ -438,6 +_,12 @@ public static boolean hasTag(ItemStack p_345665_, TagKey p_345928_) { ItemEnchantments itemenchantments = p_345665_.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY); @@ -57,25 +57,7 @@ for (Entry> entry : itemenchantments.entrySet()) { Holder holder = entry.getKey(); if (holder.is(p_345928_)) { -@@ -484,7 +_,7 @@ - - public static int getEnchantmentCost(RandomSource p_220288_, int p_220289_, int p_220290_, ItemStack p_220291_) { - Item item = p_220291_.getItem(); -- int i = item.getEnchantmentValue(); -+ int i = p_220291_.getEnchantmentValue(); - if (i <= 0) { - return 0; - } else { -@@ -529,7 +_,7 @@ - public static List selectEnchantment(RandomSource p_220298_, ItemStack p_220299_, int p_220300_, Stream> p_346061_) { - List list = Lists.newArrayList(); - Item item = p_220299_.getItem(); -- int i = item.getEnchantmentValue(); -+ int i = p_220299_.getEnchantmentValue(); - if (i <= 0) { - return list; - } else { -@@ -575,7 +_,9 @@ +@@ -594,7 +_,9 @@ public static List getAvailableEnchantmentResults(int p_44818_, ItemStack p_44819_, Stream> p_345348_) { List list = Lists.newArrayList(); boolean flag = p_44819_.is(Items.BOOK); diff --git a/patches/net/minecraft/world/level/BaseSpawner.java.patch b/patches/net/minecraft/world/level/BaseSpawner.java.patch index 05af8829aa..6a423f6cca 100644 --- a/patches/net/minecraft/world/level/BaseSpawner.java.patch +++ b/patches/net/minecraft/world/level/BaseSpawner.java.patch @@ -9,27 +9,28 @@ public static final String SPAWN_DATA_TAG = "SpawnData"; private static final Logger LOGGER = LogUtils.getLogger(); private static final int EVENT_SPAWN = 1; -@@ -151,15 +_,14 @@ +@@ -151,16 +_,14 @@ entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), randomsource.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob mob) { -- if (spawndata.getCustomSpawnRules().isEmpty() && !mob.checkSpawnRules(p_151312_, MobSpawnType.SPAWNER) +- if (spawndata.getCustomSpawnRules().isEmpty() && !mob.checkSpawnRules(p_151312_, EntitySpawnReason.SPAWNER) - || !mob.checkSpawnObstruction(p_151312_)) { -+ if (!net.neoforged.neoforge.event.EventHooks.checkSpawnPositionSpawner(mob, p_151312_, MobSpawnType.SPAWNER, spawndata, this)) { ++ if (!net.neoforged.neoforge.event.EventHooks.checkSpawnPositionSpawner(mob, p_151312_, EntitySpawnReason.SPAWNER, spawndata, this)) { continue; } boolean flag1 = spawndata.getEntityToSpawn().size() == 1 && spawndata.getEntityToSpawn().contains("id", 8); - if (flag1) { -- ((Mob)entity).finalizeSpawn(p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, null); +- ((Mob)entity) +- .finalizeSpawn(p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, null); - } + // Neo: Patch in FinalizeSpawn for spawners so it may be fired unconditionally, instead of only when vanilla would normally call it. + // The local flag1 is the conditions under which the spawner will normally call Mob#finalizeSpawn. -+ net.neoforged.neoforge.event.EventHooks.finalizeMobSpawnSpawner(mob, p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, null, this, flag1); ++ net.neoforged.neoforge.event.EventHooks.finalizeMobSpawnSpawner(mob, p_151312_, p_151312_.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, null, this, flag1); spawndata.getEquipment().ifPresent(mob::equip); } -@@ -308,5 +_,12 @@ +@@ -309,5 +_,12 @@ public double getoSpin() { return this.oSpin; diff --git a/patches/net/minecraft/world/level/BlockGetter.java.patch b/patches/net/minecraft/world/level/BlockGetter.java.patch index c04b9cc5cf..60f517c0ab 100644 --- a/patches/net/minecraft/world/level/BlockGetter.java.patch +++ b/patches/net/minecraft/world/level/BlockGetter.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/BlockGetter.java +++ b/net/minecraft/world/level/BlockGetter.java -@@ -18,7 +_,7 @@ +@@ -20,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; -public interface BlockGetter extends LevelHeightAccessor { +public interface BlockGetter extends LevelHeightAccessor, net.neoforged.neoforge.common.extensions.IBlockGetterExtension { - @Nullable - BlockEntity getBlockEntity(BlockPos p_45570_); + int MAX_BLOCK_ITERATIONS_ALONG_TRAVEL = 16; -@@ -32,7 +_,7 @@ + @Nullable +@@ -36,7 +_,7 @@ FluidState getFluidState(BlockPos p_45569_); default int getLightEmission(BlockPos p_45572_) { @@ -17,4 +17,4 @@ + return this.getBlockState(p_45572_).getLightEmission(this, p_45572_); } - default int getMaxLightLevel() { + default Stream getBlockStates(AABB p_45557_) { diff --git a/patches/net/minecraft/world/level/Explosion.java.patch b/patches/net/minecraft/world/level/Explosion.java.patch deleted file mode 100644 index 285a7530f6..0000000000 --- a/patches/net/minecraft/world/level/Explosion.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/world/level/Explosion.java -+++ b/net/minecraft/world/level/Explosion.java -@@ -269,6 +_,7 @@ - int j2 = Mth.floor(this.z - (double)f2 - 1.0); - int j1 = Mth.floor(this.z + (double)f2 + 1.0); - List list = this.level.getEntities(this.source, new AABB((double)k1, (double)i2, (double)j2, (double)l1, (double)i1, (double)j1)); -+ net.neoforged.neoforge.event.EventHooks.onExplosionDetonate(this.level, this, list, f2); - Vec3 vec3 = new Vec3(this.x, this.y, this.z); - - for (Entity entity : list) { -@@ -299,6 +_,7 @@ - d7 *= d10; - d9 *= d10; - Vec3 vec31 = new Vec3(d5, d7, d9); -+ vec31 = net.neoforged.neoforge.event.EventHooks.getExplosionKnockback(this.level, this, entity, vec31); - entity.setDeltaMovement(entity.getDeltaMovement().add(vec31)); - if (entity instanceof Player) { - Player player = (Player)entity; diff --git a/patches/net/minecraft/world/level/Level.java.patch b/patches/net/minecraft/world/level/Level.java.patch index c2328b4f8b..00df1925bc 100644 --- a/patches/net/minecraft/world/level/Level.java.patch +++ b/patches/net/minecraft/world/level/Level.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -76,7 +_,7 @@ +@@ -78,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Scoreboard; @@ -9,7 +9,7 @@ public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); public static final ResourceKey NETHER = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("the_nether")); -@@ -114,6 +_,11 @@ +@@ -115,6 +_,11 @@ private final RegistryAccess registryAccess; private final DamageSources damageSources; private long subTickCount; @@ -21,7 +21,7 @@ protected Level( WritableLevelData p_270739_, -@@ -216,11 +_,40 @@ +@@ -215,11 +_,36 @@ } else { LevelChunk levelchunk = this.getChunkAt(p_46605_); Block block = p_46606_.getBlock(); @@ -32,10 +32,6 @@ + blockSnapshot = net.neoforged.neoforge.common.util.BlockSnapshot.create(this.dimension, this, p_46605_, p_46607_); + this.capturedBlockSnapshots.add(blockSnapshot); + } -+ -+ BlockState old = getBlockState(p_46605_); -+ int oldLight = old.getLightEmission(this, p_46605_); -+ int oldOpacity = old.getLightBlock(this, p_46605_); + BlockState blockstate = levelchunk.setBlockState(p_46605_, p_46606_, (p_46607_ & 64) != 0); if (blockstate == null) { @@ -62,7 +58,7 @@ if (blockstate1 == p_46606_) { if (blockstate != blockstate1) { this.setBlocksDirty(p_46605_, blockstate, blockstate1); -@@ -247,9 +_,8 @@ +@@ -246,9 +_,8 @@ } this.onBlockStateChange(p_46605_, blockstate, blockstate1); @@ -73,15 +69,15 @@ } } } -@@ -301,6 +_,7 @@ +@@ -300,6 +_,7 @@ } public void updateNeighborsAt(BlockPos p_46673_, Block p_46674_) { + net.neoforged.neoforge.event.EventHooks.onNeighborNotify(this, p_46673_, this.getBlockState(p_46673_), java.util.EnumSet.allOf(Direction.class), false).isCanceled(); } - public void updateNeighborsAtExceptFromFacing(BlockPos p_46591_, Block p_46592_, Direction p_46593_) { -@@ -489,10 +_,26 @@ + public void updateNeighborsAt(BlockPos p_365514_, Block p_364886_, @Nullable Orientation p_363337_) { +@@ -491,10 +_,26 @@ (this.tickingBlockEntities ? this.pendingBlockEntityTickers : this.blockEntityTickers).add(p_151526_); } @@ -94,7 +90,7 @@ + } + protected void tickBlockEntities() { - ProfilerFiller profilerfiller = this.getProfiler(); + ProfilerFiller profilerfiller = Profiler.get(); profilerfiller.push("blockEntities"); + if (!this.pendingFreshBlockEntities.isEmpty()) { + this.freshBlockEntities.addAll(this.pendingFreshBlockEntities); @@ -108,7 +104,7 @@ if (!this.pendingBlockEntityTickers.isEmpty()) { this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); this.pendingBlockEntityTickers.clear(); -@@ -516,12 +_,19 @@ +@@ -518,12 +_,19 @@ public void guardEntityTick(Consumer p_46654_, T p_46655_) { try { @@ -128,24 +124,7 @@ } } -@@ -670,7 +_,7 @@ - Explosion.BlockInteraction explosion$blockinteraction = switch (p_312265_) { - case NONE -> Explosion.BlockInteraction.KEEP; - case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); -- case MOB -> this.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) -+ case MOB -> net.neoforged.neoforge.event.EventHooks.canEntityGrief(this, p_311934_) - ? this.getDestroyType(GameRules.RULE_MOB_EXPLOSION_DROP_DECAY) - : Explosion.BlockInteraction.KEEP; - case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); -@@ -691,6 +_,7 @@ - p_312060_, - p_320283_ - ); -+ if (net.neoforged.neoforge.event.EventHooks.onExplosionStart(this, explosion)) return explosion; - explosion.explode(); - explosion.finalizeExplosion(p_312145_); - return explosion; -@@ -725,6 +_,7 @@ +@@ -673,6 +_,7 @@ if (!this.isOutsideBuildHeight(p_46748_)) { this.getChunkAt(p_46748_).removeBlockEntity(p_46748_); } @@ -153,7 +132,7 @@ } public boolean isLoaded(BlockPos p_46750_) { -@@ -803,6 +_,7 @@ +@@ -751,6 +_,7 @@ list.add(p_151522_); } @@ -161,7 +140,7 @@ if (p_151522_ instanceof EnderDragon) { for (EnderDragonPart enderdragonpart : ((EnderDragon)p_151522_).getSubEntities()) { if (p_151522_ != p_46536_ && p_46538_.test(enderdragonpart)) { -@@ -811,6 +_,11 @@ +@@ -759,6 +_,11 @@ } } }); @@ -173,7 +152,7 @@ return list; } -@@ -837,6 +_,8 @@ +@@ -785,6 +_,8 @@ } } @@ -182,7 +161,7 @@ if (p_261454_ instanceof EnderDragon enderdragon) { for (EnderDragonPart enderdragonpart : enderdragon.getSubEntities()) { T t = p_261885_.tryCast(enderdragonpart); -@@ -851,6 +_,15 @@ +@@ -799,6 +_,15 @@ return AbortableIterationConsumer.Continuation.CONTINUE; }); @@ -198,7 +177,7 @@ } @Nullable -@@ -979,16 +_,15 @@ +@@ -922,16 +_,15 @@ public abstract Scoreboard getScoreboard(); public void updateNeighbourForOutputSignal(BlockPos p_46718_, Block p_46719_) { @@ -208,7 +187,7 @@ if (this.hasChunkAt(blockpos)) { BlockState blockstate = this.getBlockState(blockpos); - if (blockstate.is(Blocks.COMPARATOR)) { -- this.neighborChanged(blockstate, blockpos, p_46719_, p_46718_, false); +- this.neighborChanged(blockstate, blockpos, p_46719_, null, false); - } else if (blockstate.isRedstoneConductor(this, blockpos)) { + blockstate.onNeighborChange(this, blockpos, p_46718_); + if (blockstate.isRedstoneConductor(this, blockpos)) { @@ -216,10 +195,10 @@ blockstate = this.getBlockState(blockpos); - if (blockstate.is(Blocks.COMPARATOR)) { + if (blockstate.getWeakChanges(this, blockpos)) { - this.neighborChanged(blockstate, blockpos, p_46719_, p_46718_, false); + this.neighborChanged(blockstate, blockpos, p_46719_, null, false); } } -@@ -1078,6 +_,18 @@ +@@ -1013,6 +_,18 @@ return this.biomeManager; } @@ -238,7 +217,7 @@ public final boolean isDebug() { return this.isDebug; } -@@ -1118,5 +_,38 @@ +@@ -1055,5 +_,38 @@ public String getSerializedName() { return this.id; } diff --git a/patches/net/minecraft/world/level/LevelSettings.java.patch b/patches/net/minecraft/world/level/LevelSettings.java.patch index e7ca7e313f..086a722d3a 100644 --- a/patches/net/minecraft/world/level/LevelSettings.java.patch +++ b/patches/net/minecraft/world/level/LevelSettings.java.patch @@ -26,14 +26,14 @@ @@ -33,7 +_,8 @@ p_46925_.get("Difficulty").asNumber().map(p_46928_ -> Difficulty.byId(p_46928_.byteValue())).result().orElse(Difficulty.NORMAL), p_46925_.get("allowCommands").asBoolean(gametype == GameType.CREATIVE), - new GameRules(p_46925_.get("GameRules")), + new GameRules(p_251697_.enabledFeatures(), p_46925_.get("GameRules")), - p_251697_ + p_251697_, + net.neoforged.neoforge.common.CommonHooks.parseLifecycle(p_46925_.get("forgeLifecycle").asString("stable")) ); } -@@ -66,20 +_,27 @@ +@@ -66,15 +_,15 @@ } public LevelSettings withGameType(GameType p_46923_) { @@ -43,7 +43,6 @@ public LevelSettings withDifficulty(Difficulty p_46919_) { - return new LevelSettings(this.levelName, this.gameType, this.hardcore, p_46919_, this.allowCommands, this.gameRules, this.dataConfiguration); -+ net.neoforged.neoforge.common.CommonHooks.onDifficultyChange(p_46919_, this.difficulty); + return new LevelSettings(this.levelName, this.gameType, this.hardcore, p_46919_, this.allowCommands, this.gameRules, this.dataConfiguration, this.lifecycle); } @@ -53,14 +52,20 @@ } public LevelSettings copy() { - return new LevelSettings( -- this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(), this.dataConfiguration -+ this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules.copy(), this.dataConfiguration, this.lifecycle +@@ -85,7 +_,16 @@ + this.difficulty, + this.allowCommands, + this.gameRules.copy(this.dataConfiguration.enabledFeatures()), +- this.dataConfiguration ++ this.dataConfiguration, ++ this.lifecycle ); + } ++ + public LevelSettings withLifecycle(com.mojang.serialization.Lifecycle lifecycle) { + return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, this.dataConfiguration, lifecycle); + } ++ + public com.mojang.serialization.Lifecycle getLifecycle() { + return this.lifecycle; } diff --git a/patches/net/minecraft/world/level/NaturalSpawner.java.patch b/patches/net/minecraft/world/level/NaturalSpawner.java.patch index 53f0facd7e..396218218b 100644 --- a/patches/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/patches/net/minecraft/world/level/NaturalSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -45,6 +_,7 @@ +@@ -49,6 +_,7 @@ import net.minecraft.world.phys.Vec3; import org.slf4j.Logger; @@ -8,7 +8,7 @@ public final class NaturalSpawner { private static final Logger LOGGER = LogUtils.getLogger(); private static final int MIN_SPAWN_DISTANCE = 24; -@@ -69,7 +_,7 @@ +@@ -73,7 +_,7 @@ continue; } @@ -17,7 +17,7 @@ if (mobcategory != MobCategory.MISC) { BlockPos blockpos = entity.blockPosition(); p_186527_.query( -@@ -199,7 +_,7 @@ +@@ -214,7 +_,7 @@ l1++; p_47040_.addFreshEntityWithPassengers(mob); p_47044_.run(mob, p_47041_); @@ -26,16 +26,16 @@ return; } -@@ -272,7 +_,7 @@ +@@ -287,7 +_,7 @@ return p_46994_ > (double)(p_46993_.getType().getCategory().getDespawnDistance() * p_46993_.getType().getCategory().getDespawnDistance()) && p_46993_.removeWhenFarAway(p_46994_) ? false -- : p_46993_.checkSpawnRules(p_46992_, MobSpawnType.NATURAL) && p_46993_.checkSpawnObstruction(p_46992_); -+ : net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(p_46993_, p_46992_, MobSpawnType.NATURAL); +- : p_46993_.checkSpawnRules(p_46992_, EntitySpawnReason.NATURAL) && p_46993_.checkSpawnObstruction(p_46992_); ++ : net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(p_46993_, p_46992_, EntitySpawnReason.NATURAL); } private static Optional getRandomSpawnMobAt( -@@ -303,9 +_,14 @@ +@@ -318,9 +_,14 @@ BlockPos p_220448_, @Nullable Holder p_220449_ ) { @@ -44,7 +44,7 @@ - : p_220446_.getMobsAt(p_220449_ != null ? p_220449_ : p_220444_.getBiome(p_220448_), p_220445_, p_220447_, p_220448_); + // Forge: Add in potential spawns, and replace hardcoded nether fortress mob list + if (isInNetherFortressBounds(p_220448_, p_220444_, p_220447_, p_220445_)) { -+ var monsterSpawns = p_220445_.registryAccess().registryOrThrow(Registries.STRUCTURE).getOrThrow(BuiltinStructures.FORTRESS).spawnOverrides().get(MobCategory.MONSTER); ++ var monsterSpawns = p_220445_.registryAccess().lookupOrThrow(Registries.STRUCTURE).getValueOrThrow(BuiltinStructures.FORTRESS).spawnOverrides().get(MobCategory.MONSTER); + if (monsterSpawns != null) { // structure modifiers can clear the spawn overrides + return net.neoforged.neoforge.event.EventHooks.getPotentialSpawns(p_220444_, p_220447_, p_220448_, monsterSpawns.spawns()); + } @@ -53,13 +53,13 @@ } public static boolean isInNetherFortressBounds(BlockPos p_220456_, ServerLevel p_220457_, MobCategory p_220458_, StructureManager p_220459_) { -@@ -392,8 +_,7 @@ +@@ -407,8 +_,7 @@ entity.moveTo(d0, (double)blockpos.getY(), d1, p_220454_.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob mob -- && mob.checkSpawnRules(p_220451_, MobSpawnType.CHUNK_GENERATION) +- && mob.checkSpawnRules(p_220451_, EntitySpawnReason.CHUNK_GENERATION) - && mob.checkSpawnObstruction(p_220451_)) { -+ && net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(mob, p_220451_, MobSpawnType.CHUNK_GENERATION)) { ++ && net.neoforged.neoforge.event.EventHooks.checkSpawnPosition(mob, p_220451_, EntitySpawnReason.CHUNK_GENERATION)) { spawngroupdata = mob.finalizeSpawn( - p_220451_, p_220451_.getCurrentDifficultyAt(mob.blockPosition()), MobSpawnType.CHUNK_GENERATION, spawngroupdata + p_220451_, p_220451_.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CHUNK_GENERATION, spawngroupdata ); diff --git a/patches/net/minecraft/world/level/ServerExplosion.java.patch b/patches/net/minecraft/world/level/ServerExplosion.java.patch new file mode 100644 index 0000000000..de66d59d95 --- /dev/null +++ b/patches/net/minecraft/world/level/ServerExplosion.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/level/ServerExplosion.java ++++ b/net/minecraft/world/level/ServerExplosion.java +@@ -174,7 +_,9 @@ + int i1 = Mth.floor(this.center.z - (double)f - 1.0); + int j1 = Mth.floor(this.center.z + (double)f + 1.0); + +- for (Entity entity : this.level.getEntities(this.source, new AABB((double)i, (double)k, (double)i1, (double)j, (double)l, (double)j1))) { ++ List list = this.level.getEntities(this.source, new AABB((double)i, (double)k, (double)i1, (double)j, (double)l, (double)j1)); ++ net.neoforged.neoforge.event.EventHooks.onExplosionDetonate(this.level, this, list, f); ++ for (Entity entity : list) { + if (!entity.ignoreExplosion(this)) { + double d0 = Math.sqrt(entity.distanceToSqr(this.center)) / (double)f; + if (d0 <= 1.0) { +@@ -205,6 +_,7 @@ + d2 *= d6; + d3 *= d6; + Vec3 vec3 = new Vec3(d1, d2, d3); ++ vec3 = net.neoforged.neoforge.event.EventHooks.getExplosionKnockback(this.level, this, entity, vec3); + entity.setDeltaMovement(entity.getDeltaMovement().add(vec3)); + if (entity instanceof Player) { + Player player = (Player)entity; diff --git a/patches/net/minecraft/world/level/biome/Biome.java.patch b/patches/net/minecraft/world/level/biome/Biome.java.patch index 756ca8a329..54c553a09a 100644 --- a/patches/net/minecraft/world/level/biome/Biome.java.patch +++ b/patches/net/minecraft/world/level/biome/Biome.java.patch @@ -40,7 +40,7 @@ } public boolean hasPrecipitation() { -@@ -191,7 +_,7 @@ +@@ -188,7 +_,7 @@ } public BiomeGenerationSettings getGenerationSettings() { @@ -49,7 +49,7 @@ } public int getFogColor() { -@@ -414,5 +_,32 @@ +@@ -411,5 +_,32 @@ public String getSerializedName() { return this.name; } diff --git a/patches/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch b/patches/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch deleted file mode 100644 index a9325c1bf1..0000000000 --- a/patches/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/world/level/biome/BiomeGenerationSettings.java -+++ b/net/minecraft/world/level/biome/BiomeGenerationSettings.java -@@ -50,6 +_,7 @@ - .apply(p_186655_, BiomeGenerationSettings::new) - ); - private final Map>> carvers; -+ private final java.util.Set carversView; - private final List> features; - private final Supplier>> flowerFeatures; - private final Supplier> featureSet; -@@ -66,10 +_,15 @@ - .collect(ImmutableList.toImmutableList()) - ); - this.featureSet = Suppliers.memoize(() -> p_186651_.stream().flatMap(HolderSet::stream).map(Holder::value).collect(Collectors.toSet())); -+ this.carversView = java.util.Collections.unmodifiableSet(carvers.keySet()); - } - - public Iterable>> getCarvers(GenerationStep.Carving p_204188_) { - return Objects.requireNonNullElseGet(this.carvers.get(p_204188_), List::of); -+ } -+ -+ public java.util.Set getCarvingStages() { -+ return this.carversView; - } - - public List> getFlowerFeatures() { diff --git a/patches/net/minecraft/world/level/block/AttachedStemBlock.java.patch b/patches/net/minecraft/world/level/block/AttachedStemBlock.java.patch index 85788acd54..df3eaddebc 100644 --- a/patches/net/minecraft/world/level/block/AttachedStemBlock.java.patch +++ b/patches/net/minecraft/world/level/block/AttachedStemBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/AttachedStemBlock.java +++ b/net/minecraft/world/level/block/AttachedStemBlock.java -@@ -84,7 +_,7 @@ +@@ -94,7 +_,7 @@ @Override protected boolean mayPlaceOn(BlockState p_48863_, BlockGetter p_48864_, BlockPos p_48865_) { diff --git a/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch b/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch index cce4907ae0..f3b8f17dd2 100644 --- a/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch @@ -9,7 +9,7 @@ return p_48987_.getBlockState(p_48988_.below()).is(BlockTags.BAMBOO_PLANTABLE_ON); } -@@ -88,7 +_,7 @@ +@@ -95,7 +_,7 @@ @Override protected float getDestroyProgress(BlockState p_48981_, Player p_48982_, BlockGetter p_48983_, BlockPos p_48984_) { diff --git a/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch index efaeb2b815..91d4635c7e 100644 --- a/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -33,7 +33,7 @@ return p_262154_.getBlockState(p_261493_.below()).is(BlockTags.BAMBOO_PLANTABLE_ON); } -@@ -193,7 +_,7 @@ +@@ -198,7 +_,7 @@ @Override protected float getDestroyProgress(BlockState p_261691_, Player p_262171_, BlockGetter p_261621_, BlockPos p_261500_) { diff --git a/patches/net/minecraft/world/level/block/BaseFireBlock.java.patch b/patches/net/minecraft/world/level/block/BaseFireBlock.java.patch index c4bc4e334f..ade6a8b9df 100644 --- a/patches/net/minecraft/world/level/block/BaseFireBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BaseFireBlock.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/BaseFireBlock.java +++ b/net/minecraft/world/level/block/BaseFireBlock.java -@@ -143,6 +_,7 @@ +@@ -152,6 +_,7 @@ if (!p_49282_.is(p_49279_.getBlock())) { if (inPortalDimension(p_49280_)) { Optional optional = PortalShape.findEmptyPortalShape(p_49280_, p_49281_, Direction.Axis.X); + optional = net.neoforged.neoforge.event.EventHooks.onTrySpawnPortal(p_49280_, p_49281_, optional); if (optional.isPresent()) { - optional.get().createPortalBlocks(); + optional.get().createPortalBlocks(p_49280_); return; -@@ -185,7 +_,7 @@ +@@ -194,7 +_,7 @@ boolean flag = false; for (Direction direction : Direction.values()) { diff --git a/patches/net/minecraft/world/level/block/BaseRailBlock.java.patch b/patches/net/minecraft/world/level/block/BaseRailBlock.java.patch index af4fb513e8..cf64085b38 100644 --- a/patches/net/minecraft/world/level/block/BaseRailBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BaseRailBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BaseRailBlock.java +++ b/net/minecraft/world/level/block/BaseRailBlock.java -@@ -20,7 +_,7 @@ +@@ -23,7 +_,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,33 +9,43 @@ protected static final VoxelShape FLAT_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 2.0, 16.0); protected static final VoxelShape HALF_BLOCK_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0); public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; -@@ -49,6 +_,7 @@ +@@ -51,7 +_,7 @@ + @Override protected VoxelShape getShape(BlockState p_49403_, BlockGetter p_49404_, BlockPos p_49405_, CollisionContext p_49406_) { - RailShape railshape = p_49403_.is(this) ? p_49403_.getValue(this.getShapeProperty()) : null; -+ RailShape railShape2 = p_49403_.is(this) ? getRailDirection(p_49403_, p_49404_, p_49405_, null) : null; - return railshape != null && railshape.isAscending() ? HALF_BLOCK_AABB : FLAT_AABB; +- RailShape railshape = p_49403_.is(this) ? p_49403_.getValue(this.getShapeProperty()) : null; ++ RailShape railshape = p_49403_.is(this) ? getRailDirection(p_49403_, p_49404_, p_49405_, null) : null; + return railshape != null && railshape.isSlope() ? HALF_BLOCK_AABB : FLAT_AABB; } -@@ -76,7 +_,7 @@ +@@ -79,7 +_,7 @@ @Override - protected void neighborChanged(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, BlockPos p_49381_, boolean p_49382_) { + protected void neighborChanged(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, @Nullable Orientation p_361387_, boolean p_49382_) { if (!p_49378_.isClientSide && p_49378_.getBlockState(p_49379_).is(this)) { - RailShape railshape = p_49377_.getValue(this.getShapeProperty()); + RailShape railshape = getRailDirection(p_49377_, p_49378_, p_49379_, null); if (shouldBeRemoved(p_49379_, p_49378_, railshape)) { dropResources(p_49377_, p_49378_, p_49379_); p_49378_.removeBlock(p_49379_, p_49382_); -@@ -121,7 +_,7 @@ +@@ -115,7 +_,7 @@ + if (p_49368_.isClientSide) { + return p_49370_; + } else { +- RailShape railshape = p_49370_.getValue(this.getShapeProperty()); ++ RailShape railshape = getRailDirection(p_49370_, p_49368_, p_49369_, null); + return new RailState(p_49368_, p_49369_, p_49370_).place(p_49368_.hasNeighborSignal(p_49369_), p_49371_, railshape).getState(); + } + } +@@ -124,7 +_,7 @@ protected void onRemove(BlockState p_49384_, Level p_49385_, BlockPos p_49386_, BlockState p_49387_, boolean p_49388_) { if (!p_49388_) { super.onRemove(p_49384_, p_49385_, p_49386_, p_49387_, p_49388_); -- if (p_49384_.getValue(this.getShapeProperty()).isAscending()) { -+ if (getRailDirection(p_49384_, p_49385_, p_49386_, null).isAscending()) { +- if (p_49384_.getValue(this.getShapeProperty()).isSlope()) { ++ if (getRailDirection(p_49384_, p_49385_, p_49386_, null).isSlope()) { p_49385_.updateNeighborsAt(p_49386_.above(), this); } -@@ -142,6 +_,11 @@ +@@ -145,6 +_,11 @@ return blockstate.setValue(this.getShapeProperty(), flag1 ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH).setValue(WATERLOGGED, Boolean.valueOf(flag)); } @@ -47,7 +57,7 @@ public abstract Property getShapeProperty(); @Override -@@ -158,5 +_,15 @@ +@@ -168,5 +_,15 @@ @Override protected FluidState getFluidState(BlockState p_152158_) { return p_152158_.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(p_152158_); @@ -55,7 +65,7 @@ + + @Override + public boolean isFlexibleRail(BlockState state, BlockGetter world, BlockPos pos) { -+ return !this.isStraight; ++ return !this.isStraight; + } + + @Override diff --git a/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch b/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch index 5e59b85a4c..8f858d24fb 100644 --- a/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BeehiveBlock.java +++ b/net/minecraft/world/level/block/BeehiveBlock.java -@@ -126,7 +_,7 @@ +@@ -142,7 +_,7 @@ boolean flag = false; if (i >= 5) { Item item = p_316844_.getItem(); diff --git a/patches/net/minecraft/world/level/block/BigDripleafBlock.java.patch b/patches/net/minecraft/world/level/block/BigDripleafBlock.java.patch index 909353cec3..a95895aa63 100644 --- a/patches/net/minecraft/world/level/block/BigDripleafBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BigDripleafBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BigDripleafBlock.java +++ b/net/minecraft/world/level/block/BigDripleafBlock.java -@@ -146,6 +_,8 @@ +@@ -148,6 +_,8 @@ protected boolean canSurvive(BlockState p_152289_, LevelReader p_152290_, BlockPos p_152291_) { BlockPos blockpos = p_152291_.below(); BlockState blockstate = p_152290_.getBlockState(blockpos); diff --git a/patches/net/minecraft/world/level/block/Block.java.patch b/patches/net/minecraft/world/level/block/Block.java.patch index ca575a2ee2..652a468069 100644 --- a/patches/net/minecraft/world/level/block/Block.java.patch +++ b/patches/net/minecraft/world/level/block/Block.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -61,11 +_,11 @@ +@@ -60,11 +_,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.slf4j.Logger; @@ -14,7 +14,7 @@ private static final LoadingCache SHAPE_FULL_BLOCK_CACHE = CacheBuilder.newBuilder() .maximumSize(512L) .weakKeys() -@@ -186,7 +_,7 @@ +@@ -182,7 +_,7 @@ this.createBlockStateDefinition(builder); this.stateDefinition = builder.create(Block::defaultBlockState, BlockState::new); this.registerDefaultState(this.stateDefinition.any()); @@ -23,16 +23,30 @@ String s = this.getClass().getSimpleName(); if (!s.endsWith("Block")) { LOGGER.error("Block classes should end with Block and {} doesn't.", s); -@@ -208,6 +_,8 @@ - BlockState blockstate = p_152446_.getBlockState(p_152449_); - if (p_152445_.skipRendering(blockstate, p_152448_)) { +@@ -200,12 +_,22 @@ + || p_152464_.is(BlockTags.SHULKER_BOXES); + } + ++ /** ++ * @deprecated Neo: use overload with level context instead ++ */ ++ @Deprecated + public static boolean shouldRenderFace(BlockState p_152445_, BlockState p_361252_, Direction p_152448_) { ++ return shouldRenderFace(net.minecraft.world.level.EmptyBlockGetter.INSTANCE, BlockPos.ZERO, p_152445_, p_361252_, p_152448_); ++ } ++ ++ public static boolean shouldRenderFace(BlockGetter level, BlockPos pos, BlockState p_152445_, BlockState p_361252_, Direction p_152448_) { + VoxelShape voxelshape = p_361252_.getFaceOcclusionShape(p_152448_.getOpposite()); + if (voxelshape == Shapes.block()) { return false; -+ } else if (blockstate.hidesNeighborFace(p_152446_, p_152449_, p_152445_, p_152448_.getOpposite()) && p_152445_.supportsExternalFaceHiding()) { + } else if (p_152445_.skipRendering(p_361252_, p_152448_)) { + return false; ++ } else if (p_361252_.hidesNeighborFace(level, pos.relative(p_152448_), p_152445_, p_152448_.getOpposite()) && p_152445_.supportsExternalFaceHiding()) { + return false; - } else if (blockstate.canOcclude()) { - Block.BlockStatePairKey block$blockstatepairkey = new Block.BlockStatePairKey(p_152445_, blockstate, p_152448_); - Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = OCCLUSION_CACHE.get(); -@@ -281,24 +_,30 @@ + } else if (voxelshape == Shapes.empty()) { + return true; + } else { +@@ -278,24 +_,30 @@ public static void dropResources(BlockState p_49951_, Level p_49952_, BlockPos p_49953_) { if (p_49952_ instanceof ServerLevel) { @@ -67,15 +81,16 @@ } } -@@ -326,19 +_,26 @@ +@@ -323,20 +_,26 @@ } private static void popResource(Level p_152441_, Supplier p_152442_, ItemStack p_152443_) { -- if (!p_152441_.isClientSide && !p_152443_.isEmpty() && p_152441_.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { -+ if (!p_152441_.isClientSide && !p_152443_.isEmpty() && p_152441_.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && !p_152441_.restoringBlockSnapshots) { +- if (p_152441_ instanceof ServerLevel serverlevel && !p_152443_.isEmpty() && serverlevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { ++ if (p_152441_ instanceof ServerLevel serverLevel && !p_152443_.isEmpty() && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && !p_152441_.restoringBlockSnapshots) { ItemEntity itementity = p_152442_.get(); itementity.setDefaultPickUpDelay(); - p_152441_.addFreshEntity(itementity); +- return; + // Neo: Add drops to the captured list if capturing is enabled. + if (capturedDrops != null) { + capturedDrops.add(itementity); @@ -97,9 +112,9 @@ public float getExplosionResistance() { return this.explosionResistance; } -@@ -385,8 +_,10 @@ +@@ -375,8 +_,10 @@ - public void updateEntityAfterFallOn(BlockGetter p_49821_, Entity p_49822_) { + public void updateEntityMovementAfterFallOn(BlockGetter p_49821_, Entity p_49822_) { p_49822_.setDeltaMovement(p_49822_.getDeltaMovement().multiply(1.0, 0.0, 1.0)); + p_49822_.setDeltaMovement(p_49822_.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D)); } @@ -108,7 +123,7 @@ public ItemStack getCloneItemStack(LevelReader p_304395_, BlockPos p_49824_, BlockState p_49825_) { return new ItemStack(this); } -@@ -420,6 +_,7 @@ +@@ -410,6 +_,7 @@ public void handlePrecipitation(BlockState p_152450_, Level p_152451_, BlockPos p_152452_, Biome.Precipitation p_152453_) { } @@ -116,7 +131,7 @@ public boolean dropFromExplosion(Explosion p_49826_) { return true; } -@@ -485,6 +_,43 @@ +@@ -475,6 +_,35 @@ return this.stateDefinition.getPossibleStates().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), p_152459_)); } @@ -148,14 +163,6 @@ + return drops; + } + -+ /** -+ * Neo: Allowing mods to define client behavior for their Blocks -+ * @deprecated Use {@link net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent} instead -+ */ -+ @Deprecated(forRemoval = true, since = "1.21") -+ public void initializeClient(java.util.function.Consumer consumer) { -+ } -+ + /** @deprecated */ @Deprecated public Holder.Reference builtInRegistryHolder() { diff --git a/patches/net/minecraft/world/level/block/Blocks.java.patch b/patches/net/minecraft/world/level/block/Blocks.java.patch index 2985e101f2..c9befa089f 100644 --- a/patches/net/minecraft/world/level/block/Blocks.java.patch +++ b/patches/net/minecraft/world/level/block/Blocks.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/Blocks.java +++ b/net/minecraft/world/level/block/Blocks.java -@@ -754,7 +_,7 @@ - public static final Block RED_BED = register("red_bed", bed(DyeColor.RED)); - public static final Block BLACK_BED = register("black_bed", bed(DyeColor.BLACK)); +@@ -690,7 +_,7 @@ + public static final Block RED_BED = registerBed("red_bed", DyeColor.RED); + public static final Block BLACK_BED = registerBed("black_bed", DyeColor.BLACK); public static final Block POWERED_RAIL = register( -- "powered_rail", new PoweredRailBlock(BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL)) -+ "powered_rail", new PoweredRailBlock(BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL), true) +- "powered_rail", PoweredRailBlock::new, BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) ++ "powered_rail", p_55218_ -> new PoweredRailBlock(p_55218_, true), BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) ); public static final Block DETECTOR_RAIL = register( - "detector_rail", new DetectorRailBlock(BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL)) -@@ -7806,7 +_,8 @@ + "detector_rail", DetectorRailBlock::new, BlockBehaviour.Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL) +@@ -6919,7 +_,8 @@ static { for (Block block : BuiltInRegistries.BLOCK) { for (BlockState blockstate : block.getStateDefinition().getPossibleStates()) { @@ -18,4 +18,4 @@ + //Block.BLOCK_STATE_REGISTRY.add(blockstate); blockstate.initCache(); } - + } diff --git a/patches/net/minecraft/world/level/block/BubbleColumnBlock.java.patch b/patches/net/minecraft/world/level/block/BubbleColumnBlock.java.patch index 526c55e206..37842d4270 100644 --- a/patches/net/minecraft/world/level/block/BubbleColumnBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BubbleColumnBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BubbleColumnBlock.java +++ b/net/minecraft/world/level/block/BubbleColumnBlock.java -@@ -121,10 +_,12 @@ +@@ -122,10 +_,12 @@ private static BlockState getColumnState(BlockState p_152718_) { if (p_152718_.is(Blocks.BUBBLE_COLUMN)) { return p_152718_; @@ -15,7 +15,7 @@ ? Blocks.BUBBLE_COLUMN.defaultBlockState().setValue(DRAG_DOWN, Boolean.valueOf(true)) : Blocks.WATER.defaultBlockState(); } -@@ -190,7 +_,7 @@ +@@ -200,7 +_,7 @@ @Override protected boolean canSurvive(BlockState p_50986_, LevelReader p_50987_, BlockPos p_50988_) { BlockState blockstate = p_50987_.getBlockState(p_50988_.below()); diff --git a/patches/net/minecraft/world/level/block/BushBlock.java.patch b/patches/net/minecraft/world/level/block/BushBlock.java.patch index e1321e5049..1a33073847 100644 --- a/patches/net/minecraft/world/level/block/BushBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BushBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BushBlock.java +++ b/net/minecraft/world/level/block/BushBlock.java -@@ -20,7 +_,7 @@ +@@ -21,7 +_,7 @@ protected abstract MapCodec codec(); protected boolean mayPlaceOn(BlockState p_51042_, BlockGetter p_51043_, BlockPos p_51044_) { @@ -9,7 +9,7 @@ } @Override -@@ -33,7 +_,10 @@ +@@ -43,7 +_,10 @@ @Override protected boolean canSurvive(BlockState p_51028_, LevelReader p_51029_, BlockPos p_51030_) { BlockPos blockpos = p_51030_.below(); diff --git a/patches/net/minecraft/world/level/block/CactusBlock.java.patch b/patches/net/minecraft/world/level/block/CactusBlock.java.patch index 037a99fb7c..c4a87b6942 100644 --- a/patches/net/minecraft/world/level/block/CactusBlock.java.patch +++ b/patches/net/minecraft/world/level/block/CactusBlock.java.patch @@ -25,7 +25,7 @@ } } } -@@ -99,6 +_,8 @@ +@@ -108,6 +_,8 @@ } BlockState blockstate1 = p_51154_.getBlockState(p_51155_.below()); diff --git a/patches/net/minecraft/world/level/block/CampfireBlock.java.patch b/patches/net/minecraft/world/level/block/CampfireBlock.java.patch index e81ecca378..927f77d8db 100644 --- a/patches/net/minecraft/world/level/block/CampfireBlock.java.patch +++ b/patches/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CampfireBlock.java +++ b/net/minecraft/world/level/block/CampfireBlock.java -@@ -279,7 +_,7 @@ +@@ -292,7 +_,7 @@ return true; } diff --git a/patches/net/minecraft/world/level/block/ChestBlock.java.patch b/patches/net/minecraft/world/level/block/ChestBlock.java.patch index 99655a4e31..47e4ad187d 100644 --- a/patches/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/patches/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 -@@ -357,7 +_,8 @@ +@@ -365,7 +_,8 @@ @Override protected BlockState mirror(BlockState p_51549_, Mirror p_51550_) { diff --git a/patches/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch b/patches/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch index 7f01cbf363..c9fd63af62 100644 --- a/patches/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/ChorusFlowerBlock.java +++ b/net/minecraft/world/level/block/ChorusFlowerBlock.java -@@ -65,10 +_,13 @@ +@@ -66,10 +_,13 @@ BlockPos blockpos = p_220982_.above(); - if (p_220981_.isEmptyBlock(blockpos) && blockpos.getY() < p_220981_.getMaxBuildHeight()) { + if (p_220981_.isEmptyBlock(blockpos) && blockpos.getY() <= p_220981_.getMaxY()) { int i = p_220980_.getValue(AGE); - if (i < 5) { + if (i < 5 && net.neoforged.neoforge.common.CommonHooks.canCropGrow(p_220981_, blockpos, p_220980_, true)) { @@ -15,7 +15,7 @@ if (blockstate.is(Blocks.END_STONE)) { flag = true; } else if (blockstate.is(this.plant)) { -@@ -77,6 +_,8 @@ +@@ -78,6 +_,8 @@ for (int k = 0; k < 4; k++) { BlockState blockstate1 = p_220981_.getBlockState(p_220982_.below(j + 1)); if (!blockstate1.is(this.plant)) { @@ -24,7 +24,7 @@ if (blockstate1.is(Blocks.END_STONE)) { flag1 = true; } -@@ -123,6 +_,7 @@ +@@ -124,6 +_,7 @@ } else { this.placeDeadFlower(p_220981_, p_220982_); } @@ -32,7 +32,7 @@ } } } -@@ -159,6 +_,8 @@ +@@ -169,6 +_,8 @@ @Override protected boolean canSurvive(BlockState p_51683_, LevelReader p_51684_, BlockPos p_51685_) { BlockState blockstate = p_51684_.getBlockState(p_51685_.below()); diff --git a/patches/net/minecraft/world/level/block/ChorusPlantBlock.java.patch b/patches/net/minecraft/world/level/block/ChorusPlantBlock.java.patch index d01ed837a2..5c9b256f04 100644 --- a/patches/net/minecraft/world/level/block/ChorusPlantBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ChorusPlantBlock.java.patch @@ -10,12 +10,12 @@ .trySetValue(UP, Boolean.valueOf(blockstate1.is(block) || blockstate1.is(Blocks.CHORUS_FLOWER))) .trySetValue(NORTH, Boolean.valueOf(blockstate2.is(block) || blockstate2.is(Blocks.CHORUS_FLOWER))) .trySetValue(EAST, Boolean.valueOf(blockstate3.is(block) || blockstate3.is(Blocks.CHORUS_FLOWER))) -@@ -64,6 +_,12 @@ - return super.updateShape(p_51728_, p_51729_, p_51730_, p_51731_, p_51732_, p_51733_); +@@ -73,6 +_,12 @@ + return super.updateShape(p_51728_, p_374320_, p_374500_, p_51732_, p_51729_, p_51733_, p_51730_, p_374170_); } else { boolean flag = p_51730_.is(this) || p_51730_.is(Blocks.CHORUS_FLOWER) || p_51729_ == Direction.DOWN && p_51730_.is(Blocks.END_STONE); + if (p_51729_ == Direction.DOWN) { -+ net.neoforged.neoforge.common.util.TriState soilDecision = p_51730_.canSustainPlant(p_51731_, p_51733_.relative(p_51729_), p_51729_.getOpposite(), p_51728_); ++ net.neoforged.neoforge.common.util.TriState soilDecision = p_51730_.canSustainPlant(p_374320_, p_51733_.relative(p_51729_), p_51729_.getOpposite(), p_51728_); + if (!soilDecision.isDefault()) { + flag = soilDecision.isTrue(); + } @@ -23,7 +23,7 @@ return p_51728_.setValue(PROPERTY_BY_DIRECTION.get(p_51729_), Boolean.valueOf(flag)); } } -@@ -95,6 +_,8 @@ +@@ -104,6 +_,8 @@ } } diff --git a/patches/net/minecraft/world/level/block/ComparatorBlock.java.patch b/patches/net/minecraft/world/level/block/ComparatorBlock.java.patch index c8fc89171c..82dbe7feb6 100644 --- a/patches/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ComparatorBlock.java +++ b/net/minecraft/world/level/block/ComparatorBlock.java -@@ -199,4 +_,16 @@ +@@ -207,4 +_,17 @@ protected void createBlockStateDefinition(StateDefinition.Builder p_51887_) { p_51887_.add(FACING, MODE, POWERED); } @@ -11,9 +11,10 @@ + } + + @Override -+ public void onNeighborChange(BlockState state, net.minecraft.world.level.LevelReader world, BlockPos pos, BlockPos neighbor) { -+ if (pos.getY() == neighbor.getY() && world instanceof Level && !((Level)world).isClientSide()) { -+ state.handleNeighborChanged((Level)world, pos, world.getBlockState(neighbor).getBlock(), neighbor, false); ++ public void onNeighborChange(BlockState state, net.minecraft.world.level.LevelReader levelReader, BlockPos pos, BlockPos neighbor) { ++ if (pos.getY() == neighbor.getY() && levelReader instanceof Level level && !levelReader.isClientSide()) { ++ // TODO porting: check this still works as expected ++ state.handleNeighborChanged(level, pos, levelReader.getBlockState(neighbor).getBlock(), null, false); + } + } } diff --git a/patches/net/minecraft/world/level/block/ComposterBlock.java.patch b/patches/net/minecraft/world/level/block/ComposterBlock.java.patch index 9a3dc8180a..5d1d96dda8 100644 --- a/patches/net/minecraft/world/level/block/ComposterBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ComposterBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ComposterBlock.java +++ b/net/minecraft/world/level/block/ComposterBlock.java -@@ -48,6 +_,8 @@ +@@ -47,6 +_,8 @@ public static final int MIN_LEVEL = 0; public static final int MAX_LEVEL = 7; public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL_COMPOSTER; @@ -9,7 +9,7 @@ public static final Object2FloatMap COMPOSTABLES = new Object2FloatOpenHashMap<>(); private static final int AABB_SIDE_THICKNESS = 2; private static final VoxelShape OUTER_SHAPE = Shapes.block(); -@@ -227,6 +_,15 @@ +@@ -231,6 +_,15 @@ if (p_51978_.getValue(LEVEL) == 7) { p_51979_.scheduleTick(p_51980_, p_51978_.getBlock(), 20); } @@ -25,7 +25,7 @@ } @Override -@@ -234,7 +_,7 @@ +@@ -238,7 +_,7 @@ ItemStack p_316332_, BlockState p_316118_, Level p_316624_, BlockPos p_316660_, Player p_316715_, InteractionHand p_316472_, BlockHitResult p_316606_ ) { int i = p_316118_.getValue(LEVEL); @@ -34,7 +34,7 @@ if (i < 7 && !p_316624_.isClientSide) { BlockState blockstate = addItem(p_316715_, p_316118_, p_316624_, p_316660_, p_316332_); p_316624_.levelEvent(1500, p_316660_, p_316118_ != blockstate ? 1 : 0); -@@ -261,7 +_,7 @@ +@@ -265,7 +_,7 @@ public static BlockState insertItem(Entity p_270919_, BlockState p_270087_, ServerLevel p_270284_, ItemStack p_270253_, BlockPos p_270678_) { int i = p_270087_.getValue(LEVEL); @@ -43,7 +43,7 @@ BlockState blockstate = addItem(p_270919_, p_270087_, p_270284_, p_270678_, p_270253_); p_270253_.shrink(1); return blockstate; -@@ -292,7 +_,7 @@ +@@ -296,7 +_,7 @@ static BlockState addItem(@Nullable Entity p_270464_, BlockState p_270603_, LevelAccessor p_270151_, BlockPos p_270547_, ItemStack p_270354_) { int i = p_270603_.getValue(LEVEL); @@ -52,7 +52,7 @@ if ((i != 0 || !(f > 0.0F)) && !(p_270151_.getRandom().nextDouble() < (double)f)) { return p_270603_; } else { -@@ -392,7 +_,7 @@ +@@ -396,7 +_,7 @@ @Override public boolean canPlaceItemThroughFace(int p_52028_, ItemStack p_52029_, @Nullable Direction p_52030_) { @@ -61,7 +61,7 @@ } @Override -@@ -450,5 +_,11 @@ +@@ -454,5 +_,11 @@ ComposterBlock.empty(null, this.state, this.level, this.pos); this.changed = true; } diff --git a/patches/net/minecraft/world/level/block/ConcretePowderBlock.java.patch b/patches/net/minecraft/world/level/block/ConcretePowderBlock.java.patch index 30355c0220..9254fe666b 100644 --- a/patches/net/minecraft/world/level/block/ConcretePowderBlock.java.patch +++ b/patches/net/minecraft/world/level/block/ConcretePowderBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ConcretePowderBlock.java +++ b/net/minecraft/world/level/block/ConcretePowderBlock.java -@@ -34,7 +_,7 @@ +@@ -36,7 +_,7 @@ @Override public void onLand(Level p_52068_, BlockPos p_52069_, BlockState p_52070_, BlockState p_52071_, FallingBlockEntity p_52072_) { @@ -9,7 +9,7 @@ p_52068_.setBlock(p_52069_, this.concrete.defaultBlockState(), 3); } } -@@ -47,20 +_,24 @@ +@@ -49,20 +_,24 @@ return shouldSolidify(blockgetter, blockpos, blockstate) ? this.concrete.defaultBlockState() : super.getStateForPlacement(p_52063_); } @@ -38,12 +38,12 @@ flag = true; break; } -@@ -76,7 +_,7 @@ - - @Override - protected BlockState updateShape(BlockState p_52074_, Direction p_52075_, BlockState p_52076_, LevelAccessor p_52077_, BlockPos p_52078_, BlockPos p_52079_) { -- return touchesLiquid(p_52077_, p_52078_) -+ return touchesLiquid(p_52077_, p_52078_, p_52074_) +@@ -87,7 +_,7 @@ + BlockState p_52076_, + RandomSource p_374119_ + ) { +- return touchesLiquid(p_374245_, p_52078_) ++ return touchesLiquid(p_374245_, p_52078_, p_52074_) ? this.concrete.defaultBlockState() - : super.updateShape(p_52074_, p_52075_, p_52076_, p_52077_, p_52078_, p_52079_); + : super.updateShape(p_52074_, p_374245_, p_374286_, p_52078_, p_52075_, p_52079_, p_52076_, p_374119_); } diff --git a/patches/net/minecraft/world/level/block/CoralBlock.java.patch b/patches/net/minecraft/world/level/block/CoralBlock.java.patch index 5a1ed63e3c..ea6a1bed14 100644 --- a/patches/net/minecraft/world/level/block/CoralBlock.java.patch +++ b/patches/net/minecraft/world/level/block/CoralBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CoralBlock.java +++ b/net/minecraft/world/level/block/CoralBlock.java -@@ -51,9 +_,10 @@ +@@ -61,9 +_,10 @@ } protected boolean scanForWater(BlockGetter p_52135_, BlockPos p_52136_) { diff --git a/patches/net/minecraft/world/level/block/CrafterBlock.java.patch b/patches/net/minecraft/world/level/block/CrafterBlock.java.patch index ac39be323e..a80e470efc 100644 --- a/patches/net/minecraft/world/level/block/CrafterBlock.java.patch +++ b/patches/net/minecraft/world/level/block/CrafterBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java -@@ -221,6 +_,8 @@ +@@ -214,6 +_,8 @@ break; } } diff --git a/patches/net/minecraft/world/level/block/CropBlock.java.patch b/patches/net/minecraft/world/level/block/CropBlock.java.patch index e00cad5006..f947ffdb3e 100644 --- a/patches/net/minecraft/world/level/block/CropBlock.java.patch +++ b/patches/net/minecraft/world/level/block/CropBlock.java.patch @@ -62,8 +62,8 @@ @Override protected void entityInside(BlockState p_52277_, Level p_52278_, BlockPos p_52279_, Entity p_52280_) { -- if (p_52280_ instanceof Ravager && p_52278_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (p_52280_ instanceof Ravager && net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_52278_, p_52280_)) { - p_52278_.destroyBlock(p_52279_, true, p_52280_); +- if (p_52278_ instanceof ServerLevel serverlevel && p_52280_ instanceof Ravager && serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (p_52278_ instanceof ServerLevel serverlevel && p_52280_ instanceof Ravager && net.neoforged.neoforge.event.EventHooks.canEntityGrief(serverlevel, p_52280_)) { + serverlevel.destroyBlock(p_52279_, true, p_52280_); } diff --git a/patches/net/minecraft/world/level/block/DetectorRailBlock.java.patch b/patches/net/minecraft/world/level/block/DetectorRailBlock.java.patch index bccb363636..37e404542d 100644 --- a/patches/net/minecraft/world/level/block/DetectorRailBlock.java.patch +++ b/patches/net/minecraft/world/level/block/DetectorRailBlock.java.patch @@ -11,19 +11,6 @@ this.registerDefaultState( this.stateDefinition .any() -@@ -152,9 +_,9 @@ - return list.get(0).getCommandBlock().getSuccessCount(); - } - -- List list1 = this.getInteractingMinecartOfType( -- p_52455_, p_52456_, AbstractMinecart.class, EntitySelector.CONTAINER_ENTITY_SELECTOR -- ); -+ List carts = this.getInteractingMinecartOfType(p_52455_, p_52456_, AbstractMinecart.class, e -> e.isAlive()); -+ if (!carts.isEmpty() && carts.get(0).getComparatorLevel() > -1) return carts.get(0).getComparatorLevel(); -+ List list1 = carts.stream().filter(EntitySelector.CONTAINER_ENTITY_SELECTOR).collect(java.util.stream.Collectors.toList()); - if (!list1.isEmpty()) { - return AbstractContainerMenu.getRedstoneSignalFromContainer((Container)list1.get(0)); - } @@ -299,6 +_,6 @@ @Override diff --git a/patches/net/minecraft/world/level/block/DiodeBlock.java.patch b/patches/net/minecraft/world/level/block/DiodeBlock.java.patch index 13cfbf4a01..50271b6536 100644 --- a/patches/net/minecraft/world/level/block/DiodeBlock.java.patch +++ b/patches/net/minecraft/world/level/block/DiodeBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/DiodeBlock.java +++ b/net/minecraft/world/level/block/DiodeBlock.java -@@ -173,6 +_,8 @@ +@@ -176,6 +_,8 @@ protected void updateNeighborsInFront(Level p_52581_, BlockPos p_52582_, BlockState p_52583_) { Direction direction = p_52583_.getValue(FACING); BlockPos blockpos = p_52582_.relative(direction.getOpposite()); + if (net.neoforged.neoforge.event.EventHooks.onNeighborNotify(p_52581_, p_52582_, p_52581_.getBlockState(p_52582_), java.util.EnumSet.of(direction.getOpposite()), false).isCanceled()) + return; - p_52581_.neighborChanged(blockpos, this, p_52582_); - p_52581_.updateNeighborsAtExceptFromFacing(blockpos, this, direction); - } + Orientation orientation = ExperimentalRedstoneUtils.initialOrientation(p_52581_, direction.getOpposite(), Direction.UP); + p_52581_.neighborChanged(blockpos, this, orientation); + p_52581_.updateNeighborsAtExceptFromFacing(blockpos, this, direction, orientation); diff --git a/patches/net/minecraft/world/level/block/DoorBlock.java.patch b/patches/net/minecraft/world/level/block/DoorBlock.java.patch index 2c444805ae..bd91c16f2d 100644 --- a/patches/net/minecraft/world/level/block/DoorBlock.java.patch +++ b/patches/net/minecraft/world/level/block/DoorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoorBlock.java +++ b/net/minecraft/world/level/block/DoorBlock.java -@@ -119,7 +_,7 @@ +@@ -132,7 +_,7 @@ @Override public BlockState playerWillDestroy(Level p_52755_, BlockPos p_52756_, BlockState p_52757_, Player p_52758_) { diff --git a/patches/net/minecraft/world/level/block/DoublePlantBlock.java.patch b/patches/net/minecraft/world/level/block/DoublePlantBlock.java.patch index edfa73df39..b9261ddcd8 100644 --- a/patches/net/minecraft/world/level/block/DoublePlantBlock.java.patch +++ b/patches/net/minecraft/world/level/block/DoublePlantBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoublePlantBlock.java +++ b/net/minecraft/world/level/block/DoublePlantBlock.java -@@ -71,6 +_,7 @@ +@@ -80,6 +_,7 @@ return super.canSurvive(p_52887_, p_52888_, p_52889_); } else { BlockState blockstate = p_52888_.getBlockState(p_52889_.below()); diff --git a/patches/net/minecraft/world/level/block/FarmBlock.java.patch b/patches/net/minecraft/world/level/block/FarmBlock.java.patch index 7b5c19bf38..72f3a0e03e 100644 --- a/patches/net/minecraft/world/level/block/FarmBlock.java.patch +++ b/patches/net/minecraft/world/level/block/FarmBlock.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/level/block/FarmBlock.java +++ b/net/minecraft/world/level/block/FarmBlock.java -@@ -100,10 +_,7 @@ +@@ -109,10 +_,7 @@ @Override public void fallOn(Level p_153227_, BlockState p_153228_, BlockPos p_153229_, Entity p_153230_, float p_153231_) { - if (!p_153227_.isClientSide + if (p_153227_ instanceof ServerLevel serverlevel - && p_153227_.random.nextFloat() < p_153231_ - 0.5F - && p_153230_ instanceof LivingEntity -- && (p_153230_ instanceof Player || p_153227_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) +- && (p_153230_ instanceof Player || serverlevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) - && p_153230_.getBbWidth() * p_153230_.getBbWidth() * p_153230_.getBbHeight() > 0.512F) { -+ && net.neoforged.neoforge.common.CommonHooks.onFarmlandTrample(p_153227_, p_153229_, Blocks.DIRT.defaultBlockState(), p_153231_, p_153230_)) { // Forge: Move logic to Entity#canTrample ++ && net.neoforged.neoforge.common.CommonHooks.onFarmlandTrample(serverlevel, p_153229_, Blocks.DIRT.defaultBlockState(), p_153231_, p_153230_)) { // Forge: Move logic to Entity#canTrample turnToDirt(p_153230_, p_153228_, p_153227_, p_153229_); } -@@ -121,13 +_,14 @@ +@@ -130,13 +_,14 @@ } private static boolean isNearWater(LevelReader p_53259_, BlockPos p_53260_) { diff --git a/patches/net/minecraft/world/level/block/FenceGateBlock.java.patch b/patches/net/minecraft/world/level/block/FenceGateBlock.java.patch index e31aaf5e23..042b0ecf8c 100644 --- a/patches/net/minecraft/world/level/block/FenceGateBlock.java.patch +++ b/patches/net/minecraft/world/level/block/FenceGateBlock.java.patch @@ -1,17 +1,19 @@ --- a/net/minecraft/world/level/block/FenceGateBlock.java +++ b/net/minecraft/world/level/block/FenceGateBlock.java -@@ -31,7 +_,9 @@ +@@ -36,8 +_,10 @@ public class FenceGateBlock extends HorizontalDirectionalBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( -- p_308823_ -> p_308823_.group(WoodType.CODEC.fieldOf("wood_type").forGetter(p_304842_ -> p_304842_.type), propertiesCodec()) +- p_368422_ -> p_368422_.group(WoodType.CODEC.fieldOf("wood_type").forGetter(p_304842_ -> p_304842_.type), propertiesCodec()) +- .apply(p_368422_, FenceGateBlock::new) + p_308823_ -> p_308823_.group(WoodType.CODEC.optionalFieldOf("wood_type").forGetter(p_304842_ -> java.util.Optional.ofNullable(p_304842_.type)), propertiesCodec(), + net.minecraft.sounds.SoundEvent.DIRECT_CODEC.optionalFieldOf("open_sound").forGetter(fence -> java.util.Optional.of(fence.openSound).filter(s -> fence.type == null || s != fence.type.fenceGateOpen())), + net.minecraft.sounds.SoundEvent.DIRECT_CODEC.optionalFieldOf("close_sound").forGetter(fence -> java.util.Optional.of(fence.closeSound).filter(s -> fence.type == null || s != fence.type.fenceGateClose()))) - .apply(p_308823_, FenceGateBlock::new) ++ .apply(p_308823_, FenceGateBlock::new) ); public static final BooleanProperty OPEN = BlockStateProperties.OPEN; -@@ -49,6 +_,8 @@ + public static final BooleanProperty POWERED = BlockStateProperties.POWERED; +@@ -54,6 +_,8 @@ protected static final VoxelShape X_OCCLUSION_SHAPE = Shapes.or(Block.box(7.0, 5.0, 0.0, 9.0, 16.0, 2.0), Block.box(7.0, 5.0, 14.0, 9.0, 16.0, 16.0)); protected static final VoxelShape Z_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(0.0, 2.0, 7.0, 2.0, 13.0, 9.0), Block.box(14.0, 2.0, 7.0, 16.0, 13.0, 9.0)); protected static final VoxelShape X_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(7.0, 2.0, 0.0, 9.0, 13.0, 2.0), Block.box(7.0, 2.0, 14.0, 9.0, 13.0, 16.0)); @@ -20,7 +22,7 @@ private final WoodType type; @Override -@@ -57,8 +_,17 @@ +@@ -62,8 +_,17 @@ } public FenceGateBlock(WoodType p_273340_, BlockBehaviour.Properties p_273352_) { @@ -40,7 +42,7 @@ this.registerDefaultState( this.stateDefinition .any() -@@ -169,7 +_,7 @@ +@@ -183,7 +_,7 @@ p_53366_.playSound( p_53368_, p_53367_, @@ -49,16 +51,16 @@ SoundSource.BLOCKS, 1.0F, p_53366_.getRandom().nextFloat() * 0.1F + 0.9F -@@ -186,7 +_,7 @@ - p_311813_.playSound( +@@ -202,7 +_,7 @@ + p_361116_.playSound( null, p_312680_, - flag ? this.type.fenceGateClose() : this.type.fenceGateOpen(), + flag ? closeSound : openSound, SoundSource.BLOCKS, 1.0F, - p_311813_.getRandom().nextFloat() * 0.1F + 0.9F -@@ -207,7 +_,7 @@ + p_361116_.getRandom().nextFloat() * 0.1F + 0.9F +@@ -223,7 +_,7 @@ p_53373_.playSound( null, p_53374_, diff --git a/patches/net/minecraft/world/level/block/FireBlock.java.patch b/patches/net/minecraft/world/level/block/FireBlock.java.patch index 0e6d1d834e..1b005e4d03 100644 --- a/patches/net/minecraft/world/level/block/FireBlock.java.patch +++ b/patches/net/minecraft/world/level/block/FireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FireBlock.java +++ b/net/minecraft/world/level/block/FireBlock.java -@@ -132,13 +_,13 @@ +@@ -141,13 +_,13 @@ protected BlockState getStateForPlacement(BlockGetter p_53471_, BlockPos p_53472_) { BlockPos blockpos = p_53472_.below(); BlockState blockstate = p_53471_.getBlockState(blockpos); @@ -16,7 +16,7 @@ } } -@@ -163,7 +_,7 @@ +@@ -172,7 +_,7 @@ } BlockState blockstate = p_221161_.getBlockState(p_221162_.below()); @@ -25,7 +25,7 @@ int i = p_221160_.getValue(AGE); if (!flag && p_221161_.isRaining() && this.isNearRain(p_221161_, p_221162_) && p_221163_.nextFloat() < 0.2F + (float)i * 0.03F) { p_221161_.removeBlock(p_221162_, false); -@@ -184,7 +_,7 @@ +@@ -193,7 +_,7 @@ return; } @@ -34,7 +34,7 @@ p_221161_.removeBlock(p_221162_, false); return; } -@@ -192,12 +_,12 @@ +@@ -201,12 +_,12 @@ boolean flag1 = p_221161_.getBiome(p_221162_).is(BiomeTags.INCREASED_FIRE_BURNOUT); int k = flag1 ? -50 : 0; @@ -53,7 +53,7 @@ BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int l = -1; l <= 1; l++) { -@@ -240,33 +_,32 @@ +@@ -249,33 +_,32 @@ || p_53429_.isRainingAt(p_53430_.south()); } @@ -93,7 +93,7 @@ } } -@@ -277,7 +_,7 @@ +@@ -286,7 +_,7 @@ private boolean isValidFireLocation(BlockGetter p_53486_, BlockPos p_53487_) { for (Direction direction : Direction.values()) { @@ -102,7 +102,7 @@ return true; } } -@@ -293,7 +_,7 @@ +@@ -302,7 +_,7 @@ for (Direction direction : Direction.values()) { BlockState blockstate = p_221157_.getBlockState(p_221158_.relative(direction)); @@ -111,7 +111,7 @@ } return i; -@@ -301,6 +_,7 @@ +@@ -310,6 +_,7 @@ } @Override @@ -119,7 +119,7 @@ protected boolean canBurn(BlockState p_53489_) { return this.getIgniteOdds(p_53489_) > 0; } -@@ -321,8 +_,21 @@ +@@ -330,8 +_,21 @@ } public void setFlammable(Block p_53445_, int p_53446_, int p_53447_) { diff --git a/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch index e2a75a86fe..ce68c441bd 100644 --- a/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -59,9 +59,9 @@ - p_316655_.setBlock(p_316654_, Blocks.FLOWER_POT.defaultBlockState(), 3); + p_316655_.setBlock(p_316654_, getEmptyPot().defaultBlockState(), 3); p_316655_.gameEvent(p_316338_, GameEvent.BLOCK_CHANGE, p_316654_); - return InteractionResult.sidedSuccess(p_316655_.isClientSide); + return InteractionResult.SUCCESS; } -@@ -107,11 +_,44 @@ +@@ -116,11 +_,44 @@ } public Block getPotted() { diff --git a/patches/net/minecraft/world/level/block/LeavesBlock.java.patch b/patches/net/minecraft/world/level/block/LeavesBlock.java.patch index b086bca9d6..7807a016b1 100644 --- a/patches/net/minecraft/world/level/block/LeavesBlock.java.patch +++ b/patches/net/minecraft/world/level/block/LeavesBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LeavesBlock.java +++ b/net/minecraft/world/level/block/LeavesBlock.java -@@ -24,7 +_,7 @@ +@@ -26,7 +_,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; diff --git a/patches/net/minecraft/world/level/block/LiquidBlock.java.patch b/patches/net/minecraft/world/level/block/LiquidBlock.java.patch index bc1dea4969..5d6aea4b75 100644 --- a/patches/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/patches/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java -@@ -134,7 +_,7 @@ +@@ -137,7 +_,7 @@ @Override protected void onPlace(BlockState p_54754_, Level p_54755_, BlockPos p_54756_, BlockState p_54757_, boolean p_54758_) { @@ -9,10 +9,10 @@ p_54755_.scheduleTick(p_54756_, p_54754_.getFluidState().getType(), this.fluid.getTickDelay(p_54755_)); } } -@@ -150,11 +_,12 @@ +@@ -162,11 +_,12 @@ @Override - protected void neighborChanged(BlockState p_54709_, Level p_54710_, BlockPos p_54711_, Block p_54712_, BlockPos p_54713_, boolean p_54714_) { + protected void neighborChanged(BlockState p_54709_, Level p_54710_, BlockPos p_54711_, Block p_54712_, @Nullable Orientation p_361226_, boolean p_54714_) { - if (this.shouldSpreadLiquid(p_54710_, p_54711_, p_54709_)) { + if (!net.neoforged.neoforge.fluids.FluidInteractionRegistry.canInteract(p_54710_, p_54711_)) { p_54710_.scheduleTick(p_54711_, p_54709_.getFluidState().getType(), this.fluid.getTickDelay(p_54710_)); diff --git a/patches/net/minecraft/world/level/block/MushroomBlock.java.patch b/patches/net/minecraft/world/level/block/MushroomBlock.java.patch index a977b18527..6283cb275b 100644 --- a/patches/net/minecraft/world/level/block/MushroomBlock.java.patch +++ b/patches/net/minecraft/world/level/block/MushroomBlock.java.patch @@ -13,8 +13,8 @@ public boolean growMushroom(ServerLevel p_221774_, BlockPos p_221775_, BlockState p_221776_, RandomSource p_221777_) { Optional>> optional = p_221774_.registryAccess() - .registryOrThrow(Registries.CONFIGURED_FEATURE) - .getHolder(this.feature); + .lookupOrThrow(Registries.CONFIGURED_FEATURE) + .get(this.feature); + + // Neo: Fire the BlockGrowFeatureEvent and update the result of the Optional local with the new feature. + var event = net.neoforged.neoforge.event.EventHooks.fireBlockGrowFeature(p_221774_, p_221777_, p_221775_, optional.orElse(null)); diff --git a/patches/net/minecraft/world/level/block/NoteBlock.java.patch b/patches/net/minecraft/world/level/block/NoteBlock.java.patch index 5c0e59dbd2..9c9392dbcd 100644 --- a/patches/net/minecraft/world/level/block/NoteBlock.java.patch +++ b/patches/net/minecraft/world/level/block/NoteBlock.java.patch @@ -1,17 +1,16 @@ --- a/net/minecraft/world/level/block/NoteBlock.java +++ b/net/minecraft/world/level/block/NoteBlock.java -@@ -110,7 +_,9 @@ - if (p_316774_.isClientSide) { - return InteractionResult.SUCCESS; - } else { -- p_316441_ = p_316441_.cycle(NOTE); +@@ -122,6 +_,9 @@ + protected InteractionResult useWithoutItem(BlockState p_316441_, Level p_316774_, BlockPos p_316344_, Player p_316884_, BlockHitResult p_316631_) { + if (!p_316774_.isClientSide) { + p_316441_ = p_316441_.cycle(NOTE); + int _new = net.neoforged.neoforge.common.CommonHooks.onNoteChange(p_316774_, p_316344_, p_316441_, p_316441_.getValue(NOTE), p_316441_.cycle(NOTE).getValue(NOTE)); + if (_new == -1) return InteractionResult.FAIL; + p_316441_ = p_316441_.setValue(NOTE, _new); p_316774_.setBlock(p_316344_, p_316441_, 3); this.playNote(p_316884_, p_316441_, p_316774_, p_316344_); p_316884_.awardStat(Stats.TUNE_NOTEBLOCK); -@@ -132,6 +_,9 @@ +@@ -144,6 +_,9 @@ @Override protected boolean triggerEvent(BlockState p_55023_, Level p_55024_, BlockPos p_55025_, int p_55026_, int p_55027_) { diff --git a/patches/net/minecraft/world/level/block/PitcherCropBlock.java.patch b/patches/net/minecraft/world/level/block/PitcherCropBlock.java.patch index b38b96d495..f3be3ce25c 100644 --- a/patches/net/minecraft/world/level/block/PitcherCropBlock.java.patch +++ b/patches/net/minecraft/world/level/block/PitcherCropBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PitcherCropBlock.java +++ b/net/minecraft/world/level/block/PitcherCropBlock.java -@@ -86,12 +_,13 @@ +@@ -93,12 +_,13 @@ @Override public boolean canSurvive(BlockState p_277671_, LevelReader p_277477_, BlockPos p_278085_) { @@ -16,7 +16,7 @@ } @Override -@@ -125,7 +_,7 @@ +@@ -132,7 +_,7 @@ @Override public void randomTick(BlockState p_277950_, ServerLevel p_277589_, BlockPos p_277937_, RandomSource p_277887_) { diff --git a/patches/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch b/patches/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch index 433f12e7c7..4ba64c1bd2 100644 --- a/patches/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch +++ b/patches/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java -@@ -184,7 +_,7 @@ +@@ -192,7 +_,7 @@ @VisibleForTesting public static void maybeTransferFluid(BlockState p_221860_, ServerLevel p_221861_, BlockPos p_221862_, float p_221863_) { @@ -9,7 +9,7 @@ if (isStalactiteStartPos(p_221860_, p_221861_, p_221862_)) { Optional optional = getFluidAboveStalactite(p_221861_, p_221862_, p_221860_); if (!optional.isEmpty()) { -@@ -193,14 +_,12 @@ +@@ -201,14 +_,12 @@ if (fluid == Fluids.WATER) { f = 0.17578125F; } else { @@ -26,7 +26,7 @@ BlockPos blockpos = findTip(p_221860_, p_221861_, p_221862_, 11, false); if (blockpos != null) { if (optional.get().sourceState.is(Blocks.MUD) && fluid == Fluids.WATER) { -@@ -411,7 +_,8 @@ +@@ -419,7 +_,8 @@ double d2 = (double)((float)(p_154073_.getY() + 1) - 0.6875F) - 0.0625; double d3 = (double)p_154073_.getZ() + 0.5 + vec3.z; Fluid fluid = getDripFluid(p_154072_, p_154075_); @@ -36,7 +36,7 @@ p_154072_.addParticle(particleoptions, d1, d2, d3, 0.0, 0.0, 0.0); } -@@ -563,7 +_,7 @@ +@@ -571,7 +_,7 @@ } private static boolean canFillCauldron(Fluid p_154159_) { diff --git a/patches/net/minecraft/world/level/block/PowderSnowBlock.java.patch b/patches/net/minecraft/world/level/block/PowderSnowBlock.java.patch index 29c7e6ca18..923d5b94e6 100644 --- a/patches/net/minecraft/world/level/block/PowderSnowBlock.java.patch +++ b/patches/net/minecraft/world/level/block/PowderSnowBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PowderSnowBlock.java +++ b/net/minecraft/world/level/block/PowderSnowBlock.java -@@ -130,7 +_,7 @@ +@@ -126,7 +_,7 @@ if (p_154256_.getType().is(EntityTypeTags.POWDER_SNOW_WALKABLE_MOBS)) { return true; } else { diff --git a/patches/net/minecraft/world/level/block/PoweredRailBlock.java.patch b/patches/net/minecraft/world/level/block/PoweredRailBlock.java.patch index 7e5da26de1..e0a519f676 100644 --- a/patches/net/minecraft/world/level/block/PoweredRailBlock.java.patch +++ b/patches/net/minecraft/world/level/block/PoweredRailBlock.java.patch @@ -25,7 +25,7 @@ int k = p_55221_.getZ(); boolean flag = true; - RailShape railshape = p_55222_.getValue(SHAPE); -+ RailShape railshape = p_55222_.getValue(getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)p_55222_.getBlock()).getRailDirection(p_55222_, p_55220_, p_55221_, null); switch (railshape) { case NORTH_SOUTH: if (p_55223_) { @@ -56,8 +56,8 @@ if (flag1 != flag) { p_55233_.setBlock(p_55234_, p_55232_.setValue(POWERED, Boolean.valueOf(flag1)), 3); p_55233_.updateNeighborsAt(p_55234_.below(), this); -- if (p_55232_.getValue(SHAPE).isAscending()) { -+ if (p_55232_.getValue(getShapeProperty()).isAscending()) { +- if (p_55232_.getValue(SHAPE).isSlope()) { ++ if (((BaseRailBlock)p_55232_.getBlock()).getRailDirection(p_55232_, p_55233_, p_55234_, null).isSlope()) { p_55233_.updateNeighborsAt(p_55234_.above(), this); } } diff --git a/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch b/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch index 64546ae9af..6c99c628ff 100644 --- a/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch +++ b/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/PumpkinBlock.java +++ b/net/minecraft/world/level/block/PumpkinBlock.java @@ -35,7 +_,7 @@ - protected ItemInteractionResult useItemOn( + protected InteractionResult useItemOn( ItemStack p_316383_, BlockState p_316676_, Level p_316272_, BlockPos p_316484_, Player p_316367_, InteractionHand p_316216_, BlockHitResult p_316827_ ) { - if (!p_316383_.is(Items.SHEARS)) { + if (!p_316383_.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHEARS_CARVE)) { return super.useItemOn(p_316383_, p_316676_, p_316272_, p_316484_, p_316367_, p_316216_, p_316827_); } else if (p_316272_.isClientSide) { - return ItemInteractionResult.sidedSuccess(p_316272_.isClientSide); + return InteractionResult.SUCCESS; diff --git a/patches/net/minecraft/world/level/block/RedStoneWireBlock.java.patch b/patches/net/minecraft/world/level/block/RedStoneWireBlock.java.patch index 79ce4b3f60..1e9a7cfceb 100644 --- a/patches/net/minecraft/world/level/block/RedStoneWireBlock.java.patch +++ b/patches/net/minecraft/world/level/block/RedStoneWireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -253,7 +_,7 @@ +@@ -268,7 +_,7 @@ BlockState blockstate = p_55523_.getBlockState(blockpos); if (p_55526_) { boolean flag = blockstate.getBlock() instanceof TrapDoorBlock || this.canSurviveOn(p_55523_, blockpos, blockstate); @@ -9,7 +9,7 @@ if (blockstate.isFaceSturdy(p_55523_, blockpos, p_55525_.getOpposite())) { return RedstoneSide.UP; } -@@ -262,10 +_,14 @@ +@@ -277,10 +_,14 @@ } } diff --git a/patches/net/minecraft/world/level/block/SculkSensorBlock.java.patch b/patches/net/minecraft/world/level/block/SculkSensorBlock.java.patch index 12f47c323f..5aee48d600 100644 --- a/patches/net/minecraft/world/level/block/SculkSensorBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SculkSensorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -291,8 +_,13 @@ +@@ -299,8 +_,13 @@ @Override protected void spawnAfterBreak(BlockState p_222142_, ServerLevel p_222143_, BlockPos p_222144_, ItemStack p_222145_, boolean p_222146_) { super.spawnAfterBreak(p_222142_, p_222143_, p_222144_, p_222145_, p_222146_); diff --git a/patches/net/minecraft/world/level/block/SculkShriekerBlock.java.patch b/patches/net/minecraft/world/level/block/SculkShriekerBlock.java.patch index 6f5dedbc34..646554aa30 100644 --- a/patches/net/minecraft/world/level/block/SculkShriekerBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SculkShriekerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkShriekerBlock.java +++ b/net/minecraft/world/level/block/SculkShriekerBlock.java -@@ -141,9 +_,14 @@ +@@ -149,9 +_,14 @@ @Override protected void spawnAfterBreak(BlockState p_222192_, ServerLevel p_222193_, BlockPos p_222194_, ItemStack p_222195_, boolean p_222196_) { super.spawnAfterBreak(p_222192_, p_222193_, p_222194_, p_222195_, p_222196_); diff --git a/patches/net/minecraft/world/level/block/SeagrassBlock.java.patch b/patches/net/minecraft/world/level/block/SeagrassBlock.java.patch index a3580320c7..f596a92bef 100644 --- a/patches/net/minecraft/world/level/block/SeagrassBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SeagrassBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SeagrassBlock.java +++ b/net/minecraft/world/level/block/SeagrassBlock.java -@@ -22,7 +_,7 @@ +@@ -23,7 +_,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; diff --git a/patches/net/minecraft/world/level/block/SoundType.java.patch b/patches/net/minecraft/world/level/block/SoundType.java.patch index 0d3a12b6cd..92c1ab63a3 100644 --- a/patches/net/minecraft/world/level/block/SoundType.java.patch +++ b/patches/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 -@@ -777,6 +_,7 @@ +@@ -789,6 +_,7 @@ private final SoundEvent hitSound; private final SoundEvent fallSound; diff --git a/patches/net/minecraft/world/level/block/SpongeBlock.java.patch b/patches/net/minecraft/world/level/block/SpongeBlock.java.patch index 69c47ae16d..ac00ddee76 100644 --- a/patches/net/minecraft/world/level/block/SpongeBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SpongeBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpongeBlock.java +++ b/net/minecraft/world/level/block/SpongeBlock.java -@@ -49,6 +_,7 @@ +@@ -51,6 +_,7 @@ } private boolean removeWaterBreadthFirstSearch(Level p_56808_, BlockPos p_56809_) { @@ -8,7 +8,7 @@ return BlockPos.breadthFirstTraversal( p_56809_, 6, -@@ -64,7 +_,7 @@ +@@ -66,7 +_,7 @@ } else { BlockState blockstate = p_56808_.getBlockState(p_294069_); FluidState fluidstate = p_56808_.getFluidState(p_294069_); diff --git a/patches/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch b/patches/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch index 2f24cf95b1..0c7f4162b8 100644 --- a/patches/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java +++ b/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java -@@ -42,8 +_,10 @@ +@@ -40,8 +_,10 @@ @Override protected void randomTick(BlockState p_222508_, ServerLevel p_222509_, BlockPos p_222510_, RandomSource p_222511_) { if (!canBeGrass(p_222508_, p_222509_, p_222510_)) { diff --git a/patches/net/minecraft/world/level/block/StemBlock.java.patch b/patches/net/minecraft/world/level/block/StemBlock.java.patch index 17d8f22e5b..f8d6468063 100644 --- a/patches/net/minecraft/world/level/block/StemBlock.java.patch +++ b/patches/net/minecraft/world/level/block/StemBlock.java.patch @@ -27,7 +27,7 @@ BlockState blockstate = p_222539_.getBlockState(blockpos.below()); - if (p_222539_.getBlockState(blockpos).isAir() && (blockstate.is(Blocks.FARMLAND) || blockstate.is(BlockTags.DIRT))) { + if (p_222539_.isEmptyBlock(blockpos) && (blockstate.getBlock() instanceof net.minecraft.world.level.block.FarmBlock || blockstate.is(BlockTags.DIRT))) { - Registry registry = p_222539_.registryAccess().registryOrThrow(Registries.BLOCK); + Registry registry = p_222539_.registryAccess().lookupOrThrow(Registries.BLOCK); Optional optional = registry.getOptional(this.fruit); Optional optional1 = registry.getOptional(this.attachedStem); @@ -100,6 +_,7 @@ diff --git a/patches/net/minecraft/world/level/block/SugarCaneBlock.java.patch b/patches/net/minecraft/world/level/block/SugarCaneBlock.java.patch index 55a9cd856c..dbf788792d 100644 --- a/patches/net/minecraft/world/level/block/SugarCaneBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SugarCaneBlock.java.patch @@ -16,7 +16,7 @@ } } } -@@ -83,13 +_,15 @@ +@@ -92,13 +_,15 @@ if (blockstate.is(this)) { return true; } else { diff --git a/patches/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch b/patches/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch index 934879d9b1..9abbbc3e05 100644 --- a/patches/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch +++ b/patches/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SweetBerryBushBlock.java +++ b/net/minecraft/world/level/block/SweetBerryBushBlock.java -@@ -69,9 +_,10 @@ +@@ -68,9 +_,10 @@ @Override protected void randomTick(BlockState p_222563_, ServerLevel p_222564_, BlockPos p_222565_, RandomSource p_222566_) { int i = p_222563_.getValue(AGE); diff --git a/patches/net/minecraft/world/level/block/TntBlock.java.patch b/patches/net/minecraft/world/level/block/TntBlock.java.patch index acf16ed6ab..eb50b4ce68 100644 --- a/patches/net/minecraft/world/level/block/TntBlock.java.patch +++ b/patches/net/minecraft/world/level/block/TntBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TntBlock.java +++ b/net/minecraft/world/level/block/TntBlock.java -@@ -41,10 +_,14 @@ +@@ -43,10 +_,14 @@ } @Override @@ -16,16 +16,16 @@ p_57467_.removeBlock(p_57468_, false); } } -@@ -53,7 +_,7 @@ +@@ -55,7 +_,7 @@ @Override - protected void neighborChanged(BlockState p_57457_, Level p_57458_, BlockPos p_57459_, Block p_57460_, BlockPos p_57461_, boolean p_57462_) { + protected void neighborChanged(BlockState p_57457_, Level p_57458_, BlockPos p_57459_, Block p_57460_, @Nullable Orientation p_364510_, boolean p_57462_) { if (p_57458_.hasNeighborSignal(p_57459_)) { - explode(p_57458_, p_57459_); + onCaughtFire(p_57457_, p_57458_, p_57459_, null, null); p_57458_.removeBlock(p_57459_, false); } } -@@ -61,7 +_,7 @@ +@@ -63,7 +_,7 @@ @Override public BlockState playerWillDestroy(Level p_57445_, BlockPos p_57446_, BlockState p_57447_, Player p_57448_) { if (!p_57445_.isClientSide() && !p_57448_.isCreative() && p_57447_.getValue(UNSTABLE)) { @@ -35,7 +35,7 @@ return super.playerWillDestroy(p_57445_, p_57446_, p_57447_, p_57448_); @@ -79,10 +_,12 @@ - } + p_364953_.addFreshEntity(primedtnt); } + @Deprecated //Forge: Prefer using IForgeBlock#catchFire @@ -59,7 +59,7 @@ @@ -119,7 +_,7 @@ BlockPos blockpos = p_57431_.getBlockPos(); Entity entity = p_57432_.getOwner(); - if (p_57432_.isOnFire() && p_57432_.mayInteract(p_57429_, blockpos)) { + if (p_57432_.isOnFire() && p_57432_.mayInteract(serverlevel, blockpos)) { - explode(p_57429_, blockpos, entity instanceof LivingEntity ? (LivingEntity)entity : null); + onCaughtFire(p_57430_, p_57429_, blockpos, null, entity instanceof LivingEntity ? (LivingEntity)entity : null); p_57429_.removeBlock(blockpos, false); diff --git a/patches/net/minecraft/world/level/block/TrapDoorBlock.java.patch b/patches/net/minecraft/world/level/block/TrapDoorBlock.java.patch index 6fb22ca4cb..3ebddb6f27 100644 --- a/patches/net/minecraft/world/level/block/TrapDoorBlock.java.patch +++ b/patches/net/minecraft/world/level/block/TrapDoorBlock.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/block/TrapDoorBlock.java +++ b/net/minecraft/world/level/block/TrapDoorBlock.java -@@ -200,6 +_,17 @@ - return super.updateShape(p_57554_, p_57555_, p_57556_, p_57557_, p_57558_, p_57559_); +@@ -215,6 +_,17 @@ + return super.updateShape(p_57554_, p_374386_, p_374038_, p_57558_, p_57555_, p_57559_, p_57556_, p_374093_); } + // Neo: Allows Trapdoors to be climbable if any ladder, even modded ladders, is below Trapdoor diff --git a/patches/net/minecraft/world/level/block/TripWireBlock.java.patch b/patches/net/minecraft/world/level/block/TripWireBlock.java.patch index 1d1fd55985..e1bdf7fc7c 100644 --- a/patches/net/minecraft/world/level/block/TripWireBlock.java.patch +++ b/patches/net/minecraft/world/level/block/TripWireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TripWireBlock.java +++ b/net/minecraft/world/level/block/TripWireBlock.java -@@ -104,7 +_,7 @@ +@@ -114,7 +_,7 @@ @Override public BlockState playerWillDestroy(Level p_57615_, BlockPos p_57616_, BlockState p_57617_, Player p_57618_) { diff --git a/patches/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/patches/net/minecraft/world/level/block/TripWireHookBlock.java.patch deleted file mode 100644 index f06ccb7460..0000000000 --- a/patches/net/minecraft/world/level/block/TripWireHookBlock.java.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/world/level/block/TripWireHookBlock.java -+++ b/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -176,8 +_,8 @@ - BlockPos blockpos2 = p_57687_.relative(direction, k); - BlockState blockstate2 = ablockstate[k]; - if (blockstate2 != null) { -+ if (!p_57686_.getBlockState(blockpos2).isAir()) { // FORGE: fix MC-129055 - p_57686_.setBlock(blockpos2, blockstate2.trySetValue(ATTACHED, Boolean.valueOf(flag2)), 3); -- if (!p_57686_.getBlockState(blockpos2).isAir()) { - } - } - } diff --git a/patches/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/patches/net/minecraft/world/level/block/TurtleEggBlock.java.patch index 3f07d6855e..d3294faa4e 100644 --- a/patches/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/patches/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/TurtleEggBlock.java +++ b/net/minecraft/world/level/block/TurtleEggBlock.java -@@ -171,7 +_,7 @@ +@@ -173,7 +_,7 @@ if (p_57769_ instanceof Turtle || p_57769_ instanceof Bat) { return false; } else { -- return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || p_57768_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); -+ return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_57768_, p_57769_); +- return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || p_376510_.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); ++ return !(p_57769_ instanceof LivingEntity) ? false : p_57769_ instanceof Player || net.neoforged.neoforge.event.EventHooks.canEntityGrief(p_376510_, p_57769_); } } } diff --git a/patches/net/minecraft/world/level/block/VineBlock.java.patch b/patches/net/minecraft/world/level/block/VineBlock.java.patch index f83b32be8e..70537e1e0e 100644 --- a/patches/net/minecraft/world/level/block/VineBlock.java.patch +++ b/patches/net/minecraft/world/level/block/VineBlock.java.patch @@ -9,7 +9,7 @@ public static final MapCodec CODEC = simpleCodec(VineBlock::new); public static final BooleanProperty UP = PipeBlock.UP; public static final BooleanProperty NORTH = PipeBlock.NORTH; -@@ -183,7 +_,7 @@ +@@ -192,7 +_,7 @@ @Override protected void randomTick(BlockState p_222655_, ServerLevel p_222656_, BlockPos p_222657_, RandomSource p_222658_) { if (p_222656_.getGameRules().getBoolean(GameRules.RULE_DO_VINES_SPREAD)) { diff --git a/patches/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/patches/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index 602c72711f..03bd036ae7 100644 --- a/patches/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/patches/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -60,6 +_,7 @@ - public static final int NUM_DATA_VALUES = 4; +@@ -54,6 +_,7 @@ public static final int BURN_TIME_STANDARD = 200; public static final int BURN_COOL_SPEED = 2; + public static final int UNKNOWN_LIT_DURATION = 0; + private final RecipeType recipeType; protected NonNullList items = NonNullList.withSize(3, ItemStack.EMPTY); int litTime; - int litDuration; -@@ -72,9 +_,14 @@ + int litDuration = 0; +@@ -64,9 +_,14 @@ public int get(int p_58431_) { switch (p_58431_) { case 0: @@ -24,57 +24,15 @@ case 2: return AbstractFurnaceBlockEntity.this.cookingProgress; case 3: -@@ -114,18 +_,40 @@ +@@ -106,6 +_,7 @@ ) { super(p_154991_, p_154992_, p_154993_); this.quickCheck = RecipeManager.createCheck((RecipeType)p_154994_); + this.recipeType = p_154994_; } - public static void invalidateCache() { - fuelCache = null; - } - -+ /** -+ * @deprecated Neo: get burn times by calling {@link net.neoforged.neoforge.common.extensions.IItemStackExtension#getBurnTime(RecipeType)} -+ */ -+ @Deprecated - public static Map getFuel() { - Map map = fuelCache; - if (map != null) { - return map; - } else { - Map map1 = Maps.newLinkedHashMap(); -+ buildFuels((e, time) -> e.ifRight(tag -> add(map1, tag, time)).ifLeft(item -> add(map1, item, time))); -+ fuelCache = map1; -+ return map1; -+ } -+ } -+ -+ private static void add(java.util.function.ObjIntConsumer>> consumer, ItemLike item, int time) { -+ consumer.accept(com.mojang.datafixers.util.Either.left(item.asItem()), time); -+ } -+ -+ private static void add(java.util.function.ObjIntConsumer>> consumer, TagKey tag, int time) { -+ consumer.accept(com.mojang.datafixers.util.Either.right(tag), time); -+ } -+ -+ @org.jetbrains.annotations.ApiStatus.Internal -+ public static void buildFuels(java.util.function.ObjIntConsumer>> map1) { -+ { - add(map1, Items.LAVA_BUCKET, 20000); - add(map1, Blocks.COAL_BLOCK, 16000); - add(map1, Items.BLAZE_ROD, 2400); -@@ -185,8 +_,6 @@ - add(map1, Blocks.AZALEA, 100); - add(map1, Blocks.FLOWERING_AZALEA, 100); - add(map1, Blocks.MANGROVE_ROOTS, 300); -- fuelCache = map1; -- return map1; - } - } - -@@ -226,9 +_,9 @@ + private boolean isLit() { +@@ -117,9 +_,9 @@ super.loadAdditional(p_155025_, p_323468_); this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); ContainerHelper.loadAllItems(p_155025_, this.items, p_323468_); @@ -84,10 +42,10 @@ + this.litTime = p_155025_.getInt("BurnTime"); + this.cookingProgress = p_155025_.getInt("CookTime"); + this.cookingTotalTime = p_155025_.getInt("CookTimeTotal"); - this.litDuration = this.getBurnDuration(this.items.get(1)); + this.litDuration = 0; CompoundTag compoundtag = p_155025_.getCompound("RecipesUsed"); -@@ -240,9 +_,9 @@ +@@ -131,9 +_,9 @@ @Override protected void saveAdditional(CompoundTag p_187452_, HolderLookup.Provider p_323656_) { super.saveAdditional(p_187452_, p_323656_); @@ -99,56 +57,25 @@ + p_187452_.putInt("CookTimeTotal", this.cookingTotalTime); ContainerHelper.saveAllItems(p_187452_, this.items, p_323656_); CompoundTag compoundtag = new CompoundTag(); - this.recipesUsed.forEach((p_187449_, p_187450_) -> compoundtag.putInt(p_187449_.toString(), p_187450_)); -@@ -269,28 +_,30 @@ - } - - int i = p_155017_.getMaxStackSize(); -- if (!p_155017_.isLit() && canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { -+ if (!p_155017_.isLit() && canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i, p_155017_)) { - p_155017_.litTime = p_155017_.getBurnDuration(itemstack); + this.recipesUsed.forEach((p_380898_, p_380899_) -> compoundtag.putInt(p_380898_.location().toString(), p_380899_)); +@@ -170,11 +_,15 @@ p_155017_.litDuration = p_155017_.litTime; if (p_155017_.isLit()) { flag1 = true; -+ if (itemstack.hasCraftingRemainingItem()) -+ p_155017_.items.set(1, itemstack.getCraftingRemainingItem()); ++ var remainder = itemstack.getCraftingRemainder(); ++ if (!remainder.isEmpty()) ++ p_155017_.items.set(1, remainder); + else if (flag3) { Item item = itemstack.getItem(); itemstack.shrink(1); if (itemstack.isEmpty()) { -- Item item1 = item.getCraftingRemainingItem(); -- p_155017_.items.set(1, item1 == null ? ItemStack.EMPTY : new ItemStack(item1)); -+ p_155017_.items.set(1, itemstack.getCraftingRemainingItem()); +- p_155017_.items.set(1, item.getCraftingRemainder()); ++ p_155017_.items.set(1, item.getCraftingRemainder()); // Neo: Remainder is handled in the `if` check above. } } } - } - -- if (p_155017_.isLit() && canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { -+ if (p_155017_.isLit() && canBurn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i, p_155017_)) { - p_155017_.cookingProgress++; - if (p_155017_.cookingProgress == p_155017_.cookingTotalTime) { - p_155017_.cookingProgress = 0; - p_155017_.cookingTotalTime = getTotalCookTime(p_155014_, p_155017_); -- if (burn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i)) { -+ if (burn(p_155014_.registryAccess(), recipeholder, p_155017_.items, i, p_155017_)) { - p_155017_.setRecipeUsed(recipeholder); - } - -@@ -314,9 +_,9 @@ - } - } - -- private static boolean canBurn(RegistryAccess p_266924_, @Nullable RecipeHolder p_301107_, NonNullList p_155007_, int p_155008_) { -+ private static boolean canBurn(RegistryAccess p_266924_, @Nullable RecipeHolder p_301107_, NonNullList p_155007_, int p_155008_, AbstractFurnaceBlockEntity furnace) { - if (!p_155007_.get(0).isEmpty() && p_301107_ != null) { -- ItemStack itemstack = p_301107_.value().getResultItem(p_266924_); -+ ItemStack itemstack = ((RecipeHolder) p_301107_).value().assemble(new SingleRecipeInput(furnace.getItem(0)), p_266924_); - if (itemstack.isEmpty()) { - return false; - } else { -@@ -326,9 +_,9 @@ +@@ -227,9 +_,9 @@ } else if (!ItemStack.isSameItemSameComponents(itemstack1, itemstack)) { return false; } else { @@ -160,18 +87,7 @@ } } } else { -@@ -336,15 +_,15 @@ - } - } - -- private static boolean burn(RegistryAccess p_266740_, @Nullable RecipeHolder p_300910_, NonNullList p_267073_, int p_267157_) { -- if (p_300910_ != null && canBurn(p_266740_, p_300910_, p_267073_, p_267157_)) { -+ private static boolean burn(RegistryAccess p_266740_, @Nullable RecipeHolder p_300910_, NonNullList p_267073_, int p_267157_, AbstractFurnaceBlockEntity furnace) { -+ if (p_300910_ != null && canBurn(p_266740_, p_300910_, p_267073_, p_267157_, furnace)) { - ItemStack itemstack = p_267073_.get(0); -- ItemStack itemstack1 = p_300910_.value().getResultItem(p_266740_); -+ ItemStack itemstack1 = ((RecipeHolder) p_300910_).value().assemble(new SingleRecipeInput(furnace.getItem(0)), p_266740_); - ItemStack itemstack2 = p_267073_.get(2); +@@ -251,7 +_,7 @@ if (itemstack2.isEmpty()) { p_267073_.set(2, itemstack1.copy()); } else if (ItemStack.isSameItemSameComponents(itemstack2, itemstack1)) { @@ -180,31 +96,21 @@ } if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !p_267073_.get(1).isEmpty() && p_267073_.get(1).is(Items.BUCKET)) { -@@ -362,8 +_,7 @@ - if (p_58343_.isEmpty()) { - return 0; - } else { -- Item item = p_58343_.getItem(); -- return getFuel().getOrDefault(item, 0); -+ return p_58343_.getBurnTime(this.recipeType); - } +@@ -266,7 +_,7 @@ } -@@ -373,7 +_,7 @@ + protected int getBurnDuration(FuelValues p_363501_, ItemStack p_58343_) { +- return p_363501_.burnDuration(p_58343_); ++ return p_58343_.getBurnTime(this.recipeType, p_363501_); } - public static boolean isFuel(ItemStack p_58400_) { -- return getFuel().containsKey(p_58400_.getItem()); -+ return p_58400_.getBurnTime(null) > 0; - } - - @Override -@@ -431,7 +_,7 @@ + private static int getTotalCookTime(ServerLevel p_380169_, AbstractFurnaceBlockEntity p_222694_) { +@@ -329,7 +_,7 @@ return true; } else { ItemStack itemstack = this.items.get(1); -- return isFuel(p_58390_) || p_58390_.is(Items.BUCKET) && !itemstack.is(Items.BUCKET); -+ return p_58390_.getBurnTime(this.recipeType) > 0 || p_58390_.is(Items.BUCKET) && !itemstack.is(Items.BUCKET); +- return this.level.fuelValues().isFuel(p_58390_) || p_58390_.is(Items.BUCKET) && !itemstack.is(Items.BUCKET); ++ return p_58390_.getBurnTime(this.recipeType, this.level.fuelValues()) > 0 || p_58390_.is(Items.BUCKET) && !itemstack.is(Items.BUCKET); } } diff --git a/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch b/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch index 51453c55cf..16fb21f9f0 100644 --- a/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch +++ b/patches/net/minecraft/world/level/block/entity/BlockEntity.java.patch @@ -48,7 +48,7 @@ } public final CompoundTag saveWithFullMetadata(HolderLookup.Provider p_323767_) { -@@ -216,10 +_,14 @@ +@@ -217,10 +_,14 @@ public void setRemoved() { this.remove = true; @@ -63,7 +63,7 @@ } public boolean triggerEvent(int p_58889_, int p_58890_) { -@@ -246,6 +_,27 @@ +@@ -247,6 +_,27 @@ return this.type; } @@ -91,7 +91,7 @@ @Deprecated public void setBlockState(BlockState p_155251_) { this.validateBlockState(p_155251_); -@@ -325,5 +_,15 @@ +@@ -326,5 +_,15 @@ T get(DataComponentType p_338658_); T getOrDefault(DataComponentType p_338573_, T p_338734_); diff --git a/patches/net/minecraft/world/level/block/entity/BlockEntityType.java.patch b/patches/net/minecraft/world/level/block/entity/BlockEntityType.java.patch index 627986209a..77f3f48d29 100644 --- a/patches/net/minecraft/world/level/block/entity/BlockEntityType.java.patch +++ b/patches/net/minecraft/world/level/block/entity/BlockEntityType.java.patch @@ -1,14 +1,25 @@ --- a/net/minecraft/world/level/block/entity/BlockEntityType.java +++ b/net/minecraft/world/level/block/entity/BlockEntityType.java -@@ -268,6 +_,7 @@ - ); - public static final BlockEntityType VAULT = register("vault", BlockEntityType.Builder.of(VaultBlockEntity::new, Blocks.VAULT)); +@@ -229,6 +_,7 @@ + public static final BlockEntityType TRIAL_SPAWNER = register("trial_spawner", TrialSpawnerBlockEntity::new, Blocks.TRIAL_SPAWNER); + public static final BlockEntityType VAULT = register("vault", VaultBlockEntity::new, Blocks.VAULT); private final BlockEntityType.BlockEntitySupplier factory; + // Neo: This field will be modified by BlockEntityTypeAddBlocksEvent event. Please use the event to add to this field for vanilla or other mod's BlockEntityTypes. private final Set validBlocks; - private final Type dataType; private final Holder.Reference> builtInRegistryHolder = BuiltInRegistries.BLOCK_ENTITY_TYPE.createIntrusiveHolder(this); -@@ -295,6 +_,13 @@ + +@@ -253,9 +_,24 @@ + this.validBlocks = p_155260_; + } + ++ // Neo: Additional constructor for convenience. ++ public BlockEntityType(BlockEntityType.BlockEntitySupplier p_155259_, Block... p_155260_) { ++ this(p_155259_, Set.of(p_155260_)); ++ if (p_155260_.length == 0) { ++ throw new IllegalArgumentException("Block entity type instantiated without valid blocks. If this is intentional, pass Set.of() instead of an empty varag."); ++ } ++ } ++ @Nullable public T create(BlockPos p_155265_, BlockState p_155266_) { return (T)this.factory.create(p_155265_, p_155266_); diff --git a/patches/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch b/patches/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch index 95af4ec3c3..12d0923b2f 100644 --- a/patches/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch +++ b/patches/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -@@ -164,6 +_,7 @@ +@@ -165,6 +_,7 @@ } private static void doBrew(Level p_155291_, BlockPos p_155292_, NonNullList p_155293_) { @@ -8,28 +8,18 @@ ItemStack itemstack = p_155293_.get(3); PotionBrewing potionbrewing = p_155291_.potionBrewing(); -@@ -171,15 +_,17 @@ +@@ -172,8 +_,9 @@ p_155293_.set(i, potionbrewing.mix(itemstack, p_155293_.get(i))); } -- itemstack.shrink(1); -- if (itemstack.getItem().hasCraftingRemainingItem()) { -- ItemStack itemstack1 = new ItemStack(itemstack.getItem().getCraftingRemainingItem()); + net.neoforged.neoforge.event.EventHooks.onPotionBrewed(p_155293_); -+ if (itemstack.hasCraftingRemainingItem()) { -+ ItemStack itemstack1 = itemstack.getCraftingRemainingItem(); -+ itemstack.shrink(1); ++ ItemStack itemstack1 = itemstack.getCraftingRemainder(); + itemstack.shrink(1); +- ItemStack itemstack1 = itemstack.getItem().getCraftingRemainder(); + if (!itemstack1.isEmpty()) { if (itemstack.isEmpty()) { itemstack = itemstack1; - } else { - Containers.dropItemStack(p_155291_, (double)p_155292_.getX(), (double)p_155292_.getY(), (double)p_155292_.getZ(), itemstack1); - } - } -+ else itemstack.shrink(1); - - p_155293_.set(3, itemstack); - p_155291_.levelEvent(1035, p_155292_, 0); -@@ -208,13 +_,13 @@ +@@ -209,13 +_,13 @@ @Override public boolean canPlaceItem(int p_59017_, ItemStack p_59018_) { @@ -39,7 +29,7 @@ return potionbrewing.isIngredient(p_59018_); } else { return p_59017_ == 4 - ? p_59018_.is(Items.BLAZE_POWDER) + ? p_59018_.is(ItemTags.BREWING_FUEL) - : (p_59018_.is(Items.POTION) || p_59018_.is(Items.SPLASH_POTION) || p_59018_.is(Items.LINGERING_POTION) || p_59018_.is(Items.GLASS_BOTTLE)) + : (potionbrewing.isInput(p_59018_) || p_59018_.is(Items.GLASS_BOTTLE)) && this.getItem(p_59017_).isEmpty(); diff --git a/patches/net/minecraft/world/level/block/entity/FuelValues.java.patch b/patches/net/minecraft/world/level/block/entity/FuelValues.java.patch new file mode 100644 index 0000000000..b5166418b4 --- /dev/null +++ b/patches/net/minecraft/world/level/block/entity/FuelValues.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/world/level/block/entity/FuelValues.java ++++ b/net/minecraft/world/level/block/entity/FuelValues.java +@@ -32,6 +_,10 @@ + return Collections.unmodifiableSequencedSet(this.values.keySet()); + } + ++ /** ++ * @deprecated Neo: use {@link ItemStack#getBurnTime(net.minecraft.world.item.crafting.RecipeType, FuelValues)} instead ++ */ ++ @Deprecated + public int burnDuration(ItemStack p_362816_) { + return p_362816_.isEmpty() ? 0 : this.values.getInt(p_362816_.getItem()); + } +@@ -41,7 +_,11 @@ + } + + public static FuelValues vanillaBurnTimes(HolderLookup.Provider p_362290_, FeatureFlagSet p_364291_, int p_363365_) { +- return new FuelValues.Builder(p_362290_, p_364291_) ++ return vanillaBurnTimes(new FuelValues.Builder(p_362290_, p_364291_), p_363365_); ++ } ++ ++ public static FuelValues vanillaBurnTimes(FuelValues.Builder builder, int p_363365_) { ++ return builder + .add(Items.LAVA_BUCKET, p_363365_ * 100) + .add(Blocks.COAL_BLOCK, p_363365_ * 8 * 10) + .add(Items.BLAZE_ROD, p_363365_ * 12) diff --git a/patches/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch b/patches/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch new file mode 100644 index 0000000000..e3a36de823 --- /dev/null +++ b/patches/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +@@ -255,7 +_,7 @@ + + @Override + public boolean shouldRenderFace(Direction p_59959_) { +- return Block.shouldRenderFace(this.getBlockState(), this.level.getBlockState(this.getBlockPos().relative(p_59959_)), p_59959_); ++ return Block.shouldRenderFace(this.level, this.worldPosition, this.getBlockState(), this.level.getBlockState(this.getBlockPos().relative(p_59959_)), p_59959_); + } + + public int getParticleAmount() { diff --git a/patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch b/patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch index cd80ce062a..54f0c94786 100644 --- a/patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch +++ b/patches/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java -@@ -43,7 +_,7 @@ +@@ -44,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; @@ -9,20 +9,20 @@ public static final String NORMAL_CONFIG_TAG_NAME = "normal_config"; public static final String OMINOUS_CONFIG_TAG_NAME = "ominous_config"; public static final int DETECT_PLAYER_SPAWN_BUFFER = 40; -@@ -229,9 +_,9 @@ +@@ -237,9 +_,9 @@ } boolean flag = spawndata.getEntityToSpawn().size() == 1 && spawndata.getEntityToSpawn().contains("id", 8); - if (flag) { -- mob.finalizeSpawn(p_312582_, p_312582_.getCurrentDifficultyAt(mob.blockPosition()), MobSpawnType.TRIAL_SPAWNER, null); +- mob.finalizeSpawn(p_312582_, p_312582_.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.TRIAL_SPAWNER, null); - } + // Neo: Patch in FinalizeSpawn for spawners so it may be fired unconditionally, instead of only when vanilla would normally call it. + // The local flag is the conditions under which the spawner will normally call Mob#finalizeSpawn. -+ net.neoforged.neoforge.event.EventHooks.finalizeMobSpawnSpawner(mob, p_312582_, p_312582_.getCurrentDifficultyAt(mob.blockPosition()), MobSpawnType.TRIAL_SPAWNER, null, this, flag); ++ net.neoforged.neoforge.event.EventHooks.finalizeMobSpawnSpawner(mob, p_312582_, p_312582_.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.TRIAL_SPAWNER, null, this, flag); mob.setPersistenceRequired(); spawndata.getEquipment().ifPresent(mob::equip); -@@ -405,5 +_,14 @@ +@@ -413,5 +_,14 @@ TrialSpawnerState getState(); void markUpdated(); diff --git a/patches/net/minecraft/world/level/block/grower/TreeGrower.java.patch b/patches/net/minecraft/world/level/block/grower/TreeGrower.java.patch index 04738fa464..bef15f255b 100644 --- a/patches/net/minecraft/world/level/block/grower/TreeGrower.java.patch +++ b/patches/net/minecraft/world/level/block/grower/TreeGrower.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/level/block/grower/TreeGrower.java +++ b/net/minecraft/world/level/block/grower/TreeGrower.java -@@ -130,6 +_,9 @@ - .registryOrThrow(Registries.CONFIGURED_FEATURE) - .getHolder(resourcekey) - .orElse(null); +@@ -128,6 +_,9 @@ + ResourceKey> resourcekey = this.getConfiguredMegaFeature(p_304893_); + if (resourcekey != null) { + Holder> holder = p_304396_.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey).orElse(null); + var event = net.neoforged.neoforge.event.EventHooks.fireBlockGrowFeature(p_304396_, p_304893_, p_304643_, holder); + holder = event.getFeature(); + if (event.isCanceled()) return false; if (holder != null) { for (int i = 0; i >= -1; i--) { for (int j = 0; j >= -1; j--) { -@@ -163,6 +_,9 @@ - .registryOrThrow(Registries.CONFIGURED_FEATURE) - .getHolder(resourcekey1) - .orElse(null); +@@ -158,6 +_,9 @@ + return false; + } else { + Holder> holder1 = p_304396_.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey1).orElse(null); + var event = net.neoforged.neoforge.event.EventHooks.fireBlockGrowFeature(p_304396_, p_304893_, p_304643_, holder1); + holder1 = event.getFeature(); + if (event.isCanceled()) return false; diff --git a/patches/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch b/patches/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch index 0f685960e1..5b3568cbb0 100644 --- a/patches/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch +++ b/patches/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java -@@ -186,6 +_,7 @@ +@@ -189,6 +_,7 @@ } if (p_60195_ == 0) { @@ -8,7 +8,7 @@ if (!this.moveBlocks(p_60193_, p_60194_, direction, true)) { return false; } -@@ -194,6 +_,7 @@ +@@ -197,6 +_,7 @@ p_60193_.playSound(null, p_60194_, SoundEvents.PISTON_EXTEND, SoundSource.BLOCKS, 0.5F, p_60193_.random.nextFloat() * 0.25F + 0.6F); p_60193_.gameEvent(GameEvent.BLOCK_ACTIVATE, p_60194_, GameEvent.Context.of(blockstate)); } else if (p_60195_ == 1 || p_60195_ == 2) { @@ -16,7 +16,7 @@ BlockEntity blockentity = p_60193_.getBlockEntity(p_60194_.relative(direction)); if (blockentity instanceof PistonMovingBlockEntity) { ((PistonMovingBlockEntity)blockentity).finalTick(); -@@ -243,6 +_,7 @@ +@@ -246,6 +_,7 @@ p_60193_.gameEvent(GameEvent.BLOCK_DEACTIVATE, p_60194_, GameEvent.Context.of(blockstate1)); } @@ -24,7 +24,7 @@ return true; } -@@ -314,8 +_,7 @@ +@@ -315,8 +_,7 @@ BlockState blockstate1 = p_60182_.getBlockState(blockpos2); BlockEntity blockentity = blockstate1.hasBlockEntity() ? p_60182_.getBlockEntity(blockpos2) : null; dropResources(blockstate1, p_60182_, blockpos2, blockentity); @@ -34,7 +34,7 @@ if (!blockstate1.is(BlockTags.FIRE)) { p_60182_.addDestroyBlockEffect(blockpos2, blockstate1); } -@@ -387,6 +_,10 @@ +@@ -389,6 +_,10 @@ @Override protected BlockState rotate(BlockState p_60215_, Rotation p_60216_) { return p_60215_.setValue(FACING, p_60216_.rotate(p_60215_.getValue(FACING))); diff --git a/patches/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch b/patches/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch index 94bcbb53d7..70dbd39e7d 100644 --- a/patches/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch +++ b/patches/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -115,7 +_,7 @@ +@@ -116,7 +_,7 @@ List list = p_155911_.getEntities(null, PistonMath.getMovementArea(aabb, direction, d0).minmax(aabb)); if (!list.isEmpty()) { List list1 = voxelshape.toAabbs(); diff --git a/patches/net/minecraft/world/level/block/state/BlockBehaviour.java.patch b/patches/net/minecraft/world/level/block/state/BlockBehaviour.java.patch index 851387e29d..9fdd0acefe 100644 --- a/patches/net/minecraft/world/level/block/state/BlockBehaviour.java.patch +++ b/patches/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -1,64 +1,36 @@ --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -111,6 +_,17 @@ - this.dynamicShape = p_60452_.dynamicShape; - this.requiredFeatures = p_60452_.requiredFeatures; - this.properties = p_60452_; -+ final ResourceKey lootTableCache = p_60452_.drops; -+ if (lootTableCache != null) { -+ this.lootTableSupplier = () -> lootTableCache; -+ } else if (p_60452_.lootTableSupplier != null) { -+ this.lootTableSupplier = p_60452_.lootTableSupplier; -+ } else { -+ this.lootTableSupplier = () -> { -+ ResourceLocation resourcelocation = BuiltInRegistries.BLOCK.getKey(this.asBlock()); -+ return ResourceKey.create(Registries.LOOT_TABLE, resourcelocation.withPrefix("blocks/")); -+ }; -+ } - } - - public BlockBehaviour.Properties properties() { -@@ -168,7 +_,7 @@ +@@ -182,7 +_,7 @@ if (!p_311951_.isAir() && p_312925_.getBlockInteraction() != Explosion.BlockInteraction.TRIGGER_BLOCK) { Block block = p_311951_.getBlock(); boolean flag = p_312925_.getIndirectSourceEntity() instanceof Player; -- if (block.dropFromExplosion(p_312925_) && p_312820_ instanceof ServerLevel serverlevel) { -+ if (p_311951_.canDropFromExplosion(p_312820_, p_312489_, p_312925_) && p_312820_ instanceof ServerLevel serverlevel) { - BlockEntity blockentity = p_311951_.hasBlockEntity() ? p_312820_.getBlockEntity(p_312489_) : null; - LootParams.Builder lootparams$builder = new LootParams.Builder(serverlevel) +- if (block.dropFromExplosion(p_312925_)) { ++ if (p_311951_.canDropFromExplosion(p_365148_, p_312489_, p_312925_)) { + BlockEntity blockentity = p_311951_.hasBlockEntity() ? p_365148_.getBlockEntity(p_312489_) : null; + LootParams.Builder lootparams$builder = new LootParams.Builder(p_365148_) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(p_312489_)) -@@ -183,8 +_,7 @@ +@@ -197,8 +_,7 @@ p_311951_.getDrops(lootparams$builder).forEach(p_311752_ -> p_312073_.accept(p_311752_, p_312489_)); } -- p_312820_.setBlock(p_312489_, Blocks.AIR.defaultBlockState(), 3); -- block.wasExploded(p_312820_, p_312489_, p_312925_); -+ p_311951_.onBlockExploded(p_312820_, p_312489_, p_312925_); +- p_365148_.setBlock(p_312489_, Blocks.AIR.defaultBlockState(), 3); +- block.wasExploded(p_365148_, p_312489_, p_312925_); ++ p_311951_.onBlockExploded(p_365148_, p_312489_, p_312925_); } } -@@ -335,8 +_,8 @@ +@@ -344,8 +_,8 @@ if (f == -1.0F) { return 0.0F; } else { - int i = p_60467_.hasCorrectToolForDrops(p_60466_) ? 30 : 100; - return p_60467_.getDestroySpeed(p_60466_) / f / (float)i; + int i = net.neoforged.neoforge.event.EventHooks.doPlayerHarvestCheck(p_60467_, p_60466_, p_60468_, p_60469_) ? 30 : 100; -+ return p_60467_.getDigSpeed(p_60466_, p_60469_) / f / (float)i; ++ return p_60467_.getDestroySpeed(p_60466_, p_60469_) / f / (float)i; } } -@@ -359,8 +_,7 @@ - - public final ResourceKey getLootTable() { - if (this.drops == null) { -- ResourceLocation resourcelocation = BuiltInRegistries.BLOCK.getKey(this.asBlock()); -- this.drops = ResourceKey.create(Registries.LOOT_TABLE, resourcelocation.withPrefix("blocks/")); -+ this.drops = this.lootTableSupplier.get(); - } - - return this.drops; -@@ -377,6 +_,7 @@ +@@ -389,6 +_,7 @@ return this.isRandomlyTicking; } @@ -66,21 +38,18 @@ protected SoundType getSoundType(BlockState p_320941_) { return this.soundType; } -@@ -393,6 +_,13 @@ +@@ -405,6 +_,10 @@ return this.properties.destroyTime; } + protected boolean isAir(BlockState state) { + return ((BlockStateBase)state).isAir; + } -+ -+ // Neo: Holds the loot table for this block's drops. Used for getLootTable method. -+ private final java.util.function.Supplier> lootTableSupplier; + public abstract static class BlockStateBase extends StateHolder { - private final int lightEmission; - private final boolean useShapeForLightOcclusion; -@@ -523,12 +_,14 @@ + private static final Direction[] DIRECTIONS = Direction.values(); + private static final VoxelShape[] EMPTY_OCCLUSION_SHAPES = Util.make( +@@ -561,12 +_,14 @@ return this.useShapeForLightOcclusion; } @@ -96,7 +65,7 @@ } public boolean ignitedByLava() { -@@ -541,9 +_,11 @@ +@@ -579,9 +_,11 @@ } public MapColor getMapColor(BlockGetter p_285002_, BlockPos p_285293_) { @@ -109,7 +78,7 @@ public BlockState rotate(Rotation p_60718_) { return this.getBlock().rotate(this.asState(), p_60718_); } -@@ -597,6 +_,8 @@ +@@ -635,6 +_,8 @@ } public PushReaction getPistonPushReaction() { @@ -118,17 +87,17 @@ return this.pushReaction; } -@@ -724,6 +_,9 @@ +@@ -762,6 +_,9 @@ } - public ItemInteractionResult useItemOn(ItemStack p_316374_, Level p_316651_, Player p_316623_, InteractionHand p_316469_, BlockHitResult p_316877_) { + public InteractionResult useItemOn(ItemStack p_316374_, Level p_316651_, Player p_316623_, InteractionHand p_316469_, BlockHitResult p_316877_) { + var useOnContext = new net.minecraft.world.item.context.UseOnContext(p_316651_, p_316623_, p_316469_, p_316623_.getItemInHand(p_316469_).copy(), p_316877_); + var e = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent(useOnContext, net.neoforged.neoforge.event.entity.player.UseItemOnBlockEvent.UsePhase.BLOCK)); + if (e.isCanceled()) return e.getCancellationResult(); return this.getBlock().useItemOn(p_316374_, this.asState(), p_316651_, p_316877_.getBlockPos(), p_316623_, p_316469_, p_316877_); } -@@ -825,6 +_,7 @@ +@@ -871,6 +_,7 @@ return this.getBlock().getSeed(this.asState(), p_60727_); } @@ -136,34 +105,12 @@ public SoundType getSoundType() { return this.getBlock().getSoundType(this.asState()); } -@@ -959,11 +_,12 @@ - PushReaction pushReaction = PushReaction.NORMAL; - boolean spawnTerrainParticles = true; - NoteBlockInstrument instrument = NoteBlockInstrument.HARP; -+ private java.util.function.Supplier> lootTableSupplier; - boolean replaceable; - BlockBehaviour.StateArgumentPredicate> isValidSpawn = (p_284893_, p_284894_, p_284895_, p_284896_) -> p_284893_.isFaceSturdy( - p_284894_, p_284895_, Direction.UP +@@ -996,7 +_,7 @@ + BlockBehaviour.StateArgumentPredicate> isValidSpawn = (p_360193_, p_360194_, p_360195_, p_360196_) -> p_360193_.isFaceSturdy( + p_360194_, p_360195_, Direction.UP ) -- && p_284893_.getLightEmission() < 14; -+ && p_284893_.getLightEmission(p_284894_, p_284895_) < 14; - BlockBehaviour.StatePredicate isRedstoneConductor = (p_284888_, p_284889_, p_284890_) -> p_284888_.isCollisionShapeFullBlock(p_284889_, p_284890_); - BlockBehaviour.StatePredicate isSuffocating = (p_284885_, p_284886_, p_284887_) -> p_284885_.blocksMotion() - && p_284885_.isCollisionShapeFullBlock(p_284886_, p_284887_); -@@ -1105,9 +_,15 @@ - return this; - } - -+ @Deprecated // FORGE: Use the variant that takes a Supplier below - public BlockBehaviour.Properties dropsLike(Block p_60917_) { -- this.drops = p_60917_.getLootTable(); -+ this.lootTableSupplier = () -> p_60917_.getLootTable(); - return this; -+ } -+ -+ public BlockBehaviour.Properties lootFrom(java.util.function.Supplier blockIn) { -+ this.lootTableSupplier = () -> blockIn.get().getLootTable(); -+ return this; - } - - public BlockBehaviour.Properties ignitedByLava() { +- && p_360193_.getLightEmission() < 14; ++ && p_360193_.getLightEmission(p_360194_, p_360195_) < 14; + BlockBehaviour.StatePredicate isRedstoneConductor = (p_360190_, p_360191_, p_360192_) -> p_360190_.isCollisionShapeFullBlock(p_360191_, p_360192_); + BlockBehaviour.StatePredicate isSuffocating = (p_360187_, p_360188_, p_360189_) -> p_360187_.blocksMotion() + && p_360187_.isCollisionShapeFullBlock(p_360188_, p_360189_); diff --git a/patches/net/minecraft/world/level/chunk/ChunkAccess.java.patch b/patches/net/minecraft/world/level/chunk/ChunkAccess.java.patch index 311f7f4973..7de81bd23b 100644 --- a/patches/net/minecraft/world/level/chunk/ChunkAccess.java.patch +++ b/patches/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -4,16 +4,16 @@ import net.minecraft.world.ticks.TickContainerAccess; import org.slf4j.Logger; --public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess { -+public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess, net.neoforged.neoforge.attachment.IAttachmentHolder { +-public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess { ++public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess, net.neoforged.neoforge.attachment.IAttachmentHolder { public static final int NO_FILLED_SECTION = -1; private static final Logger LOGGER = LogUtils.getLogger(); private static final LongSet EMPTY_REFERENCE_SET = new LongOpenHashSet(); -@@ -315,10 +_,19 @@ +@@ -324,10 +_,19 @@ @Override public final void findBlockLightSources(BiConsumer p_285269_) { -- this.findBlocks(p_284897_ -> p_284897_.getLightEmission() != 0, p_285269_); +- this.findBlocks(p_360197_ -> p_360197_.getLightEmission() != 0, p_285269_); + this.findBlocks(p_284897_ -> p_284897_.hasDynamicLightEmission() || p_284897_.getLightEmission(net.minecraft.world.level.EmptyBlockGetter.INSTANCE, BlockPos.ZERO) != 0, (p_284897_, pos) -> p_284897_.getLightEmission(this, pos) != 0, p_285269_); } @@ -29,8 +29,8 @@ + public void findBlocks(Predicate p_285343_, java.util.function.BiPredicate fineFilter, BiConsumer p_285030_) { BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); - for (int i = this.getMinSection(); i < this.getMaxSection(); i++) { -@@ -330,8 +_,9 @@ + for (int i = this.getMinSectionY(); i <= this.getMaxSectionY(); i++) { +@@ -339,8 +_,9 @@ for (int k = 0; k < 16; k++) { for (int l = 0; l < 16; l++) { BlockState blockstate = levelchunksection.getBlockState(l, j, k); @@ -42,9 +42,9 @@ } } } -@@ -476,4 +_,72 @@ - - public static record TicksToSave(SerializableTickContainer blocks, SerializableTickContainer fluids) { +@@ -482,6 +_,74 @@ + public ChunkSkyLightSources getSkyLightSources() { + return this.skyLightSources; } + + // Neo: Hook in AttachmentHolder to chunks for data storage and retrieval @@ -73,14 +73,14 @@ + @Override + @Nullable + public T setData(net.neoforged.neoforge.attachment.AttachmentType type, T data) { -+ setUnsaved(true); ++ markUnsaved(); + return getAttachmentHolder().setData(type, data); + } + + @Override + @Nullable + public T removeData(net.neoforged.neoforge.attachment.AttachmentType type) { -+ setUnsaved(true); ++ markUnsaved(); + return getAttachmentHolder().removeData(type); + } + @@ -114,4 +114,6 @@ + // Neo: Allow for exposing the Level a chunk is tied to if available + @Nullable + public net.minecraft.world.level.Level getLevel() { return null; } - } + + public static record PackedTicks(List> blocks, List> fluids) { + } diff --git a/patches/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch b/patches/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch index 827439587d..6481ea0fc1 100644 --- a/patches/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch +++ b/patches/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/net/minecraft/world/level/chunk/ImposterProtoChunk.java -@@ -219,6 +_,15 @@ +@@ -223,6 +_,15 @@ } @Override @@ -16,7 +16,7 @@ public TickContainerAccess getBlockTicks() { return this.allowWrites ? this.wrapped.getBlockTicks() : BlackholeTickAccess.emptyContainer(); } -@@ -291,5 +_,10 @@ +@@ -290,5 +_,10 @@ @Override public ChunkSkyLightSources getSkyLightSources() { return this.wrapped.getSkyLightSources(); diff --git a/patches/net/minecraft/world/level/chunk/LevelChunk.java.patch b/patches/net/minecraft/world/level/chunk/LevelChunk.java.patch index a47b0de44e..dfa6a02fdf 100644 --- a/patches/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/patches/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -50,7 +_,7 @@ +@@ -51,7 +_,7 @@ import net.minecraft.world.ticks.TickContainerAccess; import org.slf4j.Logger; @@ -9,7 +9,7 @@ static final Logger LOGGER = LogUtils.getLogger(); private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { @Override -@@ -139,6 +_,7 @@ +@@ -142,6 +_,7 @@ this.setAllStarts(p_196851_.getAllStarts()); this.setAllReferences(p_196851_.getAllReferences()); @@ -17,7 +17,16 @@ for (Entry entry : p_196851_.getHeightmaps()) { if (ChunkStatus.FULL.heightmapsAfter().contains(entry.getKey())) { this.setHeightmap(entry.getKey(), entry.getValue().getRawData()); -@@ -278,7 +_,7 @@ +@@ -279,7 +_,7 @@ + this.level.getChunkSource().onSectionEmptinessChanged(this.chunkPos.x, SectionPos.blockToSectionCoord(i), this.chunkPos.z, flag1); + } + +- if (LightEngine.hasDifferentLightProperties(blockstate, p_62866_)) { ++ if (LightEngine.hasDifferentLightProperties(this, p_62865_, blockstate, p_62866_)) { + ProfilerFiller profilerfiller = Profiler.get(); + profilerfiller.push("updateSkyLightSources"); + this.skyLightSources.update(this, j, i, l); +@@ -298,7 +_,7 @@ if (!levelchunksection.getBlockState(j, k, l).is(block)) { return null; } else { @@ -26,7 +35,7 @@ p_62866_.onPlace(this.level, p_62865_, blockstate, p_62867_); } -@@ -327,6 +_,10 @@ +@@ -353,6 +_,10 @@ @Nullable public BlockEntity getBlockEntity(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { BlockEntity blockentity = this.blockEntities.get(p_62868_); @@ -37,7 +46,7 @@ if (blockentity == null) { CompoundTag compoundtag = this.pendingBlockEntities.remove(p_62868_); if (compoundtag != null) { -@@ -344,9 +_,6 @@ +@@ -370,9 +_,6 @@ this.addAndRegisterBlockEntity(blockentity); } } @@ -47,7 +56,7 @@ } return blockentity; -@@ -360,6 +_,7 @@ +@@ -386,6 +_,7 @@ } this.updateBlockEntityTicker(p_156391_); @@ -55,7 +64,7 @@ } } -@@ -403,6 +_,7 @@ +@@ -429,6 +_,7 @@ BlockEntity blockentity = this.blockEntities.put(blockpos.immutable(), p_156374_); if (blockentity != null && blockentity != p_156374_) { blockentity.setRemoved(); @@ -63,7 +72,7 @@ } } } -@@ -412,9 +_,14 @@ +@@ -438,9 +_,14 @@ public CompoundTag getBlockEntityNbtForSaving(BlockPos p_62932_, HolderLookup.Provider p_323699_) { BlockEntity blockentity = this.getBlockEntity(p_62932_); if (blockentity != null && !blockentity.isRemoved()) { @@ -78,7 +87,7 @@ } else { CompoundTag compoundtag = this.pendingBlockEntities.get(p_62932_); if (compoundtag != null) { -@@ -436,6 +_,7 @@ +@@ -462,6 +_,7 @@ } blockentity.setRemoved(); @@ -86,7 +95,7 @@ } } -@@ -496,7 +_,7 @@ +@@ -522,7 +_,7 @@ p_187974_.accept((p_338077_, p_338078_, p_338079_) -> { BlockEntity blockentity = this.getBlockEntity(p_338077_, LevelChunk.EntityCreationType.IMMEDIATE); if (blockentity != null && p_338079_ != null && blockentity.getType() == p_338078_) { @@ -95,7 +104,7 @@ } }); } -@@ -604,6 +_,7 @@ +@@ -632,6 +_,7 @@ } public void clearAllBlockEntities() { @@ -103,7 +112,7 @@ this.blockEntities.values().forEach(BlockEntity::setRemoved); this.blockEntities.clear(); this.tickersInLevel.values().forEach(p_187966_ -> p_187966_.rebind(NULL_TICKER)); -@@ -611,6 +_,7 @@ +@@ -639,6 +_,7 @@ } public void registerAllBlockEntitiesAfterLevelLoad() { @@ -111,7 +120,7 @@ this.blockEntities.values().forEach(p_187988_ -> { if (this.level instanceof ServerLevel serverlevel) { this.addGameEventListener(p_187988_, serverlevel); -@@ -662,6 +_,14 @@ +@@ -690,6 +_,14 @@ return new LevelChunk.BoundTickingBlockEntity<>(p_156376_, p_156377_); } @@ -126,15 +135,15 @@ class BoundTickingBlockEntity implements TickingBlockEntity { private final T blockEntity; private final BlockEntityTicker ticker; -@@ -679,6 +_,7 @@ +@@ -707,6 +_,7 @@ if (LevelChunk.this.isTicking(blockpos)) { try { - ProfilerFiller profilerfiller = LevelChunk.this.level.getProfiler(); + ProfilerFiller profilerfiller = Profiler.get(); + net.neoforged.neoforge.server.timings.TimeTracker.BLOCK_ENTITY_UPDATE.trackStart(blockEntity); profilerfiller.push(this::getType); BlockState blockstate = LevelChunk.this.getBlockState(blockpos); if (this.blockEntity.getType().isValid(blockstate)) { -@@ -700,7 +_,15 @@ +@@ -728,7 +_,15 @@ CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking block entity"); CrashReportCategory crashreportcategory = crashreport.addCategory("Block entity being ticked"); this.blockEntity.fillCrashReportCategory(crashreportcategory); diff --git a/patches/net/minecraft/world/level/chunk/LevelChunkSection.java.patch b/patches/net/minecraft/world/level/chunk/LevelChunkSection.java.patch index 42b524a34a..ba7c17c926 100644 --- a/patches/net/minecraft/world/level/chunk/LevelChunkSection.java.patch +++ b/patches/net/minecraft/world/level/chunk/LevelChunkSection.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -65,7 +_,7 @@ +@@ -73,7 +_,7 @@ FluidState fluidstate = blockstate.getFluidState(); FluidState fluidstate1 = p_62995_.getFluidState(); @@ -9,7 +9,7 @@ this.nonEmptyBlockCount--; if (blockstate.isRandomlyTicking()) { this.tickingBlockCount--; -@@ -76,7 +_,7 @@ +@@ -84,7 +_,7 @@ this.tickingFluidCount--; } @@ -18,7 +18,7 @@ this.nonEmptyBlockCount++; if (p_62995_.isRandomlyTicking()) { this.tickingBlockCount++; -@@ -114,7 +_,7 @@ +@@ -122,7 +_,7 @@ public void accept(BlockState p_204444_, int p_204445_) { FluidState fluidstate = p_204444_.getFluidState(); diff --git a/patches/net/minecraft/world/level/chunk/ProtoChunk.java.patch b/patches/net/minecraft/world/level/chunk/ProtoChunk.java.patch new file mode 100644 index 0000000000..ecd7f80c42 --- /dev/null +++ b/patches/net/minecraft/world/level/chunk/ProtoChunk.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/chunk/ProtoChunk.java ++++ b/net/minecraft/world/level/chunk/ProtoChunk.java +@@ -134,7 +_,7 @@ + this.lightEngine.updateSectionStatus(p_63217_, flag1); + } + +- if (LightEngine.hasDifferentLightProperties(blockstate, p_63218_)) { ++ if (LightEngine.hasDifferentLightProperties(this, p_63217_, blockstate, p_63218_)) { + this.skyLightSources.update(this, i1, j, k1); + this.lightEngine.checkBlock(p_63217_); + } diff --git a/patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch b/patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch index 788be92167..a16cba61c5 100644 --- a/patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch +++ b/patches/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch @@ -1,24 +1,25 @@ --- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java -@@ -201,10 +_,21 @@ - } +@@ -198,11 +_,22 @@ + } - levelchunk.setFullStatus(generationchunkholder::getFullStatus); -+ try { -+ generationchunkholder.currentlyLoading = levelchunk; // Neo: bypass the future chain when getChunk is called, this prevents deadlocks. - levelchunk.runPostLoad(); -+ } finally { -+ generationchunkholder.currentlyLoading = null; // Neo: Stop bypassing the future chain. -+ } - levelchunk.setLoaded(true); -+ try { -+ generationchunkholder.currentlyLoading = levelchunk; // Neo: bypass the future chain when getChunk is called, this prevents deadlocks. - levelchunk.registerAllBlockEntitiesAfterLevelLoad(); - levelchunk.registerTickContainerInLevel(serverlevel); -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkEvent.Load(levelchunk, !(protochunk instanceof ImposterProtoChunk))); -+ } finally { -+ generationchunkholder.currentlyLoading = null; // Neo: Stop bypassing the future chain. -+ } - return levelchunk; - }, - p_347404_ -> p_347565_.mainThreadMailBox() + levelchunk.setFullStatus(generationchunkholder::getFullStatus); ++ try { ++ generationchunkholder.currentlyLoading = levelchunk; // Neo: bypass the future chain when getChunk is called, this prevents deadlocks. + levelchunk.runPostLoad(); ++ } finally { ++ generationchunkholder.currentlyLoading = null; // Neo: Stop bypassing the future chain. ++ } + levelchunk.setLoaded(true); ++ try { ++ generationchunkholder.currentlyLoading = levelchunk; // Neo: bypass the future chain when getChunk is called, this prevents deadlocks. + levelchunk.registerAllBlockEntitiesAfterLevelLoad(); + levelchunk.registerTickContainerInLevel(serverlevel); + levelchunk.setUnsavedListener(p_347565_.unsavedListener()); ++ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkEvent.Load(levelchunk, !(protochunk instanceof ImposterProtoChunk))); ++ } finally { ++ generationchunkholder.currentlyLoading = null; // Neo: Stop bypassing the future chain. ++ } + return levelchunk; + }, p_347565_.mainThreadExecutor()); + } diff --git a/patches/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch b/patches/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch deleted file mode 100644 index fa78db915f..0000000000 --- a/patches/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- a/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -+++ b/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -@@ -183,6 +_,8 @@ - postLoadChunk(p_188231_, p_188234_), - blendingdata - ); -+ if (p_188234_.contains(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, net.minecraft.nbt.Tag.TAG_LIST)) -+ Objects.requireNonNull(((LevelChunk)chunkaccess).getAuxLightManager(p_188233_)).deserializeNBT(p_188231_.registryAccess(), p_188234_.getList(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, net.minecraft.nbt.Tag.TAG_COMPOUND)); - } else { - ProtoChunkTicks protochunkticks = ProtoChunkTicks.load( - p_188234_.getList("block_ticks", 10), p_258992_ -> BuiltInRegistries.BLOCK.getOptional(ResourceLocation.tryParse(p_258992_)), p_188233_ -@@ -209,6 +_,8 @@ - } - } - -+ if (p_188234_.contains(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY, net.minecraft.nbt.Tag.TAG_COMPOUND)) -+ chunkaccess.readAttachmentsFromNBT(p_188231_.registryAccess(), p_188234_.getCompound(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY)); - chunkaccess.setLightCorrect(flag); - CompoundTag compoundtag2 = p_188234_.getCompound("Heightmaps"); - EnumSet enumset = EnumSet.noneOf(Heightmap.Types.class); -@@ -241,6 +_,7 @@ - } - - if (chunktype == ChunkType.LEVELCHUNK) { -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkDataEvent.Load(chunkaccess, p_188234_, chunktype)); - return new ImposterProtoChunk((LevelChunk)chunkaccess, false); - } else { - ProtoChunk protochunk1 = (ProtoChunk)chunkaccess; -@@ -264,6 +_,7 @@ - protochunk1.setCarvingMask(generationstep$carving, new CarvingMask(compoundtag4.getLongArray(s1), chunkaccess.getMinBuildHeight())); - } - -+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.ChunkDataEvent.Load(chunkaccess, p_188234_, chunktype)); - return protochunk1; - } - } -@@ -374,6 +_,11 @@ - - compoundtag.put("CarvingMasks", compoundtag4); - } -+ else if (p_63456_ instanceof LevelChunk levelChunk){ -+ -+ Tag lightTag = levelChunk.getAuxLightManager(chunkpos).serializeNBT(p_63455_.registryAccess()); -+ if (lightTag != null) compoundtag.put(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, lightTag); -+ } - - saveTicks(p_63455_, compoundtag, p_63456_.getTicksForSerialization()); - compoundtag.put("PostProcessing", packOffsets(p_63456_.getPostProcessing())); -@@ -385,6 +_,12 @@ - } - } - -+ try { -+ final CompoundTag capTag = p_63456_.writeAttachmentsToNBT(p_63455_.registryAccess()); -+ if (capTag != null) compoundtag.put(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY, capTag); -+ } catch (Exception exception) { -+ LOGGER.error("Failed to write chunk attachments. An attachment has likely thrown an exception trying to write state. It will not persist. Report this to the mod author", exception); -+ } - compoundtag.put("Heightmaps", compoundtag2); - compoundtag.put( - "structures", diff --git a/patches/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch b/patches/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch index 07090ecf63..9adff11160 100644 --- a/patches/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch +++ b/patches/net/minecraft/world/level/chunk/storage/EntityStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/storage/EntityStorage.java +++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java -@@ -94,8 +_,12 @@ +@@ -95,8 +_,12 @@ ListTag listtag = new ListTag(); p_156559_.getEntities().forEach(p_156567_ -> { CompoundTag compoundtag1 = new CompoundTag(); diff --git a/patches/net/minecraft/world/level/chunk/storage/SectionStorage.java.patch b/patches/net/minecraft/world/level/chunk/storage/SectionStorage.java.patch index e19c187a3b..5eef3aff03 100644 --- a/patches/net/minecraft/world/level/chunk/storage/SectionStorage.java.patch +++ b/patches/net/minecraft/world/level/chunk/storage/SectionStorage.java.patch @@ -1,15 +1,22 @@ --- a/net/minecraft/world/level/chunk/storage/SectionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SectionStorage.java -@@ -238,4 +_,12 @@ - public void close() throws IOException { +@@ -302,6 +_,19 @@ this.simpleRegionStorage.close(); } -+ + + /** + * Neo: Removes the data for the given chunk position. + * See PR #937 + */ -+ public void remove(long sectionPosAsLong) { -+ this.storage.remove(sectionPosAsLong); ++ public void remove(ChunkPos chunkPos) { ++ synchronized (this.loadLock) { ++ for (int y = this.levelHeightAccessor.getMinSectionY(); y <= this.levelHeightAccessor.getMaxSectionY(); y++) { ++ this.storage.remove(getKey(chunkPos, y)); ++ } ++ this.loadedChunks.remove(chunkPos.toLong()); ++ } + } - } ++ + static record PackedChunk(Int2ObjectMap sectionsByY, boolean versionChanged) { + public static SectionStorage.PackedChunk parse( + Codec p_365233_, DynamicOps p_363840_, Tag p_364375_, SimpleRegionStorage p_362076_, LevelHeightAccessor p_362314_ diff --git a/patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch b/patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch new file mode 100644 index 0000000000..9cea770ea1 --- /dev/null +++ b/patches/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch @@ -0,0 +1,139 @@ +--- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java ++++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +@@ -91,7 +_,9 @@ + List sectionData, + List entities, + List blockEntities, +- CompoundTag structureData ++ CompoundTag structureData, ++ @Nullable CompoundTag attachmentData, ++ @Nullable ListTag auxLightData + ) { + private static final Codec> BLOCK_STATE_CODEC = PalettedContainer.codecRW( + Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState() +@@ -108,6 +_,33 @@ + public static final String BLOCK_LIGHT_TAG = "BlockLight"; + public static final String SKY_LIGHT_TAG = "SkyLight"; + ++ /** ++ * @deprecated Neo: use constructor with additional data instead ++ */ ++ @Deprecated ++ SerializableChunkData( ++ Registry biomeRegistry, ++ ChunkPos chunkPos, ++ int minSectionY, ++ long lastUpdateTime, ++ long inhabitedTime, ++ ChunkStatus chunkStatus, ++ @Nullable BlendingData.Packed blendingData, ++ @Nullable BelowZeroRetrogen belowZeroRetrogen, ++ UpgradeData upgradeData, ++ @Nullable long[] carvingMask, ++ Map heightmaps, ++ ChunkAccess.PackedTicks packedTicks, ++ ShortList[] postProcessingSections, ++ boolean lightCorrect, ++ List sectionData, ++ List entities, ++ List blockEntities, ++ CompoundTag structureData ++ ) { ++ this(biomeRegistry, chunkPos, minSectionY, lastUpdateTime, inhabitedTime, chunkStatus, blendingData, belowZeroRetrogen, upgradeData, carvingMask, heightmaps, packedTicks, postProcessingSections, lightCorrect, sectionData, entities, blockEntities, structureData, null, null); ++ } ++ + @Nullable + public static SerializableChunkData parse(LevelHeightAccessor p_361938_, RegistryAccess p_365010_, CompoundTag p_362040_) { + if (!p_362040_.contains("Status", 8)) { +@@ -224,6 +_,15 @@ + list.add(new SerializableChunkData.SectionData(j1, levelchunksection, datalayer, datalayer1)); + } + ++ CompoundTag attachmentData = null; ++ if (p_362040_.contains(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY, Tag.TAG_COMPOUND)) { ++ attachmentData = p_362040_.getCompound(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY); ++ } ++ ListTag auxLightData = null; ++ if (p_362040_.contains(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, Tag.TAG_LIST)) { ++ auxLightData = p_362040_.getList(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, Tag.TAG_COMPOUND); ++ } ++ + return new SerializableChunkData( + registry, + chunkpos, +@@ -242,7 +_,9 @@ + list, + list3, + list4, +- compoundtag2 ++ compoundtag2, ++ attachmentData, ++ auxLightData + ); + } + } +@@ -302,6 +_,9 @@ + postLoadChunk(p_360452_, this.entities, this.blockEntities), + BlendingData.unpack(this.blendingData) + ); ++ if (this.auxLightData != null) { ++ ((LevelChunk) chunkaccess).getAuxLightManager(chunkPos).deserializeNBT(p_360452_.registryAccess(), this.auxLightData); ++ } + } else { + ProtoChunkTicks protochunkticks = ProtoChunkTicks.load(this.packedTicks.blocks()); + ProtoChunkTicks protochunkticks1 = ProtoChunkTicks.load(this.packedTicks.fluids()); +@@ -340,6 +_,10 @@ + chunkaccess.addPackedPostProcess(this.postProcessingSections[j], j); + } + ++ if (this.attachmentData != null) { ++ chunkaccess.readAttachmentsFromNBT(p_360452_.registryAccess(), this.attachmentData); ++ } ++ + if (chunktype == ChunkType.LEVELCHUNK) { + return new ImposterProtoChunk((LevelChunk)chunkaccess, false); + } else { +@@ -429,6 +_,17 @@ + CompoundTag compoundtag1 = packStructureData( + StructurePieceSerializationContext.fromLevel(p_365319_), chunkpos, p_362284_.getAllStarts(), p_362284_.getAllReferences() + ); ++ ++ CompoundTag attachmentData = null; ++ try { ++ attachmentData = p_362284_.writeAttachmentsToNBT(p_365319_.registryAccess()); ++ } catch (Exception exception) { ++ LOGGER.error("Failed to write chunk attachments. An attachment has likely thrown an exception trying to write state. It will not persist. Report this to the mod author", exception); ++ } ++ ListTag auxLightData = null; ++ if (p_362284_ instanceof LevelChunk levelChunk) { ++ auxLightData = levelChunk.getAuxLightManager(chunkpos).serializeNBT(p_365319_.registryAccess()); ++ } + return new SerializableChunkData( + p_365319_.registryAccess().lookupOrThrow(Registries.BIOME), + chunkpos, +@@ -447,7 +_,9 @@ + list, + list2, + list1, +- compoundtag1 ++ compoundtag1, ++ attachmentData, ++ auxLightData + ); + } + } +@@ -526,6 +_,14 @@ + this.heightmaps.forEach((p_362472_, p_363515_) -> compoundtag2.put(p_362472_.getSerializationKey(), new LongArrayTag(p_363515_))); + compoundtag.put("Heightmaps", compoundtag2); + compoundtag.put("structures", this.structureData); ++ ++ if (attachmentData != null) { ++ compoundtag.put(net.neoforged.neoforge.attachment.AttachmentHolder.ATTACHMENTS_NBT_KEY, attachmentData); ++ } ++ if (auxLightData != null) { ++ compoundtag.put(net.neoforged.neoforge.common.world.LevelChunkAuxiliaryLightManager.LIGHT_NBT_KEY, auxLightData); ++ } ++ + return compoundtag; + } + diff --git a/patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch b/patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch index a62dbf7b2b..181d5880c0 100644 --- a/patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch +++ b/patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch @@ -20,7 +20,7 @@ static int getGameEventFrequency(ResourceKey p_316800_) { - return VIBRATION_FREQUENCY_FOR_EVENT.applyAsInt(p_316800_); -+ var holder = net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.getHolder(p_316800_); ++ var holder = net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.get(p_316800_); + return holder.map(VibrationSystem::getGameEventFrequency).orElse(0); } diff --git a/patches/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch b/patches/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch index 198e5cab39..f715082e4e 100644 --- a/patches/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch +++ b/patches/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch @@ -27,4 +27,4 @@ + int l = event.getPhantomsToSpawn(); for (int i1 = 0; i1 < l; i1++) { - Phantom phantom = EntityType.PHANTOM.create(p_64576_); + Phantom phantom = EntityType.PHANTOM.create(p_64576_, EntitySpawnReason.NATURAL); diff --git a/patches/net/minecraft/world/level/levelgen/WorldDimensions.java.patch b/patches/net/minecraft/world/level/levelgen/WorldDimensions.java.patch index 33276ce214..a65a43a3b7 100644 --- a/patches/net/minecraft/world/level/levelgen/WorldDimensions.java.patch +++ b/patches/net/minecraft/world/level/levelgen/WorldDimensions.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/WorldDimensions.java +++ b/net/minecraft/world/level/levelgen/WorldDimensions.java -@@ -36,7 +_,8 @@ +@@ -37,7 +_,8 @@ public record WorldDimensions(Map, LevelStem> dimensions) { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( p_325905_ -> p_325905_.group( diff --git a/patches/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/patches/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch index 1b2ac4b713..63803d46c0 100644 --- a/patches/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch +++ b/patches/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java +++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java -@@ -91,6 +_,9 @@ +@@ -92,6 +_,9 @@ } public final CompoundTag createTag(StructurePieceSerializationContext p_192645_) { diff --git a/patches/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch b/patches/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch index 71ababbf01..79c1cb74f1 100644 --- a/patches/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch +++ b/patches/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch @@ -4,9 +4,9 @@ public CompoundTag createTag(StructurePieceSerializationContext p_192661_, ChunkPos p_192662_) { CompoundTag compoundtag = new CompoundTag(); if (this.isValid()) { -+ if (p_192661_.registryAccess().registryOrThrow(Registries.STRUCTURE).getKey(this.getStructure()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below ++ if (p_192661_.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(this.getStructure()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below + throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\": \"" + this.getStructure() + "\" unregistered, serializing impossible."); + } - compoundtag.putString("id", p_192661_.registryAccess().registryOrThrow(Registries.STRUCTURE).getKey(this.structure).toString()); + compoundtag.putString("id", p_192661_.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(this.structure).toString()); compoundtag.putInt("ChunkX", p_192662_.x); compoundtag.putInt("ChunkZ", p_192662_.z); diff --git a/patches/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/patches/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index 04e9e46fc6..5f34e65a0c 100644 --- a/patches/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/patches/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java -@@ -219,6 +_,10 @@ +@@ -248,6 +_,10 @@ return transform(p_74565_, p_74564_.getMirror(), p_74564_.getRotation(), p_74564_.getRotationPivot()); } @@ -11,7 +11,7 @@ public boolean placeInWorld( ServerLevelAccessor p_230329_, BlockPos p_230330_, BlockPos p_230331_, StructurePlaceSettings p_230332_, RandomSource p_230333_, int p_230334_ ) { -@@ -242,7 +_,7 @@ +@@ -271,7 +_,7 @@ int j1 = Integer.MIN_VALUE; for (StructureTemplate.StructureBlockInfo structuretemplate$structureblockinfo : processBlockInfos( @@ -20,7 +20,7 @@ )) { BlockPos blockpos = structuretemplate$structureblockinfo.pos; if (boundingbox == null || boundingbox.isInside(blockpos)) { -@@ -355,15 +_,7 @@ +@@ -384,15 +_,7 @@ } if (!p_230332_.isIgnoreEntities()) { @@ -37,7 +37,7 @@ } return true; -@@ -402,12 +_,20 @@ +@@ -433,12 +_,20 @@ } public static List processBlockInfos( @@ -58,7 +58,7 @@ List list = new ArrayList<>(); List list1 = new ArrayList<>(); -@@ -422,7 +_,7 @@ +@@ -453,7 +_,7 @@ while (structuretemplate$structureblockinfo1 != null && iterator.hasNext()) { structuretemplate$structureblockinfo1 = iterator.next() @@ -67,7 +67,7 @@ } if (structuretemplate$structureblockinfo1 != null) { -@@ -438,21 +_,29 @@ +@@ -469,21 +_,29 @@ return list1; } @@ -111,26 +111,26 @@ ListTag listtag = new ListTag(); listtag.add(DoubleTag.valueOf(vec31.x)); listtag.add(DoubleTag.valueOf(vec31.y)); -@@ -460,10 +_,10 @@ - compoundtag.put("Pos", listtag); - compoundtag.remove("UUID"); - createEntityIgnoreException(p_74524_, compoundtag).ifPresent(p_275190_ -> { -- float f = p_275190_.rotate(p_74527_); -- f += p_275190_.mirror(p_74526_) - p_275190_.getYRot(); -+ float f = p_275190_.rotate(placementIn.getRotation()); -+ f += p_275190_.mirror(placementIn.getMirror()) - p_275190_.getYRot(); - p_275190_.moveTo(vec31.x, vec31.y, vec31.z, f, p_275190_.getXRot()); -- if (p_74530_ && p_275190_ instanceof Mob) { -+ if (placementIn.shouldFinalizeEntities() && p_275190_ instanceof Mob) { - ((Mob)p_275190_).finalizeSpawn(p_74524_, p_74524_.getCurrentDifficultyAt(BlockPos.containing(vec31)), MobSpawnType.STRUCTURE, null); - } - -@@ -777,7 +_,7 @@ +@@ -493,10 +_,10 @@ + createEntityIgnoreException(p_74524_, compoundtag) + .ifPresent( + p_275190_ -> { +- float f = p_275190_.rotate(p_74527_); +- f += p_275190_.mirror(p_74526_) - p_275190_.getYRot(); ++ float f = p_275190_.rotate(placementIn.getRotation()); ++ f += p_275190_.mirror(placementIn.getMirror()) - p_275190_.getYRot(); + p_275190_.moveTo(vec31.x, vec31.y, vec31.z, f, p_275190_.getXRot()); +- if (p_74530_ && p_275190_ instanceof Mob) { ++ if (placementIn.shouldFinalizeEntities() && p_275190_ instanceof Mob) { + ((Mob)p_275190_) + .finalizeSpawn(p_74524_, p_74524_.getCurrentDifficultyAt(BlockPos.containing(vec31)), EntitySpawnReason.STRUCTURE, null); + } +@@ -867,7 +_,7 @@ public static final class Palette { private final List blocks; - private final Map> cache = Maps.newHashMap(); + private final Map> cache = Maps.newConcurrentMap(); // Neo: Fixes MC-271899 - Make the global StructureTemplate's palette caches now thread safe for worldgen + @Nullable + private List cachedJigsaws; - Palette(List p_74648_) { - this.blocks = p_74648_; diff --git a/patches/net/minecraft/world/level/lighting/BlockLightEngine.java.patch b/patches/net/minecraft/world/level/lighting/BlockLightEngine.java.patch index 1ddb75cafb..7696c79c4e 100644 --- a/patches/net/minecraft/world/level/lighting/BlockLightEngine.java.patch +++ b/patches/net/minecraft/world/level/lighting/BlockLightEngine.java.patch @@ -12,9 +12,9 @@ @@ -119,7 +_,7 @@ LightChunk lightchunk = this.chunkSource.getChunkForLighting(p_285274_.x, p_285274_.z); if (lightchunk != null) { - lightchunk.findBlockLightSources((p_285266_, p_285452_) -> { -- int i = p_285452_.getLightEmission(); -+ int i = p_285452_.getLightEmission(chunkSource.getLevel(), p_285266_); - this.enqueueIncrease(p_285266_.asLong(), LightEngine.QueueEntry.increaseLightFromEmission(i, isEmptyShape(p_285452_))); + lightchunk.findBlockLightSources((p_360252_, p_360253_) -> { +- int i = p_360253_.getLightEmission(); ++ int i = p_360253_.getLightEmission(chunkSource.getLevel(), p_360252_); + this.enqueueIncrease(p_360252_.asLong(), LightEngine.QueueEntry.increaseLightFromEmission(i, isEmptyShape(p_360253_))); }); } diff --git a/patches/net/minecraft/world/level/lighting/LightEngine.java.patch b/patches/net/minecraft/world/level/lighting/LightEngine.java.patch index 63adb6e17d..618090b509 100644 --- a/patches/net/minecraft/world/level/lighting/LightEngine.java.patch +++ b/patches/net/minecraft/world/level/lighting/LightEngine.java.patch @@ -1,11 +1,23 @@ --- a/net/minecraft/world/level/lighting/LightEngine.java +++ b/net/minecraft/world/level/lighting/LightEngine.java -@@ -44,7 +_,7 @@ +@@ -38,11 +_,19 @@ + this.clearChunkCache(); + } + ++ /** ++ * @deprecated Neo: use overload with level context instead ++ */ ++ @Deprecated + public static boolean hasDifferentLightProperties(BlockState p_285110_, BlockState p_285372_) { ++ return hasDifferentLightProperties(net.minecraft.world.level.EmptyBlockGetter.INSTANCE, BlockPos.ZERO, p_285110_, p_285372_); ++ } ++ ++ public static boolean hasDifferentLightProperties(net.minecraft.world.level.BlockGetter level, BlockPos pos, BlockState p_285110_, BlockState p_285372_) { return p_285372_ == p_285110_ ? false - : p_285372_.getLightBlock(p_285159_, p_284985_) != p_285110_.getLightBlock(p_285159_, p_284985_) + : p_285372_.getLightBlock() != p_285110_.getLightBlock() - || p_285372_.getLightEmission() != p_285110_.getLightEmission() -+ || p_285372_.getLightEmission(p_285159_, p_284985_) != p_285110_.getLightEmission(p_285159_, p_284985_) ++ || p_285372_.getLightEmission(level, pos) != p_285110_.getLightEmission(level, pos) || p_285372_.useShapeForLightOcclusion() || p_285110_.useShapeForLightOcclusion(); } diff --git a/patches/net/minecraft/world/level/material/FlowingFluid.java.patch b/patches/net/minecraft/world/level/material/FlowingFluid.java.patch index a0acfa62cb..29f99b880b 100644 --- a/patches/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/patches/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -1,36 +1,36 @@ --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java -@@ -164,7 +_,7 @@ - BlockState blockstate = p_256464_.getBlockState(blockpos); +@@ -171,7 +_,7 @@ + BlockState blockstate = p_376839_.getBlockState(blockpos); FluidState fluidstate = blockstate.getFluidState(); - if (fluidstate.getType().isSame(this) && this.canPassThroughWall(direction, p_256464_, p_76037_, p_76038_, blockpos, blockstate)) { + if (fluidstate.getType().isSame(this) && canPassThroughWall(direction, p_376839_, p_76037_, p_76038_, blockpos, blockstate)) { - if (fluidstate.isSource()) { -+ if (fluidstate.isSource() && net.neoforged.neoforge.event.EventHooks.canCreateFluidSource(p_256464_, blockpos, blockstate)) { ++ if (fluidstate.isSource() && net.neoforged.neoforge.event.EventHooks.canCreateFluidSource(p_376839_, blockpos, blockstate)) { j++; } -@@ -172,7 +_,7 @@ +@@ -179,7 +_,7 @@ } } -- if (this.canConvertToSource(p_256464_) && j >= 2) { +- if (j >= 2 && this.canConvertToSource(p_376839_)) { + if (j >= 2) { - BlockState blockstate1 = p_256464_.getBlockState(p_76037_.below()); + BlockState blockstate1 = p_376839_.getBlockState(blockpos$mutableblockpos.setWithOffset(p_76037_, Direction.DOWN)); FluidState fluidstate1 = blockstate1.getFluidState(); if (blockstate1.isSolid() || this.isSourceBlockOfThisType(fluidstate1)) { -@@ -238,6 +_,15 @@ +@@ -257,6 +_,15 @@ return this.getSource().defaultFluidState().setValue(FALLING, Boolean.valueOf(p_76069_)); } + @Override -+ public boolean canConvertToSource(FluidState state, Level level, BlockPos pos) { ++ public boolean canConvertToSource(FluidState state, ServerLevel level, BlockPos pos) { + return this.canConvertToSource(level); + } + + /** -+ * @deprecated Forge: Use {@link #canConvertToSource(FluidState, Level, BlockPos)} instead. ++ * @deprecated Forge: Use {@link #canConvertToSource(FluidState, ServerLevel, BlockPos)} instead. + */ + @Deprecated - protected abstract boolean canConvertToSource(Level p_256009_); + protected abstract boolean canConvertToSource(ServerLevel p_376940_); protected void spreadTo(LevelAccessor p_76005_, BlockPos p_76006_, BlockState p_76007_, Direction p_76008_, FluidState p_76009_) { diff --git a/patches/net/minecraft/world/level/material/Fluid.java.patch b/patches/net/minecraft/world/level/material/Fluid.java.patch index 9bb749ea45..918a9f72f4 100644 --- a/patches/net/minecraft/world/level/material/Fluid.java.patch +++ b/patches/net/minecraft/world/level/material/Fluid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/Fluid.java +++ b/net/minecraft/world/level/material/Fluid.java -@@ -20,7 +_,7 @@ +@@ -21,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,7 @@ public static final IdMapper FLUID_STATE_REGISTRY = new IdMapper<>(); protected final StateDefinition stateDefinition; private FluidState defaultFluidState; -@@ -100,6 +_,13 @@ +@@ -101,6 +_,13 @@ } public abstract VoxelShape getShape(FluidState p_76137_, BlockGetter p_76138_, BlockPos p_76139_); diff --git a/patches/net/minecraft/world/level/material/FluidState.java.patch b/patches/net/minecraft/world/level/material/FluidState.java.patch index 399850a632..acc03677a4 100644 --- a/patches/net/minecraft/world/level/material/FluidState.java.patch +++ b/patches/net/minecraft/world/level/material/FluidState.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/FluidState.java +++ b/net/minecraft/world/level/material/FluidState.java -@@ -21,7 +_,7 @@ +@@ -22,7 +_,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; @@ -9,7 +9,7 @@ public static final Codec CODEC = codec(BuiltInRegistries.FLUID.byNameCodec(), Fluid::defaultFluidState).stable(); public static final int AMOUNT_MAX = 9; public static final int AMOUNT_FULL = 8; -@@ -113,6 +_,7 @@ +@@ -114,6 +_,7 @@ return this.getType() == p_192918_; } diff --git a/patches/net/minecraft/world/level/material/LavaFluid.java.patch b/patches/net/minecraft/world/level/material/LavaFluid.java.patch index 22bbfb96e8..8569dec5af 100644 --- a/patches/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/patches/net/minecraft/world/level/material/LavaFluid.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java -@@ -87,7 +_,7 @@ - BlockState blockstate = p_230572_.getBlockState(blockpos); +@@ -88,7 +_,7 @@ + BlockState blockstate = p_376493_.getBlockState(blockpos); if (blockstate.isAir()) { - if (this.hasFlammableNeighbours(p_230572_, blockpos)) { -- p_230572_.setBlockAndUpdate(blockpos, BaseFireBlock.getState(p_230572_, blockpos)); -+ p_230572_.setBlockAndUpdate(blockpos, net.neoforged.neoforge.event.EventHooks.fireFluidPlaceBlockEvent(p_230572_, blockpos, p_230573_, BaseFireBlock.getState(p_230572_, blockpos))); + if (this.hasFlammableNeighbours(p_376493_, blockpos)) { +- p_376493_.setBlockAndUpdate(blockpos, BaseFireBlock.getState(p_376493_, blockpos)); ++ p_376493_.setBlockAndUpdate(blockpos, net.neoforged.neoforge.event.EventHooks.fireFluidPlaceBlockEvent(p_376493_, blockpos, p_230573_, BaseFireBlock.getState(p_376493_, blockpos))); return; } } else if (blockstate.blocksMotion()) { -@@ -101,8 +_,8 @@ +@@ -102,8 +_,8 @@ return; } -- if (p_230572_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_230572_, blockpos1)) { -- p_230572_.setBlockAndUpdate(blockpos1.above(), BaseFireBlock.getState(p_230572_, blockpos1)); -+ if (p_230572_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_230572_, blockpos1, Direction.UP)) { -+ p_230572_.setBlockAndUpdate(blockpos1.above(), net.neoforged.neoforge.event.EventHooks.fireFluidPlaceBlockEvent(p_230572_, blockpos1.above(), p_230573_, BaseFireBlock.getState(p_230572_, blockpos1))); +- if (p_376493_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_376493_, blockpos1)) { +- p_376493_.setBlockAndUpdate(blockpos1.above(), BaseFireBlock.getState(p_376493_, blockpos1)); ++ if (p_376493_.isEmptyBlock(blockpos1.above()) && this.isFlammable(p_376493_, blockpos1, Direction.UP)) { ++ p_376493_.setBlockAndUpdate(blockpos1.above(), net.neoforged.neoforge.event.EventHooks.fireFluidPlaceBlockEvent(p_376493_, blockpos1.above(), p_230573_, BaseFireBlock.getState(p_376493_, blockpos1))); } } } -@@ -111,7 +_,7 @@ +@@ -112,7 +_,7 @@ private boolean hasFlammableNeighbours(LevelReader p_76228_, BlockPos p_76229_) { for (Direction direction : Direction.values()) { @@ -29,20 +29,18 @@ return true; } } -@@ -119,12 +_,22 @@ +@@ -120,10 +_,20 @@ return false; } + /** @deprecated Forge: use {@link LavaFluid#isFlammable(LevelReader,BlockPos,Direction)} instead */ + @Deprecated private boolean isFlammable(LevelReader p_76246_, BlockPos p_76247_) { - return p_76247_.getY() >= p_76246_.getMinBuildHeight() && p_76247_.getY() < p_76246_.getMaxBuildHeight() && !p_76246_.hasChunkAt(p_76247_) - ? false - : p_76246_.getBlockState(p_76247_).ignitedByLava(); + return p_76246_.isInsideBuildHeight(p_76247_.getY()) && !p_76246_.hasChunkAt(p_76247_) ? false : p_76246_.getBlockState(p_76247_).ignitedByLava(); } + private boolean isFlammable(LevelReader level, BlockPos pos, Direction face) { -+ if (pos.getY() >= level.getMinBuildHeight() && pos.getY() < level.getMaxBuildHeight() && !level.hasChunkAt(pos)) { ++ if (level.isInsideBuildHeight(pos.getY()) && !level.hasChunkAt(pos)) { + return false; + } + BlockState state = level.getBlockState(pos); @@ -52,7 +50,7 @@ @Nullable @Override public ParticleOptions getDripParticle() { -@@ -196,7 +_,7 @@ +@@ -195,7 +_,7 @@ FluidState fluidstate = p_76220_.getFluidState(p_76221_); if (this.is(FluidTags.LAVA) && fluidstate.is(FluidTags.WATER)) { if (p_76222_.getBlock() instanceof LiquidBlock) { diff --git a/patches/net/minecraft/world/level/portal/PortalShape.java.patch b/patches/net/minecraft/world/level/portal/PortalShape.java.patch index 133b3d8060..6da90f6816 100644 --- a/patches/net/minecraft/world/level/portal/PortalShape.java.patch +++ b/patches/net/minecraft/world/level/portal/PortalShape.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/portal/PortalShape.java +++ b/net/minecraft/world/level/portal/PortalShape.java -@@ -27,7 +_,7 @@ +@@ -28,7 +_,7 @@ public static final int MAX_WIDTH = 21; private static final int MIN_HEIGHT = 3; public static final int MAX_HEIGHT = 21; @@ -8,4 +8,4 @@ + private static final BlockBehaviour.StatePredicate FRAME = net.neoforged.neoforge.common.extensions.IBlockStateExtension::isPortalFrame; private static final float SAFE_TRAVEL_MAX_ENTITY_XY = 4.0F; private static final double SAFE_TRAVEL_MAX_VERTICAL_DELTA = 1.0; - private final LevelAccessor level; + private final Direction.Axis axis; diff --git a/patches/net/minecraft/world/level/saveddata/SavedData.java.patch b/patches/net/minecraft/world/level/saveddata/SavedData.java.patch index ac130d73e8..ed2c2352de 100644 --- a/patches/net/minecraft/world/level/saveddata/SavedData.java.patch +++ b/patches/net/minecraft/world/level/saveddata/SavedData.java.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/world/level/saveddata/SavedData.java +++ b/net/minecraft/world/level/saveddata/SavedData.java -@@ -37,7 +_,7 @@ - NbtUtils.addCurrentDataVersion(compoundtag); - - try { -- NbtIo.writeCompressed(compoundtag, p_77758_.toPath()); -+ net.neoforged.neoforge.common.IOUtilities.writeNbtCompressed(compoundtag, p_77758_.toPath()); - } catch (IOException ioexception) { - LOGGER.error("Could not save data {}", this, ioexception); - } -@@ -47,7 +_,10 @@ +@@ -33,7 +_,10 @@ } public static record Factory( diff --git a/patches/net/minecraft/world/level/storage/DimensionDataStorage.java.patch b/patches/net/minecraft/world/level/storage/DimensionDataStorage.java.patch index ecf3e43153..8dd492afb3 100644 --- a/patches/net/minecraft/world/level/storage/DimensionDataStorage.java.patch +++ b/patches/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -63,7 +_,7 @@ +@@ -69,7 +_,7 @@ } @Nullable - private T readSavedData(BiFunction p_324609_, DataFixTypes p_295832_, String p_164870_) { + private T readSavedData(BiFunction p_324609_, @Nullable DataFixTypes p_295832_, String p_164870_) { try { - File file1 = this.getDataFile(p_164870_); - if (file1.exists()) { -@@ -81,7 +_,7 @@ - this.cache.put(p_164856_, p_164857_); + Path path = this.getDataFile(p_164870_); + if (Files.exists(path)) { +@@ -88,7 +_,7 @@ + p_164857_.setDirty(); } - public CompoundTag readTagFromDisk(String p_78159_, DataFixTypes p_295038_, int p_78160_) throws IOException { + public CompoundTag readTagFromDisk(String p_78159_, @Nullable DataFixTypes p_295038_, int p_78160_) throws IOException { - File file1 = this.getDataFile(p_78159_); - CompoundTag compoundtag1; -@@ -98,9 +_,16 @@ + try ( + InputStream inputstream = Files.newInputStream(this.getDataFile(p_78159_)); +@@ -103,9 +_,16 @@ } } @@ -33,7 +33,20 @@ } + + // Neo: delete any temporary files so that we don't inflate disk space unnecessarily. -+ net.neoforged.neoforge.common.IOUtilities.cleanupTempFiles(this.dataFolder.toPath(), p_78159_); ++ net.neoforged.neoforge.common.IOUtilities.cleanupTempFiles(this.dataFolder, p_78159_); return compoundtag1; } +@@ -156,7 +_,11 @@ + private static CompletableFuture tryWriteAsync(Path p_364583_, CompoundTag p_363128_) { + return CompletableFuture.runAsync(() -> { + try { +- NbtIo.writeCompressed(p_363128_, p_364583_); ++ // Neo: ensure parent directories exist if the SavedData's path contains slashes ++ if (!Files.exists(p_364583_)) { ++ Files.createDirectories(p_364583_.getParent()); ++ } ++ net.neoforged.neoforge.common.IOUtilities.writeNbtCompressed(p_363128_, p_364583_); + } catch (IOException ioexception) { + LOGGER.error("Could not save data to {}", p_364583_.getFileName(), ioexception); + } diff --git a/patches/net/minecraft/world/level/storage/ServerLevelData.java.patch b/patches/net/minecraft/world/level/storage/ServerLevelData.java.patch index d56c58c499..ff29008c50 100644 --- a/patches/net/minecraft/world/level/storage/ServerLevelData.java.patch +++ b/patches/net/minecraft/world/level/storage/ServerLevelData.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/storage/ServerLevelData.java +++ b/net/minecraft/world/level/storage/ServerLevelData.java -@@ -87,4 +_,10 @@ - void setGameTime(long p_78617_); - +@@ -90,4 +_,10 @@ void setDayTime(long p_78624_); + + GameRules getGameRules(); + + //Neo + float getDayTimeFraction(); diff --git a/patches/net/minecraft/world/level/storage/loot/LootContext.java.patch b/patches/net/minecraft/world/level/storage/loot/LootContext.java.patch index 533f10a1a5..2c5260f97e 100644 --- a/patches/net/minecraft/world/level/storage/loot/LootContext.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/LootContext.java.patch @@ -64,7 +64,7 @@ @@ -140,6 +_,11 @@ - public LootContextParam getParam() { + public ContextKey getParam() { return this.param; + } + diff --git a/patches/net/minecraft/world/level/storage/loot/LootDataType.java.patch b/patches/net/minecraft/world/level/storage/loot/LootDataType.java.patch index 1fc2c3ab3e..0cbbb86db6 100644 --- a/patches/net/minecraft/world/level/storage/loot/LootDataType.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/LootDataType.java.patch @@ -1,15 +1,14 @@ --- a/net/minecraft/world/level/storage/loot/LootDataType.java +++ b/net/minecraft/world/level/storage/loot/LootDataType.java -@@ -16,7 +_,7 @@ +@@ -9,14 +_,26 @@ + import net.minecraft.world.level.storage.loot.functions.LootItemFunctions; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; - import org.slf4j.Logger; -public record LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.Validator validator) { -+public record LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.Validator validator, @org.jetbrains.annotations.Nullable T defaultValue, Codec> conditionalCodec, java.util.function.BiConsumer idSetter) { - private static final Logger LOGGER = LogUtils.getLogger(); ++public record LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.Validator validator, @org.jetbrains.annotations.Nullable T defaultValue, Codec> conditionalCodec, java.util.function.BiConsumer idSetter) { public static final LootDataType PREDICATE = new LootDataType<>( Registries.PREDICATE, LootItemCondition.DIRECT_CODEC, createSimpleValidator() -@@ -24,17 +_,33 @@ + ); public static final LootDataType MODIFIER = new LootDataType<>( Registries.ITEM_MODIFIER, LootItemFunctions.ROOT_CODEC, createSimpleValidator() ); @@ -24,39 +23,21 @@ + this(registryKey, codec, validator, null, (it, id) -> {}); + } + -+ private LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.Validator validator, @org.jetbrains.annotations.Nullable T defaultValue, java.util.function.BiConsumer idSetter) { ++ private LootDataType(ResourceKey> registryKey, Codec codec, LootDataType.Validator validator, @org.jetbrains.annotations.Nullable T defaultValue, java.util.function.BiConsumer idSetter) { + this(registryKey, codec, validator, defaultValue, net.neoforged.neoforge.common.conditions.ConditionalOps.createConditionalCodec(codec), idSetter); + } public void runValidation(ValidationContext p_279366_, ResourceKey p_336149_, T p_279124_) { this.validator.run(p_279366_, p_336149_, p_279124_); - } - - public Optional deserialize(ResourceLocation p_279253_, DynamicOps p_324006_, V p_324329_) { -- DataResult dataresult = this.codec.parse(p_324006_, p_324329_); -- dataresult.error() -- .ifPresent(p_350259_ -> LOGGER.error("Couldn't parse element {}/{} - {}", this.registryKey.location(), p_279253_, p_350259_.message())); -- return dataresult.result(); -+ var dataresult = this.conditionalCodec.parse(p_324006_, p_324329_); -+ dataresult.error().ifPresent(p_338121_ -> LOGGER.error("Couldn't parse element {}:{} - {}", this.registryKey, p_279253_, p_338121_.message())); -+ return dataresult.result().map(it -> { -+ it.ifPresent(val -> idSetter.accept(val, p_279253_)); -+ T value = it.orElse(defaultValue); -+ if (value instanceof LootTable lootTable) value = (T) net.neoforged.neoforge.event.EventHooks.loadLootTable(p_279253_, lootTable); -+ return value; -+ }); - } - - public static Stream> values() { -@@ -48,9 +_,11 @@ +@@ -33,9 +_,11 @@ } private static LootDataType.Validator createLootTableValidator() { -- return (p_339557_, p_339558_, p_339559_) -> p_339559_.validate( -- p_339557_.setParams(p_339559_.getParamSet()).enterElement("{" + p_339558_.registry() + "/" + p_339558_.location() + "}", p_339558_) +- return (p_380902_, p_380903_, p_380904_) -> p_380904_.validate( +- p_380902_.setContextKeySet(p_380904_.getParamSet()).enterElement("{" + p_380903_.registry() + "/" + p_380903_.location() + "}", p_380903_) + return (p_279333_, p_279227_, p_279406_) -> { + p_279406_.validate( -+ p_279333_.setParams(p_279406_.getParamSet()).enterElement("{" + p_279227_.registry() + ":" + p_279227_.location() + "}", p_279227_) ++ p_279333_.setContextKeySet(p_279406_.getParamSet()).enterElement("{" + p_279227_.registry() + ":" + p_279227_.location() + "}", p_279227_) ); + }; } diff --git a/patches/net/minecraft/world/level/storage/loot/LootParams.java.patch b/patches/net/minecraft/world/level/storage/loot/LootParams.java.patch deleted file mode 100644 index f2d7d0cb00..0000000000 --- a/patches/net/minecraft/world/level/storage/loot/LootParams.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/storage/loot/LootParams.java -+++ b/net/minecraft/world/level/storage/loot/LootParams.java -@@ -125,7 +_,7 @@ - - public LootParams create(LootContextParamSet p_287701_) { - Set> set = Sets.difference(this.params.keySet(), p_287701_.getAllowed()); -- if (!set.isEmpty()) { -+ if (false && !set.isEmpty()) { // Forge: Allow mods to pass custom loot parameters (not part of the vanilla loot table) to the loot context. - throw new IllegalArgumentException("Parameters not allowed in this parameter set: " + set); - } else { - Set> set1 = Sets.difference(p_287701_.getRequired(), this.params.keySet()); diff --git a/patches/net/minecraft/world/level/storage/loot/LootTable.java.patch b/patches/net/minecraft/world/level/storage/loot/LootTable.java.patch index 8e1d44d1ab..38d536c345 100644 --- a/patches/net/minecraft/world/level/storage/loot/LootTable.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/LootTable.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/level/storage/loot/LootTable.java +++ b/net/minecraft/world/level/storage/loot/LootTable.java @@ -38,8 +_,8 @@ - p_338123_ -> p_338123_.group( - LootContextParamSets.CODEC.lenientOptionalFieldOf("type", DEFAULT_PARAM_SET).forGetter(p_298001_ -> p_298001_.paramSet), + p_380905_ -> p_380905_.group( + LootContextParamSets.CODEC.lenientOptionalFieldOf("type", DEFAULT_PARAM_SET).forGetter(p_380906_ -> p_380906_.paramSet), ResourceLocation.CODEC.optionalFieldOf("random_sequence").forGetter(p_297998_ -> p_297998_.randomSequence), - LootPool.CODEC.listOf().optionalFieldOf("pools", List.of()).forGetter(p_298002_ -> p_298002_.pools), - LootItemFunctions.ROOT_CODEC.listOf().optionalFieldOf("functions", List.of()).forGetter(p_298000_ -> p_298000_.functions) + net.neoforged.neoforge.common.CommonHooks.lootPoolsCodec(LootPool::setName).optionalFieldOf("pools", List.of()).forGetter(p_298002_ -> p_298002_.pools), + net.neoforged.neoforge.common.conditions.ConditionalOps.decodeListWithElementConditions(LootItemFunctions.ROOT_CODEC).optionalFieldOf("functions", List.of()).forGetter(p_298000_ -> p_298000_.functions) ) - .apply(p_338123_, LootTable::new) + .apply(p_380905_, LootTable::new) ); @@ -53,7 +_,7 @@ - LootTable(LootContextParamSet p_287716_, Optional p_299055_, List p_298390_, List p_298775_) { - this.paramSet = p_287716_; + LootTable(ContextKeySet p_380952_, Optional p_299055_, List p_298390_, List p_298775_) { + this.paramSet = p_380952_; this.randomSequence = p_299055_; - this.pools = p_298390_; + this.pools = Lists.newArrayList(p_298390_); diff --git a/patches/net/minecraft/world/level/storage/loot/functions/EnchantRandomlyFunction.java.patch b/patches/net/minecraft/world/level/storage/loot/functions/EnchantRandomlyFunction.java.patch index 57bef15771..d56bd6e4d1 100644 --- a/patches/net/minecraft/world/level/storage/loot/functions/EnchantRandomlyFunction.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/functions/EnchantRandomlyFunction.java.patch @@ -3,7 +3,7 @@ @@ -59,7 +_,7 @@ Stream> stream = this.options .map(HolderSet::stream) - .orElseGet(() -> p_80430_.getLevel().registryAccess().registryOrThrow(Registries.ENCHANTMENT).holders().map(Function.identity())) + .orElseGet(() -> p_80430_.getLevel().registryAccess().lookupOrThrow(Registries.ENCHANTMENT).listElements().map(Function.identity())) - .filter(p_344686_ -> !flag1 || p_344686_.value().canEnchant(p_80429_)); + .filter(p_344686_ -> !flag1 || p_80429_.supportsEnchantment(p_344686_)); // Neo: Respect IItemExtension#supportsEnchantment List> list = stream.toList(); diff --git a/patches/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch b/patches/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch index 22bb631d44..0851d8d1ab 100644 --- a/patches/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java +++ b/net/minecraft/world/level/storage/loot/functions/SmeltItemFunction.java -@@ -41,7 +_,7 @@ +@@ -42,7 +_,7 @@ if (optional.isPresent()) { - ItemStack itemstack = optional.get().value().getResultItem(p_81269_.getLevel().registryAccess()); + ItemStack itemstack = optional.get().value().assemble(singlerecipeinput, p_81269_.getLevel().registryAccess()); if (!itemstack.isEmpty()) { - return itemstack.copyWithCount(p_81268_.getCount()); + return itemstack.copyWithCount(p_81268_.getCount() * itemstack.getCount()); // Forge: Support smelting returning multiple diff --git a/patches/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch b/patches/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch index 17ecf039d9..ad4a552cc4 100644 --- a/patches/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java +++ b/net/minecraft/world/level/storage/loot/parameters/LootContextParamSets.java -@@ -20,7 +_,7 @@ - public static final LootContextParamSet EMPTY = register("empty", p_81454_ -> { +@@ -21,7 +_,7 @@ + public static final ContextKeySet EMPTY = register("empty", p_381149_ -> { }); - public static final LootContextParamSet CHEST = register( -- "chest", p_323464_ -> p_323464_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) + public static final ContextKeySet CHEST = register( +- "chest", p_380909_ -> p_380909_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) + "chest", p_81452_ -> p_81452_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY).optional(LootContextParams.ATTACKING_ENTITY) //Forge: Chest minecarts can have killer entities ); - public static final LootContextParamSet COMMAND = register( - "command", p_330195_ -> p_330195_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) -@@ -29,7 +_,7 @@ - "selector", p_81442_ -> p_81442_.required(LootContextParams.ORIGIN).required(LootContextParams.THIS_ENTITY) + public static final ContextKeySet COMMAND = register( + "command", p_380924_ -> p_380924_.required(LootContextParams.ORIGIN).optional(LootContextParams.THIS_ENTITY) +@@ -30,7 +_,7 @@ + "selector", p_380913_ -> p_380913_.required(LootContextParams.ORIGIN).required(LootContextParams.THIS_ENTITY) ); - public static final LootContextParamSet FISHING = register( -- "fishing", p_81446_ -> p_81446_.required(LootContextParams.ORIGIN).required(LootContextParams.TOOL).optional(LootContextParams.THIS_ENTITY) + public static final ContextKeySet FISHING = register( +- "fishing", p_380928_ -> p_380928_.required(LootContextParams.ORIGIN).required(LootContextParams.TOOL).optional(LootContextParams.THIS_ENTITY) + "fishing", p_81446_ -> p_81446_.required(LootContextParams.ORIGIN).required(LootContextParams.TOOL).optional(LootContextParams.THIS_ENTITY).optional(LootContextParams.ATTACKING_ENTITY) //Forge: Add the fisher as a killer. ); - public static final LootContextParamSet ENTITY = register( + public static final ContextKeySet ENTITY = register( "entity", diff --git a/patches/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch b/patches/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch index c00e726253..69771175ba 100644 --- a/patches/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch +++ b/patches/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java +++ b/net/minecraft/world/level/storage/loot/providers/nbt/ContextNbtProvider.java -@@ -60,7 +_,7 @@ +@@ -59,7 +_,7 @@ @Override public String getId() { diff --git a/patches/net/minecraft/world/phys/AABB.java.patch b/patches/net/minecraft/world/phys/AABB.java.patch index 334c4f33b7..1f108aea04 100644 --- a/patches/net/minecraft/world/phys/AABB.java.patch +++ b/patches/net/minecraft/world/phys/AABB.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/phys/AABB.java +++ b/net/minecraft/world/phys/AABB.java -@@ -10,6 +_,7 @@ +@@ -11,6 +_,7 @@ public class AABB { private static final double EPSILON = 1.0E-7; @@ -8,7 +8,7 @@ public final double minX; public final double minY; public final double minZ; -@@ -528,5 +_,13 @@ +@@ -584,5 +_,13 @@ p_165883_.y + p_165885_ / 2.0, p_165883_.z + p_165886_ / 2.0 ); diff --git a/patches/net/minecraft/world/phys/shapes/MinecartCollisionContext.java.patch b/patches/net/minecraft/world/phys/shapes/MinecartCollisionContext.java.patch new file mode 100644 index 0000000000..fec8905831 --- /dev/null +++ b/patches/net/minecraft/world/phys/shapes/MinecartCollisionContext.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/phys/shapes/MinecartCollisionContext.java ++++ b/net/minecraft/world/phys/shapes/MinecartCollisionContext.java +@@ -25,7 +_,7 @@ + boolean flag = BaseRailBlock.isRail(blockstate); + if (flag) { + this.ingoreBelow = blockpos.below(); +- RailShape railshape = blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()); ++ RailShape railshape = ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, p_366450_.level(), blockpos, p_366450_); + if (railshape.isSlope()) { + this.slopeIgnore = switch (railshape) { + case ASCENDING_EAST -> blockpos.east(); diff --git a/projects/neoforge/build.gradle b/projects/neoforge/build.gradle index 669b21be2a..bc642bd0c9 100644 --- a/projects/neoforge/build.gradle +++ b/projects/neoforge/build.gradle @@ -81,11 +81,15 @@ dependencies { runtimeOnly "cpw.mods:bootstraplauncher:${project.bootstraplauncher_version}" moduleOnly "cpw.mods:securejarhandler:${project.securejarhandler_version}" - moduleOnly "org.ow2.asm:asm:${project.asm_version}" - moduleOnly "org.ow2.asm:asm-commons:${project.asm_version}" - moduleOnly "org.ow2.asm:asm-tree:${project.asm_version}" - moduleOnly "org.ow2.asm:asm-util:${project.asm_version}" - moduleOnly "org.ow2.asm:asm-analysis:${project.asm_version}" + for (var asmModule : ["org.ow2.asm:asm", "org.ow2.asm:asm-commons", "org.ow2.asm:asm-tree", "org.ow2.asm:asm-util", "org.ow2.asm:asm-analysis"]) { + moduleOnly(asmModule) { + // Vanilla ships with ASM 9.3 transitively (via their OpenID connect library dependency), we require + // ASM in a more recent version and have to strictly require this to override the strict Minecraft version. + version { + strictly project.asm_version + } + } + } moduleOnly "cpw.mods:bootstraplauncher:${project.bootstraplauncher_version}" moduleOnly "net.neoforged:JarJarFileSystems:${project.jarjar_version}" @@ -215,6 +219,10 @@ runs.configureEach { it -> it.arguments.addAll '--gameDir', gameDir.absolutePath } +tasks.register("genPatches") { + dependsOn tasks.unpackSourcePatches +} + launcherProfile { arguments { game '--fml.neoForgeVersion' diff --git a/src/generated/resources/assets/c/lang/en_us.json b/src/generated/resources/assets/c/lang/en_us.json index 626b385a89..3c27e29b49 100644 --- a/src/generated/resources/assets/c/lang/en_us.json +++ b/src/generated/resources/assets/c/lang/en_us.json @@ -110,6 +110,8 @@ "tag.block.c.storage_blocks.redstone": "Redstone Storage Blocks", "tag.block.c.storage_blocks.slime": "Slime Storage Blocks", "tag.block.c.storage_blocks.wheat": "Wheat Storage Blocks", + "tag.block.c.stripped_logs": "Stripped Logs", + "tag.block.c.stripped_woods": "Stripped Woods", "tag.block.c.villager_job_sites": "Villager Job Sites", "tag.block.neoforge.enderman_place_on_blacklist": "Enderman Place On Blacklist", "tag.block.neoforge.needs_gold_tool": "Needs Gold Tools", @@ -128,6 +130,7 @@ "tag.entity_type.c.minecarts": "Minecarts", "tag.entity_type.c.teleporting_not_supported": "Teleporting Not Supported", "tag.fluid.c.beetroot_soup": "Beetroot Soup", + "tag.fluid.c.experience": "Experience", "tag.fluid.c.gaseous": "Gaseous", "tag.fluid.c.hidden_from_recipe_viewers": "Hidden From Recipe Viewers", "tag.fluid.c.honey": "Honey", @@ -347,6 +350,8 @@ "tag.item.c.storage_blocks.slime": "Slime Storage Blocks", "tag.item.c.storage_blocks.wheat": "Wheat Storage Blocks", "tag.item.c.strings": "Strings", + "tag.item.c.stripped_logs": "Stripped Log Blocks", + "tag.item.c.stripped_woods": "Stripped Wood Blocks", "tag.item.c.tools": "Tools", "tag.item.c.tools.bow": "Bows", "tag.item.c.tools.brush": "Brushes", diff --git a/src/generated/resources/data/c/tags/block/stripped_logs.json b/src/generated/resources/data/c/tags/block/stripped_logs.json new file mode 100644 index 0000000000..ae69c996ad --- /dev/null +++ b/src/generated/resources/data/c/tags/block/stripped_logs.json @@ -0,0 +1,13 @@ +{ + "values": [ + "minecraft:stripped_acacia_log", + "minecraft:stripped_bamboo_block", + "minecraft:stripped_birch_log", + "minecraft:stripped_cherry_log", + "minecraft:stripped_dark_oak_log", + "minecraft:stripped_jungle_log", + "minecraft:stripped_mangrove_log", + "minecraft:stripped_oak_log", + "minecraft:stripped_spruce_log" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/block/stripped_woods.json b/src/generated/resources/data/c/tags/block/stripped_woods.json new file mode 100644 index 0000000000..197542891d --- /dev/null +++ b/src/generated/resources/data/c/tags/block/stripped_woods.json @@ -0,0 +1,12 @@ +{ + "values": [ + "minecraft:stripped_acacia_wood", + "minecraft:stripped_birch_wood", + "minecraft:stripped_cherry_wood", + "minecraft:stripped_dark_oak_wood", + "minecraft:stripped_jungle_wood", + "minecraft:stripped_mangrove_wood", + "minecraft:stripped_oak_wood", + "minecraft:stripped_spruce_wood" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/entity_type/boats.json b/src/generated/resources/data/c/tags/entity_type/boats.json index 58e89216d1..134759720c 100644 --- a/src/generated/resources/data/c/tags/entity_type/boats.json +++ b/src/generated/resources/data/c/tags/entity_type/boats.json @@ -1,7 +1,15 @@ { "values": [ - "minecraft:boat", - "minecraft:chest_boat", + "#minecraft:boat", + "minecraft:oak_chest_boat", + "minecraft:spruce_chest_boat", + "minecraft:birch_chest_boat", + "minecraft:jungle_chest_boat", + "minecraft:acacia_chest_boat", + "minecraft:cherry_chest_boat", + "minecraft:dark_oak_chest_boat", + "minecraft:mangrove_chest_boat", + "minecraft:bamboo_chest_raft", { "id": "#forge:boats", "required": false diff --git a/src/generated/resources/data/c/tags/fluid/experience.json b/src/generated/resources/data/c/tags/fluid/experience.json new file mode 100644 index 0000000000..f72d209df7 --- /dev/null +++ b/src/generated/resources/data/c/tags/fluid/experience.json @@ -0,0 +1,3 @@ +{ + "values": [] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/stripped_logs.json b/src/generated/resources/data/c/tags/item/stripped_logs.json new file mode 100644 index 0000000000..ae69c996ad --- /dev/null +++ b/src/generated/resources/data/c/tags/item/stripped_logs.json @@ -0,0 +1,13 @@ +{ + "values": [ + "minecraft:stripped_acacia_log", + "minecraft:stripped_bamboo_block", + "minecraft:stripped_birch_log", + "minecraft:stripped_cherry_log", + "minecraft:stripped_dark_oak_log", + "minecraft:stripped_jungle_log", + "minecraft:stripped_mangrove_log", + "minecraft:stripped_oak_log", + "minecraft:stripped_spruce_log" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/c/tags/item/stripped_woods.json b/src/generated/resources/data/c/tags/item/stripped_woods.json new file mode 100644 index 0000000000..197542891d --- /dev/null +++ b/src/generated/resources/data/c/tags/item/stripped_woods.json @@ -0,0 +1,12 @@ +{ + "values": [ + "minecraft:stripped_acacia_wood", + "minecraft:stripped_birch_wood", + "minecraft:stripped_cherry_wood", + "minecraft:stripped_dark_oak_wood", + "minecraft:stripped_jungle_wood", + "minecraft:stripped_mangrove_wood", + "minecraft:stripped_oak_wood", + "minecraft:stripped_spruce_wood" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/acacia_chest_boat.json b/src/generated/resources/data/minecraft/recipe/acacia_chest_boat.json index 96b6a5a3b9..745f8237ba 100644 --- a/src/generated/resources/data/minecraft/recipe/acacia_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/acacia_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:acacia_boat" - } + "minecraft:acacia_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/acacia_fence.json b/src/generated/resources/data/minecraft/recipe/acacia_fence.json index 1df661b7b1..abc4d37cba 100644 --- a/src/generated/resources/data/minecraft/recipe/acacia_fence.json +++ b/src/generated/resources/data/minecraft/recipe/acacia_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:acacia_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:acacia_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/acacia_fence_gate.json b/src/generated/resources/data/minecraft/recipe/acacia_fence_gate.json index 01c8f1d461..af366bf332 100644 --- a/src/generated/resources/data/minecraft/recipe/acacia_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/acacia_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:acacia_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:acacia_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/acacia_sign.json b/src/generated/resources/data/minecraft/recipe/acacia_sign.json index 8591a10c68..3232b1b89a 100644 --- a/src/generated/resources/data/minecraft/recipe/acacia_sign.json +++ b/src/generated/resources/data/minecraft/recipe/acacia_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:acacia_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:acacia_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/activator_rail.json b/src/generated/resources/data/minecraft/recipe/activator_rail.json index f3e8a6d92a..555bb300db 100644 --- a/src/generated/resources/data/minecraft/recipe/activator_rail.json +++ b/src/generated/resources/data/minecraft/recipe/activator_rail.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:redstone_torch" - }, - "S": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "minecraft:redstone_torch", + "S": "#c:rods/wooden", + "X": "#c:ingots/iron" }, "pattern": [ "XSX", diff --git a/src/generated/resources/data/minecraft/recipe/andesite.json b/src/generated/resources/data/minecraft/recipe/andesite.json index 909e6271f9..5dfdf07cd9 100644 --- a/src/generated/resources/data/minecraft/recipe/andesite.json +++ b/src/generated/resources/data/minecraft/recipe/andesite.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "building", "ingredients": [ - { - "item": "minecraft:diorite" - }, - { - "tag": "c:cobblestones/normal" - } + "minecraft:diorite", + "#c:cobblestones/normal" ], "result": { "count": 2, diff --git a/src/generated/resources/data/minecraft/recipe/anvil.json b/src/generated/resources/data/minecraft/recipe/anvil.json index 405668a7af..e50cd1febe 100644 --- a/src/generated/resources/data/minecraft/recipe/anvil.json +++ b/src/generated/resources/data/minecraft/recipe/anvil.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "I": { - "item": "minecraft:iron_block" - }, - "i": { - "tag": "c:ingots/iron" - } + "I": "minecraft:iron_block", + "i": "#c:ingots/iron" }, "pattern": [ "III", diff --git a/src/generated/resources/data/minecraft/recipe/armor_stand.json b/src/generated/resources/data/minecraft/recipe/armor_stand.json index 55e7dbeaff..a3ad60d12c 100644 --- a/src/generated/resources/data/minecraft/recipe/armor_stand.json +++ b/src/generated/resources/data/minecraft/recipe/armor_stand.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "/": { - "tag": "c:rods/wooden" - }, - "_": { - "item": "minecraft:smooth_stone_slab" - } + "/": "#c:rods/wooden", + "_": "minecraft:smooth_stone_slab" }, "pattern": [ "///", diff --git a/src/generated/resources/data/minecraft/recipe/arrow.json b/src/generated/resources/data/minecraft/recipe/arrow.json index 5b160e1c5a..8948fda6f2 100644 --- a/src/generated/resources/data/minecraft/recipe/arrow.json +++ b/src/generated/resources/data/minecraft/recipe/arrow.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:flint" - }, - "Y": { - "item": "minecraft:feather" - } + "#": "#c:rods/wooden", + "X": "minecraft:flint", + "Y": "minecraft:feather" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/bamboo_chest_raft.json b/src/generated/resources/data/minecraft/recipe/bamboo_chest_raft.json index a26be3e5ca..0b97b7f4cf 100644 --- a/src/generated/resources/data/minecraft/recipe/bamboo_chest_raft.json +++ b/src/generated/resources/data/minecraft/recipe/bamboo_chest_raft.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:bamboo_raft" - } + "minecraft:bamboo_raft" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/bamboo_fence.json b/src/generated/resources/data/minecraft/recipe/bamboo_fence.json index 190c83b690..d36413016a 100644 --- a/src/generated/resources/data/minecraft/recipe/bamboo_fence.json +++ b/src/generated/resources/data/minecraft/recipe/bamboo_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:bamboo_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:bamboo_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/bamboo_fence_gate.json b/src/generated/resources/data/minecraft/recipe/bamboo_fence_gate.json index 1d2e0f107b..444acda7be 100644 --- a/src/generated/resources/data/minecraft/recipe/bamboo_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/bamboo_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:bamboo_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:bamboo_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/bamboo_sign.json b/src/generated/resources/data/minecraft/recipe/bamboo_sign.json index 2ea528857f..79d256d984 100644 --- a/src/generated/resources/data/minecraft/recipe/bamboo_sign.json +++ b/src/generated/resources/data/minecraft/recipe/bamboo_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:bamboo_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:bamboo_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/birch_chest_boat.json b/src/generated/resources/data/minecraft/recipe/birch_chest_boat.json index 92de5a6d41..3043b2193a 100644 --- a/src/generated/resources/data/minecraft/recipe/birch_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/birch_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:birch_boat" - } + "minecraft:birch_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/birch_fence.json b/src/generated/resources/data/minecraft/recipe/birch_fence.json index fef03a747d..f340e905c3 100644 --- a/src/generated/resources/data/minecraft/recipe/birch_fence.json +++ b/src/generated/resources/data/minecraft/recipe/birch_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:birch_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:birch_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/birch_fence_gate.json b/src/generated/resources/data/minecraft/recipe/birch_fence_gate.json index c0f380a750..55e6c5133a 100644 --- a/src/generated/resources/data/minecraft/recipe/birch_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/birch_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:birch_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:birch_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/birch_sign.json b/src/generated/resources/data/minecraft/recipe/birch_sign.json index c7a1c36a77..94b286ed75 100644 --- a/src/generated/resources/data/minecraft/recipe/birch_sign.json +++ b/src/generated/resources/data/minecraft/recipe/birch_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:birch_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:birch_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/black_banner.json b/src/generated/resources/data/minecraft/recipe/black_banner.json index 26cb29a877..7f67600216 100644 --- a/src/generated/resources/data/minecraft/recipe/black_banner.json +++ b/src/generated/resources/data/minecraft/recipe/black_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:black_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:black_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/black_candle.json b/src/generated/resources/data/minecraft/recipe/black_candle.json new file mode 100644 index 0000000000..5d54b78d10 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/black_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/black" + ], + "result": { + "count": 1, + "id": "minecraft:black_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/black_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/black_concrete_powder.json new file mode 100644 index 0000000000..1028880277 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/black_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/black", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:black_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/black_stained_glass.json b/src/generated/resources/data/minecraft/recipe/black_stained_glass.json new file mode 100644 index 0000000000..4373c79565 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/black_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/black" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:black_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/black_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/black_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..68ad84bb87 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/black_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/black" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:black_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/black_terracotta.json b/src/generated/resources/data/minecraft/recipe/black_terracotta.json new file mode 100644 index 0000000000..8dcb00446e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/black_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/black" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:black_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/blast_furnace.json b/src/generated/resources/data/minecraft/recipe/blast_furnace.json index 6b73dce306..eb2c292aac 100644 --- a/src/generated/resources/data/minecraft/recipe/blast_furnace.json +++ b/src/generated/resources/data/minecraft/recipe/blast_furnace.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:smooth_stone" - }, - "I": { - "tag": "c:ingots/iron" - }, - "X": { - "item": "minecraft:furnace" - } + "#": "minecraft:smooth_stone", + "I": "#c:ingots/iron", + "X": "minecraft:furnace" }, "pattern": [ "III", diff --git a/src/generated/resources/data/minecraft/recipe/blue_banner.json b/src/generated/resources/data/minecraft/recipe/blue_banner.json index afb3cddb99..a98940c6b1 100644 --- a/src/generated/resources/data/minecraft/recipe/blue_banner.json +++ b/src/generated/resources/data/minecraft/recipe/blue_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:blue_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:blue_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/blue_candle.json b/src/generated/resources/data/minecraft/recipe/blue_candle.json new file mode 100644 index 0000000000..34f5806015 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/blue_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/blue" + ], + "result": { + "count": 1, + "id": "minecraft:blue_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/blue_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/blue_concrete_powder.json new file mode 100644 index 0000000000..0c04ee5a59 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/blue_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/blue", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:blue_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/blue_stained_glass.json b/src/generated/resources/data/minecraft/recipe/blue_stained_glass.json new file mode 100644 index 0000000000..d58eff4d56 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/blue_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/blue" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:blue_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/blue_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/blue_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..02431bf00f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/blue_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/blue" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:blue_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/blue_terracotta.json b/src/generated/resources/data/minecraft/recipe/blue_terracotta.json new file mode 100644 index 0000000000..58d3ee058c --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/blue_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/blue" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:blue_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/bolt_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/bolt_armor_trim_smithing_template.json index c7dcf7ebff..e5db16797d 100644 --- a/src/generated/resources/data/minecraft/recipe/bolt_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/bolt_armor_trim_smithing_template.json @@ -2,20 +2,12 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, + "#": "#c:gems/diamond", "C": [ - { - "item": "minecraft:copper_block" - }, - { - "item": "minecraft:waxed_copper_block" - } + "minecraft:copper_block", + "minecraft:waxed_copper_block" ], - "S": { - "item": "minecraft:bolt_armor_trim_smithing_template" - } + "S": "minecraft:bolt_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/bow.json b/src/generated/resources/data/minecraft/recipe/bow.json index b531f496f4..5831fc36f1 100644 --- a/src/generated/resources/data/minecraft/recipe/bow.json +++ b/src/generated/resources/data/minecraft/recipe/bow.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:strings" - } + "#": "#c:rods/wooden", + "X": "#c:strings" }, "pattern": [ " #X", diff --git a/src/generated/resources/data/minecraft/recipe/brown_banner.json b/src/generated/resources/data/minecraft/recipe/brown_banner.json index b3b8c24a19..5394a3d33c 100644 --- a/src/generated/resources/data/minecraft/recipe/brown_banner.json +++ b/src/generated/resources/data/minecraft/recipe/brown_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:brown_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:brown_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/brown_candle.json b/src/generated/resources/data/minecraft/recipe/brown_candle.json new file mode 100644 index 0000000000..730b80253d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/brown_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/brown" + ], + "result": { + "count": 1, + "id": "minecraft:brown_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/brown_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/brown_concrete_powder.json new file mode 100644 index 0000000000..32a7ffd0b3 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/brown_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/brown", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:brown_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/brown_stained_glass.json b/src/generated/resources/data/minecraft/recipe/brown_stained_glass.json new file mode 100644 index 0000000000..a74be3067e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/brown_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/brown" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:brown_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/brown_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/brown_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..0ab288f7b7 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/brown_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/brown" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:brown_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/brown_terracotta.json b/src/generated/resources/data/minecraft/recipe/brown_terracotta.json new file mode 100644 index 0000000000..1447b2e5fa --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/brown_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/brown" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:brown_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/brush.json b/src/generated/resources/data/minecraft/recipe/brush.json index ff366537c6..4fc5863cee 100644 --- a/src/generated/resources/data/minecraft/recipe/brush.json +++ b/src/generated/resources/data/minecraft/recipe/brush.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/copper" - }, - "I": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:feather" - } + "#": "#c:ingots/copper", + "I": "#c:rods/wooden", + "X": "minecraft:feather" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/bucket.json b/src/generated/resources/data/minecraft/recipe/bucket.json index 6da8ba3ded..692ea8b728 100644 --- a/src/generated/resources/data/minecraft/recipe/bucket.json +++ b/src/generated/resources/data/minecraft/recipe/bucket.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "# #", diff --git a/src/generated/resources/data/minecraft/recipe/bundle.json b/src/generated/resources/data/minecraft/recipe/bundle.json new file mode 100644 index 0000000000..fb9cad8657 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/bundle.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": "minecraft:leather", + "-": "#c:strings" + }, + "pattern": [ + "-", + "#" + ], + "result": { + "count": 1, + "id": "minecraft:bundle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/calibrated_sculk_sensor.json b/src/generated/resources/data/minecraft/recipe/calibrated_sculk_sensor.json index 5cb919ad6c..7b748c17a2 100644 --- a/src/generated/resources/data/minecraft/recipe/calibrated_sculk_sensor.json +++ b/src/generated/resources/data/minecraft/recipe/calibrated_sculk_sensor.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:gems/amethyst" - }, - "X": { - "item": "minecraft:sculk_sensor" - } + "#": "#c:gems/amethyst", + "X": "minecraft:sculk_sensor" }, "pattern": [ " # ", diff --git a/src/generated/resources/data/minecraft/recipe/campfire.json b/src/generated/resources/data/minecraft/recipe/campfire.json index de8dffe49a..fd2f337523 100644 --- a/src/generated/resources/data/minecraft/recipe/campfire.json +++ b/src/generated/resources/data/minecraft/recipe/campfire.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "C": { - "tag": "minecraft:coals" - }, - "L": { - "tag": "minecraft:logs" - }, - "S": { - "tag": "c:rods/wooden" - } + "C": "#minecraft:coals", + "L": "#minecraft:logs", + "S": "#c:rods/wooden" }, "pattern": [ " S ", diff --git a/src/generated/resources/data/minecraft/recipe/candle.json b/src/generated/resources/data/minecraft/recipe/candle.json index c19d2b0e7b..6cb6864e6b 100644 --- a/src/generated/resources/data/minecraft/recipe/candle.json +++ b/src/generated/resources/data/minecraft/recipe/candle.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "H": { - "item": "minecraft:honeycomb" - }, - "S": { - "tag": "c:strings" - } + "H": "minecraft:honeycomb", + "S": "#c:strings" }, "pattern": [ "S", diff --git a/src/generated/resources/data/minecraft/recipe/cauldron.json b/src/generated/resources/data/minecraft/recipe/cauldron.json index 9fbb8b5af2..101a0b54d6 100644 --- a/src/generated/resources/data/minecraft/recipe/cauldron.json +++ b/src/generated/resources/data/minecraft/recipe/cauldron.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "# #", diff --git a/src/generated/resources/data/minecraft/recipe/chain.json b/src/generated/resources/data/minecraft/recipe/chain.json index 057c9304ce..5e16cbe16e 100644 --- a/src/generated/resources/data/minecraft/recipe/chain.json +++ b/src/generated/resources/data/minecraft/recipe/chain.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "I": { - "tag": "c:ingots/iron" - }, - "N": { - "tag": "c:nuggets/iron" - } + "I": "#c:ingots/iron", + "N": "#c:nuggets/iron" }, "pattern": [ "N", diff --git a/src/generated/resources/data/minecraft/recipe/cherry_chest_boat.json b/src/generated/resources/data/minecraft/recipe/cherry_chest_boat.json index c5806df844..1a6fb591c0 100644 --- a/src/generated/resources/data/minecraft/recipe/cherry_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/cherry_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:cherry_boat" - } + "minecraft:cherry_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/cherry_fence.json b/src/generated/resources/data/minecraft/recipe/cherry_fence.json index c199386881..9866480fe0 100644 --- a/src/generated/resources/data/minecraft/recipe/cherry_fence.json +++ b/src/generated/resources/data/minecraft/recipe/cherry_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:cherry_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:cherry_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/cherry_fence_gate.json b/src/generated/resources/data/minecraft/recipe/cherry_fence_gate.json index d3f7509557..7ad275d012 100644 --- a/src/generated/resources/data/minecraft/recipe/cherry_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/cherry_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:cherry_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:cherry_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/cherry_sign.json b/src/generated/resources/data/minecraft/recipe/cherry_sign.json index fbd15b6ef9..000659bd4a 100644 --- a/src/generated/resources/data/minecraft/recipe/cherry_sign.json +++ b/src/generated/resources/data/minecraft/recipe/cherry_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:cherry_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:cherry_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/chest_minecart.json b/src/generated/resources/data/minecraft/recipe/chest_minecart.json index 160f781384..961f895291 100644 --- a/src/generated/resources/data/minecraft/recipe/chest_minecart.json +++ b/src/generated/resources/data/minecraft/recipe/chest_minecart.json @@ -3,17 +3,11 @@ "category": "misc", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:minecart" - } + "minecraft:minecart" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/clock.json b/src/generated/resources/data/minecraft/recipe/clock.json index 276fe557ef..0ffa5dfe00 100644 --- a/src/generated/resources/data/minecraft/recipe/clock.json +++ b/src/generated/resources/data/minecraft/recipe/clock.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/gold" - }, - "X": { - "item": "minecraft:redstone" - } + "#": "#c:ingots/gold", + "X": "minecraft:redstone" }, "pattern": [ " # ", diff --git a/src/generated/resources/data/minecraft/recipe/coast_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/coast_armor_trim_smithing_template.json index b507e536a1..91af5fbabf 100644 --- a/src/generated/resources/data/minecraft/recipe/coast_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/coast_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "c:cobblestones/normal" - }, - "S": { - "item": "minecraft:coast_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#c:cobblestones/normal", + "S": "minecraft:coast_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/compass.json b/src/generated/resources/data/minecraft/recipe/compass.json index 3c7cbcb015..89310bdf95 100644 --- a/src/generated/resources/data/minecraft/recipe/compass.json +++ b/src/generated/resources/data/minecraft/recipe/compass.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/iron" - }, - "X": { - "item": "minecraft:redstone" - } + "#": "#c:ingots/iron", + "X": "minecraft:redstone" }, "pattern": [ " # ", diff --git a/src/generated/resources/data/minecraft/recipe/copper_door.json b/src/generated/resources/data/minecraft/recipe/copper_door.json index b4010399b8..544440c5c7 100644 --- a/src/generated/resources/data/minecraft/recipe/copper_door.json +++ b/src/generated/resources/data/minecraft/recipe/copper_door.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/copper" - } + "#": "#c:ingots/copper" }, "pattern": [ "##", diff --git a/src/generated/resources/data/minecraft/recipe/copper_trapdoor.json b/src/generated/resources/data/minecraft/recipe/copper_trapdoor.json index 2e8d8efe09..2a117e7c5b 100644 --- a/src/generated/resources/data/minecraft/recipe/copper_trapdoor.json +++ b/src/generated/resources/data/minecraft/recipe/copper_trapdoor.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/copper" - } + "#": "#c:ingots/copper" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/crafter.json b/src/generated/resources/data/minecraft/recipe/crafter.json index b01e9c2509..8db88e0466 100644 --- a/src/generated/resources/data/minecraft/recipe/crafter.json +++ b/src/generated/resources/data/minecraft/recipe/crafter.json @@ -2,18 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - }, - "C": { - "item": "minecraft:crafting_table" - }, - "D": { - "item": "minecraft:dropper" - }, - "R": { - "item": "minecraft:redstone" - } + "#": "#c:ingots/iron", + "C": "minecraft:crafting_table", + "D": "minecraft:dropper", + "R": "minecraft:redstone" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/crimson_fence.json b/src/generated/resources/data/minecraft/recipe/crimson_fence.json index 7b9e174282..20e9d8a6e3 100644 --- a/src/generated/resources/data/minecraft/recipe/crimson_fence.json +++ b/src/generated/resources/data/minecraft/recipe/crimson_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:crimson_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:crimson_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/crimson_fence_gate.json b/src/generated/resources/data/minecraft/recipe/crimson_fence_gate.json index 6953799156..fdbdfa0f4b 100644 --- a/src/generated/resources/data/minecraft/recipe/crimson_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/crimson_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:crimson_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:crimson_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/crimson_sign.json b/src/generated/resources/data/minecraft/recipe/crimson_sign.json index 3bb6d2cd40..b175242019 100644 --- a/src/generated/resources/data/minecraft/recipe/crimson_sign.json +++ b/src/generated/resources/data/minecraft/recipe/crimson_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:crimson_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:crimson_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/crossbow.json b/src/generated/resources/data/minecraft/recipe/crossbow.json index 87d3fb5baf..96364225e1 100644 --- a/src/generated/resources/data/minecraft/recipe/crossbow.json +++ b/src/generated/resources/data/minecraft/recipe/crossbow.json @@ -2,18 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "$": { - "item": "minecraft:tripwire_hook" - }, - "&": { - "tag": "c:ingots/iron" - }, - "~": { - "tag": "c:strings" - } + "#": "#c:rods/wooden", + "$": "minecraft:tripwire_hook", + "&": "#c:ingots/iron", + "~": "#c:strings" }, "pattern": [ "#&#", diff --git a/src/generated/resources/data/minecraft/recipe/cyan_banner.json b/src/generated/resources/data/minecraft/recipe/cyan_banner.json index 7c029672c6..2efc2367e5 100644 --- a/src/generated/resources/data/minecraft/recipe/cyan_banner.json +++ b/src/generated/resources/data/minecraft/recipe/cyan_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:cyan_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:cyan_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/cyan_candle.json b/src/generated/resources/data/minecraft/recipe/cyan_candle.json new file mode 100644 index 0000000000..50c38c52c7 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/cyan" + ], + "result": { + "count": 1, + "id": "minecraft:cyan_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/cyan_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/cyan_concrete_powder.json new file mode 100644 index 0000000000..376392655e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/cyan", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:cyan_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/cyan_dye.json b/src/generated/resources/data/minecraft/recipe/cyan_dye.json new file mode 100644 index 0000000000..da65344e0d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_dye.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "cyan_dye", + "ingredients": [ + "#c:dyes/blue", + "#c:dyes/green" + ], + "result": { + "count": 2, + "id": "minecraft:cyan_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/cyan_stained_glass.json b/src/generated/resources/data/minecraft/recipe/cyan_stained_glass.json new file mode 100644 index 0000000000..a7981f9ac7 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/cyan" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:cyan_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/cyan_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/cyan_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..007546af61 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/cyan" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:cyan_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/cyan_terracotta.json b/src/generated/resources/data/minecraft/recipe/cyan_terracotta.json new file mode 100644 index 0000000000..ed9858a7f6 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/cyan_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/cyan" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:cyan_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dark_oak_chest_boat.json b/src/generated/resources/data/minecraft/recipe/dark_oak_chest_boat.json index 8396336c72..e7dd8b53d2 100644 --- a/src/generated/resources/data/minecraft/recipe/dark_oak_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/dark_oak_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:dark_oak_boat" - } + "minecraft:dark_oak_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/dark_oak_fence.json b/src/generated/resources/data/minecraft/recipe/dark_oak_fence.json index ba37e3f888..d5c3933be8 100644 --- a/src/generated/resources/data/minecraft/recipe/dark_oak_fence.json +++ b/src/generated/resources/data/minecraft/recipe/dark_oak_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:dark_oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:dark_oak_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/dark_oak_fence_gate.json b/src/generated/resources/data/minecraft/recipe/dark_oak_fence_gate.json index b8365d4a28..d7db1861f2 100644 --- a/src/generated/resources/data/minecraft/recipe/dark_oak_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/dark_oak_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:dark_oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:dark_oak_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/dark_oak_sign.json b/src/generated/resources/data/minecraft/recipe/dark_oak_sign.json index 4d53a6d24f..aeb6ace8bf 100644 --- a/src/generated/resources/data/minecraft/recipe/dark_oak_sign.json +++ b/src/generated/resources/data/minecraft/recipe/dark_oak_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:dark_oak_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:dark_oak_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/dark_prismarine.json b/src/generated/resources/data/minecraft/recipe/dark_prismarine.json new file mode 100644 index 0000000000..c81c46bf21 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dark_prismarine.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "key": { + "I": "#c:dyes/black", + "S": "minecraft:prismarine_shard" + }, + "pattern": [ + "SSS", + "SIS", + "SSS" + ], + "result": { + "count": 1, + "id": "minecraft:dark_prismarine" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/detector_rail.json b/src/generated/resources/data/minecraft/recipe/detector_rail.json index 97238ca6e4..aa0d8b1f83 100644 --- a/src/generated/resources/data/minecraft/recipe/detector_rail.json +++ b/src/generated/resources/data/minecraft/recipe/detector_rail.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:stone_pressure_plate" - }, - "R": { - "item": "minecraft:redstone" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "minecraft:stone_pressure_plate", + "R": "minecraft:redstone", + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_axe.json b/src/generated/resources/data/minecraft/recipe/diamond_axe.json index 118f99e563..81cfd04879 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_axe.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_boots.json b/src/generated/resources/data/minecraft/recipe/diamond_boots.json index 7d6ace85e7..38ea7f8e5d 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_boots.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_boots.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_chestplate.json b/src/generated/resources/data/minecraft/recipe/diamond_chestplate.json index 46ad865dff..bace9a7d21 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_chestplate.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_chestplate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_helmet.json b/src/generated/resources/data/minecraft/recipe/diamond_helmet.json index 50a88a0967..59067194a0 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_helmet.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_helmet.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_hoe.json b/src/generated/resources/data/minecraft/recipe/diamond_hoe.json index b2bf02dd07..6a770c0452 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_hoe.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_leggings.json b/src/generated/resources/data/minecraft/recipe/diamond_leggings.json index 5df5635836..7992a0d478 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_leggings.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_leggings.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:gems/diamond" - } + "X": "#c:gems/diamond" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_pickaxe.json b/src/generated/resources/data/minecraft/recipe/diamond_pickaxe.json index 3397993a01..bc06ce4af1 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_shovel.json b/src/generated/resources/data/minecraft/recipe/diamond_shovel.json index ae4f9eb985..ff947a6fd7 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_shovel.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/diamond_sword.json b/src/generated/resources/data/minecraft/recipe/diamond_sword.json index 338ca63240..cb872879e7 100644 --- a/src/generated/resources/data/minecraft/recipe/diamond_sword.json +++ b/src/generated/resources/data/minecraft/recipe/diamond_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#c:rods/wooden", + "X": "#minecraft:diamond_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/diorite.json b/src/generated/resources/data/minecraft/recipe/diorite.json index 54714b8f40..35427a7339 100644 --- a/src/generated/resources/data/minecraft/recipe/diorite.json +++ b/src/generated/resources/data/minecraft/recipe/diorite.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "C": { - "tag": "c:cobblestones/normal" - }, - "Q": { - "item": "minecraft:quartz" - } + "C": "#c:cobblestones/normal", + "Q": "minecraft:quartz" }, "pattern": [ "CQ", diff --git a/src/generated/resources/data/minecraft/recipe/dispenser.json b/src/generated/resources/data/minecraft/recipe/dispenser.json index 6ab105c14c..08d2b51f71 100644 --- a/src/generated/resources/data/minecraft/recipe/dispenser.json +++ b/src/generated/resources/data/minecraft/recipe/dispenser.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:cobblestones/normal" - }, - "R": { - "item": "minecraft:redstone" - }, - "X": { - "item": "minecraft:bow" - } + "#": "#c:cobblestones/normal", + "R": "minecraft:redstone", + "X": "minecraft:bow" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/dropper.json b/src/generated/resources/data/minecraft/recipe/dropper.json index e358894ca7..a079f7c193 100644 --- a/src/generated/resources/data/minecraft/recipe/dropper.json +++ b/src/generated/resources/data/minecraft/recipe/dropper.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:cobblestones/normal" - }, - "R": { - "item": "minecraft:redstone" - } + "#": "#c:cobblestones/normal", + "R": "minecraft:redstone" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/dune_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/dune_armor_trim_smithing_template.json index 905e1f3f0d..a732119fe5 100644 --- a/src/generated/resources/data/minecraft/recipe/dune_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/dune_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:sandstone" - }, - "S": { - "item": "minecraft:dune_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:sandstone", + "S": "minecraft:dune_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/dye_black_bed.json b/src/generated/resources/data/minecraft/recipe/dye_black_bed.json new file mode 100644 index 0000000000..46ce620b7f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_black_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/black", + [ + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:black_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_black_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_black_carpet.json new file mode 100644 index 0000000000..24345b7688 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_black_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/black", + [ + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:black_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_black_wool.json b/src/generated/resources/data/minecraft/recipe/dye_black_wool.json new file mode 100644 index 0000000000..4b00f9de04 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_black_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/black", + [ + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:black_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_blue_bed.json b/src/generated/resources/data/minecraft/recipe/dye_blue_bed.json new file mode 100644 index 0000000000..1addcaaf89 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_blue_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/blue", + [ + "minecraft:black_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:blue_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_blue_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_blue_carpet.json new file mode 100644 index 0000000000..f936b365bb --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_blue_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/blue", + [ + "minecraft:black_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:blue_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_blue_wool.json b/src/generated/resources/data/minecraft/recipe/dye_blue_wool.json new file mode 100644 index 0000000000..1e41106f6c --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_blue_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/blue", + [ + "minecraft:black_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:blue_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_brown_bed.json b/src/generated/resources/data/minecraft/recipe/dye_brown_bed.json new file mode 100644 index 0000000000..acd45c9cd7 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_brown_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/brown", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:brown_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_brown_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_brown_carpet.json new file mode 100644 index 0000000000..40fd195def --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_brown_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/brown", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:brown_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_brown_wool.json b/src/generated/resources/data/minecraft/recipe/dye_brown_wool.json new file mode 100644 index 0000000000..ce7255818f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_brown_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/brown", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:brown_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_cyan_bed.json b/src/generated/resources/data/minecraft/recipe/dye_cyan_bed.json new file mode 100644 index 0000000000..58c42b416a --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_cyan_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/cyan", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:cyan_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_cyan_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_cyan_carpet.json new file mode 100644 index 0000000000..d35689356c --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_cyan_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/cyan", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:cyan_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_cyan_wool.json b/src/generated/resources/data/minecraft/recipe/dye_cyan_wool.json new file mode 100644 index 0000000000..3c6551327f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_cyan_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/cyan", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:cyan_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_gray_bed.json b/src/generated/resources/data/minecraft/recipe/dye_gray_bed.json new file mode 100644 index 0000000000..e65ec79aa5 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_gray_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/gray", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:gray_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_gray_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_gray_carpet.json new file mode 100644 index 0000000000..0c93c78cb5 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_gray_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/gray", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:gray_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_gray_wool.json b/src/generated/resources/data/minecraft/recipe/dye_gray_wool.json new file mode 100644 index 0000000000..54b7a841c2 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_gray_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/gray", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:gray_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_green_bed.json b/src/generated/resources/data/minecraft/recipe/dye_green_bed.json new file mode 100644 index 0000000000..d743ad317a --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_green_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/green", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:green_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_green_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_green_carpet.json new file mode 100644 index 0000000000..575f6b4ef6 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_green_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/green", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:green_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_green_wool.json b/src/generated/resources/data/minecraft/recipe/dye_green_wool.json new file mode 100644 index 0000000000..63e86df341 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_green_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/green", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:green_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_blue_bed.json b/src/generated/resources/data/minecraft/recipe/dye_light_blue_bed.json new file mode 100644 index 0000000000..fd5df881e0 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_blue_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/light_blue", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_blue_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_blue_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_light_blue_carpet.json new file mode 100644 index 0000000000..b9f92de4d2 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_blue_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/light_blue", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_blue_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_blue_wool.json b/src/generated/resources/data/minecraft/recipe/dye_light_blue_wool.json new file mode 100644 index 0000000000..9c97901ec9 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_blue_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/light_blue", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_blue_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_gray_bed.json b/src/generated/resources/data/minecraft/recipe/dye_light_gray_bed.json new file mode 100644 index 0000000000..9a859ed12f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_gray_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/light_gray", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_gray_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_gray_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_light_gray_carpet.json new file mode 100644 index 0000000000..f0d0c19aab --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_gray_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/light_gray", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_gray_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_light_gray_wool.json b/src/generated/resources/data/minecraft/recipe/dye_light_gray_wool.json new file mode 100644 index 0000000000..701df4f96e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_light_gray_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/light_gray", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:light_gray_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_lime_bed.json b/src/generated/resources/data/minecraft/recipe/dye_lime_bed.json new file mode 100644 index 0000000000..af4ec42f52 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_lime_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/lime", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:lime_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_lime_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_lime_carpet.json new file mode 100644 index 0000000000..4a0a8df0ce --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_lime_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/lime", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:lime_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_lime_wool.json b/src/generated/resources/data/minecraft/recipe/dye_lime_wool.json new file mode 100644 index 0000000000..9cfaecd17a --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_lime_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/lime", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:lime_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_magenta_bed.json b/src/generated/resources/data/minecraft/recipe/dye_magenta_bed.json new file mode 100644 index 0000000000..f6683771f7 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_magenta_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/magenta", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:magenta_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_magenta_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_magenta_carpet.json new file mode 100644 index 0000000000..7e97162ed4 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_magenta_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/magenta", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:magenta_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_magenta_wool.json b/src/generated/resources/data/minecraft/recipe/dye_magenta_wool.json new file mode 100644 index 0000000000..b5cb50c8c0 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_magenta_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/magenta", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:magenta_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_orange_bed.json b/src/generated/resources/data/minecraft/recipe/dye_orange_bed.json new file mode 100644 index 0000000000..4f051cff93 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_orange_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/orange", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:orange_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_orange_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_orange_carpet.json new file mode 100644 index 0000000000..a4271e5768 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_orange_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/orange", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:orange_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_orange_wool.json b/src/generated/resources/data/minecraft/recipe/dye_orange_wool.json new file mode 100644 index 0000000000..0b89a2fe23 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_orange_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/orange", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:orange_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_pink_bed.json b/src/generated/resources/data/minecraft/recipe/dye_pink_bed.json new file mode 100644 index 0000000000..6c59760629 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_pink_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/pink", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:pink_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_pink_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_pink_carpet.json new file mode 100644 index 0000000000..bda90f993c --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_pink_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/pink", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:pink_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_pink_wool.json b/src/generated/resources/data/minecraft/recipe/dye_pink_wool.json new file mode 100644 index 0000000000..bb15342a01 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_pink_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/pink", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:pink_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_purple_bed.json b/src/generated/resources/data/minecraft/recipe/dye_purple_bed.json new file mode 100644 index 0000000000..ab9de93037 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_purple_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/purple", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:red_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:purple_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_purple_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_purple_carpet.json new file mode 100644 index 0000000000..1c23eee26b --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_purple_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/purple", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:purple_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_purple_wool.json b/src/generated/resources/data/minecraft/recipe/dye_purple_wool.json new file mode 100644 index 0000000000..8d26252d27 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_purple_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/purple", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:red_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:purple_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_red_bed.json b/src/generated/resources/data/minecraft/recipe/dye_red_bed.json new file mode 100644 index 0000000000..1fe4e977a4 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_red_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/red", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:yellow_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:red_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_red_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_red_carpet.json new file mode 100644 index 0000000000..5d778fac1c --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_red_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/red", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:yellow_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:red_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_red_wool.json b/src/generated/resources/data/minecraft/recipe/dye_red_wool.json new file mode 100644 index 0000000000..cfd0569b72 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_red_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/red", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:yellow_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:red_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_white_bed.json b/src/generated/resources/data/minecraft/recipe/dye_white_bed.json new file mode 100644 index 0000000000..759f3294d7 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_white_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/white", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:yellow_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:white_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_white_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_white_carpet.json new file mode 100644 index 0000000000..9065897b86 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_white_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/white", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:yellow_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:white_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_white_wool.json b/src/generated/resources/data/minecraft/recipe/dye_white_wool.json new file mode 100644 index 0000000000..f88f447f88 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_white_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/white", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:yellow_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:white_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_yellow_bed.json b/src/generated/resources/data/minecraft/recipe/dye_yellow_bed.json new file mode 100644 index 0000000000..f336bb857f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_yellow_bed.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "bed", + "ingredients": [ + "#c:dyes/yellow", + [ + "minecraft:black_bed", + "minecraft:blue_bed", + "minecraft:brown_bed", + "minecraft:cyan_bed", + "minecraft:gray_bed", + "minecraft:green_bed", + "minecraft:light_blue_bed", + "minecraft:light_gray_bed", + "minecraft:lime_bed", + "minecraft:magenta_bed", + "minecraft:orange_bed", + "minecraft:pink_bed", + "minecraft:purple_bed", + "minecraft:red_bed", + "minecraft:white_bed" + ] + ], + "result": { + "count": 1, + "id": "minecraft:yellow_bed" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_yellow_carpet.json b/src/generated/resources/data/minecraft/recipe/dye_yellow_carpet.json new file mode 100644 index 0000000000..81f9c193b8 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_yellow_carpet.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "carpet", + "ingredients": [ + "#c:dyes/yellow", + [ + "minecraft:black_carpet", + "minecraft:blue_carpet", + "minecraft:brown_carpet", + "minecraft:cyan_carpet", + "minecraft:gray_carpet", + "minecraft:green_carpet", + "minecraft:light_blue_carpet", + "minecraft:light_gray_carpet", + "minecraft:lime_carpet", + "minecraft:magenta_carpet", + "minecraft:orange_carpet", + "minecraft:pink_carpet", + "minecraft:purple_carpet", + "minecraft:red_carpet", + "minecraft:white_carpet" + ] + ], + "result": { + "count": 1, + "id": "minecraft:yellow_carpet" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/dye_yellow_wool.json b/src/generated/resources/data/minecraft/recipe/dye_yellow_wool.json new file mode 100644 index 0000000000..7cb4a1f1ca --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/dye_yellow_wool.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "wool", + "ingredients": [ + "#c:dyes/yellow", + [ + "minecraft:black_wool", + "minecraft:blue_wool", + "minecraft:brown_wool", + "minecraft:cyan_wool", + "minecraft:gray_wool", + "minecraft:green_wool", + "minecraft:light_blue_wool", + "minecraft:light_gray_wool", + "minecraft:lime_wool", + "minecraft:magenta_wool", + "minecraft:orange_wool", + "minecraft:pink_wool", + "minecraft:purple_wool", + "minecraft:red_wool", + "minecraft:white_wool" + ] + ], + "result": { + "count": 1, + "id": "minecraft:yellow_wool" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/enchanting_table.json b/src/generated/resources/data/minecraft/recipe/enchanting_table.json index 0b202c954e..a18e62aa60 100644 --- a/src/generated/resources/data/minecraft/recipe/enchanting_table.json +++ b/src/generated/resources/data/minecraft/recipe/enchanting_table.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:obsidian" - }, - "B": { - "item": "minecraft:book" - }, - "D": { - "tag": "c:gems/diamond" - } + "#": "minecraft:obsidian", + "B": "minecraft:book", + "D": "#c:gems/diamond" }, "pattern": [ " B ", diff --git a/src/generated/resources/data/minecraft/recipe/eye_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/eye_armor_trim_smithing_template.json index f4183152ba..24c0e2e4ad 100644 --- a/src/generated/resources/data/minecraft/recipe/eye_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/eye_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:end_stone" - }, - "S": { - "item": "minecraft:eye_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:end_stone", + "S": "minecraft:eye_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/fishing_rod.json b/src/generated/resources/data/minecraft/recipe/fishing_rod.json index 72690672d3..8308c1ef46 100644 --- a/src/generated/resources/data/minecraft/recipe/fishing_rod.json +++ b/src/generated/resources/data/minecraft/recipe/fishing_rod.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:strings" - } + "#": "#c:rods/wooden", + "X": "#c:strings" }, "pattern": [ " #", diff --git a/src/generated/resources/data/minecraft/recipe/flint_and_steel.json b/src/generated/resources/data/minecraft/recipe/flint_and_steel.json index c1ecbca55f..291b18605e 100644 --- a/src/generated/resources/data/minecraft/recipe/flint_and_steel.json +++ b/src/generated/resources/data/minecraft/recipe/flint_and_steel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "equipment", "ingredients": [ - { - "tag": "c:ingots/iron" - }, - { - "item": "minecraft:flint" - } + "#c:ingots/iron", + "minecraft:flint" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/flow_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/flow_armor_trim_smithing_template.json index 3b8d02a56d..958fdf6b4c 100644 --- a/src/generated/resources/data/minecraft/recipe/flow_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/flow_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:breeze_rod" - }, - "S": { - "item": "minecraft:flow_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:breeze_rod", + "S": "minecraft:flow_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/glistering_melon_slice.json b/src/generated/resources/data/minecraft/recipe/glistering_melon_slice.json index 52c02f8057..d9f7cb56c0 100644 --- a/src/generated/resources/data/minecraft/recipe/glistering_melon_slice.json +++ b/src/generated/resources/data/minecraft/recipe/glistering_melon_slice.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:nuggets/gold" - }, - "X": { - "item": "minecraft:melon_slice" - } + "#": "#c:nuggets/gold", + "X": "minecraft:melon_slice" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/gold_ingot_from_nuggets.json b/src/generated/resources/data/minecraft/recipe/gold_ingot_from_nuggets.json index ca6e7b8674..e1e752fdac 100644 --- a/src/generated/resources/data/minecraft/recipe/gold_ingot_from_nuggets.json +++ b/src/generated/resources/data/minecraft/recipe/gold_ingot_from_nuggets.json @@ -3,9 +3,7 @@ "category": "misc", "group": "gold_ingot", "key": { - "#": { - "tag": "c:nuggets/gold" - } + "#": "#c:nuggets/gold" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/golden_apple.json b/src/generated/resources/data/minecraft/recipe/golden_apple.json index 6839d31d1e..0a029564aa 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_apple.json +++ b/src/generated/resources/data/minecraft/recipe/golden_apple.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/gold" - }, - "X": { - "item": "minecraft:apple" - } + "#": "#c:ingots/gold", + "X": "minecraft:apple" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/golden_axe.json b/src/generated/resources/data/minecraft/recipe/golden_axe.json index ed95ebdd0a..aad3355e76 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_axe.json +++ b/src/generated/resources/data/minecraft/recipe/golden_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/golden_boots.json b/src/generated/resources/data/minecraft/recipe/golden_boots.json index 0b9010aa3c..baede9b2b0 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_boots.json +++ b/src/generated/resources/data/minecraft/recipe/golden_boots.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/golden_carrot.json b/src/generated/resources/data/minecraft/recipe/golden_carrot.json index 444588c03d..de1984305c 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_carrot.json +++ b/src/generated/resources/data/minecraft/recipe/golden_carrot.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:nuggets/gold" - }, - "X": { - "item": "minecraft:carrot" - } + "#": "#c:nuggets/gold", + "X": "minecraft:carrot" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/golden_chestplate.json b/src/generated/resources/data/minecraft/recipe/golden_chestplate.json index edd79c9908..44610c5b75 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_chestplate.json +++ b/src/generated/resources/data/minecraft/recipe/golden_chestplate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/golden_helmet.json b/src/generated/resources/data/minecraft/recipe/golden_helmet.json index f275fa7514..77e0c12be8 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_helmet.json +++ b/src/generated/resources/data/minecraft/recipe/golden_helmet.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/golden_hoe.json b/src/generated/resources/data/minecraft/recipe/golden_hoe.json index 6a305f1b18..6a31db7ec1 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_hoe.json +++ b/src/generated/resources/data/minecraft/recipe/golden_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/golden_leggings.json b/src/generated/resources/data/minecraft/recipe/golden_leggings.json index 54c8ae061e..6ffc3edd1c 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_leggings.json +++ b/src/generated/resources/data/minecraft/recipe/golden_leggings.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/gold" - } + "X": "#c:ingots/gold" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/golden_pickaxe.json b/src/generated/resources/data/minecraft/recipe/golden_pickaxe.json index be94e94d06..7e88522f3e 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipe/golden_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/golden_shovel.json b/src/generated/resources/data/minecraft/recipe/golden_shovel.json index b71a44cb47..ed7b535236 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_shovel.json +++ b/src/generated/resources/data/minecraft/recipe/golden_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/golden_sword.json b/src/generated/resources/data/minecraft/recipe/golden_sword.json index fdfc713b40..a400bb8117 100644 --- a/src/generated/resources/data/minecraft/recipe/golden_sword.json +++ b/src/generated/resources/data/minecraft/recipe/golden_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "X": "#minecraft:gold_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/gray_banner.json b/src/generated/resources/data/minecraft/recipe/gray_banner.json index 9a36e40aed..75e5ac3ebe 100644 --- a/src/generated/resources/data/minecraft/recipe/gray_banner.json +++ b/src/generated/resources/data/minecraft/recipe/gray_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:gray_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:gray_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/gray_candle.json b/src/generated/resources/data/minecraft/recipe/gray_candle.json new file mode 100644 index 0000000000..ef9a61dea2 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/gray" + ], + "result": { + "count": 1, + "id": "minecraft:gray_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/gray_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/gray_concrete_powder.json new file mode 100644 index 0000000000..11e77a047c --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/gray", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:gray_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/gray_dye.json b/src/generated/resources/data/minecraft/recipe/gray_dye.json new file mode 100644 index 0000000000..eaf25e280f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_dye.json @@ -0,0 +1,12 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + "#c:dyes/black", + "#c:dyes/white" + ], + "result": { + "count": 2, + "id": "minecraft:gray_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/gray_stained_glass.json b/src/generated/resources/data/minecraft/recipe/gray_stained_glass.json new file mode 100644 index 0000000000..6944a3a0e3 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/gray" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:gray_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/gray_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/gray_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..d73c5334d2 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/gray" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:gray_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/gray_terracotta.json b/src/generated/resources/data/minecraft/recipe/gray_terracotta.json new file mode 100644 index 0000000000..4aa191b3f9 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/gray_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/gray" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:gray_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/green_banner.json b/src/generated/resources/data/minecraft/recipe/green_banner.json index 3960ffd83b..e18d67a1f3 100644 --- a/src/generated/resources/data/minecraft/recipe/green_banner.json +++ b/src/generated/resources/data/minecraft/recipe/green_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:green_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:green_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/green_candle.json b/src/generated/resources/data/minecraft/recipe/green_candle.json new file mode 100644 index 0000000000..a95ce3d9d7 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/green_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/green" + ], + "result": { + "count": 1, + "id": "minecraft:green_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/green_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/green_concrete_powder.json new file mode 100644 index 0000000000..9f5cfeab6d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/green_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/green", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:green_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/green_stained_glass.json b/src/generated/resources/data/minecraft/recipe/green_stained_glass.json new file mode 100644 index 0000000000..d2deaf8899 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/green_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/green" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:green_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/green_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/green_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..683c58b104 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/green_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/green" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:green_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/green_terracotta.json b/src/generated/resources/data/minecraft/recipe/green_terracotta.json new file mode 100644 index 0000000000..7247824388 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/green_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/green" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:green_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/grindstone.json b/src/generated/resources/data/minecraft/recipe/grindstone.json index 234b5a8e4f..5edf22f750 100644 --- a/src/generated/resources/data/minecraft/recipe/grindstone.json +++ b/src/generated/resources/data/minecraft/recipe/grindstone.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "-": { - "item": "minecraft:stone_slab" - }, - "I": { - "tag": "c:rods/wooden" - } + "#": "#minecraft:planks", + "-": "minecraft:stone_slab", + "I": "#c:rods/wooden" }, "pattern": [ "I-I", diff --git a/src/generated/resources/data/minecraft/recipe/heavy_weighted_pressure_plate.json b/src/generated/resources/data/minecraft/recipe/heavy_weighted_pressure_plate.json index ac9cd700dc..e4c401e38e 100644 --- a/src/generated/resources/data/minecraft/recipe/heavy_weighted_pressure_plate.json +++ b/src/generated/resources/data/minecraft/recipe/heavy_weighted_pressure_plate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "##" diff --git a/src/generated/resources/data/minecraft/recipe/hopper.json b/src/generated/resources/data/minecraft/recipe/hopper.json index 91bdccdd82..37560a9e85 100644 --- a/src/generated/resources/data/minecraft/recipe/hopper.json +++ b/src/generated/resources/data/minecraft/recipe/hopper.json @@ -3,17 +3,11 @@ "category": "redstone", "key": { "C": { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - "I": { - "tag": "c:ingots/iron" - } + "I": "#c:ingots/iron" }, "pattern": [ "I I", diff --git a/src/generated/resources/data/minecraft/recipe/host_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/host_armor_trim_smithing_template.json index f84de52ad6..ae84d48cc6 100644 --- a/src/generated/resources/data/minecraft/recipe/host_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/host_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:host_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:host_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/iron_axe.json b/src/generated/resources/data/minecraft/recipe/iron_axe.json index 950fa6ac7a..535479a2ba 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_axe.json +++ b/src/generated/resources/data/minecraft/recipe/iron_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/iron_bars.json b/src/generated/resources/data/minecraft/recipe/iron_bars.json index 28be431fc6..e33ecdcc4f 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_bars.json +++ b/src/generated/resources/data/minecraft/recipe/iron_bars.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/iron_boots.json b/src/generated/resources/data/minecraft/recipe/iron_boots.json index f489f382e6..459f753384 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_boots.json +++ b/src/generated/resources/data/minecraft/recipe/iron_boots.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/iron_chestplate.json b/src/generated/resources/data/minecraft/recipe/iron_chestplate.json index 67f70bc19c..42ac070a95 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_chestplate.json +++ b/src/generated/resources/data/minecraft/recipe/iron_chestplate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/iron_door.json b/src/generated/resources/data/minecraft/recipe/iron_door.json index be3bbbf4da..2155da533f 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_door.json +++ b/src/generated/resources/data/minecraft/recipe/iron_door.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "##", diff --git a/src/generated/resources/data/minecraft/recipe/iron_helmet.json b/src/generated/resources/data/minecraft/recipe/iron_helmet.json index 4b7326c79f..67b4fa7229 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_helmet.json +++ b/src/generated/resources/data/minecraft/recipe/iron_helmet.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/iron_hoe.json b/src/generated/resources/data/minecraft/recipe/iron_hoe.json index e175c35d0c..65fb6202de 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_hoe.json +++ b/src/generated/resources/data/minecraft/recipe/iron_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/iron_ingot_from_nuggets.json b/src/generated/resources/data/minecraft/recipe/iron_ingot_from_nuggets.json index 2cf9cdfd88..3880618510 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_ingot_from_nuggets.json +++ b/src/generated/resources/data/minecraft/recipe/iron_ingot_from_nuggets.json @@ -3,9 +3,7 @@ "category": "misc", "group": "iron_ingot", "key": { - "#": { - "tag": "c:nuggets/iron" - } + "#": "#c:nuggets/iron" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/iron_leggings.json b/src/generated/resources/data/minecraft/recipe/iron_leggings.json index db1ad0850c..ca4c45bc62 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_leggings.json +++ b/src/generated/resources/data/minecraft/recipe/iron_leggings.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "X": { - "tag": "c:ingots/iron" - } + "X": "#c:ingots/iron" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/iron_pickaxe.json b/src/generated/resources/data/minecraft/recipe/iron_pickaxe.json index f829c9df56..169d8f7094 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipe/iron_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/iron_shovel.json b/src/generated/resources/data/minecraft/recipe/iron_shovel.json index 5a11203af5..b436766778 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_shovel.json +++ b/src/generated/resources/data/minecraft/recipe/iron_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/iron_sword.json b/src/generated/resources/data/minecraft/recipe/iron_sword.json index 6f4c0a46cd..8c909bfa56 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_sword.json +++ b/src/generated/resources/data/minecraft/recipe/iron_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#minecraft:iron_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/iron_trapdoor.json b/src/generated/resources/data/minecraft/recipe/iron_trapdoor.json index 45d3357442..a64774b455 100644 --- a/src/generated/resources/data/minecraft/recipe/iron_trapdoor.json +++ b/src/generated/resources/data/minecraft/recipe/iron_trapdoor.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "##", diff --git a/src/generated/resources/data/minecraft/recipe/item_frame.json b/src/generated/resources/data/minecraft/recipe/item_frame.json index f73e86feb5..9daf39f512 100644 --- a/src/generated/resources/data/minecraft/recipe/item_frame.json +++ b/src/generated/resources/data/minecraft/recipe/item_frame.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:leather" - } + "#": "#c:rods/wooden", + "X": "minecraft:leather" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/jukebox.json b/src/generated/resources/data/minecraft/recipe/jukebox.json index 08f3d3b4d3..c7c109d95f 100644 --- a/src/generated/resources/data/minecraft/recipe/jukebox.json +++ b/src/generated/resources/data/minecraft/recipe/jukebox.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "X": { - "tag": "c:gems/diamond" - } + "#": "#minecraft:planks", + "X": "#c:gems/diamond" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/jungle_chest_boat.json b/src/generated/resources/data/minecraft/recipe/jungle_chest_boat.json index 8a86eca6db..4ce71a21b8 100644 --- a/src/generated/resources/data/minecraft/recipe/jungle_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/jungle_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:jungle_boat" - } + "minecraft:jungle_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/jungle_fence.json b/src/generated/resources/data/minecraft/recipe/jungle_fence.json index b49a38c19a..dc919dea44 100644 --- a/src/generated/resources/data/minecraft/recipe/jungle_fence.json +++ b/src/generated/resources/data/minecraft/recipe/jungle_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:jungle_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:jungle_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/jungle_fence_gate.json b/src/generated/resources/data/minecraft/recipe/jungle_fence_gate.json index a1dcfbde01..3f3ee533ed 100644 --- a/src/generated/resources/data/minecraft/recipe/jungle_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/jungle_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:jungle_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:jungle_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/jungle_sign.json b/src/generated/resources/data/minecraft/recipe/jungle_sign.json index 713c47d1fa..9c22e2bcd1 100644 --- a/src/generated/resources/data/minecraft/recipe/jungle_sign.json +++ b/src/generated/resources/data/minecraft/recipe/jungle_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:jungle_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:jungle_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/ladder.json b/src/generated/resources/data/minecraft/recipe/ladder.json index 8d64f336a8..0aefdd0268 100644 --- a/src/generated/resources/data/minecraft/recipe/ladder.json +++ b/src/generated/resources/data/minecraft/recipe/ladder.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - } + "#": "#c:rods/wooden" }, "pattern": [ "# #", diff --git a/src/generated/resources/data/minecraft/recipe/lantern.json b/src/generated/resources/data/minecraft/recipe/lantern.json index d7435e4ee2..547cee5246 100644 --- a/src/generated/resources/data/minecraft/recipe/lantern.json +++ b/src/generated/resources/data/minecraft/recipe/lantern.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:torch" - }, - "X": { - "tag": "c:nuggets/iron" - } + "#": "minecraft:torch", + "X": "#c:nuggets/iron" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/lead.json b/src/generated/resources/data/minecraft/recipe/lead.json index 57ca6d0bbc..a48100d61a 100644 --- a/src/generated/resources/data/minecraft/recipe/lead.json +++ b/src/generated/resources/data/minecraft/recipe/lead.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "O": { - "item": "minecraft:slime_ball" - }, - "~": { - "tag": "c:strings" - } + "O": "minecraft:slime_ball", + "~": "#c:strings" }, "pattern": [ "~~ ", diff --git a/src/generated/resources/data/minecraft/recipe/lever.json b/src/generated/resources/data/minecraft/recipe/lever.json index a92056e26a..25196040a9 100644 --- a/src/generated/resources/data/minecraft/recipe/lever.json +++ b/src/generated/resources/data/minecraft/recipe/lever.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:cobblestones/normal" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "#c:cobblestones/normal", + "X": "#c:rods/wooden" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_banner.json b/src/generated/resources/data/minecraft/recipe/light_blue_banner.json index 1fb0a66d80..b0fa080366 100644 --- a/src/generated/resources/data/minecraft/recipe/light_blue_banner.json +++ b/src/generated/resources/data/minecraft/recipe/light_blue_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:light_blue_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:light_blue_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_candle.json b/src/generated/resources/data/minecraft/recipe/light_blue_candle.json new file mode 100644 index 0000000000..43cbfe0211 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/light_blue" + ], + "result": { + "count": 1, + "id": "minecraft:light_blue_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/light_blue_concrete_powder.json new file mode 100644 index 0000000000..ffb30f0661 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/light_blue", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:light_blue_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_dye_from_blue_white_dye.json b/src/generated/resources/data/minecraft/recipe/light_blue_dye_from_blue_white_dye.json new file mode 100644 index 0000000000..1d33b2a8f9 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_dye_from_blue_white_dye.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "light_blue_dye", + "ingredients": [ + "#c:dyes/blue", + "#c:dyes/white" + ], + "result": { + "count": 2, + "id": "minecraft:light_blue_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass.json b/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass.json new file mode 100644 index 0000000000..9768131cfd --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/light_blue" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_blue_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..0b1d1516e8 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/light_blue" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_blue_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_blue_terracotta.json b/src/generated/resources/data/minecraft/recipe/light_blue_terracotta.json new file mode 100644 index 0000000000..219536884b --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_blue_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/light_blue" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_blue_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_banner.json b/src/generated/resources/data/minecraft/recipe/light_gray_banner.json index 35d93c6693..7a16563cc0 100644 --- a/src/generated/resources/data/minecraft/recipe/light_gray_banner.json +++ b/src/generated/resources/data/minecraft/recipe/light_gray_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:light_gray_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:light_gray_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_candle.json b/src/generated/resources/data/minecraft/recipe/light_gray_candle.json new file mode 100644 index 0000000000..5fbd4a55c6 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/light_gray" + ], + "result": { + "count": 1, + "id": "minecraft:light_gray_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/light_gray_concrete_powder.json new file mode 100644 index 0000000000..e967595cfe --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/light_gray", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:light_gray_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_black_white_dye.json b/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_black_white_dye.json new file mode 100644 index 0000000000..23c04e8044 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_black_white_dye.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "light_gray_dye", + "ingredients": [ + "#c:dyes/black", + "#c:dyes/white", + "#c:dyes/white" + ], + "result": { + "count": 3, + "id": "minecraft:light_gray_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_gray_white_dye.json b/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_gray_white_dye.json new file mode 100644 index 0000000000..24ffa80ddf --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_dye_from_gray_white_dye.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "light_gray_dye", + "ingredients": [ + "#c:dyes/gray", + "#c:dyes/white" + ], + "result": { + "count": 2, + "id": "minecraft:light_gray_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass.json b/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass.json new file mode 100644 index 0000000000..9956a97647 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/light_gray" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_gray_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..3cf7396ff0 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/light_gray" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_gray_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_gray_terracotta.json b/src/generated/resources/data/minecraft/recipe/light_gray_terracotta.json new file mode 100644 index 0000000000..7bd8663ba9 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/light_gray_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/light_gray" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:light_gray_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/light_weighted_pressure_plate.json b/src/generated/resources/data/minecraft/recipe/light_weighted_pressure_plate.json index 0d6eec2360..ef08a13e3f 100644 --- a/src/generated/resources/data/minecraft/recipe/light_weighted_pressure_plate.json +++ b/src/generated/resources/data/minecraft/recipe/light_weighted_pressure_plate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/gold" - } + "#": "#c:ingots/gold" }, "pattern": [ "##" diff --git a/src/generated/resources/data/minecraft/recipe/lightning_rod.json b/src/generated/resources/data/minecraft/recipe/lightning_rod.json index 5a2186f659..614ed2737e 100644 --- a/src/generated/resources/data/minecraft/recipe/lightning_rod.json +++ b/src/generated/resources/data/minecraft/recipe/lightning_rod.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:ingots/copper" - } + "#": "#c:ingots/copper" }, "pattern": [ "#", diff --git a/src/generated/resources/data/minecraft/recipe/lime_banner.json b/src/generated/resources/data/minecraft/recipe/lime_banner.json index c076add05b..49b26aba09 100644 --- a/src/generated/resources/data/minecraft/recipe/lime_banner.json +++ b/src/generated/resources/data/minecraft/recipe/lime_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:lime_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:lime_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/lime_candle.json b/src/generated/resources/data/minecraft/recipe/lime_candle.json new file mode 100644 index 0000000000..f38b4cd3c5 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/lime" + ], + "result": { + "count": 1, + "id": "minecraft:lime_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lime_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/lime_concrete_powder.json new file mode 100644 index 0000000000..d3e0f4a0cc --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/lime", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:lime_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lime_dye.json b/src/generated/resources/data/minecraft/recipe/lime_dye.json new file mode 100644 index 0000000000..03f7de71e1 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_dye.json @@ -0,0 +1,12 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + "#c:dyes/green", + "#c:dyes/white" + ], + "result": { + "count": 2, + "id": "minecraft:lime_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lime_stained_glass.json b/src/generated/resources/data/minecraft/recipe/lime_stained_glass.json new file mode 100644 index 0000000000..ced0fd369e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/lime" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:lime_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lime_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/lime_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..a6fd9c362a --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/lime" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:lime_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lime_terracotta.json b/src/generated/resources/data/minecraft/recipe/lime_terracotta.json new file mode 100644 index 0000000000..199a1fab04 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/lime_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/lime" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:lime_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/lodestone.json b/src/generated/resources/data/minecraft/recipe/lodestone.json index 5d1bc8a33a..aabb2183d5 100644 --- a/src/generated/resources/data/minecraft/recipe/lodestone.json +++ b/src/generated/resources/data/minecraft/recipe/lodestone.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/netherite" - }, - "S": { - "item": "minecraft:chiseled_stone_bricks" - } + "#": "#c:ingots/netherite", + "S": "minecraft:chiseled_stone_bricks" }, "pattern": [ "SSS", diff --git a/src/generated/resources/data/minecraft/recipe/loom.json b/src/generated/resources/data/minecraft/recipe/loom.json index 7fbb48dfe9..9b25eeb36f 100644 --- a/src/generated/resources/data/minecraft/recipe/loom.json +++ b/src/generated/resources/data/minecraft/recipe/loom.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "@": { - "tag": "c:strings" - } + "#": "#minecraft:planks", + "@": "#c:strings" }, "pattern": [ "@@", diff --git a/src/generated/resources/data/minecraft/recipe/magenta_banner.json b/src/generated/resources/data/minecraft/recipe/magenta_banner.json index 5996580e8d..f09624c2ac 100644 --- a/src/generated/resources/data/minecraft/recipe/magenta_banner.json +++ b/src/generated/resources/data/minecraft/recipe/magenta_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:magenta_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:magenta_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/magenta_candle.json b/src/generated/resources/data/minecraft/recipe/magenta_candle.json new file mode 100644 index 0000000000..a424f2970c --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/magenta" + ], + "result": { + "count": 1, + "id": "minecraft:magenta_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/magenta_concrete_powder.json new file mode 100644 index 0000000000..16e3792d0f --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/magenta", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:magenta_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_pink.json b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_pink.json new file mode 100644 index 0000000000..a2fa3f6d96 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_pink.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "magenta_dye", + "ingredients": [ + "#c:dyes/blue", + "#c:dyes/red", + "#c:dyes/pink" + ], + "result": { + "count": 3, + "id": "minecraft:magenta_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_white_dye.json b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_white_dye.json new file mode 100644 index 0000000000..4eae10075b --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_blue_red_white_dye.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "magenta_dye", + "ingredients": [ + "#c:dyes/blue", + "#c:dyes/red", + "#c:dyes/red", + "#c:dyes/white" + ], + "result": { + "count": 4, + "id": "minecraft:magenta_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_dye_from_purple_and_pink.json b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_purple_and_pink.json new file mode 100644 index 0000000000..ef29fdbd87 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_dye_from_purple_and_pink.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "magenta_dye", + "ingredients": [ + "#c:dyes/purple", + "#c:dyes/pink" + ], + "result": { + "count": 2, + "id": "minecraft:magenta_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_stained_glass.json b/src/generated/resources/data/minecraft/recipe/magenta_stained_glass.json new file mode 100644 index 0000000000..35c7057b7e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/magenta" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:magenta_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/magenta_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..79dbe6233b --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/magenta" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:magenta_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/magenta_terracotta.json b/src/generated/resources/data/minecraft/recipe/magenta_terracotta.json new file mode 100644 index 0000000000..3205ae4824 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/magenta_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/magenta" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:magenta_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/mangrove_chest_boat.json b/src/generated/resources/data/minecraft/recipe/mangrove_chest_boat.json index 23e510eb5a..66a4dacf45 100644 --- a/src/generated/resources/data/minecraft/recipe/mangrove_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/mangrove_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:mangrove_boat" - } + "minecraft:mangrove_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/mangrove_fence.json b/src/generated/resources/data/minecraft/recipe/mangrove_fence.json index 01d6d24181..f939810940 100644 --- a/src/generated/resources/data/minecraft/recipe/mangrove_fence.json +++ b/src/generated/resources/data/minecraft/recipe/mangrove_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:mangrove_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:mangrove_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/mangrove_fence_gate.json b/src/generated/resources/data/minecraft/recipe/mangrove_fence_gate.json index 3a0927be5e..8510a15d3f 100644 --- a/src/generated/resources/data/minecraft/recipe/mangrove_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/mangrove_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:mangrove_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:mangrove_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/mangrove_sign.json b/src/generated/resources/data/minecraft/recipe/mangrove_sign.json index a55530fcd8..2c1eeab8a2 100644 --- a/src/generated/resources/data/minecraft/recipe/mangrove_sign.json +++ b/src/generated/resources/data/minecraft/recipe/mangrove_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:mangrove_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:mangrove_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/minecart.json b/src/generated/resources/data/minecraft/recipe/minecart.json index 15fdd90d0e..3a407b046e 100644 --- a/src/generated/resources/data/minecraft/recipe/minecart.json +++ b/src/generated/resources/data/minecraft/recipe/minecart.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ "# #", diff --git a/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json b/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json index 80acf71a6d..0600f03431 100644 --- a/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json +++ b/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_moss_block.json @@ -3,12 +3,8 @@ "category": "building", "group": "mossy_cobblestone", "ingredients": [ - { - "tag": "c:cobblestones/normal" - }, - { - "item": "minecraft:moss_block" - } + "#c:cobblestones/normal", + "minecraft:moss_block" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_vine.json b/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_vine.json index 6980c8b3a2..fb39076601 100644 --- a/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_vine.json +++ b/src/generated/resources/data/minecraft/recipe/mossy_cobblestone_from_vine.json @@ -3,12 +3,8 @@ "category": "building", "group": "mossy_cobblestone", "ingredients": [ - { - "tag": "c:cobblestones/normal" - }, - { - "item": "minecraft:vine" - } + "#c:cobblestones/normal", + "minecraft:vine" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/netherite_ingot.json b/src/generated/resources/data/minecraft/recipe/netherite_ingot.json index ffa224998e..839b4ad4f5 100644 --- a/src/generated/resources/data/minecraft/recipe/netherite_ingot.json +++ b/src/generated/resources/data/minecraft/recipe/netherite_ingot.json @@ -3,30 +3,14 @@ "category": "misc", "group": "netherite_ingot", "ingredients": [ - { - "item": "minecraft:netherite_scrap" - }, - { - "item": "minecraft:netherite_scrap" - }, - { - "item": "minecraft:netherite_scrap" - }, - { - "item": "minecraft:netherite_scrap" - }, - { - "tag": "c:ingots/gold" - }, - { - "tag": "c:ingots/gold" - }, - { - "tag": "c:ingots/gold" - }, - { - "tag": "c:ingots/gold" - } + "minecraft:netherite_scrap", + "minecraft:netherite_scrap", + "minecraft:netherite_scrap", + "minecraft:netherite_scrap", + "#c:ingots/gold", + "#c:ingots/gold", + "#c:ingots/gold", + "#c:ingots/gold" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/netherite_upgrade_smithing_template.json b/src/generated/resources/data/minecraft/recipe/netherite_upgrade_smithing_template.json index 44fc480189..aa03072c28 100644 --- a/src/generated/resources/data/minecraft/recipe/netherite_upgrade_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/netherite_upgrade_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:netherrack" - }, - "S": { - "item": "minecraft:netherite_upgrade_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:netherrack", + "S": "minecraft:netherite_upgrade_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/oak_chest_boat.json b/src/generated/resources/data/minecraft/recipe/oak_chest_boat.json index 4477f4980a..76a88f4aa3 100644 --- a/src/generated/resources/data/minecraft/recipe/oak_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/oak_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:oak_boat" - } + "minecraft:oak_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/oak_fence.json b/src/generated/resources/data/minecraft/recipe/oak_fence.json index 3227fa2bc7..b3684fd871 100644 --- a/src/generated/resources/data/minecraft/recipe/oak_fence.json +++ b/src/generated/resources/data/minecraft/recipe/oak_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:oak_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/oak_fence_gate.json b/src/generated/resources/data/minecraft/recipe/oak_fence_gate.json index 45923171d8..36941138d7 100644 --- a/src/generated/resources/data/minecraft/recipe/oak_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/oak_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:oak_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:oak_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/oak_sign.json b/src/generated/resources/data/minecraft/recipe/oak_sign.json index 618d6d414a..1692e49e39 100644 --- a/src/generated/resources/data/minecraft/recipe/oak_sign.json +++ b/src/generated/resources/data/minecraft/recipe/oak_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:oak_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:oak_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/observer.json b/src/generated/resources/data/minecraft/recipe/observer.json index d48ca4adf2..f29722af98 100644 --- a/src/generated/resources/data/minecraft/recipe/observer.json +++ b/src/generated/resources/data/minecraft/recipe/observer.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:cobblestones/normal" - }, - "Q": { - "item": "minecraft:quartz" - }, - "R": { - "item": "minecraft:redstone" - } + "#": "#c:cobblestones/normal", + "Q": "minecraft:quartz", + "R": "minecraft:redstone" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/orange_banner.json b/src/generated/resources/data/minecraft/recipe/orange_banner.json index f2f3b03d6c..8bbc0dbf42 100644 --- a/src/generated/resources/data/minecraft/recipe/orange_banner.json +++ b/src/generated/resources/data/minecraft/recipe/orange_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:orange_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:orange_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/orange_candle.json b/src/generated/resources/data/minecraft/recipe/orange_candle.json new file mode 100644 index 0000000000..9708bbc215 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/orange" + ], + "result": { + "count": 1, + "id": "minecraft:orange_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/orange_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/orange_concrete_powder.json new file mode 100644 index 0000000000..39d2b83e2e --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/orange", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:orange_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/orange_dye_from_red_yellow.json b/src/generated/resources/data/minecraft/recipe/orange_dye_from_red_yellow.json new file mode 100644 index 0000000000..72f057275b --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_dye_from_red_yellow.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "orange_dye", + "ingredients": [ + "#c:dyes/red", + "#c:dyes/yellow" + ], + "result": { + "count": 2, + "id": "minecraft:orange_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/orange_stained_glass.json b/src/generated/resources/data/minecraft/recipe/orange_stained_glass.json new file mode 100644 index 0000000000..2af7f1c934 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/orange" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:orange_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/orange_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/orange_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..34da9c5f66 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/orange" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:orange_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/orange_terracotta.json b/src/generated/resources/data/minecraft/recipe/orange_terracotta.json new file mode 100644 index 0000000000..aad543f050 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/orange_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/orange" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:orange_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/painting.json b/src/generated/resources/data/minecraft/recipe/painting.json index df1b6d324d..64b32014dc 100644 --- a/src/generated/resources/data/minecraft/recipe/painting.json +++ b/src/generated/resources/data/minecraft/recipe/painting.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:wool" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wool" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/pink_banner.json b/src/generated/resources/data/minecraft/recipe/pink_banner.json index 951e77cedd..4fd7901e5d 100644 --- a/src/generated/resources/data/minecraft/recipe/pink_banner.json +++ b/src/generated/resources/data/minecraft/recipe/pink_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:pink_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:pink_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/pink_candle.json b/src/generated/resources/data/minecraft/recipe/pink_candle.json new file mode 100644 index 0000000000..d62dd11724 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/pink" + ], + "result": { + "count": 1, + "id": "minecraft:pink_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/pink_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/pink_concrete_powder.json new file mode 100644 index 0000000000..90df434f33 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/pink", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:pink_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/pink_dye_from_red_white_dye.json b/src/generated/resources/data/minecraft/recipe/pink_dye_from_red_white_dye.json new file mode 100644 index 0000000000..7118cf0343 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_dye_from_red_white_dye.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "pink_dye", + "ingredients": [ + "#c:dyes/red", + "#c:dyes/white" + ], + "result": { + "count": 2, + "id": "minecraft:pink_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/pink_stained_glass.json b/src/generated/resources/data/minecraft/recipe/pink_stained_glass.json new file mode 100644 index 0000000000..ea7cf3ecae --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/pink" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:pink_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/pink_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/pink_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..d2e13b56e0 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/pink" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:pink_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/pink_terracotta.json b/src/generated/resources/data/minecraft/recipe/pink_terracotta.json new file mode 100644 index 0000000000..6d21dd2a75 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/pink_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/pink" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:pink_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/piston.json b/src/generated/resources/data/minecraft/recipe/piston.json index b57e13cfbc..84593e660c 100644 --- a/src/generated/resources/data/minecraft/recipe/piston.json +++ b/src/generated/resources/data/minecraft/recipe/piston.json @@ -2,18 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:cobblestones/normal" - }, - "R": { - "item": "minecraft:redstone" - }, - "T": { - "tag": "minecraft:planks" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:cobblestones/normal", + "R": "minecraft:redstone", + "T": "#minecraft:planks", + "X": "#c:ingots/iron" }, "pattern": [ "TTT", diff --git a/src/generated/resources/data/minecraft/recipe/polished_deepslate.json b/src/generated/resources/data/minecraft/recipe/polished_deepslate.json index 97f277e6b1..10b6ccbff7 100644 --- a/src/generated/resources/data/minecraft/recipe/polished_deepslate.json +++ b/src/generated/resources/data/minecraft/recipe/polished_deepslate.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "S": { - "tag": "c:cobblestones/deepslate" - } + "S": "#c:cobblestones/deepslate" }, "pattern": [ "SS", diff --git a/src/generated/resources/data/minecraft/recipe/powered_rail.json b/src/generated/resources/data/minecraft/recipe/powered_rail.json index 97f3e17964..40d834f692 100644 --- a/src/generated/resources/data/minecraft/recipe/powered_rail.json +++ b/src/generated/resources/data/minecraft/recipe/powered_rail.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "R": { - "item": "minecraft:redstone" - }, - "X": { - "tag": "c:ingots/gold" - } + "#": "#c:rods/wooden", + "R": "minecraft:redstone", + "X": "#c:ingots/gold" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/purple_banner.json b/src/generated/resources/data/minecraft/recipe/purple_banner.json index 5475bffc70..ed4b36c136 100644 --- a/src/generated/resources/data/minecraft/recipe/purple_banner.json +++ b/src/generated/resources/data/minecraft/recipe/purple_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:purple_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:purple_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/purple_candle.json b/src/generated/resources/data/minecraft/recipe/purple_candle.json new file mode 100644 index 0000000000..7f5ddcf289 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/purple" + ], + "result": { + "count": 1, + "id": "minecraft:purple_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/purple_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/purple_concrete_powder.json new file mode 100644 index 0000000000..4f0c587f5a --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/purple", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:purple_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/purple_dye.json b/src/generated/resources/data/minecraft/recipe/purple_dye.json new file mode 100644 index 0000000000..c3c75ae3d2 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_dye.json @@ -0,0 +1,12 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + "#c:dyes/blue", + "#c:dyes/red" + ], + "result": { + "count": 2, + "id": "minecraft:purple_dye" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/purple_stained_glass.json b/src/generated/resources/data/minecraft/recipe/purple_stained_glass.json new file mode 100644 index 0000000000..a76149bc89 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/purple" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:purple_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/purple_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/purple_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..bf11a7d689 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/purple" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:purple_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/purple_terracotta.json b/src/generated/resources/data/minecraft/recipe/purple_terracotta.json new file mode 100644 index 0000000000..a7ee6cc737 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/purple_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/purple" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:purple_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/rail.json b/src/generated/resources/data/minecraft/recipe/rail.json index 481af10ee3..b9ed74f2f2 100644 --- a/src/generated/resources/data/minecraft/recipe/rail.json +++ b/src/generated/resources/data/minecraft/recipe/rail.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "c:ingots/iron" - } + "#": "#c:rods/wooden", + "X": "#c:ingots/iron" }, "pattern": [ "X X", diff --git a/src/generated/resources/data/minecraft/recipe/raiser_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/raiser_armor_trim_smithing_template.json index 97a148d159..f49dd8b54a 100644 --- a/src/generated/resources/data/minecraft/recipe/raiser_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/raiser_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:raiser_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:raiser_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/red_banner.json b/src/generated/resources/data/minecraft/recipe/red_banner.json index 89b92a5470..9b0643110e 100644 --- a/src/generated/resources/data/minecraft/recipe/red_banner.json +++ b/src/generated/resources/data/minecraft/recipe/red_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:red_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:red_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/red_candle.json b/src/generated/resources/data/minecraft/recipe/red_candle.json new file mode 100644 index 0000000000..f658efa5d3 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/red_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/red" + ], + "result": { + "count": 1, + "id": "minecraft:red_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/red_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/red_concrete_powder.json new file mode 100644 index 0000000000..06ede8a2b6 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/red_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/red", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:red_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/red_stained_glass.json b/src/generated/resources/data/minecraft/recipe/red_stained_glass.json new file mode 100644 index 0000000000..0323b84f07 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/red_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/red" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:red_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/red_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/red_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..32f751142b --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/red_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/red" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:red_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/red_terracotta.json b/src/generated/resources/data/minecraft/recipe/red_terracotta.json new file mode 100644 index 0000000000..3a006cab3d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/red_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/red" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:red_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/redstone_torch.json b/src/generated/resources/data/minecraft/recipe/redstone_torch.json index 378c0d7b88..ea402cb6e4 100644 --- a/src/generated/resources/data/minecraft/recipe/redstone_torch.json +++ b/src/generated/resources/data/minecraft/recipe/redstone_torch.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "item": "minecraft:redstone" - } + "#": "#c:rods/wooden", + "X": "minecraft:redstone" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/rib_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/rib_armor_trim_smithing_template.json index 6ec72db0dd..f99a49c84f 100644 --- a/src/generated/resources/data/minecraft/recipe/rib_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/rib_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:netherrack" - }, - "S": { - "item": "minecraft:rib_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:netherrack", + "S": "minecraft:rib_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/scaffolding.json b/src/generated/resources/data/minecraft/recipe/scaffolding.json index c0290aba8c..1393f3b416 100644 --- a/src/generated/resources/data/minecraft/recipe/scaffolding.json +++ b/src/generated/resources/data/minecraft/recipe/scaffolding.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "I": { - "item": "minecraft:bamboo" - }, - "~": { - "tag": "c:strings" - } + "I": "minecraft:bamboo", + "~": "#c:strings" }, "pattern": [ "I~I", diff --git a/src/generated/resources/data/minecraft/recipe/sentry_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/sentry_armor_trim_smithing_template.json index 8bfac2e3f9..e0a1a2a451 100644 --- a/src/generated/resources/data/minecraft/recipe/sentry_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/sentry_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "c:cobblestones/normal" - }, - "S": { - "item": "minecraft:sentry_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#c:cobblestones/normal", + "S": "minecraft:sentry_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/shaper_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/shaper_armor_trim_smithing_template.json index 980b1d2108..e1f08a5ca1 100644 --- a/src/generated/resources/data/minecraft/recipe/shaper_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/shaper_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:shaper_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:shaper_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/shears.json b/src/generated/resources/data/minecraft/recipe/shears.json index cc526718eb..ca02dfb8aa 100644 --- a/src/generated/resources/data/minecraft/recipe/shears.json +++ b/src/generated/resources/data/minecraft/recipe/shears.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:ingots/iron" - } + "#": "#c:ingots/iron" }, "pattern": [ " #", diff --git a/src/generated/resources/data/minecraft/recipe/shield.json b/src/generated/resources/data/minecraft/recipe/shield.json index 46aa8fbe7d..e0cc4be9a4 100644 --- a/src/generated/resources/data/minecraft/recipe/shield.json +++ b/src/generated/resources/data/minecraft/recipe/shield.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "W": { - "tag": "minecraft:planks" - }, - "o": { - "tag": "c:ingots/iron" - } + "W": "#minecraft:wooden_tool_materials", + "o": "#c:ingots/iron" }, "pattern": [ "WoW", diff --git a/src/generated/resources/data/minecraft/recipe/shulker_box.json b/src/generated/resources/data/minecraft/recipe/shulker_box.json index dd1c970102..6b74b70a57 100644 --- a/src/generated/resources/data/minecraft/recipe/shulker_box.json +++ b/src/generated/resources/data/minecraft/recipe/shulker_box.json @@ -3,17 +3,11 @@ "category": "misc", "key": { "#": { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - "-": { - "item": "minecraft:shulker_shell" - } + "-": "minecraft:shulker_shell" }, "pattern": [ "-", diff --git a/src/generated/resources/data/minecraft/recipe/silence_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/silence_armor_trim_smithing_template.json index 4ade3deadd..364cdd75a6 100644 --- a/src/generated/resources/data/minecraft/recipe/silence_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/silence_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "c:cobblestones/deepslate" - }, - "S": { - "item": "minecraft:silence_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#c:cobblestones/deepslate", + "S": "minecraft:silence_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/smithing_table.json b/src/generated/resources/data/minecraft/recipe/smithing_table.json index e7dadd831c..cdf474dfc5 100644 --- a/src/generated/resources/data/minecraft/recipe/smithing_table.json +++ b/src/generated/resources/data/minecraft/recipe/smithing_table.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:planks" - }, - "@": { - "tag": "c:ingots/iron" - } + "#": "#minecraft:planks", + "@": "#c:ingots/iron" }, "pattern": [ "@@", diff --git a/src/generated/resources/data/minecraft/recipe/snout_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/snout_armor_trim_smithing_template.json index 8aa0dd55c1..8f24674fdd 100644 --- a/src/generated/resources/data/minecraft/recipe/snout_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/snout_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:blackstone" - }, - "S": { - "item": "minecraft:snout_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:blackstone", + "S": "minecraft:snout_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/soul_campfire.json b/src/generated/resources/data/minecraft/recipe/soul_campfire.json index e7459aa07d..8daec84a10 100644 --- a/src/generated/resources/data/minecraft/recipe/soul_campfire.json +++ b/src/generated/resources/data/minecraft/recipe/soul_campfire.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "minecraft:soul_fire_base_blocks" - }, - "L": { - "tag": "minecraft:logs" - }, - "S": { - "tag": "c:rods/wooden" - } + "#": "#minecraft:soul_fire_base_blocks", + "L": "#minecraft:logs", + "S": "#c:rods/wooden" }, "pattern": [ " S ", diff --git a/src/generated/resources/data/minecraft/recipe/soul_lantern.json b/src/generated/resources/data/minecraft/recipe/soul_lantern.json index e5f39ad8ec..3d06fd51d1 100644 --- a/src/generated/resources/data/minecraft/recipe/soul_lantern.json +++ b/src/generated/resources/data/minecraft/recipe/soul_lantern.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:soul_torch" - }, - "X": { - "tag": "c:nuggets/iron" - } + "#": "minecraft:soul_torch", + "X": "#c:nuggets/iron" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/soul_torch.json b/src/generated/resources/data/minecraft/recipe/soul_torch.json index fc57b7b0d3..89fba8cfe0 100644 --- a/src/generated/resources/data/minecraft/recipe/soul_torch.json +++ b/src/generated/resources/data/minecraft/recipe/soul_torch.json @@ -2,19 +2,11 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "S": { - "tag": "minecraft:soul_fire_base_blocks" - }, + "#": "#c:rods/wooden", + "S": "#minecraft:soul_fire_base_blocks", "X": [ - { - "item": "minecraft:coal" - }, - { - "item": "minecraft:charcoal" - } + "minecraft:coal", + "minecraft:charcoal" ] }, "pattern": [ diff --git a/src/generated/resources/data/minecraft/recipe/spire_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/spire_armor_trim_smithing_template.json index 4cd59d3d03..a4f55cc155 100644 --- a/src/generated/resources/data/minecraft/recipe/spire_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/spire_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:purpur_block" - }, - "S": { - "item": "minecraft:spire_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:purpur_block", + "S": "minecraft:spire_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/spruce_chest_boat.json b/src/generated/resources/data/minecraft/recipe/spruce_chest_boat.json index a98470ee61..b1c0547180 100644 --- a/src/generated/resources/data/minecraft/recipe/spruce_chest_boat.json +++ b/src/generated/resources/data/minecraft/recipe/spruce_chest_boat.json @@ -4,17 +4,11 @@ "group": "chest_boat", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:spruce_boat" - } + "minecraft:spruce_boat" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/spruce_fence.json b/src/generated/resources/data/minecraft/recipe/spruce_fence.json index d8790bce04..f84b63a72b 100644 --- a/src/generated/resources/data/minecraft/recipe/spruce_fence.json +++ b/src/generated/resources/data/minecraft/recipe/spruce_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:spruce_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:spruce_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/spruce_fence_gate.json b/src/generated/resources/data/minecraft/recipe/spruce_fence_gate.json index 61815e9606..ea1f612c1f 100644 --- a/src/generated/resources/data/minecraft/recipe/spruce_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/spruce_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:spruce_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:spruce_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/spruce_sign.json b/src/generated/resources/data/minecraft/recipe/spruce_sign.json index 03fb28133e..58046b4828 100644 --- a/src/generated/resources/data/minecraft/recipe/spruce_sign.json +++ b/src/generated/resources/data/minecraft/recipe/spruce_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:spruce_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:spruce_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/spyglass.json b/src/generated/resources/data/minecraft/recipe/spyglass.json index ea680e3fb9..d2caaad362 100644 --- a/src/generated/resources/data/minecraft/recipe/spyglass.json +++ b/src/generated/resources/data/minecraft/recipe/spyglass.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:gems/amethyst" - }, - "X": { - "tag": "c:ingots/copper" - } + "#": "#c:gems/amethyst", + "X": "#c:ingots/copper" }, "pattern": [ " # ", diff --git a/src/generated/resources/data/minecraft/recipe/stone_axe.json b/src/generated/resources/data/minecraft/recipe/stone_axe.json index 0bac2f1180..8d557557d6 100644 --- a/src/generated/resources/data/minecraft/recipe/stone_axe.json +++ b/src/generated/resources/data/minecraft/recipe/stone_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/stone_hoe.json b/src/generated/resources/data/minecraft/recipe/stone_hoe.json index 8c5b5eceee..8ed74421de 100644 --- a/src/generated/resources/data/minecraft/recipe/stone_hoe.json +++ b/src/generated/resources/data/minecraft/recipe/stone_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/stone_pickaxe.json b/src/generated/resources/data/minecraft/recipe/stone_pickaxe.json index b366ac2065..cd245c22c4 100644 --- a/src/generated/resources/data/minecraft/recipe/stone_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipe/stone_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/stone_shovel.json b/src/generated/resources/data/minecraft/recipe/stone_shovel.json index d1fbdebd22..bde9b0a8be 100644 --- a/src/generated/resources/data/minecraft/recipe/stone_shovel.json +++ b/src/generated/resources/data/minecraft/recipe/stone_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/stone_sword.json b/src/generated/resources/data/minecraft/recipe/stone_sword.json index 559caac73d..cdff3bf44e 100644 --- a/src/generated/resources/data/minecraft/recipe/stone_sword.json +++ b/src/generated/resources/data/minecraft/recipe/stone_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:stone_tool_materials" - } + "#": "#c:rods/wooden", + "X": "#minecraft:stone_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/stonecutter.json b/src/generated/resources/data/minecraft/recipe/stonecutter.json index e0820aeedb..e2f95eecf4 100644 --- a/src/generated/resources/data/minecraft/recipe/stonecutter.json +++ b/src/generated/resources/data/minecraft/recipe/stonecutter.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "item": "minecraft:stone" - }, - "I": { - "tag": "c:ingots/iron" - } + "#": "minecraft:stone", + "I": "#c:ingots/iron" }, "pattern": [ " I ", diff --git a/src/generated/resources/data/minecraft/recipe/tide_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/tide_armor_trim_smithing_template.json index 8292dd0993..4f4f0feec4 100644 --- a/src/generated/resources/data/minecraft/recipe/tide_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/tide_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:prismarine" - }, - "S": { - "item": "minecraft:tide_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:prismarine", + "S": "minecraft:tide_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/tinted_glass.json b/src/generated/resources/data/minecraft/recipe/tinted_glass.json index 99d27ab3d3..899d357f7e 100644 --- a/src/generated/resources/data/minecraft/recipe/tinted_glass.json +++ b/src/generated/resources/data/minecraft/recipe/tinted_glass.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "G": { - "item": "minecraft:glass" - }, - "S": { - "tag": "c:gems/amethyst" - } + "G": "minecraft:glass", + "S": "#c:gems/amethyst" }, "pattern": [ " S ", diff --git a/src/generated/resources/data/minecraft/recipe/torch.json b/src/generated/resources/data/minecraft/recipe/torch.json index 031078faf0..442a61780e 100644 --- a/src/generated/resources/data/minecraft/recipe/torch.json +++ b/src/generated/resources/data/minecraft/recipe/torch.json @@ -2,16 +2,10 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:rods/wooden" - }, + "#": "#c:rods/wooden", "X": [ - { - "item": "minecraft:coal" - }, - { - "item": "minecraft:charcoal" - } + "minecraft:coal", + "minecraft:charcoal" ] }, "pattern": [ diff --git a/src/generated/resources/data/minecraft/recipe/trapped_chest.json b/src/generated/resources/data/minecraft/recipe/trapped_chest.json index 1d48d691df..bd85e9bcad 100644 --- a/src/generated/resources/data/minecraft/recipe/trapped_chest.json +++ b/src/generated/resources/data/minecraft/recipe/trapped_chest.json @@ -3,17 +3,11 @@ "category": "redstone", "ingredients": [ { - "type": "neoforge:difference", - "base": { - "tag": "c:chests/wooden" - }, - "subtracted": { - "tag": "c:chests/trapped" - } + "neoforge:ingredient_type": "neoforge:difference", + "base": "#c:chests/wooden", + "subtracted": "#c:chests/trapped" }, - { - "item": "minecraft:tripwire_hook" - } + "minecraft:tripwire_hook" ], "result": { "count": 1, diff --git a/src/generated/resources/data/minecraft/recipe/tripwire_hook.json b/src/generated/resources/data/minecraft/recipe/tripwire_hook.json index b966ce7a63..9248d9973e 100644 --- a/src/generated/resources/data/minecraft/recipe/tripwire_hook.json +++ b/src/generated/resources/data/minecraft/recipe/tripwire_hook.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "redstone", "key": { - "#": { - "tag": "minecraft:planks" - }, - "I": { - "tag": "c:ingots/iron" - }, - "S": { - "tag": "c:rods/wooden" - } + "#": "#minecraft:planks", + "I": "#c:ingots/iron", + "S": "#c:rods/wooden" }, "pattern": [ "I", diff --git a/src/generated/resources/data/minecraft/recipe/vex_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/vex_armor_trim_smithing_template.json index c4346ef9e4..33b599c546 100644 --- a/src/generated/resources/data/minecraft/recipe/vex_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/vex_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "c:cobblestones/normal" - }, - "S": { - "item": "minecraft:vex_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#c:cobblestones/normal", + "S": "minecraft:vex_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/ward_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/ward_armor_trim_smithing_template.json index 1e6185aa9d..9a4b94b40f 100644 --- a/src/generated/resources/data/minecraft/recipe/ward_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/ward_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "tag": "c:cobblestones/deepslate" - }, - "S": { - "item": "minecraft:ward_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "#c:cobblestones/deepslate", + "S": "minecraft:ward_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/warped_fence.json b/src/generated/resources/data/minecraft/recipe/warped_fence.json index 715d558dd6..54684ffb50 100644 --- a/src/generated/resources/data/minecraft/recipe/warped_fence.json +++ b/src/generated/resources/data/minecraft/recipe/warped_fence.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_fence", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:warped_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:warped_planks" }, "pattern": [ "W#W", diff --git a/src/generated/resources/data/minecraft/recipe/warped_fence_gate.json b/src/generated/resources/data/minecraft/recipe/warped_fence_gate.json index 15dcad57d5..bd500ac089 100644 --- a/src/generated/resources/data/minecraft/recipe/warped_fence_gate.json +++ b/src/generated/resources/data/minecraft/recipe/warped_fence_gate.json @@ -3,12 +3,8 @@ "category": "redstone", "group": "wooden_fence_gate", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "W": { - "item": "minecraft:warped_planks" - } + "#": "#c:rods/wooden", + "W": "minecraft:warped_planks" }, "pattern": [ "#W#", diff --git a/src/generated/resources/data/minecraft/recipe/warped_sign.json b/src/generated/resources/data/minecraft/recipe/warped_sign.json index b0f4112a6d..fd63852c3b 100644 --- a/src/generated/resources/data/minecraft/recipe/warped_sign.json +++ b/src/generated/resources/data/minecraft/recipe/warped_sign.json @@ -3,12 +3,8 @@ "category": "misc", "group": "wooden_sign", "key": { - "#": { - "item": "minecraft:warped_planks" - }, - "X": { - "tag": "c:rods/wooden" - } + "#": "minecraft:warped_planks", + "X": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json index 563776c2c5..3c93a650a0 100644 --- a/src/generated/resources/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/wayfinder_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:terracotta" - }, - "S": { - "item": "minecraft:wayfinder_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:terracotta", + "S": "minecraft:wayfinder_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/white_banner.json b/src/generated/resources/data/minecraft/recipe/white_banner.json index 418906d5b9..0f87a1e878 100644 --- a/src/generated/resources/data/minecraft/recipe/white_banner.json +++ b/src/generated/resources/data/minecraft/recipe/white_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:white_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:white_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/white_candle.json b/src/generated/resources/data/minecraft/recipe/white_candle.json new file mode 100644 index 0000000000..45b193d999 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/white_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/white" + ], + "result": { + "count": 1, + "id": "minecraft:white_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/white_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/white_concrete_powder.json new file mode 100644 index 0000000000..e5778a9ff2 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/white_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/white", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:white_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/white_stained_glass.json b/src/generated/resources/data/minecraft/recipe/white_stained_glass.json new file mode 100644 index 0000000000..f609fa37f4 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/white_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/white" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:white_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/white_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/white_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..ce5471a140 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/white_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/white" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:white_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/white_terracotta.json b/src/generated/resources/data/minecraft/recipe/white_terracotta.json new file mode 100644 index 0000000000..7fd1569e33 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/white_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/white" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:white_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/wild_armor_trim_smithing_template.json b/src/generated/resources/data/minecraft/recipe/wild_armor_trim_smithing_template.json index 8eec0dc5e9..0048eb4531 100644 --- a/src/generated/resources/data/minecraft/recipe/wild_armor_trim_smithing_template.json +++ b/src/generated/resources/data/minecraft/recipe/wild_armor_trim_smithing_template.json @@ -2,15 +2,9 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "#": { - "tag": "c:gems/diamond" - }, - "C": { - "item": "minecraft:mossy_cobblestone" - }, - "S": { - "item": "minecraft:wild_armor_trim_smithing_template" - } + "#": "#c:gems/diamond", + "C": "minecraft:mossy_cobblestone", + "S": "minecraft:wild_armor_trim_smithing_template" }, "pattern": [ "#S#", diff --git a/src/generated/resources/data/minecraft/recipe/wooden_axe.json b/src/generated/resources/data/minecraft/recipe/wooden_axe.json index 25cc73c46f..05fdaaad7e 100644 --- a/src/generated/resources/data/minecraft/recipe/wooden_axe.json +++ b/src/generated/resources/data/minecraft/recipe/wooden_axe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/wooden_hoe.json b/src/generated/resources/data/minecraft/recipe/wooden_hoe.json index a068c7fdc5..6fd2085dda 100644 --- a/src/generated/resources/data/minecraft/recipe/wooden_hoe.json +++ b/src/generated/resources/data/minecraft/recipe/wooden_hoe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "XX", diff --git a/src/generated/resources/data/minecraft/recipe/wooden_pickaxe.json b/src/generated/resources/data/minecraft/recipe/wooden_pickaxe.json index b09f9389ab..ff84e265b6 100644 --- a/src/generated/resources/data/minecraft/recipe/wooden_pickaxe.json +++ b/src/generated/resources/data/minecraft/recipe/wooden_pickaxe.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "XXX", diff --git a/src/generated/resources/data/minecraft/recipe/wooden_shovel.json b/src/generated/resources/data/minecraft/recipe/wooden_shovel.json index dd2aa5e363..3aac8226a5 100644 --- a/src/generated/resources/data/minecraft/recipe/wooden_shovel.json +++ b/src/generated/resources/data/minecraft/recipe/wooden_shovel.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/wooden_sword.json b/src/generated/resources/data/minecraft/recipe/wooden_sword.json index 8906ea876f..35a7a42140 100644 --- a/src/generated/resources/data/minecraft/recipe/wooden_sword.json +++ b/src/generated/resources/data/minecraft/recipe/wooden_sword.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shaped", "category": "equipment", "key": { - "#": { - "tag": "c:rods/wooden" - }, - "X": { - "tag": "minecraft:planks" - } + "#": "#c:rods/wooden", + "X": "#minecraft:wooden_tool_materials" }, "pattern": [ "X", diff --git a/src/generated/resources/data/minecraft/recipe/yellow_banner.json b/src/generated/resources/data/minecraft/recipe/yellow_banner.json index 5c1c07e88b..6228650872 100644 --- a/src/generated/resources/data/minecraft/recipe/yellow_banner.json +++ b/src/generated/resources/data/minecraft/recipe/yellow_banner.json @@ -3,12 +3,8 @@ "category": "misc", "group": "banner", "key": { - "#": { - "item": "minecraft:yellow_wool" - }, - "|": { - "tag": "c:rods/wooden" - } + "#": "minecraft:yellow_wool", + "|": "#c:rods/wooden" }, "pattern": [ "###", diff --git a/src/generated/resources/data/minecraft/recipe/yellow_candle.json b/src/generated/resources/data/minecraft/recipe/yellow_candle.json new file mode 100644 index 0000000000..a3decc14ae --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/yellow_candle.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "group": "dyed_candle", + "ingredients": [ + "minecraft:candle", + "#c:dyes/yellow" + ], + "result": { + "count": 1, + "id": "minecraft:yellow_candle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/yellow_concrete_powder.json b/src/generated/resources/data/minecraft/recipe/yellow_concrete_powder.json new file mode 100644 index 0000000000..924d919978 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/yellow_concrete_powder.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "building", + "group": "concrete_powder", + "ingredients": [ + "#c:dyes/yellow", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:sand", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel", + "minecraft:gravel" + ], + "result": { + "count": 8, + "id": "minecraft:yellow_concrete_powder" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/yellow_stained_glass.json b/src/generated/resources/data/minecraft/recipe/yellow_stained_glass.json new file mode 100644 index 0000000000..40f451fd6d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/yellow_stained_glass.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_glass", + "key": { + "#": "minecraft:glass", + "X": "#c:dyes/yellow" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:yellow_stained_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/yellow_stained_glass_pane_from_glass_pane.json b/src/generated/resources/data/minecraft/recipe/yellow_stained_glass_pane_from_glass_pane.json new file mode 100644 index 0000000000..ddfae8467d --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/yellow_stained_glass_pane_from_glass_pane.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "stained_glass_pane", + "key": { + "#": "minecraft:glass_pane", + "$": "#c:dyes/yellow" + }, + "pattern": [ + "###", + "#$#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:yellow_stained_glass_pane" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/yellow_terracotta.json b/src/generated/resources/data/minecraft/recipe/yellow_terracotta.json new file mode 100644 index 0000000000..250951eefc --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/yellow_terracotta.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "building", + "group": "stained_terracotta", + "key": { + "#": "minecraft:terracotta", + "X": "#c:dyes/yellow" + }, + "pattern": [ + "###", + "#X#", + "###" + ], + "result": { + "count": 8, + "id": "minecraft:yellow_terracotta" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/neoforge/data_maps/entity_type/parrot_imitations.json b/src/generated/resources/data/neoforge/data_maps/entity_type/parrot_imitations.json index 15a3911080..513f03410d 100644 --- a/src/generated/resources/data/neoforge/data_maps/entity_type/parrot_imitations.json +++ b/src/generated/resources/data/neoforge/data_maps/entity_type/parrot_imitations.json @@ -12,6 +12,12 @@ "minecraft:cave_spider": { "sound": "minecraft:entity.parrot.imitate.spider" }, + "minecraft:creaking": { + "sound": "minecraft:entity.parrot.imitate.creaking" + }, + "minecraft:creaking_transient": { + "sound": "minecraft:entity.parrot.imitate.creaking" + }, "minecraft:creeper": { "sound": "minecraft:entity.parrot.imitate.creeper" }, diff --git a/src/generated/resources/data/neoforge/data_maps/item/compostables.json b/src/generated/resources/data/neoforge/data_maps/item/compostables.json index 7ed50fabc5..2b3bdff6a6 100644 --- a/src/generated/resources/data/neoforge/data_maps/item/compostables.json +++ b/src/generated/resources/data/neoforge/data_maps/item/compostables.json @@ -190,6 +190,21 @@ "minecraft:oxeye_daisy": { "chance": 0.65 }, + "minecraft:pale_hanging_moss": { + "chance": 0.3 + }, + "minecraft:pale_moss_block": { + "chance": 0.65 + }, + "minecraft:pale_moss_carpet": { + "chance": 0.3 + }, + "minecraft:pale_oak_leaves": { + "chance": 0.3 + }, + "minecraft:pale_oak_sapling": { + "chance": 0.3 + }, "minecraft:peony": { "chance": 0.65 }, diff --git a/src/generated/resources/pack.mcmeta b/src/generated/resources/pack.mcmeta index 6ab3546301..f49d678e8d 100644 --- a/src/generated/resources/pack.mcmeta +++ b/src/generated/resources/pack.mcmeta @@ -3,7 +3,7 @@ "description": { "translate": "pack.neoforge.description" }, - "pack_format": 48, + "pack_format": 57, "supported_formats": [ 0, 2147483647 diff --git a/src/generated/resources/reports/registry_order.json b/src/generated/resources/reports/registry_order.json index 17ea12b63d..0a52e90bf1 100644 --- a/src/generated/resources/reports/registry_order.json +++ b/src/generated/resources/reports/registry_order.json @@ -2,7 +2,6 @@ "order": [ "minecraft:attribute", "minecraft:data_component_type", - "minecraft:armor_material", "minecraft:game_event", "minecraft:sound_event", "minecraft:fluid", @@ -64,7 +63,6 @@ "minecraft:worldgen/pool_alias_binding", "minecraft:cat_variant", "minecraft:frog_variant", - "minecraft:instrument", "minecraft:decorated_pot_pattern", "minecraft:creative_mode_tab", "minecraft:trigger_type", @@ -78,6 +76,10 @@ "minecraft:enchantment_location_based_effect_type", "minecraft:enchantment_value_effect_type", "minecraft:enchantment_provider_type", + "minecraft:consume_effect_type", + "minecraft:recipe_display", + "minecraft:slot_display", + "minecraft:recipe_book_category", "neoforge:attachment_types", "neoforge:biome_modifier_serializers", "neoforge:condition_codecs", diff --git a/src/main/java/net/neoforged/neoforge/attachment/AttachmentHolder.java b/src/main/java/net/neoforged/neoforge/attachment/AttachmentHolder.java index 53b2c8bc49..e822d369cf 100644 --- a/src/main/java/net/neoforged/neoforge/attachment/AttachmentHolder.java +++ b/src/main/java/net/neoforged/neoforge/attachment/AttachmentHolder.java @@ -145,7 +145,7 @@ protected final void deserializeAttachments(HolderLookup.Provider provider, Comp continue; } - var type = NeoForgeRegistries.ATTACHMENT_TYPES.get(keyLocation); + var type = NeoForgeRegistries.ATTACHMENT_TYPES.getValue(keyLocation); if (type == null || type.serializer == null) { LOGGER.error("Encountered unknown or non-serializable data attachment {}. Skipping.", key); continue; diff --git a/src/main/java/net/neoforged/neoforge/capabilities/CapabilityHooks.java b/src/main/java/net/neoforged/neoforge/capabilities/CapabilityHooks.java index 73fe62a7f4..478e79e2ec 100644 --- a/src/main/java/net/neoforged/neoforge/capabilities/CapabilityHooks.java +++ b/src/main/java/net/neoforged/neoforge/capabilities/CapabilityHooks.java @@ -104,7 +104,15 @@ public static void registerVanillaProviders(RegisterCapabilitiesEvent event) { // Entities var containerEntities = List.of( - EntityType.CHEST_BOAT, + EntityType.ACACIA_CHEST_BOAT, + EntityType.BIRCH_CHEST_BOAT, + EntityType.CHERRY_CHEST_BOAT, + EntityType.DARK_OAK_CHEST_BOAT, + EntityType.JUNGLE_CHEST_BOAT, + EntityType.MANGROVE_CHEST_BOAT, + EntityType.OAK_CHEST_BOAT, + EntityType.SPRUCE_CHEST_BOAT, + EntityType.BAMBOO_CHEST_RAFT, EntityType.CHEST_MINECART, EntityType.HOPPER_MINECART); for (var entityType : containerEntities) { diff --git a/src/main/java/net/neoforged/neoforge/client/BlockEntityRenderBoundsDebugRenderer.java b/src/main/java/net/neoforged/neoforge/client/BlockEntityRenderBoundsDebugRenderer.java index a7cef0f09a..4df6e384c6 100644 --- a/src/main/java/net/neoforged/neoforge/client/BlockEntityRenderBoundsDebugRenderer.java +++ b/src/main/java/net/neoforged/neoforge/client/BlockEntityRenderBoundsDebugRenderer.java @@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.ShapeRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.commands.Commands; import net.minecraft.core.BlockPos; @@ -52,7 +53,7 @@ private static void drawRenderBoundingBox(PoseStack poseStack, VertexConsumer co poseStack.pushPose(); poseStack.translate(offset.x, offset.y, offset.z); - LevelRenderer.renderLineBox(poseStack, consumer, aabb, 1F, 0F, 0F, 1F); + ShapeRenderer.renderLineBox(poseStack, consumer, aabb, 1F, 0F, 0F, 1F); poseStack.popPose(); } } diff --git a/src/main/java/net/neoforged/neoforge/client/ClientCommandHandler.java b/src/main/java/net/neoforged/neoforge/client/ClientCommandHandler.java index 742a76da5e..f4d4f28d01 100644 --- a/src/main/java/net/neoforged/neoforge/client/ClientCommandHandler.java +++ b/src/main/java/net/neoforged/neoforge/client/ClientCommandHandler.java @@ -20,6 +20,7 @@ import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.player.LocalPlayer; import net.minecraft.commands.CommandBuildContext; +import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.synchronization.SuggestionProviders; @@ -105,7 +106,28 @@ public static CommandDispatcher getDispatcher() { */ public static ClientCommandSourceStack getSource() { LocalPlayer player = Minecraft.getInstance().player; - return new ClientCommandSourceStack(player, player.position(), player.getRotationVector(), player.getPermissionLevel(), + CommandSource commandSource = new CommandSource() { + @Override + public boolean acceptsSuccess() { + return true; + } + + @Override + public boolean acceptsFailure() { + return true; + } + + @Override + public boolean shouldInformAdmins() { + return true; + } + + @Override + public void sendSystemMessage(Component message) { + Minecraft.getInstance().gui.getChat().addMessage(message); + } + }; + return new ClientCommandSourceStack(commandSource, player.position(), player.getRotationVector(), player.getPermissionLevel(), player.getName().getString(), player.getDisplayName(), player); } @@ -157,7 +179,7 @@ public static boolean runCommand(String command) { // in case of unknown command, let the server try and handle it return false; } - Minecraft.getInstance().player.sendSystemMessage( + Minecraft.getInstance().gui.getChat().addMessage( Component.literal("").append(ComponentUtils.fromMessage(syntax.getRawMessage())).withStyle(ChatFormatting.RED)); if (syntax.getInput() != null && syntax.getCursor() >= 0) { int position = Math.min(syntax.getInput().length(), syntax.getCursor()); @@ -173,12 +195,12 @@ public static boolean runCommand(String command) { details.append(Component.literal(syntax.getInput().substring(position)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE)); } details.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC)); - Minecraft.getInstance().player.sendSystemMessage(Component.literal("").append(details).withStyle(ChatFormatting.RED)); + Minecraft.getInstance().gui.getChat().addMessage(Component.literal("").append(details).withStyle(ChatFormatting.RED)); } } catch (Exception generic)// Probably thrown by the command { MutableComponent message = Component.literal(generic.getMessage() == null ? generic.getClass().getName() : generic.getMessage()); - Minecraft.getInstance().player.sendSystemMessage(Component.translatable("command.failed") + Minecraft.getInstance().gui.getChat().addMessage(Component.translatable("command.failed") .withStyle(ChatFormatting.RED) .withStyle((style) -> style .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, message)))); diff --git a/src/main/java/net/neoforged/neoforge/client/ClientCommandSourceStack.java b/src/main/java/net/neoforged/neoforge/client/ClientCommandSourceStack.java index 0d5a537de1..471b085f82 100644 --- a/src/main/java/net/neoforged/neoforge/client/ClientCommandSourceStack.java +++ b/src/main/java/net/neoforged/neoforge/client/ClientCommandSourceStack.java @@ -5,27 +5,33 @@ package net.neoforged.neoforge.client; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; import java.util.Collection; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; import java.util.stream.Collectors; -import java.util.stream.Stream; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.client.Minecraft; import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; -import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Scoreboard; +import org.jetbrains.annotations.Nullable; /** * overrides for {@link CommandSourceStack} so that the methods will run successfully client side @@ -41,7 +47,7 @@ public ClientCommandSourceStack(CommandSource source, Vec3 position, Vec2 rotati */ @Override public void sendSuccess(Supplier message, boolean sendToAdmins) { - Minecraft.getInstance().player.sendSystemMessage(message.get()); + Minecraft.getInstance().gui.getChat().addMessage(message.get()); } /** @@ -60,12 +66,17 @@ public Collection getOnlinePlayerNames() { return Minecraft.getInstance().getConnection().getOnlinePlayers().stream().map((player) -> player.getProfile().getName()).collect(Collectors.toList()); } - /** - * {@return a {@link Stream} of recipe ids that are available on the client} - */ @Override - public Stream getRecipeNames() { - return Minecraft.getInstance().getConnection().getRecipeManager().getRecipeIds(); + public CompletableFuture suggestRegistryElements( + ResourceKey> p_212330_, + SharedSuggestionProvider.ElementSuggestionType p_212331_, + SuggestionsBuilder p_212332_, + CommandContext p_212333_) { + // TODO 1.21.2: Not sure what to do here. Letting super get called will cause an NPE on this.server. + if (p_212330_ == Registries.RECIPE || p_212330_ == Registries.ADVANCEMENT) { + return Suggestions.empty(); + } + return super.suggestRegistryElements(p_212330_, p_212331_, p_212332_, p_212333_); } /** @@ -96,18 +107,11 @@ public Scoreboard getScoreboard() { * {@return the advancement from the id from the client side where the advancement needs to be visible to the player} */ @Override + @Nullable public AdvancementHolder getAdvancement(ResourceLocation id) { return Minecraft.getInstance().getConnection().getAdvancements().get(id); } - /** - * {@return the {@link RecipeManager} from the client side} - */ - @Override - public RecipeManager getRecipeManager() { - return Minecraft.getInstance().getConnection().getRecipeManager(); - } - /** * {@return the level from the client side} */ diff --git a/src/main/java/net/neoforged/neoforge/client/ClientHooks.java b/src/main/java/net/neoforged/neoforge/client/ClientHooks.java index 8bc74f258c..0132b8a863 100644 --- a/src/main/java/net/neoforged/neoforge/client/ClientHooks.java +++ b/src/main/java/net/neoforged/neoforge/client/ClientHooks.java @@ -10,14 +10,11 @@ import com.google.common.collect.ImmutableMap; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.shaders.FogShape; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.datafixers.util.Either; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -34,7 +31,6 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; -import net.minecraft.FileUtil; import net.minecraft.client.Camera; import net.minecraft.client.DeltaTracker; import net.minecraft.client.KeyMapping; @@ -50,7 +46,8 @@ import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.TitleScreen; -import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.gui.screens.inventory.EffectsInInventory; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner; import net.minecraft.client.model.HumanoidModel; @@ -64,14 +61,16 @@ import net.minecraft.client.particle.ParticleEngine; import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.player.AbstractClientPlayer; -import net.minecraft.client.player.Input; +import net.minecraft.client.player.ClientInput; import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.FogParameters; import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.ShaderInstance; +import net.minecraft.client.renderer.ShaderDefines; +import net.minecraft.client.renderer.ShaderProgram; import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockElement; @@ -79,6 +78,7 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.chunk.RenderChunkRegion; import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.client.renderer.entity.state.HumanoidRenderState; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.atlas.SpriteSourceType; @@ -107,19 +107,18 @@ import net.minecraft.sounds.Music; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; +import net.minecraft.util.profiling.Profiler; import net.minecraft.world.InteractionHand; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.RecipeBookType; import net.minecraft.world.inventory.tooltip.TooltipComponent; -import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeManager; +import net.minecraft.world.item.equipment.EquipmentModel; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; @@ -129,8 +128,6 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FogType; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.EntityHitResult; -import net.minecraft.world.phys.HitResult; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.Event; import net.neoforged.bus.api.SubscribeEvent; @@ -154,7 +151,6 @@ import net.neoforged.neoforge.client.event.InputEvent; import net.neoforged.neoforge.client.event.ModelEvent; import net.neoforged.neoforge.client.event.MovementInputUpdateEvent; -import net.neoforged.neoforge.client.event.RecipesUpdatedEvent; import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; @@ -196,6 +192,7 @@ import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.joml.Vector3f; +import org.joml.Vector4f; /** * Class for various client-side-only hooks. @@ -256,9 +253,9 @@ public static float getGuiFarPlane() { return 11_000F + depth; } - public static ResourceLocation getArmorTexture(Entity entity, ItemStack armor, ArmorMaterial.Layer layer, boolean innerModel, EquipmentSlot slot) { - ResourceLocation result = armor.getItem().getArmorTexture(armor, entity, slot, layer, innerModel); - return result != null ? result : layer.texture(innerModel); + public static ResourceLocation getArmorTexture(ItemStack armor, EquipmentModel.LayerType type, EquipmentModel.Layer layer, ResourceLocation _default) { + ResourceLocation result = armor.getItem().getArmorTexture(armor, type, layer, _default); + return result != null ? result : _default; } public static boolean onClientPauseChangePre(boolean pause) { @@ -270,25 +267,15 @@ public static void onClientPauseChangePost(boolean pause) { NeoForge.EVENT_BUS.post(new ClientPauseChangeEvent.Post(pause)); } - public static boolean onDrawHighlight(LevelRenderer context, Camera camera, HitResult target, DeltaTracker deltaTracker, PoseStack poseStack, MultiBufferSource bufferSource) { - switch (target.getType()) { - case BLOCK: - if (!(target instanceof BlockHitResult blockTarget)) return false; - return NeoForge.EVENT_BUS.post(new RenderHighlightEvent.Block(context, camera, blockTarget, deltaTracker, poseStack, bufferSource)).isCanceled(); - case ENTITY: - if (!(target instanceof EntityHitResult entityTarget)) return false; - NeoForge.EVENT_BUS.post(new RenderHighlightEvent.Entity(context, camera, entityTarget, deltaTracker, poseStack, bufferSource)); - return false; - default: - return false; // NO-OP - This doesn't even get called for anything other than blocks and entities - } + public static boolean onDrawHighlight(LevelRenderer context, Camera camera, BlockHitResult target, DeltaTracker deltaTracker, PoseStack poseStack, MultiBufferSource bufferSource, boolean forTranslucentBlocks) { + return NeoForge.EVENT_BUS.post(new RenderHighlightEvent.Block(context, camera, target, deltaTracker, poseStack, bufferSource, forTranslucentBlocks)).isCanceled(); } public static void dispatchRenderStage(RenderLevelStageEvent.Stage stage, LevelRenderer levelRenderer, @Nullable PoseStack poseStack, Matrix4f modelViewMatrix, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum) { var mc = Minecraft.getInstance(); - var profiler = mc.getProfiler(); + var profiler = Profiler.get(); profiler.push(stage.toString()); - NeoForge.EVENT_BUS.post(new RenderLevelStageEvent(stage, levelRenderer, poseStack, modelViewMatrix, projectionMatrix, renderTick, mc.getTimer(), camera, frustum)); + NeoForge.EVENT_BUS.post(new RenderLevelStageEvent(stage, levelRenderer, poseStack, modelViewMatrix, projectionMatrix, renderTick, mc.getDeltaTracker(), camera, frustum)); profiler.pop(); } @@ -318,13 +305,13 @@ public static void onItemColorsInit(ItemColors itemColors, BlockColors blockColo ModLoader.postEvent(new RegisterColorHandlersEvent.Item(itemColors, blockColors)); } - public static Model getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot slot, HumanoidModel _default) { - return IClientItemExtensions.of(itemStack).getGenericArmorModel(entityLiving, itemStack, slot, _default); + public static Model getArmorModel(ItemStack itemStack, EquipmentModel.LayerType layerType, Model _default) { + return IClientItemExtensions.of(itemStack).getGenericArmorModel(itemStack, layerType, _default); } /** Copies humanoid model properties from the original model to another, used for armor models */ @SuppressWarnings("unchecked") - public static void copyModelProperties(HumanoidModel original, HumanoidModel replacement) { + public static void copyModelProperties(HumanoidModel original, HumanoidModel replacement) { // this function does not make use of the generic, so the unchecked cast should be safe original.copyPropertiesTo((HumanoidModel) replacement); replacement.head.visible = original.head.visible; @@ -352,13 +339,13 @@ public static String fixDomain(String base, String complex) { } } - public static float getFieldOfViewModifier(Player entity, float fovModifier) { - ComputeFovModifierEvent fovModifierEvent = new ComputeFovModifierEvent(entity, fovModifier); + public static float getFieldOfViewModifier(Player entity, float fovModifier, float fovScale) { + ComputeFovModifierEvent fovModifierEvent = new ComputeFovModifierEvent(entity, fovModifier, fovScale); NeoForge.EVENT_BUS.post(fovModifierEvent); return fovModifierEvent.getNewFovModifier(); } - public static double getFieldOfView(GameRenderer renderer, Camera camera, double partialTick, double fov, boolean usedConfiguredFov) { + public static float getFieldOfView(GameRenderer renderer, Camera camera, float partialTick, float fov, boolean usedConfiguredFov) { ViewportEvent.ComputeFov event = new ViewportEvent.ComputeFov(renderer, camera, partialTick, fov, usedConfiguredFov); NeoForge.EVENT_BUS.post(event); return event.getFOV(); @@ -429,10 +416,10 @@ private static void drawScreenInternal(Screen screen, GuiGraphics guiGraphics, i NeoForge.EVENT_BUS.post(new ScreenEvent.Render.Post(screen, guiGraphics, mouseX, mouseY, partialTick)); } - public static Vector3f getFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, float fogRed, float fogGreen, float fogBlue) { + public static Vector4f getFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, float fogRed, float fogGreen, float fogBlue) { // Modify fog color depending on the fluid FluidState state = level.getFluidState(camera.getBlockPosition()); - Vector3f fluidFogColor = new Vector3f(fogRed, fogGreen, fogBlue); + Vector4f fluidFogColor = new Vector4f(fogRed, fogGreen, fogBlue, 1F); if (camera.getPosition().y < (double) ((float) camera.getBlockPosition().getY() + state.getHeight(level, camera.getBlockPosition()))) fluidFogColor = IClientFluidTypeExtensions.of(state).modifyFogColor(camera, partialTick, level, renderDistance, darkenWorldAmount, fluidFogColor); @@ -443,18 +430,24 @@ public static Vector3f getFogColor(Camera camera, float partialTick, ClientLevel return fluidFogColor; } - public static void onFogRender(FogRenderer.FogMode mode, FogType type, Camera camera, float partialTick, float renderDistance, float nearDistance, float farDistance, FogShape shape) { + public static FogParameters onFogRender(FogRenderer.FogMode mode, FogType type, Camera camera, float partialTick, float renderDistance, FogParameters fogParameters) { // Modify fog rendering depending on the fluid FluidState state = camera.getEntity().level().getFluidState(camera.getBlockPosition()); if (camera.getPosition().y < (double) ((float) camera.getBlockPosition().getY() + state.getHeight(camera.getEntity().level(), camera.getBlockPosition()))) - IClientFluidTypeExtensions.of(state).modifyFogRender(camera, mode, renderDistance, partialTick, nearDistance, farDistance, shape); + fogParameters = IClientFluidTypeExtensions.of(state).modifyFogRender(camera, mode, renderDistance, partialTick, fogParameters); - ViewportEvent.RenderFog event = new ViewportEvent.RenderFog(mode, type, camera, partialTick, nearDistance, farDistance, shape); + ViewportEvent.RenderFog event = new ViewportEvent.RenderFog(mode, type, camera, partialTick, fogParameters); if (NeoForge.EVENT_BUS.post(event).isCanceled()) { - RenderSystem.setShaderFogStart(event.getNearPlaneDistance()); - RenderSystem.setShaderFogEnd(event.getFarPlaneDistance()); - RenderSystem.setShaderFogShape(event.getFogShape()); + return new FogParameters( + event.getNearPlaneDistance(), + event.getFarPlaneDistance(), + event.getFogShape(), + fogParameters.red(), + fogParameters.green(), + fogParameters.blue(), + fogParameters.alpha()); } + return fogParameters; } public static void onModifyBakingResult(Map models, Map stitchResults, ModelBakery modelBakery) { @@ -530,11 +523,11 @@ public static boolean calculateFaceWithoutAO(BlockAndTintGetter getter, BlockSta return true; } - public static void loadEntityShader(Entity entity, GameRenderer entityRenderer) { + public static void loadEntityShader(@Nullable Entity entity, GameRenderer gameRenderer) { if (entity != null) { ResourceLocation shader = EntitySpectatorShaderManager.get(entity.getType()); if (shader != null) { - entityRenderer.loadEffect(shader); + gameRenderer.setPostEffect(shader); } } } @@ -558,7 +551,7 @@ public static boolean shouldCauseReequipAnimation(ItemStack from, ItemStack to, public static CustomizeGuiOverlayEvent.BossEventProgress onCustomizeBossEventProgress(GuiGraphics guiGraphics, Window window, LerpingBossEvent bossInfo, int x, int y, int increment) { CustomizeGuiOverlayEvent.BossEventProgress evt = new CustomizeGuiOverlayEvent.BossEventProgress(window, guiGraphics, - Minecraft.getInstance().getTimer(), bossInfo, x, y, increment); + Minecraft.getInstance().getDeltaTracker(), bossInfo, x, y, increment); NeoForge.EVENT_BUS.post(evt); return evt; } @@ -576,7 +569,7 @@ public static void onClientChangeGameType(PlayerInfo info, GameType currentGameM } } - public static void onMovementInputUpdate(Player player, Input movementInput) { + public static void onMovementInputUpdate(Player player, ClientInput movementInput) { NeoForge.EVENT_BUS.post(new MovementInputUpdateEvent(player, movementInput)); } @@ -658,11 +651,6 @@ public static void onScreenCharTypedPost(Screen guiScreen, char codePoint, int m NeoForge.EVENT_BUS.post(event); } - public static void onRecipesUpdated(RecipeManager mgr) { - Event event = new RecipesUpdatedEvent(mgr); - NeoForge.EVENT_BUS.post(event); - } - public static boolean onMouseButtonPre(int button, int action, int mods) { return NeoForge.EVENT_BUS.post(new InputEvent.MouseButton.Pre(button, action, mods)).isCanceled(); } @@ -686,12 +674,9 @@ public static InputEvent.InteractionKeyMappingTriggered onClickInput(int button, return event; } - public static boolean isNameplateInRenderDistance(Entity entity, double squareDistance) { - if (entity instanceof LivingEntity) { - double value = ((LivingEntity) entity).getAttributeValue(NeoForgeMod.NAMETAG_DISTANCE); - return !(squareDistance > value * value); - } - return !(squareDistance > 4096.0f); + public static boolean isNameplateInRenderDistance(LivingEntity entity, double squareDistance) { + double value = entity.getAttributeValue(NeoForgeMod.NAMETAG_DISTANCE); + return !(squareDistance > value * value); } public static void renderPistonMovedBlocks(BlockPos pos, BlockState state, PoseStack stack, MultiBufferSource bufferSource, Level level, boolean checkSides, int packedOverlay, BlockRenderDispatcher blockRenderer) { @@ -765,28 +750,16 @@ public static String onClientSendMessage(String message) { return NeoForge.EVENT_BUS.post(event).isCanceled() ? "" : event.getMessage(); } - /** - * Mimics the behavior of {@link net.minecraft.client.renderer.ItemBlockRenderTypes#getRenderType(BlockState, boolean)} - * for the input {@link RenderType}. - */ - public static RenderType getEntityRenderType(RenderType chunkRenderType, boolean cull) { - return RenderTypeHelper.getEntityRenderType(chunkRenderType, cull); - } - @EventBusSubscriber(value = Dist.CLIENT, modid = "neoforge", bus = EventBusSubscriber.Bus.MOD) public static class ClientEvents { - @Nullable - private static ShaderInstance rendertypeEntityTranslucentUnlitShader; - - public static ShaderInstance getEntityTranslucentUnlitShader() { - return Objects.requireNonNull(rendertypeEntityTranslucentUnlitShader, "Attempted to call getEntityTranslucentUnlitShader before shaders have finished loading."); - } + public static final ShaderProgram RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER = new ShaderProgram( + ResourceLocation.fromNamespaceAndPath(NeoForgeVersion.MOD_ID, "core/rendertype_entity_unlit_translucent"), + DefaultVertexFormat.NEW_ENTITY, + ShaderDefines.EMPTY); @SubscribeEvent - public static void registerShaders(RegisterShadersEvent event) throws IOException { - event.registerShader(new ShaderInstance(event.getResourceProvider(), ResourceLocation.fromNamespaceAndPath("neoforge", "rendertype_entity_unlit_translucent"), DefaultVertexFormat.NEW_ENTITY), (p_172645_) -> { - rendertypeEntityTranslucentUnlitShader = p_172645_; - }); + public static void registerShaders(RegisterShadersEvent event) { + event.registerShader(RENDERTYPE_ENTITY_TRANSLUCENT_UNLIT_SHADER); } } @@ -801,10 +774,8 @@ public static RenderTooltipEvent.Pre onRenderTooltipPre(ItemStack stack, GuiGrap return preEvent; } - public static RenderTooltipEvent.Color onRenderTooltipColor(ItemStack stack, GuiGraphics graphics, int x, int y, Font font, List components) { - var colorEvent = new RenderTooltipEvent.Color(stack, graphics, x, y, font, 0xf0100010, 0x505000FF, 0x5028007f, components); - NeoForge.EVENT_BUS.post(colorEvent); - return colorEvent; + public static RenderTooltipEvent.Texture onRenderTooltipTexture(ItemStack stack, GuiGraphics graphics, int x, int y, Font font, List components, @Nullable ResourceLocation texture) { + return NeoForge.EVENT_BUS.post(new RenderTooltipEvent.Texture(stack, graphics, x, y, font, components, texture)); } public static List gatherTooltipComponents(ItemStack stack, List textElements, int mouseX, int screenWidth, int screenHeight, Font fallbackFont) { @@ -923,13 +894,6 @@ public static int getMaxMipmapLevel(int width, int height) { Mth.log2(Math.max(1, height))); } - public static ResourceLocation getShaderImportLocation(String basePath, boolean isRelative, String importPath) { - final var loc = ResourceLocation.parse(importPath); - final var normalised = FileUtil.normalizeResourcePath( - (isRelative ? basePath : "shaders/include/") + loc.getPath()); - return ResourceLocation.fromNamespaceAndPath(loc.getNamespace(), normalised); - } - private static final BiMap SPRITE_SOURCE_TYPES_MAP = HashBiMap.create(); public static BiMap makeSpriteSourceTypesMap() { @@ -1038,10 +1002,11 @@ public static void initClientHooks(Minecraft mc, ReloadableResourceManager resou MapDecorationRendererManager.init(); DimensionTransitionScreenManager.init(); AnimationTypeManager.init(); + CoreShaderManager.init(); } /** - * Fires {@link RenderFrameEvent.Pre}. Called just before {@link GameRenderer#render(float, long, boolean)} in {@link Minecraft#runTick(boolean)}. + * Fires {@link RenderFrameEvent.Pre}. Called just before {@link GameRenderer#render(DeltaTracker, boolean)} in {@link Minecraft#runTick(boolean)}. *

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

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

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

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

- * Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getRenderType(ItemStack, boolean)} + * Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getRenderType(ItemStack)} * but removes the need to query the model again if the item is a {@link BlockItem}. */ - public static RenderType getFallbackItemRenderType(ItemStack stack, BakedModel model, boolean cull) { + public static RenderType getFallbackItemRenderType(ItemStack stack, BakedModel model) { if (stack.getItem() instanceof BlockItem blockItem) { var renderTypes = model.getRenderTypes(blockItem.getBlock().defaultBlockState(), RandomSource.create(42), ModelData.EMPTY); if (renderTypes.contains(RenderType.translucent())) - return getEntityRenderType(RenderType.translucent(), cull); + return getEntityRenderType(RenderType.translucent()); return Sheets.cutoutBlockSheet(); } - return cull ? Sheets.translucentCullBlockSheet() : Sheets.translucentItemSheet(); + return Sheets.translucentItemSheet(); } private RenderTypeHelper() {} diff --git a/src/main/java/net/neoforged/neoforge/client/TagConventionLogWarningClient.java b/src/main/java/net/neoforged/neoforge/client/TagConventionLogWarningClient.java index 4e68adbed5..72c8d0b881 100644 --- a/src/main/java/net/neoforged/neoforge/client/TagConventionLogWarningClient.java +++ b/src/main/java/net/neoforged/neoforge/client/TagConventionLogWarningClient.java @@ -8,6 +8,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.List; import net.minecraft.client.resources.language.I18n; +import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; @@ -49,7 +50,7 @@ static void setupUntranslatedItemTagWarning(IEventBus forgeBus) { if (!FMLLoader.isProduction() == isConfigSetToDev) { List> untranslatedTags = new ObjectArrayList<>(); RegistryAccess.Frozen registryAccess = serverStartingEvent.getServer().registryAccess(); - extractUnregisteredModdedTags(registryAccess.registryOrThrow(Registries.ITEM), untranslatedTags); + extractUnregisteredModdedTags(registryAccess.lookupOrThrow(Registries.ITEM), untranslatedTags); if (!untranslatedTags.isEmpty()) { StringBuilder stringBuilder = new StringBuilder(); @@ -80,7 +81,7 @@ static void setupUntranslatedItemTagWarning(IEventBus forgeBus) { } private static void extractUnregisteredModdedTags(Registry registry, List> untranslatedTags) { - registry.getTagNames().forEach(itemTagKey -> { + registry.getTags().map(HolderSet.Named::key).forEach(itemTagKey -> { // We do not translate vanilla's tags at this moment. if (itemTagKey.location().getNamespace().equals("minecraft")) { return; diff --git a/src/main/java/net/neoforged/neoforge/client/entity/animation/json/AnimationLoader.java b/src/main/java/net/neoforged/neoforge/client/entity/animation/json/AnimationLoader.java index 8fd278c8fc..7d788419d2 100644 --- a/src/main/java/net/neoforged/neoforge/client/entity/animation/json/AnimationLoader.java +++ b/src/main/java/net/neoforged/neoforge/client/entity/animation/json/AnimationLoader.java @@ -6,11 +6,7 @@ package net.neoforged.neoforge.client.entity.animation.json; import com.google.common.collect.MapMaker; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; import com.mojang.logging.LogUtils; -import com.mojang.serialization.JsonOps; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -25,7 +21,7 @@ /** * A loader for entity animations written in JSON. You can also get parsed animations from this class. */ -public final class AnimationLoader extends SimpleJsonResourceReloadListener { +public final class AnimationLoader extends SimpleJsonResourceReloadListener { private static final Logger LOGGER = LogUtils.getLogger(); public static final AnimationLoader INSTANCE = new AnimationLoader(); @@ -35,7 +31,7 @@ public final class AnimationLoader extends SimpleJsonResourceReloadListener { private final List strongHolderReferences = new ArrayList<>(); private AnimationLoader() { - super(new Gson(), "neoforge/animations/entity"); + super(AnimationParser.CODEC, "neoforge/animations/entity"); } /** @@ -56,21 +52,15 @@ public AnimationHolder getAnimationHolder(ResourceLocation key) { } @Override - protected void apply(Map animationJsons, ResourceManager resourceManager, ProfilerFiller profiler) { + protected void apply(Map animationJsons, ResourceManager resourceManager, ProfilerFiller profiler) { animations.values().forEach(AnimationHolder::unbind); strongHolderReferences.clear(); int loaded = 0; for (final var entry : animationJsons.entrySet()) { - try { - final var animation = AnimationParser.CODEC.parse(JsonOps.INSTANCE, entry.getValue()) - .getOrThrow(JsonParseException::new); - final var holder = getAnimationHolder(entry.getKey()); - holder.bind(animation); - strongHolderReferences.add(holder); - loaded++; - } catch (Exception e) { - LOGGER.error("Failed to load animation {}", entry.getKey(), e); - } + final var holder = getAnimationHolder(entry.getKey()); + holder.bind(entry.getValue()); + strongHolderReferences.add(holder); + loaded++; } LOGGER.info("Loaded {} entity animations", loaded); } diff --git a/src/main/java/net/neoforged/neoforge/client/event/ComputeFovModifierEvent.java b/src/main/java/net/neoforged/neoforge/client/event/ComputeFovModifierEvent.java index 7e85540c4b..a2afcc39dd 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/ComputeFovModifierEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/ComputeFovModifierEvent.java @@ -5,7 +5,6 @@ package net.neoforged.neoforge.client.event; -import net.minecraft.client.Minecraft; import net.minecraft.util.Mth; import net.minecraft.world.entity.player.Player; import net.neoforged.bus.api.Event; @@ -26,13 +25,15 @@ public class ComputeFovModifierEvent extends Event { private final Player player; private final float fovModifier; + private final float fovScale; private float newFovModifier; @ApiStatus.Internal - public ComputeFovModifierEvent(Player player, float fovModifier) { + public ComputeFovModifierEvent(Player player, float fovModifier, float fovScale) { this.player = player; this.fovModifier = fovModifier; - this.setNewFovModifier((float) Mth.lerp(Minecraft.getInstance().options.fovEffectScale().get(), 1.0F, fovModifier)); + this.fovScale = fovScale; + this.setNewFovModifier(Mth.lerp(fovScale, 1.0F, fovModifier)); } /** @@ -49,6 +50,13 @@ public float getFovModifier() { return fovModifier; } + /** + * {@return the FOV scale to use for interpolating the final FOV modifier} + */ + public float getFovScale() { + return fovScale; + } + /** * {@return the current field of vision (FOV) of the player} */ diff --git a/src/main/java/net/neoforged/neoforge/client/event/EntityRenderersEvent.java b/src/main/java/net/neoforged/neoforge/client/event/EntityRenderersEvent.java index 9498a500e9..fc2d26c7ac 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/EntityRenderersEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/EntityRenderersEvent.java @@ -121,12 +121,12 @@ public void registerBlockEntityRenderer(BlockEntityType< * only on the {@linkplain LogicalSide#CLIENT logical client}.

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

* This event is only fired on the {@linkplain Dist#CLIENT physical client}. */ public class GatherEffectScreenTooltipsEvent extends Event { - protected final EffectRenderingInventoryScreen screen; + protected final AbstractContainerScreen screen; protected final MobEffectInstance effectInst; protected final List tooltip; - public GatherEffectScreenTooltipsEvent(EffectRenderingInventoryScreen screen, MobEffectInstance effectInst, List tooltip) { + public GatherEffectScreenTooltipsEvent(AbstractContainerScreen screen, MobEffectInstance effectInst, List tooltip) { this.screen = screen; this.effectInst = effectInst; this.tooltip = new ArrayList<>(tooltip); @@ -33,7 +34,7 @@ public GatherEffectScreenTooltipsEvent(EffectRenderingInventoryScreen screen, /** * @return The screen which will be rendering the tooltip lines. */ - public EffectRenderingInventoryScreen getScreen() { + public AbstractContainerScreen getScreen() { return this.screen; } diff --git a/src/main/java/net/neoforged/neoforge/client/event/MovementInputUpdateEvent.java b/src/main/java/net/neoforged/neoforge/client/event/MovementInputUpdateEvent.java index 1478760beb..4fa6142d2d 100644 --- a/src/main/java/net/neoforged/neoforge/client/event/MovementInputUpdateEvent.java +++ b/src/main/java/net/neoforged/neoforge/client/event/MovementInputUpdateEvent.java @@ -5,7 +5,7 @@ package net.neoforged.neoforge.client.event; -import net.minecraft.client.player.Input; +import net.minecraft.client.player.ClientInput; import net.minecraft.world.entity.player.Player; import net.neoforged.bus.api.Event; import net.neoforged.fml.LogicalSide; @@ -22,10 +22,10 @@ * only on the {@linkplain LogicalSide#CLIENT logical client}.

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

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

- * - *

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

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

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

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

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

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

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

+ *

This event is not {@linkplain ICancellableEvent cancellable}.

* *

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

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

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

- * - *

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

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

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

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

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

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

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

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

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

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

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

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

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

* *

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

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

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

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

* *

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

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

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

+ *

This event is not {@linkplain ICancellableEvent cancellable}.

* *

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

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

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

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

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

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

* If you override this method you are responsible for copying any properties you care about from the original model. * - * @param livingEntity The entity wearing the armor - * @param itemStack The item stack - * @param equipmentSlot The slot the item is in - * @param original The original armor model. Will have attributes set. + * @param itemStack The item stack + * @param layerType The slot the item is in + * @param original The original armor model. Will have attributes set. * @return A Model to be rendered. Relevant properties must be copied over manually. - * @see #getHumanoidArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel) + * @see #getHumanoidArmorModel(ItemStack, EquipmentModel.LayerType, Model) */ - default Model getGenericArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel original) { - HumanoidModel replacement = getHumanoidArmorModel(livingEntity, itemStack, equipmentSlot, original); + default Model getGenericArmorModel(ItemStack itemStack, EquipmentModel.LayerType layerType, Model original) { + Model replacement = getHumanoidArmorModel(itemStack, layerType, original); if (replacement != original) { - ClientHooks.copyModelProperties(original, replacement); + // FIXME: equipment rendering deals with a plain Model now + //ClientHooks.copyModelProperties(original, replacement); return replacement; } return original; @@ -141,6 +139,7 @@ default Model getGenericArmorModel(LivingEntity livingEntity, ItemStack itemStac * @param netHeadYaw The yaw (Y rotation) of the entity's head * @param headPitch The pitch (X rotation) of the entity's head */ + // TODO 1.21.2: add back patch that calls this method from HumanoidArmorLayer default void setupModelAnimations(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, Model model, float limbSwing, float limbSwingAmount, float partialTick, float ageInTicks, float netHeadYaw, float headPitch) {} /** @@ -187,7 +186,7 @@ default boolean shouldSpreadAsEntity(ItemStack stack) { } /** - * Called when armor layers are rendered by {@link net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer}. + * Called when armor layers are rendered by {@link net.minecraft.client.renderer.entity.layers.EquipmentLayerRenderer}. *

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

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

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

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

Cures can be added to or removed from your own effects via {@link MobEffect#fillEffectCures(Set, MobEffectInstance)} - * or any effect by modifying the set of cures on the {@link MobEffectInstance} in {@link MobEffectEvent.Added} - */ -public final class EffectCure { - private static final Map CURES = new ConcurrentHashMap<>(); - - public static Codec CODEC = Codec.STRING.xmap(EffectCure::get, EffectCure::name); - public static final StreamCodec STREAM_CODEC = ByteBufCodecs.STRING_UTF8.map(EffectCure::get, EffectCure::name); - - /** - * {@return all registered cures} - * This collection can be kept around, and will update itself in response to changes to the map. - * See {@link ConcurrentHashMap#values()} for details. - */ - public static Collection getAllCures() { - return Collections.unmodifiableCollection(CURES.values()); - } - - /** - * Gets or creates a new EffectCure for the given name. - */ - public static EffectCure get(String name) { - return CURES.computeIfAbsent(name, EffectCure::new); - } - - /** - * {@return the name of this cure} - */ - public String name() { - return name; - } - - @Override - public String toString() { - return "EffectCure[" + name + "]"; - } - - private final String name; - - /** - * Use {@link #get(String)} to get or create an EffectCure - */ - private EffectCure(String name) { - this.name = name; - } -} diff --git a/src/main/java/net/neoforged/neoforge/common/EffectCures.java b/src/main/java/net/neoforged/neoforge/common/EffectCures.java deleted file mode 100644 index 4362015969..0000000000 --- a/src/main/java/net/neoforged/neoforge/common/EffectCures.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) NeoForged and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.neoforge.common; - -import java.util.Set; - -public class EffectCures { - /** - * Cure used when a milk bucket is consumed. Cures any effect by default. - */ - public static final EffectCure MILK = EffectCure.get("milk"); - /** - * Cure used when a honey bottle is consumed. Only cures poison by default. - */ - public static final EffectCure HONEY = EffectCure.get("honey"); - /** - * Cure used when a totem of undying protects the player from death. Cures any effect by default. - */ - public static final EffectCure PROTECTED_BY_TOTEM = EffectCure.get("protected_by_totem"); - - public static final Set DEFAULT_CURES = Set.of(MILK, PROTECTED_BY_TOTEM); -} diff --git a/src/main/java/net/neoforged/neoforge/common/IShearable.java b/src/main/java/net/neoforged/neoforge/common/IShearable.java index ae5d51aabc..2be9098654 100644 --- a/src/main/java/net/neoforged/neoforge/common/IShearable.java +++ b/src/main/java/net/neoforged/neoforge/common/IShearable.java @@ -9,6 +9,7 @@ import java.util.Collections; import java.util.List; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundSource; import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; @@ -64,9 +65,9 @@ default boolean isShearable(@Nullable Player player, ItemStack item, Level level @SuppressWarnings("deprecation") // Expected call to deprecated vanilla Shearable#shear default List onSheared(@Nullable Player player, ItemStack item, Level level, BlockPos pos) { if (this instanceof LivingEntity entity && this instanceof Shearable shearable) { - if (!level.isClientSide) { + if (level instanceof ServerLevel serverLevel) { entity.captureDrops(new ArrayList<>()); - shearable.shear(player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS); + shearable.shear(serverLevel, player == null ? SoundSource.BLOCKS : SoundSource.PLAYERS, item); return entity.captureDrops(null).stream().map(ItemEntity::getItem).toList(); } } @@ -82,23 +83,23 @@ default List onSheared(@Nullable Player player, ItemStack item, Level * @param pos The block position of this object (if this is an entity, the value of {@link Entity#blockPosition()}. * @param drop The stack to drop, from the list of drops returned by {@link #onSheared}. */ - default void spawnShearedDrop(Level level, BlockPos pos, ItemStack drop) { + default void spawnShearedDrop(ServerLevel level, BlockPos pos, ItemStack drop) { if (this instanceof SnowGolem golem) { // SnowGolem#shear uses spawnAtLocation(..., this.getEyeHeight()); - golem.spawnAtLocation(drop, golem.getEyeHeight()); + golem.spawnAtLocation(level, drop, golem.getEyeHeight()); } else if (this instanceof Bogged bogged) { // Bogged#spawnShearedMushrooms uses spawnAtLocation(..., this.getBbHeight()); - bogged.spawnAtLocation(drop, bogged.getBbHeight()); + bogged.spawnAtLocation(level, drop, bogged.getBbHeight()); } else if (this instanceof MushroomCow cow) { // We patch Mooshrooms from using addFreshEntity to spawnAtLocation to spawnAtLocation to capture the drops. // In case a mod is also capturing drops, we also replicate that logic here. - ItemEntity itemEntity = cow.spawnAtLocation(drop, cow.getBbHeight()); + ItemEntity itemEntity = cow.spawnAtLocation(level, drop, cow.getBbHeight()); if (itemEntity != null) { itemEntity.setNoPickUpDelay(); } } else if (this instanceof Entity entity) { // Everything else uses the "default" rules invented by Sheep#shear, which uses a y-offset of 1 and these random delta movement values. - ItemEntity itemEntity = entity.spawnAtLocation(drop, 1); + ItemEntity itemEntity = entity.spawnAtLocation(level, drop, 1); if (itemEntity != null) { RandomSource rand = entity.getRandom(); Vec3 newDelta = itemEntity.getDeltaMovement().add( diff --git a/src/main/java/net/neoforged/neoforge/common/MonsterRoomHooks.java b/src/main/java/net/neoforged/neoforge/common/MonsterRoomHooks.java index dca24a231b..e2f08277a8 100644 --- a/src/main/java/net/neoforged/neoforge/common/MonsterRoomHooks.java +++ b/src/main/java/net/neoforged/neoforge/common/MonsterRoomHooks.java @@ -26,7 +26,7 @@ public class MonsterRoomHooks { @SubscribeEvent public static void onDataMapsUpdated(DataMapsUpdatedEvent event) { event.ifRegistry(Registries.ENTITY_TYPE, registry -> monsterRoomMobs = registry.getDataMap(NeoForgeDataMaps.MONSTER_ROOM_MOBS).entrySet().stream().map((entry) -> { - EntityType type = Objects.requireNonNull(registry.get(entry.getKey()), "Nonexistent entity " + entry.getKey() + " in monster room datamap!"); + EntityType type = Objects.requireNonNull(registry.getValue(entry.getKey()), "Nonexistent entity " + entry.getKey() + " in monster room datamap!"); return new MobEntry(type, entry.getValue().weight()); }).toList()); } diff --git a/src/main/java/net/neoforged/neoforge/common/NeoForgeConfig.java b/src/main/java/net/neoforged/neoforge/common/NeoForgeConfig.java index ebbe55f846..91a232a8ae 100644 --- a/src/main/java/net/neoforged/neoforge/common/NeoForgeConfig.java +++ b/src/main/java/net/neoforged/neoforge/common/NeoForgeConfig.java @@ -87,8 +87,6 @@ public static class Client { public final BooleanValue showLoadWarnings; - public final BooleanValue useCombinedDepthStencilAttachment; - public final BooleanValue logUntranslatedConfigurationWarnings; Client(ModConfigSpec.Builder builder) { @@ -102,11 +100,6 @@ public static class Client { .translation("neoforge.configgui.showLoadWarnings") .define("showLoadWarnings", true); - useCombinedDepthStencilAttachment = builder - .comment("Set to true to use a combined DEPTH_STENCIL attachment instead of two separate ones.") - .translation("neoforge.configgui.useCombinedDepthStencilAttachment") - .define("useCombinedDepthStencilAttachment", false); - logUntranslatedConfigurationWarnings = builder .comment("A config option mainly for developers. Logs out configuration values that do not have translations when running a client in a development environment.") .translation("neoforge.configgui.logUntranslatedConfigurationWarnings") diff --git a/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java b/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java index 2e2e14ab5f..d7440f1ea6 100644 --- a/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java +++ b/src/main/java/net/neoforged/neoforge/common/NeoForgeEventHandler.java @@ -57,7 +57,7 @@ public void onEntityJoinWorld(EntityJoinLevelEvent event) { entity.discard(); event.setCanceled(true); var executor = LogicalSidedProvider.WORKQUEUE.get(event.getLevel().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER); - executor.tell(new TickTask(0, () -> event.getLevel().addFreshEntity(newEntity))); + executor.schedule(new TickTask(0, () -> event.getLevel().addFreshEntity(newEntity))); } } } @@ -110,7 +110,7 @@ public void tagsUpdated(TagsUpdatedEvent event) { public void onDpSync(final OnDatapackSyncEvent event) { RegistryManager.getDataMaps().forEach((registry, values) -> { final var regOpt = event.getPlayerList().getServer().overworld().registryAccess() - .registry(registry); + .lookup(registry); if (regOpt.isEmpty()) return; event.getRelevantPlayers().forEach(player -> { if (!player.connection.hasChannel(RegistryDataMapSyncPayload.TYPE)) { diff --git a/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java b/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java index f522840453..31a0bebee8 100644 --- a/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java +++ b/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java @@ -35,6 +35,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.metadata.pack.PackMetadataSection; import net.minecraft.sounds.SoundEvent; @@ -51,16 +52,15 @@ import net.minecraft.world.entity.ai.attributes.RangedAttribute; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.display.SlotDisplay; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.GameRules; -import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.MobSpawnSettings; import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.PointedDripstoneBlock; -import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.GenerationStep.Decoration; import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; import net.minecraft.world.level.levelgen.placement.PlacedFeature; @@ -99,6 +99,7 @@ import net.neoforged.neoforge.common.conditions.TrueCondition; import net.neoforged.neoforge.common.crafting.BlockTagIngredient; import net.neoforged.neoforge.common.crafting.CompoundIngredient; +import net.neoforged.neoforge.common.crafting.CustomDisplayIngredient; import net.neoforged.neoforge.common.crafting.DataComponentIngredient; import net.neoforged.neoforge.common.crafting.DifferenceIngredient; import net.neoforged.neoforge.common.crafting.IngredientType; @@ -141,13 +142,16 @@ import net.neoforged.neoforge.fluids.CauldronFluidContent; import net.neoforged.neoforge.fluids.FluidType; import net.neoforged.neoforge.fluids.crafting.CompoundFluidIngredient; +import net.neoforged.neoforge.fluids.crafting.CustomDisplayFluidIngredient; import net.neoforged.neoforge.fluids.crafting.DataComponentFluidIngredient; import net.neoforged.neoforge.fluids.crafting.DifferenceFluidIngredient; -import net.neoforged.neoforge.fluids.crafting.EmptyFluidIngredient; +import net.neoforged.neoforge.fluids.crafting.FluidIngredientCodecs; import net.neoforged.neoforge.fluids.crafting.FluidIngredientType; import net.neoforged.neoforge.fluids.crafting.IntersectionFluidIngredient; -import net.neoforged.neoforge.fluids.crafting.SingleFluidIngredient; -import net.neoforged.neoforge.fluids.crafting.TagFluidIngredient; +import net.neoforged.neoforge.fluids.crafting.SimpleFluidIngredient; +import net.neoforged.neoforge.fluids.crafting.display.FluidSlotDisplay; +import net.neoforged.neoforge.fluids.crafting.display.FluidStackSlotDisplay; +import net.neoforged.neoforge.fluids.crafting.display.FluidTagSlotDisplay; import net.neoforged.neoforge.forge.snapshots.ForgeSnapshotsMod; import net.neoforged.neoforge.internal.versions.neoforge.NeoForgeVersion; import net.neoforged.neoforge.network.DualStackUtils; @@ -196,7 +200,7 @@ public class NeoForgeMod { SingletonArgumentInfo.contextFree(ModIdArgument::modIdArgument))); public static final Holder SWIM_SPEED = ATTRIBUTES.register("swim_speed", () -> new PercentageAttribute("neoforge.swim_speed", 1.0D, 0.0D, 1024.0D).setSyncable(true)); - public static final Holder NAMETAG_DISTANCE = ATTRIBUTES.register("nametag_distance", () -> new RangedAttribute("neoforge.name_tag_distance", 64.0D, 0.0D, 64.0).setSyncable(true).setSentiment(Sentiment.NEUTRAL)); + public static final Holder NAMETAG_DISTANCE = ATTRIBUTES.register("nametag_distance", () -> new RangedAttribute("neoforge.name_tag_distance", 32.0D, 0.0D, 32.0).setSyncable(true).setSentiment(Sentiment.NEUTRAL)); /** * This attribute controls if the player may use creative flight when not in creative mode. @@ -273,18 +277,14 @@ public class NeoForgeMod { */ public static final DeferredHolder, MapCodec> ADD_CARVERS_BIOME_MODIFIER_TYPE = BIOME_MODIFIER_SERIALIZERS.register("add_carvers", () -> RecordCodecBuilder.mapCodec(builder -> builder.group( Biome.LIST_CODEC.fieldOf("biomes").forGetter(BiomeModifiers.AddCarversBiomeModifier::biomes), - ConfiguredWorldCarver.LIST_CODEC.fieldOf("carvers").forGetter(BiomeModifiers.AddCarversBiomeModifier::carvers), - GenerationStep.Carving.CODEC.fieldOf("step").forGetter(BiomeModifiers.AddCarversBiomeModifier::step)).apply(builder, BiomeModifiers.AddCarversBiomeModifier::new))); + ConfiguredWorldCarver.LIST_CODEC.fieldOf("carvers").forGetter(BiomeModifiers.AddCarversBiomeModifier::carvers)).apply(builder, BiomeModifiers.AddCarversBiomeModifier::new))); /** * Stock biome modifier for removing carvers from biomes. */ public static final DeferredHolder, MapCodec> REMOVE_CARVERS_BIOME_MODIFIER_TYPE = BIOME_MODIFIER_SERIALIZERS.register("remove_carvers", () -> RecordCodecBuilder.mapCodec(builder -> builder.group( Biome.LIST_CODEC.fieldOf("biomes").forGetter(BiomeModifiers.RemoveCarversBiomeModifier::biomes), - ConfiguredWorldCarver.LIST_CODEC.fieldOf("carvers").forGetter(BiomeModifiers.RemoveCarversBiomeModifier::carvers), - Codec.either(GenerationStep.Carving.CODEC.listOf(), GenerationStep.Carving.CODEC).xmap( - either -> either.map(Set::copyOf, Set::of), - set -> set.size() == 1 ? Either.right(set.toArray(GenerationStep.Carving[]::new)[0]) : Either.left(List.copyOf(set))).optionalFieldOf("steps", EnumSet.allOf(GenerationStep.Carving.class)).forGetter(BiomeModifiers.RemoveCarversBiomeModifier::steps)) + ConfiguredWorldCarver.LIST_CODEC.fieldOf("carvers").forGetter(BiomeModifiers.RemoveCarversBiomeModifier::carvers)) .apply(builder, BiomeModifiers.RemoveCarversBiomeModifier::new))); /** @@ -357,6 +357,12 @@ public class NeoForgeMod { */ public static final Holder NOT_HOLDER_SET = HOLDER_SET_TYPES.register("not", NotHolderSet.Type::new); + private static final DeferredRegister> SLOT_DISPLAY_TYPES = DeferredRegister.create(Registries.SLOT_DISPLAY, NeoForgeVersion.MOD_ID); + + public static final DeferredHolder, SlotDisplay.Type> FLUID_SLOT_DISPLAY = SLOT_DISPLAY_TYPES.register("fluid", () -> new SlotDisplay.Type<>(FluidSlotDisplay.MAP_CODEC, FluidSlotDisplay.STREAM_CODEC)); + public static final DeferredHolder, SlotDisplay.Type> FLUID_STACK_SLOT_DISPLAY = SLOT_DISPLAY_TYPES.register("fluid_stack", () -> new SlotDisplay.Type<>(FluidStackSlotDisplay.MAP_CODEC, FluidStackSlotDisplay.STREAM_CODEC)); + public static final DeferredHolder, SlotDisplay.Type> FLUID_TAG_SLOT_DISPLAY = SLOT_DISPLAY_TYPES.register("fluid_tag", () -> new SlotDisplay.Type<>(FluidTagSlotDisplay.MAP_CODEC, FluidTagSlotDisplay.STREAM_CODEC)); + private static final DeferredRegister> INGREDIENT_TYPES = DeferredRegister.create(NeoForgeRegistries.Keys.INGREDIENT_TYPES, NeoForgeVersion.MOD_ID); public static final DeferredHolder, IngredientType> COMPOUND_INGREDIENT_TYPE = INGREDIENT_TYPES.register("compound", () -> new IngredientType<>(CompoundIngredient.CODEC)); @@ -364,15 +370,15 @@ public class NeoForgeMod { public static final DeferredHolder, IngredientType> DIFFERENCE_INGREDIENT_TYPE = INGREDIENT_TYPES.register("difference", () -> new IngredientType<>(DifferenceIngredient.CODEC)); public static final DeferredHolder, IngredientType> INTERSECTION_INGREDIENT_TYPE = INGREDIENT_TYPES.register("intersection", () -> new IngredientType<>(IntersectionIngredient.CODEC)); public static final DeferredHolder, IngredientType> BLOCK_TAG_INGREDIENT = INGREDIENT_TYPES.register("block_tag", () -> new IngredientType<>(BlockTagIngredient.CODEC)); + public static final DeferredHolder, IngredientType> CUSTOM_DISPLAY_INGREDIENT = INGREDIENT_TYPES.register("custom_display", () -> new IngredientType<>(CustomDisplayIngredient.CODEC)); private static final DeferredRegister> FLUID_INGREDIENT_TYPES = DeferredRegister.create(NeoForgeRegistries.Keys.FLUID_INGREDIENT_TYPES, NeoForgeVersion.MOD_ID); - public static final DeferredHolder, FluidIngredientType> SINGLE_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("single", () -> new FluidIngredientType<>(SingleFluidIngredient.CODEC)); - public static final DeferredHolder, FluidIngredientType> TAG_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("tag", () -> new FluidIngredientType<>(TagFluidIngredient.CODEC)); - public static final DeferredHolder, FluidIngredientType> EMPTY_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("empty", () -> new FluidIngredientType<>(EmptyFluidIngredient.CODEC)); + public static final DeferredHolder, FluidIngredientType> SIMPLE_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("simple", FluidIngredientCodecs::simpleType); public static final DeferredHolder, FluidIngredientType> COMPOUND_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("compound", () -> new FluidIngredientType<>(CompoundFluidIngredient.CODEC)); public static final DeferredHolder, FluidIngredientType> DATA_COMPONENT_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("components", () -> new FluidIngredientType<>(DataComponentFluidIngredient.CODEC)); public static final DeferredHolder, FluidIngredientType> DIFFERENCE_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("difference", () -> new FluidIngredientType<>(DifferenceFluidIngredient.CODEC)); public static final DeferredHolder, FluidIngredientType> INTERSECTION_FLUID_INGREDIENT_TYPE = FLUID_INGREDIENT_TYPES.register("intersection", () -> new FluidIngredientType<>(IntersectionFluidIngredient.CODEC)); + public static final DeferredHolder, FluidIngredientType> CUSTOM_DISPLAY_FLUID_INGREDIENT = FLUID_INGREDIENT_TYPES.register("custom_display", () -> new FluidIngredientType<>(CustomDisplayFluidIngredient.CODEC, CustomDisplayFluidIngredient.STREAM_CODEC)); private static final DeferredRegister> CONDITION_CODECS = DeferredRegister.create(NeoForgeRegistries.Keys.CONDITION_CODECS, NeoForgeVersion.MOD_ID); public static final DeferredHolder, MapCodec> AND_CONDITION = CONDITION_CODECS.register("and", () -> AndCondition.CODEC); @@ -425,7 +431,7 @@ public void setItemMovement(ItemEntity entity) { .addDripstoneDripping(PointedDripstoneBlock.WATER_TRANSFER_PROBABILITY_PER_RANDOM_TICK, ParticleTypes.DRIPPING_DRIPSTONE_WATER, Blocks.WATER_CAULDRON, SoundEvents.POINTED_DRIPSTONE_DRIP_WATER_INTO_CAULDRON)) { @Override public boolean canConvertToSource(FluidState state, LevelReader reader, BlockPos pos) { - if (reader instanceof Level level) { + if (reader instanceof ServerLevel level) { return level.getGameRules().getBoolean(GameRules.RULE_WATER_SOURCE_CONVERSION); } //Best guess fallback to default (true) @@ -452,7 +458,7 @@ public boolean canConvertToSource(FluidState state, LevelReader reader, BlockPos .addDripstoneDripping(PointedDripstoneBlock.LAVA_TRANSFER_PROBABILITY_PER_RANDOM_TICK, ParticleTypes.DRIPPING_DRIPSTONE_LAVA, Blocks.LAVA_CAULDRON, SoundEvents.POINTED_DRIPSTONE_DRIP_LAVA_INTO_CAULDRON)) { @Override public boolean canConvertToSource(FluidState state, LevelReader reader, BlockPos pos) { - if (reader instanceof Level level) { + if (reader instanceof ServerLevel level) { return level.getGameRules().getBoolean(GameRules.RULE_LAVA_SOURCE_CONVERSION); } //Best guess fallback to default (false) @@ -551,6 +557,7 @@ public NeoForgeMod(IEventBus modEventBus, Dist dist, ModContainer container) { VANILLA_FLUID_TYPES.register(modEventBus); ENTITY_PREDICATE_CODECS.register(modEventBus); ITEM_SUB_PREDICATES.register(modEventBus); + SLOT_DISPLAY_TYPES.register(modEventBus); INGREDIENT_TYPES.register(modEventBus); CONDITION_CODECS.register(modEventBus); GLOBAL_LOOT_MODIFIER_SERIALIZERS.register(modEventBus); @@ -623,7 +630,7 @@ public void gatherData(GatherDataEvent event) { gen.addProvider(event.includeServer(), new NeoForgeEntityTypeTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new NeoForgeFluidTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new NeoForgeEnchantmentTagsProvider(packOutput, lookupProvider, existingFileHelper)); - gen.addProvider(event.includeServer(), new NeoForgeRecipeProvider(packOutput, lookupProvider)); + gen.addProvider(event.includeServer(), new NeoForgeRecipeProvider.Runner(packOutput, lookupProvider)); gen.addProvider(event.includeServer(), new NeoForgeLootTableProvider(packOutput, lookupProvider)); gen.addProvider(event.includeServer(), new NeoForgeBiomeTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new NeoForgeStructureTagsProvider(packOutput, lookupProvider, existingFileHelper)); diff --git a/src/main/java/net/neoforged/neoforge/common/SimpleTier.java b/src/main/java/net/neoforged/neoforge/common/SimpleTier.java index 73b4dfdd41..556ba03e6a 100644 --- a/src/main/java/net/neoforged/neoforge/common/SimpleTier.java +++ b/src/main/java/net/neoforged/neoforge/common/SimpleTier.java @@ -7,14 +7,14 @@ import java.util.function.Supplier; import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Tier; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.Block; /** * Helper class to define a custom tier + * FIXME: is this still needed? */ -public class SimpleTier implements Tier { +public class SimpleTier /*implements Tier*/ { private final TagKey incorrectBlocksForDrops; private final int uses; private final float speed; @@ -32,35 +32,35 @@ public SimpleTier(TagKey incorrectBlocksForDrops, int uses, float speed, this.repairIngredient = repairIngredient; } - @Override + /*@Override public int getUses() { return this.uses; } - + @Override public float getSpeed() { return this.speed; } - + @Override public float getAttackDamageBonus() { return this.attackDamageBonus; } - + @Override public TagKey getIncorrectBlocksForDrops() { return incorrectBlocksForDrops; } - + @Override public int getEnchantmentValue() { return this.enchantmentValue; } - + @Override public Ingredient getRepairIngredient() { return this.repairIngredient.get(); - } + }*/ @Override public String toString() { diff --git a/src/main/java/net/neoforged/neoforge/common/TagConventionLogWarning.java b/src/main/java/net/neoforged/neoforge/common/TagConventionLogWarning.java index 8802212cbf..6f00ace767 100644 --- a/src/main/java/net/neoforged/neoforge/common/TagConventionLogWarning.java +++ b/src/main/java/net/neoforged/neoforge/common/TagConventionLogWarning.java @@ -10,6 +10,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; @@ -420,6 +421,8 @@ public enum LogWarningMode { createForgeMapEntry(Registries.FLUID, "milk", Tags.Fluids.MILK), createForgeMapEntry(Registries.FLUID, "gaseous", Tags.Fluids.GASEOUS), createForgeMapEntry(Registries.FLUID, "honey", Tags.Fluids.HONEY), + createForgeMapEntry(Registries.FLUID, "xp", Tags.Fluids.EXPERIENCE), + createForgeMapEntry(Registries.FLUID, "experience", Tags.Fluids.EXPERIENCE), createForgeMapEntry(Registries.FLUID, "potion", Tags.Fluids.POTION), createForgeMapEntry(Registries.FLUID, "plantoil", "plant_oil"), @@ -501,7 +504,7 @@ private static void setupLegacyTagWarning(IEventBus forgeBus) { // We only care about vanilla registries registryAccess.registries().forEach(registryEntry -> { if (registryEntry.key().location().getNamespace().equals("minecraft")) { - registryEntry.value().getTagNames().forEach(tagKey -> { + registryEntry.value().getTags().map(HolderSet.Named::key).forEach(tagKey -> { // Grab tags under 'forge' namespace if (LEGACY_FORGE_TAGS.containsKey(tagKey) || tagKey.location().getNamespace().equals("forge")) { legacyTags.add(tagKey); diff --git a/src/main/java/net/neoforged/neoforge/common/Tags.java b/src/main/java/net/neoforged/neoforge/common/Tags.java index c4dfe263b7..8a57785dc8 100644 --- a/src/main/java/net/neoforged/neoforge/common/Tags.java +++ b/src/main/java/net/neoforged/neoforge/common/Tags.java @@ -224,6 +224,8 @@ public static class Blocks { public static final TagKey STORAGE_BLOCKS_REDSTONE = tag("storage_blocks/redstone"); public static final TagKey STORAGE_BLOCKS_SLIME = tag("storage_blocks/slime"); public static final TagKey STORAGE_BLOCKS_WHEAT = tag("storage_blocks/wheat"); + public static final TagKey STRIPPED_LOGS = tag("stripped_logs"); + public static final TagKey STRIPPED_WOODS = tag("stripped_woods"); public static final TagKey VILLAGER_JOB_SITES = tag("villager_job_sites"); /** @@ -627,6 +629,8 @@ public static class Items { public static final TagKey STORAGE_BLOCKS_SLIME = tag("storage_blocks/slime"); public static final TagKey STORAGE_BLOCKS_WHEAT = tag("storage_blocks/wheat"); public static final TagKey STRINGS = tag("strings"); + public static final TagKey STRIPPED_LOGS = tag("stripped_logs"); + public static final TagKey STRIPPED_WOODS = tag("stripped_woods"); public static final TagKey VILLAGER_JOB_SITES = tag("villager_job_sites"); // Tools and Armors @@ -768,12 +772,12 @@ private static TagKey neoforgeTag(String name) { */ public static class Fluids { /** - * Holds all fluids related to water. + * Holds all fluids related to water.

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

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

+ * Holds all fluids related to honey. + *

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

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

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

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

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

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

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

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

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

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

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

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

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

The following guidelines should be followed for good compatibility: *

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

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

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

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

{@code
-     * {
-     *     "item": "minecraft:apple",
-     *     "count": 3
-     * }
-     * }
- * - * Array ingredients are serialized using the compound ingredient type: - * - *
{@code
-     * {
-     *     "type": "neoforge:compound",
-     *     "ingredients": [
-     *         { "item": "minecraft:coal" },
-     *         { "item": "minecraft:charcoal" }
-     *     ],
-     *     "count": 2
-     * }
-     * }
- * - * See {@link Ingredient#MAP_CODEC_NONEMPTY} for details of the ingredient serialization. - */ - public static final Codec FLAT_CODEC = RecordCodecBuilder.create(instance -> instance.group( - Ingredient.MAP_CODEC_NONEMPTY.forGetter(SizedIngredient::ingredient), - NeoForgeExtraCodecs.optionalFieldAlwaysWrite(ExtraCodecs.POSITIVE_INT, "count", 1).forGetter(SizedIngredient::count)) - .apply(instance, SizedIngredient::new)); - /** * The "nested" codec for {@link SizedIngredient}. * @@ -67,15 +31,13 @@ public final class SizedIngredient { * *
{@code
      * {
-     *     "ingredient": {
-     *         "item": "minecraft:apple"
-     *     },
+     *     "ingredient": "minecraft:apple",
      *     "count": 3
      * }
      * }
*/ public static final Codec NESTED_CODEC = RecordCodecBuilder.create(instance -> instance.group( - Ingredient.CODEC_NONEMPTY.fieldOf("ingredient").forGetter(SizedIngredient::ingredient), + Ingredient.CODEC.fieldOf("ingredient").forGetter(SizedIngredient::ingredient), NeoForgeExtraCodecs.optionalFieldAlwaysWrite(ExtraCodecs.POSITIVE_INT, "count", 1).forGetter(SizedIngredient::count)) .apply(instance, SizedIngredient::new)); @@ -93,17 +55,8 @@ public static SizedIngredient of(ItemLike item, int count) { return new SizedIngredient(Ingredient.of(item), count); } - /** - * Helper method to create a simple sized ingredient that matches items in a tag. - */ - public static SizedIngredient of(TagKey tag, int count) { - return new SizedIngredient(Ingredient.of(tag), count); - } - private final Ingredient ingredient; private final int count; - @Nullable - private ItemStack[] cachedStacks; public SizedIngredient(Ingredient ingredient, int count) { if (count <= 0) { @@ -130,20 +83,6 @@ public boolean test(ItemStack stack) { return ingredient.test(stack) && stack.getCount() >= count; } - /** - * Returns a list of the stacks from this {@link #ingredient}, with an updated {@link #count}. - * - * @implNote the array is cached and should not be modified, just like {@link Ingredient#getItems()}. - */ - public ItemStack[] getItems() { - if (cachedStacks == null) { - cachedStacks = Stream.of(ingredient.getItems()) - .map(s -> s.copyWithCount(count)) - .toArray(ItemStack[]::new); - } - return cachedStacks; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java b/src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java index feb26716cc..4c32559074 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java @@ -60,9 +60,9 @@ protected DataMapProvider(PackOutput packOutput, CompletableFuture run(CachedOutput cache) { - gather(); - return lookupProvider.thenCompose(provider -> { + gather(provider); + final DynamicOps dynamicOps = RegistryOps.create(JsonOps.INSTANCE, provider); return CompletableFuture.allOf(this.builders.entrySet().stream().map(entry -> { @@ -83,7 +83,7 @@ private CompletableFuture generate(Path out, CachedOutput cache, Build /** * Generate data map entries. */ - protected abstract void gather(); + protected abstract void gather(HolderLookup.Provider provider); @SuppressWarnings("unchecked") public Builder builder(DataMapType type) { diff --git a/src/main/java/net/neoforged/neoforge/common/data/LanguageProvider.java b/src/main/java/net/neoforged/neoforge/common/data/LanguageProvider.java index c7a64d6499..196484b16a 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/LanguageProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/LanguageProvider.java @@ -83,7 +83,7 @@ public void addItemStack(Supplier key, String name) { } public void add(ItemStack key, String name) { - add(key.getDescriptionId(), name); + add(key.getItem().getDescriptionId(), name); } /* diff --git a/src/main/java/net/neoforged/neoforge/common/data/SoundDefinitionsProvider.java b/src/main/java/net/neoforged/neoforge/common/data/SoundDefinitionsProvider.java index d71360a998..fba916e81a 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/SoundDefinitionsProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/SoundDefinitionsProvider.java @@ -145,7 +145,7 @@ protected void add(final Supplier soundEvent, final SoundDefinition * @param definition The {@link SoundDefinition} that defines the given event. */ protected void add(final SoundEvent soundEvent, final SoundDefinition definition) { - this.add(soundEvent.getLocation(), definition); + this.add(soundEvent.location(), definition); } /** diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java index e5fec339d6..55477b729a 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java @@ -9,6 +9,7 @@ import com.google.gson.JsonObject; import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; +import com.mojang.serialization.DynamicOps; import com.mojang.serialization.JsonOps; import java.util.ArrayList; import java.util.List; @@ -18,6 +19,7 @@ import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.UnaryOperator; +import java.util.stream.Stream; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.Criterion; @@ -30,12 +32,18 @@ import net.minecraft.advancements.critereon.PlayerInteractTrigger; import net.minecraft.advancements.critereon.SimpleCriterionTrigger; import net.minecraft.core.HolderLookup; +import net.minecraft.core.HolderOwner; import net.minecraft.core.HolderSet; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; import net.minecraft.data.advancements.AdvancementSubProvider; import net.minecraft.data.advancements.packs.VanillaAdvancementProvider; import net.minecraft.data.advancements.packs.VanillaHusbandryAdvancements; import net.minecraft.resources.RegistryOps; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.ItemTags; +import net.minecraft.tags.TagKey; import net.minecraft.world.entity.monster.piglin.PiglinAi; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; @@ -66,14 +74,14 @@ private static List getVanillaAdvancementProviders(PackOut criteriaReplacers.add(replaceInteractCriteria(ItemPredicate.Builder.item().withSubPredicate(ItemAbilityPredicate.TYPE, new ItemAbilityPredicate(ItemAbilities.SHEARS_REMOVE_ARMOR)).build(), Items.SHEARS)); criteriaReplacers.add(replaceInteractCriteria(ItemPredicate.Builder.item().withSubPredicate(PiglinCurrencyItemPredicate.TYPE, PiglinCurrencyItemPredicate.INSTANCE).build(), PiglinAi.BARTERING_ITEM)); criteriaReplacers.add(replaceWearingPredicate(PiglinNeutralArmorEntityPredicate.INSTANCE, predicate -> { - if (predicate.head().filter(item -> predicateMatches(item, Items.GOLDEN_HELMET)).isPresent()) { + if (predicate.head().filter(item -> predicateMatches(item, ItemTags.PIGLIN_SAFE_ARMOR)).isPresent()) { return true; - } else if (predicate.chest().filter(item -> predicateMatches(item, Items.GOLDEN_CHESTPLATE)).isPresent()) { + } else if (predicate.chest().filter(item -> predicateMatches(item, ItemTags.PIGLIN_SAFE_ARMOR)).isPresent()) { return true; - } else if (predicate.legs().filter(item -> predicateMatches(item, Items.GOLDEN_LEGGINGS)).isPresent()) { + } else if (predicate.legs().filter(item -> predicateMatches(item, ItemTags.PIGLIN_SAFE_ARMOR)).isPresent()) { return true; } - return predicate.feet().filter(item -> predicateMatches(item, Items.GOLDEN_BOOTS)).isPresent(); + return predicate.feet().filter(item -> predicateMatches(item, ItemTags.PIGLIN_SAFE_ARMOR)).isPresent(); })); //Walk on powdered snow criteriaReplacers.add(replaceWearingPredicate(SnowBootsEntityPredicate.INSTANCE, predicate -> predicate.feet().filter(item -> predicateMatches(item, Items.LEATHER_BOOTS)).isPresent())); @@ -127,6 +135,13 @@ private static boolean predicateMatches(ItemPredicate predicate, ItemLike... tar return true; } + private static boolean predicateMatches(ItemPredicate predicate, TagKey tagKey) { + return predicate.items().orElse(HolderSet.empty()) + .unwrapKey() + .map(k -> k == tagKey) + .orElse(false); + } + private static BiFunction, HolderLookup.Provider, Criterion> replaceWearingPredicate(EntitySubPredicate subPredicate, Predicate shouldReplace) { return replacePlayerPredicate(condition -> { boolean invert = false; @@ -235,8 +250,53 @@ private static T getPrivateValue(Class clazz, @Nullable C inst, String private record NeoForgeAdvancementGenerator(AdvancementSubProvider vanillaProvider, List, HolderLookup.Provider, Criterion>> criteriaReplacers) implements AdvancementGenerator { @Override public void generate(HolderLookup.Provider registries, Consumer saver, ExistingFileHelper existingFileHelper) { - vanillaProvider.generate(registries, advancementHolder -> { - Advancement.Builder newBuilder = findAndReplaceInHolder(advancementHolder, registries); + // Warning: ugly code here. + // Wrap the registries to allow using any tag. This is used to make decoding using the codec work in `replacePlayerPredicate`. + var registriesWithAnyTag = new HolderLookup.Provider() { + @Override + public Stream>> listRegistryKeys() { + return registries.listRegistryKeys(); + } + + @Override + public Optional> lookup(ResourceKey> p_256285_) { + return registries.lookup(p_256285_); + } + + @Override + public RegistryOps createSerializationContext(DynamicOps p_326817_) { + return RegistryOps.create(p_326817_, new RegistryOps.RegistryInfoLookup() { + @Override + public Optional> lookup(ResourceKey> registry) { + var builtInRegistry = (Registry) BuiltInRegistries.REGISTRY.getValue(registry.location()); + return registries.lookup(registry) + // Need to pass the builtin registry as the holder owner to make deserialization work! + .map(lookup -> new RegistryOps.RegistryInfo<>(builtInRegistry, new HolderLookup.RegistryLookup.Delegate<>() { + @Override + public RegistryLookup parent() { + return lookup; + } + + @Override + public boolean canSerializeIn(HolderOwner p_255875_) { + return parent().canSerializeIn(p_255875_); + } + + @Override + public Optional> get(TagKey tagKey) { + var ret = Delegate.super.get(tagKey); + if (ret.isEmpty()) { + ret = Optional.of(HolderSet.emptyNamed(lookup, tagKey)); + } + return ret; + } + }, lookup.registryLifecycle())); + } + }); + } + }; + vanillaProvider.generate(registriesWithAnyTag, advancementHolder -> { + Advancement.Builder newBuilder = findAndReplaceInHolder(advancementHolder, registriesWithAnyTag); if (newBuilder != null) { newBuilder.save(saver, advancementHolder.id(), existingFileHelper); } diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeBlockTagsProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeBlockTagsProvider.java index 8a689441d4..a1959d5aa8 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeBlockTagsProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeBlockTagsProvider.java @@ -144,6 +144,14 @@ public void addTags(HolderLookup.Provider p_256380_) { tag(Tags.Blocks.STORAGE_BLOCKS_REDSTONE).add(Blocks.REDSTONE_BLOCK); tag(Tags.Blocks.STORAGE_BLOCKS_SLIME).add(Blocks.SLIME_BLOCK); tag(Tags.Blocks.STORAGE_BLOCKS_WHEAT).add(Blocks.HAY_BLOCK); + tag(Tags.Blocks.STRIPPED_LOGS).add( + Blocks.STRIPPED_ACACIA_LOG, Blocks.STRIPPED_BAMBOO_BLOCK, Blocks.STRIPPED_BIRCH_LOG, + Blocks.STRIPPED_CHERRY_LOG, Blocks.STRIPPED_DARK_OAK_LOG, Blocks.STRIPPED_JUNGLE_LOG, + Blocks.STRIPPED_MANGROVE_LOG, Blocks.STRIPPED_OAK_LOG, Blocks.STRIPPED_SPRUCE_LOG); + tag(Tags.Blocks.STRIPPED_WOODS).add( + Blocks.STRIPPED_ACACIA_WOOD, Blocks.STRIPPED_BIRCH_WOOD, Blocks.STRIPPED_CHERRY_WOOD, + Blocks.STRIPPED_DARK_OAK_WOOD, Blocks.STRIPPED_JUNGLE_WOOD, Blocks.STRIPPED_MANGROVE_WOOD, + Blocks.STRIPPED_OAK_WOOD, Blocks.STRIPPED_SPRUCE_WOOD); tag(Tags.Blocks.VILLAGER_JOB_SITES).add( Blocks.BARREL, Blocks.BLAST_FURNACE, Blocks.BREWING_STAND, Blocks.CARTOGRAPHY_TABLE, Blocks.CAULDRON, Blocks.WATER_CAULDRON, Blocks.LAVA_CAULDRON, Blocks.POWDER_SNOW_CAULDRON, @@ -286,7 +294,7 @@ private void addColored(TagKey group, String pattern) { for (DyeColor color : DyeColor.values()) { ResourceLocation key = ResourceLocation.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); TagKey tag = getForgeTag(prefix + color.getName()); - Block block = BuiltInRegistries.BLOCK.get(key); + Block block = BuiltInRegistries.BLOCK.getValue(key); if (block == null || block == Blocks.AIR) throw new IllegalStateException("Unknown vanilla block: " + key); tag(tag).add(block); diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java index 9e5604aa69..1dd3b1d0a8 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java @@ -17,18 +17,21 @@ import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceKey; import net.minecraft.sounds.SoundEvent; -import net.minecraft.tags.ItemTags; +import net.minecraft.tags.TagKey; import net.minecraft.util.random.Weight; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.ai.behavior.GiveGiftToHero; import net.minecraft.world.entity.ai.behavior.WorkAtComposter; import net.minecraft.world.entity.animal.Parrot; import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.item.HoneycombItem; import net.minecraft.world.item.Item; +import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.ComposterBlock; import net.minecraft.world.level.block.WeatheringCopper; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; +import net.minecraft.world.level.block.entity.FuelValues; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.gameevent.vibrations.VibrationSystem; import net.minecraft.world.level.levelgen.feature.MonsterRoomFeature; @@ -51,16 +54,13 @@ public NeoForgeDataMapsProvider(PackOutput packOutput, CompletableFuture villagerCompostables = ObfuscationReflectionHelper.getPrivateValue(WorkAtComposter.class, null, "COMPOSTABLE_ITEMS"); ComposterBlock.COMPOSTABLES.forEach((item, chance) -> compostables.add(item.asItem().builtInRegistryHolder(), new Compostable(chance, villagerCompostables.contains(item.asItem())), false)); final var fuels = builder(NeoForgeDataMaps.FURNACE_FUELS); - AbstractFurnaceBlockEntity.buildFuels((value, time) -> value.ifLeft(item -> fuels.add(item.builtInRegistryHolder(), new FurnaceFuel(time), false)) - .ifRight(tag -> fuels.add(tag, new FurnaceFuel(time), false))); - // Mojang decided to use an exclusion tag for nether wood - fuels.remove(ItemTags.NON_FLAMMABLE_WOOD); + FuelValues.vanillaBurnTimes(new FuelValuesDataMapBuilder(provider, fuels), AbstractFurnaceBlockEntity.BURN_TIME_STANDARD); final var vibrationFrequencies = builder(NeoForgeDataMaps.VIBRATION_FREQUENCIES); ((Reference2IntMap>) VibrationSystem.VIBRATION_FREQUENCY_FOR_EVENT) @@ -89,4 +89,31 @@ protected void gather() { waxables.add(now.builtInRegistryHolder(), new Waxable(after), false); }); } + + private static class FuelValuesDataMapBuilder extends FuelValues.Builder { + private final Builder builder; + + public FuelValuesDataMapBuilder(HolderLookup.Provider lookupProvider, DataMapProvider.Builder builder) { + super(lookupProvider, FeatureFlags.DEFAULT_FLAGS); + this.builder = builder; + } + + @Override + public FuelValuesDataMapBuilder add(TagKey tagKey, int burnTime) { + this.builder.add(tagKey, new FurnaceFuel(burnTime), false); + return this; + } + + @Override + public FuelValuesDataMapBuilder add(ItemLike item, int burnTime) { + this.builder.add(item.asItem().builtInRegistryHolder(), new FurnaceFuel(burnTime), false); + return this; + } + + @Override + public FuelValuesDataMapBuilder remove(TagKey tagKey) { + this.builder.remove(tagKey); + return this; + } + } } diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeEntityTypeTagsProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeEntityTypeTagsProvider.java index 16a951bedd..e12f911f8f 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeEntityTypeTagsProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeEntityTypeTagsProvider.java @@ -10,6 +10,7 @@ import net.minecraft.data.PackOutput; import net.minecraft.data.tags.EntityTypeTagsProvider; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.EntityTypeTags; import net.minecraft.world.entity.EntityType; import net.neoforged.neoforge.common.Tags; import net.neoforged.neoforge.common.data.ExistingFileHelper; @@ -23,7 +24,17 @@ public NeoForgeEntityTypeTagsProvider(PackOutput output, CompletableFuture group, String pattern) { for (DyeColor color : DyeColor.values()) { ResourceLocation key = ResourceLocation.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName())); TagKey tag = getForgeItemTag(prefix + color.getName()); - Item item = BuiltInRegistries.ITEM.get(key); + Item item = BuiltInRegistries.ITEM.getValue(key); if (item == null || item == Items.AIR) throw new IllegalStateException("Unknown vanilla item: " + key); tag(tag).add(item); diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLanguageProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLanguageProvider.java index f8cb9f9f26..f764016f5c 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLanguageProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLanguageProvider.java @@ -125,6 +125,8 @@ protected void addTranslations() { add(Tags.Blocks.STORAGE_BLOCKS_REDSTONE, "Redstone Storage Blocks"); add(Tags.Blocks.STORAGE_BLOCKS_SLIME, "Slime Storage Blocks"); add(Tags.Blocks.STORAGE_BLOCKS_WHEAT, "Wheat Storage Blocks"); + add(Tags.Blocks.STRIPPED_LOGS, "Stripped Logs"); + add(Tags.Blocks.STRIPPED_WOODS, "Stripped Woods"); add(Tags.Blocks.VILLAGER_JOB_SITES, "Villager Job Sites"); add(Tags.Blocks.VILLAGER_FARMLANDS, "Villager Farmlands"); @@ -322,6 +324,8 @@ protected void addTranslations() { add(Tags.Items.STORAGE_BLOCKS_SLIME, "Slime Storage Blocks"); add(Tags.Items.STORAGE_BLOCKS_WHEAT, "Wheat Storage Blocks"); add(Tags.Items.STRINGS, "Strings"); + add(Tags.Items.STRIPPED_LOGS, "Stripped Log Blocks"); + add(Tags.Items.STRIPPED_WOODS, "Stripped Wood Blocks"); add(Tags.Items.VILLAGER_JOB_SITES, "Villager Job Sites"); add(Tags.Items.TOOLS_SHEAR, "Shears"); add(Tags.Items.TOOLS_SHIELD, "Shields"); @@ -345,6 +349,7 @@ protected void addTranslations() { add(Tags.Fluids.MILK, "Milk"); add(Tags.Fluids.GASEOUS, "Gaseous"); add(Tags.Fluids.HONEY, "Honey"); + add(Tags.Fluids.EXPERIENCE, "Experience"); add(Tags.Fluids.POTION, "Potion"); add(Tags.Fluids.SUSPICIOUS_STEW, "Suspicious Stew"); add(Tags.Fluids.MUSHROOM_STEW, "Mushroom Stew"); diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java index cfbefe02f5..7a1394c489 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java @@ -5,7 +5,6 @@ package net.neoforged.neoforge.common.data.internal; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -15,21 +14,20 @@ import java.util.concurrent.CompletableFuture; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementHolder; +import net.minecraft.core.HolderGetter; import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.data.CachedOutput; +import net.minecraft.core.registries.Registries; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; +import net.minecraft.data.recipes.RecipeProvider; import net.minecraft.data.recipes.packs.VanillaRecipeProvider; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.Ingredient.ItemValue; -import net.minecraft.world.item.crafting.Ingredient.TagValue; -import net.minecraft.world.item.crafting.Ingredient.Value; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraft.world.item.crafting.ShapedRecipePattern; @@ -43,28 +41,27 @@ import org.jetbrains.annotations.Nullable; public final class NeoForgeRecipeProvider extends VanillaRecipeProvider { - private final Map> replacements = new HashMap<>(); - private final Map specialReplacements = new HashMap<>(); - private final Set excludes = new HashSet<>(); + private final InterceptingRecipeOutput output; - public NeoForgeRecipeProvider(PackOutput packOutput, CompletableFuture provider) { - super(packOutput, provider); + private NeoForgeRecipeProvider(HolderLookup.Provider provider, InterceptingRecipeOutput output) { + super(provider, output); + this.output = output; } private void exclude(ItemLike item) { - excludes.add(BuiltInRegistries.ITEM.getKey(item.asItem())); + output.excludes.add(ResourceKey.create(Registries.RECIPE, BuiltInRegistries.ITEM.getKey(item.asItem()))); } private void exclude(String name) { - excludes.add(ResourceLocation.parse(name)); + output.excludes.add(ResourceKey.create(Registries.RECIPE, ResourceLocation.parse(name))); } private void replace(ItemLike item, TagKey tag) { - replacements.put(item.asItem(), tag); + output.replacements.put(item.asItem(), tag); } @Override - protected void buildRecipes(RecipeOutput recipeOutput) { + protected void buildRecipes() { replace(Items.STICK, Tags.Items.RODS_WOODEN); replace(Items.GOLD_INGOT, Tags.Items.INGOTS_GOLD); replace(Items.GOLD_NUGGET, Tags.Items.NUGGETS_GOLD); @@ -76,6 +73,23 @@ protected void buildRecipes(RecipeOutput recipeOutput) { replace(Items.DIAMOND, Tags.Items.GEMS_DIAMOND); replace(Items.EMERALD, Tags.Items.GEMS_EMERALD); + replace(Items.WHITE_DYE, Tags.Items.DYES_WHITE); + replace(Items.ORANGE_DYE, Tags.Items.DYES_ORANGE); + replace(Items.MAGENTA_DYE, Tags.Items.DYES_MAGENTA); + replace(Items.LIGHT_BLUE_DYE, Tags.Items.DYES_LIGHT_BLUE); + replace(Items.YELLOW_DYE, Tags.Items.DYES_YELLOW); + replace(Items.LIME_DYE, Tags.Items.DYES_LIME); + replace(Items.PINK_DYE, Tags.Items.DYES_PINK); + replace(Items.GRAY_DYE, Tags.Items.DYES_GRAY); + replace(Items.LIGHT_GRAY_DYE, Tags.Items.DYES_LIGHT_GRAY); + replace(Items.CYAN_DYE, Tags.Items.DYES_CYAN); + replace(Items.PURPLE_DYE, Tags.Items.DYES_PURPLE); + replace(Items.BLUE_DYE, Tags.Items.DYES_BLUE); + replace(Items.BROWN_DYE, Tags.Items.DYES_BROWN); + replace(Items.GREEN_DYE, Tags.Items.DYES_GREEN); + replace(Items.RED_DYE, Tags.Items.DYES_RED); + replace(Items.BLACK_DYE, Tags.Items.DYES_BLACK); + replace(Blocks.COBBLESTONE, Tags.Items.COBBLESTONES_NORMAL); replace(Blocks.COBBLED_DEEPSLATE, Tags.Items.COBBLESTONES_DEEPSLATE); @@ -99,97 +113,123 @@ protected void buildRecipes(RecipeOutput recipeOutput) { exclude(Blocks.COBBLED_DEEPSLATE_SLAB); exclude(Blocks.COBBLED_DEEPSLATE_WALL); - specialReplacements.put(Items.CHEST, DifferenceIngredient.of(Ingredient.of(Tags.Items.CHESTS_WOODEN), Ingredient.of(Tags.Items.CHESTS_TRAPPED))); - - super.buildRecipes(new RecipeOutput() { - @Override - public void accept(ResourceLocation id, Recipe recipe, @Nullable AdvancementHolder advancement, ICondition... conditions) { - Recipe modified = enhance(id, recipe); - if (modified != null) - recipeOutput.accept(id, modified, null, conditions); - } + output.specialReplacements.put(Items.CHEST, DifferenceIngredient.of(tag(Tags.Items.CHESTS_WOODEN), tag(Tags.Items.CHESTS_TRAPPED))); - @Override - public Advancement.Builder advancement() { - return recipeOutput.advancement(); - } - }); + super.buildRecipes(); } - @Nullable - private Recipe enhance(ResourceLocation id, Recipe vanilla) { - if (vanilla instanceof ShapelessRecipe shapeless) - return enhance(id, shapeless); - if (vanilla instanceof ShapedRecipe shaped) - return enhance(id, shaped); - return null; - } + private static class InterceptingRecipeOutput implements RecipeOutput { + private final HolderGetter items; + private final RecipeOutput output; + private final Map> replacements = new HashMap<>(); + private final Map specialReplacements = new HashMap<>(); + private final Set>> excludes = new HashSet<>(); - @Nullable - private ShapelessRecipe enhance(ResourceLocation id, ShapelessRecipe vanilla) { - List ingredients = vanilla.getIngredients(); - boolean modified = false; - for (int x = 0; x < ingredients.size(); x++) { - Ingredient ing = enhance(id, ingredients.get(x)); - if (ing != null) { - ingredients.set(x, ing); - modified = true; - } + private InterceptingRecipeOutput(HolderGetter items, RecipeOutput output) { + this.items = items; + this.output = output; } - return modified ? vanilla : null; - } - @Override - protected CompletableFuture buildAdvancement(CachedOutput p_253674_, HolderLookup.Provider p_323646_, AdvancementHolder p_301116_) { - // NOOP - We don't replace any of the advancement things yet... - return CompletableFuture.allOf(); - } + @Override + public Advancement.Builder advancement() { + return output.advancement(); + } - @Nullable - private ShapedRecipe enhance(ResourceLocation id, ShapedRecipe vanilla) { - ShapedRecipePattern pattern = ObfuscationReflectionHelper.getPrivateValue(ShapedRecipe.class, vanilla, "pattern"); - if (pattern == null) throw new IllegalStateException(ShapedRecipe.class.getName() + " has no field pattern"); - ShapedRecipePattern.Data data = ((Optional) ObfuscationReflectionHelper.getPrivateValue(ShapedRecipePattern.class, pattern, "data")).orElseThrow(() -> new IllegalArgumentException("recipe " + id + " does not have pattern data")); - Map ingredients = data.key(); - boolean modified = false; - for (Character x : ingredients.keySet()) { - Ingredient ing = enhance(id, ingredients.get(x)); - if (ing != null) { - ingredients.put(x, ing); - modified = true; - } + @Override + public void includeRootAdvancement() { + // Let's not + } + + @Override + public void accept(ResourceKey> id, Recipe recipe, @Nullable AdvancementHolder advancement, ICondition... conditions) { + Recipe modified = enhance(id, recipe); + if (modified != null) + output.accept(id, modified, null, conditions); } - return modified ? vanilla : null; - } - @Nullable - private Ingredient enhance(ResourceLocation name, Ingredient vanilla) { - if (excludes.contains(name)) + @Nullable + private Recipe enhance(ResourceKey> id, Recipe vanilla) { + if (vanilla instanceof ShapelessRecipe shapeless) + return enhance(id, shapeless); + if (vanilla instanceof ShapedRecipe shaped) + return enhance(id, shaped); return null; + } - boolean modified = false; - List items = new ArrayList<>(); - Value[] vanillaItems = vanilla.getValues(); - if (vanillaItems.length == 1 && vanillaItems[0] instanceof ItemValue itemValue) { - Item item = itemValue.item().getItem(); - Ingredient replacement = specialReplacements.get(item); - if (replacement != null) { - return replacement; + @Nullable + private ShapelessRecipe enhance(ResourceKey> id, ShapelessRecipe vanilla) { + List ingredients = ObfuscationReflectionHelper.getPrivateValue(ShapelessRecipe.class, vanilla, "ingredients"); + boolean modified = false; + for (int x = 0; x < ingredients.size(); x++) { + Ingredient ing = enhance(id, ingredients.get(x)); + if (ing != null) { + ingredients.set(x, ing); + modified = true; + } } + return modified ? vanilla : null; } - for (Value entry : vanillaItems) { - if (entry instanceof ItemValue) { - ItemStack stack = entry.getItems().stream().findFirst().orElse(ItemStack.EMPTY); - TagKey replacement = replacements.get(stack.getItem()); - if (replacement != null) { - items.add(new TagValue(replacement)); + @Nullable + private ShapedRecipe enhance(ResourceKey> id, ShapedRecipe vanilla) { + ShapedRecipePattern pattern = ObfuscationReflectionHelper.getPrivateValue(ShapedRecipe.class, vanilla, "pattern"); + if (pattern == null) throw new IllegalStateException(ShapedRecipe.class.getName() + " has no field pattern"); + ShapedRecipePattern.Data data = ((Optional) ObfuscationReflectionHelper.getPrivateValue(ShapedRecipePattern.class, pattern, "data")).orElseThrow(() -> new IllegalArgumentException("recipe " + id + " does not have pattern data")); + Map ingredients = data.key(); + boolean modified = false; + for (Character x : ingredients.keySet()) { + Ingredient ing = enhance(id, ingredients.get(x)); + if (ing != null) { + ingredients.put(x, ing); modified = true; - } else - items.add(entry); - } else - items.add(entry); + } + } + return modified ? vanilla : null; + } + + @Nullable + private Ingredient enhance(ResourceKey> name, Ingredient vanilla) { + if (excludes.contains(name)) + return null; + + return vanilla.getValues().unwrap().map( + tagKey -> null, + items -> { + if (items.size() == 1) { + var specialReplacement = specialReplacements.get(items.getFirst().value()); + if (specialReplacement != null) { + return specialReplacement; + } + + var replacement = replacements.get(items.getFirst().value()); + if (replacement != null) { + return Ingredient.of(this.items.getOrThrow(replacement)); + } + } + + for (var holder : items) { + if (replacements.containsKey(holder.value())) { + throw new IllegalArgumentException("Cannot replace '%s' which is part of a multi-item ingredient.".formatted(holder.value())); + } + } + return null; + }); + } + } + + public static final class Runner extends RecipeProvider.Runner { + public Runner(PackOutput output, CompletableFuture lookupProvider) { + super(output, lookupProvider); + } + + @Override + protected RecipeProvider createRecipeProvider(HolderLookup.Provider lookupProvider, RecipeOutput output) { + return new NeoForgeRecipeProvider(lookupProvider, new InterceptingRecipeOutput(lookupProvider.lookupOrThrow(Registries.ITEM), output)); + } + + @Override + public String getName() { + return "NeoForge recipes"; } - return modified ? Ingredient.fromValues(items.stream()) : null; } } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBoatExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IAbstractBoatExtension.java similarity index 83% rename from src/main/java/net/neoforged/neoforge/common/extensions/IBoatExtension.java rename to src/main/java/net/neoforged/neoforge/common/extensions/IAbstractBoatExtension.java index f3b90e3937..b7b896d1fc 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBoatExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IAbstractBoatExtension.java @@ -5,13 +5,13 @@ package net.neoforged.neoforge.common.extensions; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.AbstractBoat; import net.minecraft.world.level.material.FluidState; import net.neoforged.neoforge.fluids.FluidType; -public interface IBoatExtension { - private Boat self() { - return (Boat) this; +public interface IAbstractBoatExtension { + private AbstractBoat self() { + return (AbstractBoat) this; } /** diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IAbstractMinecartExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IAbstractMinecartExtension.java deleted file mode 100644 index fa1f2f3644..0000000000 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IAbstractMinecartExtension.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ - -package net.neoforged.neoforge.common.extensions; - -import net.minecraft.core.BlockPos; -import net.minecraft.tags.BlockTags; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.vehicle.AbstractMinecart; - -public interface IAbstractMinecartExtension { - public static float DEFAULT_MAX_SPEED_AIR_LATERAL = 0.4f; - public static float DEFAULT_MAX_SPEED_AIR_VERTICAL = -1.0f; - public static double DEFAULT_AIR_DRAG = 0.95f; - - private AbstractMinecart self() { - return (AbstractMinecart) this; - } - - /** - * Internal, returns the current spot to look for the attached rail. - */ - default BlockPos getCurrentRailPosition() { - int x = Mth.floor(self().getX()); - int y = Mth.floor(self().getY()); - int z = Mth.floor(self().getZ()); - BlockPos pos = new BlockPos(x, y, z); - if (self().level().getBlockState(pos.below()).is(BlockTags.RAILS)) pos = pos.below(); - return pos; - } - - double getMaxSpeedWithRail(); - - /** - * Moved to allow overrides. - * This code handles minecart movement and speed capping when on a rail. - */ - void moveMinecartOnRail(BlockPos pos); - - /** - * Returns true if this cart can currently use rails. - * This function is mainly used to gracefully detach a minecart from a rail. - * - * @return True if the minecart can use rails. - */ - boolean canUseRail(); - - /** - * Set whether the minecart can use rails. - * This function is mainly used to gracefully detach a minecart from a rail. - * - * @param use Whether the minecart can currently use rails. - */ - void setCanUseRail(boolean use); - - /** - * Return false if this cart should not call onMinecartPass() and should ignore Powered Rails. - * - * @return True if this cart should call onMinecartPass(). - */ - default boolean shouldDoRailFunctions() { - return true; - } - - /** - * Returns true if this cart is self propelled. - * - * @return True if powered. - */ - default boolean isPoweredCart() { - return self().getMinecartType() == AbstractMinecart.Type.FURNACE; - } - - /** - * Returns true if this cart can be ridden by an Entity. - * - * @return True if this cart can be ridden. - */ - default boolean canBeRidden() { - return self().getMinecartType() == AbstractMinecart.Type.RIDEABLE; - } - - /** - * Returns the carts max speed when traveling on rails. Carts going faster - * than 1.1 cause issues with chunk loading. Carts cant traverse slopes or - * corners at greater than 0.5 - 0.6. This value is compared with the rails - * max speed and the carts current speed cap to determine the carts current - * max speed. A normal rail's max speed is 0.4. - * - * @return Carts max speed. - */ - default float getMaxCartSpeedOnRail() { - return 1.2f; - } - - /** - * Returns the current speed cap for the cart when traveling on rails. This - * functions differs from getMaxCartSpeedOnRail() in that it controls - * current movement and cannot be overridden. The value however can never be - * higher than getMaxCartSpeedOnRail(). - */ - float getCurrentCartSpeedCapOnRail(); - - void setCurrentCartSpeedCapOnRail(float value); - - float getMaxSpeedAirLateral(); - - void setMaxSpeedAirLateral(float value); - - float getMaxSpeedAirVertical(); - - void setMaxSpeedAirVertical(float value); - - double getDragAir(); - - void setDragAir(double value); - - default double getSlopeAdjustment() { - return 0.0078125D; - } - - /** - * Called from Detector Rails to retrieve a redstone power level for comparators. - */ - default int getComparatorLevel() { - return -1; - } -} diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockAndTintGetterExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockAndTintGetterExtension.java index c177f3b878..b6bcf97ab8 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockAndTintGetterExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockAndTintGetterExtension.java @@ -21,6 +21,6 @@ private BlockAndTintGetter self() { * Alternate version of the vanilla method taking in a {@link Direction}. */ default float getShade(float normalX, float normalY, float normalZ, boolean shade) { - return self().getShade(Direction.getNearest(normalX, normalY, normalZ), shade); + return self().getShade(Direction.getApproximateNearest(normalX, normalY, normalZ), shade); } } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockEntityExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockEntityExtension.java index c76d91ab7d..4dfa896b19 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockEntityExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockEntityExtension.java @@ -11,7 +11,6 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.chunk.LevelChunk; @@ -96,16 +95,6 @@ default ModelData getModelData() { return ModelData.EMPTY; } - /** - * Returns whether this {@link BlockEntity} has custom outline rendering behavior. - * - * @param player the local player currently viewing this {@code BlockEntity} - * @return {@code true} to enable outline processing - */ - default boolean hasCustomOutlineRendering(Player player) { - return false; - } - /** * Notify all listeners that the capabilities at the positions of this block entity might have changed. * This includes new capabilities becoming available. diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java index f193bfff1e..813b8a398f 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java @@ -723,7 +723,7 @@ default boolean canDropFromExplosion(BlockState state, BlockGetter level, BlockP * @param pos Block position in level * @param explosion The explosion instance affecting the block */ - default void onBlockExploded(BlockState state, Level level, BlockPos pos, Explosion explosion) { + default void onBlockExploded(BlockState state, ServerLevel level, BlockPos pos, Explosion explosion) { level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3); self().wasExploded(level, pos, explosion); } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java index b1f5b3a2a5..3e08a8b5b0 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java @@ -596,7 +596,7 @@ default boolean canDropFromExplosion(BlockGetter level, BlockPos pos, Explosion * @param pos Block position in level * @param explosion The explosion instance affecting the block */ - default void onBlockExploded(Level level, BlockPos pos, Explosion explosion) { + default void onBlockExploded(ServerLevel level, BlockPos pos, Explosion explosion) { self().getBlock().onBlockExploded(self(), level, pos, explosion); } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/ICommandSourceStackExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/ICommandSourceStackExtension.java index 5cb998740a..19e3beaf23 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/ICommandSourceStackExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/ICommandSourceStackExtension.java @@ -8,9 +8,9 @@ import net.minecraft.advancements.AdvancementHolder; import net.minecraft.commands.CommandSourceStack; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.level.Level; import net.minecraft.world.scores.Scoreboard; +import org.jetbrains.annotations.Nullable; /** * Additional methods for {@link CommandSourceStack} so that commands and arguments can access various things without directly referencing using server specific classes @@ -30,17 +30,11 @@ default Scoreboard getScoreboard() { /** * @return the advancement from the id */ + @Nullable default AdvancementHolder getAdvancement(ResourceLocation id) { return self().getServer().getAdvancements().get(id); } - /** - * @return the recipe manager - */ - default RecipeManager getRecipeManager() { - return self().getServer().getRecipeManager(); - } - /** * @return the level but without being specifically the server side level */ diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IEntityExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IEntityExtension.java index a3a2234ba4..3b495ea523 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IEntityExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IEntityExtension.java @@ -12,6 +12,7 @@ import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.entity.Entity; @@ -128,7 +129,7 @@ default boolean canBeRiddenUnderFluidType(FluidType type, Entity rider) { * @param fallDistance The fall distance * @return {@code true} if this entity can trample, {@code false} otherwise */ - boolean canTrample(BlockState state, BlockPos pos, float fallDistance); + boolean canTrample(ServerLevel level, BlockState state, BlockPos pos, float fallDistance); /** * Returns The classification of this entity diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IFluidExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IFluidExtension.java index f8749b3a8f..b2d9c49874 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IFluidExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IFluidExtension.java @@ -6,12 +6,12 @@ package net.neoforged.neoforge.common.extensions; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.AbstractBoat; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; @@ -72,7 +72,7 @@ default boolean move(FluidState state, LivingEntity entity, Vec3 movementVector, * @param pos the location of the fluid * @return {@code true} if the fluid can create a source, {@code false} otherwise */ - default boolean canConvertToSource(FluidState state, Level level, BlockPos pos) { + default boolean canConvertToSource(FluidState state, ServerLevel level, BlockPos pos) { return getFluidType().canConvertToSource(state, level, pos); } @@ -83,7 +83,7 @@ default boolean canConvertToSource(FluidState state, Level level, BlockPos pos) * @param boat the boat trying to be used on the fluid * @return {@code true} if the boat can be used, {@code false} otherwise */ - default boolean supportsBoating(FluidState state, Boat boat) { + default boolean supportsBoating(FluidState state, AbstractBoat boat) { return getFluidType().supportsBoating(state, boat); } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IFluidStateExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IFluidStateExtension.java index a8082fcae7..97f9a158fc 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IFluidStateExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IFluidStateExtension.java @@ -6,12 +6,12 @@ package net.neoforged.neoforge.common.extensions; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.AbstractBoat; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.pathfinder.PathType; @@ -66,7 +66,7 @@ default boolean move(LivingEntity entity, Vec3 movementVector, double gravity) { * @param pos the location of the fluid * @return {@code true} if the fluid can create a source, {@code false} otherwise */ - default boolean canConvertToSource(Level level, BlockPos pos) { + default boolean canConvertToSource(ServerLevel level, BlockPos pos) { return self().getType().canConvertToSource(self(), level, pos); } @@ -76,7 +76,7 @@ default boolean canConvertToSource(Level level, BlockPos pos) { * @param boat the boat trying to be used on the fluid * @return {@code true} if the boat can be used, {@code false} otherwise */ - default boolean supportsBoating(Boat boat) { + default boolean supportsBoating(AbstractBoat boat) { return self().getType().supportsBoating(self(), boat); } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IHolderLookupProviderExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IHolderLookupProviderExtension.java index b80b29e4e5..0c2037fed9 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IHolderLookupProviderExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IHolderLookupProviderExtension.java @@ -28,7 +28,7 @@ default Holder holderOrThrow(ResourceKey key) { * Shortcut method to get an optional holder from a ResourceKey. */ default Optional> holder(ResourceKey key) { - Optional> registry = this.self().lookup(key.registryKey()); + Optional> registry = this.self().lookup(key.registryKey()); return registry.flatMap(tRegistryLookup -> tRegistryLookup.get(key)); } } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java index 0ae0cb4bc3..ab5cc0f8e1 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java @@ -20,6 +20,8 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.ItemTags; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -31,15 +33,10 @@ import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.animal.horse.Horse; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.entity.monster.piglin.PiglinAi; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.AnimalArmorItem; -import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.ArmorMaterial; -import net.minecraft.world.item.ArmorMaterials; import net.minecraft.world.item.AxeItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -51,14 +48,13 @@ import net.minecraft.world.item.enchantment.Enchantment.EnchantmentDefinition; import net.minecraft.world.item.enchantment.EnchantmentInstance; import net.minecraft.world.item.enchantment.ItemEnchantments; +import net.minecraft.world.item.equipment.EquipmentModel; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.FuelValues; import net.minecraft.world.phys.AABB; import net.neoforged.neoforge.common.CommonHooks; import net.neoforged.neoforge.common.ItemAbilities; import net.neoforged.neoforge.common.ItemAbility; -import net.neoforged.neoforge.registries.datamaps.builtin.FurnaceFuel; -import net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -75,7 +71,7 @@ private Item self() { */ @SuppressWarnings("deprecation") default ItemAttributeModifiers getDefaultAttributeModifiers(ItemStack stack) { - return self().getDefaultAttributeModifiers(); + return ItemAttributeModifiers.EMPTY; } /** @@ -130,7 +126,7 @@ default boolean isPiglinCurrency(ItemStack stack) { * @return True if piglins are neutral to players wearing this item in an armor slot */ default boolean makesPiglinsNeutral(ItemStack stack, LivingEntity wearer) { - return stack.getItem() instanceof ArmorItem && ((ArmorItem) stack.getItem()).getMaterial() == ArmorMaterials.GOLD; + return stack.is(ItemTags.PIGLIN_SAFE_ARMOR); } /** @@ -154,7 +150,7 @@ default float getXpRepairRatio(ItemStack stack) { * * Note that if you break an item while using it (that is, it becomes empty without swapping the stack instance), this hook may not be called on the serverside as you are * technically still using the empty item (thus this hook is called on air instead). It is necessary to call {@link LivingEntity#stopUsingItem()} as part of your - * {@link ItemStack#hurtAndBreak(int, LivingEntity, Consumer)} callback to prevent this issue. + * {@link ItemStack#hurtAndBreak(int, ServerLevel, LivingEntity, Consumer)} callback to prevent this issue. * * For most uses, you likely want one of the following: *