Skip to content

Commit 5e913ea

Browse files
committed
More helper methods.
1 parent ea242e4 commit 5e913ea

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/main/java/sunsetsatellite/catalyst/core/util/Direction.java

+15-8
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,29 @@
22

33
import net.minecraft.core.block.Block;
44
import net.minecraft.core.block.entity.TileEntity;
5+
import net.minecraft.core.util.helper.Axis;
56
import net.minecraft.core.util.phys.Vec3d;
67
import net.minecraft.core.world.WorldSource;
78

89
public enum Direction {
9-
X_POS (new Vec3i(1,0,0),5,"EAST"),
10-
X_NEG (new Vec3i(-1,0,0),4,"WEST"),
11-
Y_POS (new Vec3i(0,1,0),1,"UP"),
12-
Y_NEG (new Vec3i(0,-1,0),0,"DOWN"),
13-
Z_POS (new Vec3i(0,0,1),3,"SOUTH"),
14-
Z_NEG (new Vec3i(0,0,-1),2,"NORTH");
10+
X_POS (new Vec3i(1,0,0),5,"EAST", Axis.X),
11+
X_NEG (new Vec3i(-1,0,0),4,"WEST", Axis.X),
12+
Y_POS (new Vec3i(0,1,0),1,"UP", Axis.Y),
13+
Y_NEG (new Vec3i(0,-1,0),0,"DOWN", Axis.Y),
14+
Z_POS (new Vec3i(0,0,1),3,"SOUTH", Axis.Z),
15+
Z_NEG (new Vec3i(0,0,-1),2,"NORTH", Axis.Z);
1516

1617
private final Vec3i vec;
1718
private Direction opposite;
1819
private final int side;
1920
private final String name;
21+
private final Axis axis;
2022

21-
Direction(Vec3i vec3I,int side,String name) {
23+
Direction(Vec3i vec3I, int side, String name, Axis axis) {
2224
this.vec = vec3I;
2325
this.side = side;
2426
this.name = name;
27+
this.axis = axis;
2528
}
2629

2730
public TileEntity getTileEntity(WorldSource world, TileEntity tile){
@@ -56,7 +59,11 @@ public Vec3i getVec() {
5659
return vec.copy();
5760
}
5861

59-
public static Direction getDirectionFromSide(int side){
62+
public Axis getAxis() {
63+
return axis;
64+
}
65+
66+
public static Direction getDirectionFromSide(int side){
6067
for (Direction dir : values()) {
6168
if(dir.side == side){
6269
return dir;

src/main/java/sunsetsatellite/catalyst/core/util/Vec3f.java

+7
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ public Vec3f rotate(Direction direction){
149149
return pos;
150150
}
151151

152+
public Vec3f lerp(Vec3f to, double amount){
153+
double lerpX = x + (to.x - x) * amount;
154+
double lerpY = y + (to.y - x) * amount;
155+
double lerpZ = z + (to.z - x) * amount;
156+
return new Vec3f(lerpX, lerpY, lerpZ);
157+
}
158+
152159

153160
@Override
154161
public String toString() {

0 commit comments

Comments
 (0)