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
|
loader_version=0.14.14
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=0.0.2
|
mod_version=0.0.3
|
||||||
maven_group=finnmod.survivaltools
|
maven_group=finnmod.survivaltools
|
||||||
archives_base_name=finnmod
|
archives_base_name=finnmod
|
||||||
|
|
||||||
|
|||||||
@@ -19,30 +19,30 @@ import net.minecraft.block.BlockState;
|
|||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
import net.minecraft.client.option.KeyBinding;
|
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 class SurvivalTools implements ModInitializer {
|
||||||
|
public static Text ModMessage = Text.literal("[Survival Tools] ").formatted(Formatting.WHITE);
|
||||||
private static final MinecraftClient client = MinecraftClient.getInstance();
|
private static final MinecraftClient client = MinecraftClient.getInstance();
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger("finnmod");
|
public static final Logger LOGGER = LoggerFactory.getLogger("finnmod");
|
||||||
boolean ChatWelcomeMessage = false;
|
boolean ChatWelcomeMessage = false;
|
||||||
private static boolean nightVisionEnabled = false;
|
private static boolean nightVisionEnabled = false;
|
||||||
private boolean isKeyPressed = false;
|
private boolean nightVisionisPressed = false;
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||||
if (SurvivalTools.client != null && SurvivalTools.client.world != null) {
|
if (SurvivalTools.client != null && SurvivalTools.client.world != null) {
|
||||||
|
if (NightVisionKeybind.isPressed()) {
|
||||||
if (myKeyBinding.isPressed()) {
|
|
||||||
// Key is pressed
|
// Key is pressed
|
||||||
if (!isKeyPressed) {
|
if (!nightVisionisPressed) {
|
||||||
// Key was not previously pressed, so execute the function
|
// Key was not previously pressed, so execute the function
|
||||||
toggleNightVision();
|
toggleNightVision();
|
||||||
isKeyPressed = true;
|
nightVisionisPressed = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Key is not pressed
|
// Key is not pressed
|
||||||
isKeyPressed = false;
|
nightVisionisPressed = false;
|
||||||
}
|
}
|
||||||
if(nightVisionEnabled)
|
if(nightVisionEnabled)
|
||||||
{
|
{
|
||||||
@@ -62,13 +62,22 @@ public class SurvivalTools implements ModInitializer {
|
|||||||
});
|
});
|
||||||
LOGGER.info("SurvivalTools Started!");
|
LOGGER.info("SurvivalTools Started!");
|
||||||
}
|
}
|
||||||
|
KeyBinding NightVisionKeybind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||||
|
"Nightvision Key",
|
||||||
|
InputUtil.Type.KEYSYM,
|
||||||
|
GLFW.GLFW_KEY_N,
|
||||||
|
"Survival Tools"
|
||||||
|
));
|
||||||
|
|
||||||
public void WelcomeMessage() {
|
public void WelcomeMessage() {
|
||||||
if (!ChatWelcomeMessage) {
|
if (!ChatWelcomeMessage) {
|
||||||
Text Message = Text.literal("SurvivalTools Loaded").formatted(Formatting.DARK_AQUA);
|
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);
|
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();
|
//enableGamma();
|
||||||
ChatWelcomeMessage = true;
|
ChatWelcomeMessage = true;
|
||||||
}
|
}
|
||||||
@@ -126,19 +135,20 @@ public class SurvivalTools implements ModInitializer {
|
|||||||
client.options.getGamma().setValue(1.0);
|
client.options.getGamma().setValue(1.0);
|
||||||
client.worldRenderer.reload();
|
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() {
|
public static void toggleNightVision() {
|
||||||
if (nightVisionEnabled) {
|
if (nightVisionEnabled) {
|
||||||
client.player.removeStatusEffect(StatusEffects.NIGHT_VISION);
|
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;
|
nightVisionEnabled = false;
|
||||||
} else {
|
} else {
|
||||||
|
Text Message = Text.literal("Nightvision Enabled!").formatted(Formatting.GREEN);
|
||||||
|
Text FinalMessage = ModMessage.copy().append(Message);
|
||||||
|
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(FinalMessage);
|
||||||
nightVisionEnabled = true;
|
nightVisionEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user