Skip to content

Commit

Permalink
Fixed compatibility with NeoForge 21.3.23+
Browse files Browse the repository at this point in the history
Fixes #290
  • Loading branch information
RaphiMC committed Nov 10, 2024
1 parent 5ce6eaf commit eb2454d
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected int getLayerOrder(final RenderLayer layer) {
}
} else if (textureId.equals(TexturedRenderLayers.ARMOR_TRIMS_ATLAS_TEXTURE)) {
return 1;
} else if (layer.name.startsWith("text")) {
} else if (layer.name.startsWith("text") || layer.name.startsWith("neoforge_text") || layer.name.startsWith("forge_text")) {
// Draws vanilla text over custom font layers
// Fixes https://github.com/RaphiMC/ImmediatelyFast/issues/81, https://github.com/RaphiMC/ImmediatelyFast/issues/287, https://github.com/RaphiMC/ImmediatelyFast/issues/288
if (textureId.getNamespace().equals("minecraft")) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ supported_minecraft_versions=1.21.2,1.21.3
yarn_mappings=1.21.3+build.2
fabric_loader_version=0.16.5
forge_version=1.21.3-53.0.11
neoforge_version=21.3.16-beta
neoforge_version=21.3.26-beta
mixin_extras_version=0.4.1
reflect_version=1.3.4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,29 @@
@Mixin(targets = "net.neoforged.neoforge.client.NeoForgeRenderTypes$Internal", priority = 500)
public abstract class MixinNeoForgeRenderTypes {

// Pre NeoForge 21.3.23-beta
@Inject(method = {
"getText",
"getTextIntensity",
"getTextPolygonOffset",
"getTextIntensityPolygonOffset",
"getTextSeeThrough",
"getTextIntensitySeeThrough"
}, at = @At(value = "RETURN"), remap = false) // Forge doesn't allow me to target the of() call for some reason
private static void changeTranslucency(CallbackInfoReturnable<RenderLayer> cir) {
}, at = @At(value = "RETURN"), remap = false, require = 0) // Forge doesn't allow me to target the of() call for some reason
private static void changeTranslucencyOld(CallbackInfoReturnable<RenderLayer> cir) {
cir.getReturnValue().translucent = false;
}

// Post NeoForge 21.3.23-beta
@Inject(method = {
"getTextFiltered",
"getTextIntensityFiltered",
"getTextPolygonOffsetFiltered",
"getTextIntensityPolygonOffsetFiltered",
"getTextSeeThroughFiltered",
"getTextIntensitySeeThroughFiltered"
}, at = @At(value = "RETURN"), remap = false, require = 0) // Forge doesn't allow me to target the of() call for some reason
private static void changeTranslucencyNew(CallbackInfoReturnable<RenderLayer> cir) {
cir.getReturnValue().translucent = false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This file is part of ImmediatelyFast - https://github.com/RaphiMC/ImmediatelyFast
* Copyright (C) 2023-2024 RK_01/RaphiMC and contributors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.immediatelyfast.neoforge.injection.mixins.core;

import net.minecraft.client.render.RenderLayer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

@Mixin(value = RenderLayer.class, priority = 500)
public abstract class MixinRenderLayer {

@ModifyArg(method = {
"method_34834" /*TEXT*/,
"method_34833" /*TEXT_INTENSITY*/,
"method_36437" /*TEXT_POLYGON_OFFSET*/,
"method_36436" /*TEXT_INTENSITY_POLYGON_OFFSET*/,
"method_37348" /*TEXT_SEE_THROUGH*/,
"method_37347" /*TEXT_INTENSITY_SEE_THROUGH*/
}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayer;of(Ljava/lang/String;Lnet/minecraft/client/render/VertexFormat;Lnet/minecraft/client/render/VertexFormat$DrawMode;IZZLnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;)Lnet/minecraft/client/render/RenderLayer$MultiPhase;"), index = 5)
private static boolean changeTranslucency(boolean value) {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"plugin": "net.raphimc.immediatelyfast.injection.ImmediatelyFastMixinPlugin",
"client": [
"core.MixinNeoForgeRenderTypes",
"core.MixinRenderLayer",
"hud_batching.MixinItemRenderer"
],
"injectors": {
Expand Down

0 comments on commit eb2454d

Please sign in to comment.