Skip to content

Commit 4d86319

Browse files
authored
Merge pull request #256 from NOVA-Team/remove/loadable
Remove Loadable
2 parents 93020d5 + c085f46 commit 4d86319

File tree

21 files changed

+226
-201
lines changed

21 files changed

+226
-201
lines changed

minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/ClientProxy.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import cpw.mods.fml.client.FMLClientHandler;
2424
import cpw.mods.fml.client.registry.ClientRegistry;
2525
import cpw.mods.fml.client.registry.RenderingRegistry;
26+
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
2627
import net.minecraft.client.Minecraft;
2728
import net.minecraft.client.gui.GuiScreen;
2829
import net.minecraft.client.particle.EntityFX;
@@ -49,8 +50,8 @@
4950
*/
5051
public class ClientProxy extends CommonProxy {
5152
@Override
52-
public void preInit() {
53-
super.preInit();
53+
public void preInit(FMLPreInitializationEvent evt) {
54+
super.preInit(evt);
5455
MinecraftForge.EVENT_BUS.register(RenderUtility.instance);
5556
ClientRegistry.bindTileEntitySpecialRenderer(FWTile.class, FWTileRenderer.instance);
5657
RenderingRegistry.registerEntityRenderingHandler(FWEntity.class, FWEntityRenderer.instance);

minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/CommonProxy.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
package nova.core.wrapper.mc.forge.v17.launcher;
2222

23+
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
2324
import cpw.mods.fml.common.registry.EntityRegistry;
2425
import cpw.mods.fml.common.registry.GameRegistry;
2526
import net.minecraft.entity.player.EntityPlayer;
2627
import nova.core.entity.Entity;
2728
import nova.core.entity.EntityFactory;
28-
import nova.core.loader.Loadable;
2929
import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock;
3030
import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWTile;
3131
import nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.FWEntity;
@@ -36,9 +36,9 @@
3636
/**
3737
* @author Calclavia
3838
*/
39-
public class CommonProxy implements Loadable {
39+
public class CommonProxy implements ForgeLoadable {
4040
@Override
41-
public void preInit() {
41+
public void preInit(FMLPreInitializationEvent evt) {
4242
GameRegistry.registerTileEntity(FWTile.class, "novaTile");
4343
int globalUniqueEntityId = EntityRegistry.findGlobalUniqueEntityId();
4444
EntityRegistry.registerGlobalEntityID(FWEntity.class, "novaEntity", globalUniqueEntityId);
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015 NOVA, All rights reserved.
2+
* Copyright (c) 2017 NOVA, All rights reserved.
33
* This library is free software, licensed under GNU Lesser General Public License version 3
44
*
55
* This file is part of NOVA.
@@ -16,21 +16,28 @@
1616
*
1717
* You should have received a copy of the GNU General Public License
1818
* along with NOVA. If not, see <http://www.gnu.org/licenses/>.
19-
*/package nova.core.loader;
19+
*/
20+
21+
package nova.core.wrapper.mc.forge.v17.launcher;
22+
23+
import cpw.mods.fml.common.event.FMLInitializationEvent;
24+
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
25+
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
2026

2127
/**
22-
* A mod interface implemented to receive mod load event calls.
28+
* A mod interface implemented to receive FML mod loading event calls.
2329
*
24-
* @author Calclavia
30+
* @author ExE Boss
2531
*/
26-
@Deprecated
27-
public interface Loadable {
28-
default void preInit() {
32+
// TODO Maybe replace with wrapper events.
33+
public interface ForgeLoadable {
34+
35+
default void preInit(FMLPreInitializationEvent event) {
2936
}
3037

31-
default void init() {
38+
default void init(FMLInitializationEvent event) {
3239
}
3340

34-
default void postInit() {
41+
default void postInit(FMLPostInitializationEvent event) {
3542
}
3643
}

minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/NovaMinecraft.java

+25-26
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import net.minecraftforge.common.MinecraftForge;
3434
import nova.core.deps.MavenDependency;
3535
import nova.core.event.ServerEvent;
36-
import nova.core.loader.Loadable;
3736
import nova.core.wrapper.mc.forge.v17.NovaMinecraftPreloader;
3837
import nova.core.wrapper.mc.forge.v17.depmodules.ClientModule;
3938
import nova.core.wrapper.mc.forge.v17.depmodules.ComponentModule;
@@ -61,6 +60,7 @@
6160
import nova.internal.core.launch.InitializationException;
6261
import nova.internal.core.launch.NovaLauncher;
6362

63+
import java.util.HashSet;
6464
import java.util.List;
6565
import java.util.Set;
6666
import java.util.stream.Collectors;
@@ -82,7 +82,12 @@ public class NovaMinecraft {
8282
public static NovaMinecraft instance;
8383
private static NovaLauncher launcher;
8484

85-
private static Set<Loadable> nativeConverters;
85+
private static Set<ForgeLoadable> nativeConverters;
86+
private static Set<ForgeLoadable> novaWrappers = new HashSet<>();
87+
88+
public static void registerWrapper(ForgeLoadable wrapper) {
89+
novaWrappers.add(wrapper);
90+
}
8691

8792
/**
8893
* ORDER OF LOADING.
@@ -154,27 +159,25 @@ public void preInit(FMLPreInitializationEvent evt) {
154159
/**
155160
* Instantiate native loaders
156161
*/
157-
nativeConverters = Game.natives().getNativeConverters().stream().filter(n -> n instanceof Loadable).map(n -> (Loadable) n).collect(Collectors.toSet());
158-
nativeConverters.stream().forEachOrdered(Loadable::preInit);
159-
160-
Game.blocks().init();
161-
Game.items().init();
162-
Game.entities().init();
163-
Game.render().init();
164-
Game.language().init();
165-
166-
//Load preInit
167-
progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.isEmpty() ? 1 : modClasses.size());
168-
launcher.preInit(new FMLProgressBar(progressBar));
169-
ProgressManager.pop(progressBar);
162+
nativeConverters = Game.natives().getNativeConverters().stream().filter(n -> n instanceof ForgeLoadable).map(n -> (ForgeLoadable) n).collect(Collectors.toSet());
163+
nativeConverters.stream().forEachOrdered(loadable -> loadable.preInit(evt));
170164

171165
// Initiate config system TODO: Storables
172166
// launcher.getLoadedModMap().forEach((mod, loader) -> {
173167
// Configuration config = new Configuration(new File(evt.getModConfigurationDirectory(), mod.name()));
174168
// ConfigManager.instance.sync(config, loader.getClass().getPackage().getName());
175169
// });
176170

177-
proxy.preInit();
171+
Game.language().init();
172+
Game.render().init();
173+
Game.blocks().init();
174+
Game.items().init();
175+
Game.entities().init();
176+
177+
//Load preInit
178+
novaWrappers.stream().forEachOrdered(wrapper -> wrapper.preInit(evt));
179+
180+
proxy.preInit(evt);
178181

179182
/**
180183
* Register event handlers
@@ -192,11 +195,9 @@ public void preInit(FMLPreInitializationEvent evt) {
192195
@Mod.EventHandler
193196
public void init(FMLInitializationEvent evt) {
194197
try {
195-
ProgressManager.ProgressBar progressBar = ProgressManager.push("Initializing NOVA mods", NovaMinecraftPreloader.modClasses.isEmpty() ? 1 : NovaMinecraftPreloader.modClasses.size());
196-
proxy.init();
197-
nativeConverters.stream().forEachOrdered(Loadable::init);
198-
launcher.init(new FMLProgressBar(progressBar));
199-
ProgressManager.pop(progressBar);
198+
proxy.init(evt);
199+
nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.init(evt));
200+
novaWrappers.stream().forEachOrdered(wrapper -> wrapper.init(evt));
200201
} catch (Exception e) {
201202
System.out.println("Error during init");
202203
e.printStackTrace();
@@ -207,12 +208,10 @@ public void init(FMLInitializationEvent evt) {
207208
@Mod.EventHandler
208209
public void postInit(FMLPostInitializationEvent evt) {
209210
try {
210-
ProgressManager.ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA mods", NovaMinecraftPreloader.modClasses.isEmpty() ? 1 : NovaMinecraftPreloader.modClasses.size());
211211
Game.recipes().init();
212-
proxy.postInit();
213-
nativeConverters.stream().forEachOrdered(Loadable::postInit);
214-
launcher.postInit(new FMLProgressBar(progressBar));
215-
ProgressManager.pop(progressBar);
212+
proxy.postInit(evt);
213+
nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.postInit(evt));
214+
novaWrappers.stream().forEachOrdered(wrapper -> wrapper.postInit(evt));
216215
} catch (Exception e) {
217216
System.out.println("Error during postInit");
218217
e.printStackTrace();

minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@
2121
package nova.core.wrapper.mc.forge.v17.wrapper.block;
2222

2323
import cpw.mods.fml.common.FMLCommonHandler;
24+
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
2425
import cpw.mods.fml.common.registry.GameRegistry;
2526
import net.minecraft.init.Blocks;
2627
import nova.core.block.Block;
2728
import nova.core.block.BlockFactory;
2829
import nova.core.block.BlockManager;
2930
import nova.core.component.Category;
3031
import nova.core.event.BlockEvent;
31-
import nova.core.loader.Loadable;
3232
import nova.core.nativewrapper.NativeConverter;
33+
import nova.core.wrapper.mc.forge.v17.launcher.ForgeLoadable;
3334
import nova.core.wrapper.mc.forge.v17.launcher.NovaMinecraft;
3435
import nova.core.wrapper.mc.forge.v17.wrapper.CategoryConverter;
3536
import nova.core.wrapper.mc.forge.v17.wrapper.block.backward.BWBlock;
@@ -42,7 +43,7 @@
4243
/**
4344
* @author Calclavia
4445
*/
45-
public class BlockConverter implements NativeConverter<Block, net.minecraft.block.Block>, Loadable {
46+
public class BlockConverter implements NativeConverter<Block, net.minecraft.block.Block>, ForgeLoadable {
4647
/**
4748
* A map of all blockFactory to MC blocks registered
4849
*/
@@ -93,7 +94,8 @@ public net.minecraft.block.Block toNative(BlockFactory blockFactory) {
9394
/**
9495
* Register all Nova blocks
9596
*/
96-
public void preInit() {
97+
@Override
98+
public void preInit(FMLPreInitializationEvent evt) {
9799
registerMinecraftToNOVA();
98100
registerNOVAToMinecraft();
99101
}

minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/entity/EntityConverter.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020

2121
package nova.core.wrapper.mc.forge.v17.wrapper.entity;
2222

23+
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
2324
import cpw.mods.fml.relauncher.Side;
2425
import cpw.mods.fml.relauncher.SideOnly;
2526
import nova.core.entity.Entity;
2627
import nova.core.entity.EntityFactory;
27-
import nova.core.loader.Loadable;
2828
import nova.core.nativewrapper.NativeConverter;
29+
import nova.core.wrapper.mc.forge.v17.launcher.ForgeLoadable;
2930
import nova.core.wrapper.mc.forge.v17.wrapper.entity.backward.BWEntity;
3031
import nova.core.wrapper.mc.forge.v17.wrapper.entity.backward.BWEntityFX;
3132
import nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.FWEntity;
@@ -34,7 +35,7 @@
3435

3536
import java.util.Optional;
3637

37-
public class EntityConverter implements NativeConverter<Entity, net.minecraft.entity.Entity>, Loadable {
38+
public class EntityConverter implements NativeConverter<Entity, net.minecraft.entity.Entity>, ForgeLoadable {
3839

3940
@Override
4041
public Class<Entity> getNovaSide() {
@@ -78,7 +79,7 @@ public net.minecraft.entity.Entity toNative(Entity novaObj) {
7879

7980
@Override
8081
@SideOnly(Side.CLIENT)
81-
public void preInit() {
82+
public void preInit(FMLPreInitializationEvent evt) {
8283
/**
8384
* Backward register all particle effects
8485
*/

minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.google.common.collect.HashBiMap;
2424
import cpw.mods.fml.common.FMLCommonHandler;
25+
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
2526
import cpw.mods.fml.common.registry.GameRegistry;
2627
import net.minecraft.item.ItemStack;
2728
import nova.core.block.BlockFactory;
@@ -30,9 +31,9 @@
3031
import nova.core.item.Item;
3132
import nova.core.item.ItemBlock;
3233
import nova.core.item.ItemFactory;
33-
import nova.core.loader.Loadable;
3434
import nova.core.nativewrapper.NativeConverter;
3535
import nova.core.retention.Data;
36+
import nova.core.wrapper.mc.forge.v17.launcher.ForgeLoadable;
3637
import nova.core.wrapper.mc.forge.v17.launcher.NovaMinecraft;
3738
import nova.core.wrapper.mc.forge.v17.wrapper.CategoryConverter;
3839
import nova.core.wrapper.mc.forge.v17.wrapper.block.BlockConverter;
@@ -45,7 +46,7 @@
4546
* The main class responsible for wrapping items.
4647
* @author Calclavia, Stan Hebben
4748
*/
48-
public class ItemConverter implements NativeConverter<Item, ItemStack>, Loadable {
49+
public class ItemConverter implements NativeConverter<Item, ItemStack>, ForgeLoadable {
4950

5051
/**
5152
* A map of all items registered
@@ -156,7 +157,8 @@ public net.minecraft.item.ItemStack updateMCItemStack(ItemStack itemStack, nova.
156157
/**
157158
* Register all Nova blocks
158159
*/
159-
public void preInit() {
160+
@Override
161+
public void preInit(FMLPreInitializationEvent evt) {
160162
registerNOVAItemsToMinecraft();
161163
registerMinecraftItemsToNOVA();
162164
registerSubtypeResolution();

minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/ClientProxy.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import net.minecraftforge.fml.client.FMLClientHandler;
3535
import net.minecraftforge.fml.client.registry.ClientRegistry;
3636
import net.minecraftforge.fml.client.registry.RenderingRegistry;
37+
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
38+
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
3739
import nova.core.entity.Entity;
3840
import nova.core.entity.EntityFactory;
3941
import nova.core.wrapper.mc.forge.v18.render.RenderUtility;
@@ -53,16 +55,16 @@
5355
*/
5456
public class ClientProxy extends CommonProxy {
5557
@Override
56-
public void preInit() {
57-
super.preInit();
58+
public void preInit(FMLPreInitializationEvent evt) {
59+
super.preInit(evt);
5860
MinecraftForge.EVENT_BUS.register(RenderUtility.instance);
5961
ClientRegistry.bindTileEntitySpecialRenderer(FWTile.class, FWTileRenderer.instance);
6062
RenderUtility.instance.preInit();
6163
}
6264

6365
@Override
64-
public void init() {
65-
super.init();
66+
public void init(FMLInitializationEvent evt) {
67+
super.init(evt);
6668
RenderingRegistry.registerEntityRenderingHandler(FWEntity.class, FWEntityRenderer.instance);
6769
}
6870

minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/CommonProxy.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
package nova.core.wrapper.mc.forge.v18.launcher;
2222

2323
import net.minecraft.entity.player.EntityPlayer;
24+
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
2425
import net.minecraftforge.fml.common.registry.EntityRegistry;
2526
import net.minecraftforge.fml.common.registry.GameRegistry;
2627
import nova.core.entity.Entity;
2728
import nova.core.entity.EntityFactory;
28-
import nova.core.loader.Loadable;
2929
import nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWBlock;
3030
import nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWTile;
3131
import nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWTileUpdater;
@@ -37,9 +37,9 @@
3737
/**
3838
* @author Calclavia
3939
*/
40-
public class CommonProxy implements Loadable {
40+
public class CommonProxy implements ForgeLoadable {
4141
@Override
42-
public void preInit() {
42+
public void preInit(FMLPreInitializationEvent evt) {
4343
GameRegistry.registerTileEntity(FWTile.class, "novaTile");
4444
GameRegistry.registerTileEntity(FWTileUpdater.class, "novaTileUpdater");
4545
int globalUniqueEntityId = EntityRegistry.findGlobalUniqueEntityId();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2017 NOVA, All rights reserved.
3+
* This library is free software, licensed under GNU Lesser General Public License version 3
4+
*
5+
* This file is part of NOVA.
6+
*
7+
* NOVA is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* NOVA is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with NOVA. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
package nova.core.wrapper.mc.forge.v18.launcher;
22+
23+
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
24+
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
25+
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
26+
27+
/**
28+
* A mod interface implemented to receive FML mod loading event calls.
29+
*
30+
* @author ExE Boss
31+
*/
32+
// TODO Maybe replace with wrapper events.
33+
public interface ForgeLoadable {
34+
35+
default void preInit(FMLPreInitializationEvent evt) {
36+
}
37+
38+
default void init(FMLInitializationEvent evt) {
39+
}
40+
41+
default void postInit(FMLPostInitializationEvent evt) {
42+
}
43+
}

0 commit comments

Comments
 (0)