aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/net/GT_Packet_Pollution.java
blob: 20efe416793f21c9adf8f1dbda1b2f40e92edfc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package gregtech.api.net;

import com.google.common.io.ByteArrayDataInput;
import gregtech.common.GT_Client;
import io.netty.buffer.ByteBuf;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.IBlockAccess;

public class GT_Packet_Pollution extends GT_Packet_New {
    private ChunkCoordIntPair chunk;
    private int pollution;

    public GT_Packet_Pollution() {
        super(true);
    }

    public GT_Packet_Pollution(ChunkCoordIntPair chunk, int pollution) {
        super(false);
        this.chunk = chunk;
        this.pollution = pollution;
    }

    @Override
    public void encode(ByteBuf aOut) {
        aOut.writeInt(chunk.chunkXPos).writeInt(chunk.chunkZPos).writeInt(pollution);
    }

    @Override
    public GT_Packet_New decode(ByteArrayDataInput aData) {
        return new GT_Packet_Pollution(
                new ChunkCoordIntPair(aData.readInt(), aData.readInt()),
                aData.readInt()
        );
    }

    @Override
    public void process(IBlockAccess aWorld) {
        GT_Client.recieveChunkPollutionPacket(chunk, pollution);
    }

    @Override
    public byte getPacketID() {
        return 4;
    }
}