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