-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add leaflet mode to books * feat: add default item icon/model for leaflet * feat: allow linking to specific pages within leaflets * fix: add texture for leaflet to forge and neo resource folders datagen for those two loaders seems not to handle common content * fix: nullable network writing * feat: add leaflet datagen helpers and demo leaflet * fix: leaflet closing * feat: add demo leaflet to datagen for all platforms * fix: more issues with leaflet closing * fix: demo leaflet empty spaces * chore: demo leaflet margins * chore: run datagen * chore: re-establish reuse compliance
- Loading branch information
1 parent
1dfe022
commit 3e18a8c
Showing
67 changed files
with
845 additions
and
41 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
common/src/main/java/com/klikli_dev/modonomicon/api/datagen/BookSubProvider.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
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
45 changes: 45 additions & 0 deletions
45
common/src/main/java/com/klikli_dev/modonomicon/api/datagen/LeafletCategoryProvider.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,45 @@ | ||
// SPDX-FileCopyrightText: 2024 klikli-dev | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
package com.klikli_dev.modonomicon.api.datagen; | ||
|
||
import com.klikli_dev.modonomicon.api.datagen.book.BookIconModel; | ||
import net.minecraft.world.item.Items; | ||
|
||
/** | ||
* This is a one-size-fits all category provider for leaflets. | ||
* There is no need for leaflets to actually implement category providers, they all use this "dummy one" | ||
*/ | ||
class LeafletCategoryProvider extends CategoryProvider{ | ||
public static final String ID = "leaflet"; | ||
|
||
public LeafletCategoryProvider(ModonomiconProviderBase parent) { | ||
super(parent); | ||
} | ||
|
||
@Override | ||
protected String[] generateEntryMap() { | ||
return new String[0]; | ||
} | ||
|
||
@Override | ||
protected void generateEntries() { | ||
//entries are generated in the leaflet subprovider instead. | ||
} | ||
|
||
@Override | ||
protected String categoryName() { | ||
return "Leaflet"; | ||
} | ||
|
||
@Override | ||
protected BookIconModel categoryIcon() { | ||
return BookIconModel.create(Items.PAPER); | ||
} | ||
|
||
@Override | ||
protected String categoryId() { | ||
return ID; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
common/src/main/java/com/klikli_dev/modonomicon/api/datagen/LeafletEntryProvider.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,45 @@ | ||
// SPDX-FileCopyrightText: 2024 klikli-dev | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
package com.klikli_dev.modonomicon.api.datagen; | ||
|
||
import com.klikli_dev.modonomicon.api.datagen.book.BookIconModel; | ||
import com.mojang.datafixers.util.Pair; | ||
import net.minecraft.world.item.Items; | ||
|
||
public abstract class LeafletEntryProvider extends EntryProvider { | ||
public static final String ID = "leaflet"; | ||
|
||
public LeafletEntryProvider(CategoryProvider parent) { | ||
super(parent); | ||
} | ||
|
||
@Override | ||
protected String entryName() { | ||
//we assume people don't mess with leaflet provider structure | ||
//If you do and you end up here with an error, just override this method and return an entry name safely :) | ||
var book = (LeafletSubProvider) this.parent.parent; | ||
return book.bookName(); | ||
} | ||
|
||
@Override | ||
protected String entryDescription() { | ||
return ""; //Irrelevant, because it will never be rendered | ||
} | ||
|
||
@Override | ||
protected Pair<Integer, Integer> entryBackground() { | ||
return EntryBackground.DEFAULT; | ||
} | ||
|
||
@Override | ||
protected BookIconModel entryIcon() { | ||
return BookIconModel.create(Items.PAPER); | ||
} | ||
|
||
@Override | ||
protected String entryId() { | ||
return ID; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
common/src/main/java/com/klikli_dev/modonomicon/api/datagen/LeafletSubProvider.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,53 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2022 klikli-dev | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
|
||
package com.klikli_dev.modonomicon.api.datagen; | ||
|
||
import com.klikli_dev.modonomicon.api.datagen.book.BookModel; | ||
import com.klikli_dev.modonomicon.registry.ItemRegistry; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* An opinionated book leaflet sub provider with helper methods to generate a leaflet more easily. | ||
*/ | ||
public abstract class LeafletSubProvider extends SingleBookSubProvider { | ||
|
||
public LeafletSubProvider(String bookId, String modId, ModonomiconLanguageProvider defaultLang, ModonomiconLanguageProvider... translations) { | ||
super(bookId, modId, defaultLang, translations); | ||
} | ||
|
||
public LeafletSubProvider(String bookId, String modId, ModonomiconLanguageProvider defaultLang, Map<String, ModonomiconLanguageProvider> translations) { | ||
super(bookId, modId, defaultLang, translations); | ||
} | ||
|
||
@Override | ||
protected void generateCategories() { | ||
var leafletCategoryProvider = new LeafletCategoryProvider(this); | ||
var leafletCategory = this.add(leafletCategoryProvider.generate()); | ||
var entryProvider = this.createEntryProvider(leafletCategoryProvider); | ||
leafletCategory.withEntry(entryProvider.generate()); | ||
} | ||
|
||
@Override | ||
protected final BookModel additionalSetup(BookModel book) { | ||
return this.additionalLeafletSetup( | ||
book.withLeafletEntry(this.modLoc(LeafletCategoryProvider.ID, LeafletEntryProvider.ID)) | ||
.withModel(ItemRegistry.LEAFLET.getId()) | ||
); | ||
} | ||
|
||
/** | ||
* Implement this and modify the book as needed for additional config. | ||
* Context already is set to this book. | ||
*/ | ||
protected BookModel additionalLeafletSetup(BookModel book) { | ||
return book; | ||
} | ||
|
||
protected abstract LeafletEntryProvider createEntryProvider(CategoryProvider parent); | ||
} |
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.