From e853ceb5d61a183e54bf421dbabac47842e9f452 Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Sat, 11 Nov 2017 13:08:03 +0100 Subject: [PATCH] backport potential bugfix from 7.2.x branch --- buildcraft_resources/changelog/7.1.23 | 3 ++- .../core/statements/StatementParameterDirection.java | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/buildcraft_resources/changelog/7.1.23 b/buildcraft_resources/changelog/7.1.23 index 9c7d1365..4a327b65 100644 --- a/buildcraft_resources/changelog/7.1.23 +++ b/buildcraft_resources/changelog/7.1.23 @@ -1,4 +1,5 @@ Bugs fixed: * [#3839] Attempt to work around potential world corruption? -* [#3837] Oil spawn in mid-air on superflat, f \ No newline at end of file +* [#3837] Oil spawn in mid-air on superflat +* Potential direction statement parameter crash in gate GUI \ No newline at end of file diff --git a/common/buildcraft/core/statements/StatementParameterDirection.java b/common/buildcraft/core/statements/StatementParameterDirection.java index ae74ea04..eeec75e6 100644 --- a/common/buildcraft/core/statements/StatementParameterDirection.java +++ b/common/buildcraft/core/statements/StatementParameterDirection.java @@ -50,7 +50,12 @@ public class StatementParameterDirection implements IStatementParameter { public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) { if (source.getTile() instanceof IPipeTile) { for (int i = 0; i < 6; i++) { - direction = ForgeDirection.getOrientation((direction.ordinal() + (mouse.getButton() > 0 ? -1 : 1)) % 6); + int dir = (direction.ordinal() + (mouse.getButton() > 0 ? -1 : 1)) % 6; + if (dir < 0) { + dir += 6; + } + + direction = ForgeDirection.getOrientation(dir); if (((IPipeTile) source.getTile()).isPipeConnected(direction)) { return; }