Began work on Logistical Transporter - item transport :)

This commit is contained in:
Aidan Brady 2013-08-03 23:02:06 -04:00
parent 503c4eb0b5
commit 3fd76dcacc
11 changed files with 98 additions and 10 deletions

View file

@ -0,0 +1,6 @@
package mekanism.client;
public class RenderLogisticalTransporter
{
}

View file

@ -26,6 +26,15 @@ import net.minecraftforge.common.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Block class for handling multiple transmitter IDs.
* 0: Pressurized Tube
* 1: Universal Cable
* 2: Mechanical Pipe
* 3: Logistical Transporter
* @author AidanBrady
*
*/
public class BlockTransmitter extends Block
{
public BlockTransmitter(int id)
@ -48,6 +57,7 @@ public class BlockTransmitter extends Block
list.add(new ItemStack(i, 1, 0));
list.add(new ItemStack(i, 1, 1));
list.add(new ItemStack(i, 1, 2));
list.add(new ItemStack(i, 1, 3));
}
@Override
@ -323,6 +333,8 @@ public class BlockTransmitter extends Block
return new TileEntityUniversalCable();
case 2:
return new TileEntityMechanicalPipe();
case 3:
return new TileEntityLogisticalTransporter();
default:
return null;
}

View file

@ -15,6 +15,7 @@ import mekanism.api.Object3D;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.power.IPowerReceptor;
import universalelectricity.core.block.IElectrical;
public final class CableUtils
{
@ -31,7 +32,10 @@ public final class CableUtils
{
TileEntity acceptor = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(acceptor instanceof IStrictEnergyAcceptor || acceptor instanceof IEnergySink || (acceptor instanceof IPowerReceptor && !(acceptor instanceof IUniversalCable) && Mekanism.hooks.BuildCraftLoaded))
if(acceptor instanceof IStrictEnergyAcceptor ||
acceptor instanceof IEnergySink ||
(acceptor instanceof IPowerReceptor && !(acceptor instanceof IUniversalCable) && Mekanism.hooks.BuildCraftLoaded) ||
acceptor instanceof IElectrical)
{
acceptors[orientation.ordinal()] = acceptor;
}
@ -71,15 +75,15 @@ public final class CableUtils
{
boolean[] connectable = new boolean[] {false, false, false, false, false, false};
TileEntity[] connectedAcceptors = CableUtils.getConnectedEnergyAcceptors(tileEntity);
TileEntity[] connectedCables = CableUtils.getConnectedCables(tileEntity);
TileEntity[] connectedOutputters = CableUtils.getConnectedOutputters(tileEntity);
TileEntity[] connectedAcceptors = getConnectedEnergyAcceptors(tileEntity);
TileEntity[] connectedCables = getConnectedCables(tileEntity);
TileEntity[] connectedOutputters = getConnectedOutputters(tileEntity);
for(TileEntity tile : connectedAcceptors)
{
int side = Arrays.asList(connectedAcceptors).indexOf(tile);
if(CableUtils.canConnectToAcceptor(ForgeDirection.getOrientation(side), tileEntity))
if(canConnectToAcceptor(ForgeDirection.getOrientation(side), tileEntity))
{
connectable[side] = true;
}
@ -121,7 +125,9 @@ public final class CableUtils
{
TileEntity outputter = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(outputter instanceof ICableOutputter && ((ICableOutputter)outputter).canOutputTo(orientation.getOpposite()) || outputter instanceof IEnergySource && ((IEnergySource)outputter).emitsEnergyTo(tileEntity, MekanismUtils.toIC2Direction(orientation.getOpposite())))
if((outputter instanceof ICableOutputter && ((ICableOutputter)outputter).canOutputTo(orientation.getOpposite())) ||
(outputter instanceof IEnergySource && ((IEnergySource)outputter).emitsEnergyTo(tileEntity, MekanismUtils.toIC2Direction(orientation.getOpposite()))) ||
(outputter instanceof IElectrical && ((IElectrical)outputter).canConnect(orientation.getOpposite())))
{
outputters[orientation.ordinal()] = outputter;
}
@ -155,6 +161,11 @@ public final class CableUtils
return true;
}
if(tileEntity instanceof IElectrical && ((IElectrical)tileEntity).canConnect(side.getOpposite()))
{
return true;
}
if(tileEntity instanceof IPowerReceptor && !(tileEntity instanceof IUniversalCable) && Mekanism.hooks.BuildCraftLoaded)
{
if(!(tileEntity instanceof IEnergyAcceptor) || ((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(null, MekanismUtils.toIC2Direction(side).getInverse()))

View file

@ -42,6 +42,7 @@ public class CommonProxy
GameRegistry.registerTileEntity(TileEntityDynamicTank.class, "DynamicTank");
GameRegistry.registerTileEntity(TileEntityDynamicValve.class, "DynamicValve");
GameRegistry.registerTileEntity(TileEntityChargepad.class, "Chargepad");
GameRegistry.registerTileEntity(TileEntityLogisticalTransporter.class, "LogisticalTransporter");
}
/**

View file

@ -22,6 +22,8 @@ import net.minecraftforge.event.world.ChunkEvent;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.electricity.ElectricityPack;
public class EnergyNetwork
{
@ -76,6 +78,10 @@ public class EnergyNetwork
{
totalNeeded += (((IPowerReceptor)acceptor).getPowerReceiver(acceptorDirections.get(acceptor).getOpposite()).powerRequest()*Mekanism.FROM_BC);
}
else if(acceptor instanceof IElectrical)
{
totalNeeded += ((IElectrical)acceptor).getRequest(acceptorDirections.get(acceptor))*Mekanism.FROM_UE;
}
}
}
@ -85,7 +91,8 @@ public class EnergyNetwork
public double emit(double energyToSend, ArrayList<TileEntity> ignored)
{
double energyAvailable = energyToSend;
double sent;
double sent;
List availableAcceptors = Arrays.asList(getEnergyAcceptors().toArray());
Collections.shuffle(availableAcceptors);
@ -122,6 +129,12 @@ public class EnergyNetwork
receiver.receiveEnergy(Type.STORAGE, (float)(transferEnergy*Mekanism.TO_BC), acceptorDirections.get(acceptor).getOpposite());
energyToSend -= transferEnergy;
}
else if(acceptor instanceof IElectrical)
{
double toSend = Math.min(currentSending, ((IElectrical)acceptor).getRequest(acceptorDirections.get(acceptor).getOpposite())*Mekanism.FROM_UE);
ElectricityPack pack = ElectricityPack.getFromWatts((float)(toSend*Mekanism.TO_UE), ((IElectrical)acceptor).getVoltage());
energyToSend -= ((IElectrical)acceptor).receiveElectricity(acceptorDirections.get(acceptor).getOpposite(), pack, true)*Mekanism.FROM_UE;
}
}
}
@ -168,6 +181,16 @@ public class EnergyNetwork
}
}
}
else if(acceptor instanceof IElectrical)
{
if(((IElectrical)acceptor).canConnect(acceptorDirections.get(acceptor).getOpposite()))
{
if(((IElectrical)acceptor).getRequest(acceptorDirections.get(acceptor).getOpposite()) > 0)
{
toReturn.add(acceptor);
}
}
}
}
return toReturn;
@ -305,7 +328,7 @@ public class EnergyNetwork
if(nodeTile instanceof IUniversalCable)
{
((IUniversalCable) nodeTile).removeFromNetwork();
((IUniversalCable)nodeTile).removeFromNetwork();
newCables.add((IUniversalCable)nodeTile);
}
}
@ -320,6 +343,7 @@ public class EnergyNetwork
public void removeCable(IUniversalCable cable)
{
cables.remove(cable);
if(cables.size() == 0)
{
deregister();

View file

@ -19,6 +19,7 @@ import net.minecraft.util.Icon;
* 0: Pressurized Tube
* 1: Universal Cable
* 2: Mechanical Pipe
* 3: Logistical Transporter
* @author AidanBrady
*
*/
@ -60,6 +61,12 @@ public class ItemBlockTransmitter extends ItemBlock
list.add(EnumColor.DARK_GREY + "Capable of transferring:");
list.add("- " + EnumColor.PURPLE + "mB " + EnumColor.GREY + "(FluidRegistry)");
}
else if(itemstack.getItemDamage() == 3)
{
list.add(EnumColor.DARK_GREY + "Capable of transferring:");
list.add("- " + EnumColor.PURPLE + "Items (universal)");
list.add("- " + EnumColor.PURPLE + "Blocks (universal)");
}
}
}
@ -90,6 +97,9 @@ public class ItemBlockTransmitter extends ItemBlock
case 2:
name = "MechanicalPipe";
break;
case 3:
name = "LogisticalTransporter";
break;
default:
name = "Unknown";
break;

View file

@ -532,6 +532,7 @@ public class Mekanism
LanguageRegistry.instance().addStringLocalization("tile.Transmitter.PressurizedTube.name", "Pressurized Tube");
LanguageRegistry.instance().addStringLocalization("tile.Transmitter.UniversalCable.name", "Universal Cable");
LanguageRegistry.instance().addStringLocalization("tile.Transmitter.MechanicalPipe.name", "Mechanical Pipe");
LanguageRegistry.instance().addStringLocalization("tile.Transmitter.LogisticalTransporter.name", "Logistical Transporter");
//Localization for EnergyCube
LanguageRegistry.instance().addStringLocalization("tile.EnergyCube.Basic.name", "Basic Energy Cube");

View file

@ -0,0 +1,8 @@
package mekanism.common;
import net.minecraft.tileentity.TileEntity;
public class TileEntityLogisticalTransporter extends TileEntity
{
}

View file

@ -53,13 +53,28 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound
@Override
public String[] getMethodNames()
{
return null;
return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getMultiplier"};
}
@Override
public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception
{
return null;
switch(method)
{
case 0:
return new Object[] {electricityStored};
case 1:
return new Object[] {output};
case 2:
return new Object[] {MAX_ELECTRICITY};
case 3:
return new Object[] {(MAX_ELECTRICITY-electricityStored)};
case 4:
return new Object[] {getMultiplier()};
default:
System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID());
return null;
}
}
@Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB