// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.worldgen.util.bounds;

import com.hypixel.hytale.math.util.MathUtil;
import javax.annotation.Nonnull;

public class WorldBounds extends ChunkBounds implements IWorldBounds
{
    protected int minY;
    protected int maxY;
    
    public WorldBounds() {
        this.minY = Integer.MAX_VALUE;
        this.maxY = Integer.MIN_VALUE;
    }
    
    public WorldBounds(@Nonnull final IWorldBounds bounds) {
        super(bounds);
        this.minY = bounds.getLowBoundY();
        this.maxY = bounds.getHighBoundY();
    }
    
    public WorldBounds(final int minX, final int minY, final int minZ, final int maxX, final int maxY, final int maxZ) {
        super(minX, minZ, maxX, maxZ);
        this.minY = minY;
        this.maxY = maxY;
    }
    
    public WorldBounds(final int x, final int y, final int z) {
        super(x, z);
        this.maxY = y;
        this.minY = y;
    }
    
    @Override
    public int getLowBoundY() {
        return this.minY;
    }
    
    @Override
    public int getHighBoundY() {
        return this.maxY;
    }
    
    public void expandNegative(final double x, final double y, final double z) {
        this.expandNegative(x, z);
        this.minY = MathUtil.floor(this.minY + y);
    }
    
    public void expandPositive(final double x, final double y, final double z) {
        this.expandPositive(x, z);
        this.maxY = MathUtil.ceil(this.maxY + y);
    }
    
    @Override
    public void include(@Nonnull final IChunkBounds bounds) {
        super.include(bounds);
        if (bounds instanceof final IWorldBounds worldBounds) {
            if (this.minY > worldBounds.getLowBoundY()) {
                this.minY = worldBounds.getLowBoundY();
            }
            if (this.maxY < worldBounds.getHighBoundY()) {
                this.maxY = worldBounds.getHighBoundY();
            }
        }
    }
}
