1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-25 02:47:39 +00:00

Fabric lol

- Add support for Fabric. This is mostly pretty simple, though does
   require a lot more mixins than Forge.

   Half this diff is due to data generators: we run them separately as
   some aspects (recipes mostly) are different between the loaders.

 - Add integration with Iris (same as our Oculus support) and REI
   (mostly the same as our JEI support).

 - Generic peripherals only support inventories (or rather
   InventoryStorage) right now. Supporting more of the Fabric storage
   API is going to be tricky due to the slotted nature of the API: maybe
   something to revisit after Transfer API V3 (V4?, I've lost track).

Note, this does /not/ mean I will be publishing a Fabric version of
CC:T. My plan is to rebase CC:R on top of this, hopefully simplifying
the maintenance work on their end and making the two mods a little more
consistent.
This commit is contained in:
Jonathan Coates
2022-11-10 19:32:13 +00:00
parent b2b58892e3
commit 8152f19b6e
363 changed files with 7264 additions and 75 deletions

View File

@@ -6,11 +6,19 @@
package dan200.computercraft.mixin;
import net.minecraft.world.item.CreativeModeTab;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(CreativeModeTab.class)
public interface CreativeModeTabAccessor {
@Accessor("langId")
String computercraft$langId();
@Final
@Mutable
@Accessor("TABS")
static void computercraft$setTabs(CreativeModeTab[] tabs) {
}
}

View File

@@ -18,6 +18,8 @@ import net.minecraftforge.fml.config.ModConfig;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.filter.MarkerFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
@@ -25,6 +27,8 @@ import java.util.Objects;
import java.util.concurrent.TimeUnit;
public final class ConfigSpec {
private static final Logger LOG = LoggerFactory.getLogger(ConfigSpec.class);
private static final int MODEM_MAX_RANGE = 100000;
private static final String TRANSLATION_PREFIX = "gui.computercraft.config.";
@@ -337,6 +341,8 @@ public final class ConfigSpec {
}
private static void syncServer() {
if (!serverSpec.isLoaded()) return;
// General
Config.computerSpaceLimit = computerSpaceLimit.get();
Config.floppySpaceLimit = floppySpaceLimit.get();
@@ -399,6 +405,8 @@ public final class ConfigSpec {
}
private static void syncClient() {
if (!clientSpec.isLoaded()) return;
Config.monitorRenderer = monitorRenderer.get();
Config.monitorDistance = monitorDistance.get();
Config.uploadNagDelay = uploadNagDelay.get();
@@ -406,7 +414,17 @@ public final class ConfigSpec {
public static void sync(ModConfig config) {
if (!config.getModId().equals(ComputerCraftAPI.MOD_ID)) return;
if (config.getType() == ModConfig.Type.SERVER) syncServer();
if (config.getType() == ModConfig.Type.CLIENT) syncClient();
try {
if (config.getType() == ModConfig.Type.SERVER) syncServer();
if (config.getType() == ModConfig.Type.CLIENT) syncClient();
} catch (IllegalStateException e) {
// TODO: Remove when https://github.com/Fuzss/forgeconfigapiport-fabric/issues/26 is fixed.
if (e.getMessage() != null && e.getMessage().startsWith("Cannot get config value before config is loaded.")) {
return;
}
throw e;
}
}
}