Added CC integration to Laser Amplifiers

This commit is contained in:
aidancbrady 2015-07-06 08:44:43 -07:00
parent e86df43477
commit 19ccc2c025
2 changed files with 53 additions and 3 deletions

View file

@ -182,8 +182,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPe
case 3:
return new Object[] {(getMaxEnergy()-getEnergy())};
default:
Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
return null;
return new Object[] {"Unknown command."};
}
}

View file

@ -21,8 +21,15 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
public class TileEntityLaserAmplifier extends TileEntityContainerBlock implements ILaserReceptor, IRedstoneControl, ICableOutputter, IStrictEnergyStorage
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
public class TileEntityLaserAmplifier extends TileEntityContainerBlock implements ILaserReceptor, IRedstoneControl, ICableOutputter, IStrictEnergyStorage, IPeripheral
{
public static final double MAX_ENERGY = 5E9;
public double collectedEnergy = 0;
@ -309,4 +316,48 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
{
return MAX_ENERGY;
}
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return new String[] {"getStored", "getMaxEnergy"};
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{
case 0:
return new Object[] {getEnergy()};
case 1:
return new Object[] {getMaxEnergy()};
default:
return new Object[] {"Unknown command."};
}
}
@Override
@Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public boolean equals(IPeripheral other)
{
return this == other;
}
}