mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +01:00
Added a second page to the book
This commit is contained in:
parent
4dffafda01
commit
ee53f83816
7 changed files with 50 additions and 16 deletions
BIN
book.xcf
Normal file
BIN
book.xcf
Normal file
Binary file not shown.
|
@ -12,6 +12,9 @@ class PageInstance implements IPage {
|
|||
|
||||
int index;
|
||||
|
||||
@Nullable
|
||||
ResourceLocation parent;
|
||||
|
||||
@Nonnull
|
||||
ResourceLocation name;
|
||||
|
||||
|
@ -27,6 +30,10 @@ class PageInstance implements IPage {
|
|||
PageInstance(ResourceLocation id, JsonObject json) {
|
||||
this.name = id;
|
||||
|
||||
if (json.has("parent")) {
|
||||
parent = new ResourceLocation(json.get("parent").getAsString());
|
||||
}
|
||||
|
||||
if (json.has("state")) {
|
||||
state = PageState.of(json.get("state").getAsString());
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ public class Pages {
|
|||
return instance;
|
||||
}
|
||||
|
||||
private final Map<ResourceLocation, IPage> pages = Maps.newHashMap();
|
||||
private final List<IPage> pagesByIndex = Lists.newArrayList();
|
||||
private final Map<ResourceLocation, PageInstance> pages = Maps.newHashMap();
|
||||
private final List<PageInstance> pagesByIndex = Lists.newArrayList();
|
||||
|
||||
private final Map<String, IConditionFactory> conditionFactories = Maps.newHashMap();
|
||||
|
||||
|
@ -41,10 +41,25 @@ public class Pages {
|
|||
pagesByIndex.clear();
|
||||
assets.walk();
|
||||
|
||||
int index = 0;
|
||||
for (IPage ipage : pages.values()) {
|
||||
((PageInstance)ipage).index = index++;
|
||||
pagesByIndex.add(ipage);
|
||||
List<ResourceLocation> names = Lists.newArrayList();
|
||||
|
||||
for (PageInstance page : pages.values()) {
|
||||
if (page.parent != null) {
|
||||
int i = names.indexOf(page.parent);
|
||||
if (i != -1) {
|
||||
names.add(i, page.name);
|
||||
pagesByIndex.add(i, page);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
names.add(page.name);
|
||||
pagesByIndex.add(page);
|
||||
}
|
||||
|
||||
for (int i = 0; i < pagesByIndex.size(); i++) {
|
||||
pagesByIndex.get(i).index = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +85,7 @@ public class Pages {
|
|||
}
|
||||
|
||||
public Stream<IPage> getUnlockablePages(Predicate<IPage> predicate) {
|
||||
return pages.values().stream().filter(predicate);
|
||||
return pages.values().stream().map(IPage.class::cast).filter(predicate);
|
||||
}
|
||||
|
||||
public void triggerUnlockEvent(IPageOwner owner, IUnlockEvent event, @Nullable IPageUnlockListener unlockListener) {
|
||||
|
|
|
@ -60,12 +60,12 @@ public class ContainerSpellBook extends Container {
|
|||
}
|
||||
|
||||
public void initCraftingSlots() {
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 0, 180, 50));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 1, 154, 94));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 2, 180, 134));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 3, 231, 120));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 4, 232, 65));
|
||||
addSlotToContainer(resultSlot = new SlotEnchantingResult(listener, PlayerSpeciesList.instance().getPlayer(player), craftMatrix, craftResult, 0, 196, 92));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 0, 175, 50));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 1, 149, 94));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 2, 175, 134));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 3, 226, 120));
|
||||
addSlotToContainer(new SlotEnchanting(craftMatrix, 4, 227, 65));
|
||||
addSlotToContainer(resultSlot = new SlotEnchantingResult(listener, PlayerSpeciesList.instance().getPlayer(player), craftMatrix, craftResult, 0, 191, 92));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -112,10 +112,13 @@ public class GuiSpellBook extends GuiContainer implements IPageUnlockListener {
|
|||
if (slot instanceof SlotEnchanting) {
|
||||
GlStateManager.enableBlend();
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
mc.getTextureManager().bindTexture(spellBookGuiTextures);
|
||||
drawModalRectWithCustomSizedTexture(slot.xPos - 1, slot.yPos - 1, 51, 223, 18, 18, 512, 256);
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GlStateManager.disableBlend();
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -148,6 +151,9 @@ public class GuiSpellBook extends GuiContainer implements IPageUnlockListener {
|
|||
GlStateManager.enableBlend();
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
mc.getTextureManager().bindTexture(spellBookGuiTextures);
|
||||
drawModalRectWithCustomSizedTexture(left + 147, top + 49, 407, 2, 100, 101, 512, 256);
|
||||
|
||||
if (playerExtension.getPageState(currentIPage) != PageState.LOCKED) {
|
||||
ResourceLocation texture = currentIPage.getTexture();
|
||||
|
||||
|
@ -163,9 +169,6 @@ public class GuiSpellBook extends GuiContainer implements IPageUnlockListener {
|
|||
}
|
||||
}
|
||||
|
||||
mc.getTextureManager().bindTexture(spellBookGuiTextures);
|
||||
drawModalRectWithCustomSizedTexture(left + 152, top + 49, 407, 2, 100, 101, 512, 256);
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"parent": "unicopia:preface",
|
||||
"texture": "unicopia:chapter_1_gems",
|
||||
"state": "unread",
|
||||
"conditions": {
|
||||
"type": "unicopia:compound_condition",
|
||||
"conditions": []
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
Loading…
Reference in a new issue