Skip to content

Commit

Permalink
Make items invisible outside pane boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
stefvanschie committed Jun 2, 2020
1 parent fa333b7 commit b39823d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,24 @@ public void display(@NotNull Gui gui, @NotNull Inventory inventory, @NotNull Pla
Map.Entry<Integer, Integer> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,17 @@ public void display(@NotNull Gui gui, @NotNull Inventory inventory, @NotNull Pla
Map.Entry<Integer, Integer> 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);
Expand Down

0 comments on commit b39823d

Please sign in to comment.