diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderLocalization.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderLocalization.java index 53b25a053..8b5bb3d97 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderLocalization.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderLocalization.java @@ -21,6 +21,7 @@ public class PonderLocalization { static final Map SHARED = new HashMap<>(); static final Map> TAG = new HashMap<>(); + static final Map CHAPTER = new HashMap<>(); static final Map> SPECIFIC = new HashMap<>(); // @@ -42,24 +43,30 @@ public class PonderLocalization { public static String getShared(ResourceLocation key) { if (PonderIndex.EDITOR_MODE) - return SHARED.containsKey(key) ? SHARED.get(key) : ("unregistered shared entry:" + key); + return SHARED.containsKey(key) ? SHARED.get(key) : ("unregistered shared entry: " + key); return I18n.get(langKeyForShared(key)); } public static String getTag(ResourceLocation key) { if (PonderIndex.EDITOR_MODE) return TAG.containsKey(key) ? TAG.get(key) - .getFirst() : ("unregistered tag entry:" + key); + .getFirst() : ("unregistered tag entry: " + key); return I18n.get(langKeyForTag(key)); } public static String getTagDescription(ResourceLocation key) { if (PonderIndex.EDITOR_MODE) return TAG.containsKey(key) ? TAG.get(key) - .getSecond() : ("unregistered tag entry:" + key); + .getSecond() : ("unregistered tag entry: " + key); return I18n.get(langKeyForTagDescription(key)); } + public static String getChapter(ResourceLocation key) { + if (PonderIndex.EDITOR_MODE) + return CHAPTER.containsKey(key) ? CHAPTER.get(key) : ("unregistered chapter entry: " + key); + return I18n.get(langKeyForChapter(key)); + } + public static String getSpecific(ResourceLocation sceneId, String k) { if (PonderIndex.EDITOR_MODE) return SPECIFIC.get(sceneId) @@ -85,6 +92,12 @@ public class PonderLocalization { } }); + CHAPTER.forEach((k, v) -> { + if (k.getNamespace().equals(namespace)) { + object.addProperty(langKeyForChapter(k), v); + } + }); + SPECIFIC.entrySet() .stream() .filter(entry -> entry.getKey().getNamespace().equals(namespace)) @@ -174,6 +187,10 @@ public class PonderLocalization { return k.getNamespace() + "." + LANG_PREFIX + "tag." + k.getPath() + ".description"; } + protected static String langKeyForChapter(ResourceLocation k) { + return k.getNamespace() + "." + LANG_PREFIX + "chapter." + k.getPath(); + } + protected static String langKeyForSpecific(ResourceLocation sceneId, String k) { return sceneId.getNamespace() + "." + LANG_PREFIX + sceneId.getPath() + "." + k; } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistrationHelper.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistrationHelper.java new file mode 100644 index 000000000..39b97dc8c --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistrationHelper.java @@ -0,0 +1,110 @@ +package com.simibubi.create.foundation.ponder; + +import java.util.Arrays; +import java.util.function.Consumer; + +import com.simibubi.create.foundation.ponder.PonderStoryBoardEntry.PonderStoryBoard; +import com.simibubi.create.foundation.ponder.content.PonderChapter; +import com.simibubi.create.foundation.ponder.content.PonderTag; +import com.tterrag.registrate.util.entry.ItemProviderEntry; + +import net.minecraft.util.ResourceLocation; + +public class PonderRegistrationHelper { + + protected String namespace; + + public PonderRegistrationHelper(String namespace) { + this.namespace = namespace; + } + + public PonderStoryBoardEntry addStoryBoard(ResourceLocation component, + ResourceLocation schematicLocation, PonderStoryBoard storyBoard, PonderTag... tags) { + PonderStoryBoardEntry entry = this.createStoryBoardEntry(storyBoard, schematicLocation, component); + entry.highlightTags(tags); + PonderRegistry.addStoryBoard(entry); + return entry; + } + + public PonderStoryBoardEntry addStoryBoard(ResourceLocation component, + String schematicPath, PonderStoryBoard storyBoard, PonderTag... tags) { + return addStoryBoard(component, asLocation(schematicPath), storyBoard, tags); + } + + public PonderStoryBoardEntry addStoryBoard(ItemProviderEntry component, + ResourceLocation schematicLocation, PonderStoryBoard storyBoard, PonderTag... tags) { + return addStoryBoard(component.getId(), schematicLocation, storyBoard, tags); + } + + public PonderStoryBoardEntry addStoryBoard(ItemProviderEntry component, + String schematicPath, PonderStoryBoard storyBoard, PonderTag... tags) { + return addStoryBoard(component, asLocation(schematicPath), storyBoard, tags); + } + + public MultiSceneBuilder forComponents(ItemProviderEntry... components) { + return new MultiSceneBuilder(Arrays.asList(components)); + } + + public MultiSceneBuilder forComponents(Iterable> components) { + return new MultiSceneBuilder(components); + } + + public PonderStoryBoardEntry createStoryBoardEntry(PonderStoryBoard storyBoard, ResourceLocation schematicLocation, ResourceLocation component) { + return new PonderStoryBoardEntry(storyBoard, namespace, schematicLocation, component); + } + + public PonderStoryBoardEntry createStoryBoardEntry(PonderStoryBoard storyBoard, String schematicPath, ResourceLocation component) { + return createStoryBoardEntry(storyBoard, asLocation(schematicPath), component); + } + + public PonderTag createTag(String name) { + return new PonderTag(asLocation(name)); + } + + public PonderChapter getOrCreateChapter(String name) { + return PonderChapter.of(asLocation(name)); + } + + public ResourceLocation asLocation(String path) { + return new ResourceLocation(namespace, path); + } + + public class MultiSceneBuilder { + + protected Iterable> components; + + protected MultiSceneBuilder(Iterable> components) { + this.components = components; + } + + public MultiSceneBuilder addStoryBoard(ResourceLocation schematicLocation, PonderStoryBoard storyBoard) { + return addStoryBoard(schematicLocation, storyBoard, $ -> { + }); + } + + public MultiSceneBuilder addStoryBoard(ResourceLocation schematicLocation, PonderStoryBoard storyBoard, PonderTag... tags) { + return addStoryBoard(schematicLocation, storyBoard, sb -> sb.highlightTags(tags)); + } + + public MultiSceneBuilder addStoryBoard(ResourceLocation schematicLocation, PonderStoryBoard storyBoard, + Consumer extras) { + components.forEach(c -> extras.accept(PonderRegistrationHelper.this.addStoryBoard(c, schematicLocation, storyBoard))); + return this; + } + + public MultiSceneBuilder addStoryBoard(String schematicPath, PonderStoryBoard storyBoard) { + return addStoryBoard(asLocation(schematicPath), storyBoard); + } + + public MultiSceneBuilder addStoryBoard(String schematicPath, PonderStoryBoard storyBoard, PonderTag... tags) { + return addStoryBoard(asLocation(schematicPath), storyBoard, tags); + } + + public MultiSceneBuilder addStoryBoard(String schematicPath, PonderStoryBoard storyBoard, + Consumer extras) { + return addStoryBoard(asLocation(schematicPath), storyBoard, extras); + } + + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java index ee876bd31..9864d53f0 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java @@ -6,22 +6,18 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.function.Consumer; import java.util.zip.GZIPInputStream; import com.simibubi.create.Create; -import com.simibubi.create.foundation.ponder.PonderStoryBoardEntry.PonderStoryBoard; import com.simibubi.create.foundation.ponder.content.PonderChapter; import com.simibubi.create.foundation.ponder.content.PonderChapterRegistry; import com.simibubi.create.foundation.ponder.content.PonderIndex; -import com.simibubi.create.foundation.ponder.content.PonderTag; import com.simibubi.create.foundation.ponder.content.PonderTagRegistry; import com.simibubi.create.foundation.ponder.content.SharedText; -import com.tterrag.registrate.util.entry.ItemProviderEntry; import net.minecraft.client.Minecraft; import net.minecraft.nbt.CompoundNBT; @@ -38,79 +34,32 @@ public class PonderRegistry { public static final PonderTagRegistry TAGS = new PonderTagRegistry(); public static final PonderChapterRegistry CHAPTERS = new PonderChapterRegistry(); - // Map from item ids to all storyboards + // Map from item IDs to storyboard entries public static final Map> ALL = new HashMap<>(); - private static final ThreadLocal CURRENT_NAMESPACE = new ThreadLocal<>(); - - private static String getCurrentNamespace() { - return CURRENT_NAMESPACE.get(); - } - - private static void setCurrentNamespace(String namespace) { - CURRENT_NAMESPACE.set(namespace); - } - - public static void startRegistration(String namespace) { - if (getCurrentNamespace() != null) { - throw new IllegalStateException("Cannot start registration when already started!"); - } - setCurrentNamespace(namespace); - } - - public static void endRegistration() { - if (getCurrentNamespace() == null) { - throw new IllegalStateException("Cannot end registration when not started!"); - } - setCurrentNamespace(null); - } - - private static String getNamespaceOrThrow() { - String currentNamespace = getCurrentNamespace(); - if (currentNamespace == null) { - throw new IllegalStateException("Cannot register storyboard without starting registration!"); - } - return currentNamespace; - } - - public static PonderSceneBuilder addStoryBoard(ItemProviderEntry component, String schematicPath, - PonderStoryBoard storyBoard, PonderTag... tags) { - ResourceLocation id = component.getId(); - PonderStoryBoardEntry entry = new PonderStoryBoardEntry(storyBoard, getNamespaceOrThrow(), schematicPath, id); - PonderSceneBuilder builder = new PonderSceneBuilder(entry); - if (tags.length > 0) - builder.highlightTags(tags); + public static void addStoryBoard(PonderStoryBoardEntry entry) { synchronized (ALL) { - ALL.computeIfAbsent(id, _$ -> new ArrayList<>()) - .add(entry); + List list = ALL.computeIfAbsent(entry.getComponent(), $ -> new ArrayList<>()); + synchronized (list) { + list.add(entry); + } } - return builder; - } - - public static PonderSceneBuilder addStoryBoard(PonderChapter chapter, ResourceLocation component, String schematicPath, PonderStoryBoard storyBoard) { - if (component == null) - component = new ResourceLocation("minecraft", "stick"); - - PonderStoryBoardEntry entry = new PonderStoryBoardEntry(storyBoard, getNamespaceOrThrow(), schematicPath, component); - PonderSceneBuilder builder = new PonderSceneBuilder(entry); - CHAPTERS.addStoriesToChapter(chapter, entry); - return builder; - } - - public static MultiSceneBuilder forComponents(ItemProviderEntry... components) { - return new MultiSceneBuilder(Arrays.asList(components)); - } - - public static MultiSceneBuilder forComponents(Iterable> components) { - return new MultiSceneBuilder(components); } public static List compile(ResourceLocation id) { - return compile(ALL.get(id)); + List list = ALL.get(id); + if (list == null) { + return Collections.emptyList(); + } + return compile(list); } public static List compile(PonderChapter chapter) { - return compile(CHAPTERS.getStories(chapter)); + List list = CHAPTERS.getStories(chapter); + if (list == null) { + return Collections.emptyList(); + } + return compile(list); } public static List compile(List entries) { @@ -171,61 +120,4 @@ public class PonderRegistry { return t; } - public static class MultiSceneBuilder { - - private final Iterable> components; - - MultiSceneBuilder(Iterable> components) { - this.components = components; - } - - public MultiSceneBuilder addStoryBoard(String schematicPath, PonderStoryBoard storyBoard) { - return addStoryBoard(schematicPath, storyBoard, $ -> { - }); - } - - public MultiSceneBuilder addStoryBoard(String schematicPath, PonderStoryBoard storyBoard, PonderTag... tags) { - return addStoryBoard(schematicPath, storyBoard, sb -> sb.highlightTags(tags)); - } - - public MultiSceneBuilder addStoryBoard(String schematicPath, PonderStoryBoard storyBoard, - Consumer extras) { - components.forEach(c -> extras.accept(PonderRegistry.addStoryBoard(c, schematicPath, storyBoard))); - return this; - } - - } - - public static class PonderSceneBuilder { - - private final PonderStoryBoardEntry entry; - - PonderSceneBuilder(PonderStoryBoardEntry entry) { - this.entry = entry; - } - - public PonderSceneBuilder highlightAllTags() { - entry.getTags() - .add(PonderTag.Highlight.ALL); - return this; - } - - public PonderSceneBuilder highlightTags(PonderTag... tags) { - entry.getTags() - .addAll(Arrays.asList(tags)); - return this; - } - - public PonderSceneBuilder chapter(PonderChapter chapter) { - PonderRegistry.CHAPTERS.addStoriesToChapter(chapter, entry); - return this; - } - - public PonderSceneBuilder chapters(PonderChapter... chapters) { - for (PonderChapter c : chapters) - chapter(c); - return this; - } - } - } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderStoryBoardEntry.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderStoryBoardEntry.java index 5938d38e8..aa6ec545e 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderStoryBoardEntry.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderStoryBoardEntry.java @@ -1,8 +1,10 @@ package com.simibubi.create.foundation.ponder; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import com.simibubi.create.foundation.ponder.content.PonderChapter; import com.simibubi.create.foundation.ponder.content.PonderTag; import net.minecraft.util.ResourceLocation; @@ -11,18 +13,22 @@ public class PonderStoryBoardEntry { private final PonderStoryBoard board; private final String namespace; - private final String schematicPath; + private final ResourceLocation schematicLocation; private final ResourceLocation component; private final List tags; - public PonderStoryBoardEntry(PonderStoryBoard board, String namespace, String schematicPath, ResourceLocation component) { + public PonderStoryBoardEntry(PonderStoryBoard board, String namespace, ResourceLocation schematicLocation, ResourceLocation component) { this.board = board; this.namespace = namespace; - this.schematicPath = schematicPath; + this.schematicLocation = schematicLocation; this.component = component; this.tags = new ArrayList<>(); } + public PonderStoryBoardEntry(PonderStoryBoard board, String namespace, String schematicPath, ResourceLocation component) { + this(board, namespace, new ResourceLocation(namespace, schematicPath), component); + } + public PonderStoryBoard getBoard() { return board; } @@ -31,8 +37,8 @@ public class PonderStoryBoardEntry { return namespace; } - public String getSchematicPath() { - return schematicPath; + public ResourceLocation getSchematicLocation() { + return schematicLocation; } public ResourceLocation getComponent() { @@ -43,10 +49,36 @@ public class PonderStoryBoardEntry { return tags; } - public ResourceLocation getSchematicLocation() { - return new ResourceLocation(namespace, schematicPath); + // Builder start + + public PonderStoryBoardEntry highlightTag(PonderTag tag) { + tags.add(tag); + return this; } + public PonderStoryBoardEntry highlightTags(PonderTag... tags) { + Collections.addAll(this.tags, tags); + return this; + } + + public PonderStoryBoardEntry highlightAllTags() { + tags.add(PonderTag.Highlight.ALL); + return this; + } + + public PonderStoryBoardEntry chapter(PonderChapter chapter) { + PonderRegistry.CHAPTERS.addStoriesToChapter(chapter, this); + return this; + } + + public PonderStoryBoardEntry chapters(PonderChapter... chapters) { + for (PonderChapter c : chapters) + chapter(c); + return this; + } + + // Builder end + @FunctionalInterface public interface PonderStoryBoard { void program(SceneBuilder scene, SceneBuildingUtil util); diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java index 5c595c8cd..2a5584127 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java @@ -591,8 +591,7 @@ public class PonderUI extends NavigatableSimiScreen { UIRenderHelper.streak(ms, 180, 4, 10, 26, (int) (150 * fade)); drawRightAlignedString(font, ms, Lang.translate(IN_CHAPTER).getString(), 0, 0, tooltipColor); - drawRightAlignedString(font, ms, - Lang.translate(LANG_PREFIX + "chapter." + chapter.getId()).getString(), 0, 12, Theme.i(Theme.Key.TEXT)); + drawRightAlignedString(font, ms, chapter.getTitle(), 0, 12, Theme.i(Theme.Key.TEXT)); ms.popPose(); } @@ -821,8 +820,7 @@ public class PonderUI extends NavigatableSimiScreen { @Override protected String getBreadcrumbTitle() { if (chapter != null) - return Lang.translate(LANG_PREFIX + "chapter." + chapter.getId()) - .getString(); + return chapter.getTitle(); return stack.getItem() .getDescription() diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/DebugScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/DebugScenes.java index b2ed9efe7..d682bb774 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/DebugScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/DebugScenes.java @@ -5,7 +5,6 @@ import com.simibubi.create.AllItems; import com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel; import com.simibubi.create.content.contraptions.particle.RotationIndicatorParticleData; import com.simibubi.create.foundation.ponder.ElementLink; -import com.simibubi.create.foundation.ponder.PonderRegistry; import com.simibubi.create.foundation.ponder.PonderStoryBoardEntry.PonderStoryBoard; import com.simibubi.create.foundation.ponder.SceneBuilder; import com.simibubi.create.foundation.ponder.SceneBuildingUtil; @@ -51,9 +50,9 @@ public class DebugScenes { private static void add(PonderStoryBoard sb) { ItemEntry item = AllItems.BRASS_HAND; String schematicPath = "debug/scene_" + index; - PonderRegistry.addStoryBoard(item, schematicPath, sb) + PonderIndex.HELPER.addStoryBoard(item, schematicPath, sb) .highlightAllTags() - .chapter(PonderChapter.of("debug")); + .chapter(PonderIndex.HELPER.getOrCreateChapter("debug")); index++; } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapter.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapter.java index 9bedf775d..299f81fc5 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapter.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapter.java @@ -3,8 +3,8 @@ package com.simibubi.create.foundation.ponder.content; import javax.annotation.Nonnull; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.Create; import com.simibubi.create.foundation.gui.IScreenRenderable; +import com.simibubi.create.foundation.ponder.PonderLocalization; import com.simibubi.create.foundation.ponder.PonderRegistry; import net.minecraft.client.Minecraft; @@ -13,12 +13,26 @@ import net.minecraft.util.ResourceLocation; public class PonderChapter implements IScreenRenderable { - private final String id; + private final ResourceLocation id; private final ResourceLocation icon; - private PonderChapter(String id) { + private PonderChapter(ResourceLocation id) { this.id = id; - icon = new ResourceLocation(Create.ID, "textures/ponder/chapter/" + id + ".png"); + icon = new ResourceLocation(id.getNamespace(), "textures/ponder/chapter/" + id.getPath() + ".png"); + } + + public ResourceLocation getId() { + return id; + } + + public String getTitle() { + return PonderLocalization.getChapter(id); + } + + public PonderChapter addTagsToChapter(PonderTag... tags) { + for (PonderTag t : tags) + PonderRegistry.TAGS.add(t, this); + return this; } @Override @@ -32,7 +46,7 @@ public class PonderChapter implements IScreenRenderable { } @Nonnull - public static PonderChapter of(String id) { + public static PonderChapter of(ResourceLocation id) { PonderChapter chapter = PonderRegistry.CHAPTERS.getChapter(id); if (chapter == null) { chapter = PonderRegistry.CHAPTERS.addChapter(new PonderChapter(id)); @@ -40,14 +54,4 @@ public class PonderChapter implements IScreenRenderable { return chapter; } - - public PonderChapter addTagsToChapter(PonderTag... tags) { - for (PonderTag t : tags) - PonderRegistry.TAGS.add(t, this); - return this; - } - - public String getId() { - return id; - } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapterRegistry.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapterRegistry.java index 85d986fac..f1464ead4 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapterRegistry.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderChapterRegistry.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.ponder.content; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -13,21 +13,16 @@ import javax.annotation.Nullable; import com.simibubi.create.foundation.ponder.PonderStoryBoardEntry; import com.simibubi.create.foundation.utility.Pair; +import net.minecraft.util.ResourceLocation; + public class PonderChapterRegistry { - private final Map>> chapters; + private final Map>> chapters; public PonderChapterRegistry() { chapters = new HashMap<>(); } - public void addStoriesToChapter(@Nonnull PonderChapter chapter, PonderStoryBoardEntry... entries) { - List entryList = chapters.get(chapter.getId()).getSecond(); - synchronized (entryList) { - entryList.addAll(Arrays.asList(entries)); - } - } - PonderChapter addChapter(@Nonnull PonderChapter chapter) { synchronized (chapters) { chapters.put(chapter.getId(), Pair.of(chapter, new ArrayList<>())); @@ -36,7 +31,7 @@ public class PonderChapterRegistry { } @Nullable - PonderChapter getChapter(String id) { + PonderChapter getChapter(ResourceLocation id) { Pair> pair = chapters.get(id); if (pair == null) return null; @@ -44,6 +39,13 @@ public class PonderChapterRegistry { return pair.getFirst(); } + public void addStoriesToChapter(@Nonnull PonderChapter chapter, PonderStoryBoardEntry... entries) { + List entryList = chapters.get(chapter.getId()).getSecond(); + synchronized (entryList) { + Collections.addAll(entryList, entries); + } + } + public List getAllChapters() { return chapters .values() diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java index 9dc494031..be1232eb9 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java @@ -3,6 +3,7 @@ package com.simibubi.create.foundation.ponder.content; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.Create; +import com.simibubi.create.foundation.ponder.PonderRegistrationHelper; import com.simibubi.create.foundation.ponder.PonderRegistry; import com.simibubi.create.foundation.ponder.content.fluid.DrainScenes; import com.simibubi.create.foundation.ponder.content.fluid.FluidMovementActorScenes; @@ -17,179 +18,179 @@ import net.minecraft.item.DyeColor; public class PonderIndex { + static final PonderRegistrationHelper HELPER = new PonderRegistrationHelper(Create.ID); + public static final boolean EDITOR_MODE = false; public static void register() { - PonderRegistry.startRegistration(Create.ID); - // Register storyboards here // (!) Added entries require re-launch // (!) Modifications inside storyboard methods only require re-opening the ui - PonderRegistry.forComponents(AllBlocks.SHAFT) + HELPER.forComponents(AllBlocks.SHAFT) .addStoryBoard("shaft/relay", KineticsScenes::shaftAsRelay, PonderTag.KINETIC_RELAYS); - PonderRegistry.forComponents(AllBlocks.SHAFT, AllBlocks.ANDESITE_ENCASED_SHAFT, AllBlocks.BRASS_ENCASED_SHAFT) + HELPER.forComponents(AllBlocks.SHAFT, AllBlocks.ANDESITE_ENCASED_SHAFT, AllBlocks.BRASS_ENCASED_SHAFT) .addStoryBoard("shaft/encasing", KineticsScenes::shaftsCanBeEncased); - PonderRegistry.forComponents(AllBlocks.COGWHEEL) + HELPER.forComponents(AllBlocks.COGWHEEL) .addStoryBoard("cog/small", KineticsScenes::cogAsRelay, PonderTag.KINETIC_RELAYS) .addStoryBoard("cog/speedup", KineticsScenes::cogsSpeedUp); - PonderRegistry.forComponents(AllBlocks.LARGE_COGWHEEL) + HELPER.forComponents(AllBlocks.LARGE_COGWHEEL) .addStoryBoard("cog/speedup", KineticsScenes::cogsSpeedUp) .addStoryBoard("cog/large", KineticsScenes::largeCogAsRelay, PonderTag.KINETIC_RELAYS); - PonderRegistry.forComponents(AllItems.BELT_CONNECTOR) + HELPER.forComponents(AllItems.BELT_CONNECTOR) .addStoryBoard("belt/connect", BeltScenes::beltConnector, PonderTag.KINETIC_RELAYS) .addStoryBoard("belt/directions", BeltScenes::directions) .addStoryBoard("belt/transport", BeltScenes::transport, PonderTag.LOGISTICS) .addStoryBoard("belt/encasing", BeltScenes::beltsCanBeEncased); - PonderRegistry.forComponents(AllBlocks.ANDESITE_CASING, AllBlocks.BRASS_CASING) + HELPER.forComponents(AllBlocks.ANDESITE_CASING, AllBlocks.BRASS_CASING) .addStoryBoard("shaft/encasing", KineticsScenes::shaftsCanBeEncased) .addStoryBoard("belt/encasing", BeltScenes::beltsCanBeEncased); - PonderRegistry.forComponents(AllBlocks.GEARBOX, AllItems.VERTICAL_GEARBOX) + HELPER.forComponents(AllBlocks.GEARBOX, AllItems.VERTICAL_GEARBOX) .addStoryBoard("gearbox", KineticsScenes::gearbox, PonderTag.KINETIC_RELAYS); - PonderRegistry.addStoryBoard(AllBlocks.CLUTCH, "clutch", KineticsScenes::clutch, PonderTag.KINETIC_RELAYS); - PonderRegistry.addStoryBoard(AllBlocks.GEARSHIFT, "gearshift", KineticsScenes::gearshift, + HELPER.addStoryBoard(AllBlocks.CLUTCH, "clutch", KineticsScenes::clutch, PonderTag.KINETIC_RELAYS); + HELPER.addStoryBoard(AllBlocks.GEARSHIFT, "gearshift", KineticsScenes::gearshift, PonderTag.KINETIC_RELAYS); - PonderRegistry.forComponents(AllBlocks.SEQUENCED_GEARSHIFT) + HELPER.forComponents(AllBlocks.SEQUENCED_GEARSHIFT) .addStoryBoard("sequenced_gearshift", KineticsScenes::sequencedGearshift); - PonderRegistry.forComponents(AllBlocks.ENCASED_FAN) + HELPER.forComponents(AllBlocks.ENCASED_FAN) .addStoryBoard("fan/direction", FanScenes::direction, PonderTag.KINETIC_APPLIANCES) .addStoryBoard("fan/processing", FanScenes::processing) .addStoryBoard("fan/source", FanScenes::source, PonderTag.KINETIC_SOURCES); - PonderRegistry.addStoryBoard(AllBlocks.CREATIVE_MOTOR, "creative_motor", KineticsScenes::creativeMotor, + HELPER.addStoryBoard(AllBlocks.CREATIVE_MOTOR, "creative_motor", KineticsScenes::creativeMotor, PonderTag.KINETIC_SOURCES); - PonderRegistry.addStoryBoard(AllBlocks.WATER_WHEEL, "water_wheel", KineticsScenes::waterWheel, + HELPER.addStoryBoard(AllBlocks.WATER_WHEEL, "water_wheel", KineticsScenes::waterWheel, PonderTag.KINETIC_SOURCES); - PonderRegistry.addStoryBoard(AllBlocks.HAND_CRANK, "hand_crank", KineticsScenes::handCrank, + HELPER.addStoryBoard(AllBlocks.HAND_CRANK, "hand_crank", KineticsScenes::handCrank, PonderTag.KINETIC_SOURCES); - PonderRegistry.addStoryBoard(AllBlocks.COPPER_VALVE_HANDLE, "valve_handle", KineticsScenes::valveHandle, + HELPER.addStoryBoard(AllBlocks.COPPER_VALVE_HANDLE, "valve_handle", KineticsScenes::valveHandle, PonderTag.KINETIC_SOURCES); - PonderRegistry.forComponents(AllBlocks.DYED_VALVE_HANDLES.toArray()) + HELPER.forComponents(AllBlocks.DYED_VALVE_HANDLES.toArray()) .addStoryBoard("valve_handle", KineticsScenes::valveHandle); - PonderRegistry.addStoryBoard(AllBlocks.ENCASED_CHAIN_DRIVE, "chain_drive/relay", + HELPER.addStoryBoard(AllBlocks.ENCASED_CHAIN_DRIVE, "chain_drive/relay", ChainDriveScenes::chainDriveAsRelay, PonderTag.KINETIC_RELAYS); - PonderRegistry.forComponents(AllBlocks.ENCASED_CHAIN_DRIVE, AllBlocks.ADJUSTABLE_CHAIN_GEARSHIFT) + HELPER.forComponents(AllBlocks.ENCASED_CHAIN_DRIVE, AllBlocks.ADJUSTABLE_CHAIN_GEARSHIFT) .addStoryBoard("chain_drive/gearshift", ChainDriveScenes::adjustableChainGearshift); - PonderRegistry.forComponents(AllBlocks.FURNACE_ENGINE) + HELPER.forComponents(AllBlocks.FURNACE_ENGINE) .addStoryBoard("furnace_engine", KineticsScenes::furnaceEngine); - PonderRegistry.forComponents(AllBlocks.FLYWHEEL) + HELPER.forComponents(AllBlocks.FLYWHEEL) .addStoryBoard("furnace_engine", KineticsScenes::flywheel); - PonderRegistry.forComponents(AllBlocks.ROTATION_SPEED_CONTROLLER) + HELPER.forComponents(AllBlocks.ROTATION_SPEED_CONTROLLER) .addStoryBoard("speed_controller", KineticsScenes::speedController); // Gauges - PonderRegistry.addStoryBoard(AllBlocks.SPEEDOMETER, "gauges", KineticsScenes::speedometer); - PonderRegistry.addStoryBoard(AllBlocks.STRESSOMETER, "gauges", KineticsScenes::stressometer); + HELPER.addStoryBoard(AllBlocks.SPEEDOMETER, "gauges", KineticsScenes::speedometer); + HELPER.addStoryBoard(AllBlocks.STRESSOMETER, "gauges", KineticsScenes::stressometer); // Item Processing - PonderRegistry.addStoryBoard(AllBlocks.MILLSTONE, "millstone", ProcessingScenes::millstone); - PonderRegistry.addStoryBoard(AllBlocks.CRUSHING_WHEEL, "crushing_wheel", ProcessingScenes::crushingWheels); - PonderRegistry.addStoryBoard(AllBlocks.MECHANICAL_MIXER, "mechanical_mixer/mixing", ProcessingScenes::mixing); - PonderRegistry.forComponents(AllBlocks.MECHANICAL_PRESS) + HELPER.addStoryBoard(AllBlocks.MILLSTONE, "millstone", ProcessingScenes::millstone); + HELPER.addStoryBoard(AllBlocks.CRUSHING_WHEEL, "crushing_wheel", ProcessingScenes::crushingWheels); + HELPER.addStoryBoard(AllBlocks.MECHANICAL_MIXER, "mechanical_mixer/mixing", ProcessingScenes::mixing); + HELPER.forComponents(AllBlocks.MECHANICAL_PRESS) .addStoryBoard("mechanical_press/pressing", ProcessingScenes::pressing) .addStoryBoard("mechanical_press/compacting", ProcessingScenes::compacting); - PonderRegistry.forComponents(AllBlocks.BASIN) + HELPER.forComponents(AllBlocks.BASIN) .addStoryBoard("basin", ProcessingScenes::basin) .addStoryBoard("mechanical_mixer/mixing", ProcessingScenes::mixing) .addStoryBoard("mechanical_press/compacting", ProcessingScenes::compacting); - PonderRegistry.addStoryBoard(AllItems.EMPTY_BLAZE_BURNER, "empty_blaze_burner", + HELPER.addStoryBoard(AllItems.EMPTY_BLAZE_BURNER, "empty_blaze_burner", ProcessingScenes::emptyBlazeBurner); - PonderRegistry.addStoryBoard(AllBlocks.BLAZE_BURNER, "blaze_burner", ProcessingScenes::blazeBurner); - PonderRegistry.addStoryBoard(AllBlocks.DEPOT, "depot", BeltScenes::depot); - PonderRegistry.forComponents(AllBlocks.WEIGHTED_EJECTOR) + HELPER.addStoryBoard(AllBlocks.BLAZE_BURNER, "blaze_burner", ProcessingScenes::blazeBurner); + HELPER.addStoryBoard(AllBlocks.DEPOT, "depot", BeltScenes::depot); + HELPER.forComponents(AllBlocks.WEIGHTED_EJECTOR) .addStoryBoard("weighted_ejector/eject", EjectorScenes::ejector) .addStoryBoard("weighted_ejector/split", EjectorScenes::splitY) .addStoryBoard("weighted_ejector/redstone", EjectorScenes::redstone); // Crafters - PonderRegistry.forComponents(AllBlocks.MECHANICAL_CRAFTER) + HELPER.forComponents(AllBlocks.MECHANICAL_CRAFTER) .addStoryBoard("mechanical_crafter/setup", CrafterScenes::setup) .addStoryBoard("mechanical_crafter/connect", CrafterScenes::connect); - PonderRegistry.forComponents(AllBlocks.MECHANICAL_CRAFTER, AllItems.CRAFTER_SLOT_COVER) + HELPER.forComponents(AllBlocks.MECHANICAL_CRAFTER, AllItems.CRAFTER_SLOT_COVER) .addStoryBoard("mechanical_crafter/covers", CrafterScenes::covers); // Chutes - PonderRegistry.forComponents(AllBlocks.CHUTE) + HELPER.forComponents(AllBlocks.CHUTE) .addStoryBoard("chute/downward", ChuteScenes::downward, PonderTag.LOGISTICS) .addStoryBoard("chute/upward", ChuteScenes::upward); - PonderRegistry.forComponents(AllBlocks.CHUTE, AllBlocks.SMART_CHUTE) + HELPER.forComponents(AllBlocks.CHUTE, AllBlocks.SMART_CHUTE) .addStoryBoard("chute/smart", ChuteScenes::smart); // Funnels - PonderRegistry.addStoryBoard(AllBlocks.BRASS_FUNNEL, "funnels/brass", FunnelScenes::brass); - PonderRegistry.forComponents(AllBlocks.ANDESITE_FUNNEL, AllBlocks.BRASS_FUNNEL) + HELPER.addStoryBoard(AllBlocks.BRASS_FUNNEL, "funnels/brass", FunnelScenes::brass); + HELPER.forComponents(AllBlocks.ANDESITE_FUNNEL, AllBlocks.BRASS_FUNNEL) .addStoryBoard("funnels/intro", FunnelScenes::intro, PonderTag.LOGISTICS) .addStoryBoard("funnels/direction", FunnelScenes::directionality) .addStoryBoard("funnels/compat", FunnelScenes::compat) .addStoryBoard("funnels/redstone", FunnelScenes::redstone) .addStoryBoard("funnels/transposer", FunnelScenes::transposer); - PonderRegistry.addStoryBoard(AllBlocks.ANDESITE_FUNNEL, "funnels/brass", FunnelScenes::brass); + HELPER.addStoryBoard(AllBlocks.ANDESITE_FUNNEL, "funnels/brass", FunnelScenes::brass); // Tunnels - PonderRegistry.addStoryBoard(AllBlocks.ANDESITE_TUNNEL, "tunnels/andesite", TunnelScenes::andesite); - PonderRegistry.forComponents(AllBlocks.BRASS_TUNNEL) + HELPER.addStoryBoard(AllBlocks.ANDESITE_TUNNEL, "tunnels/andesite", TunnelScenes::andesite); + HELPER.forComponents(AllBlocks.BRASS_TUNNEL) .addStoryBoard("tunnels/brass", TunnelScenes::brass) .addStoryBoard("tunnels/brass_modes", TunnelScenes::brassModes); // Chassis & Super Glue - PonderRegistry.forComponents(AllBlocks.LINEAR_CHASSIS, AllBlocks.SECONDARY_LINEAR_CHASSIS) + HELPER.forComponents(AllBlocks.LINEAR_CHASSIS, AllBlocks.SECONDARY_LINEAR_CHASSIS) .addStoryBoard("chassis/linear_group", ChassisScenes::linearGroup, PonderTag.CONTRAPTION_ASSEMBLY) .addStoryBoard("chassis/linear_attachment", ChassisScenes::linearAttachement); - PonderRegistry.forComponents(AllBlocks.RADIAL_CHASSIS) + HELPER.forComponents(AllBlocks.RADIAL_CHASSIS) .addStoryBoard("chassis/radial", ChassisScenes::radial, PonderTag.CONTRAPTION_ASSEMBLY); - PonderRegistry.forComponents(AllItems.SUPER_GLUE) + HELPER.forComponents(AllItems.SUPER_GLUE) .addStoryBoard("super_glue", ChassisScenes::superGlue, PonderTag.CONTRAPTION_ASSEMBLY); - PonderRegistry.forComponents(AllBlocks.STICKER) + HELPER.forComponents(AllBlocks.STICKER) .addStoryBoard("sticker", RedstoneScenes::sticker, PonderTag.CONTRAPTION_ASSEMBLY); // Mechanical Arm - PonderRegistry.forComponents(AllBlocks.MECHANICAL_ARM) + HELPER.forComponents(AllBlocks.MECHANICAL_ARM) .addStoryBoard("mechanical_arm/setup", ArmScenes::setup, PonderTag.ARM_TARGETS) .addStoryBoard("mechanical_arm/filter", ArmScenes::filtering) .addStoryBoard("mechanical_arm/modes", ArmScenes::modes) .addStoryBoard("mechanical_arm/redstone", ArmScenes::redstone); // Mechanical Piston - PonderRegistry.forComponents(AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON) + HELPER.forComponents(AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON) .addStoryBoard("mechanical_piston/anchor", PistonScenes::movement, PonderTag.KINETIC_APPLIANCES, PonderTag.MOVEMENT_ANCHOR); - PonderRegistry + HELPER .forComponents(AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON, AllBlocks.PISTON_EXTENSION_POLE) .addStoryBoard("mechanical_piston/piston_pole", PistonScenes::poles); - PonderRegistry.forComponents(AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON) + HELPER.forComponents(AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON) .addStoryBoard("mechanical_piston/modes", PistonScenes::movementModes); // Windmill Bearing - PonderRegistry.forComponents(AllBlocks.ROPE_PULLEY) + HELPER.forComponents(AllBlocks.ROPE_PULLEY) .addStoryBoard("rope_pulley/anchor", PulleyScenes::movement, PonderTag.KINETIC_APPLIANCES, PonderTag.MOVEMENT_ANCHOR) .addStoryBoard("rope_pulley/modes", PulleyScenes::movementModes) .addStoryBoard("rope_pulley/attachment", PulleyScenes::attachment); // Windmill Bearing - PonderRegistry.forComponents(AllBlocks.WINDMILL_BEARING) + HELPER.forComponents(AllBlocks.WINDMILL_BEARING) .addStoryBoard("windmill_bearing/source", BearingScenes::windmillsAsSource, PonderTag.KINETIC_SOURCES) .addStoryBoard("windmill_bearing/structure", BearingScenes::windmillsAnyStructure, PonderTag.MOVEMENT_ANCHOR); - PonderRegistry.forComponents(AllBlocks.SAIL) + HELPER.forComponents(AllBlocks.SAIL) .addStoryBoard("sail", BearingScenes::sail); - PonderRegistry.forComponents(AllBlocks.SAIL_FRAME) + HELPER.forComponents(AllBlocks.SAIL_FRAME) .addStoryBoard("sail", BearingScenes::sailFrame); // Mechanical Bearing - PonderRegistry.forComponents(AllBlocks.MECHANICAL_BEARING) + HELPER.forComponents(AllBlocks.MECHANICAL_BEARING) .addStoryBoard("mechanical_bearing/anchor", BearingScenes::mechanicalBearing, PonderTag.KINETIC_APPLIANCES, PonderTag.MOVEMENT_ANCHOR) .addStoryBoard("mechanical_bearing/modes", BearingScenes::bearingModes) @@ -197,107 +198,105 @@ public class PonderIndex { PonderTag.CONTRAPTION_ACTOR); // Clockwork Bearing - PonderRegistry.addStoryBoard(AllBlocks.CLOCKWORK_BEARING, "clockwork_bearing", BearingScenes::clockwork, + HELPER.addStoryBoard(AllBlocks.CLOCKWORK_BEARING, "clockwork_bearing", BearingScenes::clockwork, PonderTag.KINETIC_APPLIANCES, PonderTag.MOVEMENT_ANCHOR); // Gantries - PonderRegistry.addStoryBoard(AllBlocks.GANTRY_SHAFT, "gantry/intro", GantryScenes::introForShaft, + HELPER.addStoryBoard(AllBlocks.GANTRY_SHAFT, "gantry/intro", GantryScenes::introForShaft, PonderTag.KINETIC_APPLIANCES, PonderTag.MOVEMENT_ANCHOR); - PonderRegistry.addStoryBoard(AllBlocks.GANTRY_CARRIAGE, "gantry/intro", GantryScenes::introForPinion, + HELPER.addStoryBoard(AllBlocks.GANTRY_CARRIAGE, "gantry/intro", GantryScenes::introForPinion, PonderTag.KINETIC_APPLIANCES, PonderTag.MOVEMENT_ANCHOR); - PonderRegistry.forComponents(AllBlocks.GANTRY_SHAFT, AllBlocks.GANTRY_CARRIAGE) + HELPER.forComponents(AllBlocks.GANTRY_SHAFT, AllBlocks.GANTRY_CARRIAGE) .addStoryBoard("gantry/redstone", GantryScenes::redstone) .addStoryBoard("gantry/direction", GantryScenes::direction) .addStoryBoard("gantry/subgantry", GantryScenes::subgantry); // Cart Assembler - PonderRegistry.forComponents(AllBlocks.CART_ASSEMBLER) + HELPER.forComponents(AllBlocks.CART_ASSEMBLER) .addStoryBoard("cart_assembler/anchor", CartAssemblerScenes::anchor, PonderTag.MOVEMENT_ANCHOR) .addStoryBoard("cart_assembler/modes", CartAssemblerScenes::modes) .addStoryBoard("cart_assembler/dual", CartAssemblerScenes::dual) .addStoryBoard("cart_assembler/rails", CartAssemblerScenes::rails); // Movement Actors - PonderRegistry.forComponents(AllBlocks.PORTABLE_STORAGE_INTERFACE) + HELPER.forComponents(AllBlocks.PORTABLE_STORAGE_INTERFACE) .addStoryBoard("portable_interface/transfer", MovementActorScenes::psiTransfer, PonderTag.CONTRAPTION_ACTOR) .addStoryBoard("portable_interface/redstone", MovementActorScenes::psiRedstone); - PonderRegistry.forComponents(AllBlocks.REDSTONE_CONTACT) + HELPER.forComponents(AllBlocks.REDSTONE_CONTACT) .addStoryBoard("redstone_contact", RedstoneScenes::contact); - PonderRegistry.forComponents(AllBlocks.MECHANICAL_SAW) + HELPER.forComponents(AllBlocks.MECHANICAL_SAW) .addStoryBoard("mechanical_saw/processing", MechanicalSawScenes::processing, PonderTag.KINETIC_APPLIANCES) .addStoryBoard("mechanical_saw/breaker", MechanicalSawScenes::treeCutting) .addStoryBoard("mechanical_saw/contraption", MechanicalSawScenes::contraption, PonderTag.CONTRAPTION_ACTOR); - PonderRegistry.forComponents(AllBlocks.MECHANICAL_DRILL) + HELPER.forComponents(AllBlocks.MECHANICAL_DRILL) .addStoryBoard("mechanical_drill/breaker", MechanicalDrillScenes::breaker, PonderTag.KINETIC_APPLIANCES) .addStoryBoard("mechanical_drill/contraption", MechanicalDrillScenes::contraption, PonderTag.CONTRAPTION_ACTOR); - PonderRegistry.forComponents(AllBlocks.DEPLOYER) + HELPER.forComponents(AllBlocks.DEPLOYER) .addStoryBoard("deployer/filter", DeployerScenes::filter, PonderTag.KINETIC_APPLIANCES) .addStoryBoard("deployer/modes", DeployerScenes::modes) .addStoryBoard("deployer/processing", DeployerScenes::processing) .addStoryBoard("deployer/redstone", DeployerScenes::redstone) .addStoryBoard("deployer/contraption", DeployerScenes::contraption, PonderTag.CONTRAPTION_ACTOR); - PonderRegistry.forComponents(AllBlocks.MECHANICAL_HARVESTER) + HELPER.forComponents(AllBlocks.MECHANICAL_HARVESTER) .addStoryBoard("harvester", MovementActorScenes::harvester); - PonderRegistry.forComponents(AllBlocks.MECHANICAL_PLOUGH) + HELPER.forComponents(AllBlocks.MECHANICAL_PLOUGH) .addStoryBoard("plough", MovementActorScenes::plough); // Fluids - PonderRegistry.forComponents(AllBlocks.FLUID_PIPE) + HELPER.forComponents(AllBlocks.FLUID_PIPE) .addStoryBoard("fluid_pipe/flow", PipeScenes::flow, PonderTag.FLUIDS) .addStoryBoard("fluid_pipe/interaction", PipeScenes::interaction) .addStoryBoard("fluid_pipe/encasing", PipeScenes::encasing); - PonderRegistry.forComponents(AllBlocks.COPPER_CASING) + HELPER.forComponents(AllBlocks.COPPER_CASING) .addStoryBoard("fluid_pipe/encasing", PipeScenes::encasing); - PonderRegistry.forComponents(AllBlocks.MECHANICAL_PUMP) + HELPER.forComponents(AllBlocks.MECHANICAL_PUMP) .addStoryBoard("mechanical_pump/flow", PumpScenes::flow, PonderTag.FLUIDS, PonderTag.KINETIC_APPLIANCES) .addStoryBoard("mechanical_pump/speed", PumpScenes::speed); - PonderRegistry.forComponents(AllBlocks.FLUID_VALVE) + HELPER.forComponents(AllBlocks.FLUID_VALVE) .addStoryBoard("fluid_valve", PipeScenes::valve, PonderTag.FLUIDS, PonderTag.KINETIC_APPLIANCES); - PonderRegistry.forComponents(AllBlocks.SMART_FLUID_PIPE) + HELPER.forComponents(AllBlocks.SMART_FLUID_PIPE) .addStoryBoard("smart_pipe", PipeScenes::smart, PonderTag.FLUIDS); - PonderRegistry.forComponents(AllBlocks.FLUID_TANK) + HELPER.forComponents(AllBlocks.FLUID_TANK) .addStoryBoard("fluid_tank/storage", FluidTankScenes::storage, PonderTag.FLUIDS) .addStoryBoard("fluid_tank/sizes", FluidTankScenes::sizes); - PonderRegistry.forComponents(AllBlocks.CREATIVE_FLUID_TANK) + HELPER.forComponents(AllBlocks.CREATIVE_FLUID_TANK) .addStoryBoard("fluid_tank/storage_creative", FluidTankScenes::creative, PonderTag.FLUIDS, PonderTag.CREATIVE) .addStoryBoard("fluid_tank/sizes_creative", FluidTankScenes::sizes); - PonderRegistry.forComponents(AllBlocks.HOSE_PULLEY) + HELPER.forComponents(AllBlocks.HOSE_PULLEY) .addStoryBoard("hose_pulley/intro", HosePulleyScenes::intro, PonderTag.FLUIDS, PonderTag.KINETIC_APPLIANCES) .addStoryBoard("hose_pulley/level", HosePulleyScenes::level) .addStoryBoard("hose_pulley/infinite", HosePulleyScenes::infinite); - PonderRegistry.forComponents(AllBlocks.SPOUT) + HELPER.forComponents(AllBlocks.SPOUT) .addStoryBoard("spout", SpoutScenes::filling, PonderTag.FLUIDS); - PonderRegistry.forComponents(AllBlocks.ITEM_DRAIN) + HELPER.forComponents(AllBlocks.ITEM_DRAIN) .addStoryBoard("item_drain", DrainScenes::emptying, PonderTag.FLUIDS); - PonderRegistry.forComponents(AllBlocks.PORTABLE_FLUID_INTERFACE) + HELPER.forComponents(AllBlocks.PORTABLE_FLUID_INTERFACE) .addStoryBoard("portable_interface/transfer_fluid", FluidMovementActorScenes::transfer, PonderTag.FLUIDS, PonderTag.CONTRAPTION_ACTOR) .addStoryBoard("portable_interface/redstone_fluid", MovementActorScenes::psiRedstone); // Redstone - PonderRegistry.forComponents(AllBlocks.PULSE_REPEATER) + HELPER.forComponents(AllBlocks.PULSE_REPEATER) .addStoryBoard("pulse_repeater", RedstoneScenes::pulseRepeater); - PonderRegistry.forComponents(AllBlocks.ADJUSTABLE_REPEATER) + HELPER.forComponents(AllBlocks.ADJUSTABLE_REPEATER) .addStoryBoard("adjustable_repeater", RedstoneScenes::adjustableRepeater); - PonderRegistry.forComponents(AllBlocks.ADJUSTABLE_PULSE_REPEATER) + HELPER.forComponents(AllBlocks.ADJUSTABLE_PULSE_REPEATER) .addStoryBoard("adjustable_pulse_repeater", RedstoneScenes::adjustablePulseRepeater); - PonderRegistry.forComponents(AllBlocks.POWERED_LATCH) + HELPER.forComponents(AllBlocks.POWERED_LATCH) .addStoryBoard("powered_latch", RedstoneScenes::poweredLatch); - PonderRegistry.forComponents(AllBlocks.POWERED_TOGGLE_LATCH) + HELPER.forComponents(AllBlocks.POWERED_TOGGLE_LATCH) .addStoryBoard("powered_toggle_latch", RedstoneScenes::poweredToggleLatch); - PonderRegistry.forComponents(AllBlocks.ANALOG_LEVER) + HELPER.forComponents(AllBlocks.ANALOG_LEVER) .addStoryBoard("analog_lever", RedstoneScenes::analogLever); - PonderRegistry.forComponents(AllBlocks.ORANGE_NIXIE_TUBE) + HELPER.forComponents(AllBlocks.ORANGE_NIXIE_TUBE) .addStoryBoard("nixie_tube", RedstoneScenes::nixieTube); - PonderRegistry.forComponents(AllBlocks.REDSTONE_LINK) + HELPER.forComponents(AllBlocks.REDSTONE_LINK) .addStoryBoard("redstone_link", RedstoneScenes::redstoneLink); // Debug scenes, can be found in game via the Brass Hand if (EDITOR_MODE) DebugScenes.registerAll(); - - PonderRegistry.endRegistration(); } public static void registerTags() { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java index 5a140bf69..f86073956 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java @@ -52,7 +52,7 @@ public class PonderIndexScreen extends NavigatableSimiScreen { super.init(); chapters.clear(); - // chapters.addAll(PonderRegistry.chapters.getAllChapters()); + // chapters.addAll(PonderRegistry.CHAPTERS.getAllChapters()); items.clear(); PonderRegistry.ALL.keySet() diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTag.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTag.java index f96f8e5eb..e9f266ec9 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTag.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTag.java @@ -1,8 +1,5 @@ package com.simibubi.create.foundation.ponder.content; -import java.util.ArrayList; -import java.util.List; - import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; @@ -10,6 +7,7 @@ import com.simibubi.create.Create; import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.IScreenRenderable; import com.simibubi.create.foundation.ponder.PonderLocalization; +import com.simibubi.create.foundation.ponder.PonderRegistry; import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; @@ -23,8 +21,6 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class PonderTag implements IScreenRenderable { - public static final List LISTED_TAGS = new ArrayList<>(); - public static final PonderTag KINETIC_RELAYS = create("kinetic_relays").item(AllBlocks.COGWHEEL.get(), true, false) @@ -90,6 +86,18 @@ public class PonderTag implements IScreenRenderable { private ItemStack itemIcon = ItemStack.EMPTY; private ItemStack mainItem = ItemStack.EMPTY; + public PonderTag(ResourceLocation id) { + this.id = id; + } + + public ResourceLocation getId() { + return id; + } + + public ItemStack getMainItem() { + return mainItem; + } + public String getTitle() { return PonderLocalization.getTag(id); } @@ -100,34 +108,13 @@ public class PonderTag implements IScreenRenderable { // Builder - public PonderTag(ResourceLocation id) { - this.id = id; - } - - public ResourceLocation getId() { - return id; - } - public PonderTag defaultLang(String title, String description) { PonderLocalization.registerTag(id, title, description); return this; } - public ItemStack getMainItem() { - return mainItem; - } - - public PonderTag idAsIcon() { - return icon(id); - } - public PonderTag addToIndex() { - LISTED_TAGS.add(this); - return this; - } - - public PonderTag icon(String location) { - this.icon = new ResourceLocation(id.getNamespace(), "textures/ponder/tag/" + location + ".png"); + PonderRegistry.TAGS.listTag(this); return this; } @@ -136,8 +123,13 @@ public class PonderTag implements IScreenRenderable { return this; } - public PonderTag item(IItemProvider item) { - return this.item(item, true, true); + public PonderTag icon(String location) { + this.icon = new ResourceLocation(id.getNamespace(), "textures/ponder/tag/" + location + ".png"); + return this; + } + + public PonderTag idAsIcon() { + return icon(id); } public PonderTag item(IItemProvider item, boolean useAsIcon, boolean useAsMainItem) { @@ -148,6 +140,10 @@ public class PonderTag implements IScreenRenderable { return this; } + public PonderTag item(IItemProvider item) { + return this.item(item, true, true); + } + @Override @OnlyIn(Dist.CLIENT) public void draw(MatrixStack ms, AbstractGui screen, int x, int y) { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagIndexScreen.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagIndexScreen.java index 24b4dc107..1cccb7e4e 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagIndexScreen.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagIndexScreen.java @@ -15,6 +15,7 @@ import com.simibubi.create.foundation.gui.UIRenderHelper; import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.ponder.NavigatableSimiScreen; import com.simibubi.create.foundation.ponder.PonderLocalization; +import com.simibubi.create.foundation.ponder.PonderRegistry; import com.simibubi.create.foundation.ponder.PonderUI; import com.simibubi.create.foundation.ponder.ui.LayoutHelper; import com.simibubi.create.foundation.ponder.ui.PonderButton; @@ -53,7 +54,7 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { widgets.clear(); super.init(); - List tags = PonderTag.LISTED_TAGS; + List tags = PonderRegistry.TAGS.getListedTags(); int rowCount = MathHelper.clamp((int) Math.ceil(tags.size() / 11d), 1, 3); LayoutHelper layout = LayoutHelper.centeredHorizontal(tags.size(), rowCount, 28, 28, 8); itemArea = layout.getArea(); @@ -164,7 +165,7 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen { } protected void renderItems(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { - List tags = PonderTag.LISTED_TAGS; + List tags = PonderRegistry.TAGS.getListedTags(); if (tags.isEmpty()) return; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagRegistry.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagRegistry.java index cdd5be6e6..8d0da42a2 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagRegistry.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagRegistry.java @@ -1,14 +1,15 @@ package com.simibubi.create.foundation.ponder.content; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.Set; import com.google.common.collect.ImmutableSet; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; -import com.simibubi.create.foundation.ponder.PonderRegistry; import com.tterrag.registrate.util.entry.ItemProviderEntry; import net.minecraft.util.IItemProvider; @@ -19,9 +20,12 @@ public class PonderTagRegistry { private final Multimap tags; private final Multimap chapterTags; + private final List listedTags; + public PonderTagRegistry() { tags = LinkedHashMultimap.create(); chapterTags = LinkedHashMultimap.create(); + listedTags = new ArrayList<>(); } public Set getTags(ResourceLocation item) { @@ -48,6 +52,14 @@ public class PonderTagRegistry { .collect(ImmutableSet.toImmutableSet()); } + public List getListedTags() { + return listedTags; + } + + public void listTag(PonderTag tag) { + listedTags.add(tag); + } + public void add(PonderTag tag, ResourceLocation item) { synchronized (tags) { tags.put(item, tag); @@ -68,7 +80,7 @@ public class PonderTagRegistry { return new TagBuilder(tag); } - public static class ItemBuilder { + public class ItemBuilder { private final Collection items; @@ -77,13 +89,13 @@ public class PonderTagRegistry { } public ItemBuilder add(PonderTag tag) { - items.forEach(i -> PonderRegistry.TAGS.add(tag, i)); + items.forEach(i -> PonderTagRegistry.this.add(tag, i)); return this; } } - public static class TagBuilder { + public class TagBuilder { private final PonderTag tag; @@ -92,7 +104,7 @@ public class PonderTagRegistry { } public TagBuilder add(ResourceLocation item) { - PonderRegistry.TAGS.add(tag, item); + PonderTagRegistry.this.add(tag, item); return this; } @@ -104,5 +116,7 @@ public class PonderTagRegistry { public TagBuilder add(ItemProviderEntry entry) { return add(entry.get()); } + } + } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/ui/ChapterLabel.java b/src/main/java/com/simibubi/create/foundation/ponder/ui/ChapterLabel.java index 7390a2457..59abb1d59 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/ui/ChapterLabel.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/ui/ChapterLabel.java @@ -9,7 +9,6 @@ import com.simibubi.create.foundation.gui.Theme; import com.simibubi.create.foundation.gui.UIRenderHelper; import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget; import com.simibubi.create.foundation.ponder.content.PonderChapter; -import com.simibubi.create.foundation.utility.Lang; import net.minecraft.client.Minecraft; @@ -31,7 +30,7 @@ public class ChapterLabel extends AbstractSimiWidget { @Override public void render(@Nonnull MatrixStack ms, int mouseX, int mouseY, float partialTicks) { UIRenderHelper.streak(ms, 0, x, y + height / 2, height - 2, width); - Minecraft.getInstance().font.draw(ms, Lang.translate("ponder.chapter." + chapter.getId()), x + 50, + Minecraft.getInstance().font.draw(ms, chapter.getTitle(), x + 50, y + 20, Theme.i(Theme.Key.TEXT_ACCENT_SLIGHT)); button.renderButton(ms, mouseX, mouseY, partialTicks);