Fixed all non-graphic errors(untested)
This commit is contained in:
parent
d4b3d3585a
commit
f760a4dcb4
14 changed files with 251 additions and 222 deletions
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import dark.core.api.ColorCode;
|
||||
import dark.core.api.INetworkPart;
|
||||
import dark.core.tile.network.NetworkTileEntities;
|
||||
|
@ -32,7 +34,8 @@ public class NetworkFluidContainers extends NetworkFluidTiles
|
|||
// TODO change this to place liquids at the bottom first
|
||||
public void balanceColletiveTank(boolean sumParts)
|
||||
{
|
||||
int volume = 0, itemID = 0, itemMeta = 0;
|
||||
int volume = 0;
|
||||
Fluid fluid = null;
|
||||
|
||||
if (sumParts)
|
||||
{
|
||||
|
@ -41,21 +44,20 @@ public class NetworkFluidContainers extends NetworkFluidTiles
|
|||
if (par instanceof INetworkFluidPart)
|
||||
{
|
||||
INetworkFluidPart part = ((INetworkFluidPart) par);
|
||||
if (part.getTank() != null && part.getTank().getLiquid() != null)
|
||||
if (part.getTank() != null && part.getTank().getFluid() != null)
|
||||
{
|
||||
if (itemID == 0)
|
||||
if (fluid == null)
|
||||
{
|
||||
itemID = part.getTank().getLiquid().itemID;
|
||||
itemMeta = part.getTank().getLiquid().itemMeta;
|
||||
fluid = part.getTank().getFluid().getFluid();
|
||||
}
|
||||
volume += part.getTank().getLiquid().amount;
|
||||
volume += part.getTank().getFluid().amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.combinedStorage().setLiquid(new LiquidStack(itemID, volume, itemMeta));
|
||||
this.combinedStorage().setFluid(new FluidStack(fluid, volume));
|
||||
this.loadedLiquids = true;
|
||||
}
|
||||
if (this.combinedStorage().getLiquid() != null && this.getNetworkMemebers().size() > 0)
|
||||
if (this.combinedStorage().getFluid() != null && this.getNetworkMemebers().size() > 0)
|
||||
{
|
||||
this.cleanUpMembers();
|
||||
|
||||
|
@ -72,9 +74,8 @@ public class NetworkFluidContainers extends NetworkFluidTiles
|
|||
highestY = ((TileEntity) part).yCoord;
|
||||
}
|
||||
}
|
||||
itemID = this.combinedStorage().getLiquid().itemID;
|
||||
itemMeta = this.combinedStorage().getLiquid().itemMeta;
|
||||
volume = this.combinedStorage().getLiquid().amount;
|
||||
fluid = this.combinedStorage().getFluid().getFluid();
|
||||
volume = this.combinedStorage().getFluid().amount;
|
||||
|
||||
for (int y = lowestY; y <= highestY; y++)
|
||||
{
|
||||
|
@ -92,7 +93,7 @@ public class NetworkFluidContainers extends NetworkFluidTiles
|
|||
{
|
||||
part.setTankContent(null);
|
||||
int fill = Math.min(fillvolume, part.getTank().getCapacity());
|
||||
part.setTankContent(new LiquidStack(itemID, fill, itemMeta));
|
||||
part.setTankContent(new FluidStack(fluid, fill));
|
||||
volume -= fill;
|
||||
}
|
||||
if (volume <= 0)
|
||||
|
@ -105,9 +106,9 @@ public class NetworkFluidContainers extends NetworkFluidTiles
|
|||
}
|
||||
|
||||
@Override
|
||||
public int storeFluidInSystem(LiquidStack stack, boolean doFill)
|
||||
public int storeFluidInSystem(FluidStack stack, boolean doFill)
|
||||
{
|
||||
int vol = this.combinedStorage().getLiquid() != null ? this.combinedStorage().getLiquid().amount : 0;
|
||||
int vol = this.combinedStorage().getFluid() != null ? this.combinedStorage().getFluid().amount : 0;
|
||||
int filled = super.storeFluidInSystem(stack, doFill);
|
||||
if (vol != filled)
|
||||
{
|
||||
|
@ -124,10 +125,10 @@ public class NetworkFluidContainers extends NetworkFluidTiles
|
|||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drainFluidFromSystem(int maxDrain, boolean doDrain)
|
||||
public FluidStack drainFluidFromSystem(int maxDrain, boolean doDrain)
|
||||
{
|
||||
LiquidStack vol = this.combinedStorage().getLiquid();
|
||||
LiquidStack stack = super.drainFluidFromSystem(maxDrain, doDrain);
|
||||
FluidStack vol = this.combinedStorage().getFluid();
|
||||
FluidStack stack = super.drainFluidFromSystem(maxDrain, doDrain);
|
||||
boolean flag = false;
|
||||
if (vol != null)
|
||||
{
|
||||
|
@ -164,4 +165,6 @@ public class NetworkFluidContainers extends NetworkFluidTiles
|
|||
newNetwork.cleanUpMembers();
|
||||
newNetwork.balanceColletiveTank(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -101,6 +101,15 @@ public class NetworkFluidTiles extends NetworkTileEntities
|
|||
return stack;
|
||||
}
|
||||
|
||||
public FluidStack drainFluidFromSystem(FluidStack stack, boolean doDrain)
|
||||
{
|
||||
if (stack != null && this.combinedStorage().getFluid() != null && stack.isFluidEqual(this.combinedStorage().getFluid()))
|
||||
{
|
||||
return this.drainFluidFromSystem(stack.amount, doDrain);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Moves the volume stored in the network to the parts or sums up the volume from the parts and
|
||||
* loads it to the network. Assumes that all liquidStacks stored are equal
|
||||
*
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import dark.core.api.ColorCode;
|
||||
|
@ -160,7 +161,7 @@ public class NetworkPipes extends NetworkFluidTiles
|
|||
@Override
|
||||
public boolean removeTile(TileEntity ent)
|
||||
{
|
||||
return super.removeTile(ent) || this.pressureLoads.remove(ent) || this.pressureProducers.remove(ent);
|
||||
return super.removeTile(ent) || this.pressureLoads.remove(ent) != null || this.pressureProducers.remove(ent) != null ;
|
||||
}
|
||||
|
||||
/** Adds FLuid to this network from one of the connected Pipes
|
||||
|
@ -224,24 +225,28 @@ public class NetworkPipes extends NetworkFluidTiles
|
|||
if (connectedTiles[i] instanceof INetworkPipe && ((INetworkPipe) connectedTiles[i]).getTileNetwork() == this)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i).getOpposite();
|
||||
IFluidTank targetTank = tankContainer.getTank(dir, stack);
|
||||
FluidTankInfo[] targetTank = tankContainer.getTankInfo(dir);
|
||||
int fill = tankContainer.fill(dir, stack, false);
|
||||
|
||||
/* USE GET TANK FROM SIDE METHOD FIRST */
|
||||
if (targetTank != null)
|
||||
{
|
||||
FluidStack stackStored = targetTank.getFluid();
|
||||
if (stackStored == null)
|
||||
for (int t = 0; t < targetTank.length; t++)
|
||||
{
|
||||
primaryFill = tankContainer;
|
||||
found = true;
|
||||
fillDir = dir;
|
||||
break;
|
||||
}
|
||||
else if (stackStored.amount < targetTank.getCapacity() && stackStored.amount < volume)
|
||||
{
|
||||
primaryFill = tankContainer;
|
||||
volume = stackStored.amount;
|
||||
FluidStack stackStored = targetTank[t].fluid;
|
||||
int tankCap = targetTank[t].capacity;
|
||||
if (stackStored == null)
|
||||
{
|
||||
primaryFill = tankContainer;
|
||||
found = true;
|
||||
fillDir = dir;
|
||||
break;
|
||||
}
|
||||
else if (stackStored.isFluidEqual(sta) && stackStored.amount < tankCap && stackStored.amount < volume)
|
||||
{
|
||||
primaryFill = tankContainer;
|
||||
volume = stackStored.amount;
|
||||
}
|
||||
}
|
||||
}/* USE FILL METHOD IF GET TANK == NULL */
|
||||
else if (fill > 0 && fill > mostFill)
|
||||
|
@ -281,7 +286,7 @@ public class NetworkPipes extends NetworkFluidTiles
|
|||
if (!filledMain && used > 0 && this.combinedStorage().getFluid() != null && this.combinedStorage().getFluid().amount > 0)
|
||||
{
|
||||
|
||||
LiquidStack drainStack = new LiquidStack(0, 0, 0);
|
||||
FluidStack drainStack = new FluidStack(0, 0);
|
||||
if (this.combinedStorage().getFluid().amount >= used)
|
||||
{
|
||||
drainStack = this.combinedStorage().drain(used, doFill);
|
||||
|
@ -308,21 +313,9 @@ public class NetworkPipes extends NetworkFluidTiles
|
|||
}
|
||||
|
||||
/** Gets the flow rate of the system using the lowest flow rate */
|
||||
public int getMaxFlow(LiquidStack stack)
|
||||
public int getMaxFlow(FluidStack stack)
|
||||
{
|
||||
int flow = 1000;
|
||||
for (INetworkPart conductor : this.networkMember)
|
||||
{
|
||||
if (conductor instanceof INetworkPipe)
|
||||
{
|
||||
int cFlow = ((INetworkPipe) conductor).getMaxFlowRate(stack, ForgeDirection.UNKNOWN);
|
||||
if (cFlow < flow)
|
||||
{
|
||||
flow = cFlow;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flow;
|
||||
return 1000;
|
||||
}
|
||||
|
||||
/** Updates after the pressure has changed a good bit */
|
||||
|
|
|
@ -3,6 +3,7 @@ package dark.fluid.client.render;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -22,11 +23,11 @@ public class RenderTank extends TileEntitySpecialRenderer
|
|||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||
{
|
||||
LiquidStack liquid = tileEntity instanceof TileEntityTank ? ((TileEntityTank) tileEntity).getTank().getLiquid() : null;
|
||||
FluidStack liquid = tileEntity instanceof TileEntityTank ? ((TileEntityTank) tileEntity).getTank().getFluid() : null;
|
||||
this.renderTank(tileEntity, x, y, z, 0, liquid);
|
||||
}
|
||||
|
||||
public void renderTank(TileEntity tileEntity, double x, double y, double z, int meta, LiquidStack liquid)
|
||||
public void renderTank(TileEntity tileEntity, double x, double y, double z, int meta, FluidStack liquid)
|
||||
{
|
||||
int[] render = new int[6];
|
||||
ColorCode color = ColorCode.get(meta >= 0 && meta < ColorCode.values().length ? meta : 0);
|
||||
|
|
|
@ -3,6 +3,7 @@ package dark.fluid.client.render.pipe;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -84,8 +85,8 @@ public class RenderPipe extends TileEntitySpecialRenderer
|
|||
{
|
||||
if (bool && FluidRestrictionHandler.hasRestrictedStack(meta))
|
||||
{
|
||||
FluidStack stack = FluidRestrictionHandler.getStackForColor(ColorCode.get(meta));
|
||||
String name = LiquidDictionary.findLiquidName(stack);
|
||||
Fluid stack = FluidRestrictionHandler.getStackForColor(ColorCode.get(meta));
|
||||
String name = stack != null ? stack.getName() : "";
|
||||
if (name != null)
|
||||
{
|
||||
return FluidMech.MODEL_TEXTURE_DIRECTORY + "pipes/" + name + "Pipe.png";
|
||||
|
|
|
@ -5,11 +5,15 @@ import java.util.Arrays;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.BlockFluidFinite;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
|
@ -22,6 +26,7 @@ import cpw.mods.fml.common.DummyModContainer;
|
|||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.Metadata;
|
||||
|
@ -137,7 +142,7 @@ public class FluidMech extends DummyModContainer
|
|||
MinecraftForge.EVENT_BUS.register(new FluidRestrictionHandler());
|
||||
}
|
||||
|
||||
@PreInit
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
/* LOGGER SETUP */
|
||||
|
@ -151,7 +156,10 @@ public class FluidMech extends DummyModContainer
|
|||
|
||||
/* CONFIGS */
|
||||
CONFIGURATION.load();
|
||||
|
||||
|
||||
/* LIQUID DIRECTORY CALL */
|
||||
Fluid waste = new Fluid("waste").setBlockID(FluidMech.CONFIGURATION.getBlock("WasteLiquid", BLOCK_ID_PREFIX + 7).getInt());
|
||||
|
||||
/* BLOCK DECLARATION -- CONFIG LOADER */
|
||||
blockGenPipe = new BlockPipe(FluidMech.CONFIGURATION.getBlock("Pipes", BLOCK_ID_PREFIX).getInt());
|
||||
blockMachine = new BlockPumpMachine(FluidMech.CONFIGURATION.getBlock("Machines", BLOCK_ID_PREFIX + 1).getInt());
|
||||
|
@ -159,7 +167,7 @@ public class FluidMech extends DummyModContainer
|
|||
blockGenerator = new BlockGenerator((FluidMech.CONFIGURATION.getBlock("Generator", BLOCK_ID_PREFIX + 4).getInt()));
|
||||
blockReleaseValve = new BlockReleaseValve((FluidMech.CONFIGURATION.getBlock("ReleaseValve", BLOCK_ID_PREFIX + 5).getInt()));
|
||||
blockTank = new BlockTank(FluidMech.CONFIGURATION.getBlock("Tank", BLOCK_ID_PREFIX + 6).getInt());
|
||||
blockWasteLiquid = new BlockWasteLiquid(FluidMech.CONFIGURATION.getBlock("WasteLiquid", BLOCK_ID_PREFIX + 7).getInt());
|
||||
blockWasteLiquid = new BlockFluidFinite(waste.getBlockID(), waste, Material.water);
|
||||
blockSink = new BlockSink(FluidMech.CONFIGURATION.getBlock("Sink", BLOCK_ID_PREFIX + 8).getInt());
|
||||
blockDrain = new BlockDrain(FluidMech.CONFIGURATION.getBlock("Drain", BLOCK_ID_PREFIX + 9).getInt());
|
||||
blockConPump = new BlockConstructionPump(FluidMech.CONFIGURATION.getBlock("ConstructionPump", BLOCK_ID_PREFIX + 10).getInt());
|
||||
|
@ -190,7 +198,7 @@ public class FluidMech extends DummyModContainer
|
|||
|
||||
}
|
||||
|
||||
@Init
|
||||
@EventHandler
|
||||
public void Init(FMLInitializationEvent event)
|
||||
{
|
||||
/* MCMOD.INFO FILE BUILDER? */
|
||||
|
@ -214,10 +222,10 @@ public class FluidMech extends DummyModContainer
|
|||
GameRegistry.registerTileEntity(TileEntityPipe.class, "lmPipeTile");
|
||||
GameRegistry.registerTileEntity(TileEntityGenericPipe.class, "lmGenPipeTile");
|
||||
GameRegistry.registerTileEntity(TileEntityStarterPump.class, "lmPumpTile");
|
||||
GameRegistry.registerTileEntity(TileEntityRod.class, "lmRodTile");
|
||||
//GameRegistry.registerTileEntity(TileEntityRod.class, "lmRodTile");
|
||||
GameRegistry.registerTileEntity(TileEntityReleaseValve.class, "lmeValve");
|
||||
GameRegistry.registerTileEntity(TileEntityTank.class, "lmTank");
|
||||
GameRegistry.registerTileEntity(TileEntityGenerator.class, "lmGen");
|
||||
//GameRegistry.registerTileEntity(TileEntityGenerator.class, "lmGen");
|
||||
GameRegistry.registerTileEntity(TileEntitySink.class, "lmSink");
|
||||
GameRegistry.registerTileEntity(TileEntityDrain.class, "lmDrain");
|
||||
GameRegistry.registerTileEntity(TileEntityConstructionPump.class, "lmConPump");
|
||||
|
@ -237,12 +245,9 @@ public class FluidMech extends DummyModContainer
|
|||
OreDictionary.registerOre("bronzeTube", new ItemStack(itemParts, 1, Parts.Bronze.ordinal()));
|
||||
OreDictionary.registerOre("unfinishedTank", new ItemStack(itemParts, 1, Parts.Tank.ordinal()));
|
||||
|
||||
/* LIQUID DIRECTORY CALL */
|
||||
LiquidStack waste = LiquidDictionary.getOrCreateLiquid("Waste", new LiquidStack(FluidMech.blockWasteLiquid, 1));
|
||||
|
||||
}
|
||||
|
||||
@PostInit
|
||||
@EventHandler
|
||||
public void PostInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
/* LOGGER */
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import dark.core.api.IToolReadOut;
|
||||
|
@ -62,7 +63,7 @@ public class ItemTools extends ItemBasic
|
|||
output = output.substring(0, 100);
|
||||
}
|
||||
output.trim();
|
||||
player.sendChatToPlayer("ReadOut: " + output);
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d("ReadOut: " + output));
|
||||
}
|
||||
}
|
||||
else if (meta == 1)
|
||||
|
|
|
@ -11,11 +11,14 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import dark.core.api.INetworkPart;
|
||||
import dark.core.hydraulic.helpers.FluidHelper;
|
||||
import dark.core.hydraulic.helpers.FluidRestrictionHandler;
|
||||
import dark.fluid.client.render.BlockRenderHelper;
|
||||
import dark.fluid.common.TabFluidMech;
|
||||
import dark.library.machine.AutoCraftingManager;
|
||||
import dark.library.machine.BlockMachine;
|
||||
|
||||
public class BlockTank extends BlockMachine
|
||||
|
@ -65,7 +68,7 @@ public class BlockTank extends BlockMachine
|
|||
if (current != null)
|
||||
{
|
||||
|
||||
LiquidStack liquid = LiquidContainerRegistry.getLiquidForFilledItem(current);
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current);
|
||||
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
|
@ -78,13 +81,13 @@ public class BlockTank extends BlockMachine
|
|||
{
|
||||
if (current.isItemEqual(new ItemStack(Item.potion)))
|
||||
{
|
||||
liquid = new LiquidStack(liquid.itemID, (LiquidContainerRegistry.BUCKET_VOLUME / 4), liquid.itemMeta);
|
||||
liquid = FluidHelper.getStack(liquid, FluidContainerRegistry.BUCKET_VOLUME / 4);
|
||||
}
|
||||
int filled = tank.fill(ForgeDirection.getOrientation(side), liquid, true);
|
||||
|
||||
if (filled != 0 && !entityplayer.capabilities.isCreativeMode)
|
||||
{
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current));
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, AutoCraftingManager.consumeItem(current, 1));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -94,12 +97,12 @@ public class BlockTank extends BlockMachine
|
|||
else
|
||||
{
|
||||
|
||||
LiquidStack stack = tank.getTank().getLiquid();
|
||||
FluidStack stack = tank.getTank().getFluid();
|
||||
if (stack != null)
|
||||
{
|
||||
ItemStack liquidItem = LiquidContainerRegistry.fillLiquidContainer(stack, current);
|
||||
ItemStack liquidItem = FluidContainerRegistry.fillFluidContainer(stack, current);
|
||||
|
||||
liquid = LiquidContainerRegistry.getLiquidForFilledItem(liquidItem);
|
||||
liquid = FluidContainerRegistry.getFluidForFilledItem(liquidItem);
|
||||
|
||||
if (liquid != null)
|
||||
{
|
||||
|
@ -111,19 +114,19 @@ public class BlockTank extends BlockMachine
|
|||
return false;
|
||||
else
|
||||
{
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current));
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, AutoCraftingManager.consumeItem(current, 1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, FluidHelper.consumeItem(current));
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, AutoCraftingManager.consumeItem(current, 1));
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, liquidItem);
|
||||
}
|
||||
}
|
||||
int ammount = liquid.amount;
|
||||
if (current.isItemEqual(new ItemStack(Item.glassBottle)))
|
||||
{
|
||||
ammount = (LiquidContainerRegistry.BUCKET_VOLUME / 4);
|
||||
ammount = (FluidContainerRegistry.BUCKET_VOLUME / 4);
|
||||
}
|
||||
tank.drain(ForgeDirection.getOrientation(side), ammount, true);
|
||||
return true;
|
||||
|
|
|
@ -7,6 +7,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import dark.core.api.ColorCode;
|
||||
import dark.core.api.IColorCoded;
|
||||
import dark.core.api.ITileConnector;
|
||||
|
@ -22,7 +25,7 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements ITi
|
|||
public TileEntity[] connected = new TileEntity[6];
|
||||
|
||||
private List<INetworkPipe> output = new ArrayList<INetworkPipe>();
|
||||
private ITankContainer[] input = new ITankContainer[6];
|
||||
private IFluidHandler[] input = new IFluidHandler[6];
|
||||
|
||||
public boolean isPowered = false;
|
||||
|
||||
|
@ -37,7 +40,7 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements ITi
|
|||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (connected[dir.ordinal()] instanceof ITankContainer)
|
||||
if (connected[dir.ordinal()] instanceof IFluidHandler)
|
||||
{
|
||||
if (connected[dir.ordinal()] instanceof IColorCoded && !this.canConnect(((IColorCoded) connected[dir.ordinal()]).getColor()))
|
||||
{
|
||||
|
@ -56,10 +59,10 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements ITi
|
|||
// start the draining process
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
ITankContainer drainedTank = input[dir.ordinal()];
|
||||
IFluidHandler drainedTank = input[dir.ordinal()];
|
||||
if (drainedTank != null)
|
||||
{
|
||||
LiquidStack stack = drainedTank.drain(dir.getOpposite(), LiquidContainerRegistry.BUCKET_VOLUME, false);
|
||||
FluidStack stack = drainedTank.drain(dir.getOpposite(), FluidContainerRegistry.BUCKET_VOLUME, false);
|
||||
if (stack != null && stack.amount > 0)
|
||||
{
|
||||
INetworkPipe inputPipe = this.findValidPipe(stack);
|
||||
|
@ -76,7 +79,7 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements ITi
|
|||
}
|
||||
|
||||
/** used to find a valid pipe for filling of the liquid type */
|
||||
public INetworkPipe findValidPipe(LiquidStack stack)
|
||||
public INetworkPipe findValidPipe(FluidStack stack)
|
||||
{
|
||||
// find normal color selective pipe first
|
||||
for (INetworkPipe pipe : output)
|
||||
|
@ -127,7 +130,7 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements ITi
|
|||
{
|
||||
// cleanup
|
||||
this.connected = ConnectionHelper.getSurroundingTileEntities(worldObj, xCoord, yCoord, zCoord);
|
||||
this.input = new ITankContainer[6];
|
||||
this.input = new IFluidHandler[6];
|
||||
this.output.clear();
|
||||
// read surroundings
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
|
@ -145,12 +148,12 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements ITi
|
|||
this.connected[dir.ordinal()] = null;
|
||||
}
|
||||
}
|
||||
else if (tileEntity instanceof ITankContainer)
|
||||
else if (tileEntity instanceof IFluidHandler)
|
||||
{
|
||||
ITankContainer tank = (ITankContainer) tileEntity;
|
||||
if (tank != null && tank.drain(dir.getOpposite(), LiquidContainerRegistry.BUCKET_VOLUME, false) != null)
|
||||
IFluidHandler tank = (IFluidHandler) tileEntity;
|
||||
if (tank != null && tank.drain(dir.getOpposite(), FluidContainerRegistry.BUCKET_VOLUME, false) != null)
|
||||
{
|
||||
this.input[dir.ordinal()] = (ITankContainer) tileEntity;
|
||||
this.input[dir.ordinal()] = (IFluidHandler) tileEntity;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -163,7 +166,7 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements ITi
|
|||
@Override
|
||||
public boolean canTileConnect(TileEntity entity, ForgeDirection dir)
|
||||
{
|
||||
return entity != null && entity instanceof ITankContainer && entity instanceof IColorCoded && this.canConnect(((IColorCoded) entity).getColor());
|
||||
return entity != null && entity instanceof IFluidHandler && entity instanceof IColorCoded && this.canConnect(((IColorCoded) entity).getColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,25 +1,29 @@
|
|||
package dark.fluid.common.machines;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import dark.core.api.ColorCode;
|
||||
import dark.core.api.IColorCoded;
|
||||
import dark.fluid.common.FluidMech;
|
||||
import dark.fluid.common.prefab.TileEntityFluidStorage;
|
||||
|
||||
public class TileEntitySink extends TileEntityFluidStorage implements IPacketReceiver, ITankContainer, IColorCoded
|
||||
public class TileEntitySink extends TileEntityFluidStorage implements IPacketReceiver
|
||||
{
|
||||
@Override
|
||||
public int getTankSize()
|
||||
{
|
||||
return LiquidContainerRegistry.BUCKET_VOLUME * 2;
|
||||
return FluidContainerRegistry.BUCKET_VOLUME * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,14 +41,15 @@ public class TileEntitySink extends TileEntityFluidStorage implements IPacketRec
|
|||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
LiquidStack stack = this.tank.getLiquid();
|
||||
if (stack != null)
|
||||
FluidStack stack = this.tank.getFluid();
|
||||
if (stack != null && stack.getFluid() != null)
|
||||
{
|
||||
return PacketManager.getPacket(FluidMech.CHANNEL, this, stack.itemID, stack.amount, stack.itemMeta);
|
||||
return PacketManager.getPacket(FluidMech.CHANNEL, this, stack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return PacketManager.getPacket(FluidMech.CHANNEL, this, 0, 0, 0);
|
||||
stack = new FluidStack(0, 0);
|
||||
return PacketManager.getPacket(FluidMech.CHANNEL, this, stack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +58,7 @@ public class TileEntitySink extends TileEntityFluidStorage implements IPacketRec
|
|||
{
|
||||
try
|
||||
{
|
||||
this.tank.setLiquid(new LiquidStack(data.readInt(), data.readInt(), data.readInt()));
|
||||
this.tank.setFluid(FluidStack.loadFluidStackFromNBT(PacketManager.readNBTTagCompound(data)));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -64,13 +69,34 @@ public class TileEntitySink extends TileEntityFluidStorage implements IPacketRec
|
|||
}
|
||||
|
||||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
public int fill(ForgeDirection side, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (doFill)
|
||||
int f = super.fill(side, resource, doFill);
|
||||
if (doFill && f > 0)
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
return super.fill(tankIndex, resource, doFill);
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return fluid != null && fluid.getName().equalsIgnoreCase("water") && from != ForgeDirection.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,5 +109,4 @@ public class TileEntitySink extends TileEntityFluidStorage implements IPacketRec
|
|||
{
|
||||
return ColorCode.BLUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dark.fluid.common.machines;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -12,6 +13,13 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.tileentity.TileEntityComparator;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
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 org.bouncycastle.util.Arrays;
|
||||
|
||||
|
@ -32,15 +40,15 @@ import dark.core.tile.network.NetworkTileEntities;
|
|||
import dark.fluid.api.INetworkFluidPart;
|
||||
import dark.fluid.api.INetworkPipe;
|
||||
import dark.fluid.common.FluidMech;
|
||||
import dark.fluid.common.prefab.TileEntityFluidDevice;
|
||||
import dark.fluid.common.prefab.TileEntityFluidStorage;
|
||||
|
||||
public class TileEntityTank extends TileEntityFluidDevice implements ITankContainer, IToolReadOut, IColorCoded, INetworkFluidPart, IPacketReceiver
|
||||
public class TileEntityTank extends TileEntityFluidStorage implements IFluidHandler, IToolReadOut, IColorCoded, INetworkFluidPart, IPacketReceiver
|
||||
{
|
||||
/* CURRENTLY CONNECTED TILE ENTITIES TO THIS */
|
||||
private List<TileEntity> connectedBlocks = new ArrayList<TileEntity>();
|
||||
public int[] renderConnection = new int[6];
|
||||
|
||||
private LiquidTank tank = new LiquidTank(this.getTankSize());
|
||||
private FluidTank tank = new FluidTank(this.getTankSize());
|
||||
|
||||
/* NETWORK INSTANCE THAT THIS PIPE USES */
|
||||
private NetworkFluidContainers fluidNetwork;
|
||||
|
@ -78,31 +86,41 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai
|
|||
@Override
|
||||
public void handlePacketData(INetworkManager network, int type, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
||||
{
|
||||
if (this.worldObj.isRemote)
|
||||
try
|
||||
{
|
||||
int id = dataStream.readInt();
|
||||
if (id == 0)
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
this.tank.setLiquid(new LiquidStack(dataStream.readInt(), dataStream.readInt(), dataStream.readInt()));
|
||||
this.renderConnection[0] = dataStream.readInt();
|
||||
this.renderConnection[1] = dataStream.readInt();
|
||||
this.renderConnection[2] = dataStream.readInt();
|
||||
this.renderConnection[3] = dataStream.readInt();
|
||||
this.renderConnection[4] = dataStream.readInt();
|
||||
this.renderConnection[5] = dataStream.readInt();
|
||||
int id = dataStream.readInt();
|
||||
if (id == 0)
|
||||
{
|
||||
|
||||
this.tank.setFluid(FluidStack.loadFluidStackFromNBT(PacketManager.readNBTTagCompound(dataStream)));
|
||||
|
||||
this.renderConnection[0] = dataStream.readInt();
|
||||
this.renderConnection[1] = dataStream.readInt();
|
||||
this.renderConnection[2] = dataStream.readInt();
|
||||
this.renderConnection[3] = dataStream.readInt();
|
||||
this.renderConnection[4] = dataStream.readInt();
|
||||
this.renderConnection[5] = dataStream.readInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
LiquidStack stack = new LiquidStack(0, 0, 0);
|
||||
if (this.getTank().getLiquid() != null)
|
||||
FluidStack stack = new FluidStack(0, 0);
|
||||
if (this.getTank().getFluid() != null)
|
||||
{
|
||||
stack = this.getTank().getLiquid();
|
||||
stack = this.getTank().getFluid();
|
||||
}
|
||||
return PacketManager.getPacket(FluidMech.CHANNEL, this, 0, stack.itemID, stack.amount, stack.itemMeta, this.renderConnection[0], this.renderConnection[1], this.renderConnection[2], this.renderConnection[3], this.renderConnection[4], this.renderConnection[5]);
|
||||
return PacketManager.getPacket(FluidMech.CHANNEL, this, 0, stack.writeToNBT(new NBTTagCompound()), this.renderConnection[0], this.renderConnection[1], this.renderConnection[2], this.renderConnection[3], this.renderConnection[4], this.renderConnection[5]);
|
||||
}
|
||||
|
||||
/** gets the current color mark of the pipe */
|
||||
|
@ -140,15 +158,9 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai
|
|||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return this.fill(0, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (tankIndex != 0 || resource == null || !FluidRestrictionHandler.isValidLiquid(this.getColor(), resource) || this.worldObj.isRemote)
|
||||
if (resource == null || !FluidRestrictionHandler.isValidLiquid(this.getColor(), resource.getFluid()) || this.worldObj.isRemote)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -156,15 +168,19 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai
|
|||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
public FluidStack drain(ForgeDirection from, FluidStack stack, boolean doDrain)
|
||||
{
|
||||
return this.drain(0, maxDrain, doDrain);
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return ((NetworkFluidContainers) this.getTileNetwork()).drainFluidFromSystem(stack, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (tankIndex != 0 || this.worldObj.isRemote)
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -172,19 +188,9 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai
|
|||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks(ForgeDirection direction)
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection direction)
|
||||
{
|
||||
return new ILiquidTank[] { ((NetworkFluidContainers) this.getTileNetwork()).combinedStorage() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
if (FluidRestrictionHandler.isValidLiquid(this.getColor(), type))
|
||||
{
|
||||
return ((NetworkFluidContainers) this.getTileNetwork()).combinedStorage();
|
||||
}
|
||||
return null;
|
||||
return new FluidTankInfo[] { new FluidTankInfo(((NetworkFluidContainers) this.getTileNetwork()).combinedStorage()) };
|
||||
}
|
||||
|
||||
/** Checks to make sure the connection is valid to the tileEntity
|
||||
|
@ -241,7 +247,7 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai
|
|||
@Override
|
||||
public boolean canTileConnect(TileEntity entity, ForgeDirection dir)
|
||||
{
|
||||
return entity != null && entity instanceof ITankContainer;
|
||||
return entity != null && entity instanceof IFluidHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -275,66 +281,52 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai
|
|||
return this.connectedBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
LiquidStack liquid = LiquidStack.loadLiquidStackFromNBT(nbt.getCompoundTag("stored"));
|
||||
if (liquid != null)
|
||||
{
|
||||
tank.setLiquid(liquid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
if (this.tank.containsValidLiquid())
|
||||
{
|
||||
nbt.setTag("stored", this.tank.getLiquid().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
public int getTankSize()
|
||||
{
|
||||
return LiquidContainerRegistry.BUCKET_VOLUME * 8;
|
||||
return FluidContainerRegistry.BUCKET_VOLUME * 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank()
|
||||
public FluidTank getTank()
|
||||
{
|
||||
if (this.tank == null)
|
||||
{
|
||||
this.tank = new LiquidTank(this.getTankSize());
|
||||
this.tank = new FluidTank(this.getTankSize());
|
||||
}
|
||||
return this.tank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTankContent(LiquidStack stack)
|
||||
public void setTankContent(FluidStack stack)
|
||||
{
|
||||
if (this.tank == null)
|
||||
{
|
||||
this.tank = new LiquidTank(this.getTankSize());
|
||||
}
|
||||
this.tank.setLiquid(stack);
|
||||
this.getTank().setFluid(stack);
|
||||
}
|
||||
|
||||
public int getRedstoneLevel()
|
||||
{
|
||||
if (this.getTileNetwork() != null && this.getTileNetwork() instanceof NetworkFluidTiles)
|
||||
{
|
||||
ILiquidTank tank = ((NetworkFluidTiles) this.getTileNetwork()).combinedStorage();
|
||||
if (tank != null && tank.getLiquid() != null)
|
||||
IFluidTank tank = ((NetworkFluidTiles) this.getTileNetwork()).combinedStorage();
|
||||
if (tank != null && tank.getFluid() != null)
|
||||
{
|
||||
int max = tank.getCapacity();
|
||||
int current = tank.getLiquid().amount;
|
||||
int current = tank.getFluid().amount;
|
||||
double percent = current / max;
|
||||
return ((int) (15 * percent));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return fluid != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return fluid != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,13 +117,13 @@ public class BlockPipe extends BlockMachine
|
|||
if (entity instanceof TileEntityPipe)
|
||||
{
|
||||
IFluidTank tank = ((TileEntityPipe) entity).getTank();
|
||||
if (tank != null && tank.getLiquid() != null && tank.getLiquid().amount > 0)
|
||||
if (tank != null && tank.getFluid() != null && tank.getFluid().getFluid() != null && tank.getFluid().amount > 0)
|
||||
{
|
||||
if (tank.getLiquid().itemID == Block.waterStill.blockID)
|
||||
if (tank.getFluid().getFluid().getName().equalsIgnoreCase("water"))
|
||||
{
|
||||
world.setBlock(x, y, z, Block.waterStill.blockID);
|
||||
}
|
||||
if (tank.getLiquid().itemID == Block.lavaStill.blockID)
|
||||
if (tank.getFluid().getFluid().getName().equalsIgnoreCase("lava"))
|
||||
{
|
||||
world.setBlock(x, y, z, Block.lavaStill.blockID);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package dark.fluid.common.pipes;
|
|||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.core.vector.VectorHelper;
|
||||
import dark.core.api.ColorCode;
|
||||
|
@ -11,7 +14,7 @@ import dark.core.network.fluid.NetworkPipes;
|
|||
public class TileEntityGenericPipe extends TileEntityPipe
|
||||
{
|
||||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null)
|
||||
{
|
||||
|
@ -21,22 +24,6 @@ public class TileEntityGenericPipe extends TileEntityPipe
|
|||
return ((NetworkPipes) this.getTileNetwork()).addFluidToNetwork(tile, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (tankIndex != 0 || resource == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ((NetworkPipes) this.getTileNetwork()).addFluidToNetwork(this, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
return this.fakeTank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTileConnect(TileEntity entity, ForgeDirection dir)
|
||||
{
|
||||
|
@ -53,9 +40,9 @@ public class TileEntityGenericPipe extends TileEntityPipe
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate(LiquidStack stack, ForgeDirection side)
|
||||
public int getMaxFlowRate(Fluid stack, ForgeDirection side)
|
||||
{
|
||||
return FluidHelper.getDefaultFlowRate(stack);
|
||||
return FluidContainerRegistry.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,7 @@ 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.IFluidHandler;
|
||||
|
||||
import org.bouncycastle.util.Arrays;
|
||||
|
@ -406,31 +407,15 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
|
|||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection direction)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks(ForgeDirection direction)
|
||||
{
|
||||
return new ILiquidTank[] { this.fakeTank };
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
if (FluidRestrictionHandler.isValidLiquid(this.getColor(), type))
|
||||
{
|
||||
return this.fakeTank;
|
||||
}
|
||||
return null;
|
||||
return new FluidTankInfo[] { new FluidTankInfo(this.getTank()) };
|
||||
}
|
||||
|
||||
/** Checks to make sure the connection is valid to the tileEntity
|
||||
|
@ -472,7 +457,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
|
|||
return connectedBlocks.add(tileEntity);
|
||||
}
|
||||
}
|
||||
else if (tileEntity instanceof ITankContainer)
|
||||
else if (tileEntity instanceof IFluidHandler)
|
||||
{
|
||||
return connectedBlocks.add(tileEntity);
|
||||
}
|
||||
|
@ -495,14 +480,14 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
|
|||
TileEntity ent = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj);
|
||||
this.renderConnection[dir.ordinal()] = this.validateConnectionSide(ent, dir);
|
||||
|
||||
if (this.renderConnection[dir.ordinal()] && ent instanceof ITankContainer && !(ent instanceof INetworkPipe))
|
||||
if (this.renderConnection[dir.ordinal()] && ent instanceof IFluidHandler && !(ent instanceof INetworkPipe))
|
||||
{
|
||||
ITankContainer tankContainer = (ITankContainer) ent;
|
||||
IFluidHandler tankContainer = (IFluidHandler) ent;
|
||||
this.getTileNetwork().addTile(ent, false);
|
||||
|
||||
/* LITTLE TRICK TO AUTO DRAIN TANKS ON EACH CONNECTION UPDATE */
|
||||
|
||||
LiquidStack stack = tankContainer.drain(dir, LiquidContainerRegistry.BUCKET_VOLUME, false);
|
||||
FluidStack stack = tankContainer.drain(dir, FluidContainerRegistry.BUCKET_VOLUME, false);
|
||||
if (stack != null && stack.amount > 0)
|
||||
{
|
||||
int fill = ((NetworkPipes) this.getTileNetwork()).addFluidToNetwork((TileEntity) tankContainer, stack, true);
|
||||
|
@ -551,9 +536,10 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate(LiquidStack stack, ForgeDirection side)
|
||||
public int getMaxFlowRate(Fluid stack, ForgeDirection side)
|
||||
{
|
||||
return FluidHelper.getDefaultFlowRate(stack) * 3;
|
||||
//TODO change this to get info from stack
|
||||
return 1000 * 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -580,19 +566,39 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
|
|||
}
|
||||
|
||||
@Override
|
||||
public LiquidTank getTank()
|
||||
public FluidTank getTank()
|
||||
{
|
||||
if (this.fakeTank == null)
|
||||
{
|
||||
this.fakeTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
return this.fakeTank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTankContent(LiquidStack stack)
|
||||
public void setTankContent(FluidStack stack)
|
||||
{
|
||||
this.getTank().setFluid(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if (this.fakeTank == null)
|
||||
{
|
||||
this.fakeTank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
this.fakeTank.setLiquid(stack);
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return this.subEntities[from.ordinal()] == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue