Skip to content

Commit

Permalink
update to 1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Boxadactle committed Aug 18, 2024
1 parent 4d0d4c0 commit f8814ce
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 56 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Publish
on:
push:
branches: [ "latest" ]
on: [ workflow_dispatch ]

permissions:
contents: read
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "dev.boxadactle.coordinatesdisplay.mixin",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"client": [
"DeathScreenMixin",
"LocalPlayerMixin",
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
]
},
"mixins": [
"coordinatesdisplay-common.mixins.json"
"coordinatesdisplay.mixins.json"
],
"depends": {
"fabricloader": ">=0.15.10",
Expand Down
2 changes: 1 addition & 1 deletion forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ architectury {

loom {
forge {
mixinConfig "coordinatesdisplay-common.mixins.json"
mixinConfig "coordinatesdisplay.mixins.json", "coordinatesdisplay-forge.mixins.json"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package dev.boxadactle.coordinatesdisplay.forge;

import com.mojang.blaze3d.systems.RenderSystem;
import dev.boxadactle.boxlib.util.GuiUtils;
import dev.boxadactle.boxlib.util.WorldUtils;
import dev.boxadactle.coordinatesdisplay.Bindings;
import dev.boxadactle.coordinatesdisplay.CoordinatesDisplay;
import dev.boxadactle.coordinatesdisplay.ModConfig;
import dev.boxadactle.coordinatesdisplay.screen.ConfigScreen;
import dev.boxadactle.coordinatesdisplay.position.Position;
import dev.boxadactle.coordinatesdisplay.screen.ConfigScreen;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.client.event.RenderGuiEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -34,46 +29,13 @@ public CoordinatesDisplayForge() {
}

@Mod.EventBusSubscriber(modid = CoordinatesDisplay.MOD_ID, value = Dist.CLIENT)
public static class ClientNeoforgeEvents {
public static class ClientForgeEvents {

@SubscribeEvent
public static void keyInput(InputEvent.Key e) {
Player player = WorldUtils.getPlayer();
if (player != null) {
Bindings.checkBindings(Position.of(player));
}
}

@SubscribeEvent(priority = EventPriority.LOW)
public static void renderHud(RenderGuiEvent.Pre event) {
try {
if (CoordinatesDisplay.HUD.shouldRender(CoordinatesDisplay.getConfig().visibilityFilter)) {
RenderSystem.enableBlend();

ModConfig config = CoordinatesDisplay.getConfig();

CoordinatesDisplay.HUD.render(
event.getGuiGraphics(),
Position.of(WorldUtils.getPlayer()),
config.hudX,
config.hudY,
config.renderMode,
config.startCorner,
config.hudScale
);
}
} catch (NullPointerException e) {
if (deltaError) {
throw new RuntimeException(e);
}

CoordinatesDisplay.LOGGER.error("Unknown error from config file");
CoordinatesDisplay.LOGGER.printStackTrace(e);

CoordinatesDisplay.LOGGER.player.warn(GuiUtils.getTranslatable("message.coordinatesdisplay.configError"));
CoordinatesDisplay.CONFIG.resetConfig();

deltaError = true;
Bindings.checkBindings(Position.of(player));
}
}

Expand All @@ -82,7 +44,7 @@ public static void renderHud(RenderGuiEvent.Pre event) {
@Mod.EventBusSubscriber(modid = CoordinatesDisplay.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
public static class ClientModEvents {
@SubscribeEvent
public static void clientSetup(RegisterKeyMappingsEvent e) {
public static void registerKeys(RegisterKeyMappingsEvent e) {
e.register(Bindings.hudEnabled);
e.register(Bindings.coordinatesGUIKeybind);
e.register(Bindings.copyLocation);
Expand All @@ -93,4 +55,4 @@ public static void clientSetup(RegisterKeyMappingsEvent e) {
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package dev.boxadactle.coordinatesdisplay.forge;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.registries.ForgeRegistries;

public class ModUtilImpl {

public static String getBlockName(Block block) {
return String.valueOf(ForgeRegistries.BLOCKS.getKey(block));
return String.valueOf(BuiltInRegistries.BLOCK.getId(block));
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package dev.boxadactle.coordinatesdisplay.forge.mixin;

import com.mojang.blaze3d.systems.RenderSystem;
import dev.boxadactle.boxlib.util.GuiUtils;
import dev.boxadactle.boxlib.util.WorldUtils;
import dev.boxadactle.coordinatesdisplay.CoordinatesDisplay;
import dev.boxadactle.coordinatesdisplay.ModConfig;
import dev.boxadactle.coordinatesdisplay.forge.CoordinatesDisplayForge;
import dev.boxadactle.coordinatesdisplay.hud.Hud;
import dev.boxadactle.coordinatesdisplay.position.Position;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.LayeredDraw;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(Gui.class)
public class GuiMixin {

@Inject(method = "<init>", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
private void init(Minecraft arg, CallbackInfo ci, LayeredDraw drawer) {
drawer.add((graphics, f) -> {
try {
if (CoordinatesDisplay.HUD.shouldRender(CoordinatesDisplay.getConfig().visibilityFilter)) {
RenderSystem.enableBlend();

ModConfig config = CoordinatesDisplay.getConfig();

CoordinatesDisplay.HUD.render(
graphics,
Hud.RenderType.HUD,
Position.of(WorldUtils.getPlayer()),
config.hudX,
config.hudY,
config.renderMode,
config.startCorner,
config.hudScale
);
}
} catch (NullPointerException e) {
if (CoordinatesDisplayForge.deltaError) {
throw new RuntimeException(e);
}

CoordinatesDisplay.LOGGER.error("Unknown error from config file");
CoordinatesDisplay.LOGGER.printStackTrace(e);

CoordinatesDisplay.LOGGER.player.warn(GuiUtils.getTranslatable("message.coordinatesdisplay.configError"));
CoordinatesDisplay.CONFIG.resetConfig();

CoordinatesDisplayForge.deltaError = true;
}
});
}

}
4 changes: 2 additions & 2 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ side="BOTH"
[[dependencies.coordinatesdisplay]]
modId="minecraft"
mandatory=true
versionRange="[1.20.3,1.20.4]"
versionRange="[1.21,)"
ordering="NONE"
side="BOTH"

[[dependencies.coordinatesdisplay]]
modId="boxlib"
mandatory=true
versionRange="[12.0.0,13.0.0)"
versionRange="[14.0.0,15.0.0)"
ordering="NONE"
side="CLIENT"
12 changes: 12 additions & 0 deletions forge/src/main/resources/coordinatesdisplay-forge.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"required": true,
"minVersion": "0.8",
"package": "dev.boxadactle.coordinatesdisplay.forge.mixin",
"compatibilityLevel": "JAVA_16",
"client": [
"GuiMixin"
],
"injectors": {
"defaultRequire": 1
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.parallel=true
mod_version = 13.1.0
maven_group = dev.boxadactle
archives_name = CoordinatesDisplay
enabled_platforms = fabric,neoforge
enabled_platforms = fabric,neoforge,forge

# Minecraft properties
minecraft_version = 1.21.1
Expand Down
2 changes: 1 addition & 1 deletion neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ ordering = "NONE"
side = "BOTH"

[[mixins]]
config = "coordinatesdisplay-common.mixins.json"
config = "coordinatesdisplay.mixins.json"

0 comments on commit f8814ce

Please sign in to comment.