From eec70cac6c0dbd8dc379fab6f66ec5e79b66cfbd Mon Sep 17 00:00:00 2001 From: WakelessSloth56 Date: Sun, 26 Jun 2022 23:26:13 +0800 Subject: [PATCH] feat(utils): AABBUtils moveTo methods --- .../mcmod/arnicalib/utils/game/AABBUtils.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/org/auioc/mcmod/arnicalib/utils/game/AABBUtils.java diff --git a/src/main/java/org/auioc/mcmod/arnicalib/utils/game/AABBUtils.java b/src/main/java/org/auioc/mcmod/arnicalib/utils/game/AABBUtils.java new file mode 100644 index 00000000..cb845277 --- /dev/null +++ b/src/main/java/org/auioc/mcmod/arnicalib/utils/game/AABBUtils.java @@ -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); + } + +}