Search in sources :

Example 1 with PacketTankLevelUpdate

use of forestry.core.network.packets.PacketTankLevelUpdate in project ForestryMC by ForestryMC.

the class TankManager method updateTankLevels.

private void updateTankLevels(StandardTank tank, boolean sendUpdate) {
    if (!(tile instanceof IRenderableTile)) {
        return;
    }
    int tankIndex = tank.getTankIndex();
    EnumTankLevel tankLevel = EnumTankLevel.rateTankLevel(tank);
    if (tankLevel != tankLevels.get(tankIndex)) {
        tankLevels.set(tankIndex, tankLevel);
        if (sendUpdate) {
            PacketTankLevelUpdate tankLevelUpdate = new PacketTankLevelUpdate(tile, tankIndex, tank.getFluid());
            NetworkUtil.sendNetworkPacket(tankLevelUpdate, tile.getCoordinates(), tile.getWorldObj());
        }
    }
}
Also used : EnumTankLevel(forestry.core.render.EnumTankLevel) IRenderableTile(forestry.core.tiles.IRenderableTile) PacketTankLevelUpdate(forestry.core.network.packets.PacketTankLevelUpdate)

Example 2 with PacketTankLevelUpdate

use of forestry.core.network.packets.PacketTankLevelUpdate in project ForestryMC by ForestryMC.

the class TankManager method sendTankUpdate.

private void sendTankUpdate(Container container, Iterable<IContainerListener> crafters, StandardTank tank) {
    if (tile != null) {
        int tankIndex = tank.getTankIndex();
        FluidStack fluid = tank.getFluid();
        IForestryPacketClient packet = new PacketTankLevelUpdate(tile, tankIndex, fluid);
        for (IContainerListener crafter : crafters) {
            if (crafter instanceof EntityPlayerMP) {
                NetworkUtil.sendToPlayer(packet, (EntityPlayerMP) crafter);
            }
        }
        if (fluid == null) {
            prevFluidStacks.remove(container, tankIndex);
        } else {
            prevFluidStacks.put(container, tankIndex, fluid.copy());
        }
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) IContainerListener(net.minecraft.inventory.IContainerListener) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IForestryPacketClient(forestry.core.network.IForestryPacketClient) PacketTankLevelUpdate(forestry.core.network.packets.PacketTankLevelUpdate)

Aggregations

PacketTankLevelUpdate (forestry.core.network.packets.PacketTankLevelUpdate)2 IForestryPacketClient (forestry.core.network.IForestryPacketClient)1 EnumTankLevel (forestry.core.render.EnumTankLevel)1 IRenderableTile (forestry.core.tiles.IRenderableTile)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 IContainerListener (net.minecraft.inventory.IContainerListener)1 FluidStack (net.minecraftforge.fluids.FluidStack)1