Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added crafting and smelting page types to the book - Improved error handling - Line breaks in ResourceHelper.getStringFromResource output - 2 layers for pages instead of one - ElementItem now does item cycling
- Loading branch information
Showing
35 changed files
with
516 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/java/slimeknights/mantle/client/book/data/content/ContentCrafting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package slimeknights.mantle.client.book.data.content; | ||
|
||
import java.util.ArrayList; | ||
import net.minecraft.util.ResourceLocation; | ||
import slimeknights.mantle.client.book.data.BookData; | ||
import slimeknights.mantle.client.book.data.element.ImageData; | ||
import slimeknights.mantle.client.book.data.element.ItemStackData; | ||
import slimeknights.mantle.client.book.data.element.TextData; | ||
import slimeknights.mantle.client.gui.book.GuiBook; | ||
import slimeknights.mantle.client.gui.book.element.BookElement; | ||
import slimeknights.mantle.client.gui.book.element.ElementImage; | ||
import slimeknights.mantle.client.gui.book.element.ElementItem; | ||
import slimeknights.mantle.client.gui.book.element.ElementText; | ||
|
||
public class ContentCrafting extends PageContent { | ||
|
||
public static final transient ResourceLocation TEX_CRAFTING = new ResourceLocation("mantle:textures/gui/book/crafting.png"); | ||
public static final transient int TEX_SIZE = 256; | ||
public static final transient ImageData IMG_CRAFTING_LARGE = new ImageData(TEX_CRAFTING, 0, 0, 183, 114, TEX_SIZE, TEX_SIZE); | ||
public static final transient ImageData IMG_CRAFTING_SMALL = new ImageData(TEX_CRAFTING, 0, 114, 155, 78, TEX_SIZE, TEX_SIZE); | ||
|
||
public static final transient int X_RESULT_SMALL = 118; | ||
public static final transient int Y_RESULT_SMALL = 23; | ||
public static final transient int X_RESULT_LARGE = 146; | ||
public static final transient int Y_RESULT_LARGE = 41; | ||
|
||
public static final transient float ITEM_SCALE = 2.0F; | ||
public static final transient int SLOT_MARGIN = 5; | ||
public static final transient int SLOT_PADDING = 4; | ||
|
||
public String title = "Crafting"; | ||
public String grid_size = "large"; | ||
public ItemStackData[][] grid; | ||
public ItemStackData result; | ||
public TextData[] description; | ||
|
||
@Override | ||
public void build(BookData book, ArrayList<BookElement> list) { | ||
int x = 0; | ||
int y = 16; | ||
int height = 100; | ||
int resultX = 100; | ||
int resultY = 50; | ||
|
||
TextData tdTitle = new TextData(title); | ||
tdTitle.underlined = true; | ||
list.add(new ElementText(0, 0, GuiBook.PAGE_WIDTH, 9, new TextData[]{tdTitle})); | ||
|
||
if (grid_size.equalsIgnoreCase("small")) { | ||
x = GuiBook.PAGE_WIDTH / 2 - IMG_CRAFTING_SMALL.width / 2; | ||
height = y + IMG_CRAFTING_SMALL.height; | ||
list.add(new ElementImage(x, y, IMG_CRAFTING_SMALL.width, IMG_CRAFTING_SMALL.height, IMG_CRAFTING_SMALL, book.appearance.coverColor)); | ||
resultX = x + X_RESULT_SMALL; | ||
resultY = y + Y_RESULT_SMALL; | ||
} else if (grid_size.equalsIgnoreCase("large")) { | ||
x = GuiBook.PAGE_WIDTH / 2 - IMG_CRAFTING_LARGE.width / 2; | ||
height = y + IMG_CRAFTING_LARGE.height; | ||
list.add(new ElementImage(x, y, IMG_CRAFTING_LARGE.width, IMG_CRAFTING_LARGE.height, IMG_CRAFTING_LARGE, book.appearance.coverColor)); | ||
resultX = x + X_RESULT_LARGE; | ||
resultY = y + Y_RESULT_LARGE; | ||
} | ||
|
||
if (grid != null) | ||
for (int i = 0; i < grid.length; i++) { | ||
for (int j = 0; j < grid[i].length; j++) { | ||
if (grid[i][j].id.equals("")) | ||
continue; | ||
list.add(new ElementItem(x + SLOT_MARGIN + (SLOT_PADDING + Math.round(ElementItem.ITEM_SIZE_HARDCODED * ITEM_SCALE)) * j, y + SLOT_MARGIN + (SLOT_PADDING + Math.round(ElementItem.ITEM_SIZE_HARDCODED * ITEM_SCALE)) * i, ITEM_SCALE, grid[i][j].getItemStack())); | ||
} | ||
} | ||
|
||
if (result != null) { | ||
list.add(new ElementItem(resultX, resultY, ITEM_SCALE, result.getItemStack())); | ||
} | ||
|
||
if (description != null && description.length > 0) { | ||
list.add(new ElementText(0, height + 5, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - height - 5, description)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.