Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Mar 14, 2024
1 parent ed08cc6 commit cc26473
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/main/java/eu/pb4/sgui/api/GuiHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static int getHeight(ScreenHandlerType<?> type) {
return 4;
} else if (ScreenHandlerType.GENERIC_9X2.equals(type) || ScreenHandlerType.ENCHANTMENT.equals(type) || ScreenHandlerType.STONECUTTER.equals(type)) {
return 2;
} else if (ScreenHandlerType.GENERIC_9X1.equals(type) || ScreenHandlerType.BEACON.equals(type) || ScreenHandlerType.HOPPER.equals(type) || ScreenHandlerType.BREWING_STAND.equals(type)) {
} else if (ScreenHandlerType.GENERIC_9X1.equals(type) || ScreenHandlerType.BEACON.equals(type) || ScreenHandlerType.HOPPER.equals(type) || ScreenHandlerType.BREWING_STAND.equals(type) || ScreenHandlerType.SMITHING.equals(type)) {
return 1;
}

Expand All @@ -66,11 +66,13 @@ public static int getHeight(ScreenHandlerType<?> type) {
public static int getWidth(ScreenHandlerType<?> type) {
if (ScreenHandlerType.CRAFTING.equals(type)) {
return 2;
} else if (ScreenHandlerType.SMITHING.equals(type)) {
return 4;
} else if (ScreenHandlerType.GENERIC_3X3.equals(type)) {
return 3;
} else if (ScreenHandlerType.HOPPER.equals(type) || ScreenHandlerType.BREWING_STAND.equals(type)) {
return 5;
} else if (ScreenHandlerType.ENCHANTMENT.equals(type) || ScreenHandlerType.STONECUTTER.equals(type) || ScreenHandlerType.BEACON.equals(type) || ScreenHandlerType.BLAST_FURNACE.equals(type) || ScreenHandlerType.FURNACE.equals(type) || ScreenHandlerType.SMOKER.equals(type) || ScreenHandlerType.ANVIL.equals(type) || ScreenHandlerType.SMITHING.equals(type) || ScreenHandlerType.GRINDSTONE.equals(type) || ScreenHandlerType.MERCHANT.equals(type) || ScreenHandlerType.CARTOGRAPHY_TABLE.equals(type) || ScreenHandlerType.LOOM.equals(type)) {
} else if (ScreenHandlerType.ENCHANTMENT.equals(type) || ScreenHandlerType.STONECUTTER.equals(type) || ScreenHandlerType.BEACON.equals(type) || ScreenHandlerType.BLAST_FURNACE.equals(type) || ScreenHandlerType.FURNACE.equals(type) || ScreenHandlerType.SMOKER.equals(type) || ScreenHandlerType.ANVIL.equals(type) || ScreenHandlerType.GRINDSTONE.equals(type) || ScreenHandlerType.MERCHANT.equals(type) || ScreenHandlerType.CARTOGRAPHY_TABLE.equals(type) || ScreenHandlerType.LOOM.equals(type)) {
return 1;
}

Expand Down
14 changes: 12 additions & 2 deletions src/main/java/eu/pb4/sgui/api/elements/BookElementBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ public BookElementBuilder(int count) {
* @see BookElementBuilder#setPage(int, Text...)
*/
public BookElementBuilder addPage(Text... lines) {
var text = Text.literal("");
var text = Text.empty();
for (Text line : lines) {
text.append(line).append("\n");
}
this.getOrCreatePages().add(NbtString.of(Text.Serialization.toJsonString(text)));
return this;
}

public BookElementBuilder addPage(Text text) {
this.getOrCreatePages().add(NbtString.of(Text.Serialization.toJsonString(text)));
return this;
}

/**
* Sets a page of the book. <br>
* Note that only signed books support formatting
Expand All @@ -66,14 +71,19 @@ public BookElementBuilder addPage(Text... lines) {
* @see BookElementBuilder#addPage(Text...)
*/
public BookElementBuilder setPage(int index, Text... lines) {
var text = Text.literal("");
var text = Text.empty();
for (Text line : lines) {
text.append(line).append("\n");
}
this.getOrCreatePages().set(index, NbtString.of(Text.Serialization.toJsonString(text)));
return this;
}

public BookElementBuilder setPage(int index, Text text) {
this.getOrCreatePages().set(index, NbtString.of(Text.Serialization.toJsonString(text)));
return this;
}

/**
* Sets the author of the book, also marks
* the book as signed.
Expand Down

0 comments on commit cc26473

Please sign in to comment.