mirror of
https://github.com/neoforged/NeoForge.git
synced 2026-10-12 02:19:42 +00:00
Port to 26.2-pre-2
Co-Authored-By: Dennis C <[email protected]> Co-Authored-By: RogueLogix <[email protected]>
This commit is contained in:
co-authored by
Dennis C
RogueLogix
parent
272ac27afc
commit
f6b195024f
+7
-1
@@ -88,6 +88,12 @@ immaculate {
|
||||
|
||||
def interfaceChange = Pattern.compile('[-+].*(implements|(interface.*extends))(.*)\\{')
|
||||
custom 'noInterfaceModifications', { String fileContents ->
|
||||
// FIXME: remove when handling of Holder is resolved
|
||||
// Special case: removal of sealed and permits incorrectly triggers interface change detection
|
||||
if (fileContents.startsWith("--- a/net/minecraft/core/Holder.java")) {
|
||||
return fileContents
|
||||
}
|
||||
|
||||
def interfaceChanges = fileContents.lines().filter { it.matches(interfaceChange) }.toList()
|
||||
if (interfaceChanges.isEmpty()) return fileContents
|
||||
String oldInterfaces = ""
|
||||
@@ -125,7 +131,7 @@ immaculate {
|
||||
accessChanges.each { String change ->
|
||||
//Get the type of match
|
||||
String[] data = change.substring(1).trim().split(" ", 2)
|
||||
String lineStart = data[1].substring(0, Math.min(10, data[1].length()))
|
||||
String lineStart = data[1].substring(0, Math.min(30, data[1].length()))
|
||||
if (change.startsWith('-')) {//Removal
|
||||
removals.get(data[0]).add(lineStart)
|
||||
} else {//Addition
|
||||
|
||||
+4
-6
@@ -16,14 +16,14 @@ diffpatch_version=2.1.0.43
|
||||
|
||||
java_version=25
|
||||
|
||||
minecraft_version=26.1.2
|
||||
minecraft_version=26.2-pre-2
|
||||
neoform_version=1
|
||||
# on snapshot versions, used to prefix the version
|
||||
# should always have 3 components (major.minor.hotfix)
|
||||
neoforge_snapshot_next_stable=26.1.2
|
||||
neoforge_snapshot_next_stable=26.2
|
||||
|
||||
# renovate: net.neoforged.jst:jst-cli-bundle
|
||||
jst_version=1.0.67
|
||||
jst_version=2.0.8
|
||||
legacyinstaller_version=3.0.+
|
||||
# renovate: net.neoforged.installertools:installertools
|
||||
installertools_version=4.0.12
|
||||
@@ -49,6 +49,4 @@ vintage_engine_version=5.+
|
||||
assertj_core=3.25.1
|
||||
|
||||
# renovate: org.eclipse.jdt:org.eclipse.jdt.core
|
||||
jdt_core_version=3.42.0
|
||||
|
||||
neogradle.runtime.platform.installer.debug=true
|
||||
jdt_core_version=3.42.0
|
||||
@@ -1,49 +1,62 @@
|
||||
--- a/com/mojang/blaze3d/opengl/DirectStateAccess.java
|
||||
+++ b/com/mojang/blaze3d/opengl/DirectStateAccess.java
|
||||
@@ -42,7 +_,11 @@
|
||||
@@ -40,10 +_,18 @@
|
||||
|
||||
abstract int createFrameBufferObject();
|
||||
public abstract int createFrameBufferObject();
|
||||
|
||||
- abstract void bindFrameBufferTextures(int fbo, int color0, int depth, int mipLevel, int bindSlot);
|
||||
+ abstract void bindFrameBufferTextures(int fbo, int color0, int depth, int mipLevel, int bindSlot, boolean useStencil);
|
||||
- public abstract void bindFrameBufferTextures(int fbo, int[] color, int[] colorMipLevels, int depth, int depthMipLevel, int bindSlot);
|
||||
+ public abstract void bindFrameBufferTextures(int fbo, int[] color, int[] colorMipLevels, int depth, int depthMipLevel, int bindSlot, boolean useStencil);
|
||||
+
|
||||
+ public void bindFrameBufferTextures(int fbo, int color0, int depth, int mipLevel, int bindSlot) {
|
||||
+ bindFrameBufferTextures(fbo, color0, depth, mipLevel, bindSlot, false);
|
||||
+ public void bindFrameBufferTextures(int fbo, int[] color, int[] colorMipLevels, int depth, int depthMipLevel, int bindSlot) {
|
||||
+ this.bindFrameBufferTextures(fbo, color, colorMipLevels, depth, depthMipLevel, bindSlot, false);
|
||||
+ }
|
||||
|
||||
abstract void blitFrameBuffers(
|
||||
int source, int dest, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter
|
||||
@@ -101,9 +_,14 @@
|
||||
public void bindFrameBufferTextures(int fbo, int color, int depth, int mipLevel, int bindSlot) {
|
||||
- this.bindFrameBufferTextures(fbo, new int[]{color}, new int[]{mipLevel}, depth, mipLevel, bindSlot);
|
||||
+ this.bindFrameBufferTextures(fbo, color, depth, mipLevel, bindSlot, false);
|
||||
+ }
|
||||
+
|
||||
+ public void bindFrameBufferTextures(int fbo, int color, int depth, int mipLevel, int bindSlot, boolean useStencil) {
|
||||
+ this.bindFrameBufferTextures(fbo, new int[]{color}, new int[]{mipLevel}, depth, mipLevel, bindSlot, useStencil);
|
||||
}
|
||||
|
||||
public abstract void blitFrameBuffers(
|
||||
@@ -102,12 +_,17 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void bindFrameBufferTextures(int fbo, int color0, int depth, int mipLevel, @GpuBuffer.Usage int bindSlot) {
|
||||
+ public void bindFrameBufferTextures(int fbo, int color0, int depth, int mipLevel, @GpuBuffer.Usage int bindSlot, boolean useStencil) {
|
||||
ARBDirectStateAccess.glNamedFramebufferTexture(fbo, 36064, color0, mipLevel);
|
||||
ARBDirectStateAccess.glNamedFramebufferTexture(fbo, 36096, depth, mipLevel);
|
||||
- public void bindFrameBufferTextures(int fbo, int[] color, int[] colorMipLevels, int depth, int depthMipLevel, int bindSlot) {
|
||||
+ public void bindFrameBufferTextures(int fbo, int[] color, int[] colorMipLevels, int depth, int depthMipLevel, int bindSlot, boolean useStencil) {
|
||||
for (int i = 0; i < color.length; i++) {
|
||||
ARBDirectStateAccess.glNamedFramebufferTexture(fbo, 36064 + i, color[i], colorMipLevels[i]);
|
||||
}
|
||||
|
||||
ARBDirectStateAccess.glNamedFramebufferTexture(fbo, 36096, depth, depthMipLevel);
|
||||
+ if (useStencil) {
|
||||
+ ARBDirectStateAccess.glNamedFramebufferTexture(fbo, org.lwjgl.opengl.GL32C.GL_STENCIL_ATTACHMENT, depth, mipLevel);
|
||||
+ ARBDirectStateAccess.glNamedFramebufferTexture(fbo, GL33C.GL_STENCIL_ATTACHMENT, depth, depthMipLevel);
|
||||
+ } else {
|
||||
+ ARBDirectStateAccess.glNamedFramebufferTexture(fbo, org.lwjgl.opengl.GL32C.GL_STENCIL_ATTACHMENT, 0, 0);
|
||||
+ ARBDirectStateAccess.glNamedFramebufferTexture(fbo, GL33C.GL_STENCIL_ATTACHMENT, 0, 0);
|
||||
+ }
|
||||
if (bindSlot != 0) {
|
||||
GlStateManager._glBindFramebuffer(bindSlot, fbo);
|
||||
}
|
||||
@@ -224,12 +_,17 @@
|
||||
@@ -217,7 +_,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void bindFrameBufferTextures(int fbo, int color0, int depth, int mipLevel, int bindSlot) {
|
||||
+ public void bindFrameBufferTextures(int fbo, int color0, int depth, int mipLevel, int bindSlot, boolean useStencil) {
|
||||
int tempBindSlot = bindSlot == 0 ? '\u8ca9' : bindSlot;
|
||||
- public void bindFrameBufferTextures(int fbo, int[] color, int[] colorMipLevels, int depth, int depthMipLevel, int bindSlot) {
|
||||
+ public void bindFrameBufferTextures(int fbo, int[] color, int[] colorMipLevels, int depth, int depthMipLevel, int bindSlot, boolean useStencil) {
|
||||
int tempBindSlot = bindSlot == 0 ? 36009 : bindSlot;
|
||||
int oldFbo = GlStateManager.getFrameBuffer(tempBindSlot);
|
||||
GlStateManager._glBindFramebuffer(tempBindSlot, fbo);
|
||||
GlStateManager._glFramebufferTexture2D(tempBindSlot, 36064, 3553, color0, mipLevel);
|
||||
GlStateManager._glFramebufferTexture2D(tempBindSlot, 36096, 3553, depth, mipLevel);
|
||||
@@ -227,6 +_,11 @@
|
||||
}
|
||||
|
||||
GlStateManager._glFramebufferTexture2D(tempBindSlot, 36096, 3553, depth, depthMipLevel);
|
||||
+ if (useStencil) {
|
||||
+ GlStateManager._glFramebufferTexture2D(tempBindSlot, org.lwjgl.opengl.GL32C.GL_STENCIL_ATTACHMENT, 3553, depth, mipLevel);
|
||||
+ GlStateManager._glFramebufferTexture2D(tempBindSlot, GL33C.GL_STENCIL_ATTACHMENT, 3553, depth, depthMipLevel);
|
||||
+ } else {
|
||||
+ GlStateManager._glFramebufferTexture2D(tempBindSlot, org.lwjgl.opengl.GL32C.GL_STENCIL_ATTACHMENT, 3553, 0, 0);
|
||||
+ GlStateManager._glFramebufferTexture2D(tempBindSlot, GL33C.GL_STENCIL_ATTACHMENT, 3553, 0, 0);
|
||||
+ }
|
||||
if (bindSlot == 0) {
|
||||
GlStateManager._glBindFramebuffer(tempBindSlot, oldFbo);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/com/mojang/blaze3d/opengl/FrameBufferAttachment.java
|
||||
+++ b/com/mojang/blaze3d/opengl/FrameBufferAttachment.java
|
||||
@@ -12,4 +_,8 @@
|
||||
void addAssociatedFbo(FrameBufferCache.CacheKey fboKey);
|
||||
|
||||
void removeAssociatedFbo(FrameBufferCache.CacheKey fboKey);
|
||||
+
|
||||
+ default boolean hasStencilAspect() {
|
||||
+ return false;
|
||||
+ }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
--- a/com/mojang/blaze3d/opengl/FrameBufferCache.java
|
||||
+++ b/com/mojang/blaze3d/opengl/FrameBufferCache.java
|
||||
@@ -46,7 +_,7 @@
|
||||
}
|
||||
|
||||
dsa.bindFrameBufferTextures(
|
||||
- fbo, colorIds, mipLevels, depthAttachment == null ? 0 : depthAttachment.glId(), depthAttachment == null ? 0 : depthAttachment.fboMipLevel(), 0
|
||||
+ fbo, colorIds, mipLevels, depthAttachment == null ? 0 : depthAttachment.glId(), depthAttachment == null ? 0 : depthAttachment.fboMipLevel(), 0, depthAttachment != null && depthAttachment.hasStencilAspect()
|
||||
);
|
||||
return fbo;
|
||||
}
|
||||
@@ -71,7 +_,7 @@
|
||||
|
||||
public CacheKey(List<@Nullable FrameBufferAttachment> colorAttachments, @Nullable FrameBufferAttachment depthAttachment) {
|
||||
int colorAttachmentCount = colorAttachments.size();
|
||||
- this.data = new int[(colorAttachmentCount + (depthAttachment != null ? 1 : 0)) * 2];
|
||||
+ this.data = new int[(colorAttachmentCount * 2) + (depthAttachment != null ? 3 : 0)];
|
||||
|
||||
for (int i = 0; i < colorAttachmentCount; i++) {
|
||||
FrameBufferAttachment attachment = colorAttachments.get(i);
|
||||
@@ -88,6 +_,7 @@
|
||||
if (depthAttachment != null) {
|
||||
this.data[colorAttachmentCount * 2] = depthAttachment.glId();
|
||||
this.data[colorAttachmentCount * 2 + 1] = depthAttachment.fboMipLevel();
|
||||
+ this.data[colorAttachmentCount * 2 + 2] = depthAttachment.hasStencilAspect() ? 1 : 0;
|
||||
this.associatedAttachments.add(depthAttachment);
|
||||
}
|
||||
|
||||
@@ -1,58 +1,34 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlCommandEncoder.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlCommandEncoder.java
|
||||
@@ -141,7 +_,8 @@
|
||||
@@ -255,7 +_,8 @@
|
||||
|
||||
@Override
|
||||
public void clearDepthTexture(GpuTexture depthTexture, double clearDepth) {
|
||||
- this.device.directStateAccess().bindFrameBufferTextures(this.drawFbo, 0, ((GlTexture)depthTexture).id, 0, 36160);
|
||||
+ boolean hasStencil = depthTexture.getFormat().hasStencilAspect();
|
||||
+ this.device.directStateAccess().bindFrameBufferTextures(this.drawFbo, 0, ((GlTexture)depthTexture).id, 0, 36160, hasStencil);
|
||||
GL11.glDrawBuffer(0);
|
||||
GL11.glClearDepth(clearDepth);
|
||||
GL33C.glDrawBuffer(0);
|
||||
GL33C.glClearDepth(clearDepth);
|
||||
GlStateManager._depthMask(true);
|
||||
@@ -153,6 +_,17 @@
|
||||
@@ -267,6 +_,17 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
+ public void clearStencilTexture(GpuTexture texture, int value) {
|
||||
+ this.device.directStateAccess().bindFrameBufferTextures(this.drawFbo, 0, ((GlTexture)texture).id, 0, GlConst.GL_FRAMEBUFFER, true);
|
||||
+ GL11.glDrawBuffer(GlConst.GL_NONE);
|
||||
+ GL11.glClearStencil(value);
|
||||
+ GL33C.glDrawBuffer(GlConst.GL_NONE);
|
||||
+ GL33C.glClearStencil(value);
|
||||
+ GlStateManager._depthMask(true);
|
||||
+ GlStateManager._clear(GL11.GL_STENCIL_BUFFER_BIT);
|
||||
+ GL11.glDrawBuffer(GlConst.GL_COLOR_ATTACHMENT0);
|
||||
+ GlStateManager._clear(GL33C.GL_STENCIL_BUFFER_BIT);
|
||||
+ GL33C.glDrawBuffer(GlConst.GL_COLOR_ATTACHMENT0);
|
||||
+ GlStateManager._glBindFramebuffer(GlConst.GL_FRAMEBUFFER, 0);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
public void writeToBuffer(GpuBufferSlice slice, ByteBuffer data) {
|
||||
GlBuffer buffer = (GlBuffer)slice.buffer();
|
||||
if (buffer.closed) {
|
||||
@@ -269,16 +_,46 @@
|
||||
public void copyTextureToTexture(
|
||||
GpuTexture source, GpuTexture destination, int mipLevel, int destX, int destY, int sourceX, int sourceY, int width, int height
|
||||
) {
|
||||
+ TextureFormat sourceFormat = source.getFormat();
|
||||
+ TextureFormat destFormat = destination.getFormat();
|
||||
+
|
||||
+ if (sourceFormat.hasDepthAspect() || sourceFormat.hasStencilAspect()) {
|
||||
+ if (sourceFormat != destFormat) {
|
||||
+ throw new IllegalArgumentException(
|
||||
+ "When copying depth or stencil data, the source and destination texture formats must be identical. Source: "
|
||||
+ + sourceFormat + ", Destination: " + destFormat
|
||||
+ );
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (sourceFormat.hasColorAspect() != destFormat.hasColorAspect()) {
|
||||
+ throw new IllegalArgumentException(
|
||||
+ "Source and destination texture formats must have consistent color aspects. Source: "
|
||||
+ + sourceFormat + ", Destination: " + destFormat
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
GlStateManager.clearGlErrors();
|
||||
GlStateManager._disableScissorTest();
|
||||
buffer.checkCanBeUsed();
|
||||
@@ -354,11 +_,22 @@
|
||||
boolean isDepth = source.getFormat().hasDepthAspect();
|
||||
int sourceId = ((GlTexture)source).glId();
|
||||
int destId = ((GlTexture)destination).glId();
|
||||
@@ -69,7 +45,7 @@
|
||||
+ bufferMask |= GlConst.GL_DEPTH_BUFFER_BIT;
|
||||
+ }
|
||||
+ if (source.getFormat().hasStencilAspect()) {
|
||||
+ bufferMask |= GL11.GL_STENCIL_BUFFER_BIT;
|
||||
+ bufferMask |= GL33C.GL_STENCIL_BUFFER_BIT;
|
||||
+ }
|
||||
this.device
|
||||
.directStateAccess()
|
||||
@@ -78,7 +54,7 @@
|
||||
int error = GlStateManager._getError();
|
||||
if (error != 0) {
|
||||
throw new IllegalStateException(
|
||||
@@ -602,6 +_,26 @@
|
||||
@@ -754,6 +_,26 @@
|
||||
GlStateManager._scissorBox(renderPass.getScissorX(), renderPass.getScissorY(), renderPass.getScissorWidth(), renderPass.getScissorHeight());
|
||||
} else {
|
||||
GlStateManager._disableScissorTest();
|
||||
|
||||
@@ -1,50 +1,20 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlConst.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlConst.java
|
||||
@@ -254,6 +_,8 @@
|
||||
case RED8 -> 33321;
|
||||
case RED8I -> 33329;
|
||||
case DEPTH32 -> 33191;
|
||||
+ case DEPTH24_STENCIL8 -> org.lwjgl.opengl.GL32.GL_DEPTH24_STENCIL8;
|
||||
+ case DEPTH32_STENCIL8 -> org.lwjgl.opengl.GL32.GL_DEPTH32F_STENCIL8;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -263,6 +_,10 @@
|
||||
case RED8 -> 6403;
|
||||
case RED8I -> 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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -272,6 +_,8 @@
|
||||
case RED8 -> 5121;
|
||||
case RED8I -> 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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -312,5 +_,18 @@
|
||||
} else {
|
||||
@@ -373,4 +_,17 @@
|
||||
return 35044;
|
||||
}
|
||||
+ }
|
||||
}
|
||||
+
|
||||
+ 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;
|
||||
+ case KEEP -> org.lwjgl.opengl.GL33C.GL_KEEP;
|
||||
+ case ZERO -> org.lwjgl.opengl.GL33C.GL_ZERO;
|
||||
+ case REPLACE -> org.lwjgl.opengl.GL33C.GL_REPLACE;
|
||||
+ case INCR -> org.lwjgl.opengl.GL33C.GL_INCR;
|
||||
+ case DECR -> org.lwjgl.opengl.GL33C.GL_DECR;
|
||||
+ case INVERT -> org.lwjgl.opengl.GL33C.GL_INVERT;
|
||||
+ case INCR_WRAP -> org.lwjgl.opengl.GL33C.GL_INCR_WRAP;
|
||||
+ case DECR_WRAP -> org.lwjgl.opengl.GL33C.GL_DECR_WRAP;
|
||||
+ };
|
||||
}
|
||||
+ }
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlFence.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlFence.java
|
||||
@@ -21,7 +_,8 @@
|
||||
if (this.handle == 0L) {
|
||||
return true;
|
||||
} else {
|
||||
- int result = GlStateManager._glClientWaitSync(this.handle, 0, timeoutMs);
|
||||
+ // Neo: Ensure commands are flushed to avoid a deadlock
|
||||
+ int result = GlStateManager._glClientWaitSync(this.handle, org.lwjgl.opengl.GL32.GL_SYNC_FLUSH_COMMANDS_BIT, timeoutMs);
|
||||
if (result == 37147) {
|
||||
return false;
|
||||
} else if (result == 37149) {
|
||||
@@ -1,15 +1,15 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlRenderPass.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlRenderPass.java
|
||||
@@ -22,7 +_,7 @@
|
||||
@@ -24,7 +_,7 @@
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
class GlRenderPass implements RenderPassBackend {
|
||||
protected static final int MAX_VERTEX_BUFFERS = 1;
|
||||
- public static final boolean VALIDATION = SharedConstants.IS_RUNNING_IN_IDE;
|
||||
+ public static final boolean VALIDATION = SharedConstants.IS_RUNNING_IN_IDE && !Boolean.getBoolean("neoforge.disableGlValidation");
|
||||
private final GlCommandEncoder encoder;
|
||||
private final GlDevice device;
|
||||
private final boolean hasDepthTexture;
|
||||
@@ -58,6 +_,7 @@
|
||||
@@ -65,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
public void setPipeline(RenderPipeline pipeline) {
|
||||
@@ -17,7 +17,7 @@
|
||||
if (this.pipeline == null || this.pipeline.info() != pipeline) {
|
||||
this.dirtyUniforms.addAll(this.uniforms.keySet());
|
||||
this.dirtyUniforms.addAll(this.samplers.keySet());
|
||||
@@ -87,6 +_,11 @@
|
||||
@@ -94,6 +_,11 @@
|
||||
public void setUniform(String name, GpuBufferSlice value) {
|
||||
this.uniforms.put(name, value);
|
||||
this.dirtyUniforms.add(name);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlStateManager.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlStateManager.java
|
||||
@@ -34,6 +_,7 @@
|
||||
@@ -29,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();
|
||||
@@ -8,7 +8,7 @@
|
||||
private static final GlStateManager.ScissorState SCISSOR = new GlStateManager.ScissorState();
|
||||
private static int activeTexture;
|
||||
private static final int TEXTURE_COUNT = 12;
|
||||
@@ -589,4 +_,119 @@
|
||||
@@ -625,4 +_,119 @@
|
||||
private static class TextureState {
|
||||
public int binding;
|
||||
}
|
||||
@@ -33,7 +33,7 @@
|
||||
+ STENCIL.backFunc = func;
|
||||
+ STENCIL.backRef = ref;
|
||||
+ STENCIL.backReadMask = readMask;
|
||||
+ GL32.glStencilFuncSeparate(GL32.GL_FRONT_AND_BACK, func, ref, readMask);
|
||||
+ GL33C.glStencilFuncSeparate(GL33C.GL_FRONT_AND_BACK, func, ref, readMask);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -43,7 +43,7 @@
|
||||
+ STENCIL.frontFunc = func;
|
||||
+ STENCIL.frontRef = ref;
|
||||
+ STENCIL.frontReadMask = readMask;
|
||||
+ GL32.glStencilFuncSeparate(GL32.GL_FRONT, func, ref, readMask);
|
||||
+ GL33C.glStencilFuncSeparate(GL33C.GL_FRONT, func, ref, readMask);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -53,7 +53,7 @@
|
||||
+ STENCIL.backFunc = func;
|
||||
+ STENCIL.backRef = ref;
|
||||
+ STENCIL.backReadMask = readMask;
|
||||
+ GL32.glStencilFuncSeparate(GL32.GL_BACK, func, ref, readMask);
|
||||
+ GL33C.glStencilFuncSeparate(GL33C.GL_BACK, func, ref, readMask);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -61,7 +61,7 @@
|
||||
+ RenderSystem.assertOnRenderThread();
|
||||
+ if (mask != STENCIL.writeMask) {
|
||||
+ STENCIL.writeMask = mask;
|
||||
+ GL11.glStencilMask(mask);
|
||||
+ GL33C.glStencilMask(mask);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -80,7 +80,7 @@
|
||||
+ STENCIL.backStencilFail = stencilFail;
|
||||
+ STENCIL.backDepthFail = depthFail;
|
||||
+ STENCIL.backPass = pass;
|
||||
+ GL32.glStencilOpSeparate(GL32.GL_FRONT_AND_BACK, stencilFail, depthFail, pass);
|
||||
+ GL33C.glStencilOpSeparate(GL33C.GL_FRONT_AND_BACK, stencilFail, depthFail, pass);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -93,7 +93,7 @@
|
||||
+ STENCIL.frontStencilFail = stencilFail;
|
||||
+ STENCIL.frontDepthFail = depthFail;
|
||||
+ STENCIL.frontPass= pass;
|
||||
+ GL32.glStencilOpSeparate(GL32.GL_FRONT, stencilFail, depthFail, pass);
|
||||
+ GL33C.glStencilOpSeparate(GL33C.GL_FRONT, stencilFail, depthFail, pass);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -106,25 +106,25 @@
|
||||
+ STENCIL.backStencilFail = stencilFail;
|
||||
+ STENCIL.backDepthFail = depthFail;
|
||||
+ STENCIL.backPass = pass;
|
||||
+ GL32.glStencilOpSeparate(GL32.GL_BACK, stencilFail, depthFail, pass);
|
||||
+ GL33C.glStencilOpSeparate(GL33C.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 final GlStateManager.BooleanState mode = new GlStateManager.BooleanState(GL33C.GL_STENCIL_TEST);
|
||||
+ public int frontFunc = GL33C.GL_ALWAYS;
|
||||
+ public int frontRef;
|
||||
+ public int frontReadMask = -1;
|
||||
+ public int backFunc = GL11.GL_ALWAYS;
|
||||
+ public int backFunc = GL33C.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;
|
||||
+ public int frontStencilFail = GL33C.GL_KEEP;
|
||||
+ public int frontDepthFail = GL33C.GL_KEEP;
|
||||
+ public int frontPass = GL33C.GL_KEEP;
|
||||
+ public int backStencilFail = GL33C.GL_KEEP;
|
||||
+ public int backDepthFail = GL33C.GL_KEEP;
|
||||
+ public int backPass = GL33C.GL_KEEP;
|
||||
+ }
|
||||
}
|
||||
|
||||
@@ -1,38 +1,14 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlTexture.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlTexture.java
|
||||
@@ -53,10 +_,11 @@
|
||||
|
||||
public int getFbo(DirectStateAccess dsa, @Nullable GpuTexture depth) {
|
||||
int depthId = depth == null ? 0 : ((GlTexture)depth).id;
|
||||
+ var useStencil = depth != null && depth.getFormat().hasStencilAspect();
|
||||
if (this.firstFboDepthId == depthId) {
|
||||
return this.firstFboId;
|
||||
} else if (this.firstFboId == -1) {
|
||||
- this.firstFboId = this.createFbo(dsa, depthId);
|
||||
+ this.firstFboId = this.createFbo(dsa, depthId, useStencil);
|
||||
this.firstFboDepthId = depthId;
|
||||
return this.firstFboId;
|
||||
} else {
|
||||
@@ -64,13 +_,20 @@
|
||||
this.fboCache = new Int2IntArrayMap();
|
||||
}
|
||||
|
||||
- return this.fboCache.computeIfAbsent(depthId, _depthId -> this.createFbo(dsa, _depthId));
|
||||
+ return this.fboCache.computeIfAbsent(depthId, _depthId -> this.createFbo(dsa, _depthId, useStencil));
|
||||
}
|
||||
@@ -75,6 +_,11 @@
|
||||
this.fboKeys.remove(fboKey);
|
||||
}
|
||||
|
||||
+ /** @deprecated use overload that takes useStencil */
|
||||
+ @Deprecated
|
||||
private int createFbo(DirectStateAccess dsa, int depthid) {
|
||||
+ return createFbo(dsa, depthid, false);
|
||||
+ @Override
|
||||
+ public boolean hasStencilAspect() {
|
||||
+ return this.getFormat().hasStencilAspect();
|
||||
+ }
|
||||
+
|
||||
+ // Neo: Allow for stencil use
|
||||
+ private int createFbo(DirectStateAccess dsa, int depthid, boolean useStencil) {
|
||||
int fbo = dsa.createFrameBufferObject();
|
||||
- dsa.bindFrameBufferTextures(fbo, this.id, depthid, 0, 0);
|
||||
+ dsa.bindFrameBufferTextures(fbo, this.id, depthid, 0, 0, useStencil);
|
||||
return fbo;
|
||||
public void addViews() {
|
||||
this.views++;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +1,12 @@
|
||||
--- a/com/mojang/blaze3d/opengl/GlTextureView.java
|
||||
+++ b/com/mojang/blaze3d/opengl/GlTextureView.java
|
||||
@@ -45,10 +_,11 @@
|
||||
|
||||
public int getFbo(DirectStateAccess dsa, @Nullable GpuTexture depth) {
|
||||
int depthId = depth == null ? 0 : ((GlTexture)depth).id;
|
||||
+ var useStencil = depth != null && depth.getFormat().hasStencilAspect();
|
||||
if (this.firstFboDepthId == depthId) {
|
||||
return this.firstFboId;
|
||||
} else if (this.firstFboId == -1) {
|
||||
- this.firstFboId = this.createFbo(dsa, depthId);
|
||||
+ this.firstFboId = this.createFbo(dsa, depthId, useStencil);
|
||||
this.firstFboDepthId = depthId;
|
||||
return this.firstFboId;
|
||||
} else {
|
||||
@@ -56,13 +_,19 @@
|
||||
this.fboCache = new Int2IntArrayMap();
|
||||
}
|
||||
|
||||
- return this.fboCache.computeIfAbsent(depthId, _depthId -> this.createFbo(dsa, _depthId));
|
||||
+ return this.fboCache.computeIfAbsent(depthId, _depthId -> this.createFbo(dsa, _depthId, useStencil));
|
||||
}
|
||||
@@ -59,4 +_,9 @@
|
||||
public void removeAssociatedFbo(FrameBufferCache.CacheKey fboKey) {
|
||||
this.fboKeys.remove(fboKey);
|
||||
}
|
||||
|
||||
+ /** @deprecated use overload that takes useStencil */
|
||||
private int createFbo(DirectStateAccess dsa, int depthid) {
|
||||
+ return createFbo(dsa, depthid, false);
|
||||
+ }
|
||||
+
|
||||
+ // Neo: Allow for stencil use
|
||||
+ private int createFbo(DirectStateAccess dsa, int depthid, boolean useStencil) {
|
||||
int fbo = dsa.createFrameBufferObject();
|
||||
- dsa.bindFrameBufferTextures(fbo, this.texture().id, depthid, this.baseMipLevel(), 0);
|
||||
+ dsa.bindFrameBufferTextures(fbo, this.texture().id, depthid, this.baseMipLevel(), 0, useStencil);
|
||||
return fbo;
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public boolean hasStencilAspect() {
|
||||
+ return this.texture().hasStencilAspect();
|
||||
+ }
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
private static final MainTarget.Dimension DEFAULT_DIMENSIONS = new MainTarget.Dimension(854, 480);
|
||||
|
||||
public MainTarget(int desiredWidth, int desiredHeight) {
|
||||
- super("Main", true);
|
||||
- super("Main", true, GpuFormat.RGBA8_UNORM);
|
||||
+ this(desiredWidth, desiredHeight, false);
|
||||
+ }
|
||||
+
|
||||
+ public MainTarget(int desiredWidth, int desiredHeight, boolean enableStencil) {
|
||||
+ super("Main", true, enableStencil);
|
||||
+ public MainTarget(int desiredWidth, int desiredHeight, boolean useStencil) {
|
||||
+ super("Main", true, useStencil, GpuFormat.RGBA8_UNORM);
|
||||
this.createFrameBuffer(desiredWidth, desiredHeight);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
private @Nullable GpuTexture allocateDepthAttachment(MainTarget.Dimension dimension) {
|
||||
try {
|
||||
- return RenderSystem.getDevice().createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, dimension.width, dimension.height, 1, 1);
|
||||
+ var format = this.useStencil ? net.neoforged.neoforge.client.ClientHooks.getStencilFormat() : TextureFormat.DEPTH32;
|
||||
- return RenderSystem.getDevice().createTexture(() -> this.label + " / Depth", 15, GpuFormat.D32_FLOAT, dimension.width, dimension.height, 1, 1);
|
||||
+ var format = this.useStencil ? net.neoforged.neoforge.client.ClientHooks.getStencilFormat() : GpuFormat.D32_FLOAT;
|
||||
+ return RenderSystem.getDevice().createTexture(() -> this.label + " / Depth", 15, format, dimension.width, dimension.height, 1, 1);
|
||||
} catch (GpuOutOfMemoryException var3) {
|
||||
} catch (GpuOutOfMemoryException ignored) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,42 @@
|
||||
--- a/com/mojang/blaze3d/pipeline/RenderPipeline.java
|
||||
+++ b/com/mojang/blaze3d/pipeline/RenderPipeline.java
|
||||
@@ -32,7 +_,10 @@
|
||||
private final VertexFormat.Mode vertexFormatMode;
|
||||
@@ -30,21 +_,42 @@
|
||||
private final @Nullable ColorTargetState[] colorTargetStates;
|
||||
private final @Nullable VertexFormat[] vertexFormatPerBuffer = new VertexFormat[16];
|
||||
private final PrimitiveTopology primitiveTopology;
|
||||
+ private final Optional<net.neoforged.neoforge.client.stencil.StencilTest> stencilTest;
|
||||
private final int sortKey;
|
||||
private static int sortKeySeed;
|
||||
+ private final Optional<net.neoforged.neoforge.client.stencil.StencilTest> stencilTest;
|
||||
|
||||
+ /** @deprecated Neo: use {@link #RenderPipeline(Identifier, Identifier, Identifier, ShaderDefines, List, List, ColorTargetState, DepthStencilState, PolygonMode, boolean, VertexFormat, VertexFormat.Mode, int, Optional)} instead */
|
||||
- protected RenderPipeline(
|
||||
- Identifier location,
|
||||
- Identifier vertexShader,
|
||||
- Identifier fragmentShader,
|
||||
- ShaderDefines shaderDefines,
|
||||
- List<BindGroupLayout> bindGroupLayouts,
|
||||
- @Nullable ColorTargetState[] colorTargetStates,
|
||||
- @Nullable DepthStencilState depthStencilState,
|
||||
- PolygonMode polygonMode,
|
||||
- boolean cull,
|
||||
- @Nullable VertexFormat[] vertexFormatPerBuffer,
|
||||
- PrimitiveTopology primitiveTopology,
|
||||
+ /// @deprecated Neo: use [#RenderPipeline(Identifier, Identifier, Identifier, ShaderDefines, List, ColorTargetState\[\], DepthStencilState, PolygonMode, boolean, VertexFormat\[\], PrimitiveTopology, Optional, int)] instead
|
||||
+ @Deprecated
|
||||
protected RenderPipeline(
|
||||
Identifier location,
|
||||
Identifier vertexShader,
|
||||
@@ -48,6 +_,25 @@
|
||||
VertexFormat.Mode vertexFormatMode,
|
||||
int sortKey
|
||||
) {
|
||||
+ this(location, vertexShader, fragmentShader, shaderDefines, samplers, uniforms, colorTargetState, depthStencilState, polygonMode, cull, vertexFormat, vertexFormatMode, sortKey, Optional.empty());
|
||||
+ protected RenderPipeline(
|
||||
+ Identifier location,
|
||||
+ Identifier vertexShader,
|
||||
+ Identifier fragmentShader,
|
||||
+ ShaderDefines shaderDefines,
|
||||
+ List<BindGroupLayout> bindGroupLayouts,
|
||||
+ @Nullable ColorTargetState[] colorTargetStates,
|
||||
+ @Nullable DepthStencilState depthStencilState,
|
||||
+ PolygonMode polygonMode,
|
||||
+ boolean cull,
|
||||
+ @Nullable VertexFormat[] vertexFormatPerBuffer,
|
||||
+ PrimitiveTopology primitiveTopology,
|
||||
+ int sortKey
|
||||
+ ) {
|
||||
+ this(location, vertexShader, fragmentShader, shaderDefines, bindGroupLayouts, colorTargetStates, depthStencilState, polygonMode, cull, vertexFormatPerBuffer, primitiveTopology, Optional.empty(), sortKey);
|
||||
+ }
|
||||
+
|
||||
+ protected RenderPipeline(
|
||||
@@ -23,29 +44,26 @@
|
||||
+ Identifier vertexShader,
|
||||
+ Identifier fragmentShader,
|
||||
+ ShaderDefines shaderDefines,
|
||||
+ List<String> samplers,
|
||||
+ List<RenderPipeline.UniformDescription> uniforms,
|
||||
+ ColorTargetState colorTargetState,
|
||||
+ List<BindGroupLayout> bindGroupLayouts,
|
||||
+ @Nullable ColorTargetState[] colorTargetStates,
|
||||
+ @Nullable DepthStencilState depthStencilState,
|
||||
+ PolygonMode polygonMode,
|
||||
+ boolean cull,
|
||||
+ VertexFormat vertexFormat,
|
||||
+ VertexFormat.Mode vertexFormatMode,
|
||||
+ int sortKey,
|
||||
+ Optional<net.neoforged.neoforge.client.stencil.StencilTest> stencilTest
|
||||
+ ) {
|
||||
+ @Nullable VertexFormat[] vertexFormatPerBuffer,
|
||||
+ PrimitiveTopology primitiveTopology,
|
||||
+ Optional<net.neoforged.neoforge.client.stencil.StencilTest> stencilTest,
|
||||
int sortKey
|
||||
) {
|
||||
this.location = location;
|
||||
this.vertexShader = vertexShader;
|
||||
this.fragmentShader = fragmentShader;
|
||||
@@ -61,6 +_,7 @@
|
||||
this.vertexFormat = vertexFormat;
|
||||
this.vertexFormatMode = vertexFormatMode;
|
||||
this.sortKey = sortKey;
|
||||
@@ -57,6 +_,7 @@
|
||||
this.cull = cull;
|
||||
this.colorTargetStates = colorTargetStates;
|
||||
this.primitiveTopology = primitiveTopology;
|
||||
+ this.stencilTest = stencilTest;
|
||||
this.sortKey = sortKey;
|
||||
System.arraycopy(vertexFormatPerBuffer, 0, this.vertexFormatPerBuffer, 0, this.vertexFormatPerBuffer.length);
|
||||
}
|
||||
|
||||
public int getSortKey() {
|
||||
@@ -128,6 +_,45 @@
|
||||
@@ -130,6 +_,48 @@
|
||||
return this.depthStencilState != null;
|
||||
}
|
||||
|
||||
@@ -72,18 +90,21 @@
|
||||
+ }
|
||||
+ builder.definesBuilder = Optional.of(defBuilder);
|
||||
+ }
|
||||
+ if (!this.samplers.isEmpty()) {
|
||||
+ builder.samplers = Optional.of(new ArrayList<>(this.samplers));
|
||||
+ }
|
||||
+ if (!this.uniforms.isEmpty()) {
|
||||
+ builder.uniforms = Optional.of(new ArrayList<>(this.uniforms));
|
||||
+ if (!this.bindGroupLayouts.isEmpty()) {
|
||||
+ builder.bindGroupLayouts = Optional.of(new ArrayList<>(this.bindGroupLayouts));
|
||||
+ }
|
||||
+ builder.depthStencilState = Optional.ofNullable(this.depthStencilState);
|
||||
+ builder.polygonMode = Optional.of(this.polygonMode);
|
||||
+ builder.cull = Optional.of(this.cull);
|
||||
+ builder.colorTargetState = Optional.of(this.colorTargetState);
|
||||
+ builder.vertexFormat = Optional.of(this.vertexFormat);
|
||||
+ builder.vertexFormatMode = Optional.of(this.vertexFormatMode);
|
||||
+ System.arraycopy(this.colorTargetStates, 0, builder.colorTargetStates, 0, this.colorTargetStates.length);
|
||||
+ int activeColorTargetStateCount = 0;
|
||||
+ for (int i = 0; i < this.colorTargetStates.length; i++) {
|
||||
+ if (this.colorTargetStates[i] != null) {
|
||||
+ activeColorTargetStateCount = i + 1;
|
||||
+ }
|
||||
+ }
|
||||
+ System.arraycopy(this.vertexFormatPerBuffer, 0, builder.vertexFormatPerBuffer, 0, this.vertexFormatPerBuffer.length);
|
||||
+ builder.primitiveTopology = Optional.of(this.primitiveTopology);
|
||||
+ builder.stencilTest = this.stencilTest;
|
||||
+ return builder;
|
||||
+ }
|
||||
@@ -91,15 +112,15 @@
|
||||
public static RenderPipeline.Builder builder(RenderPipeline.Snippet... snippets) {
|
||||
RenderPipeline.Builder builder = new RenderPipeline.Builder();
|
||||
|
||||
@@ -153,6 +_,7 @@
|
||||
private Optional<ColorTargetState> colorTargetState = Optional.empty();
|
||||
private Optional<VertexFormat> vertexFormat = Optional.empty();
|
||||
private Optional<VertexFormat.Mode> vertexFormatMode = Optional.empty();
|
||||
@@ -154,6 +_,7 @@
|
||||
private int activeColorTargetStateCount;
|
||||
private final @Nullable VertexFormat[] vertexFormatPerBuffer = new VertexFormat[16];
|
||||
private Optional<PrimitiveTopology> primitiveTopology = Optional.empty();
|
||||
+ private Optional<net.neoforged.neoforge.client.stencil.StencilTest> stencilTest = Optional.empty();
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
@@ -280,6 +_,16 @@
|
||||
@@ -270,6 +_,16 @@
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -116,7 +137,7 @@
|
||||
private void withSnippet(RenderPipeline.Snippet snippet) {
|
||||
if (snippet.vertexShader.isPresent()) {
|
||||
this.vertexShader = snippet.vertexShader;
|
||||
@@ -342,6 +_,10 @@
|
||||
@@ -332,6 +_,10 @@
|
||||
if (snippet.polygonMode.isPresent()) {
|
||||
this.polygonMode = snippet.polygonMode;
|
||||
}
|
||||
@@ -127,51 +148,48 @@
|
||||
}
|
||||
|
||||
public RenderPipeline.Snippet buildSnippet() {
|
||||
@@ -356,7 +_,8 @@
|
||||
@@ -346,7 +_,8 @@
|
||||
this.polygonMode,
|
||||
this.cull,
|
||||
this.vertexFormat,
|
||||
- this.vertexFormatMode
|
||||
+ this.vertexFormatMode,
|
||||
this.vertexFormatPerBuffer,
|
||||
- this.primitiveTopology
|
||||
+ this.primitiveTopology,
|
||||
+ this.stencilTest
|
||||
);
|
||||
}
|
||||
|
||||
@@ -385,7 +_,8 @@
|
||||
@@ -411,6 +_,7 @@
|
||||
this.cull.orElse(true),
|
||||
this.vertexFormat.get(),
|
||||
this.vertexFormatMode.get(),
|
||||
- nextPipelineSortKey++
|
||||
+ nextPipelineSortKey++,
|
||||
+ this.stencilTest
|
||||
this.vertexFormatPerBuffer,
|
||||
this.primitiveTopology.get(),
|
||||
+ this.stencilTest,
|
||||
nextPipelineSortKey++
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -403,8 +_,26 @@
|
||||
@@ -428,7 +_,25 @@
|
||||
Optional<PolygonMode> polygonMode,
|
||||
Optional<Boolean> cull,
|
||||
Optional<VertexFormat> vertexFormat,
|
||||
- Optional<VertexFormat.Mode> vertexFormatMode
|
||||
+ Optional<VertexFormat.Mode> vertexFormatMode,
|
||||
@Nullable VertexFormat[] vertexFormatPerBuffer,
|
||||
- Optional<PrimitiveTopology> vertexFormatMode
|
||||
+ Optional<PrimitiveTopology> vertexFormatMode,
|
||||
+ Optional<net.neoforged.neoforge.client.stencil.StencilTest> stencilTest
|
||||
) {
|
||||
+ /** @deprecated Neo: use {@link #Snippet(Optional, Optional, Optional, Optional, Optional, Optional, Optional, Optional, Optional, Optional, Optional, Optional)} instead */
|
||||
+ /// @deprecated Neo: use [#Snippet(Optional, Optional, Optional, Optional, ColorTargetState\[\], int, Optional, Optional, Optional, VertexFormat\[\], Optional, Optional)] instead
|
||||
+ @Deprecated
|
||||
+ public Snippet(
|
||||
+ Optional<Identifier> vertexShader,
|
||||
+ Optional<Identifier> fragmentShader,
|
||||
+ Optional<ShaderDefines> shaderDefines,
|
||||
+ Optional<List<String>> samplers,
|
||||
+ Optional<List<RenderPipeline.UniformDescription>> uniforms,
|
||||
+ Optional<ColorTargetState> colorTargetState,
|
||||
+ Optional<DepthStencilState> depthStencilState,
|
||||
+ Optional<PolygonMode> polygonMode,
|
||||
+ Optional<Boolean> cull,
|
||||
+ Optional<VertexFormat> vertexFormat,
|
||||
+ Optional<VertexFormat.Mode> vertexFormatMode
|
||||
+ Optional<Identifier> vertexShader,
|
||||
+ Optional<Identifier> fragmentShader,
|
||||
+ Optional<ShaderDefines> shaderDefines,
|
||||
+ Optional<List<BindGroupLayout>> bindGroupLayouts,
|
||||
+ @Nullable ColorTargetState[] colorTargetStates,
|
||||
+ int activeColorTargetStateCount,
|
||||
+ Optional<DepthStencilState> depthStencilState,
|
||||
+ Optional<PolygonMode> polygonMode,
|
||||
+ Optional<Boolean> cull,
|
||||
+ @Nullable VertexFormat[] vertexFormatPerBuffer,
|
||||
+ Optional<PrimitiveTopology> vertexFormatMode
|
||||
+ ) {
|
||||
+ this(vertexShader, fragmentShader, shaderDefines, samplers, uniforms, colorTargetState, depthStencilState, polygonMode, cull, vertexFormat, vertexFormatMode, Optional.empty());
|
||||
+ this(vertexShader, fragmentShader, shaderDefines, bindGroupLayouts, colorTargetStates, activeColorTargetStateCount, depthStencilState, polygonMode, cull, vertexFormatPerBuffer, vertexFormatMode, Optional.empty());
|
||||
+ }
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
}
|
||||
|
||||
@@ -1,35 +1,36 @@
|
||||
--- a/com/mojang/blaze3d/pipeline/RenderTarget.java
|
||||
+++ b/com/mojang/blaze3d/pipeline/RenderTarget.java
|
||||
@@ -20,14 +_,23 @@
|
||||
@@ -21,6 +_,7 @@
|
||||
public int height;
|
||||
protected final String label;
|
||||
public final boolean useDepth;
|
||||
+ public final boolean useStencil;
|
||||
protected final GpuFormat format;
|
||||
protected @Nullable GpuTexture colorTexture;
|
||||
protected @Nullable GpuTextureView colorTextureView;
|
||||
protected @Nullable GpuTexture depthTexture;
|
||||
@@ -28,8 +_,16 @@
|
||||
protected @Nullable GpuTextureView depthTextureView;
|
||||
|
||||
public RenderTarget(@Nullable String label, boolean useDepth) {
|
||||
+ this(label, useDepth, false);
|
||||
public RenderTarget(@Nullable String label, boolean useDepth, GpuFormat format) {
|
||||
+ this(label, useDepth, false, format);
|
||||
+ }
|
||||
+
|
||||
+ public RenderTarget(@Nullable String label, boolean useDepth, boolean useStencil) {
|
||||
+ public RenderTarget(@Nullable String label, boolean useDepth, boolean useStencil, GpuFormat format) {
|
||||
+ if (useStencil && !useDepth) {
|
||||
+ throw new IllegalArgumentException("Stencil can only be enabled if depth is enabled.");
|
||||
+ }
|
||||
this.label = label == null ? "FBO " + UNNAMED_RENDER_TARGETS++ : label;
|
||||
this.useDepth = useDepth;
|
||||
+ this.useStencil = useStencil;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public void resize(int width, int height) {
|
||||
@@ -80,7 +_,8 @@
|
||||
@@ -83,7 +_,8 @@
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
if (this.useDepth) {
|
||||
- this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, width, height, 1, 1);
|
||||
+ var format = this.useStencil ? net.neoforged.neoforge.client.ClientHooks.getStencilFormat() : TextureFormat.DEPTH32;
|
||||
- this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, GpuFormat.D32_FLOAT, width, height, 1, 1);
|
||||
+ var format = this.useStencil ? net.neoforged.neoforge.client.ClientHooks.getStencilFormat() : GpuFormat.D32_FLOAT;
|
||||
+ this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, format, width, height, 1, 1);
|
||||
this.depthTextureView = device.createTextureView(this.depthTexture);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
--- a/com/mojang/blaze3d/pipeline/TextureTarget.java
|
||||
+++ b/com/mojang/blaze3d/pipeline/TextureTarget.java
|
||||
@@ -8,7 +_,10 @@
|
||||
@@ -9,7 +_,11 @@
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class TextureTarget extends RenderTarget {
|
||||
public TextureTarget(@Nullable String label, int width, int height, boolean useDepth) {
|
||||
- super(label, useDepth);
|
||||
+ this(label, width, height, useDepth, false);
|
||||
public TextureTarget(@Nullable String label, int width, int height, boolean useDepth, GpuFormat format) {
|
||||
- super(label, useDepth, format);
|
||||
+ this(label, width, height, useDepth, false, format);
|
||||
+ }
|
||||
+ public TextureTarget(@Nullable String label, int width, int height, boolean useDepth, boolean enableStencil) {
|
||||
+ super(label, useDepth, enableStencil);
|
||||
+
|
||||
+ public TextureTarget(@Nullable String label, int width, int height, boolean useDepth, boolean useStencil, GpuFormat format) {
|
||||
+ super(label, useDepth, useStencil, format);
|
||||
RenderSystem.assertOnRenderThread();
|
||||
this.resize(width, height);
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
--- a/com/mojang/blaze3d/platform/DestFactor.java
|
||||
+++ b/com/mojang/blaze3d/platform/DestFactor.java
|
||||
@@ -4,6 +_,7 @@
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
[email protected](reason = "Further dest factors may be added")
|
||||
public enum DestFactor {
|
||||
CONSTANT_ALPHA,
|
||||
CONSTANT_COLOR,
|
||||
@@ -1,10 +0,0 @@
|
||||
--- a/com/mojang/blaze3d/platform/SourceFactor.java
|
||||
+++ b/com/mojang/blaze3d/platform/SourceFactor.java
|
||||
@@ -4,6 +_,7 @@
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
[email protected](reason = "Further source factors may be added")
|
||||
public enum SourceFactor {
|
||||
CONSTANT_ALPHA,
|
||||
CONSTANT_COLOR,
|
||||
@@ -1,21 +0,0 @@
|
||||
--- a/com/mojang/blaze3d/platform/TextureUtil.java
|
||||
+++ b/com/mojang/blaze3d/platform/TextureUtil.java
|
||||
@@ -54,6 +_,10 @@
|
||||
|
||||
public static void writeAsPNG(Path dir, String prefix, GpuTexture texture, int maxMipLevel, IntUnaryOperator pixelModifier) {
|
||||
RenderSystem.assertOnRenderThread();
|
||||
+ // Neo: Textures with packed depth/stencil formats cannot be exported as the driver implementation is free to store this data in whatever layout it prefers
|
||||
+ if (texture.getFormat() == com.mojang.blaze3d.textures.TextureFormat.DEPTH24_STENCIL8 || texture.getFormat() == com.mojang.blaze3d.textures.TextureFormat.DEPTH32_STENCIL8) {
|
||||
+ throw new IllegalArgumentException("Textures with packed depth/stencil formats cannot be exported");
|
||||
+ }
|
||||
long bufferLength = 0L;
|
||||
|
||||
for (int i = 0; i <= maxMipLevel; i++) {
|
||||
@@ -80,6 +_,7 @@
|
||||
};
|
||||
case RGBA8 -> byteOffset -> data.getInt(byteOffset);
|
||||
case DEPTH32 -> byteOffset -> ARGB.gray(data.getFloat(byteOffset));
|
||||
+ case DEPTH24_STENCIL8, DEPTH32_STENCIL8 -> _ -> -1;
|
||||
};
|
||||
int offsetx = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/com/mojang/blaze3d/platform/Window.java
|
||||
+++ b/com/mojang/blaze3d/platform/Window.java
|
||||
@@ -92,6 +_,16 @@
|
||||
@@ -91,6 +_,16 @@
|
||||
this.windowedWidth = this.width = allowedWindowMinSize(displayData.width());
|
||||
this.windowedHeight = this.height = allowedWindowMinSize(displayData.height());
|
||||
this.handle = this.createWindow(backend, this.width, this.height, title, this.fullscreen && initialMonitor != null ? initialMonitor.getMonitor() : 0L);
|
||||
@@ -18,9 +18,9 @@
|
||||
if (initialMonitor != null) {
|
||||
VideoMode mode = initialMonitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty());
|
||||
@@ -121,6 +_,11 @@
|
||||
long windowHandle;
|
||||
try (GLFWErrorScope var9 = new GLFWErrorScope(glfwErrors)) {
|
||||
backend.setWindowHints();
|
||||
GLFW.glfwWindowHint(131076, 0);
|
||||
+ var earlyLoadingScreen = net.neoforged.fml.loading.EarlyLoadingScreenController.current();
|
||||
+ if (earlyLoadingScreen != null) {
|
||||
+ windowHandle = earlyLoadingScreen.takeOverGlfwWindow();
|
||||
@@ -29,15 +29,19 @@
|
||||
windowHandle = GLFW.glfwCreateWindow(width, height, title, monitor, 0L);
|
||||
if (windowHandle == 0L) {
|
||||
backend.handleWindowCreationErrors(glfwErrors.firstError());
|
||||
@@ -226,8 +_,10 @@
|
||||
@@ -226,11 +_,11 @@
|
||||
}
|
||||
|
||||
public void defaultErrorCallback(int errorCode, long description) {
|
||||
- RenderSystem.assertOnRenderThread();
|
||||
- if (!RenderSystem.isOnRenderThread()) {
|
||||
- LOGGER.error("Error callback from invalid thread ({})", Thread.currentThread().getName());
|
||||
- }
|
||||
-
|
||||
String errorString = MemoryUtil.memUTF8(description);
|
||||
+ if (!RenderSystem.isOnRenderThread()) {
|
||||
+ throw new IllegalStateException("Encountered GL error off-thread @ " + errorSection + ": " + errorCode + ": " + errorString);
|
||||
+ LOGGER.error("Error callback from invalid thread ({}): {}: {}", Thread.currentThread().getName(), errorCode, errorString);
|
||||
+ }
|
||||
+
|
||||
LOGGER.error("########## GL ERROR ##########");
|
||||
LOGGER.error("@ {}", this.errorSection);
|
||||
LOGGER.error("{}: {}", errorCode, errorString);
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
--- a/com/mojang/blaze3d/resource/RenderTargetDescriptor.java
|
||||
+++ b/com/mojang/blaze3d/resource/RenderTargetDescriptor.java
|
||||
@@ -7,9 +_,13 @@
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
@@ -9,10 +_,14 @@
|
||||
import org.joml.Vector4fc;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-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 record RenderTargetDescriptor(int width, int height, boolean useDepth, Vector4fc clearColor, GpuFormat format)
|
||||
+public record RenderTargetDescriptor(int width, int height, boolean useDepth, boolean useStencil, Vector4fc clearColor, GpuFormat format)
|
||||
implements ResourceDescriptor<RenderTarget> {
|
||||
+ public RenderTargetDescriptor(int width, int height, boolean useDepth, Vector4fc clearColor, GpuFormat format) {
|
||||
+ this(width, height, useDepth, false, clearColor, format);
|
||||
+ }
|
||||
+
|
||||
public RenderTarget allocate() {
|
||||
- return new TextureTarget(null, this.width, this.height, this.useDepth);
|
||||
+ return new TextureTarget(null, this.width, this.height, this.useDepth, this.useStencil);
|
||||
- return new TextureTarget(null, this.width, this.height, this.useDepth, this.format);
|
||||
+ return new TextureTarget(null, this.width, this.height, this.useDepth, this.useStencil, this.format);
|
||||
}
|
||||
|
||||
public void prepare(RenderTarget resource) {
|
||||
@@ -20,6 +_,9 @@
|
||||
@@ -23,6 +_,9 @@
|
||||
} else {
|
||||
RenderSystem.getDevice().createCommandEncoder().clearColorTexture(resource.getColorTexture(), this.clearColor);
|
||||
}
|
||||
@@ -26,11 +27,11 @@
|
||||
}
|
||||
|
||||
public void free(RenderTarget resource) {
|
||||
@@ -30,6 +_,6 @@
|
||||
@@ -33,6 +_,6 @@
|
||||
public boolean canUsePhysicalResource(ResourceDescriptor<?> other) {
|
||||
return !(other instanceof RenderTargetDescriptor descriptor)
|
||||
? false
|
||||
- : this.width == descriptor.width && this.height == descriptor.height && this.useDepth == descriptor.useDepth;
|
||||
+ : this.width == descriptor.width && this.height == descriptor.height && this.useDepth == descriptor.useDepth && this.useStencil == descriptor.useStencil;
|
||||
- : this.width == descriptor.width && this.height == descriptor.height && this.useDepth == descriptor.useDepth && this.format == descriptor.format;
|
||||
+ : this.width == descriptor.width && this.height == descriptor.height && this.useDepth == descriptor.useDepth && this.format == descriptor.format && this.useStencil == descriptor.useStencil;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
[email protected](reason = "Further uniform types such as SSBO and StorageTexelBuffer may be added")
|
||||
public enum UniformType {
|
||||
UNIFORM_BUFFER("ubo"),
|
||||
TEXEL_BUFFER("utb");
|
||||
UNIFORM_BUFFER,
|
||||
TEXEL_BUFFER;
|
||||
|
||||
@@ -1,24 +1,50 @@
|
||||
--- a/com/mojang/blaze3d/systems/CommandEncoder.java
|
||||
+++ b/com/mojang/blaze3d/systems/CommandEncoder.java
|
||||
@@ -108,6 +_,15 @@
|
||||
}
|
||||
@@ -207,6 +_,15 @@
|
||||
this.backend.clearDepthTexture(depthTexture, clearDepth);
|
||||
}
|
||||
|
||||
+ public void clearStencilTexture(GpuTexture texture, int value) {
|
||||
+ if (this.backend.isInRenderPass()) {
|
||||
+ if (this.isInRenderPass) {
|
||||
+ throw new IllegalStateException("Close the existing render pass before creating a new one!");
|
||||
+ } else {
|
||||
+ this.verifyStencilTexture(texture);
|
||||
+ this.backend.clearStencilTexture(texture, value);
|
||||
+ }
|
||||
+
|
||||
+ this.verifyStencilTexture(texture);
|
||||
+ this.backend.clearStencilTexture(texture, value);
|
||||
+ }
|
||||
+
|
||||
public void writeToBuffer(GpuBufferSlice destination, ByteBuffer data) {
|
||||
if (this.backend.isInRenderPass()) {
|
||||
if (this.isInRenderPass) {
|
||||
throw new IllegalStateException("Close the existing render pass before performing additional commands");
|
||||
@@ -482,6 +_,18 @@
|
||||
throw new IllegalStateException("Depth texture must have USAGE_COPY_DST");
|
||||
} else if (depthTexture.getDepthOrLayers() > 1) {
|
||||
@@ -577,6 +_,25 @@
|
||||
throw new UnsupportedOperationException("Textures with multiple depths or layers are not yet supported for copying");
|
||||
}
|
||||
|
||||
+ final var sourceFormat = source.getFormat();
|
||||
+ final var destFormat = destination.getFormat();
|
||||
+ if (sourceFormat.hasDepthAspect() || sourceFormat.hasStencilAspect()) {
|
||||
+ if (sourceFormat != destFormat) {
|
||||
+ throw new IllegalArgumentException(
|
||||
+ "When copying depth or stencil data, the source and destination texture formats must be identical. Source: "
|
||||
+ + sourceFormat + ", Destination: " + destFormat
|
||||
+ );
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (sourceFormat.hasColorAspect() != destFormat.hasColorAspect()) {
|
||||
+ throw new IllegalArgumentException(
|
||||
+ "Source and destination texture formats must have consistent color aspects. Source: "
|
||||
+ + sourceFormat + ", Destination: " + destFormat
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+
|
||||
this.backend.copyTextureToTexture(source, destination, mipLevel, destX, destY, sourceX, sourceY, width, height);
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -642,6 +_,24 @@
|
||||
|
||||
if (depthTexture.getDepthOrLayers() > 1) {
|
||||
throw new UnsupportedOperationException("Clearing a texture with multiple layers or depths is not yet supported");
|
||||
+ }
|
||||
+ }
|
||||
@@ -26,11 +52,17 @@
|
||||
+ private void verifyStencilTexture(GpuTexture stencilTexture) {
|
||||
+ if (!stencilTexture.getFormat().hasStencilAspect()) {
|
||||
+ throw new IllegalStateException("Trying to clear stencil in a texture that has no stencil component!");
|
||||
+ } else if (stencilTexture.isClosed()) {
|
||||
+ }
|
||||
+
|
||||
+ if (stencilTexture.isClosed()) {
|
||||
+ throw new IllegalStateException("Stencil texture is closed");
|
||||
+ } else if ((stencilTexture.usage() & GpuTexture.USAGE_RENDER_ATTACHMENT) == 0) {
|
||||
+ }
|
||||
+
|
||||
+ if ((stencilTexture.usage() & GpuTexture.USAGE_RENDER_ATTACHMENT) == 0) {
|
||||
+ throw new IllegalStateException("Stencil texture must have USAGE_RENDER_ATTACHMENT");
|
||||
+ } else if ((stencilTexture.usage() & GpuTexture.USAGE_COPY_DST) == 0) {
|
||||
+ }
|
||||
+
|
||||
+ if ((stencilTexture.usage() & GpuTexture.USAGE_COPY_DST) == 0) {
|
||||
+ throw new IllegalStateException("Stencil texture must have USAGE_COPY_DST");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/com/mojang/blaze3d/systems/CommandEncoderBackend.java
|
||||
+++ b/com/mojang/blaze3d/systems/CommandEncoderBackend.java
|
||||
@@ -34,6 +_,8 @@
|
||||
@@ -30,6 +_,8 @@
|
||||
|
||||
void clearDepthTexture(GpuTexture depthTexture, double clearDepth);
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
+
|
||||
void writeToBuffer(GpuBufferSlice destination, ByteBuffer data);
|
||||
|
||||
GpuBuffer.MappedView mapBuffer(GpuBufferSlice buffer, boolean read, boolean write);
|
||||
void copyToBuffer(GpuBufferSlice source, GpuBufferSlice target);
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
--- a/com/mojang/blaze3d/systems/RenderPass.java
|
||||
+++ b/com/mojang/blaze3d/systems/RenderPass.java
|
||||
@@ -68,6 +_,10 @@
|
||||
}
|
||||
@@ -116,6 +_,16 @@
|
||||
this.backend.setUniform(name, value);
|
||||
}
|
||||
|
||||
+ public void setViewport(int x, int y, int width, int height) {
|
||||
+ if (width < 0 || height < 0) {
|
||||
+ throw new IllegalArgumentException("Viewport size must be >0, was " + width + "x" + height);
|
||||
+ }
|
||||
+ if (x < this.renderArea.x() || y < this.renderArea.y() || x + width > this.renderArea.x() + this.renderArea.width() || y + height > this.renderArea.height()) {
|
||||
+ throw new IllegalArgumentException("Viewport at " + x + ", " + y + " with size " + width + "x" + height + " is out of bounds for render area " + this.renderArea);
|
||||
+ }
|
||||
+ this.backend.setViewport(x, y, width, height);
|
||||
+ }
|
||||
+
|
||||
public void enableScissor(int x, int y, int width, int height) {
|
||||
this.backend.enableScissor(x, y, width, height);
|
||||
}
|
||||
if (width > 0 && height > 0) {
|
||||
if (x >= this.renderArea.x()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/com/mojang/blaze3d/systems/RenderPassBackend.java
|
||||
+++ b/com/mojang/blaze3d/systems/RenderPassBackend.java
|
||||
@@ -26,6 +_,8 @@
|
||||
@@ -28,6 +_,8 @@
|
||||
|
||||
void setUniform(final String name, final GpuBufferSlice value);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/com/mojang/blaze3d/systems/RenderSystem.java
|
||||
+++ b/com/mojang/blaze3d/systems/RenderSystem.java
|
||||
@@ -74,6 +_,7 @@
|
||||
@@ -71,6 +_,7 @@
|
||||
private static @Nullable DynamicUniforms dynamicUniforms;
|
||||
private static final ScissorState scissorStateForRenderTypeDraws = new ScissorState();
|
||||
private static final SamplerCache samplerCache = new SamplerCache();
|
||||
@@ -21,26 +21,20 @@
|
||||
record GpuAsyncTask(Runnable callback, GpuFence fence) {
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Neo: Push the provided {@link net.neoforged.neoforge.client.pipeline.PipelineModifier PipelineModifier} to be applied to subsequent rendering.
|
||||
+ * <p>
|
||||
+ * Must be paired with a corresponding {@link #popPipelineModifier()} call after flushing the used buffers
|
||||
+ */
|
||||
+ /// Neo: Push the provided [net.neoforged.neoforge.client.pipeline.PipelineModifier] to be applied to subsequent rendering.
|
||||
+ ///
|
||||
+ /// Must be paired with a corresponding [#popPipelineModifier()] call after flushing the used buffers
|
||||
+ public static void pushPipelineModifier(net.minecraft.resources.ResourceKey<net.neoforged.neoforge.client.pipeline.PipelineModifier> modifier) {
|
||||
+ PIPELINE_MODIFIERS.push(modifier);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Neo: Pop the last {@link net.neoforged.neoforge.client.pipeline.PipelineModifier PipelineModifier} off the modifier stack
|
||||
+ */
|
||||
+ /// Neo: Pop the last [net.neoforged.neoforge.client.pipeline.PipelineModifier] off the modifier stack
|
||||
+ public static void popPipelineModifier() {
|
||||
+ PIPELINE_MODIFIERS.pop();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Neo: Run the provided {@link Runnable} with the provided {@link net.neoforged.neoforge.client.pipeline.PipelineModifier PipelineModifier} applied
|
||||
+ * to the pipelines used by the rendering done in the {@link Runnable}
|
||||
+ */
|
||||
+ /// Neo: Run the provided [Runnable] with the provided [net.neoforged.neoforge.client.pipeline.PipelineModifier] applied
|
||||
+ /// to the pipelines used by the rendering done in the [Runnable]
|
||||
+ public static void renderWithPipelineModifier(net.minecraft.resources.ResourceKey<net.neoforged.neoforge.client.pipeline.PipelineModifier> modifier, Runnable renderTask) {
|
||||
+ PIPELINE_MODIFIERS.renderWithModifier(modifier, renderTask);
|
||||
+ }
|
||||
@@ -53,5 +47,6 @@
|
||||
+ @org.jetbrains.annotations.ApiStatus.Internal
|
||||
+ public static void ensurePipelineModifiersEmpty() {
|
||||
+ PIPELINE_MODIFIERS.ensureEmpty();
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
public static final class AutoStorageIndexBuffer implements AutoCloseable {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
--- a/com/mojang/blaze3d/textures/TextureFormat.java
|
||||
+++ b/com/mojang/blaze3d/textures/TextureFormat.java
|
||||
@@ -4,11 +_,15 @@
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
[email protected](reason = "Additional texture formats may be added")
|
||||
public enum TextureFormat {
|
||||
RGBA8(4),
|
||||
RED8(1),
|
||||
RED8I(1),
|
||||
- DEPTH32(4);
|
||||
+ DEPTH32(4),
|
||||
+ // Neo: Add depth+stencil formats
|
||||
+ DEPTH24_STENCIL8(4),
|
||||
+ DEPTH32_STENCIL8(8);
|
||||
|
||||
private final int pixelSize;
|
||||
|
||||
@@ -25,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;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/com/mojang/blaze3d/vertex/VertexConsumer.java
|
||||
+++ b/com/mojang/blaze3d/vertex/VertexConsumer.java
|
||||
@@ -57,7 +_,7 @@
|
||||
@@ -59,7 +_,7 @@
|
||||
for (int vertex = 0; vertex < 4; vertex++) {
|
||||
Vector3fc pos = quad.position(vertex);
|
||||
long packedUv = quad.packedUV(vertex);
|
||||
@@ -9,7 +9,7 @@
|
||||
int light = instance.getLightCoordsWithEmission(vertex, lightEmission);
|
||||
float u = UVPair.unpackU(packedUv);
|
||||
float v = UVPair.unpackV(packedUv);
|
||||
@@ -74,11 +_,12 @@
|
||||
@@ -76,11 +_,12 @@
|
||||
for (int vertex = 0; vertex < 4; vertex++) {
|
||||
Vector3fc position = quad.position(vertex);
|
||||
long packedUv = quad.packedUV(vertex);
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
--- a/com/mojang/blaze3d/vertex/VertexFormat.java
|
||||
+++ b/com/mojang/blaze3d/vertex/VertexFormat.java
|
||||
@@ -219,4 +_,12 @@
|
||||
};
|
||||
}
|
||||
}
|
||||
+
|
||||
+ public ImmutableMap<String, VertexFormatElement> getElementMapping() {
|
||||
+ ImmutableMap.Builder<String, VertexFormatElement> builder = ImmutableMap.builder();
|
||||
+ for (int i = 0; i < elements.size(); i++) {
|
||||
+ builder.put(names.get(i), elements.get(i));
|
||||
+ }
|
||||
+ return builder.build();
|
||||
+ }
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
--- a/com/mojang/blaze3d/vertex/VertexFormatElement.java
|
||||
+++ b/com/mojang/blaze3d/vertex/VertexFormatElement.java
|
||||
@@ -67,6 +_,15 @@
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
+ public static int findNextId() {
|
||||
+ for (int i = 0; i < BY_ID.length; i++) {
|
||||
+ if (BY_ID[i] == null) {
|
||||
+ return i;
|
||||
+ }
|
||||
+ }
|
||||
+ throw new IllegalStateException("VertexFormatElement count limit exceeded");
|
||||
+ }
|
||||
+
|
||||
public static enum Type {
|
||||
FLOAT(4, "Float"),
|
||||
UBYTE(1, "Unsigned Byte"),
|
||||
@@ -0,0 +1,48 @@
|
||||
--- a/com/mojang/blaze3d/vulkan/VulkanCommandEncoder.java
|
||||
+++ b/com/mojang/blaze3d/vulkan/VulkanCommandEncoder.java
|
||||
@@ -309,6 +_,15 @@
|
||||
}
|
||||
|
||||
renderingInfo.pDepthAttachment(depthAttachmentInfo);
|
||||
+
|
||||
+ if (vulkanDepthAttachment.texture().getFormat().hasStencilAspect()) {
|
||||
+ VkRenderingAttachmentInfo stencilAttachmentInfo = VkRenderingAttachmentInfo.calloc(stack).sType$Default();
|
||||
+ stencilAttachmentInfo.imageView(vulkanDepthAttachment.vkImageView());
|
||||
+ stencilAttachmentInfo.imageLayout(VK12.VK_IMAGE_LAYOUT_GENERAL);
|
||||
+ stencilAttachmentInfo.loadOp(VK12.VK_ATTACHMENT_LOAD_OP_LOAD);
|
||||
+ stencilAttachmentInfo.storeOp(VK12.VK_ATTACHMENT_STORE_OP_STORE);
|
||||
+ renderingInfo.pStencilAttachment(stencilAttachmentInfo);
|
||||
+ }
|
||||
}
|
||||
|
||||
KHRDynamicRendering.vkCmdBeginRenderingKHR(this.commandBuffer(), renderingInfo);
|
||||
@@ -321,6 +_,7 @@
|
||||
width,
|
||||
height,
|
||||
depthAttachment != null,
|
||||
+ depthAttachment != null && depthAttachment.textureView().texture().getFormat().hasStencilAspect(),
|
||||
descriptor.label()
|
||||
);
|
||||
}
|
||||
@@ -425,6 +_,21 @@
|
||||
public void clearDepthTexture(GpuTexture depthTexture, double clearDepth) {
|
||||
try (MemoryStack stack = MemoryStack.stackPush()) {
|
||||
this.clearDepthTextureUnsynced(stack, depthTexture, clearDepth);
|
||||
+ this.memoryBarrier(stack);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void clearStencilTexture(GpuTexture texture, int value) {
|
||||
+ try (MemoryStack stack = MemoryStack.stackPush()) {
|
||||
+ VkClearDepthStencilValue vkClearStencil = VkClearDepthStencilValue.calloc(stack).stencil(value);
|
||||
+ VkImageSubresourceRange subresourceRange = VkImageSubresourceRange.calloc(stack);
|
||||
+ subresourceRange.baseMipLevel(0);
|
||||
+ subresourceRange.levelCount(texture.getMipLevels());
|
||||
+ subresourceRange.baseArrayLayer(0);
|
||||
+ subresourceRange.layerCount(1);
|
||||
+ subresourceRange.aspectMask(VK12.VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
+ VK12.vkCmdClearDepthStencilImage(this.commandBuffer(), ((VulkanGpuTexture)texture).vkImage(), 1, vkClearStencil, subresourceRange);
|
||||
this.memoryBarrier(stack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/com/mojang/blaze3d/vulkan/VulkanConst.java
|
||||
+++ b/com/mojang/blaze3d/vulkan/VulkanConst.java
|
||||
@@ -261,4 +_,17 @@
|
||||
case FIFO_RELAXED -> 3;
|
||||
};
|
||||
}
|
||||
+
|
||||
+ public static int toVk(net.neoforged.neoforge.client.stencil.StencilOperation op) {
|
||||
+ return switch (op) {
|
||||
+ case KEEP -> org.lwjgl.vulkan.VK12.VK_STENCIL_OP_KEEP;
|
||||
+ case ZERO -> org.lwjgl.vulkan.VK12.VK_STENCIL_OP_ZERO;
|
||||
+ case REPLACE -> org.lwjgl.vulkan.VK12.VK_STENCIL_OP_REPLACE;
|
||||
+ case INCR -> org.lwjgl.vulkan.VK12.VK_STENCIL_OP_INCREMENT_AND_CLAMP;
|
||||
+ case DECR -> org.lwjgl.vulkan.VK12.VK_STENCIL_OP_DECREMENT_AND_CLAMP;
|
||||
+ case INVERT -> org.lwjgl.vulkan.VK12.VK_STENCIL_OP_INVERT;
|
||||
+ case INCR_WRAP -> org.lwjgl.vulkan.VK12.VK_STENCIL_OP_INCREMENT_AND_WRAP;
|
||||
+ case DECR_WRAP -> org.lwjgl.vulkan.VK12.VK_STENCIL_OP_DECREMENT_AND_WRAP;
|
||||
+ };
|
||||
+ }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
--- a/com/mojang/blaze3d/vulkan/VulkanDevice.java
|
||||
+++ b/com/mojang/blaze3d/vulkan/VulkanDevice.java
|
||||
@@ -279,12 +_,12 @@
|
||||
);
|
||||
if (vertexShader == IntermediaryShaderModule.INVALID) {
|
||||
LOGGER.error("Couldn't compile pipeline {}: vertex shader {} was invalid", pipeline.getLocation(), pipeline.getVertexShader());
|
||||
- return new VulkanRenderPipeline(pipeline, this, 0L, 0L, 0L, VulkanBindGroupLayout.INVALID_LAYOUT, 0L, 0L);
|
||||
+ return new VulkanRenderPipeline(pipeline, this, 0L, 0L, 0L, 0L, VulkanBindGroupLayout.INVALID_LAYOUT, 0L, 0L);
|
||||
}
|
||||
|
||||
if (fragmentShader == IntermediaryShaderModule.INVALID) {
|
||||
LOGGER.error("Couldn't compile pipeline {}: fragment shader {} was invalid", pipeline.getLocation(), pipeline.getFragmentShader());
|
||||
- return new VulkanRenderPipeline(pipeline, this, 0L, 0L, 0L, VulkanBindGroupLayout.INVALID_LAYOUT, 0L, 0L);
|
||||
+ return new VulkanRenderPipeline(pipeline, this, 0L, 0L, 0L, 0L, VulkanBindGroupLayout.INVALID_LAYOUT, 0L, 0L);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -292,7 +_,7 @@
|
||||
return VulkanRenderPipeline.compile(this, modules.layout(), pipeline, modules.vertex(), modules.fragment());
|
||||
} catch (ShaderCompileException e) {
|
||||
LOGGER.error("Couldn't compile pipeline {}: {}", pipeline.getLocation(), e.getMessage());
|
||||
- return new VulkanRenderPipeline(pipeline, this, 0L, 0L, 0L, VulkanBindGroupLayout.INVALID_LAYOUT, 0L, 0L);
|
||||
+ return new VulkanRenderPipeline(pipeline, this, 0L, 0L, 0L, 0L, VulkanBindGroupLayout.INVALID_LAYOUT, 0L, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
--- a/com/mojang/blaze3d/vulkan/VulkanRenderPass.java
|
||||
+++ b/com/mojang/blaze3d/vulkan/VulkanRenderPass.java
|
||||
@@ -52,6 +_,7 @@
|
||||
private final int outputWidth;
|
||||
private final int outputHeight;
|
||||
private final boolean hasDepth;
|
||||
+ private final boolean hasStencil;
|
||||
private final Supplier<String> label;
|
||||
protected int pushedDebugGroups = 0;
|
||||
private final VkCommandBuffer commandBuffer;
|
||||
@@ -69,6 +_,7 @@
|
||||
int outputWidth,
|
||||
int outputHeight,
|
||||
boolean hasDepth,
|
||||
+ boolean hasStencil,
|
||||
Supplier<String> label
|
||||
) {
|
||||
this.device = device;
|
||||
@@ -79,6 +_,7 @@
|
||||
this.outputWidth = outputWidth;
|
||||
this.outputHeight = outputHeight;
|
||||
this.hasDepth = hasDepth;
|
||||
+ this.hasStencil = hasStencil;
|
||||
this.label = label;
|
||||
|
||||
try (MemoryStack stack = MemoryStack.stackPush()) {
|
||||
@@ -124,6 +_,10 @@
|
||||
}
|
||||
|
||||
this.anyDescriptorDirty = true;
|
||||
+ if (this.hasStencil) {
|
||||
+ VK12.vkCmdBindPipeline(this.commandBuffer(), VK12.VK_PIPELINE_BIND_POINT_GRAPHICS, this.pipeline.withDepthStencilPipeline());
|
||||
+ return;
|
||||
+ }
|
||||
VK12.vkCmdBindPipeline(this.commandBuffer(), 0, this.hasDepth ? this.pipeline.withDepthPipeline() : this.pipeline.withoutDepthPipeline());
|
||||
}
|
||||
|
||||
@@ -149,6 +_,18 @@
|
||||
public void setUniform(String name, GpuBufferSlice value) {
|
||||
this.uniforms.put(name, value);
|
||||
this.anyDescriptorDirty = true;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setViewport(int x, int y, int width, int height) {
|
||||
+ try (MemoryStack stack = MemoryStack.stackPush()) {
|
||||
+ VkViewport.Buffer viewport = VkViewport.calloc(1, stack);
|
||||
+ viewport.x(x);
|
||||
+ viewport.y(y);
|
||||
+ viewport.width(width);
|
||||
+ viewport.height(height);
|
||||
+ VK12.vkCmdSetViewport(this.commandBuffer(), 0, viewport);
|
||||
+ }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,53 @@
|
||||
--- a/com/mojang/blaze3d/vulkan/VulkanRenderPipeline.java
|
||||
+++ b/com/mojang/blaze3d/vulkan/VulkanRenderPipeline.java
|
||||
@@ -36,6 +_,7 @@
|
||||
public record VulkanRenderPipeline(
|
||||
RenderPipeline info,
|
||||
VulkanDevice device,
|
||||
+ long withDepthStencilPipeline,
|
||||
long withDepthPipeline,
|
||||
long withoutDepthPipeline,
|
||||
long pipelineLayout,
|
||||
@@ -152,6 +_,27 @@
|
||||
depthStencilState.depthCompareOp(VulkanConst.toVk(pipeline.getDepthStencilState().depthTest()));
|
||||
}
|
||||
|
||||
+ if (pipeline.getStencilTest().isPresent()) {
|
||||
+ final var stencilTest = pipeline.getStencilTest().get();
|
||||
+ depthStencilState.stencilTestEnable(true);
|
||||
+ final var frontState = depthStencilState.front();
|
||||
+ frontState.failOp(VulkanConst.toVk(stencilTest.front().fail()));
|
||||
+ frontState.passOp(VulkanConst.toVk(stencilTest.front().pass()));
|
||||
+ frontState.depthFailOp(VulkanConst.toVk(stencilTest.front().depthFail()));
|
||||
+ frontState.compareOp(VulkanConst.toVk(stencilTest.front().compare()));
|
||||
+ frontState.compareMask(stencilTest.readMask());
|
||||
+ frontState.writeMask(stencilTest.writeMask());
|
||||
+ frontState.reference(stencilTest.referenceValue());
|
||||
+ final var backState = depthStencilState.front();
|
||||
+ backState.failOp(VulkanConst.toVk(stencilTest.front().fail()));
|
||||
+ backState.passOp(VulkanConst.toVk(stencilTest.front().pass()));
|
||||
+ backState.depthFailOp(VulkanConst.toVk(stencilTest.front().depthFail()));
|
||||
+ backState.compareOp(VulkanConst.toVk(stencilTest.front().compare()));
|
||||
+ backState.compareMask(stencilTest.readMask());
|
||||
+ backState.writeMask(stencilTest.writeMask());
|
||||
+ backState.reference(stencilTest.referenceValue()); // note: must match front unless portability feature is required and checked for (if on portability device)
|
||||
+ }
|
||||
+
|
||||
ColorTargetState[] colorTargetStates = pipeline.getColorTargetStates();
|
||||
org.lwjgl.vulkan.VkPipelineColorBlendAttachmentState.Buffer blendAttachments = VkPipelineColorBlendAttachmentState.calloc(
|
||||
colorTargetStates.length, stack
|
||||
@@ -219,8 +_,13 @@
|
||||
} else {
|
||||
withoutDepthPipeline = 0L;
|
||||
}
|
||||
+ renderingInfo.depthAttachmentFormat(VK12.VK_FORMAT_D32_SFLOAT_S8_UINT);
|
||||
+ renderingInfo.stencilAttachmentFormat(VK12.VK_FORMAT_D32_SFLOAT_S8_UINT);
|
||||
+ VulkanUtils.crashIfFailure(device, VK12.vkCreateGraphicsPipelines(device.vkDevice(), 0L, createInfo, null, pointer), "Can't compile pipeline " + pipeline.getLocation());
|
||||
+ final long withDepthStencilPipeline = pointer.get(0);
|
||||
+ device.instance().debug().setObjectName(device.vkDevice(), VK12.VK_OBJECT_TYPE_PIPELINE, withDepthStencilPipeline, () -> "Pipeline " + pipeline.getLocation());
|
||||
|
||||
- return new VulkanRenderPipeline(pipeline, device, withDepthPipeline, withoutDepthPipeline, pipelineLayout, layout, vertexModule, fragmentModule);
|
||||
+ return new VulkanRenderPipeline(pipeline, device, withDepthStencilPipeline, withDepthPipeline, withoutDepthPipeline, pipelineLayout, layout, vertexModule, fragmentModule);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
--- a/com/mojang/math/Transformation.java
|
||||
+++ b/com/mojang/math/Transformation.java
|
||||
@@ -156,6 +_,19 @@
|
||||
@@ -159,6 +_,19 @@
|
||||
return Objects.hash(this.matrix);
|
||||
}
|
||||
|
||||
+ private Matrix3f normalTransform = null;
|
||||
+ private org.joml.Matrix3f normalTransform = null;
|
||||
+ public org.joml.Matrix3fc getNormalMatrix() {
|
||||
+ checkNormalTransform();
|
||||
+ return normalTransform;
|
||||
+ }
|
||||
+ private void checkNormalTransform() {
|
||||
+ if (normalTransform == null) {
|
||||
+ normalTransform = new Matrix3f(matrix);
|
||||
+ normalTransform = new org.joml.Matrix3f(matrix);
|
||||
+ normalTransform.invert();
|
||||
+ normalTransform.transpose();
|
||||
+ }
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
@Override
|
||||
+ public boolean keyPressed(net.minecraft.client.input.KeyEvent keyEvent) {
|
||||
+ if (keyEvent.isEscape()) {
|
||||
+ minecraft.setScreen(this.nextScreen);
|
||||
+ minecraft.gui.setScreen(this.nextScreen);
|
||||
+ return true;
|
||||
+ }
|
||||
+ return super.keyPressed(keyEvent);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java
|
||||
+++ b/com/mojang/realmsclient/gui/screens/RealmsNotificationsScreen.java
|
||||
@@ -131,7 +_,7 @@
|
||||
@@ -123,7 +_,7 @@
|
||||
private void extractIcons(GuiGraphicsExtractor graphics) {
|
||||
int pendingInvitesCount = this.numberOfPendingInvites;
|
||||
int spacing = 24;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/CrashReport.java
|
||||
+++ b/net/minecraft/CrashReport.java
|
||||
@@ -58,14 +_,8 @@
|
||||
if (this.uncategorizedStackTrace != null && this.uncategorizedStackTrace.length > 0) {
|
||||
if (this.uncategorizedStackTrace.length > 0) {
|
||||
builder.append("-- Head --\n");
|
||||
builder.append("Thread: ").append(Thread.currentThread().getName()).append("\n");
|
||||
- builder.append("Stacktrace:\n");
|
||||
@@ -25,23 +25,20 @@
|
||||
this.systemReport.appendToCrashReportString(builder);
|
||||
}
|
||||
|
||||
@@ -92,18 +_,7 @@
|
||||
exception.setStackTrace(this.exception.getStackTrace());
|
||||
@@ -84,15 +_,7 @@
|
||||
exception = replaceMessage(exception, this.title);
|
||||
}
|
||||
|
||||
- String var4;
|
||||
- try {
|
||||
- writer = new StringWriter();
|
||||
- printWriter = new PrintWriter(writer);
|
||||
- exception.printStackTrace(printWriter);
|
||||
- var4 = writer.toString();
|
||||
- return writer.toString();
|
||||
- } finally {
|
||||
- IOUtils.closeQuietly((Writer)writer);
|
||||
- IOUtils.closeQuietly((Writer)printWriter);
|
||||
- IOUtils.closeQuietly(writer);
|
||||
- IOUtils.closeQuietly(printWriter);
|
||||
- }
|
||||
-
|
||||
- return var4;
|
||||
+ return net.neoforged.neoforge.logging.CrashReportExtender.generateEnhancedStackTrace(exception);
|
||||
}
|
||||
|
||||
public String getFriendlyReport(ReportType reportType, List<String> extraComments) {
|
||||
private static Throwable copyProperties(Throwable original, Throwable copy) {
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
--- a/net/minecraft/CrashReportCategory.java
|
||||
+++ b/net/minecraft/CrashReportCategory.java
|
||||
@@ -140,8 +_,10 @@
|
||||
if (full.length <= 0) {
|
||||
@@ -138,8 +_,10 @@
|
||||
return 0;
|
||||
} else {
|
||||
- this.stackTrace = new StackTraceElement[full.length - 3 - nestedOffset];
|
||||
- System.arraycopy(full, 3 + nestedOffset, this.stackTrace, 0, this.stackTrace.length);
|
||||
+ int len = full.length - 3 - nestedOffset;
|
||||
+ if (len <= 0) len = full.length;
|
||||
+ this.stackTrace = new StackTraceElement[len];
|
||||
+ System.arraycopy(full, full.length - len, this.stackTrace, 0, this.stackTrace.length);
|
||||
return this.stackTrace.length;
|
||||
}
|
||||
}
|
||||
@@ -188,16 +_,16 @@
|
||||
|
||||
if (this.stackTrace != null && this.stackTrace.length > 0) {
|
||||
- this.stackTrace = new StackTraceElement[full.length - 3 - nestedOffset];
|
||||
- System.arraycopy(full, 3 + nestedOffset, this.stackTrace, 0, this.stackTrace.length);
|
||||
+ int len = full.length - 3 - nestedOffset;
|
||||
+ if (len <= 0) len = full.length;
|
||||
+ this.stackTrace = new StackTraceElement[len];
|
||||
+ System.arraycopy(full, full.length - len, this.stackTrace, 0, this.stackTrace.length);
|
||||
return this.stackTrace.length;
|
||||
}
|
||||
|
||||
@@ -181,16 +_,16 @@
|
||||
|
||||
if (this.stackTrace.length > 0) {
|
||||
builder.append("\nStacktrace:");
|
||||
-
|
||||
- for (StackTraceElement element : this.stackTrace) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/SharedConstants.java
|
||||
+++ b/net/minecraft/SharedConstants.java
|
||||
@@ -123,7 +_,8 @@
|
||||
@@ -125,7 +_,8 @@
|
||||
public static final float MAXIMUM_BLOCK_EXPLOSION_RESISTANCE = 3600000.0F;
|
||||
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;
|
||||
@@ -216,6 +_,7 @@
|
||||
@@ -218,6 +_,7 @@
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/advancements/Advancement.java
|
||||
+++ b/net/minecraft/advancements/Advancement.java
|
||||
@@ -52,6 +_,7 @@
|
||||
@@ -55,6 +_,7 @@
|
||||
)
|
||||
.validate(Advancement::validate);
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, Advancement> STREAM_CODEC = StreamCodec.ofMember(Advancement::write, Advancement::read);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
--- a/net/minecraft/advancements/predicates/entity/EntityPredicate.java
|
||||
+++ b/net/minecraft/advancements/predicates/entity/EntityPredicate.java
|
||||
@@ -91,6 +_,11 @@
|
||||
return entity == null ? false : this.combinedPart.matches(entity, level, position);
|
||||
}
|
||||
|
||||
+ @Nullable
|
||||
+ public <T extends EntitySubPredicate> T getPartIfExists(Codec<T> type) {
|
||||
+ return (T) parts.get(type);
|
||||
+ }
|
||||
+
|
||||
public static LootContext createContext(ServerPlayer player, Entity entity) {
|
||||
LootParams lootParams = new LootParams.Builder(player.level())
|
||||
.withParameter(LootContextParams.THIS_ENTITY, entity)
|
||||
@@ -140,6 +_,12 @@
|
||||
|
||||
public static EntityPredicate.Builder entity() {
|
||||
return new EntityPredicate.Builder();
|
||||
+ }
|
||||
+
|
||||
+ public static EntityPredicate.Builder from(EntityPredicate predicate) {
|
||||
+ var builder = new Builder();
|
||||
+ builder.parts.putAll(predicate.parts);
|
||||
+ return builder;
|
||||
}
|
||||
|
||||
public <T extends EntitySubPredicate> EntityPredicate.Builder put(Codec<T> key, T predicate) {
|
||||
@@ -8,7 +8,7 @@
|
||||
private final Quaternionf rotation = new Quaternionf();
|
||||
private boolean detached;
|
||||
private float eyeHeight;
|
||||
@@ -136,6 +_,9 @@
|
||||
@@ -142,6 +_,9 @@
|
||||
cameraState.entityRenderState.hurtTime = livingEntity.hurtTime - cameraEntityPartialTicks;
|
||||
cameraState.entityRenderState.deathTime = livingEntity.deathTime + cameraEntityPartialTicks;
|
||||
cameraState.entityRenderState.hurtDuration = livingEntity.hurtDuration;
|
||||
@@ -18,39 +18,15 @@
|
||||
} else {
|
||||
cameraState.entityRenderState.isLiving = false;
|
||||
cameraState.entityRenderState.isSleeping = false;
|
||||
@@ -217,15 +_,21 @@
|
||||
return 90.0F;
|
||||
} else {
|
||||
float fov = this.minecraft.options.fov().get().intValue() * Mth.lerp(partialTicks, this.oldFovModifier, this.fovModifier);
|
||||
- return this.modifyFovBasedOnDeathOrFluid(partialTicks, fov);
|
||||
+ return this.modifyFovBasedOnDeathOrFluid(partialTicks, fov, true);
|
||||
}
|
||||
}
|
||||
|
||||
private float calculateHudFov(float partialTicks) {
|
||||
- return this.modifyFovBasedOnDeathOrFluid(partialTicks, 70.0F);
|
||||
+ return this.modifyFovBasedOnDeathOrFluid(partialTicks, 70.0F, false);
|
||||
}
|
||||
|
||||
+ /** @deprecated Neo: use {@link #modifyFovBasedOnDeathOrFluid(float, float, boolean)} instead */
|
||||
+ @Deprecated
|
||||
private float modifyFovBasedOnDeathOrFluid(float partialTicks, float fov) {
|
||||
+ return modifyFovBasedOnDeathOrFluid(partialTicks, fov, false);
|
||||
+ }
|
||||
+
|
||||
+ private float modifyFovBasedOnDeathOrFluid(float partialTicks, float fov, boolean useFovSetting) {
|
||||
if (this.entity instanceof LivingEntity cameraEntity && cameraEntity.isDeadOrDying()) {
|
||||
float duration = Math.min(cameraEntity.deathTime + partialTicks, 20.0F);
|
||||
fov /= (1.0F - 500.0F / (duration + 500.0F)) * 2.0F + 1.0F;
|
||||
@@ -237,6 +_,7 @@
|
||||
@@ -243,6 +_,7 @@
|
||||
fov *= Mth.lerp(effectScale, 1.0F, 0.85714287F);
|
||||
}
|
||||
|
||||
+ fov = net.neoforged.neoforge.client.ClientHooks.getFieldOfView(this.minecraft.gameRenderer, this, partialTicks, fov, useFovSetting);
|
||||
+ fov = net.neoforged.neoforge.client.ClientHooks.getFieldOfView(this.minecraft.gameRenderer, this, partialTicks, fov);
|
||||
return fov;
|
||||
}
|
||||
|
||||
@@ -252,7 +_,10 @@
|
||||
@@ -258,7 +_,10 @@
|
||||
this.setRotation(this.entity.getViewYRot(partialTicks), this.entity.getViewXRot(partialTicks));
|
||||
this.setPosition(behavior.getCartLerpPosition(partialTicks).add(positionOffset));
|
||||
} else {
|
||||
@@ -60,9 +36,9 @@
|
||||
+ );
|
||||
+ this.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll());
|
||||
this.setPosition(
|
||||
Mth.lerp((double)partialTicks, this.entity.xo, this.entity.getX()),
|
||||
Mth.lerp((double)partialTicks, this.entity.yo, this.entity.getY()) + Mth.lerp(partialTicks, this.eyeHeightOld, this.eyeHeight),
|
||||
@@ -263,7 +_,7 @@
|
||||
Mth.lerp(partialTicks, this.entity.xo, this.entity.getX()),
|
||||
Mth.lerp(partialTicks, this.entity.yo, this.entity.getY()) + Mth.lerp(partialTicks, this.eyeHeightOld, this.eyeHeight),
|
||||
@@ -269,7 +_,7 @@
|
||||
this.detached = !this.minecraft.options.getCameraType().isFirstPerson();
|
||||
if (this.detached) {
|
||||
if (this.minecraft.options.getCameraType().isMirrored()) {
|
||||
@@ -71,7 +47,7 @@
|
||||
}
|
||||
|
||||
float cameraDistance = 4.0F;
|
||||
@@ -280,7 +_,7 @@
|
||||
@@ -286,7 +_,7 @@
|
||||
mountDistance = (float)mount.getAttributeValue(Attributes.CAMERA_DISTANCE);
|
||||
}
|
||||
|
||||
@@ -80,7 +56,7 @@
|
||||
} else if (this.entity instanceof LivingEntity && ((LivingEntity)this.entity).isSleeping()) {
|
||||
Direction bedOrientation = ((LivingEntity)this.entity).getBedOrientation();
|
||||
this.setRotation(bedOrientation != null ? bedOrientation.toYRot() - 180.0F : 0.0F, 0.0F);
|
||||
@@ -330,10 +_,17 @@
|
||||
@@ -336,10 +_,17 @@
|
||||
this.setPosition(new Vec3(this.position.x + offset.x, this.position.y + offset.y, this.position.z + offset.z));
|
||||
}
|
||||
|
||||
@@ -99,7 +75,7 @@
|
||||
FORWARDS.rotate(this.rotation, this.forwards);
|
||||
UP.rotate(this.rotation, this.up);
|
||||
LEFT.rotate(this.rotation, this.left);
|
||||
@@ -493,6 +_,17 @@
|
||||
@@ -499,6 +_,17 @@
|
||||
|
||||
public void disablePanoramicMode() {
|
||||
this.isPanoramicMode = false;
|
||||
@@ -109,11 +85,11 @@
|
||||
+ return this.roll;
|
||||
+ }
|
||||
+
|
||||
+ public net.minecraft.world.level.block.state.BlockState getBlockAtCamera() {
|
||||
+ if (!this.initialized)
|
||||
+ return net.minecraft.world.level.block.Blocks.AIR.defaultBlockState();
|
||||
+ else
|
||||
+ return this.level.getBlockState(this.blockPosition).getStateAtViewpoint(this.level, this.blockPosition, this.position);
|
||||
+ public BlockState getBlockAtCamera() {
|
||||
+ if (!this.initialized) {
|
||||
+ return Blocks.AIR.defaultBlockState();
|
||||
+ }
|
||||
+ return this.level.getBlockState(this.blockPosition).getStateAtViewpoint(this.level, this.blockPosition, this.position);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class NearPlane {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
--- a/net/minecraft/client/ClientClockManager.java
|
||||
+++ b/net/minecraft/client/ClientClockManager.java
|
||||
@@ -46,6 +_,11 @@
|
||||
@@ -46,6 +_,12 @@
|
||||
return this.getInstance(definition).totalTicks;
|
||||
}
|
||||
|
||||
+
|
||||
+ @Override
|
||||
+ public float getPartialTick(Holder<WorldClock> definition) {
|
||||
+ return this.getInstance(definition).partialTick;
|
||||
+ }
|
||||
+
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static class ClockInstance {
|
||||
private long totalTicks;
|
||||
private float partialTick;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
--- a/net/minecraft/client/KeyMapping.java
|
||||
+++ b/net/minecraft/client/KeyMapping.java
|
||||
@@ -20,8 +_,8 @@
|
||||
@@ -22,8 +_,8 @@
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class KeyMapping implements Comparable<KeyMapping>, net.neoforged.neoforge.client.extensions.IKeyMappingExtension {
|
||||
public class KeyMapping implements Comparable<KeyMapping>, IKeyMappingExtension {
|
||||
- private static final Map<String, KeyMapping> ALL = Maps.newHashMap();
|
||||
- private static final Map<InputConstants.Key, List<KeyMapping>> MAP = Maps.newHashMap();
|
||||
+ private static final Map<String, KeyMapping> ALL = Maps.newConcurrentMap();
|
||||
@@ -11,7 +11,7 @@
|
||||
private final String name;
|
||||
private final InputConstants.Key defaultKey;
|
||||
private final KeyMapping.Category category;
|
||||
@@ -29,17 +_,25 @@
|
||||
@@ -31,17 +_,25 @@
|
||||
boolean isDown;
|
||||
private int clickCount;
|
||||
private final int order;
|
||||
@@ -39,7 +39,7 @@
|
||||
if (keyMappings != null && !keyMappings.isEmpty()) {
|
||||
for (KeyMapping keyMapping : keyMappings) {
|
||||
operation.accept(keyMapping);
|
||||
@@ -105,8 +_,83 @@
|
||||
@@ -107,8 +_,83 @@
|
||||
this.registerMapping(this.key);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
}
|
||||
|
||||
public KeyMapping.Category getCategory() {
|
||||
@@ -157,6 +_,20 @@
|
||||
@@ -159,6 +_,20 @@
|
||||
}
|
||||
|
||||
public boolean same(KeyMapping that) {
|
||||
@@ -145,7 +145,7 @@
|
||||
return this.key.equals(that.key);
|
||||
}
|
||||
|
||||
@@ -175,11 +_,13 @@
|
||||
@@ -177,11 +_,13 @@
|
||||
}
|
||||
|
||||
public Component getTranslatedKeyMessage() {
|
||||
@@ -160,7 +160,7 @@
|
||||
}
|
||||
|
||||
public String saveString() {
|
||||
@@ -191,7 +_,7 @@
|
||||
@@ -193,7 +_,7 @@
|
||||
}
|
||||
|
||||
private void registerMapping(InputConstants.Key key) {
|
||||
@@ -169,7 +169,7 @@
|
||||
}
|
||||
|
||||
public static @Nullable KeyMapping get(String name) {
|
||||
@@ -214,6 +_,10 @@
|
||||
@@ -215,6 +_,10 @@
|
||||
return register(Identifier.withDefaultNamespace(name));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/KeyboardHandler.java
|
||||
+++ b/net/minecraft/client/KeyboardHandler.java
|
||||
@@ -514,7 +_,11 @@
|
||||
@@ -501,7 +_,11 @@
|
||||
if (screen != null) {
|
||||
try {
|
||||
if (action != 1 && action != 2) {
|
||||
@@ -13,7 +13,7 @@
|
||||
if (options.keyDebugModifier.matches(event)) {
|
||||
this.usedDebugKeyAsModifier = false;
|
||||
}
|
||||
@@ -523,7 +_,11 @@
|
||||
@@ -510,7 +_,11 @@
|
||||
}
|
||||
} else {
|
||||
screen.afterKeyboardAction();
|
||||
@@ -23,10 +23,10 @@
|
||||
+ screen.keyPressed(event) ||
|
||||
+ net.neoforged.neoforge.client.ClientHooks.onScreenKeyPressedPost(screen, event)
|
||||
+ ) {
|
||||
if (this.minecraft.screen == null) {
|
||||
if (this.minecraft.gui.screen() == null) {
|
||||
InputConstants.Key key = InputConstants.getKey(event);
|
||||
KeyMapping.set(key, false);
|
||||
@@ -595,6 +_,7 @@
|
||||
@@ -582,6 +_,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,14 +34,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,7 +_,9 @@
|
||||
Screen screen = this.minecraft.screen;
|
||||
if (screen != null && this.minecraft.getOverlay() == null) {
|
||||
@@ -590,7 +_,9 @@
|
||||
Screen screen = this.minecraft.gui.screen();
|
||||
if (screen != null && this.minecraft.gui.overlay() == null) {
|
||||
try {
|
||||
- screen.charTyped(event);
|
||||
+ if (net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPre(screen, event)) return;
|
||||
+ if (screen.charTyped(event)) return;
|
||||
+ net.neoforged.neoforge.client.ClientHooks.onScreenCharTypedPost(screen, event);
|
||||
} catch (Throwable var8) {
|
||||
CrashReport report = CrashReport.forThrowable(var8, "charTyped event handler");
|
||||
} catch (Throwable t) {
|
||||
CrashReport report = CrashReport.forThrowable(t, "charTyped event handler");
|
||||
screen.fillCrashDetails(report);
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
--- a/net/minecraft/client/Minecraft.java
|
||||
+++ b/net/minecraft/client/Minecraft.java
|
||||
@@ -432,7 +_,6 @@
|
||||
@@ -274,6 +_,7 @@
|
||||
public final LevelExtractor levelExtractor;
|
||||
public final LevelRenderer levelRenderer;
|
||||
private final EntityRenderDispatcher entityRenderDispatcher;
|
||||
+ private final BlockModelResolver blockModelResolver;
|
||||
private final ItemModelResolver itemModelResolver;
|
||||
private final MapRenderer mapRenderer;
|
||||
public final ParticleEngine particleEngine;
|
||||
@@ -404,7 +_,6 @@
|
||||
}
|
||||
}, Util.nonCriticalIoPool());
|
||||
LOGGER.info("Setting user: {}", this.user.getName());
|
||||
@@ -8,113 +16,118 @@
|
||||
this.demo = gameConfig.game.demo;
|
||||
this.allowsMultiplayer = !gameConfig.game.disableMultiplayer;
|
||||
this.allowsChat = !gameConfig.game.disableChat;
|
||||
@@ -466,6 +_,8 @@
|
||||
@@ -436,6 +_,7 @@
|
||||
StringBuilder errorMsgBuilder = new StringBuilder("No supported graphics backend was found.");
|
||||
Window windowCandidate = null;
|
||||
GpuDevice device = null;
|
||||
+
|
||||
PreferredGraphicsApi forcedGraphicsApi = gameConfig.game.forcedGraphicsApi;
|
||||
if (forcedGraphicsApi != null) {
|
||||
LOGGER.warn(
|
||||
@@ -446,6 +_,9 @@
|
||||
|
||||
PreferredGraphicsApi preferredGraphicsBackend = forcedGraphicsApi == null ? this.options.preferredGraphicsBackend().get() : forcedGraphicsApi;
|
||||
|
||||
+ // 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);
|
||||
|
||||
for (GpuBackend backend : backends) {
|
||||
+
|
||||
for (GpuBackend backend : preferredGraphicsBackend.getBackendsToTry()) {
|
||||
try {
|
||||
@@ -474,7 +_,7 @@
|
||||
.createDevice(
|
||||
windowCandidate.handle(),
|
||||
GLFW.glfwDefaultWindowHints();
|
||||
@@ -457,8 +_,8 @@
|
||||
(id, type) -> this.getShaderManager().getShader(id, type),
|
||||
- new GpuDebugOptions(this.options.glDebugVerbosity, SharedConstants.DEBUG_SYNCHRONOUS_GL_LOGS, gameConfig.game.renderDebugLabels)
|
||||
+ new GpuDebugOptions(this.options.glDebugVerbosity, SharedConstants.DEBUG_SYNCHRONOUS_GL_LOGS || enableGlDebug, gameConfig.game.renderDebugLabels || enableGlDebug)
|
||||
);
|
||||
RenderSystem.initRenderer(device);
|
||||
break;
|
||||
@@ -518,14 +_,16 @@
|
||||
LOGGER.error("Couldn't set icon", (Throwable)var23);
|
||||
new GpuDebugOptions(
|
||||
this.options.glDebugVerbosity,
|
||||
- SharedConstants.DEBUG_SYNCHRONOUS_GL_LOGS,
|
||||
- gameConfig.game.renderDebugLabels,
|
||||
+ SharedConstants.DEBUG_SYNCHRONOUS_GL_LOGS || enableGlDebug,
|
||||
+ gameConfig.game.renderDebugLabels || enableGlDebug,
|
||||
gameConfig.game.vulkanValidation
|
||||
),
|
||||
this::loadCriticalShaders
|
||||
@@ -522,12 +_,14 @@
|
||||
LOGGER.error("Couldn't set icon", e);
|
||||
}
|
||||
|
||||
+ // Neo: Move mouse and keyboard handler setup further below
|
||||
this.mouseHandler = new MouseHandler(this);
|
||||
- this.mouseHandler.setup(this.window);
|
||||
this.keyboardHandler = new KeyboardHandler(this);
|
||||
- this.keyboardHandler.setup(this.window);
|
||||
this.options.applyGraphicsPreset(this.options.graphicsPreset().get());
|
||||
this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES);
|
||||
+ net.neoforged.neoforge.client.loading.ClientModLoader.setupModResourcePacks(this.resourcePackRepository);
|
||||
+ //Move client bootstrap to after mod loading so that events can be fired for it.
|
||||
+ ClientBootstrap.bootstrap();
|
||||
this.resourcePackRepository.reload();
|
||||
this.options.loadSelectedResourcePacks(this.resourcePackRepository);
|
||||
this.languageManager = new LanguageManager(this.options.languageCode, var1 -> {
|
||||
@@ -563,11 +_,13 @@
|
||||
RenderSystem.setupDefaultState();
|
||||
this.window.setErrorSection("Post startup");
|
||||
this.blockColors = BlockColors.createDefault();
|
||||
+ net.neoforged.neoforge.client.model.UnbakedModelParser.init();
|
||||
this.modelManager = new ModelManager(this.blockColors, this.atlasManager, this.playerSkinRenderCache);
|
||||
this.resourceManager.registerReloadListener(this.modelManager);
|
||||
EquipmentAssetManager equipmentAssets = new EquipmentAssetManager();
|
||||
this.resourceManager.registerReloadListener(equipmentAssets);
|
||||
BlockModelResolver blockModelResolver = new BlockModelResolver(this.modelManager);
|
||||
+ this.blockModelResolver = blockModelResolver;
|
||||
this.itemModelResolver = new ItemModelResolver(this.modelManager);
|
||||
this.mapTextureManager = new MapTextureManager(this.textureManager);
|
||||
this.mapRenderer = new MapRenderer(this.atlasManager, this.mapTextureManager);
|
||||
@@ -606,6 +_,7 @@
|
||||
this.resourceManager.registerReloadListener(particleResources);
|
||||
this.particleEngine = new ParticleEngine(this.level, particleResources);
|
||||
particleResources.onReload(this.particleEngine::clearParticles);
|
||||
+ net.neoforged.neoforge.client.ClientHooks.onRegisterParticleProviders(particleResources);
|
||||
this.gameRenderer = new GameRenderer(this, this.entityRenderDispatcher.getItemInHandRenderer(), this.modelManager);
|
||||
WindowRenderState windowRenderState = this.gameRenderer.gameRenderState().windowRenderState;
|
||||
windowRenderState.width = this.window.getWidth();
|
||||
@@ -627,6 +_,9 @@
|
||||
this.gpuWarnlistManager = new GpuWarnlistManager();
|
||||
this.resourceManager.registerReloadListener(this.gpuWarnlistManager);
|
||||
this.resourceManager.registerReloadListener(this.regionalCompliancies);
|
||||
+ // NEO: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them.
|
||||
+ this.mouseHandler.setup(this.window);
|
||||
+ this.keyboardHandler.setup(this.window);
|
||||
this.gui = new Gui(this, new Hud(this), this.gameRenderer.gameRenderState().guiRenderState);
|
||||
this.gui.registerReloadListeners(this.resourceManager);
|
||||
RealmsClient realmsClient = RealmsClient.getOrCreate(this);
|
||||
@@ -661,6 +_,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ net.neoforged.neoforge.client.ClientHooks.initClientHooks(this, this.resourceManager);
|
||||
this.window.updateRawMouseInput(this.options.rawMouseInput().get());
|
||||
this.window.setAllowCursorChanges(this.options.allowCursorChanges().get());
|
||||
this.window.setDefaultErrorCallback();
|
||||
@@ -677,6 +_,7 @@
|
||||
TitleScreen.registerTextures(this.textureManager);
|
||||
LoadingOverlay.registerTextures(this.textureManager);
|
||||
this.gameRenderer.registerPanoramaTextures(this.textureManager);
|
||||
+ net.neoforged.neoforge.client.loading.ClientModLoader.finish();
|
||||
this.timerQuery = new TimerQuery();
|
||||
this.gui.setScreen(new GenericMessageScreen(Component.translatable("gui.loadingMinecraft")));
|
||||
List<PackResources> packs = this.resourcePackRepository.openAllSelected();
|
||||
@@ -686,7 +_,7 @@
|
||||
GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS);
|
||||
GameLoadCookie loadCookie = new GameLoadCookie(realmsClient, gameConfig.quickPlay);
|
||||
this.gui.setOverlay(new LoadingOverlay(this, reloadInstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, loadCookie), () -> {
|
||||
- if (SharedConstants.IS_RUNNING_IN_IDE) {
|
||||
+ if (SharedConstants.IS_RUNNING_IN_IDE && false /* Neo: Disable self-test */) {
|
||||
this.selfTest();
|
||||
}
|
||||
|
||||
+ // FORGE: Move mouse and keyboard handler setup further below
|
||||
this.mouseHandler = new MouseHandler(this);
|
||||
- this.mouseHandler.setup(this.window);
|
||||
this.keyboardHandler = new KeyboardHandler(this);
|
||||
- this.keyboardHandler.setup(this.window);
|
||||
this.options.applyGraphicsPreset(this.options.graphicsPreset().get());
|
||||
LOGGER.info("Using optional rendering extensions: {}", String.join(", ", RenderSystem.getDevice().getEnabledExtensions()));
|
||||
- this.mainRenderTarget = new MainTarget(this.window.getWidth(), this.window.getHeight());
|
||||
+ this.mainRenderTarget = net.neoforged.neoforge.client.ClientHooks.instantiateMainTarget(this.window.getWidth(), this.window.getHeight());
|
||||
this.resourceManager = new ReloadableResourceManager(PackType.CLIENT_RESOURCES);
|
||||
+ net.neoforged.neoforge.client.loading.ClientModLoader.setupModResourcePacks(this.resourcePackRepository);
|
||||
+ //Move client bootstrap to after mod loading so that events can be fired for it.
|
||||
+ ClientBootstrap.bootstrap();
|
||||
this.resourcePackRepository.reload();
|
||||
this.options.loadSelectedResourcePacks(this.resourcePackRepository);
|
||||
this.languageManager = new LanguageManager(this.options.languageCode, languageData -> {
|
||||
@@ -564,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.blockColors, this.atlasManager, this.playerSkinRenderCache);
|
||||
this.resourceManager.registerReloadListener(this.modelManager);
|
||||
EquipmentAssetManager equipmentAssets = new EquipmentAssetManager();
|
||||
@@ -614,6 +_,7 @@
|
||||
this.resourceManager.registerReloadListener(this.particleResources);
|
||||
this.particleEngine = new ParticleEngine(this.level, this.particleResources);
|
||||
this.particleResources.onReload(this.particleEngine::clearParticles);
|
||||
+ net.neoforged.neoforge.client.ClientHooks.onRegisterParticleProviders(this.particleResources);
|
||||
this.waypointStyles = new WaypointStyleManager();
|
||||
this.resourceManager.registerReloadListener(this.waypointStyles);
|
||||
this.gameRenderer = new GameRenderer(this, this.entityRenderDispatcher.getItemInHandRenderer(), this.renderBuffers, this.modelManager);
|
||||
@@ -633,6 +_,9 @@
|
||||
this.gpuWarnlistManager = new GpuWarnlistManager();
|
||||
this.resourceManager.registerReloadListener(this.gpuWarnlistManager);
|
||||
this.resourceManager.registerReloadListener(this.regionalCompliancies);
|
||||
+ // NEO: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them.
|
||||
+ this.mouseHandler.setup(this.window);
|
||||
+ this.keyboardHandler.setup(this.window);
|
||||
this.gui = new Gui(this);
|
||||
RealmsClient realmsClient = RealmsClient.getOrCreate(this);
|
||||
this.realmsDataFetcher = new RealmsDataFetcher(realmsClient);
|
||||
@@ -665,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.setAllowCursorChanges(this.options.allowCursorChanges().get());
|
||||
@@ -683,6 +_,7 @@
|
||||
TitleScreen.registerTextures(this.textureManager);
|
||||
LoadingOverlay.registerTextures(this.textureManager);
|
||||
this.gameRenderer.registerPanoramaTextures(this.textureManager);
|
||||
+ net.neoforged.neoforge.client.loading.ClientModLoader.finish();
|
||||
this.setScreen(new GenericMessageScreen(Component.translatable("gui.loadingMinecraft")));
|
||||
List<PackResources> packs = this.resourcePackRepository.openAllSelected();
|
||||
this.reloadStateTracker.startReload(ResourceLoadStateTracker.ReloadReason.INITIAL, packs);
|
||||
@@ -691,7 +_,7 @@
|
||||
GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS);
|
||||
Minecraft.GameLoadCookie loadCookie = new Minecraft.GameLoadCookie(realmsClient, gameConfig.quickPlay);
|
||||
this.setOverlay(new LoadingOverlay(this, reloadInstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, loadCookie), () -> {
|
||||
- if (SharedConstants.IS_RUNNING_IN_IDE) {
|
||||
+ if (SharedConstants.IS_RUNNING_IN_IDE && false /* Neo: Disable self-test */) {
|
||||
this.selfTest();
|
||||
}
|
||||
|
||||
@@ -727,6 +_,7 @@
|
||||
@@ -740,6 +_,7 @@
|
||||
}
|
||||
|
||||
private void onResourceLoadFinished(Minecraft.@Nullable GameLoadCookie loadCookie) {
|
||||
private void onResourceLoadFinished(@Nullable GameLoadCookie loadCookie) {
|
||||
+ net.neoforged.neoforge.client.ClientHooks.fireResourceLoadFinishedEvent(!this.gameLoadFinished);
|
||||
if (!this.gameLoadFinished) {
|
||||
this.gameLoadFinished = true;
|
||||
this.onGameLoadFinished(loadCookie);
|
||||
@@ -763,6 +_,8 @@
|
||||
nextStep = () -> this.setScreen(screen);
|
||||
}
|
||||
|
||||
+ nextStep = net.neoforged.neoforge.client.loading.ClientModLoader.completeModLoading(nextStep);
|
||||
+
|
||||
return nextStep;
|
||||
}
|
||||
|
||||
@@ -815,7 +_,7 @@
|
||||
@@ -775,7 +_,7 @@
|
||||
private String createTitle() {
|
||||
StringBuilder builder = new StringBuilder("Minecraft");
|
||||
if (checkModStatus().shouldReportAsModified()) {
|
||||
@@ -123,16 +136,16 @@
|
||||
}
|
||||
|
||||
builder.append(" ");
|
||||
@@ -851,7 +_,7 @@
|
||||
@@ -815,7 +_,7 @@
|
||||
}
|
||||
|
||||
private void rollbackResourcePacks(Throwable t, Minecraft.@Nullable GameLoadCookie loadCookie) {
|
||||
private void rollbackResourcePacks(Throwable t, @Nullable GameLoadCookie loadCookie) {
|
||||
- if (this.resourcePackRepository.getSelectedIds().size() > 1) {
|
||||
+ if (this.resourcePackRepository.getSelectedPacks().stream().anyMatch(e -> !e.isRequired())) { //Forge: This caused infinite loop if any resource packs are forced. Such as mod resources. So check if we can disable any.
|
||||
this.clearResourcePacksOnError(t, null, loadCookie);
|
||||
} else {
|
||||
Util.throwAsRuntime(t);
|
||||
@@ -907,6 +_,8 @@
|
||||
@@ -871,6 +_,8 @@
|
||||
DiscontinuousFrame tickFrame = TracyClient.createDiscontinuousFrame("Client Tick");
|
||||
|
||||
try {
|
||||
@@ -141,108 +154,76 @@
|
||||
boolean oomRecovery = false;
|
||||
|
||||
while (this.running) {
|
||||
@@ -977,7 +_,7 @@
|
||||
@@ -932,7 +_,7 @@
|
||||
CrashReport finalReport = this.fillReport(partialReport);
|
||||
int exitCode = saveReportAndShutdownSoundManager(this, this.gameDirectory, finalReport);
|
||||
int exitCode = saveReportAndShutdownSoundManager(this, this.gameDirectory, finalReport, -1);
|
||||
this.emergencySave();
|
||||
- System.exit(exitCode);
|
||||
+ net.neoforged.neoforge.server.ServerLifecycleHooks.handleExit(exitCode);
|
||||
}
|
||||
|
||||
public static int saveReport(File gameDirectory, CrashReport crash) {
|
||||
@@ -1009,7 +_,7 @@
|
||||
public static void saveReport(File gameDirectory, CrashReport crash) {
|
||||
@@ -969,7 +_,7 @@
|
||||
|
||||
public static void crash(@Nullable Minecraft minecraft, File gameDirectory, CrashReport crash) {
|
||||
int exitCode = saveReportAndShutdownSoundManager(minecraft, gameDirectory, crash);
|
||||
- System.exit(exitCode);
|
||||
+ net.neoforged.neoforge.server.ServerLifecycleHooks.handleExit(exitCode);
|
||||
public static void crash(@Nullable Minecraft minecraft, File gameDirectory, CrashReport crash, int exitCode) {
|
||||
int actualExitCode = saveReportAndShutdownSoundManager(minecraft, gameDirectory, crash, exitCode);
|
||||
- System.exit(actualExitCode);
|
||||
+ net.neoforged.neoforge.server.ServerLifecycleHooks.handleExit(actualExitCode);
|
||||
}
|
||||
|
||||
private static int saveReportAndShutdownSoundManager(@Nullable Minecraft minecraft, File gameDirectory, CrashReport crash) {
|
||||
@@ -1128,9 +_,7 @@
|
||||
LOGGER.error("setScreen called from non-game thread");
|
||||
}
|
||||
public static int saveReportAndShutdownSoundManager(@Nullable Minecraft minecraft, File gameDirectory, CrashReport crash, int exitCode) {
|
||||
@@ -1073,6 +_,7 @@
|
||||
|
||||
- if (this.screen != null) {
|
||||
- this.screen.removed();
|
||||
- } else {
|
||||
+ if (this.screen == null) {
|
||||
this.setLastInputType(InputType.NONE);
|
||||
}
|
||||
|
||||
@@ -1152,6 +_,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ net.neoforged.neoforge.client.ClientHooks.clearGuiLayers(this);
|
||||
+ Screen old = this.screen;
|
||||
+ if (screen != null) {
|
||||
+ var event = new net.neoforged.neoforge.client.event.ScreenEvent.Opening(old, screen);
|
||||
+ if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event).isCanceled()) return;
|
||||
+ screen = event.getNewScreen();
|
||||
+ }
|
||||
+
|
||||
+ if (old != null && screen != old) {
|
||||
+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.ScreenEvent.Closing(old));
|
||||
+ old.removed();
|
||||
+ }
|
||||
+
|
||||
this.screen = screen;
|
||||
if (this.screen != null) {
|
||||
this.screen.added();
|
||||
@@ -1180,6 +_,7 @@
|
||||
|
||||
public void destroy() {
|
||||
public void exitWorldAndClose() {
|
||||
try {
|
||||
+ net.neoforged.neoforge.client.ClientLifecycleHooks.handleClientStopping(this);
|
||||
LOGGER.info("Stopping!");
|
||||
|
||||
try {
|
||||
@@ -1201,6 +_,7 @@
|
||||
}
|
||||
|
||||
this.close();
|
||||
if (this.level != null) {
|
||||
this.level.disconnect(ClientLevel.DEFAULT_QUIT_MESSAGE);
|
||||
@@ -1114,6 +_,8 @@
|
||||
Util.shutdownExecutors();
|
||||
this.windowSurface.close();
|
||||
RenderSystem.shutdownRenderer();
|
||||
+
|
||||
+ net.neoforged.neoforge.client.ClientLifecycleHooks.handleClientStopped(this);
|
||||
} finally {
|
||||
Util.timeSource = System::nanoTime;
|
||||
if (!this.hasDelayedCrash()) {
|
||||
@@ -1304,9 +_,13 @@
|
||||
} catch (Throwable t) {
|
||||
LOGGER.error("Shutdown failure!", t);
|
||||
throw t;
|
||||
@@ -1192,7 +_,11 @@
|
||||
|
||||
this.window.setErrorSection("Post render");
|
||||
boolean previouslyPaused = this.pause;
|
||||
- this.pause = this.hasSingleplayerServer()
|
||||
+ boolean pause = this.hasSingleplayerServer()
|
||||
&& (this.screen != null && this.screen.isPauseScreen() || this.overlay != null && this.overlay.isPauseScreen())
|
||||
&& !this.singleplayerServer.isPublished();
|
||||
boolean var28 = this.pause;
|
||||
- this.pause = this.hasSingleplayerServer() && this.gui.isPausing() && !this.singleplayerServer.isPublished();
|
||||
+ boolean pause = this.hasSingleplayerServer() && this.gui.isPausing() && !this.singleplayerServer.isPublished();
|
||||
+ if (pause != this.pause && !net.neoforged.neoforge.client.ClientHooks.onClientPauseChangePre(pause)) {
|
||||
+ this.pause = pause;
|
||||
+ net.neoforged.neoforge.client.ClientHooks.onClientPauseChangePost(pause);
|
||||
+ }
|
||||
if (!previouslyPaused && this.pause) {
|
||||
if (!var28 && this.pause) {
|
||||
this.soundManager.pauseAllExcept(SoundSource.MUSIC, SoundSource.UI);
|
||||
}
|
||||
@@ -1346,7 +_,9 @@
|
||||
profiler.popPush("gpuAsync");
|
||||
RenderSystem.executePendingTasks();
|
||||
profiler.pop();
|
||||
+ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePre(this.deltaTracker);
|
||||
this.gameRenderer.render(this.deltaTracker, advanceGameTime);
|
||||
+ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePost(this.deltaTracker);
|
||||
profiler.push("present");
|
||||
if (!this.gameRenderer.getGameRenderState().windowRenderState.isMinimized) {
|
||||
this.mainRenderTarget.blitToScreen();
|
||||
@@ -1448,8 +_,10 @@
|
||||
@@ -1273,7 +_,9 @@
|
||||
profiler.popPush("gpuAsync");
|
||||
RenderSystem.executePendingTasks();
|
||||
profiler.pop();
|
||||
+ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePre(this.deltaTracker);
|
||||
this.gameRenderer.render(this.deltaTracker, advanceGameTime);
|
||||
+ net.neoforged.neoforge.client.ClientHooks.fireRenderFramePost(this.deltaTracker);
|
||||
}
|
||||
|
||||
profiler.push("present");
|
||||
@@ -1395,8 +_,10 @@
|
||||
public void resizeGui() {
|
||||
int guiScale = this.window.calculateScale(this.options.guiScale().get(), this.isEnforceUnicode());
|
||||
this.window.setGuiScale(guiScale);
|
||||
+ net.neoforged.neoforge.client.ClientHooks.fireWindowResize(this.window);
|
||||
if (this.screen != null) {
|
||||
this.screen.resize(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
|
||||
if (this.gui.screen() != null) {
|
||||
this.gui.screen().resize(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
|
||||
+ net.neoforged.neoforge.client.ClientHooks.resizeGuiLayers(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
|
||||
}
|
||||
|
||||
this.mouseHandler.setIgnoreFirstMove();
|
||||
@@ -1601,6 +_,7 @@
|
||||
@@ -1548,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
@@ -250,7 +231,7 @@
|
||||
this.running = false;
|
||||
}
|
||||
|
||||
@@ -1632,8 +_,16 @@
|
||||
@@ -1573,8 +_,16 @@
|
||||
BlockPos pos = blockHit.getBlockPos();
|
||||
if (!this.level.getBlockState(pos).isAir()) {
|
||||
Direction direction = blockHit.getDirection();
|
||||
@@ -269,9 +250,9 @@
|
||||
this.player.swing(InteractionHand.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
@@ -1670,9 +_,16 @@
|
||||
return false;
|
||||
} else {
|
||||
@@ -1621,9 +_,16 @@
|
||||
}
|
||||
|
||||
boolean endAttack = false;
|
||||
+ var inputEvent = net.neoforged.neoforge.client.ClientHooks.onClickInput(0, this.options.keyAttack, InteractionHand.MAIN_HAND);
|
||||
+ if (inputEvent.isCanceled()) {
|
||||
@@ -285,19 +266,19 @@
|
||||
+ if (inputEvent.shouldSwingHand())
|
||||
this.player.swing(InteractionHand.MAIN_HAND);
|
||||
return true;
|
||||
} else {
|
||||
@@ -1699,8 +_,10 @@
|
||||
}
|
||||
|
||||
this.player.resetAttackStrengthTicker();
|
||||
+ net.neoforged.neoforge.common.CommonHooks.onEmptyLeftClick(this.player);
|
||||
}
|
||||
|
||||
+ if (inputEvent.shouldSwingHand())
|
||||
this.player.swing(InteractionHand.MAIN_HAND);
|
||||
return endAttack;
|
||||
}
|
||||
@@ -1717,6 +_,11 @@
|
||||
@@ -1651,8 +_,10 @@
|
||||
}
|
||||
|
||||
this.player.resetAttackStrengthTicker();
|
||||
+ net.neoforged.neoforge.common.CommonHooks.onEmptyLeftClick(this.player);
|
||||
}
|
||||
|
||||
+ if (inputEvent.shouldSwingHand())
|
||||
this.player.swing(InteractionHand.MAIN_HAND);
|
||||
return endAttack;
|
||||
}
|
||||
@@ -1668,6 +_,11 @@
|
||||
}
|
||||
|
||||
for (InteractionHand hand : InteractionHand.values()) {
|
||||
@@ -309,7 +290,7 @@
|
||||
ItemStack heldItem = this.player.getItemInHand(hand);
|
||||
if (!heldItem.isItemEnabled(this.level.enabledFeatures())) {
|
||||
return;
|
||||
@@ -1733,7 +_,7 @@
|
||||
@@ -1684,7 +_,7 @@
|
||||
|
||||
if (this.player.isWithinEntityInteractionRange(entity, 0.0)
|
||||
&& this.gameMode.interact(this.player, entity, entityHit, hand) instanceof InteractionResult.Success success) {
|
||||
@@ -318,7 +299,7 @@
|
||||
this.player.swing(hand);
|
||||
}
|
||||
|
||||
@@ -1745,7 +_,7 @@
|
||||
@@ -1696,7 +_,7 @@
|
||||
int oldCount = heldItem.getCount();
|
||||
InteractionResult useResult = this.gameMode.useItemOn(this.player, hand, blockHit);
|
||||
if (useResult instanceof InteractionResult.Success success) {
|
||||
@@ -327,7 +308,7 @@
|
||||
this.player.swing(hand);
|
||||
if (!heldItem.isEmpty() && (heldItem.getCount() != oldCount || this.player.hasInfiniteMaterials())) {
|
||||
this.gameRenderer.itemInHandRenderer.itemUsed(hand);
|
||||
@@ -1761,8 +_,11 @@
|
||||
@@ -1712,8 +_,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +321,7 @@
|
||||
this.player.swing(hand);
|
||||
}
|
||||
|
||||
@@ -1780,6 +_,10 @@
|
||||
@@ -1731,6 +_,10 @@
|
||||
|
||||
public void tick() {
|
||||
this.clientTickCount++;
|
||||
@@ -351,15 +332,15 @@
|
||||
if (this.level != null && !this.pause) {
|
||||
this.level.tickRateManager().tick();
|
||||
}
|
||||
@@ -1871,6 +_,7 @@
|
||||
@@ -1793,6 +_,7 @@
|
||||
|
||||
this.tutorial.tick();
|
||||
|
||||
+ net.neoforged.neoforge.event.EventHooks.fireLevelTickPre(this.level, () -> true);
|
||||
try {
|
||||
this.level.tick(() -> true);
|
||||
} catch (Throwable var6) {
|
||||
@@ -1884,6 +_,7 @@
|
||||
} catch (Throwable t) {
|
||||
@@ -1806,6 +_,7 @@
|
||||
|
||||
throw new ReportedException(report);
|
||||
}
|
||||
@@ -367,7 +348,7 @@
|
||||
}
|
||||
|
||||
profiler.popPush("animateTick");
|
||||
@@ -1908,6 +_,10 @@
|
||||
@@ -1830,6 +_,10 @@
|
||||
profiler.popPush("keyboard");
|
||||
this.keyboardHandler.tick();
|
||||
profiler.pop();
|
||||
@@ -378,7 +359,7 @@
|
||||
}
|
||||
|
||||
private boolean isLevelRunningNormally() {
|
||||
@@ -2138,6 +_,7 @@
|
||||
@@ -2035,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void setLevel(ClientLevel level) {
|
||||
@@ -386,40 +367,40 @@
|
||||
this.level = level;
|
||||
this.updateLevelInEngines(level);
|
||||
}
|
||||
@@ -2199,13 +_,16 @@
|
||||
@@ -2096,13 +_,16 @@
|
||||
IntegratedServer server = this.singleplayerServer;
|
||||
this.singleplayerServer = null;
|
||||
this.gameRenderer.resetData();
|
||||
+ net.neoforged.neoforge.client.ClientHooks.firePlayerLogout(this.gameMode, this.player);
|
||||
this.gameMode = null;
|
||||
this.narrator.clear();
|
||||
this.clientLevelTeardownInProgress = true;
|
||||
this.gui.setClientLevelTeardownInProgress(true);
|
||||
|
||||
+ var shouldRevertRegistriesToFrozen = this.getConnection() != null && this.getConnection().getConnection() != null; // Neo: Track whether to revert registries after disconnect
|
||||
try {
|
||||
if (this.level != null) {
|
||||
this.gui.onDisconnected();
|
||||
this.gui.hud.onDisconnected();
|
||||
+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.LevelEvent.Unload(this.level));
|
||||
}
|
||||
|
||||
this.level = null;
|
||||
@@ -2229,6 +_,7 @@
|
||||
@@ -2126,6 +_,7 @@
|
||||
} finally {
|
||||
this.clientLevelTeardownInProgress = false;
|
||||
this.gui.setClientLevelTeardownInProgress(false);
|
||||
}
|
||||
+ if(shouldRevertRegistriesToFrozen) net.neoforged.neoforge.registries.RegistryManager.revertToFrozen(); // Neo: Revert registries to frozen on disconnect
|
||||
+ if (shouldRevertRegistriesToFrozen) net.neoforged.neoforge.registries.RegistryManager.revertToFrozen(); // Neo: Revert registries to frozen on disconnect
|
||||
}
|
||||
|
||||
public void clearDownloadedResourcePacks() {
|
||||
@@ -2254,6 +_,7 @@
|
||||
@@ -2151,6 +_,7 @@
|
||||
try {
|
||||
this.setScreenAndShow(screen);
|
||||
this.gui.onDisconnected();
|
||||
this.gui.hud.onDisconnected();
|
||||
+ if (this.level != null) net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.level.LevelEvent.Unload(this.level));
|
||||
this.level = null;
|
||||
this.updateLevelInEngines(null);
|
||||
this.player = null;
|
||||
@@ -2372,6 +_,7 @@
|
||||
@@ -2283,6 +_,7 @@
|
||||
|
||||
private void pickBlockOrEntity() {
|
||||
if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) {
|
||||
@@ -427,23 +408,7 @@
|
||||
boolean includeData = this.hasControlDown();
|
||||
switch (this.hitResult) {
|
||||
case BlockHitResult blockHitResult:
|
||||
@@ -2438,7 +_,14 @@
|
||||
systemReport.setDetail("Backend API", RenderSystem::getApiDescription);
|
||||
systemReport.setDetail("Window size", () -> minecraft != null ? minecraft.window.getWidth() + "x" + minecraft.window.getHeight() : "<not initialized>");
|
||||
systemReport.setDetail("GFLW Platform", Window::getPlatform);
|
||||
- systemReport.setDetail("Render Extensions", () -> String.join(", ", RenderSystem.getDevice().getEnabledExtensions()));
|
||||
+ systemReport.setDetail("Render Extensions", () -> {
|
||||
+ GpuDevice device = RenderSystem.tryGetDevice();
|
||||
+ if (device == null) {
|
||||
+ return "<no renderer available>";
|
||||
+ } else {
|
||||
+ return String.join(", ", device.getEnabledExtensions());
|
||||
+ }
|
||||
+ });
|
||||
systemReport.setDetail("GL debug messages", () -> {
|
||||
GpuDevice device = RenderSystem.tryGetDevice();
|
||||
if (device == null) {
|
||||
@@ -2900,6 +_,10 @@
|
||||
@@ -2832,6 +_,10 @@
|
||||
}
|
||||
|
||||
return defaultTickTargetMillis;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
--- a/net/minecraft/client/MouseHandler.java
|
||||
+++ b/net/minecraft/client/MouseHandler.java
|
||||
@@ -87,6 +_,8 @@
|
||||
@@ -77,6 +_,8 @@
|
||||
this.activeButton = null;
|
||||
}
|
||||
|
||||
+ if (net.neoforged.neoforge.client.ClientHooks.onMouseButtonPre(rawButtonInfo, action)) return;
|
||||
+ boolean screenHandled = false;
|
||||
if (this.minecraft.getOverlay() == null) {
|
||||
if (this.minecraft.screen == null) {
|
||||
if (!this.mouseGrabbed && pressed) {
|
||||
@@ -106,10 +_,14 @@
|
||||
if (this.minecraft.gui.overlay() == null) {
|
||||
if (pressed
|
||||
&& this.minecraft
|
||||
@@ -105,10 +_,14 @@
|
||||
&& currentTime - this.lastClick.time() < 250L
|
||||
&& this.lastClick.screen() == screen
|
||||
&& this.lastClickButton == event.button();
|
||||
@@ -24,9 +24,9 @@
|
||||
this.lastClickButton = buttonInfo.button();
|
||||
- return;
|
||||
}
|
||||
} catch (Throwable var18) {
|
||||
CrashReport report = CrashReport.forThrowable(var18, "mouseClicked event handler");
|
||||
@@ -121,8 +_,10 @@
|
||||
} catch (Throwable t) {
|
||||
CrashReport report = CrashReport.forThrowable(t, "mouseClicked event handler");
|
||||
@@ -120,8 +_,10 @@
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
@@ -37,9 +37,9 @@
|
||||
+ screenHandled = screen.mouseReleased(event);
|
||||
+ screenHandled = net.neoforged.neoforge.client.ClientHooks.onScreenMouseReleasedPost(screen, event, screenHandled);
|
||||
}
|
||||
} catch (Throwable var17) {
|
||||
CrashReport report = CrashReport.forThrowable(var17, "mouseReleased event handler");
|
||||
@@ -136,6 +_,10 @@
|
||||
} catch (Throwable t) {
|
||||
CrashReport report = CrashReport.forThrowable(t, "mouseReleased event handler");
|
||||
@@ -135,6 +_,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@
|
||||
+ // therefore we add a boolean to check whether the screen handled the click and if not we let
|
||||
+ // vanilla's fallback handle it
|
||||
+ if (!screenHandled) {
|
||||
if (this.minecraft.screen == null && this.minecraft.getOverlay() == null) {
|
||||
if (this.minecraft.gui.screen() == null && this.minecraft.gui.overlay() == null) {
|
||||
if (buttonInfo.button() == 0) {
|
||||
this.isLeftPressed = pressed;
|
||||
@@ -151,6 +_,8 @@
|
||||
@@ -150,6 +_,8 @@
|
||||
KeyMapping.click(mouseKey);
|
||||
}
|
||||
}
|
||||
@@ -59,28 +59,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +_,11 @@
|
||||
if (this.minecraft.screen != null) {
|
||||
@@ -201,7 +_,11 @@
|
||||
if (this.minecraft.gui.screen() != null) {
|
||||
double xm = this.getScaledXPos(this.minecraft.getWindow());
|
||||
double ym = this.getScaledYPos(this.minecraft.getWindow());
|
||||
- this.minecraft.screen.mouseScrolled(xm, ym, scaledXOffset, scaledYOffset);
|
||||
+ if (!net.neoforged.neoforge.client.ClientHooks.onScreenMouseScrollPre(this, this.minecraft.screen, scaledXOffset, scaledYOffset)) {
|
||||
+ if (!this.minecraft.screen.mouseScrolled(xm, ym, scaledXOffset, scaledYOffset)) {
|
||||
+ net.neoforged.neoforge.client.ClientHooks.onScreenMouseScrollPost(this, this.minecraft.screen, scaledXOffset, scaledYOffset);
|
||||
- this.minecraft.gui.screen().mouseScrolled(xm, ym, scaledXOffset, scaledYOffset);
|
||||
+ if (!net.neoforged.neoforge.client.ClientHooks.onScreenMouseScrollPre(this, this.minecraft.gui.screen(), scaledXOffset, scaledYOffset)) {
|
||||
+ if (!this.minecraft.gui.screen().mouseScrolled(xm, ym, scaledXOffset, scaledYOffset)) {
|
||||
+ net.neoforged.neoforge.client.ClientHooks.onScreenMouseScrollPost(this, this.minecraft.gui.screen(), scaledXOffset, scaledYOffset);
|
||||
+ }
|
||||
+ }
|
||||
this.minecraft.screen.afterMouseAction();
|
||||
this.minecraft.gui.screen().afterMouseAction();
|
||||
} else if (this.minecraft.player != null) {
|
||||
Vector2i wheelXY = this.scrollWheelHandler.onMouseScroll(scaledXOffset, scaledYOffset);
|
||||
@@ -211,6 +_,7 @@
|
||||
@@ -210,6 +_,7 @@
|
||||
}
|
||||
|
||||
int wheel = wheelXY.y == 0 ? -wheelXY.x : wheelXY.y;
|
||||
+ if (net.neoforged.neoforge.client.ClientHooks.onMouseScroll(this, scaledXOffset, scaledYOffset)) return;
|
||||
if (this.minecraft.player.isSpectator()) {
|
||||
if (this.minecraft.gui.getSpectatorGui().isMenuActive()) {
|
||||
this.minecraft.gui.getSpectatorGui().onMouseScrolled(-wheel);
|
||||
@@ -317,7 +_,12 @@
|
||||
if (this.minecraft.gui.hud.getSpectatorGui().isMenuActive()) {
|
||||
this.minecraft.gui.hud.getSpectatorGui().onMouseScrolled(-wheel);
|
||||
@@ -316,7 +_,12 @@
|
||||
double dy = getScaledYPos(window, this.accumulatedDY);
|
||||
|
||||
try {
|
||||
@@ -91,10 +91,10 @@
|
||||
+ net.neoforged.neoforge.client.ClientHooks.onScreenMouseDragPost(screen, mouseButtonEvent, dx, dy);
|
||||
+ }
|
||||
+ }
|
||||
} catch (Throwable var19) {
|
||||
CrashReport report = CrashReport.forThrowable(var19, "mouseDragged event handler");
|
||||
} catch (Throwable t) {
|
||||
CrashReport report = CrashReport.forThrowable(t, "mouseDragged event handler");
|
||||
screen.fillCrashDetails(report);
|
||||
@@ -356,12 +_,13 @@
|
||||
@@ -355,12 +_,13 @@
|
||||
}
|
||||
|
||||
private void turnPlayer(double mousea) {
|
||||
@@ -110,7 +110,7 @@
|
||||
double dx = this.smoothTurnX.getNewDeltaValue(this.accumulatedDX * sens, mousea * sens);
|
||||
double dy = this.smoothTurnY.getNewDeltaValue(this.accumulatedDY * sens, mousea * sens);
|
||||
xo = dx;
|
||||
@@ -402,6 +_,14 @@
|
||||
@@ -401,6 +_,14 @@
|
||||
|
||||
public double ypos() {
|
||||
return this.ypos;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/Options.java
|
||||
+++ b/net/minecraft/client/Options.java
|
||||
@@ -1029,7 +_,7 @@
|
||||
@@ -1100,7 +_,7 @@
|
||||
this.incompatibleResourcePacks.clear();
|
||||
|
||||
for (Pack entry : packRepository.getSelectedPacks()) {
|
||||
@@ -9,7 +9,7 @@
|
||||
this.resourcePacks.add(entry.getId());
|
||||
if (!entry.getCompatibility().isCompatible()) {
|
||||
this.incompatibleResourcePacks.add(entry.getId());
|
||||
@@ -1404,6 +_,7 @@
|
||||
@@ -1479,6 +_,7 @@
|
||||
}
|
||||
|
||||
public Options(Minecraft minecraft, File workingDirectory) {
|
||||
@@ -17,15 +17,15 @@
|
||||
this.minecraft = minecraft;
|
||||
this.optionsFile = new File(workingDirectory, "options.txt");
|
||||
boolean largeDistances = Runtime.getRuntime().maxMemory() >= 1000000000L;
|
||||
@@ -1427,6 +_,7 @@
|
||||
value -> this.setGraphicsPresetToCustom()
|
||||
@@ -1499,6 +_,7 @@
|
||||
var1 -> this.setGraphicsPresetToCustom()
|
||||
);
|
||||
this.syncWrites = Util.getPlatform() == Util.OS.WINDOWS;
|
||||
+ net.neoforged.neoforge.client.ClientHooks.onRegisterKeyMappings(this, KeyMapping.Category.SORT_ORDER);
|
||||
this.load();
|
||||
this.initialExclusiveFullscreen = this.exclusiveFullscreen.get();
|
||||
}
|
||||
@@ -1558,10 +_,15 @@
|
||||
|
||||
@@ -1631,10 +_,15 @@
|
||||
access.process("musicFrequency", this.musicFrequency);
|
||||
|
||||
for (KeyMapping keyMapping : this.keyMappings) {
|
||||
@@ -43,7 +43,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1857,6 +_,23 @@
|
||||
@@ -1929,6 +_,23 @@
|
||||
}
|
||||
|
||||
repository.setSelected(selected);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/Screenshot.java
|
||||
+++ b/net/minecraft/client/Screenshot.java
|
||||
@@ -42,6 +_,13 @@
|
||||
@@ -51,15 +_,26 @@
|
||||
file = new File(picDir, forceName);
|
||||
}
|
||||
|
||||
@@ -14,24 +14,21 @@
|
||||
Util.ioPool()
|
||||
.execute(
|
||||
() -> {
|
||||
@@ -49,11 +_,15 @@
|
||||
NativeImage twrVar0$ = image;
|
||||
|
||||
try {
|
||||
- image.writeToFile(file);
|
||||
- Component component = Component.literal(file.getName())
|
||||
- .withStyle(ChatFormatting.UNDERLINE)
|
||||
- .withStyle(s -> s.withClickEvent(new ClickEvent.OpenFile(file.getAbsoluteFile())));
|
||||
- callback.accept(Component.translatable("screenshot.success", component));
|
||||
+ image.writeToFile(screenshotFile);
|
||||
+ if (event.getResultMessage() != null) {
|
||||
+ callback.accept(event.getResultMessage());
|
||||
+ } else {
|
||||
+ Component component = Component.literal(screenshotFile.getName())
|
||||
+ .withStyle(ChatFormatting.UNDERLINE)
|
||||
+ .withStyle(s -> s.withClickEvent(new ClickEvent.OpenFile(screenshotFile.getAbsoluteFile())));
|
||||
+ callback.accept(Component.translatable("screenshot.success", component));
|
||||
+ }
|
||||
} catch (Throwable var7) {
|
||||
if (image != null) {
|
||||
try {
|
||||
try (image) {
|
||||
- image.writeToFile(file);
|
||||
- Component component = Component.literal(file.getName())
|
||||
- .withStyle(ChatFormatting.UNDERLINE)
|
||||
- .withStyle(s -> s.withClickEvent(new ClickEvent.OpenFile(file.getAbsoluteFile())));
|
||||
- callback.accept(Component.translatable("screenshot.success", component));
|
||||
+ image.writeToFile(screenshotFile);
|
||||
+ if (event.getResultMessage() != null) {
|
||||
+ callback.accept(event.getResultMessage());
|
||||
+ } else {
|
||||
+ Component component = Component.literal(screenshotFile.getName())
|
||||
+ .withStyle(ChatFormatting.UNDERLINE)
|
||||
+ .withStyle(s -> s.withClickEvent(new ClickEvent.OpenFile(screenshotFile.getAbsoluteFile())));
|
||||
+ callback.accept(Component.translatable("screenshot.success", component));
|
||||
+ }
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Couldn't save screenshot", e);
|
||||
callback.accept(Component.translatable("screenshot.failure", e.getMessage()));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/data/models/BlockModelGenerators.java
|
||||
+++ b/net/minecraft/client/data/models/BlockModelGenerators.java
|
||||
@@ -4633,4 +_,16 @@
|
||||
@@ -4554,4 +_,16 @@
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 @@
|
||||
blockStateGenerators.validate();
|
||||
itemModels.finalizeAndValidate();
|
||||
return CompletableFuture.allOf(
|
||||
@@ -59,12 +_,22 @@
|
||||
@@ -61,11 +_,21 @@
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@@ -71,7 +71,6 @@
|
||||
+ return "Model Definitions - " + modId;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static class BlockStateGeneratorCollector implements Consumer<BlockModelDefinitionGenerator> {
|
||||
private final Map<Block, BlockModelDefinitionGenerator> generators = new HashMap<>();
|
||||
+ private final Supplier<java.util.stream.Stream<? extends net.minecraft.core.Holder<Block>>> knownBlocks;
|
||||
@@ -87,7 +86,7 @@
|
||||
|
||||
public void accept(BlockModelDefinitionGenerator generator) {
|
||||
Block block = generator.block();
|
||||
@@ -75,11 +_,8 @@
|
||||
@@ -76,11 +_,8 @@
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
@@ -142,8 +141,8 @@
|
||||
if (item instanceof BlockItem blockItem && !this.itemInfos.containsKey(blockItem)) {
|
||||
Identifier targetModel = ModelLocationUtils.getModelLocation(blockItem.getBlock());
|
||||
@@ -131,10 +_,9 @@
|
||||
this.register(acceptor, donorInfo);
|
||||
}
|
||||
|
||||
this.register(acceptor, donorInfo);
|
||||
});
|
||||
- List<Identifier> missingDefinitions = BuiltInRegistries.ITEM
|
||||
- .listElements()
|
||||
|
||||
@@ -1,31 +1,24 @@
|
||||
--- a/net/minecraft/client/data/models/MultiVariant.java
|
||||
+++ b/net/minecraft/client/data/models/MultiVariant.java
|
||||
@@ -12,20 +_,67 @@
|
||||
@@ -11,19 +_,59 @@
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
|
||||
+/// @param customBlockStateModels Neo-added parameter to allow using custom blockstate models with MultiVariantGenerator and MultiPartGenerator (only used during datagen)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public record MultiVariant(WeightedList<Variant> variants) {
|
||||
- public MultiVariant(WeightedList<Variant> variants) {
|
||||
+public record MultiVariant(WeightedList<Variant> variants, WeightedList<net.neoforged.neoforge.client.model.generators.blockstate.CustomBlockStateModelBuilder> customBlockStateModels) {
|
||||
+ /**
|
||||
+ * @param customBlockStateModels Neo-added parameter to allow using custom blockstate models with MultiVariantGenerator and MultiPartGenerator (only used during datagen)
|
||||
+ */
|
||||
+ public MultiVariant(WeightedList<Variant> variants, WeightedList<net.neoforged.neoforge.client.model.generators.blockstate.CustomBlockStateModelBuilder> customBlockStateModels) {
|
||||
public MultiVariant {
|
||||
+ if (!customBlockStateModels.isEmpty()) {
|
||||
+ if (!variants.isEmpty()) {
|
||||
+ throw new IllegalArgumentException("Cannot specify both a variant list and a custom blockstate model");
|
||||
+ }
|
||||
+ this.variants = variants;
|
||||
+ this.customBlockStateModels = customBlockStateModels;
|
||||
+ } else
|
||||
if (variants.isEmpty()) {
|
||||
throw new IllegalArgumentException("Variant list must contain at least one element");
|
||||
} else {
|
||||
this.variants = variants;
|
||||
+ this.customBlockStateModels = customBlockStateModels;
|
||||
}
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ public MultiVariant(WeightedList<Variant> variants) {
|
||||
+ this(variants, WeightedList.of());
|
||||
+ }
|
||||
@@ -37,8 +30,8 @@
|
||||
+
|
||||
+ public static MultiVariant of(net.neoforged.neoforge.client.model.generators.blockstate.CustomBlockStateModelBuilder customBlockStateModel) {
|
||||
+ return new MultiVariant(WeightedList.of(), WeightedList.of(customBlockStateModel));
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
public MultiVariant with(VariantMutator mutator) {
|
||||
+ if (!this.customBlockStateModels.isEmpty()) {
|
||||
+ return new MultiVariant(this.variants, this.customBlockStateModels.map(model -> model.with(mutator)));
|
||||
@@ -46,12 +39,10 @@
|
||||
return new MultiVariant(this.variants.map(mutator));
|
||||
}
|
||||
|
||||
+ /**
|
||||
+ * Applies the given unbaked mutator.
|
||||
+ * <p>
|
||||
+ * If this multi variant consists of plain Vanilla {@linkplain Variant variants}, each variant will be
|
||||
+ * temporarily converted to a {@link SingleVariant.Unbaked}, mutated and then converted back to a plain variant.
|
||||
+ */
|
||||
+ /// Applies the given unbaked mutator.
|
||||
+ ///
|
||||
+ /// If this multi variant consists of plain Vanilla [variants][Variant], each variant will be
|
||||
+ /// temporarily converted to a [SingleVariant.Unbaked], mutated and then converted back to a plain variant.
|
||||
+ public MultiVariant with(net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator mutator) {
|
||||
+ if (!this.customBlockStateModels.isEmpty()) {
|
||||
+ return new MultiVariant(this.variants, this.customBlockStateModels.map(model -> model.with(mutator)));
|
||||
@@ -68,5 +59,5 @@
|
||||
+ return new WeightedVariants.Unbaked(this.customBlockStateModels.map(net.neoforged.neoforge.client.model.generators.blockstate.CustomBlockStateModelBuilder::toUnbaked));
|
||||
+ }
|
||||
List<Weighted<Variant>> entries = this.variants.unwrap();
|
||||
return (BlockStateModel.Unbaked)(entries.size() == 1
|
||||
return entries.size() == 1
|
||||
? new SingleVariant.Unbaked(entries.getFirst().value())
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/data/models/blockstates/MultiVariantGenerator.java
|
||||
+++ b/net/minecraft/client/data/models/blockstates/MultiVariantGenerator.java
|
||||
@@ -53,6 +_,18 @@
|
||||
@@ -55,6 +_,18 @@
|
||||
return new MultiVariantGenerator(this.block, newEntries, this.seenProperties);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,52 +1,42 @@
|
||||
--- a/net/minecraft/client/data/models/blockstates/PropertyDispatch.java
|
||||
+++ b/net/minecraft/client/data/models/blockstates/PropertyDispatch.java
|
||||
@@ -103,6 +_,49 @@
|
||||
@@ -103,6 +_,39 @@
|
||||
return new PropertyDispatch.C5<>(property1, property2, property3, property4, property5);
|
||||
}
|
||||
|
||||
+ /**
|
||||
+ * Creates a property dispatch on a single blockstate property that can be used to apply a {@link net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator}.
|
||||
+ */
|
||||
+ /// Creates a property dispatch on a single blockstate property that can be used to apply a [net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator].
|
||||
+ public static <T1 extends Comparable<T1>> PropertyDispatch.C1<net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator, T1> modifyUnbaked(Property<T1> p1) {
|
||||
+ return new PropertyDispatch.C1<>(p1);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a property dispatch on two blockstate properties that can be used to apply a {@link net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator}.
|
||||
+ */
|
||||
+ /// Creates a property dispatch on two blockstate properties that can be used to apply a [net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator].
|
||||
+ public static <T1 extends Comparable<T1>, T2 extends Comparable<T2>> PropertyDispatch.C2<net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator, T1, T2> modifyUnbaked(
|
||||
+ Property<T1> p1, Property<T2> p2
|
||||
+ Property<T1> p1, Property<T2> p2
|
||||
+ ) {
|
||||
+ return new PropertyDispatch.C2<>(p1, p2);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a property dispatch on three blockstate properties that can be used to apply a {@link net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator}.
|
||||
+ */
|
||||
+ /// Creates a property dispatch on three blockstate properties that can be used to apply a [net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator].
|
||||
+ public static <T1 extends Comparable<T1>, T2 extends Comparable<T2>, T3 extends Comparable<T3>> PropertyDispatch.C3<net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator, T1, T2, T3> modifyUnbaked(
|
||||
+ Property<T1> p1, Property<T2> p2, Property<T3> p3
|
||||
+ Property<T1> p1, Property<T2> p2, Property<T3> p3
|
||||
+ ) {
|
||||
+ return new PropertyDispatch.C3<>(p1, p2, p3);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a property dispatch on four blockstate properties that can be used to apply a {@link net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator}.
|
||||
+ */
|
||||
+ /// Creates a property dispatch on four blockstate properties that can be used to apply a [net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator].
|
||||
+ public static <T1 extends Comparable<T1>, T2 extends Comparable<T2>, T3 extends Comparable<T3>, T4 extends Comparable<T4>> PropertyDispatch.C4<net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator, T1, T2, T3, T4> modifyUnbaked(
|
||||
+ Property<T1> p1, Property<T2> p2, Property<T3> p3, Property<T4> p4
|
||||
+ Property<T1> p1, Property<T2> p2, Property<T3> p3, Property<T4> p4
|
||||
+ ) {
|
||||
+ return new PropertyDispatch.C4<>(p1, p2, p3, p4);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates a property dispatch on five blockstate properties that can be used to apply a {@link net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator}.
|
||||
+ */
|
||||
+ /// Creates a property dispatch on five blockstate properties that can be used to apply a [net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator].
|
||||
+ public static <T1 extends Comparable<T1>, T2 extends Comparable<T2>, T3 extends Comparable<T3>, T4 extends Comparable<T4>, T5 extends Comparable<T5>> PropertyDispatch.C5<net.neoforged.neoforge.client.model.generators.blockstate.UnbakedMutator, T1, T2, T3, T4, T5> modifyUnbaked(
|
||||
+ Property<T1> p1, Property<T2> p2, Property<T3> p3, Property<T4> p4, Property<T5> p5
|
||||
+ Property<T1> p1, Property<T2> p2, Property<T3> p3, Property<T4> p4, Property<T5> p5
|
||||
+ ) {
|
||||
+ return new PropertyDispatch.C5<>(p1, p2, p3, p4, p5);
|
||||
+ }
|
||||
+
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class C1<V, T1 extends Comparable<T1>> extends PropertyDispatch<V> {
|
||||
private final Property<T1> property1;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/data/models/model/ModelTemplates.java
|
||||
+++ b/net/minecraft/client/data/models/model/ModelTemplates.java
|
||||
@@ -234,18 +_,18 @@
|
||||
@@ -249,18 +_,18 @@
|
||||
}
|
||||
|
||||
public static ModelTemplate create(String id, TextureSlot... slots) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/data/models/model/TextureMapping.java
|
||||
+++ b/net/minecraft/client/data/models/model/TextureMapping.java
|
||||
@@ -436,4 +_,12 @@
|
||||
@@ -453,4 +_,12 @@
|
||||
Identifier id = BuiltInRegistries.ITEM.getKey(item);
|
||||
return new Material(id.withPath(path -> "item/" + path + suffix));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/Font.java
|
||||
+++ b/net/minecraft/client/gui/Font.java
|
||||
@@ -42,6 +_,8 @@
|
||||
@@ -39,6 +_,8 @@
|
||||
private final RandomSource random = RandomSource.create();
|
||||
private final Font.Provider provider;
|
||||
private final StringSplitter splitter;
|
||||
@@ -9,12 +9,3 @@
|
||||
|
||||
public Font(Font.Provider provider) {
|
||||
this.provider = provider;
|
||||
@@ -216,6 +_,8 @@
|
||||
public StringSplitter getSplitter() {
|
||||
return this.splitter;
|
||||
}
|
||||
+
|
||||
+ @Override public Font self() { return this; }
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static enum DisplayMode {
|
||||
|
||||
@@ -1,417 +1,52 @@
|
||||
--- a/net/minecraft/client/gui/Gui.java
|
||||
+++ b/net/minecraft/client/gui/Gui.java
|
||||
@@ -79,6 +_,8 @@
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
+// Neo: Exceptionally add a static wildcard import to make the patch bearable, and comments to avoid the detection by spotless rules.
|
||||
+/* space for import change */ import static net.neoforged.neoforge.client.gui.VanillaGuiLayers.* /* space for wildcard import */;
|
||||
@@ -177,7 +_,8 @@
|
||||
profiler.push("screen");
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class Gui {
|
||||
@@ -172,6 +_,15 @@
|
||||
private Pair<Gui.ContextualInfo, ContextualBarRenderer> contextualInfoBar = Pair.of(Gui.ContextualInfo.EMPTY, ContextualBarRenderer.EMPTY);
|
||||
private final Map<Gui.ContextualInfo, Supplier<ContextualBarRenderer>> contextualInfoBarRenderers;
|
||||
private float scopeScale;
|
||||
+ private final net.neoforged.neoforge.client.gui.GuiLayerManager layerManager = new net.neoforged.neoforge.client.gui.GuiLayerManager();
|
||||
+ /**
|
||||
+ * Neo: This variable controls the height of overlays on the left of the hotbar (e.g. health, armor).
|
||||
+ */
|
||||
+ public int leftHeight;
|
||||
+ /**
|
||||
+ * Neo: This variable controls the height of overlays on the right of the hotbar (e.g. food, vehicle health, air).
|
||||
+ */
|
||||
+ public int rightHeight;
|
||||
try {
|
||||
- this.screen.extractRenderStateWithTooltipAndSubtitles(graphics, xMouse, yMouse, deltaTracker.getGameTimeDeltaTicks());
|
||||
+ // Neo: Wrap Screen#extractRenderStateWithTooltipAndSubtitles() to allow for GUI Layers and ScreenEvent.Render.[Pre/Post]
|
||||
+ net.neoforged.neoforge.client.ClientHooks.drawScreen(this.screen, graphics, xMouse, yMouse, deltaTracker.getGameTimeDeltaTicks());
|
||||
} catch (Throwable t) {
|
||||
CrashReport report = CrashReport.forThrowable(t, "Rendering screen");
|
||||
CrashReportCategory category = report.addCategory("Screen render details");
|
||||
@@ -226,9 +_,7 @@
|
||||
LOGGER.error("setScreen called from non-game thread");
|
||||
}
|
||||
|
||||
public Gui(Minecraft minecraft) {
|
||||
this.minecraft = minecraft;
|
||||
@@ -192,6 +_,7 @@
|
||||
() -> new JumpableVehicleBarRenderer(minecraft)
|
||||
);
|
||||
this.resetTitleTimes();
|
||||
+ this.registerVanillaLayers();
|
||||
}
|
||||
- if (this.screen != null) {
|
||||
- this.screen.removed();
|
||||
- } else {
|
||||
+ if (this.screen == null) {
|
||||
this.minecraft.setLastInputType(InputType.NONE);
|
||||
}
|
||||
|
||||
public void resetTitleTimes() {
|
||||
@@ -202,28 +_,47 @@
|
||||
@@ -250,6 +_,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void extractRenderState(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
if (!(this.minecraft.screen instanceof LevelLoadingScreen)) {
|
||||
- if (!this.minecraft.options.hideGui) {
|
||||
- this.extractCameraOverlays(graphics, deltaTracker);
|
||||
- this.extractCrosshair(graphics, deltaTracker);
|
||||
- graphics.nextStratum();
|
||||
- this.extractHotbarAndDecorations(graphics, deltaTracker);
|
||||
- this.extractEffects(graphics, deltaTracker);
|
||||
- this.extractBossOverlay(graphics, deltaTracker);
|
||||
- }
|
||||
+ leftHeight = 39;
|
||||
+ rightHeight = 39;
|
||||
+ updateContextualBarRenderer();
|
||||
+ layerManager.render(graphics, deltaTracker);
|
||||
+ net.neoforged.neoforge.client.ClientHooks.clearGuiLayers(this);
|
||||
+ Screen old = this.screen;
|
||||
+ if (screen != null) {
|
||||
+ var event = new net.neoforged.neoforge.client.event.ScreenEvent.Opening(old, screen);
|
||||
+ if (net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(event).isCanceled()) return;
|
||||
+ screen = event.getNewScreen();
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- this.extractSleepOverlay(graphics, deltaTracker);
|
||||
+ private void registerVanillaLayers() {
|
||||
+ java.util.function.BooleanSupplier guiVisible = () -> !this.minecraft.options.hideGui;
|
||||
+ java.util.function.BooleanSupplier survivalVisible = () -> this.minecraft.gameMode.canHurtPlayer() && guiVisible.getAsBoolean();
|
||||
+ layerManager.add(CAMERA_OVERLAYS, this::extractCameraOverlays, guiVisible);
|
||||
+ layerManager.add(CROSSHAIR, this::extractCrosshair, guiVisible);
|
||||
+ layerManager.add(AFTER_CAMERA_DECORATIONS, (guiGraphics, deltaTracker) -> guiGraphics.nextStratum(), guiVisible);
|
||||
+ // TODO: Split this up again into its pieces
|
||||
+ layerManager.add(HOTBAR, this::extractHotbar, guiVisible);
|
||||
+ layerManager.add(PLAYER_HEALTH, (guiGraphics, partialTick) -> extractHealthLevel(guiGraphics), survivalVisible);
|
||||
+ layerManager.add(ARMOR_LEVEL, (guiGraphics, partialTick) -> extractArmorLevel(guiGraphics), survivalVisible);
|
||||
+ layerManager.add(FOOD_LEVEL, (guiGraphics, partialTick) -> extractFoodLevel(guiGraphics), survivalVisible);
|
||||
+ layerManager.add(VEHICLE_HEALTH, (guiGraphics, partialTick) -> extractVehicleHealth(guiGraphics), guiVisible);
|
||||
+ layerManager.add(AIR_LEVEL, (guiGraphics, partialTick) -> extractAirLevel(guiGraphics), survivalVisible);
|
||||
+ layerManager.add(CONTEXTUAL_INFO_BAR_BACKGROUND, this::extractContextualInfoBarBackground, guiVisible);
|
||||
+ layerManager.add(EXPERIENCE_LEVEL, this::extractExperienceLevel, guiVisible);
|
||||
+ layerManager.add(CONTEXTUAL_INFO_BAR, this::extractContextualInfoBar, guiVisible);
|
||||
+ layerManager.add(SELECTED_ITEM_NAME, this::maybeExtractSelectedItemName, guiVisible);
|
||||
+ layerManager.add(SPECTATOR_TOOLTIP, this::maybeExtractSpectatorTooltip, guiVisible);
|
||||
+ layerManager.add(EFFECTS, this::extractEffects, guiVisible);
|
||||
+ layerManager.add(BOSS_OVERLAY, this::extractBossOverlay, guiVisible);
|
||||
+ layerManager.add(SLEEP_OVERLAY, this::extractSleepOverlay);
|
||||
+ layerManager.add(DEMO_OVERLAY, this::extractDemoOverlay, guiVisible);
|
||||
+ layerManager.add(SCOREBOARD_SIDEBAR, this::extractScoreboardSidebar, guiVisible);
|
||||
+ layerManager.add(OVERLAY_MESSAGE, this::extractOverlayMessage, guiVisible);
|
||||
+ layerManager.add(TITLE, this::extractTitle, guiVisible);
|
||||
+ layerManager.add(CHAT, this::extractChat, guiVisible);
|
||||
+ layerManager.add(TAB_LIST, this::extractTabList, guiVisible);
|
||||
+ layerManager.add(SUBTITLE_OVERLAY, (graphics, _) -> {
|
||||
if (!this.minecraft.options.hideGui) {
|
||||
- this.extractDemoOverlay(graphics, deltaTracker);
|
||||
- this.extractScoreboardSidebar(graphics, deltaTracker);
|
||||
- this.extractOverlayMessage(graphics, deltaTracker);
|
||||
- this.extractTitle(graphics, deltaTracker);
|
||||
- this.extractChat(graphics, deltaTracker);
|
||||
- this.extractTabList(graphics, deltaTracker);
|
||||
this.extractSubtitleOverlay(graphics, this.minecraft.screen == null || this.minecraft.screen.isInGameUi());
|
||||
} else if (this.minecraft.screen != null && this.minecraft.screen.isInGameUi()) {
|
||||
this.extractSubtitleOverlay(graphics, true);
|
||||
}
|
||||
- }
|
||||
+ });
|
||||
}
|
||||
|
||||
private void extractBossOverlay(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
@@ -267,8 +_,12 @@
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
ItemStack item = player.getItemBySlot(slot);
|
||||
Equippable equippable = item.get(DataComponents.EQUIPPABLE);
|
||||
- if (equippable != null && equippable.slot() == slot && equippable.cameraOverlay().isPresent()) {
|
||||
- this.extractTextureOverlay(graphics, equippable.cameraOverlay().get().withPath(p -> "textures/" + p + ".png"), 1.0F);
|
||||
+ if (equippable != null && equippable.slot() == slot) {
|
||||
+ if (equippable.cameraOverlay().isPresent()) {
|
||||
+ this.extractTextureOverlay(graphics, equippable.cameraOverlay().get().withPath(p -> "textures/" + p + ".png"), 1.0F);
|
||||
+ }
|
||||
+
|
||||
+ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(item).renderFirstPersonOverlay(item, slot, this.minecraft.player, graphics, deltaTracker);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,7 +_,11 @@
|
||||
if (alpha > 0) {
|
||||
graphics.nextStratum();
|
||||
graphics.pose().pushMatrix();
|
||||
- graphics.pose().translate(graphics.guiWidth() / 2, graphics.guiHeight() - 68);
|
||||
+ // Include a shift based on the bar height plus the difference between the height that renderSelectedItemName
|
||||
+ // renders at (59) and the height that the overlay/status bar renders at (68) by default
|
||||
+ int yShift = Math.max(leftHeight, rightHeight) + (68 - 59);
|
||||
+ // If y shift is less than the default y level, just render it at the base y level
|
||||
+ graphics.pose().translate(graphics.guiWidth() / 2, graphics.guiHeight() - Math.max(yShift, 68));
|
||||
int color;
|
||||
if (this.animateOverlayMessageColor) {
|
||||
color = Mth.hsvToArgb(t / 50.0F, 0.7F, 0.6F, alpha);
|
||||
@@ -382,10 +_,19 @@
|
||||
private void extractChat(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
if (this.minecraft.player != null && !this.chat.isChatFocused()) {
|
||||
Window window = this.minecraft.getWindow();
|
||||
+ // Neo: Allow customizing position of chat component
|
||||
+ var chatBottomMargin = 40; // See ChatComponent#BOTTOM_MARGIN (used in translate calls in ChatComponent#render)
|
||||
+ var event = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(
|
||||
+ new net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent.Chat(window, graphics, deltaTracker, 0, graphics.guiHeight() - chatBottomMargin)
|
||||
+ );
|
||||
+ // The event is given the absolute Y position; account for chat component's own offsetting here
|
||||
+ graphics.pose().pushMatrix();
|
||||
+ graphics.pose().translate(event.getPosX(), (event.getPosY() - graphics.guiHeight() + chatBottomMargin) / (float) this.chat.getScale());
|
||||
int mouseX = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window));
|
||||
int mouseY = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window));
|
||||
graphics.nextStratum();
|
||||
this.chat.extractRenderState(graphics, this.getFont(), this.tickCount, mouseX, mouseY, ChatComponent.DisplayMode.BACKGROUND, false);
|
||||
+ graphics.pose().popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,6 +_,8 @@
|
||||
int harmfulCount = 0;
|
||||
|
||||
for (MobEffectInstance instance : Ordering.natural().reverse().sortedCopy(activeEffects)) {
|
||||
+ var renderer = net.neoforged.neoforge.client.extensions.common.IClientMobEffectExtensions.of(instance);
|
||||
+ if (!renderer.isVisibleInGui(instance)) continue;
|
||||
Holder<MobEffect> effect = instance.getEffect();
|
||||
if (instance.showIcon()) {
|
||||
int x = graphics.guiWidth();
|
||||
@@ -508,6 +_,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ if (renderer.renderGuiIcon(instance, this, graphics, x, y, 0, alpha)) continue;
|
||||
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(effect), x + 3, y + 3, 18, 18, ARGB.white(alpha));
|
||||
}
|
||||
}
|
||||
@@ -518,32 +_,52 @@
|
||||
return effect.unwrapKey().map(ResourceKey::identifier).map(id -> id.withPrefix("mob_effect/")).orElseGet(MissingTextureAtlasSprite::getLocation);
|
||||
}
|
||||
|
||||
- private void extractHotbarAndDecorations(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void extractHotbar(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
if (this.minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR) {
|
||||
this.spectatorGui.extractHotbar(graphics);
|
||||
} else {
|
||||
this.extractItemHotbar(graphics, deltaTracker);
|
||||
}
|
||||
-
|
||||
- if (this.minecraft.gameMode.canHurtPlayer()) {
|
||||
- this.extractPlayerHealth(graphics);
|
||||
- }
|
||||
-
|
||||
- this.extractVehicleHealth(graphics);
|
||||
+ }
|
||||
+
|
||||
+ // Neo: Wrap in a method to call it when re-rendering
|
||||
+ private void updateContextualBarRenderer() {
|
||||
Gui.ContextualInfo nextContextualInfo = this.nextContextualInfoState();
|
||||
if (nextContextualInfo != this.contextualInfoBar.getKey()) {
|
||||
this.contextualInfoBar = Pair.of(nextContextualInfo, this.contextualInfoBarRenderers.get(nextContextualInfo).get());
|
||||
}
|
||||
+ }
|
||||
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void extractContextualInfoBarBackground(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker)
|
||||
+ {
|
||||
this.contextualInfoBar.getValue().extractBackground(graphics, deltaTracker);
|
||||
+ }
|
||||
+
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void extractExperienceLevel(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
if (this.minecraft.gameMode.hasExperience() && this.minecraft.player.experienceLevel > 0) {
|
||||
ContextualBarRenderer.extractExperienceLevel(graphics, this.minecraft.font, this.minecraft.player.experienceLevel);
|
||||
}
|
||||
+ }
|
||||
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void extractContextualInfoBar(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
this.contextualInfoBar.getValue().extractRenderState(graphics, deltaTracker);
|
||||
+ }
|
||||
+
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void maybeExtractSelectedItemName(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
if (this.minecraft.gameMode.getPlayerMode() != GameType.SPECTATOR) {
|
||||
- this.extractSelectedItemName(graphics);
|
||||
- } else if (this.minecraft.player.isSpectator()) {
|
||||
+ this.extractSelectedItemName(graphics, Math.max(this.leftHeight, this.rightHeight));
|
||||
+ if (old != null && screen != old) {
|
||||
+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.ScreenEvent.Closing(old));
|
||||
+ old.removed();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void maybeExtractSpectatorTooltip(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
+ // Neo: Note this is originally mutually exclusive with the condition in maybeRenderSelectedItemName
|
||||
+ if (this.minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR && this.minecraft.player.isSpectator()) {
|
||||
this.spectatorGui.extractAction(graphics);
|
||||
}
|
||||
}
|
||||
@@ -610,15 +_,20 @@
|
||||
}
|
||||
|
||||
private void extractSelectedItemName(GuiGraphicsExtractor graphics) {
|
||||
+ extractSelectedItemName(graphics, 0);
|
||||
+ }
|
||||
+
|
||||
+ private void extractSelectedItemName(GuiGraphicsExtractor graphics, int yShift) {
|
||||
if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) {
|
||||
- MutableComponent str = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color());
|
||||
+ MutableComponent str = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().getStyleModifier());
|
||||
if (this.lastToolHighlight.has(DataComponents.CUSTOM_NAME)) {
|
||||
str.withStyle(ChatFormatting.ITALIC);
|
||||
}
|
||||
|
||||
- int strWidth = this.getFont().width(str);
|
||||
+ Component highlightTip = this.lastToolHighlight.getHighlightTip(str);
|
||||
+ int strWidth = this.getFont().width(highlightTip);
|
||||
int x = (graphics.guiWidth() - strWidth) / 2;
|
||||
- int y = graphics.guiHeight() - 59;
|
||||
+ int y = graphics.guiHeight() - Math.max(yShift, 59);
|
||||
if (!this.minecraft.gameMode.canHurtPlayer()) {
|
||||
y += 14;
|
||||
}
|
||||
@@ -629,7 +_,13 @@
|
||||
}
|
||||
|
||||
if (alpha > 0) {
|
||||
- graphics.textWithBackdrop(this.getFont(), str, x, y, strWidth, ARGB.white(alpha));
|
||||
+ Font font = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(lastToolHighlight).getFont(lastToolHighlight, net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.FontContext.SELECTED_ITEM_NAME);
|
||||
+ if (font == null) {
|
||||
+ graphics.textWithBackdrop(this.getFont(), highlightTip, x, y, strWidth, ARGB.color(alpha, -1));
|
||||
+ } else {
|
||||
+ x = (graphics.guiWidth() - font.width(highlightTip)) / 2;
|
||||
+ graphics.textWithBackdrop(font, highlightTip, x, y, strWidth, ARGB.color(alpha, -1));
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -746,7 +_,15 @@
|
||||
return (int)Math.ceil(hearts / 10.0);
|
||||
}
|
||||
|
||||
+ @Deprecated // Neo: Split up into different layers
|
||||
private void extractPlayerHealth(GuiGraphicsExtractor graphics) {
|
||||
+ extractHealthLevel(graphics);
|
||||
+ extractArmorLevel(graphics);
|
||||
+ extractFoodLevel(graphics);
|
||||
+ extractAirLevel(graphics);
|
||||
+ }
|
||||
+
|
||||
+ private void extractHealthLevel(GuiGraphicsExtractor graphics) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
int currentHealth = Mth.ceil(player.getHealth());
|
||||
@@ -770,33 +_,62 @@
|
||||
this.random.setSeed(this.tickCount * 312871);
|
||||
int xLeft = graphics.guiWidth() / 2 - 91;
|
||||
int xRight = graphics.guiWidth() / 2 + 91;
|
||||
- int yLineBase = graphics.guiHeight() - 39;
|
||||
+ int yLineBase = graphics.guiHeight() - leftHeight;
|
||||
float maxHealth = Math.max((float)player.getAttributeValue(Attributes.MAX_HEALTH), (float)Math.max(oldHealth, currentHealth));
|
||||
int totalAbsorption = Mth.ceil(player.getAbsorptionAmount());
|
||||
int numHealthRows = Mth.ceil((maxHealth + totalAbsorption) / 2.0F / 10.0F);
|
||||
int healthRowHeight = Math.max(10 - (numHealthRows - 2), 3);
|
||||
int yLineAir = yLineBase - 10;
|
||||
+ leftHeight += (numHealthRows - 1) * healthRowHeight + 10;
|
||||
int heartOffsetIndex = -1;
|
||||
if (player.hasEffect(MobEffects.REGENERATION)) {
|
||||
heartOffsetIndex = this.tickCount % Mth.ceil(maxHealth + 5.0F);
|
||||
}
|
||||
|
||||
- Profiler.get().push("armor");
|
||||
- extractArmor(graphics, player, yLineBase, numHealthRows, healthRowHeight, xLeft);
|
||||
- Profiler.get().popPush("health");
|
||||
+ Profiler.get().push("health");
|
||||
this.extractHearts(
|
||||
graphics, player, xLeft, yLineBase, healthRowHeight, heartOffsetIndex, maxHealth, currentHealth, oldHealth, totalAbsorption, blink
|
||||
);
|
||||
+ Profiler.get().pop();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void extractArmorLevel(GuiGraphicsExtractor graphics) {
|
||||
+ Player player = this.getCameraPlayer();
|
||||
+ if (player != null) {
|
||||
+ int l = graphics.guiWidth() / 2 - 91;
|
||||
+ Profiler.get().push("armor");
|
||||
+ extractArmor(graphics, player, graphics.guiHeight() - leftHeight + 10, 1, 0, l);
|
||||
+ Profiler.get().pop();
|
||||
+ if (player.getArmorValue() > 0) {
|
||||
+ leftHeight += 10;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void extractFoodLevel(GuiGraphicsExtractor graphics) {
|
||||
+ Player player = this.getCameraPlayer();
|
||||
+ if (player != null) {
|
||||
LivingEntity vehicleWithHearts = this.getPlayerVehicleWithHealth();
|
||||
int vehicleHearts = this.getVehicleMaxHearts(vehicleWithHearts);
|
||||
if (vehicleHearts == 0) {
|
||||
- Profiler.get().popPush("food");
|
||||
+ Profiler.get().push("food");
|
||||
+ int xRight = graphics.guiWidth() / 2 + 91;
|
||||
+ int yLineBase = graphics.guiHeight() - rightHeight;
|
||||
this.extractFood(graphics, player, yLineBase, xRight);
|
||||
- yLineAir -= 10;
|
||||
+ rightHeight += 10;
|
||||
+ Profiler.get().pop();
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- Profiler.get().popPush("air");
|
||||
- this.extractAirBubbles(graphics, player, vehicleHearts, yLineAir, xRight);
|
||||
+ private void extractAirLevel(GuiGraphicsExtractor graphics) {
|
||||
+ Player player = this.getCameraPlayer();
|
||||
+ if (player != null) {
|
||||
+ int xRight = graphics.guiWidth() / 2 + 91;
|
||||
+ int yLineAir = graphics.guiHeight() - rightHeight;
|
||||
+ Profiler.get().push("air");
|
||||
+ this.extractAirBubbles(graphics, player, 10, yLineAir, xRight);
|
||||
Profiler.get().pop();
|
||||
}
|
||||
}
|
||||
@@ -909,6 +_,8 @@
|
||||
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, AIR_EMPTY_SPRITE, airBubbleXPos, yLineAir + wobbleYOffset, 9, 9);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ rightHeight += 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -976,7 +_,7 @@
|
||||
if (hearts != 0) {
|
||||
int currentHealth = (int)Math.ceil(vehicleWithHearts.getHealth());
|
||||
Profiler.get().popPush("mountHealth");
|
||||
- int yLine1 = graphics.guiHeight() - 39;
|
||||
+ int yLine1 = graphics.guiHeight() - rightHeight;
|
||||
int xRight = graphics.guiWidth() / 2 + 91;
|
||||
int yo = yLine1;
|
||||
|
||||
@@ -997,6 +_,7 @@
|
||||
}
|
||||
|
||||
yo -= 10;
|
||||
+ rightHeight += 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1028,7 +_,9 @@
|
||||
int top = (graphics.guiHeight() - height) / 2;
|
||||
int right = left + width;
|
||||
int bottom = top + height;
|
||||
- graphics.blit(RenderPipelines.GUI_TEXTURED, SPYGLASS_SCOPE_LOCATION, left, top, 0.0F, 0.0F, width, height, width, height);
|
||||
+ ItemStack useItem = this.minecraft.player.getUseItem();
|
||||
+ var clientItemExtensions = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(useItem);
|
||||
+ graphics.blit(RenderPipelines.GUI_TEXTURED, clientItemExtensions.getScopeOverlayTexture(useItem), left, top, 0.0F, 0.0F, width, height, width, height);
|
||||
graphics.fill(RenderPipelines.GUI, 0, bottom, graphics.guiWidth(), graphics.guiHeight(), -16777216);
|
||||
graphics.fill(RenderPipelines.GUI, 0, 0, graphics.guiWidth(), top, -16777216);
|
||||
graphics.fill(RenderPipelines.GUI, 0, top, left, bottom, -16777216);
|
||||
@@ -1177,7 +_,7 @@
|
||||
this.toolHighlightTimer = 0;
|
||||
} else if (this.lastToolHighlight.isEmpty()
|
||||
|| !selected.is(this.lastToolHighlight.getItem())
|
||||
- || !selected.getHoverName().equals(this.lastToolHighlight.getHoverName())) {
|
||||
+ || (!selected.getHoverName().equals(this.lastToolHighlight.getHoverName()) || !selected.getHighlightTip(selected.getHoverName()).equals(this.lastToolHighlight.getHighlightTip(this.lastToolHighlight.getHoverName())))) {
|
||||
this.toolHighlightTimer = (int)(40.0 * this.minecraft.options.notificationDisplayTime().get());
|
||||
} else if (this.toolHighlightTimer > 0) {
|
||||
this.toolHighlightTimer--;
|
||||
@@ -1452,7 +_,18 @@
|
||||
type = NORMAL;
|
||||
}
|
||||
|
||||
+ type = net.neoforged.neoforge.client.ClientHooks.firePlayerHeartTypeEvent(player, type);
|
||||
+
|
||||
return type;
|
||||
this.screen = screen;
|
||||
if (this.screen != null) {
|
||||
this.screen.added();
|
||||
@@ -376,6 +_,8 @@
|
||||
Screen screen = function.apply(nextStep);
|
||||
nextStep = () -> this.setScreen(screen);
|
||||
}
|
||||
+
|
||||
+ public static net.neoforged.fml.common.asm.enumextension.ExtensionInfo getExtensionInfo() {
|
||||
+ return net.neoforged.fml.common.asm.enumextension.ExtensionInfo.nonExtended(Gui.HeartType.class);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @org.jetbrains.annotations.ApiStatus.Internal
|
||||
+ public void initModdedOverlays() {
|
||||
+ this.layerManager.initModdedLayers();
|
||||
+ nextStep = net.neoforged.neoforge.client.loading.ClientModLoader.completeModLoading(nextStep);
|
||||
|
||||
return nextStep;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/GuiGraphicsExtractor.java
|
||||
+++ b/net/minecraft/client/gui/GuiGraphicsExtractor.java
|
||||
@@ -103,6 +_,7 @@
|
||||
@@ -102,6 +_,7 @@
|
||||
private @Nullable Style hoveredTextStyle;
|
||||
private @Nullable Style clickableTextStyle;
|
||||
private @Nullable Renderable preeditOverlay;
|
||||
@@ -16,7 +16,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1021,9 +_,21 @@
|
||||
@@ -1017,9 +_,21 @@
|
||||
}
|
||||
|
||||
public void setTooltipForNextFrame(Font font, ItemStack itemStack, int xo, int yo) {
|
||||
@@ -38,7 +38,7 @@
|
||||
}
|
||||
|
||||
public void setTooltipForNextFrame(Font font, List<Component> texts, Optional<TooltipComponent> optionalImage, int xo, int yo) {
|
||||
@@ -1031,11 +_,7 @@
|
||||
@@ -1027,11 +_,7 @@
|
||||
}
|
||||
|
||||
public void setTooltipForNextFrame(Font font, List<Component> texts, Optional<TooltipComponent> optionalImage, int xo, int yo, @Nullable Identifier style) {
|
||||
@@ -51,7 +51,7 @@
|
||||
this.setTooltipForNextFrameInternal(font, components, xo, yo, DefaultTooltipPositioner.INSTANCE, style, false);
|
||||
}
|
||||
|
||||
@@ -1063,13 +_,14 @@
|
||||
@@ -1059,13 +_,14 @@
|
||||
}
|
||||
|
||||
public void setComponentTooltipForNextFrame(Font font, List<Component> lines, int xo, int yo) {
|
||||
@@ -68,7 +68,7 @@
|
||||
xo,
|
||||
yo,
|
||||
DefaultTooltipPositioner.INSTANCE,
|
||||
@@ -1078,6 +_,28 @@
|
||||
@@ -1074,6 +_,28 @@
|
||||
);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
public void setTooltipForNextFrame(Font font, List<? extends FormattedCharSequence> lines, int xo, int yo) {
|
||||
this.setTooltipForNextFrame(font, lines, xo, yo, null);
|
||||
}
|
||||
@@ -1101,12 +_,24 @@
|
||||
@@ -1097,12 +_,24 @@
|
||||
) {
|
||||
if (!lines.isEmpty()) {
|
||||
if (this.deferredTooltip == null || replaceExisting) {
|
||||
@@ -123,17 +123,17 @@
|
||||
int textWidth = 0;
|
||||
int tempHeight = lines.size() == 1 ? -2 : 0;
|
||||
|
||||
@@ -1125,7 +_,8 @@
|
||||
@@ -1121,7 +_,8 @@
|
||||
int x = positionedTooltip.x();
|
||||
int y = positionedTooltip.y();
|
||||
this.pose.pushMatrix();
|
||||
- TooltipRenderUtil.extractTooltipBackground(this, x, y, textWidth, tempHeight, style);
|
||||
- TooltipRenderUtil.extractTooltipBackground(this, x, y, w, h, style);
|
||||
+ var textureEvent = net.neoforged.neoforge.client.ClientHooks.onRenderTooltipTexture(tooltipStack, this, x, y, preEvent.getFont(), lines, style);
|
||||
+ TooltipRenderUtil.extractTooltipBackground(this, x, y, textWidth, tempHeight, textureEvent.getTexture());
|
||||
int localY = y;
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
@@ -1188,6 +_,31 @@
|
||||
@@ -1183,6 +_,31 @@
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,414 @@
|
||||
--- a/net/minecraft/client/gui/Hud.java
|
||||
+++ b/net/minecraft/client/gui/Hud.java
|
||||
@@ -85,6 +_,8 @@
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import net.neoforged.fml.common.asm.enumextension.IExtensibleEnum;
|
||||
+// Neo: Exceptionally add a static wildcard import to make the patch bearable, and comments to avoid the detection by spotless rules.
|
||||
+/* space for import change */ import static net.neoforged.neoforge.client.gui.VanillaGuiLayers.* /* space for wildcard import */;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class Hud {
|
||||
@@ -180,6 +_,11 @@
|
||||
private Pair<Hud.ContextualInfo, ContextualBar> contextualInfoBar = Pair.of(Hud.ContextualInfo.EMPTY, ContextualBar.EMPTY);
|
||||
private final Map<Hud.ContextualInfo, Supplier<ContextualBar>> contextualInfoBars;
|
||||
private float scopeScale;
|
||||
+ private final net.neoforged.neoforge.client.gui.GuiLayerManager layerManager = new net.neoforged.neoforge.client.gui.GuiLayerManager();
|
||||
+ /// Neo: This variable controls the height of overlays on the left of the hotbar (e.g. health, armor).
|
||||
+ public int leftHeight;
|
||||
+ /// Neo: This variable controls the height of overlays on the right of the hotbar (e.g. food, vehicle health, air).
|
||||
+ public int rightHeight;
|
||||
|
||||
public Hud(Minecraft minecraft) {
|
||||
this.minecraft = minecraft;
|
||||
@@ -200,6 +_,7 @@
|
||||
() -> new JumpableVehicleBar(minecraft)
|
||||
);
|
||||
this.resetTitleTimes();
|
||||
+ this.registerVanillaLayers();
|
||||
}
|
||||
|
||||
public void registerReloadListeners(ReloadableResourceManager resourceManager) {
|
||||
@@ -223,28 +_,48 @@
|
||||
public void extractRenderState(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
this.minecraft.gameRenderer.gameRenderState().guiRenderState.isHudHidden = this.isHidden;
|
||||
if (!(this.minecraft.gui.screen() instanceof LevelLoadingScreen)) {
|
||||
- if (!this.isHidden) {
|
||||
- this.extractCameraOverlays(graphics, deltaTracker);
|
||||
- this.extractCrosshair(graphics, deltaTracker);
|
||||
- graphics.nextStratum();
|
||||
- this.extractHotbarAndDecorations(graphics, deltaTracker);
|
||||
- this.extractEffects(graphics, deltaTracker);
|
||||
- this.extractBossOverlay(graphics, deltaTracker);
|
||||
- }
|
||||
-
|
||||
- this.extractSleepOverlay(graphics, deltaTracker);
|
||||
- if (!this.isHidden) {
|
||||
- this.extractDemoOverlay(graphics, deltaTracker);
|
||||
- this.extractScoreboardSidebar(graphics, deltaTracker);
|
||||
- this.extractOverlayMessage(graphics, deltaTracker);
|
||||
- this.extractTitle(graphics, deltaTracker);
|
||||
- this.extractChat(graphics, deltaTracker);
|
||||
- this.extractTabList(graphics, deltaTracker);
|
||||
+ leftHeight = 39;
|
||||
+ rightHeight = 39;
|
||||
+ updateContextualBarRenderer();
|
||||
+ layerManager.render(graphics, deltaTracker);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void registerVanillaLayers() {
|
||||
+ java.util.function.BooleanSupplier hudVisible = () -> !this.isHidden;
|
||||
+ java.util.function.BooleanSupplier survivalVisible = () -> this.minecraft.gameMode.canHurtPlayer() && hudVisible.getAsBoolean();
|
||||
+
|
||||
+ layerManager.add(CAMERA_OVERLAYS, this::extractCameraOverlays, hudVisible);
|
||||
+ layerManager.add(CROSSHAIR, this::extractCrosshair, hudVisible);
|
||||
+ layerManager.add(AFTER_CAMERA_DECORATIONS, (guiGraphics, _) -> guiGraphics.nextStratum(), hudVisible);
|
||||
+ // TODO: Split this up again into its pieces
|
||||
+ layerManager.add(HOTBAR, this::extractHotbar, hudVisible);
|
||||
+ layerManager.add(PLAYER_HEALTH, (guiGraphics, _) -> extractHealthLevel(guiGraphics), survivalVisible);
|
||||
+ layerManager.add(ARMOR_LEVEL, (guiGraphics, _) -> extractArmorLevel(guiGraphics), survivalVisible);
|
||||
+ layerManager.add(FOOD_LEVEL, (guiGraphics, _) -> extractFoodLevel(guiGraphics), survivalVisible);
|
||||
+ layerManager.add(VEHICLE_HEALTH, (guiGraphics, _) -> extractVehicleHealth(guiGraphics), hudVisible);
|
||||
+ layerManager.add(AIR_LEVEL, (guiGraphics, _) -> extractAirLevel(guiGraphics), survivalVisible);
|
||||
+ layerManager.add(CONTEXTUAL_INFO_BAR_BACKGROUND, this::extractContextualInfoBarBackground, hudVisible);
|
||||
+ layerManager.add(EXPERIENCE_LEVEL, this::extractExperienceLevel, hudVisible);
|
||||
+ layerManager.add(CONTEXTUAL_INFO_BAR, this::extractContextualInfoBar, hudVisible);
|
||||
+ layerManager.add(SELECTED_ITEM_NAME, this::maybeExtractSelectedItemName, hudVisible);
|
||||
+ layerManager.add(SPECTATOR_TOOLTIP, this::maybeExtractSpectatorTooltip, hudVisible);
|
||||
+ layerManager.add(EFFECTS, this::extractEffects, hudVisible);
|
||||
+ layerManager.add(BOSS_OVERLAY, this::extractBossOverlay, hudVisible);
|
||||
+ layerManager.add(SLEEP_OVERLAY, this::extractSleepOverlay);
|
||||
+ layerManager.add(DEMO_OVERLAY, this::extractDemoOverlay, hudVisible);
|
||||
+ layerManager.add(SCOREBOARD_SIDEBAR, this::extractScoreboardSidebar, hudVisible);
|
||||
+ layerManager.add(OVERLAY_MESSAGE, this::extractOverlayMessage, hudVisible);
|
||||
+ layerManager.add(TITLE, this::extractTitle, hudVisible);
|
||||
+ layerManager.add(CHAT, this::extractChat, hudVisible);
|
||||
+ layerManager.add(TAB_LIST, this::extractTabList, hudVisible);
|
||||
+ layerManager.add(SUBTITLE_OVERLAY, (graphics, _) -> {
|
||||
+ if (!this.isHidden) {
|
||||
this.extractSubtitleOverlay(graphics, this.minecraft.gui.screen() == null || this.minecraft.gui.screen().isInGameUi());
|
||||
} else if (this.minecraft.gui.screen() != null && this.minecraft.gui.screen().isInGameUi()) {
|
||||
this.extractSubtitleOverlay(graphics, true);
|
||||
}
|
||||
- }
|
||||
+ });
|
||||
}
|
||||
|
||||
private void extractBossOverlay(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
@@ -288,8 +_,12 @@
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
ItemStack item = player.getItemBySlot(slot);
|
||||
Equippable equippable = item.get(DataComponents.EQUIPPABLE);
|
||||
- if (equippable != null && equippable.slot() == slot && equippable.cameraOverlay().isPresent()) {
|
||||
+ if (equippable != null && equippable.slot() == slot) {
|
||||
+ if (equippable.cameraOverlay().isPresent()) {
|
||||
this.extractTextureOverlay(graphics, equippable.cameraOverlay().get().withPath(p -> "textures/" + p + ".png"), 1.0F);
|
||||
+ }
|
||||
+
|
||||
+ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(item).renderFirstPersonOverlay(item, slot, this.minecraft.player, graphics, deltaTracker);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,7 +_,11 @@
|
||||
if (alpha > 0) {
|
||||
graphics.nextStratum();
|
||||
graphics.pose().pushMatrix();
|
||||
- graphics.pose().translate(graphics.guiWidth() / 2, graphics.guiHeight() - 68);
|
||||
+ // Include a shift based on the bar height plus the difference between the height that renderSelectedItemName
|
||||
+ // renders at (59) and the height that the overlay/status bar renders at (68) by default
|
||||
+ int yShift = Math.max(leftHeight, rightHeight) + (68 - 59);
|
||||
+ // If y shift is less than the default y level, just render it at the base y level
|
||||
+ graphics.pose().translate(graphics.guiWidth() / 2, graphics.guiHeight() - Math.max(yShift, 68));
|
||||
int color;
|
||||
if (this.animateOverlayMessageColor) {
|
||||
color = Mth.hsvToArgb(t / 50.0F, 0.7F, 0.6F, alpha);
|
||||
@@ -403,10 +_,19 @@
|
||||
private void extractChat(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
if (this.minecraft.player != null && !this.chat.isChatFocused()) {
|
||||
Window window = this.minecraft.getWindow();
|
||||
+ // Neo: Allow customizing position of chat component
|
||||
+ var chatBottomMargin = 40; // See ChatComponent#BOTTOM_MARGIN (used in translate calls in ChatComponent#render)
|
||||
+ var event = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(
|
||||
+ new net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent.Chat(window, graphics, deltaTracker, 0, graphics.guiHeight() - chatBottomMargin)
|
||||
+ );
|
||||
+ // The event is given the absolute Y position; account for chat component's own offsetting here
|
||||
+ graphics.pose().pushMatrix();
|
||||
+ graphics.pose().translate(event.getPosX(), (event.getPosY() - graphics.guiHeight() + chatBottomMargin) / (float) this.chat.getScale());
|
||||
int mouseX = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window));
|
||||
int mouseY = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window));
|
||||
graphics.nextStratum();
|
||||
this.chat.extractRenderState(graphics, this.getFont(), this.tickCount, mouseX, mouseY, ChatComponent.DisplayMode.BACKGROUND, false);
|
||||
+ graphics.pose().popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,6 +_,8 @@
|
||||
int harmfulCount = 0;
|
||||
|
||||
for (MobEffectInstance instance : Ordering.natural().reverse().sortedCopy(activeEffects)) {
|
||||
+ var renderer = net.neoforged.neoforge.client.extensions.common.IClientMobEffectExtensions.of(instance);
|
||||
+ if (!renderer.isVisibleInGui(instance)) continue;
|
||||
Holder<MobEffect> effect = instance.getEffect();
|
||||
if (instance.showIcon()) {
|
||||
int x = graphics.guiWidth();
|
||||
@@ -529,6 +_,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ if (renderer.renderGuiIcon(instance, this, graphics, x, y, 0, alpha)) continue;
|
||||
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(effect), x + 3, y + 3, 18, 18, ARGB.white(alpha));
|
||||
}
|
||||
}
|
||||
@@ -539,32 +_,51 @@
|
||||
return effect.unwrapKey().map(ResourceKey::identifier).map(id -> id.withPrefix("mob_effect/")).orElseGet(MissingTextureAtlasSprite::getLocation);
|
||||
}
|
||||
|
||||
- private void extractHotbarAndDecorations(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void extractHotbar(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
if (this.minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR) {
|
||||
this.spectatorGui.extractHotbar(graphics);
|
||||
} else {
|
||||
this.extractItemHotbar(graphics, deltaTracker);
|
||||
}
|
||||
-
|
||||
- if (this.minecraft.gameMode.canHurtPlayer()) {
|
||||
- this.extractPlayerHealth(graphics);
|
||||
- }
|
||||
-
|
||||
- this.extractVehicleHealth(graphics);
|
||||
+ }
|
||||
+
|
||||
+ // Neo: Wrap in a method to call it when re-rendering
|
||||
+ private void updateContextualBarRenderer() {
|
||||
Hud.ContextualInfo nextContextualInfo = this.nextContextualInfoState();
|
||||
if (nextContextualInfo != this.contextualInfoBar.getFirst()) {
|
||||
this.contextualInfoBar = Pair.of(nextContextualInfo, this.contextualInfoBars.get(nextContextualInfo).get());
|
||||
}
|
||||
+ }
|
||||
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void extractContextualInfoBarBackground(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
this.contextualInfoBar.getSecond().extractBackground(graphics, deltaTracker);
|
||||
+ }
|
||||
+
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void extractExperienceLevel(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
if (this.minecraft.gameMode.hasExperience() && this.minecraft.player.experienceLevel > 0) {
|
||||
ContextualBar.extractExperienceLevel(graphics, this.minecraft.font, this.minecraft.player.experienceLevel);
|
||||
}
|
||||
+ }
|
||||
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void extractContextualInfoBar(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
this.contextualInfoBar.getSecond().extractRenderState(graphics, deltaTracker);
|
||||
+ }
|
||||
+
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void maybeExtractSelectedItemName(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
if (this.minecraft.gameMode.getPlayerMode() != GameType.SPECTATOR) {
|
||||
- this.extractSelectedItemName(graphics);
|
||||
- } else if (this.minecraft.player.isSpectator()) {
|
||||
+ this.extractSelectedItemName(graphics, Math.max(this.leftHeight, this.rightHeight));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Neo: Split off into separate method to wrap in a layer
|
||||
+ private void maybeExtractSpectatorTooltip(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker) {
|
||||
+ // Neo: Note this is originally mutually exclusive with the condition in maybeRenderSelectedItemName
|
||||
+ if (this.minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR && this.minecraft.player.isSpectator()) {
|
||||
this.spectatorGui.extractAction(graphics);
|
||||
}
|
||||
}
|
||||
@@ -631,15 +_,20 @@
|
||||
}
|
||||
|
||||
private void extractSelectedItemName(GuiGraphicsExtractor graphics) {
|
||||
+ extractSelectedItemName(graphics, 0);
|
||||
+ }
|
||||
+
|
||||
+ private void extractSelectedItemName(GuiGraphicsExtractor graphics, int yShift) {
|
||||
if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) {
|
||||
- MutableComponent str = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color());
|
||||
+ MutableComponent str = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().getStyleModifier());
|
||||
if (this.lastToolHighlight.has(DataComponents.CUSTOM_NAME)) {
|
||||
str.withStyle(ChatFormatting.ITALIC);
|
||||
}
|
||||
|
||||
- int strWidth = this.getFont().width(str);
|
||||
+ Component highlightTip = this.lastToolHighlight.getHighlightTip(str);
|
||||
+ int strWidth = this.getFont().width(highlightTip);
|
||||
int x = (graphics.guiWidth() - strWidth) / 2;
|
||||
- int y = graphics.guiHeight() - 59;
|
||||
+ int y = graphics.guiHeight() - Math.max(yShift, 59);
|
||||
if (!this.minecraft.gameMode.canHurtPlayer()) {
|
||||
y += 14;
|
||||
}
|
||||
@@ -650,7 +_,13 @@
|
||||
}
|
||||
|
||||
if (alpha > 0) {
|
||||
- graphics.textWithBackdrop(this.getFont(), str, x, y, strWidth, ARGB.white(alpha));
|
||||
+ Font font = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(lastToolHighlight).getFont(lastToolHighlight, net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.FontContext.SELECTED_ITEM_NAME);
|
||||
+ if (font == null) {
|
||||
+ graphics.textWithBackdrop(this.getFont(), highlightTip, x, y, strWidth, ARGB.white(alpha));
|
||||
+ } else {
|
||||
+ x = (graphics.guiWidth() - font.width(highlightTip)) / 2;
|
||||
+ graphics.textWithBackdrop(font, highlightTip, x, y, strWidth, ARGB.white(alpha));
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -767,7 +_,15 @@
|
||||
return (int)Math.ceil(hearts / 10.0);
|
||||
}
|
||||
|
||||
+ @Deprecated // Neo: Split up into different layers
|
||||
private void extractPlayerHealth(GuiGraphicsExtractor graphics) {
|
||||
+ extractHealthLevel(graphics);
|
||||
+ extractArmorLevel(graphics);
|
||||
+ extractFoodLevel(graphics);
|
||||
+ extractAirLevel(graphics);
|
||||
+ }
|
||||
+
|
||||
+ private void extractHealthLevel(GuiGraphicsExtractor graphics) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
int currentHealth = Mth.ceil(player.getHealth());
|
||||
@@ -791,32 +_,63 @@
|
||||
this.random.setSeed(this.tickCount * 312871);
|
||||
int xLeft = graphics.guiWidth() / 2 - 91;
|
||||
int xRight = graphics.guiWidth() / 2 + 91;
|
||||
- int yLineBase = graphics.guiHeight() - 39;
|
||||
+ int yLineBase = graphics.guiHeight() - leftHeight;
|
||||
float maxHealth = Math.max((float)player.getAttributeValue(Attributes.MAX_HEALTH), Math.max(oldHealth, currentHealth));
|
||||
int totalAbsorption = Mth.ceil(player.getAbsorptionAmount());
|
||||
int numHealthRows = Mth.ceil((maxHealth + totalAbsorption) / 2.0F / 10.0F);
|
||||
int healthRowHeight = Math.max(10 - (numHealthRows - 2), 3);
|
||||
int yLineAir = yLineBase - 10;
|
||||
+ leftHeight += (numHealthRows - 1) * healthRowHeight + 10;
|
||||
int heartOffsetIndex = -1;
|
||||
if (player.hasEffect(MobEffects.REGENERATION)) {
|
||||
heartOffsetIndex = this.tickCount % Mth.ceil(maxHealth + 5.0F);
|
||||
}
|
||||
|
||||
- Profiler.get().push("armor");
|
||||
- extractArmor(graphics, player, yLineBase, numHealthRows, healthRowHeight, xLeft);
|
||||
- Profiler.get().popPush("health");
|
||||
+ Profiler.get().push("health");
|
||||
this.extractHearts(
|
||||
graphics, player, xLeft, yLineBase, healthRowHeight, heartOffsetIndex, maxHealth, currentHealth, oldHealth, totalAbsorption, blink
|
||||
);
|
||||
+ Profiler.get().pop();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void extractArmorLevel(GuiGraphicsExtractor graphics) {
|
||||
+ Player player = this.getCameraPlayer();
|
||||
+ if (player != null) {
|
||||
+ int l = graphics.guiWidth() / 2 - 91;
|
||||
+ Profiler.get().push("armor");
|
||||
+ extractArmor(graphics, player, graphics.guiHeight() - leftHeight + 10, 1, 0, l);
|
||||
+ Profiler.get().pop();
|
||||
+ if (player.getArmorValue() > 0) {
|
||||
+ leftHeight += 10;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void extractFoodLevel(GuiGraphicsExtractor graphics) {
|
||||
+ Player player = this.getCameraPlayer();
|
||||
+ if (player != null) {
|
||||
LivingEntity vehicleWithHearts = this.getPlayerVehicleWithHealth();
|
||||
int vehicleHearts = this.getVehicleMaxHearts(vehicleWithHearts);
|
||||
if (vehicleHearts == 0) {
|
||||
- Profiler.get().popPush("food");
|
||||
+ Profiler.get().push("food");
|
||||
+ int xRight = graphics.guiWidth() / 2 + 91;
|
||||
+ int yLineBase = graphics.guiHeight() - rightHeight;
|
||||
this.extractFood(graphics, player, yLineBase, xRight);
|
||||
- yLineAir -= 10;
|
||||
+ rightHeight += 10;
|
||||
+ Profiler.get().pop();
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- Profiler.get().popPush("air");
|
||||
+ private void extractAirLevel(GuiGraphicsExtractor graphics) {
|
||||
+ Player player = this.getCameraPlayer();
|
||||
+ if (player != null) {
|
||||
+ int xRight = graphics.guiWidth() / 2 + 91;
|
||||
+ int yLineAir = graphics.guiHeight() - rightHeight;
|
||||
+ LivingEntity vehicleWithHearts = this.getPlayerVehicleWithHealth();
|
||||
+ int vehicleHearts = this.getVehicleMaxHearts(vehicleWithHearts);
|
||||
+ Profiler.get().push("air");
|
||||
this.extractAirBubbles(graphics, player, vehicleHearts, yLineAir, xRight);
|
||||
Profiler.get().pop();
|
||||
}
|
||||
@@ -930,6 +_,8 @@
|
||||
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, AIR_EMPTY_SPRITE, airBubbleXPos, yLineAir + wobbleYOffset, 9, 9);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ rightHeight += 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -997,7 +_,7 @@
|
||||
if (hearts != 0) {
|
||||
int currentHealth = (int)Math.ceil(vehicleWithHearts.getHealth());
|
||||
Profiler.get().popPush("mountHealth");
|
||||
- int yLine1 = graphics.guiHeight() - 39;
|
||||
+ int yLine1 = graphics.guiHeight() - rightHeight;
|
||||
int xRight = graphics.guiWidth() / 2 + 91;
|
||||
int yo = yLine1;
|
||||
|
||||
@@ -1018,6 +_,7 @@
|
||||
}
|
||||
|
||||
yo -= 10;
|
||||
+ rightHeight += 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1050,7 +_,9 @@
|
||||
int top = (graphics.guiHeight() - height) / 2;
|
||||
int right = left + width;
|
||||
int bottom = top + height;
|
||||
- graphics.blit(RenderPipelines.GUI_TEXTURED, SPYGLASS_SCOPE_LOCATION, left, top, 0.0F, 0.0F, width, height, width, height);
|
||||
+ ItemStack useItem = this.minecraft.player.getUseItem();
|
||||
+ var clientItemExtensions = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(useItem);
|
||||
+ graphics.blit(RenderPipelines.GUI_TEXTURED, clientItemExtensions.getScopeOverlayTexture(useItem), left, top, 0.0F, 0.0F, width, height, width, height);
|
||||
graphics.fill(RenderPipelines.GUI, 0, bottom, graphics.guiWidth(), graphics.guiHeight(), -16777216);
|
||||
graphics.fill(RenderPipelines.GUI, 0, 0, graphics.guiWidth(), top, -16777216);
|
||||
graphics.fill(RenderPipelines.GUI, 0, top, left, bottom, -16777216);
|
||||
@@ -1199,7 +_,7 @@
|
||||
this.toolHighlightTimer = 0;
|
||||
} else if (this.lastToolHighlight.isEmpty()
|
||||
|| !selected.is(this.lastToolHighlight.getItem())
|
||||
- || !selected.getHoverName().equals(this.lastToolHighlight.getHoverName())) {
|
||||
+ || (!selected.getHoverName().equals(this.lastToolHighlight.getHoverName()) || !selected.getHighlightTip(selected.getHoverName()).equals(this.lastToolHighlight.getHighlightTip(this.lastToolHighlight.getHoverName())))) {
|
||||
this.toolHighlightTimer = (int)(40.0 * this.minecraft.options.notificationDisplayTime().get());
|
||||
} else if (this.toolHighlightTimer > 0) {
|
||||
this.toolHighlightTimer--;
|
||||
@@ -1476,7 +_,18 @@
|
||||
type = NORMAL;
|
||||
}
|
||||
|
||||
+ type = net.neoforged.neoforge.client.ClientHooks.firePlayerHeartTypeEvent(player, type);
|
||||
+
|
||||
return type;
|
||||
}
|
||||
+
|
||||
+ public static net.neoforged.fml.common.asm.enumextension.ExtensionInfo getExtensionInfo() {
|
||||
+ return net.neoforged.fml.common.asm.enumextension.ExtensionInfo.nonExtended(Hud.HeartType.class);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @org.jetbrains.annotations.ApiStatus.Internal
|
||||
+ public void initModdedOverlays() {
|
||||
+ this.layerManager.initModdedLayers();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/components/AbstractWidget.java
|
||||
+++ b/net/minecraft/client/gui/components/AbstractWidget.java
|
||||
@@ -221,6 +_,19 @@
|
||||
@@ -225,6 +_,19 @@
|
||||
this.focused = focused;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
--- a/net/minecraft/client/gui/components/BossHealthOverlay.java
|
||||
+++ b/net/minecraft/client/gui/components/BossHealthOverlay.java
|
||||
@@ -68,6 +_,8 @@
|
||||
|
||||
for (LerpingBossEvent event : this.events.values()) {
|
||||
int xLeft = screenWidth / 2 - 91;
|
||||
int yo = yOffset;
|
||||
+ var customizeEvent = net.neoforged.neoforge.client.ClientHooks.onCustomizeBossEventProgress(graphics, this.minecraft.getWindow(), event, xLeft, yOffset, 10 + this.minecraft.font.lineHeight);
|
||||
+ if (!customizeEvent.isCanceled()) {
|
||||
this.extractBar(graphics, xLeft, yOffset, event);
|
||||
this.extractBar(graphics, xLeft, yo, event);
|
||||
Component msg = event.getName();
|
||||
int width = this.minecraft.font.width(msg);
|
||||
@@ -75,6 +_,8 @@
|
||||
int y = yOffset - 9;
|
||||
int y = yo - 9;
|
||||
graphics.text(this.minecraft.font, msg, x, y, -1);
|
||||
yOffset += 10 + 9;
|
||||
+ }
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
@Override
|
||||
public void onPress(InputWithModifiers input) {
|
||||
this.onPress.onPress(this);
|
||||
@@ -98,6 +_,10 @@
|
||||
@@ -97,6 +_,10 @@
|
||||
button.setTooltip(this.tooltip);
|
||||
return button;
|
||||
}
|
||||
@@ -22,8 +22,8 @@
|
||||
+ }
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@@ -114,6 +_,10 @@
|
||||
public interface CreateNarration {
|
||||
@@ -110,6 +_,10 @@
|
||||
public static class Plain extends Button {
|
||||
protected Plain(int x, int y, int width, int height, Component message, Button.OnPress onPress, Button.CreateNarration createNarration) {
|
||||
super(x, y, width, height, message, onPress, createNarration);
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
private int textY;
|
||||
+ private java.util.function.Predicate<String> filter = _ -> true; // Neo: Add back text input filtering
|
||||
|
||||
public EditBox(Font font, int width, int height, Component narration) {
|
||||
this(font, 0, 0, width, height, narration);
|
||||
@@ -94,6 +_,8 @@
|
||||
public EditBox(Font font, Component narration) {
|
||||
this(font, 150, 20, narration);
|
||||
@@ -98,6 +_,8 @@
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
@@ -17,7 +17,7 @@
|
||||
if (value.length() > this.maxLength) {
|
||||
this.value = value.substring(0, this.maxLength);
|
||||
} else {
|
||||
@@ -127,6 +_,14 @@
|
||||
@@ -131,6 +_,14 @@
|
||||
this.updateTextPosition();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
public void insertText(String input) {
|
||||
int start = Math.min(this.cursorPos, this.highlightPos);
|
||||
int end = Math.max(this.cursorPos, this.highlightPos);
|
||||
@@ -143,6 +_,7 @@
|
||||
@@ -147,6 +_,7 @@
|
||||
insertionLength = maxInsertionLength;
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@
|
||||
this.value = new StringBuilder(this.value).replace(start, end, text).toString();
|
||||
this.setCursorPosition(start + insertionLength);
|
||||
this.setHighlightPos(this.cursorPos);
|
||||
@@ -622,6 +_,10 @@
|
||||
@@ -628,6 +_,10 @@
|
||||
public void setHint(Component hint) {
|
||||
boolean hasNoStyle = hint.getStyle().equals(Style.EMPTY);
|
||||
this.hint = (Component)(hasNoStyle ? hint.copy().withStyle(DEFAULT_HINT_STYLE) : hint);
|
||||
this.hint = hasNoStyle ? hint.copy().withStyle(DEFAULT_HINT_STYLE) : hint;
|
||||
+ }
|
||||
+
|
||||
+ public boolean getTextShadow() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/components/debug/DebugScreenEntryList.java
|
||||
+++ b/net/minecraft/client/gui/components/debug/DebugScreenEntryList.java
|
||||
@@ -163,7 +_,8 @@
|
||||
@@ -164,7 +_,8 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/components/toasts/ToastManager.java
|
||||
+++ b/net/minecraft/client/gui/components/toasts/ToastManager.java
|
||||
@@ -143,6 +_,7 @@
|
||||
@@ -142,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void addToast(Toast toast) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/font/AtlasGlyphProvider.java
|
||||
+++ b/net/minecraft/client/gui/font/AtlasGlyphProvider.java
|
||||
@@ -98,6 +_,15 @@
|
||||
@@ -92,6 +_,15 @@
|
||||
buffer.addVertex(pose, x1, y0, z).setUv(this.sprite.getU1(), this.sprite.getV0()).setColor(color).setLight(packedLightCoords);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
+ this(normal, seeThrough, polygonOffset, guiPipeline, normal, seeThrough, polygonOffset);
|
||||
+ }
|
||||
+
|
||||
public static GlyphRenderTypes createForIntensityTexture(Identifier name) {
|
||||
public static GlyphRenderTypes createForGrayscaleTexture(Identifier name) {
|
||||
return new GlyphRenderTypes(
|
||||
RenderTypes.textIntensity(name),
|
||||
RenderTypes.textIntensitySeeThrough(name),
|
||||
RenderTypes.textIntensityPolygonOffset(name),
|
||||
- RenderPipelines.GUI_TEXT_INTENSITY
|
||||
+ RenderPipelines.GUI_TEXT_INTENSITY,
|
||||
RenderTypes.textGrayscale(name),
|
||||
RenderTypes.textGrayscaleSeeThrough(name),
|
||||
RenderTypes.textGrayscalePolygonOffset(name),
|
||||
- RenderPipelines.GUI_TEXT_GRAYSCALE
|
||||
+ RenderPipelines.GUI_TEXT_GRAYSCALE,
|
||||
+ net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextIntensityFiltered(name),
|
||||
+ net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextIntensitySeeThroughFiltered(name),
|
||||
+ net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextIntensityPolygonOffsetFiltered(name)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/font/glyphs/BakedSheetGlyph.java
|
||||
+++ b/net/minecraft/client/gui/font/glyphs/BakedSheetGlyph.java
|
||||
@@ -206,6 +_,15 @@
|
||||
@@ -205,6 +_,15 @@
|
||||
this.glyph.renderEffect(this, pose, buffer, packedLightCoords, false);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
@Override
|
||||
public RenderType renderType(Font.DisplayMode displayMode) {
|
||||
return this.glyph.renderTypes.select(displayMode);
|
||||
@@ -259,6 +_,15 @@
|
||||
@@ -257,6 +_,15 @@
|
||||
this.glyph.renderChar(this, pose, buffer, packedLightCoords, flat);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
--- a/net/minecraft/client/gui/font/providers/GlyphProviderType.java
|
||||
+++ b/net/minecraft/client/gui/font/providers/GlyphProviderType.java
|
||||
@@ -8,6 +_,7 @@
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
@@ -10,6 +_,7 @@
|
||||
import net.neoforged.fml.common.asm.enumextension.IExtensibleEnum;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
[email protected]
|
||||
public enum GlyphProviderType implements StringRepresentable, net.neoforged.fml.common.asm.enumextension.IExtensibleEnum {
|
||||
public enum GlyphProviderType implements StringRepresentable, IExtensibleEnum {
|
||||
BITMAP("bitmap", BitmapProvider.Definition.CODEC),
|
||||
TTF("ttf", TrueTypeGlyphProviderDefinition.CODEC),
|
||||
@@ -31,5 +_,9 @@
|
||||
@@ -33,5 +_,9 @@
|
||||
|
||||
public MapCodec<? extends GlyphProviderDefinition> mapCodec() {
|
||||
return this.codec;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/client/gui/render/GuiRenderer.java
|
||||
+++ b/net/minecraft/client/gui/render/GuiRenderer.java
|
||||
@@ -104,7 +_,8 @@
|
||||
private final MultiBufferSource.BufferSource bufferSource;
|
||||
private final SubmitNodeCollector submitNodeCollector;
|
||||
@@ -88,7 +_,8 @@
|
||||
private final Projection guiProjection = new Projection();
|
||||
private final ProjectionMatrixBuffer guiProjectionMatrixBuffer = new ProjectionMatrixBuffer("gui");
|
||||
private final FeatureRenderDispatcher featureRenderDispatcher;
|
||||
- private final Map<Class<? extends PictureInPictureRenderState>, PictureInPictureRenderer<?>> pictureInPictureRenderers;
|
||||
+ private final Map<Class<? extends PictureInPictureRenderState>, net.neoforged.neoforge.client.gui.PictureInPictureRendererPool<?>> pictureInPictureRendererPools;
|
||||
@@ -10,16 +10,13 @@
|
||||
private @Nullable GuiItemAtlas itemAtlas;
|
||||
private int cachedGuiScale;
|
||||
private final CubeMap cubeMap = new CubeMap(Identifier.withDefaultNamespace("textures/gui/title/background/panorama"));
|
||||
@@ -118,19 +_,13 @@
|
||||
MultiBufferSource.BufferSource bufferSource,
|
||||
SubmitNodeCollector submitNodeCollector,
|
||||
FeatureRenderDispatcher featureRenderDispatcher,
|
||||
- List<PictureInPictureRenderer<?>> pictureInPictureRenderers
|
||||
+ List<net.neoforged.neoforge.client.gui.PictureInPictureRendererRegistration<?>> pipRendererFactories
|
||||
) {
|
||||
@@ -97,16 +_,10 @@
|
||||
private @Nullable TextureSetup previousTextureSetup = null;
|
||||
private StagedVertexBuffer.@Nullable Draw previousDraw;
|
||||
|
||||
- public GuiRenderer(GuiRenderState renderState, FeatureRenderDispatcher featureRenderDispatcher, List<PictureInPictureRenderer<?>> pictureInPictureRenderers) {
|
||||
+ public GuiRenderer(GuiRenderState renderState, FeatureRenderDispatcher featureRenderDispatcher, List<net.neoforged.neoforge.client.gui.PictureInPictureRendererRegistration<?>> pipRendererFactories) {
|
||||
this.renderState = renderState;
|
||||
this.bufferSource = bufferSource;
|
||||
this.submitNodeCollector = submitNodeCollector;
|
||||
this.featureRenderDispatcher = featureRenderDispatcher;
|
||||
- Builder<Class<? extends PictureInPictureRenderState>, PictureInPictureRenderer<?>> builder = ImmutableMap.builder();
|
||||
-
|
||||
@@ -28,11 +25,11 @@
|
||||
- }
|
||||
-
|
||||
- this.pictureInPictureRenderers = builder.buildOrThrow();
|
||||
+ this.pictureInPictureRendererPools = net.neoforged.neoforge.client.gui.PictureInPictureRendererPool.createPools(bufferSource, pipRendererFactories);
|
||||
+ this.pictureInPictureRendererPools = net.neoforged.neoforge.client.gui.PictureInPictureRendererPool.createPools(pipRendererFactories);
|
||||
}
|
||||
|
||||
public void endFrame() {
|
||||
@@ -161,6 +_,7 @@
|
||||
@@ -134,6 +_,7 @@
|
||||
this.renderState.reset();
|
||||
this.firstDrawIndexAfterBlur = Integer.MAX_VALUE;
|
||||
this.clearUnusedOversizedItemRenderers();
|
||||
@@ -40,21 +37,18 @@
|
||||
if (SharedConstants.DEBUG_SHUFFLE_UI_RENDERING_ORDER) {
|
||||
RenderPipeline.updateSortKeySeed();
|
||||
TextureSetup.updateSortKeySeed();
|
||||
@@ -290,7 +_,9 @@
|
||||
RenderPipeline pipeline = elementState.pipeline();
|
||||
TextureSetup textureSetup = elementState.textureSetup();
|
||||
@@ -224,6 +_,7 @@
|
||||
ScreenRectangle scissorArea = elementState.scissorArea();
|
||||
- if (pipeline != this.previousPipeline || this.scissorChanged(scissorArea, this.previousScissorArea) || !textureSetup.equals(this.previousTextureSetup)) {
|
||||
+ if (pipeline != this.previousPipeline || this.scissorChanged(scissorArea, this.previousScissorArea) || !textureSetup.equals(this.previousTextureSetup)
|
||||
+ || pipeline.getVertexFormatMode().connectedPrimitives // Neo: flush elements with connected primitives individually
|
||||
+ ) {
|
||||
if (this.bufferBuilder != null) {
|
||||
this.recordMesh(this.bufferBuilder, this.previousPipeline, this.previousTextureSetup, this.previousScissorArea);
|
||||
}
|
||||
@@ -368,14 +_,31 @@
|
||||
if (this.previousDraw == null
|
||||
|| pipeline != this.previousPipeline
|
||||
+ || pipeline.getPrimitiveTopology().connectedPrimitives // Neo: flush elements with connected primitives individually
|
||||
|| this.scissorChanged(scissorArea, this.previousScissorArea)
|
||||
|| !textureSetup.equals(this.previousTextureSetup)) {
|
||||
this.previousPipeline = pipeline;
|
||||
@@ -287,14 +_,31 @@
|
||||
|
||||
private void preparePictureInPicture() {
|
||||
int guiScale = Minecraft.getInstance().gameRenderer.getGameRenderState().windowRenderState.guiScale;
|
||||
int guiScale = Minecraft.getInstance().gameRenderer.gameRenderState().windowRenderState.guiScale;
|
||||
- this.renderState.forEachPictureInPicture(pictureInPictureState -> this.preparePictureInPictureState(pictureInPictureState, guiScale));
|
||||
+ this.pictureInPictureRenderStatesScratch.clear();
|
||||
+ this.renderState.forEachPictureInPicture(state -> {
|
||||
@@ -79,34 +73,19 @@
|
||||
+ }
|
||||
+ PictureInPictureRenderer<T> renderer = pool.get(picturesInPictureState, guiScale, firstPass);
|
||||
if (renderer != null) {
|
||||
renderer.prepare(picturesInPictureState, this.renderState, guiScale);
|
||||
renderer.prepare(picturesInPictureState, this.renderState, this.featureRenderDispatcher, guiScale);
|
||||
+ return true;
|
||||
}
|
||||
+ return false;
|
||||
}
|
||||
|
||||
private void submitBlitFromItemAtlas(GuiItemRenderState itemState, GuiItemAtlas.SlotView slotView) {
|
||||
@@ -548,6 +_,14 @@
|
||||
renderPass.bindTexture("Sampler2", draw.textureSetup.texure2(), draw.textureSetup.sampler2());
|
||||
}
|
||||
|
||||
+ // Neo: support non-quad vertex format modes
|
||||
+ VertexFormat.Mode formatMode = pipeline.getVertexFormatMode();
|
||||
+ if (formatMode != VertexFormat.Mode.QUADS) {
|
||||
+ RenderSystem.AutoStorageIndexBuffer autoStorageIndexBuffer = RenderSystem.getSequentialBuffer(formatMode);
|
||||
+ indexBuffer = autoStorageIndexBuffer.getBuffer(draw.indexCount);
|
||||
+ indexType = autoStorageIndexBuffer.type();
|
||||
+ }
|
||||
+
|
||||
renderPass.setIndexBuffer(indexBuffer, indexType);
|
||||
renderPass.drawIndexed(draw.baseVertex, 0, draw.indexCount, 1);
|
||||
}
|
||||
@@ -587,7 +_,7 @@
|
||||
@@ -422,7 +_,7 @@
|
||||
this.itemAtlas = null;
|
||||
}
|
||||
|
||||
- this.pictureInPictureRenderers.values().forEach(PictureInPictureRenderer::close);
|
||||
+ this.pictureInPictureRendererPools.values().forEach(net.neoforged.neoforge.client.gui.PictureInPictureRendererPool::close);
|
||||
this.guiProjectionMatrixBuffer.close();
|
||||
|
||||
for (MappableRingBuffer buffer : this.vertexBuffers.values()) {
|
||||
this.oversizedItemRenderers.values().forEach(PictureInPictureRenderer::close);
|
||||
this.cubeMap.close();
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
--- a/net/minecraft/client/gui/render/pip/PictureInPictureRenderer.java
|
||||
+++ b/net/minecraft/client/gui/render/pip/PictureInPictureRenderer.java
|
||||
@@ -93,7 +_,9 @@
|
||||
@@ -96,7 +_,9 @@
|
||||
if (this.texture == null) {
|
||||
this.texture = device.createTexture(() -> "UI " + this.getTextureLabel() + " texture", 13, TextureFormat.RGBA8, width, height, 1, 1);
|
||||
this.texture = device.createTexture(() -> "UI " + this.getTextureLabel() + " texture", 13, GpuFormat.RGBA8_UNORM, width, height, 1, 1);
|
||||
this.textureView = device.createTextureView(this.texture);
|
||||
- this.depthTexture = device.createTexture(() -> "UI " + this.getTextureLabel() + " depth texture", 9, TextureFormat.DEPTH32, width, height, 1, 1);
|
||||
- this.depthTexture = device.createTexture(() -> "UI " + this.getTextureLabel() + " depth texture", 9, GpuFormat.D32_FLOAT, width, height, 1, 1);
|
||||
+ // Neo: copy stencil setting from main target
|
||||
+ TextureFormat depthFormat = net.minecraft.client.Minecraft.getInstance().getMainRenderTarget().getDepthTexture().getFormat();
|
||||
+ GpuFormat depthFormat = net.minecraft.client.Minecraft.getInstance().gameRenderer.mainRenderTarget().getDepthTexture().getFormat();
|
||||
+ this.depthTexture = device.createTexture(() -> "UI " + this.getTextureLabel() + " depth texture", 9, depthFormat, width, height, 1, 1);
|
||||
this.depthTextureView = device.createTextureView(this.depthTexture);
|
||||
}
|
||||
|
||||
@@ -136,4 +_,13 @@
|
||||
protected abstract void renderToTexture(final T renderState, final PoseStack poseStack);
|
||||
@@ -139,4 +_,11 @@
|
||||
protected abstract void renderToTexture(T renderState, PoseStack poseStack, SubmitNodeCollector submitNodeCollector);
|
||||
|
||||
protected abstract String getTextureLabel();
|
||||
+
|
||||
+ /**
|
||||
+ * Neo: This is used to check if this renderer can be reused for a given state, texture width and texture height on
|
||||
+ * a subsequent frame. In Vanilla, a renderer would be used for multiple different states even within the same frame,
|
||||
+ * leading to crashes and the last state being used for all blits of that renderer in that frame.
|
||||
+ */
|
||||
+ /// Neo: This is used to check if this renderer can be reused for a given state, texture width and texture height on
|
||||
+ /// a subsequent frame. In Vanilla, a renderer would be used for multiple different states even within the same frame,
|
||||
+ /// leading to crashes and the last state being used for all blits of that renderer in that frame.
|
||||
+ public boolean canBeReusedFor(T state, int textureWidth, int textureHeight) {
|
||||
+ return texture == null || (texture.getWidth(0) == textureWidth && texture.getHeight(0) == textureHeight);
|
||||
+ }
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
--- a/net/minecraft/client/gui/screens/ChatScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/ChatScreen.java
|
||||
@@ -139,7 +_,10 @@
|
||||
this.handleChatInput(this.input.getValue(), true);
|
||||
if (this.closeOnSubmit) {
|
||||
this.exitReason = ChatScreen.ExitReason.DONE;
|
||||
- this.minecraft.setScreen(null);
|
||||
+ // FORGE: Prevent closing the screen if another screen has been opened.
|
||||
+ if (minecraft.screen == this) {
|
||||
+ this.minecraft.setScreen(null);
|
||||
+ }
|
||||
} else {
|
||||
this.input.setValue("");
|
||||
this.minecraft.gui.getChat().resetChatScroll();
|
||||
@@ -141,6 +_,8 @@
|
||||
this.handleChatInput(this.input.getValue(), true);
|
||||
if (this.closeOnSubmit) {
|
||||
this.exitReason = ChatScreen.ExitReason.DONE;
|
||||
+ // Neo: Prevent closing the screen if another screen has been opened.
|
||||
+ if (this.minecraft.gui.screen() == this)
|
||||
this.minecraft.gui.setScreen(null);
|
||||
} else {
|
||||
this.input.setValue("");
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/client/gui/screens/ConnectScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/ConnectScreen.java
|
||||
@@ -109,6 +_,8 @@
|
||||
@@ -104,6 +_,8 @@
|
||||
}
|
||||
|
||||
if (resolvedAddress.isEmpty()) {
|
||||
+ ConnectScreen.LOGGER.error("Couldn't connect to server: Unknown host \"{}\"", hostAndPort.getHost());
|
||||
+ net.neoforged.neoforge.network.DualStackUtils.logInitialPreferences();
|
||||
minecraft.execute(
|
||||
() -> minecraft.setScreen(
|
||||
new DisconnectedScreen(ConnectScreen.this.parent, ConnectScreen.this.connectFailedTitle, ConnectScreen.UNKNOWN_HOST_MESSAGE)
|
||||
() -> minecraft.gui
|
||||
.setScreen(
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
this.reload.checkExceptions();
|
||||
this.onFinish.accept(Optional.empty());
|
||||
@@ -164,7 +_,6 @@
|
||||
this.onFinish.accept(Optional.of(var2));
|
||||
this.onFinish.accept(Optional.of(t));
|
||||
}
|
||||
|
||||
- this.fadeOutStart = Util.getMillis();
|
||||
if (this.minecraft.screen != null) {
|
||||
if (this.minecraft.gui.screen() != null) {
|
||||
Window window = this.minecraft.getWindow();
|
||||
this.minecraft.screen.init(window.getGuiScaledWidth(), window.getGuiScaledHeight());
|
||||
this.minecraft.gui.screen().init(window.getGuiScaledWidth(), window.getGuiScaledHeight());
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
--- a/net/minecraft/client/gui/screens/PauseScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/PauseScreen.java
|
||||
@@ -102,6 +_,7 @@
|
||||
} else {
|
||||
helper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this)));
|
||||
@@ -165,6 +_,7 @@
|
||||
);
|
||||
}
|
||||
+ helper.addChild(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.neoforged.neoforge.client.gui.ModListScreen(this))).width(BUTTON_WIDTH_FULL).build(), 2);
|
||||
|
||||
+ helper.addChild(Button.builder(Component.translatable("fml.menu.mods"), _ -> this.minecraft.gui.setScreen(new net.neoforged.neoforge.client.gui.ModListScreen(this))).width(BUTTON_WIDTH_FULL).build(), 2);
|
||||
this.disconnectButton = helper.addChild(
|
||||
Button.builder(
|
||||
CommonComponents.disconnectButtonLabel(this.minecraft.isLocalServer()),
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
graphics.nextStratum();
|
||||
this.extractRenderState(graphics, mouseX, mouseY, a);
|
||||
graphics.extractDeferredElements(mouseX, mouseY, a);
|
||||
@@ -194,7 +_,7 @@
|
||||
@@ -196,7 +_,7 @@
|
||||
}
|
||||
|
||||
public void onClose() {
|
||||
- this.minecraft.setScreen(null);
|
||||
+ this.minecraft.popGuiLayer();
|
||||
- this.minecraft.gui.setScreen(null);
|
||||
+ this.minecraft.gui.popGuiLayer();
|
||||
}
|
||||
|
||||
protected <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(T widget) {
|
||||
@@ -237,9 +_,9 @@
|
||||
@@ -239,9 +_,9 @@
|
||||
|
||||
public static List<Component> getTooltipFromItem(Minecraft minecraft, ItemStack itemStack) {
|
||||
return itemStack.getTooltipLines(
|
||||
@@ -29,7 +29,7 @@
|
||||
);
|
||||
}
|
||||
|
||||
@@ -326,8 +_,11 @@
|
||||
@@ -327,8 +_,11 @@
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
if (!this.initialized) {
|
||||
@@ -41,7 +41,7 @@
|
||||
} else {
|
||||
this.repositionElements();
|
||||
}
|
||||
@@ -344,8 +_,11 @@
|
||||
@@ -345,8 +_,11 @@
|
||||
protected void rebuildWidgets() {
|
||||
this.clearWidgets();
|
||||
this.clearFocus();
|
||||
@@ -53,7 +53,7 @@
|
||||
}
|
||||
|
||||
protected void fadeWidgets(float widgetFade) {
|
||||
@@ -469,6 +_,10 @@
|
||||
@@ -466,6 +_,10 @@
|
||||
public void onFilesDrop(List<Path> files) {
|
||||
}
|
||||
|
||||
@@ -64,18 +64,20 @@
|
||||
private void scheduleNarration(long delay, boolean ignoreSuppression) {
|
||||
this.nextNarrationTime = Util.getMillis() + delay;
|
||||
if (ignoreSuppression) {
|
||||
@@ -616,6 +_,14 @@
|
||||
@@ -613,6 +_,16 @@
|
||||
|
||||
public @Nullable Music getBackgroundMusic() {
|
||||
return null;
|
||||
+ }
|
||||
+
|
||||
+ private void addEventWidget(GuiEventListener b) {
|
||||
+ if (b instanceof Renderable r)
|
||||
+ private void addEventWidget(GuiEventListener listener) {
|
||||
+ if (listener instanceof Renderable r) {
|
||||
+ this.renderables.add(r);
|
||||
+ if (b instanceof NarratableEntry ne)
|
||||
+ }
|
||||
+ if (listener instanceof NarratableEntry ne) {
|
||||
+ this.narratables.add(ne);
|
||||
+ children.add(b);
|
||||
+ }
|
||||
+ children.add(listener);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public record NarratableSearchResult(NarratableEntry entry, int index, NarratableEntry.NarrationPriority priority) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/screens/TitleScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/TitleScreen.java
|
||||
@@ -104,11 +_,17 @@
|
||||
@@ -113,11 +_,17 @@
|
||||
int copyrightWidth = this.font.width(COPYRIGHT_TEXT);
|
||||
int copyrightX = this.width - copyrightWidth - 2;
|
||||
int spacing = 24;
|
||||
@@ -12,23 +12,14 @@
|
||||
topPos = this.createNormalMenuOptions(topPos, 24);
|
||||
+ int modsOffset = SharedConstants.IS_RUNNING_IN_IDE ? 2 : -100;
|
||||
+ int modsWidth = SharedConstants.IS_RUNNING_IN_IDE ? 98 : 200;
|
||||
+ this.addRenderableWidget(new net.neoforged.neoforge.client.gui.widget.ModsButton(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.neoforged.neoforge.client.gui.ModListScreen(this)))
|
||||
+ this.addRenderableWidget(new net.neoforged.neoforge.client.gui.widget.ModsButton(Button.builder(Component.translatable("fml.menu.mods"), _ -> this.minecraft.gui.setScreen(new net.neoforged.neoforge.client.gui.ModListScreen(this)))
|
||||
+ .pos(this.width / 2 + modsOffset, topPos + 24).size(modsWidth, 20)));
|
||||
+ if (!SharedConstants.IS_RUNNING_IN_IDE)
|
||||
+ topPos += 24; // Move down Options, Quit, Language, and Accessibility buttons to make room for mods button (in-dev the test world button "handles" this)
|
||||
}
|
||||
|
||||
topPos = this.createTestWorldButton(topPos, 24);
|
||||
@@ -158,7 +_,7 @@
|
||||
Button.builder(
|
||||
Component.literal("Create Test World"), button -> CreateWorldScreen.testWorld(this.minecraft, () -> this.minecraft.setScreen(this))
|
||||
)
|
||||
- .bounds(this.width / 2 - 100, topPos += spacing, 200, 20)
|
||||
+ .bounds(this.width / 2 - 100, topPos += spacing, 98, 20)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
@@ -297,6 +_,7 @@
|
||||
boolean friendsListEnabled = this.minecraft.getPlayerSocialManager().isFriendListEnabled();
|
||||
@@ -310,6 +_,7 @@
|
||||
this.extractPanorama(graphics, a);
|
||||
super.extractRenderState(graphics, mouseX, mouseY, a);
|
||||
this.logoRenderer.extractRenderState(graphics, this.width, this.logoRenderer.keepLogoThroughFade() ? 1.0F : widgetFade);
|
||||
@@ -36,7 +27,7 @@
|
||||
if (this.splash != null && !this.minecraft.options.hideSplashTexts().get()) {
|
||||
this.splash.extractRenderState(graphics, this.width, this.font, widgetFade);
|
||||
}
|
||||
@@ -310,7 +_,13 @@
|
||||
@@ -323,7 +_,13 @@
|
||||
versionString = versionString + I18n.get("menu.modded");
|
||||
}
|
||||
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
public AdvancementTabType getType() {
|
||||
return this.type;
|
||||
}
|
||||
@@ -148,8 +_,8 @@
|
||||
return null;
|
||||
} else {
|
||||
for (AdvancementTabType type : AdvancementTabType.values()) {
|
||||
- if (index < type.getMax()) {
|
||||
- return new AdvancementTab(minecraft, screen, type, index, root, display.get());
|
||||
+ if ((index % AdvancementTabType.MAX_TABS) < type.getMax()) {
|
||||
+ return new AdvancementTab(minecraft, screen, type, index % AdvancementTabType.MAX_TABS, index / AdvancementTabType.MAX_TABS, root, display.get());
|
||||
}
|
||||
@@ -149,8 +_,8 @@
|
||||
}
|
||||
|
||||
index -= type.getMax();
|
||||
for (AdvancementTabType type : AdvancementTabType.values()) {
|
||||
- if (index < type.getMax()) {
|
||||
- return new AdvancementTab(minecraft, screen, type, index, root, display.get());
|
||||
+ if ((index % AdvancementTabType.MAX_TABS) < type.getMax()) {
|
||||
+ return new AdvancementTab(minecraft, screen, type, index % AdvancementTabType.MAX_TABS, index / AdvancementTabType.MAX_TABS, root, display.get());
|
||||
}
|
||||
|
||||
index -= type.getMax();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/screens/debug/DebugOptionsScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/debug/DebugOptionsScreen.java
|
||||
@@ -192,6 +_,10 @@
|
||||
@@ -178,6 +_,10 @@
|
||||
DebugScreenEntry entry = DebugScreenEntries.getEntry(location);
|
||||
this.isAllowed = entry != null && entry.isAllowed(DebugOptionsScreen.this.minecraft.showOnlyReducedInfo());
|
||||
String name = location.getPath();
|
||||
@@ -11,7 +11,7 @@
|
||||
if (this.isAllowed) {
|
||||
this.name = name;
|
||||
} else {
|
||||
@@ -252,8 +_,11 @@
|
||||
@@ -238,8 +_,11 @@
|
||||
public void extractContent(GuiGraphicsExtractor graphics, int mouseX, int mouseY, boolean hovered, float a) {
|
||||
int x = this.getContentX();
|
||||
int y = this.getContentY();
|
||||
@@ -24,7 +24,7 @@
|
||||
if (!this.isAllowed && hovered && mouseX < buttonsStartX) {
|
||||
graphics.setTooltipForNextFrame(DebugOptionsScreen.NOT_ALLOWED_TOOLTIP, mouseX, mouseY);
|
||||
}
|
||||
@@ -317,6 +_,9 @@
|
||||
@@ -301,6 +_,9 @@
|
||||
|
||||
public void updateSearch(String value) {
|
||||
this.clearEntries();
|
||||
@@ -34,7 +34,7 @@
|
||||
List<Map.Entry<Identifier, DebugScreenEntry>> all = new ArrayList<>(DebugScreenEntries.allEntries().entrySet());
|
||||
all.sort(COMPARATOR);
|
||||
DebugEntryCategory currentCategory = null;
|
||||
@@ -331,6 +_,7 @@
|
||||
@@ -315,6 +_,7 @@
|
||||
|
||||
this.addEntry(DebugOptionsScreen.this.new OptionEntry(entry.getKey()));
|
||||
}
|
||||
|
||||
+54
-75
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java
|
||||
@@ -123,6 +_,7 @@
|
||||
@@ -110,6 +_,7 @@
|
||||
this.onStopHovering(previouslyHoveredSlot);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
graphics.pose().popMatrix();
|
||||
}
|
||||
|
||||
@@ -200,7 +_,7 @@
|
||||
@@ -170,7 +_,7 @@
|
||||
ItemStack item = this.hoveredSlot.getItem();
|
||||
if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(item)) {
|
||||
graphics.setTooltipForNextFrame(
|
||||
@@ -17,17 +17,17 @@
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -216,7 +_,8 @@
|
||||
@@ -186,7 +_,8 @@
|
||||
|
||||
private void extractFloatingItem(GuiGraphicsExtractor graphics, ItemStack carried, int x, int y, @Nullable String itemCount) {
|
||||
graphics.item(carried, x, y);
|
||||
- graphics.itemDecorations(this.font, carried, x, y - (this.draggingItem.isEmpty() ? 0 : 8), itemCount);
|
||||
- graphics.itemDecorations(this.font, carried, x, y, itemCount);
|
||||
+ var font = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(carried).getFont(carried, net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.FontContext.ITEM_COUNT);
|
||||
+ graphics.itemDecorations(font != null ? font : this.font, carried, x, y - (this.draggingItem.isEmpty() ? 0 : 8), itemCount);
|
||||
+ graphics.itemDecorations(font != null ? font : this.font, carried, x, y, itemCount);
|
||||
}
|
||||
|
||||
protected void extractLabels(GuiGraphicsExtractor graphics, int xm, int ym) {
|
||||
@@ -269,6 +_,13 @@
|
||||
@@ -237,6 +_,13 @@
|
||||
graphics.fill(x, y, x + 16, y + 16, -2130706433);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
int seed = slot.x + slot.y * this.imageWidth;
|
||||
if (slot.isFake()) {
|
||||
graphics.fakeItem(itemStack, x, y, seed);
|
||||
@@ -276,7 +_,8 @@
|
||||
@@ -244,7 +_,8 @@
|
||||
graphics.item(itemStack, x, y, seed);
|
||||
}
|
||||
|
||||
@@ -51,43 +51,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +_,8 @@
|
||||
if (super.mouseClicked(event, doubleClick)) {
|
||||
@@ -285,7 +_,8 @@
|
||||
return true;
|
||||
} else {
|
||||
- boolean cloning = this.minecraft.options.keyPickItem.matchesMouse(event) && this.minecraft.player.hasInfiniteMaterials();
|
||||
+ var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(event.button());
|
||||
+ boolean cloning = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey) && this.minecraft.player.hasInfiniteMaterials();
|
||||
Slot slot = this.getHoveredSlot(event.x(), event.y());
|
||||
this.doubleclick = this.lastClickSlot == slot && doubleClick;
|
||||
this.skipNextRelease = false;
|
||||
@@ -326,6 +_,7 @@
|
||||
int xo = this.leftPos;
|
||||
int yo = this.topPos;
|
||||
boolean clickedOutside = this.hasClickedOutside(event.x(), event.y(), xo, yo);
|
||||
+ if (slot != null) clickedOutside = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
|
||||
int slotId = -1;
|
||||
if (slot != null) {
|
||||
slotId = slot.index;
|
||||
@@ -351,7 +_,7 @@
|
||||
}
|
||||
} else if (!this.isQuickCrafting) {
|
||||
if (this.menu.getCarried().isEmpty()) {
|
||||
- if (cloning) {
|
||||
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
|
||||
this.slotClicked(slot, slotId, event.button(), ContainerInput.CLONE);
|
||||
} else {
|
||||
boolean quickKey = slotId != -999 && event.hasShiftDown();
|
||||
@@ -375,7 +_,7 @@
|
||||
this.quickCraftingType = 0;
|
||||
} else if (event.button() == 1) {
|
||||
this.quickCraftingType = 1;
|
||||
- } else if (cloning) {
|
||||
+ } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
|
||||
this.quickCraftingType = 2;
|
||||
}
|
||||
}
|
||||
@@ -445,10 +_,13 @@
|
||||
}
|
||||
|
||||
- boolean cloning = this.minecraft.options.keyPickItem.matchesMouse(event) && this.minecraft.player.hasInfiniteMaterials();
|
||||
+ var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(event.button());
|
||||
+ boolean cloning = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey) && this.minecraft.player.hasInfiniteMaterials();
|
||||
Slot slot = this.getHoveredSlot(event.x(), event.y());
|
||||
this.doubleclick = this.lastClickSlot == slot && doubleClick;
|
||||
this.skipNextRelease = false;
|
||||
@@ -295,6 +_,7 @@
|
||||
int xo = this.leftPos;
|
||||
int yo = this.topPos;
|
||||
boolean clickedOutside = this.hasClickedOutside(event.x(), event.y(), xo, yo);
|
||||
+ if (slot != null) clickedOutside = false; // Neo: prevent dropping of items through slots outside of GUI boundaries
|
||||
int slotId = -1;
|
||||
if (slot != null) {
|
||||
slotId = slot.index;
|
||||
@@ -374,10 +_,13 @@
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(MouseButtonEvent event) {
|
||||
@@ -101,7 +83,7 @@
|
||||
int slotId = -1;
|
||||
if (slot != null) {
|
||||
slotId = slot.index;
|
||||
@@ -465,7 +_,7 @@
|
||||
@@ -394,7 +_,7 @@
|
||||
if (target != null
|
||||
&& target.mayPickup(this.minecraft.player)
|
||||
&& target.hasItem()
|
||||
@@ -110,8 +92,8 @@
|
||||
&& AbstractContainerMenu.canItemQuickReplace(target, this.lastQuickMoved, true)) {
|
||||
this.slotClicked(target, target.index, event.button(), ContainerInput.QUICK_MOVE);
|
||||
}
|
||||
@@ -524,7 +_,7 @@
|
||||
} else if (this.isQuickCrafting && !this.quickCraftSlots.isEmpty()) {
|
||||
@@ -421,7 +_,7 @@
|
||||
if (this.isQuickCrafting && !this.quickCraftSlots.isEmpty()) {
|
||||
this.quickCraftToSlots();
|
||||
} else if (!this.menu.getCarried().isEmpty()) {
|
||||
- if (this.minecraft.options.keyPickItem.matchesMouse(event)) {
|
||||
@@ -119,43 +101,40 @@
|
||||
this.slotClicked(slot, slotId, event.button(), ContainerInput.CLONE);
|
||||
} else {
|
||||
boolean quickKey = slotId != -999 && event.hasShiftDown();
|
||||
@@ -593,34 +_,40 @@
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(KeyEvent event) {
|
||||
+ var key = com.mojang.blaze3d.platform.InputConstants.getKey(event);
|
||||
if (super.keyPressed(event)) {
|
||||
@@ -489,32 +_,38 @@
|
||||
return true;
|
||||
- } else if (this.minecraft.options.keyInventory.matches(event)) {
|
||||
+ } else if (this.minecraft.options.keyInventory.isActiveAndMatches(key)) {
|
||||
}
|
||||
|
||||
- if (this.minecraft.options.keyInventory.matches(event)) {
|
||||
+ var key = com.mojang.blaze3d.platform.InputConstants.getKey(event);
|
||||
+ if (this.minecraft.options.keyInventory.isActiveAndMatches(key)) {
|
||||
this.onClose();
|
||||
return true;
|
||||
} else {
|
||||
- this.checkHotbarKeyPressed(event);
|
||||
+ boolean handled = this.checkHotbarKeyPressed(event); // Forge MC-146650: Needs to return true when the key is handled
|
||||
if (this.hoveredSlot != null && this.hoveredSlot.hasItem()) {
|
||||
- if (this.minecraft.options.keyPickItem.matches(event)) {
|
||||
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(key)) {
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, 0, ContainerInput.CLONE);
|
||||
- } else if (this.minecraft.options.keyDrop.matches(event)) {
|
||||
+ handled = true;
|
||||
+ } else if (this.minecraft.options.keyDrop.isActiveAndMatches(key)) {
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, event.hasControlDown() ? 1 : 0, ContainerInput.THROW);
|
||||
+ handled = true;
|
||||
}
|
||||
+ } else if (this.minecraft.options.keyDrop.isActiveAndMatches(key)) {
|
||||
+ handled = true; // Forge MC-146650: Emulate MC bug, so we don't drop from hotbar when pressing drop without hovering over a item.
|
||||
}
|
||||
|
||||
- return false;
|
||||
+ return handled;
|
||||
}
|
||||
|
||||
- this.checkHotbarKeyPressed(event);
|
||||
+ boolean handled = this.checkHotbarKeyPressed(event); // Forge MC-146650: Needs to return true when the key is handled
|
||||
if (this.hoveredSlot != null && this.hoveredSlot.hasItem()) {
|
||||
- if (this.minecraft.options.keyPickItem.matches(event)) {
|
||||
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(key)) {
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, 0, ContainerInput.CLONE);
|
||||
+ handled = true;
|
||||
} else if (this.minecraft.options.keyDrop.matches(event)) {
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, event.hasControlDown() ? 1 : 0, ContainerInput.THROW);
|
||||
+ handled = true;
|
||||
}
|
||||
+ } else if (this.minecraft.options.keyDrop.isActiveAndMatches(key)) {
|
||||
+ handled = true; // Forge MC-146650: Emulate MC bug, so we don't drop from hotbar when pressing drop without hovering over a item.
|
||||
}
|
||||
|
||||
- return false;
|
||||
+ return handled;
|
||||
}
|
||||
|
||||
protected boolean checkHotbarKeyPressed(KeyEvent event) {
|
||||
+ var key = com.mojang.blaze3d.platform.InputConstants.getKey(event);
|
||||
if (this.menu.getCarried().isEmpty() && this.hoveredSlot != null) {
|
||||
- if (this.minecraft.options.keySwapOffhand.matches(event)) {
|
||||
+ var key = com.mojang.blaze3d.platform.InputConstants.getKey(event);
|
||||
+ if (this.minecraft.options.keySwapOffhand.isActiveAndMatches(key)) {
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, 40, ContainerInput.SWAP);
|
||||
return true;
|
||||
@@ -167,7 +146,7 @@
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, i, ContainerInput.SWAP);
|
||||
return true;
|
||||
}
|
||||
@@ -682,6 +_,59 @@
|
||||
@@ -576,6 +_,59 @@
|
||||
@Override
|
||||
public T getMenu() {
|
||||
return this.menu;
|
||||
|
||||
+47
-47
@@ -9,21 +9,21 @@
|
||||
|
||||
public CreativeModeInventoryScreen(LocalPlayer player, FeatureFlagSet enabledFeatures, boolean displayOperatorCreativeTab) {
|
||||
super(new CreativeModeInventoryScreen.ItemPickerMenu(player), player.getInventory(), CommonComponents.EMPTY, 195, 136);
|
||||
@@ -152,9 +_,11 @@
|
||||
return false;
|
||||
} else {
|
||||
if (searchTrees != null) {
|
||||
- List<ItemStack> creativeSearchItems = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems());
|
||||
- searchTrees.updateCreativeTooltips(holders, creativeSearchItems);
|
||||
- searchTrees.updateCreativeTags(creativeSearchItems);
|
||||
+ CreativeModeTabs.allTabs().stream().filter(net.minecraft.world.item.CreativeModeTab::hasSearchBar).forEach(tab -> {
|
||||
+ List<ItemStack> list = List.copyOf(tab.getDisplayItems());
|
||||
+ searchTrees.updateCreativeTooltips(holders, list, net.neoforged.neoforge.client.CreativeModeTabSearchRegistry.getNameSearchKey(tab));
|
||||
+ searchTrees.updateCreativeTags(list, net.neoforged.neoforge.client.CreativeModeTabSearchRegistry.getTagSearchKey(tab));
|
||||
+ });
|
||||
}
|
||||
@@ -153,9 +_,11 @@
|
||||
}
|
||||
|
||||
return true;
|
||||
if (searchTrees != null) {
|
||||
- List<ItemStack> creativeSearchItems = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems());
|
||||
- searchTrees.updateCreativeTooltips(holders, creativeSearchItems);
|
||||
- searchTrees.updateCreativeTags(creativeSearchItems);
|
||||
+ CreativeModeTabs.allTabs().stream().filter(net.minecraft.world.item.CreativeModeTab::hasSearchBar).forEach(tab -> {
|
||||
+ List<ItemStack> list = List.copyOf(tab.getDisplayItems());
|
||||
+ searchTrees.updateCreativeTooltips(holders, list, net.neoforged.neoforge.client.CreativeModeTabSearchRegistry.getNameSearchKey(tab));
|
||||
+ searchTrees.updateCreativeTags(list, net.neoforged.neoforge.client.CreativeModeTabSearchRegistry.getTagSearchKey(tab));
|
||||
+ });
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -164,7 +_,7 @@
|
||||
private void refreshCurrentTabContents(Collection<ItemStack> displayList) {
|
||||
int oldRowIndex = this.menu.getRowIndexForScroll(this.scrollOffs);
|
||||
@@ -68,16 +68,16 @@
|
||||
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);
|
||||
@@ -377,7 +_,7 @@
|
||||
public boolean charTyped(CharacterEvent event) {
|
||||
if (this.ignoreTextInput) {
|
||||
@@ -379,7 +_,7 @@
|
||||
return false;
|
||||
- } else if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) {
|
||||
+ } else if (!selectedTab.hasSearchBar()) {
|
||||
}
|
||||
|
||||
- if (selectedTab.getType() != CreativeModeTab.Type.SEARCH) {
|
||||
+ if (!selectedTab.hasSearchBar()) {
|
||||
return false;
|
||||
} else {
|
||||
String oldContents = this.searchBox.getValue();
|
||||
@@ -405,7 +_,7 @@
|
||||
}
|
||||
|
||||
@@ -407,7 +_,7 @@
|
||||
@Override
|
||||
public boolean keyPressed(KeyEvent event) {
|
||||
this.ignoreTextInput = false;
|
||||
@@ -86,7 +86,7 @@
|
||||
if (this.minecraft.options.keyChat.matches(event)) {
|
||||
this.ignoreTextInput = true;
|
||||
this.selectTab(CreativeModeTabs.searchTab());
|
||||
@@ -441,6 +_,7 @@
|
||||
@@ -443,6 +_,7 @@
|
||||
}
|
||||
|
||||
private void refreshSearchResults() {
|
||||
@@ -94,7 +94,7 @@
|
||||
this.menu.items.clear();
|
||||
this.visibleTags.clear();
|
||||
String searchTerm = this.searchBox.getValue();
|
||||
@@ -453,10 +_,10 @@
|
||||
@@ -455,10 +_,10 @@
|
||||
SearchTree<ItemStack> tree;
|
||||
if (searchTerm.startsWith("#")) {
|
||||
searchTerm = searchTerm.substring(1);
|
||||
@@ -107,7 +107,7 @@
|
||||
}
|
||||
|
||||
this.menu.items.addAll(tree.search(searchTerm.toLowerCase(Locale.ROOT)));
|
||||
@@ -484,7 +_,7 @@
|
||||
@@ -486,7 +_,7 @@
|
||||
@Override
|
||||
protected void extractLabels(GuiGraphicsExtractor graphics, int xm, int ym) {
|
||||
if (selectedTab.showTitle()) {
|
||||
@@ -116,7 +116,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,7 +_,7 @@
|
||||
@@ -496,7 +_,7 @@
|
||||
double xm = event.x() - this.leftPos;
|
||||
double ym = event.y() - this.topPos;
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
if (this.checkTabClicked(tab, xm, ym)) {
|
||||
return true;
|
||||
}
|
||||
@@ -516,7 +_,7 @@
|
||||
@@ -518,7 +_,7 @@
|
||||
double ym = event.y() - this.topPos;
|
||||
this.scrolling = false;
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
if (this.checkTabClicked(tab, xm, ym)) {
|
||||
this.selectTab(tab);
|
||||
return true;
|
||||
@@ -610,13 +_,15 @@
|
||||
@@ -611,13 +_,15 @@
|
||||
this.originalSlots = null;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
|
||||
this.refreshSearchResults();
|
||||
} else {
|
||||
@@ -679,8 +_,14 @@
|
||||
@@ -682,8 +_,14 @@
|
||||
this.effects.extractRenderState(graphics, mouseX, mouseY);
|
||||
super.extractRenderState(graphics, mouseX, mouseY, a);
|
||||
|
||||
@@ -168,7 +168,7 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -701,10 +_,10 @@
|
||||
@@ -704,10 +_,10 @@
|
||||
public List<Component> getTooltipFromContainerItem(ItemStack itemStack) {
|
||||
boolean isCreativeSlot = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot;
|
||||
boolean isSingleCategoryTab = selectedTab.getType() == CreativeModeTab.Type.CATEGORY;
|
||||
@@ -180,17 +180,17 @@
|
||||
+ List<Component> originalLines = itemStack.getTooltipLines(Item.TooltipContext.of(this.minecraft.level, this.minecraft.player), this.minecraft.player, net.neoforged.neoforge.client.ClientTooltipFlag.of(tooltipStyle));
|
||||
if (originalLines.isEmpty()) {
|
||||
return originalLines;
|
||||
} else if (isSingleCategoryTab && isCreativeSlot) {
|
||||
@@ -722,7 +_,7 @@
|
||||
int i = 1;
|
||||
}
|
||||
@@ -728,7 +_,7 @@
|
||||
int i = 1;
|
||||
|
||||
for (CreativeModeTab tab : CreativeModeTabs.tabs()) {
|
||||
- if (tab.getType() != CreativeModeTab.Type.SEARCH && tab.contains(itemStack)) {
|
||||
+ if (!tab.hasSearchBar() && tab.contains(itemStack)) {
|
||||
linesToDisplay.add(i++, tab.getDisplayName().copy().withStyle(ChatFormatting.BLUE));
|
||||
}
|
||||
for (CreativeModeTab tab : CreativeModeTabs.tabs()) {
|
||||
- if (tab.getType() != CreativeModeTab.Type.SEARCH && tab.contains(itemStack)) {
|
||||
+ if (!tab.hasSearchBar() && tab.contains(itemStack)) {
|
||||
linesToDisplay.add(i++, tab.getDisplayName().copy().withStyle(ChatFormatting.BLUE));
|
||||
}
|
||||
@@ -735,7 +_,7 @@
|
||||
}
|
||||
@@ -740,7 +_,7 @@
|
||||
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
|
||||
super.extractBackground(graphics, mouseX, mouseY, a);
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
if (tab != selectedTab) {
|
||||
this.extractTabButton(graphics, mouseX, mouseY, tab);
|
||||
}
|
||||
@@ -766,10 +_,11 @@
|
||||
@@ -771,10 +_,11 @@
|
||||
int yscr = this.topPos + 18;
|
||||
int yscr2 = yscr + 112;
|
||||
if (selectedTab.canScroll()) {
|
||||
@@ -213,7 +213,7 @@
|
||||
this.extractTabButton(graphics, mouseX, mouseY, selectedTab);
|
||||
if (selectedTab.getType() == CreativeModeTab.Type.INVENTORY) {
|
||||
InventoryScreen.extractEntityInInventoryFollowsMouse(
|
||||
@@ -779,7 +_,7 @@
|
||||
@@ -784,7 +_,7 @@
|
||||
}
|
||||
|
||||
private int getTabX(CreativeModeTab tab) {
|
||||
@@ -222,7 +222,7 @@
|
||||
int spacing = 27;
|
||||
int x = 27 * pos;
|
||||
if (tab.isAlignedRight()) {
|
||||
@@ -791,7 +_,7 @@
|
||||
@@ -796,7 +_,7 @@
|
||||
|
||||
private int getTabY(CreativeModeTab tab) {
|
||||
int y = 0;
|
||||
@@ -231,7 +231,7 @@
|
||||
y -= 32;
|
||||
} else {
|
||||
y += this.imageHeight;
|
||||
@@ -819,8 +_,8 @@
|
||||
@@ -824,8 +_,8 @@
|
||||
|
||||
protected void extractTabButton(GuiGraphicsExtractor graphics, int mouseX, int mouseY, CreativeModeTab tab) {
|
||||
boolean selected = tab == selectedTab;
|
||||
@@ -242,7 +242,7 @@
|
||||
int x = this.leftPos + this.getTabX(tab);
|
||||
int y = this.topPos - (isTop ? 28 : -(this.imageHeight - 4));
|
||||
Identifier[] sprites;
|
||||
@@ -834,6 +_,7 @@
|
||||
@@ -839,6 +_,7 @@
|
||||
graphics.requestCursor(CursorTypes.POINTING_HAND);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@
|
||||
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, sprites[Mth.clamp(pos, 0, sprites.length)], x, y, 26, 32);
|
||||
int iconX = x + 13 - 8;
|
||||
int iconY = y + 16 - 8 + (isTop ? 1 : -1);
|
||||
@@ -870,6 +_,14 @@
|
||||
@@ -875,6 +_,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,10 +262,10 @@
|
||||
+ this.currentPage = currentPage;
|
||||
+ }
|
||||
+
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static class CustomCreativeSlot extends Slot {
|
||||
public CustomCreativeSlot(Container container, int slot, int x, int y) {
|
||||
@@ -1050,6 +_,22 @@
|
||||
super(container, slot, x, y);
|
||||
@@ -1052,6 +_,22 @@
|
||||
@Override
|
||||
public boolean mayPickup(Player player) {
|
||||
return this.target.mayPickup(player);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
+ if (!renderer.renderInventoryText(effect, screen, graphics, x0, y0, 0))
|
||||
+ this.renderText(graphics, effectText, duration, font, x0, y0, textureWidth, yStep, mouseX, mouseY, effect);
|
||||
+ if (!renderer.renderInventoryIcon(effect, screen, graphics, x0 + 7, y0, 0))
|
||||
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, Gui.getMobEffectSprite(effect.getEffect()), x0 + 7, y0 + 7, 18, 18);
|
||||
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, Hud.getMobEffectSprite(effect.getEffect()), x0 + 7, y0 + 7, 18, 18);
|
||||
y0 += yStep;
|
||||
}
|
||||
@@ -85,9 +_,15 @@
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/inventory/HangingSignEditScreen.java
|
||||
@@ -15,7 +_,7 @@
|
||||
private static final Vector3f TEXT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F);
|
||||
@@ -16,7 +_,7 @@
|
||||
private static final Vector3fc TEXT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F);
|
||||
private static final int TEXTURE_WIDTH = 16;
|
||||
private static final int TEXTURE_HEIGHT = 16;
|
||||
- private final Identifier texture = Identifier.withDefaultNamespace("textures/gui/hanging_signs/" + this.woodType.name() + ".png");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/screens/inventory/InventoryScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/inventory/InventoryScreen.java
|
||||
@@ -109,6 +_,13 @@
|
||||
@@ -111,6 +_,13 @@
|
||||
float centerY = (y0 + y1) / 2.0F;
|
||||
float xAngle = (float)Math.atan((centerX - mouseX) / 40.0F);
|
||||
float yAngle = (float)Math.atan((centerY - mouseY) / 40.0F);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/screens/inventory/MerchantScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/inventory/MerchantScreen.java
|
||||
@@ -234,7 +_,11 @@
|
||||
@@ -233,7 +_,11 @@
|
||||
graphics.itemDecorations(this.font, costA, sellItem1X, decorHeight);
|
||||
} else {
|
||||
graphics.itemDecorations(this.font, baseCostA, sellItem1X, decorHeight, baseCostA.getCount() == 1 ? "1" : null);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/client/gui/screens/inventory/SignEditScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/inventory/SignEditScreen.java
|
||||
@@ -19,7 +_,7 @@
|
||||
private static final int POST_HEIGHT = 14;
|
||||
private static final Vector3fc TEXT_SCALE = new Vector3f(0.9765628F, 0.9765628F, 0.9765628F);
|
||||
private final int displayedHeight;
|
||||
- private final Identifier texture = Identifier.withDefaultNamespace("textures/gui/signs/" + this.woodType.name() + ".png");
|
||||
+ private final Identifier texture = Identifier.parse(this.woodType.name() + ".png").withPrefix("textures/gui/signs/");
|
||||
|
||||
public SignEditScreen(SignBlockEntity sign, boolean isFrontText, boolean shouldFilter) {
|
||||
super(sign, isFrontText, shouldFilter);
|
||||
+6
-4
@@ -1,15 +1,17 @@
|
||||
--- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java
|
||||
+++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java
|
||||
@@ -18,7 +_,11 @@
|
||||
return (ClientTooltipComponent)(switch (component) {
|
||||
@@ -18,7 +_,13 @@
|
||||
return switch (component) {
|
||||
case BundleTooltip bundleTooltip -> new ClientBundleTooltip(bundleTooltip.contents());
|
||||
case ClientActivePlayersTooltip.ActivePlayersTooltip activePlayersTooltip -> new ClientActivePlayersTooltip(activePlayersTooltip);
|
||||
- default -> throw new IllegalArgumentException("Unknown TooltipComponent");
|
||||
+ default -> {
|
||||
+ ClientTooltipComponent result = net.neoforged.neoforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(component);
|
||||
+ if (result != null) yield result;
|
||||
+ if (result != null) {
|
||||
+ yield result;
|
||||
+ }
|
||||
+ throw new IllegalArgumentException("Unknown TooltipComponent");
|
||||
+ }
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
|
||||
+++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
|
||||
@@ -40,7 +_,7 @@
|
||||
@@ -39,7 +_,7 @@
|
||||
this.addEntry(new KeyBindsList.CategoryEntry(category));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
int width = minecraft.font.width(name);
|
||||
if (width > this.maxNameWidth) {
|
||||
this.maxNameWidth = width;
|
||||
@@ -132,6 +_,7 @@
|
||||
@@ -123,6 +_,7 @@
|
||||
)
|
||||
.build();
|
||||
this.resetButton = Button.builder(RESET_BUTTON_TITLE, button -> {
|
||||
@@ -17,7 +17,7 @@
|
||||
key.setKey(key.getDefaultKey());
|
||||
KeyBindsList.this.resetMappingAndUpdateButtons();
|
||||
}).bounds(0, 0, 50, 20).createNarration(defaultNarrationSupplier -> Component.translatable("narrator.controls.reset", name)).build();
|
||||
@@ -173,13 +_,13 @@
|
||||
@@ -164,13 +_,13 @@
|
||||
MutableComponent tooltip = Component.empty();
|
||||
if (!this.key.isUnbound()) {
|
||||
for (KeyMapping otherKey : KeyBindsList.this.minecraft.options.keyMappings) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/screens/packs/PackSelectionModel.java
|
||||
+++ b/net/minecraft/client/gui/screens/packs/PackSelectionModel.java
|
||||
@@ -34,9 +_,9 @@
|
||||
@@ -33,9 +_,9 @@
|
||||
this.onListChanged = onListChanged;
|
||||
this.iconGetter = iconGetter;
|
||||
this.repository = repository;
|
||||
@@ -12,7 +12,7 @@
|
||||
this.unselected.removeAll(this.selected);
|
||||
this.output = output;
|
||||
}
|
||||
@@ -62,7 +_,7 @@
|
||||
@@ -61,7 +_,7 @@
|
||||
this.repository.reload();
|
||||
this.selected.retainAll(this.repository.getAvailablePacks());
|
||||
this.unselected.clear();
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java
|
||||
+++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java
|
||||
@@ -171,6 +_,7 @@
|
||||
@@ -169,6 +_,7 @@
|
||||
queueLoadScreen(minecraft, PREPARING_WORLD_DATA);
|
||||
long start = Util.getMillis();
|
||||
PackRepository vanillaOnlyPackRepository = new PackRepository(new ServerPacksSource(minecraft.directoryValidator()));
|
||||
@@ -8,7 +8,7 @@
|
||||
WorldDataConfiguration dataConfig = SharedConstants.IS_RUNNING_IN_IDE
|
||||
? new WorldDataConfiguration(new DataPackConfig(List.of("vanilla", "tests"), List.of()), FeatureFlags.DEFAULT_FLAGS)
|
||||
: WorldDataConfiguration.DEFAULT;
|
||||
@@ -331,6 +_,10 @@
|
||||
@@ -329,6 +_,10 @@
|
||||
SystemToast.onPackCopyFailure(this.minecraft, worldFolder);
|
||||
return false;
|
||||
} else {
|
||||
@@ -19,7 +19,7 @@
|
||||
this.minecraft
|
||||
.createWorldOpenFlows()
|
||||
.createLevelFromExistingSettings(newWorldAccess.get(), context.dataPackResources(), finalLayers, worldDataAndGenSettings, gameRules);
|
||||
@@ -501,7 +_,7 @@
|
||||
@@ -504,7 +_,7 @@
|
||||
if (retry) {
|
||||
onAbort.accept(this.uiState.getSettings().dataConfiguration());
|
||||
} else {
|
||||
@@ -28,7 +28,7 @@
|
||||
}
|
||||
},
|
||||
Component.translatable("dataPack.validation.failed"),
|
||||
@@ -615,6 +_,7 @@
|
||||
@@ -613,6 +_,7 @@
|
||||
if (dataPackDir != null) {
|
||||
if (this.tempDataPackRepository == null) {
|
||||
this.tempDataPackRepository = ServerPacksSource.createPackRepository(dataPackDir, this.packValidator);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java
|
||||
+++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java
|
||||
@@ -227,7 +_,7 @@
|
||||
@@ -237,7 +_,7 @@
|
||||
|
||||
public @Nullable PresetEditor getPresetEditor() {
|
||||
Holder<WorldPreset> preset = this.getWorldType().preset();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
|
||||
+++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
|
||||
@@ -255,7 +_,9 @@
|
||||
@@ -254,7 +_,9 @@
|
||||
backupWarning = Component.translatable("selectWorld.backupWarning.customized");
|
||||
} else {
|
||||
backupQuestion = Component.translatable("selectWorld.backupQuestion.experimental");
|
||||
@@ -11,15 +11,15 @@
|
||||
}
|
||||
|
||||
this.minecraft
|
||||
@@ -314,6 +_,7 @@
|
||||
@@ -318,6 +_,7 @@
|
||||
try {
|
||||
levelDataTag = worldAccess.getUnfixedDataTag(false);
|
||||
summary = worldAccess.fixAndGetSummaryFromTag(levelDataTag);
|
||||
+ worldAccess.readAdditionalLevelSaveData(false);
|
||||
} catch (NbtException | ReportedNbtException | IOException var10) {
|
||||
this.minecraft.setScreen(new RecoverWorldDataScreen(this.minecraft, success -> {
|
||||
} catch (IOException | NbtException | ReportedNbtException e) {
|
||||
this.minecraft.gui.setScreen(new RecoverWorldDataScreen(this.minecraft, success -> {
|
||||
if (success) {
|
||||
@@ -518,11 +_,20 @@
|
||||
@@ -524,11 +_,20 @@
|
||||
WorldData data = worldDataAndGenSettings.data();
|
||||
boolean oldCustomized = worldDataAndGenSettings.genSettings().options().isOldCustomizedWorld();
|
||||
boolean unstable = data.worldGenSettingsLifecycle() != Lifecycle.stable();
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java
|
||||
+++ b/net/minecraft/client/gui/screens/worldselection/WorldSelectionList.java
|
||||
@@ -83,6 +_,7 @@
|
||||
@@ -82,6 +_,7 @@
|
||||
private static final Identifier WARNING_SPRITE = Identifier.withDefaultNamespace("world_list/warning");
|
||||
private static final Identifier JOIN_HIGHLIGHTED_SPRITE = Identifier.withDefaultNamespace("world_list/join_highlighted");
|
||||
private static final Identifier JOIN_SPRITE = Identifier.withDefaultNamespace("world_list/join");
|
||||
@@ -8,15 +8,15 @@
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final Component FROM_NEWER_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.fromNewerVersion1").withStyle(ChatFormatting.RED);
|
||||
private static final Component FROM_NEWER_TOOLTIP_2 = Component.translatable("selectWorld.tooltip.fromNewerVersion2").withStyle(ChatFormatting.RED);
|
||||
@@ -515,6 +_,7 @@
|
||||
@@ -506,6 +_,7 @@
|
||||
this.infoText.setPosition(textX, this.getContentY() + 9 + 9 + 3);
|
||||
this.infoText.extractRenderState(graphics, mouseX, mouseY, a);
|
||||
graphics.blit(RenderPipelines.GUI_TEXTURED, this.icon.textureLocation(), this.getContentX(), this.getContentY(), 0.0F, 0.0F, 32, 32, 32, 32);
|
||||
+ renderExperimentalWarning(graphics, mouseX, mouseY, hovered);
|
||||
if (this.list.entryType == WorldSelectionList.EntryType.SINGLEPLAYER && (this.minecraft.options.touchscreen().get() || hovered)) {
|
||||
if (this.list.entryType == WorldSelectionList.EntryType.SINGLEPLAYER && hovered) {
|
||||
graphics.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544);
|
||||
int relX = mouseX - this.getContentX();
|
||||
@@ -779,6 +_,19 @@
|
||||
@@ -775,6 +_,19 @@
|
||||
@Override
|
||||
public LevelSummary getLevelSummary() {
|
||||
return this.summary;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/main/Main.java
|
||||
+++ b/net/minecraft/client/main/Main.java
|
||||
@@ -74,12 +_,13 @@
|
||||
@@ -99,12 +_,13 @@
|
||||
OptionSpec<Integer> proxyPortOption = parser.accepts("proxyPort").withRequiredArg().defaultsTo("8080").ofType(Integer.class);
|
||||
OptionSpec<String> proxyUserOption = parser.accepts("proxyUser").withRequiredArg();
|
||||
OptionSpec<String> proxyPassOption = parser.accepts("proxyPass").withRequiredArg();
|
||||
@@ -16,7 +16,7 @@
|
||||
OptionSpec<String> versionOption = parser.accepts("version").withRequiredArg().required();
|
||||
OptionSpec<Integer> widthOption = parser.accepts("width").withRequiredArg().ofType(Integer.class).defaultsTo(854);
|
||||
OptionSpec<Integer> heightOption = parser.accepts("height").withRequiredArg().ofType(Integer.class).defaultsTo(480);
|
||||
@@ -114,10 +_,12 @@
|
||||
@@ -159,10 +_,12 @@
|
||||
CrashReport.preload();
|
||||
logger = LogUtils.getLogger();
|
||||
stage = "Bootstrap";
|
||||
@@ -31,24 +31,24 @@
|
||||
stage = "Argument parsing";
|
||||
List<String> leftoverArgs = optionSet.valuesOf(nonOption);
|
||||
if (!leftoverArgs.isEmpty()) {
|
||||
@@ -186,7 +_,8 @@
|
||||
disableChat,
|
||||
captureTracyImages,
|
||||
@@ -235,7 +_,8 @@
|
||||
vulkanValidation,
|
||||
renderDebugLabels,
|
||||
forcedGraphicsApi,
|
||||
- optionSet.has(offlineDeveloperMode)
|
||||
+ // Neo: Auto-enable offlineDeveloperMode if no accessToken is passed in dev
|
||||
+ optionSet.has(offlineDeveloperMode) || !optionSet.has(accessTokenOption)
|
||||
),
|
||||
new GameConfig.QuickPlayData(quickPlayLogPath, quickPlayVariant)
|
||||
);
|
||||
@@ -197,7 +_,11 @@
|
||||
@@ -246,7 +_,11 @@
|
||||
CrashReportCategory initialization = report.addCategory("Initialization");
|
||||
NativeModuleLister.addCrashSection(initialization);
|
||||
Minecraft.fillReport(null, null, launchedVersion, null, report);
|
||||
- Minecraft.crash(null, gameDir, report);
|
||||
- Minecraft.crash(null, gameDir, report, -1);
|
||||
+ // Neo: Instead of crash(...), we show the error immediately using our earlydisplay GUI
|
||||
+ int exitCode = Minecraft.saveReport(gameDir, report);
|
||||
+ net.neoforged.neoforge.client.loading.ClientModLoader.reportFatalError(var75, gameDir.toPath(), report);
|
||||
+ int exitCode = Minecraft.saveReport(gameDir, report, -1);
|
||||
+ net.neoforged.neoforge.client.loading.ClientModLoader.reportFatalError(t, gameDir.toPath(), report);
|
||||
+ System.exit(exitCode);
|
||||
+ // Neo: Rethrow to let early error screen handle it
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/model/HumanoidModel.java
|
||||
+++ b/net/minecraft/client/model/HumanoidModel.java
|
||||
@@ -389,6 +_,9 @@
|
||||
@@ -391,6 +_,9 @@
|
||||
break;
|
||||
case SPEAR:
|
||||
SpearAnimations.thirdPersonHandUse(this.rightArm, this.head, true, state.getUseItemStackForArm(HumanoidArm.RIGHT), state);
|
||||
@@ -10,7 +10,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,6 +_,9 @@
|
||||
@@ -436,6 +_,9 @@
|
||||
break;
|
||||
case SPEAR:
|
||||
SpearAnimations.thirdPersonHandUse(this.leftArm, this.head, false, state.getUseItemStackForArm(HumanoidArm.LEFT), state);
|
||||
@@ -20,14 +20,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,9 +_,20 @@
|
||||
@@ -519,9 +_,20 @@
|
||||
private final boolean twoHanded;
|
||||
private final boolean affectsOffhandPose;
|
||||
|
||||
+ private final [email protected] IArmPoseTransformer forgeArmPose;
|
||||
+
|
||||
+ @net.neoforged.fml.common.asm.enumextension.ReservedConstructor
|
||||
private ArmPose(boolean twoHanded, boolean affectsOffhandPose) {
|
||||
ArmPose(boolean twoHanded, boolean affectsOffhandPose) {
|
||||
this.twoHanded = twoHanded;
|
||||
this.affectsOffhandPose = affectsOffhandPose;
|
||||
+ this.forgeArmPose = null;
|
||||
@@ -41,7 +41,7 @@
|
||||
}
|
||||
|
||||
public boolean isTwoHanded() {
|
||||
@@ -529,6 +_,14 @@
|
||||
@@ -530,6 +_,14 @@
|
||||
|
||||
public boolean affectsOffhandPose() {
|
||||
return this.affectsOffhandPose;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
--- a/net/minecraft/client/model/geom/LayerDefinitions.java
|
||||
+++ b/net/minecraft/client/model/geom/LayerDefinitions.java
|
||||
@@ -569,6 +_,7 @@
|
||||
result.put(ModelLayers.createHangingSignModelName(woodType, attachmentType), hangingSignModel);
|
||||
}
|
||||
});
|
||||
@@ -557,6 +_,7 @@
|
||||
result.put(ModelLayers.PALE_OAK_CHEST_BOAT, chestBoatModel);
|
||||
result.put(ModelLayers.MANGROVE_BOAT, boatModel);
|
||||
result.put(ModelLayers.MANGROVE_CHEST_BOAT, chestBoatModel);
|
||||
+ net.neoforged.neoforge.client.ClientHooks.loadLayerDefinitions(result);
|
||||
ImmutableMap<ModelLayerLocation, LayerDefinition> definitions = result.build();
|
||||
List<ModelLayerLocation> missingDefinitions = ModelLayers.getKnownLocations().filter(l -> !definitions.containsKey(l)).toList();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user