Skip to content

Commit

Permalink
idk
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysdh540 committed Dec 29, 2023
1 parent 092e079 commit ed01c86
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void registerConfigCommand() {
LiteralArgumentBuilder<CommandSourceStack> category = null;

for (Field field : CUServer.class.getDeclaredFields()) {
// skip if not config value or string
// skip if not config value
if (!CValue.class.isAssignableFrom(field.getType())) continue;

String name = field.getName();
Expand Down Expand Up @@ -91,31 +91,27 @@ public static void registerConfigCommand() {
}

// get config as forge config value
ConfigValue<?> value = ((CValueAccessor) cValue).value;
ConfigValue<?> value = ((CValueAccessor) cValue).getValue();

// get, description, reset
gdr(category, name, value);

// set for boolean
if (value instanceof BooleanValue bValue)
setBoolean(category, name, bValue);

// set for enums
else if (value instanceof EnumValue<? extends Enum<?>> eValue)
setEnum(category, name, eValue);

// set for int
else if (value instanceof IntValue iValue)
setInt(category, name, iValue);

// set for double
else if (value instanceof DoubleValue dValue)
setDouble(category, name, dValue);

}

if(Util.isDevEnv()) {
base.then(literal("disableEverything")//.requires(CUCommands::perms)
base.then(literal("disableEverything").requires(CUCommands::perms)
.executes(context -> {
CUConfigs.server().placementChecks.set(CUServer.PlacementCheck.OFF);
CUConfigs.server().extendedDriving.set(0.01);
Expand All @@ -138,11 +134,12 @@ else if (value instanceof DoubleValue dValue)
Util.registerCommand(base);
}

// private static boolean perms(Object o) {
private static boolean perms(Object o) {
// if(!(o instanceof CommandSourceStack source)) return false;
// Entity e = source.getEntity();
// return e != null && e.hasPermissions(4);
// }
return true;
}

private static <T> void gdr(LiteralArgumentBuilder<CommandSourceStack> category, String name, ConfigValue<T> value) {
category.then(literal(name)
Expand All @@ -152,7 +149,7 @@ private static <T> void gdr(LiteralArgumentBuilder<CommandSourceStack> category,
context.message("Default value: " + value.getDefault());
return Command.SINGLE_SUCCESS;
})
.then(literal("reset")//.requires(CUCommands::perms)
.then(literal("reset").requires(CUCommands::perms)
.executes(context -> {
if(value.get().equals(value.getDefault())) {
context.error("Value is already default!");
Expand All @@ -168,7 +165,7 @@ private static <T> void gdr(LiteralArgumentBuilder<CommandSourceStack> category,

private static void setBoolean(LiteralArgumentBuilder<CommandSourceStack> category, String name, BooleanValue value) {
category.then(literal(name)
.then(argument("value", BoolArgumentType.bool())//.requires(CUCommands::perms)
.then(argument("value", BoolArgumentType.bool()).requires(CUCommands::perms)
.executes(context -> {
boolean set = BoolArgumentType.getBool(context, "value");
if(set == value.get()) {
Expand All @@ -185,7 +182,7 @@ private static void setBoolean(LiteralArgumentBuilder<CommandSourceStack> catego

private static void setInt(LiteralArgumentBuilder<CommandSourceStack> category, String name, IntValue value) {
category.then(literal(name)
.then(argument("value", IntegerArgumentType.integer())//.requires(CUCommands::perms)
.then(argument("value", IntegerArgumentType.integer()).requires(CUCommands::perms)
.executes(context -> {
int set = IntegerArgumentType.getInteger(context, "value");
if(set == value.get()) {
Expand All @@ -202,7 +199,7 @@ private static void setInt(LiteralArgumentBuilder<CommandSourceStack> category,

private static void setDouble(LiteralArgumentBuilder<CommandSourceStack> category, String name, DoubleValue value) {
category.then(literal(name)
.then(argument("value", DoubleArgumentType.doubleArg())//.requires(CUCommands::perms)
.then(argument("value", DoubleArgumentType.doubleArg()).requires(CUCommands::perms)
.executes(context -> {
double set = DoubleArgumentType.getDouble(context, "value");
if(set == value.get()) {
Expand All @@ -221,7 +218,7 @@ private static void setDouble(LiteralArgumentBuilder<CommandSourceStack> categor
private static <T extends Enum<T>> void setEnum(LiteralArgumentBuilder<CommandSourceStack> category, String name, EnumValue<T> value) {
category.then(literal(name)
.then(argument("value", EnumArgument.enumArg(value.getDefault().getClass(), true))
//.requires(CUCommands::perms)
.requires(CUCommands::perms)
.executes(context -> {
T set = EnumArgument.getEnum(context, "value", (Class<T>) value.getDefault().getClass());
if(set == value.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;

import org.joml.Math;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Invoker;

@NoBootstrap
@SuppressWarnings("unused")
Expand Down Expand Up @@ -404,13 +404,13 @@ else if (j == inv.selected)
}

if (simulate && foundTracks < tracks) {
info.setValid(false);
info.isValid = false;
info.hasRequiredTracks = false;
return info.withMessage("not_enough_tracks").tooJumbly();
}

if (simulate && foundPavement < pavement) {
info.setValid(false);
info.isValid = false;
info.hasRequiredPavement = false;
return info.withMessage("not_enough_pavement").tooJumbly();
}
Expand All @@ -426,9 +426,13 @@ else if (j == inv.selected)
return placeTracks(level, info, state1, state2, targetPos1, targetPos2, false);
}

@Invoker("paveTracks")
private static void paveTracks(Level level, PlacementInfo info, BlockItem blockItem, boolean simulate) { throw new AssertionError(); }
@Shadow
private static void paveTracks(Level level, PlacementInfo info, BlockItem blockItem, boolean simulate) {
throw new AssertionError();
}

@Invoker("placeTracks")
private static PlacementInfo placeTracks(Level level, PlacementInfo info, BlockState state1, BlockState state2, BlockPos targetPos1, BlockPos targetPos2, boolean simulate) { throw new AssertionError(); }
@Shadow
private static PlacementInfo placeTracks(Level level, PlacementInfo info, BlockState state1, BlockState state2, BlockPos targetPos1, BlockPos targetPos2, boolean simulate) {
throw new AssertionError();
}
}

0 comments on commit ed01c86

Please sign in to comment.