mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-30 00:26:16 -04:00
Merge branch 'master' of github.com:MightyPirates/OpenComputers into MC1.7
Conflicts: src/main/scala/li/cil/oc/common/block/Delegator.scala
This commit is contained in:
commit
d9a94049d7
@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@Deprecated
|
||||
public interface IWailaBlock {
|
||||
/*
|
||||
* Use this method to return an item stack in case the default lookup system fails.
|
||||
|
@ -1,7 +1,5 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWailaBlockDecorator {
|
||||
|
@ -24,5 +24,5 @@ public interface IWailaConfigHandler {
|
||||
/* Returns the current value of an option (true/false) with a default value true if not set*/
|
||||
public boolean getConfig(String key);
|
||||
|
||||
public void setConfig(String key, boolean value);
|
||||
//public void setConfig(String key, boolean value);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package mcp.mobius.waila.api;
|
||||
|
||||
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;
|
||||
@ -9,7 +10,13 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/* The Accessor is used to get some basic data out of the game without having to request
|
||||
* direct access to the game engine.
|
||||
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
|
||||
*/
|
||||
|
||||
public interface IWailaDataAccessor {
|
||||
|
||||
World getWorld();
|
||||
EntityPlayer getPlayer();
|
||||
Block getBlock();
|
||||
@ -22,4 +29,5 @@ public interface IWailaDataAccessor {
|
||||
int getNBTInteger(NBTTagCompound tag, String keyname);
|
||||
double getPartialFrame();
|
||||
ForgeDirection getSide();
|
||||
ItemStack getStack();
|
||||
}
|
||||
|
@ -1,4 +1,33 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
public interface IWailaDataProvider extends IWailaBlock{
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWailaDataProvider{
|
||||
/*
|
||||
* 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);
|
||||
List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
}
|
||||
|
24
src/api/java/mcp/mobius/waila/api/IWailaEntityAccessor.java
Normal file
24
src/api/java/mcp/mobius/waila/api/IWailaEntityAccessor.java
Normal file
@ -0,0 +1,24 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/* The Accessor is used to get some basic data out of the game without having to request
|
||||
* direct access to the game engine.
|
||||
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
|
||||
*/
|
||||
|
||||
public interface IWailaEntityAccessor {
|
||||
World getWorld();
|
||||
EntityPlayer getPlayer();
|
||||
Entity getEntity();
|
||||
MovingObjectPosition getPosition();
|
||||
Vec3 getRenderingPosition();
|
||||
NBTTagCompound getNBTData();
|
||||
int getNBTInteger(NBTTagCompound tag, String keyname);
|
||||
double getPartialFrame();
|
||||
}
|
16
src/api/java/mcp/mobius/waila/api/IWailaEntityProvider.java
Normal file
16
src/api/java/mcp/mobius/waila/api/IWailaEntityProvider.java
Normal file
@ -0,0 +1,16 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public interface IWailaEntityProvider {
|
||||
|
||||
/* A way to get an override on the entity returned by the raytracing */
|
||||
Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config);
|
||||
|
||||
/* The classical HEAD/BODY/TAIL text getters */
|
||||
List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
|
||||
List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
|
||||
List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
|
||||
}
|
28
src/api/java/mcp/mobius/waila/api/IWailaFMPAccessor.java
Normal file
28
src/api/java/mcp/mobius/waila/api/IWailaFMPAccessor.java
Normal file
@ -0,0 +1,28 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
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.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/* The Accessor is used to get some basic data out of the game without having to request
|
||||
* direct access to the game engine.
|
||||
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
|
||||
*/
|
||||
|
||||
public interface IWailaFMPAccessor {
|
||||
World getWorld();
|
||||
EntityPlayer getPlayer();
|
||||
TileEntity getTileEntity();
|
||||
MovingObjectPosition getPosition();
|
||||
NBTTagCompound getNBTData();
|
||||
NBTTagCompound getFullNBTData();
|
||||
int getNBTInteger(NBTTagCompound tag, String keyname);
|
||||
double getPartialFrame();
|
||||
Vec3 getRenderingPosition();
|
||||
String getID();
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWailaFMPDecorator {
|
||||
void decorateBlock(ItemStack itemStack, IWailaFMPAccessor accessor, IWailaConfigHandler config);
|
||||
}
|
12
src/api/java/mcp/mobius/waila/api/IWailaFMPProvider.java
Normal file
12
src/api/java/mcp/mobius/waila/api/IWailaFMPProvider.java
Normal file
@ -0,0 +1,12 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWailaFMPProvider {
|
||||
/* The classical HEAD/BODY/TAIL text getters */
|
||||
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
|
||||
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
|
||||
List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
|
||||
}
|
@ -8,11 +8,15 @@ public interface IWailaRegistrar {
|
||||
public void addConfigRemote(String modname, String keyname);
|
||||
|
||||
/* Register a IWailaDataProvider for the given blockID, either for the Head section or the Body section */
|
||||
@Deprecated
|
||||
public void registerHeadProvider (IWailaDataProvider dataProvider, int blockID);
|
||||
@Deprecated
|
||||
public void registerBodyProvider (IWailaDataProvider dataProvider, int blockID);
|
||||
@Deprecated
|
||||
public void registerTailProvider (IWailaDataProvider dataProvider, int blockID);
|
||||
|
||||
/* Register a stack overrider for the given blockID */
|
||||
@Deprecated
|
||||
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID);
|
||||
public void registerStackProvider(IWailaDataProvider dataProvider, Class block);
|
||||
|
||||
@ -20,12 +24,33 @@ public interface IWailaRegistrar {
|
||||
public void registerHeadProvider (IWailaDataProvider dataProvider, Class block);
|
||||
public void registerBodyProvider (IWailaDataProvider dataProvider, Class block);
|
||||
public void registerTailProvider (IWailaDataProvider dataProvider, Class block);
|
||||
|
||||
/* Entity text registration methods */
|
||||
public void registerHeadProvider (IWailaEntityProvider dataProvider, Class entity);
|
||||
public void registerBodyProvider (IWailaEntityProvider dataProvider, Class entity);
|
||||
public void registerTailProvider (IWailaEntityProvider dataProvider, Class entity);
|
||||
public void registerOverrideEntityProvider (IWailaEntityProvider dataProvider, Class entity);
|
||||
|
||||
/* FMP Providers */
|
||||
public void registerHeadProvider(IWailaFMPProvider dataProvider, String name);
|
||||
public void registerBodyProvider(IWailaFMPProvider dataProvider, String name);
|
||||
public void registerTailProvider(IWailaFMPProvider dataProvider, String name);
|
||||
|
||||
/* The block decorators */
|
||||
public void registerBlockDecorator (IWailaBlockDecorator decorator, int blockID);
|
||||
public void registerBlockDecorator (IWailaBlockDecorator decorator, Class block);
|
||||
@Deprecated
|
||||
public void registerDecorator (IWailaBlockDecorator decorator, int blockID);
|
||||
public void registerDecorator (IWailaBlockDecorator decorator, Class block);
|
||||
public void registerDecorator (IWailaFMPDecorator decorator, String name);
|
||||
|
||||
/* Selective NBT key syncing. Will register a key to sync over the network for the given class (block, te or ent).
|
||||
* Accept * as a ending wildcard
|
||||
* registerNBTKey("bob.*", MyBlock.class)
|
||||
* registerNBTKey("data.life", MyEntity.class)
|
||||
* registerNBTKey("*", MyTileEntity.class) will reproduce the full tag syncing from 1.4.5
|
||||
* */
|
||||
public void registerSyncedNBTKey(String key, Class target);
|
||||
|
||||
/* UNUSED FOR NOW (Will be used for the ingame wiki */
|
||||
public void registerDocTextFile (String filename);
|
||||
|
||||
public void registerShortDataProvider (IWailaSummaryProvider dataProvider, Class item);
|
||||
}
|
||||
|
40
src/api/java/mcp/mobius/waila/api/SpecialChars.java
Normal file
40
src/api/java/mcp/mobius/waila/api/SpecialChars.java
Normal file
@ -0,0 +1,40 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
public class SpecialChars {
|
||||
|
||||
public static String MCStyle = "\u00A7";
|
||||
|
||||
public static String BLACK = MCStyle + "0";
|
||||
public static String DBLUE = MCStyle + "1";
|
||||
public static String DGREEN = MCStyle + "2";
|
||||
public static String DAQUA = MCStyle + "3";
|
||||
public static String DRED = MCStyle + "4";
|
||||
public static String DPURPLE = MCStyle + "5";
|
||||
public static String GOLD = MCStyle + "6";
|
||||
public static String GRAY = MCStyle + "7";
|
||||
public static String DGRAY = MCStyle + "8";
|
||||
public static String BLUE = MCStyle + "9";
|
||||
public static String GREEN = MCStyle + "a";
|
||||
public static String AQUA = MCStyle + "b";
|
||||
public static String RED = MCStyle + "c";
|
||||
public static String LPURPLE = MCStyle + "d";
|
||||
public static String YELLOW = MCStyle + "e";
|
||||
public static String WHITE = MCStyle + "f";
|
||||
|
||||
public static String OBF = MCStyle + "k";
|
||||
public static String BOLD = MCStyle + "l";
|
||||
public static String STRIKE = MCStyle + "m";
|
||||
public static String UNDER = MCStyle + "n";
|
||||
public static String ITALIC = MCStyle + "o";
|
||||
public static String RESET = MCStyle + "r";
|
||||
|
||||
public static String WailaStyle = "\u00A4";
|
||||
public static String WailaIcon = "\u00A5";
|
||||
public static String TAB = WailaStyle + WailaStyle +"a";
|
||||
public static String ALIGNRIGHT = WailaStyle + WailaStyle +"b";
|
||||
public static String ALIGNCENTER = WailaStyle + WailaStyle +"c";
|
||||
public static String HEART = WailaStyle + WailaIcon +"a";
|
||||
public static String HHEART = WailaStyle + WailaIcon +"b";
|
||||
public static String EHEART = WailaStyle + WailaIcon +"c";
|
||||
|
||||
}
|
3
src/api/java/mcp/mobius/waila/api/package-info.java
Normal file
3
src/api/java/mcp/mobius/waila/api/package-info.java
Normal file
@ -0,0 +1,3 @@
|
||||
@API(apiVersion="1.0",owner="Waila",provides="WailaAPI")
|
||||
package mcp.mobius.waila.api;
|
||||
import cpw.mods.fml.common.API;
|
@ -78,6 +78,8 @@ class Proxy {
|
||||
OpenComputers.channel.register(server.PacketHandler)
|
||||
|
||||
Loot.init()
|
||||
|
||||
FMLInterModComms.sendMessage("Waila", "register", "li.cil.oc.util.mods.Waila.init")
|
||||
}
|
||||
|
||||
def postInit(e: FMLPostInitializationEvent) {
|
||||
|
@ -9,7 +9,6 @@ import li.cil.oc.common.tileentity.traits.{Rotatable, BundledRedstoneAware}
|
||||
import li.cil.oc.util.ItemCosts
|
||||
import li.cil.oc.util.mods.Mods
|
||||
import li.cil.oc.{Settings, CreativeTab}
|
||||
import mcp.mobius.waila.api.{IWailaConfigHandler, IWailaDataAccessor, IWailaBlock}
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.client.renderer.texture.IIconRegister
|
||||
@ -25,8 +24,7 @@ import org.lwjgl.input
|
||||
import powercrystals.minefactoryreloaded.api.rednet.{IRedNetNetworkContainer, RedNetConnectionType, IConnectableRedNet}
|
||||
import scala.collection.mutable
|
||||
|
||||
@Optional.Interface(iface = "mcp.mobius.waila.api.IWailaBlock", modid = "Waila")
|
||||
class Delegator[Child <: Delegate] extends Block(Material.iron) with IWailaBlock {
|
||||
class Delegator[Child <: Delegate] extends Block(Material.iron) {
|
||||
setHardness(2f)
|
||||
setCreativeTab(CreativeTab)
|
||||
|
||||
@ -413,30 +411,6 @@ class Delegator[Child <: Delegate] extends Block(Material.iron) with IWailaBlock
|
||||
super.registerBlockIcons(iconRegister)
|
||||
subBlocks.foreach(_.registerIcons(iconRegister))
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
// Waila
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
@Optional.Method(modid = "Waila")
|
||||
override def getWailaStack(accessor: IWailaDataAccessor, config: IWailaConfigHandler) =
|
||||
subBlock(accessor.getMetadata).fold(null: ItemStack)(_.createItemStack())
|
||||
|
||||
@Optional.Method(modid = "Waila")
|
||||
override def getWailaHead(stack: ItemStack, tooltip: util.List[String], accessor: IWailaDataAccessor, config: IWailaConfigHandler) = {
|
||||
tooltip
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Waila")
|
||||
override def getWailaBody(stack: ItemStack, tooltip: util.List[String], accessor: IWailaDataAccessor, config: IWailaConfigHandler) = {
|
||||
subBlock(stack).foreach(_.wailaBody(stack, tooltip, accessor, config))
|
||||
tooltip
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Waila")
|
||||
override def getWailaTail(stack: ItemStack, tooltip: util.List[String], accessor: IWailaDataAccessor, config: IWailaConfigHandler) = {
|
||||
tooltip
|
||||
}
|
||||
}
|
||||
|
||||
object Delegator {
|
||||
|
@ -1,5 +1,45 @@
|
||||
package li.cil.oc.util.mods
|
||||
|
||||
import cpw.mods.fml.common.Optional
|
||||
import java.util
|
||||
import li.cil.oc.common.block.Delegator
|
||||
import li.cil.oc.common.tileentity
|
||||
import li.cil.oc.Settings
|
||||
import mcp.mobius.waila.api.{IWailaDataProvider, IWailaConfigHandler, IWailaDataAccessor, IWailaRegistrar}
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object Waila {
|
||||
@Optional.Method(modid = "Waila")
|
||||
def init(registrar: IWailaRegistrar) {
|
||||
registrar.registerBodyProvider(BlockDataProvider, classOf[Delegator[_]])
|
||||
registrar.registerSyncedNBTKey(Settings.namespace + "node", classOf[tileentity.Capacitor])
|
||||
registrar.registerSyncedNBTKey(Settings.namespace + "items", classOf[tileentity.DiskDrive])
|
||||
registrar.registerSyncedNBTKey(Settings.namespace + "node", classOf[tileentity.Hologram])
|
||||
registrar.registerSyncedNBTKey(Settings.namespace + "keyboard", classOf[tileentity.Keyboard])
|
||||
registrar.registerSyncedNBTKey(Settings.namespace + "node", classOf[tileentity.Screen])
|
||||
registrar.registerSyncedNBTKey(Settings.namespace + "componentNodes", classOf[tileentity.WirelessRouter])
|
||||
registrar.registerSyncedNBTKey(Settings.namespace + "strength", classOf[tileentity.WirelessRouter])
|
||||
}
|
||||
|
||||
def isSavingForTooltip = new Exception().getStackTrace.exists(_.getClassName.startsWith("mcp.mobius.waila"))
|
||||
}
|
||||
|
||||
object BlockDataProvider extends IWailaDataProvider {
|
||||
override def getWailaStack(accessor: IWailaDataAccessor, config: IWailaConfigHandler) =
|
||||
accessor.getBlock match {
|
||||
case delegator: Delegator[_] => delegator.subBlock(accessor.getMetadata).fold(null: ItemStack)(_.createItemStack())
|
||||
case _ => null
|
||||
}
|
||||
|
||||
override def getWailaHead(stack: ItemStack, tooltip: util.List[String], accessor: IWailaDataAccessor, config: IWailaConfigHandler) = tooltip
|
||||
|
||||
override def getWailaBody(stack: ItemStack, tooltip: util.List[String], accessor: IWailaDataAccessor, config: IWailaConfigHandler) = {
|
||||
accessor.getBlock match {
|
||||
case delegator: Delegator[_] => delegator.subBlock(accessor.getMetadata).foreach(_.wailaBody(stack, tooltip, accessor, config))
|
||||
case _ =>
|
||||
}
|
||||
tooltip
|
||||
}
|
||||
|
||||
override def getWailaTail(stack: ItemStack, tooltip: util.List[String], accessor: IWailaDataAccessor, config: IWailaConfigHandler) = tooltip
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user