package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.util.Mth;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.state.properties.StructureMode;
import net.minecraft.world.level.block.entity.StructureBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.network.protocol.Packet;

public class ServerboundSetStructureBlockPacket implements Packet<ServerGamePacketListener> {
    private BlockPos pos;
    private StructureBlockEntity.UpdateType updateType;
    private StructureMode mode;
    private String name;
    private BlockPos offset;
    private BlockPos size;
    private Mirror mirror;
    private Rotation rotation;
    private String data;
    private boolean ignoreEntities;
    private boolean showAir;
    private boolean showBoundingBox;
    private float integrity;
    private long seed;
    
    public ServerboundSetStructureBlockPacket() {
    }
    
    public ServerboundSetStructureBlockPacket(final BlockPos fu1, final StructureBlockEntity.UpdateType a, final StructureMode cgq, final String string4, final BlockPos fu5, final BlockPos fu6, final Mirror bzj, final Rotation cap, final String string9, final boolean boolean10, final boolean boolean11, final boolean boolean12, final float float13, final long long14) {
        this.pos = fu1;
        this.updateType = a;
        this.mode = cgq;
        this.name = string4;
        this.offset = fu5;
        this.size = fu6;
        this.mirror = bzj;
        this.rotation = cap;
        this.data = string9;
        this.ignoreEntities = boolean10;
        this.showAir = boolean11;
        this.showBoundingBox = boolean12;
        this.integrity = float13;
        this.seed = long14;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.pos = mg.readBlockPos();
        this.updateType = mg.<StructureBlockEntity.UpdateType>readEnum(StructureBlockEntity.UpdateType.class);
        this.mode = mg.<StructureMode>readEnum(StructureMode.class);
        this.name = mg.readUtf(32767);
        this.offset = new BlockPos(Mth.clamp(mg.readByte(), -32, 32), Mth.clamp(mg.readByte(), -32, 32), Mth.clamp(mg.readByte(), -32, 32));
        this.size = new BlockPos(Mth.clamp(mg.readByte(), 0, 32), Mth.clamp(mg.readByte(), 0, 32), Mth.clamp(mg.readByte(), 0, 32));
        this.mirror = mg.<Mirror>readEnum(Mirror.class);
        this.rotation = mg.<Rotation>readEnum(Rotation.class);
        this.data = mg.readUtf(12);
        this.integrity = Mth.clamp(mg.readFloat(), 0.0f, 1.0f);
        this.seed = mg.readVarLong();
        final int integer3 = mg.readByte();
        this.ignoreEntities = ((integer3 & 0x1) != 0x0);
        this.showAir = ((integer3 & 0x2) != 0x0);
        this.showBoundingBox = ((integer3 & 0x4) != 0x0);
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeBlockPos(this.pos);
        mg.writeEnum(this.updateType);
        mg.writeEnum(this.mode);
        mg.writeUtf(this.name);
        mg.writeByte(this.offset.getX());
        mg.writeByte(this.offset.getY());
        mg.writeByte(this.offset.getZ());
        mg.writeByte(this.size.getX());
        mg.writeByte(this.size.getY());
        mg.writeByte(this.size.getZ());
        mg.writeEnum(this.mirror);
        mg.writeEnum(this.rotation);
        mg.writeUtf(this.data);
        mg.writeFloat(this.integrity);
        mg.writeVarLong(this.seed);
        int integer3 = 0;
        if (this.ignoreEntities) {
            integer3 |= 0x1;
        }
        if (this.showAir) {
            integer3 |= 0x2;
        }
        if (this.showBoundingBox) {
            integer3 |= 0x4;
        }
        mg.writeByte(integer3);
    }
    
    @Override
    public void handle(final ServerGamePacketListener qz) {
        qz.handleSetStructureBlock(this);
    }
    
    public BlockPos getPos() {
        return this.pos;
    }
    
    public StructureBlockEntity.UpdateType getUpdateType() {
        return this.updateType;
    }
    
    public StructureMode getMode() {
        return this.mode;
    }
    
    public String getName() {
        return this.name;
    }
    
    public BlockPos getOffset() {
        return this.offset;
    }
    
    public BlockPos getSize() {
        return this.size;
    }
    
    public Mirror getMirror() {
        return this.mirror;
    }
    
    public Rotation getRotation() {
        return this.rotation;
    }
    
    public String getData() {
        return this.data;
    }
    
    public boolean isIgnoreEntities() {
        return this.ignoreEntities;
    }
    
    public boolean isShowAir() {
        return this.showAir;
    }
    
    public boolean isShowBoundingBox() {
        return this.showBoundingBox;
    }
    
    public float getIntegrity() {
        return this.integrity;
    }
    
    public long getSeed() {
        return this.seed;
    }
}
