Removed IReadOut in favor of IInformation

This commit is contained in:
Calclavia 2014-02-13 16:06:42 +08:00
parent fcb78c6a4a
commit b5f710992e
5 changed files with 27 additions and 66 deletions

View file

@ -8,7 +8,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import resonantinduction.api.EntityDictionary;
import resonantinduction.api.electrical.ArmbotEntity;
import resonantinduction.core.ArgumentData;
import resonantinduction.electrical.armbot.IArmbot;
import resonantinduction.electrical.armbot.TaskBaseProcess;
@ -98,7 +98,7 @@ public class TaskGrabEntity extends TaskGrabPrefab
{
super.loadProgress(taskCompound);
this.child = taskCompound.getBoolean("child");
this.entityToInclude = EntityDictionary.get(taskCompound.getString("name"));
this.entityToInclude = ArmbotEntity.get(taskCompound.getString("name"));
}
@Override
@ -106,7 +106,7 @@ public class TaskGrabEntity extends TaskGrabPrefab
{
super.saveProgress(taskCompound);
taskCompound.setBoolean("child", child);
taskCompound.setString("name", ((this.entityToInclude != null) ? EntityDictionary.get(this.entityToInclude) : ""));
taskCompound.setString("name", ((this.entityToInclude != null) ? ArmbotEntity.get(this.entityToInclude) : ""));
}
@Override
@ -116,7 +116,7 @@ public class TaskGrabEntity extends TaskGrabPrefab
String entity = "";
if (this.entityToInclude != null)
{
entity = EntityDictionary.get(this.entityToInclude);
entity = ArmbotEntity.get(this.entityToInclude);
if (this.child)
{
// TODO do check for EntityAgable

View file

@ -1,5 +1,7 @@
package resonantinduction.mechanical.fluid.prefab;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
@ -12,7 +14,7 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import resonantinduction.api.IReadOut;
import resonantinduction.api.IInformation;
import resonantinduction.api.mechanical.fluid.IFluidConnector;
import resonantinduction.api.mechanical.fluid.IFluidNetwork;
import resonantinduction.core.ResonantInduction;
@ -34,7 +36,7 @@ import cpw.mods.fml.relauncher.SideOnly;
* @author DarkCow
*
*/
public abstract class TileFluidNetwork extends TileAdvanced implements IFluidConnector, IPacketReceiverWithID, IReadOut
public abstract class TileFluidNetwork extends TileAdvanced implements IFluidConnector, IPacketReceiverWithID, IInformation
{
protected FluidTank tank;
protected Object[] connectedBlocks = new Object[6];
@ -301,13 +303,9 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
}
@Override
public String getMeterReading(EntityPlayer user, ForgeDirection side, EnumTools tool)
public void getInformation(List<String> info)
{
if (tool == EnumTools.PIPE_GUAGE)
{
return this.getNetwork().toString();
}
return null;
info.add(this.getNetwork().toString());
}
@Override

View file

@ -1,5 +1,8 @@
package resonantinduction.mechanical.item;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -10,8 +13,7 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.IReadOut;
import resonantinduction.api.IReadOut.EnumTools;
import resonantinduction.api.IInformation;
import calclavia.lib.utility.FluidUtility;
public class ItemPipeGauge extends Item
@ -31,17 +33,16 @@ public class ItemPipeGauge extends Item
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
ForgeDirection hitSide = ForgeDirection.getOrientation(side);
if (tileEntity instanceof IReadOut)
if (tileEntity instanceof IInformation)
{
String output = ((IReadOut) tileEntity).getMeterReading(player, hitSide, EnumTools.PIPE_GUAGE);
if (output != null && !output.isEmpty())
List<String> list = new ArrayList<String>();
((IInformation) tileEntity).getInformation(list);
if (list.size() > 0)
{
if (output.length() > 100)
{
output = output.substring(0, 100);
}
output.trim();
player.sendChatToPlayer(ChatMessageComponent.createFromText("ReadOut> " + output));
for (String output : list)
player.addChatMessage(output);
return true;
}
}
@ -51,10 +52,10 @@ public class ItemPipeGauge extends Item
if (tanks != null)
{
player.sendChatToPlayer(ChatMessageComponent.createFromText("FluidHandler> Side:" + hitSide.toString() + " Tanks:" + tanks.length));
for (FluidStack stack : FluidUtility.getFluidList(tanks))
{
player.sendChatToPlayer(ChatMessageComponent.createFromText("Fluid>" + stack.amount + "mb of " + stack.getFluid().getName()));
}
player.addChatMessage("Fluid: " + stack.amount + "mb of " + stack.getFluid().getName());
return true;
}
}

View file

@ -1,38 +0,0 @@
package resonantinduction.api;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.ForgeDirection;
/**
* Simple way to control the read-out display over several tools when they are used on the
* tileEntity
*
* @author DarkGuardsman
*/
@Deprecated
public interface IReadOut
{
/**
* Grabs the message displayed to the user on right click of the machine with the given tool
*
* @param user
* @param side - may not work correctly yet but should give you a side
* @return - a string to be displayed to the player for a reading. automatically adds ReadOut:
* to the beginning
*/
public String getMeterReading(EntityPlayer user, ForgeDirection side, EnumTools tool);
public static enum EnumTools
{
PIPE_GUAGE(), MULTI_METER();
public static EnumTools get(int meta)
{
if (meta < EnumTools.values().length)
{
return EnumTools.values()[meta];
}
return null;
}
}
}

View file

@ -1,4 +1,4 @@
package resonantinduction.api;
package resonantinduction.api.electrical;
import java.util.HashMap;
import java.util.List;
@ -30,7 +30,7 @@ import net.minecraft.entity.player.EntityPlayer;
*
* @author DarkGuardsman
*/
public class EntityDictionary
public class ArmbotEntity
{
public static HashMap<String, Class<? extends Entity>> entityMap = new HashMap();
public static HashMap<Class<? extends Entity>, Boolean> grabMap = new HashMap();