package net.minecraft.world.level.block.entity;

import javax.annotation.Nullable;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;

public class JigsawBlockEntity extends BlockEntity {
    private ResourceLocation attachementType;
    private ResourceLocation targetPool;
    private String finalState;
    
    public JigsawBlockEntity(final BlockEntityType<?> bwm) {
        super(bwm);
        this.attachementType = new ResourceLocation("empty");
        this.targetPool = new ResourceLocation("empty");
        this.finalState = "minecraft:air";
    }
    
    public JigsawBlockEntity() {
        this(BlockEntityType.JIGSAW);
    }
    
    public ResourceLocation getAttachementType() {
        return this.attachementType;
    }
    
    public ResourceLocation getTargetPool() {
        return this.targetPool;
    }
    
    public String getFinalState() {
        return this.finalState;
    }
    
    public void setAttachementType(final ResourceLocation sm) {
        this.attachementType = sm;
    }
    
    public void setTargetPool(final ResourceLocation sm) {
        this.targetPool = sm;
    }
    
    public void setFinalState(final String string) {
        this.finalState = string;
    }
    
    @Override
    public CompoundTag save(final CompoundTag jt) {
        super.save(jt);
        jt.putString("attachement_type", this.attachementType.toString());
        jt.putString("target_pool", this.targetPool.toString());
        jt.putString("final_state", this.finalState);
        return jt;
    }
    
    @Override
    public void load(final CompoundTag jt) {
        super.load(jt);
        this.attachementType = new ResourceLocation(jt.getString("attachement_type"));
        this.targetPool = new ResourceLocation(jt.getString("target_pool"));
        this.finalState = jt.getString("final_state");
    }
    
    @Nullable
    @Override
    public ClientboundBlockEntityDataPacket getUpdatePacket() {
        return new ClientboundBlockEntityDataPacket(this.worldPosition, 12, this.getUpdateTag());
    }
    
    @Override
    public CompoundTag getUpdateTag() {
        return this.save(new CompoundTag());
    }
}
