Applied-Energistics-2-tiler.../core/sync/packets/PacketProgressBar.java

57 lines
1.3 KiB
Java
Raw Normal View History

package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import appeng.container.AEBaseContainer;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
public class PacketProgressBar extends AppEngPacket
{
short id;
2014-02-16 08:33:17 +01:00
long value;
// automatic.
public PacketProgressBar(ByteBuf stream) throws IOException {
id = stream.readShort();
2014-02-16 08:33:17 +01:00
value = stream.readLong();
}
@Override
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
{
Container c = player.openContainer;
if ( c instanceof AEBaseContainer )
2014-02-16 08:33:17 +01:00
((AEBaseContainer) c).updateFullProgressBar( id, value );
}
@Override
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
{
Container c = player.openContainer;
if ( c instanceof AEBaseContainer )
2014-02-16 08:33:17 +01:00
((AEBaseContainer) c).updateFullProgressBar( id, value );
}
// api
2014-02-16 08:33:17 +01:00
public PacketProgressBar(int short_id, long value) throws IOException {
this.id = (short) short_id;
this.value = value;
ByteBuf data = Unpooled.buffer();
data.writeInt( getPacketID() );
data.writeShort( short_id );
2014-02-16 08:33:17 +01:00
data.writeLong( value );
configureWrite( data );
}
}