All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.network.protocol.UpdateSubChunkBlocksPacket Maven / Gradle / Ivy

There is a newer version: 1.20.40-r1
Show newest version
package cn.nukkit.network.protocol;

import cn.nukkit.api.PowerNukkitXOnly;
import cn.nukkit.api.Since;
import cn.nukkit.network.protocol.types.BlockChangeEntry;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.Value;

import java.util.List;

@PowerNukkitXOnly
@Since("1.6.0.0-PNX")
@EqualsAndHashCode(doNotUseGetters = true, callSuper = false)
@ToString(doNotUseGetters = true)
@Value
public class UpdateSubChunkBlocksPacket extends DataPacket {
    public int chunkX;
    public int chunkY;
    public int chunkZ;

    public List standardBlocks = new ObjectArrayList<>();
    public List extraBlocks = new ObjectArrayList<>();

    @Override
    public byte pid() {
        return ProtocolInfo.UPDATE_SUB_CHUNK_BLOCKS_PACKET;
    }

    @Override
    public void decode() {

    }

    @Override
    public void encode() {
        putVarInt(chunkX);
        putUnsignedVarInt(chunkY);
        putVarInt(chunkZ);
        putVarInt(standardBlocks.size());
        for(final var each : standardBlocks) {
            putBlockVector3(each.blockPos());
            putUnsignedVarInt(each.runtimeID());
            putUnsignedVarInt(each.updateFlags());
            putUnsignedVarLong(each.messageEntityID());
            putUnsignedVarInt(each.messageType().ordinal());
        }
        for(final var each : extraBlocks) {
            putBlockVector3(each.blockPos());
            putUnsignedVarInt(each.runtimeID());
            putUnsignedVarInt(each.updateFlags());
            putUnsignedVarLong(each.messageEntityID());
            putUnsignedVarInt(each.messageType().ordinal());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy