com.yungnickyoung.minecraft.yungsapi.world.util.BoundingBoxHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of YungsApi-1.21-Fabric Show documentation
Show all versions of YungsApi-1.21-Fabric Show documentation
A common API for YUNG's Minecraft mods
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;
}
}