From 07932d0f76d3f0ec84e321c6017a421ccb0ef4b8 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Wed, 8 Jan 2025 15:03:16 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Added=20advanced=20jukebox?= =?UTF-8?q?=20upgrade=20-=20Has=20multiple=20slots=20that=20can=20hold=20m?= =?UTF-8?q?usic=20discs=20and=20plays=20them=20one=20by=20one=20-=20Has=20?= =?UTF-8?q?controls=20to=20go=20skip=20between=20discs=20played=20-=20Allo?= =?UTF-8?q?ws=20playing=20discs=20in=20random=20order=20by=20using=20Shuff?= =?UTF-8?q?le=20toggle=20-=20Allows=20repeating=20all=20or=20the=20current?= =?UTF-8?q?=20disc=20played=20-=20Mobs=20that=20spawn=20with=20jukebox=20i?= =?UTF-8?q?n=20their=20backpack=20will=20now=20sometimes=20have=20an=20adv?= =?UTF-8?q?anced=20one=20with=20possibly=20more=20than=20one=20disc=20in?= =?UTF-8?q?=20them?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 4 +- .../misc/advanced_jukebox_upgrade.json | 38 ++++++++++++++++++ .../recipe/advanced_jukebox_upgrade.json | 33 +++++++++++++++ .../sophisticatedbackpacks/Config.java | 7 +++- .../common/EntityBackpackAdditionHandler.java | 17 +++++--- .../data/SBPRecipeProvider.java | 11 +++++ .../sophisticatedbackpacks/init/ModItems.java | 9 +++-- .../init/ModItemsClient.java | 4 +- .../sophisticatedbackpacks/lang/en_us.json | 2 + .../models/item/advanced_jukebox_upgrade.json | 6 +++ .../item/advanced_jukebox_upgrade.png | Bin 0 -> 304 bytes 11 files changed, 117 insertions(+), 14 deletions(-) create mode 100644 src/generated/resources/data/sophisticatedbackpacks/advancement/recipes/misc/advanced_jukebox_upgrade.json create mode 100644 src/generated/resources/data/sophisticatedbackpacks/recipe/advanced_jukebox_upgrade.json create mode 100644 src/main/resources/assets/sophisticatedbackpacks/models/item/advanced_jukebox_upgrade.json create mode 100644 src/main/resources/assets/sophisticatedbackpacks/textures/item/advanced_jukebox_upgrade.png diff --git a/gradle.properties b/gradle.properties index 0b03d3ea..542b8d4f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ loader_version_range=[4,) mod_id=sophisticatedbackpacks mod_name=Sophisticated Backpacks mod_license=GNU General Public License v3.0 -mod_version=3.21.1 +mod_version=3.22.0 mod_group_id=sophisticatedbackpacks mod_authors=P3pp3rF1y, Ridanisaurus mod_description=Fancy and functional backpacks. @@ -34,7 +34,7 @@ chipped_cf_file_id=5506938 resourcefullib_cf_file_id=5483169 athena_cf_file_id=5431579 curios_cf_file_id=5546342 -sc_version=[1.21-1.0.9,1.22) +sc_version=[1.21-1.1.0,1.22) #publish curseforge_id=422301 diff --git a/src/generated/resources/data/sophisticatedbackpacks/advancement/recipes/misc/advanced_jukebox_upgrade.json b/src/generated/resources/data/sophisticatedbackpacks/advancement/recipes/misc/advanced_jukebox_upgrade.json new file mode 100644 index 00000000..33d734d2 --- /dev/null +++ b/src/generated/resources/data/sophisticatedbackpacks/advancement/recipes/misc/advanced_jukebox_upgrade.json @@ -0,0 +1,38 @@ +{ + "neoforge:conditions": [ + { + "type": "sophisticatedcore:item_enabled", + "itemRegistryName": "sophisticatedbackpacks:advanced_jukebox_upgrade" + } + ], + "parent": "minecraft:recipes/root", + "criteria": { + "has_jukebox_upgrade": { + "conditions": { + "items": [ + { + "items": "sophisticatedbackpacks:jukebox_upgrade" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "sophisticatedbackpacks:advanced_jukebox_upgrade" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_jukebox_upgrade" + ] + ], + "rewards": { + "recipes": [ + "sophisticatedbackpacks:advanced_jukebox_upgrade" + ] + } +} \ No newline at end of file diff --git a/src/generated/resources/data/sophisticatedbackpacks/recipe/advanced_jukebox_upgrade.json b/src/generated/resources/data/sophisticatedbackpacks/recipe/advanced_jukebox_upgrade.json new file mode 100644 index 00000000..7b4d80c8 --- /dev/null +++ b/src/generated/resources/data/sophisticatedbackpacks/recipe/advanced_jukebox_upgrade.json @@ -0,0 +1,33 @@ +{ + "neoforge:conditions": [ + { + "type": "sophisticatedcore:item_enabled", + "itemRegistryName": "sophisticatedbackpacks:advanced_jukebox_upgrade" + } + ], + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "D": { + "tag": "c:gems/diamond" + }, + "G": { + "tag": "c:ingots/gold" + }, + "J": { + "item": "sophisticatedbackpacks:jukebox_upgrade" + }, + "R": { + "tag": "c:dusts/redstone" + } + }, + "pattern": [ + " D ", + "GJG", + "RRR" + ], + "result": { + "count": 1, + "id": "sophisticatedbackpacks:advanced_jukebox_upgrade" + } +} \ No newline at end of file diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java index 04511e34..eaf2a051 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java @@ -12,7 +12,6 @@ import net.neoforged.fml.event.config.ModConfigEvent; import net.neoforged.neoforge.common.ModConfigSpec; import net.p3pp3rf1y.sophisticatedbackpacks.backpack.BackpackItem; -import net.p3pp3rf1y.sophisticatedbackpacks.init.ModItems; import net.p3pp3rf1y.sophisticatedcore.upgrades.FilteredUpgradeConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.IUpgradeCountLimitConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeGroup; @@ -20,6 +19,8 @@ import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.AutoCookingUpgradeConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.CookingUpgradeConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.ICookingUpgrade; +import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeConfig; +import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeItem; import net.p3pp3rf1y.sophisticatedcore.upgrades.magnet.MagnetUpgradeConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.pump.PumpUpgradeConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.stack.StackUpgradeConfig; @@ -106,6 +107,7 @@ public static class Server { public final StackUpgradeConfig stackUpgrade; public final PumpUpgradeConfig pumpUpgrade; public final XpPumpUpgradeConfig xpPumpUpgrade; + public final JukeboxUpgradeConfig advancedJukeboxUpgrade; public final NerfsConfig nerfsConfig; public final MaxUgradesPerStorageConfig maxUpgradesPerStorage; @@ -177,13 +179,14 @@ private void clearCache() { batteryUpgrade = new BatteryUpgradeConfig(builder); pumpUpgrade = new PumpUpgradeConfig(builder); xpPumpUpgrade = new XpPumpUpgradeConfig(builder); + advancedJukeboxUpgrade = new JukeboxUpgradeConfig(builder, "Advanced Jukebox Upgrade", "advancedJukeboxUpgrade", 12); entityBackpackAdditions = new EntityBackpackAdditionsConfig(builder); nerfsConfig = new NerfsConfig(builder); maxUpgradesPerStorage = new MaxUgradesPerStorageConfig(builder, Map.of( StackUpgradeItem.UPGRADE_GROUP.name(), 3, ICookingUpgrade.UPGRADE_GROUP.name(), 1, - ModItems.JUKEBOX_UPGRADE_NAME, 1 + JukeboxUpgradeItem.UPGRADE_GROUP.name(), 1 ) ); diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/EntityBackpackAdditionHandler.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/EntityBackpackAdditionHandler.java index 2f665c9e..688a4c5f 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/EntityBackpackAdditionHandler.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/EntityBackpackAdditionHandler.java @@ -42,6 +42,7 @@ import net.p3pp3rf1y.sophisticatedbackpacks.init.ModItems; import net.p3pp3rf1y.sophisticatedcore.api.IStorageWrapper; import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeItem; +import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeWrapper; import net.p3pp3rf1y.sophisticatedcore.util.RandHelper; import net.p3pp3rf1y.sophisticatedcore.util.WeightedElement; @@ -159,7 +160,7 @@ private static void equipBackpack(Monster monster, ItemStack backpack, int diffi wrapper.getInventoryHandler(); //just to assign uuid and real upgrade handler if (wrapper.getUpgradeHandler().getSlots() > 0) { monster.addTag(SPAWNED_WITH_JUKEBOX_UPGRADE); - addJukeboxUpgradeAndRandomDisc(wrapper, rnd); + addJukeboxUpgradeAndRandomDisc(level.getRandom(), wrapper, rnd); } } }); @@ -167,12 +168,16 @@ private static void equipBackpack(Monster monster, ItemStack backpack, int diffi monster.setDropChance(EquipmentSlot.CHEST, 0); } - private static void addJukeboxUpgradeAndRandomDisc(IStorageWrapper w, RandomSource rnd) { - w.getUpgradeHandler().setStackInSlot(0, new ItemStack(ModItems.JUKEBOX_UPGRADE.get())); - Iterator it = w.getUpgradeHandler().getTypeWrappers(JukeboxUpgradeItem.TYPE).iterator(); + private static void addJukeboxUpgradeAndRandomDisc(RandomSource random, IStorageWrapper w, RandomSource rnd) { + boolean advancedJukebox = random.nextFloat() < 0.25; + w.getUpgradeHandler().setStackInSlot(0, new ItemStack(advancedJukebox ? ModItems.ADVANCED_JUKEBOX_UPGRADE.get() : ModItems.JUKEBOX_UPGRADE.get())); + Iterator it = w.getUpgradeHandler().getTypeWrappers(JukeboxUpgradeItem.TYPE).iterator(); if (it.hasNext()) { - JukeboxUpgradeItem.Wrapper wrapper = it.next(); - wrapper.setDisc(new ItemStack(getMusicDiscs().get(rnd.nextInt(getMusicDiscs().size())))); + JukeboxUpgradeWrapper wrapper = it.next(); + int numberOfDiscs = advancedJukebox ? random.nextInt(wrapper.getDiscInventory().getSlots() / 3) + 1 : 1; + for (int i = 0; i < numberOfDiscs; i++) { + wrapper.getDiscInventory().insertItem(i, new ItemStack(getMusicDiscs().get(rnd.nextInt(getMusicDiscs().size())), 1), false); + } } } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/data/SBPRecipeProvider.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/data/SBPRecipeProvider.java index 01e1457c..0a487e9b 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/data/SBPRecipeProvider.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/data/SBPRecipeProvider.java @@ -437,6 +437,17 @@ protected void buildRecipes(RecipeOutput recipeOutput) { .unlockedBy(HAS_UPGRADE_BASE, has(ModItems.UPGRADE_BASE.get())) .save(recipeOutput); + ShapeBasedRecipeBuilder.shaped(ModItems.ADVANCED_JUKEBOX_UPGRADE.get()) + .pattern(" D ") + .pattern("GJG") + .pattern("RRR") + .define('D', Tags.Items.GEMS_DIAMOND) + .define('G', Tags.Items.INGOTS_GOLD) + .define('R', Tags.Items.DUSTS_REDSTONE) + .define('J', ModItems.JUKEBOX_UPGRADE.get()) + .unlockedBy("has_jukebox_upgrade", has(ModItems.JUKEBOX_UPGRADE.get())) + .save(recipeOutput); + ShapeBasedRecipeBuilder.shaped(ModItems.TOOL_SWAPPER_UPGRADE.get()) .pattern("RWR") .pattern("PBA") diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java index ef1625e0..6d4a4a4d 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java @@ -96,6 +96,7 @@ import net.p3pp3rf1y.sophisticatedcore.upgrades.filter.FilterUpgradeItem; import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeContainer; import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeItem; +import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeWrapper; import net.p3pp3rf1y.sophisticatedcore.upgrades.magnet.MagnetUpgradeContainer; import net.p3pp3rf1y.sophisticatedcore.upgrades.magnet.MagnetUpgradeItem; import net.p3pp3rf1y.sophisticatedcore.upgrades.magnet.MagnetUpgradeWrapper; @@ -214,8 +215,8 @@ private ModItems() { new StackUpgradeItem(8, Config.SERVER.maxUpgradesPerStorage)); public static final DeferredHolder STACK_UPGRADE_TIER_4 = ITEMS.register("stack_upgrade_tier_4", () -> new StackUpgradeItem(16, Config.SERVER.maxUpgradesPerStorage)); - public static final String JUKEBOX_UPGRADE_NAME = "jukebox_upgrade"; - public static final DeferredHolder JUKEBOX_UPGRADE = ITEMS.register(JUKEBOX_UPGRADE_NAME, () -> new JukeboxUpgradeItem(Config.SERVER.maxUpgradesPerStorage)); + public static final DeferredHolder JUKEBOX_UPGRADE = ITEMS.register("jukebox_upgrade", () -> new JukeboxUpgradeItem(Config.SERVER.maxUpgradesPerStorage, () -> 1, () -> 1)); + public static final DeferredHolder ADVANCED_JUKEBOX_UPGRADE = ITEMS.register("advanced_jukebox_upgrade", () -> new JukeboxUpgradeItem(Config.SERVER.maxUpgradesPerStorage, Config.SERVER.advancedJukeboxUpgrade.numberOfSlots, Config.SERVER.advancedJukeboxUpgrade.slotsInRow)); public static final DeferredHolder TOOL_SWAPPER_UPGRADE = ITEMS.register("tool_swapper_upgrade", () -> new ToolSwapperUpgradeItem(false, false)); public static final DeferredHolder ADVANCED_TOOL_SWAPPER_UPGRADE = ITEMS.register("advanced_tool_swapper_upgrade", @@ -303,7 +304,8 @@ public static void registerHandlers(IEventBus modBus) { public static final UpgradeContainerType CRAFTING_TYPE = new UpgradeContainerType<>(CraftingUpgradeContainer::new); public static final UpgradeContainerType INCEPTION_TYPE = new UpgradeContainerType<>(InceptionUpgradeContainer::new); public static final UpgradeContainerType STONECUTTER_TYPE = new UpgradeContainerType<>(StonecutterUpgradeContainer::new); - public static final UpgradeContainerType JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new); + public static final UpgradeContainerType JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new); + public static final UpgradeContainerType ADVANCED_JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new); public static final UpgradeContainerType TOOL_SWAPPER_TYPE = new UpgradeContainerType<>(ToolSwapperUpgradeContainer::new); public static final UpgradeContainerType TANK_TYPE = new UpgradeContainerType<>(TankUpgradeContainer::new); public static final UpgradeContainerType BATTERY_TYPE = new UpgradeContainerType<>(BatteryUpgradeContainer::new); @@ -346,6 +348,7 @@ public static void registerContainers(RegisterEvent event) { UpgradeContainerRegistry.register(INCEPTION_UPGRADE.getId(), INCEPTION_TYPE); UpgradeContainerRegistry.register(STONECUTTER_UPGRADE.getId(), STONECUTTER_TYPE); UpgradeContainerRegistry.register(JUKEBOX_UPGRADE.getId(), JUKEBOX_TYPE); + UpgradeContainerRegistry.register(ADVANCED_JUKEBOX_UPGRADE.getId(), ADVANCED_JUKEBOX_TYPE); UpgradeContainerRegistry.register(ADVANCED_TOOL_SWAPPER_UPGRADE.getId(), TOOL_SWAPPER_TYPE); UpgradeContainerRegistry.register(TANK_UPGRADE.getId(), TANK_TYPE); UpgradeContainerRegistry.register(BATTERY_UPGRADE.getId(), BATTERY_TYPE); diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItemsClient.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItemsClient.java index 1dbc1c74..8d031093 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItemsClient.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItemsClient.java @@ -36,6 +36,7 @@ import net.p3pp3rf1y.sophisticatedcore.upgrades.feeding.FeedingUpgradeTab; import net.p3pp3rf1y.sophisticatedcore.upgrades.filter.FilterUpgradeContainer; import net.p3pp3rf1y.sophisticatedcore.upgrades.filter.FilterUpgradeTab; +import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeContainer; import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeTab; import net.p3pp3rf1y.sophisticatedcore.upgrades.magnet.MagnetUpgradeContainer; import net.p3pp3rf1y.sophisticatedcore.upgrades.magnet.MagnetUpgradeTab; @@ -108,7 +109,8 @@ private static void onMenuScreenRegister(RegisterMenuScreensEvent event) { UpgradeGuiManager.registerTab(ModItems.INCEPTION_TYPE, InceptionUpgradeTab::new); UpgradeGuiManager.registerTab(ModItems.STONECUTTER_TYPE, (StonecutterUpgradeContainer upgradeContainer, Position position, StorageScreenBase screen) -> new StonecutterUpgradeTab(upgradeContainer, position, screen, SBPButtonDefinitions.SHIFT_CLICK_TARGET)); - UpgradeGuiManager.registerTab(ModItems.JUKEBOX_TYPE, JukeboxUpgradeTab::new); + UpgradeGuiManager.registerTab(ModItems.JUKEBOX_TYPE, JukeboxUpgradeTab.Basic::new); + UpgradeGuiManager.registerTab(ModItems.ADVANCED_JUKEBOX_TYPE, (JukeboxUpgradeContainer uc, Position p, StorageScreenBase s) -> new JukeboxUpgradeTab.Advanced(uc, p, s, Config.SERVER.advancedJukeboxUpgrade.slotsInRow.get())); UpgradeGuiManager.registerTab(ModItems.TOOL_SWAPPER_TYPE, ToolSwapperUpgradeTab::new); UpgradeGuiManager.registerTab(ModItems.TANK_TYPE, TankUpgradeTab::new); UpgradeGuiManager.registerTab(ModItems.BATTERY_TYPE, BatteryUpgradeTab::new); diff --git a/src/main/resources/assets/sophisticatedbackpacks/lang/en_us.json b/src/main/resources/assets/sophisticatedbackpacks/lang/en_us.json index 6dba804a..4de2abe6 100644 --- a/src/main/resources/assets/sophisticatedbackpacks/lang/en_us.json +++ b/src/main/resources/assets/sophisticatedbackpacks/lang/en_us.json @@ -71,6 +71,8 @@ "item.sophisticatedbackpacks.stonecutter_upgrade.tooltip": "Stonecutter in an upgrade tab", "item.sophisticatedbackpacks.jukebox_upgrade": "Jukebox Upgrade", "item.sophisticatedbackpacks.jukebox_upgrade.tooltip": "Portable Jukebox", + "item.sophisticatedbackpacks.advanced_jukebox_upgrade": "Advanced Jukebox Upgrade", + "item.sophisticatedbackpacks.advanced_jukebox_upgrade.tooltip": "Portable Jukebox with support for more music discs\nAlso more playback options", "item.sophisticatedbackpacks.stack_upgrade_starter_tier": "Stack Upgrade Starter Tier", "item.sophisticatedbackpacks.stack_upgrade_starter_tier.tooltip": "Multiplies the number of stacks that can fit in a slot by 1.5", "item.sophisticatedbackpacks.stack_upgrade_tier_1": "Stack Upgrade Tier 1", diff --git a/src/main/resources/assets/sophisticatedbackpacks/models/item/advanced_jukebox_upgrade.json b/src/main/resources/assets/sophisticatedbackpacks/models/item/advanced_jukebox_upgrade.json new file mode 100644 index 00000000..a7d74855 --- /dev/null +++ b/src/main/resources/assets/sophisticatedbackpacks/models/item/advanced_jukebox_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "sophisticatedbackpacks:item/advanced_jukebox_upgrade" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/sophisticatedbackpacks/textures/item/advanced_jukebox_upgrade.png b/src/main/resources/assets/sophisticatedbackpacks/textures/item/advanced_jukebox_upgrade.png new file mode 100644 index 0000000000000000000000000000000000000000..e1bb3e725e9073475d49a0f8d9bc73e0966447fb GIT binary patch literal 304 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`-#uL%Lo7}wCoB*!FfuSO__IIp zyS$pftNP|fAW$s7meqDLbD_kWtJ0&R359tJdr^IJ5r`kLzLN=MiPGJrwA;OXk;vd$@?2>_x@b?yKF literal 0 HcmV?d00001