Skip to content

Commit

Permalink
Finished Logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Leclowndu93150 committed Jun 9, 2024
1 parent 33723b2 commit c54f468
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void onUnequip(SlotContext slotContext, ItemStack newStack) {
@Override
public void appendHoverText(@NotNull ItemStack stack, @NotNull TooltipContext pContext, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pTooltipFlag) {
if (AngelRingModules.getMiningSpeedModifier(stack) && KeyBindRegistry.miningEnabled) {
pTooltipComponents.add(Component.literal("Mining Module: ").append("Enabled").withStyle(ChatFormatting.GREEN));
pTooltipComponents.add(Component.literal("Mining Module:").append("Enabled").withStyle(ChatFormatting.GREEN));
}
if (AngelRingModules.getInertiaModifier(stack) && KeyBindRegistry.inertiaEnabled){
pTooltipComponents.add(Component.literal("Inertia Module: ").append("Enabled").withStyle(ChatFormatting.GREEN));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package com.leclowndu93150.modular_angelring.registry;

import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.ChatFormatting;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.player.Player;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.client.event.InputEvent;
Expand All @@ -10,6 +16,8 @@
import net.neoforged.neoforge.common.util.Lazy;
import org.lwjgl.glfw.GLFW;

import java.awt.*;

import static com.leclowndu93150.modular_angelring.AngelRingMain.MODID;

@EventBusSubscriber(modid = MODID, bus = EventBusSubscriber.Bus.MOD)
Expand All @@ -31,14 +39,31 @@ public static void registerBindings(RegisterKeyMappingsEvent event) {

public static boolean miningEnabled = true;
public static boolean inertiaEnabled = true;
public static void onKey(InputEvent.Key event){
if(MINING_MODULE.get().consumeClick()){
public static void onKey(InputEvent.Key event) {
Player player = Minecraft.getInstance().player;
if (MINING_MODULE.get().consumeClick()) {
miningEnabled = !miningEnabled;
}
if (INERTIA_MODULE.get().consumeClick()){
inertiaEnabled = !inertiaEnabled;
if (player != null) {
if (miningEnabled) {
player.displayClientMessage(Component.literal("Mining Module: Enabled").withStyle(ChatFormatting.GREEN), true);
player.level().playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BELL.value(), SoundSource.PLAYERS, 0.4f, 0.01f);
} else {
player.displayClientMessage(Component.literal("Mining Module: Disabled").withStyle(ChatFormatting.RED), true);
player.level().playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BELL.value(), SoundSource.PLAYERS, 0.4f, 0.09f);
}
}
if (INERTIA_MODULE.get().consumeClick()) {
inertiaEnabled = !inertiaEnabled;
if (player != null) {
if (inertiaEnabled) {
player.displayClientMessage(Component.literal("Inertia Module: Enabled").withStyle(ChatFormatting.GREEN), true);
player.level().playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BELL.value(), SoundSource.PLAYERS, 0.4f, 0.01f);
} else {
player.displayClientMessage(Component.literal("Inertia Module: Disabled").withStyle(ChatFormatting.RED), true);
player.level().playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BELL.value(), SoundSource.PLAYERS, 0.4f, 0.09f);
}
}
}
}
}


}

0 comments on commit c54f468

Please sign in to comment.