Skip to content

Commit 9374e59

Browse files
authored
Allow vertical orientations with component (#940)
1 parent a5bf998 commit 9374e59

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/main/java/aztech/modern_industrialization/machines/components/OrientationComponent.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public boolean useWrench(Player player, InteractionHand hand, Direction face) {
8989
return true;
9090
}
9191
} else {
92-
if (face.getAxis().isHorizontal()) {
92+
if (params.canBeVertical || face.getAxis().isHorizontal()) {
9393
facingDirection = face;
9494
}
9595
// We consume the event to prevent the GUI from opening.
@@ -100,7 +100,7 @@ public boolean useWrench(Player player, InteractionHand hand, Direction face) {
100100

101101
public void onPlaced(@Nullable LivingEntity placer, ItemStack itemStack) {
102102
// The placer can be null using some mods' automatic placement: pick NORTH arbitrarily.
103-
Direction dir = placer != null ? placer.getDirection() : Direction.NORTH;
103+
Direction dir = placer != null ? (params.canBeVertical ? placer.getNearestViewDirection() : placer.getDirection()) : Direction.NORTH;
104104
facingDirection = dir.getOpposite();
105105
if (params.hasOutput) {
106106
outputDirection = dir;
@@ -111,11 +111,21 @@ public static class Params {
111111
public final boolean hasOutput;
112112
public final boolean hasExtractItems;
113113
public final boolean hasExtractFluids;
114+
/**
115+
* MI itself does not make use of this field, and it purely exists for addons. If you want to use this field, you will need to make your own
116+
* model loader.
117+
*/
118+
public final boolean canBeVertical;
114119

115-
public Params(boolean hasOutput, boolean hasExtractItems, boolean hasExtractFluids) {
120+
public Params(boolean hasOutput, boolean hasExtractItems, boolean hasExtractFluids, boolean canBeVertical) {
116121
this.hasOutput = hasOutput;
117122
this.hasExtractItems = hasExtractItems;
118123
this.hasExtractFluids = hasExtractFluids;
124+
this.canBeVertical = canBeVertical;
125+
}
126+
127+
public Params(boolean hasOutput, boolean hasExtractItems, boolean hasExtractFluids) {
128+
this(hasOutput, hasExtractItems, hasExtractFluids, false);
119129
}
120130
}
121131

0 commit comments

Comments
 (0)