package net.minecraft.world.level.levelgen.feature.structures;

import java.util.Map;
import com.google.common.collect.ImmutableMap;
import com.mojang.serialization.Dynamic;
import com.mojang.serialization.DynamicOps;

public class JigsawJunction {
    private final int sourceX;
    private final int sourceGroundY;
    private final int sourceZ;
    private final int deltaY;
    private final StructureTemplatePool.Projection destProjection;
    
    public JigsawJunction(final int integer1, final int integer2, final int integer3, final int integer4, final StructureTemplatePool.Projection a) {
        this.sourceX = integer1;
        this.sourceGroundY = integer2;
        this.sourceZ = integer3;
        this.deltaY = integer4;
        this.destProjection = a;
    }
    
    public int getSourceX() {
        return this.sourceX;
    }
    
    public int getSourceGroundY() {
        return this.sourceGroundY;
    }
    
    public int getSourceZ() {
        return this.sourceZ;
    }
    
    public <T> Dynamic<T> serialize(final DynamicOps<T> dynamicOps) {
        final ImmutableMap.Builder<T, T> builder3 = ImmutableMap.<T, T>builder();
        builder3.put((T)dynamicOps.createString("source_x"), (T)dynamicOps.createInt(this.sourceX)).put((T)dynamicOps.createString("source_ground_y"), (T)dynamicOps.createInt(this.sourceGroundY)).put((T)dynamicOps.createString("source_z"), (T)dynamicOps.createInt(this.sourceZ)).put((T)dynamicOps.createString("delta_y"), (T)dynamicOps.createInt(this.deltaY)).put((T)dynamicOps.createString("dest_proj"), (T)dynamicOps.createString(this.destProjection.getName()));
        return (Dynamic<T>)new Dynamic((DynamicOps)dynamicOps, dynamicOps.createMap((Map)builder3.build()));
    }
    
    public static <T> JigsawJunction deserialize(final Dynamic<T> dynamic) {
        return new JigsawJunction(dynamic.get("source_x").asInt(0), dynamic.get("source_ground_y").asInt(0), dynamic.get("source_z").asInt(0), dynamic.get("delta_y").asInt(0), StructureTemplatePool.Projection.byName(dynamic.get("dest_proj").asString("")));
    }
    
    @Override
    public boolean equals(final Object object) {
        if (this == object) {
            return true;
        }
        if (object == null || this.getClass() != object.getClass()) {
            return false;
        }
        final JigsawJunction cpy3 = (JigsawJunction)object;
        return this.sourceX == cpy3.sourceX && this.sourceZ == cpy3.sourceZ && this.deltaY == cpy3.deltaY && this.destProjection == cpy3.destProjection;
    }
    
    @Override
    public int hashCode() {
        int integer2 = this.sourceX;
        integer2 = 31 * integer2 + this.sourceGroundY;
        integer2 = 31 * integer2 + this.sourceZ;
        integer2 = 31 * integer2 + this.deltaY;
        integer2 = 31 * integer2 + this.destProjection.hashCode();
        return integer2;
    }
    
    @Override
    public String toString() {
        return "JigsawJunction{sourceX=" + this.sourceX + ", sourceGroundY=" + this.sourceGroundY + ", sourceZ=" + this.sourceZ + ", deltaY=" + this.deltaY + ", destProjection=" + this.destProjection + '}';
    }
}
