From b7211f3d6df9020d4456b006804f471935ec405b Mon Sep 17 00:00:00 2001 From: Craig Date: Wed, 20 Dec 2023 12:28:59 +0000 Subject: [PATCH 1/4] Edited ShellPatternProvider to allow for Addon Mod extension --- .../common/capability/upgrades/Upgrades.java | 5 +--- .../common/data/ShellPatternProvider.java | 25 +++++++++---------- .../neoforge/TardisRefinedForge.java | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/Upgrades.java b/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/Upgrades.java index fa763f1af..015299740 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/Upgrades.java +++ b/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/Upgrades.java @@ -38,11 +38,8 @@ public class Upgrades { public static final RegistrySupplier DEFENSE_SYSTEM = UPGRADE_DEFERRED_REGISTRY.register("defense_system", () -> new Upgrade(Items.DIAMOND_SWORD::getDefaultInstance, TARDIS_XP, RegistryHelper.makeKey("defense_system"), Upgrade.UpgradeType.MAIN_UPGRADE) .setSkillPointsRequired(50).setPosition(0, 1)); - public static final RegistrySupplier HOSTILE_DISPLACEMENT = UPGRADE_DEFERRED_REGISTRY.register("hostile_displacement", () -> new Upgrade(Items.ZOMBIE_HEAD::getDefaultInstance, DEFENSE_SYSTEM, RegistryHelper.makeKey("hostile_displacement"), Upgrade.UpgradeType.SUB_UPGRADE) - .setSkillPointsRequired(50).setPosition(1, 1)); - public static final RegistrySupplier MATERIALIZE_AROUND = UPGRADE_DEFERRED_REGISTRY.register("materialize_around", () -> new Upgrade(Items.GLASS_PANE::getDefaultInstance, DEFENSE_SYSTEM, RegistryHelper.makeKey("materialize_around"), Upgrade.UpgradeType.SUB_UPGRADE) - .setSkillPointsRequired(50).setPosition(2, 1)); + .setSkillPointsRequired(50).setPosition(1, 1)); // Navigation Upgrades public static final RegistrySupplier NAVIGATION_SYSTEM = UPGRADE_DEFERRED_REGISTRY.register("navigation_system", () -> new Upgrade(Items.COMPASS::getDefaultInstance, TARDIS_XP, RegistryHelper.makeKey("navigation_system"), Upgrade.UpgradeType.MAIN_UPGRADE) diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java b/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java index 1cb8f799e..e04fe9549 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java @@ -8,7 +8,6 @@ import net.minecraft.data.DataProvider; import net.minecraft.resources.ResourceLocation; import whocraft.tardis_refined.TardisRefined; -import whocraft.tardis_refined.common.tardis.themes.ShellTheme; import whocraft.tardis_refined.patterns.ShellPattern; import whocraft.tardis_refined.patterns.ShellPatternCollection; import whocraft.tardis_refined.patterns.ShellPatterns; @@ -22,15 +21,17 @@ public class ShellPatternProvider implements DataProvider { protected final DataGenerator generator; private final boolean addDefaults; protected Map data = new HashMap<>(); + private final String modid; - public ShellPatternProvider(DataGenerator generator) { - this(generator, true); + public ShellPatternProvider(DataGenerator generator, String modid) { + this(generator, modid, true); } - public ShellPatternProvider(DataGenerator generator, boolean addDefaults) { + public ShellPatternProvider(DataGenerator generator, String modid, boolean addDefaults) { Preconditions.checkNotNull(generator); this.generator = generator; this.addDefaults = addDefaults; + this.modid = modid; } /** @@ -53,9 +54,8 @@ public CompletableFuture run(CachedOutput arg) { this.addPatterns(); if (!data.isEmpty()) { - data.entrySet().forEach(entry -> { + data.forEach((key, patternCollection) -> { try { - ShellPatternCollection patternCollection = entry.getValue(); JsonObject currentPatternCollection = ShellPatternCollection.CODEC.encodeStart(JsonOps.INSTANCE, patternCollection).get() .ifRight(right -> { TardisRefined.LOGGER.error(right.message()); @@ -63,20 +63,19 @@ public CompletableFuture run(CachedOutput arg) { Path output = getPath(patternCollection.themeId()); futures.add(DataProvider.saveStable(arg, currentPatternCollection, output)); } catch (Exception exception) { - TardisRefined.LOGGER.debug("Issue writing ShellPatternCollection {}! Error: {}", entry.getValue().themeId(), exception.getMessage()); + TardisRefined.LOGGER.debug("Issue writing ShellPatternCollection {}! Error: {}", patternCollection.themeId(), exception.getMessage()); } }); } return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)); } - protected ShellPattern addPatternToDatagen(ResourceLocation themeId, ShellPattern shellPattern) { + public ShellPattern addPattern(ResourceLocation themeId, ShellPattern shellPattern) { ShellPattern pattern = (ShellPattern) shellPattern.setThemeId(themeId); ShellPatternCollection collection; if (this.data.containsKey(themeId)) { collection = this.data.get(themeId); - List currentList = new ArrayList<>(); - currentList.addAll(collection.patterns()); + List currentList = new ArrayList<>(collection.patterns()); currentList.add(pattern); collection.setPatterns(currentList); this.data.replace(themeId, collection); @@ -88,16 +87,16 @@ protected ShellPattern addPatternToDatagen(ResourceLocation themeId, ShellPatter return pattern; } - protected ResourceLocation exteriorTextureLocation(ResourceLocation themeId) { + public ResourceLocation exteriorTextureLocation(ResourceLocation themeId) { return new ResourceLocation(themeId.getNamespace(), "textures/blockentity/shell/" + themeId.getPath() + "/" + themeId.getPath() + ".png"); } - protected ResourceLocation interiorTextureLocation(ResourceLocation themeId) { + public ResourceLocation interiorTextureLocation(ResourceLocation themeId) { return new ResourceLocation(themeId.getNamespace(), "textures/blockentity/shell/" + themeId.getPath() + "/" + themeId.getPath() + "_interior.png"); } protected Path getPath(ResourceLocation themeId) { - return generator.getPackOutput().getOutputFolder().resolve("data/" + TardisRefined.MODID + "/" + TardisRefined.MODID + "/patterns/shell/" + themeId.getPath() + ".json"); + return generator.getPackOutput().getOutputFolder().resolve("data/" + modid + "/" + modid + "/patterns/shell/" + themeId.getPath() + ".json"); } @Override diff --git a/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java b/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java index ef8d0d11d..8dfc77b6c 100644 --- a/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java +++ b/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java @@ -53,7 +53,7 @@ public void onGatherData(GatherDataEvent e) { generator.addProvider(e.includeServer(), new RecipeProvider(generator, e.getLookupProvider())); generator.addProvider(e.includeServer(), new ConsolePatternProvider(generator)); generator.addProvider(e.includeServer(), new DesktopProvider(generator)); - generator.addProvider(e.includeServer(), new ShellPatternProvider(generator)); + generator.addProvider(e.includeServer(), new ShellPatternProvider(generator, TardisRefined.MODID)); //Tags generator.addProvider(e.includeServer(), new TRBiomeTagsProvider(generator.getPackOutput(), e.getLookupProvider(), e.getExistingFileHelper())); From c6cfcd6f2443709fa7cd88c937bee02a61774dcd Mon Sep 17 00:00:00 2001 From: Craig Date: Wed, 20 Dec 2023 12:40:18 +0000 Subject: [PATCH 2/4] Removed HADS Language Entry --- .../resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 | 4 ++-- .../generated/resources/assets/tardis_refined/lang/en_us.json | 2 -- .../tardis_refined/common/data/LangProviderEnglish.java | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 b/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 index 49f17dc43..8738c5515 100644 --- a/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 +++ b/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 @@ -1,2 +1,2 @@ -// 1.20.2 2023-12-13T17:23:49.2085353 Languages: en_us -918df6357a51f37e6384a7a2a029249d89d8b970 assets/tardis_refined/lang/en_us.json +// 1.20.2 2023-12-20T12:39:49.6663005 Languages: en_us +b15287898c149aa4559ad436a4a80a5484e7df22 assets/tardis_refined/lang/en_us.json diff --git a/forge/src/generated/resources/assets/tardis_refined/lang/en_us.json b/forge/src/generated/resources/assets/tardis_refined/lang/en_us.json index 92cdca4c2..f25320084 100644 --- a/forge/src/generated/resources/assets/tardis_refined/lang/en_us.json +++ b/forge/src/generated/resources/assets/tardis_refined/lang/en_us.json @@ -116,8 +116,6 @@ "upgrade.tardis_refined.explorer_ii.description": "x2500 Increment", "upgrade.tardis_refined.explorer_iii": "Explorer III", "upgrade.tardis_refined.explorer_iii.description": "x5000 Increment", - "upgrade.tardis_refined.hostile_displacement": "Hostile Action Displacement", - "upgrade.tardis_refined.hostile_displacement.description": "Enables the displacement of the TARDIS when attacked", "upgrade.tardis_refined.inside_architecture": "Desktop Reconfiguration", "upgrade.tardis_refined.inside_architecture.description": "Allows the Pilot to change the appearance of the TARDIS Desktop", "upgrade.tardis_refined.landing_pad": "Landing Pad", diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java b/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java index e2ac488c4..c7b95e3db 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java @@ -155,7 +155,6 @@ protected void addTranslations() { addUpgrade(Upgrades.COORDINATE_INPUT.get(), "Coordinate Input", "Allows the Pilot to input coordinates with the monitor"); addUpgrade(Upgrades.CHAMELEON_CIRCUIT_SYSTEM.get(), "Chameleon Circuit", "Allows the TARDIS to change it's shape"); addUpgrade(Upgrades.DEFENSE_SYSTEM.get(), "Defense System", "Enables Defense Protocols"); - addUpgrade(Upgrades.HOSTILE_DISPLACEMENT.get(), "Hostile Action Displacement", "Enables the displacement of the TARDIS when attacked"); addUpgrade(Upgrades.WAYPOINTS.get(), "Waypoints", "Allows the Pilot to create saved locations"); addUpgrade(Upgrades.NAVIGATION_SYSTEM.get(), "Navigation System", "Allows upgrades to the TARDIS Navigation System"); addUpgrade(Upgrades.TARDIS_XP.get(), "System Upgrades", "Allows upgrades to the TARDIS"); From f2da41e3a081f8b267812e4f4d5b52911e3fe4bc Mon Sep 17 00:00:00 2001 From: Craig Date: Wed, 20 Dec 2023 12:57:24 +0000 Subject: [PATCH 3/4] Adds Flexibility to ShellEntry --- .../client/model/blockentity/shell/ShellEntry.java | 12 +++--------- .../blockentity/shell/ShellModelCollection.java | 4 ++++ .../blockentity/console/GlobalConsoleRenderer.java | 4 ++-- .../blockentity/door/GlobalDoorRenderer.java | 2 +- .../blockentity/shell/GlobalShellRenderer.java | 3 ++- .../screen/selections/ShellSelectionScreen.java | 2 +- .../common/data/ShellPatternProvider.java | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/ShellEntry.java b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/ShellEntry.java index 342903d5c..b2ab51132 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/ShellEntry.java +++ b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/ShellEntry.java @@ -1,6 +1,7 @@ package whocraft.tardis_refined.client.model.blockentity.shell; import whocraft.tardis_refined.client.model.blockentity.door.interior.ShellDoorModel; +import whocraft.tardis_refined.patterns.ShellPattern; public class ShellEntry { @@ -12,19 +13,12 @@ public ShellEntry(ShellModel shellModel, ShellDoorModel shellDoorModel) { this.shellDoorModel = shellDoorModel; } - public ShellModel getShellModel() { + public ShellModel getShellModel(ShellPattern shellPattern) { return shellModel; } - public void setShellModel(ShellModel shellModel) { - this.shellModel = shellModel; - } - - public ShellDoorModel getShellDoorModel() { + public ShellDoorModel getShellDoorModel(ShellPattern shellPattern) { return shellDoorModel; } - public void setShellDoorModel(ShellDoorModel shellDoorModel) { - this.shellDoorModel = shellDoorModel; - } } diff --git a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/ShellModelCollection.java b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/ShellModelCollection.java index bb2326760..b1f28da03 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/ShellModelCollection.java +++ b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/shell/ShellModelCollection.java @@ -94,6 +94,10 @@ public static void registerShellEntry(ShellTheme theme, ShellModel shellModel, S SHELL_MODELS.put(ShellTheme.getKey(theme), new ShellEntry(shellModel, shellDoorModel)); } + public static void registerShellEntry(ShellTheme theme, ShellEntry shellEntry){ + SHELL_MODELS.put(ShellTheme.getKey(theme), shellEntry); + } + /** * Get the associated shell model from a shell theme. * @param themeId The Shell theme Id. diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java index 1b9ba18c6..987db2b75 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java @@ -63,8 +63,9 @@ private void renderHoloShell(Vec3 offset, int rotation, GlobalConsoleBlockEntity TardisClientData reactions = TardisClientData.getInstance(blockEntity.getLevel().dimension()); ResourceLocation shellTheme = reactions.getShellTheme(); ResourceLocation shellPattern = reactions.getShellPattern(); + ShellPattern pattern = ShellPatterns.getPatternOrDefault(shellTheme, shellPattern); - var model = ShellModelCollection.getInstance().getShellEntry(shellTheme).getShellModel(); + var model = ShellModelCollection.getInstance().getShellEntry(shellTheme).getShellModel(pattern); model.setDoorPosition(false); poseStack.mulPose(Axis.ZP.rotationDegrees(180F)); @@ -81,7 +82,6 @@ private void renderHoloShell(Vec3 offset, int rotation, GlobalConsoleBlockEntity ShellSelectionScreen.generateDummyGlobalShell(); } - ShellPattern pattern = ShellPatterns.getPatternOrDefault(shellTheme, shellPattern); model.renderShell(ShellSelectionScreen.globalShellBlockEntity, false, true, poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(pattern.exteriorDoorTexture().texture())), packedLight, OverlayTexture.NO_OVERLAY, (float) color.x, (float) color.y, (float) color.z, 0.25f); poseStack.popPose(); } diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/door/GlobalDoorRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/door/GlobalDoorRenderer.java index 2f25e2342..49a697703 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/door/GlobalDoorRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/door/GlobalDoorRenderer.java @@ -38,7 +38,7 @@ public void render(GlobalDoorBlockEntity blockEntity, float partialTick, PoseSta // Render slightly off the wall to prevent z-fighting. poseStack.translate(0, 0, -0.01); - currentModel = ShellModelCollection.getInstance().getShellEntry(theme).getShellDoorModel(); + currentModel = ShellModelCollection.getInstance().getShellEntry(theme).getShellDoorModel(blockEntity.pattern()); if(theme == ShellTheme.POLICE_BOX.getId()){ poseStack.scale(1.05f, 1.05f, 1.05f); diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/shell/GlobalShellRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/shell/GlobalShellRenderer.java index ecc3e5acc..274ea828e 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/shell/GlobalShellRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/shell/GlobalShellRenderer.java @@ -45,9 +45,10 @@ public void render(GlobalShellBlockEntity blockEntity, float partialTick, PoseSt } } - var currentModel = ShellModelCollection.getInstance().getShellEntry(theme).getShellModel(); ShellPattern pattern = blockEntity.pattern(); + var currentModel = ShellModelCollection.getInstance().getShellEntry(theme).getShellModel(pattern); + currentModel.renderShell(blockEntity, isOpen, true, poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(currentModel.getShellTexture(pattern, false))), packedLight, OverlayTexture.NO_OVERLAY, 1f, 1f, 1f, 1f); diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/ShellSelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/selections/ShellSelectionScreen.java index a9fc7ac24..b1a159646 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/ShellSelectionScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/selections/ShellSelectionScreen.java @@ -155,7 +155,7 @@ public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { } private void renderShell(GuiGraphics guiGraphics, int x, int y, float scale) { - ShellModel model = ShellModelCollection.getInstance().getShellEntry(this.currentShellTheme).getShellModel(); + ShellModel model = ShellModelCollection.getInstance().getShellEntry(this.currentShellTheme).getShellModel(pattern); model.setDoorPosition(false); Lighting.setupForEntityInInventory(); PoseStack pose = guiGraphics.pose(); diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java b/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java index e04fe9549..a26f67c33 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java @@ -96,7 +96,7 @@ public ResourceLocation interiorTextureLocation(ResourceLocation themeId) { } protected Path getPath(ResourceLocation themeId) { - return generator.getPackOutput().getOutputFolder().resolve("data/" + modid + "/" + modid + "/patterns/shell/" + themeId.getPath() + ".json"); + return generator.getPackOutput().getOutputFolder().resolve("data/" + TardisRefined.MODID + "/" + modid + "/patterns/shell/" + themeId.getPath() + ".json"); } @Override From 9019ec0ca5ea80ab8c8d74b516780b03f79dbc47 Mon Sep 17 00:00:00 2001 From: Craig Date: Wed, 20 Dec 2023 13:12:55 +0000 Subject: [PATCH 4/4] Fixed Inversion --- .../tardis_refined/common/data/ShellPatternProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java b/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java index a26f67c33..7f771b30e 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/ShellPatternProvider.java @@ -96,7 +96,7 @@ public ResourceLocation interiorTextureLocation(ResourceLocation themeId) { } protected Path getPath(ResourceLocation themeId) { - return generator.getPackOutput().getOutputFolder().resolve("data/" + TardisRefined.MODID + "/" + modid + "/patterns/shell/" + themeId.getPath() + ".json"); + return generator.getPackOutput().getOutputFolder().resolve("data/" + modid + "/" + TardisRefined.MODID + "/patterns/shell/" + themeId.getPath() + ".json"); } @Override