Fix
Version 0.0.3
This commit is contained in:
@@ -9,7 +9,7 @@ yarn_mappings=1.19.3+build.5
|
||||
loader_version=0.14.14
|
||||
|
||||
# Mod Properties
|
||||
mod_version=0.0.2
|
||||
mod_version=0.0.3
|
||||
maven_group=finnmod.survivaltools
|
||||
archives_base_name=finnmod
|
||||
|
||||
|
||||
@@ -19,30 +19,30 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.glfw.*;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
public class SurvivalTools implements ModInitializer {
|
||||
|
||||
public static Text ModMessage = Text.literal("[Survival Tools] ").formatted(Formatting.WHITE);
|
||||
private static final MinecraftClient client = MinecraftClient.getInstance();
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("finnmod");
|
||||
boolean ChatWelcomeMessage = false;
|
||||
private static boolean nightVisionEnabled = false;
|
||||
private boolean isKeyPressed = false;
|
||||
private boolean nightVisionisPressed = false;
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
if (SurvivalTools.client != null && SurvivalTools.client.world != null) {
|
||||
|
||||
if (myKeyBinding.isPressed()) {
|
||||
if (NightVisionKeybind.isPressed()) {
|
||||
// Key is pressed
|
||||
if (!isKeyPressed) {
|
||||
if (!nightVisionisPressed) {
|
||||
// Key was not previously pressed, so execute the function
|
||||
toggleNightVision();
|
||||
isKeyPressed = true;
|
||||
nightVisionisPressed = true;
|
||||
}
|
||||
} else {
|
||||
// Key is not pressed
|
||||
isKeyPressed = false;
|
||||
nightVisionisPressed = false;
|
||||
}
|
||||
if(nightVisionEnabled)
|
||||
{
|
||||
@@ -62,13 +62,22 @@ public class SurvivalTools implements ModInitializer {
|
||||
});
|
||||
LOGGER.info("SurvivalTools Started!");
|
||||
}
|
||||
KeyBinding NightVisionKeybind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||
"Nightvision Key",
|
||||
InputUtil.Type.KEYSYM,
|
||||
GLFW.GLFW_KEY_N,
|
||||
"Survival Tools"
|
||||
));
|
||||
|
||||
public void WelcomeMessage() {
|
||||
if (!ChatWelcomeMessage) {
|
||||
Text Message = Text.literal("SurvivalTools Loaded").formatted(Formatting.DARK_AQUA);
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Message);
|
||||
Text FinalMessage = ModMessage.copy().append(Message);
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(FinalMessage);
|
||||
|
||||
Text Message2 = Text.literal("Made by Finn_#9999").formatted(Formatting.AQUA);
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Message2);
|
||||
Text FinalMessage2 = ModMessage.copy().append(Message2);
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(FinalMessage2);
|
||||
//enableGamma();
|
||||
ChatWelcomeMessage = true;
|
||||
}
|
||||
@@ -126,19 +135,20 @@ public class SurvivalTools implements ModInitializer {
|
||||
client.options.getGamma().setValue(1.0);
|
||||
client.worldRenderer.reload();
|
||||
}
|
||||
KeyBinding myKeyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||
"Nightvision Key", // The translation key used to display the key binding in the options menu
|
||||
InputUtil.Type.KEYSYM, // The input type (key or mouse button)
|
||||
GLFW.GLFW_KEY_N, // The GLFW keycode for the N key
|
||||
"Survival Tools" // The translation key used to group this key binding with other key bindings in the options menu
|
||||
));
|
||||
|
||||
public static void toggleNightVision() {
|
||||
if (nightVisionEnabled) {
|
||||
client.player.removeStatusEffect(StatusEffects.NIGHT_VISION);
|
||||
Text Message = Text.literal("Nightvision Disabled!").formatted(Formatting.RED);;
|
||||
Text FinalMessage = ModMessage.copy().append(Message);
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(FinalMessage);
|
||||
nightVisionEnabled = false;
|
||||
} else {
|
||||
Text Message = Text.literal("Nightvision Enabled!").formatted(Formatting.GREEN);
|
||||
Text FinalMessage = ModMessage.copy().append(Message);
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(FinalMessage);
|
||||
nightVisionEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user