Port to 1.21.5-rc1

Co-authored-by: Apex <robsonlawson3@gmail.com>
Co-authored-by: coehlrich <coehlrich@users.noreply.github.com>
Co-authored-by: embeddedt <42941056+embeddedt@users.noreply.github.com>
Co-authored-by: Matyrobbrt <matyrobbrt@gmail.com>
Co-authored-by: Minecraftschurli <minecraftschurli@gmail.com>
Co-authored-by: Sara Freimer <sara@freimer.com>
Co-authored-by: Sebastian Hartte <shartte@users.noreply.github.com>
Co-authored-by: Technici4n <13494793+Technici4n@users.noreply.github.com>
Co-authored-by: XFactHD <xfacthd@gmx.de>
This commit is contained in:
Technici4n 2025-03-21 21:46:31 +01:00
parent b7942bb332
commit 9f6edae189
762 changed files with 8650 additions and 9628 deletions

View file

@ -82,7 +82,8 @@ abstract class CreateUserDevConfig extends DefaultTask {
case CLIENT -> "neoforgeclientdev";
case CLIENT_DATA -> "neoforgeclientdatadev";
case SERVER_DATA -> "neoforgeserverdatadev";
case GAME_TEST_SERVER, SERVER -> "neoforgeserverdev";
case SERVER -> "neoforgeserverdev";
case GAME_TEST_SERVER -> "neoforgegametestserverdev";
case JUNIT -> "neoforgejunitdev";
};
@ -116,10 +117,6 @@ abstract class CreateUserDevConfig extends DefaultTask {
if (runType == RunType.CLIENT || runType == RunType.GAME_TEST_SERVER) {
systemProperties.put("neoforge.enableGameTest", "true");
if (runType == RunType.GAME_TEST_SERVER) {
systemProperties.put("neoforge.gameTestServer", "true");
}
}
config.runs().put(runType.jsonName, new UserDevRunType(

View file

@ -160,6 +160,10 @@ public abstract class GenerateAccessTransformers extends DefaultTask {
return value -> true;
}
public <T extends Named> SerializablePredicate<T> not(SerializablePredicate<T> pred) {
return target -> !pred.test(target);
}
public record AtGroup(String name, Modifier modifier, SerializablePredicate<ClassInfo> classMatch,
@Nullable SerializablePredicate<MethodInfo> methodMatch, @Nullable SerializablePredicate<FieldInfo> fieldMatch) implements Serializable {
}

View file

@ -16,8 +16,8 @@ diffpatch_version=2.0.0.35
java_version=21
minecraft_version=1.21.4
neoform_version=20241203.161809
minecraft_version=1.21.5-rc1
neoform_version=20250320.202415
# on snapshot versions, used to prefix the version
neoforge_snapshot_next_stable=21.5
@ -43,7 +43,7 @@ nightconfig_version=3.8.1
jetbrains_annotations_version=24.0.1
apache_maven_artifact_version=3.9.9
jarjar_version=0.4.1
fancy_mod_loader_version=6.0.11
fancy_mod_loader_version=6.0.14
typetools_version=0.6.3
nashorn_core_version=15.3
mixin_extras_version=0.4.1

View file

@ -0,0 +1,44 @@
--- a/com/mojang/blaze3d/opengl/DirectStateAccess.java
+++ b/com/mojang/blaze3d/opengl/DirectStateAccess.java
@@ -19,7 +_,11 @@
abstract int createFrameBufferObject();
- abstract void bindFrameBufferTextures(int p_412046_, int p_412388_, int p_412116_, int p_412536_, int p_412779_);
+ abstract void bindFrameBufferTextures(int p_412046_, int p_412388_, int p_412116_, int p_412536_, int p_412779_, boolean useStencil);
+
+ public void bindFrameBufferTextures(int p_412046_, int p_412388_, int p_412116_, int p_412536_, int p_412779_) {
+ bindFrameBufferTextures(p_412046_, p_412388_, p_412116_, p_412536_, p_412779_, false);
+ }
abstract void blitFrameBuffers(
int p_412546_,
@@ -44,9 +_,10 @@
}
@Override
- public void bindFrameBufferTextures(int p_412474_, int p_412101_, int p_412181_, int p_412742_, int p_412591_) {
+ public void bindFrameBufferTextures(int p_412474_, int p_412101_, int p_412181_, int p_412742_, int p_412591_, boolean useStencil) {
ARBDirectStateAccess.glNamedFramebufferTexture(p_412474_, 36064, p_412101_, p_412742_);
- ARBDirectStateAccess.glNamedFramebufferTexture(p_412474_, 36096, p_412181_, p_412742_);
+ int depthAttachment = useStencil ? org.lwjgl.opengl.GL32C.GL_DEPTH_STENCIL_ATTACHMENT : org.lwjgl.opengl.GL32C.GL_DEPTH_ATTACHMENT;
+ ARBDirectStateAccess.glNamedFramebufferTexture(p_412474_, depthAttachment, p_412181_, p_412742_);
if (p_412591_ != 0) {
GlStateManager._glBindFramebuffer(p_412591_, p_412474_);
}
@@ -81,12 +_,13 @@
}
@Override
- public void bindFrameBufferTextures(int p_412192_, int p_412614_, int p_412332_, int p_412295_, int p_412775_) {
+ public void bindFrameBufferTextures(int p_412192_, int p_412614_, int p_412332_, int p_412295_, int p_412775_, boolean useStencil) {
int i = p_412775_ == 0 ? '\u8ca9' : p_412775_;
int j = GlStateManager.getFrameBuffer(i);
GlStateManager._glBindFramebuffer(i, p_412192_);
GlStateManager._glFramebufferTexture2D(i, 36064, 3553, p_412614_, p_412295_);
- GlStateManager._glFramebufferTexture2D(i, 36096, 3553, p_412332_, p_412295_);
+ int depthAttachment = useStencil ? org.lwjgl.opengl.GL32C.GL_DEPTH_STENCIL_ATTACHMENT : org.lwjgl.opengl.GL32C.GL_DEPTH_ATTACHMENT;
+ GlStateManager._glFramebufferTexture2D(i, depthAttachment, 3553, p_412332_, p_412295_);
if (p_412775_ == 0) {
GlStateManager._glBindFramebuffer(i, j);
}

View file

@ -0,0 +1,94 @@
--- a/com/mojang/blaze3d/opengl/GlCommandEncoder.java
+++ b/com/mojang/blaze3d/opengl/GlCommandEncoder.java
@@ -147,7 +_,8 @@
} else if (p_410548_.isClosed()) {
throw new IllegalStateException("Depth texture is closed");
} else {
- this.device.directStateAccess().bindFrameBufferTextures(this.drawFbo, 0, ((GlTexture)p_410548_).id, 0, 36160);
+ boolean hasStencil = p_410548_.getFormat().hasStencilAspect();
+ this.device.directStateAccess().bindFrameBufferTextures(this.drawFbo, 0, ((GlTexture)p_410548_).id, 0, 36160, hasStencil);
GL11.glDrawBuffer(0);
GL11.glClearDepth(p_410067_);
GlStateManager._depthMask(true);
@@ -160,6 +_,23 @@
}
@Override
+ public void clearStencilTexture(GpuTexture texture, int value) {
+ if (this.inRenderPass) {
+ throw new IllegalStateException("Close the existing render pass before creating a new one!");
+ } else if (!texture.getFormat().hasStencilAspect()) {
+ throw new IllegalStateException("Trying to clear stencil in a texture that has no stencil component!");
+ } else {
+ this.device.directStateAccess().bindFrameBufferTextures(this.drawFbo, 0, ((GlTexture)texture).id, 0, GlConst.GL_FRAMEBUFFER, true);
+ GL11.glDrawBuffer(GlConst.GL_NONE);
+ GL11.glClearStencil(value);
+ GlStateManager._depthMask(true);
+ GlStateManager._clear(GL11.GL_STENCIL_BUFFER_BIT);
+ GL11.glDrawBuffer(GlConst.GL_COLOR_ATTACHMENT0);
+ GlStateManager._glBindFramebuffer(GlConst.GL_FRAMEBUFFER, 0);
+ }
+ }
+
+ @Override
public void writeToBuffer(GpuBuffer p_409838_, ByteBuffer p_410689_, int p_409997_) {
if (this.inRenderPass) {
throw new IllegalStateException("Close the existing render pass before performing additional commands");
@@ -478,8 +_,19 @@
boolean flag = p_410700_.getFormat().hasDepthAspect();
int i = ((GlTexture)p_410700_).glId();
int j = ((GlTexture)p_410735_).glId();
- this.device.directStateAccess().bindFrameBufferTextures(this.readFbo, flag ? 0 : i, flag ? i : 0, 0, 0);
- this.device.directStateAccess().bindFrameBufferTextures(this.drawFbo, flag ? 0 : j, flag ? j : 0, 0, 0);
+ var hasStencil = p_410700_.getFormat().hasStencilAspect();
+ this.device.directStateAccess().bindFrameBufferTextures(this.readFbo, flag ? 0 : i, flag ? i : 0, 0, 0, hasStencil);
+ this.device.directStateAccess().bindFrameBufferTextures(this.drawFbo, flag ? 0 : j, flag ? j : 0, 0, 0, hasStencil);
+ var bufferMask = 0;
+ if (p_410700_.getFormat().hasColorAspect()) {
+ bufferMask |= GlConst.GL_COLOR_BUFFER_BIT;
+ }
+ if (p_410700_.getFormat().hasDepthAspect()) {
+ bufferMask |= GlConst.GL_DEPTH_BUFFER_BIT;
+ }
+ if (p_410700_.getFormat().hasStencilAspect()) {
+ bufferMask |= GL11.GL_STENCIL_BUFFER_BIT;
+ }
this.device
.directStateAccess()
.blitFrameBuffers(
@@ -493,7 +_,7 @@
p_410236_,
p_409870_,
p_409949_,
- flag ? 256 : 16384,
+ bufferMask,
9728
);
int k = GlStateManager._getError();
@@ -711,6 +_,26 @@
);
} else {
GlStateManager._disableScissorTest();
+ }
+
+ var stencilTest = p_410853_.stencilTest;
+ if (stencilTest != null) {
+ GlStateManager._enableStencilTest();
+
+ var front = stencilTest.front();
+ var back = stencilTest.back();
+ if (front.equals(back)) {
+ GlStateManager._stencilFunc(GlConst.toGl(front.compare()), stencilTest.referenceValue(), stencilTest.readMask());
+ GlStateManager._stencilOp(GlConst.toGl(front.fail()), GlConst.toGl(front.depthFail()), GlConst.toGl(front.pass()));
+ } else {
+ GlStateManager._stencilFuncFront(GlConst.toGl(front.compare()), stencilTest.referenceValue(), stencilTest.readMask());
+ GlStateManager._stencilFuncBack(GlConst.toGl(back.compare()), stencilTest.referenceValue(), stencilTest.readMask());
+ GlStateManager._stencilOpFront(GlConst.toGl(front.fail()), GlConst.toGl(front.depthFail()), GlConst.toGl(front.pass()));
+ GlStateManager._stencilOpBack(GlConst.toGl(back.fail()), GlConst.toGl(back.depthFail()), GlConst.toGl(back.pass()));
+ }
+ GlStateManager._stencilMask(stencilTest.writeMask());
+ } else {
+ GlStateManager._disableStencilTest();
}
return true;

View file

@ -0,0 +1,64 @@
--- a/com/mojang/blaze3d/opengl/GlConst.java
+++ b/com/mojang/blaze3d/opengl/GlConst.java
@@ -275,6 +_,8 @@
case RGBA8 -> 32856;
case RED8 -> 33321;
case DEPTH32 -> 33191;
+ case DEPTH24_STENCIL8 -> org.lwjgl.opengl.GL32.GL_DEPTH24_STENCIL8;
+ case DEPTH32_STENCIL8 -> org.lwjgl.opengl.GL32.GL_DEPTH32F_STENCIL8;
};
}
@@ -283,6 +_,10 @@
case RGBA8 -> 6408;
case RED8 -> 6403;
case DEPTH32 -> 6402;
+ // As long as null data will be passed to texImage2D, the external format does not matter as long as it matches the internalFormat.
+ // So the usage, for depth, of unsigned int in one case and float in the other case, is not a problem.
+ case DEPTH24_STENCIL8 -> org.lwjgl.opengl.GL32.GL_DEPTH_STENCIL;
+ case DEPTH32_STENCIL8 -> org.lwjgl.opengl.GL32.GL_DEPTH_STENCIL;
};
}
@@ -291,6 +_,8 @@
case RGBA8 -> 5121;
case RED8 -> 5121;
case DEPTH32 -> 5126;
+ case DEPTH24_STENCIL8 -> org.lwjgl.opengl.GL32.GL_UNSIGNED_INT_24_8;
+ case DEPTH32_STENCIL8 -> org.lwjgl.opengl.GL32.GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
};
}
@@ -298,6 +_,32 @@
return switch (p_412490_) {
case VERTEX -> 35633;
case FRAGMENT -> 35632;
+ };
+ }
+
+ public static int toGl(net.neoforged.neoforge.client.stencil.StencilFunction func) {
+ return switch (func) {
+ case NEVER -> org.lwjgl.opengl.GL32.GL_NEVER;
+ case ALWAYS -> org.lwjgl.opengl.GL32.GL_ALWAYS;
+ case LESS -> org.lwjgl.opengl.GL32.GL_LESS;
+ case LEQUAL -> org.lwjgl.opengl.GL32.GL_LEQUAL;
+ case EQUAL -> org.lwjgl.opengl.GL32.GL_EQUAL;
+ case GEQUAL -> org.lwjgl.opengl.GL32.GL_GEQUAL;
+ case GREATER -> org.lwjgl.opengl.GL32.GL_GREATER;
+ case NOTEQUAL -> org.lwjgl.opengl.GL32.GL_NOTEQUAL;
+ };
+ }
+
+ public static int toGl(net.neoforged.neoforge.client.stencil.StencilOperation op) {
+ return switch (op) {
+ case KEEP -> org.lwjgl.opengl.GL32.GL_KEEP;
+ case ZERO -> org.lwjgl.opengl.GL32.GL_ZERO;
+ case REPLACE -> org.lwjgl.opengl.GL32.GL_REPLACE;
+ case INCR -> org.lwjgl.opengl.GL32.GL_INCR;
+ case DECR -> org.lwjgl.opengl.GL32.GL_DECR;
+ case INVERT -> org.lwjgl.opengl.GL32.GL_INVERT;
+ case INCR_WRAP -> org.lwjgl.opengl.GL32.GL_INCR_WRAP;
+ case DECR_WRAP -> org.lwjgl.opengl.GL32.GL_DECR_WRAP;
};
}
}

View file

@ -0,0 +1,68 @@
--- a/com/mojang/blaze3d/opengl/GlDevice.java
+++ b/com/mojang/blaze3d/opengl/GlDevice.java
@@ -129,6 +_,65 @@
}
}
+ /**
+ * Adopt an external OpenGL texture into a GpuTexture.
+ * The lifecycle of the OpenGL texture will not be tied to this GpuTexture and the external system is responsible
+ * for cleaning up the OpenGL texture. Calling this is a relatively expensive operation since we
+ * introspect the texture using OpenGL getters.
+ */
+ public GpuTexture createExternalTexture(@Nullable String label, int nativeId) {
+ var previousBinding = org.lwjgl.opengl.GL11.glGetInteger(org.lwjgl.opengl.GL11.GL_TEXTURE_BINDING_2D);
+ org.lwjgl.opengl.GL11.glBindTexture(org.lwjgl.opengl.GL11.GL_TEXTURE_2D, nativeId);
+
+ TextureFormat format = null;
+ // Get internal format
+ var internalFormat = org.lwjgl.opengl.GL11.glGetTexLevelParameteri(org.lwjgl.opengl.GL11.GL_TEXTURE_2D, 0, org.lwjgl.opengl.GL11.GL_TEXTURE_INTERNAL_FORMAT);
+ // Find matching TextureFormat. We only care about the internal format here, since we're not going to read/write pixels
+ for (var candidate : TextureFormat.values()) {
+ if (GlConst.toGlInternalId(candidate) == internalFormat || GlConst.toGlExternalId(candidate) == internalFormat) {
+ format = candidate;
+ break;
+ }
+ }
+
+ if (format == null) {
+ org.lwjgl.opengl.GL11.glBindTexture(org.lwjgl.opengl.GL11.GL_TEXTURE_2D, previousBinding);
+ throw new IllegalArgumentException("Couldn't find a matching vanilla TextureFormat for OpenGL internal format id " + internalFormat);
+ }
+
+ // Get width and height
+ int width = org.lwjgl.opengl.GL11.glGetTexLevelParameteri(org.lwjgl.opengl.GL11.GL_TEXTURE_2D, 0, org.lwjgl.opengl.GL11.GL_TEXTURE_WIDTH);
+ int height = org.lwjgl.opengl.GL11.glGetTexLevelParameteri(org.lwjgl.opengl.GL11.GL_TEXTURE_2D, 0, org.lwjgl.opengl.GL11.GL_TEXTURE_HEIGHT);
+
+ // Count mip levels by querying sizes until we get 0
+ int mipLevels = 1;
+ int mipWidth = width;
+ while (mipWidth > 1) {
+ int nextWidth = org.lwjgl.opengl.GL11.glGetTexLevelParameteri(org.lwjgl.opengl.GL11.GL_TEXTURE_2D, mipLevels, org.lwjgl.opengl.GL11.GL_TEXTURE_WIDTH);
+ if (nextWidth == 0) {
+ break;
+ }
+ mipLevels++;
+ mipWidth = nextWidth;
+ }
+
+ org.lwjgl.opengl.GL11.glBindTexture(org.lwjgl.opengl.GL11.GL_TEXTURE_2D, previousBinding);
+
+ return createExternalTexture(label, format, width, height, mipLevels, nativeId);
+ }
+
+ /**
+ * Create a new GPU texture from an existing texture whose lifecycle is externally managed.
+ */
+ public GpuTexture createExternalTexture(@Nullable String label, TextureFormat format, int width, int height, int mipLevels, int nativeId) {
+ if (label == null) {
+ label = String.valueOf(nativeId);
+ }
+ GlTexture gltexture = new GlTexture(label, format, width, height, mipLevels, nativeId);
+ this.debugLabels.applyLabel(gltexture);
+ return gltexture;
+ }
+
@Override
public GpuBuffer createBuffer(@Nullable Supplier<String> p_409705_, BufferType p_409714_, BufferUsage p_409894_, int p_410348_) {
if (p_410348_ <= 0) {

View file

@ -0,0 +1,28 @@
--- a/com/mojang/blaze3d/opengl/GlRenderPass.java
+++ b/com/mojang/blaze3d/opengl/GlRenderPass.java
@@ -34,6 +_,8 @@
protected final HashMap<String, GpuTexture> samplers = new HashMap<>();
protected final Set<String> dirtyUniforms = new HashSet<>();
protected final Set<String> dirtySamplers = new HashSet<>();
+ @Nullable
+ protected net.neoforged.neoforge.client.stencil.StencilTest stencilTest;
public GlRenderPass(GlCommandEncoder p_409888_, boolean p_410304_) {
this.encoder = p_409888_;
@@ -91,6 +_,16 @@
@Override
public void disableScissor() {
this.scissorState.disable();
+ }
+
+ @Override
+ public void enableStencilTest(net.neoforged.neoforge.client.stencil.StencilTest stencilTest) {
+ this.stencilTest = stencilTest;
+ }
+
+ @Override
+ public void disableStencilTest() {
+ this.stencilTest = null;
}
@Override

View file

@ -0,0 +1,131 @@
--- a/com/mojang/blaze3d/opengl/GlStateManager.java
+++ b/com/mojang/blaze3d/opengl/GlStateManager.java
@@ -40,6 +_,7 @@
private static final GlStateManager.CullState CULL = new GlStateManager.CullState();
private static final GlStateManager.PolygonOffsetState POLY_OFFSET = new GlStateManager.PolygonOffsetState();
private static final GlStateManager.ColorLogicState COLOR_LOGIC = new GlStateManager.ColorLogicState();
+ private static final GlStateManager.StencilState STENCIL = new GlStateManager.StencilState();
private static final GlStateManager.ScissorState SCISSOR = new GlStateManager.ScissorState();
private static int activeTexture;
private static final GlStateManager.TextureState[] TEXTURES = IntStream.range(0, 12)
@@ -649,5 +_,120 @@
@OnlyIn(Dist.CLIENT)
static class TextureState {
public int binding;
+ }
+
+ public static void _disableStencilTest() {
+ RenderSystem.assertOnRenderThread();
+ STENCIL.mode.disable();
+ }
+
+ public static void _enableStencilTest() {
+ RenderSystem.assertOnRenderThread();
+ STENCIL.mode.enable();
+ }
+
+ public static void _stencilFunc(int func, int ref, int readMask) {
+ RenderSystem.assertOnRenderThread();
+ if (func != STENCIL.frontFunc || ref != STENCIL.frontRef || readMask != STENCIL.frontReadMask
+ || func != STENCIL.backFunc || ref != STENCIL.backRef || readMask != STENCIL.backReadMask) {
+ STENCIL.frontFunc = func;
+ STENCIL.frontRef = ref;
+ STENCIL.frontReadMask = readMask;
+ STENCIL.backFunc = func;
+ STENCIL.backRef = ref;
+ STENCIL.backReadMask = readMask;
+ GL32.glStencilFuncSeparate(GL32.GL_FRONT_AND_BACK, func, ref, readMask);
+ }
+ }
+
+ public static void _stencilFuncFront(int func, int ref, int readMask) {
+ RenderSystem.assertOnRenderThread();
+ if (func != STENCIL.frontFunc || ref != STENCIL.frontRef || readMask != STENCIL.frontReadMask) {
+ STENCIL.frontFunc = func;
+ STENCIL.frontRef = ref;
+ STENCIL.frontReadMask = readMask;
+ GL32.glStencilFuncSeparate(GL32.GL_FRONT, func, ref, readMask);
+ }
+ }
+
+ public static void _stencilFuncBack(int func, int ref, int readMask) {
+ RenderSystem.assertOnRenderThread();
+ if (func != STENCIL.backFunc || ref != STENCIL.backRef || readMask != STENCIL.backReadMask) {
+ STENCIL.backFunc = func;
+ STENCIL.backRef = ref;
+ STENCIL.backReadMask = readMask;
+ GL32.glStencilFuncSeparate(GL32.GL_BACK, func, ref, readMask);
+ }
+ }
+
+ public static void _stencilMask(int mask) {
+ RenderSystem.assertOnRenderThread();
+ if (mask != STENCIL.writeMask) {
+ STENCIL.writeMask = mask;
+ GL11.glStencilMask(mask);
+ }
+ }
+
+ /**
+ * @param stencilFail The action to take if the stencil test fails.
+ * @param depthFail The action to take if the depth buffer test fails.
+ * @param pass The action to take if both tests pass.
+ */
+ public static void _stencilOp(int stencilFail, int depthFail, int pass) {
+ RenderSystem.assertOnRenderThread();
+ if (stencilFail != STENCIL.frontStencilFail || depthFail != STENCIL.frontDepthFail || pass != STENCIL.frontPass
+ || stencilFail != STENCIL.backStencilFail || depthFail != STENCIL.backDepthFail || pass != STENCIL.backPass) {
+ STENCIL.frontStencilFail = stencilFail;
+ STENCIL.frontDepthFail = depthFail;
+ STENCIL.frontPass= pass;
+ STENCIL.backStencilFail = stencilFail;
+ STENCIL.backDepthFail = depthFail;
+ STENCIL.backPass = pass;
+ GL32.glStencilOpSeparate(GL32.GL_FRONT_AND_BACK, stencilFail, depthFail, pass);
+ }
+ }
+
+ /**
+ * Same as {@link #_stencilOp}, but affects only front-faces.
+ */
+ public static void _stencilOpFront(int stencilFail, int depthFail, int pass) {
+ RenderSystem.assertOnRenderThread();
+ if (stencilFail != STENCIL.frontStencilFail || depthFail != STENCIL.frontDepthFail || pass != STENCIL.frontPass) {
+ STENCIL.frontStencilFail = stencilFail;
+ STENCIL.frontDepthFail = depthFail;
+ STENCIL.frontPass= pass;
+ GL32.glStencilOpSeparate(GL32.GL_FRONT, stencilFail, depthFail, pass);
+ }
+ }
+
+ /**
+ * Same as {@link #_stencilOp}, but affects only back-faces.
+ */
+ public static void _stencilOpBack(int stencilFail, int depthFail, int pass) {
+ RenderSystem.assertOnRenderThread();
+ if (stencilFail != STENCIL.backStencilFail || depthFail != STENCIL.backDepthFail || pass != STENCIL.backPass) {
+ STENCIL.backStencilFail = stencilFail;
+ STENCIL.backDepthFail = depthFail;
+ STENCIL.backPass = pass;
+ GL32.glStencilOpSeparate(GL32.GL_BACK, stencilFail, depthFail, pass);
+ }
+ }
+
+ @OnlyIn(Dist.CLIENT)
+ static class StencilState {
+ public final GlStateManager.BooleanState mode = new GlStateManager.BooleanState(GL11.GL_STENCIL_TEST);
+ public int frontFunc = GL11.GL_ALWAYS;
+ public int frontRef;
+ public int frontReadMask = -1;
+ public int backFunc = GL11.GL_ALWAYS;
+ public int backRef;
+ public int backReadMask = -1;
+ public int writeMask = -1;
+ public int frontStencilFail = GL11.GL_KEEP;
+ public int frontDepthFail = GL11.GL_KEEP;
+ public int frontPass = GL11.GL_KEEP;
+ public int backStencilFail = GL11.GL_KEEP;
+ public int backDepthFail = GL11.GL_KEEP;
+ public int backPass = GL11.GL_KEEP;
}
}

View file

@ -0,0 +1,37 @@
--- a/com/mojang/blaze3d/opengl/GlTexture.java
+++ b/com/mojang/blaze3d/opengl/GlTexture.java
@@ -16,15 +_,21 @@
private final Int2IntMap fboCache = new Int2IntOpenHashMap();
protected boolean closed;
protected boolean modesDirty = true;
+ protected final boolean external; // If true, the raw OpenGL texture is not managed by this GpuTexture
protected GlTexture(String p_410238_, TextureFormat p_410416_, int p_409690_, int p_409866_, int p_410468_, int p_409791_) {
+ this(p_410238_, p_410416_, p_409690_, p_409866_, p_410468_, p_409791_, false);
+ }
+
+ protected GlTexture(String p_410238_, TextureFormat p_410416_, int p_409690_, int p_409866_, int p_410468_, int p_409791_, boolean external) {
super(p_410238_, p_410416_, p_409690_, p_409866_, p_410468_);
this.id = p_409791_;
+ this.external = external;
}
@Override
public void close() {
- if (!this.closed) {
+ if (!this.closed && !this.external) {
this.closed = true;
GlStateManager._deleteTexture(this.id);
@@ -41,9 +_,10 @@
public int getFbo(DirectStateAccess p_412345_, @Nullable GpuTexture p_410364_) {
int i = p_410364_ == null ? 0 : ((GlTexture)p_410364_).id;
+ var useStencil = p_410364_ != null && p_410364_.getFormat().hasStencilAspect();
return this.fboCache.computeIfAbsent(i, p_411998_ -> {
int j = p_412345_.createFrameBufferObject();
- p_412345_.bindFrameBufferTextures(j, this.id, i, 0, 0);
+ p_412345_.bindFrameBufferTextures(j, this.id, i, 0, 0, useStencil);
return j;
});
}

View file

@ -1,42 +1,25 @@
--- a/com/mojang/blaze3d/pipeline/MainTarget.java
+++ b/com/mojang/blaze3d/pipeline/MainTarget.java
@@ -16,7 +_,10 @@
@@ -20,7 +_,11 @@
static final MainTarget.Dimension DEFAULT_DIMENSIONS = new MainTarget.Dimension(854, 480);
public MainTarget(int p_166137_, int p_166138_) {
- super(true);
- super("Main", true);
+ this(p_166137_, p_166138_, false);
+ }
+
+ public MainTarget(int p_166137_, int p_166138_, boolean enableStencil) {
+ super(true, enableStencil);
+ super("Main", true, enableStencil);
this.createFrameBuffer(p_166137_, p_166138_);
}
@@ -37,6 +_,14 @@
GlStateManager._texParameter(3553, 10242, 33071);
GlStateManager._texParameter(3553, 10243, 33071);
GlStateManager._glFramebufferTexture2D(36160, 36096, 3553, this.depthBufferId, 0);
+ if (this.useStencil) {
+ GlStateManager._glFramebufferTexture2D(
+ org.lwjgl.opengl.GL32.GL_FRAMEBUFFER,
+ org.lwjgl.opengl.GL32.GL_STENCIL_ATTACHMENT,
+ org.lwjgl.opengl.GL32.GL_TEXTURE_2D,
+ this.depthBufferId,
+ 0);
+ }
GlStateManager._bindTexture(0);
this.viewWidth = maintarget$dimension.width;
this.viewHeight = maintarget$dimension.height;
@@ -82,7 +_,11 @@
RenderSystem.assertOnRenderThreadOrInit();
GlStateManager._getError();
GlStateManager._bindTexture(this.depthBufferId);
- GlStateManager._texImage2D(3553, 0, 6402, p_166145_.width, p_166145_.height, 0, 6402, 5126, null);
+ if (!this.useStencil) {
+ GlStateManager._texImage2D(3553, 0, 6402, p_166145_.width, p_166145_.height, 0, 6402, 5126, null);
+ } else {
+ net.neoforged.neoforge.client.ClientHooks.texImageDepthStencil(p_166145_.width, p_166145_.height);
+ }
return GlStateManager._getError() != 1285;
}
@@ -82,7 +_,8 @@
@Nullable
private GpuTexture allocateDepthAttachment(MainTarget.Dimension p_166145_) {
try {
- return RenderSystem.getDevice().createTexture(() -> this.label + " / Depth", TextureFormat.DEPTH32, p_166145_.width, p_166145_.height, 1);
+ var format = this.useStencil ? net.neoforged.neoforge.client.ClientHooks.getStencilFormat() : TextureFormat.DEPTH32;
+ return RenderSystem.getDevice().createTexture(() -> this.label + " / Depth", format, p_166145_.width, p_166145_.height, 1);
} catch (GpuOutOfMemoryException gpuoutofmemoryexception) {
return null;
}

View file

@ -1,66 +1,37 @@
--- a/com/mojang/blaze3d/pipeline/RenderTarget.java
+++ b/com/mojang/blaze3d/pipeline/RenderTarget.java
@@ -25,6 +_,7 @@
public int viewWidth;
@@ -23,6 +_,7 @@
public int viewHeight;
protected final String label;
public final boolean useDepth;
+ public final boolean useStencil;
public int frameBufferId;
protected int colorTextureId;
protected int depthBufferId;
@@ -32,7 +_,15 @@
public int filterMode;
@Nullable
protected GpuTexture colorTexture;
@Nullable
@@ -30,8 +_,16 @@
public FilterMode filterMode;
public RenderTarget(boolean p_166199_) {
- this.useDepth = p_166199_;
+ this(p_166199_, false);
public RenderTarget(@Nullable String p_405387_, boolean p_166199_) {
+ this(p_405387_, p_166199_, false);
+ }
+
+ public RenderTarget(boolean useDepth, boolean useStencil) {
+ if (useStencil && !useDepth) {
+ public RenderTarget(@Nullable String p_405387_, boolean p_166199_, boolean useStencil) {
+ if (useStencil && !p_166199_) {
+ throw new IllegalArgumentException("Stencil can only be enabled if depth is enabled.");
+ }
+ this.useDepth = useDepth;
this.label = p_405387_ == null ? "FBO " + UNNAMED_RENDER_TARGETS++ : p_405387_;
this.useDepth = p_166199_;
+ this.useStencil = useStencil;
this.frameBufferId = -1;
this.colorTextureId = -1;
this.depthBufferId = -1;
@@ -96,7 +_,11 @@
GlStateManager._texParameter(3553, 34892, 0);
GlStateManager._texParameter(3553, 10242, 33071);
GlStateManager._texParameter(3553, 10243, 33071);
- GlStateManager._texImage2D(3553, 0, 6402, this.width, this.height, 0, 6402, 5126, null);
+ if (!this.useStencil) {
+ GlStateManager._texImage2D(3553, 0, 6402, this.width, this.height, 0, 6402, 5126, null);
+ } else {
+ net.neoforged.neoforge.client.ClientHooks.texImageDepthStencil(this.width, this.height);
+ }
}
}
this.setFilterMode(9728, true);
@@ -109,6 +_,14 @@
public void resize(int p_83942_, int p_83943_) {
@@ -75,7 +_,8 @@
this.width = p_83951_;
this.height = p_83952_;
if (this.useDepth) {
GlStateManager._glFramebufferTexture2D(36160, 36096, 3553, this.depthBufferId, 0);
- this.depthTexture = RenderSystem.getDevice().createTexture(() -> this.label + " / Depth", TextureFormat.DEPTH32, p_83951_, p_83952_, 1);
+ var format = this.useStencil ? net.neoforged.neoforge.client.ClientHooks.getStencilFormat() : TextureFormat.DEPTH32;
+ this.depthTexture = RenderSystem.getDevice().createTexture(() -> this.label + " / Depth", format, p_83951_, p_83952_, 1);
this.depthTexture.setTextureFilter(FilterMode.NEAREST, false);
this.depthTexture.setAddressMode(AddressMode.CLAMP_TO_EDGE);
}
+ if (this.useStencil) {
+ GlStateManager._glFramebufferTexture2D(
+ org.lwjgl.opengl.GL32.GL_FRAMEBUFFER,
+ org.lwjgl.opengl.GL32.GL_STENCIL_ATTACHMENT,
+ org.lwjgl.opengl.GL32.GL_TEXTURE_2D,
+ this.depthBufferId,
+ 0);
+ }
this.checkStatus();
this.clear();
@@ -217,6 +_,10 @@
if (this.useDepth) {
GlStateManager._clearDepth(1.0);
i |= 256;
+ }
+ if (this.useStencil) {
+ GlStateManager._clearStencil(0);
+ i |= org.lwjgl.opengl.GL32.GL_STENCIL_BUFFER_BIT;
}
GlStateManager._clear(i);

View file

@ -1,14 +1,14 @@
--- a/com/mojang/blaze3d/pipeline/TextureTarget.java
+++ b/com/mojang/blaze3d/pipeline/TextureTarget.java
@@ -7,7 +_,10 @@
@@ -8,7 +_,10 @@
@OnlyIn(Dist.CLIENT)
public class TextureTarget extends RenderTarget {
public TextureTarget(int p_166213_, int p_166214_, boolean p_166215_) {
- super(p_166215_);
+ this(p_166213_, p_166214_, p_166215_, false);
public TextureTarget(@Nullable String p_405118_, int p_166213_, int p_166214_, boolean p_166215_) {
- super(p_405118_, p_166215_);
+ this(p_405118_, p_166213_, p_166214_, p_166215_, false);
+ }
+ public TextureTarget(int p_166213_, int p_166214_, boolean p_166215_, boolean useStencil) {
+ super(p_166215_, useStencil);
RenderSystem.assertOnRenderThreadOrInit();
+ public TextureTarget(@Nullable String p_405118_, int p_166213_, int p_166214_, boolean p_166215_, boolean enableStencil) {
+ super(p_405118_, p_166215_, enableStencil);
RenderSystem.assertOnRenderThread();
this.resize(p_166213_, p_166214_);
}

View file

@ -1,56 +0,0 @@
--- a/com/mojang/blaze3d/platform/GlStateManager.java
+++ b/com/mojang/blaze3d/platform/GlStateManager.java
@@ -1009,4 +_,53 @@
return INSTANCE.height;
}
}
+
+ public static void _backupGlState(net.neoforged.neoforge.client.GlStateBackup state) {
+ state.blendEnabled = BLEND.mode.enabled;
+ state.blendSrcRgb = BLEND.srcRgb;
+ state.blendDestRgb = BLEND.dstRgb;
+ state.blendSrcAlpha = BLEND.srcAlpha;
+ state.blendDestAlpha = BLEND.dstAlpha;
+ state.depthEnabled = DEPTH.mode.enabled;
+ state.depthMask = DEPTH.mask;
+ state.depthFunc = DEPTH.func;
+ state.cullEnabled = CULL.enable.enabled;
+ state.polyOffsetFillEnabled = POLY_OFFSET.fill.enabled;
+ state.polyOffsetLineEnabled = POLY_OFFSET.line.enabled;
+ state.polyOffsetFactor = POLY_OFFSET.factor;
+ state.polyOffsetUnits = POLY_OFFSET.units;
+ state.colorLogicEnabled = COLOR_LOGIC.enable.enabled;
+ state.colorLogicOp = COLOR_LOGIC.op;
+ state.stencilFuncFunc = STENCIL.func.func;
+ state.stencilFuncRef = STENCIL.func.ref;
+ state.stencilFuncMask = STENCIL.func.mask;
+ state.stencilMask = STENCIL.mask;
+ state.stencilFail = STENCIL.fail;
+ state.stencilZFail = STENCIL.zfail;
+ state.stencilZPass = STENCIL.zpass;
+ state.scissorEnabled = SCISSOR.mode.enabled;
+ state.colorMaskRed = COLOR_MASK.red;
+ state.colorMaskGreen = COLOR_MASK.green;
+ state.colorMaskBlue = COLOR_MASK.blue;
+ state.colorMaskAlpha = COLOR_MASK.alpha;
+ }
+
+ public static void _restoreGlState(net.neoforged.neoforge.client.GlStateBackup state) {
+ BLEND.mode.setEnabled(state.blendEnabled);
+ _blendFuncSeparate(state.blendSrcRgb, state.blendDestRgb, state.blendSrcAlpha, state.blendDestAlpha);
+ DEPTH.mode.setEnabled(state.depthEnabled);
+ _depthMask(state.depthMask);
+ _depthFunc(state.depthFunc);
+ CULL.enable.setEnabled(state.cullEnabled);
+ POLY_OFFSET.fill.setEnabled(state.polyOffsetFillEnabled);
+ POLY_OFFSET.line.setEnabled(state.polyOffsetLineEnabled);
+ _polygonOffset(state.polyOffsetFactor, state.polyOffsetUnits);
+ COLOR_LOGIC.enable.setEnabled(state.colorLogicEnabled);
+ _logicOp(state.colorLogicOp);
+ _stencilFunc(state.stencilFuncFunc, state.stencilFuncRef, state.stencilFuncMask);
+ _stencilMask(state.stencilMask);
+ _stencilOp(state.stencilFail, state.stencilZFail, state.stencilZPass);
+ SCISSOR.mode.setEnabled(state.scissorEnabled);
+ _colorMask(state.colorMaskRed, state.colorMaskGreen, state.colorMaskBlue, state.colorMaskAlpha);
+ }
}

View file

@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/platform/Window.java
+++ b/com/mojang/blaze3d/platform/Window.java
@@ -91,7 +_,8 @@
@@ -90,7 +_,8 @@
GLFW.glfwWindowHint(139267, 2);
GLFW.glfwWindowHint(139272, 204801);
GLFW.glfwWindowHint(139270, 1);
@ -10,15 +10,15 @@
if (monitor != null) {
VideoMode videomode = monitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty());
this.windowedX = this.x = monitor.getX() + videomode.getWidth() / 2 - this.width / 2;
@@ -103,6 +_,7 @@
@@ -102,6 +_,7 @@
this.windowedX = this.x = aint1[0];
this.windowedY = this.y = aint[0];
}
+ }
GLFW.glfwMakeContextCurrent(this.window);
GL.createCapabilities();
@@ -208,8 +_,10 @@
this.setMode();
this.refreshFramebufferSize();
@@ -203,8 +_,10 @@
}
public void defaultErrorCallback(int p_85383_, long p_85384_) {
@ -30,7 +30,7 @@
LOGGER.error("########## GL ERROR ##########");
LOGGER.error("@ {}", this.errorSection);
LOGGER.error("{}: {}", p_85383_, s);
@@ -273,6 +_,7 @@
@@ -268,6 +_,7 @@
GLFW.glfwGetFramebufferSize(this.window, aint, aint1);
this.framebufferWidth = aint[0] > 0 ? aint[0] : 1;
this.framebufferHeight = aint1[0] > 0 ? aint1[0] : 1;

View file

@ -1,18 +1,36 @@
--- a/com/mojang/blaze3d/resource/RenderTargetDescriptor.java
+++ b/com/mojang/blaze3d/resource/RenderTargetDescriptor.java
@@ -6,9 +_,13 @@
@@ -7,9 +_,13 @@
import net.neoforged.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
-public record RenderTargetDescriptor(int width, int height, boolean useDepth) implements ResourceDescriptor<RenderTarget> {
+public record RenderTargetDescriptor(int width, int height, boolean useDepth, boolean useStencil) implements ResourceDescriptor<RenderTarget> {
+ public RenderTargetDescriptor(int width, int height, boolean useDepth) {
+ this(width, height, useDepth, false);
-public record RenderTargetDescriptor(int width, int height, boolean useDepth, int clearColor) implements ResourceDescriptor<RenderTarget> {
+public record RenderTargetDescriptor(int width, int height, boolean useDepth, int clearColor, boolean useStencil) implements ResourceDescriptor<RenderTarget> {
+ public RenderTargetDescriptor(int width, int height, boolean useDepth, int clearColor) {
+ this(width, height, useDepth, clearColor, false);
+ }
+
public RenderTarget allocate() {
- return new TextureTarget(this.width, this.height, this.useDepth);
+ return new TextureTarget(this.width, this.height, this.useDepth, this.useStencil);
- return new TextureTarget(null, this.width, this.height, this.useDepth);
+ return new TextureTarget(null, this.width, this.height, this.useDepth, this.useStencil);
}
public void prepare(RenderTarget p_393765_) {
@@ -20,6 +_,9 @@
} else {
RenderSystem.getDevice().createCommandEncoder().clearColorTexture(p_393765_.getColorTexture(), this.clearColor);
}
+ if (this.useStencil) {
+ RenderSystem.getDevice().createCommandEncoder().clearStencilTexture(p_393765_.getDepthTexture(), 0);
+ }
}
public void free(RenderTarget p_363223_) {
@@ -30,6 +_,6 @@
public boolean canUsePhysicalResource(ResourceDescriptor<?> p_394237_) {
return !(p_394237_ instanceof RenderTargetDescriptor rendertargetdescriptor)
? false
- : this.width == rendertargetdescriptor.width && this.height == rendertargetdescriptor.height && this.useDepth == rendertargetdescriptor.useDepth;
+ : this.width == rendertargetdescriptor.width && this.height == rendertargetdescriptor.height && this.useDepth == rendertargetdescriptor.useDepth && this.useStencil == rendertargetdescriptor.useStencil;
}
}

View file

@ -0,0 +1,11 @@
--- a/com/mojang/blaze3d/systems/CommandEncoder.java
+++ b/com/mojang/blaze3d/systems/CommandEncoder.java
@@ -25,6 +_,8 @@
void clearDepthTexture(GpuTexture p_410276_, double p_410184_);
+ void clearStencilTexture(GpuTexture texture, int value);
+
void writeToBuffer(GpuBuffer p_410195_, ByteBuffer p_410481_, int p_410055_);
GpuBuffer.ReadView readBuffer(GpuBuffer p_410459_);

View file

@ -0,0 +1,13 @@
--- a/com/mojang/blaze3d/systems/RenderPass.java
+++ b/com/mojang/blaze3d/systems/RenderPass.java
@@ -31,6 +_,10 @@
void disableScissor();
+ void enableStencilTest(net.neoforged.neoforge.client.stencil.StencilTest stencilTest);
+
+ void disableStencilTest();
+
void setVertexBuffer(int p_409605_, GpuBuffer p_410644_);
void setIndexBuffer(GpuBuffer p_409862_, VertexFormat.IndexType p_410093_);

View file

@ -1,17 +1,27 @@
--- a/com/mojang/blaze3d/systems/RenderSystem.java
+++ b/com/mojang/blaze3d/systems/RenderSystem.java
@@ -818,4 +_,14 @@
void accept(it.unimi.dsi.fastutil.ints.IntConsumer p_157488_, int p_157489_);
}
@@ -45,6 +_,8 @@
@DontObfuscate
public class RenderSystem {
public static final ScissorState SCISSOR_STATE = new ScissorState();
+ @Nullable
+ public static net.neoforged.neoforge.client.stencil.StencilTest STENCIL_TEST = null;
static final Logger LOGGER = LogUtils.getLogger();
public static final int MINIMUM_ATLAS_TEXTURE_SIZE = 1024;
@Nullable
@@ -152,6 +_,15 @@
public static void disableScissor() {
SCISSOR_STATE.disable();
+ }
+
+
+ public static void enableStencil(net.neoforged.neoforge.client.stencil.StencilTest stencilTest) {
+ STENCIL_TEST = stencilTest;
+ }
+
+ public static void disableStencil() {
+ STENCIL_TEST = null;
}
+
+ public static void backupGlState(net.neoforged.neoforge.client.GlStateBackup state) {
+ assertOnRenderThread();
+ GlStateManager._backupGlState(state);
+ }
+
+ public static void restoreGlState(net.neoforged.neoforge.client.GlStateBackup state) {
+ assertOnRenderThread();
+ GlStateManager._restoreGlState(state);
+ }
}
public static void setShaderFog(FogParameters p_360454_) {

View file

@ -0,0 +1,33 @@
--- a/com/mojang/blaze3d/textures/TextureFormat.java
+++ b/com/mojang/blaze3d/textures/TextureFormat.java
@@ -9,12 +_,15 @@
public enum TextureFormat {
RGBA8(4),
RED8(1),
- DEPTH32(4);
+ DEPTH32(4),
+ // Neo: Add depth+stencil formats
+ DEPTH24_STENCIL8(4),
+ DEPTH32_STENCIL8(8);
private final int pixelSize;
- private TextureFormat(int p_404990_) {
- this.pixelSize = p_404990_;
+ private TextureFormat(int pixelSize) {
+ this.pixelSize = pixelSize;
}
public int pixelSize() {
@@ -26,6 +_,10 @@
}
public boolean hasDepthAspect() {
- return this == DEPTH32;
+ return this == DEPTH32 || this == DEPTH24_STENCIL8 || this == DEPTH32_STENCIL8;
+ }
+
+ public boolean hasStencilAspect() {
+ return this == DEPTH24_STENCIL8 || this == DEPTH32_STENCIL8;
}
}

View file

@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/vertex/VertexFormat.java
+++ b/com/mojang/blaze3d/vertex/VertexFormat.java
@@ -220,4 +_,28 @@
@@ -222,4 +_,28 @@
};
}
}

View file

@ -1,6 +1,6 @@
--- a/com/mojang/blaze3d/vertex/VertexFormatElement.java
+++ b/com/mojang/blaze3d/vertex/VertexFormatElement.java
@@ -78,6 +_,15 @@
@@ -75,6 +_,15 @@
return ELEMENTS.stream().filter(p_350573_ -> p_350573_ != null && (p_350349_ & p_350573_.mask()) != 0);
}
@ -14,24 +14,5 @@
+ }
+
@OnlyIn(Dist.CLIENT)
@DontObfuscate
public static enum Type {
FLOAT(4, "Float", 5126),
@@ -113,6 +_,7 @@
}
@OnlyIn(Dist.CLIENT)
+ @net.neoforged.fml.common.asm.enumextension.NamedEnum
public static enum Usage implements net.neoforged.fml.common.asm.enumextension.IExtensibleEnum {
POSITION(
"Position",
@@ -163,6 +_,10 @@
@OnlyIn(Dist.CLIENT)
public interface SetupState {
void setupBufferState(int p_167053_, int p_167054_, int p_167055_, long p_167056_, int p_167057_);
+ }
+
+ public static net.neoforged.fml.common.asm.enumextension.ExtensionInfo getExtensionInfo() {
+ return net.neoforged.fml.common.asm.enumextension.ExtensionInfo.nonExtended(VertexFormatElement.Usage.class);
}
}
}

View file

@ -1,6 +1,6 @@
--- a/com/mojang/math/Transformation.java
+++ b/com/mojang/math/Transformation.java
@@ -159,6 +_,19 @@
@@ -164,6 +_,19 @@
return Objects.hash(this.matrix);
}

View file

@ -40,4 +40,4 @@
+ this.stackTrace = stackTrace;
}
public static void populateBlockDetails(CrashReportCategory p_178951_, LevelHeightAccessor p_178952_, BlockPos p_178953_, @Nullable BlockState p_178954_) {
public static void populateBlockDetails(CrashReportCategory p_178951_, LevelHeightAccessor p_178952_, BlockPos p_178953_, BlockState p_178954_) {

View file

@ -1,13 +1,6 @@
--- a/net/minecraft/FileUtil.java
+++ b/net/minecraft/FileUtil.java
@@ -13,12 +_,14 @@
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import org.apache.commons.io.FilenameUtils;
public class FileUtil {
@@ -19,6 +_,7 @@
private static final Pattern COPY_COUNTER_PATTERN = Pattern.compile("(<name>.*) \\((<count>\\d*)\\)", 66);
private static final int MAX_FILE_NAME = 255;
private static final Pattern RESERVED_WINDOWS_FILENAMES = Pattern.compile(".*\\.|(?:COM|CLOCK\\$|CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\\..*)?", 2);

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/SharedConstants.java
+++ b/net/minecraft/SharedConstants.java
@@ -117,7 +_,8 @@
@@ -118,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;
@@ -170,6 +_,7 @@
@@ -171,6 +_,7 @@
}
static {

View file

@ -11,7 +11,7 @@
throw illegalargumentexception;
}
}
@@ -634,20 +_,20 @@
@@ -646,20 +_,20 @@
public static void logAndPauseIfInIde(String p_143786_) {
LOGGER.error(p_143786_);

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/advancements/Advancement.java
+++ b/net/minecraft/advancements/Advancement.java
@@ -52,6 +_,7 @@
@@ -53,6 +_,7 @@
)
.validate(Advancement::validate);
public static final StreamCodec<RegistryFriendlyByteBuf, Advancement> STREAM_CODEC = StreamCodec.ofMember(Advancement::write, Advancement::read);

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/advancements/AdvancementRewards.java
+++ b/net/minecraft/advancements/AdvancementRewards.java
@@ -41,6 +_,7 @@
@@ -40,6 +_,7 @@
LootParams lootparams = new LootParams.Builder(p_9990_.serverLevel())
.withParameter(LootContextParams.THIS_ENTITY, p_9990_)
.withParameter(LootContextParams.ORIGIN, p_9990_.position())

View file

@ -1,17 +0,0 @@
--- a/net/minecraft/advancements/critereon/ItemAttributeModifiersPredicate.java
+++ b/net/minecraft/advancements/critereon/ItemAttributeModifiersPredicate.java
@@ -40,6 +_,14 @@
return !this.modifiers.isPresent() || this.modifiers.get().test(p_341374_.modifiers());
}
+ /**
+ * Neo: Override this method to reflect gameplay attribute modifiers instead of only NBT modifiers.
+ */
+ @Override
+ public boolean matches(ItemStack p_333958_) {
+ return matches(p_333958_, p_333958_.getAttributeModifiers());
+ }
+
public static record EntryPredicate(
Optional<HolderSet<Attribute>> attribute,
Optional<ResourceLocation> id,

View file

@ -1,19 +0,0 @@
--- a/net/minecraft/advancements/critereon/ItemEnchantmentsPredicate.java
+++ b/net/minecraft/advancements/critereon/ItemEnchantmentsPredicate.java
@@ -52,6 +_,16 @@
public DataComponentType<ItemEnchantments> componentType() {
return DataComponents.ENCHANTMENTS;
}
+
+ // Neo: use IItemExtension#getAllEnchantments for enchantments when testing this predicate.
+ @Override
+ public boolean matches(ItemStack p_333958_) {
+ var lookup = net.neoforged.neoforge.common.CommonHooks.resolveLookup(net.minecraft.core.registries.Registries.ENCHANTMENT);
+ if (lookup != null) {
+ return matches(p_333958_, p_333958_.getAllEnchantments(lookup));
+ }
+ return super.matches(p_333958_);
+ }
}
public static class StoredEnchantments extends ItemEnchantmentsPredicate {

View file

@ -19,7 +19,7 @@
+ 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),
Mth.lerp((double)p_90580_, p_90577_.yo, p_90577_.getY()) + Mth.lerp(p_90580_, this.eyeHeightOld, this.eyeHeight),
@@ -72,11 +_,11 @@
if (p_90578_) {
@ -35,7 +35,7 @@
Direction direction = ((LivingEntity)p_90577_).getBedOrientation();
this.setRotation(direction != null ? direction.toYRot() - 180.0F : 0.0F, 0.0F);
@@ -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));
this.setPosition(new Vec3(this.position.x + vector3f.x, this.position.y + vector3f.y, this.position.z + vector3f.z));
}
+ /** @deprecated Neo: call {@link #setRotation(float, float, float)} instead */
@ -53,7 +53,7 @@
FORWARDS.rotate(this.rotation, this.forwards);
UP.rotate(this.rotation, this.up);
LEFT.rotate(this.rotation, this.left);
@@ -236,6 +_,17 @@
@@ -235,6 +_,17 @@
public float getPartialTickTime() {
return this.partialTickTime;

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/GameNarrator.java
+++ b/net/minecraft/client/GameNarrator.java
@@ -59,7 +_,7 @@
@@ -69,7 +_,7 @@
}
private void logNarratedMessage(String p_168788_) {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/KeyboardHandler.java
+++ b/net/minecraft/client/KeyboardHandler.java
@@ -426,12 +_,20 @@
@@ -433,12 +_,20 @@
if (screen != null) {
try {
if (p_90897_ != 1 && p_90897_ != 2) {
@ -23,7 +23,7 @@
return;
}
}
@@ -507,6 +_,7 @@
@@ -497,6 +_,7 @@
}
}
}
@ -31,7 +31,7 @@
}
}
@@ -516,10 +_,20 @@
@@ -506,10 +_,20 @@
if (screen != null && this.minecraft.getOverlay() == null) {
try {
if (Character.isBmpCodePoint(p_90891_)) {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/Minecraft.java
+++ b/net/minecraft/client/Minecraft.java
@@ -432,7 +_,6 @@
@@ -430,7 +_,6 @@
}
}, Util.nonCriticalIoPool());
LOGGER.info("Setting user: {}", this.user.getName());
@ -8,7 +8,7 @@
this.demo = p_91084_.game.demo;
this.allowsMultiplayer = !p_91084_.game.disableMultiplayer;
this.allowsChat = !p_91084_.game.disableChat;
@@ -483,15 +_,18 @@
@@ -482,20 +_,25 @@
LOGGER.error("Couldn't set icon", (Throwable)ioexception);
}
@ -17,12 +17,21 @@
- this.mouseHandler.setup(this.window.getWindow());
this.keyboardHandler = new KeyboardHandler(this);
- this.keyboardHandler.setup(this.window.getWindow());
RenderSystem.initRenderer(this.options.glDebugVerbosity, false);
+ // Neo: Enable GL debug labels and synchronous GL debug output via FML config
+ boolean enableGlDebug = net.neoforged.fml.loading.FMLConfig.getBoolConfigValue(net.neoforged.fml.loading.FMLConfig.ConfigValue.DEBUG_OPENGL);
RenderSystem.initRenderer(
this.window.getWindow(),
this.options.glDebugVerbosity,
- false,
+ enableGlDebug,
(p_408948_, p_408949_) -> this.getShaderManager().getShader(p_408948_, p_408949_),
- p_91084_.game.renderDebugLabels
+ p_91084_.game.renderDebugLabels || enableGlDebug
);
LOGGER.info("Using optional rendering extensions: {}", String.join(", ", RenderSystem.getDevice().getEnabledExtensions()));
- this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight());
+ net.neoforged.neoforge.client.loading.ClientModLoader.begin(this);
+ this.mainRenderTarget = net.neoforged.neoforge.client.ClientHooks.instantiateMainTarget(this.window.getWidth(), this.window.getHeight());
this.mainRenderTarget.setClearColor(0.0F, 0.0F, 0.0F, 0.0F);
this.mainRenderTarget.clear();
this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES);
+ net.neoforged.neoforge.client.loading.ClientModLoader.finish(this.resourcePackRepository, this.resourceManager);
+ //Move client bootstrap to after mod loading so that events can be fired for it.
@ -30,7 +39,15 @@
this.resourcePackRepository.reload();
this.options.loadSelectedResourcePacks(this.resourcePackRepository);
this.languageManager = new LanguageManager(this.options.languageCode, p_344151_ -> {
@@ -571,6 +_,7 @@
@@ -528,6 +_,7 @@
RenderSystem.setupDefaultState();
this.window.setErrorSection("Post startup");
this.blockColors = BlockColors.createDefault();
+ net.neoforged.neoforge.client.model.UnbakedModelParser.init();
this.modelManager = new ModelManager(this.textureManager, this.blockColors, this.options.mipmapLevels().get());
this.resourceManager.registerReloadListener(this.modelManager);
EquipmentAssetManager equipmentassetmanager = new EquipmentAssetManager();
@@ -576,6 +_,7 @@
);
this.resourceManager.registerReloadListener(this.blockEntityRenderDispatcher);
this.particleEngine = new ParticleEngine(this.level, this.textureManager);
@ -38,7 +55,7 @@
this.resourceManager.registerReloadListener(this.particleEngine);
this.paintingTextures = new PaintingTextureManager(this.textureManager);
this.resourceManager.registerReloadListener(this.paintingTextures);
@@ -580,11 +_,15 @@
@@ -585,11 +_,15 @@
this.resourceManager.registerReloadListener(this.guiSprites);
this.gameRenderer = new GameRenderer(this, this.entityRenderDispatcher.getItemInHandRenderer(), this.resourceManager, this.renderBuffers);
this.levelRenderer = new LevelRenderer(this, this.entityRenderDispatcher, this.blockEntityRenderDispatcher, this.renderBuffers);
@ -53,39 +70,37 @@
+ this.keyboardHandler.setup(this.window.getWindow());
this.gui = new Gui(this);
this.debugRenderer = new DebugRenderer(this);
RealmsClient realmsclient = RealmsClient.create(this);
@@ -609,6 +_,7 @@
this.options.fullscreen().set(this.window.isFullscreen());
RealmsClient realmsclient = RealmsClient.getOrCreate(this);
@@ -624,6 +_,7 @@
}
}
+ net.neoforged.neoforge.client.ClientHooks.initClientHooks(this, this.resourceManager);
this.window.updateVsync(this.options.enableVsync().get());
this.window.updateRawMouseInput(this.options.rawMouseInput().get());
this.window.setDefaultErrorCallback();
@@ -631,16 +_,18 @@
@@ -646,16 +_,16 @@
GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS);
Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay);
this.setOverlay(
- new LoadingOverlay(
- this, reloadinstance, p_299779_ -> Util.ifElse(p_299779_, p_299772_ -> this.rollbackResourcePacks(p_299772_, minecraft$gameloadcookie), () -> {
- if (SharedConstants.IS_RUNNING_IN_IDE) {
- if (SharedConstants.IS_RUNNING_IN_IDE) {
+ net.neoforged.fml.loading.ImmediateWindowHandler.<LoadingOverlay>loadingOverlay(
+ () -> this, () -> reloadinstance, p_299779_ -> Util.ifElse(p_299779_, p_299772_ -> this.rollbackResourcePacks(p_299772_, minecraft$gameloadcookie), () -> {
+ if (SharedConstants.IS_RUNNING_IN_IDE && false) {
this.selfTest();
}
+ () -> this, () -> reloadinstance, p_299779_ -> Util.ifElse(p_299779_, p_299772_ -> this.rollbackResourcePacks(p_299772_, minecraft$gameloadcookie), () -> {
+ if (SharedConstants.IS_RUNNING_IN_IDE && false) {
this.selfTest();
}
this.reloadStateTracker.finishReload();
this.onResourceLoadFinished(minecraft$gameloadcookie);
+
+
}), false
this.reloadStateTracker.finishReload();
this.onResourceLoadFinished(minecraft$gameloadcookie);
}), false
- )
+ ).get()
);
this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.path());
this.framerateLimitTracker = new FramerateLimitTracker(this.options, this);
@@ -686,6 +_,8 @@
@@ -704,6 +_,8 @@
runnable = () -> this.setScreen(screen);
}
@ -94,7 +109,7 @@
return runnable;
}
@@ -734,7 +_,7 @@
@@ -752,7 +_,7 @@
private String createTitle() {
StringBuilder stringbuilder = new StringBuilder("Minecraft");
if (checkModStatus().shouldReportAsModified()) {
@ -103,7 +118,7 @@
}
stringbuilder.append(" ");
@@ -766,7 +_,7 @@
@@ -784,7 +_,7 @@
}
private void rollbackResourcePacks(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299846_) {
@ -112,7 +127,7 @@
this.clearResourcePacksOnError(p_91240_, null, p_299846_);
} else {
Util.throwAsRuntime(p_91240_);
@@ -925,7 +_,7 @@
@@ -943,7 +_,7 @@
p_307414_.soundManager.emergencyShutdown();
}
@ -121,7 +136,7 @@
}
public boolean isEnforceUnicode() {
@@ -1052,9 +_,7 @@
@@ -1070,9 +_,7 @@
LOGGER.error("setScreen called from non-game thread");
}
@ -132,7 +147,7 @@
this.setLastInputType(InputType.NONE);
}
@@ -1071,6 +_,19 @@
@@ -1089,6 +_,19 @@
}
}
@ -152,7 +167,7 @@
this.screen = p_91153_;
if (this.screen != null) {
this.screen.added();
@@ -1224,9 +_,11 @@
@@ -1242,9 +_,11 @@
this.mouseHandler.handleAccumulatedMovement();
profilerfiller.pop();
if (!this.noRender) {
@ -164,7 +179,7 @@
}
profilerfiller.push("blit");
@@ -1257,9 +_,13 @@
@@ -1274,9 +_,13 @@
profilerfiller.pop();
this.window.setErrorSection("Post render");
this.frames++;
@ -179,8 +194,8 @@
this.deltaTracker.updatePauseState(this.pause);
this.deltaTracker.updateFrozenState(!this.isLevelRunningNormally());
long l = Util.getNanos();
@@ -1351,10 +_,13 @@
this.window.setGuiScale((double)i);
@@ -1368,10 +_,13 @@
this.window.setGuiScale(i);
if (this.screen != null) {
this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
+ net.neoforged.neoforge.client.ClientHooks.resizeGuiLayers(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
@ -193,7 +208,7 @@
this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight());
this.mouseHandler.setIgnoreFirstMove();
}
@@ -1495,6 +_,7 @@
@@ -1511,6 +_,7 @@
}
public void stop() {
@ -201,7 +216,7 @@
this.running = false;
}
@@ -1524,9 +_,17 @@
@@ -1540,9 +_,17 @@
BlockHitResult blockhitresult = (BlockHitResult)this.hitResult;
BlockPos blockpos = blockhitresult.getBlockPos();
if (!this.level.getBlockState(blockpos).isAir()) {
@ -221,7 +236,7 @@
this.player.swing(InteractionHand.MAIN_HAND);
}
}
@@ -1554,6 +_,8 @@
@@ -1570,6 +_,8 @@
return false;
} else {
boolean flag = false;
@ -230,7 +245,7 @@
switch (this.hitResult.getType()) {
case ENTITY:
this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity());
@@ -1574,8 +_,10 @@
@@ -1590,8 +_,10 @@
}
this.player.resetAttackStrengthTicker();
@ -241,7 +256,7 @@
this.player.swing(InteractionHand.MAIN_HAND);
return flag;
}
@@ -1591,6 +_,11 @@
@@ -1607,6 +_,11 @@
}
for (InteractionHand interactionhand : InteractionHand.values()) {
@ -253,7 +268,7 @@
ItemStack itemstack = this.player.getItemInHand(interactionhand);
if (!itemstack.isItemEnabled(this.level.enabledFeatures())) {
return;
@@ -1611,7 +_,7 @@
@@ -1627,7 +_,7 @@
}
if (interactionresult instanceof InteractionResult.Success interactionresult$success2) {
@ -262,16 +277,16 @@
this.player.swing(interactionhand);
}
@@ -1623,7 +_,7 @@
@@ -1639,7 +_,7 @@
int i = itemstack.getCount();
InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult);
if (interactionresult1 instanceof InteractionResult.Success interactionresult$success) {
- if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT) {
+ if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) {
this.player.swing(interactionhand);
if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.gameMode.hasInfiniteItems())) {
if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.player.hasInfiniteMaterials())) {
this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand);
@@ -1639,6 +_,9 @@
@@ -1655,6 +_,9 @@
}
}
@ -281,7 +296,7 @@
if (!itemstack.isEmpty()
&& this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) {
if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) {
@@ -1659,6 +_,8 @@
@@ -1675,6 +_,8 @@
public void tick() {
this.clientTickCount++;
@ -290,7 +305,7 @@
if (this.level != null && !this.pause) {
this.level.tickRateManager().tick();
}
@@ -1757,6 +_,7 @@
@@ -1773,6 +_,7 @@
this.tutorial.tick();
@ -298,7 +313,7 @@
try {
this.level.tick(() -> true);
} catch (Throwable throwable1) {
@@ -1770,6 +_,7 @@
@@ -1786,6 +_,7 @@
throw new ReportedException(crashreport1);
}
@ -306,7 +321,7 @@
}
profilerfiller.popPush("animateTick");
@@ -1794,6 +_,8 @@
@@ -1810,6 +_,8 @@
profilerfiller.popPush("keyboard");
this.keyboardHandler.tick();
profilerfiller.pop();
@ -315,7 +330,7 @@
}
private boolean isLevelRunningNormally() {
@@ -1993,7 +_,8 @@
@@ -2008,7 +_,8 @@
}
public void setLevel(ClientLevel p_91157_, ReceivingLevelScreen.Reason p_341652_) {
@ -325,7 +340,7 @@
this.level = p_91157_;
this.updateLevelInEngines(p_91157_);
if (!this.isLocalServer) {
@@ -2030,13 +_,16 @@
@@ -2045,13 +_,16 @@
IntegratedServer integratedserver = this.singleplayerServer;
this.singleplayerServer = null;
this.gameRenderer.resetData();
@ -342,7 +357,7 @@
if (integratedserver != null) {
ProfilerFiller profilerfiller = Profiler.get();
profilerfiller.push("waitForServer");
@@ -2060,6 +_,7 @@
@@ -2075,6 +_,7 @@
}
SkullBlockEntity.clear();
@ -350,11 +365,11 @@
}
public void clearDownloadedResourcePacks() {
@@ -2197,6 +_,7 @@
@@ -2212,6 +_,7 @@
private void pickBlock() {
if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) {
+ if (net.neoforged.neoforge.client.ClientHooks.onClickInput(2, this.options.keyPickItem, InteractionHand.MAIN_HAND).isCanceled()) return;
boolean flag = Screen.hasControlDown();
HitResult hitresult = this.hitResult;
Objects.requireNonNull(this.hitResult);
switch (this.hitResult) {
case BlockHitResult blockhitresult:

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/MouseHandler.java
+++ b/net/minecraft/client/MouseHandler.java
@@ -85,6 +_,7 @@
@@ -90,6 +_,7 @@
this.activeButton = -1;
}
@ -8,7 +8,7 @@
if (this.minecraft.getOverlay() == null) {
if (this.minecraft.screen == null) {
if (!this.mouseGrabbed && flag) {
@@ -98,7 +_,12 @@
@@ -103,7 +_,12 @@
screen.afterMouseAction();
try {
@ -22,7 +22,7 @@
return;
}
} catch (Throwable throwable1) {
@@ -112,7 +_,12 @@
@@ -116,7 +_,12 @@
}
} else {
try {
@ -36,7 +36,7 @@
return;
}
} catch (Throwable throwable) {
@@ -146,6 +_,7 @@
@@ -149,6 +_,7 @@
}
}
}
@ -44,10 +44,10 @@
}
}
@@ -160,7 +_,11 @@
@@ -189,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();
double d3 = this.getScaledXPos(this.minecraft.getWindow());
double d4 = this.getScaledYPos(this.minecraft.getWindow());
- this.minecraft.screen.mouseScrolled(d3, d4, d1, d2);
+ if (!net.neoforged.neoforge.client.ClientHooks.onScreenMouseScrollPre(this, this.minecraft.screen, d1, d2)) {
+ if (!this.minecraft.screen.mouseScrolled(d3, d4, d1, d2)) {
@ -57,7 +57,7 @@
this.minecraft.screen.afterMouseAction();
} else if (this.minecraft.player != null) {
Vector2i vector2i = this.scrollWheelHandler.onMouseScroll(d1, d2);
@@ -169,6 +_,7 @@
@@ -198,6 +_,7 @@
}
int i = vector2i.y == 0 ? -vector2i.x : vector2i.y;
@ -65,8 +65,8 @@
if (this.minecraft.player.isSpectator()) {
if (this.minecraft.gui.getSpectatorGui().isMenuActive()) {
this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i);
@@ -280,7 +_,11 @@
/ (double)this.minecraft.getWindow().getScreenHeight();
@@ -303,7 +_,11 @@
double d5 = getScaledYPos(window, this.accumulatedDY);
try {
- screen.mouseDragged(d2, d3, this.activeButton, d4, d5);
@ -78,7 +78,7 @@
} catch (Throwable throwable) {
CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler");
screen.fillCrashDetails(crashreport1);
@@ -304,12 +_,13 @@
@@ -342,12 +_,13 @@
}
private void turnPlayer(double p_316356_) {
@ -94,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;
@@ -355,6 +_,14 @@
@@ -393,6 +_,14 @@
public double ypos() {
return this.ypos;

View file

@ -1,18 +1,18 @@
--- a/net/minecraft/client/Options.java
+++ b/net/minecraft/client/Options.java
@@ -746,9 +_,10 @@
@@ -721,9 +_,10 @@
}
},
new OptionInstance.LazyEnum<>(
+ // FORGE: fix incorrect string comparison - PR #8767
() -> Stream.concat(Stream.of(""), Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().stream()).toList(),
p_232011_ -> Minecraft.getInstance().isRunning()
- && p_232011_ != ""
+ && (p_232011_ == null || !p_232011_.isEmpty())
&& !Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().contains(p_232011_)
? Optional.empty()
: Optional.of(p_232011_),
@@ -822,7 +_,7 @@
- && p_232011_ != ""
+ && (p_232011_ == null || !p_232011_.isEmpty())
&& !Minecraft.getInstance().getSoundManager().getAvailableSoundDevices().contains(p_232011_)
? Optional.empty()
: Optional.of(p_232011_),
@@ -798,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());
@@ -1130,6 +_,7 @@
@@ -1106,6 +_,7 @@
}
public Options(Minecraft p_92138_, File p_92139_) {
@ -29,9 +29,9 @@
this.minecraft = p_92138_;
this.optionsFile = new File(p_92139_, "options.txt");
boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L;
@@ -1264,11 +_,21 @@
this.onboardAccessibility = p_168428_.process("onboardAccessibility", this.onboardAccessibility);
@@ -1240,11 +_,21 @@
p_168428_.process("menuBackgroundBlurriness", this.menuBackgroundBlurriness);
this.startedCleanly = p_168428_.process("startedCleanly", this.startedCleanly);
+ net.neoforged.neoforge.forge.snapshots.ForgeSnapshotsMod.processOptions(p_168428_);
+ processOptionsForge(p_168428_);
@ -53,7 +53,7 @@
}
}
@@ -1286,6 +_,9 @@
@@ -1262,6 +_,9 @@
}
public void load() {
@ -63,8 +63,8 @@
try {
if (!this.optionsFile.exists()) {
return;
@@ -1313,7 +_,8 @@
}
@@ -1286,7 +_,8 @@
this.graphicsMode.set(isTrue(optional.get()) ? GraphicsStatus.FANCY : GraphicsStatus.FAST);
}
- this.processOptions(
@ -72,8 +72,8 @@
+ processor.accept(
new Options.FieldAccess() {
@Nullable
private String getValueOrNull(String p_168459_) {
@@ -1484,6 +_,7 @@
private String getValue(String p_405059_) {
@@ -1471,6 +_,7 @@
}
public ClientInformation buildPlayerInformation() {
@ -81,7 +81,7 @@
int i = 0;
for (PlayerModelPart playermodelpart : this.modelParts) {
@@ -1555,6 +_,23 @@
@@ -1542,6 +_,23 @@
}
p_92146_.setSelected(set);

View file

@ -1,32 +1,35 @@
--- a/net/minecraft/client/Screenshot.java
+++ b/net/minecraft/client/Screenshot.java
@@ -54,15 +_,25 @@
file2 = new File(file1, p_92307_);
}
@@ -43,6 +_,13 @@
file2 = new File(file1, p_92297_);
}
+ net.neoforged.neoforge.client.event.ScreenshotEvent event = net.neoforged.neoforge.client.ClientHooks.onScreenshot(nativeimage, file2);
+ if (event.isCanceled()) {
+ p_92311_.accept(event.getCancelMessage());
+ return;
+ }
+ final File target = event.getScreenshotFile();
+ net.neoforged.neoforge.client.event.ScreenshotEvent event = net.neoforged.neoforge.client.ClientHooks.onScreenshot(p_406180_, file2);
+ if (event.isCanceled()) {
+ p_92301_.accept(event.getCancelMessage());
+ return;
+ }
+ final File target = event.getScreenshotFile();
+
Util.ioPool()
.execute(
() -> {
try {
- nativeimage.writeToFile(file2);
- Component component = Component.literal(file2.getName())
+ nativeimage.writeToFile(target);
+ Component component = Component.literal(target.getName())
.withStyle(ChatFormatting.UNDERLINE)
- .withStyle(p_168608_ -> p_168608_.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file2.getAbsolutePath())));
- p_92311_.accept(Component.translatable("screenshot.success", component));
+ .withStyle(p_168608_ -> p_168608_.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, target.getAbsolutePath())));
+ if (event.getResultMessage() != null)
+ p_92311_.accept(event.getResultMessage());
+ else
+ p_92311_.accept(Component.translatable("screenshot.success", component));
} catch (Exception exception) {
LOGGER.warn("Couldn't save screenshot", (Throwable)exception);
p_92311_.accept(Component.translatable("screenshot.failure", exception.getMessage()));
Util.ioPool()
.execute(
() -> {
@@ -50,11 +_,15 @@
NativeImage $$4x = p_406180_;
try {
- p_406180_.writeToFile(file2);
- Component component = Component.literal(file2.getName())
+ p_406180_.writeToFile(target);
+ if (event.getResultMessage() != null) {
+ p_92301_.accept(event.getResultMessage());
+ } else {
+ Component component = Component.literal(target.getName())
.withStyle(ChatFormatting.UNDERLINE)
- .withStyle(p_392495_ -> p_392495_.withClickEvent(new ClickEvent.OpenFile(file2.getAbsoluteFile())));
+ .withStyle(p_392495_ -> p_392495_.withClickEvent(new ClickEvent.OpenFile(target.getAbsoluteFile())));
p_92301_.accept(Component.translatable("screenshot.success", component));
+ }
} catch (Throwable throwable1) {
if (p_406180_ != null) {
try {

View file

@ -10,7 +10,7 @@
private final Map<Block, Set<Property<?>>> coloringStates = Maps.newHashMap();
public static BlockColors createDefault() {
@@ -95,11 +_,12 @@
@@ -102,11 +_,12 @@
}, Blocks.MELON_STEM, Blocks.PUMPKIN_STEM);
blockcolors.addColoringState(StemBlock.AGE, Blocks.MELON_STEM, Blocks.PUMPKIN_STEM);
blockcolors.register((p_92596_, p_92597_, p_92598_, p_92599_) -> p_92597_ != null && p_92598_ != null ? -14647248 : -9321636, Blocks.LILY_PAD);
@ -24,7 +24,7 @@
if (blockcolor != null) {
return blockcolor.getColor(p_92583_, null, null, 0);
} else {
@@ -109,13 +_,15 @@
@@ -116,13 +_,15 @@
}
public int getColor(BlockState p_92578_, @Nullable BlockAndTintGetter p_92579_, @Nullable BlockPos p_92580_, int p_92581_) {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/data/Main.java
+++ b/net/minecraft/client/data/Main.java
@@ -30,16 +_,31 @@
@@ -30,16 +_,30 @@
OptionSpec<Void> optionspec1 = optionparser.accepts("client", "Include client generators");
OptionSpec<Void> optionspec2 = optionparser.accepts("all", "Include all generators");
OptionSpec<String> optionspec3 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
@ -30,7 +30,6 @@
+ }
+ net.neoforged.neoforge.data.loading.DatagenModLoader.begin(mods, path, java.util.List.of(), existingPacks, false, false, validate, isFlat, optionset.valueOf(assetIndex), optionset.valueOf(assetsDir), () -> {
+ ClientBootstrap.bootstrap();
+ net.neoforged.neoforge.client.ClientHooks.registerSpriteSourceTypes();
+ net.neoforged.neoforge.client.entity.animation.json.AnimationTypeManager.init();
+ }, net.neoforged.neoforge.data.event.GatherDataEvent.Client::new, datagenerator);
} else {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/data/models/BlockModelGenerators.java
+++ b/net/minecraft/client/data/models/BlockModelGenerators.java
@@ -5819,4 +_,16 @@
@@ -4463,4 +_,16 @@
return this;
}
}
@ -13,7 +13,7 @@
+ */
+ public BlockModelGenerators.BlockFamilyProvider familyWithExistingFullBlock(Block fullBlock) {
+ var provider = new BlockModelGenerators.BlockFamilyProvider(TextureMapping.cube(fullBlock));
+ provider.fullBlock = ModelLocationUtils.getModelLocation(fullBlock);
+ provider.fullBlock = BlockModelGenerators.plainModel(ModelLocationUtils.getModelLocation(fullBlock));
+ return provider;
+ }
}

View file

@ -11,7 +11,7 @@
private static void bootstrap(BiConsumer<ResourceKey<EquipmentAsset>, EquipmentClientInfo> p_387865_) {
p_387865_.accept(
EquipmentAssets.LEATHER,
@@ -91,14 +_,14 @@
@@ -105,14 +_,14 @@
}
public static EquipmentClientInfo onlyHumanoid(String p_388505_) {
@ -29,7 +29,7 @@
)
.build();
}
@@ -106,7 +_,7 @@
@@ -120,7 +_,7 @@
@Override
public CompletableFuture<?> run(CachedOutput p_387304_) {
Map<ResourceKey<EquipmentAsset>, EquipmentClientInfo> map = new HashMap<>();

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/data/models/ModelProvider.java
+++ b/net/minecraft/client/data/models/ModelProvider.java
@@ -34,20 +_,58 @@
@@ -36,20 +_,58 @@
private final PackOutput.PathProvider blockStatePathProvider;
private final PackOutput.PathProvider itemInfoPathProvider;
private final PackOutput.PathProvider modelPathProvider;
@ -63,7 +63,7 @@
modelprovider$blockstategeneratorcollector.validate();
modelprovider$iteminfocollector.finalizeAndValidate();
return CompletableFuture.allOf(
@@ -63,12 +_,22 @@
@@ -61,12 +_,22 @@
@Override
public String getName() {
@ -72,8 +72,8 @@
}
@OnlyIn(Dist.CLIENT)
static class BlockStateGeneratorCollector implements Consumer<BlockStateGenerator> {
private final Map<Block, BlockStateGenerator> generators = new HashMap<>();
static class BlockStateGeneratorCollector implements Consumer<BlockModelDefinitionGenerator> {
private final Map<Block, BlockModelDefinitionGenerator> generators = new HashMap<>();
+ private final Supplier<Stream<? extends Holder<Block>>> knownBlocks;
+
+ public BlockStateGeneratorCollector(Supplier<Stream<? extends Holder<Block>>> knownBlocks) {
@ -85,9 +85,9 @@
+ this(BuiltInRegistries.BLOCK::listElements);
+ }
public void accept(BlockStateGenerator p_388748_) {
Block block = p_388748_.getBlock();
@@ -79,9 +_,9 @@
public void accept(BlockModelDefinitionGenerator p_405192_) {
Block block = p_405192_.block();
@@ -77,9 +_,9 @@
}
public void validate() {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/data/models/model/ModelTemplates.java
+++ b/net/minecraft/client/data/models/model/ModelTemplates.java
@@ -203,18 +_,18 @@
@@ -207,18 +_,18 @@
}
public static ModelTemplate create(String p_386521_, TextureSlot... p_388561_) {

View file

@ -18,7 +18,7 @@
@OnlyIn(Dist.CLIENT)
public static enum DisplayMode {
NORMAL,
@@ -403,7 +_,7 @@
@@ -402,7 +_,7 @@
p_381032_ - 1.0F, this.y + 9.0F, this.x, this.y - 1.0F, this.getUnderTextEffectDepth(), this.backgroundColor
);
bakedglyph = Font.this.getFontSet(Style.DEFAULT_FONT).whiteGlyph();
@ -27,7 +27,7 @@
bakedglyph.renderEffect(bakedglyph$effect, this.pose, vertexconsumer, this.packedLightCoords);
}
@@ -413,7 +_,7 @@
@@ -412,7 +_,7 @@
bakedglyph = Font.this.getFontSet(Style.DEFAULT_FONT).whiteGlyph();
}
@ -36,7 +36,7 @@
for (BakedGlyph.Effect bakedglyph$effect1 : this.effects) {
bakedglyph.renderEffect(bakedglyph$effect1, this.pose, vertexconsumer1, this.packedLightCoords);
@@ -447,7 +_,7 @@
@@ -446,7 +_,7 @@
void renderCharacters() {
for (BakedGlyph.GlyphInstance bakedglyph$glyphinstance : this.glyphInstances) {
BakedGlyph bakedglyph = bakedglyph$glyphinstance.glyph();

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/Gui.java
+++ b/net/minecraft/client/gui/Gui.java
@@ -71,6 +_,9 @@
@@ -72,6 +_,9 @@
import net.neoforged.api.distmarker.OnlyIn;
import org.joml.Matrix4fStack;
@ -10,7 +10,7 @@
@OnlyIn(Dist.CLIENT)
public class Gui {
private static final ResourceLocation CROSSHAIR_SPRITE = ResourceLocation.withDefaultNamespace("hud/crosshair");
@@ -175,9 +_,21 @@
@@ -176,9 +_,21 @@
private int lastBubblePopSoundPlayed;
private float autosaveIndicatorValue;
private float lastAutosaveIndicatorValue;
@ -32,7 +32,7 @@
public Gui(Minecraft p_232355_) {
this.minecraft = p_232355_;
this.debugOverlay = new DebugScreenOverlay(p_232355_);
@@ -187,27 +_,40 @@
@@ -188,27 +_,40 @@
this.bossOverlay = new BossHealthOverlay(p_232355_);
this.subtitleOverlay = new SubtitleOverlay(p_232355_);
this.resetTitleTimes();
@ -90,7 +90,7 @@
}
public void resetTitleTimes() {
@@ -217,7 +_,9 @@
@@ -218,7 +_,9 @@
}
public void render(GuiGraphics p_282884_, DeltaTracker p_348630_) {
@ -101,9 +101,9 @@
}
private void renderCameraOverlays(GuiGraphics p_316735_, DeltaTracker p_348538_) {
@@ -236,8 +_,12 @@
@@ -238,8 +_,12 @@
for (EquipmentSlot equipmentslot : EquipmentSlot.values()) {
ItemStack itemstack = this.minecraft.player.getItemBySlot(equipmentslot);
ItemStack itemstack = localplayer.getItemBySlot(equipmentslot);
Equippable equippable = itemstack.get(DataComponents.EQUIPPABLE);
- if (equippable != null && equippable.slot() == equipmentslot && equippable.cameraOverlay().isPresent()) {
- this.renderTextureOverlay(p_316735_, equippable.cameraOverlay().get().withPath(p_380782_ -> "textures/" + p_380782_ + ".png"), 1.0F);
@ -130,7 +130,7 @@
int j;
if (this.animateOverlayMessageColor) {
j = Mth.hsvToArgb(f / 50.0F, 0.7F, 0.6F, i);
@@ -350,9 +_,19 @@
@@ -350,9 +_,18 @@
private void renderChat(GuiGraphics p_316307_, DeltaTracker p_348631_) {
if (!this.chat.isChatFocused()) {
Window window = this.minecraft.getWindow();
@ -139,12 +139,11 @@
+ var event = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(
+ new net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent.Chat(window, p_316307_, p_348631_, 0, p_316307_.guiHeight() - chatBottomMargin)
+ );
+
+ // The event is given the absolute Y position; account for chat component's own offsetting here
+ p_316307_.pose().pushPose();
+ p_316307_.pose().translate(event.getPosX(), (event.getPosY() - p_316307_.guiHeight() + chatBottomMargin) / this.chat.getScale(), 0.0F);
int i = Mth.floor(this.minecraft.mouseHandler.xpos() * (double)window.getGuiScaledWidth() / (double)window.getScreenWidth());
int j = Mth.floor(this.minecraft.mouseHandler.ypos() * (double)window.getGuiScaledHeight() / (double)window.getScreenHeight());
int i = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window));
int j = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window));
this.chat.render(p_316307_, this.tickCount, i, j, false);
+ p_316307_.pose().popPose();
}
@ -230,7 +229,7 @@
this.spectatorGui.renderTooltip(p_316628_);
}
}
@@ -632,18 +_,23 @@
@@ -637,18 +_,23 @@
}
private void renderSelectedItemName(GuiGraphics p_283501_) {
@ -257,7 +256,7 @@
if (!this.minecraft.gameMode.canHurtPlayer()) {
k += 14;
}
@@ -654,7 +_,13 @@
@@ -659,7 +_,13 @@
}
if (l > 0) {
@ -272,7 +271,7 @@
}
}
@@ -662,7 +_,7 @@
@@ -667,7 +_,7 @@
}
private void renderDemoOverlay(GuiGraphics p_281825_, DeltaTracker p_348679_) {
@ -281,8 +280,8 @@
Profiler.get().push("demo");
Component component;
if (this.minecraft.level.getGameTime() >= 120500L) {
@@ -774,7 +_,15 @@
return (int)Math.ceil((double)p_93013_ / 10.0);
@@ -779,7 +_,15 @@
return (int)Math.ceil(p_93013_ / 10.0);
}
+ @Deprecated // Neo: Split up into different layers
@ -297,15 +296,15 @@
Player player = this.getCameraPlayer();
if (player != null) {
int i = Mth.ceil(player.getHealth());
@@ -798,31 +_,59 @@
this.random.setSeed((long)(this.tickCount * 312871));
@@ -803,31 +_,59 @@
this.random.setSeed(this.tickCount * 312871);
int l = p_283143_.guiWidth() / 2 - 91;
int i1 = p_283143_.guiWidth() / 2 + 91;
- int j1 = p_283143_.guiHeight() - 39;
+ int j1 = p_283143_.guiHeight() - leftHeight;
float f = Math.max((float)player.getAttributeValue(Attributes.MAX_HEALTH), (float)Math.max(k, i));
int k1 = Mth.ceil(player.getAbsorptionAmount());
int l1 = Mth.ceil((f + (float)k1) / 2.0F / 10.0F);
int l1 = Mth.ceil((f + k1) / 2.0F / 10.0F);
int i2 = Math.max(10 - (l1 - 2), 3);
int j2 = j1 - 10;
+ leftHeight += (l1 - 1) * i2 + 10;
@ -366,7 +365,7 @@
Profiler.get().pop();
}
}
@@ -936,6 +_,8 @@
@@ -941,6 +_,8 @@
p_381066_.blitSprite(RenderType::guiTextured, AIR_EMPTY_SPRITE, k1, p_381100_ + l1, 9, 9);
}
}
@ -375,16 +374,16 @@
}
}
@@ -1003,7 +_,7 @@
@@ -1008,7 +_,7 @@
if (i != 0) {
int j = (int)Math.ceil((double)livingentity.getHealth());
int j = (int)Math.ceil(livingentity.getHealth());
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;
@@ -1024,6 +_,7 @@
@@ -1029,6 +_,7 @@
}
i1 -= 10;
@ -392,7 +391,7 @@
}
}
}
@@ -1190,7 +_,7 @@
@@ -1195,7 +_,7 @@
this.toolHighlightTimer = 0;
} else if (this.lastToolHighlight.isEmpty()
|| !itemstack.is(this.lastToolHighlight.getItem())
@ -401,7 +400,7 @@
this.toolHighlightTimer = (int)(40.0 * this.minecraft.options.notificationDisplayTime().get());
} else if (this.toolHighlightTimer > 0) {
this.toolHighlightTimer--;
@@ -1321,6 +_,15 @@
@@ -1326,6 +_,15 @@
}
}
@ -417,7 +416,7 @@
@OnlyIn(Dist.CLIENT)
public static enum HeartType implements net.neoforged.fml.common.asm.enumextension.IExtensibleEnum {
CONTAINER(
@@ -1438,8 +_,13 @@
@@ -1443,8 +_,13 @@
} else {
gui$hearttype = NORMAL;
}

View file

@ -18,7 +18,7 @@
return true;
}
}
@@ -248,6 +_,19 @@
@@ -243,6 +_,19 @@
@Override
public void setFocused(boolean p_93693_) {
this.focused = p_93693_;

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/components/DebugScreenOverlay.java
+++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java
@@ -141,8 +_,14 @@
@@ -185,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);
@ -17,7 +17,7 @@
this.profilerPieChart.setBottomOffset(10);
if (this.renderFpsCharts) {
int i = p_281427_.guiWidth();
@@ -175,7 +_,11 @@
@@ -219,7 +_,11 @@
profilerfiller.pop();
}
@ -30,7 +30,7 @@
List<String> list = this.getGameInformation();
list.add("");
boolean flag = this.minecraft.getSingleplayerServer() != null;
@@ -190,11 +_,25 @@
@@ -234,11 +_,25 @@
+ (this.renderNetworkCharts ? " visible" : " hidden")
);
list.add("For help: press F3 + Q");
@ -57,9 +57,9 @@
this.renderLines(p_281261_, list, false);
}
@@ -523,6 +_,13 @@
GlUtil.getRenderer(),
GlUtil.getOpenGLVersion()
@@ -568,6 +_,13 @@
gpudevice.getRenderer(),
String.format(Locale.ROOT, "%s %s", gpudevice.getBackendName(), gpudevice.getVersion())
);
+ if (this.minecraft.isDemo()) {
+ if (this.minecraft.level.getGameTime() >= 120500L) {
@ -71,7 +71,7 @@
if (this.minecraft.showOnlyReducedInfo()) {
return list;
} else {
@@ -559,6 +_,7 @@
@@ -604,6 +_,7 @@
list.add("");
list.add(ChatFormatting.UNDERLINE + "Targeted Entity");
list.add(String.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType())));

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/components/toasts/ToastManager.java
+++ b/net/minecraft/client/gui/components/toasts/ToastManager.java
@@ -107,6 +_,7 @@
@@ -127,6 +_,7 @@
}
public void addToast(Toast p_362712_) {

View file

@ -8,4 +8,4 @@
+ net.neoforged.neoforge.network.DualStackUtils.logInitialPreferences();
p_251955_.execute(
() -> p_251955_.setScreen(
new DisconnectedScreen(ConnectScreen.this.parent, ConnectScreen.this.connectFailedTitle, ConnectScreen.UNKNOWN_HOST_MESSAGE)
new DisconnectedScreen(ConnectScreen.this.parent, ConnectScreen.this.connectFailedTitle, ConnectScreen.UNKNOWN_HOST_MESSAGE)

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/LoadingOverlay.java
+++ b/net/minecraft/client/gui/screens/LoadingOverlay.java
@@ -122,6 +_,7 @@
@@ -118,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());
@@ -129,7 +_,6 @@
@@ -125,7 +_,6 @@
this.onFinish.accept(Optional.of(throwable));
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/Screen.java
+++ b/net/minecraft/client/gui/screens/Screen.java
@@ -115,6 +_,7 @@
@@ -112,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_);
@@ -200,7 +_,7 @@
@@ -197,7 +_,7 @@
}
public void onClose() {
@ -17,7 +17,7 @@
}
protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(T p_169406_) {
@@ -241,7 +_,7 @@
@@ -238,7 +_,7 @@
return p_282833_.getTooltipLines(
Item.TooltipContext.of(p_281881_.level),
p_281881_.player,
@ -58,7 +58,7 @@
}
protected void renderBlurredBackground() {
@@ -458,6 +_,10 @@
@@ -457,6 +_,10 @@
public void onFilesDrop(List<Path> 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_;
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/advancements/AdvancementTab.java
+++ b/net/minecraft/client/gui/screens/advancements/AdvancementTab.java
@@ -38,6 +_,7 @@
@@ -39,6 +_,7 @@
private int maxY = Integer.MIN_VALUE;
private float fade;
private boolean centered;
@ -8,7 +8,7 @@
public AdvancementTab(
Minecraft p_97145_, AdvancementsScreen p_97146_, AdvancementTabType p_97147_, int p_97148_, AdvancementNode p_300867_, DisplayInfo p_97150_
@@ -54,6 +_,15 @@
@@ -55,6 +_,15 @@
this.addWidget(this.root, p_300867_.holder());
}
@ -24,7 +24,7 @@
public AdvancementTabType getType() {
return this.type;
}
@@ -147,8 +_,8 @@
@@ -148,8 +_,8 @@
return null;
} else {
for (AdvancementTabType advancementtabtype : AdvancementTabType.values()) {

View file

@ -63,7 +63,7 @@
if (this.tabs.size() > 1) {
for (AdvancementTab advancementtab : this.tabs.values()) {
- if (advancementtab.isMouseOver(p_281519_, p_283371_, (double)p_283556_, (double)p_282458_)) {
- if (advancementtab.isMouseOver(p_281519_, p_283371_, p_283556_, p_282458_)) {
+ if (advancementtab.getPage() == tabPage && advancementtab.isMouseOver(p_281519_, p_283371_, (double)p_283556_, (double)p_282458_)) {
p_282784_.renderTooltip(this.font, advancementtab.getTitle(), p_283556_, p_282458_);
}

View file

@ -69,7 +69,7 @@
if (super.mouseClicked(p_97748_, p_97749_, p_97750_)) {
return true;
} else {
- boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_97750_) && this.minecraft.gameMode.hasInfiniteItems();
- boolean flag = this.minecraft.options.keyPickItem.matchesMouse(p_97750_) && this.minecraft.player.hasInfiniteMaterials();
+ InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97750_);
+ boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey);
Slot slot = this.getHoveredSlot(p_97748_, p_97749_);
@ -101,7 +101,7 @@
this.quickCraftingType = 2;
}
}
@@ -469,10 +_,13 @@
@@ -466,10 +_,13 @@
@Override
public boolean mouseReleased(double p_97812_, double p_97813_, int p_97814_) {
@ -115,7 +115,7 @@
int k = -1;
if (slot != null) {
k = slot.index;
@@ -489,7 +_,7 @@
@@ -486,7 +_,7 @@
if (slot2 != null
&& slot2.mayPickup(this.minecraft.player)
&& slot2.hasItem()
@ -124,7 +124,7 @@
&& AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) {
this.slotClicked(slot2, slot2.index, p_97814_, ClickType.QUICK_MOVE);
}
@@ -553,7 +_,7 @@
@@ -550,7 +_,7 @@
this.slotClicked(null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT);
} else if (!this.menu.getCarried().isEmpty()) {
@ -133,7 +133,7 @@
this.slotClicked(slot, k, p_97814_, ClickType.CLONE);
} else {
boolean flag1 = k != -999
@@ -633,34 +_,39 @@
@@ -627,34 +_,39 @@
@Override
public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) {
@ -180,7 +180,7 @@
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, i, ClickType.SWAP);
return true;
}
@@ -698,6 +_,18 @@
@@ -692,6 +_,18 @@
@Override
public T getMenu() {
return this.menu;

View file

@ -33,9 +33,9 @@
this.refreshSearchResults();
} else {
this.menu.items.addAll(p_261591_);
@@ -336,6 +_,34 @@
@@ -332,6 +_,34 @@
protected void init() {
if (this.minecraft.gameMode.hasInfiniteItems()) {
if (this.minecraft.player.hasInfiniteMaterials()) {
super.init();
+ this.pages.clear();
+ int tabIndex = 0;
@ -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);
@@ -382,7 +_,7 @@
@@ -378,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();
@@ -401,7 +_,7 @@
@@ -397,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());
@@ -437,6 +_,7 @@
@@ -433,6 +_,7 @@
}
private void refreshSearchResults() {
@ -94,7 +94,7 @@
this.menu.items.clear();
this.visibleTags.clear();
String s = this.searchBox.getValue();
@@ -449,10 +_,10 @@
@@ -445,10 +_,10 @@
SearchTree<ItemStack> searchtree;
if (s.startsWith("#")) {
s = s.substring(1);
@ -107,27 +107,26 @@
}
this.menu.items.addAll(searchtree.search(s.toLowerCase(Locale.ROOT)));
@@ -480,7 +_,8 @@
@@ -476,7 +_,7 @@
@Override
protected void renderLabels(GuiGraphics p_283168_, int p_281774_, int p_281466_) {
if (selectedTab.showTitle()) {
- p_283168_.drawString(this.font, selectedTab.getDisplayName(), 8, 6, 4210752, false);
+ com.mojang.blaze3d.systems.RenderSystem.disableBlend();
+ p_283168_.drawString(this.font, selectedTab.getDisplayName(), 8, 6, selectedTab.getLabelColor(), false);
}
}
@@ -490,7 +_,7 @@
double d0 = p_98531_ - (double)this.leftPos;
double d1 = p_98532_ - (double)this.topPos;
@@ -486,7 +_,7 @@
double d0 = p_98531_ - this.leftPos;
double d1 = p_98532_ - this.topPos;
- for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) {
+ for(CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) {
if (this.checkTabClicked(creativemodetab, d0, d1)) {
return true;
}
@@ -512,7 +_,7 @@
double d1 = p_98623_ - (double)this.topPos;
@@ -508,7 +_,7 @@
double d1 = p_98623_ - this.topPos;
this.scrolling = false;
- for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) {
@ -135,7 +134,7 @@
if (this.checkTabClicked(creativemodetab, d0, d1)) {
this.selectTab(creativemodetab);
return true;
@@ -530,6 +_,7 @@
@@ -526,6 +_,7 @@
private void selectTab(CreativeModeTab p_98561_) {
CreativeModeTab creativemodetab = selectedTab;
selectedTab = p_98561_;
@ -143,7 +142,7 @@
this.quickCraftSlots.clear();
this.menu.items.clear();
this.clearDraggingState();
@@ -606,13 +_,15 @@
@@ -602,13 +_,15 @@
this.originalSlots = null;
}
@ -160,7 +159,7 @@
this.refreshSearchResults();
} else {
@@ -678,18 +_,27 @@
@@ -671,18 +_,27 @@
super.render(p_283000_, p_281317_, p_282770_, p_281295_);
this.effects.render(p_283000_, p_281317_, p_282770_, p_281295_);
@ -172,7 +171,7 @@
-
if (this.destroyItemSlot != null
&& selectedTab.getType() == CreativeModeTab.Type.INVENTORY
&& this.isHovering(this.destroyItemSlot.x, this.destroyItemSlot.y, 16, 16, (double)p_281317_, (double)p_282770_)) {
&& this.isHovering(this.destroyItemSlot.x, this.destroyItemSlot.y, 16, 16, p_281317_, p_282770_)) {
p_283000_.renderTooltip(this.font, TRASH_SLOT_TOOLTIP, p_281317_, p_282770_);
}
@ -194,7 +193,7 @@
this.renderTooltip(p_283000_, p_281317_, p_282770_);
}
@@ -702,10 +_,10 @@
@@ -695,10 +_,10 @@
public List<Component> getTooltipFromContainerItem(ItemStack p_281769_) {
boolean flag = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot;
boolean flag1 = selectedTab.getType() == CreativeModeTab.Type.CATEGORY;
@ -204,10 +203,10 @@
TooltipFlag tooltipflag = flag ? tooltipflag$default.asCreative() : tooltipflag$default;
- List<Component> list = p_281769_.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipflag);
+ List<Component> list = p_281769_.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, net.neoforged.neoforge.client.ClientTooltipFlag.of(tooltipflag));
if (flag1 && flag) {
if (list.isEmpty()) {
return list;
} else {
@@ -721,7 +_,7 @@
} else if (flag1 && flag) {
@@ -716,7 +_,7 @@
int i = 1;
for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) {
@ -216,7 +215,7 @@
list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE));
}
}
@@ -732,7 +_,7 @@
@@ -727,7 +_,7 @@
@Override
protected void renderBg(GuiGraphics p_282663_, float p_282504_, int p_282089_, int p_282249_) {
@ -225,20 +224,20 @@
if (creativemodetab != selectedTab) {
this.renderTabButton(p_282663_, creativemodetab);
}
@@ -746,10 +_,11 @@
@@ -741,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(RenderType::guiTextured, resourcelocation, j, k + (int)((float)(i - k - 17) * this.scrollOffs), 12, 15);
p_282663_.blitSprite(RenderType::guiTextured, resourcelocation, j, k + (int)((i - k - 17) * this.scrollOffs), 12, 15);
}
+ if (currentPage.getVisibleTabs().contains(selectedTab)) //Forge: only display tab selection when the selected tab is on the current page
this.renderTabButton(p_282663_, selectedTab);
if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) {
InventoryScreen.renderEntityInInventoryFollowsMouse(
@@ -768,7 +_,7 @@
@@ -754,7 +_,7 @@
}
private int getTabX(CreativeModeTab p_260136_) {
@ -247,7 +246,7 @@
int j = 27;
int k = 27 * i;
if (p_260136_.isAlignedRight()) {
@@ -780,7 +_,7 @@
@@ -766,7 +_,7 @@
private int getTabY(CreativeModeTab p_260181_) {
int i = 0;
@ -256,7 +255,7 @@
i -= 32;
} else {
i += this.imageHeight;
@@ -808,8 +_,8 @@
@@ -794,8 +_,8 @@
protected void renderTabButton(GuiGraphics p_283590_, CreativeModeTab p_283489_) {
boolean flag = p_283489_ == selectedTab;
@ -267,7 +266,7 @@
int j = this.leftPos + this.getTabX(p_283489_);
int k = this.topPos - (flag1 ? 28 : -(this.imageHeight - 4));
ResourceLocation[] aresourcelocation;
@@ -819,6 +_,7 @@
@@ -805,6 +_,7 @@
aresourcelocation = flag ? SELECTED_BOTTOM_TABS : UNSELECTED_BOTTOM_TABS;
}
@ -275,7 +274,7 @@
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);
@@ -860,6 +_,14 @@
@@ -846,6 +_,14 @@
}
}
@ -290,7 +289,7 @@
@OnlyIn(Dist.CLIENT)
static class CustomCreativeSlot extends Slot {
public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) {
@@ -1041,6 +_,22 @@
@@ -1027,6 +_,22 @@
@Override
public boolean mayPickup(Player p_98665_) {
return this.target.mayPickup(p_98665_);

View file

@ -4,7 +4,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.hasInfiniteMaterials()) {
+ 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
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);
@ -17,8 +17,8 @@
+ if (true) {
int l = this.menu.levelClue[j];
int i1 = j + 1;
- if (this.isHovering(60, 14 + 19 * j, 108, 17, (double)p_282491_, (double)p_281953_) && k > 0 && l >= 0 && optional != null) {
+ if (this.isHovering(60, 14 + 19 * j, 108, 17, (double)p_282491_, (double)p_281953_) && k > 0) {
- if (this.isHovering(60, 14 + 19 * j, 108, 17, p_282491_, p_281953_) && k > 0 && l >= 0 && optional != null) {
+ if (this.isHovering(60, 14 + 19 * j, 108, 17, p_282491_, p_281953_) && k > 0) {
List<Component> list = Lists.newArrayList();
- list.add(Component.translatable("container.enchant.clue", Enchantment.getFullname(optional.get(), l)).withStyle(ChatFormatting.WHITE));
- if (!flag) {

View file

@ -1,31 +1,47 @@
--- a/net/minecraft/client/gui/screens/inventory/InventoryScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/InventoryScreen.java
@@ -118,9 +_,29 @@
) {
float f = (float)(p_275688_ + p_275535_) / 2.0F;
float f1 = (float)(p_275245_ + p_294406_) / 2.0F;
- p_282802_.enableScissor(p_275688_, p_275245_, p_275535_, p_294406_);
float f2 = (float)Math.atan((double)((f - p_275546_) / 40.0F));
float f3 = (float)Math.atan((double)((f1 - p_295352_) / 40.0F));
@@ -105,6 +_,26 @@
}
public static void renderEntityInInventoryFollowsMouse(
+ GuiGraphics p_282802_,
+ int p_275688_,
+ int p_275245_,
+ int p_275535_,
+ int p_294406_,
+ int p_294663_,
+ float p_275604_,
+ float p_275546_,
+ float p_295352_,
+ LivingEntity p_275689_
+ ) {
+ float f = (p_275688_ + p_275535_) / 2.0F;
+ float f1 = (p_275245_ + p_294406_) / 2.0F;
+ float f2 = (float)Math.atan((f - p_275546_) / 40.0F);
+ float f3 = (float)Math.atan((f1 - p_295352_) / 40.0F);
+ // Forge: Allow passing in direct angle components instead of mouse position
+ renderEntityInInventoryFollowsAngle(p_282802_, p_275688_, p_275245_, p_275535_, p_294406_, p_294663_, p_275604_, f2, f3, p_275689_);
+ }
+
+ public static void renderEntityInInventoryFollowsAngle(
+ GuiGraphics p_282802_,
+ int p_275688_,
+ int p_275245_,
+ int p_275535_,
+ int p_294406_,
+ int p_294663_,
+ float p_275604_,
GuiGraphics p_282802_,
int p_275688_,
int p_275245_,
@@ -112,15 +_,15 @@
int p_294406_,
int p_294663_,
float p_275604_,
- float p_275546_,
- float p_295352_,
+ float angleXComponent,
+ float angleYComponent,
+ LivingEntity p_275689_
+ ) {
+ float f = (float)(p_275688_ + p_275535_) / 2.0F;
+ float f1 = (float)(p_275245_ + p_294406_) / 2.0F;
+ p_282802_.enableScissor(p_275688_, p_275245_, p_275535_, p_294406_);
LivingEntity p_275689_
) {
float f = (p_275688_ + p_275535_) / 2.0F;
float f1 = (p_275245_ + p_294406_) / 2.0F;
p_282802_.enableScissor(p_275688_, p_275245_, p_275535_, p_294406_);
- float f2 = (float)Math.atan((f - p_275546_) / 40.0F);
- float f3 = (float)Math.atan((f1 - p_295352_) / 40.0F);
+ float f2 = angleXComponent;
+ float f3 = angleYComponent;
Quaternionf quaternionf = new Quaternionf().rotateZ((float) Math.PI);

View file

@ -1,9 +1,9 @@
--- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java
+++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java
@@ -25,7 +_,11 @@
@@ -22,7 +_,11 @@
case ClientActivePlayersTooltip.ActivePlayersTooltip clientactiveplayerstooltip$activeplayerstooltip -> new ClientActivePlayersTooltip(
clientactiveplayerstooltip$activeplayerstooltip
);
clientactiveplayerstooltip$activeplayerstooltip
);
- default -> throw new IllegalArgumentException("Unknown TooltipComponent");
+ default -> {
+ ClientTooltipComponent result = net.neoforged.neoforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(p_169951_);

View file

@ -5,10 +5,10 @@
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<WorldCreationContext> completablefuture = WorldLoader.load(
worldloader$initconfig,
@@ -306,6 +_,10 @@
WorldDataConfiguration worlddataconfiguration = SharedConstants.IS_RUNNING_IN_IDE
? new WorldDataConfiguration(new DataPackConfig(List.of("vanilla", "tests"), List.of()), FeatureFlags.DEFAULT_FLAGS)
: WorldDataConfiguration.DEFAULT;
@@ -309,6 +_,10 @@
SystemToast.onPackCopyFailure(this.minecraft, s);
return false;
} else {
@ -19,7 +19,7 @@
this.minecraft
.createWorldOpenFlows()
.createLevelFromExistingSettings(optional.get(), worldcreationcontext.dataPackResources(), p_249152_, p_374211_);
@@ -480,7 +_,7 @@
@@ -483,7 +_,7 @@
if (p_269627_) {
p_270552_.accept(this.uiState.getSettings().dataConfiguration());
} else {
@ -28,7 +28,7 @@
}
},
Component.translatable("dataPack.validation.failed"),
@@ -594,6 +_,7 @@
@@ -597,6 +_,7 @@
if (path != null) {
if (this.tempDataPackRepository == null) {
this.tempDataPackRepository = ServerPacksSource.createPackRepository(path, this.packValidator);

View file

@ -10,7 +10,7 @@
abstractwidget.render(p_387127_, p_388038_, p_386932_, p_388026_);
}
@@ -188,6 +_,44 @@
this.setScrollAmount(this.scrollAmount() + (double)j + 14.0);
this.setScrollAmount(this.scrollAmount() + j + 14.0);
}
}
+ }

View file

@ -1,7 +1,7 @@
--- a/net/minecraft/client/model/geom/LayerDefinitions.java
+++ b/net/minecraft/client/model/geom/LayerDefinitions.java
@@ -468,6 +_,7 @@
builder.put(ModelLayers.createHangingSignModelName(p_382521_, hangingsignrenderer$attachmenttype), layerdefinition55);
@@ -501,6 +_,7 @@
builder.put(ModelLayers.createHangingSignModelName(p_382521_, hangingsignrenderer$attachmenttype), layerdefinition60);
}
});
+ net.neoforged.neoforge.client.ClientHooks.loadLayerDefinitions(builder);

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/model/geom/ModelLayers.java
+++ b/net/minecraft/client/model/geom/ModelLayers.java
@@ -308,15 +_,18 @@
@@ -330,15 +_,18 @@
}
public static ModelLayerLocation createStandingSignModelName(WoodType p_171292_) {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientChunkCache.java
+++ b/net/minecraft/client/multiplayer/ClientChunkCache.java
@@ -65,6 +_,7 @@
@@ -66,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)) {
@ -8,7 +8,7 @@
this.storage.drop(i, levelchunk);
}
}
@@ -126,6 +_,7 @@
@@ -127,6 +_,7 @@
}
this.level.onChunkLoaded(chunkpos);

View file

@ -65,7 +65,7 @@
@@ -409,5 +_,10 @@
@OnlyIn(Dist.CLIENT)
static record PendingRequest(UUID id, URL url, String hash) {
record PendingRequest(UUID id, URL url, String hash) {
}
+ }
+

View file

@ -31,7 +31,7 @@
new ClientPacketListener(
this.minecraft,
this.connection,
@@ -136,12 +_,20 @@
@@ -136,14 +_,22 @@
this.serverCookies,
this.chatState,
this.customReportDetails,
@ -49,12 +49,14 @@
+ }
+ net.neoforged.neoforge.network.registration.NetworkRegistry.onConfigurationFinished(this);
this.connection.send(ServerboundFinishConfigurationPacket.INSTANCE);
- this.connection.setupOutboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(registryaccess$frozen)));
+ this.connection.setupOutboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(registryaccess$frozen, this.connectionType)));
}
@Override
@@ -153,5 +_,51 @@
this.connection
.setupOutboundProtocol(
- GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(registryaccess$frozen), new GameProtocols.Context() {
+ GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(registryaccess$frozen, this.connectionType), new GameProtocols.Context() {
@Override
public boolean hasInfiniteMaterials() {
return true;
@@ -161,5 +_,51 @@
public void onDisconnect(DisconnectionDetails p_351005_) {
super.onDisconnect(p_351005_);
this.minecraft.clearDownloadedResourcePacks();

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientLevel.java
+++ b/net/minecraft/client/multiplayer/ClientLevel.java
@@ -115,7 +_,7 @@
@@ -117,7 +_,7 @@
private final TickRateManager tickRateManager;
private final Minecraft minecraft = Minecraft.getInstance();
final List<AbstractClientPlayer> players = Lists.newArrayList();
@ -9,15 +9,15 @@
private final Map<MapId, MapItemSavedData> mapData = Maps.newHashMap();
private static final int CLOUD_COLOR = -1;
private int skyFlashTime;
@@ -131,6 +_,7 @@
p_194170_.put(
@@ -137,6 +_,7 @@
p_406186_.put(
BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache(p_194168_ -> this.calculateBlockTint(p_194168_, BiomeColors.WATER_COLOR_RESOLVER))
);
+ net.neoforged.neoforge.client.ColorResolverManager.registerBlockTintCaches(ClientLevel.this, p_194170_);
+ net.neoforged.neoforge.client.ColorResolverManager.registerBlockTintCaches(ClientLevel.this, p_406186_);
}
);
private final ClientChunkCache chunkSource;
@@ -140,6 +_,7 @@
@@ -146,6 +_,7 @@
private final int seaLevel;
private boolean tickDayTime;
private static final Set<Item> MARKER_PARTICLE_ITEMS = Set.of(Items.BARRIER, Items.LIGHT);
@ -25,7 +25,7 @@
public void handleBlockChangedAck(int p_233652_) {
this.blockStatePredictionHandler.endPredictionsUpTo(p_233652_, this);
@@ -169,10 +_,15 @@
@@ -175,10 +_,15 @@
@Override
public boolean setBlock(BlockPos p_233643_, BlockState p_233644_, int p_233645_, int p_233646_) {
if (this.blockStatePredictionHandler.isPredicting()) {
@ -41,7 +41,7 @@
}
return flag;
@@ -206,6 +_,7 @@
@@ -212,6 +_,7 @@
this.serverSimulationDistance = p_363776_;
this.updateSkyBrightness();
this.prepareWeather();
@ -49,7 +49,7 @@
}
public void queueLightUpdate(Runnable p_194172_) {
@@ -249,7 +_,7 @@
@@ -255,7 +_,7 @@
private void tickTime() {
this.clientLevelData.setGameTime(this.clientLevelData.getGameTime() + 1L);
if (this.tickDayTime) {
@ -58,7 +58,7 @@
}
}
@@ -288,7 +_,11 @@
@@ -294,7 +_,11 @@
p_104640_.setOldPosAndRot();
p_104640_.tickCount++;
Profiler.get().push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(p_104640_.getType()).toString());
@ -71,7 +71,7 @@
Profiler.get().pop();
for (Entity entity : p_104640_.getPassengers()) {
@@ -339,8 +_,10 @@
@@ -345,8 +_,10 @@
}
public void addEntity(Entity p_104741_) {
@ -82,7 +82,7 @@
}
public void removeEntity(int p_171643_, Entity.RemovalReason p_171644_) {
@@ -511,6 +_,13 @@
@@ -523,6 +_,13 @@
float p_263349_,
long p_263408_
) {
@ -93,23 +93,23 @@
+ p_263416_ = event.getNewVolume();
+ p_263349_ = event.getNewPitch();
+
if (p_263381_ == this.minecraft.player) {
if (p_393665_ == this.minecraft.player) {
this.playSound(p_263372_, p_263404_, p_263365_, p_263335_.value(), p_263417_, p_263416_, p_263349_, false, p_263408_);
}
@@ -520,6 +_,12 @@
@@ -532,6 +_,12 @@
public void playSeededSound(
@Nullable Player p_263514_, Entity p_263536_, Holder<SoundEvent> p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_
@Nullable Entity p_263536_, Entity p_394209_, Holder<SoundEvent> p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_
) {
+ net.neoforged.neoforge.event.PlayLevelSoundEvent.AtEntity event = net.neoforged.neoforge.event.EventHooks.onPlaySoundAtEntity(p_263536_, p_263518_, p_263487_, p_263538_, p_263524_);
+ net.neoforged.neoforge.event.PlayLevelSoundEvent.AtEntity event = net.neoforged.neoforge.event.EventHooks.onPlaySoundAtEntity(p_394209_, p_263518_, p_263487_, p_263538_, p_263524_);
+ if (event.isCanceled() || event.getSound() == null) return;
+ p_263518_ = event.getSound();
+ p_263487_ = event.getSource();
+ p_263538_ = event.getNewVolume();
+ p_263524_ = event.getNewPitch();
if (p_263514_ == this.minecraft.player) {
this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_263518_.value(), p_263487_, p_263538_, p_263524_, p_263536_, p_263509_));
if (p_263536_ == this.minecraft.player) {
this.minecraft.getSoundManager().play(new EntityBoundSoundInstance(p_263518_.value(), p_263487_, p_263538_, p_263524_, p_394209_, p_263509_));
}
@@ -731,7 +_,7 @@
@@ -743,7 +_,7 @@
return this.players;
}
@ -118,7 +118,7 @@
return this.dragonParts;
}
@@ -1056,6 +_,7 @@
@@ -1076,6 +_,7 @@
}
public void setDifficulty(Difficulty p_104852_) {
@ -126,7 +126,7 @@
this.difficulty = p_104852_;
}
@@ -1098,6 +_,9 @@
@@ -1117,6 +_,9 @@
ClientLevel.this.dragonParts.addAll(Arrays.asList(enderdragon.getSubEntities()));
break;
default:
@ -136,7 +136,7 @@
}
}
@@ -1112,10 +_,58 @@
@@ -1130,10 +_,58 @@
ClientLevel.this.dragonParts.removeAll(Arrays.asList(enderdragon.getSubEntities()));
break;
default:

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientPacketListener.java
+++ b/net/minecraft/client/multiplayer/ClientPacketListener.java
@@ -368,6 +_,7 @@
@@ -376,6 +_,7 @@
private final ChunkBatchSizeCalculator chunkBatchSizeCalculator = new ChunkBatchSizeCalculator();
private final PingDebugMonitor pingDebugMonitor;
private final DebugSampleSubscriber debugSampleSubscriber;
@ -8,7 +8,7 @@
@Nullable
private LevelLoadStatusManager levelLoadStatusManager;
private boolean serverEnforcesSecureChat;
@@ -389,7 +_,8 @@
@@ -402,7 +_,8 @@
p_253924_.gui.getChat().restoreState(p_295121_.chatState());
}
@ -18,7 +18,7 @@
this.fuelValues = FuelValues.vanillaBurnTimes(p_295121_.receivedRegistries(), this.enabledFeatures);
}
@@ -452,12 +_,13 @@
@@ -477,12 +_,13 @@
this.minecraft.debugRenderer.clear();
this.minecraft.player.resetPos();
@ -33,7 +33,7 @@
this.minecraft.player.setReducedDebugInfo(p_105030_.reducedDebugInfo());
this.minecraft.player.setShowDeathScreen(p_105030_.showDeathScreen());
this.minecraft.player.setDoLimitedCrafting(p_105030_.doLimitedCrafting());
@@ -902,7 +_,8 @@
@@ -909,7 +_,8 @@
this.serverCookies,
chatcomponent$state,
this.customReportDetails,
@ -43,7 +43,7 @@
)
)
);
@@ -1217,7 +_,7 @@
@@ -1231,7 +_,7 @@
localplayer1 = this.minecraft.gameMode.createPlayer(this.level, localplayer.getStats(), localplayer.getRecipeBook());
}
@ -52,7 +52,7 @@
localplayer1.setId(localplayer.getId());
this.minecraft.player = localplayer1;
if (flag) {
@@ -1245,6 +_,7 @@
@@ -1259,6 +_,7 @@
localplayer1.getAttributes().assignBaseValues(localplayer.getAttributes());
}
@ -60,19 +60,16 @@
this.level.addEntity(localplayer1);
localplayer1.input = new KeyboardInput(this.minecraft.options);
this.minecraft.gameMode.adjustPlayer(localplayer1);
@@ -1391,10 +_,7 @@
@@ -1405,7 +_,7 @@
PacketUtils.ensureRunningOnSameThread(p_104976_, this, this.minecraft);
BlockPos blockpos = p_104976_.getPos();
this.minecraft.level.getBlockEntity(blockpos, p_104976_.getType()).ifPresent(p_337415_ -> {
- CompoundTag compoundtag = p_104976_.getTag();
- if (!compoundtag.isEmpty()) {
- p_337415_.loadWithComponents(compoundtag, this.registryAccess);
- }
+ p_337415_.onDataPacket(connection, p_104976_, this.registryAccess);
if (p_337415_ instanceof CommandBlockEntity && this.minecraft.screen instanceof CommandBlockEditScreen) {
this.minecraft.level.getBlockEntity(blockpos, p_104976_.getType()).ifPresent(p_399316_ -> {
- p_399316_.loadWithComponents(p_104976_.getTag(), this.registryAccess);
+ p_399316_.onDataPacket(connection, p_104976_, this.registryAccess);
if (p_399316_ instanceof CommandBlockEntity && this.minecraft.screen instanceof CommandBlockEditScreen) {
((CommandBlockEditScreen)this.minecraft.screen).updateGui();
@@ -1505,9 +_,15 @@
}
@@ -1515,9 +_,15 @@
}
}
@ -89,7 +86,7 @@
}
@Override
@@ -1555,7 +_,9 @@
@@ -1565,7 +_,9 @@
@Override
public void handleCommands(ClientboundCommandsPacket p_104990_) {
PacketUtils.ensureRunningOnSameThread(p_104990_, this, this.minecraft);
@ -100,7 +97,7 @@
}
@Override
@@ -1574,6 +_,8 @@
@@ -1584,6 +_,8 @@
public void handleUpdateRecipes(ClientboundUpdateRecipesPacket p_105132_) {
PacketUtils.ensureRunningOnSameThread(p_105132_, this, this.minecraft);
this.recipes = new ClientRecipeContainer(p_105132_.itemSets(), p_105132_.stonecutterRecipes());
@ -109,7 +106,7 @@
}
@Override
@@ -1698,8 +_,11 @@
@@ -1708,8 +_,11 @@
});
list.forEach(Registry.PendingTags::apply);
this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures);
@ -123,7 +120,7 @@
}
@Override
@@ -2540,6 +_,8 @@
@@ -2558,6 +_,8 @@
}
public void sendChat(String p_249888_) {
@ -132,7 +129,7 @@
Instant instant = Instant.now();
long i = Crypt.SaltSupplier.getLong();
LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.lastSeenMessages.generateAndApplyUpdate();
@@ -2549,6 +_,7 @@
@@ -2567,6 +_,7 @@
}
public void sendCommand(String p_250092_) {
@ -140,7 +137,7 @@
SignableCommand<SharedSuggestionProvider> signablecommand = SignableCommand.of(this.parseCommand(p_250092_));
if (signablecommand.arguments().isEmpty()) {
this.send(new ServerboundChatCommandPacket(p_250092_));
@@ -2565,6 +_,8 @@
@@ -2583,6 +_,8 @@
}
public boolean sendUnsignedCommand(String p_251509_) {
@ -149,7 +146,7 @@
if (!SignableCommand.hasSignableArguments(this.parseCommand(p_251509_))) {
this.send(new ServerboundChatCommandPacket(p_251509_));
return true;
@@ -2640,6 +_,10 @@
@@ -2658,6 +_,10 @@
public Scoreboard scoreboard() {
return this.scoreboard;

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/MultiPlayerGameMode.java
+++ b/net/minecraft/client/multiplayer/MultiPlayerGameMode.java
@@ -121,11 +_,12 @@
@@ -124,11 +_,12 @@
} else if (blockstate.isAir()) {
return false;
} else {
@ -15,7 +15,7 @@
}
return flag;
@@ -144,6 +_,7 @@
@@ -147,6 +_,7 @@
BlockState blockstate = this.minecraft.level.getBlockState(p_105270_);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105270_, blockstate, 1.0F);
this.startPrediction(this.minecraft.level, p_233757_ -> {
@ -23,7 +23,7 @@
this.destroyBlock(p_105270_);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105270_, p_105271_, p_233757_);
});
@@ -153,15 +_,19 @@
@@ -156,15 +_,19 @@
this.connection
.send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, this.destroyBlockPos, p_105271_));
}
@ -34,7 +34,7 @@
this.startPrediction(this.minecraft.level, p_233728_ -> {
boolean flag = !blockstate1.isAir();
if (flag && this.destroyProgress == 0.0F) {
+ if (event.getUseBlock() != net.neoforged.neoforge.common.util.TriState.FALSE)
+ if (event.getUseBlock() != net.minecraft.util.TriState.FALSE)
blockstate1.attack(this.minecraft.level, p_105270_, this.minecraft.player);
}
@ -43,7 +43,7 @@
if (flag && blockstate1.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105270_) >= 1.0F) {
this.destroyBlock(p_105270_);
} else {
@@ -173,7 +_,7 @@
@@ -176,7 +_,7 @@
this.minecraft.level.destroyBlockProgress(this.minecraft.player.getId(), this.destroyBlockPos, this.getDestroyStage());
}
@ -52,7 +52,7 @@
});
}
@@ -204,6 +_,7 @@
@@ -207,6 +_,7 @@
BlockState blockstate1 = this.minecraft.level.getBlockState(p_105284_);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate1, 1.0F);
this.startPrediction(this.minecraft.level, p_233753_ -> {
@ -60,7 +60,7 @@
this.destroyBlock(p_105284_);
return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, p_105284_, p_105285_, p_233753_);
});
@@ -216,7 +_,7 @@
@@ -219,7 +_,7 @@
} else {
this.destroyProgress = this.destroyProgress + blockstate.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), p_105284_);
if (this.destroyTicks % 4.0F == 0.0F) {
@ -69,7 +69,7 @@
this.minecraft
.getSoundManager()
.play(
@@ -233,6 +_,7 @@
@@ -236,6 +_,7 @@
this.destroyTicks++;
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, p_105284_, blockstate, Mth.clamp(this.destroyProgress, 0.0F, 1.0F));
@ -77,7 +77,7 @@
if (this.destroyProgress >= 1.0F) {
this.isDestroying = false;
this.startPrediction(this.minecraft.level, p_233739_ -> {
@@ -271,7 +_,7 @@
@@ -274,7 +_,7 @@
private boolean sameDestroyTarget(BlockPos p_105282_) {
ItemStack itemstack = this.minecraft.player.getMainHandItem();
@ -86,7 +86,7 @@
}
private void ensureHasSentCarriedItem() {
@@ -299,12 +_,23 @@
@@ -302,12 +_,23 @@
private InteractionResult performUseItemOn(LocalPlayer p_233747_, InteractionHand p_233748_, BlockHitResult p_233749_) {
BlockPos blockpos = p_233749_.getBlockPos();
ItemStack itemstack = p_233747_.getItemInHand(p_233748_);
@ -99,7 +99,7 @@
} else {
- boolean flag = !p_233747_.getMainHandItem().isEmpty() || !p_233747_.getOffhandItem().isEmpty();
+ UseOnContext useoncontext = new UseOnContext(p_233747_, p_233748_, p_233749_);
+ if (event.getUseItem() != net.neoforged.neoforge.common.util.TriState.FALSE) {
+ if (event.getUseItem() != net.minecraft.util.TriState.FALSE) {
+ InteractionResult result = itemstack.onItemUseFirst(useoncontext);
+ if (result != InteractionResult.PASS) {
+ return result;
@ -112,7 +112,7 @@
BlockState blockstate = this.minecraft.level.getBlockState(blockpos);
if (!this.connection.isFeatureEnabled(blockstate.getBlock().requiredFeatures())) {
return InteractionResult.FAIL;
@@ -325,8 +_,10 @@
@@ -328,8 +_,10 @@
}
}
@ -123,9 +123,9 @@
+ }
+ if (event.getUseItem().isTrue() || (!itemstack.isEmpty() && !p_233747_.getCooldowns().isOnCooldown(itemstack))) {
InteractionResult interactionresult2;
if (this.localPlayerMode.isCreative()) {
if (p_233747_.hasInfiniteMaterials()) {
int i = itemstack.getCount();
@@ -360,6 +_,11 @@
@@ -363,6 +_,11 @@
mutableobject.setValue(InteractionResult.PASS);
return serverbounduseitempacket;
} else {
@ -137,7 +137,7 @@
InteractionResult interactionresult = itemstack.use(this.minecraft.level, p_233722_, p_233723_);
ItemStack itemstack1;
if (interactionresult instanceof InteractionResult.Success interactionresult$success) {
@@ -372,6 +_,8 @@
@@ -375,6 +_,8 @@
if (itemstack1 != itemstack) {
p_233722_.setItemInHand(p_233723_, itemstack1);
@ -146,7 +146,7 @@
}
mutableobject.setValue(interactionresult);
@@ -410,6 +_,9 @@
@@ -413,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));

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ServerData.java
+++ b/net/minecraft/client/multiplayer/ServerData.java
@@ -34,6 +_,7 @@
@@ -37,6 +_,7 @@
private byte[] iconBytes;
private ServerData.Type type;
private ServerData.State state = ServerData.State.INITIAL;

View file

@ -9,7 +9,7 @@
CompletableFuture<?> completablefuture = this.recipeSearch;
this.recipeSearch = CompletableFuture.supplyAsync(
() -> new FullTextSearchTree<>(
@@ -92,44 +_,60 @@
@@ -90,44 +_,60 @@
}
public void updateCreativeTags(List<ItemStack> p_346121_) {
@ -59,10 +59,10 @@
+ CompletableFuture<?> completablefuture = net.neoforged.neoforge.client.CreativeModeTabSearchRegistry.getNameSearchTree(key);
+ net.neoforged.neoforge.client.CreativeModeTabSearchRegistry.putNameSearchTree(key, CompletableFuture.supplyAsync(
() -> new FullTextSearchTree<>(
p_345006_ -> getTooltipLines(Stream.of(p_345006_), item$tooltipcontext, tooltipflag),
p_345861_ -> p_345861_.getItemHolder().unwrapKey().map(ResourceKey::location).stream(),
p_346357_
),
p_345006_ -> getTooltipLines(Stream.of(p_345006_), item$tooltipcontext, tooltipflag),
p_345861_ -> p_345861_.getItemHolder().unwrapKey().map(ResourceKey::location).stream(),
p_346357_
),
Util.backgroundExecutor()
- );
+ ));

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/chat/ChatListener.java
+++ b/net/minecraft/client/multiplayer/chat/ChatListener.java
@@ -118,7 +_,9 @@
@@ -123,7 +_,9 @@
Instant instant = Instant.now();
this.handleMessage(null, () -> {
Component component = p_251256_.decorate(p_250375_);
@ -11,7 +11,7 @@
this.narrateChatMessage(p_251256_, p_250375_);
this.logSystemMessage(component, instant);
this.previousMessageTime = Util.getMillis();
@@ -137,12 +_,16 @@
@@ -142,12 +_,16 @@
MessageSignature messagesignature = p_249430_.signature();
FilterMask filtermask = p_249430_.filterMask();
if (filtermask.isEmpty()) {
@ -30,7 +30,7 @@
this.narrateChatMessage(p_251766_, component);
}
}
@@ -175,6 +_,8 @@
@@ -180,6 +_,8 @@
public void handleSystemMessage(Component p_240522_, boolean p_240642_) {
if (!this.minecraft.options.hideMatchedNames().get() || !this.minecraft.isBlocked(this.guessChatUUID(p_240522_))) {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/particle/Particle.java
+++ b/net/minecraft/client/particle/Particle.java
@@ -250,6 +_,18 @@
@@ -248,6 +_,18 @@
return Optional.empty();
}
@ -17,5 +17,5 @@
+ }
+
@OnlyIn(Dist.CLIENT)
public static record LifetimeAlpha(float startAlpha, float endAlpha, float startAtNormalizedAge, float endAtNormalizedAge) {
public record LifetimeAlpha(float startAlpha, float endAlpha, float startAtNormalizedAge, float endAtNormalizedAge) {
public static final Particle.LifetimeAlpha ALWAYS_OPAQUE = new Particle.LifetimeAlpha(1.0F, 1.0F, 0.0F, 1.0F);

View file

@ -1,13 +1,12 @@
--- a/net/minecraft/client/particle/ParticleEngine.java
+++ b/net/minecraft/client/particle/ParticleEngine.java
@@ -74,11 +_,11 @@
@@ -74,10 +_,10 @@
ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT
);
protected ClientLevel level;
- private final Map<ParticleRenderType, Queue<Particle>> particles = Maps.newIdentityHashMap();
+ private final Map<ParticleRenderType, Queue<Particle>> particles = Maps.newTreeMap(net.neoforged.neoforge.client.ClientHooks.makeParticleRenderTypeComparator(RENDER_ORDER));
private final Queue<TrackingEmitter> trackingEmitters = Queues.newArrayDeque();
private final TextureManager textureManager;
private final RandomSource random = RandomSource.create();
- private final Int2ObjectMap<ParticleProvider<?>> providers = new Int2ObjectOpenHashMap<>();
+ private final Map<ResourceLocation, ParticleProvider<?>> providers = new java.util.HashMap<>();
@ -15,7 +14,7 @@
private final Map<ResourceLocation, ParticleEngine.MutableSpriteSet> spriteSets = Maps.newHashMap();
private final TextureAtlas textureAtlas;
@@ -207,10 +_,14 @@
this.register(ParticleTypes.BLOCK_CRUMBLE, new TerrainParticle.CrumblingProvider());
this.register(ParticleTypes.FIREFLY, FireflyParticle.FireflyProvider::new);
}
+ /** @deprecated Register via {@link net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent} */
@ -143,11 +142,11 @@
}
}
@@ -560,12 +_,28 @@
d0 = (double)i + aabb.maxX + 0.1F;
d0 = i + aabb.maxX + 0.1F;
}
- this.add(new TerrainParticle(this.level, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_107368_).setPower(0.2F).scale(0.6F));
+ this.add((new TerrainParticle(this.level, d0, d1, d2, 0.0D, 0.0D, 0.0D, blockstate, p_107368_).updateSprite(blockstate, p_107368_)).setPower(0.2F).scale(0.6F));
+ this.add(new TerrainParticle(this.level, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, p_107368_).updateSprite(blockstate, p_107368_).setPower(0.2F).scale(0.6F));
}
}

View file

@ -1,9 +1,9 @@
--- a/net/minecraft/client/particle/PortalParticle.java
+++ b/net/minecraft/client/particle/PortalParticle.java
@@ -80,6 +_,7 @@
this.x = this.xStart + this.xd * (double)f2;
this.y = this.yStart + this.yd * (double)f2 + (double)(1.0F - f);
this.z = this.zStart + this.zd * (double)f2;
this.x = this.xStart + this.xd * f2;
this.y = this.yStart + this.yd * f2 + (1.0F - f);
this.z = this.zStart + this.zd * f2;
+ this.setPos(this.x, this.y, this.z); // FORGE: update the particle's bounding box
}
}

View file

@ -1,9 +1,9 @@
--- a/net/minecraft/client/particle/ReversePortalParticle.java
+++ b/net/minecraft/client/particle/ReversePortalParticle.java
@@ -31,6 +_,7 @@
this.x = this.x + this.xd * (double)f;
this.y = this.y + this.yd * (double)f;
this.z = this.z + this.zd * (double)f;
this.x = this.x + this.xd * f;
this.y = this.y + this.yd * f;
this.z = this.z + this.zd * f;
+ this.setPos(this.x, this.y, this.z); // Neo: update the particle's bounding box
}
}

View file

@ -7,8 +7,8 @@
- if (!p_172458_.is(Blocks.GRASS_BLOCK)) {
+ if (net.neoforged.neoforge.client.extensions.common.IClientBlockExtensions.of(p_172458_).areBreakingParticlesTinted(p_172458_, p_172451_, p_172459_)) {
int i = Minecraft.getInstance().getBlockColors().getColor(p_172458_, p_172451_, p_172459_, 0);
this.rCol *= (float)(i >> 16 & 0xFF) / 255.0F;
this.gCol *= (float)(i >> 8 & 0xFF) / 255.0F;
this.rCol *= (i >> 16 & 0xFF) / 255.0F;
this.gCol *= (i >> 8 & 0xFF) / 255.0F;
@@ -97,8 +_,14 @@
) {
BlockState blockstate = p_338588_.getState();
@ -20,7 +20,7 @@
+
+ public TerrainParticle updateSprite(BlockState state, BlockPos pos) { //FORGE: we cannot assume that the x y z of the particles match the block pos of the block.
+ if (pos != null) // There are cases where we are not able to obtain the correct source pos, and need to fallback to the non-model data version
+ this.setSprite(Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getTexture(state, level, pos));
+ this.setSprite(Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getParticleIcon(state, level, pos));
+ return this;
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/player/AbstractClientPlayer.java
+++ b/net/minecraft/client/player/AbstractClientPlayer.java
@@ -91,6 +_,6 @@
@@ -86,6 +_,6 @@
}
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/player/LocalPlayer.java
+++ b/net/minecraft/client/player/LocalPlayer.java
@@ -307,6 +_,7 @@
@@ -303,6 +_,7 @@
ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_108701_
? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS
: ServerboundPlayerActionPacket.Action.DROP_ITEM;
@ -8,7 +8,7 @@
ItemStack itemstack = this.getInventory().removeFromSelected(p_108701_);
this.connection.send(new ServerboundPlayerActionPacket(serverboundplayeractionpacket$action, BlockPos.ZERO, Direction.DOWN));
return !itemstack.isEmpty();
@@ -487,7 +_,14 @@
@@ -480,7 +_,14 @@
@Override
public void playSound(SoundEvent p_108651_, float p_108652_, float p_108653_) {
@ -24,52 +24,24 @@
}
@Override
@@ -680,6 +_,7 @@
@@ -715,6 +_,7 @@
&& this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.CROUCHING)
&& (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING));
this.input.tick();
+ net.neoforged.neoforge.client.ClientHooks.onMovementInputUpdate(this, this.input);
this.minecraft.getTutorial().onInput(this.input);
if (this.shouldStopSprinting()) {
this.setSprinting(false);
@@ -718,7 +_,7 @@
boolean flag3 = this.canStartSprinting();
boolean flag4 = this.isPassenger() ? this.getVehicle().onGround() : this.onGround();
boolean flag5 = !flag1 && !flag2;
- if ((flag4 || this.isUnderWater()) && flag5 && flag3) {
+ if ((flag4 || this.isUnderWater() || this.canStartSwimming()) && flag5 && flag3) {
if (this.sprintTriggerTime <= 0 && !this.minecraft.options.keySprint.isDown()) {
this.sprintTriggerTime = 7;
} else {
@@ -726,15 +_,15 @@
}
boolean flag3 = false;
if (this.autoJumpTime > 0) {
@@ -759,7 +_,7 @@
}
- if ((!this.isInWater() || this.isUnderWater()) && flag3 && this.minecraft.options.keySprint.isDown()) {
+ if (!this.isSprinting() && (!(this.isInWater() || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType))) || (this.isUnderWater() || this.canStartSwimming())) && this.hasEnoughImpulseToStartSprinting() && flag3 && !this.isUsingItem() && !this.hasEffect(MobEffects.BLINDNESS) && this.minecraft.options.keySprint.isDown()) {
this.setSprinting(true);
}
if (this.isSprinting()) {
boolean flag6 = !this.input.hasForwardImpulse() || !this.hasEnoughFoodToStartSprinting();
- boolean flag7 = flag6 || this.horizontalCollision && !this.minorHorizontalCollision || this.isInWater() && !this.isUnderWater();
+ boolean flag7 = flag6 || 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.keyPresses.shift() && flag6 || !this.isInWater()) {
+ if (!this.onGround() && !this.input.keyPresses.shift() && flag6 || !(this.isInWater() || this.isInFluidType((fluidType, height) -> this.canSwimInFluidType(fluidType)))) {
this.setSprinting(false);
}
} else if (flag7) {
@@ -743,7 +_,7 @@
}
boolean flag9 = false;
boolean flag4 = false;
- if (abilities.mayfly) {
+ if (this.mayFly()) {
if (this.minecraft.gameMode.isAlwaysFlying()) {
if (!abilities.flying) {
abilities.flying = true;
@@ -896,6 +_,10 @@
@@ -915,6 +_,10 @@
@Override
public void rideTick() {
super.rideTick();
@ -80,12 +52,12 @@
this.handsBusy = false;
if (this.getControlledVehicle() instanceof AbstractBoat abstractboat) {
abstractboat.setInput(
@@ -1094,7 +_,7 @@
@@ -1097,7 +_,7 @@
}
private boolean hasEnoughFoodToStartSprinting() {
- return this.isPassenger() || (float)this.getFoodData().getFoodLevel() > 6.0F || this.getAbilities().mayfly;
+ return this.isPassenger() || (float)this.getFoodData().getFoodLevel() > 6.0F || this.mayFly();
private boolean hasEnoughFoodToSprint() {
- return this.isPassenger() || this.getFoodData().getFoodLevel() > 6.0F || this.getAbilities().mayfly;
+ return this.isPassenger() || this.getFoodData().getFoodLevel() > 6.0F || this.mayFly();
}
public float getWaterVision() {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/FogRenderer.java
+++ b/net/minecraft/client/renderer/FogRenderer.java
@@ -196,7 +_,7 @@
@@ -191,7 +_,7 @@
f2 = f2 * (1.0F - f10) + f2 * f12 * f10;
}
@ -9,7 +9,7 @@
}
public static boolean toggleFog() {
@@ -274,9 +_,9 @@
@@ -269,9 +_,9 @@
fogrenderer$fogdata.shape = FogShape.CYLINDER;
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/GameRenderer.java
+++ b/net/minecraft/client/renderer/GameRenderer.java
@@ -158,6 +_,8 @@
@@ -168,6 +_,8 @@
this.setPostEffect(ResourceLocation.withDefaultNamespace("spider"));
} else if (p_109107_ instanceof EnderMan) {
this.setPostEffect(ResourceLocation.withDefaultNamespace("invert"));
@ -9,7 +9,7 @@
}
}
@@ -312,7 +_,7 @@
@@ -345,7 +_,7 @@
f *= Mth.lerp(f2, 1.0F, 0.85714287F);
}
@ -18,7 +18,7 @@
}
}
@@ -328,6 +_,10 @@
@@ -361,6 +_,10 @@
return;
}
@ -26,16 +26,15 @@
+ var lastSrc = livingentity.getLastDamageSource();
+ if (lastSrc != null && lastSrc.is(net.neoforged.neoforge.common.Tags.DamageTypes.NO_FLINCH)) return;
+
f2 /= (float)livingentity.hurtDuration;
f2 /= livingentity.hurtDuration;
f2 = Mth.sin(f2 * f2 * f2 * f2 * (float) Math.PI);
float f3 = livingentity.getHurtDir();
@@ -476,12 +_,12 @@
(float)((double)window.getHeight() / window.getGuiScale()),
0.0F,
1000.0F,
- 21000.0F
+ net.neoforged.neoforge.client.ClientHooks.getGuiFarPlane()
);
@@ -491,11 +_,11 @@
RenderTarget rendertarget = this.minecraft.getMainRenderTarget();
RenderSystem.getDevice().createCommandEncoder().clearDepthTexture(rendertarget.getDepthTexture(), 1.0);
Matrix4f matrix4f = new Matrix4f()
- .setOrtho(0.0F, (float)(window.getWidth() / window.getGuiScale()), (float)(window.getHeight() / window.getGuiScale()), 0.0F, 1000.0F, 21000.0F);
+ .setOrtho(0.0F, (float)(window.getWidth() / window.getGuiScale()), (float)(window.getHeight() / window.getGuiScale()), 0.0F, 1000.0F, net.neoforged.neoforge.client.ClientHooks.getGuiFarPlane());
RenderSystem.setProjectionMatrix(matrix4f, ProjectionType.ORTHOGRAPHIC);
Matrix4fStack matrix4fstack = RenderSystem.getModelViewStack();
matrix4fstack.pushMatrix();
@ -44,7 +43,7 @@
Lighting.setupFor3DItems();
GuiGraphics guigraphics = new GuiGraphics(this.minecraft, this.renderBuffers.bufferSource());
if (flag && p_109096_ && this.minecraft.level != null) {
@@ -507,7 +_,8 @@
@@ -521,7 +_,8 @@
}
} else if (flag && this.minecraft.screen != null) {
try {
@ -54,12 +53,12 @@
} catch (Throwable throwable1) {
CrashReport crashreport1 = CrashReport.forThrowable(throwable1, "Rendering screen");
CrashReportCategory crashreportcategory1 = crashreport1.addCategory("Screen render details");
@@ -689,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, matrix4f2, matrix4f);
@@ -681,6 +_,8 @@
Matrix4f matrix4f1 = new Matrix4f().rotation(quaternionf);
this.minecraft.levelRenderer.prepareCullFrustum(camera.getPosition(), matrix4f1, matrix4f2);
this.minecraft.levelRenderer.renderLevel(this.resourcePool, p_348589_, flag, camera, this, matrix4f1, matrix4f);
+ profilerfiller.popPush("neoforge_render_last");
+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_LEVEL, this.minecraft.level, this.minecraft.levelRenderer, null, matrix4f1, matrix4f, this.minecraft.levelRenderer.getTicks(), camera, this.minecraft.levelRenderer.getFrustum());
profilerfiller.popPush("hand");
if (this.renderHand) {
RenderSystem.clear(256);
RenderSystem.getDevice().createCommandEncoder().clearDepthTexture(this.minecraft.getMainRenderTarget().getDepthTexture(), 1.0);

View file

@ -5,108 +5,67 @@
@OnlyIn(Dist.CLIENT)
public class ItemBlockRenderTypes {
+ @Deprecated
private static final Map<Block, RenderType> TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_382527_ -> {
private static final Map<Block, RenderType> TYPE_BY_BLOCK = Util.make(Maps.newHashMap(), p_401711_ -> {
RenderType rendertype = RenderType.tripwire();
p_382527_.put(Blocks.TRIPWIRE, rendertype);
@@ -345,6 +_,7 @@
p_382527_.put(Blocks.BUBBLE_COLUMN, rendertype3);
p_382527_.put(Blocks.TINTED_GLASS, rendertype3);
p_401711_.put(Blocks.TRIPWIRE, rendertype);
@@ -352,6 +_,7 @@
p_401711_.put(Blocks.BUBBLE_COLUMN, rendertype3);
p_401711_.put(Blocks.TINTED_GLASS, rendertype3);
});
+ @Deprecated
private static final Map<Fluid, RenderType> TYPE_BY_FLUID = Util.make(Maps.newHashMap(), p_109290_ -> {
RenderType rendertype = RenderType.translucent();
p_109290_.put(Fluids.FLOWING_WATER, rendertype);
@@ -352,6 +_,8 @@
@@ -359,6 +_,8 @@
});
private static boolean renderCutout;
+ /** @deprecated Forge: Use {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.neoforged.neoforge.client.model.data.ModelData)}. */
+ /** @deprecated Neo: Use {@link net.minecraft.client.renderer.block.model.BlockModelPart#getRenderType(BlockState)}. */
+ @Deprecated // Note: this method does NOT support model-based render types
public static RenderType getChunkRenderType(BlockState p_109283_) {
Block block = p_109283_.getBlock();
if (block instanceof LeavesBlock) {
@@ -362,6 +_,8 @@
@@ -369,6 +_,8 @@
}
}
+ /** @deprecated Forge: Use {@link net.neoforged.neoforge.client.RenderTypeHelper#getMovingBlockRenderType(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 Neo: Use {@link net.neoforged.neoforge.client.RenderTypeHelper#getMovingBlockRenderType(RenderType)} with the result of {@link net.minecraft.client.renderer.block.model.BlockModelPart#getRenderType(BlockState)}. */
+ @Deprecated // Note: this method does NOT support model-based render types
public static RenderType getMovingBlockRenderType(BlockState p_109294_) {
Block block = p_109294_.getBlock();
if (block instanceof LeavesBlock) {
@@ -376,11 +_,15 @@
@@ -383,11 +_,15 @@
}
}
+ /** @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 Neo: Use {@link net.neoforged.neoforge.client.RenderTypeHelper#getEntityRenderType(RenderType)} with the result of {@link net.minecraft.client.renderer.block.model.BlockModelPart#getRenderType(BlockState)}. */
+ @Deprecated // Note: this method does NOT support model-based render types
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)} and {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(ItemStack)}. */
+ /** @deprecated Neo: See {@link net.minecraft.client.renderer.item.BlockModelWrapper#renderType}. */
+ @Deprecated // Note: this method does NOT support model-based render types
public static RenderType getRenderType(ItemStack p_366701_) {
if (p_366701_.getItem() instanceof BlockItem blockitem) {
Block block = blockitem.getBlock();
@@ -397,5 +_,78 @@
@@ -404,5 +_,32 @@
public static void setFancy(boolean p_109292_) {
renderCutout = p_109292_;
+ }
+
+ // Neo: Injected new ChunkRenderTypeSets for Blocks to be able to use
+ private static final net.neoforged.neoforge.client.ChunkRenderTypeSet CUTOUT_MIPPED = net.neoforged.neoforge.client.ChunkRenderTypeSet.of(RenderType.cutoutMipped());
+ private static final net.neoforged.neoforge.client.ChunkRenderTypeSet SOLID = net.neoforged.neoforge.client.ChunkRenderTypeSet.of(RenderType.solid());
+
+ private static final Map<Block, net.neoforged.neoforge.client.ChunkRenderTypeSet> BLOCK_RENDER_TYPES = Util.make(new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(TYPE_BY_BLOCK.size(), 0.5F), map -> {
+ map.defaultReturnValue(SOLID);
+ for(Map.Entry<Block, RenderType> entry : TYPE_BY_BLOCK.entrySet()) {
+ map.put(entry.getKey(), net.neoforged.neoforge.client.ChunkRenderTypeSet.of(entry.getValue()));
+ }
+ });
+
+
+ /** @deprecated Use {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.neoforged.neoforge.client.model.data.ModelData)}. */
+ @Deprecated(since = "1.19")
+ public static net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderLayers(BlockState state) {
+ Block block = state.getBlock();
+ if (block instanceof LeavesBlock) {
+ return renderCutout ? CUTOUT_MIPPED : SOLID;
+ } else {
+ return BLOCK_RENDER_TYPES.get(block);
+ }
+ }
+
+ // Neo: RenderType for block setters injected
+ /**
+ * Helper to set the RenderType for Blocks
+ * @deprecated Set your render type in your block model's JSON (eg. {@code "render_type": "cutout"}) or override {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.neoforged.neoforge.client.model.data.ModelData)}
+ * @deprecated Set your render type in your block model's JSON (e.g. {@code "render_type": "cutout"}) or override {@link net.minecraft.client.renderer.block.model.BlockModelPart#getRenderType(BlockState)}
+ * */
+ @Deprecated(since = "1.19")
+ public static void setRenderLayer(Block block, RenderType type) {
+ public static synchronized void setRenderLayer(Block block, RenderType type) {
+ com.google.common.base.Preconditions.checkArgument(type.getChunkLayerId() >= 0, "The argument must be a valid chunk render type returned by RenderType#chunkBufferLayers().");
+ setRenderLayer(block, net.neoforged.neoforge.client.ChunkRenderTypeSet.of(type));
+ }
+
+ /**
+ * Helper to set the matching RenderType for Blocks
+ * @deprecated Set your render type in your block model's JSON (eg. {@code "render_type": "cutout"}) or override {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.neoforged.neoforge.client.model.data.ModelData)}
+ * */
+ @Deprecated(since = "1.19")
+ public static synchronized void setRenderLayer(Block block, java.util.function.Predicate<RenderType> predicate) {
+ setRenderLayer(block, createSetFromPredicate(predicate));
+ }
+
+ /**
+ * Helper to set the ChunkRenderTypeSet for Blocks
+ * @deprecated Set your render type in your block model's JSON (eg. {@code "render_type": "cutout"}) or override {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.neoforged.neoforge.client.model.data.ModelData)}
+ * */
+ @Deprecated(since = "1.19")
+ public static synchronized void setRenderLayer(Block block, net.neoforged.neoforge.client.ChunkRenderTypeSet layers) {
+ checkClientLoading();
+ BLOCK_RENDER_TYPES.put(block, layers);
+ TYPE_BY_BLOCK.put(block, type);
+ }
+
+ /**
@ -120,12 +79,7 @@
+
+ private static void checkClientLoading() {
+ com.google.common.base.Preconditions.checkState(net.neoforged.neoforge.client.loading.ClientModLoader.isLoading(),
+ "Render layers can only be set during client loading! " +
+ "This might ideally be done from `FMLClientSetupEvent`."
+ "Render layers can only be set during client loading! This should ideally be done from `FMLClientSetupEvent`."
+ );
+ }
+
+ private static net.neoforged.neoforge.client.ChunkRenderTypeSet createSetFromPredicate(java.util.function.Predicate<RenderType> predicate) {
+ return net.neoforged.neoforge.client.ChunkRenderTypeSet.of(RenderType.chunkBufferLayers().stream().filter(predicate).toArray(RenderType[]::new));
}
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/ItemInHandRenderer.java
+++ b/net/minecraft/client/renderer/ItemInHandRenderer.java
@@ -172,11 +_,11 @@
@@ -165,11 +_,11 @@
ResourceLocation resourcelocation = this.minecraft.player.getSkin().texture();
if (p_109365_ == HumanoidArm.RIGHT) {
playerrenderer.renderRightHand(
@ -14,7 +14,7 @@
);
}
@@ -238,7 +_,7 @@
@@ -231,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);
@ -23,7 +23,7 @@
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_);
@@ -275,10 +_,10 @@
@@ -268,10 +_,10 @@
ResourceLocation resourcelocation = abstractclientplayer.getSkin().texture();
if (flag) {
playerrenderer.renderRightHand(
@ -36,7 +36,7 @@
}
}
@@ -351,12 +_,14 @@
@@ -344,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);
@ -51,7 +51,7 @@
this.renderArmWithItem(p_109318_, p_109315_, f1, InteractionHand.OFF_HAND, f6, this.offHandItem, f7, p_109316_, p_109317_, p_109319_);
}
@@ -416,13 +_,13 @@
@@ -409,13 +_,13 @@
if (flag && !p_109372_.isInvisible()) {
this.renderPlayerArm(p_109379_, p_109380_, p_109381_, p_109378_, p_109376_, humanoidarm);
}
@ -67,7 +67,7 @@
boolean flag1 = CrossbowItem.isCharged(p_109377_);
boolean flag2 = humanoidarm == HumanoidArm.RIGHT;
int i = flag2 ? 1 : -1;
@@ -468,6 +_,8 @@
@@ -460,6 +_,8 @@
} else {
boolean flag3 = humanoidarm == HumanoidArm.RIGHT;
int j = flag3 ? 1 : -1;
@ -76,12 +76,12 @@
if (p_109372_.isUsingItem() && p_109372_.getUseItemRemainingTicks() > 0 && p_109372_.getUsedItemHand() == p_109375_) {
switch (p_109377_.getUseAnimation()) {
case NONE:
@@ -595,9 +_,18 @@
@@ -586,9 +_,18 @@
this.mainHandHeight = Mth.clamp(this.mainHandHeight - 0.4F, 0.0F, 1.0F);
this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F);
} else {
+ // Neo: allow suppressing re-equip animation when only the stack's data changes
+ boolean swapAnimMain = net.neoforged.neoforge.client.ClientHooks.shouldCauseReequipAnimation(this.mainHandItem, itemstack, localplayer.getInventory().selected);
+ boolean swapAnimMain = net.neoforged.neoforge.client.ClientHooks.shouldCauseReequipAnimation(this.mainHandItem, itemstack, localplayer.getInventory().getSelectedSlot());
+ boolean swapAnimOff = net.neoforged.neoforge.client.ClientHooks.shouldCauseReequipAnimation(this.offHandItem, itemstack1, -1);
+
+ if (!swapAnimMain && this.mainHandItem != itemstack)

View file

@ -1,15 +1,15 @@
--- a/net/minecraft/client/renderer/LevelRenderer.java
+++ b/net/minecraft/client/renderer/LevelRenderer.java
@@ -459,7 +_,7 @@
@@ -454,7 +_,7 @@
this.targets.main = framegraphbuilder.importExternal("main", this.minecraft.getMainRenderTarget());
int i = this.minecraft.getMainRenderTarget().width;
int j = this.minecraft.getMainRenderTarget().height;
- RenderTargetDescriptor rendertargetdescriptor = new RenderTargetDescriptor(i, j, true);
+ RenderTargetDescriptor rendertargetdescriptor = new RenderTargetDescriptor(i, j, true, this.minecraft.getMainRenderTarget().useStencil);
- RenderTargetDescriptor rendertargetdescriptor = new RenderTargetDescriptor(i, j, true, 0);
+ RenderTargetDescriptor rendertargetdescriptor = new RenderTargetDescriptor(i, j, true, 0, this.minecraft.getMainRenderTarget().useStencil);
PostChain postchain = this.getTransparencyChain();
if (postchain != null) {
this.targets.translucent = framegraphbuilder.createInternal("translucent", rendertargetdescriptor);
@@ -473,6 +_,9 @@
@@ -468,6 +_,9 @@
this.targets.entityOutline = framegraphbuilder.importExternal("entity_outline", this.entityOutlineTarget);
}
@ -18,18 +18,18 @@
+
FramePass framepass = framegraphbuilder.addPass("clear");
this.targets.main = framepass.readsAndWrites(this.targets.main);
framepass.executes(() -> {
@@ -480,7 +_,7 @@
RenderSystem.clear(16640);
});
framepass.executes(
@@ -481,7 +_,7 @@
}
);
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);
@@ -489,7 +_,7 @@
postchain1.addToFrame(framegraphbuilder, i, j, this.targets);
@@ -490,7 +_,7 @@
postchain1.addToFrame(framegraphbuilder, i, j, this.targets, null);
}
- this.addParticlesPass(framegraphbuilder, p_109604_, f, fogparameters);
@ -37,55 +37,55 @@
CloudStatus cloudstatus = this.minecraft.options.getCloudsType();
if (cloudstatus != CloudStatus.OFF) {
float f2 = this.level.effects().getCloudHeight();
@@ -500,7 +_,7 @@
@@ -501,7 +_,7 @@
}
}
- this.addWeatherPass(framegraphbuilder, p_109604_.getPosition(), f, fogparameters);
+ this.addWeatherPass(framegraphbuilder, p_109604_.getPosition(), f, fogparameters, p_254120_, p_323920_, p_109604_);
if (postchain != null) {
postchain.addToFrame(framegraphbuilder, i, j, this.targets);
postchain.addToFrame(framegraphbuilder, i, j, this.targets, null);
}
@@ -571,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();
@@ -603,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, level, 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);
@@ -619,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, level, this, posestack, p_362420_, p_361272_, this.ticks, p_363453_, p_366590_);
if (p_363964_) {
this.renderBlockOutline(p_363453_, multibuffersource$buffersource, posestack, false);
}
@@ -639,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(p_363453_, f, this.renderBuffers.bufferSource(), p_366590_, type -> !type.translucent());
+ }
multibuffersource$buffersource.endBatch();
if (resourcehandle1 != null) {
resourcehandle1.get().setClearColor(0.0F, 0.0F, 0.0F, 0.0F);
@@ -659,7 +_,15 @@
});
@@ -569,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();
@@ -594,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, level, 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);
@@ -610,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, level, this, posestack, p_362420_, p_361272_, this.ticks, p_363453_, p_366590_);
if (p_363964_) {
this.renderBlockOutline(p_363453_, multibuffersource$buffersource, posestack, false);
}
@@ -630,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(p_363453_, f, this.renderBuffers.bufferSource(), p_366590_, type -> !type.translucent());
+ }
multibuffersource$buffersource.endBatch();
if (resourcehandle1 != null) {
resourcehandle1.get().copyDepthFrom(resourcehandle.get());
@@ -649,7 +_,15 @@
);
}
+ /**
@ -100,7 +100,7 @@
FramePass framepass = p_363357_.addPass("particles");
if (this.targets.particles != null) {
this.targets.particles = framepass.readsAndWrites(this.targets.particles);
@@ -678,7 +_,8 @@
@@ -666,11 +_,20 @@
resourcehandle1.get().copyDepthFrom(resourcehandle.get());
}
@ -110,13 +110,28 @@
});
}
@@ -706,11 +_,20 @@
resourcehandle.get().clear();
}
+ /**
+ * @deprecated Neo: use {@link #addCloudsPass(FrameGraphBuilder, CloudStatus, Vec3, float, int, float, Matrix4f, Matrix4f)} instead
+ */
+ @Deprecated
private void addCloudsPass(FrameGraphBuilder p_361907_, CloudStatus p_364196_, Vec3 p_362985_, float p_365209_, int p_362342_, float p_362337_) {
+ addCloudsPass(p_361907_, p_364196_, p_362985_, p_365209_, p_362342_, p_362337_, RenderSystem.getModelViewMatrix(), RenderSystem.getProjectionMatrix());
+ }
+
+ private void addCloudsPass(FrameGraphBuilder p_361907_, CloudStatus p_364196_, Vec3 p_362985_, float p_365209_, int p_362342_, float p_362337_, Matrix4f modelViewMatrix, Matrix4f projectionMatrix) {
FramePass framepass = p_361907_.addPass("clouds");
if (this.targets.clouds != null) {
this.targets.clouds = framepass.readsAndWrites(this.targets.clouds);
@@ -678,10 +_,22 @@
this.targets.main = framepass.readsAndWrites(this.targets.main);
}
+ 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_);
});
- framepass.executes(() -> this.cloudRenderer.render(p_362342_, p_364196_, p_362337_, p_362985_, p_365209_));
+ framepass.executes(() -> {
+ if (!level.effects().renderClouds(level, ticks, p_365209_, p_362985_.x, p_362985_.y, p_362985_.z, modelViewMatrix, projectionMatrix)) {
+ this.cloudRenderer.render(p_362342_, p_364196_, p_362337_, p_362985_, p_365209_);
+ }
+ });
}
+ /**
@ -131,15 +146,15 @@
int i = this.minecraft.options.getEffectiveRenderDistance() * 16;
float f = this.minecraft.gameRenderer.getDepthFar();
FramePass framepass = p_364025_.addPass("weather");
@@ -724,6 +_,7 @@
@@ -695,6 +_,7 @@
RenderSystem.setShaderFog(p_360974_);
MultiBufferSource.BufferSource multibuffersource$buffersource = this.renderBuffers.bufferSource();
this.weatherEffectRenderer.render(this.minecraft.level, multibuffersource$buffersource, this.ticks, p_362434_, p_360771_);
+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_WEATHER, level, this, null, modelViewMatrix, projectionMatrix, this.ticks, camera, getFrustum());
this.worldBorderRenderer.render(this.level.getWorldBorder(), p_360771_, (double)i, (double)f);
this.worldBorderRenderer.render(this.level.getWorldBorder(), p_360771_, i, f);
multibuffersource$buffersource.endBatch();
});
@@ -768,11 +_,14 @@
@@ -738,11 +_,14 @@
|| p_363510_.isDetached()
|| p_363510_.getEntity() instanceof LivingEntity && ((LivingEntity)p_363510_.getEntity()).isSleeping()
)
@ -155,7 +170,7 @@
}
}
}
@@ -818,10 +_,12 @@
@@ -788,10 +_,12 @@
double d1 = vec3.y();
double d2 = vec3.z();
@ -168,27 +183,15 @@
BlockPos blockpos = blockentity.getBlockPos();
MultiBufferSource multibuffersource = p_363819_;
p_362832_.pushPose();
@@ -849,6 +_,7 @@
@@ -819,6 +_,7 @@
synchronized (this.globalBlockEntities) {
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);
@@ -876,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(blockpos);
this.minecraft
.getBlockRenderer()
- .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();
}
}
@@ -890,8 +_,9 @@
p_362832_.translate(blockpos1.getX() - d0, blockpos1.getY() - d1, blockpos1.getZ() - d2);
@@ -860,8 +_,9 @@
if (blockhitresult.getType() != HitResult.Type.MISS) {
BlockPos blockpos = blockhitresult.getBlockPos();
BlockState blockstate = this.level.getBlockState(blockpos);
@ -199,15 +202,15 @@
if (flag != p_361698_) {
return;
}
@@ -1019,6 +_,7 @@
compiledshaderprogram.clear();
VertexBuffer.unbind();
zone.close();
+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(p_294513_, level, this, p_294782_, p_324517_, this.ticks, this.minecraft.gameRenderer.getMainCamera(), this.getFrustum());
p_294513_.clearRenderState();
@@ -1015,6 +_,7 @@
}
zone.close();
+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(p_294513_, level, this, p_294782_, p_324517_, this.ticks, this.minecraft.gameRenderer.getMainCamera(), this.getFrustum());
p_294513_.clearRenderState();
}
@@ -1059,7 +_,15 @@
@@ -1054,7 +_,15 @@
}
}
@ -223,7 +226,7 @@
FogType fogtype = p_362177_.getFluidInCamera();
if (fogtype != FogType.POWDER_SNOW && fogtype != FogType.LAVA && !this.doesMobEffectBlockSky(p_362177_)) {
DimensionSpecialEffects dimensionspecialeffects = this.level.effects();
@@ -1068,6 +_,7 @@
@@ -1063,6 +_,7 @@
FramePass framepass = p_362870_.addPass("sky");
this.targets.main = framepass.readsAndWrites(this.targets.main);
framepass.executes(() -> {
@ -231,8 +234,8 @@
RenderSystem.setShaderFog(p_364999_);
if (dimensionspecialeffects$skytype == DimensionSpecialEffects.SkyType.END) {
this.skyRenderer.renderEndSky();
@@ -1095,6 +_,8 @@
this.skyRenderer.renderDarkDisc(posestack);
@@ -1090,6 +_,8 @@
this.skyRenderer.renderDarkDisc();
}
}
+ }
@ -240,16 +243,16 @@
});
}
}
@@ -1387,7 +_,7 @@
@@ -1382,7 +_,7 @@
} else {
int i = p_109538_.getBrightness(LightLayer.SKY, p_109540_);
int j = p_109538_.getBrightness(LightLayer.BLOCK, p_109540_);
int i = p_412967_.packedBrightness(p_109538_, p_109540_);
int j = LightTexture.block(i);
- int k = p_109539_.getLightEmission();
+ int k = p_109539_.getLightEmission(p_109538_, p_109540_);
if (j < k) {
j = k;
}
@@ -1449,5 +_,27 @@
int l = LightTexture.sky(i);
return LightTexture.pack(k, l);
@@ -1445,6 +_,28 @@
public CloudRenderer getCloudRenderer() {
return this.cloudRenderer;
@ -274,6 +277,7 @@
+
+ @org.jetbrains.annotations.ApiStatus.Internal
+ public Iterable<? extends net.neoforged.neoforge.client.IRenderableSection> getRenderableSections() {
+ return this.visibleSections;
+ return this.visibleSections;
}
}
@FunctionalInterface

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/LightTexture.java
+++ b/net/minecraft/client/renderer/LightTexture.java
@@ -141,7 +_,7 @@
@@ -142,7 +_,7 @@
}
public static int block(int p_109884_) {

View file

@ -9,9 +9,9 @@
+ 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
@@ -109,13 +_,15 @@
p_362483_.translate(maprenderstate$mapdecorationrenderstate.x / 2.0F + 64.0F, maprenderstate$mapdecorationrenderstate.y / 2.0F + 64.0F, -0.02F);
p_362483_.mulPose(Axis.ZP.rotationDegrees(maprenderstate$mapdecorationrenderstate.rot * 360 / 16.0F));
@@ -107,13 +_,15 @@
p_364922_.texture = this.mapTextureManager.prepareMapTexture(p_361383_, p_363500_);
p_364922_.decorations.clear();

View file

@ -0,0 +1,17 @@
--- a/net/minecraft/client/renderer/RenderPipelines.java
+++ b/net/minecraft/client/renderer/RenderPipelines.java
@@ -768,4 +_,14 @@
public static List<RenderPipeline> getStaticPipelines() {
return PIPELINES_BY_LOCATION.values().stream().toList();
}
+
+ @org.jetbrains.annotations.ApiStatus.Internal
+ public static void registerCustomPipelines() {
+ var event = new net.neoforged.neoforge.client.event.RegisterRenderPipelinesEvent(pipeline -> {
+ if (PIPELINES_BY_LOCATION.putIfAbsent(pipeline.getLocation(), pipeline) != null) {
+ throw new IllegalStateException("Duplicate RenderPipeline registration for location: " + pipeline.getLocation());
+ }
+ });
+ net.neoforged.fml.ModLoader.postEvent(event);
+ }
}

View file

@ -1,9 +1,20 @@
--- a/net/minecraft/client/renderer/RenderType.java
+++ b/net/minecraft/client/renderer/RenderType.java
@@ -1847,4 +_,16 @@
@@ -1210,6 +_,9 @@
if (RenderSystem.SCISSOR_STATE.isEnabled()) {
renderpass.enableScissor(RenderSystem.SCISSOR_STATE);
}
+ if (RenderSystem.STENCIL_TEST != null) {
+ renderpass.enableStencilTest(RenderSystem.STENCIL_TEST);
+ }
for (int i = 0; i < 12; i++) {
GpuTexture gputexture = RenderSystem.getShaderTexture(i);
@@ -1366,5 +_,17 @@
public String toString() {
return this.name;
}
}
+ }
+
+ // Neo: Assign internal IDs for RenderType to be used in rendering
+ private int chunkLayerId = -1;
@ -15,5 +26,5 @@
+ int i = 0;
+ for (var layer : chunkBufferLayers())
+ layer.chunkLayerId = i++;
+ }
}
}

View file

@ -10,7 +10,7 @@
+ org.apache.commons.lang3.tuple.Pair<BlockState, BlockPos> overlay = getOverlayBlock(player);
+ if (overlay != null) {
+ if (!net.neoforged.neoforge.client.ClientHooks.renderBlockOverlay(player, p_110720_, net.neoforged.neoforge.client.event.RenderBlockScreenEffectEvent.OverlayType.BLOCK, overlay.getLeft(), overlay.getRight()))
+ renderTex(p_110719_.getBlockRenderer().getBlockModelShaper().getTexture(overlay.getLeft(), p_110719_.level, overlay.getRight()), p_110720_, p_382889_);
+ renderTex(p_110719_.getBlockRenderer().getBlockModelShaper().getParticleIcon(overlay.getLeft(), p_110719_.level, overlay.getRight()), p_110720_, p_382889_);
}
}

View file

@ -1,11 +0,0 @@
--- a/net/minecraft/client/renderer/ShaderManager.java
+++ b/net/minecraft/client/renderer/ShaderManager.java
@@ -169,7 +_,7 @@
protected void apply(ShaderManager.Configs p_366597_, ResourceManager p_366533_, ProfilerFiller p_366866_) {
ShaderManager.CompilationCache shadermanager$compilationcache = new ShaderManager.CompilationCache(p_366597_);
Map<ShaderProgram, ShaderManager.CompilationException> map = new HashMap<>();
- Set<ShaderProgram> set = new HashSet<>(CoreShaders.getProgramsToPreload());
+ Set<ShaderProgram> set = new HashSet<>(net.neoforged.neoforge.client.CoreShaderManager.getProgramsToPreload());
for (PostChainConfig postchainconfig : p_366597_.postChains.values()) {
for (PostChainConfig.Pass postchainconfig$pass : postchainconfig.passes()) {

View file

@ -1,24 +1,20 @@
--- a/net/minecraft/client/renderer/Sheets.java
+++ b/net/minecraft/client/renderer/Sheets.java
@@ -156,7 +_,7 @@
@@ -158,11 +_,11 @@
}
private static Material createSignMaterial(WoodType p_173386_) {
- return createSignMaterial(ResourceLocation.withDefaultNamespace(p_173386_.name()));
+ return createSignMaterial(ResourceLocation.parse(p_173386_.name()));
}
public static Material createSignMaterial(ResourceLocation p_389416_) {
@@ -164,7 +_,7 @@
- return SIGN_MAPPER.defaultNamespaceApply(p_173386_.name());
+ return SIGN_MAPPER.apply(ResourceLocation.parse(p_173386_.name()));
}
private static Material createHangingSignMaterial(WoodType p_251735_) {
- return createHangingSignMaterial(ResourceLocation.withDefaultNamespace(p_251735_.name()));
+ return createHangingSignMaterial(ResourceLocation.parse(p_251735_.name()));
- return HANGING_SIGN_MAPPER.defaultNamespaceApply(p_251735_.name());
+ return HANGING_SIGN_MAPPER.apply(ResourceLocation.parse(p_251735_.name()));
}
public static Material createHangingSignMaterial(ResourceLocation p_389413_) {
@@ -231,6 +_,23 @@
public static Material getSignMaterial(WoodType p_173382_) {
@@ -207,6 +_,23 @@
case SINGLE:
default:
return p_110773_;

View file

@ -17,4 +17,4 @@
+ 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);
RandomSource randomsource = RandomSource.create(p_361788_ * 312987231L);

View file

@ -1,19 +1,18 @@
--- a/net/minecraft/client/renderer/block/BlockModelShaper.java
+++ b/net/minecraft/client/renderer/block/BlockModelShaper.java
@@ -22,8 +_,15 @@
@@ -17,8 +_,14 @@
this.modelManager = p_110880_;
}
+ @Deprecated
public TextureAtlasSprite getParticleIcon(BlockState p_110883_) {
- return this.getBlockModel(p_110883_).getParticleIcon();
+ return this.getBlockModel(p_110883_).getParticleIcon(net.neoforged.neoforge.client.model.data.ModelData.EMPTY);
- return this.getBlockModel(p_110883_).particleIcon();
+ return getParticleIcon(p_110883_, net.minecraft.world.level.EmptyBlockAndTintGetter.INSTANCE, net.minecraft.core.BlockPos.ZERO);
+ }
+
+ public TextureAtlasSprite getTexture(BlockState p_110883_, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) {
+ var data = level.getModelData(pos);
+ BakedModel model = this.getBlockModel(p_110883_);
+ return model.getParticleIcon(model.getModelData(level, pos, p_110883_, data));
+ public TextureAtlasSprite getParticleIcon(BlockState p_110883_, net.minecraft.world.level.BlockAndTintGetter level, net.minecraft.core.BlockPos pos) {
+ var model = this.getBlockModel(p_110883_);
+ return model.particleIcon(level, pos, p_110883_);
}
public BakedModel getBlockModel(BlockState p_110894_) {
public BlockStateModel getBlockModel(BlockState p_110894_) {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/block/BlockRenderDispatcher.java
+++ b/net/minecraft/client/renderer/block/BlockRenderDispatcher.java
@@ -37,7 +_,7 @@
@@ -41,7 +_,7 @@
this.blockModelShaper = p_173399_;
this.specialBlockModelRenderer = p_386717_;
this.blockColors = p_173401_;
@ -9,61 +9,45 @@
this.liquidBlockRenderer = new LiquidBlockRenderer();
}
@@ -45,13 +_,30 @@
return this.blockModelShaper;
@@ -54,12 +_,13 @@
BlockStateModel blockstatemodel = this.blockModelShaper.getBlockModel(p_110919_);
this.singleThreadRandom.setSeed(p_110919_.getSeed(p_110920_));
this.singleThreadPartList.clear();
- blockstatemodel.collectParts(this.singleThreadRandom, this.singleThreadPartList);
+ blockstatemodel.collectParts(p_110921_, p_110920_, p_110919_, this.singleThreadRandom, this.singleThreadPartList);
this.modelRenderer
- .tesselateBlock(p_110921_, this.singleThreadPartList, p_110919_, p_110920_, p_110922_, p_110923_, true, OverlayTexture.NO_OVERLAY);
+ .tesselateBlock(p_110921_, this.singleThreadPartList, p_110919_, p_110920_, p_110922_, type -> p_110923_, true, OverlayTexture.NO_OVERLAY);
}
}
+ @Deprecated //Forge: Model data parameter
public void renderBreakingTexture(BlockState p_110919_, BlockPos p_110920_, BlockAndTintGetter p_110921_, PoseStack p_110922_, VertexConsumer p_110923_) {
+ renderBreakingTexture(p_110919_, p_110920_, p_110921_, p_110922_, p_110923_, net.neoforged.neoforge.client.model.data.ModelData.EMPTY);
+ }
+ public void renderBreakingTexture(BlockState p_110919_, BlockPos p_110920_, BlockAndTintGetter p_110921_, PoseStack p_110922_, VertexConsumer p_110923_, net.neoforged.neoforge.client.model.data.ModelData modelData) {
if (p_110919_.getRenderShape() == RenderShape.MODEL) {
BakedModel bakedmodel = this.blockModelShaper.getBlockModel(p_110919_);
long i = p_110919_.getSeed(p_110920_);
+ modelData = bakedmodel.getModelData(p_110921_, p_110920_, p_110919_, modelData);
this.modelRenderer
- .tesselateBlock(p_110921_, bakedmodel, p_110919_, p_110920_, p_110922_, p_110923_, true, this.random, i, OverlayTexture.NO_OVERLAY);
+ .tesselateBlock(p_110921_, bakedmodel, p_110919_, p_110920_, p_110922_, p_110923_, true, this.random, i, OverlayTexture.NO_OVERLAY, modelData, null);
}
+ @Deprecated // Neo: Buffer lookup parameter
public void renderBatched(
BlockState p_234356_,
BlockPos p_234357_,
@@ -69,8 +_,20 @@
boolean p_234361_,
List<BlockModelPart> p_410643_
) {
+ this.renderBatched(p_234356_, p_234357_, p_234358_, p_234359_, type -> p_234360_, p_234361_, p_410643_);
+ }
+
+ public void renderBatched(
+ BlockState p_234356_,
+ BlockPos p_234357_,
+ BlockAndTintGetter p_234358_,
+ PoseStack p_234359_,
+ VertexConsumer p_234360_,
+ boolean p_234361_,
+ RandomSource p_234362_
+ BlockState p_234356_,
+ BlockPos p_234357_,
+ BlockAndTintGetter p_234358_,
+ PoseStack p_234359_,
+ java.util.function.Function<net.minecraft.client.renderer.RenderType, VertexConsumer> bufferLookup,
+ boolean p_234361_,
+ List<BlockModelPart> p_410643_
+ ) {
+ renderBatched(p_234356_, p_234357_, p_234358_, p_234359_, p_234360_, p_234361_, p_234362_, net.neoforged.neoforge.client.model.data.ModelData.EMPTY, null);
}
public void renderBatched(
@@ -61,7 +_,9 @@
PoseStack p_234359_,
VertexConsumer p_234360_,
boolean p_234361_,
- RandomSource p_234362_
+ RandomSource p_234362_,
+ net.neoforged.neoforge.client.model.data.ModelData modelData,
+ net.minecraft.client.renderer.RenderType renderType
) {
try {
this.modelRenderer
@@ -75,7 +_,9 @@
p_234361_,
p_234362_,
p_234356_.getSeed(p_234357_),
- OverlayTexture.NO_OVERLAY
+ OverlayTexture.NO_OVERLAY,
+ modelData,
+ renderType
);
- this.modelRenderer.tesselateBlock(p_234358_, p_410643_, p_234356_, p_234357_, p_234359_, p_234360_, p_234361_, OverlayTexture.NO_OVERLAY);
+ this.modelRenderer.tesselateBlock(p_234358_, p_410643_, p_234356_, p_234357_, p_234359_, bufferLookup, p_234361_, OverlayTexture.NO_OVERLAY);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating block in world");
@@ -87,6 +_,7 @@
CrashReportCategory crashreportcategory = crashreport.addCategory("Block being tesselated");
@@ -81,6 +_,7 @@
public void renderLiquid(BlockPos p_234364_, BlockAndTintGetter p_234365_, VertexConsumer p_234366_, BlockState p_234367_, FluidState p_234368_) {
try {
@ -71,46 +55,29 @@
this.liquidBlockRenderer.tesselate(p_234365_, p_234364_, p_234366_, p_234367_, p_234368_);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating liquid in world");
@@ -104,25 +_,33 @@
@@ -98,7 +_,12 @@
return this.blockModelShaper.getBlockModel(p_110911_);
}
+ @Deprecated //Forge: Model data and render type parameter
+ @Deprecated // Neo: Level and pos parameters
public void renderSingleBlock(BlockState p_110913_, PoseStack p_110914_, MultiBufferSource p_110915_, int p_110916_, int p_110917_) {
+ renderSingleBlock(p_110913_, p_110914_, p_110915_, p_110916_, p_110917_, net.neoforged.neoforge.client.model.data.ModelData.EMPTY, null);
+ renderSingleBlock(p_110913_, p_110914_, p_110915_, p_110916_, p_110917_, net.minecraft.world.level.EmptyBlockAndTintGetter.INSTANCE, BlockPos.ZERO);
+ }
+
+ public void renderSingleBlock(BlockState p_110913_, PoseStack p_110914_, MultiBufferSource p_110915_, int p_110916_, int p_110917_, net.neoforged.neoforge.client.model.data.ModelData modelData, @org.jetbrains.annotations.Nullable net.minecraft.client.renderer.RenderType renderType) {
+ public void renderSingleBlock(BlockState p_110913_, PoseStack p_110914_, MultiBufferSource p_110915_, int p_110916_, int p_110917_, BlockAndTintGetter level, BlockPos pos) {
RenderShape rendershape = p_110913_.getRenderShape();
if (rendershape != RenderShape.INVISIBLE) {
BakedModel bakedmodel = this.getBlockModel(p_110913_);
int i = this.blockColors.getColor(p_110913_, null, null, 0);
- float f = (float)(i >> 16 & 0xFF) / 255.0F;
- float f1 = (float)(i >> 8 & 0xFF) / 255.0F;
- float f2 = (float)(i & 0xFF) / 255.0F;
+ float f = (float) (i >> 16 & 0xFF) / 255.0F;
+ float f1 = (float) (i >> 8 & 0xFF) / 255.0F;
+ float f2 = (float) (i & 0xFF) / 255.0F;
+ for (net.minecraft.client.renderer.RenderType rt : bakedmodel.getRenderTypes(p_110913_, RandomSource.create(42), modelData))
this.modelRenderer
.renderModel(
p_110914_.last(),
- p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_)),
+ p_110915_.getBuffer(renderType != null ? renderType : net.neoforged.neoforge.client.RenderTypeHelper.getEntityRenderType(rt)),
p_110913_,
bakedmodel,
f,
f1,
f2,
p_110916_,
- p_110917_
+ p_110917_,
+ modelData,
+ rt
);
BlockStateModel blockstatemodel = this.getBlockModel(p_110913_);
@@ -107,7 +_,7 @@
float f1 = (i >> 8 & 0xFF) / 255.0F;
float f2 = (i & 0xFF) / 255.0F;
ModelBlockRenderer.renderModel(
- p_110914_.last(), p_110915_.getBuffer(ItemBlockRenderTypes.getRenderType(p_110913_)), blockstatemodel, f, f1, f2, p_110916_, p_110917_
+ p_110914_.last(), p_110915_, blockstatemodel, f, f1, f2, p_110916_, p_110917_, level, pos, p_110913_
);
this.specialBlockModelRenderer.get().renderByBlock(p_110913_.getBlock(), ItemDisplayContext.NONE, p_110914_, p_110915_, p_110916_, p_110917_);
}
@@ -131,5 +_,9 @@
@@ -116,5 +_,9 @@
@Override
public void onResourceManagerReload(ResourceManager p_110909_) {
this.liquidBlockRenderer.setupSprites();

View file

@ -1,7 +1,7 @@
--- a/net/minecraft/client/renderer/block/LiquidBlockRenderer.java
+++ b/net/minecraft/client/renderer/block/LiquidBlockRenderer.java
@@ -37,12 +_,17 @@
this.waterIcons[0] = Minecraft.getInstance().getModelManager().getBlockModelShaper().getBlockModel(Blocks.WATER.defaultBlockState()).getParticleIcon();
this.waterIcons[0] = Minecraft.getInstance().getModelManager().getBlockModelShaper().getBlockModel(Blocks.WATER.defaultBlockState()).particleIcon();
this.waterIcons[1] = ModelBakery.WATER_FLOW.sprite();
this.waterOverlay = ModelBakery.WATER_OVERLAY.sprite();
+ net.neoforged.neoforge.client.textures.FluidSpriteCache.reload();
@ -37,10 +37,10 @@
- int i = flag ? 16777215 : BiomeColors.getAverageWaterColor(p_234370_, p_234371_);
+ TextureAtlasSprite[] atextureatlassprite = net.neoforged.neoforge.client.textures.FluidSpriteCache.getFluidSprites(p_234370_, p_234371_, p_234374_);
+ int i = net.neoforged.neoforge.client.extensions.common.IClientFluidTypeExtensions.of(p_234374_).getTintColor(p_234374_, p_234370_, p_234371_);
+ float alpha = (float)(i >> 24 & 255) / 255.0F;
float f = (float)(i >> 16 & 0xFF) / 255.0F;
float f1 = (float)(i >> 8 & 0xFF) / 255.0F;
float f2 = (float)(i & 0xFF) / 255.0F;
+ float alpha = (i >> 24 & 255) / 255.0F;
float f = (i >> 16 & 0xFF) / 255.0F;
float f1 = (i >> 8 & 0xFF) / 255.0F;
float f2 = (i & 0xFF) / 255.0F;
@@ -87,12 +_,12 @@
FluidState fluidstate4 = blockstate4.getFluidState();
BlockState blockstate5 = p_234370_.getBlockState(p_234371_.relative(Direction.EAST));

View file

@ -1,230 +1,215 @@
--- a/net/minecraft/client/renderer/block/ModelBlockRenderer.java
+++ b/net/minecraft/client/renderer/block/ModelBlockRenderer.java
@@ -39,6 +_,7 @@
@@ -37,6 +_,7 @@
this.blockColors = p_110999_;
}
+ @Deprecated //Forge: Model data and render type parameter
+ @Deprecated // Neo: Buffer lookup parameter
public void tesselateBlock(
BlockAndTintGetter p_234380_,
BakedModel p_234381_,
@@ -51,14 +_,35 @@
long p_234388_,
List<BlockModelPart> p_410025_,
@@ -47,15 +_,32 @@
boolean p_234386_,
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);
+ tesselateBlock(p_234380_, p_410025_, p_234382_, p_234383_, p_234384_, type -> p_234385_, p_234386_, p_234389_);
+ }
+
+ 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_,
+ List<BlockModelPart> p_410025_,
+ BlockState p_234382_,
+ BlockPos p_234383_,
+ PoseStack p_234384_,
+ java.util.function.Function<net.minecraft.client.renderer.RenderType, VertexConsumer> bufferLookup,
+ boolean p_234386_,
+ int p_234389_
+ ) {
+ 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;
+ };
p_234384_.translate(p_234382_.getOffset(p_234383_));
if (!p_410025_.isEmpty()) {
- boolean flag = Minecraft.useAmbientOcclusion() && p_234382_.getLightEmission() == 0 && p_410025_.getFirst().useAmbientOcclusion();
+ boolean flag = Minecraft.useAmbientOcclusion() && switch(p_410025_.getFirst().ambientOcclusion()) {
+ case TRUE -> true;
+ case DEFAULT -> p_234382_.getLightEmission(p_234380_, p_234383_) == 0;
+ case FALSE -> false;
+ };
p_234384_.translate(p_234382_.getOffset(p_234383_));
try {
if (flag) {
- this.tesselateWithAO(p_234380_, p_234381_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234387_, p_234388_, p_234389_);
+ this.tesselateWithAO(p_234380_, p_234381_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234387_, p_234388_, p_234389_, modelData, renderType);
} else {
- this.tesselateWithoutAO(p_234380_, p_234381_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234387_, p_234388_, p_234389_);
+ this.tesselateWithoutAO(p_234380_, p_234381_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234387_, p_234388_, p_234389_, modelData, renderType);
}
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating block model");
@@ -69,6 +_,7 @@
try {
if (flag) {
- this.tesselateWithAO(p_234380_, p_410025_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234389_);
+ this.tesselateWithAO(p_234380_, p_410025_, p_234382_, p_234383_, p_234384_, bufferLookup, p_234386_, p_234389_);
} else {
- this.tesselateWithoutAO(p_234380_, p_410025_, p_234382_, p_234383_, p_234384_, p_234385_, p_234386_, p_234389_);
+ this.tesselateWithoutAO(p_234380_, p_410025_, p_234382_, p_234383_, p_234384_, bufferLookup, p_234386_, p_234389_);
}
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Tesselating block model");
@@ -67,6 +_,8 @@
}
}
+ @Deprecated //Forge: Model data and render type parameter
+ /** @deprecated Neo: use {@link #shouldRenderFace(BlockAndTintGetter, BlockPos, BlockState, boolean, Direction, BlockPos)} instead */
+ @Deprecated
private static boolean shouldRenderFace(BlockAndTintGetter p_412640_, BlockState p_412168_, boolean p_412054_, Direction p_412130_, BlockPos p_412608_) {
if (!p_412054_) {
return true;
@@ -76,6 +_,16 @@
}
}
+ protected static boolean shouldRenderFace(BlockAndTintGetter p_412640_, BlockPos pos, BlockState p_412168_, boolean p_412054_, Direction p_412130_, BlockPos p_412608_) {
+ if (!p_412054_) {
+ return true;
+ } else {
+ BlockState blockstate = p_412640_.getBlockState(p_412608_);
+ return Block.shouldRenderFace(p_412640_, pos, p_412168_, blockstate, p_412130_);
+ }
+ }
+
+ @Deprecated // Neo: Buffer lookup parameter
public void tesselateWithAO(
BlockAndTintGetter p_234391_,
BakedModel p_234392_,
@@ -81,6 +_,23 @@
long p_234399_,
List<BlockModelPart> p_410478_,
@@ -86,11 +_,25 @@
boolean p_234397_,
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);
+ this.tesselateWithAO(p_234391_, p_410478_, p_234393_, p_234394_, p_234395_, type -> p_234396_, p_234397_, p_234400_);
+ }
+
+ public void tesselateWithAO(
+ BlockAndTintGetter p_234391_,
+ BakedModel p_234392_,
+ List<BlockModelPart> p_410478_,
+ BlockState p_234393_,
+ BlockPos p_234394_,
+ PoseStack p_234395_,
+ VertexConsumer p_234396_,
+ java.util.function.Function<net.minecraft.client.renderer.RenderType, VertexConsumer> bufferLookup,
+ boolean p_234397_,
+ RandomSource p_234398_,
+ long p_234399_,
+ int p_234400_,
+ net.neoforged.neoforge.client.model.data.ModelData modelData,
+ net.minecraft.client.renderer.RenderType renderType
+ int p_234400_
+ ) {
float[] afloat = new float[DIRECTIONS.length * 2];
BitSet bitset = new BitSet(3);
ModelBlockRenderer.AmbientOcclusionFace modelblockrenderer$ambientocclusionface = new ModelBlockRenderer.AmbientOcclusionFace();
@@ -88,10 +_,10 @@
ModelBlockRenderer.AmbientOcclusionRenderStorage modelblockrenderer$ambientocclusionrenderstorage = new ModelBlockRenderer.AmbientOcclusionRenderStorage();
int i = 0;
int j = 0;
for (Direction direction : DIRECTIONS) {
p_234398_.setSeed(p_234399_);
- List<BakedQuad> list = p_234392_.getQuads(p_234393_, direction, p_234398_);
+ List<BakedQuad> list = p_234392_.getQuads(p_234393_, direction, p_234398_, modelData, renderType);
if (!list.isEmpty()) {
blockpos$mutableblockpos.setWithOffset(p_234394_, direction);
- if (!p_234397_ || Block.shouldRenderFace(p_234393_, p_234391_.getBlockState(blockpos$mutableblockpos), direction)) {
+ 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_);
- List<BakedQuad> list1 = p_234392_.getQuads(p_234393_, null, p_234398_);
+ List<BakedQuad> list1 = p_234392_.getQuads(p_234393_, (Direction)null, p_234398_, modelData, renderType);
if (!list1.isEmpty()) {
this.renderModelFaceAO(
p_234391_, p_234393_, p_234394_, p_234395_, p_234396_, list1, afloat, bitset, modelblockrenderer$ambientocclusionface, p_234400_
@@ -108,6 +_,7 @@
for (BlockModelPart blockmodelpart : p_410478_) {
+ VertexConsumer p_234396_ = bufferLookup.apply(blockmodelpart.getRenderType(p_234393_));
for (Direction direction : DIRECTIONS) {
int k = 1 << direction.ordinal();
boolean flag = (i & k) == 1;
@@ -101,6 +_,7 @@
if (!flag) {
flag1 = shouldRenderFace(
p_234391_,
+ p_234394_,
p_234393_,
p_234397_,
direction,
@@ -130,6 +_,7 @@
}
}
+ @Deprecated //Forge: Model data and render type parameter
+ @Deprecated // Neo: Buffer lookup parameter
public void tesselateWithoutAO(
BlockAndTintGetter p_234402_,
BakedModel p_234403_,
@@ -120,15 +_,32 @@
long p_234410_,
List<BlockModelPart> p_410604_,
@@ -140,11 +_,25 @@
boolean p_234408_,
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);
+ this.tesselateWithoutAO(p_234402_, p_410604_, p_234404_, p_234405_, p_234406_, type -> p_234407_, p_234408_, p_234411_);
+ }
+
+ public void tesselateWithoutAO(
+ BlockAndTintGetter p_234402_,
+ BakedModel p_234403_,
+ List<BlockModelPart> p_410604_,
+ BlockState p_234404_,
+ BlockPos p_234405_,
+ PoseStack p_234406_,
+ VertexConsumer p_234407_,
+ java.util.function.Function<net.minecraft.client.renderer.RenderType, VertexConsumer> bufferLookup,
+ boolean p_234408_,
+ RandomSource p_234409_,
+ long p_234410_,
+ int p_234411_,
+ net.neoforged.neoforge.client.model.data.ModelData modelData,
+ net.minecraft.client.renderer.RenderType renderType
+ int p_234411_
+ ) {
BitSet bitset = new BitSet(3);
BlockPos.MutableBlockPos blockpos$mutableblockpos = p_234405_.mutable();
ModelBlockRenderer.CommonRenderStorage modelblockrenderer$commonrenderstorage = new ModelBlockRenderer.CommonRenderStorage();
int i = 0;
int j = 0;
for (Direction direction : DIRECTIONS) {
p_234409_.setSeed(p_234410_);
- List<BakedQuad> list = p_234403_.getQuads(p_234404_, direction, p_234409_);
+ List<BakedQuad> list = p_234403_.getQuads(p_234404_, direction, p_234409_, modelData, renderType);
if (!list.isEmpty()) {
blockpos$mutableblockpos.setWithOffset(p_234405_, direction);
- if (!p_234408_ || Block.shouldRenderFace(p_234404_, p_234402_.getBlockState(blockpos$mutableblockpos), direction)) {
+ 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_);
- List<BakedQuad> list1 = p_234403_.getQuads(p_234404_, null, p_234409_);
+ List<BakedQuad> list1 = p_234403_.getQuads(p_234404_, null, p_234409_, modelData, renderType);
if (!list1.isEmpty()) {
this.renderModelFaceFlat(p_234402_, p_234404_, p_234405_, -1, p_234411_, true, p_234406_, p_234407_, list1, bitset);
}
@@ -156,6 +_,7 @@
for (BlockModelPart blockmodelpart : p_410604_) {
+ VertexConsumer p_234407_ = bufferLookup.apply(blockmodelpart.getRenderType(p_234404_));
for (Direction direction : DIRECTIONS) {
int k = 1 << direction.ordinal();
boolean flag = (i & k) == 1;
@@ -154,7 +_,7 @@
if (!list.isEmpty()) {
BlockPos blockpos = modelblockrenderer$commonrenderstorage.scratchPos.setWithOffset(p_234405_, direction);
if (!flag) {
- flag1 = shouldRenderFace(p_234402_, p_234404_, p_234408_, direction, blockpos);
+ flag1 = shouldRenderFace(p_234402_, p_234405_, p_234404_, p_234408_, direction, blockpos);
i |= k;
if (flag1) {
j |= k;
@@ -192,6 +_,7 @@
) {
for (BakedQuad bakedquad : p_111018_) {
this.calculateShape(p_111013_, p_111014_, p_111015_, bakedquad.getVertices(), bakedquad.getDirection(), p_111019_, p_111020_);
+ if (!net.neoforged.neoforge.client.ClientHooks.calculateFaceWithoutAO(p_111013_, p_111014_, p_111015_, bakedquad, p_111020_.get(0), p_111021_.brightness, p_111021_.lightmap))
p_111021_.calculate(p_111013_, p_111014_, p_111015_, bakedquad.getDirection(), p_111019_, p_111020_, bakedquad.isShade());
this.putQuadData(
p_111013_,
@@ -321,6 +_,7 @@
calculateShape(p_111013_, p_111014_, p_111015_, bakedquad.vertices(), bakedquad.direction(), p_412172_);
+ if (!net.neoforged.neoforge.client.ClientHooks.calculateFaceWithoutAO(p_111013_, p_111014_, p_111015_, bakedquad, p_412172_.cache, p_412172_.faceCubic, p_412172_.brightness, p_412172_.lightmap))
p_412172_.calculate(p_111013_, p_111014_, p_111015_, bakedquad.direction(), bakedquad.shade());
this.putQuadData(p_111013_, p_111014_, p_111015_, p_111017_, p_111016_.last(), bakedquad, p_412172_, p_111022_);
}
@@ -326,6 +_,7 @@
}
}
+ @Deprecated //Forge: Model data and render type parameter
public void renderModel(
+ @Deprecated // Neo: Level, position, and buffer source parameters
public static void renderModel(
PoseStack.Pose p_111068_,
VertexConsumer p_111069_,
@@ -332,16 +_,32 @@
@@ -336,7 +_,24 @@
int p_111075_,
int p_111076_
) {
+ renderModel(p_111068_, p_111069_, p_111070_, p_111071_, p_111072_, p_111073_, p_111074_, p_111075_, p_111076_, net.neoforged.neoforge.client.model.data.ModelData.EMPTY, null);
- for (BlockModelPart blockmodelpart : p_405848_.collectParts(RandomSource.create(42L))) {
+ renderModel(p_111068_, type -> p_111069_, p_405848_, p_111072_, p_111073_, p_111074_, p_111075_, p_111076_, net.minecraft.world.level.EmptyBlockAndTintGetter.INSTANCE, BlockPos.ZERO, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState());
+ }
+
+ public void renderModel(
+ public static void renderModel(
+ PoseStack.Pose p_111068_,
+ VertexConsumer p_111069_,
+ @Nullable BlockState p_111070_,
+ BakedModel p_111071_,
+ net.minecraft.client.renderer.MultiBufferSource bufferSource,
+ BlockStateModel p_405848_,
+ float p_111072_,
+ float p_111073_,
+ float p_111074_,
+ int p_111075_,
+ int p_111076_,
+ net.neoforged.neoforge.client.model.data.ModelData modelData,
+ net.minecraft.client.renderer.RenderType renderType
+ net.minecraft.world.level.BlockAndTintGetter level,
+ BlockPos pos,
+ BlockState state
+ ) {
RandomSource randomsource = RandomSource.create();
long i = 42L;
for (Direction direction : DIRECTIONS) {
randomsource.setSeed(42L);
- renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, direction, randomsource), p_111075_, p_111076_);
+ renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, direction, randomsource, modelData, renderType), p_111075_, p_111076_);
}
randomsource.setSeed(42L);
- renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, null, randomsource), p_111075_, p_111076_);
+ renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, p_111071_.getQuads(p_111070_, null, randomsource, modelData, renderType), p_111075_, p_111076_);
}
private static void renderQuadList(
@@ -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_366875_)
+ for (BlockModelPart blockmodelpart : p_405848_.collectParts(level, pos, state, RandomSource.create(42L))) {
+ VertexConsumer p_111069_ = bufferSource.getBuffer(net.neoforged.neoforge.client.RenderTypeHelper.getEntityRenderType(blockmodelpart.getRenderType(state)));
for (Direction direction : DIRECTIONS) {
renderQuadList(p_111068_, p_111069_, p_111072_, p_111073_, p_111074_, blockmodelpart.getQuads(direction), p_111075_, p_111076_);
}
@@ -719,19 +_,19 @@
int l = this.cache.getLightColor(blockstate3, p_412286_, blockpos$mutableblockpos);
float f3 = this.cache.getShadeBrightness(blockstate3, p_412286_, blockpos$mutableblockpos);
BlockState blockstate4 = p_412286_.getBlockState(
- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[0]).move(p_412336_)
+ 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() == 0;
BlockState blockstate5 = p_111168_.getBlockState(
- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[1]).move(p_366875_)
boolean flag = !blockstate4.isViewBlocking(p_412286_, blockpos$mutableblockpos) || blockstate4.getLightBlock() == 0;
BlockState blockstate5 = p_412286_.getBlockState(
- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[1]).move(p_412336_)
+ 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() == 0;
BlockState blockstate6 = p_111168_.getBlockState(
- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[2]).move(p_366875_)
boolean flag1 = !blockstate5.isViewBlocking(p_412286_, blockpos$mutableblockpos) || blockstate5.getLightBlock() == 0;
BlockState blockstate6 = p_412286_.getBlockState(
- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[2]).move(p_412336_)
+ 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() == 0;
BlockState blockstate7 = p_111168_.getBlockState(
- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[3]).move(p_366875_)
boolean flag2 = !blockstate6.isViewBlocking(p_412286_, blockpos$mutableblockpos) || blockstate6.getLightBlock() == 0;
BlockState blockstate7 = p_412286_.getBlockState(
- blockpos$mutableblockpos.setWithOffset(blockpos, modelblockrenderer$adjacencyinfo.corners[3]).move(p_412336_)
+ 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() == 0;
boolean flag3 = !blockstate7.isViewBlocking(p_412286_, blockpos$mutableblockpos) || blockstate7.getLightBlock() == 0;
float f4;

View file

@ -1,37 +1,21 @@
--- a/net/minecraft/client/renderer/block/model/BakedQuad.java
+++ b/net/minecraft/client/renderer/block/model/BakedQuad.java
@@ -13,14 +_,20 @@
protected final TextureAtlasSprite sprite;
private final boolean shade;
private final int lightEmission;
+ private final boolean hasAmbientOcclusion;
@@ -5,8 +_,17 @@
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
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);
+/**
+ * @param hasAmbientOcclusion {@code false} to force-disable AO for this quad
+ * or {@code true} to use the behavior dictated by
+ * {@link net.neoforged.neoforge.client.extensions.IBakedModelExtension#useAmbientOcclusion(net.minecraft.world.level.block.state.BlockState, net.neoforged.neoforge.client.model.data.ModelData, net.minecraft.client.renderer.RenderType)}
+ */
@OnlyIn(Dist.CLIENT)
-public record BakedQuad(int[] vertices, int tintIndex, Direction direction, TextureAtlasSprite sprite, boolean shade, int lightEmission) {
+public record BakedQuad(int[] vertices, int tintIndex, Direction direction, TextureAtlasSprite sprite, boolean shade, int lightEmission, boolean hasAmbientOcclusion) {
+ public BakedQuad(int[] vertices, int tintIndex, Direction direction, TextureAtlasSprite sprite, boolean shade, int lightEmission) {
+ this(vertices, tintIndex, direction, sprite, shade, lightEmission, true);
+ }
+
+ public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, int p_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 boolean isTinted() {
return this.tintIndex != -1;
}
public TextureAtlasSprite getSprite() {
@@ -49,5 +_,13 @@
public int getLightEmission() {
return this.lightEmission;
+ }
+
+ /**
+ * {@return false to force-disable AO for this quad or true to use the behavior dictated by
+ * {@link net.neoforged.neoforge.client.extensions.IBakedModelExtension#useAmbientOcclusion(net.minecraft.world.level.block.state.BlockState, net.neoforged.neoforge.client.model.data.ModelData, net.minecraft.client.renderer.RenderType)}}
+ */
+ public boolean hasAmbientOcclusion() {
+ return this.hasAmbientOcclusion;
}
}

View file

@ -1,34 +1,28 @@
--- a/net/minecraft/client/renderer/block/model/BlockElement.java
+++ b/net/minecraft/client/renderer/block/model/BlockElement.java
@@ -31,6 +_,7 @@
public final BlockElementRotation rotation;
public final boolean shade;
public final int lightEmission;
+ private net.neoforged.neoforge.client.model.ExtraFaceData faceData;
@@ -22,12 +_,20 @@
public BlockElement(Vector3f p_253626_, Vector3f p_254426_, Map<Direction, BlockElementFace> p_254454_) {
this(p_253626_, p_254426_, p_254454_, null, true, 0);
@@ -44,6 +_,10 @@
boolean p_361372_,
int p_361908_
) {
+ this(p_361324_, p_363867_, p_362722_, p_360926_, p_361372_, p_361908_, net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT);
@OnlyIn(Dist.CLIENT)
public record BlockElement(
- Vector3fc from, Vector3fc to, Map<Direction, BlockElementFace> faces, @Nullable BlockElementRotation rotation, boolean shade, int lightEmission
+ Vector3fc from, Vector3fc to, Map<Direction, BlockElementFace> faces, @Nullable BlockElementRotation rotation, boolean shade, int lightEmission, net.neoforged.neoforge.client.model.ExtraFaceData faceData
) {
private static final boolean DEFAULT_RESCALE = false;
private static final float MIN_EXTENT = -16.0F;
private static final float MAX_EXTENT = 32.0F;
+ public BlockElement {
+ faces.values().forEach(face -> face.parent().setValue(this));
+ }
+
+ public BlockElement(Vector3f p_361324_, Vector3f p_363867_, Map<Direction, BlockElementFace> 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_;
@@ -51,6 +_,8 @@
this.shade = p_361372_;
this.lightEmission = p_361908_;
this.fillUvs();
+ this.setFaceData(faceData);
+ this.faces.values().forEach(face -> face.parent().setValue(this));
+ public BlockElement(Vector3fc from, Vector3fc to, Map<Direction, BlockElementFace> faces, @Nullable BlockElementRotation rotation, boolean shade, int lightEmission) {
+ this(from, to, faces, rotation, shade, lightEmission, net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT);
+ }
+
public BlockElement(Vector3fc p_405527_, Vector3fc p_405454_, Map<Direction, BlockElementFace> p_362722_) {
this(p_405527_, p_405454_, p_362722_, null, true, 0);
}
private void fillUvs() {
@@ -98,7 +_,8 @@
@@ -59,7 +_,8 @@
}
}
@ -38,17 +32,3 @@
}
}
@@ -209,5 +_,13 @@
return new Vector3f(afloat[0], afloat[1], afloat[2]);
}
}
+ }
+
+ public net.neoforged.neoforge.client.model.ExtraFaceData getFaceData() {
+ return this.faceData;
+ }
+
+ public void setFaceData(net.neoforged.neoforge.client.model.ExtraFaceData faceData) {
+ this.faceData = java.util.Objects.requireNonNull(faceData);
}
}

View file

@ -1,38 +1,44 @@
--- a/net/minecraft/client/renderer/block/model/BlockElementFace.java
+++ b/net/minecraft/client/renderer/block/model/BlockElementFace.java
@@ -13,9 +_,23 @@
@@ -15,7 +_,7 @@
import net.neoforged.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
-public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, BlockFaceUV uv) {
+public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, BlockFaceUV uv, @Nullable net.neoforged.neoforge.client.model.ExtraFaceData faceData, org.apache.commons.lang3.mutable.MutableObject<BlockElement> parent) {
-public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, @Nullable BlockElementFace.UVs uvs, Quadrant rotation) {
+public record BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, @Nullable BlockElementFace.UVs uvs, Quadrant rotation, @Nullable net.neoforged.neoforge.client.model.ExtraFaceData faceData, org.apache.commons.lang3.mutable.MutableObject<BlockElement> parent) {
public static final int NO_TINT = -1;
+ public BlockElementFace(@Nullable Direction p_111359_, int p_111360_, String p_111361_, BlockFaceUV p_111362_) {
+ this(p_111359_, p_111360_, p_111361_, p_111362_, null, new org.apache.commons.lang3.mutable.MutableObject<>());
public static float getU(BlockElementFace.UVs p_405199_, Quadrant p_404689_, int p_404785_) {
@@ -26,6 +_,21 @@
return p_405500_.getVertexV(p_404709_.rotateVertexIndex(p_405113_)) / 16.0F;
}
+ public BlockElementFace(@Nullable Direction cullForDirection, int tintIndex, String texture, @Nullable BlockElementFace.UVs uvs, Quadrant rotation) {
+ this(cullForDirection, tintIndex, texture, uvs, rotation, null, new org.apache.commons.lang3.mutable.MutableObject<>());
+ }
+
+ @Override
+ public net.neoforged.neoforge.client.model.ExtraFaceData faceData() {
+ if(this.faceData != null) {
+ if (this.faceData != null) {
+ return this.faceData;
+ } else if(this.parent.getValue() != null) {
+ return this.parent.getValue().getFaceData();
+ } else if (this.parent.getValue() != null) {
+ return this.parent.getValue().faceData();
+ } else {
+ return net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT;
+ }
+ return net.neoforged.neoforge.client.model.ExtraFaceData.DEFAULT;
+ }
+
@OnlyIn(Dist.CLIENT)
public static class Deserializer implements JsonDeserializer<BlockElementFace> {
private static final int DEFAULT_TINT_INDEX = -1;
@@ -26,7 +_,9 @@
int i = this.getTintIndex(jsonobject);
String s = this.getTexture(jsonobject);
BlockFaceUV blockfaceuv = p_111367_.deserialize(jsonobject, BlockFaceUV.class);
- return new BlockElementFace(direction, i, s, blockfaceuv);
@@ -38,7 +_,9 @@
String s = getTexture(jsonobject);
BlockElementFace.UVs blockelementface$uvs = getUVs(jsonobject);
Quadrant quadrant = getRotation(jsonobject);
- return new BlockElementFace(direction, i, s, blockelementface$uvs, quadrant);
+ if (jsonobject.has("forge_data")) throw new JsonParseException("forge_data should be replaced by neoforge_data"); // TODO 1.22: Remove
+ var faceData = net.neoforged.neoforge.client.model.ExtraFaceData.read(jsonobject.get("neoforge_data"), null);
+ return new BlockElementFace(direction, i, s, blockfaceuv, faceData, new org.apache.commons.lang3.mutable.MutableObject<>());
+ return new BlockElementFace(direction, i, s, blockelementface$uvs, quadrant, faceData, new org.apache.commons.lang3.mutable.MutableObject<>());
}
protected int getTintIndex(JsonObject p_111369_) {
private static int getTintIndex(JsonObject p_111369_) {

View file

@ -1,28 +1,25 @@
--- a/net/minecraft/client/renderer/block/model/BlockModel.java
+++ b/net/minecraft/client/renderer/block/model/BlockModel.java
@@ -29,12 +_,14 @@
public class BlockModel implements UnbakedModel, net.neoforged.neoforge.client.model.ExtendedUnbakedModel {
@@ -28,21 +_,48 @@
@Nullable Boolean ambientOcclusion,
@Nullable ItemTransforms transforms,
TextureSlots.Data textureSlots,
- @Nullable ResourceLocation parent
+ @Nullable ResourceLocation parent,
+ @Nullable com.mojang.math.Transformation rootTransform,
+ net.neoforged.neoforge.client.RenderTypeGroup renderTypeGroup,
+ java.util.Map<String, Boolean> partVisibility
) implements UnbakedModel {
@VisibleForTesting
public static final Gson GSON = new GsonBuilder()
+ .registerTypeHierarchyAdapter(UnbakedModel.class, new net.neoforged.neoforge.client.model.UnbakedModelParser.Deserializer())
.registerTypeAdapter(BlockModel.class, new BlockModel.Deserializer())
.registerTypeAdapter(BlockElement.class, new BlockElement.Deserializer())
.registerTypeAdapter(BlockElementFace.class, new BlockElementFace.Deserializer())
.registerTypeAdapter(BlockFaceUV.class, new BlockFaceUV.Deserializer())
.registerTypeAdapter(ItemTransform.class, new ItemTransform.Deserializer())
.registerTypeAdapter(ItemTransforms.class, new ItemTransforms.Deserializer())
+ .registerTypeAdapter(com.mojang.math.Transformation.class, new net.neoforged.neoforge.common.util.TransformationHelper.Deserializer())
.create();
private final List<BlockElement> elements;
@Nullable
@@ -49,7 +_,15 @@
private UnbakedModel parent;
@Nullable
private final ResourceLocation parentLocation;
+ @Nullable
+ private final com.mojang.math.Transformation rootTransform;
+ private final net.neoforged.neoforge.client.RenderTypeGroup renderTypeGroup;
+ private final java.util.Map<String, Boolean> partVisibility;
+ /**
+ * @deprecated Neo: use {@link net.neoforged.neoforge.client.model.UnbakedModelParser#parse(Reader)} instead
@ -31,56 +28,18 @@
public static BlockModel fromStream(Reader p_111462_) {
return GsonHelper.fromJson(GSON, p_111462_, BlockModel.class);
}
@@ -62,12 +_,29 @@
@Nullable UnbakedModel.GuiLight p_387948_,
@Nullable ItemTransforms p_273480_
) {
+ this(p_273263_, p_272668_, p_386899_, p_272676_, p_387948_, p_273480_, null, net.neoforged.neoforge.client.RenderTypeGroup.EMPTY, java.util.Map.of());
+ public BlockModel(
+ @Nullable UnbakedGeometry geometry,
+ @Nullable UnbakedModel.GuiLight guiLight,
+ @Nullable Boolean ambientOcclusion,
+ @Nullable ItemTransforms transforms,
+ TextureSlots.Data textureSlots,
+ @Nullable ResourceLocation parent
+ ) {
+ this(geometry, guiLight, ambientOcclusion, transforms, textureSlots, parent, null, net.neoforged.neoforge.client.RenderTypeGroup.EMPTY, java.util.Map.of());
+ }
+
+ public BlockModel(
+ @Nullable ResourceLocation p_273263_,
+ List<BlockElement> p_272668_,
+ TextureSlots.Data p_386899_,
+ @Nullable Boolean p_272676_,
+ @Nullable UnbakedModel.GuiLight p_387948_,
+ @Nullable ItemTransforms p_273480_,
+ @Nullable com.mojang.math.Transformation rootTransform,
+ net.neoforged.neoforge.client.RenderTypeGroup renderTypeGroup,
+ java.util.Map<String, Boolean> partVisibility
+ ) {
this.elements = p_272668_;
this.hasAmbientOcclusion = p_272676_;
this.guiLight = p_387948_;
this.textureSlots = p_386899_;
this.parentLocation = p_273263_;
this.transforms = p_273480_;
+ this.rootTransform = rootTransform;
+ this.renderTypeGroup = renderTypeGroup;
+ this.partVisibility = partVisibility;
}
@Nullable
@@ -107,10 +_,12 @@
}
@Override
- public BakedModel bake(TextureSlots p_387258_, ModelBaker p_388168_, ModelState p_111453_, boolean p_111455_, boolean p_387632_, ItemTransforms p_386577_) {
+ public BakedModel bake(TextureSlots p_387258_, ModelBaker p_388168_, ModelState p_111453_, boolean p_111455_, boolean p_387632_, ItemTransforms p_386577_, net.minecraft.util.context.ContextMap additionalProperties) {
return this.elements.isEmpty() && this.parent != null
- ? this.parent.bake(p_387258_, p_388168_, p_111453_, p_111455_, p_387632_, p_386577_)
- : SimpleBakedModel.bakeElements(this.elements, p_387258_, p_388168_.sprites(), p_111453_, p_111455_, p_387632_, true, p_386577_);
+ ? this.parent.bake(p_387258_, p_388168_, p_111453_, p_111455_, p_387632_, p_386577_, additionalProperties)
+ : SimpleBakedModel.bakeElements(this.elements, p_387258_, p_388168_.sprites(), p_111453_, p_111455_, p_387632_, true, p_386577_,
+ additionalProperties.getOrDefault(net.neoforged.neoforge.client.model.NeoForgeModelProperties.TRANSFORM, com.mojang.math.Transformation.identity()),
+ additionalProperties.getOrDefault(net.neoforged.neoforge.client.model.NeoForgeModelProperties.RENDER_TYPE, net.neoforged.neoforge.client.RenderTypeGroup.EMPTY));
}
@Nullable
@@ -125,6 +_,13 @@
return this.parentLocation;
}
+ @Override
+ public void fillAdditionalProperties(net.minecraft.util.context.ContextMap.Builder propertiesBuilder) {
+ net.neoforged.neoforge.client.model.NeoForgeModelProperties.fillRootTransformProperty(propertiesBuilder, this.rootTransform);
@ -91,17 +50,17 @@
@OnlyIn(Dist.CLIENT)
public static class Deserializer implements JsonDeserializer<BlockModel> {
public BlockModel deserialize(JsonElement p_111498_, Type p_111499_, JsonDeserializationContext p_111500_) throws JsonParseException {
@@ -145,7 +_,12 @@
@@ -63,7 +_,12 @@
}
ResourceLocation resourcelocation = s.isEmpty() ? null : ResourceLocation.parse(s);
- return new BlockModel(resourcelocation, list, textureslots$data, obool, unbakedmodel$guilight, itemtransforms);
- return new BlockModel(unbakedgeometry, unbakedmodel$guilight, obool, itemtransforms, textureslots$data, resourcelocation);
+
+ var rootTransform = net.neoforged.neoforge.client.model.NeoForgeModelProperties.deserializeRootTransform(jsonobject, p_111500_);
+ var renderTypeGroup = net.neoforged.neoforge.client.model.NeoForgeModelProperties.deserializeRenderType(jsonobject);
+ var partVisibility = net.neoforged.neoforge.client.model.NeoForgeModelProperties.deserializePartVisibility(jsonobject);
+
+ return new BlockModel(resourcelocation, list, textureslots$data, obool, unbakedmodel$guilight, itemtransforms, rootTransform, renderTypeGroup, partVisibility);
+ return new BlockModel(unbakedgeometry, unbakedmodel$guilight, obool, itemtransforms, textureslots$data, resourcelocation, rootTransform, renderTypeGroup, partVisibility);
}
private TextureSlots.Data getTextureMap(JsonObject p_111510_) {

Some files were not shown because too many files have changed in this diff Show more