fix compilation on Forge 1355+, fluid pipe NBT saving, add tank debug mode

This commit is contained in:
asiekierka 2015-04-25 12:39:51 +02:00
parent 5c929b40b2
commit aa49a1d321
4 changed files with 28 additions and 18 deletions

View file

@ -88,7 +88,7 @@ public final class StackKey {
}
}
if (fluidStack != null) {
if (fluidStack.fluidID != k.fluidStack.fluidID ||
if (fluidStack.getFluid().getID() != k.fluidStack.getFluid().getID() ||
fluidStack.amount != k.fluidStack.amount ||
!objectsEqual(fluidStack.tag, k.fluidStack.tag)) {
return false;
@ -107,7 +107,7 @@ public final class StackKey {
}
result = 31 * result + 7;
if (fluidStack != null) {
result = 31 * result + fluidStack.fluidID;
result = 31 * result + fluidStack.getFluid().getID();
result = 31 * result + fluidStack.amount;
result = 31 * result + objectHashCode(fluidStack.tag);
}

View file

@ -14,6 +14,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@ -29,6 +30,7 @@ import buildcraft.core.lib.block.BlockBuildCraft;
import buildcraft.core.lib.inventory.InvUtils;
public class BlockTank extends BlockBuildCraft {
private static final boolean DEBUG_MODE = false;
private IIcon textureStackedSide;
public BlockTank() {
@ -170,6 +172,15 @@ public class BlockTank extends BlockBuildCraft {
return true;
}
}
} else if (DEBUG_MODE) {
TileEntity tile = world.getTileEntity(i, j, k);
if (tile instanceof TileTank) {
TileTank tank = (TileTank) tile;
if (tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid != null) {
entityplayer.addChatComponentMessage(new ChatComponentText("Amount: " + tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid.amount + " mB"));
}
}
}
return false;

View file

@ -26,7 +26,6 @@ import buildcraft.core.lib.fluids.Tank;
import buildcraft.core.lib.fluids.TankManager;
public class TileTank extends TileBuildCraft implements IFluidHandler {
public final Tank tank = new Tank("tank", FluidContainerRegistry.BUCKET_VOLUME * 16, this);
public final TankManager<Tank> tankManager = new TankManager<Tank>(tank);
public boolean hasUpdate = false;

View file

@ -38,7 +38,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
public int amount;
private short currentTime = 0;
private short[] incoming = new short[travelDelay];
private short[] incoming = new short[MAX_TRAVEL_DELAY];
public int fill(int maxFill, boolean doFill) {
int amountToFill = Math.min(getMaxFillRate(), maxFill);
@ -125,6 +125,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
* pipe sections are assumed to be of the same volume.
*/
public static int LIQUID_IN_PIPE = FluidContainerRegistry.BUCKET_VOLUME / 4;
public static int MAX_TRAVEL_DELAY = 12;
public static short INPUT_TTL = 60; // 100
public static short OUTPUT_TTL = 80; // 80
public static short OUTPUT_COOLDOWN = 30; // 30
@ -153,8 +154,10 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
public PipeTransportFluids() {
for (ForgeDirection direction : directions) {
sections[direction.ordinal()] = new PipeSection();
transferState[direction.ordinal()] = TransferState.None;
}
sections[6] = new PipeSection();
}
public int getCapacity() {
@ -168,10 +171,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
public void initFromPipe(Class<? extends Pipe> pipeClass) {
capacity = LIQUID_IN_PIPE;
flowRate = fluidCapacities.get(pipeClass);
travelDelay = MathUtils.clamp(Math.round(16 / (flowRate / 10)), 1, 12);
for (ForgeDirection direction : orientations) {
sections[direction.ordinal()] = new PipeSection();
}
travelDelay = MathUtils.clamp(Math.round(16 / (flowRate / 10)), 1, MAX_TRAVEL_DELAY);
}
@Override
@ -486,10 +486,10 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
fluidType = stack;
}
if (stack.isFluidEqual(fluidType)) {
sections[direction.ordinal()].readFromNBT(nbttagcompound);
sections[direction.ordinal()].readFromNBT(compound);
}
} else {
sections[direction.ordinal()].readFromNBT(nbttagcompound);
sections[direction.ordinal()].readFromNBT(compound);
}
}
if (direction != ForgeDirection.UNKNOWN) {
@ -502,18 +502,18 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
NBTTagCompound fluidTag = new NBTTagCompound();
if (fluidType != null) {
NBTTagCompound fluidTag = new NBTTagCompound();
fluidType.writeToNBT(fluidTag);
nbttagcompound.setTag("fluid", fluidTag);
}
for (ForgeDirection direction : orientations) {
NBTTagCompound subTag = new NBTTagCompound();
sections[direction.ordinal()].writeToNBT(subTag);
nbttagcompound.setTag("tank[" + direction.ordinal() + "]", subTag);
if (direction != ForgeDirection.UNKNOWN) {
nbttagcompound.setShort("transferState[" + direction.ordinal() + "]", (short) transferState[direction.ordinal()].ordinal());
for (ForgeDirection direction : orientations) {
NBTTagCompound subTag = new NBTTagCompound();
sections[direction.ordinal()].writeToNBT(subTag);
nbttagcompound.setTag("tank[" + direction.ordinal() + "]", subTag);
if (direction != ForgeDirection.UNKNOWN) {
nbttagcompound.setShort("transferState[" + direction.ordinal() + "]", (short) transferState[direction.ordinal()].ordinal());
}
}
}
}