Skip to content

Commit

Permalink
I wanna cuddleee
Browse files Browse the repository at this point in the history
  • Loading branch information
SammySemicolon committed Apr 15, 2024
1 parent ae304ac commit 40b7451
Show file tree
Hide file tree
Showing 44 changed files with 224 additions and 239 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/sammy/malum/client/screen/codex/BookEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

import java.util.function.*;

public class BookEntry<T extends AbstractMalumScreen<T>> {
public class BookEntry<T extends EntryScreen<T, K>, K extends AbstractMalumScreen<K>> {

public final String identifier;
public final boolean isVoid;
public final ImmutableList<BookPage<T>> pages;
public final ImmutableList<EntryReference<T>> references;
public final ImmutableList<EntryReference<T, K>> references;
public Predicate<T> isValid = t -> true;

public BookEntry(String identifier, boolean isVoid, ImmutableList<BookPage<T>> pages, ImmutableList<EntryReference<T>> references) {
public BookEntry(String identifier, boolean isVoid, ImmutableList<BookPage<T>> pages, ImmutableList<EntryReference<T, K>> references) {
this.identifier = identifier;
this.isVoid = isVoid;
this.pages = pages;
Expand All @@ -33,11 +33,11 @@ public boolean isValid(T screen) {
return isValid.test(screen);
}

public static <T extends AbstractProgressionCodexScreen<T>> PlacedBookEntryBuilder<T> build(String identifier, int xOffset, int yOffset) {
public static <T extends EntryScreen<T, K>, K extends AbstractProgressionCodexScreen<K>> PlacedBookEntryBuilder<T, K> build(String identifier, int xOffset, int yOffset) {
return new PlacedBookEntryBuilder<>(identifier, xOffset, yOffset);
}

public static <T extends AbstractMalumScreen<T>> BookEntryBuilder<T> build(String identifier) {
public static <T extends EntryScreen<T, K>, K extends AbstractMalumScreen<K>> BookEntryBuilder<T, K> build(String identifier) {
return new BookEntryBuilder<>(identifier);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,34 @@

import java.util.*;

public class BookEntryBuilder<T extends AbstractMalumScreen<T>> {
public class BookEntryBuilder<T extends EntryScreen<T, K>, K extends AbstractMalumScreen<K>> {

protected final String identifier;
protected final boolean isVoid;

protected int xOffset;
protected int yOffset;

protected List<BookPage<T>> pages = new ArrayList<>();
protected List<EntryReference<T>> references = new ArrayList<>();
protected List<EntryReference<T, K>> references = new ArrayList<>();

public BookEntryBuilder(String identifier) {
this.identifier = identifier;
this.isVoid = identifier.startsWith("void.");
}

public BookEntryBuilder(String identifier, int xOffset, int yOffset) {
this(identifier);
this.xOffset = xOffset*40;
this.yOffset = yOffset*40;
}

public BookEntryBuilder<T> addPage(BookPage<T> page) {
public BookEntryBuilder<T, K> addPage(BookPage<T> page) {
if (page.isValid()) {
pages.add(page);
}
return this;
}
public BookEntryBuilder<T> addReference(EntryReference<T> reference) {
public BookEntryBuilder<T, K> addReference(EntryReference<T, K> reference) {
references.add(reference);
return this;
}

public BookEntry<T> build() {
public BookEntry<T, K> build() {
ImmutableList<BookPage<T>> bookPages = ImmutableList.copyOf(pages);
ImmutableList<EntryReference<T>> entryReferences = ImmutableList.copyOf(references);
BookEntry<T> bookEntry = new BookEntry<>(identifier, isVoid, bookPages, entryReferences);
ImmutableList<EntryReference<T, K>> entryReferences = ImmutableList.copyOf(references);
BookEntry<T, K> bookEntry = new BookEntry<>(identifier, isVoid, bookPages, entryReferences);
bookPages.forEach(p -> p.setBookEntry(bookEntry));
return bookEntry;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@

import java.util.function.*;

public class PlacedBookEntry<T extends AbstractProgressionCodexScreen<T>> extends BookEntry<T> {
private final BookEntryWidgetPlacementData<T> widgetData;
public class PlacedBookEntry<T extends EntryScreen<T, K>, K extends AbstractProgressionCodexScreen<K>>extends BookEntry<T, K> {
private final BookEntryWidgetPlacementData<K> widgetData;

public PlacedBookEntry(String identifier, boolean isVoid, BookEntryWidgetPlacementData<T> widgetData, ImmutableList<BookPage<T>> bookPages, ImmutableList<EntryReference<T>> entryReferences) {
public PlacedBookEntry(String identifier, boolean isVoid, BookEntryWidgetPlacementData<K> widgetData, ImmutableList<BookPage<T>> bookPages, ImmutableList<EntryReference<T, K>> entryReferences) {
super(identifier, isVoid, bookPages, entryReferences);
this.widgetData = widgetData;
}

public BookEntryWidgetPlacementData<T> getWidgetData() {
public BookEntryWidgetPlacementData<K> getWidgetData() {
return widgetData;
}

public interface WidgetSupplier<T extends AbstractProgressionCodexScreen<T>> {
ProgressionEntryObject<T> getBookObject(BookEntry<T> entry, int x, int y);
ProgressionEntryObject<T> getBookObject(BookEntry<?, T> entry, int x, int y);
}

public record BookEntryWidgetPlacementData<T extends AbstractProgressionCodexScreen<T>>(int xOffset, int yOffset, WidgetSupplier<T> widgetSupplier, Consumer<ProgressionEntryObject<T>> widgetConfig) { }
}
public record BookEntryWidgetPlacementData<T extends AbstractProgressionCodexScreen<T>>(int xOffset, int yOffset,
WidgetSupplier<T> widgetSupplier,
Consumer<ProgressionEntryObject<T>> widgetConfig) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,36 @@

import java.util.function.*;

public class PlacedBookEntryBuilder<T extends AbstractProgressionCodexScreen<T>> extends BookEntryBuilder<T> {
public class PlacedBookEntryBuilder<T extends EntryScreen<T, K>, K extends AbstractProgressionCodexScreen<K>> extends BookEntryBuilder<T, K> {

protected PlacedBookEntry.WidgetSupplier<T> widgetSupplier;
protected Consumer<ProgressionEntryObject<T>> widgetConfig;
protected PlacedBookEntry.WidgetSupplier<K> widgetSupplier = ProgressionEntryObject::new;
protected Consumer<ProgressionEntryObject<K>> widgetConfig;

public PlacedBookEntryBuilder(String identifier) {
super(identifier);
}
protected final int xOffset;
protected final int yOffset;

public PlacedBookEntryBuilder(String identifier, int xOffset, int yOffset) {
super(identifier, xOffset, yOffset);
super(identifier);
this.xOffset = xOffset*40;
this.yOffset = yOffset*40;
}

public PlacedBookEntryBuilder<T> setWidgetSupplier(PlacedBookEntry.WidgetSupplier<T> widgetSupplier) {
public PlacedBookEntryBuilder<T, K> setWidgetSupplier(PlacedBookEntry.WidgetSupplier<K> widgetSupplier) {
this.widgetSupplier = widgetSupplier;
return this;
}

public PlacedBookEntryBuilder<T> setWidgetConfig(Consumer<ProgressionEntryObject<T>> widgetConfig) {
public PlacedBookEntryBuilder<T, K> setWidgetConfig(Consumer<ProgressionEntryObject<K>> widgetConfig) {
this.widgetConfig = widgetConfig;
return this;
}

@Override
public BookEntry<T> build() {
public PlacedBookEntry<T, K> build() {
ImmutableList<BookPage<T>> bookPages = ImmutableList.copyOf(pages);
ImmutableList<EntryReference<T>> entryReferences = ImmutableList.copyOf(references);
PlacedBookEntry.BookEntryWidgetPlacementData<T> data = widgetSupplier != null ? new PlacedBookEntry.BookEntryWidgetPlacementData<>(xOffset, yOffset, widgetSupplier, widgetConfig) : null;
PlacedBookEntry<T> bookEntry = new PlacedBookEntry<>(identifier, isVoid, data, bookPages, entryReferences);
ImmutableList<EntryReference<T, K>> entryReferences = ImmutableList.copyOf(references);
PlacedBookEntry.BookEntryWidgetPlacementData<K> data = new PlacedBookEntry.BookEntryWidgetPlacementData<>(xOffset, yOffset, widgetSupplier, widgetConfig);
PlacedBookEntry<T, K> bookEntry = new PlacedBookEntry<>(identifier, isVoid, data, bookPages, entryReferences);
bookPages.forEach(p -> p.setBookEntry(bookEntry));
return bookEntry;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

public class ArtificeEntries {

@SuppressWarnings({"rawtypes", "unchecked"})
public static void setupEntries(ArcanaProgressionScreen screen) {
Item EMPTY = ItemStack.EMPTY.getItem();

Expand Down Expand Up @@ -54,7 +55,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
screen.addEntry("soulhunter_gear", 4, 7, b -> b
.setWidgetConfig(w -> w.setIcon(SOUL_HUNTER_CLOAK))
.addPage(new HeadlineTextPage<>("soulhunter_gear", "soulhunter_gear.1"))
.addPage(new CyclingPage<ArcanaProgressionScreen>(
.addPage(new CyclingPage(
SpiritInfusionPage.fromOutput(SOUL_HUNTER_CLOAK.get()),
SpiritInfusionPage.fromOutput(SOUL_HUNTER_ROBE.get()),
SpiritInfusionPage.fromOutput(SOUL_HUNTER_LEGGINGS.get()),
Expand Down Expand Up @@ -82,7 +83,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.setWidgetConfig(w -> w.setIcon(IRON_NODE))
.addPage(new HeadlineTextItemPage<>("focus_metals", "focus_metals.1", IRON_NODE.get()))
.addPage(new TextPage<>("focus_metals.2"))
.addPage(new CyclingPage<ArcanaProgressionScreen>(
.addPage(new CyclingPage(
SpiritInfusionPage.fromOutput(IRON_IMPETUS.get()),
SpiritInfusionPage.fromOutput(GOLD_IMPETUS.get()),
SpiritInfusionPage.fromOutput(COPPER_IMPETUS.get()),
Expand All @@ -95,7 +96,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
SpiritInfusionPage.fromOutput(ZINC_IMPETUS.get()),
SpiritInfusionPage.fromOutput(TIN_IMPETUS.get())
))
.addPage(new CyclingPage<ArcanaProgressionScreen>(
.addPage(new CyclingPage(
SpiritFocusingPage.fromOutput(IRON_NODE.get()),
SpiritFocusingPage.fromOutput(GOLD_NODE.get()),
SpiritFocusingPage.fromOutput(COPPER_NODE.get()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

public class TinkeringEntries {

@SuppressWarnings({"rawtypes", "unchecked"})
public static void setupEntries(ArcanaProgressionScreen screen) {
Item EMPTY = ItemStack.EMPTY.getItem();

Expand All @@ -20,15 +21,14 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(new HeadlineTextItemPage<>("spirit_metals.soulstained_steel", "spirit_metals.soulstained_steel.1", SOUL_STAINED_STEEL_INGOT.get()))
.addPage(new TextPage<>("spirit_metals.soulstained_steel.2"))
.addPage(SpiritInfusionPage.fromOutput(SOUL_STAINED_STEEL_INGOT.get()))
.addPage(new CyclingPage<ArcanaProgressionScreen>(
.addPage(new CyclingPage(
CraftingPage.toolPage(SOUL_STAINED_STEEL_PICKAXE.get(), SOUL_STAINED_STEEL_INGOT.get()),
CraftingPage.toolPage(SOUL_STAINED_STEEL_AXE.get(), SOUL_STAINED_STEEL_INGOT.get()),
CraftingPage.toolPage(SOUL_STAINED_STEEL_HOE.get(), SOUL_STAINED_STEEL_INGOT.get()),
CraftingPage.toolPage(SOUL_STAINED_STEEL_SHOVEL.get(), SOUL_STAINED_STEEL_INGOT.get()),
CraftingPage.toolPage(SOUL_STAINED_STEEL_SWORD.get(), SOUL_STAINED_STEEL_INGOT.get()),
CraftingPage.knifePage(SOUL_STAINED_STEEL_KNIFE.get(), SOUL_STAINED_STEEL_INGOT.get())
))
//TODO: the above is a temporary bandaid, implement a proper thing for this once book page/entry refactor happens
.addPage(new HeadlineTextItemPage<>("spirit_metals.hallowed_gold", "spirit_metals.hallowed_gold.1", HALLOWED_GOLD_INGOT.get()))
.addPage(new TextPage<>("spirit_metals.hallowed_gold.2"))
.addPage(SpiritInfusionPage.fromOutput(HALLOWED_GOLD_INGOT.get()))
Expand All @@ -47,7 +47,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(new HeadlineTextPage<>("soulstained_armor", "soulstained_armor.1"))
.addPage(new TextPage<>("soulstained_armor.2"))
.addPage(new TextPage<>("soulstained_armor.3"))
.addPage(new CyclingPage<ArcanaProgressionScreen>(
.addPage(new CyclingPage(
SpiritInfusionPage.fromOutput(SOUL_STAINED_STEEL_HELMET.get()),
SpiritInfusionPage.fromOutput(SOUL_STAINED_STEEL_CHESTPLATE.get()),
SpiritInfusionPage.fromOutput(SOUL_STAINED_STEEL_LEGGINGS.get()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import static net.minecraft.world.item.Items.*;

public class TotemMagicEntries {


@SuppressWarnings({"rawtypes", "unchecked"})
public static void setupEntries(ArcanaProgressionScreen screen) {
Item EMPTY = ItemStack.EMPTY.getItem();

Expand Down Expand Up @@ -46,8 +47,8 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(new HeadlineTextPage<>("totemic_runes", "void.runes.1"))
.addPage(new EntrySelectorPage<>(item -> {
final String translationKey = ForgeRegistries.ITEMS.getKey(item).getPath();
return new EntryReference<>(item,
BookEntry.<ArcanaProgressionScreen>build(translationKey)
return new EntryReference(item,
BookEntry.build(translationKey)
.addPage(new HeadlineTextPage<>(translationKey))
.addPage(RuneworkingPage.fromOutput(item)));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.sammy.malum.client.screen.codex.objects.progression.*;
import com.sammy.malum.client.screen.codex.screens.*;

public class EntryObjectHandler<T extends AbstractProgressionCodexScreen<T>> extends BookObjectHandler<T>{
public class EntryObjectHandler<T extends AbstractProgressionCodexScreen<T>> extends BookObjectHandler<T> {
public EntryObjectHandler() {
super();
}
Expand All @@ -13,16 +13,15 @@ public void setupEntryObjects(T screen) {
clear();
int left = screen.getGuiLeft() + screen.bookInsideWidth;
int top = screen.getGuiTop() + screen.bookInsideHeight;
for (BookEntry<T> entry : screen.getEntries()) {
entry.getWidgetData().ifPresent(data -> {
final ProgressionEntryObject<T> bookObject = data.widgetSupplier().getBookObject(entry, left + data.xOffset(), top - data.yOffset());
var config = data.widgetConfig();
if (config != null) {
config.accept(bookObject);
}
add(bookObject);
});
for (PlacedBookEntry<?, T> entry : screen.getEntries()) {
final PlacedBookEntry.BookEntryWidgetPlacementData<T> data = entry.getWidgetData();
final ProgressionEntryObject<T> bookObject = data.widgetSupplier().getBookObject(entry, left + data.xOffset(), top - data.yOffset());
var config = data.widgetConfig();
if (config != null) {
config.accept(bookObject);
}
add(bookObject);
}
screen.faceObject(get(1));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

import java.util.*;

public abstract class AbstractSelectableEntryObject<T extends AbstractMalumScreen<T>> extends BookObject<T> {
public abstract class AbstractSelectableEntryObject<T extends EntryScreen<T, K>, K extends AbstractMalumScreen<K>> extends BookObject<T> {

public final EntryReference<T> entryReference;
public final EntryReference<T, K> entryReference;

public AbstractSelectableEntryObject(int posX, int posY, int width, int height, EntryReference<T> entryReference) {
public AbstractSelectableEntryObject(int posX, int posY, int width, int height, EntryReference<T, K> entryReference) {
super(posX, posY, width, height);
this.entryReference = entryReference;
}

@Override
public void renderLate(T screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
if (isHoveredOver) {
final BookEntry<T> entry = entryReference.entry;
final BookEntry<T, K> entry = entryReference.entry;
final List<Component> list = Arrays.asList(
Component.translatable(entry.translationKey()),
Component.translatable(entry.descriptionTranslationKey()).withStyle(ChatFormatting.GRAY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import static com.sammy.malum.client.screen.codex.ArcanaCodexHelper.renderTexture;

public class ArrowObject<T extends AbstractMalumScreen<T>> extends BookObject<T> {
public class ArrowObject<T extends EntryScreen<T, K>, K extends AbstractMalumScreen<K>> extends BookObject<T> {

public static final ResourceLocation ARROWS = MalumMod.malumPath("textures/gui/book/entry_elements/arrows.png");
public static final ResourceLocation ARROWS_LIT_UP = MalumMod.malumPath("textures/gui/book/entry_elements/arrows_active.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

import static com.sammy.malum.client.screen.codex.ArcanaCodexHelper.*;

public class LinkedEntryObject<T extends AbstractMalumScreen<T>> extends AbstractSelectableEntryObject<T> {
public class LinkedEntryObject<T extends EntryScreen<T, K>, K extends AbstractMalumScreen<K>> extends AbstractSelectableEntryObject<T, K> {

public static final ResourceLocation LINK = MalumMod.malumPath("textures/gui/book/entry_elements/arrows.png");

public final boolean flipped;

public LinkedEntryObject(int posX, int posY, boolean flipped, EntryReference<T> entryReference) {
public LinkedEntryObject(int posX, int posY, boolean flipped, EntryReference<T, K> entryReference) {
super(posX, posY, 36, 22, entryReference);
this.flipped = flipped;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

import static com.sammy.malum.client.screen.codex.ArcanaCodexHelper.*;

public class SelectableEntryObject<T extends EntryScreen<?, T>> extends AbstractSelectableEntryObject<T> {
public class SelectableEntryObject<T extends EntryScreen<T, K>, K extends AbstractMalumScreen<K>> extends AbstractSelectableEntryObject<T, K> {

public static final ResourceLocation SOCKET = MalumMod.malumPath("textures/gui/book/entry_elements/entry_socket.png");

public SelectableEntryObject(int posX, int posY, EntryReference<T> entryReference) {
public SelectableEntryObject(int posX, int posY, EntryReference<T, K> entryReference) {
super(posX, posY, 32, 32, entryReference);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class IconObject<T extends AbstractProgressionCodexScreen<T>> extends Pro
public final int textureWidth;
public final int textureHeight;

public IconObject(BookEntry<T> entry, int posX, int posY, ResourceLocation textureLocation) {
public IconObject(BookEntry<?, T> entry, int posX, int posY, ResourceLocation textureLocation) {
this(entry, posX, posY, textureLocation, 16, 16);
}
public IconObject(BookEntry<T> entry, int posX, int posY, ResourceLocation textureLocation, int textureWidth, int textureHeight) {
public IconObject(BookEntry<?, T> entry, int posX, int posY, ResourceLocation textureLocation, int textureWidth, int textureHeight) {
super(entry, posX, posY);
this.textureLocation = textureLocation;
this.textureWidth = textureWidth;
Expand Down
Loading

0 comments on commit 40b7451

Please sign in to comment.