mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-30 13:13:00 +00:00 
			
		
		
		
	Update to latest Forge
This fixes the issue with DeferredRegister crashing on non-wrapped registries.
This commit is contained in:
		| @@ -4,7 +4,7 @@ | ||||
| # MC version is specified in gradle.properties, as we need that in settings.gradle. | ||||
| fabric-api = "0.68.1+1.19.3" | ||||
| fabric-loader = "0.14.11" | ||||
| forge = "44.0.0" | ||||
| forge = "44.0.18" | ||||
| forgeSpi = "6.0.0" | ||||
| mixin = "0.8.5" | ||||
| parchment = "2022.11.27" | ||||
| @@ -15,14 +15,13 @@ asm = "9.3" | ||||
| autoService = "1.0.1" | ||||
| checkerFramework = "3.12.0" | ||||
| cobalt = "0.5.8" | ||||
| fastutil = "8.5.6" | ||||
| guava = "31.0.1-jre" | ||||
| fastutil = "8.5.9" | ||||
| guava = "31.1-jre" | ||||
| jetbrainsAnnotations = "23.0.0" | ||||
| jsr305 = "3.0.2" | ||||
| kotlin = "1.7.10" | ||||
| kotlin-coroutines = "1.6.0" | ||||
| logback = "1.2.11" | ||||
| netty = "4.1.77.Final" | ||||
| netty = "4.1.82.Final" | ||||
| nightConfig = "3.6.5" | ||||
| slf4j = "1.7.36" | ||||
|  | ||||
| @@ -107,7 +106,7 @@ jqwik-engine = { module = "net.jqwik:jqwik-engine", version.ref = "jqwik" } | ||||
| junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" } | ||||
| junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" } | ||||
| junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" } | ||||
| logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } | ||||
| slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" } | ||||
|  | ||||
| # Build tools | ||||
| cctJavadoc = { module = "cc.tweaked:cct-javadoc", version.ref = "cctJavadoc" } | ||||
|   | ||||
| @@ -25,7 +25,7 @@ dependencies { | ||||
|  | ||||
|     testImplementation(libs.bundles.test) | ||||
|     testRuntimeOnly(libs.bundles.testRuntime) | ||||
|     testRuntimeOnly(libs.logback) | ||||
|     testRuntimeOnly(libs.slf4j.simple) | ||||
| } | ||||
|  | ||||
| tasks.processResources { | ||||
|   | ||||
| @@ -21,7 +21,7 @@ class TestHttpApi { | ||||
|         @JvmStatic | ||||
|         @BeforeAll | ||||
|         fun before() { | ||||
|             CoreConfig.httpRules = listOf(AddressRule.parse("*", null, Action.ALLOW.toPartial())) | ||||
|             CoreConfig.httpRules = listOf(AddressRule.parse("*", OptionalInt.empty(), Action.ALLOW.toPartial())) | ||||
|         } | ||||
| 
 | ||||
|         @JvmStatic | ||||
| @@ -29,8 +29,8 @@ class TestHttpApi { | ||||
|         fun after() { | ||||
|             CoreConfig.httpRules = Collections.unmodifiableList( | ||||
|                 listOf( | ||||
|                     AddressRule.parse("\$private", null, Action.DENY.toPartial()), | ||||
|                     AddressRule.parse("*", null, Action.ALLOW.toPartial()), | ||||
|                     AddressRule.parse("\$private", OptionalInt.empty(), Action.DENY.toPartial()), | ||||
|                     AddressRule.parse("*", OptionalInt.empty(), Action.ALLOW.toPartial()), | ||||
|                 ), | ||||
|             ) | ||||
|         } | ||||
|   | ||||
| @@ -65,9 +65,10 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | ||||
| import net.minecraftforge.items.wrapper.InvWrapper; | ||||
| import net.minecraftforge.items.wrapper.SidedInvWrapper; | ||||
| import net.minecraftforge.network.NetworkHooks; | ||||
| import net.minecraftforge.registries.DeferredRegister; | ||||
| import net.minecraftforge.registries.ForgeRegistry; | ||||
| import net.minecraftforge.registries.RegisterEvent; | ||||
| import net.minecraftforge.registries.RegistryManager; | ||||
| import net.minecraftforge.registries.RegistryObject; | ||||
| 
 | ||||
| import javax.annotation.Nullable; | ||||
| import java.util.*; | ||||
| @@ -99,7 +100,7 @@ public class PlatformHelperImpl implements PlatformHelper { | ||||
| 
 | ||||
|     @Override | ||||
|     public <T> RegistrationHelper<T> createRegistrationHelper(ResourceKey<Registry<T>> registry) { | ||||
|         return new RegistrationHelperImpl<>(registry); | ||||
|         return new RegistrationHelperImpl<>(DeferredRegister.create(registry, ComputerCraftAPI.MOD_ID)); | ||||
|     } | ||||
| 
 | ||||
|     @Nullable | ||||
| @@ -366,55 +367,27 @@ public class PlatformHelperImpl implements PlatformHelper { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // TODO: Switch back to using a DeferredRegistry: Right now it's broken for some registry types. | ||||
|     private static final class RegistrationHelperImpl<T> implements RegistrationHelper<T> { | ||||
|         private final ResourceKey<Registry<T>> registry; | ||||
|         private final List<RegistryEntryImpl<? extends T>> entries = new ArrayList<>(); | ||||
| 
 | ||||
|         private RegistrationHelperImpl(ResourceKey<Registry<T>> registry) { | ||||
|             this.registry = registry; | ||||
|         } | ||||
| 
 | ||||
|     private record RegistrationHelperImpl<T>(DeferredRegister<T> registry) implements RegistrationHelper<T> { | ||||
|         @Override | ||||
|         public <U extends T> RegistryEntry<U> register(String name, Supplier<U> create) { | ||||
|             var entry = new RegistryEntryImpl<>(new ResourceLocation(ComputerCraftAPI.MOD_ID, name), create); | ||||
|             entries.add(entry); | ||||
|             return entry; | ||||
|             return new RegistryEntryImpl<>(registry().register(name, create)); | ||||
|         } | ||||
| 
 | ||||
|         @Override | ||||
|         public void register() { | ||||
|             FMLJavaModLoadingContext.get().getModEventBus().addListener((RegisterEvent event) -> { | ||||
|                 event.register(registry, helper -> { | ||||
|                     for (var object : entries) object.register(helper); | ||||
|                 }); | ||||
|             }); | ||||
|             registry().register(FMLJavaModLoadingContext.get().getModEventBus()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private static final class RegistryEntryImpl<T> implements RegistryEntry<T> { | ||||
|         private final ResourceLocation id; | ||||
|         private final Supplier<T> supplier; | ||||
|         private @Nullable T instance; | ||||
| 
 | ||||
|         RegistryEntryImpl(ResourceLocation id, Supplier<T> supplier) { | ||||
|             this.id = id; | ||||
|             this.supplier = supplier; | ||||
|         } | ||||
| 
 | ||||
|         void register(RegisterEvent.RegisterHelper<? super T> registry) { | ||||
|             registry.register(id, instance = supplier.get()); | ||||
|         } | ||||
| 
 | ||||
|     private record RegistryEntryImpl<T>(RegistryObject<T> object) implements RegistryEntry<T> { | ||||
|         @Override | ||||
|         public ResourceLocation id() { | ||||
|             return id; | ||||
|             return object().getId(); | ||||
|         } | ||||
| 
 | ||||
|         @Override | ||||
|         public T get() { | ||||
|             if (instance == null) throw new IllegalStateException(id + " has not been constructed yet"); | ||||
|             return instance; | ||||
|             return object().get(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates