mirror of
https://github.com/TicTicBoooom-Mods/MasterfulMachinery.git
synced 2026-03-18 21:40:34 +01:00
added mod bus even t for registration of 3rd party port-types
This commit is contained in:
@@ -11,6 +11,8 @@ import com.ticticboooom.mods.mm.client.screen.ControllerBlockContainerScreen;
|
||||
import com.ticticboooom.mods.mm.client.screen.PortBlockContainerScreen;
|
||||
import com.ticticboooom.mods.mm.client.screen.StructureGenBlockContainerScreen;
|
||||
import com.ticticboooom.mods.mm.client.ter.StructureGenTileEntityRenderer;
|
||||
import com.ticticboooom.mods.mm.event.MMPortEventHandler;
|
||||
import com.ticticboooom.mods.mm.event.MMPortRegistrationEvent;
|
||||
import com.ticticboooom.mods.mm.datagen.MMPackFinder;
|
||||
import com.ticticboooom.mods.mm.datagen.DataGeneratorFactory;
|
||||
import com.ticticboooom.mods.mm.datagen.PackType;
|
||||
@@ -59,8 +61,6 @@ public class MM {
|
||||
|
||||
public MM() {
|
||||
instance = this;
|
||||
MMPorts.init();
|
||||
MMLoader.load();
|
||||
DataGeneratorFactory.init();
|
||||
PacketHandler.init();
|
||||
registerDataGen();
|
||||
@@ -72,13 +72,13 @@ public class MM {
|
||||
RecipeTypes.RECIPE_SERIALIZERS.register(bus);
|
||||
bus.addListener(this::clientEvents);
|
||||
try {
|
||||
|
||||
if (FMLEnvironment.dist == Dist.CLIENT) {
|
||||
Minecraft.getInstance().getResourcePackList().addPackFinder(new MMPackFinder(PackType.RESOURCE));
|
||||
if (FMLEnvironment.dist == Dist.CLIENT) {
|
||||
Minecraft.getInstance().getResourcePackList().addPackFinder(new MMPackFinder(PackType.RESOURCE));
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch(Exception ignored){
|
||||
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.addListener(this::onServerStart);
|
||||
}
|
||||
|
||||
@@ -87,15 +87,17 @@ public class MM {
|
||||
ExistingFileHelper existingFileHelper = new ExistingFileHelper(ImmutableList.of(), ImmutableSet.of(), false);
|
||||
generator.addProvider(new MMLootTableProvider(generator));
|
||||
|
||||
if (FMLEnvironment.dist != Dist.DEDICATED_SERVER){
|
||||
if (FMLEnvironment.dist != Dist.DEDICATED_SERVER) {
|
||||
generator.addProvider(new MMBlockStateProvider(generator, existingFileHelper));
|
||||
generator.addProvider(new MMItemModelProvider(generator, existingFileHelper));
|
||||
generator.addProvider(new MMLangProvider(generator));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void generate() {
|
||||
if(!hasGenerated) {
|
||||
if (!hasGenerated) {
|
||||
try {
|
||||
instance.generator.run();
|
||||
} catch (IOException e) {
|
||||
@@ -105,10 +107,12 @@ public class MM {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onServerStart(final FMLServerAboutToStartEvent event) {
|
||||
event.getServer().getResourcePacks().addPackFinder(new MMPackFinder(PackType.DATA));
|
||||
}
|
||||
|
||||
|
||||
private void clientEvents(final FMLClientSetupEvent event) {
|
||||
|
||||
for (RegistryObject<ContainerType<ControllerBlockContainer>> container : MMLoader.CONTAINERS) {
|
||||
@@ -137,8 +141,8 @@ public class MM {
|
||||
ClientRegistry.bindTileEntityRenderer(MMSetup.STRUCTURE_TILE.get(), StructureGenTileEntityRenderer::new);
|
||||
}
|
||||
|
||||
public static void injectDatapackFinder (ResourcePackList resourcePacks) {
|
||||
if (DistExecutor.unsafeRunForDist( () -> () -> resourcePacks != Minecraft.getInstance().getResourcePackList(), () -> () -> true)) {
|
||||
public static void injectDatapackFinder(ResourcePackList resourcePacks) {
|
||||
if (DistExecutor.unsafeRunForDist(() -> () -> resourcePacks != Minecraft.getInstance().getResourcePackList(), () -> () -> true)) {
|
||||
resourcePacks.addPackFinder(new MMPackFinder(PackType.RESOURCE));
|
||||
MM.LOG.info("Injecting data pack finder.");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ticticboooom.mods.mm.event;
|
||||
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.registration.MMLoader;
|
||||
import com.ticticboooom.mods.mm.registration.MMPorts;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MM.ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ConstructEventHandler {
|
||||
@SubscribeEvent
|
||||
public static void onConstruct(FMLConstructModEvent event) {
|
||||
FMLJavaModLoadingContext.get().getModEventBus().post(new MMPortRegistrationEvent(MMPorts.PORTS));
|
||||
MMLoader.load();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ticticboooom.mods.mm.event;
|
||||
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.registration.MMPorts;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MM.ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class MMPortEventHandler {
|
||||
@SubscribeEvent
|
||||
public static void onMMPorts(MMPortRegistrationEvent event) {
|
||||
MMPorts.init();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ticticboooom.mods.mm.core;
|
||||
package com.ticticboooom.mods.mm.event;
|
||||
|
||||
import com.ticticboooom.mods.mm.ports.MasterfulPortType;
|
||||
import lombok.Getter;
|
||||
@@ -8,7 +8,7 @@ import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class MMPortRegistrationEvent extends Event {
|
||||
public class MMPortRegistrationEvent extends Event implements IModBusEvent {
|
||||
@Getter
|
||||
private Map<ResourceLocation, MasterfulPortType> portsMap;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#Tue Jul 13 03:35:05 BST 2021
|
||||
VERSION_CODE=553
|
||||
#Tue Jul 13 16:42:54 BST 2021
|
||||
VERSION_CODE=639
|
||||
|
||||
Reference in New Issue
Block a user