Skip to content

Commit

Permalink
Attempted to load class net/minecraft/client/player/LocalPlayer for i…
Browse files Browse the repository at this point in the history
…nvalid dist DEDICATED_SERVER
  • Loading branch information
Leclowndu93150 committed Jul 17, 2024
1 parent 64bcfe0 commit 862e2c2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ neo_version_range=[21.0.10-beta,)

loader_version_range=[2,)

jei_version = 19.4.0.28
jei_version = 19.5.0.35

mod_id=modular_angelring

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.leclowndu93150.modular_angelring.common;

import com.leclowndu93150.modular_angelring.networking.PayloadActions;
import com.leclowndu93150.modular_angelring.registry.DataComponentRegistry;
import com.leclowndu93150.modular_angelring.registry.ItemRegistry;
import com.leclowndu93150.modular_angelring.registry.KeyBindRegistry;
Expand Down Expand Up @@ -61,8 +62,8 @@ public static void tickRing(ItemStack stack, Player player) {
}

ItemStack angelRingStack = slotResult.get().stack();
if(angelRingStack.has(DataComponentRegistry.SPEED_MODIFIER) && ((player.getAbilities().getFlyingSpeed() != getSpeedModifier(angelRingStack)) || !KeyBindRegistry.speedEnabled)){
if(KeyBindRegistry.speedEnabled){
if(angelRingStack.has(DataComponentRegistry.SPEED_MODIFIER) && ((player.getAbilities().getFlyingSpeed() != getSpeedModifier(angelRingStack)) || !PayloadActions.speedEnabled)){
if(PayloadActions.speedEnabled){
player.getAbilities().setFlyingSpeed(getSpeedModifier(angelRingStack));
} else player.getAbilities().setFlyingSpeed(0.05F);
}
Expand All @@ -85,16 +86,16 @@ public void appendHoverText(@NotNull ItemStack stack, @NotNull TooltipContext pC
if (AngelRingModules.getMiningSpeedModifier(stack) /* && KeyBindRegistry.miningEnabled */) {
pTooltipComponents.add(Component.literal("Mining Module")/*.append("Enabled")*/.withStyle(ChatFormatting.GRAY));
}
if (AngelRingModules.getInertiaModifier(stack) && KeyBindRegistry.inertiaEnabled){
if (AngelRingModules.getInertiaModifier(stack) && PayloadActions.inertiaEnabled){
pTooltipComponents.add(Component.literal("Inertia Module: ").append("Enabled").withStyle(ChatFormatting.GREEN));
}
if (AngelRingModules.getInertiaModifier(stack) && !KeyBindRegistry.inertiaEnabled){
if (AngelRingModules.getInertiaModifier(stack) && !PayloadActions.inertiaEnabled){
pTooltipComponents.add(Component.literal("Inertia Module: ").append("Disabled").withStyle(ChatFormatting.RED));
}
if (stack.has(DataComponentRegistry.SPEED_MODIFIER) && KeyBindRegistry.speedEnabled){
if (stack.has(DataComponentRegistry.SPEED_MODIFIER) && PayloadActions.speedEnabled){
pTooltipComponents.add(Component.literal("Speed Module: ").append(String.valueOf(FlightSpeedPercentage.speedToPercentage(AngelRingModules.getSpeedModifier(stack)))).append("%").withStyle(ChatFormatting.GREEN));
}
if (stack.has(DataComponentRegistry.SPEED_MODIFIER) && !KeyBindRegistry.speedEnabled){
if (stack.has(DataComponentRegistry.SPEED_MODIFIER) && !PayloadActions.speedEnabled){
pTooltipComponents.add(Component.literal("Speed Module: ").append(String.valueOf(FlightSpeedPercentage.speedToPercentage(AngelRingModules.getSpeedModifier(stack)))).append("%").withStyle(ChatFormatting.RED));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.leclowndu93150.modular_angelring.AngelRingMain;
import com.leclowndu93150.modular_angelring.common.AngelRingItem;
import com.leclowndu93150.modular_angelring.networking.PayloadActions;
import com.leclowndu93150.modular_angelring.registry.DataComponentRegistry;
import com.leclowndu93150.modular_angelring.registry.ItemRegistry;
import com.leclowndu93150.modular_angelring.registry.KeyBindRegistry;
Expand Down Expand Up @@ -39,7 +40,7 @@ public static void setRingBreakSpeed(PlayerEvent.BreakSpeed event) {
if (slotResult.isPresent()) {
ItemStack angelRingStack = slotResult.get().stack();
float newDigSpeed = event.getOriginalSpeed();
if (getMiningSpeedModifier(angelRingStack) && !player.onGround() && KeyBindRegistry.miningEnabled) {
if (getMiningSpeedModifier(angelRingStack) && !player.onGround()) {
newDigSpeed *= 5f;
}
if (newDigSpeed != event.getOriginalSpeed()) {
Expand All @@ -56,7 +57,7 @@ public static void stopDrift(PlayerTickEvent.Pre event) {
ItemStack angelRingStack = slotResult.get().stack();
Vec3 motion = player.getDeltaMovement();
Options opt = Minecraft.getInstance().options;
if (player.getAbilities().flying && getInertiaModifier(angelRingStack) && KeyBindRegistry.inertiaEnabled) {
if (player.getAbilities().flying && getInertiaModifier(angelRingStack) && PayloadActions.inertiaEnabled) {
if (!opt.keyUp.isDown() && !opt.keyDown.isDown() && !opt.keyLeft.isDown() && !opt.keyRight.isDown()) {
if (motion.x != 0 || motion.z != 0) {
player.setDeltaMovement(0, motion.y, 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
package com.leclowndu93150.modular_angelring.networking;

import com.leclowndu93150.modular_angelring.AngelRingMain;
import com.leclowndu93150.modular_angelring.registry.KeyBindRegistry;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.neoforged.neoforge.network.handling.IPayloadContext;

public final class PayloadActions {
public static boolean inertiaEnabled = true;
public static boolean speedEnabled = true;

public static void keyPressedAction(KeyPressedPayload payload, IPayloadContext ctx) {
// SERVER-SIDE
Player player = ctx.player();
Level level = player.level();
int key = payload.key();
if (key == KeyBindRegistry.INERTIA_MODULE.get().getKey().getValue()) {
// do stuff if inertia module key was pressed
System.out.println("Inertia pressed");
inertiaEnabled = !inertiaEnabled;
}

if (key == KeyBindRegistry.SPEED_MODULE.get().getKey().getValue()) {
speedEnabled = !speedEnabled;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.leclowndu93150.modular_angelring.registry;

import com.leclowndu93150.modular_angelring.common.AngelRingItem;
import com.leclowndu93150.modular_angelring.common.AngelRingModules;
import com.leclowndu93150.modular_angelring.networking.KeyPressedPayload;
import com.leclowndu93150.modular_angelring.networking.PayloadActions;
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.ChatFormatting;
import net.minecraft.client.KeyMapping;
Expand Down Expand Up @@ -44,7 +44,6 @@ public static void registerBindings(RegisterKeyMappingsEvent event) {
NeoForge.EVENT_BUS.addListener(KeyBindRegistry::onKey);
}

public static boolean miningEnabled = true;
public static boolean inertiaEnabled = true;
public static boolean speedEnabled = true;

Expand All @@ -56,9 +55,8 @@ public static void onKey(InputEvent.Key event) {
ItemStack angelRingStack = slotResult.get().stack();
Level level = player.level();
if (INERTIA_MODULE.get().consumeClick() && AngelRingModules.getInertiaModifier(angelRingStack)) {
// Send payload to server
PacketDistributor.sendToServer(new KeyPressedPayload(INERTIA_MODULE.get().getKey().getValue()));
inertiaEnabled = !inertiaEnabled;
PacketDistributor.sendToServer(new KeyPressedPayload(INERTIA_MODULE.get().getKey().getValue()));
if (inertiaEnabled) {
player.displayClientMessage(Component.literal("Inertia Module: Enabled").withStyle(ChatFormatting.GREEN), true);
level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BELL.value(), SoundSource.PLAYERS, 0.4f, 0.01f);
Expand All @@ -69,6 +67,7 @@ public static void onKey(InputEvent.Key event) {
}
if (SPEED_MODULE.get().consumeClick() && angelRingStack.has(DataComponentRegistry.SPEED_MODIFIER)) {
speedEnabled = !speedEnabled;
PacketDistributor.sendToServer(new KeyPressedPayload(SPEED_MODULE.get().getKey().getValue()));
if (speedEnabled) {
player.displayClientMessage(Component.literal("Speed Module: Enabled").withStyle(ChatFormatting.GREEN), true);
level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BELL.value(), SoundSource.PLAYERS, 0.4f, 0.01f);
Expand Down

0 comments on commit 862e2c2

Please sign in to comment.