Skip to content

Commit

Permalink
debug commands
Browse files Browse the repository at this point in the history
  • Loading branch information
TropheusJ committed Jul 8, 2023
1 parent 4cd892d commit d1a6ed4
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/one/devos/nautical/succ/StateChangeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void handle(Minecraft mc, FriendlyByteBuf buf) {
mc.execute(() -> {
ClimbingState state = GlobalClimbingManager.getState(playerId, true);
state.facing = facing;
LocalPlayer player = Minecraft.getInstance().player;
LocalPlayer player = mc.player;
if (player != null && player.getUUID().equals(playerId)) {
LocalClimbingManager.INSTANCE = state.isClimbing() ? new LocalClimbingManager(mc) : null;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/one/devos/nautical/succ/Succ.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;

import one.devos.nautical.succ.commands.SuccCommands;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -69,6 +71,7 @@ public void onInitialize(ModContainer mod) {
EntityWorldChangeEvents.AFTER_ENTITY_WORLD_CHANGE.register(GlobalClimbingManager::onChangeWorld);
ClimbingSuctionCupEntity.networkingInit();
GlobalClimbingManager.networkingInit();
SuccCommands.init();
}

public static ResourceLocation id(String path) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/one/devos/nautical/succ/SuccClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import one.devos.nautical.succ.commands.SuccClientCommands;
import one.devos.nautical.succ.model.DepressedSuctionCupModel;
import one.devos.nautical.succ.model.SuctionCupModel;

Expand All @@ -16,6 +17,7 @@ public class SuccClient implements ClientModInitializer {
public void onInitializeClient(ModContainer mod) {
SuccKeybinds.init();
GlobalClimbingManager.clientNetworkingInit();
SuccClientCommands.init();

EntityModelLayerRegistry.registerModelLayer(SuctionCupModel.LAYER, SuctionCupModel::getLayerDefinition);
EntityModelLayerRegistry.registerModelLayer(DepressedSuctionCupModel.LAYER, DepressedSuctionCupModel::getLayerDefinition);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package one.devos.nautical.succ.commands;

import static org.quiltmc.qsl.command.api.client.ClientCommandManager.literal;

import one.devos.nautical.succ.ClimbingState;
import one.devos.nautical.succ.GlobalClimbingManager;
import net.minecraft.network.chat.Component;

import org.quiltmc.qsl.command.api.client.ClientCommandRegistrationCallback;
import org.quiltmc.qsl.command.api.client.QuiltClientCommandSource;

public class SuccClientCommands {
public static void init() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, ctx, env) -> dispatcher.register(
literal("succ")
.then(literal("climbinfo")
.then(literal("client")
.executes(context -> {
QuiltClientCommandSource source = context.getSource();
ClimbingState state = GlobalClimbingManager.getState(source.getPlayer());

source.sendFeedback(Component.literal("climbing: " + state.isClimbing()));
source.sendFeedback(Component.literal("entities: " + state.entities.size()));
source.sendFeedback(Component.literal("facing: " + state.facing));
return 1;
})
)
)
));
}
}
32 changes: 32 additions & 0 deletions src/main/java/one/devos/nautical/succ/commands/SuccCommands.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package one.devos.nautical.succ.commands;

import static net.minecraft.commands.Commands.literal;

import one.devos.nautical.succ.ClimbingState;
import one.devos.nautical.succ.GlobalClimbingManager;

import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;

import org.quiltmc.qsl.command.api.CommandRegistrationCallback;

public class SuccCommands {
public static void init() {
CommandRegistrationCallback.EVENT.register((dispatcher, ctx, env) -> dispatcher.register(
literal("succ")
.then(literal("climbinfo")
.then(literal("server")
.executes(context -> {
CommandSourceStack source = context.getSource();
ClimbingState state = GlobalClimbingManager.getState(source.getPlayerOrException());

source.sendSystemMessage(Component.literal("climbing: " + state.isClimbing()));
source.sendSystemMessage(Component.literal("entities: " + state.entities.size()));
source.sendSystemMessage(Component.literal("facing: " + state.facing));
return 1;
})
)
)
));
}
}

0 comments on commit d1a6ed4

Please sign in to comment.