Main class work and nulled out the RegistryHandler

This commit is contained in:
Michael 2020-09-09 16:10:55 +01:00
parent 47f11f0287
commit 69df7e0e81
No known key found for this signature in database
GPG key ID: 971C5B254742488F
5 changed files with 150 additions and 119 deletions

View file

@ -0,0 +1,4 @@
package de.ellpeck.actuallyadditions.client;
public class ClientSetup {
}

View file

@ -1,10 +1,8 @@
package de.ellpeck.actuallyadditions.common; package de.ellpeck.actuallyadditions.common;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.booklet.InitBooklet; import de.ellpeck.actuallyadditions.booklet.InitBooklet;
import de.ellpeck.actuallyadditions.common.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.common.config.ConfigurationHandler; import de.ellpeck.actuallyadditions.common.config.ConfigurationHandler;
import de.ellpeck.actuallyadditions.common.crafting.CrusherCrafting; import de.ellpeck.actuallyadditions.common.crafting.CrusherCrafting;
import de.ellpeck.actuallyadditions.common.data.WorldData; import de.ellpeck.actuallyadditions.common.data.WorldData;
@ -31,47 +29,96 @@ import de.ellpeck.actuallyadditions.common.recipe.TreasureChestHandler;
import de.ellpeck.actuallyadditions.common.tile.TileEntityBase; import de.ellpeck.actuallyadditions.common.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.common.update.UpdateChecker; import de.ellpeck.actuallyadditions.common.update.UpdateChecker;
import de.ellpeck.actuallyadditions.common.util.compat.CompatUtil; import de.ellpeck.actuallyadditions.common.util.compat.CompatUtil;
import net.minecraft.launchwrapper.Launch; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartedEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppedEvent;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@Mod(modid = ActuallyAdditions.MODID, name = ActuallyAdditions.NAME, version = ActuallyAdditions.VERSION, guiFactory = ActuallyAdditions.GUIFACTORY, dependencies = ActuallyAdditions.DEPS) @Mod(ActuallyAdditions.MODID)
public class ActuallyAdditions { public class ActuallyAdditions {
public static final String MODID = ActuallyAdditionsAPI.MOD_ID; public static final String MODID = ActuallyAdditionsAPI.MOD_ID;
public static final String NAME = "Actually Additions"; public static final String NAME = "Actually Additions";
public static final String VERSION = "@VERSION@"; // public static final String VERSION = "@VERSION@";
public static final String GUIFACTORY = "de.ellpeck.actuallyadditions.common.config.GuiFactory"; // public static final String GUIFACTORY = "de.ellpeck.actuallyadditions.common.config.GuiFactory";
public static final String DEPS = "required:forge@[14.23.5.2836,);before:craftingtweaks;after:fastbench@[1.3.2,)"; // public static final String DEPS = "required:forge@[14.23.5.2836,);before:craftingtweaks;after:fastbench@[1.3.2,)";
public static final boolean DEOBF = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); // public static final boolean DEOBF = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
@Instance public static final Logger LOGGER = LogManager.getLogger(MODID);
public static ActuallyAdditions INSTANCE; public static ActuallyAdditions INSTANCE;
public static boolean commonCapsLoaded = false;
// Creative Tab
public static ItemGroup aaGroup = new ItemGroup(MODID) {
@Override
public ItemStack createIcon() {
return new ItemStack(Items.PACKED_ICE); // placeholder until I've done the actual stuff @todo
}
};
public ActuallyAdditions() {
INSTANCE = this;
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
// Register registers
InitBlocks.BLOCKS.register(bus);
bus.addListener(this::setup);
bus.addListener(this::clientSetup);
MinecraftForge.EVENT_BUS.register(this);
}
private void setup(final FMLCommonSetupEvent event) {
}
private void clientSetup(final FMLClientSetupEvent event) {
}
@SubscribeEvent
public void serverStarted(FMLServerStartedEvent event) {
// todo: come back to this if it's still needed after migrating the world save to a newer version
// MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
// if (server != null) {
// World world = server.getEntityWorld();
// if (world != null && !world.isRemote) {
// WorldData.get(world, true).markDirty();
// }
// }
}
@SubscribeEvent
public void serverStopped(FMLServerStoppedEvent event) {
WorldData.clear();
}
@SidedProxy(clientSide = "de.ellpeck.actuallyadditions.common.proxy.ClientProxy", serverSide = "de.ellpeck.actuallyadditions.common.proxy.ServerProxy") @SidedProxy(clientSide = "de.ellpeck.actuallyadditions.common.proxy.ClientProxy", serverSide = "de.ellpeck.actuallyadditions.common.proxy.ServerProxy")
public static IProxy PROXY; public static IProxy PROXY;
public static final Logger LOGGER = LogManager.getLogger(NAME);
static { static {
FluidRegistry.enableUniversalBucket(); FluidRegistry.enableUniversalBucket();
} }
public static boolean commonCapsLoaded;
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent event) { public void preInit(FMLPreInitializationEvent event) {
@ -82,9 +129,9 @@ public class ActuallyAdditions {
Lenses.init(); Lenses.init();
InitBooklet.preInit(); InitBooklet.preInit();
CompatUtil.registerCraftingTweaks(); CompatUtil.registerCraftingTweaks();
commonCapsLoaded = Loader.isModLoaded("commoncapabilities");
MinecraftForge.EVENT_BUS.register(new RegistryHandler()); // commonCapsLoaded = Loader.isModLoaded("commoncapabilities");
// MinecraftForge.EVENT_BUS.register(new RegistryHandler());
new ConfigurationHandler(event.getSuggestedConfigurationFile()); new ConfigurationHandler(event.getSuggestedConfigurationFile());
PacketHandler.init(); PacketHandler.init();
@ -138,20 +185,4 @@ public class ActuallyAdditions {
ActuallyAdditions.LOGGER.info("PostInitialization Finished."); ActuallyAdditions.LOGGER.info("PostInitialization Finished.");
} }
@EventHandler
public void serverStarted(FMLServerStartedEvent event) {
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server != null) {
World world = server.getEntityWorld();
if (world != null && !world.isRemote) {
WorldData.get(world, true).markDirty();
}
}
}
@EventHandler
public void serverStopped(FMLServerStoppedEvent event) {
WorldData.clear();
}
} }

View file

@ -1,8 +1,5 @@
package de.ellpeck.actuallyadditions.common; package de.ellpeck.actuallyadditions.common;
import java.util.HashMap;
import java.util.Map;
import de.ellpeck.actuallyadditions.common.blocks.render.ActualCompostModel; import de.ellpeck.actuallyadditions.common.blocks.render.ActualCompostModel;
import de.ellpeck.actuallyadditions.common.blocks.render.CompostModel; import de.ellpeck.actuallyadditions.common.blocks.render.CompostModel;
import de.ellpeck.actuallyadditions.common.blocks.render.IHasModel; import de.ellpeck.actuallyadditions.common.blocks.render.IHasModel;
@ -10,7 +7,8 @@ import de.ellpeck.actuallyadditions.common.fluids.InitFluids;
import de.ellpeck.actuallyadditions.common.util.FluidStateMapper; import de.ellpeck.actuallyadditions.common.util.FluidStateMapper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -20,6 +18,9 @@ import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.HashMap;
import java.util.Map;
public class ClientRegistryHandler { public class ClientRegistryHandler {
public static final Map<ItemStack, ModelResourceLocation> MODEL_LOCATIONS_FOR_REGISTERING = new HashMap<>(); public static final Map<ItemStack, ModelResourceLocation> MODEL_LOCATIONS_FOR_REGISTERING = new HashMap<>();

View file

@ -1,78 +1,62 @@
package de.ellpeck.actuallyadditions.common; package de.ellpeck.actuallyadditions.common;
import java.util.ArrayList;
import java.util.List;
import de.ellpeck.actuallyadditions.common.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.common.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.common.crafting.InitCrafting;
import de.ellpeck.actuallyadditions.common.gen.village.InitVillager;
import de.ellpeck.actuallyadditions.common.items.InitItems;
import de.ellpeck.actuallyadditions.common.misc.SoundHandler;
import de.ellpeck.actuallyadditions.common.ore.InitOreDict;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.event.RegistryEvent.Register;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
//Class to wrap around the trainwreck that is the new registry system //Class to wrap around the trainwreck that is the new registry system
// @todo: remove this completely
@Deprecated
public class RegistryHandler { public class RegistryHandler {
//
public static final List<Block> BLOCKS_TO_REGISTER = new ArrayList<>(); // public static final List<Block> BLOCKS_TO_REGISTER = new ArrayList<>();
public static final List<Item> ITEMS_TO_REGISTER = new ArrayList<>(); // public static final List<Item> ITEMS_TO_REGISTER = new ArrayList<>();
public static final List<SoundEvent> SOUNDS_TO_REGISTER = new ArrayList<>(); // public static final List<SoundEvent> SOUNDS_TO_REGISTER = new ArrayList<>();
public static final List<IRecipe> RECIPES_TO_REGISTER = new ArrayList<>(); // public static final List<IRecipe> RECIPES_TO_REGISTER = new ArrayList<>();
//
@SubscribeEvent // @SubscribeEvent
public void onBlockRegistry(Register<Block> event) { // public void onBlockRegistry(Register<Block> event) {
InitBlocks.init(); // InitBlocks.init();
//
for (Block block : BLOCKS_TO_REGISTER) { // for (Block block : BLOCKS_TO_REGISTER) {
event.getRegistry().register(block); // event.getRegistry().register(block);
} // }
} // }
//
@SubscribeEvent // @SubscribeEvent
public void onItemRegistry(Register<Item> event) { // public void onItemRegistry(Register<Item> event) {
InitItems.init(); // InitItems.init();
//
for (Item item : ITEMS_TO_REGISTER) { // for (Item item : ITEMS_TO_REGISTER) {
event.getRegistry().register(item); // event.getRegistry().register(item);
} // }
ITEMS_TO_REGISTER.clear(); // ITEMS_TO_REGISTER.clear();
//
//Hack to make this register before recipes :> // //Hack to make this register before recipes :>
InitOreDict.init(); // InitOreDict.init();
} // }
//
@SubscribeEvent // @SubscribeEvent
public void onVillagerRegistry(Register<VillagerProfession> event) { // public void onVillagerRegistry(Register<VillagerProfession> event) {
InitVillager.init(); // InitVillager.init();
//
if (ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.jamProfession); // if (ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.jamProfession);
if (ConfigBoolValues.ENGINEER_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.engineerProfession); // if (ConfigBoolValues.ENGINEER_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.engineerProfession);
} // }
//
@SubscribeEvent // @SubscribeEvent
public void onCraftingRegistry(Register<IRecipe> event) { // public void onCraftingRegistry(Register<IRecipe> event) {
InitCrafting.init(); // InitCrafting.init();
//
for (IRecipe recipe : RECIPES_TO_REGISTER) { // for (IRecipe recipe : RECIPES_TO_REGISTER) {
event.getRegistry().register(recipe); // event.getRegistry().register(recipe);
} // }
RECIPES_TO_REGISTER.clear(); // RECIPES_TO_REGISTER.clear();
} // }
//
@SubscribeEvent // @SubscribeEvent
public void onSoundRegistry(Register<SoundEvent> event) { // public void onSoundRegistry(Register<SoundEvent> event) {
SoundHandler.init(); // SoundHandler.init();
//
for (SoundEvent sound : SOUNDS_TO_REGISTER) { // for (SoundEvent sound : SOUNDS_TO_REGISTER) {
event.getRegistry().register(sound); // event.getRegistry().register(sound);
} // }
SOUNDS_TO_REGISTER.clear(); // SOUNDS_TO_REGISTER.clear();
} // }
} }

View file

@ -1,4 +1,15 @@
package de.ellpeck.actuallyadditions.data; package de.ellpeck.actuallyadditions.data;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
@Mod.EventBusSubscriber(modid = ActuallyAdditions.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class AADataGenerator { public class AADataGenerator {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
}
} }