Cleaner CC support with a separate peripheral handler

This commit is contained in:
aidancbrady 2015-07-20 12:28:18 -07:00
parent 728e497dd1
commit c7fe1f86eb
18 changed files with 132 additions and 654 deletions

View file

@ -1,10 +1,15 @@
package mekanism.common.block;
import java.util.Random;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import mekanism.common.integration.CCPeripheral;
import mekanism.common.integration.IComputerIntegration;
import mekanism.common.tile.TileEntityAdvancedBoundingBlock;
import mekanism.common.tile.TileEntityBoundingBlock;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@ -14,13 +19,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import java.util.Random;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheralProvider", modid = "ComputerCraft")
public class BlockBounding extends Block implements IPeripheralProvider
@ -139,9 +139,9 @@ public class BlockBounding extends Block implements IPeripheralProvider
{
TileEntity te = world.getTileEntity(x, y, z);
if(te != null && te instanceof IPeripheral)
if(te != null && te instanceof IComputerIntegration)
{
return (IPeripheral)te;
return new CCPeripheral((IComputerIntegration)te);
}
return null;

View file

@ -1,8 +1,12 @@
package mekanism.common.block;
import java.util.List;
import java.util.Random;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import mekanism.api.energy.IEnergizedItem;
import mekanism.common.ItemAttacher;
import mekanism.common.Mekanism;
@ -10,12 +14,12 @@ import mekanism.common.MekanismBlocks;
import mekanism.common.Tier.EnergyCubeTier;
import mekanism.common.base.IEnergyCube;
import mekanism.common.base.ISustainedInventory;
import mekanism.common.integration.CCPeripheral;
import mekanism.common.integration.IComputerIntegration;
import mekanism.common.item.ItemBlockEnergyCube;
import mekanism.common.tile.TileEntityBasicBlock;
import mekanism.common.tile.TileEntityElectricBlock;
import mekanism.common.tile.TileEntityEnergyCube;
import mekanism.common.util.MekanismUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -27,21 +31,14 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.ModAPIManager;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import buildcraft.api.tools.IToolWrench;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import java.util.List;
import java.util.Random;
/**
* Block class for handling multiple energy cube block IDs.
@ -341,9 +338,9 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
{
TileEntity te = world.getTileEntity(x, y, z);
if(te != null && te instanceof IPeripheral)
if(te != null && te instanceof IComputerIntegration)
{
return (IPeripheral)te;
return new CCPeripheral((IComputerIntegration)te);
}
return null;

View file

@ -25,6 +25,8 @@ import mekanism.common.MekanismBlocks;
import mekanism.common.Tier.BaseTier;
import mekanism.common.base.*;
import mekanism.common.base.IFactory.RecipeType;
import mekanism.common.integration.CCPeripheral;
import mekanism.common.integration.IComputerIntegration;
import mekanism.common.item.ItemBlockMachine;
import mekanism.common.network.PacketElectricChest.ElectricChestMessage;
import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
@ -1302,9 +1304,9 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
{
TileEntity te = world.getTileEntity(x, y, z);
if(te != null && te instanceof IPeripheral)
if(te != null && te instanceof IComputerIntegration)
{
return (IPeripheral)te;
return new CCPeripheral((IComputerIntegration)te);
}
return null;

View file

@ -0,0 +1,62 @@
package mekanism.common.integration;
import cpw.mods.fml.common.Optional;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
/**
* Created by aidancbrady on 7/20/15.
*/
public class CCPeripheral implements IPeripheral
{
public IComputerIntegration computerTile;
public CCPeripheral(IComputerIntegration tile)
{
computerTile = tile;
}
@Override
@Optional.Method(modid = "ComputerCraft")
public String getType()
{
return computerTile.getInventoryName();
}
@Override
@Optional.Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return computerTile.getMethods();
}
@Override
@Optional.Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return computerTile.invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
@Override
@Optional.Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer) {}
@Override
@Optional.Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
@Override
@Optional.Method(modid = "ComputerCraft")
public boolean equals(IPeripheral other)
{
return this == other;
}
}

View file

@ -1,14 +1,11 @@
package mekanism.common.integration;
import cpw.mods.fml.common.Optional;
import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.inventory.IInventory;
/**
* Created by aidancbrady on 7/20/15.
*/
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
public interface IComputerIntegration extends IInventory, IPeripheral
public interface IComputerIntegration extends IInventory
{
public String[] getMethods();

View file

@ -4,10 +4,6 @@ import cofh.api.energy.IEnergyHandler;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
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;
import ic2.api.energy.tile.IEnergySink;
import mekanism.api.Coord4D;
import mekanism.api.IFilterAccess;
@ -391,38 +387,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
}
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
if(getInv() == null)
{
return null;
}
return getInv().getType();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return getMethods();
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
@Override
public String[] getMethods()
{
@ -445,37 +409,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
return getInv().invoke(method, arguments);
}
@Override
@Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer)
{
if(getInv() == null)
{
return;
}
getInv().attach(computer);
}
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer)
{
if(getInv() == null)
{
return;
}
getInv().detach(computer);
}
@Override
@Method(modid = "ComputerCraft")
public boolean equals(IPeripheral other)
{
return this == other;
}
@Override
public NBTTagCompound getFilterData(NBTTagCompound nbtTags)
{

View file

@ -1,10 +1,5 @@
package mekanism.common.tile;
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;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.general;
@ -226,54 +221,12 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
}
}
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public boolean equals(IPeripheral other)
{
return this == other;
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return getMethods();
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
@Override
public boolean canSetFacing(int facing)
{
return facing != 0 && facing != 1;
}
@Override
@Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
@Override
public int[] getAccessibleSlotsFromSide(int side)
{

View file

@ -1,12 +1,7 @@
package mekanism.common.tile;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import io.netty.buffer.ByteBuf;
import mekanism.api.Chunk3D;
import mekanism.api.Coord4D;
@ -1229,33 +1224,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
numPowering--;
}
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return getMethods();
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
public String[] methods = {"setRadius", "setMin", "setMax", "addFilter", "removeFilter", "addOreFilter", "removeOreFilter", "reset", "start", "stop"};
@Override
@ -1378,21 +1346,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
return null;
}
@Override
@Method(modid = "ComputerCraft")
public boolean equals(IPeripheral other)
{
return this == other;
}
@Override
@Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
@Override
public NBTTagCompound getFilterData(NBTTagCompound nbtTags)
{

View file

@ -1,10 +1,5 @@
package mekanism.common.tile;
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;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
@ -512,33 +507,6 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
return new Object[] {fluidTank};
}
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return getMethods();
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
private static final String[] methods = new String[] {"reset"};
@Override
@ -559,19 +527,4 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
throw new NoSuchMethodException();
}
}
@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;
}
}

View file

@ -1,10 +1,5 @@
package mekanism.common.tile;
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;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.api.Range4D;
@ -532,33 +527,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
nbtTags.setInteger("dumpRight", dumpRight.ordinal());
}
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return getMethods();
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getWater", "getWaterNeeded", "getHydrogen", "getHydrogenNeeded", "getOxygen", "getOxygenNeeded"};
@Override
@ -597,21 +565,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
}
}
@Override
@Method(modid = "ComputerCraft")
public boolean equals(IPeripheral other)
{
return this == other;
}
@Override
@Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
@Override
public boolean canTubeConnect(ForgeDirection side)
{

View file

@ -1,10 +1,5 @@
package mekanism.common.tile;
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;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.api.Range4D;
@ -150,33 +145,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
return false;
}
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return getMethods();
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded"};
@Override
@ -203,21 +171,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
}
}
@Override
@Method(modid = "ComputerCraft")
public boolean equals(IPeripheral other)
{
return this == other;
}
@Override
@Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
@Override
public void handlePacketData(ByteBuf dataStream)
{

View file

@ -1,12 +1,7 @@
package mekanism.common.tile;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
@ -782,33 +777,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
return tier.getBaseTier().getLocalizedName() + " " + recipeType.getLocalizedName() + " " + super.getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return getMethods();
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
private static final String[] methods = new String[] {"getStored", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
@Override
@ -869,21 +837,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
}
}
@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;
}
@Override
public void setActive(boolean active)
{

View file

@ -1,10 +1,5 @@
package mekanism.common.tile;
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;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
@ -503,33 +498,6 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
{
return false;
}
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return getMethods();
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
private static final String[] methods = new String[] {"reset"};
@ -541,32 +509,17 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception
{
switch(method)
{
case 0:
activeNodes.clear();
usedNodes.clear();
finishedCalc = false;
return new Object[] {"Plenisher calculation reset."};
default:
throw new NoSuchMethodException();
}
}
{
switch(method)
{
case 0:
activeNodes.clear();
usedNodes.clear();
finishedCalc = false;
@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;
}
return new Object[]{"Plenisher calculation reset."};
default:
throw new NoSuchMethodException();
}
}
}

View file

@ -1,10 +1,5 @@
package mekanism.common.tile;
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;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.general;
@ -314,33 +309,6 @@ 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 getMethods();
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
private static final String[] methods = new String[] {"getStored", "getMaxEnergy"};
@ -363,19 +331,4 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
throw new NoSuchMethodException();
}
}
@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;
}
}

View file

@ -1,10 +1,5 @@
package mekanism.common.tile;
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;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
@ -364,33 +359,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
return data;
}
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return getMethods();
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
private static final String[] methods = new String[] {"getStored", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded", "getInfuse", "getInfuseNeeded"};
@Override
@ -425,21 +393,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
}
}
@Override
@Method(modid = "ComputerCraft")
public boolean equals(IPeripheral other)
{
return this == other;
}
@Override
@Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
@Override
public int[] getAccessibleSlotsFromSide(int side)
{

View file

@ -1,13 +1,9 @@
package mekanism.common.tile;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import mekanism.api.Chunk3D;
import mekanism.api.Coord4D;
import mekanism.common.Mekanism;
@ -17,6 +13,7 @@ import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.chunkloading.IChunkLoader;
import mekanism.common.frequency.Frequency;
import mekanism.common.frequency.FrequencyManager;
import mekanism.common.integration.IComputerIntegration;
import mekanism.common.network.PacketPortalFX.PortalFXMessage;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.ChargeUtils;
@ -36,18 +33,10 @@ import net.minecraft.world.WorldServer;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.ForgeChunkManager.Type;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
public class TileEntityTeleporter extends TileEntityElectricBlock implements IPeripheral, IChunkLoader
import java.util.*;
public class TileEntityTeleporter extends TileEntityElectricBlock implements IComputerIntegration, IChunkLoader
{
private MinecraftServer server = MinecraftServer.getServer();
@ -655,23 +644,16 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
return ChargeUtils.canBeOutputted(itemstack, false);
}
private static final String[] methods = new String[] {"getStored", "canTeleport", "getMaxEnergy", "getEnergyNeeded", "teleport", "set"};
@Override
@Method(modid = "ComputerCraft")
public String getType()
public String[] getMethods()
{
return getInventoryName();
return methods;
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return new String[] {"getStored", "canTeleport", "getMaxEnergy", "getEnergyNeeded", "teleport", "set"};
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
public Object[] invoke(int method, Object[] arguments) throws Exception
{
switch(method)
{
@ -699,26 +681,10 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
return new Object[] {"Frequency set."};
default:
Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
return new Object[] {"Unknown command."};
throw new NoSuchMethodException();
}
}
@Override
@Method(modid = "ComputerCraft")
public boolean equals(IPeripheral other)
{
return this == other;
}
@Override
@Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()

View file

@ -1,30 +1,26 @@
package mekanism.generators.common.block;
import java.util.List;
import java.util.Random;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import mekanism.api.MekanismConfig.general;
import mekanism.api.energy.IEnergizedItem;
import mekanism.common.ItemAttacher;
import mekanism.common.Mekanism;
import mekanism.common.base.IActiveState;
import mekanism.common.base.IBoundingBlock;
import mekanism.common.base.ISpecialBounds;
import mekanism.common.base.ISustainedData;
import mekanism.common.base.ISustainedInventory;
import mekanism.common.base.ISustainedTank;
import mekanism.common.base.*;
import mekanism.common.integration.CCPeripheral;
import mekanism.common.integration.IComputerIntegration;
import mekanism.common.tile.TileEntityBasicBlock;
import mekanism.common.tile.TileEntityElectricBlock;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.generators.common.GeneratorsBlocks;
import mekanism.generators.common.MekanismGenerators;
import mekanism.generators.common.tile.TileEntityAdvancedSolarGenerator;
import mekanism.generators.common.tile.TileEntityBioGenerator;
import mekanism.generators.common.tile.TileEntityGasGenerator;
import mekanism.generators.common.tile.TileEntityHeatGenerator;
import mekanism.generators.common.tile.TileEntitySolarGenerator;
import mekanism.generators.common.tile.TileEntityWindTurbine;
import mekanism.generators.common.tile.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -41,14 +37,9 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.ModAPIManager;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import java.util.List;
import java.util.Random;
/**
@ -654,9 +645,9 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
{
TileEntity te = world.getTileEntity(x, y, z);
if(te != null && te instanceof IPeripheral)
if(te != null && te instanceof IComputerIntegration)
{
return (IPeripheral)te;
return new CCPeripheral((IComputerIntegration)te);
}
return null;

View file

@ -1,12 +1,7 @@
package mekanism.generators.common.tile;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.general;
@ -139,48 +134,6 @@ public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock i
}
}
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return getMethods();
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
try {
return invoke(method, arguments);
} catch(NoSuchMethodException e) {
return new Object[] {"Unknown command."};
} finally {
return new Object[] {"Error."};
}
}
@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;
}
@Override
public boolean canSetFacing(int side)
{