Removed 2 PreInits, added waila support

This commit is contained in:
modmuss50 2015-04-12 11:39:06 +01:00
parent 6f75bd48e0
commit ee14540196
9 changed files with 147 additions and 21 deletions

View file

@ -58,7 +58,7 @@ task deleteOldArtifacts(type: Delete) {
classes.dependsOn deleteOldArtifacts
dependencies {
compile 'net.industrial-craft:industrialcraft-2:2.2.712-experimental:api'
compile 'net.industrial-craft:industrialcraft-2:2.2.712-experimental:dev'
compile "codechicken:CodeChickenLib:1.7.10-1.1.3.127:dev"
compile "codechicken:CodeChickenCore:1.7.10-1.0.4.+:dev"
compile "codechicken:NotEnoughItems:1.7.10-1.0.4.+:dev"

View file

@ -1,6 +1,6 @@
#Sun Apr 12 10:46:15 BST 2015
#Sun Apr 12 11:14:36 BST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-all.zip

View file

@ -1,10 +1,12 @@
package techreborn;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import techreborn.client.GuiHandler;
import techreborn.compat.CompatManager;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
@ -23,8 +25,7 @@ public class Core {
public static Core INSTANCE;
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent event)
{
public void preinit(FMLPreInitializationEvent event) {
INSTANCE = this;
String path = event.getSuggestedConfigurationFile().getAbsolutePath()
.replace(ModInfo.MOD_ID, "TechReborn");
@ -33,20 +34,21 @@ public class Core {
LogHelper.info("PreInitialization Compleate");
}
@Mod.EventHandler
public void init(FMLPreInitializationEvent event)
{
//Register ModBlocks
ModBlocks.init();
//Register ModItems
ModItems.init();
// Recipes
ModRecipes.init();
// WorldGen
GameRegistry.registerWorldGenerator(new TROreGen(), 0);
//Register Gui Handler
NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
//Register ModBlocks
ModBlocks.init();
//Register ModItems
ModItems.init();
// Recipes
ModRecipes.init();
//Compat
CompatManager.init(event);
// WorldGen
GameRegistry.registerWorldGenerator(new TROreGen(), 0);
//Register Gui Handler
NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
LogHelper.info("Initialization Compleate");
}
}
}

View file

@ -0,0 +1,14 @@
package techreborn.compat;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import techreborn.compat.waila.CompatModuleWaila;
public class CompatManager {
public static void init(FMLInitializationEvent event) {
if(Loader.isModLoaded("Waila")){
new CompatModuleWaila().init(event);
}
}
}

View file

@ -0,0 +1,17 @@
package techreborn.compat.waila;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import mcp.mobius.waila.api.IWailaRegistrar;
import techreborn.tiles.TileMachineBase;
public class CompatModuleWaila {
public void init(FMLInitializationEvent event) {
FMLInterModComms.sendMessage("Waila", "register", getClass().getName() + ".callbackRegister");
}
public static void callbackRegister(IWailaRegistrar registrar) {
registrar.registerBodyProvider(new WailaProviderMachines(), TileMachineBase.class);
}
}

View file

@ -0,0 +1,55 @@
package techreborn.compat.waila;
import java.util.ArrayList;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import techreborn.tiles.TileMachineBase;
public class WailaProviderMachines implements IWailaDataProvider {
private List<String> info = new ArrayList<String>();
@Override
public List<String> getWailaBody(ItemStack item, List<String> tip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
TileMachineBase machine = (TileMachineBase) accessor.getTileEntity();
machine.addWailaInfo(info);
tip.addAll(info);
info.clear();
return tip;
}
@Override
public List<String> getWailaHead(ItemStack item, List<String> tip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return tip;
}
@Override
public List<String> getWailaTail(ItemStack item, List<String> tip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return tip;
}
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World w, int x, int y, int z) {
return tag;
}
}

View file

@ -0,0 +1,15 @@
package techreborn.tiles;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.tileentity.TileEntity;
import java.util.List;
public class TileMachineBase extends TileEntity {
@SideOnly(Side.CLIENT)
public void addWailaInfo(List<String> info) {
}
}

View file

@ -14,8 +14,10 @@ import techreborn.util.FluidUtils;
import techreborn.util.Inventory;
import techreborn.util.ItemUtils;
import java.util.List;
public class TileQuantumChest extends TileEntity implements IInventory ,IWrenchable{
public class TileQuantumChest extends TileMachineBase implements IInventory ,IWrenchable{
//Slot 0 = Input
//Slot 1 = Output
@ -214,4 +216,13 @@ public class TileQuantumChest extends TileEntity implements IInventory ,IWrencha
return dropStack;
}
@Override
public void addWailaInfo(List<String> info) {
super.addWailaInfo(info);
if(storedItem != null){
info.add(storedItem.stackSize + " of " + storedItem.getItem().getItemStackDisplayName(storedItem));
} else {
info.add("Empty");
}
}
}

View file

@ -19,7 +19,9 @@ import techreborn.util.FluidUtils;
import techreborn.util.Inventory;
import techreborn.util.Tank;
public class TileQuantumTank extends TileEntity implements IFluidHandler, IInventory, IWrenchable {
import java.util.List;
public class TileQuantumTank extends TileMachineBase implements IFluidHandler, IInventory, IWrenchable {
public Tank tank = new Tank("TileQuantumTank", Integer.MAX_VALUE, this);
public Inventory inventory = new Inventory(3, "TileQuantumTank", 64);
@ -200,4 +202,14 @@ public class TileQuantumTank extends TileEntity implements IFluidHandler, IInven
dropStack.stackTagCompound.setTag("tileEntity", tileEntity);
return dropStack;
}
@Override
public void addWailaInfo(List<String> info) {
super.addWailaInfo(info);
if(tank.getFluid() != null){
info.add(tank.getFluidAmount() + " of " + tank.getFluidType().getName());
} else {
info.add("Empty");
}
}
}