Quantum gates now transport fluids!
This commit is contained in:
parent
15c1b565ca
commit
45207ae2bb
7 changed files with 156 additions and 17 deletions
|
@ -52,7 +52,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Mod(modid = Electrical.ID, name = Electrical.NAME, version = Reference.VERSION, dependencies = "before:ThermalExpansion;after:ResonantInduction|Mechanical;required-after:" + ResonantInduction.ID)
|
@Mod(modid = Electrical.ID, name = Electrical.NAME, version = Reference.VERSION, dependencies = "before:ThermalExpansion;before:Mekanism;after:ResonantInduction|Mechanical;required-after:" + ResonantInduction.ID)
|
||||||
@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
||||||
public class Electrical
|
public class Electrical
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package resonantinduction.quantum.gate;
|
package resonantinduction.quantum.gate;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import icbm.api.IBlockFrequency;
|
import icbm.api.IBlockFrequency;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraftforge.fluids.FluidTank;
|
||||||
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only TileEntities should implement this.
|
* Only TileEntities should implement this.
|
||||||
|
@ -9,7 +11,9 @@ import icbm.api.IBlockFrequency;
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface IQuantumGate extends IBlockFrequency
|
public interface IQuantumGate extends IBlockFrequency, IFluidHandler
|
||||||
{
|
{
|
||||||
public void transport(Entity entity);
|
public void transport(Entity entity);
|
||||||
|
|
||||||
|
FluidTank getQuantumTank();
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class ItemQuantumGlyph extends JItemMultiPart implements IHighlight
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pos.offset(side);
|
//pos.offset(side);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import icbm.api.IBlockFrequency;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -14,6 +15,14 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import net.minecraftforge.fluids.FluidTank;
|
||||||
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
import net.minecraftforge.fluids.IFluidTank;
|
||||||
import resonantinduction.electrical.Electrical;
|
import resonantinduction.electrical.Electrical;
|
||||||
import universalelectricity.api.vector.VectorWorld;
|
import universalelectricity.api.vector.VectorWorld;
|
||||||
import codechicken.lib.data.MCDataInput;
|
import codechicken.lib.data.MCDataInput;
|
||||||
|
@ -60,7 +69,9 @@ public class PartQuantumGlyph extends JCuboidPart implements TSlottedPart, JNorm
|
||||||
public void onWorldJoin()
|
public void onWorldJoin()
|
||||||
{
|
{
|
||||||
if (((IQuantumGate) tile()).getFrequency() != -1)
|
if (((IQuantumGate) tile()).getFrequency() != -1)
|
||||||
|
{
|
||||||
FrequencyGrid.instance().register((IQuantumGate) tile());
|
FrequencyGrid.instance().register((IQuantumGate) tile());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -134,24 +145,25 @@ public class PartQuantumGlyph extends JCuboidPart implements TSlottedPart, JNorm
|
||||||
@Override
|
@Override
|
||||||
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack itemStack)
|
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack itemStack)
|
||||||
{
|
{
|
||||||
if (!world().isRemote)
|
if (player.isSneaking())
|
||||||
{
|
{
|
||||||
if (player.isSneaking())
|
if (!world().isRemote)
|
||||||
{
|
{
|
||||||
transport(player);
|
transport(player);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
int frequency = ((IBlockFrequency) tile()).getFrequency();
|
{
|
||||||
|
int frequency = ((IBlockFrequency) tile()).getFrequency();
|
||||||
|
|
||||||
if (frequency > -1)
|
if (frequency > -1)
|
||||||
|
{
|
||||||
|
if (!world().isRemote)
|
||||||
{
|
{
|
||||||
|
System.out.println(getQuantumTank());
|
||||||
player.addChatMessage("Quantum Gate Frequency: " + frequency);
|
player.addChatMessage("Quantum Gate Frequency: " + frequency);
|
||||||
}
|
}
|
||||||
else
|
return false;
|
||||||
{
|
|
||||||
player.addChatMessage("Quantum Gate not set up.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,4 +266,67 @@ public class PartQuantumGlyph extends JCuboidPart implements TSlottedPart, JNorm
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synced Fluid
|
||||||
|
*/
|
||||||
|
static final HashMap<Integer, FluidTank> quantumTanks = new HashMap<Integer, FluidTank>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidTank getQuantumTank()
|
||||||
|
{
|
||||||
|
int frequency = ((IQuantumGate) tile()).getFrequency();
|
||||||
|
|
||||||
|
if (frequency > -1)
|
||||||
|
{
|
||||||
|
if (!quantumTanks.containsKey(frequency))
|
||||||
|
quantumTanks.put(frequency, new FluidTank(FluidContainerRegistry.BUCKET_VOLUME));
|
||||||
|
|
||||||
|
return quantumTanks.get(frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||||
|
{
|
||||||
|
if (((IQuantumGate) tile()).getFrequency() != -1)
|
||||||
|
return getQuantumTank().fill(resource, doFill);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||||
|
{
|
||||||
|
if (((IQuantumGate) tile()).getFrequency() != -1)
|
||||||
|
return getQuantumTank().drain(resource.amount, doDrain);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||||
|
{
|
||||||
|
if (((IQuantumGate) tile()).getFrequency() != -1)
|
||||||
|
return getQuantumTank().drain(maxDrain, doDrain);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||||
|
{
|
||||||
|
return ((IQuantumGate) tile()).getFrequency() != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||||
|
{
|
||||||
|
return ((IQuantumGate) tile()).getFrequency() != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||||
|
{
|
||||||
|
return new FluidTankInfo[] { getQuantumTank().getInfo() };
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class QuantumGateManager
|
||||||
|
|
||||||
if (currentEntity instanceof EntityPlayerMP)
|
if (currentEntity instanceof EntityPlayerMP)
|
||||||
{
|
{
|
||||||
if (playerCooldown.get(((EntityPlayerMP) currentEntity).username) == null || (System.currentTimeMillis() - playerCooldown.get(((EntityPlayerMP) currentEntity).username) > 2000))
|
if (playerCooldown.get(((EntityPlayerMP) currentEntity).username) == null || (System.currentTimeMillis() - playerCooldown.get(((EntityPlayerMP) currentEntity).username) > 1000))
|
||||||
{
|
{
|
||||||
EntityPlayerMP player = (EntityPlayerMP) currentEntity;
|
EntityPlayerMP player = (EntityPlayerMP) currentEntity;
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,40 @@ import mffs.api.fortron.FrequencyGrid;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import net.minecraftforge.fluids.FluidTank;
|
||||||
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import universalelectricity.api.vector.VectorWorld;
|
import universalelectricity.api.vector.VectorWorld;
|
||||||
import codechicken.multipart.TMultiPart;
|
import codechicken.multipart.TMultiPart;
|
||||||
import codechicken.multipart.TileMultipart;
|
import codechicken.multipart.TileMultipart;
|
||||||
|
|
||||||
public class TraitQuantumGate extends TileMultipart implements IQuantumGate
|
public class TraitQuantumGate extends TileMultipart implements IQuantumGate
|
||||||
{
|
{
|
||||||
|
public PartQuantumGlyph get()
|
||||||
|
{
|
||||||
|
for (TMultiPart part : jPartList())
|
||||||
|
{
|
||||||
|
if (part instanceof PartQuantumGlyph)
|
||||||
|
{
|
||||||
|
return ((PartQuantumGlyph) part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidTank getQuantumTank()
|
||||||
|
{
|
||||||
|
return get().getQuantumTank();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transport(Entity entity)
|
public void transport(Entity entity)
|
||||||
{
|
{
|
||||||
|
get().transport(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,4 +73,40 @@ public class TraitQuantumGate extends TileMultipart implements IQuantumGate
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||||
|
{
|
||||||
|
return get().fill(from, resource, doFill);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||||
|
{
|
||||||
|
return get().drain(from, resource, doDrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||||
|
{
|
||||||
|
return get().drain(from, maxDrain, doDrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||||
|
{
|
||||||
|
return get().canFill(from, fluid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||||
|
{
|
||||||
|
return get().canDrain(from, fluid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||||
|
{
|
||||||
|
return get().getTankInfo(from);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
*
|
*
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*/
|
*/
|
||||||
@Mod(modid = ResonantInduction.ID, name = ResonantInduction.NAME, version = Reference.VERSION, dependencies = "required-after:ForgeMultipart@[1.0.0.244,);required-after:CalclaviaCore;before:IC2")
|
@Mod(modid = ResonantInduction.ID, name = ResonantInduction.NAME, version = Reference.VERSION, dependencies = "required-after:ForgeMultipart@[1.0.0.244,);required-after:CalclaviaCore;before:ThermalExpansion;before:Mekanism")
|
||||||
@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
||||||
@ModstatInfo(prefix = "resonantin")
|
@ModstatInfo(prefix = "resonantin")
|
||||||
public class ResonantInduction
|
public class ResonantInduction
|
||||||
|
|
Loading…
Reference in a new issue