All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yungnickyoung.minecraft.yungsapi.world.util.BoundingBoxHelper Maven / Gradle / Ivy

The newest version!
package com.yungnickyoung.minecraft.yungsapi.world.util;

import com.yungnickyoung.minecraft.yungsapi.mixin.accessor.BoundingBoxAccessor;
import net.minecraft.class_2350;
import net.minecraft.class_3341;

public class BoundingBoxHelper {
    /**
     * Generates and rotates a block box.
     * The main axis is the primary of the x and z axes, in the direction
     * the structure should generate from the starting point.
     */
    public static class_3341 boxFromCoordsWithRotation(int x, int y, int z, int secondaryAxisLen, int yLen, int mainAxisLen, class_2350 mainAxis) {
        class_3341 boundingBox = new class_3341(x, y, z, x, y + yLen - 1, z);
        switch (mainAxis) {
            default -> {
                ((BoundingBoxAccessor) boundingBox).setMaxX(x + (secondaryAxisLen - 1));
                ((BoundingBoxAccessor) boundingBox).setMinZ(z - (mainAxisLen - 1));
            }
            case field_11035 -> {
                ((BoundingBoxAccessor) boundingBox).setMinX(x - (secondaryAxisLen - 1));
                ((BoundingBoxAccessor) boundingBox).setMaxZ(z + (mainAxisLen - 1));
            }
            case field_11039 -> {
                ((BoundingBoxAccessor) boundingBox).setMinX(x - (mainAxisLen - 1));
                ((BoundingBoxAccessor) boundingBox).setMinZ(z - (secondaryAxisLen - 1));
            }
            case field_11034 -> {
                ((BoundingBoxAccessor) boundingBox).setMaxX(x + (mainAxisLen - 1));
                ((BoundingBoxAccessor) boundingBox).setMaxZ(z + (secondaryAxisLen - 1));
            }
        }
        return boundingBox;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy