Skip to content

Commit

Permalink
feat(1.21.2): Update to Minecraft 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Oct 22, 2024
1 parent cde594f commit da7a04b
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.blay09.mods.balm.common.client;

import com.mojang.blaze3d.ProjectionType;
import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.pipeline.TextureTarget;
import com.mojang.blaze3d.platform.Lighting;
Expand All @@ -11,10 +12,14 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.CreativeModeTabs;
import org.joml.Matrix4f;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

public class IconExport {
private static final Logger logger = LoggerFactory.getLogger(IconExport.class);

public static void export(String filter) {
final var minecraft = Minecraft.getInstance();
minecraft.execute(() -> {
Expand Down Expand Up @@ -48,7 +53,7 @@ public static void export(String filter) {
renderTarget.bindWrite(false);

final var matrix = new Matrix4f().setOrtho(0f, 16, 16, 0f, 1000f, 21000f);
RenderSystem.setProjectionMatrix(matrix, VertexSorting.ORTHOGRAPHIC_Z);
RenderSystem.setProjectionMatrix(matrix, ProjectionType.ORTHOGRAPHIC);
final var modelViewStack = RenderSystem.getModelViewStack();
modelViewStack.pushMatrix();
modelViewStack.translation(0f, 0f, -11000f);
Expand All @@ -61,7 +66,7 @@ public static void export(String filter) {
renderTarget.unbindWrite();
RenderSystem.disableDepthTest();

try(final var nativeImage = new NativeImage(renderTarget.width, renderTarget.height, false)) {
try (final var nativeImage = new NativeImage(renderTarget.width, renderTarget.height, false)) {
RenderSystem.bindTexture(renderTarget.getColorTextureId());
nativeImage.downloadTexture(0, false);
nativeImage.flipY();
Expand All @@ -70,7 +75,7 @@ public static void export(String filter) {
}
}
} catch (Exception e) {
e.printStackTrace();
logger.error("Failed to export icons", e);
} finally {
if (renderTarget != null) {
renderTarget.destroyBuffers();
Expand Down

0 comments on commit da7a04b

Please sign in to comment.