Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supports seared tank derivatives and Casting channels. Essence extractor stuff present but disabled due to bug #219.
- Loading branch information
Sunstrike
committed
Oct 5, 2013
1 parent
96630e6
commit f1288ad
Showing
10 changed files
with
272 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package mcp.mobius.waila.api; | ||
|
||
import java.util.List; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.MovingObjectPosition; | ||
import net.minecraft.world.World; | ||
|
||
public interface IWailaBlock { | ||
/* | ||
* Use this method to return an item stack in case the default lookup system fails. | ||
* Return null if you want to use the default lookup system. | ||
* You get the world, the player and the location of the block. With that, it is easy to gather information & tile entities | ||
*/ | ||
ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config); | ||
|
||
/* Waila HUD is divided into 3 zones. The head corresponds to the item name, | ||
* body to where you mostly want to put informations, and I reserve the tail for modname display | ||
*/ | ||
|
||
/* Those 2 methods works exactly the same way, except they are related to a different zone in Waila HUD. | ||
* You get in input world, player and the block location. You also get the itemstack as returned by the default lookup system or getWailaStack(). | ||
* ConfigHandler provides the current Waila config state so you can show/hide elements depending on the configuration. Refer the ConfigHandler class for more info. | ||
* currenttip represents the current list of text lines in the tooltip zone. | ||
* For example, getWailaHead() will have the current item name as currenttip. | ||
* You can modify the tips, add more, remove some, etc. | ||
* When you are done, just returns the currenttip and it will display in Waila. | ||
* | ||
* Always return the currenttip is you don't want to modify the current zone. | ||
*/ | ||
|
||
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); | ||
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package mcp.mobius.waila.api; | ||
|
||
import java.util.HashMap; | ||
import java.util.Set; | ||
|
||
public interface IWailaConfigHandler { | ||
/* Returns a set of all the currently loaded modules in the config handler */ | ||
public Set<String> getModuleNames(); | ||
|
||
/* Returns all the currently available options for a given module */ | ||
public HashMap<String, String> getConfigKeys(String modName); | ||
|
||
/* Add a new option to a given module | ||
* | ||
* modName is the name of the module to add the option to (ie : Buildcraft, IndustrialCraft2, etc) | ||
* key is the config key (ie : bc.tankcontent, ic2.inputvalue) | ||
* name is the human readable name of the option (ie : "Tank content", "Max EU Input") | ||
* */ | ||
//public void addConfig(String modName, String key, String name); | ||
|
||
/* Returns the current value of an option (true/false) with a default value defvalue if not set*/ | ||
public boolean getConfig(String key, boolean defvalue); | ||
|
||
/* Returns the current value of an option (true/false) with a default value true if not set*/ | ||
public boolean getConfig(String key); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package mcp.mobius.waila.api; | ||
|
||
import java.util.List; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.MovingObjectPosition; | ||
import net.minecraft.world.World; | ||
|
||
public interface IWailaDataAccessor { | ||
World getWorld(); | ||
EntityPlayer getPlayer(); | ||
Block getBlock(); | ||
int getBlockID(); | ||
int getMetadata(); | ||
TileEntity getTileEntity(); | ||
MovingObjectPosition getPosition(); | ||
NBTTagCompound getNBTData(); | ||
int getNBTInteger(NBTTagCompound tag, String keyname); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package mcp.mobius.waila.api; | ||
|
||
public interface IWailaDataProvider extends IWailaBlock{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package mcp.mobius.waila.api; | ||
|
||
public interface IWailaRegistrar { | ||
/* Add a config option in the section modname with displayed text configtext and access key keyname */ | ||
public void addConfig(String modname, String keyname, String configtext); | ||
public void addConfigRemote(String modname, String keyname, String configtext); | ||
|
||
/* Register a IWailaDataProvider for the given blockID, either for the Head section or the Body section */ | ||
public void registerHeadProvider (IWailaDataProvider dataProvider, int blockID); | ||
public void registerBodyProvider (IWailaDataProvider dataProvider, int blockID); | ||
|
||
/* Register a stack overrider for the given blockID */ | ||
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID); | ||
|
||
|
||
/* Same thing, but works on a class hierarchy instead */ | ||
public void registerHeadProvider (IWailaDataProvider dataProvider, Class block); | ||
public void registerBodyProvider (IWailaDataProvider dataProvider, Class block); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/tconstruct/plugins/waila/CastingChannelDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package tconstruct.plugins.waila; | ||
|
||
import mcp.mobius.waila.api.IWailaConfigHandler; | ||
import mcp.mobius.waila.api.IWailaDataAccessor; | ||
import mcp.mobius.waila.api.IWailaDataProvider; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import tconstruct.blocks.logic.CastingChannelLogic; | ||
|
||
import java.util.List; | ||
|
||
public class CastingChannelDataProvider implements IWailaDataProvider { | ||
|
||
@Override | ||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { | ||
return currenttip; | ||
} | ||
|
||
@Override | ||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { | ||
if (accessor.getTileEntity() instanceof CastingChannelLogic) { | ||
CastingChannelLogic te = (CastingChannelLogic)accessor.getTileEntity(); | ||
if (te.liquid != null && te.liquid.amount > 0) { | ||
FluidStack fs = te.liquid; | ||
currenttip.add("Liquid: " + fs.getFluid().getLocalizedName()); | ||
currenttip.add("Amount: " + fs.amount + "/" + te.getCapacity()); | ||
} else { | ||
currenttip.add("§oEmpty"); // "§o" == Italics | ||
} | ||
} | ||
|
||
return currenttip; | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/tconstruct/plugins/waila/EssenceExtractorDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package tconstruct.plugins.waila; | ||
|
||
import mcp.mobius.waila.api.IWailaConfigHandler; | ||
import mcp.mobius.waila.api.IWailaDataAccessor; | ||
import mcp.mobius.waila.api.IWailaDataProvider; | ||
import net.minecraft.item.ItemStack; | ||
import tconstruct.blocks.logic.EssenceExtractorLogic; | ||
|
||
import java.util.List; | ||
|
||
public class EssenceExtractorDataProvider implements IWailaDataProvider { | ||
|
||
@Override | ||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { | ||
return currenttip; | ||
} | ||
|
||
@Override | ||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { | ||
if (accessor.getTileEntity() instanceof EssenceExtractorLogic) { | ||
EssenceExtractorLogic te = (EssenceExtractorLogic)accessor.getTileEntity(); | ||
currenttip.add("Total Essence: " + te.essenceAmount); | ||
currenttip.add("Stored Levels: " + EssenceExtractorLogic.getEssencelevels(te.essenceAmount)); | ||
} | ||
|
||
return currenttip; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package tconstruct.plugins.waila; | ||
|
||
import mcp.mobius.waila.api.IWailaConfigHandler; | ||
import mcp.mobius.waila.api.IWailaDataAccessor; | ||
import mcp.mobius.waila.api.IWailaDataProvider; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import tconstruct.blocks.logic.LavaTankLogic; | ||
|
||
import java.util.List; | ||
|
||
public class SearedTankDataProvider implements IWailaDataProvider { | ||
|
||
@Override | ||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { | ||
return currenttip; | ||
} | ||
|
||
@Override | ||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { | ||
if (accessor.getTileEntity() instanceof LavaTankLogic) { | ||
LavaTankLogic te = (LavaTankLogic)accessor.getTileEntity(); | ||
if (te.containsFluid()) { | ||
FluidStack fs = te.tank.getFluid(); | ||
currenttip.add("Liquid: " + fs.getFluid().getLocalizedName()); | ||
currenttip.add("Amount: " + fs.amount + "/" + te.tank.getCapacity()); | ||
} else { | ||
currenttip.add("§oEmpty"); // "§o" == Italics | ||
} | ||
} | ||
return currenttip; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package tconstruct.plugins.waila; | ||
|
||
import cpw.mods.fml.common.FMLCommonHandler; | ||
import cpw.mods.fml.common.Loader; | ||
import cpw.mods.fml.common.Mod; | ||
import cpw.mods.fml.common.Mod.EventHandler; | ||
import cpw.mods.fml.common.event.FMLInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLInterModComms; | ||
import cpw.mods.fml.common.network.NetworkMod; | ||
import mcp.mobius.waila.api.IWailaRegistrar; | ||
import tconstruct.blocks.LavaTankBlock; | ||
import tconstruct.blocks.logic.CastingChannelLogic; | ||
|
||
import java.util.logging.Logger; | ||
|
||
@Mod(modid = "TConstruct|CompatWaila", name = "TConstruct Compat: Waila", version = "0.0.1", dependencies = "after:Waila;required-after:TConstruct") | ||
@NetworkMod(clientSideRequired = false, serverSideRequired = false) | ||
public class Waila { | ||
|
||
public static Logger logger = Logger.getLogger("TConstruct Waila"); | ||
|
||
@EventHandler | ||
public static void load (FMLInitializationEvent ev) | ||
{ | ||
logger.setParent(FMLCommonHandler.instance().getFMLLogger()); | ||
|
||
if (!Loader.isModLoaded("Waila")) { | ||
logger.warning("Waila missing - TConstruct Compat: Waila not loading."); | ||
return; | ||
} try { | ||
logger.info("Waila detected. Registering TConstruct tank blocks with Waila registry."); | ||
|
||
FMLInterModComms.sendMessage("Waila", "register", "tconstruct.plugins.waila.Waila.wailaCallback"); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static void wailaCallback(IWailaRegistrar registrar) { | ||
logger.info("Got registrar: " + registrar); | ||
|
||
registrar.registerBodyProvider(new SearedTankDataProvider(), LavaTankBlock.class); | ||
registrar.registerBodyProvider(new CastingChannelDataProvider(), CastingChannelLogic.class); | ||
//registrar.registerBodyProvider(new EssenceExtractorDataProvider(), EssenceExtractor.class); | ||
} | ||
|
||
} |