Very start of a working teleportation system. Works for Energy and Fluids, probably Gases. Not Items yet.
This commit is contained in:
parent
f596848240
commit
40659dcdac
6 changed files with 262 additions and 3 deletions
|
@ -479,6 +479,8 @@ public class ClientProxy extends CommonProxy
|
|||
return new GuiUpgradeManagement(player.inventory, (IUpgradeTile)tileEntity);
|
||||
case 44:
|
||||
return new GuiLaserAmplifier(player.inventory, (TileEntityLaserAmplifier)tileEntity);
|
||||
case 45:
|
||||
return null; //new GuiEntangledBlock(player.sharedInventory, (TileEntityEntangledInventory)tileEntity);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -439,6 +439,8 @@ public class CommonProxy
|
|||
return new ContainerUpgradeManagement(player.inventory, (IUpgradeTile)tileEntity);
|
||||
case 44:
|
||||
return new ContainerNull(player, (TileEntityContainerBlock)tileEntity);
|
||||
case 45:
|
||||
return null; // new ContainerEntangledInventory(player.sharedInventory, (TileEntityEntangledInventory)tileEntity)
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -59,6 +59,7 @@ import mekanism.common.tile.TileEntityBoundingBlock;
|
|||
import mekanism.common.tile.TileEntityCardboardBox;
|
||||
import mekanism.common.tile.TileEntityElectricBlock;
|
||||
import mekanism.common.tile.TileEntityEnergizedSmelter;
|
||||
import mekanism.common.tile.TileEntityEntangledInventory;
|
||||
import mekanism.common.tile.TileEntitySalinationBlock;
|
||||
import mekanism.common.tile.TileEntitySalinationValve;
|
||||
import mekanism.common.transporter.TransporterManager;
|
||||
|
@ -935,6 +936,7 @@ public class Mekanism
|
|||
GameRegistry.registerTileEntity(TileEntityCardboardBox.class, "CardboardBox");
|
||||
GameRegistry.registerTileEntity(TileEntitySalinationValve.class, "SalinationValve");
|
||||
GameRegistry.registerTileEntity(TileEntitySalinationBlock.class, "SalinationTank");
|
||||
GameRegistry.registerTileEntity(TileEntityEntangledInventory.class, "EntangledBlock");
|
||||
|
||||
//Load tile entities that have special renderers.
|
||||
proxy.registerSpecialTileEntities();
|
||||
|
|
|
@ -48,6 +48,7 @@ import mekanism.common.tile.TileEntityElectrolyticSeparator;
|
|||
import mekanism.common.tile.TileEntityEliteFactory;
|
||||
import mekanism.common.tile.TileEntityEnergizedSmelter;
|
||||
import mekanism.common.tile.TileEntityEnrichmentChamber;
|
||||
import mekanism.common.tile.TileEntityEntangledInventory;
|
||||
import mekanism.common.tile.TileEntityFactory;
|
||||
import mekanism.common.tile.TileEntityFluidicPlenisher;
|
||||
import mekanism.common.tile.TileEntityLaser;
|
||||
|
@ -190,6 +191,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
icons[5][0] = register.registerIcon("mekanism:PrecisionSawmillFrontOff");
|
||||
icons[5][1] = register.registerIcon("mekanism:PrecisionSawmillFrontOn");
|
||||
icons[5][2] = register.registerIcon("mekanism:SteelCasing");
|
||||
icons[15][0] = register.registerIcon("mekanism:SteelCasing");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,6 +467,10 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
return icons[meta][0];
|
||||
}
|
||||
}
|
||||
else if(meta == 15)
|
||||
{
|
||||
return icons[meta][0];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -608,6 +614,10 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
return icons[metadata][0];
|
||||
}
|
||||
}
|
||||
else if(metadata == 15)
|
||||
{
|
||||
return icons[metadata][0];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -1201,7 +1211,8 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
PORTABLE_TANK(MekanismBlocks.MachineBlock2, 11, "PortableTank", 41, 0, TileEntityPortableTank.class, false, true, false),
|
||||
FLUIDIC_PLENISHER(MekanismBlocks.MachineBlock2, 12, "FluidicPlenisher", 42, 10000, TileEntityFluidicPlenisher.class, true, true, false),
|
||||
LASER(MekanismBlocks.MachineBlock2, 13, "Laser", -1, 100000, TileEntityLaser.class, true, true, false),
|
||||
LASER_AMPLIFIER(MekanismBlocks.MachineBlock2, 14, "LaserAmplifier", 44, 0, TileEntityLaserAmplifier.class, false, true, false);
|
||||
LASER_AMPLIFIER(MekanismBlocks.MachineBlock2, 14, "LaserAmplifier", 44, 0, TileEntityLaserAmplifier.class, false, true, false),
|
||||
ENTANGLED_BLOCK(MekanismBlocks.MachineBlock2, 15, "EntangledBlock", 45, 0, TileEntityEntangledInventory.class, true, false, false);
|
||||
|
||||
public Block typeBlock;
|
||||
public int meta;
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
package mekanism.common.teleportation;
|
||||
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class SharedInventory
|
||||
public class SharedInventory implements IStrictEnergyStorage, IFluidHandler, IGasHandler
|
||||
{
|
||||
public String name;
|
||||
|
||||
public double storedEnergy;
|
||||
public double MAX_ENERGY = 1000;
|
||||
public FluidTank storedFluid;
|
||||
public GasTank storedGas;
|
||||
public ItemStack storedItem;
|
||||
|
@ -23,4 +35,87 @@ public class SharedInventory
|
|||
storedGas = new GasTank(1000);
|
||||
storedItem = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return storedFluid.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if(resource.isFluidEqual(storedFluid.getFluid()))
|
||||
{
|
||||
return storedFluid.drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return storedFluid.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return storedFluid.getFluid() == null || fluid == storedFluid.getFluid().getFluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return storedFluid.getFluid() == null || fluid == storedFluid.getFluid().getFluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[]{new FluidTankInfo(storedFluid)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveGas(ForgeDirection side, GasStack stack)
|
||||
{
|
||||
return storedGas.receive(stack, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack drawGas(ForgeDirection side, int amount)
|
||||
{
|
||||
return storedGas.draw(amount, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
||||
{
|
||||
return storedGas.getGasType() == null || type == storedGas.getGasType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrawGas(ForgeDirection side, Gas type)
|
||||
{
|
||||
return storedGas.getGasType() == null || type == storedGas.getGasType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergy()
|
||||
{
|
||||
return storedEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(double energy)
|
||||
{
|
||||
storedEnergy = Math.max(0, Math.min(energy, MAX_ENERGY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxEnergy()
|
||||
{
|
||||
return MAX_ENERGY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,156 @@
|
|||
package mekanism.common.tile;
|
||||
|
||||
public class TileEntityEntangledInventory extends TileEntityElectricBlock
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.teleportation.SharedInventory;
|
||||
import mekanism.common.teleportation.SharedInventoryManager;
|
||||
import mekanism.common.util.CableUtils;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class TileEntityEntangledInventory extends TileEntityElectricBlock implements IFluidHandler, IGasHandler, ITubeConnection
|
||||
{
|
||||
public SharedInventory sharedInventory;
|
||||
|
||||
public TileEntityEntangledInventory()
|
||||
{
|
||||
super("Entangled", 0);
|
||||
inventory = new ItemStack[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
CableUtils.emit(this);
|
||||
}
|
||||
|
||||
public void setInventory(String frequency)
|
||||
{
|
||||
sharedInventory = SharedInventoryManager.getInventory(frequency);
|
||||
}
|
||||
|
||||
public EnumSet<ForgeDirection> getOutputtingSides()
|
||||
{
|
||||
return EnumSet.of(ForgeDirection.UP);
|
||||
}
|
||||
|
||||
protected EnumSet<ForgeDirection> getConsumingSides()
|
||||
{
|
||||
EnumSet set = EnumSet.allOf(ForgeDirection.class);
|
||||
set.remove(ForgeDirection.UNKNOWN);
|
||||
set.remove(ForgeDirection.UP);
|
||||
return set;
|
||||
}
|
||||
|
||||
public double getMaxOutput()
|
||||
{
|
||||
return sharedInventory == null ? 0 : 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergy()
|
||||
{
|
||||
return sharedInventory == null ? 0 : sharedInventory.getEnergy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(double energy)
|
||||
{
|
||||
if(sharedInventory != null)
|
||||
{
|
||||
sharedInventory.setEnergy(energy);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxEnergy()
|
||||
{
|
||||
return sharedInventory == null ? 0 : sharedInventory.getMaxEnergy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return sharedInventory == null ? 0 : sharedInventory.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if(sharedInventory == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return sharedInventory.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if(sharedInventory == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return sharedInventory.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return sharedInventory == null ? false : sharedInventory.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return sharedInventory == null ? false : sharedInventory.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return sharedInventory == null ? new FluidTankInfo[0] : sharedInventory.getTankInfo(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveGas(ForgeDirection side, GasStack stack)
|
||||
{
|
||||
return sharedInventory == null ? 0 : sharedInventory.receiveGas(side, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack drawGas(ForgeDirection side, int amount)
|
||||
{
|
||||
return sharedInventory == null ? null : sharedInventory.drawGas(side, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
||||
{
|
||||
return sharedInventory == null ? false : sharedInventory.canReceiveGas(side, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrawGas(ForgeDirection side, Gas type)
|
||||
{
|
||||
return sharedInventory == null ? false : sharedInventory.canDrawGas(side, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(ForgeDirection side)
|
||||
{
|
||||
return sharedInventory == null ? false : true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue