diff --git a/src/main/java/com/github/stefvanschie/inventoryframework/pane/OutlinePane.java b/src/main/java/com/github/stefvanschie/inventoryframework/pane/OutlinePane.java index e2d1b495..9426c2df 100644 --- a/src/main/java/com/github/stefvanschie/inventoryframework/pane/OutlinePane.java +++ b/src/main/java/com/github/stefvanschie/inventoryframework/pane/OutlinePane.java @@ -148,19 +148,24 @@ public void display(@NotNull Gui gui, @NotNull Inventory inventory, @NotNull Pla Map.Entry coordinates = GeometryUtil.processClockwiseRotation(newX, newY, length, height, rotation); - int finalRow = getY() + coordinates.getValue() + paneOffsetY; - int finalColumn = getX() + coordinates.getKey() + paneOffsetX; + newX = coordinates.getKey(); + newY = coordinates.getValue(); - if (finalRow >= gui.getRows()) { - gui.setState(Gui.State.BOTTOM); + if (newX >= 0 || newX < length || newY >= 0 || newY < height) { + int finalRow = getY() + newY + paneOffsetY; + int finalColumn = getX() + newX + paneOffsetX; - if (finalRow == gui.getRows() + 3) { - playerInventory.setItem(finalColumn, item.getItem()); + if (finalRow >= gui.getRows()) { + gui.setState(Gui.State.BOTTOM); + + if (finalRow == gui.getRows() + 3) { + playerInventory.setItem(finalColumn, item.getItem()); + } else { + playerInventory.setItem(((finalRow - gui.getRows()) + 1) * 9 + finalColumn, item.getItem()); + } } else { - playerInventory.setItem(((finalRow - gui.getRows()) + 1) * 9 + finalColumn, item.getItem()); + inventory.setItem(finalRow * 9 + finalColumn, item.getItem()); } - } else { - inventory.setItem(finalRow * 9 + finalColumn, item.getItem()); } int gapCount = gap; diff --git a/src/main/java/com/github/stefvanschie/inventoryframework/pane/StaticPane.java b/src/main/java/com/github/stefvanschie/inventoryframework/pane/StaticPane.java index 43a0014c..b1e9d6d5 100644 --- a/src/main/java/com/github/stefvanschie/inventoryframework/pane/StaticPane.java +++ b/src/main/java/com/github/stefvanschie/inventoryframework/pane/StaticPane.java @@ -80,10 +80,17 @@ public void display(@NotNull Gui gui, @NotNull Inventory inventory, @NotNull Pla Map.Entry coordinates = GeometryUtil.processClockwiseRotation(x, y, length, height, rotation); + x = coordinates.getKey(); + y = coordinates.getValue(); + + if (x < 0 || x >= length || y < 0 || y >= height) { + return; + } + ItemStack item = entry.getValue().getItem(); - int finalRow = getY() + coordinates.getValue() + paneOffsetY; - int finalColumn = getX() + coordinates.getKey() + paneOffsetX; + int finalRow = getY() + y + paneOffsetY; + int finalColumn = getX() + x + paneOffsetX; if (finalRow >= gui.getRows()) { gui.setState(Gui.State.BOTTOM);