Skip to content

Commit

Permalink
Fix compile errors and rebase to master
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Feb 27, 2017
1 parent 924f941 commit ec5ae03
Show file tree
Hide file tree
Showing 23 changed files with 342 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ComponentInjector(Class<T> baseClazz) {
this.baseClazz = baseClazz;
}

public synchronized T inject(ComponentProvider provider, Class<?>[] typeArgs, Object[] args) {
public synchronized T inject(ComponentProvider<?> provider, Class<?>[] typeArgs, Object[] args) {
try {
List<Component> components = provider.components().stream()
.filter(component -> component.getClass().getAnnotationsByType(Passthrough.class).length > 0)
Expand Down Expand Up @@ -89,7 +89,7 @@ public synchronized T inject(ComponentProvider provider, Class<?>[] typeArgs, Ob
}
}

private T inject(T instance, ComponentProvider provider) throws ReflectiveOperationException {
private T inject(T instance, ComponentProvider<?> provider) throws ReflectiveOperationException {
Field f = instance.getClass().getDeclaredField("$$_provider");
f.setAccessible(true);
f.set(instance, provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

package nova.core.wrapper.mc.forge.v1_11.depmodules;

import nova.core.util.registry.LanguageManager;
import nova.core.language.LanguageManager;
import nova.core.wrapper.mc.forge.v1_11.util.MCLanguageManager;
import se.jbee.inject.bind.BinderModule;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import nova.core.entity.Entity;
import nova.core.entity.EntityFactory;
import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility;
Expand All @@ -50,16 +52,16 @@
*/
public class ClientProxy extends CommonProxy {
@Override
public void preInit() {
super.preInit();
public void preInit(FMLPreInitializationEvent evt) {
super.preInit(evt);
MinecraftForge.EVENT_BUS.register(RenderUtility.instance);
ClientRegistry.bindTileEntitySpecialRenderer(FWTile.class, FWTileRenderer.instance);
RenderUtility.instance.preInit();
RenderUtility.instance.preInit(evt);
}

@Override
public void init() {
super.init();
public void init(FMLInitializationEvent evt) {
super.init(evt);
RenderingRegistry.registerEntityRenderingHandler(FWEntity.class, FWEntityRenderer.instance);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
package nova.core.wrapper.mc.forge.v1_11.launcher;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import nova.core.entity.Entity;
import nova.core.entity.EntityFactory;
import nova.core.loader.Loadable;
import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock;
import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile;
import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTileUpdater;
Expand All @@ -34,14 +35,12 @@

import java.util.Set;

import net.minecraft.util.ResourceLocation;

/**
* @author Calclavia
*/
public class CommonProxy implements Loadable {
public class CommonProxy implements ForgeLoadable {
@Override
public void preInit() {
public void preInit(FMLPreInitializationEvent evt) {
GameRegistry.registerTileEntity(FWTile.class, "nova:novaTile");
GameRegistry.registerTileEntity(FWTileUpdater.class, "nova:novaTileUpdater");
EntityRegistry.registerModEntity(new ResourceLocation("nova", "novaEntity"), FWEntity.class, "novaEntity", 1, NovaMinecraft.instance, 64, 20, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
package nova.core.wrapper.mc.forge.v1_11.launcher;

import net.minecraftforge.fml.common.ProgressManager.ProgressBar;
import nova.core.util.AbstractProgressBar;

/**
* Wrapper class for FML progress bar that is shown when Minecraft boots.
*
* @author ExE Boss
*/
public class FMLProgressBar extends nova.core.util.AbstractProgressBar {
public class FMLProgressBar extends AbstractProgressBar {

private final ProgressBar progressBar;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2017 NOVA, All rights reserved.
* This library is free software, licensed under GNU Lesser General Public License version 3
*
* This file is part of NOVA.
*
* NOVA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NOVA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOVA. If not, see <http://www.gnu.org/licenses/>.
*/

package nova.core.wrapper.mc.forge.v1_11.launcher;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

/**
* A mod interface implemented to receive FML mod loading event calls.
*
* @author ExE Boss
*/
// TODO Maybe replace with wrapper events.
public interface ForgeLoadable {

default void preInit(FMLPreInitializationEvent event) {
}

default void init(FMLInitializationEvent event) {
}

default void postInit(FMLPostInitializationEvent event) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import net.minecraftforge.fml.relauncher.FMLInjectionData;
import nova.core.deps.MavenDependency;
import nova.core.event.ServerEvent;
import nova.core.loader.Loadable;
import nova.core.wrapper.mc.forge.v1_11.NovaMinecraftPreloader;
import nova.core.wrapper.mc.forge.v1_11.depmodules.ClientModule;
import nova.core.wrapper.mc.forge.v1_11.depmodules.ComponentModule;
Expand Down Expand Up @@ -64,6 +63,7 @@
import nova.internal.core.launch.InitializationException;
import nova.internal.core.launch.NovaLauncher;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
Expand All @@ -87,7 +87,13 @@ public class NovaMinecraft {
@Metadata(id)
private static ModMetadata modMetadata;

private static Set<Loadable> nativeConverters;
private static Set<ForgeLoadable> nativeConverters;
private static Set<ForgeLoadable> novaWrappers = new HashSet<>();
private static List<ForgeLoadable> novaModWrappers;

public static void registerWrapper(ForgeLoadable wrapper) {
novaWrappers.add(wrapper);
}

/**
* ORDER OF LOADING.
Expand Down Expand Up @@ -159,29 +165,39 @@ public void preInit(FMLPreInitializationEvent evt) {
/**
* Instantiate native loaders
*/
nativeConverters = Game.natives().getNativeConverters().stream().filter(n -> n instanceof Loadable).map(n -> (Loadable) n).collect(Collectors.toSet());
nativeConverters.stream().forEachOrdered(Loadable::preInit);

Game.blocks().init();
Game.items().init();
Game.entities().init();
Game.render().init();
Game.language().init();

//Load preInit
progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.size(), true);
launcher.preInit(new FMLProgressBar(progressBar));
while (progressBar.getStep() < progressBar.getSteps())
progressBar.step("null");
ProgressManager.pop(progressBar);
nativeConverters = Game.natives().getNativeConverters().stream().filter(n -> n instanceof ForgeLoadable).map(n -> (ForgeLoadable) n).collect(Collectors.toSet());
nativeConverters.stream().forEachOrdered(loadable -> loadable.preInit(evt));

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

proxy.preInit();
Game.language().init();
Game.render().init();
Game.blocks().init();
Game.items().init();
Game.entities().init();

//Load preInit
int size = novaModWrappers.size() + novaWrappers.size();
if (size > 0) {
progressBar = ProgressManager.push("Pre-initializing NOVA wrappers", size);
FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
novaModWrappers.stream().forEachOrdered(wrapper -> {
fmlProgressBar.step(wrapper.getClass());
wrapper.preInit(evt);
});
novaWrappers.stream().forEachOrdered(wrapper -> {
fmlProgressBar.step(wrapper.getClass());
wrapper.preInit(evt);
});
fmlProgressBar.finish();
ProgressManager.pop(progressBar);
}

proxy.preInit(evt);

/**
* Register event handlers
Expand All @@ -199,11 +215,23 @@ public void preInit(FMLPreInitializationEvent evt) {
@Mod.EventHandler
public void init(FMLInitializationEvent evt) {
try {
ProgressBar progressBar = ProgressManager.push("Initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true);
proxy.init();
nativeConverters.stream().forEachOrdered(Loadable::init);
launcher.init(new FMLProgressBar(progressBar));
ProgressManager.pop(progressBar);
proxy.init(evt);
nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.init(evt));
int size = novaModWrappers.size() + novaWrappers.size();
if (size > 0) {
ProgressManager.ProgressBar progressBar = ProgressManager.push("Initializing NOVA wrappers", size);
FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
novaModWrappers.stream().forEachOrdered(wrapper -> {
fmlProgressBar.step(wrapper.getClass());
wrapper.init(evt);
});
novaWrappers.stream().forEachOrdered(wrapper -> {
fmlProgressBar.step(wrapper.getClass());
wrapper.init(evt);
});
fmlProgressBar.finish();
ProgressManager.pop(progressBar);
}
} catch (Exception e) {
System.out.println("Error during init");
e.printStackTrace();
Expand All @@ -214,12 +242,24 @@ public void init(FMLInitializationEvent evt) {
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent evt) {
try {
ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true);
proxy.postInit(evt);
nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.postInit(evt));
Game.recipes().init();
proxy.postInit();
nativeConverters.stream().forEachOrdered(Loadable::postInit);
launcher.postInit(new FMLProgressBar(progressBar));
ProgressManager.pop(progressBar);
int size = novaModWrappers.size() + novaWrappers.size();
if (size > 0) {
ProgressManager.ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA wrappers", size);
FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
novaModWrappers.stream().forEachOrdered(wrapper -> {
fmlProgressBar.step(wrapper.getClass());
wrapper.postInit(evt);
});
novaWrappers.stream().forEachOrdered(wrapper -> {
fmlProgressBar.step(wrapper.getClass());
wrapper.postInit(evt);
});
fmlProgressBar.finish();
ProgressManager.pop(progressBar);
}
} catch (Exception e) {
System.out.println("Error during postInit");
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
package nova.core.wrapper.mc.forge.v1_11.recipes;

import nova.core.item.Item;
import nova.core.recipes.crafting.SpecificItemIngredient;
import nova.core.recipes.ingredient.SpecificItemIngredient;
import nova.internal.core.Game;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import net.minecraftforge.oredict.ShapelessOreRecipe;
import nova.core.item.Item;
import nova.core.recipes.crafting.CraftingRecipe;
import nova.core.recipes.crafting.ItemIngredient;
import nova.core.recipes.crafting.OreItemIngredient;
import nova.core.recipes.ingredient.ItemIngredient;
import nova.core.recipes.ingredient.OreItemIngredient;
import nova.core.recipes.crafting.ShapedCraftingRecipe;
import nova.core.recipes.crafting.ShapelessCraftingRecipe;
import nova.core.recipes.crafting.SpecificItemIngredient;
import nova.core.recipes.ingredient.SpecificItemIngredient;
import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil;
import nova.internal.core.Game;

Expand Down Expand Up @@ -111,7 +111,7 @@ private static String findOreDictEntryFor(List<ItemStack> ingredient) {
}

private static ItemStack wrapSpecific(SpecificItemIngredient ingredient) {
for (Item item : ingredient.getExampleItems().get()) {
for (Item item : ingredient.getExampleItems()) {
return Game.natives().toNative(item.getFactory().build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
import net.minecraft.client.renderer.block.model.ModelBlock;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.IResource;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand All @@ -43,6 +43,7 @@
import nova.core.render.texture.BlockTexture;
import nova.core.render.texture.ItemTexture;
import nova.core.render.texture.Texture;
import nova.core.wrapper.mc.forge.v1_11.launcher.ForgeLoadable;
import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock;
import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem;
import nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward.FWEmptyModel;
Expand Down Expand Up @@ -71,7 +72,7 @@
* @author Calclavia
*/
@SideOnly(Side.CLIENT)
public class RenderUtility {
public class RenderUtility implements ForgeLoadable {

public static final ResourceLocation particleResource = new ResourceLocation("textures/particle/particles.png");

Expand Down Expand Up @@ -231,7 +232,8 @@ public void onModelBakeEvent(ModelBakeEvent event) {
});
}

public void preInit() {
@Override
public void preInit(FMLPreInitializationEvent event) {
//Load models
Game.render().modelProviders.forEach(m -> {
ResourceLocation resource = new ResourceLocation(m.domain, "models/" + m.name + "." + m.getType());
Expand Down
Loading

0 comments on commit ec5ae03

Please sign in to comment.