Compare commits

...
7 Commits
Author SHA1 Message Date
Dream Master 09619b0a28 Merge branch 'master' into dev
# Conflicts:
#	dependencies.gradle
2025-08-04 10:30:11 +07:00
Dream Master 6283931667 update 2025-08-04 10:28:35 +07:00
Abdiel Kavash 3b3bc4b9ad Add preset IAlignmentLimits constants. (#43)
Many multiblocks can only be placed or rotated in certain orientations.
This has been always done ad-hoc, with individual checks for each
controller. This is inconsistent and sometimes it results in bugs where
certain orientations are not allowed for no discernible reason; for
example
https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/14206.

This PR introduces a short list of named constants to
`IAlignmentLimits`, which describe common multiplboc orientations. These
are currently:

* `UNLIMITED`: Any orientation is allowed. Most multiblocks.
* `UPRIGHT`: The multiblock must be in an upright position, with the top
side facing up. Example: Distillation Tower, Ore Washing Plant.
* `NOT_UPSIDE_DOWN`: The multiblock can be in any orientation, except
for the top side facing directly downwards. This is currently only the
Large Heat Exchanger and Integrated Ore Factory.
* `FACING_UP`: The front of the controller must face up. Example:
Flotation Cell, XL Turbines.

Currently, these constants describe the allowed facings of *all* GT5U
multiblocks.

A multiblock can then simply return one of these constants from
`getInitialAlignmentLimits()` to describe its valid orientations,
instead of implementing the logic itself. This concentrates the code to
one place, improves readability, and fixes any bugs connected with these
checks being done wrong.

Of course, even though the list is currently complete, if any future
multiblock wants to implement its own strange restrictions on
orientation, it can still implement its own check instead of returning
one of the constants.

A follow-up PR to GT5U implements this for all multiblocks which
restrict valid orientations:
https://github.com/GTNewHorizons/GT5-Unofficial/pull/4595
2025-08-01 10:54:59 +07:00
Dream Master 6de4676338 Merge remote-tracking branch 'AbdielKavash/AlignmentLimits' into dev 2025-07-16 10:58:20 +07:00
Abdiel Kavash 6d9047210f Merge branch 'master' into AlignmentLimits 2025-07-14 17:22:39 -06:00
Abdiel Kavash a17951c7d7 IAlignmentLimits presets 2025-07-12 09:32:54 -06:00
Abdiel Kavash e3d159d0d7 uBS + uD 2025-07-12 09:32:33 -06:00
3 changed files with 39 additions and 2 deletions

No files matched your search

+2 -2
View File
@@ -2,12 +2,12 @@
dependencies {
api("com.github.GTNewHorizons:GTNHLib:0.6.38:dev")
implementation("com.github.GTNewHorizons:NotEnoughItems:2.7.64-GTNH:dev")
implementation("com.github.GTNewHorizons:NotEnoughItems:2.7.69-GTNH:dev")
testImplementation(platform('org.junit:junit-bom:5.9.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.391:dev") {
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.420:dev") {
// exclude group: "com.github.GTNewHorizons", module: "StructureLib"
// }
}
+17
View File
@@ -0,0 +1,17 @@
// Add your dependencies here
dependencies {
api("com.github.GTNewHorizons:GTNHLib:0.6.38:dev")
<<<<<<< HEAD
implementation("com.github.GTNewHorizons:NotEnoughItems:2.7.64-GTNH:dev")
=======
implementation("com.github.GTNewHorizons:NotEnoughItems:2.7.69-GTNH:dev")
>>>>>>> master
testImplementation(platform('org.junit:junit-bom:5.9.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.391:dev") {
// exclude group: "com.github.GTNewHorizons", module: "StructureLib"
// }
}
@@ -14,8 +14,28 @@ import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
public interface IAlignmentLimits {
/**
* Can be placed in any orientation.
*/
IAlignmentLimits UNLIMITED = (direction, rotation, flip) -> true;
/**
* Must be standing upright; i.e., top side of the block facing up.
*/
IAlignmentLimits UPRIGHT = (direction, rotation, flip) -> direction.offsetY == 0
&& (flip.isVerticallyFliped() ? rotation.isUpsideDown() : rotation.isNotRotated());
/**
* Can be in any orientation except upside down; i.e., top side of the block facing down.
*/
IAlignmentLimits NOT_UPSIDE_DOWN = (direction, rotation, flip) -> direction.offsetY != 0
|| (flip.isVerticallyFliped() ? !rotation.isNotRotated() : !rotation.isUpsideDown());
/**
* Front side of the block must be facing up.
*/
IAlignmentLimits FACING_UP = (direction, rotation, flip) -> direction == ForgeDirection.UP;
boolean isNewExtendedFacingValid(ForgeDirection direction, Rotation rotation, Flip flip);
default boolean isNewExtendedFacingValid(ExtendedFacing alignment) {