Skip to content

Commit

Permalink
bugfixes?
Browse files Browse the repository at this point in the history
- change CUCommands#perms to possibly not kill servers
- remove var stuff (what was i thinking)
- update to patch f
  • Loading branch information
rhysdh540 committed Nov 4, 2023
1 parent a8605a2 commit efd243b
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 23 deletions.
6 changes: 3 additions & 3 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# DO NOT EDIT
# Generated by the build script. Change mcVer property to change minecraft version.

PRE_CURRENT_MC_1_19_2=
MC_1_19_2=
POST_MC_1_19_2=
POST_CURRENT_MC_1_19_2=
PRE_MC_1_20_1=
PRE_CURRENT_MC_1_20_1=
MC_1_20_1=
POST_CURRENT_MC_1_20_1=
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.EnumMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Supplier;

import manifold.rt.api.NoBootstrap;
Expand Down Expand Up @@ -61,7 +62,7 @@ private static <T extends ConfigBase> void register(Supplier<T> factory, Type si
public static void register() {
register(CUServer::new, SERVER);

for(var pair : CONFIGS.entrySet())
for(Entry<Type, ConfigBase> pair : CONFIGS.entrySet())
Util.registerConfig(pair.getKey(), pair.getValue().specification);
}

Expand All @@ -78,13 +79,14 @@ public static void onReload(ModConfig modConfig) {
}

public static BaseConfigScreen createConfigScreen(Screen parent) {
if(!done) initBCS();
initBCS();
return new BaseConfigScreen(parent, CreateUnlimited.ID);
}

private static boolean done = false;

private static void initBCS() {
if(done) return;
BaseConfigScreen.setDefaultActionFor(CreateUnlimited.ID, (base) ->
base.withSpecs(getSpecByType(CLIENT), getSpecByType(COMMON), getSpecByType(SERVER))
.withTitles("", "", "Settings")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
import net.minecraft.network.chat.ComponentUtils;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.entity.Entity;

import net.minecraftforge.common.ForgeConfigSpec.*;

import dev.rdh.createunlimited.mixin.accessor.CValueAccessor;

import java.lang.reflect.Field;
import java.util.List;

import manifold.rt.api.NoBootstrap;
Expand All @@ -49,7 +51,7 @@ public static void registerConfigCommand() {
LiteralArgumentBuilder<CommandSourceStack> base = literal(CreateUnlimited.ID).executes(context -> {
context.message(CreateUnlimited.NAME + " v" + CreateUnlimited.VERSION + " by rdh\nVisit us on:");

var link = MutableComponent.create(CommonComponents.EMPTY.getContents());
MutableComponent link = MutableComponent.create(CommonComponents.EMPTY.getContents());
links.forEach(a -> link.append(a).append(Component.literal(" ")));

context.message(link);
Expand All @@ -58,7 +60,7 @@ public static void registerConfigCommand() {

LiteralArgumentBuilder<CommandSourceStack> category = null;

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

Expand Down Expand Up @@ -136,7 +138,9 @@ else if (value instanceof DoubleValue dValue)
}

private static boolean perms(Object o) {
return o instanceof CommandSourceStack source && (source.hasPermission(4) || !source.getLevel().getServer().isDedicatedServer());
if(!(o instanceof CommandSourceStack source)) return false;
Entity e = source.getEntity();
return e != null && e.hasPermissions(4);
}

private static <T> void gdr(LiteralArgumentBuilder<CommandSourceStack> category, String name, ConfigValue<T> value) {
Expand Down Expand Up @@ -165,7 +169,7 @@ private static void setBoolean(LiteralArgumentBuilder<CommandSourceStack> catego
category.then(literal(name)
.then(argument("value", BoolArgumentType.bool()).requires(CUCommands::perms)
.executes(context -> {
var set = BoolArgumentType.getBool(context, "value");
boolean set = BoolArgumentType.getBool(context, "value");
if(set == value.get()) {
context.error("Value is already set to " + set);
return 0;
Expand All @@ -182,7 +186,7 @@ private static void setInt(LiteralArgumentBuilder<CommandSourceStack> category,
category.then(literal(name)
.then(argument("value", IntegerArgumentType.integer()).requires(CUCommands::perms)
.executes(context -> {
var set = IntegerArgumentType.getInteger(context, "value");
int set = IntegerArgumentType.getInteger(context, "value");
if(set == value.get()) {
context.error("Value is already set to " + set);
return 0;
Expand All @@ -199,7 +203,7 @@ private static void setDouble(LiteralArgumentBuilder<CommandSourceStack> categor
category.then(literal(name)
.then(argument("value", DoubleArgumentType.doubleArg()).requires(CUCommands::perms)
.executes(context -> {
var set = DoubleArgumentType.getDouble(context, "value");
double set = DoubleArgumentType.getDouble(context, "value");
if(set == value.get()) {
context.error("Value is already set to " + set);
return 0;
Expand All @@ -217,7 +221,7 @@ private static <T extends Enum<T>> void setEnum(LiteralArgumentBuilder<CommandSo
category.then(literal(name)
.then(argument("value", EnumArgument.enumArg(value.getDefault().getClass(), true)).requires(CUCommands::perms)
.executes(context -> {
var set = (T) context.getArgument("value", value.get().getClass());
T set = EnumArgument.getEnum(context, "value", (Class<T>) value.getDefault().getClass());
if(set == value.get()) {
context.error("Value is already set to " + set.name().toLowerCase());
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class EnumArgument<T extends Enum<T>> implements ArgumentType<T> {
private final Class<T> enumClass;
private final boolean lowercase;

@SuppressWarnings({"unchecked", "rawtypes"})
public static void init() {
Util.registerArgument(EnumArgument.class, new EnumArgument.Info(), CreateUnlimited.asResource("enumargument"));
}
Expand All @@ -68,6 +69,10 @@ public T parse(final StringReader reader) throws CommandSyntaxException {
}
}

public static <R extends Enum<R>> R getEnum(CommandContext<?> context, String name, Class<R> enumClass) {
return context.getArgument(name, enumClass);
}

@Override
public <S> CompletableFuture<Suggestions> listSuggestions(final CommandContext<S> context, final SuggestionsBuilder builder) {
return SharedSuggestionProvider.suggest(Stream.of(enumClass.getEnumConstants()).map(Enum::name).map(this::lowercase), builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Mixin(value = CTrains.class, remap = false)
public abstract class CTrainsMixin {
@ModifyConstant(method = "<init>", constant = @Constant(intValue = 128, ordinal = 0))
private int modifyMaxTrackPlacementLength(int par1) {
private int modifyMaxTrackPlacementLength(int original) {
CreateUnlimited.LOGGER.info("CTrains config override loaded (probably)");
return Integer.MAX_VALUE;
}
Expand Down
5 changes: 2 additions & 3 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ dependencies {

modImplementation("com.simibubi.create:create-fabric-${rootProject.minecraft_version}:${rootProject.create_fabric}+mc${rootProject.minecraft_version}")

if(rootProject.hasProperty('snr')) {
modImplementation("com.railwayteam.railways:Steam_Rails-fabric-${minecraft_version}:${snr}+fabric-mc${minecraft_version}-build.${snr_build}") { transitive = false }
}
// have deprecated modules present at runtime only
modLocalRuntime "net.fabricmc.fabric-api:fabric-api-deprecated:${rootProject.fabric_api}+${rootProject.minecraft_version}"

// Dev Env Optimizations
if (rootProject.hasProperty("lazydfu")) {
Expand Down
4 changes: 0 additions & 4 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ dependencies {

include "com.github.LlamaLad7:MixinExtras:${rootProject.mixin_extras}"

if(rootProject.hasProperty('snr')) {
modImplementation("com.railwayteam.railways:Steam_Rails-forge-${minecraft_version}:${snr}+forge-mc${minecraft_version}-build.${snr_build}")
}

// Dev Env Optimizations
if (rootProject.hasProperty("bmb")) {
modRuntimeOnly "curse.maven:better-mods-button-541584:${rootProject.bmb}"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ forgix_version = 1.2.6
shadow_version = 8.1.1

# the mc version to compile against (see their respective property files for version-specific stuff)
mcVer = 1.19.2
mcVer = 1.20.1

# the actual stuff
mod_version = 0.5.0
Expand Down
2 changes: 1 addition & 1 deletion versionProperties/1.19.2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ forge=43.2.4
# https://mvn.devos.one/#/snapshots/com/simibubi/create/create-fabric-1.19.2
create_fabric = 0.5.1-c-build.1160
# https://github.com/Creators-of-Create/Create/wiki/Depending-on-Create
create_forge = 0.5.1.e-44
create_forge = 0.5.1.f-46
registrate = MC1.19-1.1.5
flywheel_mc = 1.19.2
flywheel = 0.6.10-20
Expand Down
2 changes: 1 addition & 1 deletion versionProperties/1.20.1.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ forge = 47.1.43
# https://mvn.devos.one/#/snapshots/com/simibubi/create/create-fabric-1.20.1
create_fabric = 0.5.1-d-build.1161
# https://github.com/Creators-of-Create/Create/wiki/Depending-on-Create
create_forge = 0.5.1.e-22
create_forge = 0.5.1.f-26
registrate = MC1.20-1.3.3
flywheel_mc = 1.20.1
flywheel = 0.6.10-7
Expand Down

0 comments on commit efd243b

Please sign in to comment.