Skip to content

Commit

Permalink
apply 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
umjammer committed Jun 14, 2024
1 parent cc02c83 commit 9b79306
Show file tree
Hide file tree
Showing 26 changed files with 186 additions and 181 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Fabric](https://img.shields.io/badge/Mod_Loader-Fabric-blue)](https://fabricmc.net/)
[![Minecraft](https://img.shields.io/badge/Minecraft-1.20.5-green)](https://www.minecraft.net/)
[![Minecraft](https://img.shields.io/badge/Minecraft-1.20.6-green)](https://www.minecraft.net/)
[![Java CI](https://github.com/umjammer/JustMap/actions/workflows/build.yml/badge.svg)](https://github.com/umjammer/JustMap/actions/workflows/build.yml)
[![GitHub Release Assets](https://github.com/umjammer/JustMap/actions/workflows/publish.yml/badge.svg)](https://github.com/umjammer/JustMap/actions/workflows/publish.yml)
![Java](https://img.shields.io/badge/Java-21-b07219)
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version = 1.20.6
yarn_mappings = 1.20.6+build.1
loader_version = 0.15.10
minecraft_version = 1.21
yarn_mappings = 1.21+build.1
loader_version = 0.15.11

mod_version = 1.0.0
maven_group = ru.bulldog
archives_base_name = justmap

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric
fabric_version = 0.97.8+1.20.6
cloth_version = 14.0.126
modmenu_version = 10.0.0-beta.1
fabric_version = 0.100.1+1.21
cloth_version = 15.0.127
modmenu_version = 11.0.0-beta.1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@Environment(EnvType.CLIENT)
public abstract class AbstractMiniMapRenderer {

protected static final Identifier roundMask = new Identifier(JustMap.MODID, "textures/round_mask.png");
protected static final Identifier roundMask = Identifier.of(JustMap.MODID, "textures/round_mask.png");
protected static final MinecraftClient minecraft = MinecraftClient.getInstance();
protected static TextManager textManager;
protected static final InfoText dirN = new MapText(TextAlignment.CENTER, "N");
Expand Down Expand Up @@ -89,7 +89,7 @@ public void updateParamsOnRender() {
this.winHeight = winH;
}

this.delta = minecraft.getTickDelta();
this.delta = minecraft.getRenderTickCounter().getTickDelta(false); // TODO 1.21
this.currX = CurrentWorldPos.doubleX(delta);
this.currZ = CurrentWorldPos.doubleZ(delta);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ protected void render(DrawContext context, double scale) {
this.primaryFramebuffer.beginRead();
RenderUtil.startDraw();
BufferBuilder buffer = RenderUtil.getBuffer();
buffer.vertex(0.0, scaledH, 0.0).texture(0.0F, 0.0F).next();
buffer.vertex(scaledW, scaledH, 0.0).texture(1.0F, 0.0F).next();
buffer.vertex(scaledW, 0.0, 0.0).texture(1.0F, 1.0F).next();
buffer.vertex(0.0, 0.0, 0.0).texture(0.0F, 1.0F).next();
buffer.vertex(0.0f, scaledH, 0.0f).texture(0.0F, 0.0F);
buffer.vertex(scaledW, scaledH, 0.0f).texture(1.0F, 0.0F);
buffer.vertex(scaledW, 0.0f, 0.0f).texture(1.0F, 1.0F);
buffer.vertex(0.0f, 0.0f, 0.0f).texture(0.0F, 1.0F);
RenderUtil.endDraw();
if (mapRotation) {
matrices.push();
Expand Down Expand Up @@ -155,10 +155,10 @@ protected void render(DrawContext context, double scale) {
this.secondaryFramebuffer.beginRead();
RenderUtil.startDraw();
buffer = RenderUtil.getBuffer();
buffer.vertex(imgX, imgY + imgH, 0.0).texture(0.0F, 0.0F).next();
buffer.vertex(imgX + imgW, imgY + imgH, 0.0).texture(1.0F, 0.0F).next();
buffer.vertex(imgX + imgW, imgY, 0.0).texture(1.0F, 1.0F).next();
buffer.vertex(imgX, imgY, 0.0).texture(0.0F, 1.0F).next();
buffer.vertex(imgX, imgY + imgH, 0.0f).texture(0.0F, 0.0F);
buffer.vertex(imgX + imgW, imgY + imgH, 0.0f).texture(1.0F, 0.0F);
buffer.vertex(imgX + imgW, imgY, 0.0f).texture(1.0F, 1.0F);
buffer.vertex(imgX, imgY, 0.0f).texture(0.0F, 1.0F);
RenderUtil.endDraw();
matrices.pop();
List<WaypointIcon> drawableWaypoints = minimap.getWaypoints(playerPos, centerX, centerY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@Environment(EnvType.CLIENT)
public class WaypointRenderer {
private static final WaypointRenderer renderer = new WaypointRenderer();
private final static Identifier BEAM_TEX = new Identifier("textures/entity/beacon_beam.png");
private final static Identifier BEAM_TEX = Identifier.of("textures/entity/beacon_beam.png");
private final static MinecraftClient minecraft = MinecraftClient.getInstance();

public static void renderHUD(DrawContext context, float delta, float fov) {
Expand Down Expand Up @@ -64,16 +64,15 @@ public static void startWaypointRender() {

matrixStack.push();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
RenderSystem.applyModelViewMatrix();

Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera();
float tickDelta = MinecraftClient.getInstance().getTickDelta();
float tickDelta = MinecraftClient.getInstance().getRenderTickCounter().getTickDelta(false); // TODO 1.21

renderWaypoints(matrixStack, camera, tickDelta);

tessellator.draw();
buffer.endNullable();
matrixStack.pop();
RenderSystem.applyModelViewMatrix();
RenderSystem.disableBlend();
Expand Down Expand Up @@ -236,7 +235,7 @@ private void renderBeam(Matrix4f matrix4f, MatrixStack.Entry matrixSE, VertexCon
}

private void addVertex(Matrix4f matrix4f, MatrixStack.Entry matrixSE, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, float y, float x, float l, float m, float n) {
vertexConsumer.vertex(matrix4f, x, y, l).color(red, green, blue, alpha).texture(m, n).overlay(OverlayTexture.DEFAULT_UV).light(Colors.LIGHT).normal(matrixSE, 0.0F, 1.0F, 0.0F).next();
vertexConsumer.vertex(matrix4f, x, y, l).color(red, green, blue, alpha).texture(m, n).overlay(OverlayTexture.DEFAULT_UV).light(Colors.LIGHT).normal(matrixSE, 0.0F, 1.0F, 0.0F);
}

private double correctAngle(float angle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
import ru.bulldog.justmap.util.render.RenderUtil;

public abstract class AbstractJustMapScreen extends Screen {
public static final Identifier DEFAULT_TEXTURE = new Identifier("textures/block/dirt.png");
public static final Identifier DEFAULT_TEXTURE = Identifier.of("textures/block/dirt.png");
public static final HashMap<String, Pair<String, Identifier>> DIMENSION_INFO = new HashMap<>() {
private static final long serialVersionUID = 1L;
{
put("minecraft:overworld", new Pair<>(JustMap.MODID + ".dim.overworld", new Identifier("textures/block/stone.png")));
put("minecraft:the_nether", new Pair<>(JustMap.MODID + ".dim.nether", new Identifier("textures/block/netherrack.png")));
put("minecraft:the_end", new Pair<>(JustMap.MODID + ".dim.the_end", new Identifier("textures/block/end_stone.png")));
put("minecraft:overworld", new Pair<>(JustMap.MODID + ".dim.overworld", Identifier.of("textures/block/stone.png")));
put("minecraft:the_nether", new Pair<>(JustMap.MODID + ".dim.nether", Identifier.of("textures/block/netherrack.png")));
put("minecraft:the_end", new Pair<>(JustMap.MODID + ".dim.the_end", Identifier.of("textures/block/end_stone.png")));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class WorldnameScreen extends Screen {

private final static Text TITLE = MutableText.of(LangUtil.getText("gui", "screen.worldname"));
private final static Identifier FRAME_TEXTURE = new Identifier(JustMap.MODID, "textures/screen_background.png");
private final static Identifier FRAME_TEXTURE = Identifier.of(JustMap.MODID, "textures/screen_background.png");

private final Screen parent;
private TextFieldWidget nameField;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ru/bulldog/justmap/map/ChunkGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ private GridLine(double sx, double sy, double ex, double ey) {
}

private void draw(VertexConsumer builder) {
builder.vertex(first.x, first.y, 0).next();
builder.vertex(second.x, second.y, 0).next();
builder.vertex((float) first.x, (float) first.y, 0);
builder.vertex((float) second.x, (float) second.y, 0);
}
}

Expand Down
27 changes: 13 additions & 14 deletions src/main/java/ru/bulldog/justmap/map/DirectionArrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import com.google.common.collect.ImmutableMap;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormatElement;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.resource.metadata.AnimationResourceMetadata;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteContents;
import net.minecraft.client.texture.SpriteDimensions;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.resource.metadata.ResourceMetadata;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.RotationAxis;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import ru.bulldog.justmap.JustMap;
import ru.bulldog.justmap.client.config.ClientSettings;
Expand All @@ -26,7 +26,7 @@
import ru.bulldog.justmap.util.render.RenderUtil;

public class DirectionArrow extends Sprite {
private final static VertexFormat vertexFormat = new VertexFormat(ImmutableMap.of("position", VertexFormats.POSITION_ELEMENT, "texture", VertexFormats.TEXTURE_ELEMENT, "normal", VertexFormats.NORMAL_ELEMENT, "padding", VertexFormats.PADDING_ELEMENT));
private final static VertexFormat vertexFormat = VertexFormat.builder().add("Position", VertexFormatElement.POSITION).add("UV0", VertexFormatElement.UV_0).add("Normal", VertexFormatElement.NORMAL).build();
private static DirectionArrow ARROW;

private DirectionArrow(Identifier texture, int w, int h) {
Expand All @@ -36,15 +36,12 @@ private DirectionArrow(Identifier texture, int w, int h) {
public static void draw(double x, double y, int size, float rotation) {
if (!ClientSettings.simpleArrow) {
if (ARROW == null) {
ARROW = new DirectionArrow(new Identifier(JustMap.MODID, "textures/icon/player_arrow.png"), 20, 20);
ARROW = new DirectionArrow(Identifier.of(JustMap.MODID, "textures/icon/player_arrow.png"), 20, 20);
}

MatrixStack matrix = new MatrixStack();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder builder = tessellator.getBuffer();

// FIXME: is mode 7 really quads?
builder.begin(VertexFormat.DrawMode.QUADS, vertexFormat);
BufferBuilder builder = tessellator.begin(VertexFormat.DrawMode.QUADS, vertexFormat);

VertexConsumer vertexConsumer = ARROW.getTextureSpecificVertexConsumer(builder);

Expand All @@ -61,7 +58,10 @@ public static void draw(double x, double y, int size, float rotation) {
MatrixStack.Entry mse = matrix.peek();

addVertices(m4f, mse, vertexConsumer, size);
tessellator.draw();
var builtBuffer = builder.endNullable();
if (builtBuffer != null) {
BufferRenderer.drawWithGlobalProgram(builtBuffer);
}

matrix.pop();
} else {
Expand All @@ -85,10 +85,9 @@ public static void draw(double x, double y, int size, float rotation) {
private static void addVertices(Matrix4f m4f, MatrixStack.Entry mse, VertexConsumer vertexConsumer, int size) {
float half = size / 2f;

vertexConsumer.vertex(m4f, -half, -half, 0.0F).texture(0.0F, 0.0F).normal(mse, 0.0F, 1.0F, 0.0F).next();
vertexConsumer.vertex(m4f, -half, half, 0.0F).texture(0.0F, 1.0F).normal(mse, 0.0F, 1.0F, 0.0F).next();
vertexConsumer.vertex(m4f, half, half, 0.0F).texture(1.0F, 1.0F).normal(mse, 0.0F, 1.0F, 0.0F).next();
vertexConsumer.vertex(m4f, half, -half, 0.0F).texture(1.0F, 0.0F).normal(mse, 0.0F, 1.0F, 0.0F).next();
vertexConsumer.vertex(m4f, -half, -half, 0.0F).texture(0.0F, 0.0F).normal(mse, 0.0F, 1.0F, 0.0F);
vertexConsumer.vertex(m4f, -half, half, 0.0F).texture(0.0F, 1.0F).normal(mse, 0.0F, 1.0F, 0.0F);
vertexConsumer.vertex(m4f, half, half, 0.0F).texture(1.0F, 1.0F).normal(mse, 0.0F, 1.0F, 0.0F);
vertexConsumer.vertex(m4f, half, -half, 0.0F).texture(1.0F, 0.0F).normal(mse, 0.0F, 1.0F, 0.0F);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ChunkDataManager {
private final WorldChunk emptyChunk;

ChunkDataManager(WorldData data, World world) {
this.emptyChunk = new EmptyChunk(world, new ChunkPos(0, 0), null); // TODO null
this.emptyChunk = new EmptyChunk(world, new ChunkPos(0, 0), null); // TODO 1.18.2 null
this.mapData = data;
}

Expand Down Expand Up @@ -126,7 +126,7 @@ private WorldChunk callSaves(World world, ChunkPos chunkPos) {
CurrentWorldPos.getPersistentSupplier(), storage.getNbt(chunkPos).get().get(), opt);
if (chunkTag == null) return this.emptyChunk;
Chunk chunk = ChunkSerializer.deserialize(
serverWorld, serverWorld.getPointOfInterestStorage(), chunkPos, chunkTag);
serverWorld, serverWorld.getPointOfInterestStorage(), null, chunkPos, chunkTag); // TODO 1.21
if (chunk instanceof WrapperProtoChunk) {
return ((WrapperProtoChunk) chunk).getWrappedChunk();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private boolean isSolid() {

private static Identifier iconId(Identifier id) {
String path = String.format("textures/minimap/entities/%s.png", id.getPath());
return new Identifier(id.getNamespace(), path);
return Identifier.of(id.getNamespace(), path);
}

private static EntityHeadIconImage registerIcon(Entity entity, Identifier entityId, Identifier texture) {
Expand Down
Loading

0 comments on commit 9b79306

Please sign in to comment.