Skip to content

Commit

Permalink
Command tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jun 21, 2023
1 parent 1cc3b30 commit f2e55ac
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@
import com.fusionflux.portalcubed.util.PortalDirectionUtils;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.arguments.BoolArgumentType;
import com.unascribed.lib39.recoil.api.RecoilEvents;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
import net.fabricmc.fabric.api.client.render.fluid.v1.SimpleFluidRenderHandler;
import net.fabricmc.fabric.api.client.rendering.v1.*;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.DeathScreen;
import net.minecraft.client.gui.screens.MenuScreens;
Expand Down Expand Up @@ -145,8 +144,7 @@ public class PortalCubedClient implements ClientModInitializer {

public static WorldRenderContext worldRenderContext; // QFAPI impl detail: this is a mutable singleton

private static String clShowPosValue = "0";
public static boolean clShowPos = false;
public static boolean showPos = false;

@Override
public void onInitializeClient(ModContainer mod) {
Expand Down Expand Up @@ -487,7 +485,7 @@ Items.LIGHT, new ResourceLocation("level")
WorldRenderEvents.START.register(context -> worldRenderContext = context);

HudRenderCallback.EVENT.register((poseStack, tickDelta) -> {
if (!clShowPos) return;
if (!showPos) return;
final Minecraft minecraft = Minecraft.getInstance();
if (minecraft.options.renderDebug) return;
final LocalPlayer player = minecraft.player;
Expand Down Expand Up @@ -552,27 +550,17 @@ Items.LIGHT, new ResourceLocation("level")
)
);
}
dispatcher.register(literal("cl_showpos")
.then(argument("value", StringArgumentType.greedyString())
dispatcher.register(literal("showpos")
.then(argument("enabled", BoolArgumentType.bool())
.executes(ctx -> {
clShowPosValue = StringArgumentType.getString(ctx, "value");
try {
clShowPos = Integer.parseInt(clShowPosValue) != 0;
} catch (NumberFormatException e) {
clShowPos = false;
}
return 1;
showPos = BoolArgumentType.getBool(ctx, "enabled");
ctx.getSource().sendFeedback(Component.literal("showpos = " + showPos));
return showPos ? 1 : 0;
})
)
.executes(ctx -> {
ctx.getSource().sendFeedback(
Component.empty()
.append(Component.literal("\"cl_showpos\" = \"" + clShowPosValue + "\"").withStyle(ChatFormatting.RED))
.append(" (def. \"0\" )")
);
ctx.getSource().sendFeedback(Component.literal(" client"));
ctx.getSource().sendFeedback(Component.literal(" - Draw current position at top of screen"));
return 1;
ctx.getSource().sendFeedback(Component.literal("showpos = " + showPos));
return showPos ? 1 : 0;
})
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class ChellScaleCommand {

public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(literal("chellscale")
.requires(s -> s.hasPermission(2))
.executes(ctx -> scale(Collections.singleton(ctx.getSource().getEntity())))
.then(argument("targets", EntityArgument.entities())
.executes(ctx -> scale(EntityArgument.getEntities(ctx, "targets")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
public class FireRocketCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(literal("firerocket")
.requires(s -> s.hasPermission(2))
.executes(ctx -> fireRocket(ctx.getSource(), null))
.then(argument("rotation", RotationArgument.rotation())
.executes(ctx -> fireRocket(ctx.getSource(), RotationArgument.getRotation(ctx, "rotation")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private interface DefaultDimensionAction {

public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(buildDefaultDimension(literal("fog"), FogCommand::getFog)
.requires(s -> s.hasPermission(2))
.then(buildDefaultDimension(literal("reset"), FogCommand::resetFog))
.then(buildSet(literal("set"), true)
.then(buildSet(argument("dimension", DimensionArgument.dimension()), false))
Expand Down

0 comments on commit f2e55ac

Please sign in to comment.