mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-11 18:26:08 +00:00
start moving to int vector impls where possible
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.api.block.state.properties.enums;
|
||||
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.generic.Construct;
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ package com.dfsek.terra.api.structure;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.structure.rotation;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
|
||||
public enum Rotation {
|
||||
|
||||
CW_90(90),
|
||||
CW_180(180),
|
||||
CCW_90(270),
|
||||
NONE(0);
|
||||
private final int degrees;
|
||||
|
||||
Rotation(int degrees) {
|
||||
this.degrees = degrees;
|
||||
}
|
||||
|
||||
public static Rotation fromDegrees(int deg) {
|
||||
return switch(FastMath.floorMod(deg, 360)) {
|
||||
case 0 -> Rotation.NONE;
|
||||
case 90 -> Rotation.CW_90;
|
||||
case 180 -> Rotation.CW_180;
|
||||
case 270 -> Rotation.CCW_90;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
public Rotation inverse() {
|
||||
return switch(this) {
|
||||
case NONE -> NONE;
|
||||
case CCW_90 -> CW_90;
|
||||
case CW_90 -> CCW_90;
|
||||
case CW_180 -> CW_180;
|
||||
};
|
||||
}
|
||||
|
||||
public Rotation rotate(Rotation rotation) {
|
||||
return fromDegrees(this.getDegrees() + rotation.getDegrees());
|
||||
}
|
||||
|
||||
public int getDegrees() {
|
||||
return degrees;
|
||||
}
|
||||
|
||||
public enum Axis {
|
||||
X,
|
||||
Y,
|
||||
Z
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import com.dfsek.terra.api.block.state.properties.enums.Axis;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.RailShape;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.RedstoneConnection;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.WallHeight;
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user