aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/net/GTPacketPollution.java
blob: 6d15341682b27ff037c93ce4b238bbaa41557e95 (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
46
47
package gregtech.api.net;

import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.IBlockAccess;

import com.google.common.io.ByteArrayDataInput;

import gregtech.common.GTClient;
import io.netty.buffer.ByteBuf;

public class GTPacketPollution extends GTPacket {

    private ChunkCoordIntPair chunk;
    private int pollution;

    public GTPacketPollution() {
        super();
    }

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

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

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

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

    @Override
    public byte getPacketID() {
        return GTPacketTypes.POLLUTION.id;
    }
}