Dirty casting hacks to fix eclipse compiler inference issue. I'm sorry cpw.

This commit is contained in:
LexManos 2020-09-02 21:15:16 -07:00
parent 7dbae7ea4a
commit 3820d1b66f
2 changed files with 4 additions and 3 deletions

View file

@ -50,7 +50,8 @@ public enum ModLoadingStage
ERROR(),
VALIDATE(),
CONSTRUCT(FMLConstructModEvent.class),
CREATE_REGISTRIES(()->Stream.of(RegistryEvent.NewRegistry::new), EventDispatcher.identity()),
@SuppressWarnings({ "unchecked", "rawtypes" }) //Eclipse compiler generics issue. Sorry cpw, your nested generics can't be inferred
CREATE_REGISTRIES((Supplier)()->Stream.of((Function<ModContainer, IModBusEvent>)RegistryEvent.NewRegistry::new), EventDispatcher.identity()),
LOAD_REGISTRIES(GameData::generateRegistryEvents, GameData.buildRegistryEventDispatch()),
COMMON_SETUP(FMLCommonSetupEvent.class),
SIDED_SETUP(DistExecutor.unsafeRunForDist(()->()->FMLClientSetupEvent.class, ()->()->FMLDedicatedServerSetupEvent.class)),
@ -79,7 +80,6 @@ public enum ModLoadingStage
}, e);
}
@SuppressWarnings("unchecked")
<T extends Event & IModBusEvent> ModLoadingStage(Supplier<Stream<EventGenerator<?>>> eventStream, EventDispatcher<?> eventManager) {
this.eventFunctionStream = eventStream;
this.parallelEventClass = Optional.empty();

View file

@ -327,6 +327,7 @@ public class GameData
LOGGER.debug(REGISTRIES, "Reverting complete");
}
@SuppressWarnings("rawtypes") //Eclipse compiler generics issue.
public static Stream<ModLoadingStage.EventGenerator<?>> generateRegistryEvents() {
List<ResourceLocation> keys = Lists.newArrayList(RegistryManager.ACTIVE.registries.keySet());
keys.sort((o1, o2) -> String.valueOf(o1).compareToIgnoreCase(String.valueOf(o2)));
@ -338,7 +339,7 @@ public class GameData
keys.add(0, BLOCKS.func_240901_a_());
keys.add(1, ITEMS.func_240901_a_());
return keys.stream().map(rl -> mc -> RegistryManager.ACTIVE.getRegistry(rl).getRegisterEvent(rl));
return keys.stream().map(rl -> (ModLoadingStage.EventGenerator)(mc -> RegistryManager.ACTIVE.getRegistry(rl).getRegisterEvent(rl)));
}
public static ModLoadingStage.EventDispatcher<RegistryEvent.Register<?>> buildRegistryEventDispatch() {