Skip to content

Commit

Permalink
apply 1.20.5
Browse files Browse the repository at this point in the history
  • Loading branch information
umjammer committed Apr 26, 2024
1 parent 60f6697 commit 9bff88c
Show file tree
Hide file tree
Showing 18 changed files with 155 additions and 104 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![Fabric](https://img.shields.io/badge/Mod_Loader-Fabric-blue)](https://fabricmc.net/)
[![Minecraft](https://img.shields.io/badge/Minecraft-1.20.4-green)](https://www.minecraft.net/)
[![Minecraft](https://img.shields.io/badge/Minecraft-1.20.5-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-17-b07219)
![Java](https://img.shields.io/badge/Java-21-b07219)

# Just Map

Expand All @@ -22,3 +22,4 @@ Translation via [Crowdin](https://crowdin.com/project/justmap)
## TODO

* new entities' texture for minimap
* jump always teleports to the overworld from other worlds?
21 changes: 12 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
id 'idea'
}

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

Expand Down Expand Up @@ -34,12 +33,20 @@ if (versionPropsFile.canWrite()) {

version = "${major}.${minor}.${build}"

base {
archivesName = project.archives_base_name
}

repositories {
maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
}

loom {
accessWidenerPath = file("src/main/resources/justmap.accesswidener")
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
Expand All @@ -57,10 +64,6 @@ dependencies {
}
}

loom {
accessWidenerPath = file("src/main/resources/justmap.accesswidener")
}

processResources {
inputs.property "version", project.version
duplicatesStrategy = 'WARN'
Expand All @@ -71,19 +74,19 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
from("LICENSE") {
rename { "${it}_${base.archivesName.get()}"}
rename { "${it}_${project.base.archivesName.get()}"}
}
}

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.4
yarn_mappings = 1.20.4+build.3
loader_version = 0.15.9
minecraft_version = 1.20.5
yarn_mappings = 1.20.5+build.1
loader_version = 0.15.10

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.96.11+1.20.4
cloth_version = 13.0.121
modmenu_version = 9.0.0
fabric_version = 0.97.6+1.20.5
cloth_version = 14.0.126
modmenu_version = 10.0.0-beta.1
2 changes: 2 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,11 @@ private void renderWaypoint(MatrixStack matrixStack, VertexConsumerProvider cons
private void renderIcon(MatrixStack matrixStack, VertexConsumer vertexConsumer, float[] colors, float alpha) {
MatrixStack.Entry entry = matrixStack.peek();
Matrix4f matrix4f = entry.getPositionMatrix();
Matrix3f matrix3f = entry.getNormalMatrix();

this.addVertex(matrix4f, matrix3f, vertexConsumer, colors[0], colors[1], colors[2], alpha, -0.5F, -0.5F, 0.0F, 0.0F, 0.0F);
this.addVertex(matrix4f, matrix3f, vertexConsumer, colors[0], colors[1], colors[2], alpha, -0.5F, 0.5F, 0.0F, 0.0F, 1.0F);
this.addVertex(matrix4f, matrix3f, vertexConsumer, colors[0], colors[1], colors[2], alpha, 0.5F, 0.5F, 0.0F, 1.0F, 1.0F);
this.addVertex(matrix4f, matrix3f, vertexConsumer, colors[0], colors[1], colors[2], alpha, 0.5F, -0.5F, 0.0F, 1.0F, 0.0F);
this.addVertex(matrix4f, entry, vertexConsumer, colors[0], colors[1], colors[2], alpha, -0.5F, -0.5F, 0.0F, 0.0F, 0.0F);
this.addVertex(matrix4f, entry, vertexConsumer, colors[0], colors[1], colors[2], alpha, -0.5F, 0.5F, 0.0F, 0.0F, 1.0F);
this.addVertex(matrix4f, entry, vertexConsumer, colors[0], colors[1], colors[2], alpha, 0.5F, 0.5F, 0.0F, 1.0F, 1.0F);
this.addVertex(matrix4f, entry, vertexConsumer, colors[0], colors[1], colors[2], alpha, 0.5F, -0.5F, 0.0F, 1.0F, 0.0F);
}

private void renderLightBeam(MatrixStack matrixStack, VertexConsumer vertexConsumer, float tick, int i, int j, float[] colors, float alpha, float h, float k) {
Expand Down Expand Up @@ -223,22 +222,21 @@ private void renderLightBeam(MatrixStack matrixStack, VertexConsumer vertexConsu
private void renderBeam(MatrixStack matrixStack, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, int j, int k, float l, float m, float n, float o, float p, float q, float r, float s, float t, float u, float v, float w) {
MatrixStack.Entry entry = matrixStack.peek();
Matrix4f matrix4f = entry.getPositionMatrix();
Matrix3f matrix3f = entry.getNormalMatrix();
this.renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, j, k, l, m, n, o, t, u, v, w);
this.renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, j, k, r, s, p, q, t, u, v, w);
this.renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, j, k, n, o, r, s, t, u, v, w);
this.renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, j, k, p, q, l, m, t, u, v, w);
this.renderBeam(matrix4f, entry, vertexConsumer, red, green, blue, alpha, j, k, l, m, n, o, t, u, v, w);
this.renderBeam(matrix4f, entry, vertexConsumer, red, green, blue, alpha, j, k, r, s, p, q, t, u, v, w);
this.renderBeam(matrix4f, entry, vertexConsumer, red, green, blue, alpha, j, k, n, o, r, s, t, u, v, w);
this.renderBeam(matrix4f, entry, vertexConsumer, red, green, blue, alpha, j, k, p, q, l, m, t, u, v, w);
}

private void renderBeam(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, int j, int k, float l, float m, float n, float o, float p, float q, float r, float s) {
this.addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, k, l, m, q, r);
this.addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, j, l, m, q, s);
this.addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, j, n, o, p, s);
this.addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, k, n, o, p, r);
private void renderBeam(Matrix4f matrix4f, MatrixStack.Entry matrixSE, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, int j, int k, float l, float m, float n, float o, float p, float q, float r, float s) {
this.addVertex(matrix4f, matrixSE, vertexConsumer, red, green, blue, alpha, k, l, m, q, r);
this.addVertex(matrix4f, matrixSE, vertexConsumer, red, green, blue, alpha, j, l, m, q, s);
this.addVertex(matrix4f, matrixSE, vertexConsumer, red, green, blue, alpha, j, n, o, p, s);
this.addVertex(matrix4f, matrixSE, vertexConsumer, red, green, blue, alpha, k, n, o, p, r);
}

private void addVertex(Matrix4f matrix4f, Matrix3f matrix3f, 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(matrix3f, 0.0F, 1.0F, 0.0F).next();
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();
}

private double correctAngle(float angle) {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/ru/bulldog/justmap/map/DirectionArrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public static void draw(double x, double y, int size, float rotation) {
matrix.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(rotation + 180));

Matrix4f m4f = matrix.peek().getPositionMatrix();
Matrix3f m3f = matrix.peek().getNormalMatrix();
MatrixStack.Entry mse = matrix.peek();

addVertices(m4f, m3f, vertexConsumer, size);
addVertices(m4f, mse, vertexConsumer, size);
tessellator.draw();

matrix.pop();
Expand All @@ -82,13 +82,13 @@ public static void draw(double x, double y, int size, float rotation) {
}
}

private static void addVertices(Matrix4f m4f, Matrix3f m3f, VertexConsumer vertexConsumer, int size) {
float half = size / 2;
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(m3f, 0.0F, 1.0F, 0.0F).next();
vertexConsumer.vertex(m4f, -half, half, 0.0F).texture(0.0F, 1.0F).normal(m3f, 0.0F, 1.0F, 0.0F).next();
vertexConsumer.vertex(m4f, half, half, 0.0F).texture(1.0F, 1.0F).normal(m3f, 0.0F, 1.0F, 0.0F).next();
vertexConsumer.vertex(m4f, half, -half, 0.0F).texture(1.0F, 0.0F).normal(m3f, 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).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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Optional;

import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryKey;
import net.minecraft.server.world.ServerWorld;
Expand Down Expand Up @@ -120,7 +121,7 @@ private WorldChunk callSaves(World world, ChunkPos chunkPos) {

ServerWorld serverWorld = (ServerWorld) world;
try (VersionedChunkStorage storage = StorageUtil.getChunkStorage(serverWorld)) {
Optional<RegistryKey<Codec<? extends ChunkGenerator>>> opt = Optional.ofNullable(null);
Optional<RegistryKey<MapCodec<? extends ChunkGenerator>>> opt = Optional.ofNullable(null);
NbtCompound chunkTag = storage.updateChunkNbt(serverWorld.getRegistryKey(),
CurrentWorldPos.getPersistentSupplier(), storage.getNbt(chunkPos).get().get(), opt);
if (chunkTag == null) return this.emptyChunk;
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/ru/bulldog/justmap/mixins/client/HudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.ibm.icu.text.ListFormatter.Width;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
Expand All @@ -15,10 +16,12 @@
import net.minecraft.client.texture.StatusEffectSpriteManager;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -34,13 +37,10 @@ abstract class HudMixin {
@Shadow
private MinecraftClient client;

@Shadow
private int scaledWidth;

@Inject(at = @At("HEAD"), method = "renderStatusEffectOverlay", cancellable = true)
protected void renderStatusEffects(DrawContext context, CallbackInfo info) {
protected void renderStatusEffects(DrawContext context, float tickDelta, CallbackInfo info) {
if (ClientSettings.moveEffects) {
int posX = this.scaledWidth;
int posX = context.getScaledWindowWidth();
int posY = ClientSettings.positionOffset;
if (ClientSettings.mapPosition == ScreenPosition.TOP_RIGHT) {
posX = JustMapClient.getMiniMap().getSkinX();
Expand All @@ -51,6 +51,7 @@ protected void renderStatusEffects(DrawContext context, CallbackInfo info) {
}
}

@Unique
private void drawMovedEffects(DrawContext context, int screenX, int screenY) {
Collection<StatusEffectInstance> statusEffects = this.client.player.getStatusEffects();
if (statusEffects.isEmpty()) return;
Expand All @@ -75,15 +76,15 @@ private void drawMovedEffects(DrawContext context, int screenX, int screenY) {
int i = 0, j = 0;
while (effectsIterator.hasNext()) {
StatusEffectInstance statusEffectInstance = effectsIterator.next();
StatusEffect statusEffect = statusEffectInstance.getEffectType();
RegistryEntry<StatusEffect> statusEffect = statusEffectInstance.getEffectType();
if (statusEffectInstance.shouldShowIcon()) {
int x = screenX;
int y = screenY;
if (this.client.isDemo()) {
y += 15;
}

if (statusEffect.isBeneficial()) {
if (statusEffect.value().isBeneficial()) {
++i;
x -= (size + hOffset) * i;
} else {
Expand Down Expand Up @@ -124,7 +125,8 @@ private void drawMovedEffects(DrawContext context, int screenX, int screenY) {
timers.forEach(Runnable::run);
}

private String convertDuration(int time) {
@Unique
private static String convertDuration(int time) {
int mils = time * 50;
int s = (mils / 1000) % 60;
int m = (mils / (1000 * 60)) % 60;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.bulldog.justmap.mixins.client;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.DownloadingTerrainScreen.WorldEntryReason;
import net.minecraft.client.world.ClientWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -14,7 +15,7 @@
public abstract class MinecraftClientMixin {

@Inject(method = "joinWorld", at = @At("TAIL"))
public void onJoinWorld(ClientWorld world, CallbackInfo cinfo) {
public void onJoinWorld(ClientWorld world, WorldEntryReason worldEntryReason, CallbackInfo ci) {
MapDataProvider.getMultiworldManager().onWorldChanged(world);
CurrentWorldPos.updateWorld(world);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ConnectedClientData;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.world.GameRules;
Expand All @@ -26,15 +27,15 @@ public abstract class PlayerManagerMixin {
private MinecraftServer server;

@Inject(method = "onPlayerConnect", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/DifficultyS2CPacket;<init>(Lnet/minecraft/world/Difficulty;Z)V"))
public void onPlayerConnectPre(ClientConnection connection, ServerPlayerEntity player, CallbackInfo info) {
public void onPlayerConnectPre(ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData, CallbackInfo ci) {
ServerNetworkHandler networkHandler = JustMapServer.getNetworkHandler();
if (networkHandler != null) {
networkHandler.onPlayerConnect(player);
}
}

@Inject(method = "onPlayerConnect", at = @At("TAIL"))
public void onPlayerConnectPost(ClientConnection clientConnection, ServerPlayerEntity serverPlayerEntity, CallbackInfo info) {
public void onPlayerConnectPost(ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData, CallbackInfo ci) {
StringBuilder command = new StringBuilder("§0§0");
if (ServerSettings.useGameRules) {
GameRules gameRules = server.getGameRules();
Expand Down Expand Up @@ -85,7 +86,7 @@ public void onPlayerConnectPost(ClientConnection clientConnection, ServerPlayerE
command.append("§f§f");

if (command.length() > 8) {
this.sendCommand(serverPlayerEntity, Text.of(command.toString()));
this.sendCommand(player, Text.of(command.toString()));
}
}

Expand Down
32 changes: 18 additions & 14 deletions src/main/java/ru/bulldog/justmap/network/ClientNetworkHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,40 @@
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket;
import net.minecraft.util.math.ChunkPos;

import ru.bulldog.justmap.JustMap;
import ru.bulldog.justmap.map.data.RegionPos;

import static ru.bulldog.justmap.network.NetworkHandler.PacketByteBufPayload.channelPacketCodec;


public class ClientNetworkHandler extends NetworkHandler {

private final Map<Integer, Consumer<?>> responseListeners = new HashMap<>();
private boolean serverReady = false;
private Random random;

public void registerPacketsListeners() {
ClientPlayNetworking.registerGlobalReceiver(INIT_PACKET_ID, (client, handler, buf, responseSender) -> {
long seed = buf.readLong();
PayloadTypeRegistry.playS2C().register(INIT_PACKET_ID, PacketByteBufPayload.initPacketCodec);
ClientPlayNetworking.registerGlobalReceiver(INIT_PACKET_ID, (payload, context) -> {
PacketByteBuf packetData = new PacketByteBuf(Unpooled.buffer());
channelPacketCodec.encode(packetData, payload);
long seed = packetData.readLong();
this.random = new Random(seed);
this.serverReady = true;
JustMap.LOGGER.info("Networking successfully initialized.");
});
ClientPlayNetworking.registerGlobalReceiver(CHANNEL_ID, (client, handler, buf, responseSender) -> {
ByteBuf packetData = buf.copy();
PayloadTypeRegistry.playS2C().register(CHANNEL_ID, PacketByteBufPayload.channelPacketCodec);
ClientPlayNetworking.registerGlobalReceiver(CHANNEL_ID, (payload, context) -> {
PacketByteBuf packetData = new PacketByteBuf(Unpooled.buffer());
channelPacketCodec.encode(packetData, payload);
PacketType packetType = PacketType.get(packetData.readByte());
switch (packetType) {
case SLIME_CHUNK_PACKET: {
client.execute(() -> this.onChunkHasSlimeResponse(packetData));
break;
}
case GET_IMAGE_PACKET: {
client.execute(() -> this.onRegionImageResponse(packetData));
break;
}
case SLIME_CHUNK_PACKET -> context.client().execute(() -> this.onChunkHasSlimeResponse(packetData));
case GET_IMAGE_PACKET -> context.client().execute(() -> this.onRegionImageResponse(packetData));
}
});
}
Expand All @@ -55,7 +58,8 @@ public void requestChunkHasSlime(ChunkPos chunkPos, Consumer<Boolean> responseCo
data.writeInt(packet_id);
data.writeInt(chunkPos.x);
data.writeInt(chunkPos.z);
CustomPayloadC2SPacket packet = new CustomPayloadC2SPacket(data);
PacketByteBufPayload payload = channelPacketCodec.decode(data);
CustomPayloadC2SPacket packet = new CustomPayloadC2SPacket(payload);
this.sendToServer(packet);
}

Expand Down
Loading

0 comments on commit 9bff88c

Please sign in to comment.