mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-28 15:36:05 +00:00
reformat project according to .editorconfig
Signed-off-by: Glease <[email protected]>
This commit is contained in:
36 files changed
+2507
-2467
No files matched your search
@@ -7,10 +7,10 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
public class AlignmentUtility {
|
||||
private AlignmentUtility(){
|
||||
private AlignmentUtility() {
|
||||
}
|
||||
|
||||
public static boolean handle(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ){
|
||||
public static boolean handle(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) {
|
||||
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
|
||||
if (tTileEntity == null || aPlayer instanceof FakePlayer) {
|
||||
return aPlayer instanceof EntityPlayerMP;
|
||||
|
||||
@@ -6,10 +6,10 @@ import com.gtnewhorizon.structurelib.alignment.enumerable.Flip;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IAlignment extends IAlignmentLimits,IAlignmentProvider {
|
||||
int DIRECTIONS_COUNT= Direction.VALUES.length;
|
||||
int ROTATIONS_COUNT= Rotation.VALUES.length;
|
||||
int FLIPS_COUNT= Flip.VALUES.length;
|
||||
public interface IAlignment extends IAlignmentLimits, IAlignmentProvider {
|
||||
int DIRECTIONS_COUNT = Direction.VALUES.length;
|
||||
int ROTATIONS_COUNT = Rotation.VALUES.length;
|
||||
int FLIPS_COUNT = Flip.VALUES.length;
|
||||
int STATES_COUNT = ExtendedFacing.STATES_COUNT;
|
||||
|
||||
ExtendedFacing getExtendedFacing();
|
||||
@@ -23,48 +23,48 @@ public interface IAlignment extends IAlignmentLimits,IAlignmentProvider {
|
||||
IAlignmentLimits getAlignmentLimits();
|
||||
|
||||
@Override
|
||||
default IAlignment getAlignment(){
|
||||
default IAlignment getAlignment() {
|
||||
return this;
|
||||
}
|
||||
|
||||
static int getAlignmentIndex(ForgeDirection direction, Rotation rotation, Flip flip){
|
||||
return (direction.ordinal()*ROTATIONS_COUNT+rotation.getIndex())*FLIPS_COUNT+flip.getIndex();
|
||||
static int getAlignmentIndex(ForgeDirection direction, Rotation rotation, Flip flip) {
|
||||
return (direction.ordinal() * ROTATIONS_COUNT + rotation.getIndex()) * FLIPS_COUNT + flip.getIndex();
|
||||
}
|
||||
|
||||
default ForgeDirection getDirection(){
|
||||
default ForgeDirection getDirection() {
|
||||
return getExtendedFacing().getDirection();
|
||||
}
|
||||
|
||||
default void setDirection(ForgeDirection direction){
|
||||
default void setDirection(ForgeDirection direction) {
|
||||
setExtendedFacing(getExtendedFacing().with(direction));
|
||||
}
|
||||
|
||||
default Rotation getRotation(){
|
||||
default Rotation getRotation() {
|
||||
return getExtendedFacing().getRotation();
|
||||
}
|
||||
|
||||
default void setRotation(Rotation rotation){
|
||||
default void setRotation(Rotation rotation) {
|
||||
setExtendedFacing(getExtendedFacing().with(rotation));
|
||||
}
|
||||
|
||||
default Flip getFlip(){
|
||||
default Flip getFlip() {
|
||||
return getExtendedFacing().getFlip();
|
||||
}
|
||||
|
||||
default void setFlip(Flip flip){
|
||||
default void setFlip(Flip flip) {
|
||||
setExtendedFacing(getExtendedFacing().with(flip));
|
||||
}
|
||||
|
||||
default boolean toolSetDirection(ForgeDirection direction){
|
||||
if(direction==null || direction==ForgeDirection.UNKNOWN){
|
||||
for (int i = 0,j=getDirection().ordinal()+1, valuesLength = Direction.VALUES.length; i < valuesLength; i++) {
|
||||
default boolean toolSetDirection(ForgeDirection direction) {
|
||||
if (direction == null || direction == ForgeDirection.UNKNOWN) {
|
||||
for (int i = 0, j = getDirection().ordinal() + 1, valuesLength = Direction.VALUES.length; i < valuesLength; i++) {
|
||||
if (toolSetDirection(Direction.VALUES[(j + i) % valuesLength].getForgeDirection())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
for (ExtendedFacing extendedFacing : ExtendedFacing.FOR_FACING.get(direction)) {
|
||||
if(checkedSetExtendedFacing(extendedFacing)){
|
||||
if (checkedSetExtendedFacing(extendedFacing)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -72,17 +72,17 @@ public interface IAlignment extends IAlignmentLimits,IAlignmentProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean checkedSetDirection(ForgeDirection direction){
|
||||
if (isNewDirectionValid(direction)){
|
||||
default boolean checkedSetDirection(ForgeDirection direction) {
|
||||
if (isNewDirectionValid(direction)) {
|
||||
setDirection(direction);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean canSetToDirectionAny(ForgeDirection direction){
|
||||
default boolean canSetToDirectionAny(ForgeDirection direction) {
|
||||
for (ExtendedFacing extendedFacing : ExtendedFacing.FOR_FACING.get(direction)) {
|
||||
if(isNewExtendedFacingValid(extendedFacing)){
|
||||
if (isNewExtendedFacingValid(extendedFacing)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -90,10 +90,10 @@ public interface IAlignment extends IAlignmentLimits,IAlignmentProvider {
|
||||
}
|
||||
|
||||
default boolean toolSetRotation(Rotation rotation) {
|
||||
if(rotation==null){
|
||||
if (rotation == null) {
|
||||
int flips = Flip.VALUES.length;
|
||||
int rotations = Rotation.VALUES.length;
|
||||
for (int ii = 0,jj=getFlip().ordinal(); ii < flips; ii++) {
|
||||
for (int ii = 0, jj = getFlip().ordinal(); ii < flips; ii++) {
|
||||
for (int i = 1, j = getRotation().ordinal(); i < rotations; i++) {
|
||||
if (checkedSetExtendedFacing(ExtendedFacing.of(getDirection(), Rotation.VALUES[(j + i) % rotations], Flip.VALUES[(jj + ii) % flips]))) {
|
||||
return true;
|
||||
@@ -101,55 +101,55 @@ public interface IAlignment extends IAlignmentLimits,IAlignmentProvider {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}else {
|
||||
} else {
|
||||
return checkedSetRotation(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
default boolean checkedSetRotation(Rotation rotation){
|
||||
if (isNewRotationValid(rotation)){
|
||||
default boolean checkedSetRotation(Rotation rotation) {
|
||||
if (isNewRotationValid(rotation)) {
|
||||
setRotation(rotation);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean toolSetFlip(Flip flip){
|
||||
if(flip==null){
|
||||
default boolean toolSetFlip(Flip flip) {
|
||||
if (flip == null) {
|
||||
for (int i = 1, j = getFlip().ordinal(), valuesLength = Flip.VALUES.length; i < valuesLength; i++) {
|
||||
if (checkedSetFlip(Flip.VALUES[(j + i) % valuesLength])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}else {
|
||||
} else {
|
||||
return checkedSetFlip(flip);
|
||||
}
|
||||
}
|
||||
|
||||
default boolean checkedSetFlip(Flip flip){
|
||||
if (isNewFlipValid(flip)){
|
||||
default boolean checkedSetFlip(Flip flip) {
|
||||
if (isNewFlipValid(flip)) {
|
||||
setFlip(flip);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean toolSetExtendedFacing(ExtendedFacing extendedFacing){
|
||||
if(extendedFacing==null){
|
||||
for (int i = 0,j=getExtendedFacing().ordinal()+1, valuesLength = ExtendedFacing.VALUES.length; i < valuesLength; i++) {
|
||||
if (checkedSetExtendedFacing(ExtendedFacing.VALUES[(j + i)%valuesLength])){
|
||||
default boolean toolSetExtendedFacing(ExtendedFacing extendedFacing) {
|
||||
if (extendedFacing == null) {
|
||||
for (int i = 0, j = getExtendedFacing().ordinal() + 1, valuesLength = ExtendedFacing.VALUES.length; i < valuesLength; i++) {
|
||||
if (checkedSetExtendedFacing(ExtendedFacing.VALUES[(j + i) % valuesLength])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}else {
|
||||
} else {
|
||||
return checkedSetExtendedFacing(extendedFacing);
|
||||
}
|
||||
}
|
||||
|
||||
default boolean checkedSetExtendedFacing(ExtendedFacing alignment){
|
||||
if (isNewExtendedFacingValid(alignment)){
|
||||
default boolean checkedSetExtendedFacing(ExtendedFacing alignment) {
|
||||
if (isNewExtendedFacingValid(alignment)) {
|
||||
setExtendedFacing(alignment);
|
||||
return true;
|
||||
}
|
||||
@@ -157,31 +157,31 @@ public interface IAlignment extends IAlignmentLimits,IAlignmentProvider {
|
||||
}
|
||||
|
||||
default boolean isNewDirectionValid(ForgeDirection direction) {
|
||||
return isNewExtendedFacingValid(direction,getRotation(),getFlip());
|
||||
return isNewExtendedFacingValid(direction, getRotation(), getFlip());
|
||||
}
|
||||
|
||||
default boolean isNewRotationValid(Rotation rotation){
|
||||
return isNewExtendedFacingValid(getDirection(),rotation,getFlip());
|
||||
default boolean isNewRotationValid(Rotation rotation) {
|
||||
return isNewExtendedFacingValid(getDirection(), rotation, getFlip());
|
||||
}
|
||||
|
||||
default boolean isNewFlipValid(Flip flip){
|
||||
return isNewExtendedFacingValid(getDirection(),getRotation(),flip);
|
||||
default boolean isNewFlipValid(Flip flip) {
|
||||
return isNewExtendedFacingValid(getDirection(), getRotation(), flip);
|
||||
}
|
||||
|
||||
default boolean isExtendedFacingValid() {
|
||||
return isNewExtendedFacingValid(getDirection(),getRotation(),getFlip());
|
||||
return isNewExtendedFacingValid(getDirection(), getRotation(), getFlip());
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean isNewExtendedFacingValid(ForgeDirection direction, Rotation rotation, Flip flip){
|
||||
default boolean isNewExtendedFacingValid(ForgeDirection direction, Rotation rotation, Flip flip) {
|
||||
return getAlignmentLimits().isNewExtendedFacingValid(direction, rotation, flip);
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean isNewExtendedFacingValid(ExtendedFacing alignment){
|
||||
default boolean isNewExtendedFacingValid(ExtendedFacing alignment) {
|
||||
return getAlignmentLimits().isNewExtendedFacingValid(
|
||||
alignment.getDirection(),
|
||||
alignment.getRotation(),
|
||||
alignment.getFlip());
|
||||
alignment.getDirection(),
|
||||
alignment.getRotation(),
|
||||
alignment.getFlip());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
package com.gtnewhorizon.structurelib.alignment;
|
||||
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Flip;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
|
||||
@@ -18,9 +19,9 @@ public interface IAlignmentLimits {
|
||||
|
||||
default boolean isNewExtendedFacingValid(ExtendedFacing alignment) {
|
||||
return isNewExtendedFacingValid(
|
||||
alignment.getDirection(),
|
||||
alignment.getRotation(),
|
||||
alignment.getFlip());
|
||||
alignment.getDirection(),
|
||||
alignment.getRotation(),
|
||||
alignment.getFlip());
|
||||
}
|
||||
|
||||
static IAlignmentLimits allowOnly(ExtendedFacing... allowedFacings) {
|
||||
@@ -42,7 +43,8 @@ public interface IAlignmentLimits {
|
||||
class Builder {
|
||||
protected final boolean[] validStates = new boolean[STATES_COUNT];
|
||||
|
||||
private Builder() {}
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
public static Builder allowAll() {
|
||||
Builder b = new Builder();
|
||||
|
||||
@@ -16,69 +16,69 @@ public class IntegerAxisSwap {
|
||||
this.forFirstAxis = Direction.getAxisVector(forFirstAxis);
|
||||
this.forSecondAxis = Direction.getAxisVector(forSecondAxis);
|
||||
this.forThirdAxis = Direction.getAxisVector(forThirdAxis);
|
||||
if(abs(this.forFirstAxis.get0())+abs(this.forSecondAxis.get0())+abs(this.forThirdAxis.get0())!=1 ||
|
||||
abs(this.forFirstAxis.get1())+abs(this.forSecondAxis.get1())+abs(this.forThirdAxis.get1())!=1 ||
|
||||
abs(this.forFirstAxis.get2())+abs(this.forSecondAxis.get2())+abs(this.forThirdAxis.get2())!=1){
|
||||
throw new IllegalArgumentException("Axis are overlapping/missing! "+
|
||||
forFirstAxis.name()+" "+
|
||||
forSecondAxis.name()+" "+
|
||||
forThirdAxis.name());
|
||||
if (abs(this.forFirstAxis.get0()) + abs(this.forSecondAxis.get0()) + abs(this.forThirdAxis.get0()) != 1 ||
|
||||
abs(this.forFirstAxis.get1()) + abs(this.forSecondAxis.get1()) + abs(this.forThirdAxis.get1()) != 1 ||
|
||||
abs(this.forFirstAxis.get2()) + abs(this.forSecondAxis.get2()) + abs(this.forThirdAxis.get2()) != 1) {
|
||||
throw new IllegalArgumentException("Axis are overlapping/missing! " +
|
||||
forFirstAxis.name() + " " +
|
||||
forSecondAxis.name() + " " +
|
||||
forThirdAxis.name());
|
||||
}
|
||||
}
|
||||
|
||||
public Vec3Impl translate(Vec3Impl point){
|
||||
public Vec3Impl translate(Vec3Impl point) {
|
||||
return new Vec3Impl(
|
||||
forFirstAxis.get0()*point.get0() +forFirstAxis.get1()*point.get1() +forFirstAxis.get2()*point.get2(),
|
||||
forSecondAxis.get0()*point.get0()+forSecondAxis.get1()*point.get1()+forSecondAxis.get2()*point.get2(),
|
||||
forThirdAxis.get0()*point.get0() +forThirdAxis.get1()*point.get1() +forThirdAxis.get2()*point.get2()
|
||||
forFirstAxis.get0() * point.get0() + forFirstAxis.get1() * point.get1() + forFirstAxis.get2() * point.get2(),
|
||||
forSecondAxis.get0() * point.get0() + forSecondAxis.get1() * point.get1() + forSecondAxis.get2() * point.get2(),
|
||||
forThirdAxis.get0() * point.get0() + forThirdAxis.get1() * point.get1() + forThirdAxis.get2() * point.get2()
|
||||
);
|
||||
}
|
||||
|
||||
public Vec3Impl inverseTranslate(Vec3Impl point){
|
||||
public Vec3Impl inverseTranslate(Vec3Impl point) {
|
||||
return new Vec3Impl(
|
||||
forFirstAxis.get0()*point.get0()+forSecondAxis.get0()*point.get1()+forThirdAxis.get0()*point.get2(),
|
||||
forFirstAxis.get1()*point.get0()+forSecondAxis.get1()*point.get1()+forThirdAxis.get1()*point.get2(),
|
||||
forFirstAxis.get2()*point.get0()+forSecondAxis.get2()*point.get1()+forThirdAxis.get2()*point.get2()
|
||||
forFirstAxis.get0() * point.get0() + forSecondAxis.get0() * point.get1() + forThirdAxis.get0() * point.get2(),
|
||||
forFirstAxis.get1() * point.get0() + forSecondAxis.get1() * point.get1() + forThirdAxis.get1() * point.get2(),
|
||||
forFirstAxis.get2() * point.get0() + forSecondAxis.get2() * point.get1() + forThirdAxis.get2() * point.get2()
|
||||
);
|
||||
}
|
||||
|
||||
public Vec3 translate(Vec3 point){
|
||||
public Vec3 translate(Vec3 point) {
|
||||
return Vec3.createVectorHelper(
|
||||
forFirstAxis.get0()*point.xCoord +forFirstAxis.get1()*point.yCoord +forFirstAxis.get2()*point.zCoord,
|
||||
forSecondAxis.get0()*point.xCoord+forSecondAxis.get1()*point.yCoord+forSecondAxis.get2()*point.zCoord,
|
||||
forThirdAxis.get0()*point.xCoord +forThirdAxis.get1()*point.yCoord +forThirdAxis.get2()*point.zCoord
|
||||
forFirstAxis.get0() * point.xCoord + forFirstAxis.get1() * point.yCoord + forFirstAxis.get2() * point.zCoord,
|
||||
forSecondAxis.get0() * point.xCoord + forSecondAxis.get1() * point.yCoord + forSecondAxis.get2() * point.zCoord,
|
||||
forThirdAxis.get0() * point.xCoord + forThirdAxis.get1() * point.yCoord + forThirdAxis.get2() * point.zCoord
|
||||
);
|
||||
}
|
||||
|
||||
public Vec3 inverseTranslate(Vec3 point){
|
||||
public Vec3 inverseTranslate(Vec3 point) {
|
||||
return Vec3.createVectorHelper(
|
||||
forFirstAxis.get0()*point.xCoord+forSecondAxis.get0()*point.yCoord+forThirdAxis.get0()*point.zCoord,
|
||||
forFirstAxis.get1()*point.xCoord+forSecondAxis.get1()*point.yCoord+forThirdAxis.get1()*point.zCoord,
|
||||
forFirstAxis.get2()*point.xCoord+forSecondAxis.get2()*point.yCoord+forThirdAxis.get2()*point.zCoord
|
||||
forFirstAxis.get0() * point.xCoord + forSecondAxis.get0() * point.yCoord + forThirdAxis.get0() * point.zCoord,
|
||||
forFirstAxis.get1() * point.xCoord + forSecondAxis.get1() * point.yCoord + forThirdAxis.get1() * point.zCoord,
|
||||
forFirstAxis.get2() * point.xCoord + forSecondAxis.get2() * point.yCoord + forThirdAxis.get2() * point.zCoord
|
||||
);
|
||||
}
|
||||
|
||||
public void translate(int[] point,int[] out){
|
||||
out[0]=forFirstAxis.get0()*point[0] +forFirstAxis.get1()*point[1] +forFirstAxis.get2()*point[2];
|
||||
out[1]=forSecondAxis.get0()*point[0]+forSecondAxis.get1()*point[1]+forSecondAxis.get2()*point[2];
|
||||
out[2]=forThirdAxis.get0()*point[0] +forThirdAxis.get1()*point[1] +forThirdAxis.get2()*point[2];
|
||||
|
||||
public void translate(int[] point, int[] out) {
|
||||
out[0] = forFirstAxis.get0() * point[0] + forFirstAxis.get1() * point[1] + forFirstAxis.get2() * point[2];
|
||||
out[1] = forSecondAxis.get0() * point[0] + forSecondAxis.get1() * point[1] + forSecondAxis.get2() * point[2];
|
||||
out[2] = forThirdAxis.get0() * point[0] + forThirdAxis.get1() * point[1] + forThirdAxis.get2() * point[2];
|
||||
}
|
||||
|
||||
public void inverseTranslate(int[] point,int[] out){
|
||||
out[0]=forFirstAxis.get0()*point[0]+forSecondAxis.get0()*point[1]+forThirdAxis.get0()*point[2];
|
||||
out[1]=forFirstAxis.get1()*point[0]+forSecondAxis.get1()*point[1]+forThirdAxis.get1()*point[2];
|
||||
out[2]=forFirstAxis.get2()*point[0]+forSecondAxis.get2()*point[1]+forThirdAxis.get2()*point[2];
|
||||
public void inverseTranslate(int[] point, int[] out) {
|
||||
out[0] = forFirstAxis.get0() * point[0] + forSecondAxis.get0() * point[1] + forThirdAxis.get0() * point[2];
|
||||
out[1] = forFirstAxis.get1() * point[0] + forSecondAxis.get1() * point[1] + forThirdAxis.get1() * point[2];
|
||||
out[2] = forFirstAxis.get2() * point[0] + forSecondAxis.get2() * point[1] + forThirdAxis.get2() * point[2];
|
||||
}
|
||||
|
||||
public void translate(double[] point,double[] out){
|
||||
out[0]=forFirstAxis.get0()*point[0] +forFirstAxis.get1()*point[1] +forFirstAxis.get2()*point[2];
|
||||
out[1]=forSecondAxis.get0()*point[0]+forSecondAxis.get1()*point[1]+forSecondAxis.get2()*point[2];
|
||||
out[2]=forThirdAxis.get0()*point[0] +forThirdAxis.get1()*point[1] +forThirdAxis.get2()*point[2];
|
||||
public void translate(double[] point, double[] out) {
|
||||
out[0] = forFirstAxis.get0() * point[0] + forFirstAxis.get1() * point[1] + forFirstAxis.get2() * point[2];
|
||||
out[1] = forSecondAxis.get0() * point[0] + forSecondAxis.get1() * point[1] + forSecondAxis.get2() * point[2];
|
||||
out[2] = forThirdAxis.get0() * point[0] + forThirdAxis.get1() * point[1] + forThirdAxis.get2() * point[2];
|
||||
}
|
||||
|
||||
public void inverseTranslate(double[] point,double[] out){
|
||||
out[0]=forFirstAxis.get0()*point[0]+forSecondAxis.get0()*point[1]+forThirdAxis.get0()*point[2];
|
||||
out[1]=forFirstAxis.get1()*point[0]+forSecondAxis.get1()*point[1]+forThirdAxis.get1()*point[2];
|
||||
out[2]=forFirstAxis.get2()*point[0]+forSecondAxis.get2()*point[1]+forThirdAxis.get2()*point[2];
|
||||
public void inverseTranslate(double[] point, double[] out) {
|
||||
out[0] = forFirstAxis.get0() * point[0] + forSecondAxis.get0() * point[1] + forThirdAxis.get0() * point[2];
|
||||
out[1] = forFirstAxis.get1() * point[0] + forSecondAxis.get1() * point[1] + forThirdAxis.get1() * point[2];
|
||||
out[2] = forFirstAxis.get2() * point[0] + forSecondAxis.get2() * point[1] + forThirdAxis.get2() * point[2];
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -43,10 +43,10 @@ public class ConstructableUtility {
|
||||
IMultiblockInfoContainer<TileEntity> iMultiblockInfoContainer = IMultiblockInfoContainer.get(tTileEntity.getClass());
|
||||
if (tTileEntity instanceof IAlignment) {
|
||||
iMultiblockInfoContainer.construct(aStack, false, tTileEntity,
|
||||
((IAlignment) tTileEntity).getExtendedFacing());
|
||||
((IAlignment) tTileEntity).getExtendedFacing());
|
||||
} else {
|
||||
iMultiblockInfoContainer.construct(aStack, false, tTileEntity,
|
||||
ExtendedFacing.of(ForgeDirection.getOrientation(aSide)));
|
||||
ExtendedFacing.of(ForgeDirection.getOrientation(aSide)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,10 +68,10 @@ public class ConstructableUtility {
|
||||
IMultiblockInfoContainer<TileEntity> iMultiblockInfoContainer = IMultiblockInfoContainer.get(tTileEntity.getClass());
|
||||
if (tTileEntity instanceof IAlignment) {
|
||||
iMultiblockInfoContainer.construct(aStack, true, tTileEntity,
|
||||
((IAlignment) tTileEntity).getExtendedFacing());
|
||||
((IAlignment) tTileEntity).getExtendedFacing());
|
||||
} else {
|
||||
iMultiblockInfoContainer.construct(aStack, true, tTileEntity,
|
||||
ExtendedFacing.of(ForgeDirection.getOrientation(aSide)));
|
||||
ExtendedFacing.of(ForgeDirection.getOrientation(aSide)));
|
||||
}
|
||||
StructureLib.addClientSideChatMessages(IMultiblockInfoContainer.get(tTileEntity.getClass()).getDescription(aStack));
|
||||
return false;
|
||||
|
||||
+5
-5
@@ -6,9 +6,9 @@ import javax.annotation.Nullable;
|
||||
* Implement this interface if this tile entity MIGHT be constructable
|
||||
*/
|
||||
public interface IConstructableProvider {
|
||||
/**
|
||||
* @return null if not constructable, an instance otherwise.
|
||||
*/
|
||||
@Nullable
|
||||
IConstructable getConstructable();
|
||||
/**
|
||||
* @return null if not constructable, an instance otherwise.
|
||||
*/
|
||||
@Nullable
|
||||
IConstructable getConstructable();
|
||||
}
|
||||
@@ -13,11 +13,11 @@ public enum Direction {
|
||||
|
||||
private final ForgeDirection forgeDirection;
|
||||
private final Vec3Impl axisVector;
|
||||
public static final Direction[] VALUES=values();
|
||||
public static final Direction[] VALUES = values();
|
||||
|
||||
Direction(ForgeDirection forgeDirection) {
|
||||
this.forgeDirection = forgeDirection;
|
||||
axisVector=new Vec3Impl(forgeDirection.offsetX,forgeDirection.offsetY,forgeDirection.offsetZ);
|
||||
axisVector = new Vec3Impl(forgeDirection.offsetX, forgeDirection.offsetY, forgeDirection.offsetZ);
|
||||
}
|
||||
|
||||
public ForgeDirection getForgeDirection() {
|
||||
@@ -28,7 +28,7 @@ public enum Direction {
|
||||
return axisVector;
|
||||
}
|
||||
|
||||
public static Vec3Impl getAxisVector(ForgeDirection forgeDirection){
|
||||
public static Vec3Impl getAxisVector(ForgeDirection forgeDirection) {
|
||||
return VALUES[forgeDirection.ordinal()].axisVector;
|
||||
}
|
||||
}
|
||||
+106
-84
@@ -114,19 +114,20 @@ public enum ExtendedFacing {
|
||||
EAST_COUNTER_CLOCKWISE_VERTICAL("east counter clockwise vertical"),
|
||||
EAST_COUNTER_CLOCKWISE_BOTH("east counter clockwise both");
|
||||
|
||||
public static final ExtendedFacing DEFAULT=NORTH_NORMAL_NONE;
|
||||
public static final ExtendedFacing DEFAULT = NORTH_NORMAL_NONE;
|
||||
public static final ExtendedFacing[] VALUES = values();
|
||||
public static final Map<ForgeDirection, List<ExtendedFacing>> FOR_FACING=new HashMap<>();
|
||||
public static final Map<ForgeDirection, List<ExtendedFacing>> FOR_FACING = new HashMap<>();
|
||||
public static final int STATES_COUNT = VALUES.length;
|
||||
|
||||
static {
|
||||
stream(values()).forEach(extendedFacing ->
|
||||
FOR_FACING.compute(extendedFacing.direction, ((forgeDirection, extendedFacings) -> {
|
||||
if (extendedFacings == null) {
|
||||
extendedFacings = new ArrayList<>();
|
||||
}
|
||||
extendedFacings.add(extendedFacing);
|
||||
return extendedFacings;
|
||||
})));
|
||||
FOR_FACING.compute(extendedFacing.direction, ((forgeDirection, extendedFacings) -> {
|
||||
if (extendedFacings == null) {
|
||||
extendedFacings = new ArrayList<>();
|
||||
}
|
||||
extendedFacings.add(extendedFacing);
|
||||
return extendedFacings;
|
||||
})));
|
||||
}
|
||||
|
||||
private static final Map<String, ExtendedFacing> NAME_LOOKUP = stream(VALUES).collect(toMap(ExtendedFacing::getName2, (extendedFacing) -> extendedFacing));
|
||||
@@ -143,133 +144,146 @@ public enum ExtendedFacing {
|
||||
|
||||
ExtendedFacing(String name) {
|
||||
this.name = name;
|
||||
direction= Direction.VALUES[ordinal()/(ROTATIONS_COUNT*FLIPS_COUNT)].getForgeDirection();
|
||||
rotation=Rotation.VALUES[ordinal()/FLIPS_COUNT-direction.ordinal()*ROTATIONS_COUNT];
|
||||
flip=Flip.VALUES[ordinal()%FLIPS_COUNT];
|
||||
ForgeDirection a,b,c;
|
||||
switch (direction){
|
||||
direction = Direction.VALUES[ordinal() / (ROTATIONS_COUNT * FLIPS_COUNT)].getForgeDirection();
|
||||
rotation = Rotation.VALUES[ordinal() / FLIPS_COUNT - direction.ordinal() * ROTATIONS_COUNT];
|
||||
flip = Flip.VALUES[ordinal() % FLIPS_COUNT];
|
||||
ForgeDirection a, b, c;
|
||||
switch (direction) {
|
||||
case DOWN:
|
||||
a= ForgeDirection.WEST;
|
||||
b= ForgeDirection.SOUTH;
|
||||
c= ForgeDirection.UP;
|
||||
a = ForgeDirection.WEST;
|
||||
b = ForgeDirection.SOUTH;
|
||||
c = ForgeDirection.UP;
|
||||
break;
|
||||
case UP:
|
||||
a= ForgeDirection.EAST;
|
||||
b= ForgeDirection.SOUTH;
|
||||
c= ForgeDirection.DOWN;
|
||||
a = ForgeDirection.EAST;
|
||||
b = ForgeDirection.SOUTH;
|
||||
c = ForgeDirection.DOWN;
|
||||
break;
|
||||
case NORTH:
|
||||
a= ForgeDirection.WEST;
|
||||
b= ForgeDirection.DOWN;
|
||||
c= ForgeDirection.SOUTH;
|
||||
a = ForgeDirection.WEST;
|
||||
b = ForgeDirection.DOWN;
|
||||
c = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case SOUTH:
|
||||
a= ForgeDirection.EAST;
|
||||
b= ForgeDirection.DOWN;
|
||||
c= ForgeDirection.NORTH;
|
||||
a = ForgeDirection.EAST;
|
||||
b = ForgeDirection.DOWN;
|
||||
c = ForgeDirection.NORTH;
|
||||
break;
|
||||
case WEST:
|
||||
a= ForgeDirection.SOUTH;
|
||||
b= ForgeDirection.DOWN;
|
||||
c= ForgeDirection.EAST;
|
||||
a = ForgeDirection.SOUTH;
|
||||
b = ForgeDirection.DOWN;
|
||||
c = ForgeDirection.EAST;
|
||||
break;
|
||||
case EAST:
|
||||
a= ForgeDirection.NORTH;
|
||||
b= ForgeDirection.DOWN;
|
||||
c= ForgeDirection.WEST;
|
||||
a = ForgeDirection.NORTH;
|
||||
b = ForgeDirection.DOWN;
|
||||
c = ForgeDirection.WEST;
|
||||
break;
|
||||
default:throw new RuntimeException("Is impossible...");
|
||||
default:
|
||||
throw new RuntimeException("Is impossible...");
|
||||
}
|
||||
switch (flip){//This duplicates some axis swaps since flip boolean would do, but seems more convenient to use
|
||||
switch (flip) {//This duplicates some axis swaps since flip boolean would do, but seems more convenient to use
|
||||
case HORIZONTAL:
|
||||
a=a.getOpposite();
|
||||
a = a.getOpposite();
|
||||
break;
|
||||
case BOTH:
|
||||
a=a.getOpposite();
|
||||
a = a.getOpposite();
|
||||
case VERTICAL:
|
||||
b=b.getOpposite();
|
||||
b = b.getOpposite();
|
||||
break;
|
||||
case NONE: break;
|
||||
default:throw new RuntimeException("Even more impossible...");
|
||||
case NONE:
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Even more impossible...");
|
||||
}
|
||||
switch (rotation) {
|
||||
case CLOCKWISE: {
|
||||
ForgeDirection _a=a;
|
||||
a =b;
|
||||
b =_a.getOpposite();
|
||||
ForgeDirection _a = a;
|
||||
a = b;
|
||||
b = _a.getOpposite();
|
||||
break;
|
||||
}
|
||||
case UPSIDE_DOWN:
|
||||
a=a.getOpposite();
|
||||
b=b.getOpposite();
|
||||
a = a.getOpposite();
|
||||
b = b.getOpposite();
|
||||
break;
|
||||
case COUNTER_CLOCKWISE: {
|
||||
ForgeDirection _a=a;
|
||||
a =b.getOpposite();
|
||||
b =_a;
|
||||
ForgeDirection _a = a;
|
||||
a = b.getOpposite();
|
||||
b = _a;
|
||||
break;
|
||||
}
|
||||
case NORMAL: break;
|
||||
case NORMAL:
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("More impossible...");
|
||||
}
|
||||
this.a=a;
|
||||
this.b=b;
|
||||
this.c=c;
|
||||
integerAxisSwap =new IntegerAxisSwap(a,b,c);
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
integerAxisSwap = new IntegerAxisSwap(a, b, c);
|
||||
}
|
||||
|
||||
public static ExtendedFacing of(ForgeDirection direction, Rotation rotation, Flip flip){
|
||||
if(direction==ForgeDirection.UNKNOWN){
|
||||
public static ExtendedFacing of(ForgeDirection direction, Rotation rotation, Flip flip) {
|
||||
if (direction == ForgeDirection.UNKNOWN) {
|
||||
return VALUES[IAlignment.getAlignmentIndex(ForgeDirection.NORTH, rotation, flip)];
|
||||
}
|
||||
return VALUES[IAlignment.getAlignmentIndex(direction, rotation, flip)];
|
||||
}
|
||||
|
||||
public static ExtendedFacing of(ForgeDirection direction){
|
||||
if(direction==ForgeDirection.UNKNOWN){
|
||||
public static ExtendedFacing of(ForgeDirection direction) {
|
||||
if (direction == ForgeDirection.UNKNOWN) {
|
||||
return DEFAULT;
|
||||
}
|
||||
return VALUES[IAlignment.getAlignmentIndex(direction, Rotation.NORMAL, Flip.NONE)];
|
||||
}
|
||||
|
||||
public static ImmutableSet<ExtendedFacing> getAllWith(ForgeDirection direction) { return LOOKUP_BY_DIRECTION.get(direction);}
|
||||
public static ImmutableSet<ExtendedFacing> getAllWith(Rotation rotation) { return LOOKUP_BY_ROTATION.get(rotation);}
|
||||
public static ImmutableSet<ExtendedFacing> getAllWith(Flip flip) { return LOOKUP_BY_FLIP.get(flip);}
|
||||
|
||||
public ExtendedFacing with(ForgeDirection direction){
|
||||
return of(direction,rotation,flip);
|
||||
public static ImmutableSet<ExtendedFacing> getAllWith(ForgeDirection direction) {
|
||||
return LOOKUP_BY_DIRECTION.get(direction);
|
||||
}
|
||||
|
||||
public ExtendedFacing with(Rotation rotation){
|
||||
return of(direction,rotation,flip);
|
||||
public static ImmutableSet<ExtendedFacing> getAllWith(Rotation rotation) {
|
||||
return LOOKUP_BY_ROTATION.get(rotation);
|
||||
}
|
||||
|
||||
public ExtendedFacing with(Flip flip){
|
||||
return of(direction,rotation,flip);
|
||||
public static ImmutableSet<ExtendedFacing> getAllWith(Flip flip) {
|
||||
return LOOKUP_BY_FLIP.get(flip);
|
||||
}
|
||||
|
||||
public ExtendedFacing with(ForgeDirection direction) {
|
||||
return of(direction, rotation, flip);
|
||||
}
|
||||
|
||||
public ExtendedFacing with(Rotation rotation) {
|
||||
return of(direction, rotation, flip);
|
||||
}
|
||||
|
||||
public ExtendedFacing with(Flip flip) {
|
||||
return of(direction, rotation, flip);
|
||||
}
|
||||
|
||||
public ExtendedFacing getOppositeDirection() {
|
||||
return of(direction.getOpposite(),rotation,flip);
|
||||
return of(direction.getOpposite(), rotation, flip);
|
||||
}
|
||||
|
||||
public ExtendedFacing getOppositeRotation() {
|
||||
return of(direction,rotation.getOpposite(),flip);
|
||||
return of(direction, rotation.getOpposite(), flip);
|
||||
}
|
||||
|
||||
public ExtendedFacing getOppositeFlip() {
|
||||
return of(direction,rotation,flip.getOpposite());
|
||||
return of(direction, rotation, flip.getOpposite());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the same effective facing achieved by different rot/flip combo
|
||||
*
|
||||
* @return same effective facing, but different enum value
|
||||
*/
|
||||
public ExtendedFacing getDuplicate(){
|
||||
return of(direction,rotation.getOpposite(),flip.getOpposite());
|
||||
public ExtendedFacing getDuplicate() {
|
||||
return of(direction, rotation.getOpposite(), flip.getOpposite());
|
||||
}
|
||||
|
||||
public int getIndex(){
|
||||
public int getIndex() {
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@@ -307,39 +321,47 @@ public enum ExtendedFacing {
|
||||
|
||||
/**
|
||||
* Translates relative to front facing offset to world offset
|
||||
*
|
||||
* @param abcOffset A,B,C offset (facing relative L-->R,U-->D,F-->B)
|
||||
* @return X,Y,Z offset in world
|
||||
* @return X, Y, Z offset in world
|
||||
*/
|
||||
public Vec3 getWorldOffset(Vec3 abcOffset) {
|
||||
return integerAxisSwap.inverseTranslate(abcOffset);
|
||||
}
|
||||
|
||||
public Vec3Impl getWorldOffset(Vec3Impl abcOffset) {
|
||||
return integerAxisSwap.inverseTranslate(abcOffset);
|
||||
}
|
||||
public void getWorldOffset(int[] point,int[] out){
|
||||
integerAxisSwap.inverseTranslate(point,out);
|
||||
|
||||
public void getWorldOffset(int[] point, int[] out) {
|
||||
integerAxisSwap.inverseTranslate(point, out);
|
||||
}
|
||||
public void getWorldOffset(double[] point,double[] out){
|
||||
integerAxisSwap.inverseTranslate(point,out);
|
||||
|
||||
public void getWorldOffset(double[] point, double[] out) {
|
||||
integerAxisSwap.inverseTranslate(point, out);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates world offset to relative front facing offset
|
||||
*
|
||||
* @param xyzOffset X,Y,Z offset in world
|
||||
* @return A,B,C offset (facing relative L-->R,U-->D,F-->B)
|
||||
* @return A, B, C offset (facing relative L-->R,U-->D,F-->B)
|
||||
*/
|
||||
public Vec3 getOffsetABC(Vec3 xyzOffset){
|
||||
public Vec3 getOffsetABC(Vec3 xyzOffset) {
|
||||
return integerAxisSwap.translate(xyzOffset);
|
||||
}
|
||||
public Vec3Impl getOffsetABC(Vec3Impl xyzOffset){
|
||||
|
||||
public Vec3Impl getOffsetABC(Vec3Impl xyzOffset) {
|
||||
return integerAxisSwap.translate(xyzOffset);
|
||||
}
|
||||
public void getOffsetABC(int[] point,int[] out){
|
||||
integerAxisSwap.translate(point,out);
|
||||
|
||||
public void getOffsetABC(int[] point, int[] out) {
|
||||
integerAxisSwap.translate(point, out);
|
||||
}
|
||||
public void getOffsetABC(double[] point,double[] out){
|
||||
integerAxisSwap.translate(point,out);
|
||||
|
||||
public void getOffsetABC(double[] point, double[] out) {
|
||||
integerAxisSwap.translate(point, out);
|
||||
}
|
||||
|
||||
public IntegerAxisSwap getIntegerAxisSwap() {
|
||||
|
||||
@@ -26,7 +26,7 @@ public enum Flip {
|
||||
this.name = nameIn;
|
||||
}
|
||||
|
||||
public int getIndex(){
|
||||
public int getIndex() {
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@@ -58,19 +58,19 @@ public enum Flip {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isNotFlipped(){
|
||||
return this==NONE;
|
||||
public boolean isNotFlipped() {
|
||||
return this == NONE;
|
||||
}
|
||||
|
||||
public boolean isBothFlipped(){
|
||||
return this==BOTH;
|
||||
public boolean isBothFlipped() {
|
||||
return this == BOTH;
|
||||
}
|
||||
|
||||
public boolean isHorizontallyFlipped() {
|
||||
return this==HORIZONTAL || isBothFlipped();
|
||||
return this == HORIZONTAL || isBothFlipped();
|
||||
}
|
||||
|
||||
public boolean isVerticallyFliped() {
|
||||
return this==VERTICAL || isBothFlipped();
|
||||
return this == VERTICAL || isBothFlipped();
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public enum Rotation {
|
||||
this.name = nameIn;
|
||||
}
|
||||
|
||||
public int getIndex(){
|
||||
public int getIndex() {
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@@ -58,19 +58,19 @@ public enum Rotation {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isNotRotated(){
|
||||
return this==NORMAL;
|
||||
public boolean isNotRotated() {
|
||||
return this == NORMAL;
|
||||
}
|
||||
|
||||
public boolean isClockwise(){
|
||||
return this==CLOCKWISE;
|
||||
public boolean isClockwise() {
|
||||
return this == CLOCKWISE;
|
||||
}
|
||||
|
||||
public boolean isCounterClockwise(){
|
||||
return this==COUNTER_CLOCKWISE;
|
||||
public boolean isCounterClockwise() {
|
||||
return this == COUNTER_CLOCKWISE;
|
||||
}
|
||||
|
||||
public boolean isUpsideDown(){
|
||||
return this==UPSIDE_DOWN;
|
||||
public boolean isUpsideDown() {
|
||||
return this == UPSIDE_DOWN;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user