Search in sources :

Example 1 with FluidUpdatePacket

use of knightminer.ceramics.network.FluidUpdatePacket in project Ceramics by KnightMiner.

the class TileFaucet method reset.

protected void reset() {
    isPouring = false;
    stopPouring = false;
    drained = null;
    // invalid direction
    direction = EnumFacing.DOWN;
    lastRedstoneState = false;
    // sync to clients
    if (getWorld() != null && !getWorld().isRemote && getWorld() instanceof WorldServer) {
        CeramicsNetwork.sendToClients((WorldServer) getWorld(), pos, new FluidUpdatePacket(pos, null));
    }
}
Also used : FluidUpdatePacket(knightminer.ceramics.network.FluidUpdatePacket) WorldServer(net.minecraft.world.WorldServer)

Example 2 with FluidUpdatePacket

use of knightminer.ceramics.network.FluidUpdatePacket in project Ceramics by KnightMiner.

the class TileFaucet method doTransfer.

protected void doTransfer() {
    // still got content left
    if (drained != null) {
        return;
    }
    IFluidHandler toDrain = getFluidHandler(pos.offset(direction), direction);
    IFluidHandler toFill = getFluidHandler(pos.down(), EnumFacing.UP);
    if (toDrain != null && toFill != null) {
        // can we drain?
        FluidStack drained = toDrain.drain(TRANSACTION_AMOUNT, false);
        if (drained != null) {
            // can we fill?
            int filled = toFill.fill(drained, false);
            if (filled > 0) {
                // drain the liquid and transfer it, buffer the amount for delay
                this.drained = toDrain.drain(filled, true);
                this.isPouring = true;
                pour();
                // sync to clients
                if (!getWorld().isRemote && getWorld() instanceof WorldServer) {
                    CeramicsNetwork.sendToClients((WorldServer) getWorld(), pos, new FluidUpdatePacket(pos, drained));
                }
                return;
            }
        }
    }
    // draining unsuccessful
    reset();
}
Also used : FluidUpdatePacket(knightminer.ceramics.network.FluidUpdatePacket) FluidStack(net.minecraftforge.fluids.FluidStack) WorldServer(net.minecraft.world.WorldServer) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Aggregations

FluidUpdatePacket (knightminer.ceramics.network.FluidUpdatePacket)2 WorldServer (net.minecraft.world.WorldServer)2 FluidStack (net.minecraftforge.fluids.FluidStack)1 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)1