Added Translation support and configuration options
This commit is contained in:
@@ -21,24 +21,22 @@ public class ClientKeyHandler {
|
||||
"key.categories.knockedback"
|
||||
);
|
||||
|
||||
// This event still needs to be registered on the MOD bus for key mapping registration.
|
||||
@Mod.EventBusSubscriber(modid = "knockedback", value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class KeyMappingRegistration {
|
||||
@SubscribeEvent
|
||||
public static void registerKeyMappings(RegisterKeyMappingsEvent event) {
|
||||
event.register(EXECUTE_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
public static final KeyMapping CARRY_KEY = new KeyMapping(
|
||||
"key.knockedback.carry",
|
||||
GLFW.GLFW_KEY_V,
|
||||
"key.categories.knockedback"
|
||||
);
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerCarryKey(RegisterKeyMappingsEvent e) {
|
||||
e.register(CARRY_KEY);
|
||||
@Mod.EventBusSubscriber(modid = "knockedback", value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class KeyMappingRegistration {
|
||||
@SubscribeEvent
|
||||
public static void registerKeyMappings(RegisterKeyMappingsEvent event) {
|
||||
event.register(EXECUTE_KEY);
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void registerCarryKey(RegisterKeyMappingsEvent e) {
|
||||
e.register(CARRY_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -46,10 +44,6 @@ public class ClientKeyHandler {
|
||||
if (Minecraft.getInstance().screen != null) return;
|
||||
if (EXECUTE_KEY.consumeClick()) {
|
||||
if (Minecraft.getInstance().player != null) {
|
||||
Minecraft.getInstance().player.sendSystemMessage(
|
||||
Component.literal("Key B pressed! Sending execution request to server.")
|
||||
);
|
||||
// Send the packet to the server
|
||||
NetworkHandler.CHANNEL.sendToServer(new ExecuteKnockedPacket());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.fretux.knockedback.client;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.fretux.knockedback.KnockedBack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.fretux.knockedback.KnockedBack;
|
||||
import net.fretux.knockedback.client.ClientKnockedState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -16,7 +17,7 @@ public class KnockedTimeOverlay {
|
||||
if (!ClientKnockedState.isKnocked()) return;
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
GuiGraphics guiGraphics = event.getGuiGraphics();
|
||||
String text = "Time until recovery: " + (ClientKnockedState.getTimeLeft() / 20) + " s";
|
||||
String text = I18n.get("overlay.knockedback.recovery_time", ClientKnockedState.getTimeLeft() / 20);
|
||||
int screenWidth = mc.getWindow().getGuiScaledWidth();
|
||||
int x = screenWidth / 2 - mc.font.width(text) / 2;
|
||||
int y = 10;
|
||||
|
||||
Reference in New Issue
Block a user