2014-07-07 04:04:58 +02:00
|
|
|
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 appeng.api.storage.data.IAEItemStack;
|
2014-07-09 10:17:11 +02:00
|
|
|
import appeng.client.EffectType;
|
|
|
|
import appeng.core.CommonHelper;
|
2014-07-07 04:04:58 +02:00
|
|
|
import appeng.core.sync.AppEngPacket;
|
|
|
|
import appeng.core.sync.network.INetworkInfo;
|
|
|
|
import appeng.util.item.AEItemStack;
|
2014-07-09 10:17:11 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2014-07-07 04:04:58 +02:00
|
|
|
|
|
|
|
public class PacketAssemblerAnimation extends AppEngPacket
|
|
|
|
{
|
|
|
|
|
2014-07-09 10:17:11 +02:00
|
|
|
final public int x, y, z;
|
|
|
|
final public byte rate;
|
|
|
|
final public IAEItemStack is;
|
2014-07-07 04:04:58 +02:00
|
|
|
|
|
|
|
// automatic.
|
|
|
|
public PacketAssemblerAnimation(ByteBuf stream) throws IOException {
|
|
|
|
x = stream.readInt();
|
|
|
|
y = stream.readInt();
|
|
|
|
z = stream.readInt();
|
|
|
|
rate = stream.readByte();
|
|
|
|
is = AEItemStack.loadItemStackFromPacket( stream );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-07-09 10:17:11 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2014-07-07 04:04:58 +02:00
|
|
|
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
|
|
|
{
|
|
|
|
double d0 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
|
|
|
double d1 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
|
|
|
double d2 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
|
|
|
|
2014-07-09 10:17:11 +02:00
|
|
|
CommonHelper.proxy.spawnEffect( EffectType.Assembler, player.getEntityWorld(), x + d0, y + d1, z + d2, this );
|
2014-07-07 04:04:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// api
|
|
|
|
public PacketAssemblerAnimation(int x, int y, int z, byte rate, IAEItemStack is) throws IOException {
|
|
|
|
|
|
|
|
ByteBuf data = Unpooled.buffer();
|
|
|
|
|
|
|
|
data.writeInt( getPacketID() );
|
|
|
|
data.writeInt( this.x = x );
|
|
|
|
data.writeInt( this.y = y );
|
|
|
|
data.writeInt( this.z = z );
|
|
|
|
data.writeByte( this.rate = rate );
|
|
|
|
is.writeToPacket( data );
|
|
|
|
this.is = is;
|
|
|
|
|
|
|
|
configureWrite( data );
|
|
|
|
}
|
|
|
|
}
|