package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.block.entity.JigsawBlockEntity;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.network.protocol.Packet;

public class ServerboundSetJigsawBlockPacket implements Packet<ServerGamePacketListener> {
    private BlockPos pos;
    private ResourceLocation name;
    private ResourceLocation target;
    private ResourceLocation pool;
    private String finalState;
    private JigsawBlockEntity.JointType joint;
    
    public ServerboundSetJigsawBlockPacket() {
    }
    
    public ServerboundSetJigsawBlockPacket(final BlockPos fu, final ResourceLocation uh2, final ResourceLocation uh3, final ResourceLocation uh4, final String string, final JigsawBlockEntity.JointType a) {
        this.pos = fu;
        this.name = uh2;
        this.target = uh3;
        this.pool = uh4;
        this.finalState = string;
        this.joint = a;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.pos = mg.readBlockPos();
        this.name = mg.readResourceLocation();
        this.target = mg.readResourceLocation();
        this.pool = mg.readResourceLocation();
        this.finalState = mg.readUtf(32767);
        this.joint = JigsawBlockEntity.JointType.byName(mg.readUtf(32767)).orElse(JigsawBlockEntity.JointType.ALIGNED);
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeBlockPos(this.pos);
        mg.writeResourceLocation(this.name);
        mg.writeResourceLocation(this.target);
        mg.writeResourceLocation(this.pool);
        mg.writeUtf(this.finalState);
        mg.writeUtf(this.joint.getSerializedName());
    }
    
    @Override
    public void handle(final ServerGamePacketListener qz) {
        qz.handleSetJigsawBlock(this);
    }
    
    public BlockPos getPos() {
        return this.pos;
    }
    
    public ResourceLocation getName() {
        return this.name;
    }
    
    public ResourceLocation getTarget() {
        return this.target;
    }
    
    public ResourceLocation getPool() {
        return this.pool;
    }
    
    public String getFinalState() {
        return this.finalState;
    }
    
    public JigsawBlockEntity.JointType getJoint() {
        return this.joint;
    }
}
