mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-25 00:16:54 +00:00
Udpate to latest Neo, Fabric and Parchment
- Update to latest NeoForge, fixing issues with config API changes. Closes #1903. - Update to latest Fabric, switching to the ender pearl conventional tag, and new loot API.
This commit is contained in:
parent
2c740bb904
commit
2765abf971
@ -7,13 +7,13 @@
|
||||
# Minecraft
|
||||
# MC version is specified in gradle.properties, as we need that in settings.gradle.
|
||||
# Remember to update corresponding versions in fabric.mod.json/neoforge.mods.toml
|
||||
fabric-api = "0.100.3+1.21"
|
||||
fabric-api = "0.100.7+1.21"
|
||||
fabric-loader = "0.15.11"
|
||||
neoForge = "21.0.42-beta"
|
||||
neoForge = "21.0.143"
|
||||
neoForgeSpi = "8.0.1"
|
||||
mixin = "0.8.5"
|
||||
parchment = "2024.06.16"
|
||||
parchmentMc = "1.20.6"
|
||||
parchment = "2024.07.28"
|
||||
parchmentMc = "1.21"
|
||||
yarn = "1.21+build.1"
|
||||
|
||||
# Core dependencies (these versions are tied to the version Minecraft uses)
|
||||
|
@ -31,7 +31,7 @@ abstract class ItemStackComponentizationFixMixin extends DataFix {
|
||||
}
|
||||
|
||||
@Inject(method = "fixItemStack", at = @At("TAIL"))
|
||||
@SuppressWarnings("UnusedMethod")
|
||||
@SuppressWarnings("unused")
|
||||
private static void fixItemStack(ItemStackComponentizationFix.ItemStackData data, Dynamic<?> ops, CallbackInfo ci) {
|
||||
ComponentizationFixers.fixItemComponents(data, ops);
|
||||
}
|
||||
|
@ -69,6 +69,13 @@ class AddressRuleConfig {
|
||||
);
|
||||
}
|
||||
|
||||
public static UnmodifiableConfig newRule() {
|
||||
return makeRule(config -> {
|
||||
config.add("host", "example.com");
|
||||
config.add("action", Action.DENY.name().toLowerCase(Locale.ROOT));
|
||||
});
|
||||
}
|
||||
|
||||
private static UnmodifiableConfig makeRule(Consumer<CommentedConfig> setup) {
|
||||
var config = InMemoryCommentedFormat.defaultInstance().createConfig(LinkedHashMap::new);
|
||||
setup.accept(config);
|
||||
|
@ -126,7 +126,7 @@ public interface ConfigFile {
|
||||
|
||||
public abstract ConfigFile.Value<Integer> defineInRange(String path, int defaultValue, int min, int max);
|
||||
|
||||
public abstract <T> ConfigFile.Value<List<? extends T>> defineList(String path, List<? extends T> defaultValue, Predicate<Object> elementValidator);
|
||||
public abstract <T> ConfigFile.Value<List<? extends T>> defineList(String path, List<? extends T> defaultValue, Supplier<T> newValue, Predicate<Object> elementValidator);
|
||||
|
||||
public abstract <V extends Enum<V>> ConfigFile.Value<V> defineEnum(String path, V defaultValue);
|
||||
|
||||
|
@ -145,7 +145,7 @@ public final class ConfigSpec {
|
||||
or a single method (computercraft:inventory#pushItems).
|
||||
""")
|
||||
.worldRestart()
|
||||
.defineList("disabled_generic_methods", List.of(), x -> x instanceof String);
|
||||
.defineList("disabled_generic_methods", List.of(), () -> "", x -> x instanceof String);
|
||||
}
|
||||
|
||||
{
|
||||
@ -214,7 +214,7 @@ public final class ConfigSpec {
|
||||
- "max_websocket_message" (optional): The maximum size (in bytes) that a computer can send or
|
||||
receive in one websocket packet.
|
||||
- "use_proxy" (optional): Enable use of the HTTP/SOCKS proxy if it is configured.""")
|
||||
.defineList("rules", AddressRuleConfig.defaultRules(), x -> x instanceof UnmodifiableConfig);
|
||||
.defineList("rules", AddressRuleConfig.defaultRules(), AddressRuleConfig::newRule, x -> x instanceof UnmodifiableConfig);
|
||||
|
||||
httpMaxRequests = builder
|
||||
.comment("""
|
||||
|
@ -15,17 +15,17 @@ import java.util.function.Function;
|
||||
* A custom version of {@link ShapedRecipe}, which can be converted to and from a {@link ShapedRecipeSpec}.
|
||||
*/
|
||||
public abstract class CustomShapedRecipe extends ShapedRecipe {
|
||||
private final ShapedRecipePattern pattern;
|
||||
private final ShapedRecipePattern shapedPattern;
|
||||
private final ItemStack result;
|
||||
|
||||
public CustomShapedRecipe(ShapedRecipeSpec recipe) {
|
||||
super(recipe.properties().group(), recipe.properties().category(), recipe.pattern(), recipe.result(), recipe.properties().showNotification());
|
||||
this.pattern = recipe.pattern();
|
||||
this.shapedPattern = recipe.pattern();
|
||||
this.result = recipe.result();
|
||||
}
|
||||
|
||||
public final ShapedRecipeSpec toSpec() {
|
||||
return new ShapedRecipeSpec(RecipeProperties.of(this), pattern, result);
|
||||
return new ShapedRecipeSpec(RecipeProperties.of(this), shapedPattern, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"category": "redstone",
|
||||
"key": {"#": {"item": "minecraft:stone"}, "E": {"item": "minecraft:ender_pearl"}},
|
||||
"pattern": ["###", "#E#", "###"],
|
||||
"result": {"count": 1, "id": "computercraft:wireless_modem_normal"}
|
||||
}
|
@ -36,7 +36,7 @@ import net.fabricmc.fabric.api.event.registry.DynamicRegistries;
|
||||
import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder;
|
||||
import net.fabricmc.fabric.api.event.registry.RegistryAttribute;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
|
||||
import net.fabricmc.fabric.api.loot.v3.LootTableEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
|
||||
@ -122,7 +122,7 @@ public class ComputerCraft {
|
||||
PlayerBlockBreakEvents.BEFORE.register(FabricCommonHooks::onBlockDestroy);
|
||||
UseBlockCallback.EVENT.register(FabricCommonHooks::useOnBlock);
|
||||
|
||||
LootTableEvents.MODIFY.register((id, tableBuilder, source) -> {
|
||||
LootTableEvents.MODIFY.register((id, tableBuilder, source, registries) -> {
|
||||
var pool = CommonHooks.getExtraLootPool(id);
|
||||
if (pool != null) tableBuilder.withPool(pool);
|
||||
});
|
||||
|
@ -23,6 +23,7 @@ import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -203,7 +204,7 @@ public class FabricConfigFile implements ConfigFile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Value<List<? extends T>> defineList(String path, List<? extends T> defaultValue, Predicate<Object> elementValidator) {
|
||||
public <T> Value<List<? extends T>> defineList(String path, List<? extends T> defaultValue, Supplier<T> newValue, Predicate<Object> elementValidator) {
|
||||
var fullPath = getFullPath(path);
|
||||
spec.defineList(fullPath, defaultValue, elementValidator);
|
||||
return defineValue(fullPath, takeComment(), defaultValue, Config::getOrElse);
|
||||
|
@ -148,7 +148,7 @@ public class PlatformHelperImpl implements PlatformHelper {
|
||||
Ingredient.of(ConventionalItemTags.STORAGE_BLOCKS_GOLD),
|
||||
Ingredient.of(ConventionalItemTags.IRON_INGOTS),
|
||||
Ingredient.of(ConventionalItemTags.DYES),
|
||||
Ingredient.of(Items.ENDER_PEARL),
|
||||
Ingredient.of(ConventionalItemTags.ENDER_PEARLS),
|
||||
Ingredient.of(ConventionalItemTags.WOODEN_CHESTS)
|
||||
);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.15.10",
|
||||
"fabric-api": ">=0.100.3",
|
||||
"fabric-api": ">=0.100.5",
|
||||
"minecraft": "=1.21"
|
||||
},
|
||||
"accessWidener": "computercraft.accesswidener"
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package dan200.computercraft;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.FileConfig;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.ForgeComputerCraftAPI;
|
||||
import dan200.computercraft.api.detail.ForgeDetailRegistries;
|
||||
@ -171,8 +170,7 @@ public final class ComputerCraft {
|
||||
private static void syncConfig(ModConfig config) {
|
||||
if (!config.getModId().equals(ComputerCraftAPI.MOD_ID)) return;
|
||||
|
||||
var path = config.getConfigData() instanceof FileConfig fileConfig ? fileConfig.getNioPath() : null;
|
||||
|
||||
var path = config.getFullPath();
|
||||
if (config.getType() == ModConfig.Type.SERVER && ((ForgeConfigFile) ConfigSpec.serverSpec).spec().isLoaded()) {
|
||||
ConfigSpec.syncServer(path);
|
||||
} else if (config.getType() == ModConfig.Type.CLIENT) {
|
||||
|
@ -11,7 +11,9 @@ import net.neoforged.neoforge.common.ModConfigSpec;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
@ -105,9 +107,9 @@ public final class ForgeConfigFile implements ConfigFile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ConfigFile.Value<List<? extends T>> defineList(String path, List<? extends T> defaultValue, Predicate<Object> elementValidator) {
|
||||
public <T> ConfigFile.Value<List<? extends T>> defineList(String path, List<? extends T> defaultValue, Supplier<T> newValue, Predicate<Object> elementValidator) {
|
||||
translation(path);
|
||||
return defineValue(builder.defineList(path, defaultValue, elementValidator));
|
||||
return defineValue(builder.defineList(path, defaultValue, newValue, elementValidator));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -168,12 +170,12 @@ public final class ForgeConfigFile implements ConfigFile {
|
||||
|
||||
@Override
|
||||
public String translationKey() {
|
||||
return spec().getTranslationKey();
|
||||
return Objects.requireNonNull(spec().getTranslationKey(), "No comment for value");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String comment() {
|
||||
return spec().getComment();
|
||||
return Objects.requireNonNull(spec().getComment(), "No comment for value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user