Forgot about generators!

This commit is contained in:
aidancbrady committed 2015-07-20 11:58:03 -07:00
1 parent ee709cc202
commit 728e497dd1
6 files changed
+82 -130

No files matched your search

@@ -1,32 +1,19 @@
package mekanism.generators.common.tile;
import java.util.ArrayList;
import java.util.EnumSet;
import io.netty.buffer.ByteBuf;
import mekanism.api.MekanismConfig.generators;
import mekanism.common.FluidSlot;
import mekanism.common.Mekanism;
import mekanism.common.MekanismItems;
import mekanism.common.base.ISustainedData;
import mekanism.common.util.ChargeUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import cpw.mods.fml.common.Optional.Method;
import net.minecraftforge.fluids.*;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import java.util.ArrayList;
import java.util.EnumSet;
public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandler, ISustainedData
{
@@ -224,16 +211,16 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite());
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getBioFuel", "getBioFuelNeeded"};
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
public String[] getMethods()
{
return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getBioFuel", "getBioFuelNeeded"};
return methods;
}
@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)
{
@@ -250,8 +237,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
case 5:
return new Object[] {bioFuelSlot.MAX_FLUID-bioFuelSlot.fluidStored};
default:
Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
return null;
throw new NoSuchMethodException();
}
}
@@ -1,33 +1,18 @@
package mekanism.generators.common.tile;
import java.util.ArrayList;
import io.netty.buffer.ByteBuf;
import mekanism.api.MekanismConfig.general;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection;
import mekanism.api.gas.*;
import mekanism.common.FuelHandler;
import mekanism.common.FuelHandler.FuelGas;
import mekanism.common.Mekanism;
import mekanism.common.base.ISustainedData;
import mekanism.common.util.ChargeUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import java.util.ArrayList;
public class TileEntityGasGenerator extends TileEntityGenerator implements IGasHandler, ITubeConnection, ISustainedData
{
@@ -171,16 +156,16 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
return fuelTank.getStored()*i / MAX_GAS;
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getGas", "getGasNeeded"};
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
public String[] getMethods()
{
return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getGas", "getGasNeeded"};
return methods;
}
@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)
{
@@ -197,8 +182,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
case 5:
return new Object[] {fuelTank.getNeeded()};
default:
Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
return null;
throw new NoSuchMethodException();
}
}
@@ -1,17 +1,22 @@
package mekanism.generators.common.tile;
import java.util.ArrayList;
import java.util.EnumSet;
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;
import mekanism.api.Range4D;
import mekanism.client.sound.ISoundSource;
import mekanism.client.sound.TileSound;
import mekanism.common.Mekanism;
import mekanism.common.base.IActiveState;
import mekanism.common.base.IHasSound;
import mekanism.common.base.IRedstoneControl;
import mekanism.common.integration.IComputerIntegration;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.tile.TileEntityNoisyElectricBlock;
import mekanism.common.util.CableUtils;
@@ -19,16 +24,11 @@ import mekanism.common.util.MekanismUtils;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
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 io.netty.buffer.ByteBuf;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock implements IPeripheral, IActiveState, IHasSound, ISoundSource, IRedstoneControl
import java.util.ArrayList;
import java.util.EnumSet;
public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock implements IComputerIntegration, IActiveState, IHasSound, ISoundSource, IRedstoneControl
{
/** Output per tick this generator can transfer. */
public double output;
@@ -146,6 +146,26 @@ public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock i
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) {}
@@ -1,18 +1,11 @@
package mekanism.generators.common.tile;
import java.util.ArrayList;
import io.netty.buffer.ByteBuf;
import mekanism.api.Coord4D;
import mekanism.api.IHeatTransfer;
import mekanism.api.MekanismConfig.generators;
import mekanism.common.Mekanism;
import mekanism.common.base.ISustainedData;
import mekanism.common.util.ChargeUtils;
import mekanism.common.util.FluidContainerUtils;
import mekanism.common.util.HeatUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.PipeUtils;
import mekanism.common.util.*;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@@ -20,21 +13,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fluids.IFluidHandler;
import cpw.mods.fml.common.Optional.Method;
import net.minecraftforge.fluids.*;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import java.util.ArrayList;
public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandler, ISustainedData, IHeatTransfer
{
@@ -295,16 +276,16 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
return data;
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getFuel", "getFuelNeeded"};
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
public String[] getMethods()
{
return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getFuel", "getFuelNeeded"};
return methods;
}
@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)
{
@@ -321,8 +302,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
case 5:
return new Object[] {lavaTank.getCapacity()-(lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0)};
default:
Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
return null;
throw new NoSuchMethodException();
}
}
@@ -1,27 +1,18 @@
package mekanism.generators.common.tile;
import java.util.ArrayList;
import java.util.EnumSet;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import mekanism.api.MekanismConfig.generators;
import mekanism.common.Mekanism;
import mekanism.common.util.ChargeUtils;
import mekanism.common.util.MekanismUtils;
import micdoodle8.mods.galacticraft.api.world.ISolarLevel;
import net.minecraft.item.ItemStack;
import net.minecraft.world.biome.BiomeGenDesert;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.ModAPIManager;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import micdoodle8.mods.galacticraft.api.world.ISolarLevel;
import java.util.ArrayList;
import java.util.EnumSet;
public class TileEntitySolarGenerator extends TileEntityGenerator
{
@@ -147,16 +138,16 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
return 0;
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getSeesSun"};
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
public String[] getMethods()
{
return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getSeesSun"};
return methods;
}
@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)
{
@@ -171,8 +162,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
case 4:
return new Object[] {seesSun};
default:
Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
return null;
throw new NoSuchMethodException();
}
}
@@ -1,20 +1,13 @@
package mekanism.generators.common.tile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.generators;
import mekanism.common.Mekanism;
import mekanism.common.base.IBoundingBlock;
import mekanism.common.util.ChargeUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.item.ItemStack;
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;
public class TileEntityWindTurbine extends TileEntityGenerator implements IBoundingBlock
{
@@ -77,16 +70,16 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound
return 1.5F;
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getMultiplier"};
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
public String[] getMethods()
{
return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getMultiplier"};
return methods;
}
@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)
{
@@ -101,8 +94,7 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound
case 4:
return new Object[] {getMultiplier()};
default:
Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
return null;
throw new NoSuchMethodException();
}
}