Compare commits

...
9 Commits
431 changed files with 4728 additions and 4764 deletions

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ org.gradle.parallel=true
JAVA_VERSION=25 JAVA_VERSION=25
MC_VERSION=26.1 MC_VERSION=26.1
MC_NEXT_VERSION=26.2 MC_NEXT_VERSION=26.2
MCP_VERSION=20260324.123823 MCP_VERSION=20260326.105027
MAPPING_CHANNEL=official MAPPING_CHANNEL=official
MAPPING_VERSION=26.1 MAPPING_VERSION=26.1
+1 -3
View File
@@ -6,7 +6,7 @@ plugins {
id 'java' id 'java'
id 'idea' id 'idea'
id 'eclipse' id 'eclipse'
id 'net.minecraftforge.gradle' version '[7.0.3,8)' id 'net.minecraftforge.gradle' version '[7.0.17,8)'
} }
version = '1.0.0' version = '1.0.0'
@@ -19,8 +19,6 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(25)
sourceSets.main.resources { srcDir 'src/generated/resources' } sourceSets.main.resources { srcDir 'src/generated/resources' }
minecraft { minecraft {
mappings channel: 'official', version: '@MC_VERSION@'
runs { runs {
configureEach { configureEach {
workingDir = layout.projectDirectory.dir('run') workingDir = layout.projectDirectory.dir('run')
@@ -18,14 +18,14 @@
@@ -103,6 +_,8 @@ @@ -103,6 +_,8 @@
} }
LOGGER.info("OpenGL debug message: {}", gldebug$logentry); LOGGER.info("OpenGL debug message: {}", entry);
+ // TODO: [VEN] Trim the stack trace + // TODO: [VEN] Trim the stack trace
+ if (PRINT_STACKTRACE_ON_ERROR) LOGGER.info("Trace: ", new Throwable("GlDebug")); + if (PRINT_STACKTRACE_ON_ERROR) LOGGER.info("Trace: ", new Throwable("GlDebug"));
} }
public List<String> getLastOpenGlDebugMessages() { public List<String> getLastOpenGlDebugMessages() {
@@ -126,7 +_,7 @@ @@ -126,7 +_,7 @@
GlDebug gldebug1 = new GlDebug(); GlDebug debug = new GlDebug();
enabledExtensions.add("GL_KHR_debug"); enabledExtensions.add("GL_KHR_debug");
GL11.glEnable(37600); GL11.glEnable(37600);
- if (debugSynchronousGlLogs) { - if (debugSynchronousGlLogs) {
@@ -34,8 +34,8 @@
} }
@@ -140,7 +_,7 @@ @@ -140,7 +_,7 @@
} else if (glcapabilities.GL_ARB_debug_output && GlDevice.USE_GL_ARB_debug_output) { } else if (caps.GL_ARB_debug_output && GlDevice.USE_GL_ARB_debug_output) {
GlDebug gldebug = new GlDebug(); GlDebug debug = new GlDebug();
enabledExtensions.add("GL_ARB_debug_output"); enabledExtensions.add("GL_ARB_debug_output");
- if (debugSynchronousGlLogs) { - if (debugSynchronousGlLogs) {
+ if (debugSynchronousGlLogs | PRINT_STACKTRACE_ON_ERROR) { + if (debugSynchronousGlLogs | PRINT_STACKTRACE_ON_ERROR) {
@@ -24,31 +24,39 @@
+ @Override + @Override
+ public GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage final int usage, final TextureFormat format, final int width, final int height, final int depthOrLayers, final int mipLevels, boolean stencil) { + public GpuTexture createTexture(@Nullable String label, @GpuTexture.Usage final int usage, final TextureFormat format, final int width, final int height, final int depthOrLayers, final int mipLevels, boolean stencil) {
GlStateManager.clearGlErrors(); GlStateManager.clearGlErrors();
int i = GlStateManager._genTexture(); int id = GlStateManager._genTexture();
if (label == null) { if (label == null) {
@@ -169,14 +_,14 @@ @@ -171,12 +_,12 @@
for (int k : GlConst.CUBEMAP_TARGETS) {
for (int l = 0; l < mipLevels; l++) {
GlStateManager._texImage2D( GlStateManager._texImage2D(
- k, l, GlConst.toGlInternalId(format), width >> l, height >> l, 0, GlConst.toGlExternalId(format), GlConst.toGlType(format), null cubeTarget,
+ k, l, GlConst.toGlInternalId(format, stencil), width >> l, height >> l, 0, GlConst.toGlExternalId(format, stencil), GlConst.toGlType(format, stencil), null i,
- GlConst.toGlInternalId(format),
+ GlConst.toGlInternalId(format, stencil),
width >> i,
height >> i,
0,
- GlConst.toGlExternalId(format),
- GlConst.toGlType(format),
+ GlConst.toGlExternalId(format, stencil),
+ GlConst.toGlType(format, stencil),
null
); );
} }
} @@ -184,7 +_,7 @@
} else { } else {
for (int i1 = 0; i1 < mipLevels; i1++) { for (int i = 0; i < mipLevels; i++) {
GlStateManager._texImage2D( GlStateManager._texImage2D(
- j, i1, GlConst.toGlInternalId(format), width >> i1, height >> i1, 0, GlConst.toGlExternalId(format), GlConst.toGlType(format), null - target, i, GlConst.toGlInternalId(format), width >> i, height >> i, 0, GlConst.toGlExternalId(format), GlConst.toGlType(format), null
+ j, i1, GlConst.toGlInternalId(format, stencil), width >> i1, height >> i1, 0, GlConst.toGlExternalId(format, stencil), GlConst.toGlType(format, stencil), null + target, i, GlConst.toGlInternalId(format, stencil), width >> i, height >> i, 0, GlConst.toGlExternalId(format, stencil), GlConst.toGlType(format, stencil), null
); );
} }
} }
@@ -187,7 +_,7 @@ @@ -195,7 +_,7 @@
} else if (j1 != 0) { } else if (error != 0) {
throw new IllegalStateException("OpenGL error " + j1); throw new IllegalStateException("OpenGL error " + error);
} else { } else {
- GlTexture gltexture = new GlTexture(usage, label, format, width, height, depthOrLayers, mipLevels, i); - GlTexture texture = new GlTexture(usage, label, format, width, height, depthOrLayers, mipLevels, id);
+ GlTexture gltexture = new GlTexture(usage, label, format, width, height, depthOrLayers, mipLevels, i, stencil); + GlTexture texture = new GlTexture(usage, label, format, width, height, depthOrLayers, mipLevels, id, stencil);
this.debugLabels.applyLabel(gltexture); this.debugLabels.applyLabel(texture);
return gltexture; return texture;
} }
@@ -4,9 +4,9 @@
this.width = width; this.width = width;
this.height = height; this.height = height;
if (this.useDepth) { if (this.useDepth) {
- this.depthTexture = gpudevice.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, width, height, 1, 1); - this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, width, height, 1, 1);
+ this.depthTexture = gpudevice.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, width, height, 1, 1, this.stencilEnabled); + this.depthTexture = device.createTexture(() -> this.label + " / Depth", 15, TextureFormat.DEPTH32, width, height, 1, 1, this.stencilEnabled);
this.depthTextureView = gpudevice.createTextureView(this.depthTexture); this.depthTextureView = device.createTextureView(this.depthTexture);
} }
@@ -124,5 +_,26 @@ @@ -124,5 +_,26 @@
@@ -1,28 +1,28 @@
--- a/com/mojang/blaze3d/platform/Window.java --- a/com/mojang/blaze3d/platform/Window.java
+++ b/com/mojang/blaze3d/platform/Window.java +++ b/com/mojang/blaze3d/platform/Window.java
@@ -97,8 +_,9 @@ @@ -97,8 +_,9 @@
Monitor monitor = this.screenManager.getMonitor(GLFW.glfwGetPrimaryMonitor()); Monitor initialMonitor = this.screenManager.getMonitor(GLFW.glfwGetPrimaryMonitor());
this.windowedWidth = this.width = allowedWindowMinSize(displayData.width()); this.windowedWidth = this.width = allowedWindowMinSize(displayData.width());
this.windowedHeight = this.height = allowedWindowMinSize(displayData.height()); this.windowedHeight = this.height = allowedWindowMinSize(displayData.height());
- this.handle = this.createWindow(backend, this.width, this.height, title, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L); - this.handle = this.createWindow(backend, this.width, this.height, title, this.fullscreen && initialMonitor != null ? initialMonitor.getMonitor() : 0L);
+ this.handle = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(this.width, this.height, title, this.fullscreen && monitor != null ? monitor.getMonitor() : 0L, () -> backend); + this.handle = net.minecraftforge.fml.loading.ImmediateWindowHandler.setupMinecraftWindow(this.width, this.height, title, this.fullscreen && initialMonitor != null ? initialMonitor.getMonitor() : 0L, () -> backend);
this.backend = backend; this.backend = backend;
+ if (!net.minecraftforge.fml.loading.ImmediateWindowHandler.positionWindow(Optional.ofNullable(monitor), w->this.width = this.windowedWidth = w, h->this.height = this.windowedHeight = h, x->this.x = this.windowedX = x, y->this.y = this.windowedY = y)) { + if (!net.minecraftforge.fml.loading.ImmediateWindowHandler.positionWindow(Optional.ofNullable(initialMonitor), w->this.width = this.windowedWidth = w, h->this.height = this.windowedHeight = h, x->this.x = this.windowedX = x, y->this.y = this.windowedY = y)) {
if (monitor != null) { if (initialMonitor != null) {
VideoMode videomode = monitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty()); VideoMode mode = initialMonitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty());
this.windowedX = this.x = monitor.getX() + videomode.getWidth() / 2 - this.width / 2; this.windowedX = this.x = initialMonitor.getX() + mode.getWidth() / 2 - this.width / 2;
@@ -110,6 +_,7 @@ @@ -110,6 +_,7 @@
this.windowedX = this.x = aint1[0]; this.windowedX = this.x = actualX[0];
this.windowedY = this.y = aint[0]; this.windowedY = this.y = actualY[0];
} }
+ } + }
this.setMode(); this.setMode();
this.refreshFramebufferSize(); this.refreshFramebufferSize();
@@ -300,6 +_,9 @@ @@ -300,6 +_,9 @@
GLFW.glfwGetFramebufferSize(this.handle, aint, aint1); GLFW.glfwGetFramebufferSize(this.handle, outWidth, outHeight);
this.framebufferWidth = aint[0] > 0 ? aint[0] : 1; this.framebufferWidth = outWidth[0] > 0 ? outWidth[0] : 1;
this.framebufferHeight = aint1[0] > 0 ? aint1[0] : 1; this.framebufferHeight = outHeight[0] > 0 ? outHeight[0] : 1;
+ if (this.framebufferHeight == 0 || this.framebufferWidth == 0) { + if (this.framebufferHeight == 0 || this.framebufferWidth == 0) {
+ net.minecraftforge.fml.loading.ImmediateWindowHandler.updateFBSize(w -> this.framebufferWidth = w, h -> this.framebufferHeight = h); + net.minecraftforge.fml.loading.ImmediateWindowHandler.updateFBSize(w -> this.framebufferWidth = w, h -> this.framebufferHeight = h);
+ } + }
@@ -9,8 +9,8 @@
private VertexFormat(final List<VertexFormatElement> elements, final List<String> names, final IntList offsets, final int vertexSize) { private VertexFormat(final List<VertexFormatElement> elements, final List<String> names, final IntList offsets, final int vertexSize) {
this.elements = elements; this.elements = elements;
@@ -41,6 +_,11 @@ @@ -41,6 +_,11 @@
int j = vertexformatelement != null ? elements.indexOf(vertexformatelement) : -1; int index = element != null ? elements.indexOf(element) : -1;
this.offsetsByElement[i] = j != -1 ? offsets.getInt(j) : -1; this.offsetsByElement[id] = index != -1 ? offsets.getInt(index) : -1;
} }
+ +
+ ImmutableMap.Builder<String, VertexFormatElement> elementMapping = ImmutableMap.builder(); + ImmutableMap.Builder<String, VertexFormatElement> elementMapping = ImmutableMap.builder();
@@ -1,6 +1,6 @@
--- a/com/mojang/math/Transformation.java --- a/com/mojang/math/Transformation.java
+++ b/com/mojang/math/Transformation.java +++ b/com/mojang/math/Transformation.java
@@ -17,7 +_,7 @@ @@ -16,7 +_,7 @@
import org.joml.Vector3fc; import org.joml.Vector3fc;
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
@@ -9,7 +9,7 @@
private static final Vector3fc ZERO_TRANSLATION = new Vector3f(); private static final Vector3fc ZERO_TRANSLATION = new Vector3f();
private static final Vector3fc UNIT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F); private static final Vector3fc UNIT_SCALE = new Vector3f(1.0F, 1.0F, 1.0F);
private static final Quaternionfc ZERO_ROTATION = new Quaternionf(); private static final Quaternionfc ZERO_ROTATION = new Quaternionf();
@@ -172,6 +_,20 @@ @@ -171,6 +_,20 @@
this.scale().lerp(that.scale(), progress, new Vector3f()), this.scale().lerp(that.scale(), progress, new Vector3f()),
this.rightRotation().slerp(that.rightRotation(), progress, new Quaternionf()) this.rightRotation().slerp(that.rightRotation(), progress, new Quaternionf())
); );
@@ -1,11 +1,11 @@
--- a/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java --- a/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java
+++ b/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java +++ b/com/mojang/realmsclient/gui/screens/RealmsResetWorldScreen.java
@@ -303,7 +_,7 @@ @@ -302,7 +_,7 @@
int k = this.getY(); int y = this.getY();
graphics.blit(RenderPipelines.GUI_TEXTURED, this.image, j + 2, k + 2, 0.0F, 0.0F, 56, 56, 56, 56, 56, 56, i); graphics.blit(RenderPipelines.GUI_TEXTURED, this.image, x + 2, y + 2, 0.0F, 0.0F, 56, 56, 56, 56, 56, 56, color);
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, SLOT_FRAME_SPRITE, j, k, 60, 60, i); graphics.blitSprite(RenderPipelines.GUI_TEXTURED, SLOT_FRAME_SPRITE, x, y, 60, 60, color);
- int l = flag ? -6250336 : -1; - int textColor = hoveredOrFocused ? -6250336 : -1;
+ int l = getFGColor(); + int textColor = getFGColor();
graphics.centeredText(RealmsResetWorldScreen.this.font, this.getMessage(), j + 28, k - 14, l); graphics.centeredText(RealmsResetWorldScreen.this.font, this.getMessage(), x + 28, y - 14, textColor);
} }
} }
@@ -6,8 +6,8 @@
builder.append("Thread: ").append(Thread.currentThread().getName()).append("\n"); builder.append("Thread: ").append(Thread.currentThread().getName()).append("\n");
- builder.append("Stacktrace:\n"); - builder.append("Stacktrace:\n");
- -
- for (StackTraceElement stacktraceelement : this.uncategorizedStackTrace) { - for (StackTraceElement element : this.uncategorizedStackTrace) {
- builder.append("\t").append("at ").append(stacktraceelement); - builder.append("\t").append("at ").append(element);
- builder.append("\n"); - builder.append("\n");
- } - }
- -
@@ -17,7 +17,7 @@
+ builder.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.uncategorizedStackTrace)); + builder.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.uncategorizedStackTrace));
} }
for (CrashReportCategory crashreportcategory : this.details) { for (CrashReportCategory entry : this.details) {
@@ -73,6 +_,7 @@ @@ -73,6 +_,7 @@
builder.append("\n\n"); builder.append("\n\n");
} }
@@ -27,22 +27,22 @@
} }
@@ -92,18 +_,7 @@ @@ -92,18 +_,7 @@
throwable.setStackTrace(this.exception.getStackTrace()); exception.setStackTrace(this.exception.getStackTrace());
} }
- String s; - String var4;
- try { - try {
- stringwriter = new StringWriter(); - writer = new StringWriter();
- printwriter = new PrintWriter(stringwriter); - printWriter = new PrintWriter(writer);
- throwable.printStackTrace(printwriter); - exception.printStackTrace(printWriter);
- s = stringwriter.toString(); - var4 = writer.toString();
- } finally { - } finally {
- IOUtils.closeQuietly((Writer)stringwriter); - IOUtils.closeQuietly((Writer)writer);
- IOUtils.closeQuietly((Writer)printwriter); - IOUtils.closeQuietly((Writer)printWriter);
- } - }
- -
- return s; - return var4;
+ return net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(throwable); + return net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(exception);
} }
public String getFriendlyReport(final ReportType reportType, final List<String> extraComments) { public String getFriendlyReport(final ReportType reportType, final List<String> extraComments) {
@@ -1,26 +1,26 @@
--- a/net/minecraft/CrashReportCategory.java --- a/net/minecraft/CrashReportCategory.java
+++ b/net/minecraft/CrashReportCategory.java +++ b/net/minecraft/CrashReportCategory.java
@@ -114,8 +_,10 @@ @@ -140,8 +_,10 @@
if (astacktraceelement.length <= 0) { if (full.length <= 0) {
return 0; return 0;
} else { } else {
- this.stackTrace = new StackTraceElement[astacktraceelement.length - 3 - nestedOffset]; - this.stackTrace = new StackTraceElement[full.length - 3 - nestedOffset];
- System.arraycopy(astacktraceelement, 3 + nestedOffset, this.stackTrace, 0, this.stackTrace.length); - System.arraycopy(full, 3 + nestedOffset, this.stackTrace, 0, this.stackTrace.length);
+ int len = astacktraceelement.length - 3 - nestedOffset; + int len = full.length - 3 - nestedOffset;
+ if (len <= 0) len = astacktraceelement.length; + if (len <= 0) len = full.length;
+ this.stackTrace = new StackTraceElement[len]; + this.stackTrace = new StackTraceElement[len];
+ System.arraycopy(astacktraceelement, astacktraceelement.length - len, this.stackTrace, 0, this.stackTrace.length); + System.arraycopy(full, full.length - len, this.stackTrace, 0, this.stackTrace.length);
return this.stackTrace.length; return this.stackTrace.length;
} }
} }
@@ -162,16 +_,16 @@ @@ -188,16 +_,16 @@
if (this.stackTrace != null && this.stackTrace.length > 0) { if (this.stackTrace != null && this.stackTrace.length > 0) {
builder.append("\nStacktrace:"); builder.append("\nStacktrace:");
- -
- for (StackTraceElement stacktraceelement : this.stackTrace) { - for (StackTraceElement element : this.stackTrace) {
- builder.append("\n\tat "); - builder.append("\n\tat ");
- builder.append(stacktraceelement); - builder.append(element);
- } - }
+ builder.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.stackTrace)); + builder.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.stackTrace));
} }
@@ -1,15 +1,15 @@
--- a/net/minecraft/advancements/Advancement.java --- a/net/minecraft/advancements/Advancement.java
+++ b/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java
@@ -227,7 +_,11 @@ @@ -219,7 +_,11 @@
} }
public AdvancementHolder save(final Consumer<AdvancementHolder> output, final String name) { public AdvancementHolder save(final Consumer<AdvancementHolder> output, final String name) {
- AdvancementHolder advancementholder = this.build(Identifier.parse(name)); - AdvancementHolder advancement = this.build(Identifier.parse(name));
+ return save(output, Identifier.parse(name)); + return save(output, Identifier.parse(name));
+ } + }
+ +
+ public AdvancementHolder save(Consumer<AdvancementHolder> output, Identifier id) { + public AdvancementHolder save(Consumer<AdvancementHolder> output, Identifier id) {
+ AdvancementHolder advancementholder = this.build(id); + AdvancementHolder advancement = this.build(id);
output.accept(advancementholder); output.accept(advancement);
return advancementholder; return advancement;
} }
@@ -1,10 +1,10 @@
--- a/net/minecraft/advancements/AdvancementRewards.java --- a/net/minecraft/advancements/AdvancementRewards.java
+++ b/net/minecraft/advancements/AdvancementRewards.java +++ b/net/minecraft/advancements/AdvancementRewards.java
@@ -44,6 +_,7 @@ @@ -43,6 +_,7 @@
LootParams lootparams = new LootParams.Builder(serverlevel) LootParams params = new LootParams.Builder(level)
.withParameter(LootContextParams.THIS_ENTITY, player) .withParameter(LootContextParams.THIS_ENTITY, player)
.withParameter(LootContextParams.ORIGIN, player.position()) .withParameter(LootContextParams.ORIGIN, player.position())
+ .withLuck(player.getLuck()) + .withLuck(player.getLuck())
.create(LootContextParamSets.ADVANCEMENT_REWARD); .create(LootContextParamSets.ADVANCEMENT_REWARD);
boolean flag = false; boolean changes = false;
@@ -3,9 +3,9 @@
@@ -217,12 +_,14 @@ @@ -217,12 +_,14 @@
return 90.0F; return 90.0F;
} else { } else {
float f = this.minecraft.options.fov().get().intValue() * Mth.lerp(partialTicks, this.oldFovModifier, this.fovModifier); float fov = this.minecraft.options.fov().get().intValue() * Mth.lerp(partialTicks, this.oldFovModifier, this.fovModifier);
- return this.modifyFovBasedOnDeathOrFluid(partialTicks, f); - return this.modifyFovBasedOnDeathOrFluid(partialTicks, fov);
+ var ret = this.modifyFovBasedOnDeathOrFluid(partialTicks, f); + var ret = this.modifyFovBasedOnDeathOrFluid(partialTicks, fov);
+ return net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeFov(this.minecraft.gameRenderer, this, partialTicks, ret, true).getFOV(); + return net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeFov(this.minecraft.gameRenderer, this, partialTicks, ret, true).getFOV();
} }
} }
@@ -16,11 +16,11 @@
} }
private static void forAllKeyMappings(final InputConstants.Key key, final Consumer<KeyMapping> operation) { private static void forAllKeyMappings(final InputConstants.Key key, final Consumer<KeyMapping> operation) {
- List<KeyMapping> list = MAP.get(key); - List<KeyMapping> keyMappings = MAP.get(key);
+ List<KeyMapping> list = MAP.getAll(key); + List<KeyMapping> keyMappings = MAP.getAll(key);
if (list != null && !list.isEmpty()) { if (keyMappings != null && !keyMappings.isEmpty()) {
for (KeyMapping keymapping : list) { for (KeyMapping keyMapping : keyMappings) {
operation.accept(keymapping); operation.accept(keyMapping);
@@ -106,7 +_,7 @@ @@ -106,7 +_,7 @@
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/KeyboardHandler.java --- a/net/minecraft/client/KeyboardHandler.java
+++ b/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java
@@ -516,7 +_,7 @@ @@ -514,7 +_,7 @@
if (screen != null) { if (screen != null) {
try { try {
if (action != 1 && action != 2) { if (action != 1 && action != 2) {
@@ -9,16 +9,16 @@
if (options.keyDebugModifier.matches(event)) { if (options.keyDebugModifier.matches(event)) {
this.usedDebugKeyAsModifier = false; this.usedDebugKeyAsModifier = false;
} }
@@ -525,7 +_,7 @@ @@ -523,7 +_,7 @@
} }
} else { } else {
screen.afterKeyboardAction(); screen.afterKeyboardAction();
- if (screen.keyPressed(event)) { - if (screen.keyPressed(event)) {
+ if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, event)) { + if (net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressed(screen, event)) {
if (this.minecraft.screen == null) { if (this.minecraft.screen == null) {
InputConstants.Key inputconstants$key = InputConstants.getKey(event); InputConstants.Key key = InputConstants.getKey(event);
KeyMapping.set(inputconstants$key, false); KeyMapping.set(key, false);
@@ -597,6 +_,7 @@ @@ -595,6 +_,7 @@
} }
} }
} }
@@ -26,12 +26,12 @@
} }
} }
@@ -605,7 +_,7 @@ @@ -603,7 +_,7 @@
Screen screen = this.minecraft.screen; Screen screen = this.minecraft.screen;
if (screen != null && this.minecraft.getOverlay() == null) { if (screen != null && this.minecraft.getOverlay() == null) {
try { try {
- screen.charTyped(event); - screen.charTyped(event);
+ net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, event); + net.minecraftforge.client.ForgeHooksClient.onScreenCharTyped(screen, event);
} catch (Throwable throwable) { } catch (Throwable var8) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "charTyped event handler"); CrashReport report = CrashReport.forThrowable(var8, "charTyped event handler");
screen.fillCrashDetails(crashreport); screen.fillCrashDetails(report);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Minecraft.java --- a/net/minecraft/client/Minecraft.java
+++ b/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java
@@ -272,7 +_,7 @@ @@ -268,7 +_,7 @@
import org.slf4j.Logger; import org.slf4j.Logger;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -9,7 +9,7 @@
private static Minecraft instance; private static Minecraft instance;
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
private static final int MAX_TICKS_PER_UPDATE = 10; private static final int MAX_TICKS_PER_UPDATE = 10;
@@ -436,7 +_,6 @@ @@ -432,7 +_,6 @@
} }
}, Util.nonCriticalIoPool()); }, Util.nonCriticalIoPool());
LOGGER.info("Setting user: {}", this.user.getName()); LOGGER.info("Setting user: {}", this.user.getName());
@@ -17,8 +17,8 @@
this.demo = gameConfig.game.demo; this.demo = gameConfig.game.demo;
this.allowsMultiplayer = !gameConfig.game.disableMultiplayer; this.allowsMultiplayer = !gameConfig.game.disableMultiplayer;
this.allowsChat = !gameConfig.game.disableChat; this.allowsChat = !gameConfig.game.disableChat;
@@ -522,14 +_,14 @@ @@ -518,14 +_,14 @@
LOGGER.error("Couldn't set icon", (Throwable)ioexception); LOGGER.error("Couldn't set icon", (Throwable)var23);
} }
+ // FORGE: Move mouse and keyboard handler setup further below + // FORGE: Move mouse and keyboard handler setup further below
@@ -34,7 +34,7 @@
this.resourcePackRepository.reload(); this.resourcePackRepository.reload();
this.options.loadSelectedResourcePacks(this.resourcePackRepository); this.options.loadSelectedResourcePacks(this.resourcePackRepository);
this.languageManager = new LanguageManager(this.options.languageCode, languageData -> { this.languageManager = new LanguageManager(this.options.languageCode, languageData -> {
@@ -617,6 +_,7 @@ @@ -613,6 +_,7 @@
this.particleResources = new ParticleResources(); this.particleResources = new ParticleResources();
this.resourceManager.registerReloadListener(this.particleResources); this.resourceManager.registerReloadListener(this.particleResources);
this.particleEngine = new ParticleEngine(this.level, this.particleResources); this.particleEngine = new ParticleEngine(this.level, this.particleResources);
@@ -42,17 +42,17 @@
this.particleResources.onReload(this.particleEngine::clearParticles); this.particleResources.onReload(this.particleEngine::clearParticles);
this.waypointStyles = new WaypointStyleManager(); this.waypointStyles = new WaypointStyleManager();
this.resourceManager.registerReloadListener(this.waypointStyles); this.resourceManager.registerReloadListener(this.waypointStyles);
@@ -638,6 +_,9 @@ @@ -634,6 +_,9 @@
this.resourceManager.registerReloadListener(this.gpuWarnlistManager); this.resourceManager.registerReloadListener(this.gpuWarnlistManager);
this.resourceManager.registerReloadListener(this.regionalCompliancies); this.resourceManager.registerReloadListener(this.regionalCompliancies);
this.gui = new Gui(this); this.gui = new Gui(this);
+ // FORGE: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them. + // FORGE: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them.
+ this.mouseHandler.setup(this.window); + this.mouseHandler.setup(this.window);
+ this.keyboardHandler.setup(this.window); + this.keyboardHandler.setup(this.window);
RealmsClient realmsclient = RealmsClient.getOrCreate(this); RealmsClient realmsClient = RealmsClient.getOrCreate(this);
this.realmsDataFetcher = new RealmsDataFetcher(realmsclient); this.realmsDataFetcher = new RealmsDataFetcher(realmsClient);
RenderSystem.setErrorCallback(this::onFullscreenError); RenderSystem.setErrorCallback(this::onFullscreenError);
@@ -669,6 +_,7 @@ @@ -665,6 +_,7 @@
} }
} }
@@ -60,34 +60,33 @@
this.window.updateVsync(this.options.enableVsync().get()); this.window.updateVsync(this.options.enableVsync().get());
this.window.updateRawMouseInput(this.options.rawMouseInput().get()); this.window.updateRawMouseInput(this.options.rawMouseInput().get());
this.window.setAllowCursorChanges(this.options.allowCursorChanges().get()); this.window.setAllowCursorChanges(this.options.allowCursorChanges().get());
@@ -695,14 +_,16 @@ @@ -690,14 +_,15 @@
.createReload(Util.backgroundExecutor().forName("resourceLoad"), this, RESOURCE_RELOAD_INITIAL_TASK, packs);
GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS); GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS);
Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, gameConfig.quickPlay); Minecraft.GameLoadCookie loadCookie = new Minecraft.GameLoadCookie(realmsClient, gameConfig.quickPlay);
this.setOverlay( - this.setOverlay(new LoadingOverlay(this, reloadInstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, loadCookie), () -> {
- new LoadingOverlay(this, reloadinstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, minecraft$gameloadcookie), () -> { + this.setOverlay(net.minecraftforge.fml.loading.ImmediateWindowHandler.<LoadingOverlay>loadingOverlay(() -> this, () ->reloadInstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, loadCookie), () -> {
+ net.minecraftforge.fml.loading.ImmediateWindowHandler.<LoadingOverlay>loadingOverlay( if (SharedConstants.IS_RUNNING_IN_IDE) {
+ () -> this, () -> reloadinstance, maybeT -> Util.ifElse(maybeT, t -> this.rollbackResourcePacks(t, minecraft$gameloadcookie), () -> { this.selfTest();
if (SharedConstants.IS_RUNNING_IN_IDE) { }
this.selfTest();
}
this.reloadStateTracker.finishReload(); this.reloadStateTracker.finishReload();
this.onResourceLoadFinished(minecraft$gameloadcookie); this.onResourceLoadFinished(loadCookie);
- }), false) - }), false));
+ net.minecraftforge.client.loading.ClientModLoader.completeModLoading(); + net.minecraftforge.client.loading.ClientModLoader.completeModLoading();
+ }), false).get() + }), false).get());
);
this.quickPlayLog = QuickPlayLog.of(gameConfig.quickPlay.logPath()); this.quickPlayLog = QuickPlayLog.of(gameConfig.quickPlay.logPath());
this.framerateLimitTracker = new FramerateLimitTracker(this.options, this); this.framerateLimitTracker = new FramerateLimitTracker(this.options, this);
@@ -822,6 +_,7 @@ this.fpsPieProfiler = new ContinuousProfiler(Util.timeSource, () -> this.fpsPieRenderTicks, this.framerateLimitTracker::isHeavilyThrottled);
StringBuilder stringbuilder = new StringBuilder("Minecraft"); @@ -816,6 +_,7 @@
StringBuilder builder = new StringBuilder("Minecraft");
if (checkModStatus().shouldReportAsModified()) { if (checkModStatus().shouldReportAsModified()) {
stringbuilder.append("*"); builder.append("*");
+ stringbuilder.append(" Forge"); + builder.append(" Forge");
} }
stringbuilder.append(" "); builder.append(" ");
@@ -845,6 +_,8 @@ @@ -839,6 +_,8 @@
} }
private UserApiService createUserApiService(final YggdrasilAuthenticationService authService, final GameConfig config) { private UserApiService createUserApiService(final YggdrasilAuthenticationService authService, final GameConfig config) {
@@ -96,7 +95,7 @@
return config.game.offlineDeveloperMode ? UserApiService.OFFLINE : authService.createUserApiService(config.user.user.getAccessToken()); return config.game.offlineDeveloperMode ? UserApiService.OFFLINE : authService.createUserApiService(config.user.user.getAccessToken());
} }
@@ -857,7 +_,7 @@ @@ -851,7 +_,7 @@
} }
private void rollbackResourcePacks(final Throwable t, final Minecraft.@Nullable GameLoadCookie loadCookie) { private void rollbackResourcePacks(final Throwable t, final Minecraft.@Nullable GameLoadCookie loadCookie) {
@@ -105,7 +104,7 @@
this.clearResourcePacksOnError(t, null, loadCookie); this.clearResourcePacksOnError(t, null, loadCookie);
} else { } else {
Util.throwAsRuntime(t); Util.throwAsRuntime(t);
@@ -1134,12 +_,6 @@ @@ -1128,12 +_,6 @@
LOGGER.error("setScreen called from non-game thread"); LOGGER.error("setScreen called from non-game thread");
} }
@@ -118,7 +117,7 @@
if (screen == null) { if (screen == null) {
if (this.clientLevelTeardownInProgress) { if (this.clientLevelTeardownInProgress) {
throw new IllegalStateException("Trying to return to in-game GUI during disconnection"); throw new IllegalStateException("Trying to return to in-game GUI during disconnection");
@@ -1158,6 +_,23 @@ @@ -1152,6 +_,23 @@
} }
} }
@@ -142,33 +141,33 @@
this.screen = screen; this.screen = screen;
if (this.screen != null) { if (this.screen != null) {
this.screen.added(); this.screen.added();
@@ -1241,6 +_,7 @@ @@ -1235,6 +_,7 @@
Util.shutdownExecutors(); Util.shutdownExecutors();
RenderSystem.getSamplerCache().close(); RenderSystem.getSamplerCache().close();
RenderSystem.getDevice().close(); RenderSystem.getDevice().close();
+ net.minecraftforge.fml.config.ConfigTracker.forceUnload(); + net.minecraftforge.fml.config.ConfigTracker.forceUnload();
} catch (Throwable throwable) { } catch (Throwable var5) {
LOGGER.error("Shutdown failure!", throwable); LOGGER.error("Shutdown failure!", var5);
throw throwable; throw var5;
@@ -1352,7 +_,9 @@ @@ -1346,7 +_,9 @@
profilerfiller.popPush("gpuAsync"); profiler.popPush("gpuAsync");
RenderSystem.executePendingTasks(); RenderSystem.executePendingTasks();
profilerfiller.pop(); profiler.pop();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickStart(this.deltaTracker);
this.gameRenderer.render(this.deltaTracker, advanceGameTime); this.gameRenderer.render(this.deltaTracker, advanceGameTime);
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderTickEnd(this.deltaTracker);
profilerfiller.push("present"); profiler.push("present");
if (!this.gameRenderer.getGameRenderState().windowRenderState.isMinimized) { if (!this.gameRenderer.getGameRenderState().windowRenderState.isMinimized) {
this.mainRenderTarget.blitToScreen(); this.mainRenderTarget.blitToScreen();
@@ -1456,6 +_,7 @@ @@ -1450,6 +_,7 @@
this.window.setGuiScale(i); this.window.setGuiScale(guiScale);
if (this.screen != null) { if (this.screen != null) {
this.screen.resize(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); this.screen.resize(this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
+ net.minecraftforge.client.ForgeHooksClient.resizeGuiLayers(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); + net.minecraftforge.client.ForgeHooksClient.resizeGuiLayers(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight());
} }
this.mouseHandler.setIgnoreFirstMove(); this.mouseHandler.setIgnoreFirstMove();
@@ -1600,6 +_,7 @@ @@ -1601,6 +_,7 @@
} }
public void stop() { public void stop() {
@@ -176,29 +175,29 @@
this.running = false; this.running = false;
} }
@@ -1629,10 +_,18 @@ @@ -1630,10 +_,18 @@
if (down && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) { if (down && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockHitResult blockHit = (BlockHitResult)this.hitResult;
BlockPos blockpos = blockhitresult.getBlockPos(); BlockPos pos = blockHit.getBlockPos();
- if (!this.level.getBlockState(blockpos).isAir()) { - if (!this.level.getBlockState(pos).isAir()) {
+ if (!this.level.isEmptyBlock(blockpos)) { + if (!this.level.isEmptyBlock(pos)) {
+ var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered(0, this.options.keyAttack, InteractionHand.MAIN_HAND); + var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered(0, this.options.keyAttack, InteractionHand.MAIN_HAND);
+ if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) { + if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) {
+ if (inputEvent.shouldSwingHand()) { + if (inputEvent.shouldSwingHand()) {
+ this.level.addBreakingBlockEffect(blockpos, blockhitresult); + this.level.addBreakingBlockEffect(pos, blockHit);
+ this.player.swing(InteractionHand.MAIN_HAND); + this.player.swing(InteractionHand.MAIN_HAND);
+ } + }
+ return; + return;
+ } + }
Direction direction = blockhitresult.getDirection(); Direction direction = blockHit.getDirection();
- if (this.gameMode.continueDestroyBlock(blockpos, direction)) { - if (this.gameMode.continueDestroyBlock(pos, direction)) {
- this.level.addBreakingBlockEffect(blockpos, direction); - this.level.addBreakingBlockEffect(pos, direction);
+ if (this.gameMode.continueDestroyBlock(blockpos, direction) && inputEvent.shouldSwingHand()) { + if (this.gameMode.continueDestroyBlock(pos, direction) && inputEvent.shouldSwingHand()) {
+ this.level.addBreakingBlockEffect(blockpos, blockhitresult); + this.level.addBreakingBlockEffect(pos, blockHit);
this.player.swing(InteractionHand.MAIN_HAND); this.player.swing(InteractionHand.MAIN_HAND);
} }
} }
@@ -1675,6 +_,8 @@ @@ -1676,6 +_,8 @@
this.player.swing(InteractionHand.MAIN_HAND); this.player.swing(InteractionHand.MAIN_HAND);
return true; return true;
} else { } else {
@@ -206,17 +205,17 @@
+ if (!net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) + if (!net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent))
switch (this.hitResult.getType()) { switch (this.hitResult.getType()) {
case ENTITY: case ENTITY:
AttackRange attackrange = itemstack.get(DataComponents.ATTACK_RANGE); AttackRange customItemRange = heldItem.get(DataComponents.ATTACK_RANGE);
@@ -1685,7 +_,7 @@ @@ -1686,7 +_,7 @@
case BLOCK: case BLOCK:
BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockHitResult blockHit = (BlockHitResult)this.hitResult;
BlockPos blockpos = blockhitresult.getBlockPos(); BlockPos pos = blockHit.getBlockPos();
- if (!this.level.getBlockState(blockpos).isAir()) { - if (!this.level.getBlockState(pos).isAir()) {
+ if (!this.level.isEmptyBlock(blockpos)) { + if (!this.level.isEmptyBlock(pos)) {
this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection()); this.gameMode.startDestroyBlock(pos, blockHit.getDirection());
if (this.level.getBlockState(blockpos).isAir()) { if (this.level.getBlockState(pos).isAir()) {
flag = true; endAttack = true;
@@ -1698,8 +_,10 @@ @@ -1699,8 +_,10 @@
} }
this.player.resetAttackStrengthTicker(); this.player.resetAttackStrengthTicker();
@@ -225,83 +224,83 @@
+ if (inputEvent.shouldSwingHand()) + if (inputEvent.shouldSwingHand())
this.player.swing(InteractionHand.MAIN_HAND); this.player.swing(InteractionHand.MAIN_HAND);
return flag; return endAttack;
} }
@@ -1716,6 +_,12 @@ @@ -1717,6 +_,12 @@
} }
for (InteractionHand interactionhand : InteractionHand.values()) { for (InteractionHand hand : InteractionHand.values()) {
+ var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered(1, this.options.keyUse, interactionhand); + var inputEvent = new net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered(1, this.options.keyUse, hand);
+ if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) { + if (net.minecraftforge.client.event.InputEvent.InteractionKeyMappingTriggered.BUS.post(inputEvent)) {
+ if (inputEvent.shouldSwingHand()) this.player.swing(interactionhand); + if (inputEvent.shouldSwingHand()) this.player.swing(hand);
+ return; + return;
+ } + }
+ +
ItemStack itemstack = this.player.getItemInHand(interactionhand); ItemStack heldItem = this.player.getItemInHand(hand);
if (!itemstack.isItemEnabled(this.level.enabledFeatures())) { if (!heldItem.isItemEnabled(this.level.enabledFeatures())) {
return; return;
@@ -1734,7 +_,7 @@ @@ -1733,7 +_,7 @@
&& this.gameMode.interact(this.player, entity, entityhitresult, interactionhand) instanceof InteractionResult.Success interactionresult$success2
) if (this.player.isWithinEntityInteractionRange(entity, 0.0)
{ && this.gameMode.interact(this.player, entity, entityHit, hand) instanceof InteractionResult.Success success) {
- if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT) { - if (success.swingSource() == InteractionResult.SwingSource.CLIENT) {
+ if (interactionresult$success2.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { + if (success.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) {
this.player.swing(interactionhand); this.player.swing(hand);
} }
@@ -1746,7 +_,7 @@ @@ -1745,7 +_,7 @@
int i = itemstack.getCount(); int oldCount = heldItem.getCount();
InteractionResult interactionresult = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult); InteractionResult useResult = this.gameMode.useItemOn(this.player, hand, blockHit);
if (interactionresult instanceof InteractionResult.Success interactionresult$success) { if (useResult instanceof InteractionResult.Success success) {
- if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT) { - if (success.swingSource() == InteractionResult.SwingSource.CLIENT) {
+ if (interactionresult$success.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) { + if (success.swingSource() == InteractionResult.SwingSource.CLIENT && inputEvent.shouldSwingHand()) {
this.player.swing(interactionhand); this.player.swing(hand);
if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.player.hasInfiniteMaterials())) { if (!heldItem.isEmpty() && (heldItem.getCount() != oldCount || this.player.hasInfiniteMaterials())) {
this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand); this.gameRenderer.itemInHandRenderer.itemUsed(hand);
@@ -1762,6 +_,9 @@ @@ -1761,6 +_,9 @@
} }
} }
+ if (itemstack.isEmpty() && (this.hitResult == null || this.hitResult.getType() == HitResult.Type.MISS)) + if (heldItem.isEmpty() && (this.hitResult == null || this.hitResult.getType() == HitResult.Type.MISS))
+ net.minecraftforge.event.ForgeEventFactory.onRightClickEmpty(this.player, interactionhand); + net.minecraftforge.event.ForgeEventFactory.onRightClickEmpty(this.player, hand);
+ +
if (!itemstack.isEmpty() if (!heldItem.isEmpty() && this.gameMode.useItem(this.player, hand) instanceof InteractionResult.Success success) {
&& this.gameMode.useItem(this.player, interactionhand) instanceof InteractionResult.Success interactionresult$success1) { if (success.swingSource() == InteractionResult.SwingSource.CLIENT) {
if (interactionresult$success1.swingSource() == InteractionResult.SwingSource.CLIENT) { this.player.swing(hand);
@@ -1791,6 +_,8 @@ @@ -1789,6 +_,8 @@
} }
ProfilerFiller profilerfiller = Profiler.get(); ProfilerFiller profiler = Profiler.get();
+ net.minecraftforge.event.ForgeEventFactory.onPreClientTick(); + net.minecraftforge.event.ForgeEventFactory.onPreClientTick();
+ +
profilerfiller.push("gui"); profiler.push("gui");
this.textInputManager.tick(); this.textInputManager.tick();
this.chatListener.tick(); this.chatListener.tick();
@@ -1873,6 +_,7 @@ @@ -1871,6 +_,7 @@
this.tutorial.tick(); this.tutorial.tick();
+ net.minecraftforge.event.ForgeEventFactory.onPreLevelTick(this.level, () -> true); + net.minecraftforge.event.ForgeEventFactory.onPreLevelTick(this.level, () -> true);
try { try {
this.level.tick(() -> true); this.level.tick(() -> true);
} catch (Throwable throwable1) { } catch (Throwable var6) {
@@ -1886,6 +_,7 @@ @@ -1884,6 +_,7 @@
throw new ReportedException(crashreport1); throw new ReportedException(report);
} }
+ net.minecraftforge.event.ForgeEventFactory.onPostLevelTick(this.level, () -> true); + net.minecraftforge.event.ForgeEventFactory.onPostLevelTick(this.level, () -> true);
} }
profilerfiller.popPush("animateTick"); profiler.popPush("animateTick");
@@ -1910,6 +_,7 @@ @@ -1908,6 +_,7 @@
profilerfiller.popPush("keyboard"); profiler.popPush("keyboard");
this.keyboardHandler.tick(); this.keyboardHandler.tick();
profilerfiller.pop(); profiler.pop();
+ net.minecraftforge.event.ForgeEventFactory.onPostClientTick(); + net.minecraftforge.event.ForgeEventFactory.onPostClientTick();
} }
private boolean isLevelRunningNormally() { private boolean isLevelRunningNormally() {
@@ -2140,6 +_,7 @@ @@ -2138,6 +_,7 @@
} }
public void setLevel(final ClientLevel level) { public void setLevel(final ClientLevel level) {
@@ -309,15 +308,15 @@
this.level = level; this.level = level;
this.updateLevelInEngines(level); this.updateLevelInEngines(level);
} }
@@ -2201,6 +_,7 @@ @@ -2199,6 +_,7 @@
IntegratedServer integratedserver = this.singleplayerServer; IntegratedServer server = this.singleplayerServer;
this.singleplayerServer = null; this.singleplayerServer = null;
this.gameRenderer.resetData(); this.gameRenderer.resetData();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerLogout(this.gameMode, this.player); + net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerLogout(this.gameMode, this.player);
this.gameMode = null; this.gameMode = null;
this.narrator.clear(); this.narrator.clear();
this.clientLevelTeardownInProgress = true; this.clientLevelTeardownInProgress = true;
@@ -2208,6 +_,7 @@ @@ -2206,6 +_,7 @@
try { try {
if (this.level != null) { if (this.level != null) {
this.gui.onDisconnected(); this.gui.onDisconnected();
@@ -325,19 +324,19 @@
} }
this.level = null; this.level = null;
@@ -2222,6 +_,7 @@ @@ -2220,6 +_,7 @@
} }
profilerfiller.pop(); profiler.pop();
+ net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(this.level); + net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(this.level);
} }
this.setScreenAndShow(screen); this.setScreenAndShow(screen);
@@ -2374,6 +_,7 @@ @@ -2372,6 +_,7 @@
private void pickBlockOrEntity() { private void pickBlockOrEntity() {
if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onClickInputPickBlock(this.options.keyPickItem)) return; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onClickInputPickBlock(this.options.keyPickItem)) return;
boolean flag = this.hasControlDown(); boolean includeData = this.hasControlDown();
switch (this.hitResult) { switch (this.hitResult) {
case BlockHitResult blockhitresult: case BlockHitResult blockHitResult:
@@ -4,65 +4,65 @@
this.activeButton = null; this.activeButton = null;
} }
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(mousebuttoninfo, action)) return; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPre(buttonInfo, action)) return;
if (this.minecraft.getOverlay() == null) { if (this.minecraft.getOverlay() == null) {
if (this.minecraft.screen == null) { if (this.minecraft.screen == null) {
if (!this.mouseGrabbed && flag) { if (!this.mouseGrabbed && pressed) {
@@ -106,7 +_,7 @@ @@ -106,7 +_,7 @@
&& i - this.lastClick.time() < 250L && currentTime - this.lastClick.time() < 250L
&& this.lastClick.screen() == screen && this.lastClick.screen() == screen
&& this.lastClickButton == mousebuttonevent.button(); && this.lastClickButton == event.button();
- if (screen.mouseClicked(mousebuttonevent, flag1)) { - if (screen.mouseClicked(event, doubleClick)) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(screen, d0, d1, mousebuttonevent, flag1)) { + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseClicked(screen, xm, ym, event, doubleClick)) {
this.lastClick = new MouseHandler.LastClick(i, screen); this.lastClick = new MouseHandler.LastClick(currentTime, screen);
this.lastClickButton = mousebuttoninfo.button(); this.lastClickButton = buttonInfo.button();
return; return;
@@ -121,7 +_,7 @@ @@ -121,7 +_,7 @@
} }
} else { } else {
try { try {
- if (screen.mouseReleased(mousebuttonevent)) { - if (screen.mouseReleased(event)) {
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(screen, d0, d1, mousebuttonevent)) { + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseReleased(screen, xm, ym, event)) {
return; return;
} }
} catch (Throwable throwable) { } catch (Throwable var17) {
@@ -151,6 +_,7 @@ @@ -151,6 +_,7 @@
KeyMapping.click(inputconstants$key); KeyMapping.click(mouseKey);
} }
} }
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(mousebuttoninfo, action); + net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseButtonPost(buttonInfo, action);
} }
} }
@@ -202,7 +_,9 @@ @@ -202,7 +_,9 @@
if (this.minecraft.screen != null) { if (this.minecraft.screen != null) {
double d3 = this.getScaledXPos(this.minecraft.getWindow()); double xm = this.getScaledXPos(this.minecraft.getWindow());
double d4 = this.getScaledYPos(this.minecraft.getWindow()); double ym = this.getScaledYPos(this.minecraft.getWindow());
- this.minecraft.screen.mouseScrolled(d3, d4, d1, d2); - this.minecraft.screen.mouseScrolled(xm, ym, scaledXOffset, scaledYOffset);
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseScrollPre(this.minecraft.screen, d3, d4, d1, d2)) return; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseScrollPre(this.minecraft.screen, xm, ym, scaledXOffset, scaledYOffset)) return;
+ if (this.minecraft.screen.mouseScrolled(d3, d4, d1, d2)) return; + if (this.minecraft.screen.mouseScrolled(xm, ym, scaledXOffset, scaledYOffset)) return;
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseScrollPost(this.minecraft.screen, d3, d4, d1, d2); + net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenMouseScrollPost(this.minecraft.screen, xm, ym, scaledXOffset, scaledYOffset);
this.minecraft.screen.afterMouseAction(); this.minecraft.screen.afterMouseAction();
} else if (this.minecraft.player != null) { } else if (this.minecraft.player != null) {
Vector2i vector2i = this.scrollWheelHandler.onMouseScroll(d1, d2); Vector2i wheelXY = this.scrollWheelHandler.onMouseScroll(scaledXOffset, scaledYOffset);
@@ -211,6 +_,7 @@ @@ -211,6 +_,7 @@
} }
int i = vector2i.y == 0 ? -vector2i.x : vector2i.y; int wheel = wheelXY.y == 0 ? -wheelXY.x : wheelXY.y;
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseScroll(this, d1, d2)) return; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onMouseScroll(this, scaledXOffset, scaledYOffset)) return;
if (this.minecraft.player.isSpectator()) { if (this.minecraft.player.isSpectator()) {
if (this.minecraft.gui.getSpectatorGui().isMenuActive()) { if (this.minecraft.gui.getSpectatorGui().isMenuActive()) {
this.minecraft.gui.getSpectatorGui().onMouseScrolled(-i); this.minecraft.gui.getSpectatorGui().onMouseScrolled(-wheel);
@@ -315,7 +_,7 @@ @@ -317,7 +_,7 @@
double d5 = getScaledYPos(window, this.accumulatedDY); double dy = getScaledYPos(window, this.accumulatedDY);
try { try {
- screen.mouseDragged(new MouseButtonEvent(d2, d3, this.activeButton), d4, d5); - screen.mouseDragged(new MouseButtonEvent(xm, ym, this.activeButton), dx, dy);
+ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, new MouseButtonEvent(d2, d3, this.activeButton), d4, d5); + net.minecraftforge.client.ForgeHooksClient.onScreenMouseDrag(screen, new MouseButtonEvent(xm, ym, this.activeButton), dx, dy);
} catch (Throwable throwable) { } catch (Throwable var19) {
CrashReport crashreport1 = CrashReport.forThrowable(throwable, "mouseDragged event handler"); CrashReport report = CrashReport.forThrowable(var19, "mouseDragged event handler");
screen.fillCrashDetails(crashreport1); screen.fillCrashDetails(report);
@@ -400,6 +_,14 @@ @@ -402,6 +_,14 @@
public double ypos() { public double ypos() {
return this.ypos; return this.ypos;
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Options.java --- a/net/minecraft/client/Options.java
+++ b/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java
@@ -921,6 +_,7 @@ @@ -929,6 +_,7 @@
); );
public boolean syncWrites; public boolean syncWrites;
public boolean startedCleanly = true; public boolean startedCleanly = true;
@@ -8,15 +8,15 @@
public static boolean isSoundDeviceDefault(final String deviceName) { public static boolean isSoundDeviceDefault(final String deviceName) {
return deviceName.equals(""); return deviceName.equals("");
@@ -1396,6 +_,7 @@ @@ -1404,6 +_,7 @@
} }
public Options(final Minecraft minecraft, final File workingDirectory) { public Options(final Minecraft minecraft, final File workingDirectory) {
+ setForgeKeybindProperties(); + setForgeKeybindProperties();
this.minecraft = minecraft; this.minecraft = minecraft;
this.optionsFile = new File(workingDirectory, "options.txt"); this.optionsFile = new File(workingDirectory, "options.txt");
boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L; boolean largeDistances = Runtime.getRuntime().maxMemory() >= 1000000000L;
@@ -1548,15 +_,28 @@ @@ -1556,15 +_,28 @@
this.startedCleanly = access.process("startedCleanly", this.startedCleanly); this.startedCleanly = access.process("startedCleanly", this.startedCleanly);
access.process("musicToast", this.musicToast); access.process("musicToast", this.musicToast);
access.process("musicFrequency", this.musicFrequency); access.process("musicFrequency", this.musicFrequency);
@@ -26,27 +26,27 @@
+ // FORGE: split off to allow reloading keys after mod loading is done + // FORGE: split off to allow reloading keys after mod loading is done
+ private void processOptionsKeysOnly(Options.FieldAccess access) { + private void processOptionsKeysOnly(Options.FieldAccess access) {
for (KeyMapping keymapping : this.keyMappings) { for (KeyMapping keyMapping : this.keyMappings) {
- String s = keymapping.saveString(); - String currentValue = keyMapping.saveString();
+ String s = keymapping.saveString() + (keymapping.getKeyModifier() != net.minecraftforge.client.settings.KeyModifier.NONE ? ":" + keymapping.getKeyModifier() : ""); + String currentValue = keyMapping.saveString() + (keyMapping.getKeyModifier() != net.minecraftforge.client.settings.KeyModifier.NONE ? ":" + keyMapping.getKeyModifier() : "");
String s1 = access.process("key_" + keymapping.getName(), s); String newValue = access.process("key_" + keyMapping.getName(), currentValue);
if (!s.equals(s1)) { if (!currentValue.equals(newValue)) {
keymapping.setKey(InputConstants.getKey(s1)); keyMapping.setKey(InputConstants.getKey(newValue));
+ if (s1.indexOf(':') != -1) { + if (newValue.indexOf(':') != -1) {
+ String[] pts = s1.split(":"); + String[] pts = newValue.split(":");
+ keymapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.valueFromString(pts[1]), InputConstants.getKey(pts[0])); + keyMapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.valueFromString(pts[1]), InputConstants.getKey(pts[0]));
+ } else { + } else {
+ keymapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, InputConstants.getKey(s1)); + keyMapping.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, InputConstants.getKey(newValue));
+ } + }
} }
} }
+ } + }
+ private void processOptionsEnd(Options.FieldAccess access) { + private void processOptionsEnd(Options.FieldAccess access) {
for (SoundSource soundsource : SoundSource.values()) { for (SoundSource source : SoundSource.values()) {
access.process("soundCategory_" + soundsource.getName(), this.soundSourceVolumes.get(soundsource)); access.process("soundCategory_" + source.getName(), this.soundSourceVolumes.get(source));
} }
@@ -1571,6 +_,10 @@ @@ -1579,6 +_,10 @@
} }
public void load() { public void load() {
@@ -57,64 +57,64 @@
try { try {
if (!this.optionsFile.exists()) { if (!this.optionsFile.exists()) {
return; return;
@@ -1590,7 +_,8 @@ @@ -1598,7 +_,8 @@
} }
final CompoundTag compoundtag1 = this.dataFix(compoundtag); final CompoundTag options = this.dataFix(rawOptions);
- this.processOptions( - this.processOptions(
+ java.util.function.Consumer<FieldAccess> processor = limited ? this::processOptionsKeysOnly : this::processOptions; + java.util.function.Consumer<FieldAccess> processor = limited ? this::processOptionsKeysOnly : this::processOptions;
+ processor.accept( + processor.accept(
new Options.FieldAccess() { new Options.FieldAccess() {
{ {
Objects.requireNonNull(Options.this); Objects.requireNonNull(Options.this);
@@ -1672,6 +_,17 @@ @@ -1680,6 +_,17 @@
); );
compoundtag1.getString("fullscreenResolution").ifPresent(fullscreenResolution -> this.fullscreenVideoModeString = fullscreenResolution); options.getString("fullscreenResolution").ifPresent(fullscreenResolution -> this.fullscreenVideoModeString = fullscreenResolution);
KeyMapping.resetMapping(); KeyMapping.resetMapping();
+ +
+ if (limited) { + if (limited) {
+ this.unknownKeys.clear(); + this.unknownKeys.clear();
+ } else { + } else {
+ var knownKeys = Arrays.stream(this.keyMappings).map(k -> "key_" + k.getName()).collect(Collectors.toSet()); + var knownKeys = Arrays.stream(this.keyMappings).map(k -> "key_" + k.getName()).collect(Collectors.toSet());
+ for (var entry : compoundtag1.entrySet()) { + for (var entry : options.entrySet()) {
+ if (entry.getKey().startsWith("key_") && entry.getValue().asString().isPresent() && !knownKeys.contains(entry.getKey())) + if (entry.getKey().startsWith("key_") && entry.getValue().asString().isPresent() && !knownKeys.contains(entry.getKey()))
+ this.unknownKeys.put(entry.getKey(), entry.getValue().asString().get()); + this.unknownKeys.put(entry.getKey(), entry.getValue().asString().get());
+ } + }
+ } + }
+ +
} catch (Exception exception) { } catch (Exception var7) {
LOGGER.error("Failed to load options", (Throwable)exception); LOGGER.error("Failed to load options", (Throwable)var7);
} }
@@ -1699,6 +_,7 @@ @@ -1707,6 +_,7 @@
public void save() { public void save() {
try (final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) { try (final PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) {
printwriter.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version()); writer.println("version:" + SharedConstants.getCurrentVersion().dataVersion().version());
+ var seen = new java.util.HashSet<String>(); + var seen = new java.util.HashSet<String>();
this.processOptions( this.processOptions(
new Options.FieldAccess() { new Options.FieldAccess() {
{ {
@@ -1706,6 +_,7 @@ @@ -1714,6 +_,7 @@
} }
public void writePrefix(final String name) { public void writePrefix(final String name) {
+ seen.add(name); + seen.add(name);
printwriter.print(name); writer.print(name);
printwriter.print(':'); writer.print(':');
} }
@@ -1761,6 +_,12 @@ @@ -1769,6 +_,12 @@
if (s != null) { if (fullscreenVideoModeString != null) {
printwriter.println("fullscreenResolution:" + s); writer.println("fullscreenResolution:" + fullscreenVideoModeString);
} }
+ // Forge add any unknown keys so that Mods can add keybindings between vanilla loading/saving its config. + // Forge add any unknown keys so that Mods can add keybindings between vanilla loading/saving its config.
+ for (var entry : this.unknownKeys.entrySet()) { + for (var entry : this.unknownKeys.entrySet()) {
+ if (!seen.contains(entry.getKey())) + if (!seen.contains(entry.getKey()))
+ printwriter.println(entry.getKey() + ":" + entry.getValue()); + writer.println(entry.getKey() + ":" + entry.getValue());
+ } + }
+ +
} catch (Exception exception) { } catch (Exception var6) {
LOGGER.error("Failed to save options", (Throwable)exception); LOGGER.error("Failed to save options", (Throwable)var6);
} }
@@ -1798,6 +_,7 @@ @@ -1806,6 +_,7 @@
} }
public void broadcastOptions() { public void broadcastOptions() {
@@ -122,7 +122,7 @@
if (this.minecraft.player != null) { if (this.minecraft.player != null) {
this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation()); this.minecraft.player.connection.broadcastClientInformation(this.buildPlayerInformation());
} }
@@ -1915,6 +_,23 @@ @@ -1923,6 +_,23 @@
public static Component genericValueLabel(final Component caption, final int value) { public static Component genericValueLabel(final Component caption, final int value) {
return genericValueLabel(caption, Component.literal(Integer.toString(value))); return genericValueLabel(caption, Component.literal(Integer.toString(value)));
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/Screenshot.java --- a/net/minecraft/client/Screenshot.java
+++ b/net/minecraft/client/Screenshot.java +++ b/net/minecraft/client/Screenshot.java
@@ -45,6 +_,13 @@ @@ -44,6 +_,13 @@
file2 = new File(file1, forceName); file = new File(picDir, forceName);
} }
+ var event = new net.minecraftforge.client.event.ScreenshotEvent(image, file2); + var event = new net.minecraftforge.client.event.ScreenshotEvent(image, file);
+ if (net.minecraftforge.client.event.ScreenshotEvent.BUS.post(event)) { + if (net.minecraftforge.client.event.ScreenshotEvent.BUS.post(event)) {
+ callback.accept(event.getCancelMessage()); + callback.accept(event.getCancelMessage());
+ return; + return;
@@ -14,19 +14,19 @@
Util.ioPool() Util.ioPool()
.execute( .execute(
() -> { () -> {
@@ -52,10 +_,13 @@ @@ -51,10 +_,13 @@
NativeImage nativeimage = image; NativeImage twrVar0$ = image;
try { try {
- image.writeToFile(file2); - image.writeToFile(file);
- Component component = Component.literal(file2.getName()) - Component component = Component.literal(file.getName())
+ image.writeToFile(outputFile); + image.writeToFile(outputFile);
+ Component component = Component.literal(outputFile.getName()) + Component component = Component.literal(outputFile.getName())
.withStyle(ChatFormatting.UNDERLINE) .withStyle(ChatFormatting.UNDERLINE)
.withStyle(s -> s.withClickEvent(new ClickEvent.OpenFile(file2.getAbsoluteFile()))); .withStyle(s -> s.withClickEvent(new ClickEvent.OpenFile(file.getAbsoluteFile())));
+ if (event.getResultMessage() != null) + if (event.getResultMessage() != null)
+ callback.accept(event.getResultMessage()); + callback.accept(event.getResultMessage());
+ else + else
callback.accept(Component.translatable("screenshot.success", component)); callback.accept(Component.translatable("screenshot.success", component));
} catch (Throwable throwable1) { } catch (Throwable var7) {
if (image != null) { if (image != null) {
@@ -1,15 +1,15 @@
--- a/net/minecraft/client/color/block/BlockColors.java --- a/net/minecraft/client/color/block/BlockColors.java
+++ b/net/minecraft/client/color/block/BlockColors.java +++ b/net/minecraft/client/color/block/BlockColors.java
@@ -45,6 +_,7 @@ @@ -45,6 +_,7 @@
blockcolors.register(List.of(BlockTintSources.constant(-2046180)), Blocks.ATTACHED_MELON_STEM, Blocks.ATTACHED_PUMPKIN_STEM); colors.register(List.of(BlockTintSources.constant(-2046180)), Blocks.ATTACHED_MELON_STEM, Blocks.ATTACHED_PUMPKIN_STEM);
blockcolors.register(List.of(BlockTintSources.stem()), Blocks.MELON_STEM, Blocks.PUMPKIN_STEM); colors.register(List.of(BlockTintSources.stem()), Blocks.MELON_STEM, Blocks.PUMPKIN_STEM);
blockcolors.register(List.of(BlockTintSources.constant(-9321636, -14647248)), Blocks.LILY_PAD); colors.register(List.of(BlockTintSources.constant(-9321636, -14647248)), Blocks.LILY_PAD);
+ net.minecraftforge.client.ForgeHooksClient.onBlockColorsInit(blockcolors); + net.minecraftforge.client.ForgeHooksClient.onBlockColorsInit(colors);
return blockcolors; return colors;
} }
@@ -57,6 +_,8 @@ @@ -57,6 +_,8 @@
return layer >= list.size() ? null : list.get(layer); return layer >= layers.size() ? null : layers.get(layer);
} }
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterColorHandlersEvent.Block} */ + /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterColorHandlersEvent.Block} */
@@ -1,22 +1,22 @@
--- a/net/minecraft/client/data/Main.java --- a/net/minecraft/client/data/Main.java
+++ b/net/minecraft/client/data/Main.java +++ b/net/minecraft/client/data/Main.java
@@ -28,13 +_,18 @@ @@ -28,13 +_,18 @@
OptionSpec<Void> optionspec1 = optionparser.accepts("client", "Include client generators"); OptionSpec<Void> clientOption = parser.accepts("client", "Include client generators");
OptionSpec<Void> optionspec2 = optionparser.accepts("all", "Include all generators"); OptionSpec<Void> allOption = parser.accepts("all", "Include all generators");
OptionSpec<String> optionspec3 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated"); OptionSpec<String> outputOption = parser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
+ OptionSpec<String> inputSpec = optionparser.accepts("input", "Input folder").withRequiredArg(); + OptionSpec<String> inputSpec = parser.accepts("input", "Input folder").withRequiredArg();
+ var loader = net.minecraftforge.data.loading.DatagenModLoader.setup(optionparser, true); + var loader = net.minecraftforge.data.loading.DatagenModLoader.setup(parser, true);
OptionSet optionset = optionparser.parse(args); OptionSet optionSet = parser.parse(args);
- if (!optionset.has(optionspec) && optionset.hasOptions()) { - if (!optionSet.has(helpOption) && optionSet.hasOptions()) {
+ if (!optionset.has(optionspec) && optionset.hasOptions() && loader.hasArgs(optionset)) { + if (!optionSet.has(helpOption) && optionSet.hasOptions() && loader.hasArgs(optionSet)) {
+ var input = optionset.valuesOf(inputSpec).stream().map(Paths::get).toList(); + var input = optionSet.valuesOf(inputSpec).stream().map(Paths::get).toList();
Path path = Paths.get(optionspec3.value(optionset)); Path output = Paths.get(outputOption.value(optionSet));
boolean flag = optionset.has(optionspec2); boolean allOptions = optionSet.has(allOption);
boolean flag1 = flag || optionset.has(optionspec1); boolean client = allOptions || optionSet.has(clientOption);
Bootstrap.bootStrap(); Bootstrap.bootStrap();
ClientBootstrap.bootstrap(); ClientBootstrap.bootstrap();
+ if (!loader.run(optionset, path, input, flag, flag1, flag, flag)) + if (!loader.run(optionSet, output, input, allOptions, client, allOptions, allOptions))
+ return; + return;
DataGenerator datagenerator = new DataGenerator.Cached(path, SharedConstants.getCurrentVersion(), true); DataGenerator generator = new DataGenerator.Cached(output, SharedConstants.getCurrentVersion(), true);
addClientProviders(datagenerator, flag1); addClientProviders(generator, client);
datagenerator.run(); generator.run();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/data/models/ItemModelGenerators.java --- a/net/minecraft/client/data/models/ItemModelGenerators.java
+++ b/net/minecraft/client/data/models/ItemModelGenerators.java +++ b/net/minecraft/client/data/models/ItemModelGenerators.java
@@ -922,6 +_,9 @@ @@ -909,6 +_,9 @@
this.declareCustomModelItem(Items.COD); this.declareCustomModelItem(Items.COD);
this.declareCustomModelItem(Items.FEATHER); this.declareCustomModelItem(Items.FEATHER);
this.declareCustomModelItem(Items.LEAD); this.declareCustomModelItem(Items.LEAD);
@@ -1,22 +1,22 @@
--- a/net/minecraft/client/data/models/ModelProvider.java --- a/net/minecraft/client/data/models/ModelProvider.java
+++ b/net/minecraft/client/data/models/ModelProvider.java +++ b/net/minecraft/client/data/models/ModelProvider.java
@@ -44,11 +_,11 @@ @@ -43,11 +_,11 @@
@Override @Override
public CompletableFuture<?> run(final CachedOutput cache) { public CompletableFuture<?> run(final CachedOutput cache) {
- ModelProvider.ItemInfoCollector modelprovider$iteminfocollector = new ModelProvider.ItemInfoCollector(); - ModelProvider.ItemInfoCollector itemModels = new ModelProvider.ItemInfoCollector();
- ModelProvider.BlockStateGeneratorCollector modelprovider$blockstategeneratorcollector = new ModelProvider.BlockStateGeneratorCollector(); - ModelProvider.BlockStateGeneratorCollector blockStateGenerators = new ModelProvider.BlockStateGeneratorCollector();
+ ModelProvider.ItemInfoCollector modelprovider$iteminfocollector = new ModelProvider.ItemInfoCollector(this::getKnownItems); + ModelProvider.ItemInfoCollector itemModels = new ModelProvider.ItemInfoCollector(this::getKnownItems);
+ ModelProvider.BlockStateGeneratorCollector modelprovider$blockstategeneratorcollector = new ModelProvider.BlockStateGeneratorCollector(this::getKnownBlocks); + ModelProvider.BlockStateGeneratorCollector blockStateGenerators = new ModelProvider.BlockStateGeneratorCollector(this::getKnownBlocks);
ModelProvider.SimpleModelCollector modelprovider$simplemodelcollector = new ModelProvider.SimpleModelCollector(); ModelProvider.SimpleModelCollector simpleModels = new ModelProvider.SimpleModelCollector();
- new BlockModelGenerators(modelprovider$blockstategeneratorcollector, modelprovider$iteminfocollector, modelprovider$simplemodelcollector).run(); - new BlockModelGenerators(blockStateGenerators, itemModels, simpleModels).run();
- new ItemModelGenerators(modelprovider$iteminfocollector, modelprovider$simplemodelcollector).run(); - new ItemModelGenerators(itemModels, simpleModels).run();
+ getBlockModelGenerators(modelprovider$blockstategeneratorcollector, modelprovider$iteminfocollector, modelprovider$simplemodelcollector).run(); + getBlockModelGenerators(blockStateGenerators, itemModels, simpleModels).run();
+ getItemModelGenerators(modelprovider$iteminfocollector, modelprovider$simplemodelcollector).run(); + getItemModelGenerators(itemModels, simpleModels).run();
modelprovider$blockstategeneratorcollector.validate(); blockStateGenerators.validate();
modelprovider$iteminfocollector.finalizeAndValidate(); itemModels.finalizeAndValidate();
return CompletableFuture.allOf( return CompletableFuture.allOf(
@@ -58,6 +_,22 @@ @@ -57,6 +_,22 @@
); );
} }
@@ -39,7 +39,7 @@
@Override @Override
public final String getName() { public final String getName() {
return "Model Definitions"; return "Model Definitions";
@@ -66,6 +_,15 @@ @@ -65,6 +_,15 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static class BlockStateGeneratorCollector implements Consumer<BlockModelDefinitionGenerator> { public static class BlockStateGeneratorCollector implements Consumer<BlockModelDefinitionGenerator> {
private final Map<Block, BlockModelDefinitionGenerator> generators = new HashMap<>(); private final Map<Block, BlockModelDefinitionGenerator> generators = new HashMap<>();
@@ -55,17 +55,17 @@
public void accept(final BlockModelDefinitionGenerator generator) { public void accept(final BlockModelDefinitionGenerator generator) {
Block block = generator.block(); Block block = generator.block();
@@ -76,8 +_,7 @@ @@ -75,8 +_,7 @@
} }
public void validate() { public void validate() {
- List<Identifier> list = BuiltInRegistries.BLOCK - List<Identifier> missingDefinitions = BuiltInRegistries.BLOCK
- .listElements() - .listElements()
+ List<Identifier> list = known.get().map(Block::builtInRegistryHolder) + List<Identifier> missingDefinitions = known.get().map(Block::builtInRegistryHolder)
.filter(e -> !this.generators.containsKey(e.value())) .filter(e -> !this.generators.containsKey(e.value()))
.map(e -> e.key().identifier()) .map(e -> e.key().identifier())
.toList(); .toList();
@@ -97,6 +_,15 @@ @@ -96,6 +_,15 @@
public static class ItemInfoCollector implements ItemModelOutput { public static class ItemInfoCollector implements ItemModelOutput {
private final Map<Item, ClientItem> itemInfos = new HashMap<>(); private final Map<Item, ClientItem> itemInfos = new HashMap<>();
private final Map<Item, Item> copies = new HashMap<>(); private final Map<Item, Item> copies = new HashMap<>();
@@ -81,7 +81,7 @@
@Override @Override
public void accept(final Item item, final ItemModel.Unbaked model, final ClientItem.Properties properties) { public void accept(final Item item, final ItemModel.Unbaked model, final ClientItem.Properties properties) {
@@ -115,7 +_,7 @@ @@ -114,7 +_,7 @@
this.copies.put(acceptor, donor); this.copies.put(acceptor, donor);
} }
@@ -89,23 +89,23 @@
+ public void generateDefaultBlockModels() { + public void generateDefaultBlockModels() {
BuiltInRegistries.ITEM.forEach(item -> { BuiltInRegistries.ITEM.forEach(item -> {
if (!this.copies.containsKey(item)) { if (!this.copies.containsKey(item)) {
if (item instanceof BlockItem blockitem && !this.itemInfos.containsKey(blockitem)) { if (item instanceof BlockItem blockItem && !this.itemInfos.containsKey(blockItem)) {
@@ -124,6 +_,8 @@ @@ -123,6 +_,8 @@
} }
} }
}); });
+ } + }
+ public void finalizeAndValidate() { + public void finalizeAndValidate() {
this.copies.forEach((acceptor, donor) -> { this.copies.forEach((acceptor, donor) -> {
ClientItem clientitem = this.itemInfos.get(donor); ClientItem donorInfo = this.itemInfos.get(donor);
if (clientitem == null) { if (donorInfo == null) {
@@ -132,8 +_,8 @@ @@ -131,8 +_,8 @@
this.register(acceptor, clientitem); this.register(acceptor, donorInfo);
} }
}); });
- List<Identifier> list = BuiltInRegistries.ITEM - List<Identifier> missingDefinitions = BuiltInRegistries.ITEM
- .listElements() - .listElements()
+ List<Identifier> list = known.get() + List<Identifier> missingDefinitions = known.get()
+ .map(item -> item.builtInRegistryHolder()) + .map(item -> item.builtInRegistryHolder())
.filter(e -> !this.itemInfos.containsKey(e.value())) .filter(e -> !this.itemInfos.containsKey(e.value()))
.map(e -> e.key().identifier()) .map(e -> e.key().identifier())
@@ -29,32 +29,32 @@
this.extractCameraOverlays(graphics, deltaTracker); this.extractCameraOverlays(graphics, deltaTracker);
this.extractCrosshair(graphics, deltaTracker); this.extractCrosshair(graphics, deltaTracker);
@@ -385,7 +_,7 @@ @@ -385,7 +_,7 @@
int i = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window)); int mouseX = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window));
int j = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window)); int mouseY = Mth.floor(this.minecraft.mouseHandler.getScaledYPos(window));
graphics.nextStratum(); graphics.nextStratum();
- this.chat.extractRenderState(graphics, this.getFont(), this.tickCount, i, j, ChatComponent.DisplayMode.BACKGROUND, false); - this.chat.extractRenderState(graphics, this.getFont(), this.tickCount, mouseX, mouseY, ChatComponent.DisplayMode.BACKGROUND, false);
+ net.minecraftforge.client.ForgeHooksClient.onCustomizeChatEvent(graphics, this.chat, window, i, j, this.tickCount, this.getFont()); + net.minecraftforge.client.ForgeHooksClient.onCustomizeChatEvent(graphics, this.chat, window, mouseX, mouseY, this.tickCount, this.getFont());
} }
} }
@@ -475,6 +_,8 @@ @@ -478,6 +_,8 @@
for (MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { for (MobEffectInstance instance : Ordering.natural().reverse().sortedCopy(activeEffects)) {
Holder<MobEffect> holder = mobeffectinstance.getEffect(); Holder<MobEffect> effect = instance.getEffect();
+ var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance); + var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(instance);
+ if (!renderer.isVisibleInGui(mobeffectinstance)) continue; + if (!renderer.isVisibleInGui(instance)) continue;
if (mobeffectinstance.showIcon()) { if (instance.showIcon()) {
int k = graphics.guiWidth(); int x = graphics.guiWidth();
int l = 1; int y = 1;
@@ -505,6 +_,7 @@ @@ -508,6 +_,7 @@
} }
} }
+ if (renderer.extractGuiIcon(mobeffectinstance, this, graphics, k, l, 0, f)) continue; + if (renderer.extractGuiIcon(instance, this, graphics, x, y, 0, alpha)) continue;
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(holder), k + 3, l + 3, 18, 18, ARGB.white(f)); graphics.blitSprite(RenderPipelines.GUI_TEXTURED, getMobEffectSprite(effect), x + 3, y + 3, 18, 18, ARGB.white(alpha));
} }
} }
@@ -605,6 +_,10 @@ @@ -610,15 +_,23 @@
} }
public void extractSelectedItemName(final GuiGraphicsExtractor graphics) { public void extractSelectedItemName(final GuiGraphicsExtractor graphics) {
@@ -63,40 +63,39 @@
+ +
+ public void renderSelectedItemName(final GuiGraphicsExtractor graphics, int yShift) { + public void renderSelectedItemName(final GuiGraphicsExtractor graphics, int yShift) {
if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) { if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) {
MutableComponent mutablecomponent = Component.empty() MutableComponent str = Component.empty().append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color());
.append(this.lastToolHighlight.getHoverName()) if (this.lastToolHighlight.has(DataComponents.CUSTOM_NAME)) {
@@ -613,9 +_,13 @@ str.withStyle(ChatFormatting.ITALIC);
mutablecomponent.withStyle(ChatFormatting.ITALIC);
} }
- int i = this.getFont().width(mutablecomponent); - int strWidth = this.getFont().width(str);
+ Component highlightTip = this.lastToolHighlight.getHighlightTip(mutablecomponent); + Component highlightTip = this.lastToolHighlight.getHighlightTip(str);
+ Font font = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(lastToolHighlight).getFont(lastToolHighlight, net.minecraftforge.client.extensions.common.IClientItemExtensions.FontContext.SELECTED_ITEM_NAME); + Font font = net.minecraftforge.client.extensions.common.IClientItemExtensions.of(lastToolHighlight).getFont(lastToolHighlight, net.minecraftforge.client.extensions.common.IClientItemExtensions.FontContext.SELECTED_ITEM_NAME);
+ if (font == null) + if (font == null)
+ font = this.getFont(); + font = this.getFont();
+ int i = font.width(highlightTip); + int strWidth = font.width(highlightTip);
int j = (graphics.guiWidth() - i) / 2; int x = (graphics.guiWidth() - strWidth) / 2;
- int k = graphics.guiHeight() - 59; - int y = graphics.guiHeight() - 59;
+ int k = graphics.guiHeight() - Math.max(yShift, 59); + int y = graphics.guiHeight() - Math.max(yShift, 59);
if (!this.minecraft.gameMode.canHurtPlayer()) { if (!this.minecraft.gameMode.canHurtPlayer()) {
k += 14; y += 14;
} }
@@ -626,7 +_,7 @@ @@ -629,7 +_,7 @@
} }
if (l > 0) { if (alpha > 0) {
- graphics.textWithBackdrop(this.getFont(), mutablecomponent, j, k, i, ARGB.white(l)); - graphics.textWithBackdrop(this.getFont(), str, x, y, strWidth, ARGB.white(alpha));
+ graphics.textWithBackdrop(font, highlightTip, j, k, i, ARGB.white(l)); + graphics.textWithBackdrop(font, highlightTip, x, y, strWidth, ARGB.white(alpha));
} }
} }
} }
@@ -1165,7 +_,9 @@ @@ -1195,7 +_,9 @@
this.toolHighlightTimer = 0; this.toolHighlightTimer = 0;
} else if (this.lastToolHighlight.isEmpty() } else if (this.lastToolHighlight.isEmpty()
|| !itemstack.is(this.lastToolHighlight.getItem()) || !selected.is(this.lastToolHighlight.getItem())
- || !itemstack.getHoverName().equals(this.lastToolHighlight.getHoverName())) { - || !selected.getHoverName().equals(this.lastToolHighlight.getHoverName())) {
+ || !itemstack.getHoverName().equals(this.lastToolHighlight.getHoverName()) + || !selected.getHoverName().equals(this.lastToolHighlight.getHoverName())
+ || !itemstack.getHighlightTip(itemstack.getHoverName()).equals(lastToolHighlight.getHighlightTip(lastToolHighlight.getHoverName())) + || !selected.getHighlightTip(selected.getHoverName()).equals(lastToolHighlight.getHighlightTip(lastToolHighlight.getHoverName()))
+ ) { + ) {
this.toolHighlightTimer = (int)(40.0 * this.minecraft.options.notificationDisplayTime().get()); this.toolHighlightTimer = (int)(40.0 * this.minecraft.options.notificationDisplayTime().get());
} else if (this.toolHighlightTimer > 0) { } else if (this.toolHighlightTimer > 0) {
@@ -9,15 +9,15 @@
private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2; private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE = 2;
private final Minecraft minecraft; private final Minecraft minecraft;
private final Matrix3x2fStack pose; private final Matrix3x2fStack pose;
@@ -867,6 +_,7 @@ @@ -914,6 +_,7 @@
CrashReport crashreport = CrashReport.forThrowable(throwable, "Rendering item"); CrashReport report = CrashReport.forThrowable(var11, "Rendering item");
CrashReportCategory crashreportcategory = crashreport.addCategory("Item being rendered"); CrashReportCategory category = report.addCategory("Item being rendered");
crashreportcategory.setDetail("Item Type", () -> String.valueOf(itemStack.getItem())); category.setDetail("Item Type", () -> String.valueOf(itemStack.getItem()));
+ crashreportcategory.setDetail("Registry Name", () -> String.valueOf(net.minecraftforge.registries.ForgeRegistries.ITEMS.getKey(itemStack.getItem()))); + category.setDetail("Registry Name", () -> String.valueOf(net.minecraftforge.registries.ForgeRegistries.ITEMS.getKey(itemStack.getItem())));
crashreportcategory.setDetail("Item Components", () -> String.valueOf(itemStack.getComponents())); category.setDetail("Item Components", () -> String.valueOf(itemStack.getComponents()));
crashreportcategory.setDetail("Item Foil", () -> String.valueOf(itemStack.hasFoil())); category.setDetail("Item Foil", () -> String.valueOf(itemStack.hasFoil()));
throw new ReportedException(crashreport); throw new ReportedException(report);
@@ -893,6 +_,7 @@ @@ -940,6 +_,7 @@
this.itemCooldown(itemStack, x, y); this.itemCooldown(itemStack, x, y);
this.itemCount(font, itemStack, x, y, countText); this.itemCount(font, itemStack, x, y, countText);
this.pose.popMatrix(); this.pose.popMatrix();
@@ -25,7 +25,7 @@
} }
} }
@@ -1069,16 +_,25 @@ @@ -1112,16 +_,25 @@
this.setTooltipForNextFrame(this.minecraft.font, formattedCharSequences, DefaultTooltipPositioner.INSTANCE, x, y, false); this.setTooltipForNextFrame(this.minecraft.font, formattedCharSequences, DefaultTooltipPositioner.INSTANCE, x, y, false);
} }
@@ -51,17 +51,20 @@
public void setTooltipForNextFrame( public void setTooltipForNextFrame(
final Font font, final Font font,
final List<Component> texts, final List<Component> texts,
@@ -1087,8 +_,7 @@ @@ -1130,11 +_,7 @@
final int yo, final int yo,
final @Nullable Identifier style final @Nullable Identifier style
) { ) {
- List<ClientTooltipComponent> list = texts.stream().map(Component::getVisualOrderText).map(ClientTooltipComponent::create).collect(Util.toMutableList()); - List<ClientTooltipComponent> components = texts.stream()
- optionalImage.ifPresent(image -> list.add(list.isEmpty() ? 0 : 1, ClientTooltipComponent.create(image))); - .map(Component::getVisualOrderText)
+ List<ClientTooltipComponent> list = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, texts, optionalImage, xo, guiWidth(), guiHeight(), font); - .map(ClientTooltipComponent::create)
this.setTooltipForNextFrameInternal(font, list, xo, yo, DefaultTooltipPositioner.INSTANCE, style, false); - .collect(Util.toMutableList());
- optionalImage.ifPresent(image -> components.add(components.isEmpty() ? 0 : 1, ClientTooltipComponent.create(image)));
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(this.tooltipStack, texts, optionalImage, xo, guiWidth(), guiHeight(), font);
this.setTooltipForNextFrameInternal(font, components, xo, yo, DefaultTooltipPositioner.INSTANCE, style, false);
} }
@@ -1116,7 +_,22 @@ @@ -1162,7 +_,22 @@
} }
public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo) { public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo) {
@@ -85,7 +88,7 @@
} }
public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo, final @Nullable Identifier style) { public void setComponentTooltipForNextFrame(final Font font, final List<Component> lines, final int xo, final int yo, final @Nullable Identifier style) {
@@ -1167,10 +_,16 @@ @@ -1213,10 +_,16 @@
) { ) {
if (!lines.isEmpty()) { if (!lines.isEmpty()) {
if (this.deferredTooltip == null || replaceExisting) { if (this.deferredTooltip == null || replaceExisting) {
@@ -103,7 +106,7 @@
public void tooltip( public void tooltip(
final Font font, final Font font,
@@ -1178,13 +_,16 @@ @@ -1224,13 +_,16 @@
final int xo, final int xo,
final int yo, final int yo,
final ClientTooltipPositioner positioner, final ClientTooltipPositioner positioner,
@@ -113,48 +116,48 @@
) { ) {
+ var preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(itemstack, this, xo, yo, guiWidth(), guiHeight(), lines, font, positioner, style); + var preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(itemstack, this, xo, yo, guiWidth(), guiHeight(), lines, font, positioner, style);
+ if (preEvent == null) return; + if (preEvent == null) return;
int i = 0; int textWidth = 0;
int j = lines.size() == 1 ? -2 : 0; int tempHeight = lines.size() == 1 ? -2 : 0;
for (ClientTooltipComponent clienttooltipcomponent : lines) { for (ClientTooltipComponent line : lines) {
- int k = clienttooltipcomponent.getWidth(font); - int lineWidth = line.getWidth(font);
+ int k = clienttooltipcomponent.getWidth(preEvent.getFont()); + int lineWidth = line.getWidth(preEvent.getFont());
if (k > i) { if (lineWidth > textWidth) {
i = k; textWidth = lineWidth;
} }
@@ -1194,25 +_,25 @@ @@ -1240,25 +_,25 @@
int l1 = i; int w = textWidth;
int i2 = j; int h = tempHeight;
- Vector2ic vector2ic = positioner.positionTooltip(this.guiWidth(), this.guiHeight(), xo, yo, i, j); - Vector2ic positionedTooltip = positioner.positionTooltip(this.guiWidth(), this.guiHeight(), xo, yo, textWidth, tempHeight);
+ Vector2ic vector2ic = positioner.positionTooltip(this.guiWidth(), this.guiHeight(), preEvent.getX(), preEvent.getY(), i, j); + Vector2ic positionedTooltip = positioner.positionTooltip(this.guiWidth(), this.guiHeight(), preEvent.getX(), preEvent.getY(), textWidth, tempHeight);
int l = vector2ic.x(); int x = positionedTooltip.x();
int i1 = vector2ic.y(); int y = positionedTooltip.y();
this.pose.pushMatrix(); this.pose.pushMatrix();
- TooltipRenderUtil.extractTooltipBackground(this, l, i1, i, j, style); - TooltipRenderUtil.extractTooltipBackground(this, x, y, textWidth, tempHeight, style);
+ TooltipRenderUtil.extractTooltipBackground(this, l, i1, i, j, preEvent.getBackground()); + TooltipRenderUtil.extractTooltipBackground(this, x, y, textWidth, tempHeight, preEvent.getBackground());
int j1 = i1; int localY = y;
for (int k1 = 0; k1 < lines.size(); k1++) { for (int i = 0; i < lines.size(); i++) {
ClientTooltipComponent clienttooltipcomponent1 = lines.get(k1); ClientTooltipComponent line = lines.get(i);
- clienttooltipcomponent1.extractText(this, font, l, j1); - line.extractText(this, font, x, localY);
- j1 += clienttooltipcomponent1.getHeight(font) + (k1 == 0 ? 2 : 0); - localY += line.getHeight(font) + (i == 0 ? 2 : 0);
+ clienttooltipcomponent1.extractText(this, preEvent.getFont(), l, j1); + line.extractText(this, preEvent.getFont(), x, localY);
+ j1 += clienttooltipcomponent1.getHeight(preEvent.getFont()) + (k1 == 0 ? 2 : 0); + localY += line.getHeight(preEvent.getFont()) + (i == 0 ? 2 : 0);
} }
j1 = i1; localY = y;
for (int j2 = 0; j2 < lines.size(); j2++) { for (int i = 0; i < lines.size(); i++) {
ClientTooltipComponent clienttooltipcomponent2 = lines.get(j2); ClientTooltipComponent line = lines.get(i);
- clienttooltipcomponent2.extractImage(font, l, j1, l1, i2, this); - line.extractImage(font, x, localY, w, h, this);
- j1 += clienttooltipcomponent2.getHeight(font) + (j2 == 0 ? 2 : 0); - localY += line.getHeight(font) + (i == 0 ? 2 : 0);
+ clienttooltipcomponent2.extractImage(preEvent.getFont(), l, j1, l1, i2, this); + line.extractImage(preEvent.getFont(), x, localY, w, h, this);
+ j1 += clienttooltipcomponent2.getHeight(preEvent.getFont()) + (j2 == 0 ? 2 : 0); + localY += line.getHeight(preEvent.getFont()) + (i == 0 ? 2 : 0);
} }
this.pose.popMatrix(); this.pose.popMatrix();
@@ -1287,6 +_,14 @@ @@ -1333,6 +_,14 @@
private ActiveTextCollector.Parameters createDefaultTextParameters(final float opacity) { private ActiveTextCollector.Parameters createDefaultTextParameters(final float opacity) {
return new ActiveTextCollector.Parameters(new Matrix3x2f(this.pose), opacity, this.scissorStack.peek()); return new ActiveTextCollector.Parameters(new Matrix3x2f(this.pose), opacity, this.scissorStack.peek());
@@ -2,19 +2,19 @@
+++ b/net/minecraft/client/gui/components/BossHealthOverlay.java +++ b/net/minecraft/client/gui/components/BossHealthOverlay.java
@@ -68,13 +_,16 @@ @@ -68,13 +_,16 @@
for (LerpingBossEvent lerpingbossevent : this.events.values()) { for (LerpingBossEvent event : this.events.values()) {
int k = i / 2 - 91; int xLeft = screenWidth / 2 - 91;
+ var event = net.minecraftforge.client.ForgeHooksClient.onCustomizeBossEventProgress(graphics, this.minecraft.getWindow(), lerpingbossevent, k, j, 10 + this.minecraft.font.lineHeight); + var progressEvent = net.minecraftforge.client.ForgeHooksClient.onCustomizeBossEventProgress(graphics, this.minecraft.getWindow(), event, xLeft, yOffset, 10 + this.minecraft.font.lineHeight);
+ if (event != null) { + if (progressEvent != null) {
this.extractBar(graphics, k, j, lerpingbossevent); this.extractBar(graphics, xLeft, yOffset, event);
Component component = lerpingbossevent.getName(); Component msg = event.getName();
int l = this.minecraft.font.width(component); int width = this.minecraft.font.width(msg);
int i1 = i / 2 - l / 2; int x = screenWidth / 2 - width / 2;
int j1 = j - 9; int y = yOffset - 9;
graphics.text(this.minecraft.font, component, i1, j1, -1); graphics.text(this.minecraft.font, msg, x, y, -1);
- j += 10 + 9; - yOffset += 10 + 9;
+ } + }
+ j += event.getIncrement(); + yOffset += progressEvent.getIncrement();
if (j >= graphics.guiHeight() / 3) { if (yOffset >= graphics.guiHeight() / 3) {
break; break;
} }
@@ -2,9 +2,9 @@
+++ b/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java +++ b/net/minecraft/client/gui/components/debug/DebugEntryLookingAtEntity.java
@@ -29,6 +_,7 @@ @@ -29,6 +_,7 @@
if (entity != null) { if (entity != null) {
list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); result.add(ChatFormatting.UNDERLINE + "Targeted Entity");
list.add(entity.typeHolder().getRegisteredName()); result.add(entity.typeHolder().getRegisteredName());
+ entity.getType().builtInRegistryHolder().tags().forEach(t -> list.add("#" + t.location())); + entity.getType().builtInRegistryHolder().tags().forEach(t -> result.add("#" + t.location()));
} }
displayer.addToGroup(GROUP, list); displayer.addToGroup(GROUP, result);
@@ -1,7 +1,7 @@
--- a/net/minecraft/client/gui/render/GuiRenderer.java --- a/net/minecraft/client/gui/render/GuiRenderer.java
+++ b/net/minecraft/client/gui/render/GuiRenderer.java +++ b/net/minecraft/client/gui/render/GuiRenderer.java
@@ -131,6 +_,7 @@ @@ -130,6 +_,7 @@
builder.put((Class<? extends PictureInPictureRenderState>)pictureinpicturerenderer.getRenderStateClass(), pictureinpicturerenderer); builder.put((Class<? extends PictureInPictureRenderState>)pictureInPictureRenderer.getRenderStateClass(), pictureInPictureRenderer);
} }
+ net.minecraftforge.client.ForgeHooksClient.onRegisterPictureInPictureRenderers(pictureInPictureRenderers, bufferSource, builder); + net.minecraftforge.client.ForgeHooksClient.onRegisterPictureInPictureRenderers(pictureInPictureRenderers, bufferSource, builder);
@@ -3,7 +3,7 @@
@@ -114,6 +_,8 @@ @@ -114,6 +_,8 @@
} }
if (optional.isEmpty()) { if (resolvedAddress.isEmpty()) {
+ ConnectScreen.LOGGER.error("Couldn't connect to server: Unknown host \"{}\"", hostAndPort.getHost()); + ConnectScreen.LOGGER.error("Couldn't connect to server: Unknown host \"{}\"", hostAndPort.getHost());
+ net.minecraftforge.network.DualStackUtils.logInitialPreferences(); + net.minecraftforge.network.DualStackUtils.logInitialPreferences();
minecraft.execute( minecraft.execute(
@@ -8,24 +8,24 @@
+ +
@Override @Override
public void extractRenderState(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) { public void extractRenderState(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) {
int i = graphics.guiWidth(); int width = graphics.guiWidth();
@@ -103,6 +_,7 @@ @@ -103,6 +_,7 @@
f2 = 1.0F; logoAlpha = 1.0F;
} }
+ if (extractContentRenderState(graphics, f2)) { + if (extractContentRenderState(graphics, logoAlpha)) {
int k2 = (int)(graphics.guiWidth() * 0.5); int contentX = (int)(graphics.guiWidth() * 0.5);
int i1 = (int)(graphics.guiHeight() * 0.5); int logoY = (int)(graphics.guiHeight() * 0.5);
double d0 = Math.min(graphics.guiWidth() * 0.75, (double)graphics.guiHeight()) * 0.25; double logoHeight = Math.min(graphics.guiWidth() * 0.75, (double)graphics.guiHeight()) * 0.25;
@@ -118,6 +_,7 @@ @@ -148,6 +_,7 @@
if (f < 1.0F) { graphics, width / 2 - logoWidthHalf, barY - 5, width / 2 + logoWidthHalf, barY + 5, 1.0F - Mth.clamp(fadeOutAnim, 0.0F, 1.0F)
this.extractProgressBar(graphics, i / 2 - k1, i2 - 5, i / 2 + k1, i2 + 5, 1.0F - Mth.clamp(f, 0.0F, 1.0F)); );
} }
+ } + }
if (f >= 2.0F) { if (fadeOutAnim >= 2.0F) {
this.minecraft.setOverlay(null); this.minecraft.setOverlay(null);
@@ -127,6 +_,7 @@ @@ -157,6 +_,7 @@
@Override @Override
public void tick() { public void tick() {
if (this.fadeOutStart == -1L && this.reload.isDone() && this.isReadyToFadeOut()) { if (this.fadeOutStart == -1L && this.reload.isDone() && this.isReadyToFadeOut()) {
@@ -33,8 +33,8 @@
try { try {
this.reload.checkExceptions(); this.reload.checkExceptions();
this.onFinish.accept(Optional.empty()); this.onFinish.accept(Optional.empty());
@@ -134,7 +_,6 @@ @@ -164,7 +_,6 @@
this.onFinish.accept(Optional.of(throwable)); this.onFinish.accept(Optional.of(var2));
} }
- this.fadeOutStart = Util.getMillis(); - this.fadeOutStart = Util.getMillis();
@@ -8,13 +8,13 @@
+ } + }
+ +
+ public static <T extends AbstractContainerMenu> java.util.Optional<ScreenConstructor<T, ?>> getScreenFactory(@Nullable MenuType<T> type, Minecraft minecraft, int containerId, Component title) { + public static <T extends AbstractContainerMenu> java.util.Optional<ScreenConstructor<T, ?>> getScreenFactory(@Nullable MenuType<T> type, Minecraft minecraft, int containerId, Component title) {
MenuScreens.ScreenConstructor<T, ?> screenconstructor = getConstructor(type); MenuScreens.ScreenConstructor<T, ?> constructor = getConstructor(type);
if (screenconstructor == null) { if (constructor == null) {
LOGGER.warn("Failed to create screen for menu type: {}", BuiltInRegistries.MENU.getKey(type)); LOGGER.warn("Failed to create screen for menu type: {}", BuiltInRegistries.MENU.getKey(type));
+ return java.util.Optional.empty(); + return java.util.Optional.empty();
} else { } else {
- screenconstructor.fromPacket(title, type, minecraft, containerId); - constructor.fromPacket(title, type, minecraft, containerId);
+ return java.util.Optional.of(screenconstructor); + return java.util.Optional.of(constructor);
} }
} }
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/gui/screens/PauseScreen.java --- a/net/minecraft/client/gui/screens/PauseScreen.java
+++ b/net/minecraft/client/gui/screens/PauseScreen.java +++ b/net/minecraft/client/gui/screens/PauseScreen.java
@@ -104,6 +_,7 @@ @@ -102,6 +_,7 @@
} else { } else {
gridlayout$rowhelper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this))); helper.addChild(this.openScreenButton(PLAYER_REPORTING, () -> new SocialInteractionsScreen(this)));
} }
+ gridlayout$rowhelper.addChild(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.minecraftforge.client.gui.ModListScreen(this))).width(BUTTON_WIDTH_FULL).build(), 2); + helper.addChild(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.minecraftforge.client.gui.ModListScreen(this))).width(BUTTON_WIDTH_FULL).build(), 2);
this.disconnectButton = gridlayout$rowhelper.addChild( this.disconnectButton = helper.addChild(
Button.builder( Button.builder(
@@ -9,47 +9,47 @@
public TitleScreen() { public TitleScreen() {
this(false); this(false);
@@ -105,11 +_,15 @@ @@ -105,11 +_,15 @@
int j = this.width - i - 2; int copyrightX = this.width - copyrightWidth - 2;
int k = 24; int spacing = 24;
int l = this.height / 4 + 48; int topPos = this.height / 4 + 48;
+ Button modButton = null; + Button modButton = null;
if (this.minecraft.isDemo()) { if (this.minecraft.isDemo()) {
l = this.createDemoMenuOptions(l, 24); topPos = this.createDemoMenuOptions(topPos, 24);
} else { } else {
l = this.createNormalMenuOptions(l, 24); topPos = this.createNormalMenuOptions(topPos, 24);
+ modButton = this.addRenderableWidget(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.minecraftforge.client.gui.ModListScreen(this))) + modButton = this.addRenderableWidget(Button.builder(Component.translatable("fml.menu.mods"), button -> this.minecraft.setScreen(new net.minecraftforge.client.gui.ModListScreen(this)))
+ .pos(this.width / 2 - 100, l).size(98, 20).build()); + .pos(this.width / 2 - 100, topPos).size(98, 20).build());
} }
+ modUpdateNotification = net.minecraftforge.client.gui.TitleScreenModUpdateIndicator.init(this, modButton); + modUpdateNotification = net.minecraftforge.client.gui.TitleScreenModUpdateIndicator.init(this, modButton);
l = this.createTestWorldButton(l, 24); topPos = this.createTestWorldButton(topPos, 24);
SpriteIconButton spriteiconbutton = this.addRenderableWidget( SpriteIconButton language = this.addRenderableWidget(
@@ -176,7 +_,7 @@ @@ -182,7 +_,7 @@
}).bounds(this.width / 2 - 100, i = topPos + spacing, 200, 20).tooltip(tooltip).build()).active = flag; }).bounds(this.width / 2 - 100, var6 = topPos + spacing, 200, 20).tooltip(tooltip).build()).active = multiplayerAllowed;
this.addRenderableWidget( this.addRenderableWidget(
Button.builder(Component.translatable("menu.online"), button -> this.minecraft.setScreen(new RealmsMainScreen(this))) Button.builder(Component.translatable("menu.online"), button -> this.minecraft.setScreen(new RealmsMainScreen(this)))
- .bounds(this.width / 2 - 100, topPos = i + spacing, 200, 20) - .bounds(this.width / 2 - 100, topPos = var6 + spacing, 200, 20)
+ .bounds(this.width / 2 + 2, topPos = i + spacing, 98, 20) + .bounds(this.width / 2 + 2, topPos = var6 + spacing, 98, 20)
.tooltip(tooltip) .tooltip(tooltip)
.build() .build()
) )
@@ -304,9 +_,18 @@ @@ -310,9 +_,18 @@
s = s + I18n.get("menu.modded"); versionString = versionString + I18n.get("menu.modded");
} }
- graphics.text(this.font, s, 2, this.height - 10, ARGB.white(f)); - graphics.text(this.font, versionString, 2, this.height - 10, ARGB.white(widgetFade));
+ final float f_f = f; + final float widgetFade_f = widgetFade;
+ net.minecraftforge.internal.BrandingControl.forEachLine(true, true, (brd, brdline) -> + net.minecraftforge.internal.BrandingControl.forEachLine(true, true, (brd, brdline) ->
+ graphics.text(this.font, brd, 2, this.height - ( 10 + brdline * (this.font.lineHeight + 1)), ARGB.color(f_f, -1)) + graphics.text(this.font, brd, 2, this.height - ( 10 + brdline * (this.font.lineHeight + 1)), ARGB.color(widgetFade_f, -1))
+ ); + );
+ +
+ net.minecraftforge.internal.BrandingControl.forEachAboveCopyrightLine((brd, brdline) -> + net.minecraftforge.internal.BrandingControl.forEachAboveCopyrightLine((brd, brdline) ->
+ graphics.text(this.font, brd, this.width - font.width(brd), this.height - (10 + (brdline + 1) * ( this.font.lineHeight + 1)), ARGB.color(f_f, -1)) + graphics.text(this.font, brd, this.width - font.width(brd), this.height - (10 + (brdline + 1) * ( this.font.lineHeight + 1)), ARGB.color(widgetFade_f, -1))
+ ); + );
+ +
if (this.realmsNotificationsEnabled() && f >= 1.0F) { if (this.realmsNotificationsEnabled() && widgetFade >= 1.0F) {
this.realmsNotificationsScreen.extractRenderState(graphics, mouseX, mouseY, a); this.realmsNotificationsScreen.extractRenderState(graphics, mouseX, mouseY, a);
+ if (f >= 1.0f) this.modUpdateNotification.extractRenderState(graphics, mouseX, mouseY, a); + if (widgetFade >= 1.0f) this.modUpdateNotification.extractRenderState(graphics, mouseX, mouseY, a);
} }
} }
@@ -27,11 +27,11 @@
@@ -155,8 +_,8 @@ @@ -155,8 +_,8 @@
return null; return null;
} else { } else {
for (AdvancementTabType advancementtabtype : AdvancementTabType.values()) { for (AdvancementTabType type : AdvancementTabType.values()) {
- if (index < advancementtabtype.getMax()) { - if (index < type.getMax()) {
- return new AdvancementTab(minecraft, screen, advancementtabtype, index, root, optional.get()); - return new AdvancementTab(minecraft, screen, type, index, root, display.get());
+ if ((index % AdvancementTabType.MAX_TABS) < advancementtabtype.getMax()) { + if ((index % AdvancementTabType.MAX_TABS) < type.getMax()) {
+ return new AdvancementTab(minecraft, screen, advancementtabtype, index % AdvancementTabType.MAX_TABS, index / AdvancementTabType.MAX_TABS, root, optional.get()); + return new AdvancementTab(minecraft, screen, type, index % AdvancementTabType.MAX_TABS, index / AdvancementTabType.MAX_TABS, root, display.get());
} }
index -= advancementtabtype.getMax(); index -= type.getMax();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java --- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java
+++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java
@@ -51,6 +_,7 @@ @@ -50,6 +_,7 @@
private final Map<AdvancementHolder, AdvancementTab> tabs = Maps.newLinkedHashMap(); private final Map<AdvancementHolder, AdvancementTab> tabs = Maps.newLinkedHashMap();
private @Nullable AdvancementTab selectedTab; private @Nullable AdvancementTab selectedTab;
private boolean isScrolling; private boolean isScrolling;
@@ -8,7 +8,7 @@
public AdvancementsScreen(final ClientAdvancements advancements) { public AdvancementsScreen(final ClientAdvancements advancements) {
this(advancements, null); this(advancements, null);
@@ -64,6 +_,19 @@ @@ -63,6 +_,19 @@
@Override @Override
protected void init() { protected void init() {
@@ -28,33 +28,33 @@
this.layout.addTitleHeader(TITLE, this.font); this.layout.addTitleHeader(TITLE, this.font);
this.tabs.clear(); this.tabs.clear();
this.selectedTab = null; this.selectedTab = null;
@@ -106,7 +_,7 @@ @@ -105,7 +_,7 @@
int j = (this.height - 140) / 2; int yo = (this.height - 140) / 2;
for (AdvancementTab advancementtab : this.tabs.values()) { for (AdvancementTab tab : this.tabs.values()) {
- if (advancementtab.isMouseOver(i, j, event.x(), event.y())) { - if (tab.isMouseOver(xo, yo, event.x(), event.y())) {
+ if (advancementtab.getPage() == tabPage && advancementtab.isMouseOver(i, j, event.x(), event.y())) { + if (tab.getPage() == tabPage && tab.isMouseOver(xo, yo, event.x(), event.y())) {
this.advancements.setSelectedTab(advancementtab.getRootNode().holder(), true); this.advancements.setSelectedTab(tab.getRootNode().holder(), true);
break; break;
} }
@@ -197,10 +_,12 @@ @@ -196,10 +_,12 @@
graphics.blit(RenderPipelines.GUI_TEXTURED, WINDOW_LOCATION, xo, yo, 0.0F, 0.0F, 252, 140, 256, 256); graphics.blit(RenderPipelines.GUI_TEXTURED, WINDOW_LOCATION, xo, yo, 0.0F, 0.0F, 252, 140, 256, 256);
if (this.tabs.size() > 1) { if (this.tabs.size() > 1) {
for (AdvancementTab advancementtab : this.tabs.values()) { for (AdvancementTab tab : this.tabs.values()) {
+ if (advancementtab.getPage() == tabPage) + if (tab.getPage() == tabPage)
advancementtab.extractTab(graphics, xo, yo, mouseX, mouseY, advancementtab == this.selectedTab); tab.extractTab(graphics, xo, yo, mouseX, mouseY, tab == this.selectedTab);
} }
for (AdvancementTab advancementtab1 : this.tabs.values()) { for (AdvancementTab tab : this.tabs.values()) {
+ if (advancementtab1.getPage() == tabPage) + if (tab.getPage() == tabPage)
advancementtab1.extractIcon(graphics, xo, yo); tab.extractIcon(graphics, xo, yo);
} }
} }
@@ -219,6 +_,7 @@ @@ -218,6 +_,7 @@
if (this.tabs.size() > 1) { if (this.tabs.size() > 1) {
for (AdvancementTab advancementtab : this.tabs.values()) { for (AdvancementTab tab : this.tabs.values()) {
+ if (advancementtab.getPage() == tabPage) + if (tab.getPage() == tabPage)
if (advancementtab.isMouseOver(xo, yo, mouseX, mouseY)) { if (tab.isMouseOver(xo, yo, mouseX, mouseY)) {
graphics.setTooltipForNextFrame(this.font, advancementtab.getTitle(), mouseX, mouseY); graphics.setTooltipForNextFrame(this.font, tab.getTitle(), mouseX, mouseY);
} }
@@ -1,34 +1,31 @@
--- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java --- a/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java +++ b/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java
@@ -111,6 +_,7 @@ @@ -111,6 +_,7 @@
int i = this.leftPos; int xo = this.leftPos;
int j = this.topPos; int yo = this.topPos;
super.extractRenderState(graphics, mouseX, mouseY, a); super.extractRenderState(graphics, mouseX, mouseY, a);
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onContainerRenderBackground(this, graphics, mouseX, mouseY); + net.minecraftforge.client.event.ForgeEventFactoryClient.onContainerRenderBackground(this, graphics, mouseX, mouseY);
graphics.pose().pushMatrix(); graphics.pose().pushMatrix();
graphics.pose().translate(i, j); graphics.pose().translate(xo, yo);
this.extractLabels(graphics, mouseX, mouseY); this.extractLabels(graphics, mouseX, mouseY);
@@ -122,6 +_,7 @@ @@ -122,6 +_,7 @@
if (slot != null && slot != this.hoveredSlot) { if (previouslyHoveredSlot != null && previouslyHoveredSlot != this.hoveredSlot) {
this.onStopHovering(slot); this.onStopHovering(previouslyHoveredSlot);
} }
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onContainerRenderForeground(this, graphics, mouseX, mouseY); + net.minecraftforge.client.event.ForgeEventFactoryClient.onContainerRenderForeground(this, graphics, mouseX, mouseY);
graphics.pose().popMatrix(); graphics.pose().popMatrix();
} }
@@ -203,9 +_,9 @@ @@ -200,7 +_,7 @@
this.font, ItemStack item = this.hoveredSlot.getItem();
this.getTooltipFromContainerItem(itemstack), if (this.menu.getCarried().isEmpty() || this.showTooltipWithItemInHand(item)) {
itemstack.getTooltipImage(), graphics.setTooltipForNextFrame(
+ itemstack, - this.font, this.getTooltipFromContainerItem(item), item.getTooltipImage(), mouseX, mouseY, item.get(DataComponents.TOOLTIP_STYLE)
mouseX, + this.font, this.getTooltipFromContainerItem(item), item.getTooltipImage(), item, mouseX, mouseY
- mouseY,
- itemstack.get(DataComponents.TOOLTIP_STYLE)
+ mouseY
); );
} }
} }
@@ -221,7 +_,8 @@ @@ -216,7 +_,8 @@
private void extractFloatingItem(final GuiGraphicsExtractor graphics, final ItemStack carried, final int x, final int y, final @Nullable String itemCount) { private void extractFloatingItem(final GuiGraphicsExtractor graphics, final ItemStack carried, final int x, final int y, final @Nullable String itemCount) {
graphics.item(carried, x, y); graphics.item(carried, x, y);
@@ -38,75 +35,75 @@
} }
protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) { protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) {
@@ -319,7 +_,8 @@ @@ -316,7 +_,8 @@
if (super.mouseClicked(event, doubleClick)) { if (super.mouseClicked(event, doubleClick)) {
return true; return true;
} else { } else {
- boolean flag = this.minecraft.options.keyPickItem.matchesMouse(event) && this.minecraft.player.hasInfiniteMaterials(); - boolean cloning = this.minecraft.options.keyPickItem.matchesMouse(event) && this.minecraft.player.hasInfiniteMaterials();
+ var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(event.button()); + var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(event.button());
+ boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey) && this.minecraft.player.hasInfiniteMaterials(); + boolean cloning = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey) && this.minecraft.player.hasInfiniteMaterials();
Slot slot = this.getHoveredSlot(event.x(), event.y()); Slot slot = this.getHoveredSlot(event.x(), event.y());
this.doubleclick = this.lastClickSlot == slot && doubleClick; this.doubleclick = this.lastClickSlot == slot && doubleClick;
this.skipNextRelease = false; this.skipNextRelease = false;
@@ -329,6 +_,7 @@ @@ -326,6 +_,7 @@
int i = this.leftPos; int xo = this.leftPos;
int j = this.topPos; int yo = this.topPos;
boolean flag1 = this.hasClickedOutside(event.x(), event.y(), i, j); boolean clickedOutside = this.hasClickedOutside(event.x(), event.y(), xo, yo);
+ if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries + if (slot != null) clickedOutside = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
int k = -1; int slotId = -1;
if (slot != null) { if (slot != null) {
k = slot.index; slotId = slot.index;
@@ -354,7 +_,7 @@ @@ -351,7 +_,7 @@
} }
} else if (!this.isQuickCrafting) { } else if (!this.isQuickCrafting) {
if (this.menu.getCarried().isEmpty()) { if (this.menu.getCarried().isEmpty()) {
- if (flag) { - if (cloning) {
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.slotClicked(slot, k, event.button(), ContainerInput.CLONE); this.slotClicked(slot, slotId, event.button(), ContainerInput.CLONE);
} else { } else {
boolean flag2 = k != -999 && event.hasShiftDown(); boolean quickKey = slotId != -999 && event.hasShiftDown();
@@ -378,7 +_,7 @@ @@ -375,7 +_,7 @@
this.quickCraftingType = 0; this.quickCraftingType = 0;
} else if (event.button() == 1) { } else if (event.button() == 1) {
this.quickCraftingType = 1; this.quickCraftingType = 1;
- } else if (flag) { - } else if (cloning) {
+ } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + } else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.quickCraftingType = 2; this.quickCraftingType = 2;
} }
} }
@@ -448,10 +_,13 @@ @@ -445,10 +_,13 @@
@Override @Override
public boolean mouseReleased(final MouseButtonEvent event) { public boolean mouseReleased(final MouseButtonEvent event) {
+ super.mouseReleased(event); //Forge, Call parent to release buttons + super.mouseReleased(event); //Forge, Call parent to release buttons
Slot slot = this.getHoveredSlot(event.x(), event.y()); Slot slot = this.getHoveredSlot(event.x(), event.y());
int i = this.leftPos; int xo = this.leftPos;
int j = this.topPos; int yo = this.topPos;
boolean flag = this.hasClickedOutside(event.x(), event.y(), i, j); boolean clickedOutside = this.hasClickedOutside(event.x(), event.y(), xo, yo);
+ if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries + if (slot != null) clickedOutside = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
+ var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(event.button()); + var mouseKey = com.mojang.blaze3d.platform.InputConstants.Type.MOUSE.getOrCreate(event.button());
int k = -1; int slotId = -1;
if (slot != null) { if (slot != null) {
k = slot.index; slotId = slot.index;
@@ -468,7 +_,7 @@ @@ -465,7 +_,7 @@
if (slot1 != null if (target != null
&& slot1.mayPickup(this.minecraft.player) && target.mayPickup(this.minecraft.player)
&& slot1.hasItem() && target.hasItem()
- && slot1.container == slot.container - && target.container == slot.container
+ && slot1.isSameInventory(slot) + && target.isSameInventory(slot)
&& AbstractContainerMenu.canItemQuickReplace(slot1, this.lastQuickMoved, true)) { && AbstractContainerMenu.canItemQuickReplace(target, this.lastQuickMoved, true)) {
this.slotClicked(slot1, slot1.index, event.button(), ContainerInput.QUICK_MOVE); this.slotClicked(target, target.index, event.button(), ContainerInput.QUICK_MOVE);
} }
@@ -527,7 +_,7 @@ @@ -524,7 +_,7 @@
} else if (this.isQuickCrafting && !this.quickCraftSlots.isEmpty()) { } else if (this.isQuickCrafting && !this.quickCraftSlots.isEmpty()) {
this.quickCraftToSlots(); this.quickCraftToSlots();
} else if (!this.menu.getCarried().isEmpty()) { } else if (!this.menu.getCarried().isEmpty()) {
- if (this.minecraft.options.keyPickItem.matchesMouse(event)) { - if (this.minecraft.options.keyPickItem.matchesMouse(event)) {
+ if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) { + if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
this.slotClicked(slot, k, event.button(), ContainerInput.CLONE); this.slotClicked(slot, slotId, event.button(), ContainerInput.CLONE);
} else { } else {
boolean flag1 = k != -999 && event.hasShiftDown(); boolean quickKey = slotId != -999 && event.hasShiftDown();
@@ -598,7 +_,7 @@ @@ -595,7 +_,7 @@
public boolean keyPressed(final KeyEvent event) { public boolean keyPressed(final KeyEvent event) {
if (super.keyPressed(event)) { if (super.keyPressed(event)) {
return true; return true;
@@ -115,7 +112,7 @@
this.onClose(); this.onClose();
return true; return true;
} else { } else {
@@ -696,6 +_,13 @@ @@ -693,6 +_,13 @@
super.onClose(); super.onClose();
} }
@@ -11,7 +11,7 @@
super(new CreativeModeInventoryScreen.ItemPickerMenu(player), player.getInventory(), CommonComponents.EMPTY, 195, 136); super(new CreativeModeInventoryScreen.ItemPickerMenu(player), player.getInventory(), CommonComponents.EMPTY, 195, 136);
@@ -164,7 +_,7 @@ @@ -164,7 +_,7 @@
private void refreshCurrentTabContents(final Collection<ItemStack> displayList) { private void refreshCurrentTabContents(final Collection<ItemStack> displayList) {
int i = this.menu.getRowIndexForScroll(this.scrollOffs); int oldRowIndex = this.menu.getRowIndexForScroll(this.scrollOffs);
this.menu.items.clear(); this.menu.items.clear();
- if (selectedTab.getType() == CreativeModeTab.Type.SEARCH) { - if (selectedTab.getType() == CreativeModeTab.Type.SEARCH) {
+ if (selectedTab.hasSearchBar()) { + if (selectedTab.hasSearchBar()) {
@@ -63,7 +63,7 @@
+ } else if (!selectedTab.hasSearchBar()) { + } else if (!selectedTab.hasSearchBar()) {
return false; return false;
} else { } else {
String s = this.searchBox.getValue(); String oldContents = this.searchBox.getValue();
@@ -405,7 +_,7 @@ @@ -405,7 +_,7 @@
@Override @Override
public boolean keyPressed(final KeyEvent event) { public boolean keyPressed(final KeyEvent event) {
@@ -80,20 +80,20 @@
+ if (!selectedTab.hasSearchBar()) return; + if (!selectedTab.hasSearchBar()) return;
this.menu.items.clear(); this.menu.items.clear();
this.visibleTags.clear(); this.visibleTags.clear();
String s = this.searchBox.getValue(); String searchTerm = this.searchBox.getValue();
@@ -453,10 +_,10 @@ @@ -453,10 +_,10 @@
SearchTree<ItemStack> searchtree; SearchTree<ItemStack> tree;
if (s.startsWith("#")) { if (searchTerm.startsWith("#")) {
s = s.substring(1); searchTerm = searchTerm.substring(1);
- searchtree = sessionsearchtrees.creativeTagSearch(); - tree = searchTrees.creativeTagSearch();
+ searchtree = sessionsearchtrees.getSearchTree(net.minecraftforge.client.CreativeModeTabSearchRegistry.getTagSearchKey(selectedTab)); + tree = searchTrees.getSearchTree(net.minecraftforge.client.CreativeModeTabSearchRegistry.getTagSearchKey(selectedTab));
this.updateVisibleTags(s); this.updateVisibleTags(searchTerm);
} else { } else {
- searchtree = sessionsearchtrees.creativeNameSearch(); - tree = searchTrees.creativeNameSearch();
+ searchtree = sessionsearchtrees.getSearchTree(net.minecraftforge.client.CreativeModeTabSearchRegistry.getNameSearchKey(selectedTab)); + tree = searchTrees.getSearchTree(net.minecraftforge.client.CreativeModeTabSearchRegistry.getNameSearchKey(selectedTab));
} }
this.menu.items.addAll(searchtree.search(s.toLowerCase(Locale.ROOT))); this.menu.items.addAll(tree.search(searchTerm.toLowerCase(Locale.ROOT)));
@@ -484,7 +_,7 @@ @@ -484,7 +_,7 @@
@Override @Override
protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) { protected void extractLabels(final GuiGraphicsExtractor graphics, final int xm, final int ym) {
@@ -104,22 +104,22 @@
} }
@@ -494,7 +_,7 @@ @@ -494,7 +_,7 @@
double d0 = event.x() - this.leftPos; double xm = event.x() - this.leftPos;
double d1 = event.y() - this.topPos; double ym = event.y() - this.topPos;
- for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { - for (CreativeModeTab tab : CreativeModeTabs.tabs()) {
+ for (CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { + for (CreativeModeTab tab : currentPage.getVisibleTabs()) {
if (this.checkTabClicked(creativemodetab, d0, d1)) { if (this.checkTabClicked(tab, xm, ym)) {
return true; return true;
} }
@@ -516,7 +_,7 @@ @@ -516,7 +_,7 @@
double d1 = event.y() - this.topPos; double ym = event.y() - this.topPos;
this.scrolling = false; this.scrolling = false;
- for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { - for (CreativeModeTab tab : CreativeModeTabs.tabs()) {
+ for (CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { + for (CreativeModeTab tab : currentPage.getVisibleTabs()) {
if (this.checkTabClicked(creativemodetab, d0, d1)) { if (this.checkTabClicked(tab, xm, ym)) {
this.selectTab(creativemodetab); this.selectTab(tab);
return true; return true;
@@ -610,13 +_,15 @@ @@ -610,13 +_,15 @@
this.originalSlots = null; this.originalSlots = null;
@@ -130,7 +130,7 @@
this.searchBox.setVisible(true); this.searchBox.setVisible(true);
this.searchBox.setCanLoseFocus(false); this.searchBox.setCanLoseFocus(false);
this.searchBox.setFocused(true); this.searchBox.setFocused(true);
if (creativemodetab != tab) { if (oldTab != tab) {
this.searchBox.setValue(""); this.searchBox.setValue("");
} }
+ this.searchBox.setWidth(selectedTab.getSearchBarWidth()); + this.searchBox.setWidth(selectedTab.getSearchBarWidth());
@@ -142,7 +142,7 @@
this.effects.extractRenderState(graphics, mouseX, mouseY); this.effects.extractRenderState(graphics, mouseX, mouseY);
super.extractRenderState(graphics, mouseX, mouseY, a); super.extractRenderState(graphics, mouseX, mouseY, a);
- for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { - for (CreativeModeTab tab : CreativeModeTabs.tabs()) {
+ if (this.pages.size() != 1) { + if (this.pages.size() != 1) {
+ Component page = Component.literal(String.format("%d / %d", this.pages.indexOf(this.currentPage) + 1, this.pages.size())); + Component page = Component.literal(String.format("%d / %d", this.pages.indexOf(this.currentPage) + 1, this.pages.size()));
+ graphics.pose().pushMatrix(); + graphics.pose().pushMatrix();
@@ -150,39 +150,39 @@
+ graphics.pose().popMatrix(); + graphics.pose().popMatrix();
+ } + }
+ +
+ for (CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { + for (CreativeModeTab tab : currentPage.getVisibleTabs()) {
if (this.checkTabHovering(graphics, creativemodetab, mouseX, mouseY)) { if (this.checkTabHovering(graphics, tab, mouseX, mouseY)) {
break; break;
} }
@@ -701,7 +_,7 @@ @@ -701,7 +_,7 @@
public List<Component> getTooltipFromContainerItem(final ItemStack itemStack) { public List<Component> getTooltipFromContainerItem(final ItemStack itemStack) {
boolean flag = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot; boolean isCreativeSlot = this.hoveredSlot != null && this.hoveredSlot instanceof CreativeModeInventoryScreen.CustomCreativeSlot;
boolean flag1 = selectedTab.getType() == CreativeModeTab.Type.CATEGORY; boolean isSingleCategoryTab = selectedTab.getType() == CreativeModeTab.Type.CATEGORY;
- boolean flag2 = selectedTab.getType() == CreativeModeTab.Type.SEARCH; - boolean isSearchTab = selectedTab.getType() == CreativeModeTab.Type.SEARCH;
+ boolean flag2 = selectedTab.hasSearchBar(); + boolean isSearchTab = selectedTab.hasSearchBar();
TooltipFlag.Default tooltipflag$default = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL; TooltipFlag.Default originalTooltipStyle = this.minecraft.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL;
TooltipFlag tooltipflag = flag ? tooltipflag$default.asCreative() : tooltipflag$default; TooltipFlag tooltipStyle = isCreativeSlot ? originalTooltipStyle.asCreative() : originalTooltipStyle;
List<Component> list = itemStack.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipflag); List<Component> originalLines = itemStack.getTooltipLines(Item.TooltipContext.of(this.minecraft.level), this.minecraft.player, tooltipStyle);
@@ -722,7 +_,7 @@ @@ -722,7 +_,7 @@
int i = 1; int i = 1;
for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { for (CreativeModeTab tab : CreativeModeTabs.tabs()) {
- if (creativemodetab.getType() != CreativeModeTab.Type.SEARCH && creativemodetab.contains(itemStack)) { - if (tab.getType() != CreativeModeTab.Type.SEARCH && tab.contains(itemStack)) {
+ if (!creativemodetab.hasSearchBar() && creativemodetab.contains(itemStack)) { + if (!tab.hasSearchBar() && tab.contains(itemStack)) {
list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE)); linesToDisplay.add(i++, tab.getDisplayName().copy().withStyle(ChatFormatting.BLUE));
} }
} }
@@ -735,7 +_,7 @@ @@ -735,7 +_,7 @@
public void extractBackground(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) { public void extractBackground(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final float a) {
super.extractBackground(graphics, mouseX, mouseY, a); super.extractBackground(graphics, mouseX, mouseY, a);
- for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) { - for (CreativeModeTab tab : CreativeModeTabs.tabs()) {
+ for (CreativeModeTab creativemodetab : currentPage.getVisibleTabs()) { + for (CreativeModeTab tab : currentPage.getVisibleTabs()) {
if (creativemodetab != selectedTab) { if (tab != selectedTab) {
this.extractTabButton(graphics, mouseX, mouseY, creativemodetab); this.extractTabButton(graphics, mouseX, mouseY, tab);
} }
@@ -770,6 +_,7 @@ @@ -770,6 +_,7 @@
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, identifier, j, k + (int)((i - k - 17) * this.scrollOffs), 12, 15); graphics.blitSprite(RenderPipelines.GUI_TEXTURED, sprite, xscr, yscr + (int)((yscr2 - yscr - 17) * this.scrollOffs), 12, 15);
} }
+ if (currentPage.getVisibleTabs().contains(selectedTab)) //Forge: only display tab selection when the selected tab is on the current page + if (currentPage.getVisibleTabs().contains(selectedTab)) //Forge: only display tab selection when the selected tab is on the current page
@@ -193,39 +193,39 @@
} }
private int getTabX(final CreativeModeTab tab) { private int getTabX(final CreativeModeTab tab) {
- int i = tab.column(); - int pos = tab.column();
+ int i = currentPage.getColumn(tab); + int pos = currentPage.getColumn(tab);
int j = 27; int spacing = 27;
int k = 27 * i; int x = 27 * pos;
if (tab.isAlignedRight()) { if (tab.isAlignedRight()) {
@@ -791,7 +_,7 @@ @@ -791,7 +_,7 @@
private int getTabY(final CreativeModeTab tab) { private int getTabY(final CreativeModeTab tab) {
int i = 0; int y = 0;
- if (tab.row() == CreativeModeTab.Row.TOP) { - if (tab.row() == CreativeModeTab.Row.TOP) {
+ if (currentPage.isTop(tab)) { + if (currentPage.isTop(tab)) {
i -= 32; y -= 32;
} else { } else {
i += this.imageHeight; y += this.imageHeight;
@@ -819,8 +_,8 @@ @@ -819,8 +_,8 @@
protected void extractTabButton(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final CreativeModeTab tab) { protected void extractTabButton(final GuiGraphicsExtractor graphics, final int mouseX, final int mouseY, final CreativeModeTab tab) {
boolean flag = tab == selectedTab; boolean selected = tab == selectedTab;
- boolean flag1 = tab.row() == CreativeModeTab.Row.TOP; - boolean isTop = tab.row() == CreativeModeTab.Row.TOP;
- int i = tab.column(); - int pos = tab.column();
+ boolean flag1 = currentPage.isTop(tab); + boolean isTop = currentPage.isTop(tab);
+ int i = currentPage.getColumn(tab); + int pos = currentPage.getColumn(tab);
int j = this.leftPos + this.getTabX(tab); int x = this.leftPos + this.getTabX(tab);
int k = this.topPos - (flag1 ? 28 : -(this.imageHeight - 4)); int y = this.topPos - (isTop ? 28 : -(this.imageHeight - 4));
Identifier[] aidentifier; Identifier[] sprites;
@@ -834,6 +_,7 @@ @@ -834,6 +_,7 @@
graphics.requestCursor(CursorTypes.POINTING_HAND); graphics.requestCursor(CursorTypes.POINTING_HAND);
} }
+ com.mojang.blaze3d.opengl.GlStateManager._enableBlend(); //Forge: Make sure blend is enabled else tabs show a white border. + com.mojang.blaze3d.opengl.GlStateManager._enableBlend(); //Forge: Make sure blend is enabled else tabs show a white border.
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, aidentifier[Mth.clamp(i, 0, aidentifier.length)], j, k, 26, 32); graphics.blitSprite(RenderPipelines.GUI_TEXTURED, sprites[Mth.clamp(pos, 0, sprites.length)], x, y, 26, 32);
int l = j + 13 - 8; int iconX = x + 13 - 8;
int i1 = k + 16 - 8 + (flag1 ? 1 : -1); int iconY = y + 16 - 8 + (isTop ? 1 : -1);
@@ -870,6 +_,14 @@ @@ -870,6 +_,14 @@
} }
} }
@@ -1,39 +1,39 @@
--- a/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java --- a/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java
+++ b/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java +++ b/net/minecraft/client/gui/screens/inventory/EffectsInInventory.java
@@ -47,12 +_,16 @@ @@ -47,12 +_,16 @@
int j = this.screen.width - i; int availableWidth = this.screen.width - xo;
Collection<MobEffectInstance> collection = this.minecraft.player.getActiveEffects(); Collection<MobEffectInstance> activeEffects = this.minecraft.player.getActiveEffects();
if (!collection.isEmpty() && j >= 32) { if (!activeEffects.isEmpty() && availableWidth >= 32) {
- int k = j >= 120 ? j - 7 : 32; - int maxWidth = availableWidth >= 120 ? availableWidth - 7 : 32;
+ var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenEffectSize(this.screen, j, j < 120, i); + var event = net.minecraftforge.client.event.ForgeEventFactoryClient.onScreenEffectSize(this.screen, availableWidth, availableWidth < 120, xo);
+ if (event == null) return; + if (event == null) return;
+ int k = !event.isCompact() ? j - 7 : 32; + int maxWidth = !event.isCompact() ? availableWidth - 7 : 32;
+ i = event.getHorizontalOffset(); + xo = event.getHorizontalOffset();
int l = 33; int yStep = 33;
if (collection.size() > 5) { if (activeEffects.size() > 5) {
l = 132 / (collection.size() - 1); yStep = 132 / (activeEffects.size() - 1);
} }
+ Iterable<MobEffectInstance> iterable = collection.stream().filter(net.minecraftforge.client.ForgeHooksClient::shouldRenderEffect).sorted().toList(); + Iterable<MobEffectInstance> iterable = activeEffects.stream().filter(net.minecraftforge.client.ForgeHooksClient::shouldRenderEffect).sorted().toList();
this.extractEffects(graphics, collection, i, l, mouseX, mouseY, k); this.extractEffects(graphics, activeEffects, xo, yStep, mouseX, mouseY, maxWidth);
} }
} }
@@ -72,6 +_,11 @@ @@ -72,6 +_,11 @@
for (MobEffectInstance mobeffectinstance : iterable) { for (MobEffectInstance effect : sortedEffects) {
boolean flag = mobeffectinstance.isAmbient(); boolean isAmbient = effect.isAmbient();
+ var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(mobeffectinstance); + var renderer = net.minecraftforge.client.extensions.common.IClientMobEffectExtensions.of(effect);
+ if (renderer.extractInventory(mobeffectinstance, this, graphics, x0, i, 0)) { + if (renderer.extractInventory(effect, this, graphics, x0, y0, 0)) {
+ i += yStep; + y0 += yStep;
+ continue; + continue;
+ } + }
Component component = this.getEffectName(mobeffectinstance); Component effectText = this.getEffectName(effect);
Component component1 = MobEffectUtil.formatDuration(mobeffectinstance, 1.0F, this.minecraft.level.tickRateManager().tickrate()); Component duration = MobEffectUtil.formatDuration(effect, 1.0F, this.minecraft.level.tickRateManager().tickrate());
int j = this.extractBackground(graphics, font, component, component1, x0, i, flag, maxWidth); int textureWidth = this.extractBackground(graphics, font, effectText, duration, x0, y0, isAmbient, maxWidth);
@@ -136,5 +_,9 @@ @@ -136,5 +_,9 @@
} }
return mutablecomponent; return name;
+ } + }
+ +
+ public AbstractContainerScreen<?> getScreen() { + public AbstractContainerScreen<?> getScreen() {
@@ -1,32 +1,33 @@
--- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java --- a/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java +++ b/net/minecraft/client/gui/screens/inventory/EnchantmentScreen.java
@@ -111,7 +_,7 @@ @@ -111,7 +_,7 @@
int l1 = 86 - this.font.width(s); int textWidth = 86 - this.font.width(costText);
FormattedText formattedtext = EnchantmentNames.getInstance().getRandomName(this.font, l1); FormattedText message = EnchantmentNames.getInstance().getRandomName(this.font, textWidth);
int i2 = -9937334; int col = -9937334;
- if ((k < l + 1 || this.minecraft.player.experienceLevel < k1) && !this.minecraft.player.hasInfiniteMaterials()) { - if ((goldCount < i + 1 || this.minecraft.player.experienceLevel < cost) && !this.minecraft.player.hasInfiniteMaterials()) {
+ if (((k < l + 1 || this.minecraft.player.experienceLevel < k1) && !this.minecraft.player.hasInfiniteMaterials()) || this.menu.enchantClue[l] == -1) { // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels{ + if (((goldCount < i + 1 || this.minecraft.player.experienceLevel < cost) && !this.minecraft.player.hasInfiniteMaterials()) || this.menu.enchantClue[i] == -1) { // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels{
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, ENCHANTMENT_SLOT_DISABLED_SPRITE, i1, j + 14 + 19 * l, 108, 19); graphics.blitSprite(RenderPipelines.GUI_TEXTURED, ENCHANTMENT_SLOT_DISABLED_SPRITE, leftPos, yo + 14 + 19 * i, 108, 19);
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, DISABLED_LEVEL_SPRITES[l], i1 + 1, j + 15 + 19 * l, 16, 16); graphics.blitSprite(RenderPipelines.GUI_TEXTURED, DISABLED_LEVEL_SPRITES[i], leftPos + 1, yo + 15 + 19 * i, 16, 16);
graphics.textWithWordWrap(this.font, formattedtext, j1, j + 16 + 19 * l, l1, ARGB.opaque((i2 & 16711422) >> 1), false); graphics.textWithWordWrap(this.font, message, leftPosText, yo + 16 + 19 * i, textWidth, ARGB.opaque((col & 16711422) >> 1), false);
@@ -162,13 +_,16 @@ @@ -162,14 +_,18 @@
.registryAccess() .registryAccess()
.lookupOrThrow(Registries.ENCHANTMENT) .lookupOrThrow(Registries.ENCHANTMENT)
.get(this.menu.enchantClue[j]); .get(this.menu.enchantClue[i]);
- if (!optional.isEmpty()) { - if (!enchant.isEmpty()) {
+ { + {
int l = this.menu.levelClue[j]; int enchantLevel = this.menu.levelClue[i];
int i1 = j + 1; int cost = i + 1;
- if (this.isHovering(60, 14 + 19 * j, 108, 17, mouseX, mouseY) && k > 0 && l >= 0) { - if (this.isHovering(60, 14 + 19 * i, 108, 17, mouseX, mouseY) && minLevel > 0 && enchantLevel >= 0) {
+ if (this.isHovering(60, 14 + 19 * j, 108, 17, (double)mouseX, (double)mouseY) && l >= 0) { + if (this.isHovering(60, 14 + 19 * i, 108, 17, (double)mouseX, (double)mouseY) && enchantLevel >= 0) {
List<Component> list = Lists.newArrayList(); List<Component> texts = Lists.newArrayList();
- list.add(Component.translatable("container.enchant.clue", Enchantment.getFullname(optional.get(), l)).withStyle(ChatFormatting.WHITE)); texts.add(
- if (!flag) { - Component.translatable("container.enchant.clue", Enchantment.getFullname(enchant.get(), enchantLevel)).withStyle(ChatFormatting.WHITE)
+ list.add(Component.translatable("container.enchant.clue", optional.isEmpty() ? "" : Enchantment.getFullname(optional.get(), l)).withStyle(ChatFormatting.WHITE)); + Component.translatable("container.enchant.clue", enchant.isEmpty() ? "" : Enchantment.getFullname(enchant.get(), enchantLevel)).withStyle(ChatFormatting.WHITE)
+ if (optional.isEmpty()) { );
+ list.add(Component.literal("")); + if (enchant.isEmpty()) {
+ list.add(Component.translatable("forge.container.enchant.limitedEnchantability").withStyle(ChatFormatting.RED)); + texts.add(Component.literal(""));
+ } else if (!flag) { + texts.add(Component.translatable("forge.container.enchant.limitedEnchantability").withStyle(ChatFormatting.RED));
list.add(CommonComponents.EMPTY); + } else
if (this.minecraft.player.experienceLevel < k) { if (!infiniteMaterials) {
list.add(Component.translatable("container.enchant.level.requirement", this.menu.costs[j]).withStyle(ChatFormatting.RED)); texts.add(CommonComponents.EMPTY);
if (this.minecraft.player.experienceLevel < minLevel) {
@@ -1,9 +1,9 @@
--- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java --- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java
+++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java +++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java
@@ -20,7 +_,7 @@ @@ -18,7 +_,7 @@
case ClientActivePlayersTooltip.ActivePlayersTooltip clientactiveplayerstooltip$activeplayerstooltip -> new ClientActivePlayersTooltip( return (ClientTooltipComponent)(switch (component) {
clientactiveplayerstooltip$activeplayerstooltip case BundleTooltip bundleTooltip -> new ClientBundleTooltip(bundleTooltip.contents());
); case ClientActivePlayersTooltip.ActivePlayersTooltip activePlayersTooltip -> new ClientActivePlayersTooltip(activePlayersTooltip);
- default -> throw new IllegalArgumentException("Unknown TooltipComponent"); - default -> throw new IllegalArgumentException("Unknown TooltipComponent");
+ default -> net.minecraftforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(component); + default -> net.minecraftforge.client.gui.ClientTooltipComponentManager.createClientTooltipComponent(component);
}); });
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java --- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java
+++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java +++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java
@@ -371,6 +_,8 @@ @@ -372,6 +_,8 @@
graphics.setTooltipForNextFrame(Lists.transform(this.onlinePlayersTooltip, Component::getVisualOrderText), mouseX, mouseY); graphics.setTooltipForNextFrame(Lists.transform(this.onlinePlayersTooltip, Component::getVisualOrderText), mouseX, mouseY);
} }
@@ -8,4 +8,4 @@
+ +
if (this.minecraft.options.touchscreen().get() || hovered) { if (this.minecraft.options.touchscreen().get() || hovered) {
graphics.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544); graphics.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544);
int i1 = mouseX - this.getContentX(); int relX = mouseX - this.getContentX();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java --- a/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
+++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java +++ b/net/minecraft/client/gui/screens/options/controls/KeyBindsList.java
@@ -123,9 +_,10 @@ @@ -122,9 +_,10 @@
this.name = name; this.name = name;
this.changeButton = Button.builder(name, button -> { this.changeButton = Button.builder(name, button -> {
KeyBindsList.this.keyBindsScreen.selectedKey = key; KeyBindsList.this.keyBindsScreen.selectedKey = key;
@@ -12,7 +12,7 @@
.createNarration( .createNarration(
defaultNarrationSupplier -> key.isUnbound() defaultNarrationSupplier -> key.isUnbound()
? Component.translatable("narrator.controls.unbound", name) ? Component.translatable("narrator.controls.unbound", name)
@@ -133,7 +_,7 @@ @@ -132,7 +_,7 @@
) )
.build(); .build();
this.resetButton = Button.builder(RESET_BUTTON_TITLE, button -> { this.resetButton = Button.builder(RESET_BUTTON_TITLE, button -> {
@@ -21,13 +21,13 @@
KeyBindsList.this.resetMappingAndUpdateButtons(); KeyBindsList.this.resetMappingAndUpdateButtons();
}).bounds(0, 0, 50, 20).createNarration(defaultNarrationSupplier -> Component.translatable("narrator.controls.reset", name)).build(); }).bounds(0, 0, 50, 20).createNarration(defaultNarrationSupplier -> Component.translatable("narrator.controls.reset", name)).build();
this.refreshEntry(); this.refreshEntry();
@@ -174,7 +_,8 @@ @@ -173,7 +_,8 @@
MutableComponent mutablecomponent = Component.empty(); MutableComponent tooltip = Component.empty();
if (!this.key.isUnbound()) { if (!this.key.isUnbound()) {
for (KeyMapping keymapping : KeyBindsList.this.minecraft.options.keyMappings) { for (KeyMapping otherKey : KeyBindsList.this.minecraft.options.keyMappings) {
- if (keymapping != this.key && this.key.same(keymapping) && (!keymapping.isDefault() || !this.key.isDefault())) { - if (otherKey != this.key && this.key.same(otherKey) && (!otherKey.isDefault() || !this.key.isDefault())) {
+ var vanillConflict = keymapping != this.key && this.key.same(keymapping) && (!keymapping.isDefault() || !this.key.isDefault()); + var vanillConflict = otherKey != this.key && this.key.same(otherKey) && (!otherKey.isDefault() || !this.key.isDefault());
+ if (vanillConflict || keymapping.hasKeyModifierConflict(this.key)) { // FORGE: gracefully handle conflicts like SHIFT vs SHIFT+G + if (vanillConflict || otherKey.hasKeyModifierConflict(this.key)) { // FORGE: gracefully handle conflicts like SHIFT vs SHIFT+G
if (this.hasCollision) { if (this.hasCollision) {
mutablecomponent.append(", "); tooltip.append(", ");
} }
@@ -3,9 +3,9 @@
@@ -42,7 +_,7 @@ @@ -42,7 +_,7 @@
protected void addFooter() { protected void addFooter() {
this.resetButton = Button.builder(Component.translatable("controls.resetAll"), button -> { this.resetButton = Button.builder(Component.translatable("controls.resetAll"), button -> {
for (KeyMapping keymapping : this.options.keyMappings) { for (KeyMapping key : this.options.keyMappings) {
- keymapping.setKey(keymapping.getDefaultKey()); - key.setKey(key.getDefaultKey());
+ keymapping.setToDefault(); + key.setToDefault();
} }
this.keyBindsList.resetMappingAndUpdateButtons(); this.keyBindsList.resetMappingAndUpdateButtons();
@@ -27,7 +27,7 @@
@@ -101,5 +_,18 @@ @@ -101,5 +_,18 @@
} }
this.resetButton.active = flag; this.resetButton.active = canReset;
+ } + }
+ +
+ @Override + @Override
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java --- a/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java
+++ b/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java +++ b/net/minecraft/client/gui/screens/packs/TransferableSelectionList.java
@@ -66,7 +_,7 @@ @@ -66,7 +_,7 @@
Component component = Component.empty().append(this.title).withStyle(ChatFormatting.UNDERLINE, ChatFormatting.BOLD); Component header = Component.empty().append(this.title).withStyle(ChatFormatting.UNDERLINE, ChatFormatting.BOLD);
this.addEntry(new TransferableSelectionList.HeaderEntry(this.minecraft.font, component), (int)(9.0F * 1.5F)); this.addEntry(new TransferableSelectionList.HeaderEntry(this.minecraft.font, header), (int)(9.0F * 1.5F));
this.setSelected(null); this.setSelected(null);
- entries.forEach(e -> { - entries.forEach(e -> {
+ entries.filter(PackSelectionModel.Entry::notHidden).forEach(e -> { + entries.filter(PackSelectionModel.Entry::notHidden).forEach(e -> {
TransferableSelectionList.PackEntry transferableselectionlist$packentry = new TransferableSelectionList.PackEntry(this.minecraft, this, e); TransferableSelectionList.PackEntry entry = new TransferableSelectionList.PackEntry(this.minecraft, this, e);
this.addEntry(transferableselectionlist$packentry); this.addEntry(entry);
if (transferredEntry != null && transferredEntry.getId().equals(e.getId())) { if (transferredEntry != null && transferredEntry.getId().equals(e.getId())) {
@@ -1,14 +1,14 @@
--- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java --- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java
+++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java +++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java
@@ -177,6 +_,7 @@ @@ -174,6 +_,7 @@
WorldDataConfiguration worlddataconfiguration = SharedConstants.IS_RUNNING_IN_IDE WorldDataConfiguration dataConfig = SharedConstants.IS_RUNNING_IN_IDE
? new WorldDataConfiguration(new DataPackConfig(List.of("vanilla", "tests"), List.of()), FeatureFlags.DEFAULT_FLAGS) ? new WorldDataConfiguration(new DataPackConfig(List.of("vanilla", "tests"), List.of()), FeatureFlags.DEFAULT_FLAGS)
: WorldDataConfiguration.DEFAULT; : WorldDataConfiguration.DEFAULT;
+ net.minecraftforge.event.ForgeEventFactory.addPackFindersServer(packrepository::addPackFinder); + net.minecraftforge.event.ForgeEventFactory.addPackFindersServer(vanillaOnlyPackRepository::addPackFinder);
WorldLoader.InitConfig worldloader$initconfig = createDefaultLoadConfig(packrepository, worlddataconfiguration); WorldLoader.InitConfig loadConfig = createDefaultLoadConfig(vanillaOnlyPackRepository, dataConfig);
CompletableFuture<WorldCreationContext> completablefuture = WorldLoader.load( CompletableFuture<WorldCreationContext> loadResult = WorldLoader.load(
worldloader$initconfig, loadConfig,
@@ -520,7 +_,7 @@ @@ -509,7 +_,7 @@
if (retry) { if (retry) {
onAbort.accept(this.uiState.getSettings().dataConfiguration()); onAbort.accept(this.uiState.getSettings().dataConfiguration());
} else { } else {
@@ -17,10 +17,10 @@
} }
}, },
Component.translatable("dataPack.validation.failed"), Component.translatable("dataPack.validation.failed"),
@@ -634,6 +_,7 @@ @@ -623,6 +_,7 @@
if (path != null) { if (dataPackDir != null) {
if (this.tempDataPackRepository == null) { if (this.tempDataPackRepository == null) {
this.tempDataPackRepository = ServerPacksSource.createPackRepository(path, this.packValidator); this.tempDataPackRepository = ServerPacksSource.createPackRepository(dataPackDir, this.packValidator);
+ net.minecraftforge.resource.ResourcePackLoader.loadResourcePacks(this.tempDataPackRepository, false); + net.minecraftforge.resource.ResourcePackLoader.loadResourcePacks(this.tempDataPackRepository, false);
this.tempDataPackRepository.reload(); this.tempDataPackRepository.reload();
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/gui/screens/worldselection/PresetEditor.java --- a/net/minecraft/client/gui/screens/worldselection/PresetEditor.java
+++ b/net/minecraft/client/gui/screens/worldselection/PresetEditor.java +++ b/net/minecraft/client/gui/screens/worldselection/PresetEditor.java
@@ -29,6 +_,10 @@ @@ -28,6 +_,10 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public interface PresetEditor { public interface PresetEditor {
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java --- a/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java
+++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldCreationUiState.java
@@ -234,7 +_,7 @@ @@ -229,7 +_,7 @@
public @Nullable PresetEditor getPresetEditor() { public @Nullable PresetEditor getPresetEditor() {
Holder<WorldPreset> holder = this.getWorldType().preset(); Holder<WorldPreset> preset = this.getWorldType().preset();
- return holder != null ? PresetEditor.EDITORS.get(holder.unwrapKey()) : null; - return preset != null ? PresetEditor.EDITORS.get(preset.unwrapKey()) : null;
+ return holder != null ? holder.unwrapKey().map(net.minecraftforge.client.PresetEditorManager::get).orElse(null) : null; // FORGE: redirect lookup to expanded map + return preset != null ? preset.unwrapKey().map(net.minecraftforge.client.PresetEditorManager::get).orElse(null) : null; // FORGE: redirect lookup to expanded map
} }
public List<WorldCreationUiState.WorldTypeEntry> getNormalPresetList() { public List<WorldCreationUiState.WorldTypeEntry> getNormalPresetList() {
@@ -1,11 +1,29 @@
--- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java --- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
+++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java
@@ -507,6 +_,8 @@ @@ -489,6 +_,8 @@
this.minecraft.setScreenAndShow(new GenericMessageScreen(Component.translatable("selectWorld.resource_load"))); this.minecraft.setScreenAndShow(new GenericMessageScreen(Component.translatable("selectWorld.resource_load")));
PackRepository packrepository = ServerPacksSource.createPackRepository(worldAccess); PackRepository packRepository = ServerPacksSource.createPackRepository(worldAccess);
+ net.minecraftforge.common.ForgeHooks.readAdditionalLevelSaveData(worldAccess, worldAccess.getLevelDirectory()); + net.minecraftforge.common.ForgeHooks.readAdditionalLevelSaveData(worldAccess, worldAccess.getLevelDirectory());
+ +
WorldStem worldstem; WorldStem worldStem;
try { try {
worldstem = this.loadWorldStem(worldAccess, levelDataTag, safeMode, packrepository); worldStem = this.loadWorldStem(worldAccess, levelDataTag, safeMode, packRepository);
@@ -530,6 +_,8 @@
WorldData data = worldDataAndGenSettings.data();
boolean oldCustomized = worldDataAndGenSettings.genSettings().options().isOldCustomizedWorld();
boolean unstable = data.worldGenSettingsLifecycle() != Lifecycle.stable();
+ if (unstable && data instanceof PrimaryLevelData primaryData)
+ unstable = !primaryData.hasConfirmedExperimentalWarning();
if (!oldCustomized && !unstable) {
this.openWorldLoadBundledResourcePack(worldAccess, worldStem, packRepository, onCancel);
} else {
@@ -546,6 +_,8 @@
private void openWorldLoadBundledResourcePack(
final LevelStorageSource.LevelStorageAccess worldAccess, final WorldStem worldStem, final PackRepository packRepository, final Runnable onCancel
) {
+ if (worldStem.worldDataAndGenSettings().data() instanceof PrimaryLevelData primaryLevelData)
+ primaryLevelData.withConfirmedWarning(worldStem.worldDataAndGenSettings().data().worldGenSettingsLifecycle() != Lifecycle.stable());
DownloadedPackSource packSource = this.minecraft.getDownloadedPackSource();
this.loadBundledResourcePack(packSource, worldAccess).thenApply(unused -> true).exceptionallyComposeAsync(t -> {
LOGGER.warn("Failed to load pack: ", t);
@@ -8,7 +8,7 @@
private static final Component FROM_NEWER_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.fromNewerVersion1").withStyle(ChatFormatting.RED); 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); private static final Component FROM_NEWER_TOOLTIP_2 = Component.translatable("selectWorld.tooltip.fromNewerVersion2").withStyle(ChatFormatting.RED);
private static final Component SNAPSHOT_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.snapshot1").withStyle(ChatFormatting.GOLD); private static final Component SNAPSHOT_TOOLTIP_1 = Component.translatable("selectWorld.tooltip.snapshot1").withStyle(ChatFormatting.GOLD);
@@ -493,6 +_,19 @@ @@ -486,6 +_,19 @@
} }
} }
@@ -27,12 +27,12 @@
+ +
@Override @Override
public Component getNarration() { public Component getNarration() {
Component component = Component.translatable( Component entryNarration = Component.translatable(
@@ -522,6 +_,7 @@ @@ -515,6 +_,7 @@
this.infoText.setPosition(i, this.getContentY() + 9 + 9 + 3); this.infoText.setPosition(textX, this.getContentY() + 9 + 9 + 3);
this.infoText.extractRenderState(graphics, mouseX, mouseY, a); 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); graphics.blit(RenderPipelines.GUI_TEXTURED, this.icon.textureLocation(), this.getContentX(), this.getContentY(), 0.0F, 0.0F, 32, 32, 32, 32);
+ renderExperimentalWarning(graphics, mouseX, mouseY, this.getContentY(), this.getContentX()); + renderExperimentalWarning(graphics, mouseX, mouseY, this.getContentY(), this.getContentX());
if (this.list.entryType == WorldSelectionList.EntryType.SINGLEPLAYER && (this.minecraft.options.touchscreen().get() || hovered)) { if (this.list.entryType == WorldSelectionList.EntryType.SINGLEPLAYER && (this.minecraft.options.touchscreen().get() || hovered)) {
graphics.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544); graphics.fill(this.getContentX(), this.getContentY(), this.getContentX() + 32, this.getContentY() + 32, -1601138544);
int j = mouseX - this.getContentX(); int relX = mouseX - this.getContentX();
@@ -3,11 +3,11 @@
@@ -114,8 +_,8 @@ @@ -114,8 +_,8 @@
CrashReport.preload(); CrashReport.preload();
logger = LogUtils.getLogger(); logger = LogUtils.getLogger();
s1 = "Bootstrap"; stage = "Bootstrap";
- Bootstrap.bootStrap(); - Bootstrap.bootStrap();
- ClientBootstrap.bootstrap(); - ClientBootstrap.bootstrap();
+ net.minecraftforge.fml.loading.BackgroundWaiter.runAndTick(Bootstrap::bootStrap, net.minecraftforge.fml.loading.FMLLoader.progressWindowTick); + net.minecraftforge.fml.loading.BackgroundWaiter.runAndTick(Bootstrap::bootStrap, net.minecraftforge.fml.loading.FMLLoader.progressWindowTick);
+ net.minecraftforge.fml.loading.BackgroundWaiter.runAndTick(ClientBootstrap::bootstrap, net.minecraftforge.fml.loading.FMLLoader.progressWindowTick); + net.minecraftforge.fml.loading.BackgroundWaiter.runAndTick(ClientBootstrap::bootstrap, net.minecraftforge.fml.loading.FMLLoader.progressWindowTick);
GameLoadTimesEvent.INSTANCE.setBootstrapTime(Bootstrap.bootstrapDuration.get()); GameLoadTimesEvent.INSTANCE.setBootstrapTime(Bootstrap.bootstrapDuration.get());
Bootstrap.validate(); Bootstrap.validate();
s1 = "Argument parsing"; stage = "Argument parsing";
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/model/HumanoidModel.java --- a/net/minecraft/client/model/HumanoidModel.java
+++ b/net/minecraft/client/model/HumanoidModel.java +++ b/net/minecraft/client/model/HumanoidModel.java
@@ -387,6 +_,8 @@ @@ -391,6 +_,8 @@
break; break;
case SPEAR: case SPEAR:
SpearAnimations.thirdPersonHandUse(this.rightArm, this.head, true, state.getUseItemStackForArm(HumanoidArm.RIGHT), state); SpearAnimations.thirdPersonHandUse(this.rightArm, this.head, true, state.getUseItemStackForArm(HumanoidArm.RIGHT), state);
@@ -9,7 +9,7 @@
} }
} }
@@ -432,6 +_,8 @@ @@ -436,6 +_,8 @@
break; break;
case SPEAR: case SPEAR:
SpearAnimations.thirdPersonHandUse(this.leftArm, this.head, false, state.getUseItemStackForArm(HumanoidArm.LEFT), state); SpearAnimations.thirdPersonHandUse(this.leftArm, this.head, false, state.getUseItemStackForArm(HumanoidArm.LEFT), state);
@@ -18,7 +18,7 @@
} }
} }
@@ -493,7 +_,7 @@ @@ -497,7 +_,7 @@
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -27,7 +27,7 @@
EMPTY(false, false), EMPTY(false, false),
ITEM(false, false), ITEM(false, false),
BLOCK(false, false), BLOCK(false, false),
@@ -519,10 +_,29 @@ @@ -523,10 +_,29 @@
private ArmPose(final boolean twoHanded, final boolean affectsOffhandPose) { private ArmPose(final boolean twoHanded, final boolean affectsOffhandPose) {
this.twoHanded = twoHanded; this.twoHanded = twoHanded;
this.affectsOffhandPose = affectsOffhandPose; this.affectsOffhandPose = affectsOffhandPose;
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/model/geom/LayerDefinitions.java --- a/net/minecraft/client/model/geom/LayerDefinitions.java
+++ b/net/minecraft/client/model/geom/LayerDefinitions.java +++ b/net/minecraft/client/model/geom/LayerDefinitions.java
@@ -572,6 +_,7 @@ @@ -569,6 +_,7 @@
builder.put(ModelLayers.createHangingSignModelName(woodType, hangingsignblock$attachment), layerdefinition70); result.put(ModelLayers.createHangingSignModelName(woodType, attachmentType), hangingSignModel);
} }
}); });
+ net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(builder); + net.minecraftforge.client.ForgeHooksClient.loadLayerDefinitions(result);
ImmutableMap<ModelLayerLocation, LayerDefinition> immutablemap = builder.build(); ImmutableMap<ModelLayerLocation, LayerDefinition> definitions = result.build();
List<ModelLayerLocation> list = ModelLayers.getKnownLocations().filter(l -> !immutablemap.containsKey(l)).toList(); List<ModelLayerLocation> missingDefinitions = ModelLayers.getKnownLocations().filter(l -> !definitions.containsKey(l)).toList();
if (!list.isEmpty()) { if (!missingDefinitions.isEmpty()) {
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/multiplayer/AccountProfileKeyPairManager.java --- a/net/minecraft/client/multiplayer/AccountProfileKeyPairManager.java
+++ b/net/minecraft/client/multiplayer/AccountProfileKeyPairManager.java +++ b/net/minecraft/client/multiplayer/AccountProfileKeyPairManager.java
@@ -76,6 +_,8 @@ @@ -75,6 +_,8 @@
this.writeProfileKeyPair(profilekeypair); this.writeProfileKeyPair(fetchedKeyPair);
return Optional.ofNullable(profilekeypair); return Optional.ofNullable(fetchedKeyPair);
} catch (CryptException | MinecraftClientException | IOException ioexception) { } catch (CryptException | MinecraftClientException | IOException var3) {
+ // Forge: The offline user api service always returns a null profile key pair, so let's hide this useless exception if in dev + // Forge: The offline user api service always returns a null profile key pair, so let's hide this useless exception if in dev
+ if (net.minecraftforge.fml.loading.FMLLoader.isProduction() || this.userApiService != UserApiService.OFFLINE) + if (net.minecraftforge.fml.loading.FMLLoader.isProduction() || this.userApiService != UserApiService.OFFLINE)
LOGGER.error("Failed to retrieve profile key pair", (Throwable)ioexception); LOGGER.error("Failed to retrieve profile key pair", (Throwable)var3);
this.writeProfileKeyPair(null); this.writeProfileKeyPair(null);
return cachedKeyPair; return cachedKeyPair;
@@ -1,18 +1,18 @@
--- a/net/minecraft/client/multiplayer/ClientChunkCache.java --- a/net/minecraft/client/multiplayer/ClientChunkCache.java
+++ b/net/minecraft/client/multiplayer/ClientChunkCache.java +++ b/net/minecraft/client/multiplayer/ClientChunkCache.java
@@ -65,6 +_,7 @@ @@ -65,6 +_,7 @@
int i = this.storage.getIndex(pos.x(), pos.z()); int index = this.storage.getIndex(pos.x(), pos.z());
LevelChunk levelchunk = this.storage.getChunk(i); LevelChunk currentChunk = this.storage.getChunk(index);
if (isValidChunk(levelchunk, pos.x(), pos.z())) { if (isValidChunk(currentChunk, pos.x(), pos.z())) {
+ net.minecraftforge.event.level.ChunkEvent.Unload.BUS.post(new net.minecraftforge.event.level.ChunkEvent.Unload(levelchunk)); + net.minecraftforge.event.level.ChunkEvent.Unload.BUS.post(new net.minecraftforge.event.level.ChunkEvent.Unload(currentChunk));
this.storage.drop(i, levelchunk); this.storage.drop(index, currentChunk);
} }
} }
@@ -124,6 +_,7 @@ @@ -124,6 +_,7 @@
} }
this.level.onChunkLoaded(chunkpos); this.level.onChunkLoaded(pos);
+ net.minecraftforge.event.level.ChunkEvent.Load.BUS.post(new net.minecraftforge.event.level.ChunkEvent.Load(levelchunk, false)); + net.minecraftforge.event.level.ChunkEvent.Load.BUS.post(new net.minecraftforge.event.level.ChunkEvent.Load(chunk, false));
return levelchunk; return chunk;
} }
} }
@@ -5,6 +5,6 @@
@Override @Override
public void handleCustomPayload(final ClientboundCustomPayloadPacket packet) { public void handleCustomPayload(final ClientboundCustomPayloadPacket packet) {
+ if (net.minecraftforge.common.ForgeHooks.onCustomPayload(packet.payload(), this.connection)) return; + if (net.minecraftforge.common.ForgeHooks.onCustomPayload(packet.payload(), this.connection)) return;
CustomPacketPayload custompacketpayload = packet.payload(); CustomPacketPayload payload = packet.payload();
if (!(custompacketpayload instanceof DiscardedPayload)) { if (!(payload instanceof DiscardedPayload)) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.minecraft.packetProcessor()); PacketUtils.ensureRunningOnSameThread(packet, this, this.minecraft.packetProcessor());
@@ -1,12 +1,12 @@
--- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java --- a/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java
+++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java +++ b/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java
@@ -209,6 +_,7 @@ @@ -209,6 +_,7 @@
Component component = this.wasTransferredTo ? CommonComponents.TRANSFER_CONNECT_FAILED : CommonComponents.CONNECT_FAILED; Component title = this.wasTransferredTo ? CommonComponents.TRANSFER_CONNECT_FAILED : CommonComponents.CONNECT_FAILED;
if (this.serverData != null && this.serverData.isRealm()) { if (this.serverData != null && this.serverData.isRealm()) {
this.minecraft.setScreen(new DisconnectedScreen(this.parent, component, details.reason(), CommonComponents.GUI_BACK)); this.minecraft.setScreen(new DisconnectedScreen(this.parent, title, details.reason(), CommonComponents.GUI_BACK));
+ } else if (net.minecraftforge.client.ForgeHooksClient.onClientDisconnect(this.connection, this.minecraft, this.parent, details.reason())) { + } else if (net.minecraftforge.client.ForgeHooksClient.onClientDisconnect(this.connection, this.minecraft, this.parent, details.reason())) {
} else { } else {
this.minecraft.setScreen(new DisconnectedScreen(this.parent, component, details)); this.minecraft.setScreen(new DisconnectedScreen(this.parent, title, details));
} }
@@ -233,6 +_,7 @@ @@ -233,6 +_,7 @@
@@ -19,7 +19,7 @@
if (SharedConstants.DEBUG_BLOCK_BREAK) { if (SharedConstants.DEBUG_BLOCK_BREAK) {
@@ -273,6 +_,8 @@ @@ -273,6 +_,8 @@
runnable.run(); update.run();
} }
+ this.gatherCapabilities(); + this.gatherCapabilities();
+ net.minecraftforge.event.ForgeEventFactory.onLevelLoad(this); + net.minecraftforge.event.ForgeEventFactory.onLevelLoad(this);
@@ -45,7 +45,7 @@
} }
public void removeEntity(final int id, final Entity.RemovalReason reason) { public void removeEntity(final int id, final Entity.RemovalReason reason) {
@@ -579,8 +_,10 @@ @@ -576,8 +_,10 @@
final float pitch, final float pitch,
final long seed final long seed
) { ) {
@@ -57,7 +57,7 @@
} }
} }
@@ -594,8 +_,10 @@ @@ -591,8 +_,10 @@
final float pitch, final float pitch,
final long seed final long seed
) { ) {
@@ -69,24 +69,24 @@
} }
} }
@@ -951,7 +_,7 @@ @@ -946,7 +_,7 @@
@Override @Override
public void addDestroyBlockEffect(final BlockPos pos, final BlockState blockState) { public void addDestroyBlockEffect(final BlockPos pos, final BlockState blockState) {
- if (!blockState.isAir() && blockState.shouldSpawnTerrainParticles()) { - if (!blockState.isAir() && blockState.shouldSpawnTerrainParticles()) {
+ if (!blockState.isAir() && !net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(blockState).addDestroyEffects(blockState, this, pos, this.minecraft.particleEngine)) { + if (!blockState.isAir() && !net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(blockState).addDestroyEffects(blockState, this, pos, this.minecraft.particleEngine)) {
VoxelShape voxelshape = blockState.getShape(this, pos); VoxelShape shape = blockState.getShape(this, pos);
double d0 = 0.25; double density = 0.25;
voxelshape.forAllBoxes( shape.forAllBoxes(
@@ -978,6 +_,7 @@ @@ -973,6 +_,7 @@
new TerrainParticle( new TerrainParticle(
this, pos.getX() + d7, pos.getY() + d8, pos.getZ() + d9, d4 - 0.5, d5 - 0.5, d6 - 0.5, blockState, pos this, pos.getX() + x, pos.getY() + y, pos.getZ() + z, relX - 0.5, relY - 0.5, relZ - 0.5, blockState, pos
) )
+ .updateSprite(blockState, pos) + .updateSprite(blockState, pos)
); );
} }
} }
@@ -987,6 +_,13 @@ @@ -982,6 +_,13 @@
} }
} }
@@ -98,18 +98,18 @@
+ +
+ /** @deprecated Forge - Use crack(BlockPos, BlockHitResult) as it has more context and gives more control to modders */ + /** @deprecated Forge - Use crack(BlockPos, BlockHitResult) as it has more context and gives more control to modders */
public void addBreakingBlockEffect(final BlockPos pos, final Direction direction) { public void addBreakingBlockEffect(final BlockPos pos, final Direction direction) {
BlockState blockstate = this.getBlockState(pos); BlockState blockState = this.getBlockState(pos);
if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.shouldSpawnTerrainParticles()) { if (blockState.getRenderShape() != RenderShape.INVISIBLE && blockState.shouldSpawnTerrainParticles()) {
@@ -1022,7 +_,7 @@ @@ -1017,7 +_,7 @@
d0 = i + aabb.maxX + 0.1F; xp = x + shape.maxX + 0.1F;
} }
- this.minecraft.particleEngine.add(new TerrainParticle(this, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, pos).setPower(0.2F).scale(0.6F)); - this.minecraft.particleEngine.add(new TerrainParticle(this, xp, yp, zp, 0.0, 0.0, 0.0, blockState, pos).setPower(0.2F).scale(0.6F));
+ this.minecraft.particleEngine.add(new TerrainParticle(this, d0, d1, d2, 0.0, 0.0, 0.0, blockstate, pos).updateSprite(blockstate, pos).setPower(0.2F).scale(0.6F)); + this.minecraft.particleEngine.add(new TerrainParticle(this, xp, yp, zp, 0.0, 0.0, 0.0, blockState, pos).updateSprite(blockState, pos).setPower(0.2F).scale(0.6F));
} }
} }
@@ -1088,6 +_,16 @@ @@ -1083,6 +_,16 @@
this.explosionTracker.track(center, radius, blockCount, blockParticles); this.explosionTracker.track(center, radius, blockCount, blockParticles);
} }
@@ -126,7 +126,7 @@
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static class ClientLevelData implements WritableLevelData { public static class ClientLevelData implements WritableLevelData {
private final boolean hardcore; private final boolean hardcore;
@@ -1143,6 +_,7 @@ @@ -1138,6 +_,7 @@
} }
public void setDifficulty(final Difficulty difficulty) { public void setDifficulty(final Difficulty difficulty) {
@@ -134,7 +134,7 @@
this.difficulty = difficulty; this.difficulty = difficulty;
} }
@@ -1190,6 +_,12 @@ @@ -1185,6 +_,12 @@
break; break;
default: default:
} }
@@ -147,8 +147,8 @@
} }
public void onTrackingEnd(final Entity entity) { public void onTrackingEnd(final Entity entity) {
@@ -1202,6 +_,15 @@ @@ -1197,6 +_,15 @@
ClientLevel.this.dragonParts.removeAll(Arrays.asList(enderdragon.getSubEntities())); ClientLevel.this.dragonParts.removeAll(Arrays.asList(dragon.getSubEntities()));
break; break;
default: default:
+ } + }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/ClientPacketListener.java --- a/net/minecraft/client/multiplayer/ClientPacketListener.java
+++ b/net/minecraft/client/multiplayer/ClientPacketListener.java +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java
@@ -536,6 +_,7 @@ @@ -531,6 +_,7 @@
this.debugSubscriber.clear(); this.debugSubscriber.clear();
this.minecraft.levelRenderer.debugRenderer.refreshRendererList(); this.minecraft.levelRenderer.debugRenderer.refreshRendererList();
this.minecraft.player.resetPos(); this.minecraft.player.resetPos();
@@ -8,25 +8,25 @@
this.minecraft.player.setId(packet.playerId()); this.minecraft.player.setId(packet.playerId());
this.level.addEntity(this.minecraft.player); this.level.addEntity(this.minecraft.player);
this.minecraft.player.input = new KeyboardInput(this.minecraft.options); this.minecraft.player.input = new KeyboardInput(this.minecraft.options);
@@ -1345,6 +_,8 @@ @@ -1325,6 +_,8 @@
localplayer1.getAttributes().assignBaseValues(localplayer.getAttributes()); newPlayer.getAttributes().assignBaseValues(oldPlayer.getAttributes());
} }
+ localplayer1.updateSyncFields(localplayer); // Forge: fix MC-10657 + newPlayer.updateSyncFields(oldPlayer); // Forge: fix MC-10657
+ net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerRespawn(this.minecraft.gameMode, localplayer, localplayer1, localplayer1.connection.connection); + net.minecraftforge.client.event.ForgeEventFactoryClient.firePlayerRespawn(this.minecraft.gameMode, oldPlayer, newPlayer, newPlayer.connection.connection);
this.level.addEntity(localplayer1); this.level.addEntity(newPlayer);
localplayer1.input = new KeyboardInput(this.minecraft.options); newPlayer.input = new KeyboardInput(this.minecraft.options);
this.minecraft.gameMode.adjustPlayer(localplayer1); this.minecraft.gameMode.adjustPlayer(newPlayer);
@@ -1504,7 +_,7 @@ @@ -1480,7 +_,7 @@
ProblemReporter.ScopedCollector problemreporter$scopedcollector = new ProblemReporter.ScopedCollector(blockEntity.problemPath(), LOGGER); ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(blockEntity.problemPath(), LOGGER);
try { try {
- blockEntity.loadWithComponents(TagValueInput.create(problemreporter$scopedcollector, this.registryAccess, packet.getTag())); - blockEntity.loadWithComponents(TagValueInput.create(reporter, this.registryAccess, packet.getTag()));
+ blockEntity.onDataPacket(connection, TagValueInput.create(problemreporter$scopedcollector, this.registryAccess, packet.getTag()), this.registryAccess); + blockEntity.onDataPacket(connection, TagValueInput.create(reporter, this.registryAccess, packet.getTag()), this.registryAccess);
} catch (Throwable throwable1) { } catch (Throwable var7) {
try { try {
problemreporter$scopedcollector.close(); reporter.close();
@@ -1727,7 +_,9 @@ @@ -1687,7 +_,9 @@
@Override @Override
public void handleCommands(final ClientboundCommandsPacket packet) { public void handleCommands(final ClientboundCommandsPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.minecraft.packetProcessor()); PacketUtils.ensureRunningOnSameThread(packet, this, this.minecraft.packetProcessor());
@@ -37,24 +37,24 @@
} }
@Override @Override
@@ -1828,6 +_,7 @@ @@ -1788,6 +_,7 @@
if (this.minecraft.screen instanceof RecipeUpdateListener recipeupdatelistener) { if (this.minecraft.screen instanceof RecipeUpdateListener updateListener) {
recipeupdatelistener.recipesUpdated(); updateListener.recipesUpdated();
} }
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onRecipesUpdated(recipeBook); + net.minecraftforge.client.event.ForgeEventFactoryClient.onRecipesUpdated(recipeBook);
} }
@Override @Override
@@ -1872,6 +_,8 @@ @@ -1832,6 +_,8 @@
this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures); this.fuelValues = FuelValues.vanillaBurnTimes(this.registryAccess, this.enabledFeatures);
List<ItemStack> list1 = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems()); List<ItemStack> searchItems = List.copyOf(CreativeModeTabs.searchTab().getDisplayItems());
this.searchTrees.updateCreativeTags(list1); this.searchTrees.updateCreativeTags(searchItems);
+ +
+ net.minecraftforge.event.ForgeEventFactory.onTagsUpdated(this.registryAccess, true, this.connection.isMemoryConnection()); + net.minecraftforge.event.ForgeEventFactory.onTagsUpdated(this.registryAccess, true, this.connection.isMemoryConnection());
} }
@Override @Override
@@ -2688,7 +_,9 @@ @@ -2650,7 +_,9 @@
} }
} }
@@ -62,18 +62,18 @@
+ public void sendChat(String content) { + public void sendChat(String content) {
+ content = net.minecraftforge.client.ForgeHooksClient.onClientSendMessage(content); + content = net.minecraftforge.client.ForgeHooksClient.onClientSendMessage(content);
+ if (content.isEmpty()) return; + if (content.isEmpty()) return;
Instant instant = Instant.now(); Instant timeStamp = Instant.now();
long i = Crypt.SaltSupplier.getLong(); long salt = Crypt.SaltSupplier.getLong();
LastSeenMessagesTracker.Update lastseenmessagestracker$update = this.lastSeenMessages.generateAndApplyUpdate(); LastSeenMessagesTracker.Update lastSeenUpdate = this.lastSeenMessages.generateAndApplyUpdate();
@@ -2698,6 +_,7 @@ @@ -2659,6 +_,7 @@
} }
public void sendCommand(final String command) { public void sendCommand(final String command) {
+ if (net.minecraftforge.client.ClientCommandHandler.runCommand(command)) return; + if (net.minecraftforge.client.ClientCommandHandler.runCommand(command)) return;
SignableCommand<ClientSuggestionProvider> signablecommand = SignableCommand.of(this.commands.parse(command, this.suggestionsProvider)); SignableCommand<ClientSuggestionProvider> signableCommand = SignableCommand.of(this.commands.parse(command, this.suggestionsProvider));
if (signablecommand.arguments().isEmpty()) { if (signableCommand.arguments().isEmpty()) {
this.send(new ServerboundChatCommandPacket(command)); this.send(new ServerboundChatCommandPacket(command));
@@ -2714,6 +_,7 @@ @@ -2675,6 +_,7 @@
} }
public void sendUnattendedCommand(final String command, final @Nullable Screen screenAfterCommand) { public void sendUnattendedCommand(final String command, final @Nullable Screen screenAfterCommand) {
@@ -9,15 +9,15 @@
return false; return false;
} else { } else {
@@ -128,9 +_,8 @@ @@ -128,9 +_,8 @@
} else if (blockstate.isAir()) { } else if (oldState.isAir()) {
return false; return false;
} else { } else {
- block.playerWillDestroy(level, pos, blockstate, this.minecraft.player); - oldBlock.playerWillDestroy(level, pos, oldState, this.minecraft.player);
FluidState fluidstate = level.getFluidState(pos); FluidState fluidState = level.getFluidState(pos);
- boolean flag = level.setBlock(pos, fluidstate.createLegacyBlock(), 11); - boolean changed = level.setBlock(pos, fluidState.createLegacyBlock(), 11);
+ boolean flag = blockstate.onDestroyedByPlayer(level, pos, minecraft.player, false, fluidstate); + boolean changed = oldState.onDestroyedByPlayer(level, pos, minecraft.player, false, fluidState);
if (flag) { if (changed) {
block.destroy(level, pos, blockstate); oldBlock.destroy(level, pos, oldState);
} }
@@ -159,6 +_,7 @@ @@ -159,6 +_,7 @@
} }
@@ -33,18 +33,18 @@
} }
+ var event = net.minecraftforge.event.ForgeEventFactory.onLeftClickBlock(this.minecraft.player, pos, direction, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK); + var event = net.minecraftforge.event.ForgeEventFactory.onLeftClickBlock(this.minecraft.player, pos, direction, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK);
BlockState blockstate1 = this.minecraft.level.getBlockState(pos); BlockState state = this.minecraft.level.getBlockState(pos);
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, blockstate1, 0.0F); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, state, 0.0F);
@@ -182,9 +_,11 @@ @@ -182,9 +_,11 @@
this.startPrediction(this.minecraft.level, sequence -> { this.startPrediction(this.minecraft.level, sequence -> {
boolean flag = !blockstate1.isAir(); boolean notAir = !state.isAir();
if (flag && this.destroyProgress == 0.0F) { if (notAir && this.destroyProgress == 0.0F) {
+ if (event != null && !event.getUseBlock().isDenied()) + if (event != null && !event.getUseBlock().isDenied())
blockstate1.attack(this.minecraft.level, pos, this.minecraft.player); state.attack(this.minecraft.level, pos, this.minecraft.player);
} }
+ if (event != null && !event.getUseItem().isDenied()) { + if (event != null && !event.getUseItem().isDenied()) {
if (flag && blockstate1.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos) >= 1.0F) { if (notAir && state.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos) >= 1.0F) {
this.destroyBlock(pos); this.destroyBlock(pos);
} else { } else {
@@ -195,6 +_,7 @@ @@ -195,6 +_,7 @@
@@ -65,17 +65,17 @@
}); });
@@ -247,7 +_,7 @@ @@ -247,7 +_,7 @@
} else { } else {
this.destroyProgress = this.destroyProgress + blockstate.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos); this.destroyProgress = this.destroyProgress + state.getDestroyProgress(this.minecraft.player, this.minecraft.player.level(), pos);
if (this.destroyTicks % 4.0F == 0.0F) { if (this.destroyTicks % 4.0F == 0.0F) {
- SoundType soundtype = blockstate.getSoundType(); - SoundType soundType = state.getSoundType();
+ SoundType soundtype = blockstate.getSoundType(this.minecraft.level, pos, this.minecraft.player); + SoundType soundType = state.getSoundType(this.minecraft.level, pos, this.minecraft.player);
this.minecraft this.minecraft
.getSoundManager() .getSoundManager()
.play( .play(
@@ -264,6 +_,7 @@ @@ -264,6 +_,7 @@
this.destroyTicks++; this.destroyTicks++;
this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, blockstate, Mth.clamp(this.destroyProgress, 0.0F, 1.0F)); this.minecraft.getTutorial().onDestroyBlock(this.minecraft.level, pos, state, Mth.clamp(this.destroyProgress, 0.0F, 1.0F));
+ if (net.minecraftforge.event.ForgeEventFactory.onLeftClickBlockHold(this.minecraft.player, pos, direction).getUseItem().isDenied()) return true; + if (net.minecraftforge.event.ForgeEventFactory.onLeftClickBlockHold(this.minecraft.player, pos, direction).getUseItem().isDenied()) return true;
if (this.destroyProgress >= 1.0F) { if (this.destroyProgress >= 1.0F) {
this.isDestroying = false; this.isDestroying = false;
@@ -83,81 +83,81 @@
@@ -306,7 +_,7 @@ @@ -306,7 +_,7 @@
private boolean sameDestroyTarget(final BlockPos pos) { private boolean sameDestroyTarget(final BlockPos pos) {
ItemStack itemstack = this.minecraft.player.getMainHandItem(); ItemStack selected = this.minecraft.player.getMainHandItem();
- return pos.equals(this.destroyBlockPos) && ItemStack.isSameItemSameComponents(itemstack, this.destroyingItem); - return pos.equals(this.destroyBlockPos) && ItemStack.isSameItemSameComponents(selected, this.destroyingItem);
+ return pos.equals(this.destroyBlockPos) && !destroyingItem.shouldCauseBlockBreakReset(itemstack); + return pos.equals(this.destroyBlockPos) && !destroyingItem.shouldCauseBlockBreakReset(selected);
} }
private void ensureHasSentCarriedItem() { private void ensureHasSentCarriedItem() {
@@ -334,12 +_,23 @@ @@ -334,12 +_,23 @@
private InteractionResult performUseItemOn(final LocalPlayer player, final InteractionHand hand, final BlockHitResult blockHit) { private InteractionResult performUseItemOn(final LocalPlayer player, final InteractionHand hand, final BlockHitResult blockHit) {
BlockPos blockpos = blockHit.getBlockPos(); BlockPos pos = blockHit.getBlockPos();
ItemStack itemstack = player.getItemInHand(hand); ItemStack itemStack = player.getItemInHand(hand);
+ var event = new net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock(player, hand, blockpos, blockHit); + var event = new net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock(player, hand, pos, blockHit);
+ if (net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock.BUS.post(event)) { + if (net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock.BUS.post(event)) {
+ return event.getCancellationResult(); + return event.getCancellationResult();
+ } + }
if (this.localPlayerMode == GameType.SPECTATOR) { if (this.localPlayerMode == GameType.SPECTATOR) {
return InteractionResult.CONSUME; return InteractionResult.CONSUME;
} else { } else {
- boolean flag = !player.getMainHandItem().isEmpty() || !player.getOffhandItem().isEmpty(); - boolean haveSomethingInOurHands = !player.getMainHandItem().isEmpty() || !player.getOffhandItem().isEmpty();
+ UseOnContext useoncontext = new UseOnContext(player, hand, blockHit); + UseOnContext context = new UseOnContext(player, hand, blockHit);
+ if (!event.getUseItem().isDenied()) { + if (!event.getUseItem().isDenied()) {
+ InteractionResult result = itemstack.onItemUseFirst(useoncontext); + InteractionResult result = itemStack.onItemUseFirst(context);
+ if (result != InteractionResult.PASS) { + if (result != InteractionResult.PASS) {
+ return result; + return result;
+ } + }
+ } + }
+ boolean flag = !player.getMainHandItem().doesSneakBypassUse(player.level(), blockpos, player) || !player.getOffhandItem().doesSneakBypassUse(player.level(), blockpos, player); + boolean haveSomethingInOurHands = !player.getMainHandItem().doesSneakBypassUse(player.level(), pos, player) || !player.getOffhandItem().doesSneakBypassUse(player.level(), pos, player);
boolean flag1 = player.isSecondaryUseActive() && flag; boolean suppressUsingBlock = player.isSecondaryUseActive() && haveSomethingInOurHands;
- if (!flag1) { - if (!suppressUsingBlock) {
+ if (event.getUseBlock().isAllowed() || (!event.getUseBlock().isDenied() && !flag1)) { + if (event.getUseBlock().isAllowed() || (!event.getUseBlock().isDenied() && !suppressUsingBlock)) {
BlockState blockstate = this.minecraft.level.getBlockState(blockpos); BlockState blockState = this.minecraft.level.getBlockState(pos);
if (!this.connection.isFeatureEnabled(blockstate.getBlock().requiredFeatures())) { if (!this.connection.isFeatureEnabled(blockState.getBlock().requiredFeatures())) {
return InteractionResult.FAIL; return InteractionResult.FAIL;
@@ -358,8 +_,10 @@ @@ -358,8 +_,10 @@
} }
} }
- if (!itemstack.isEmpty() && !player.getCooldowns().isOnCooldown(itemstack)) { - if (!itemStack.isEmpty() && !player.getCooldowns().isOnCooldown(itemStack)) {
- UseOnContext useoncontext = new UseOnContext(player, hand, blockHit); - UseOnContext context = new UseOnContext(player, hand, blockHit);
+ if (event.getUseItem().isDenied()) { + if (event.getUseItem().isDenied()) {
+ return InteractionResult.PASS; + return InteractionResult.PASS;
+ } + }
+ if (event.getUseItem().isAllowed() || (!itemstack.isEmpty() && !player.getCooldowns().isOnCooldown(itemstack))) { + if (event.getUseItem().isAllowed() || (!itemStack.isEmpty() && !player.getCooldowns().isOnCooldown(itemStack))) {
InteractionResult interactionresult2; InteractionResult success;
if (player.hasInfiniteMaterials()) { if (player.hasInfiniteMaterials()) {
int i = itemstack.getCount(); int count = itemStack.getCount();
@@ -389,6 +_,11 @@ @@ -389,6 +_,11 @@
mutableobject.setValue(InteractionResult.PASS); interactionResult.setValue(InteractionResult.PASS);
return serverbounduseitempacket; return packet;
} else { } else {
+ var event = new net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickItem(player, hand); + var event = new net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickItem(player, hand);
+ if (net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickItem.BUS.post(event)) { + if (net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickItem.BUS.post(event)) {
+ mutableobject.setValue(event.getCancellationResult()); + interactionResult.setValue(event.getCancellationResult());
+ return serverbounduseitempacket; + return packet;
+ } + }
InteractionResult interactionresult = itemstack.use(this.minecraft.level, player, hand); InteractionResult resultHolder = itemStack.use(this.minecraft.level, player, hand);
ItemStack itemstack1; ItemStack result;
if (interactionresult instanceof InteractionResult.Success interactionresult$success) { if (resultHolder instanceof InteractionResult.Success success) {
@@ -399,6 +_,9 @@ @@ -399,6 +_,9 @@
if (itemstack1 != itemstack) { if (result != itemStack) {
player.setItemInHand(hand, itemstack1); player.setItemInHand(hand, result);
+ if (itemstack1.isEmpty()) { + if (result.isEmpty()) {
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemstack, hand); + net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemStack, hand);
+ } + }
} }
mutableobject.setValue(interactionresult); interactionResult.setValue(resultHolder);
@@ -434,6 +_,10 @@ @@ -434,6 +_,10 @@
this.ensureHasSentCarriedItem(); this.ensureHasSentCarriedItem();
Vec3 vec3 = hitResult.getLocation().subtract(entity.getX(), entity.getY(), entity.getZ()); Vec3 location = hitResult.getLocation().subtract(entity.getX(), entity.getY(), entity.getZ());
this.connection.send(new ServerboundInteractPacket(entity.getId(), hand, vec3, player.isShiftKeyDown())); this.connection.send(new ServerboundInteractPacket(entity.getId(), hand, location, player.isShiftKeyDown()));
+ if (this.localPlayerMode != GameType.SPECTATOR) { + if (this.localPlayerMode != GameType.SPECTATOR) {
+ var event = new net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteractSpecific(player, hand, entity, vec3); + var event = new net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteractSpecific(player, hand, entity, location);
+ if (net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteractSpecific.BUS.post(event)) return event.getCancellationResult(); + if (net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteractSpecific.BUS.post(event)) return event.getCancellationResult();
+ } + }
return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : player.interactOn(entity, hand, vec3)); return (InteractionResult)(this.localPlayerMode == GameType.SPECTATOR ? InteractionResult.PASS : player.interactOn(entity, hand, location));
} }
@@ -1,14 +1,14 @@
--- a/net/minecraft/client/multiplayer/ServerStatusPinger.java --- a/net/minecraft/client/multiplayer/ServerStatusPinger.java
+++ b/net/minecraft/client/multiplayer/ServerStatusPinger.java +++ b/net/minecraft/client/multiplayer/ServerStatusPinger.java
@@ -124,6 +_,7 @@ @@ -123,6 +_,7 @@
onPersistentDataChange.run(); onPersistentDataChange.run();
} }
}); });
+ net.minecraftforge.client.ForgeHooksClient.processForgeListPingData(serverstatus, data); + net.minecraftforge.client.ForgeHooksClient.processForgeListPingData(status, data);
this.pingStart = Util.getMillis(); this.pingStart = Util.getMillis();
connection.send(new ServerboundPingRequestPacket(this.pingStart)); connection.send(new ServerboundPingRequestPacket(this.pingStart));
this.success = true; this.success = true;
@@ -180,7 +_,7 @@ @@ -179,7 +_,7 @@
private void pingLegacyServer( private void pingLegacyServer(
final InetSocketAddress resolvedAddress, final ServerAddress rawAddress, final ServerData data, final EventLoopGroupHolder eventLoopGroupHolder final InetSocketAddress resolvedAddress, final ServerAddress rawAddress, final ServerData data, final EventLoopGroupHolder eventLoopGroupHolder
) { ) {
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/multiplayer/SessionSearchTrees.java --- a/net/minecraft/client/multiplayer/SessionSearchTrees.java
+++ b/net/minecraft/client/multiplayer/SessionSearchTrees.java +++ b/net/minecraft/client/multiplayer/SessionSearchTrees.java
@@ -34,8 +_,8 @@ @@ -33,8 +_,8 @@
private static final SessionSearchTrees.Key RECIPE_COLLECTIONS = new SessionSearchTrees.Key(); private static final SessionSearchTrees.Key RECIPE_COLLECTIONS = new SessionSearchTrees.Key();
public static final SessionSearchTrees.Key CREATIVE_NAMES = new SessionSearchTrees.Key(); public static final SessionSearchTrees.Key CREATIVE_NAMES = new SessionSearchTrees.Key();
public static final SessionSearchTrees.Key CREATIVE_TAGS = new SessionSearchTrees.Key(); public static final SessionSearchTrees.Key CREATIVE_TAGS = new SessionSearchTrees.Key();
@@ -11,7 +11,7 @@
private CompletableFuture<SearchTree<RecipeCollection>> recipeSearch = CompletableFuture.completedFuture(SearchTree.empty()); private CompletableFuture<SearchTree<RecipeCollection>> recipeSearch = CompletableFuture.completedFuture(SearchTree.empty());
private final Map<SessionSearchTrees.Key, Runnable> reloaders = new IdentityHashMap<>(); private final Map<SessionSearchTrees.Key, Runnable> reloaders = new IdentityHashMap<>();
@@ -90,44 +_,52 @@ @@ -89,44 +_,52 @@
} }
public void updateCreativeTags(final List<ItemStack> items) { public void updateCreativeTags(final List<ItemStack> items) {
@@ -20,16 +20,16 @@
- CREATIVE_TAGS, - CREATIVE_TAGS,
+ entry.getValue(), + entry.getValue(),
() -> { () -> {
- CompletableFuture<?> completablefuture = this.creativeByTagSearch; - CompletableFuture<?> previous = this.creativeByTagSearch;
- this.creativeByTagSearch = CompletableFuture.supplyAsync( - this.creativeByTagSearch = CompletableFuture.supplyAsync(
- () -> new IdSearchTree<>(itemStack -> itemStack.tags().map(TagKey::location), items), Util.backgroundExecutor() - () -> new IdSearchTree<>(itemStack -> itemStack.tags().map(TagKey::location), items), Util.backgroundExecutor()
- ); - );
+ var tabItems = entry.getKey() == net.minecraft.world.item.CreativeModeTabs.searchTab() ? items : List.copyOf(entry.getKey().getDisplayItems()); + var tabItems = entry.getKey() == net.minecraft.world.item.CreativeModeTabs.searchTab() ? items : List.copyOf(entry.getKey().getDisplayItems());
+ CompletableFuture<?> completablefuture = this.creativeSearch.getOrDefault(entry.getValue(), EMPTY); + CompletableFuture<?> previous = this.creativeSearch.getOrDefault(entry.getValue(), EMPTY);
+ this.creativeSearch.put(entry.getValue(), CompletableFuture.supplyAsync( + this.creativeSearch.put(entry.getValue(), CompletableFuture.supplyAsync(
+ () -> new IdSearchTree<>(itemStack -> itemStack.tags().map(TagKey::location), tabItems), Util.backgroundExecutor() + () -> new IdSearchTree<>(itemStack -> itemStack.tags().map(TagKey::location), tabItems), Util.backgroundExecutor()
+ )); + ));
completablefuture.cancel(true); previous.cancel(true);
} }
); );
} }
@@ -46,14 +46,14 @@
+ entry.getValue(), + entry.getValue(),
() -> { () -> {
+ var items = entry.getKey() == net.minecraft.world.item.CreativeModeTabs.searchTab() ? itemStacks : List.copyOf(entry.getKey().getDisplayItems()); + var items = entry.getKey() == net.minecraft.world.item.CreativeModeTabs.searchTab() ? itemStacks : List.copyOf(entry.getKey().getDisplayItems());
Item.TooltipContext item$tooltipcontext = Item.TooltipContext.of(registries); Item.TooltipContext tooltipContext = Item.TooltipContext.of(registries);
TooltipFlag tooltipflag = TooltipFlag.Default.NORMAL.asCreative(); TooltipFlag tooltipFlag = TooltipFlag.Default.NORMAL.asCreative();
- CompletableFuture<?> completablefuture = this.creativeByNameSearch; - CompletableFuture<?> previous = this.creativeByNameSearch;
- this.creativeByNameSearch = CompletableFuture.supplyAsync( - this.creativeByNameSearch = CompletableFuture.supplyAsync(
+ CompletableFuture<?> completablefuture = this.creativeSearch.getOrDefault(entry.getValue(), EMPTY); + CompletableFuture<?> previous = this.creativeSearch.getOrDefault(entry.getValue(), EMPTY);
+ this.creativeSearch.put(entry.getValue(), CompletableFuture.supplyAsync( + this.creativeSearch.put(entry.getValue(), CompletableFuture.supplyAsync(
() -> new FullTextSearchTree<>( () -> new FullTextSearchTree<>(
itemStack -> getTooltipLines(Stream.of(itemStack), item$tooltipcontext, tooltipflag), itemStack -> getTooltipLines(Stream.of(itemStack), tooltipContext, tooltipFlag),
itemStack -> itemStack.typeHolder().unwrapKey().map(ResourceKey::identifier).stream(), itemStack -> itemStack.typeHolder().unwrapKey().map(ResourceKey::identifier).stream(),
- itemStacks - itemStacks
+ items + items
@@ -61,7 +61,7 @@
Util.backgroundExecutor() Util.backgroundExecutor()
- ); - );
+ )); + ));
completablefuture.cancel(true); previous.cancel(true);
} }
); );
} }
@@ -1,42 +1,42 @@
--- a/net/minecraft/client/multiplayer/chat/ChatListener.java --- a/net/minecraft/client/multiplayer/chat/ChatListener.java
+++ b/net/minecraft/client/multiplayer/chat/ChatListener.java +++ b/net/minecraft/client/multiplayer/chat/ChatListener.java
@@ -140,6 +_,8 @@ @@ -140,6 +_,8 @@
LocalPlayer localplayer = this.minecraft.player; LocalPlayer receiver = this.minecraft.player;
if (localplayer != null && localplayer.chatAbilities().canReceivePlayerMessages()) { if (receiver != null && receiver.chatAbilities().canReceivePlayerMessages()) {
Component component = boundChatType.decorate(message); Component decoratedMessage = boundChatType.decorate(message);
+ component = net.minecraftforge.client.ForgeHooksClient.onClientChat(boundChatType, component, Util.NIL_UUID); + decoratedMessage = net.minecraftforge.client.ForgeHooksClient.onClientChat(boundChatType, decoratedMessage, Util.NIL_UUID);
+ if (component == null) return false; + if (decoratedMessage == null) return false;
this.minecraft.gui.getChat().addPlayerMessage(component, null, GuiMessageTag.system()); this.minecraft.gui.getChat().addPlayerMessage(decoratedMessage, null, GuiMessageTag.system());
this.narrateChatMessage(boundChatType, message); this.narrateChatMessage(boundChatType, message);
this.logSystemMessage(component, instant); this.logSystemMessage(decoratedMessage, received);
@@ -169,12 +_,16 @@ @@ -169,12 +_,16 @@
MessageSignature messagesignature = message.signature(); MessageSignature signature = message.signature();
FilterMask filtermask = message.filterMask(); FilterMask filterMask = message.filterMask();
if (filtermask.isEmpty()) { if (filterMask.isEmpty()) {
- this.minecraft.gui.getChat().addPlayerMessage(decoratedMessage, messagesignature, guimessagetag); - this.minecraft.gui.getChat().addPlayerMessage(decoratedMessage, signature, tag);
+ Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientPlayerChat(boundChatType, decoratedMessage, message, message.sender()); + Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientPlayerChat(boundChatType, decoratedMessage, message, message.sender());
+ if (forgeComponent == null) return false; + if (forgeComponent == null) return false;
+ this.minecraft.gui.getChat().addPlayerMessage(forgeComponent, messagesignature, guimessagetag); + this.minecraft.gui.getChat().addPlayerMessage(forgeComponent, signature, tag);
this.narrateChatMessage(boundChatType, message.decoratedContent()); this.narrateChatMessage(boundChatType, message.decoratedContent());
} else { } else {
Component component = filtermask.applyWithFormatting(message.signedContent()); Component filteredContent = filterMask.applyWithFormatting(message.signedContent());
if (component != null) { if (filteredContent != null) {
- this.minecraft.gui.getChat().addPlayerMessage(boundChatType.decorate(component), messagesignature, guimessagetag); - this.minecraft.gui.getChat().addPlayerMessage(boundChatType.decorate(filteredContent), signature, tag);
+ Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientPlayerChat(boundChatType, boundChatType.decorate(component), message, message.sender()); + Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientPlayerChat(boundChatType, boundChatType.decorate(filteredContent), message, message.sender());
+ if (forgeComponent == null) return false; + if (forgeComponent == null) return false;
+ this.minecraft.gui.getChat().addPlayerMessage(forgeComponent, messagesignature, guimessagetag); + this.minecraft.gui.getChat().addPlayerMessage(forgeComponent, signature, tag);
this.narrateChatMessage(boundChatType, component); this.narrateChatMessage(boundChatType, filteredContent);
} }
} }
@@ -208,10 +_,12 @@ @@ -208,10 +_,12 @@
chatlog.push(LoggedChatMessage.system(message, timeStamp)); chatLog.push(LoggedChatMessage.system(message, timeStamp));
} }
- public void handleSystemMessage(final Component message, final boolean remote) { - public void handleSystemMessage(final Component message, final boolean remote) {
+ public void handleSystemMessage(Component message, final boolean remote) { + public void handleSystemMessage(Component message, final boolean remote) {
if (!this.minecraft.options.hideMatchedNames().get() || !this.minecraft.isBlocked(this.guessChatUUID(message))) { if (!this.minecraft.options.hideMatchedNames().get() || !this.minecraft.isBlocked(this.guessChatUUID(message))) {
LocalPlayer localplayer = this.minecraft.player; LocalPlayer receiver = this.minecraft.player;
if (localplayer != null && localplayer.chatAbilities().canReceiveSystemMessages()) { if (receiver != null && receiver.chatAbilities().canReceiveSystemMessages()) {
+ message = net.minecraftforge.client.ForgeHooksClient.onClientSystemMessage(message, remote); + message = net.minecraftforge.client.ForgeHooksClient.onClientSystemMessage(message, remote);
+ if (message == null) return; + if (message == null) return;
if (remote) { if (remote) {
@@ -4,8 +4,8 @@
boolean isAllowed(ServerAddress address); boolean isAllowed(ServerAddress address);
static AddressCheck createFromService() { static AddressCheck createFromService() {
- final ImmutableList<Predicate<String>> immutablelist = Streams.stream(ServiceLoader.load(BlockListSupplier.class)) - final ImmutableList<Predicate<String>> blockLists = Streams.stream(ServiceLoader.load(BlockListSupplier.class))
+ final ImmutableList<Predicate<String>> immutablelist = Streams.stream(ServiceLoader.load(BlockListSupplier.class, net.minecraftforge.fml.loading.FMLLoader.class.getClassLoader())) + final ImmutableList<Predicate<String>> blockLists = Streams.stream(ServiceLoader.load(BlockListSupplier.class, net.minecraftforge.fml.loading.FMLLoader.class.getClassLoader()))
.map(BlockListSupplier::createBlockList) .map(BlockListSupplier::createBlockList)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.collect(ImmutableList.toImmutableList()); .collect(ImmutableList.toImmutableList());
@@ -1,13 +1,13 @@
--- a/net/minecraft/client/particle/FireworkParticles.java --- a/net/minecraft/client/particle/FireworkParticles.java
+++ b/net/minecraft/client/particle/FireworkParticles.java +++ b/net/minecraft/client/particle/FireworkParticles.java
@@ -256,6 +_,10 @@ @@ -256,6 +_,10 @@
intlist = IntList.of(DyeColor.BLACK.getFireworkColor()); colors = IntList.of(DyeColor.BLACK.getFireworkColor());
} }
+ var factory = net.minecraftforge.client.FireworkShapeFactoryRegistry.get(fireworkexplosion1.shape()); + var factory = net.minecraftforge.client.FireworkShapeFactoryRegistry.get(explosionx.shape());
+ if (factory != null) + if (factory != null)
+ factory.build(this, flag3, flag4, intlist.toIntArray(), intlist1.toIntArray()); + factory.build(this, trail, twinkle, colors.toIntArray(), colors.toIntArray());
+ else + else
switch (fireworkexplosion1.shape()) { switch (explosionx.shape()) {
case SMALL_BALL: case SMALL_BALL:
this.createParticleBall(0.25, 2, intlist, intlist1, flag3, flag4); this.createParticleBall(0.25, 2, colors, fadeColors, trail, twinkle);
@@ -1,9 +1,9 @@
--- a/net/minecraft/client/particle/FlyTowardsPositionParticle.java --- a/net/minecraft/client/particle/FlyTowardsPositionParticle.java
+++ b/net/minecraft/client/particle/FlyTowardsPositionParticle.java +++ b/net/minecraft/client/particle/FlyTowardsPositionParticle.java
@@ -107,6 +_,7 @@ @@ -107,6 +_,7 @@
this.x = this.xStart + this.xd * f; this.x = this.xStart + this.xd * pos;
this.y = this.yStart + this.yd * f - f1 * 1.2F; this.y = this.yStart + this.yd * pos - pp * 1.2F;
this.z = this.zStart + this.zd * f; this.z = this.zStart + this.zd * pos;
+ this.setPos(this.x, this.y, this.z); // FORGE: update the particle's bounding box + this.setPos(this.x, this.y, this.z); // FORGE: update the particle's bounding box
} }
} }
@@ -1,16 +1,15 @@
--- a/net/minecraft/client/particle/ParticleEngine.java --- a/net/minecraft/client/particle/ParticleEngine.java
+++ b/net/minecraft/client/particle/ParticleEngine.java +++ b/net/minecraft/client/particle/ParticleEngine.java
@@ -64,8 +_,7 @@ @@ -63,7 +_,7 @@
private <T extends ParticleOptions> @Nullable Particle makeParticle(
final T options, final double x, final double y, final double z, final double xa, final double ya, final double za final T options, final double x, final double y, final double z, final double xa, final double ya, final double za
) { ) {
ParticleProvider<T> particleprovider = (ParticleProvider<T>)this.resourceManager - ParticleProvider<T> provider = (ParticleProvider<T>)this.resourceManager.getProviders().get(BuiltInRegistries.PARTICLE_TYPE.getId(options.getType()));
- .getProviders() + ParticleProvider<T> provider = (ParticleProvider<T>)this.resourceManager.getProvider(options.getType());
- .get(BuiltInRegistries.PARTICLE_TYPE.getId(options.getType())); return provider == null ? null : provider.createParticle(options, this.level, x, y, z, xa, ya, za, this.random);
+ .getProvider(options.getType());
return particleprovider == null ? null : particleprovider.createParticle(options, this.level, x, y, z, xa, ya, za, this.random);
} }
@@ -113,6 +_,8 @@ @@ -111,6 +_,8 @@
return new ItemPickupParticleGroup(this); return new ItemPickupParticleGroup(this);
} else if (type == ParticleRenderType.ELDER_GUARDIANS) { } else if (type == ParticleRenderType.ELDER_GUARDIANS) {
return new ElderGuardianParticleGroup(this); return new ElderGuardianParticleGroup(this);
@@ -19,7 +18,7 @@
} else { } else {
return (ParticleGroup<?>)(type == ParticleRenderType.NO_RENDER ? new NoRenderParticleGroup(this) : new QuadParticleGroup(this, type)); return (ParticleGroup<?>)(type == ParticleRenderType.NO_RENDER ? new NoRenderParticleGroup(this) : new QuadParticleGroup(this, type));
} }
@@ -122,8 +_,20 @@ @@ -120,8 +_,20 @@
this.trackedParticleCounts.addTo(limit, change); this.trackedParticleCounts.addTo(limit, change);
} }
@@ -36,8 +35,8 @@
+ } + }
+ +
public void extract(final ParticlesRenderState particlesRenderState, final Frustum frustum, final Camera camera, final float partialTickTime) { public void extract(final ParticlesRenderState particlesRenderState, final Frustum frustum, final Camera camera, final float partialTickTime) {
- for (ParticleRenderType particlerendertype : RENDER_ORDER) { - for (ParticleRenderType particleType : RENDER_ORDER) {
+ for (ParticleRenderType particlerendertype : particleRenderOrder) { // Forge: allow custom ParticleRenderType's + for (ParticleRenderType particleType : particleRenderOrder) { // Forge: allow custom ParticleRenderType's
ParticleGroup<?> particlegroup = this.particles.get(particlerendertype); ParticleGroup<?> particles = this.particles.get(particleType);
if (particlegroup != null && !particlegroup.isEmpty()) { if (particles != null && !particles.isEmpty()) {
particlesRenderState.add(particlegroup.extractRenderState(frustum, camera, partialTickTime)); particlesRenderState.add(particles.extractRenderState(frustum, camera, partialTickTime));
@@ -20,10 +20,10 @@
+ /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ + /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */
public <T extends ParticleOptions> void register(final ParticleType<T> type, final ParticleResources.SpriteParticleRegistration<T> provider) { public <T extends ParticleOptions> void register(final ParticleType<T> type, final ParticleResources.SpriteParticleRegistration<T> provider) {
ParticleResources.MutableSpriteSet particleresources$mutablespriteset = new ParticleResources.MutableSpriteSet(); ParticleResources.MutableSpriteSet spriteSet = new ParticleResources.MutableSpriteSet();
this.spriteSets.put(BuiltInRegistries.PARTICLE_TYPE.getKey(type), particleresources$mutablespriteset); this.spriteSets.put(BuiltInRegistries.PARTICLE_TYPE.getKey(type), spriteSet);
- this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(type), provider.create(particleresources$mutablespriteset)); - this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getId(type), provider.create(spriteSet));
+ register(type, provider.create(particleresources$mutablespriteset)); + register(type, provider.create(spriteSet));
} }
@Override @Override
@@ -1,9 +1,9 @@
--- a/net/minecraft/client/particle/PortalParticle.java --- a/net/minecraft/client/particle/PortalParticle.java
+++ b/net/minecraft/client/particle/PortalParticle.java +++ b/net/minecraft/client/particle/PortalParticle.java
@@ -84,6 +_,7 @@ @@ -84,6 +_,7 @@
this.x = this.xStart + this.xd * f2; this.x = this.xStart + this.xd * var4;
this.y = this.yStart + this.yd * f2 + (1.0F - f); this.y = this.yStart + this.yd * var4 + (1.0F - pos);
this.z = this.zStart + this.zd * f2; this.z = this.zStart + this.zd * var4;
+ this.setPos(this.x, this.y, this.z); // FORGE: update the particle's bounding box + this.setPos(this.x, this.y, this.z); // FORGE: update the particle's bounding box
} }
} }
@@ -1,9 +1,9 @@
--- a/net/minecraft/client/particle/ReversePortalParticle.java --- a/net/minecraft/client/particle/ReversePortalParticle.java
+++ b/net/minecraft/client/particle/ReversePortalParticle.java +++ b/net/minecraft/client/particle/ReversePortalParticle.java
@@ -42,6 +_,7 @@ @@ -42,6 +_,7 @@
this.x = this.x + this.xd * f; this.x = this.x + this.xd * speedMultiplier;
this.y = this.y + this.yd * f; this.y = this.y + this.yd * speedMultiplier;
this.z = this.z + this.zd * f; this.z = this.z + this.zd * speedMultiplier;
+ this.setPos(this.x, this.y, this.z); // FORGE: update the particle's bounding box + this.setPos(this.x, this.y, this.z); // FORGE: update the particle's bounding box
} }
} }
@@ -3,18 +3,18 @@
@@ -43,7 +_,7 @@ @@ -43,7 +_,7 @@
this.gCol = 0.6F; this.gCol = 0.6F;
this.bCol = 0.6F; this.bCol = 0.6F;
BlockTintSource blocktintsource = Minecraft.getInstance().getBlockColors().getTintSource(blockState, 0); BlockTintSource tintSource = Minecraft.getInstance().getBlockColors().getTintSource(blockState, 0);
- if (blocktintsource != null) { - if (tintSource != null) {
+ if (blocktintsource != null && net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(blockState).areBreakingParticlesTinted(blockState, level, pos)) { + if (tintSource != null && net.minecraftforge.client.extensions.common.IClientBlockExtensions.of(blockState).areBreakingParticlesTinted(blockState, level, pos)) {
int i = blocktintsource.colorAsTerrainParticle(blockState, level, pos); int col = tintSource.colorAsTerrainParticle(blockState, level, pos);
this.rCol *= (i >> 16 & 0xFF) / 255.0F; this.rCol *= (col >> 16 & 0xFF) / 255.0F;
this.gCol *= (i >> 8 & 0xFF) / 255.0F; this.gCol *= (col >> 8 & 0xFF) / 255.0F;
@@ -93,8 +_,14 @@ @@ -93,8 +_,14 @@
) { ) {
BlockState blockstate = options.getState(); BlockState state = options.getState();
return !blockstate.isAir() && !blockstate.is(Blocks.MOVING_PISTON) && blockstate.shouldSpawnTerrainParticles() return !state.isAir() && !state.is(Blocks.MOVING_PISTON) && state.shouldSpawnTerrainParticles()
- ? new TerrainParticle(level, x, y, z, xAux, yAux, zAux, blockstate) - ? new TerrainParticle(level, x, y, z, xAux, yAux, zAux, state)
+ ? (TerrainParticle)new TerrainParticle(level, x, y, z, xAux, yAux, zAux, blockstate).updateSprite(blockstate, options.getPos()) + ? (TerrainParticle)new TerrainParticle(level, x, y, z, xAux, yAux, zAux, state).updateSprite(state, options.getPos())
: null; : null;
+ } + }
+ +
@@ -1,10 +1,10 @@
--- a/net/minecraft/client/particle/VibrationSignalParticle.java --- a/net/minecraft/client/particle/VibrationSignalParticle.java
+++ b/net/minecraft/client/particle/VibrationSignalParticle.java +++ b/net/minecraft/client/particle/VibrationSignalParticle.java
@@ -87,6 +_,7 @@ @@ -87,6 +_,7 @@
this.x = Mth.lerp(d0, this.x, vec3.x()); this.x = Mth.lerp(alpha, this.x, destination.x());
this.y = Mth.lerp(d0, this.y, vec3.y()); this.y = Mth.lerp(alpha, this.y, destination.y());
this.z = Mth.lerp(d0, this.z, vec3.z()); this.z = Mth.lerp(alpha, this.z, destination.z());
+ this.setPos(this.x, this.y, this.z); // FORGE: Update the particle's bounding box + this.setPos(this.x, this.y, this.z); // FORGE: Update the particle's bounding box
double d1 = this.x - vec3.x(); double dx = this.x - destination.x();
double d2 = this.y - vec3.y(); double dy = this.y - destination.y();
double d3 = this.z - vec3.z(); double dz = this.z - destination.z();
@@ -4,8 +4,8 @@
} }
} }
- return Mth.lerp(effectScale, 1.0F, f); - return Mth.lerp(effectScale, 1.0F, modifier);
+ return net.minecraftforge.client.event.ForgeEventFactoryClient.fireFovModifierEvent(this, f, effectScale).getNewFovModifier(); + return net.minecraftforge.client.event.ForgeEventFactoryClient.fireFovModifierEvent(this, modifier, effectScale).getNewFovModifier();
} }
@Override @Override
@@ -1,14 +1,14 @@
--- a/net/minecraft/client/player/LocalPlayer.java --- a/net/minecraft/client/player/LocalPlayer.java
+++ b/net/minecraft/client/player/LocalPlayer.java +++ b/net/minecraft/client/player/LocalPlayer.java
@@ -324,6 +_,7 @@ @@ -318,6 +_,7 @@
ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = all ServerboundPlayerActionPacket.Action action = all
? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS ? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS
: ServerboundPlayerActionPacket.Action.DROP_ITEM; : ServerboundPlayerActionPacket.Action.DROP_ITEM;
+ if (isUsingItem() && getUsedItemHand() == InteractionHand.MAIN_HAND && (all || getUseItem().getCount() == 1)) stopUsingItem(); // Forge: fix MC-231097 on the clientside + if (isUsingItem() && getUsedItemHand() == InteractionHand.MAIN_HAND && (all || getUseItem().getCount() == 1)) stopUsingItem(); // Forge: fix MC-231097 on the clientside
ItemStack itemstack = this.getInventory().removeFromSelected(all); ItemStack prediction = this.getInventory().removeFromSelected(all);
this.connection.send(new ServerboundPlayerActionPacket(serverboundplayeractionpacket$action, BlockPos.ZERO, Direction.DOWN)); this.connection.send(new ServerboundPlayerActionPacket(action, BlockPos.ZERO, Direction.DOWN));
return !itemstack.isEmpty(); return !prediction.isEmpty();
@@ -551,7 +_,10 @@ @@ -545,7 +_,10 @@
@Override @Override
public void playSound(final SoundEvent sound, final float volume, final float pitch) { public void playSound(final SoundEvent sound, final float volume, final float pitch) {
@@ -20,15 +20,15 @@
} }
@Override @Override
@@ -793,6 +_,7 @@ @@ -787,6 +_,7 @@
&& this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.CROUCHING) && this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.CROUCHING)
&& (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING)); && (this.isShiftKeyDown() || !this.isSleeping() && !this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.STANDING));
this.input.tick(); this.input.tick();
+ net.minecraftforge.client.ForgeHooksClient.onMovementInputUpdate(this, this.input); + net.minecraftforge.client.ForgeHooksClient.onMovementInputUpdate(this, this.input);
this.minecraft.getTutorial().onInput(this.input); this.minecraft.getTutorial().onInput(this.input);
boolean flag3 = false; boolean wasAutoJump = false;
if (this.autoJumpTime > 0) { if (this.autoJumpTime > 0) {
@@ -865,8 +_,9 @@ @@ -859,8 +_,9 @@
} }
this.wasFallFlying = this.isFallFlying(); this.wasFallFlying = this.isFallFlying();
@@ -40,7 +40,7 @@
} }
if (this.isEyeInFluid(FluidTags.WATER)) { if (this.isEyeInFluid(FluidTags.WATER)) {
@@ -934,7 +_,7 @@ @@ -928,7 +_,7 @@
} }
private boolean shouldStopSwimSprinting() { private boolean shouldStopSwimSprinting() {
@@ -49,16 +49,16 @@
} }
public Portal.Transition getActivePortalLocalTransition() { public Portal.Transition getActivePortalLocalTransition() {
@@ -979,6 +_,8 @@ @@ -973,6 +_,8 @@
@Override @Override
public void rideTick() { public void rideTick() {
super.rideTick(); super.rideTick();
+ if (this.wantsToStopRiding() && this.isPassenger()) + if (this.wantsToStopRiding() && this.isPassenger())
+ this.input.keyPresses = this.input.keyPresses.jump(false); + this.input.keyPresses = this.input.keyPresses.jump(false);
this.handsBusy = false; this.handsBusy = false;
if (this.getControlledVehicle() instanceof AbstractBoat abstractboat) { if (this.getControlledVehicle() instanceof AbstractBoat boat) {
abstractboat.setInput( boat.setInput(this.input.keyPresses.left(), this.input.keyPresses.right(), this.input.keyPresses.forward(), this.input.keyPresses.backward());
@@ -1154,7 +_,7 @@ @@ -1146,7 +_,7 @@
&& this.isSprintingPossible(this.getAbilities().flying) && this.isSprintingPossible(this.getAbilities().flying)
&& !this.isSlowDueToUsingItem() && !this.isSlowDueToUsingItem()
&& (!this.isFallFlying() || this.isUnderWater()) && (!this.isFallFlying() || this.isUnderWater())
@@ -67,7 +67,7 @@
} }
private boolean vehicleCanSprint(final Entity vehicle) { private boolean vehicleCanSprint(final Entity vehicle) {
@@ -1230,6 +_,17 @@ @@ -1222,6 +_,17 @@
@Override @Override
public float getVisualRotationYInDegrees() { public float getVisualRotationYInDegrees() {
return this.getYRot(); return this.getYRot();
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/GameRenderer.java --- a/net/minecraft/client/renderer/GameRenderer.java
+++ b/net/minecraft/client/renderer/GameRenderer.java +++ b/net/minecraft/client/renderer/GameRenderer.java
@@ -235,6 +_,9 @@ @@ -233,6 +_,9 @@
case null: case null:
default: default:
this.clearPostEffect(); this.clearPostEffect();
@@ -10,47 +10,47 @@
} }
} }
@@ -246,7 +_,13 @@ @@ -244,7 +_,13 @@
public void processBlurEffect() { public void processBlurEffect() {
PostChain postchain = this.minecraft.getShaderManager().getPostChain(BLUR_POST_CHAIN_ID, LevelTargetBundle.MAIN_TARGETS); PostChain postChain = this.minecraft.getShaderManager().getPostChain(BLUR_POST_CHAIN_ID, LevelTargetBundle.MAIN_TARGETS);
if (postchain != null) { if (postChain != null) {
+ // TODO: [Forge][Rendering] Check if this blend management is needed anymnore with the new render pipeline changes + // TODO: [Forge][Rendering] Check if this blend management is needed anymnore with the new render pipeline changes
+ boolean wasBlendEnabled = com.mojang.blaze3d.opengl.GlStateManager._isBlendEnabled(); + boolean wasBlendEnabled = com.mojang.blaze3d.opengl.GlStateManager._isBlendEnabled();
+ if (wasBlendEnabled) + if (wasBlendEnabled)
+ com.mojang.blaze3d.opengl.GlStateManager._disableBlend(); + com.mojang.blaze3d.opengl.GlStateManager._disableBlend();
postchain.process(this.minecraft.getMainRenderTarget(), this.resourcePool); postChain.process(this.minecraft.getMainRenderTarget(), this.resourcePool);
+ if (wasBlendEnabled) + if (wasBlendEnabled)
+ com.mojang.blaze3d.opengl.GlStateManager._enableBlend(); + com.mojang.blaze3d.opengl.GlStateManager._enableBlend();
} }
} }
@@ -507,7 +_,7 @@ @@ -509,7 +_,7 @@
profilerfiller.push("screen"); profiler.push("screen");
try { try {
- this.minecraft.screen.extractRenderStateWithTooltipAndSubtitles(guigraphicsextractor, i, j, deltaTracker.getGameTimeDeltaTicks()); - this.minecraft.screen.extractRenderStateWithTooltipAndSubtitles(graphics, xMouse, yMouse, deltaTracker.getGameTimeDeltaTicks());
+ net.minecraftforge.client.ForgeHooksClient.drawScreen(this.minecraft.screen, guigraphicsextractor, i, j, deltaTracker.getRealtimeDeltaTicks()); + net.minecraftforge.client.ForgeHooksClient.drawScreen(this.minecraft.screen, graphics, xMouse, yMouse, deltaTracker.getRealtimeDeltaTicks());
} catch (Throwable throwable) { } catch (Throwable var12) {
CrashReport crashreport1 = CrashReport.forThrowable(throwable, "Rendering screen"); CrashReport report = CrashReport.forThrowable(var12, "Rendering screen");
CrashReportCategory crashreportcategory1 = crashreport1.addCategory("Screen render details"); CrashReportCategory category = report.addCategory("Screen render details");
@@ -672,6 +_,10 @@ @@ -674,6 +_,10 @@
Registry<Block> registry = this.minecraft.level.registryAccess().lookupOrThrow(Registries.BLOCK); Registry<Block> blockRegistry = this.minecraft.level.registryAccess().lookupOrThrow(Registries.BLOCK);
flag = !itemstack.isEmpty() renderOutline = !itemStack.isEmpty()
&& (itemstack.canBreakBlockInAdventureMode(blockinworld) || itemstack.canPlaceOnBlockInAdventureMode(blockinworld)); && (itemStack.canBreakBlockInAdventureMode(blockInWorld) || itemStack.canPlaceOnBlockInAdventureMode(blockInWorld));
+ if (!flag && blockstate.hasBlockEntity()) { + if (!renderOutline && blockState.hasBlockEntity()) {
+ var blockEntity = this.minecraft.level.getBlockEntity(blockpos); + var blockEntity = this.minecraft.level.getBlockEntity(pos);
+ flag = blockEntity != null && blockEntity.hasCustomOutlineRendering(); + renderOutline = blockEntity != null && blockEntity.hasCustomOutlineRendering();
+ } + }
} }
} }
} }
@@ -696,6 +_,9 @@ @@ -698,6 +_,9 @@
if (optionsrenderstate.bobView) { if (optionsState.bobView) {
this.bobView(camerarenderstate, posestack); this.bobView(cameraState, bobStack);
} }
+ +
+ var cameraSetup = net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeCameraAngles(this, this.mainCamera, f); + var cameraSetup = net.minecraftforge.client.event.ForgeEventFactoryClient.fireComputeCameraAngles(this, this.mainCamera, worldPartialTicks);
+ this.mainCamera.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll()); + this.mainCamera.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll());
matrix4f.mul(posestack.last().pose()); projectionMatrix.mul(bobStack.last().pose());
float f2 = optionsrenderstate.screenEffectScale; float screenEffectScale = optionsState.screenEffectScale;
@@ -1,55 +1,57 @@
--- a/net/minecraft/client/renderer/ItemInHandRenderer.java --- a/net/minecraft/client/renderer/ItemInHandRenderer.java
+++ b/net/minecraft/client/renderer/ItemInHandRenderer.java +++ b/net/minecraft/client/renderer/ItemInHandRenderer.java
@@ -366,12 +_,14 @@ @@ -362,6 +_,7 @@
if (iteminhandrenderer$handrenderselection.renderMainHand) { float mainHandAttack = attackHand == InteractionHand.MAIN_HAND ? attackValue : 0.0F;
float f4 = interactionhand == InteractionHand.MAIN_HAND ? f : 0.0F; float mainhandInverseArmHeight = this.itemModelResolver.swapAnimationScale(this.mainHandItem)
float f5 = this.itemModelResolver.swapAnimationScale(this.mainHandItem) * (1.0F - Mth.lerp(frameInterp, this.oMainHandHeight, this.mainHandHeight)); * (1.0F - Mth.lerp(frameInterp, this.oMainHandHeight, this.mainHandHeight));
+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, poseStack, submitNodeCollector, lightCoords, frameInterp, f1, f4, f5, this.mainHandItem)) + if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.MAIN_HAND, poseStack, submitNodeCollector, lightCoords, frameInterp, xRot, mainHandAttack, mainhandInverseArmHeight, this.mainHandItem))
this.renderArmWithItem(player, frameInterp, f1, InteractionHand.MAIN_HAND, f4, this.mainHandItem, f5, poseStack, submitNodeCollector, lightCoords); this.renderArmWithItem(
} player,
frameInterp,
if (iteminhandrenderer$handrenderselection.renderOffHand) { @@ -380,6 +_,8 @@
float f6 = interactionhand == InteractionHand.OFF_HAND ? f : 0.0F; float offHandAttack = attackHand == InteractionHand.OFF_HAND ? attackValue : 0.0F;
float f7 = this.itemModelResolver.swapAnimationScale(this.offHandItem) * (1.0F - Mth.lerp(frameInterp, this.oOffHandHeight, this.offHandHeight)); float offhandInverseArmHeight = this.itemModelResolver.swapAnimationScale(this.offHandItem)
+ if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.OFF_HAND, poseStack, submitNodeCollector, lightCoords, frameInterp, f1, f6, f7, this.offHandItem)) * (1.0F - Mth.lerp(frameInterp, this.oOffHandHeight, this.offHandHeight));
this.renderArmWithItem(player, frameInterp, f1, InteractionHand.OFF_HAND, f6, this.offHandItem, f7, poseStack, submitNodeCollector, lightCoords); +
} + if (!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(InteractionHand.OFF_HAND, poseStack, submitNodeCollector, lightCoords, frameInterp, xRot, offHandAttack, offhandInverseArmHeight, this.offHandItem))
this.renderArmWithItem(
@@ -438,7 +_,7 @@ player,
frameInterp,
@@ -457,7 +_,7 @@
} else { } else {
this.renderOneHandedMap(poseStack, submitNodeCollector, lightCoords, inverseArmHeight, humanoidarm, attack, itemStack); this.renderOneHandedMap(poseStack, submitNodeCollector, lightCoords, inverseArmHeight, arm, attack, itemStack);
} }
- } else if (itemStack.is(Items.CROSSBOW)) { - } else if (itemStack.is(Items.CROSSBOW)) {
+ } else if (itemStack.getItem() instanceof CrossbowItem) { + } else if (itemStack.getItem() instanceof CrossbowItem) {
this.applyItemArmTransform(poseStack, humanoidarm, inverseArmHeight); this.applyItemArmTransform(poseStack, arm, inverseArmHeight);
boolean flag1 = CrossbowItem.isCharged(itemStack); boolean charged = CrossbowItem.isCharged(itemStack);
boolean flag2 = humanoidarm == HumanoidArm.RIGHT; boolean isRightArm = arm == HumanoidArm.RIGHT;
@@ -483,6 +_,7 @@ @@ -502,6 +_,7 @@
} else { } else {
boolean flag3 = humanoidarm == HumanoidArm.RIGHT; boolean isRightArm = arm == HumanoidArm.RIGHT;
int j = flag3 ? 1 : -1; int invert = isRightArm ? 1 : -1;
+ if (!net.minecraftforge.client.extensions.common.IClientItemExtensions.of(itemStack).applyForgeHandTransform(poseStack, minecraft.player, humanoidarm, itemStack, frameInterp, inverseArmHeight, attack)) // FORGE: Allow items to define custom arm animation + if (!net.minecraftforge.client.extensions.common.IClientItemExtensions.of(itemStack).applyForgeHandTransform(poseStack, minecraft.player, arm, itemStack, frameInterp, inverseArmHeight, attack)) // FORGE: Allow items to define custom arm animation
if (player.isUsingItem() && player.getUseItemRemainingTicks() > 0 && player.getUsedItemHand() == hand) { if (player.isUsingItem() && player.getUseItemRemainingTicks() > 0 && player.getUsedItemHand() == hand) {
ItemUseAnimation itemuseanimation = itemStack.getUseAnimation(); ItemUseAnimation useAnimation = itemStack.getUseAnimation();
if (!itemuseanimation.hasCustomArmTransform()) { if (!useAnimation.hasCustomArmTransform()) {
@@ -628,8 +_,18 @@ @@ -647,8 +_,18 @@
this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F); this.offHandHeight = Mth.clamp(this.offHandHeight - 0.4F, 0.0F, 1.0F);
} else { } else {
float f = localplayer.getItemSwapScale(1.0F); float attackAnim = player.getItemSwapScale(1.0F);
- float f1 = this.mainHandItem != itemstack ? 0.0F : f * f * f; - float mainHandTargetHeight = this.mainHandItem != nextMainHand ? 0.0F : attackAnim * attackAnim * attackAnim;
- float f2 = this.offHandItem != itemstack1 ? 0.0F : 1.0F; - float offHandTargetHeight = this.offHandItem != nextOffHand ? 0.0F : 1.0F;
+ +
+ boolean requipM = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.mainHandItem, itemstack, localplayer.getInventory().getSelectedSlot()); + boolean requipM = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.mainHandItem, nextMainHand, player.getInventory().getSelectedSlot());
+ boolean requipO = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.offHandItem, itemstack1, -1); + boolean requipO = net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.offHandItem, nextOffHand, -1);
+ +
+ if (!requipM && this.mainHandItem != itemstack) + if (!requipM && this.mainHandItem != nextMainHand)
+ this.mainHandItem = itemstack; + this.mainHandItem = nextMainHand;
+ if (!requipO && this.offHandItem != itemstack1) + if (!requipO && this.offHandItem != nextOffHand)
+ this.offHandItem = itemstack1; + this.offHandItem = nextOffHand;
+ +
+ float f1 = requipM ? 0.0F : f * f * f; + float mainHandTargetHeight = requipM ? 0.0F : attackAnim * attackAnim * attackAnim;
+ float f2 = requipO ? 0.0F : 1.0F; + float offHandTargetHeight = requipO ? 0.0F : 1.0F;
+ +
this.mainHandHeight = this.mainHandHeight + Mth.clamp(f1 - this.mainHandHeight, -0.4F, 0.4F); this.mainHandHeight = this.mainHandHeight + Mth.clamp(mainHandTargetHeight - this.mainHandHeight, -0.4F, 0.4F);
this.offHandHeight = this.offHandHeight + Mth.clamp(f2 - this.offHandHeight, -0.4F, 0.4F); this.offHandHeight = this.offHandHeight + Mth.clamp(offHandTargetHeight - this.offHandHeight, -0.4F, 0.4F);
} }
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/renderer/LevelEventHandler.java --- a/net/minecraft/client/renderer/LevelEventHandler.java
+++ b/net/minecraft/client/renderer/LevelEventHandler.java +++ b/net/minecraft/client/renderer/LevelEventHandler.java
@@ -384,7 +_,7 @@ @@ -302,7 +_,7 @@
case 2001: case 2001:
BlockState blockstate1 = Block.stateById(data); BlockState blockState = Block.stateById(data);
if (!blockstate1.isAir()) { if (!blockState.isAir()) {
- SoundType soundtype = blockstate1.getSoundType(); - SoundType soundType = blockState.getSoundType();
+ SoundType soundtype = blockstate1.getSoundType(this.level, pos, null); + SoundType soundType = blockState.getSoundType(this.level, pos, null);
this.level this.level
.playLocalSound( .playLocalSound(
pos, soundtype.getBreakSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F, false pos, soundType.getBreakSound(), SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F, false
@@ -8,69 +8,68 @@
} }
@Override @Override
@@ -515,8 +_,9 @@ @@ -518,7 +_,8 @@
this.addSkyPass(framegraphbuilder, cameraState, terrainFog); this.addSkyPass(frame, cameraState, terrainFog);
} }
- this.addMainPass(frame, cullFrustum, modelViewMatrix, terrainFog, renderOutline, this.levelRenderState, deltaTracker, profiler, chunkSectionsToRender);
+ var hasCustomOutline = this.levelRenderState.blockOutlineRenderState != null && this.levelRenderState.blockOutlineRenderState.customRenderer() != null; + var hasCustomOutline = this.levelRenderState.blockOutlineRenderState != null && this.levelRenderState.blockOutlineRenderState.customRenderer() != null;
this.addMainPass( + this.addMainPass(frame, cullFrustum, modelViewMatrix, terrainFog, renderOutline | hasCustomOutline, this.levelRenderState, deltaTracker, profiler, chunkSectionsToRender);
- framegraphbuilder, frustum, modelViewMatrix, terrainFog, renderOutline, this.levelRenderState, deltaTracker, profilerfiller, chunkSectionsToRender PostChain entityOutlineChain = this.minecraft.getShaderManager().getPostChain(ENTITY_OUTLINE_POST_CHAIN_ID, LevelTargetBundle.OUTLINE_TARGETS);
+ framegraphbuilder, frustum, modelViewMatrix, terrainFog, renderOutline | hasCustomOutline, this.levelRenderState, deltaTracker, profilerfiller, chunkSectionsToRender if (this.levelRenderState.haveGlowingEntities && entityOutlineChain != null) {
); entityOutlineChain.addToFrame(frame, screenWidth, screenHeight, this.targets);
PostChain postchain1 = this.minecraft.getShaderManager().getPostChain(ENTITY_OUTLINE_POST_CHAIN_ID, LevelTargetBundle.OUTLINE_TARGETS); @@ -544,6 +_,7 @@
if (this.levelRenderState.haveGlowingEntities && postchain1 != null) {
@@ -543,6 +_,7 @@
} }
this.addLateDebugPass(framegraphbuilder, this.levelRenderState.cameraRenderState, terrainFog, modelViewMatrix); this.addLateDebugPass(frame, this.levelRenderState.cameraRenderState, terrainFog, modelViewMatrix);
+ net.minecraftforge.client.FramePassManager.insertForgePasses(framegraphbuilder, targets, this.levelRenderState); // Forge: Modded passes are inserted here. + net.minecraftforge.client.FramePassManager.insertForgePasses(frame, targets, this.levelRenderState); // Forge: Modded passes are inserted here.
profilerfiller.popPush("executeFrameGraph"); profiler.popPush("executeFrameGraph");
framegraphbuilder.execute(resourceAllocator, new FrameGraphBuilder.Inspector() { frame.execute(resourceAllocator, new FrameGraphBuilder.Inspector() {
{ {
@@ -580,7 +_,7 @@ @@ -581,7 +_,7 @@
profilerfiller.popPush("entities"); profiler.popPush("entities");
this.extractVisibleEntities(camera, frustum, deltaTracker, this.levelRenderState); this.extractVisibleEntities(camera, cullFrustum, deltaTracker, this.levelRenderState);
profilerfiller.popPush("blockEntities"); profiler.popPush("blockEntities");
- this.extractVisibleBlockEntities(camera, deltaPartialTick, this.levelRenderState); - this.extractVisibleBlockEntities(camera, deltaPartialTick, this.levelRenderState);
+ this.extractVisibleBlockEntities(camera, deltaPartialTick, this.levelRenderState, frustum); + this.extractVisibleBlockEntities(camera, deltaPartialTick, this.levelRenderState, cullFrustum);
profilerfiller.popPush("blockOutline"); profiler.popPush("blockOutline");
this.extractBlockOutline(camera, this.levelRenderState); this.extractBlockOutline(camera, this.levelRenderState);
profilerfiller.popPush("blockBreaking"); profiler.popPush("blockBreaking");
@@ -863,7 +_,7 @@ @@ -857,7 +_,7 @@
} }
} }
- private void extractVisibleBlockEntities(final Camera camera, final float deltaPartialTick, final LevelRenderState levelRenderState) { - private void extractVisibleBlockEntities(final Camera camera, final float deltaPartialTick, final LevelRenderState levelRenderState) {
+ private void extractVisibleBlockEntities(final Camera camera, final float deltaPartialTick, final LevelRenderState levelRenderState, final Frustum frustum) { + private void extractVisibleBlockEntities(final Camera camera, final float deltaPartialTick, final LevelRenderState levelRenderState, final Frustum frustum) {
Vec3 vec3 = camera.position(); Vec3 cameraPos = camera.position();
double d0 = vec3.x(); double camX = cameraPos.x();
double d1 = vec3.y(); double camY = cameraPos.y();
@@ -874,6 +_,7 @@ @@ -868,6 +_,7 @@
List<BlockEntity> list = sectionrenderdispatcher$rendersection.getSectionMesh().getRenderableBlockEntities(); List<BlockEntity> renderableBlockEntities = section.getSectionMesh().getRenderableBlockEntities();
if (!list.isEmpty() && !(sectionrenderdispatcher$rendersection.getVisibility(Util.getMillis()) < 0.3F)) { if (!renderableBlockEntities.isEmpty() && !(section.getVisibility(Util.getMillis()) < 0.3F)) {
for (BlockEntity blockentity : list) { for (BlockEntity blockEntity : renderableBlockEntities) {
+ if (!frustum.isVisible(blockentity.getRenderBoundingBox())) continue; + if (!frustum.isVisible(blockEntity.getRenderBoundingBox())) continue;
BlockPos blockpos = blockentity.getBlockPos(); BlockPos blockPos = blockEntity.getBlockPos();
SortedSet<BlockDestructionProgress> sortedset = this.destructionProgress.get(blockpos.asLong()); SortedSet<BlockDestructionProgress> progresses = this.destructionProgress.get(blockPos.asLong());
ModelFeatureRenderer.CrumblingOverlay modelfeaturerenderer$crumblingoverlay; ModelFeatureRenderer.CrumblingOverlay breakProgress;
@@ -902,6 +_,7 @@ @@ -895,6 +_,7 @@
if (blockentity1.isRemoved()) { if (blockEntity.isRemoved()) {
iterator.remove(); iterator.remove();
} else { } else {
+ if (!frustum.isVisible(blockentity1.getRenderBoundingBox())) continue; + if (!frustum.isVisible(blockEntity.getRenderBoundingBox())) continue;
BlockEntityRenderState blockentityrenderstate1 = this.blockEntityRenderDispatcher.tryExtractRenderState(blockentity1, deltaPartialTick, null); BlockEntityRenderState state = this.blockEntityRenderDispatcher.tryExtractRenderState(blockEntity, deltaPartialTick, null);
if (blockentityrenderstate1 != null) { if (state != null) {
levelRenderState.blockEntityRenderStates.add(blockentityrenderstate1); levelRenderState.blockEntityRenderStates.add(state);
@@ -938,7 +_,7 @@ @@ -931,7 +_,7 @@
SortedSet<BlockDestructionProgress> sortedset = entry.getValue(); SortedSet<BlockDestructionProgress> progresses = entry.getValue();
if (sortedset != null && !sortedset.isEmpty()) { if (progresses != null && !progresses.isEmpty()) {
int i = sortedset.last().getProgress(); int progress = progresses.last().getProgress();
- levelRenderState.blockBreakingRenderStates.add(new BlockBreakingRenderState(blockpos, this.level.getBlockState(blockpos), i)); - levelRenderState.blockBreakingRenderStates.add(new BlockBreakingRenderState(pos, this.level.getBlockState(pos), progress));
+ levelRenderState.blockBreakingRenderStates.add(new BlockBreakingRenderState(blockpos, this.level.getBlockState(blockpos), i, this.level.getModelDataManager().getAtOrEmpty(blockpos))); + levelRenderState.blockBreakingRenderStates.add(new BlockBreakingRenderState(pos, this.level.getBlockState(pos), progress, this.level.getModelDataManager().getAtOrEmpty(pos)));
} }
} }
} }
@@ -966,6 +_,12 @@ @@ -957,6 +_,12 @@
private void extractBlockOutline(final Camera camera, final LevelRenderState levelRenderState) { private void extractBlockOutline(final Camera camera, final LevelRenderState levelRenderState) {
levelRenderState.blockOutlineRenderState = null; levelRenderState.blockOutlineRenderState = null;
@@ -80,30 +79,30 @@
+ return; + return;
+ } + }
+ +
if (this.minecraft.hitResult instanceof BlockHitResult blockhitresult) { if (this.minecraft.hitResult instanceof BlockHitResult blockHitResult) {
if (blockhitresult.getType() != HitResult.Type.MISS) { if (blockHitResult.getType() != HitResult.Type.MISS) {
BlockPos blockpos = blockhitresult.getBlockPos(); BlockPos pos = blockHitResult.getBlockPos();
@@ -999,6 +_,10 @@ @@ -990,6 +_,10 @@
) { ) {
BlockOutlineRenderState blockoutlinerenderstate = levelRenderState.blockOutlineRenderState; BlockOutlineRenderState state = levelRenderState.blockOutlineRenderState;
if (blockoutlinerenderstate != null) { if (state != null) {
+ if (blockoutlinerenderstate.customRenderer() != null) { + if (state.customRenderer() != null) {
+ blockoutlinerenderstate.customRenderer().render(bufferSource, poseStack, onlyTranslucentBlocks, levelRenderState); + state.customRenderer().render(bufferSource, poseStack, onlyTranslucentBlocks, levelRenderState);
+ return; + return;
+ } + }
if (blockoutlinerenderstate.isTranslucent() == onlyTranslucentBlocks) { if (state.isTranslucent() == onlyTranslucentBlocks) {
Vec3 vec3 = levelRenderState.cameraRenderState.pos; Vec3 cameraPos = levelRenderState.cameraRenderState.pos;
if (blockoutlinerenderstate.highContrast()) { if (state.highContrast()) {
@@ -1491,7 +_,7 @@ @@ -1458,7 +_,7 @@
} else { } else {
int i = brightnessGetter.packedBrightness(level, pos); int packedBrightness = brightnessGetter.packedBrightness(level, pos);
int j = LightCoordsUtil.block(i); int block = LightCoordsUtil.block(packedBrightness);
- int k = state.getLightEmission(); - int blockSelfEmission = state.getLightEmission();
+ int k = state.getLightEmission(level, pos); + int blockSelfEmission = state.getLightEmission(level, pos);
return j < k ? LightCoordsUtil.withBlock(i, k) : i; return block < blockSelfEmission ? LightCoordsUtil.withBlock(packedBrightness, blockSelfEmission) : packedBrightness;
} }
} }
@@ -1539,6 +_,18 @@ @@ -1506,6 +_,18 @@
public CloudRenderer getCloudRenderer() { public CloudRenderer getCloudRenderer() {
return this.cloudRenderer; return this.cloudRenderer;
@@ -4,30 +4,30 @@
Player player = this.minecraft.player; Player player = this.minecraft.player;
if (isFirstPerson && !isSleeping) { if (isFirstPerson && !isSleeping) {
if (!player.noPhysics) { if (!player.noPhysics) {
- BlockState blockstate = getViewBlockingState(player); - BlockState blockState = getViewBlockingState(player);
+ var overlay = getOverlayBlock(player); + var overlay = getOverlayBlock(player);
+ BlockState blockstate = overlay == null ? null : overlay.getLeft(); + BlockState blockState = overlay == null ? null : overlay.getLeft();
if (blockstate != null) { if (blockState != null) {
+ if (!net.minecraftforge.client.ForgeHooksClient.renderBlockOverlay(player, posestack, net.minecraftforge.client.event.RenderBlockScreenEffectEvent.OverlayType.BLOCK, overlay.getLeft(), overlay.getRight())) + if (!net.minecraftforge.client.ForgeHooksClient.renderBlockOverlay(player, poseStack, net.minecraftforge.client.event.RenderBlockScreenEffectEvent.OverlayType.BLOCK, overlay.getLeft(), overlay.getRight()))
renderTex(this.minecraft.getModelManager().getBlockStateModelSet().getParticleMaterial(blockstate).sprite(), posestack, this.bufferSource); renderTex(this.minecraft.getModelManager().getBlockStateModelSet().getParticleMaterial(blockState).sprite(), poseStack, this.bufferSource);
} }
} }
if (!this.minecraft.player.isSpectator()) { if (!this.minecraft.player.isSpectator()) {
if (this.minecraft.player.isEyeInFluid(FluidTags.WATER)) { if (this.minecraft.player.isEyeInFluid(FluidTags.WATER)) {
+ if (!net.minecraftforge.client.ForgeHooksClient.renderWaterOverlay(player, posestack)) + if (!net.minecraftforge.client.ForgeHooksClient.renderWaterOverlay(player, poseStack))
renderWater(this.minecraft, posestack, this.bufferSource); renderWater(this.minecraft, poseStack, this.bufferSource);
+ } else if (!player.getEyeInFluidType().isAir()) { + } else if (!player.getEyeInFluidType().isAir()) {
+ net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions.of(player.getEyeInFluidType()).renderOverlay(this.minecraft, posestack, this.bufferSource); + net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions.of(player.getEyeInFluidType()).renderOverlay(this.minecraft, poseStack, this.bufferSource);
} }
if (this.minecraft.player.isOnFire()) { if (this.minecraft.player.isOnFire()) {
TextureAtlasSprite textureatlassprite = this.sprites.get(ModelBakery.FIRE_1); TextureAtlasSprite fireSprite = this.sprites.get(ModelBakery.FIRE_1);
+ if (!net.minecraftforge.client.ForgeHooksClient.renderFireOverlay(player, posestack)) + if (!net.minecraftforge.client.ForgeHooksClient.renderFireOverlay(player, poseStack))
renderFire(posestack, this.bufferSource, textureatlassprite); renderFire(poseStack, this.bufferSource, fireSprite);
} }
} }
@@ -126,6 +_,11 @@ @@ -124,6 +_,11 @@
} }
private static @Nullable BlockState getViewBlockingState(final Player player) { private static @Nullable BlockState getViewBlockingState(final Player player) {
@@ -36,19 +36,19 @@
+ } + }
+ +
+ private static org.apache.commons.lang3.tuple.@Nullable Pair<BlockState, BlockPos> getOverlayBlock(Player player) { + private static org.apache.commons.lang3.tuple.@Nullable Pair<BlockState, BlockPos> getOverlayBlock(Player player) {
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); BlockPos.MutableBlockPos testPos = new BlockPos.MutableBlockPos();
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
@@ -135,7 +_,7 @@ @@ -133,7 +_,7 @@
blockpos$mutableblockpos.set(d0, d1, d2); testPos.set(xo, yo, zo);
BlockState blockstate = player.level().getBlockState(blockpos$mutableblockpos); BlockState blockState = player.level().getBlockState(testPos);
if (blockstate.getRenderShape() != RenderShape.INVISIBLE && blockstate.isViewBlocking(player.level(), blockpos$mutableblockpos)) { if (blockState.getRenderShape() != RenderShape.INVISIBLE && blockState.isViewBlocking(player.level(), testPos)) {
- return blockstate; - return blockState;
+ return org.apache.commons.lang3.tuple.Pair.of(blockstate, blockpos$mutableblockpos.immutable()); + return org.apache.commons.lang3.tuple.Pair.of(blockState, testPos.immutable());
} }
} }
@@ -163,6 +_,10 @@ @@ -161,6 +_,10 @@
} }
private static void renderWater(final Minecraft minecraft, final PoseStack poseStack, final MultiBufferSource bufferSource) { private static void renderWater(final Minecraft minecraft, final PoseStack poseStack, final MultiBufferSource bufferSource) {
@@ -56,15 +56,15 @@
+ } + }
+ +
+ public static void renderFluid(Minecraft minecraft, PoseStack poseStack, MultiBufferSource bufferSource, Identifier texture) { + public static void renderFluid(Minecraft minecraft, PoseStack poseStack, MultiBufferSource bufferSource, Identifier texture) {
BlockPos blockpos = BlockPos.containing(minecraft.player.getX(), minecraft.player.getEyeY(), minecraft.player.getZ()); BlockPos pos = BlockPos.containing(minecraft.player.getX(), minecraft.player.getEyeY(), minecraft.player.getZ());
float f = Lightmap.getBrightness(minecraft.player.level().dimensionType(), minecraft.player.level().getMaxLocalRawBrightness(blockpos)); float br = Lightmap.getBrightness(minecraft.player.level().dimensionType(), minecraft.player.level().getMaxLocalRawBrightness(pos));
int i = ARGB.colorFromFloat(0.1F, f, f, f); int color = ARGB.colorFromFloat(0.1F, br, br, br);
@@ -175,7 +_,7 @@ @@ -173,7 +_,7 @@
float f7 = -minecraft.player.getYRot() / 64.0F; float uo = -minecraft.player.getYRot() / 64.0F;
float f8 = minecraft.player.getXRot() / 64.0F; float vo = minecraft.player.getXRot() / 64.0F;
Matrix4f matrix4f = poseStack.last().pose(); Matrix4f pose = poseStack.last().pose();
- VertexConsumer vertexconsumer = bufferSource.getBuffer(RenderTypes.blockScreenEffect(UNDERWATER_LOCATION)); - VertexConsumer builder = bufferSource.getBuffer(RenderTypes.blockScreenEffect(UNDERWATER_LOCATION));
+ VertexConsumer vertexconsumer = bufferSource.getBuffer(RenderTypes.blockScreenEffect(texture)); + VertexConsumer builder = bufferSource.getBuffer(RenderTypes.blockScreenEffect(texture));
vertexconsumer.addVertex(matrix4f, -1.0F, -1.0F, -0.5F).setUv(4.0F + f7, 4.0F + f8).setColor(i); builder.addVertex(pose, -1.0F, -1.0F, -0.5F).setUv(4.0F + uo, 4.0F + vo).setColor(color);
vertexconsumer.addVertex(matrix4f, 1.0F, -1.0F, -0.5F).setUv(0.0F + f7, 4.0F + f8).setColor(i); builder.addVertex(pose, 1.0F, -1.0F, -0.5F).setUv(0.0F + uo, 4.0F + vo).setColor(color);
vertexconsumer.addVertex(matrix4f, 1.0F, 1.0F, -0.5F).setUv(0.0F + f7, 0.0F + f8).setColor(i); builder.addVertex(pose, 1.0F, 1.0F, -0.5F).setUv(0.0F + uo, 0.0F + vo).setColor(color);
@@ -1,23 +1,23 @@
--- a/net/minecraft/client/renderer/block/FluidRenderer.java --- a/net/minecraft/client/renderer/block/FluidRenderer.java
+++ b/net/minecraft/client/renderer/block/FluidRenderer.java +++ b/net/minecraft/client/renderer/block/FluidRenderer.java
@@ -87,8 +_,10 @@ @@ -87,8 +_,10 @@
boolean flag5 = shouldRenderFace(fluidState, blockState, Direction.EAST, fluidstate5); boolean renderEast = shouldRenderFace(fluidState, blockState, Direction.EAST, fluidStateEast);
if (flag || flag1 || flag5 || flag4 || flag2 || flag3) { if (renderUp || renderDown || renderEast || renderWest || renderNorth || renderSouth) {
FluidModel fluidmodel = this.fluidModels.get(fluidState); FluidModel model = this.fluidModels.get(fluidState);
+ var fluidExt = net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions.of(fluidState); + var fluidExt = net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions.of(fluidState);
+ fluidmodel = fluidExt.getModel(fluidState, level, pos, fluidmodel); + model = fluidExt.getModel(fluidState, level, pos, model);
VertexConsumer vertexconsumer = output.getBuilder(fluidmodel.layer()); VertexConsumer builder = output.getBuilder(model.layer());
- int i = fluidmodel.tintSource() != null ? fluidmodel.tintSource().colorInWorld(blockState, level, pos) : -1; - int tintColor = model.tintSource() != null ? model.tintSource().colorInWorld(blockState, level, pos) : -1;
+ int i = fluidmodel.tintSource() != null ? fluidmodel.tintSource().colorInWorld(blockState, level, pos) : fluidExt.getTintColor(); + int tintColor = model.tintSource() != null ? model.tintSource().colorInWorld(blockState, level, pos) : fluidExt.getTintColor();
CardinalLighting cardinallighting = level.cardinalLighting(); CardinalLighting cardinalLighting = level.cardinalLighting();
Fluid fluid = fluidState.getType(); Fluid type = fluidState.getType();
float f4 = this.getHeight(level, fluid, pos, blockState, fluidState); float heightSelf = this.getHeight(level, type, pos, blockState, fluidState);
@@ -284,7 +_,7 @@ @@ -295,7 +_,7 @@
boolean flag7 = false; boolean isOverlay = false;
if (fluidmodel.overlayMaterial() != null) { if (model.overlayMaterial() != null) {
Block block = blockstate6.getBlock(); Block relativeBlock = faceState.getBlock();
- if (block instanceof HalfTransparentBlock || block instanceof LeavesBlock) { - if (relativeBlock instanceof HalfTransparentBlock || relativeBlock instanceof LeavesBlock) {
+ if (blockstate6.shouldDisplayFluidOverlay(level, pos.relative(direction), fluidState)) { + if (faceState.shouldDisplayFluidOverlay(level, pos.relative(faceDir), fluidState)) {
textureatlassprite3 = fluidmodel.overlayMaterial().sprite(); sprite = model.overlayMaterial().sprite();
flag7 = true; isOverlay = true;
} }
@@ -26,9 +26,9 @@
+ model.collectParts(this.random, this.parts, modelData); + model.collectParts(this.random, this.parts, modelData);
if (!this.parts.isEmpty()) { if (!this.parts.isEmpty()) {
try { try {
Vec3 vec3 = blockState.getOffset(pos); Vec3 offset = blockState.getOffset(pos);
- if (this.ambientOcclusion && blockState.getLightEmission() == 0 && this.parts.getFirst().useAmbientOcclusion()) { - if (this.ambientOcclusion && blockState.getLightEmission() == 0 && this.parts.getFirst().useAmbientOcclusion()) {
+ if (this.ambientOcclusion && blockState.getLightEmission(level, pos) == 0 && this.parts.getFirst().useAmbientOcclusion()) { + if (this.ambientOcclusion && blockState.getLightEmission(level, pos) == 0 && this.parts.getFirst().useAmbientOcclusion()) {
this.tesselateAmbientOcclusion(output, x + (float)vec3.x, y + (float)vec3.y, z + (float)vec3.z, this.parts, level, blockState, pos); this.tesselateAmbientOcclusion(output, x + (float)offset.x, y + (float)offset.y, z + (float)offset.z, this.parts, level, blockState, pos);
} else { } else {
this.tesselateFlat(output, x + (float)vec3.x, y + (float)vec3.y, z + (float)vec3.z, this.parts, level, blockState, pos); this.tesselateFlat(output, x + (float)offset.x, y + (float)offset.y, z + (float)offset.z, this.parts, level, blockState, pos);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/block/dispatch/BlockStateModel.java --- a/net/minecraft/client/renderer/block/dispatch/BlockStateModel.java
+++ b/net/minecraft/client/renderer/block/dispatch/BlockStateModel.java +++ b/net/minecraft/client/renderer/block/dispatch/BlockStateModel.java
@@ -22,9 +_,11 @@ @@ -21,9 +_,11 @@
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -8,9 +8,9 @@
public WeightedVariants(final WeightedList<BlockStateModel> list) { public WeightedVariants(final WeightedList<BlockStateModel> list) {
this.list = list; this.list = list;
BlockStateModel blockstatemodel = list.unwrap().getFirst().value(); BlockStateModel firstModel = list.unwrap().getFirst().value();
this.particleMaterial = blockstatemodel.particleMaterial(); this.particleMaterial = firstModel.particleMaterial();
+ this.first = blockstatemodel; + this.first = firstModel;
this.materialFlags = computeMaterialFlags(list); this.materialFlags = computeMaterialFlags(list);
} }
@@ -28,10 +28,10 @@
} }
@@ -54,7 +_,7 @@ @@ -54,7 +_,7 @@
for (BlockStateModel blockstatemodel : this.models) { for (BlockStateModel model : this.models) {
random.setSeed(i); random.setSeed(seed);
- blockstatemodel.collectParts(random, output); - model.collectParts(random, output);
+ blockstatemodel.collectParts(random, output, data); + model.collectParts(random, output, data);
} }
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java --- a/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java
+++ b/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java +++ b/net/minecraft/client/renderer/blockentity/SkullBlockRenderer.java
@@ -44,6 +_,7 @@ @@ -43,6 +_,7 @@
public static final WallAndGroundTransformations<Transformation> TRANSFORMATIONS = new WallAndGroundTransformations<>( public static final WallAndGroundTransformations<Transformation> TRANSFORMATIONS = new WallAndGroundTransformations<>(
SkullBlockRenderer::createWallTransformation, SkullBlockRenderer::createGroundTransformation, 16 SkullBlockRenderer::createWallTransformation, SkullBlockRenderer::createGroundTransformation, 16
); );
@@ -8,7 +8,7 @@
private final Function<SkullBlock.Type, SkullModelBase> modelByType; private final Function<SkullBlock.Type, SkullModelBase> modelByType;
public static final Map<SkullBlock.Type, Identifier> SKIN_BY_TYPE = Util.make(Maps.newHashMap(), map -> { public static final Map<SkullBlock.Type, Identifier> SKIN_BY_TYPE = Util.make(Maps.newHashMap(), map -> {
map.put(SkullBlock.Types.SKELETON, Identifier.withDefaultNamespace("textures/entity/skeleton/skeleton.png")); map.put(SkullBlock.Types.SKELETON, Identifier.withDefaultNamespace("textures/entity/skeleton/skeleton.png"));
@@ -68,7 +_,9 @@ @@ -67,7 +_,9 @@
case PIGLIN -> new PiglinHeadModel(modelSet.bakeLayer(ModelLayers.PIGLIN_HEAD)); case PIGLIN -> new PiglinHeadModel(modelSet.bakeLayer(ModelLayers.PIGLIN_HEAD));
}); });
} else { } else {
@@ -1,20 +1,20 @@
--- a/net/minecraft/client/renderer/chunk/SectionCompiler.java --- a/net/minecraft/client/renderer/chunk/SectionCompiler.java
+++ b/net/minecraft/client/renderer/chunk/SectionCompiler.java +++ b/net/minecraft/client/renderer/chunk/SectionCompiler.java
@@ -63,6 +_,7 @@ @@ -61,6 +_,7 @@
public SectionCompiler.Results compile( public SectionCompiler.Results compile(
final SectionPos sectionPos, final RenderSectionRegion region, final VertexSorting vertexSorting, final SectionBufferBuilderPack builders final SectionPos sectionPos, final RenderSectionRegion region, final VertexSorting vertexSorting, final SectionBufferBuilderPack builders
) { ) {
+ var modelDataMap = net.minecraft.client.Minecraft.getInstance().level.getModelDataManager().getAt(sectionPos); + var modelDataMap = net.minecraft.client.Minecraft.getInstance().level.getModelDataManager().getAt(sectionPos);
SectionCompiler.Results sectioncompiler$results = new SectionCompiler.Results(); SectionCompiler.Results results = new SectionCompiler.Results();
BlockPos blockpos = sectionPos.origin(); BlockPos minPos = sectionPos.origin();
BlockPos blockpos1 = blockpos.offset(15, 15, 15); BlockPos maxPos = minPos.offset(15, 15, 15);
@@ -111,7 +_,8 @@ @@ -109,7 +_,8 @@
blockpos2, pos,
blockstate, blockState,
this.blockModelSet.get(blockstate), this.blockModelSet.get(blockState),
- blockstate.getSeed(blockpos2) - blockState.getSeed(pos)
+ blockstate.getSeed(blockpos2), + blockState.getSeed(pos),
+ modelDataMap.getOrDefault(blockpos2, net.minecraftforge.client.model.data.ModelData.EMPTY) + modelDataMap.getOrDefault(pos, net.minecraftforge.client.model.data.ModelData.EMPTY)
); );
} }
} catch (Throwable throwable) { } catch (Throwable var21) {
@@ -6,6 +6,6 @@
public boolean isVisible(final AABB bb) { public boolean isVisible(final AABB bb) {
+ // Forge: exit early for infinite bounds, these would otherwise fail in the intersection test at certain camera angles (GH-9321) + // Forge: exit early for infinite bounds, these would otherwise fail in the intersection test at certain camera angles (GH-9321)
+ if (bb.equals(net.minecraftforge.common.extensions.IForgeBlockEntity.INFINITE_EXTENT_AABB)) return true; + if (bb.equals(net.minecraftforge.common.extensions.IForgeBlockEntity.INFINITE_EXTENT_AABB)) return true;
int i = this.cubeInFrustum(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); int intersectionResult = this.cubeInFrustum(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
return i == -2 || i == -1; return intersectionResult == -2 || intersectionResult == -1;
} }
@@ -1,13 +1,13 @@
--- a/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java --- a/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java
+++ b/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java +++ b/net/minecraft/client/renderer/debug/EntityHitboxDebugRenderer.java
@@ -93,8 +_,8 @@ @@ -98,8 +_,8 @@
); );
} }
- if (entity instanceof EnderDragon enderdragon) { - if (entity instanceof EnderDragon dragon) {
- for (EnderDragonPart enderdragonpart : enderdragon.getSubEntities()) { - for (EnderDragonPart subEntity : dragon.getSubEntities()) {
+ if (entity.isMultipartEntity()) { + if (entity.isMultipartEntity()) {
+ for (var enderdragonpart : entity.getParts()) { + for (var subEntity : entity.getParts()) {
Vec3 vec34 = enderdragonpart.position(); Vec3 latestSubPosition = subEntity.position();
Vec3 vec35 = enderdragonpart.getPosition(partialTicks); Vec3 currentSubPosition = subEntity.getPosition(partialTicks);
Vec3 vec36 = vec35.subtract(vec34); Vec3 subOffset = currentSubPosition.subtract(latestSubPosition);
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java --- a/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java
+++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java +++ b/net/minecraft/client/renderer/entity/EntityRenderDispatcher.java
@@ -209,6 +_,14 @@ @@ -207,6 +_,14 @@
return this.itemInHandRenderer; return this.itemInHandRenderer;
} }
@@ -14,11 +14,11 @@
+ +
@Override @Override
public void onResourceManagerReload(final ResourceManager resourceManager) { public void onResourceManagerReload(final ResourceManager resourceManager) {
EntityRendererProvider.Context entityrendererprovider$context = new EntityRendererProvider.Context( EntityRendererProvider.Context context = new EntityRendererProvider.Context(
@@ -226,5 +_,6 @@ @@ -224,5 +_,6 @@
this.renderers = EntityRenderers.createEntityRenderers(entityrendererprovider$context); this.renderers = EntityRenderers.createEntityRenderers(context);
this.playerRenderers = EntityRenderers.createAvatarRenderers(entityrendererprovider$context); this.playerRenderers = EntityRenderers.createAvatarRenderers(context);
this.mannequinRenderers = EntityRenderers.createAvatarRenderers(entityrendererprovider$context); this.mannequinRenderers = EntityRenderers.createAvatarRenderers(context);
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onGatherLayers(renderers, playerRenderers, mannequinRenderers, entityrendererprovider$context); + net.minecraftforge.client.event.ForgeEventFactoryClient.onGatherLayers(renderers, playerRenderers, mannequinRenderers, context);
} }
} }
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/entity/EntityRenderer.java --- a/net/minecraft/client/renderer/entity/EntityRenderer.java
+++ b/net/minecraft/client/renderer/entity/EntityRenderer.java +++ b/net/minecraft/client/renderer/entity/EntityRenderer.java
@@ -126,16 +_,17 @@ @@ -128,16 +_,17 @@
final S state, final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, final CameraRenderState camera, final int offset final S state, final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, final CameraRenderState camera, final int offset
) { ) {
poseStack.pushPose(); poseStack.pushPose();
@@ -22,12 +22,12 @@
); );
} }
@@ -187,7 +_,7 @@ @@ -189,7 +_,7 @@
if (this.entityRenderDispatcher.camera != null) { if (this.entityRenderDispatcher.camera != null) {
state.distanceToCameraSq = this.entityRenderDispatcher.distanceToSqr(entity); state.distanceToCameraSq = this.entityRenderDispatcher.distanceToSqr(entity);
- boolean flag1 = state.distanceToCameraSq < 4096.0 && this.shouldShowName(entity, state.distanceToCameraSq); - boolean shouldShowName = state.distanceToCameraSq < 4096.0 && this.shouldShowName(entity, state.distanceToCameraSq);
+ boolean flag1 = net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(entity, state.distanceToCameraSq) && this.shouldShowName(entity, state.distanceToCameraSq); + boolean shouldShowName = net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(entity, state.distanceToCameraSq) && this.shouldShowName(entity, state.distanceToCameraSq);
if (flag1) { if (shouldShowName) {
state.nameTag = this.getNameTag(entity); state.nameTag = this.getNameTag(entity);
state.nameTagAttachment = entity.getAttachments().getNullable(EntityAttachment.NAME_TAG, 0, entity.getYRot(partialTicks)); state.nameTagAttachment = entity.getAttachments().getNullable(EntityAttachment.NAME_TAG, 0, entity.getYRot(partialTicks));
@@ -2,17 +2,17 @@
+++ b/net/minecraft/client/renderer/entity/ItemFrameRenderer.java +++ b/net/minecraft/client/renderer/entity/ItemFrameRenderer.java
@@ -82,6 +_,7 @@ @@ -82,6 +_,7 @@
if (state.mapId != null) { if (state.mapId != null) {
int i = state.rotation % 4 * 2; int rotation = state.rotation % 4 * 2;
poseStack.mulPose(Axis.ZP.rotationDegrees(i * 360.0F / 8.0F)); poseStack.mulPose(Axis.ZP.rotationDegrees(rotation * 360.0F / 8.0F));
+ if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderItemInFrame(state, this, poseStack, submitNodeCollector, state.lightCoords)) { + if (!net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderItemInFrame(state, this, poseStack, submitNodeCollector, state.lightCoords)) {
poseStack.mulPose(Axis.ZP.rotationDegrees(180.0F)); poseStack.mulPose(Axis.ZP.rotationDegrees(180.0F));
float f2 = 0.0078125F; float s = 0.0078125F;
poseStack.scale(0.0078125F, 0.0078125F, 0.0078125F); poseStack.scale(0.0078125F, 0.0078125F, 0.0078125F);
@@ -89,6 +_,7 @@ @@ -89,6 +_,7 @@
poseStack.translate(0.0F, 0.0F, -1.0F); poseStack.translate(0.0F, 0.0F, -1.0F);
int j = this.getLightCoords(state.isGlowFrame, 15728850, state.lightCoords); int lightCoords = this.getLightCoords(state.isGlowFrame, 15728850, state.lightCoords);
this.mapRenderer.render(state.mapRenderState, poseStack, submitNodeCollector, true, j); this.mapRenderer.render(state.mapRenderState, poseStack, submitNodeCollector, true, lightCoords);
+ } + }
} else if (!state.item.isEmpty()) { } else if (!state.item.isEmpty()) {
poseStack.mulPose(Axis.ZP.rotationDegrees(state.rotation * 360.0F / 8.0F)); poseStack.mulPose(Axis.ZP.rotationDegrees(state.rotation * 360.0F / 8.0F));
int k = this.getLightCoords(state.isGlowFrame, 15728880, state.lightCoords); int lightVal = this.getLightCoords(state.isGlowFrame, 15728880, state.lightCoords);
@@ -7,8 +7,8 @@
+ if (net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPre(state, this, poseStack, submitNodeCollector, camera)) return; + if (net.minecraftforge.client.event.ForgeEventFactoryClient.onRenderLivingPre(state, this, poseStack, submitNodeCollector, camera)) return;
poseStack.pushPose(); poseStack.pushPose();
if (state.hasPose(Pose.SLEEPING)) { if (state.hasPose(Pose.SLEEPING)) {
Direction direction = state.bedOrientation; Direction bedOrientation = state.bedOrientation;
@@ -107,6 +_,7 @@ @@ -109,6 +_,7 @@
poseStack.popPose(); poseStack.popPose();
super.submit(state, poseStack, submitNodeCollector, camera); super.submit(state, poseStack, submitNodeCollector, camera);
@@ -16,7 +16,7 @@
} }
protected boolean shouldRenderLayers(final S state) { protected boolean shouldRenderLayers(final S state) {
@@ -283,7 +_,7 @@ @@ -285,7 +_,7 @@
state.isFullyFrozen = entity.isFullyFrozen(); state.isFullyFrozen = entity.isFullyFrozen();
state.isBaby = entity.isBaby(); state.isBaby = entity.isBaby();
@@ -1,23 +1,21 @@
--- a/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java --- a/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java
+++ b/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java +++ b/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java
@@ -66,6 +_,7 @@ @@ -66,12 +_,13 @@
Equippable equippable = itemStack.get(DataComponents.EQUIPPABLE); Equippable equippable = itemStack.get(DataComponents.EQUIPPABLE);
if (equippable != null && shouldRender(equippable, slot)) { if (equippable != null && shouldRender(equippable, slot)) {
A a = this.getArmorModel(state, slot); A model = this.getArmorModel(state, slot);
+ var model = this.getArmorModel(state, slot, itemStack, a); + var newModel = this.getArmorModel(state, slot, itemStack, model);
EquipmentClientInfo.LayerType equipmentclientinfo$layertype = state.isBaby && state.entityType != EntityType.ARMOR_STAND EquipmentClientInfo.LayerType layerType = state.isBaby && state.entityType != EntityType.ARMOR_STAND
? EquipmentClientInfo.LayerType.HUMANOID_BABY ? EquipmentClientInfo.LayerType.HUMANOID_BABY
: (this.usesInnerModel(slot) ? EquipmentClientInfo.LayerType.HUMANOID_LEGGINGS : EquipmentClientInfo.LayerType.HUMANOID); : (this.usesInnerModel(slot) ? EquipmentClientInfo.LayerType.HUMANOID_LEGGINGS : EquipmentClientInfo.LayerType.HUMANOID);
@@ -73,7 +_,7 @@ this.equipmentRenderer
.renderLayers( .renderLayers(
equipmentclientinfo$layertype, - layerType, equippable.assetId().orElseThrow(), model, state, itemStack, poseStack, submitNodeCollector, lightCoords, state.outlineColor
equippable.assetId().orElseThrow(), + layerType, equippable.assetId().orElseThrow(), newModel, state, itemStack, poseStack, submitNodeCollector, lightCoords, state.outlineColor
- a, );
+ model, }
state, }
itemStack, @@ -82,5 +_,12 @@
poseStack,
@@ -90,5 +_,12 @@
private boolean usesInnerModel(final EquipmentSlot slot) { private boolean usesInnerModel(final EquipmentSlot slot) {
return slot == EquipmentSlot.LEGS; return slot == EquipmentSlot.LEGS;
@@ -6,6 +6,6 @@
- protected static @Nullable Identifier getPlayerElytraTexture(final HumanoidRenderState state) { - protected static @Nullable Identifier getPlayerElytraTexture(final HumanoidRenderState state) {
+ protected @Nullable Identifier getPlayerElytraTexture(final HumanoidRenderState state) { + protected @Nullable Identifier getPlayerElytraTexture(final HumanoidRenderState state) {
if (state instanceof AvatarRenderState avatarrenderstate) { if (state instanceof AvatarRenderState playerState) {
PlayerSkin playerskin = avatarrenderstate.skin; PlayerSkin skin = playerState.skin;
if (playerskin.elytra() != null) { if (skin.elytra() != null) {
@@ -10,7 +10,7 @@
} else { } else {
if (avatar.getUsedItemHand() == hand && avatar.getUseItemRemainingTicks() > 0) { if (avatar.getUsedItemHand() == hand && avatar.getUseItemRemainingTicks() > 0) {
@@ -138,7 +_,9 @@ @@ -138,7 +_,9 @@
if (swinganimation != null && swinganimation.type() == SwingAnimationType.STAB && avatar.swinging) { if (attack != null && attack.type() == SwingAnimationType.STAB && avatar.swinging) {
return HumanoidModel.ArmPose.SPEAR; return HumanoidModel.ArmPose.SPEAR;
} else { } else {
- return itemInHand.is(ItemTags.SPEARS) ? HumanoidModel.ArmPose.SPEAR : HumanoidModel.ArmPose.ITEM; - return itemInHand.is(ItemTags.SPEARS) ? HumanoidModel.ArmPose.SPEAR : HumanoidModel.ArmPose.ITEM;
@@ -1,11 +1,11 @@
--- a/net/minecraft/client/renderer/feature/BlockFeatureRenderer.java --- a/net/minecraft/client/renderer/feature/BlockFeatureRenderer.java
+++ b/net/minecraft/client/renderer/feature/BlockFeatureRenderer.java +++ b/net/minecraft/client/renderer/feature/BlockFeatureRenderer.java
@@ -164,7 +_,7 @@ @@ -153,7 +_,7 @@
this.random.setSeed(submitnodestorage$breakingblockmodelsubmit.seed()); this.random.setSeed(submit.seed());
try { try {
- submitnodestorage$breakingblockmodelsubmit.model().collectParts(this.random, this.parts); - submit.model().collectParts(this.random, this.parts);
+ submitnodestorage$breakingblockmodelsubmit.model().collectParts(this.random, this.parts, submitnodestorage$breakingblockmodelsubmit.data()); + submit.model().collectParts(this.random, this.parts, submit.data());
for (BlockStateModelPart blockstatemodelpart : this.parts) { for (BlockStateModelPart part : this.parts) {
putPartQuads(blockstatemodelpart, submitnodestorage$breakingblockmodelsubmit.pose(), this.quadInstance, NO_TINT, vertexconsumer, null); putPartQuads(part, submit.pose(), this.quadInstance, NO_TINT, buffer, null);
@@ -1,23 +1,23 @@
--- a/net/minecraft/client/renderer/fog/FogRenderer.java --- a/net/minecraft/client/renderer/fog/FogRenderer.java
+++ b/net/minecraft/client/renderer/fog/FogRenderer.java +++ b/net/minecraft/client/renderer/fog/FogRenderer.java
@@ -153,6 +_,12 @@ @@ -153,6 +_,12 @@
f2 = Mth.lerp(f6, f2, f2 * f7); fogBlue = Mth.lerp(brightenFactor, fogBlue, fogBlue * targetScale);
} }
+ var fogColor = net.minecraftforge.client.ForgeHooksClient.getFogColor(camera, partialTicks, level, renderDistance, darkenWorldAmount, f5, f1, f2); + var fogColor = net.minecraftforge.client.ForgeHooksClient.getFogColor(camera, partialTicks, level, renderDistance, darkenWorldAmount, fogRed, fogGreen, fogBlue);
+ +
+ f5 = fogColor.x(); + fogRed = fogColor.x();
+ f1 = fogColor.y(); + fogGreen = fogColor.y();
+ f2 = fogColor.z(); + fogBlue = fogColor.z();
+ +
dest.set(f5, f1, f2, 1.0F); dest.set(fogRed, fogGreen, fogBlue, 1.0F);
} }
} }
@@ -181,6 +_,7 @@ @@ -181,6 +_,7 @@
float f2 = Mth.clamp(f1 / 10.0F, 4.0F, 64.0F); float renderDistanceFogSpan = Mth.clamp(renderDistanceInBlocks / 10.0F, 4.0F, 64.0F);
fogdata.renderDistanceStart = f1 - f2; fog.renderDistanceStart = renderDistanceInBlocks - renderDistanceFogSpan;
fogdata.renderDistanceEnd = f1; fog.renderDistanceEnd = renderDistanceInBlocks;
+ fogdata.color = net.minecraftforge.client.ForgeHooksClient.setupFog(fogtype, camera, deltaTracker, fogdata, fogdata.color); + fog.color = net.minecraftforge.client.ForgeHooksClient.setupFog(fogType, camera, deltaTracker, fog, fog.color);
return fogdata; return fog;
} }
@@ -30,9 +30,9 @@
); );
} }
+ map.putAll(this.texturesWithSamplers); + result.putAll(this.texturesWithSamplers);
+ +
return map; return result;
} }
} }
@@ -150,6 +_,7 @@ @@ -150,6 +_,7 @@
@@ -1,28 +1,28 @@
--- a/net/minecraft/client/renderer/texture/MipmapGenerator.java --- a/net/minecraft/client/renderer/texture/MipmapGenerator.java
+++ b/net/minecraft/client/renderer/texture/MipmapGenerator.java +++ b/net/minecraft/client/renderer/texture/MipmapGenerator.java
@@ -122,12 +_,16 @@ @@ -122,12 +_,16 @@
float f = mipmapStrategy == MipmapStrategy.STRICT_CUTOUT ? 0.3F : 0.5F; float cutoutRef = mipmapStrategy == MipmapStrategy.STRICT_CUTOUT ? 0.3F : 0.5F;
float f1 = flag ? alphaTestCoverage(currentMips[0], f, 1.0F) : 0.0F; float originalCoverage = isCutoutMip ? alphaTestCoverage(currentMips[0], cutoutRef, 1.0F) : 0.0F;
+ int maxMipmapLevel = net.minecraftforge.client.ForgeHooksClient.getMaxMipmapLevel(anativeimage[0].getWidth(), anativeimage[0].getHeight()); + int maxMipmapLevel = net.minecraftforge.client.ForgeHooksClient.getMaxMipmapLevel(result[0].getWidth(), result[0].getHeight());
for (int i = 1; i <= newMipLevel; i++) { for (int level = 1; level <= newMipLevel; level++) {
if (i < currentMips.length) { if (level < currentMips.length) {
anativeimage[i] = currentMips[i]; result[level] = currentMips[level];
} else { } else {
NativeImage nativeimage = anativeimage[i - 1]; NativeImage lastData = result[level - 1];
- NativeImage nativeimage1 = new NativeImage(nativeimage.getWidth() >> 1, nativeimage.getHeight() >> 1, false); - NativeImage data = new NativeImage(lastData.getWidth() >> 1, lastData.getHeight() >> 1, false);
+ // Forge: Guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes + // Forge: Guard against invalid texture size, because we allow generating mipmaps regardless of texture sizes
+ NativeImage nativeimage1 = new NativeImage(Math.max(1, nativeimage.getWidth() >> 1), Math.max(1, nativeimage.getHeight() >> 1), false); + NativeImage data = new NativeImage(Math.max(1, lastData.getWidth() >> 1), Math.max(1, lastData.getHeight() >> 1), false);
+ if (i <= maxMipmapLevel) { + if (level <= maxMipmapLevel) {
+ +
int j = nativeimage1.getWidth(); int width = data.getWidth();
int k = nativeimage1.getHeight(); int height = data.getHeight();
@@ -146,6 +_,7 @@ @@ -146,6 +_,7 @@
nativeimage1.setPixel(l, i1, j2); data.setPixel(x, y, color);
} }
+ } + }
} }
anativeimage[i] = nativeimage1; result[level] = data;
@@ -1,30 +1,30 @@
--- a/net/minecraft/client/renderer/texture/SpriteLoader.java --- a/net/minecraft/client/renderer/texture/SpriteLoader.java
+++ b/net/minecraft/client/renderer/texture/SpriteLoader.java +++ b/net/minecraft/client/renderer/texture/SpriteLoader.java
@@ -72,7 +_,7 @@ @@ -72,7 +_,7 @@
int j1 = Math.min(j, k); int minSize = Math.min(minTexelSize, lowestOneBit);
int k1 = Mth.log2(j1); int minPowerOfTwo = Mth.log2(minSize);
int l1; int mipLevel;
- if (k1 < maxMipmapLevels) { - if (minPowerOfTwo < maxMipmapLevels) {
+ if (k1 < maxMipmapLevels && net.minecraftforge.common.ForgeConfig.CLIENT.allowMipmapLowering()) { // Forge: Do not lower the mipmap level + if (minPowerOfTwo < maxMipmapLevels && net.minecraftforge.common.ForgeConfig.CLIENT.allowMipmapLowering()) { // Forge: Do not lower the mipmap level
LOGGER.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.location, maxMipmapLevels, k1, j1); LOGGER.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.location, maxMipmapLevels, minPowerOfTwo, minSize);
l1 = k1; mipLevel = minPowerOfTwo;
} else { } else {
@@ -130,7 +_,8 @@ @@ -132,7 +_,8 @@
final Executor taskExecutor, final Executor taskExecutor,
final Set<MetadataSectionType<?>> additionalMetadata final Set<MetadataSectionType<?>> additionalMetadata
) { ) {
- SpriteResourceLoader spriteresourceloader = SpriteResourceLoader.create(additionalMetadata); - SpriteResourceLoader spriteResourceLoader = SpriteResourceLoader.create(additionalMetadata);
+ var sections = net.minecraftforge.client.ForgeHooksClient.getAtlastMetadataSections(atlasInfoLocation, additionalMetadata); + var sections = net.minecraftforge.client.ForgeHooksClient.getAtlastMetadataSections(atlasInfoLocation, additionalMetadata);
+ SpriteResourceLoader spriteresourceloader = SpriteResourceLoader.create(sections); + SpriteResourceLoader spriteResourceLoader = SpriteResourceLoader.create(sections);
return CompletableFuture.<List<SpriteSource.Loader>>supplyAsync(() -> SpriteSourceList.load(manager, atlasInfoLocation).list(manager), taskExecutor) return CompletableFuture.<List<SpriteSource.Loader>>supplyAsync(() -> SpriteSourceList.load(manager, atlasInfoLocation).list(manager), taskExecutor)
.thenCompose(sprites -> runSpriteSuppliers(spriteresourceloader, (List<SpriteSource.Loader>)sprites, taskExecutor)) .thenCompose(sprites -> runSpriteSuppliers(spriteResourceLoader, (List<SpriteSource.Loader>)sprites, taskExecutor))
.thenApply(resources -> this.stitch((List<SpriteContents>)resources, maxMipmapLevels, taskExecutor)); .thenApply(resources -> this.stitch((List<SpriteContents>)resources, maxMipmapLevels, taskExecutor));
@@ -139,7 +_,7 @@ @@ -141,7 +_,7 @@
private Map<Identifier, TextureAtlasSprite> getStitchedSprites(final Stitcher<SpriteContents> stitcher, final int atlasWidth, final int atlasHeight) { private Map<Identifier, TextureAtlasSprite> getStitchedSprites(final Stitcher<SpriteContents> stitcher, final int atlasWidth, final int atlasHeight) {
Map<Identifier, TextureAtlasSprite> map = new HashMap<>(); Map<Identifier, TextureAtlasSprite> result = new HashMap<>();
stitcher.gatherSprites( stitcher.gatherSprites(
- (contents, x, y, padding) -> map.put(contents.name(), new TextureAtlasSprite(this.location, contents, atlasWidth, atlasHeight, x, y, padding)) - (contents, x, y, padding) -> result.put(contents.name(), new TextureAtlasSprite(this.location, contents, atlasWidth, atlasHeight, x, y, padding))
+ (contents, x, y, padding) -> map.put(contents.name(), net.minecraftforge.client.ForgeHooksClient.loadTextureAtlasSprite(this.location, contents, atlasWidth, atlasHeight, x, y, padding)) + (contents, x, y, padding) -> result.put(contents.name(), net.minecraftforge.client.ForgeHooksClient.loadTextureAtlasSprite(this.location, contents, atlasWidth, atlasHeight, x, y, padding))
); );
return map; return result;
} }
Loaded 100 of 431 files, more files were not shown because too many files have changed in this diff. Show more