Skip to content

Commit

Permalink
Fixed stage setting priority
Browse files Browse the repository at this point in the history
  • Loading branch information
Cibernet83 committed Jan 26, 2024
1 parent 5c59100 commit c8f069a
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ public static boolean getLocalizedRule(Level level, BlockPos pos, GameRules.Key<
ArrayList<Stage> stages = new ArrayList<>(level.isClientSide ? ClientUtils.clientStages.values() : SaveInfoCapability.get(level.getServer()).getStages().values());

Stage localStage = null;
AABB localStageBounds = null;


for (Object obj : stages.stream().filter(stage -> stage.dimID.equals(level.dimension().location()) && new AABB(stage.cornerA, stage.cornerB).expandTowards(1, 1, 1).contains(pos.getX(), pos.getY(), pos.getZ())).toArray()) {
Stage stage = (Stage) obj;
if (localStage == null ||
Math.abs(stage.cornerA.getX() - stage.cornerB.getX()) < Math.abs(localStage.cornerA.getX() - localStage.cornerB.getX()) ||
Math.abs(stage.cornerA.getY() - stage.cornerB.getY()) < Math.abs(localStage.cornerA.getY() - localStage.cornerB.getY()) ||
Math.abs(stage.cornerA.getZ() - stage.cornerB.getZ()) < Math.abs(localStage.cornerA.getZ() - localStage.cornerB.getZ()))
AABB stageBounds = new AABB(stage.cornerA, stage.cornerB);

if (localStage == null || stageBounds.getSize() < localStageBounds.getSize())
{
localStage = stage;
localStageBounds = new AABB(stage.cornerA, stage.cornerB);
}
}

if (localStage != null && localStage.hasSetting(rule))
Expand Down

0 comments on commit c8f069a

Please sign in to comment.