Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(utils): AABBUtils moveTo methods
- Loading branch information
1 parent
9641106
commit eec70ca
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/main/java/org/auioc/mcmod/arnicalib/utils/game/AABBUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.auioc.mcmod.arnicalib.utils.game; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.phys.AABB; | ||
|
||
public interface AABBUtils { | ||
|
||
static AABB moveTo(AABB aabb, double x, double y, double z) { | ||
return aabb.move( | ||
x - ((aabb.minX + aabb.maxX) / 2), // (x+0.5)-(min+(max-min)/2) | ||
y - aabb.minY, | ||
z - ((aabb.minZ + aabb.maxZ) / 2) | ||
); | ||
} | ||
|
||
static AABB moveTo(AABB aabb, int x, int y, int z) { | ||
return moveTo(aabb, x + 0.5D, y, x + 0.5D); | ||
} | ||
|
||
static AABB moveTo(AABB aabb, BlockPos pos) { | ||
return moveTo(aabb, pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D); | ||
} | ||
|
||
} |