| 1 | package net.minecraft.network.play.server;
|
| 2 |
|
| 3 | import com.google.common.collect.Lists;
|
| 4 | import java.io.IOException;
|
| 5 | import java.util.List;
|
| 6 | import net.minecraft.network.Packet;
|
| 7 | import net.minecraft.network.PacketBuffer;
|
| 8 | import net.minecraft.network.play.INetHandlerPlayClient;
|
| 9 | import net.minecraft.util.BlockPos;
|
| 10 | import net.minecraft.util.Vec3;
|
| 11 |
|
| 12 | public class S27PacketExplosion implements Packet<INetHandlerPlayClient>
|
| 13 | {
|
| 14 | private double posX;
|
| 15 | private double posY;
|
| 16 | private double posZ;
|
| 17 | private float strength;
|
| 18 | private List<BlockPos> affectedBlockPositions;
|
| 19 | private float field_149152_f;
|
| 20 | private float field_149153_g;
|
| 21 | private float field_149159_h;
|
| 22 |
|
| 23 | public S27PacketExplosion()
|
| 24 | {
|
| 25 | }
|
| 26 |
|
| 27 | public S27PacketExplosion(double p_i45193_1_, double y, double z, float strengthIn, List<BlockPos> affectedBlocksIn, Vec3 p_i45193_9_)
|
| 28 | {
|
| 29 | this.posX = p_i45193_1_;
|
| 30 | this.posY = y;
|
| 31 | this.posZ = z;
|
| 32 | this.strength = strengthIn;
|
| 33 | this.affectedBlockPositions = Lists.newArrayList(affectedBlocksIn);
|
| 34 |
|
| 35 | if (p_i45193_9_ != null)
|
| 36 | {
|
| 37 | this.field_149152_f = (float)p_i45193_9_.xCoord;
|
| 38 | this.field_149153_g = (float)p_i45193_9_.yCoord;
|
| 39 | this.field_149159_h = (float)p_i45193_9_.zCoord;
|
| 40 | }
|
| 41 | }
|
| 42 |
|
| 43 | /**
|
| 44 | * Reads the raw packet data from the data stream.
|
| 45 | */
|
| 46 | public void readPacketData(PacketBuffer buf) throws IOException
|
| 47 | {
|
| 48 | this.posX = (double)buf.readFloat();
|
| 49 | this.posY = (double)buf.readFloat();
|
| 50 | this.posZ = (double)buf.readFloat();
|
| 51 | this.strength = buf.readFloat();
|
| 52 | int i = buf.readInt();
|
| 53 | this.affectedBlockPositions = Lists.<BlockPos>newArrayListWithCapacity(i);
|
| 54 | int j = (int)this.posX;
|
| 55 | int k = (int)this.posY;
|
| 56 | int l = (int)this.posZ;
|
| 57 |
|
| 58 | for (int i1 = 0; i1 < i; ++i1)
|
| 59 | {
|
| 60 | int j1 = buf.readByte() + j;
|
| 61 | int k1 = buf.readByte() + k;
|
| 62 | int l1 = buf.readByte() + l;
|
| 63 | this.affectedBlockPositions.add(new BlockPos(j1, k1, l1));
|
| 64 | }
|
| 65 |
|
| 66 | this.field_149152_f = buf.readFloat();
|
| 67 | this.field_149153_g = buf.readFloat();
|
| 68 | this.field_149159_h = buf.readFloat();
|
| 69 | }
|
| 70 |
|
| 71 | /**
|
| 72 | * Writes the raw packet data to the data stream.
|
| 73 | */
|
| 74 | public void writePacketData(PacketBuffer buf) throws IOException
|
| 75 | {
|
| 76 | buf.writeFloat((float)this.posX);
|
| 77 | buf.writeFloat((float)this.posY);
|
| 78 | buf.writeFloat((float)this.posZ);
|
| 79 | buf.writeFloat(this.strength);
|
| 80 | buf.writeInt(this.affectedBlockPositions.size());
|
| 81 | int i = (int)this.posX;
|
| 82 | int j = (int)this.posY;
|
| 83 | int k = (int)this.posZ;
|
| 84 |
|
| 85 | for (BlockPos blockpos : this.affectedBlockPositions)
|
| 86 | {
|
| 87 | int l = blockpos.getX() - i;
|
| 88 | int i1 = blockpos.getY() - j;
|
| 89 | int j1 = blockpos.getZ() - k;
|
| 90 | buf.writeByte(l);
|
| 91 | buf.writeByte(i1);
|
| 92 | buf.writeByte(j1);
|
| 93 | }
|
| 94 |
|
| 95 | buf.writeFloat(this.field_149152_f);
|
| 96 | buf.writeFloat(this.field_149153_g);
|
| 97 | buf.writeFloat(this.field_149159_h);
|
| 98 | }
|
| 99 |
|
| 100 | /**
|
| 101 | * Passes this Packet on to the NetHandler for processing.
|
| 102 | */
|
| 103 | public void processPacket(INetHandlerPlayClient handler)
|
| 104 | {
|
| 105 | handler.handleExplosion(this);
|
| 106 | }
|
| 107 |
|
| 108 | public float func_149149_c()
|
| 109 | {
|
| 110 | return this.field_149152_f;
|
| 111 | }
|
| 112 |
|
| 113 | public float func_149144_d()
|
| 114 | {
|
| 115 | return this.field_149153_g;
|
| 116 | }
|
| 117 |
|
| 118 | public float func_149147_e()
|
| 119 | {
|
| 120 | return this.field_149159_h;
|
| 121 | }
|
| 122 |
|
| 123 | public double getX()
|
| 124 | {
|
| 125 | return this.posX;
|
| 126 | }
|
| 127 |
|
| 128 | public double getY()
|
| 129 | {
|
| 130 | return this.posY;
|
| 131 | }
|
| 132 |
|
| 133 | public double getZ()
|
| 134 | {
|
| 135 | return this.posZ;
|
| 136 | }
|
| 137 |
|
| 138 | public float getStrength()
|
| 139 | {
|
| 140 | return this.strength;
|
| 141 | }
|
| 142 |
|
| 143 | public List<BlockPos> getAffectedBlockPositions()
|
| 144 | {
|
| 145 | return this.affectedBlockPositions;
|
| 146 | }
|
| 147 | }
|
| 148 |
|