Skip to content

Commit 8bc8bb6

Browse files
authored
Port/1.21 (#92)
Port/1.21
1 parent 6d91a53 commit 8bc8bb6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1262
-1166
lines changed

gradle.properties

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ modGroup=com.ldtteam
66
modVersion=0.0.1-LOCAL
77
modBaseName=blockui
88

9-
javaVersion=17
9+
javaVersion=21
1010
useJavaToolChains=true
1111
#The currently running forge.
12-
forgeVersion=20.4.223
12+
forgeVersion=21.0.75-beta
1313
#The minimal needed forge, as marked in metadata and curseforge.
14-
forgeMinVersion=20.4.127-beta
14+
forgeMinVersion=21.0.75-beta
1515

16-
fml_range=[1,)
17-
forge_range=[20.4.127-beta,)
18-
minecraft_range=[1.20.4, 1.21)
16+
fml_range=[4,)
17+
forge_range=[21.0.75-beta,)
18+
minecraft_range=[1.21, 1.22)
1919

2020
#The version for forge (dependency)
21-
exactMinecraftVersion=1.20.4
21+
exactMinecraftVersion=1.21
2222
#The main version on curseforge
23-
minecraftVersion=1.20.4
23+
minecraftVersion=1.21
2424
#Semicolon seperated list of mc versions, which are marked as compatible on curseforge
2525
additionalMinecraftVersions=
2626

gradle/wrapper/gradle-wrapper.jar

-19.8 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew.bat

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
4343
%JAVA_EXE% -version >NUL 2>&1
4444
if %ERRORLEVEL% equ 0 goto execute
4545

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
46+
echo. 1>&2
47+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48+
echo. 1>&2
49+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50+
echo location of your Java installation. 1>&2
5151

5252
goto fail
5353

@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5757

5858
if exist "%JAVA_EXE%" goto execute
5959

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
60+
echo. 1>&2
61+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62+
echo. 1>&2
63+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64+
echo location of your Java installation. 1>&2
6565

6666
goto fail
6767

src/main/java/com/ldtteam/blockui/AtlasManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ private class CustomGuiSpriteManager extends TextureAtlasHolder
107107
private CustomGuiSpriteManager(final TextureManager textureManager, final String modId)
108108
{
109109
super(textureManager,
110-
new ResourceLocation(modId, "textures/atlas/" + modId + "_gui.png"),
111-
new ResourceLocation(modId, modId + "_gui"),
110+
ResourceLocation.fromNamespaceAndPath(modId, "textures/atlas/" + modId + "_gui.png"),
111+
ResourceLocation.fromNamespaceAndPath(modId, modId + "_gui"),
112112
GuiSpriteManager.METADATA_SECTIONS);
113113
}
114114

src/main/java/com/ldtteam/blockui/BOGuiGraphics.java

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.ldtteam.blockui.mod.item.BlockStateRenderingData;
44
import com.ldtteam.blockui.util.SingleBlockGetter.SingleBlockNeighborhood;
55
import com.ldtteam.blockui.util.cursor.Cursor;
6-
import com.mojang.blaze3d.platform.Lighting;
76
import com.mojang.blaze3d.systems.RenderSystem;
87
import com.mojang.blaze3d.vertex.PoseStack;
98
import com.mojang.math.Axis;
@@ -25,7 +24,7 @@
2524
import net.neoforged.neoforge.client.ClientHooks;
2625
import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions;
2726
import org.jetbrains.annotations.Nullable;
28-
import org.joml.Matrix4f;
27+
import org.joml.Matrix3f;
2928

3029
public class BOGuiGraphics extends GuiGraphics
3130
{
@@ -113,43 +112,33 @@ public void renderBlockStateAsItem(final BlockStateRenderingData data, final Ite
113112
// prepare pose just like itemStack rendering would do
114113

115114
pose().pushPose();
115+
pose().last().normal().identity(); // reset normals cuz lighting
116116
pose().translate(8, 8, 150);
117-
pose().mulPoseMatrix(new Matrix4f().scaling(1.0F, -1.0F, 1.0F));
118-
pose().scale(16.0F, 16.0F, 16.0F);
117+
pose().scale(16.0F, -16.0F, 16.0F);
119118
ClientHooks.handleCameraTransforms(pose(), itemModel, ItemDisplayContext.GUI, false);
120119

121120
if (data.modelNeedsRotationFix())
122121
{
122+
final Matrix3f oldNormal = pose().last().normal();
123123
pose().pushPose();
124124
pose().rotateAround(Axis.YP.rotationDegrees(45), 0.0f, 0.5f, 0.0f);
125+
pose().last().normal().set(oldNormal.rotate(Axis.YP.rotationDegrees(-45)));
125126
}
126127

127128
pose().translate(-0.5F, -0.5F, -0.5F);
128129

129-
pushMvApplyPose();
130-
131-
if (data.modelNeedsRotationFix())
132-
{
133-
Lighting.setupLevel(new Matrix4f().rotationAround(Axis.ZP.rotationDegrees(-180), 0.5f, 0.0f, 0.5f));
134-
}
135-
else
136-
{
137-
Lighting.setupLevel(new Matrix4f().rotationAround(Axis.YP.rotationDegrees(-45), 0.0f, 0.5f, 0.0f));
138-
}
139-
140130
// render block and BE
141131

142-
final PoseStack poseStack = new PoseStack();
143-
final int light = LightTexture.pack(10, 10);
132+
final int light = LightTexture.pack(15, 15);
144133
minecraft.getBlockRenderer()
145-
.renderSingleBlock(data.blockState(), poseStack, bufferSource(), light, OverlayTexture.NO_OVERLAY, data.modelData(), null);
134+
.renderSingleBlock(data.blockState(), pose(), bufferSource(), light, OverlayTexture.NO_OVERLAY, data.modelData(), null);
146135
if (data.blockEntity() != null)
147136
{
148137
try
149138
{
150139
minecraft.getBlockEntityRenderDispatcher()
151140
.getRenderer(data.blockEntity())
152-
.render(data.blockEntity(), 0, poseStack, bufferSource(), light, OverlayTexture.NO_OVERLAY);
141+
.render(data.blockEntity(), 0, pose(), bufferSource(), light, OverlayTexture.NO_OVERLAY);
153142
}
154143
catch (final Exception e)
155144
{
@@ -162,9 +151,6 @@ public void renderBlockStateAsItem(final BlockStateRenderingData data, final Ite
162151
{
163152
pose().popPose();
164153
pose().translate(-0.5F, -0.5F, -0.5F);
165-
166-
RenderSystem.getModelViewStack().popPose();
167-
pushMvApplyPose();
168154
}
169155

170156
// render fluid
@@ -173,26 +159,29 @@ public void renderBlockStateAsItem(final BlockStateRenderingData data, final Ite
173159
if (!fluidState.isEmpty())
174160
{
175161
final RenderType renderType = ItemBlockRenderTypes.getRenderLayer(fluidState);
162+
pushMvApplyPose();
176163

177164
NEIGHBORHOOD.blockState = data.blockState();
178165
minecraft.getBlockRenderer()
179166
.renderLiquid(BlockPos.ZERO, NEIGHBORHOOD, bufferSource().getBuffer(renderType), data.blockState(), fluidState);
180167

181168
bufferSource().endBatch(renderType);
169+
popMvPose();
182170
}
183171

184-
Lighting.setupFor3DItems();
185-
186-
RenderSystem.getModelViewStack().popPose();
187-
RenderSystem.applyModelViewMatrix();
188-
189172
pose().popPose();
190173
}
191174

192175
public void pushMvApplyPose()
193176
{
194-
RenderSystem.getModelViewStack().pushPose();
195-
RenderSystem.getModelViewStack().mulPoseMatrix(pose().last().pose());
177+
RenderSystem.getModelViewStack().pushMatrix();
178+
RenderSystem.getModelViewStack().mul(pose().last().pose());
179+
RenderSystem.applyModelViewMatrix();
180+
}
181+
182+
public void popMvPose()
183+
{
184+
RenderSystem.getModelViewStack().popMatrix();
196185
RenderSystem.applyModelViewMatrix();
197186
}
198187
}

src/main/java/com/ldtteam/blockui/BOScreen.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.mojang.blaze3d.vertex.PoseStack;
77
import com.mojang.blaze3d.vertex.VertexSorting;
88
import org.joml.Matrix4f;
9+
import org.joml.Matrix4fStack;
910
import net.minecraft.CrashReport;
1011
import net.minecraft.CrashReportCategory;
1112
import net.minecraft.ReportedException;
@@ -80,14 +81,14 @@ public void render(final GuiGraphics ms, final int mx, final int my, final float
8081
y = Math.floor((guiHeight - height * renderScale) / 2.0d);
8182

8283
// replace vanilla projection
83-
final PoseStack shaderPs = RenderSystem.getModelViewStack();
84+
final Matrix4fStack shaderPs = RenderSystem.getModelViewStack();
8485
final Matrix4f oldProjection = RenderSystem.getProjectionMatrix();
8586
RenderSystem.setProjectionMatrix(
8687
new Matrix4f().setOrtho(0.0F, framebufferWidth, framebufferHeight, 0.0F, 1000.0F, ClientHooks.getGuiFarPlane()),
8788
VertexSorting.ORTHOGRAPHIC_Z);
88-
shaderPs.pushPose();
89-
shaderPs.setIdentity();
90-
shaderPs.translate(0.0D, 0.0D, 10000F - net.neoforged.neoforge.client.ClientHooks.getGuiFarPlane());
89+
shaderPs.pushMatrix();
90+
shaderPs.identity();
91+
shaderPs.translate(0.0f, 0.0f, 10000f - net.neoforged.neoforge.client.ClientHooks.getGuiFarPlane());
9192
RenderSystem.applyModelViewMatrix();
9293

9394
final PoseStack newMs = new PoseStack();
@@ -134,7 +135,7 @@ public void render(final GuiGraphics ms, final int mx, final int my, final float
134135
finally
135136
{
136137
// restore vanilla state
137-
shaderPs.popPose();
138+
shaderPs.popMatrix();
138139
RenderSystem.setProjectionMatrix(oldProjection, VertexSorting.ORTHOGRAPHIC_Z);
139140
RenderSystem.applyModelViewMatrix();
140141

src/main/java/com/ldtteam/blockui/Loader.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public final class Loader extends SimplePreparableReloadListener<Map<ResourceLoc
2727
{
2828
public static final Loader INSTANCE = new Loader();
2929

30-
private final Map<ResourceLocation, Function<PaneParams, ? extends Pane>> paneFactories = new HashMap<>();
30+
private final Map<String, Function<PaneParams, ? extends Pane>> paneFactories = new HashMap<>();
3131

3232
private Map<ResourceLocation, PaneParams> xmlCache = new HashMap<>();
3333

@@ -42,7 +42,6 @@ private Loader()
4242
register("toggle", ToggleButton::new);
4343
register("input", TextFieldVanilla::new);
4444
register("image", Image::new);
45-
register("imagerepeat", ImageRepeatable::new);
4645
register("box", Box::new);
4746
register("itemicon", Loader::itemIcon);
4847
register("entityicon", EntityIcon::new);
@@ -80,14 +79,12 @@ private static ItemIcon itemIcon(final PaneParams paneParams)
8079
*/
8180
public void register(final String name, final Function<PaneParams, ? extends Pane> factoryMethod)
8281
{
83-
final ResourceLocation key = new ResourceLocation(name);
84-
85-
if (paneFactories.containsKey(key))
82+
if (paneFactories.containsKey(name))
8683
{
8784
throw new IllegalArgumentException("Duplicate pane type '" + name + "' when registering Pane class method.");
8885
}
8986

90-
paneFactories.put(key, factoryMethod);
87+
paneFactories.put(name, factoryMethod);
9188
}
9289

9390
/**
@@ -98,20 +95,13 @@ public void register(final String name, final Function<PaneParams, ? extends Pan
9895
*/
9996
private Pane createFromPaneParams(final PaneParams params)
10097
{
101-
final ResourceLocation paneType = new ResourceLocation(params.getType());
102-
103-
if (paneFactories.containsKey(paneType))
104-
{
105-
return paneFactories.get(paneType).apply(params);
106-
}
107-
108-
if (paneFactories.containsKey(new ResourceLocation(paneType.getPath())))
98+
final String name = params.getType();
99+
if (paneFactories.containsKey(name))
109100
{
110-
Log.getLogger().warn("Namespace override for " + paneType.getPath() + " not found. Using default.");
111-
return paneFactories.get(new ResourceLocation(paneType.getPath())).apply(params);
101+
return paneFactories.get(name).apply(params);
112102
}
113103

114-
Log.getLogger().error("There is no factory method for " + paneType.getPath());
104+
Log.getLogger().error("There is no factory method for " + name);
115105
return null;
116106
}
117107

src/main/java/com/ldtteam/blockui/PaneParams.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,6 @@ public ResourceLocation getResource(final String name)
204204
return getResource(name, (ResourceLocation) null);
205205
}
206206

207-
/**
208-
* Get the resource location from the name
209-
* @param name the attribute name
210-
* @param def the default value to fallback to
211-
* @return the parsed resource location
212-
* @deprecated use {@link PaneParams#getResource(String, ResourceLocation)} instead.
213-
*/
214-
@Deprecated(forRemoval = true, since = "1.20.1")
215-
public ResourceLocation getResource(final String name, final String def)
216-
{
217-
return getResource(name, new ResourceLocation(def));
218-
}
219-
220207
/**
221208
* Get the resource location from the name
222209
* @param name the attribute name

src/main/java/com/ldtteam/blockui/Parsers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private Parsers()
3232
public static Function<String, Double> DOUBLE = Double::parseDouble;
3333

3434
/** Parses a resource location, include shorthand tricks */
35-
public static Function<String, ResourceLocation> RESOURCE = ResourceLocation::new;
35+
public static Function<String, ResourceLocation> RESOURCE = ResourceLocation::tryParse;
3636

3737
/** Parses a potentially translatable portion of text as a component */
3838
private static Function<String, String> RAW_TEXT = v -> {

0 commit comments

Comments
 (0)