From 10009d051ca5d785770fa7a77e95416a49f2f215 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Wed, 8 Jan 2025 20:36:04 +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 --- build.gradle | 13 ++----- gradle.properties | 4 +- .../misc/advanced_jukebox_upgrade.json | 35 ++++++++++++++++++ .../recipes/advanced_jukebox_upgrade.json | 31 ++++++++++++++++ .../sophisticatedbackpacks/Config.java | 7 +++- .../common/EntityBackpackAdditionHandler.java | 25 ++++++------- .../data/SBPRecipeProvider.java | 11 ++++++ .../sophisticatedbackpacks/init/ModItems.java | 12 ++++-- .../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, 115 insertions(+), 31 deletions(-) create mode 100644 src/generated/resources/data/sophisticatedbackpacks/advancements/recipes/misc/advanced_jukebox_upgrade.json create mode 100644 src/generated/resources/data/sophisticatedbackpacks/recipes/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/build.gradle b/build.gradle index 5e6e7a47..7a600c62 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ repositories { } group = mod_group_id -version = "${project.minecraft_version}-${project.mod_version}.${getBuildNumber()}${getStable()}" +version = "${project.minecraft_version}-${project.mod_version}.${getBuildNumber()}" archivesBaseName = mod_id sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '17' @@ -155,7 +155,7 @@ tasks.withType(ProcessResources).configureEach { neo_version : neo_version, neo_version_range: neo_version_range, loader_version_range: loader_version_range, mod_id : mod_id, mod_version: mod_version, - mod_full_version : "${project.mod_version}.${getBuildNumber()}${getStable()}", + mod_full_version : "${project.mod_version}.${getBuildNumber()}", sc_version : sc_version.substring(sc_version.indexOf("-") + 1, sc_version.lastIndexOf(',')) + ".+" ] inputs.properties replaceProperties @@ -169,14 +169,7 @@ static def getBuildNumber() { if (System.getenv("GITHUB_RUN_NUMBER") != null) { return System.getenv("GITHUB_RUN_NUMBER").toString() } - return "" -} - -static def getStable() { - if (System.getenv("GITHUB_REF") == null || System.getenv("GITHUB_REF").endsWith("-dev")) { - return "-SNAPSHOT" - } - return "" + return "1" } tasks.named('publish').configure { diff --git a/gradle.properties b/gradle.properties index a03db307..af880875 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false mod_id=sophisticatedbackpacks mod_group_id=sophisticatedbackpacks -mod_version=3.21.2 +mod_version=3.22.0 sonar_project_key=sophisticatedbackpacks:SophisticatedBackpacks github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedBackpacks @@ -31,5 +31,5 @@ crafting_tweaks_cf_file_id=4596466 chipped_cf_file_id=5077656 resourcefullib_cf_file_id=5070629 athena_cf_file_id=4764357 -sc_version=[1.20.1-1.0.5,1.20.4) +sc_version=[1.20.1-1.1.0,1.20.4) parchment_version=2023.09.03-1.20.1 \ No newline at end of file diff --git a/src/generated/resources/data/sophisticatedbackpacks/advancements/recipes/misc/advanced_jukebox_upgrade.json b/src/generated/resources/data/sophisticatedbackpacks/advancements/recipes/misc/advanced_jukebox_upgrade.json new file mode 100644 index 00000000..aead9acd --- /dev/null +++ b/src/generated/resources/data/sophisticatedbackpacks/advancements/recipes/misc/advanced_jukebox_upgrade.json @@ -0,0 +1,35 @@ +{ + "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_jukebox_upgrade", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "sophisticatedbackpacks:advanced_jukebox_upgrade" + ] + }, + "sends_telemetry_event": true +} \ No newline at end of file diff --git a/src/generated/resources/data/sophisticatedbackpacks/recipes/advanced_jukebox_upgrade.json b/src/generated/resources/data/sophisticatedbackpacks/recipes/advanced_jukebox_upgrade.json new file mode 100644 index 00000000..78034120 --- /dev/null +++ b/src/generated/resources/data/sophisticatedbackpacks/recipes/advanced_jukebox_upgrade.json @@ -0,0 +1,31 @@ +{ + "type": "minecraft:crafting_shaped", + "conditions": [ + { + "type": "sophisticatedcore:item_enabled", + "itemRegistryName": "sophisticatedbackpacks:advanced_jukebox_upgrade" + } + ], + "key": { + "D": { + "tag": "forge:gems/diamond" + }, + "G": { + "tag": "forge:ingots/gold" + }, + "J": { + "item": "sophisticatedbackpacks:jukebox_upgrade" + }, + "R": { + "tag": "forge:dusts/redstone" + } + }, + "pattern": [ + " D ", + "GJG", + "RRR" + ], + "result": { + "item": "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 79f19100..f33f515d 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java @@ -10,7 +10,6 @@ import net.minecraftforge.fml.event.config.ModConfigEvent; import net.minecraftforge.registries.ForgeRegistries; 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; @@ -18,6 +17,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; @@ -104,6 +105,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; @@ -175,13 +177,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 f41f6a92..2cde31af 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/EntityBackpackAdditionHandler.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/EntityBackpackAdditionHandler.java @@ -33,16 +33,11 @@ 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; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; public class EntityBackpackAdditionHandler { private static final int MAX_DIFFICULTY = 3; @@ -155,7 +150,7 @@ private static void equipBackpack(Monster monster, ItemStack backpack, int diffi w.getInventoryHandler(); //just to assign uuid and real upgrade handler if (w.getUpgradeHandler().getSlots() > 0) { monster.addTag(SPAWNED_WITH_JUKEBOX_UPGRADE); - addJukeboxUpgradeAndRandomDisc(w, rnd); + addJukeboxUpgradeAndRandomDisc(level.getRandom(), w, rnd); } } })); @@ -163,13 +158,17 @@ 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(); List musicDiscs = getMusicDiscs(); - wrapper.setDisc(new ItemStack(musicDiscs.get(rnd.nextInt(musicDiscs.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(musicDiscs.get(rnd.nextInt(musicDiscs.size()))), false); + } } } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/data/SBPRecipeProvider.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/data/SBPRecipeProvider.java index a6c9134e..a3b5b3e1 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/data/SBPRecipeProvider.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/data/SBPRecipeProvider.java @@ -432,6 +432,17 @@ protected void buildRecipes(Consumer consumer) { .unlockedBy(HAS_UPGRADE_BASE, has(ModItems.UPGRADE_BASE.get())) .save(consumer); + 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(consumer); + 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 7cf453ae..5b9eda68 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java @@ -113,6 +113,7 @@ import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeContainer; import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeItem; import net.p3pp3rf1y.sophisticatedcore.upgrades.jukebox.JukeboxUpgradeTab; +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.MagnetUpgradeTab; @@ -233,8 +234,8 @@ private ModItems() { new StackUpgradeItem(8, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject 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 RegistryObject JUKEBOX_UPGRADE = ITEMS.register(JUKEBOX_UPGRADE_NAME, () -> new JukeboxUpgradeItem(Config.SERVER.maxUpgradesPerStorage)); + public static final RegistryObject JUKEBOX_UPGRADE = ITEMS.register("jukebox_upgrade", () -> new JukeboxUpgradeItem(Config.SERVER.maxUpgradesPerStorage, () -> 1, () -> 1)); + public static final RegistryObject ADVANCED_JUKEBOX_UPGRADE = ITEMS.register("advanced_jukebox_upgrade", () -> new JukeboxUpgradeItem(Config.SERVER.maxUpgradesPerStorage, Config.SERVER.advancedJukeboxUpgrade.numberOfSlots::get, Config.SERVER.advancedJukeboxUpgrade.slotsInRow::get)); public static final RegistryObject TOOL_SWAPPER_UPGRADE = ITEMS.register("tool_swapper_upgrade", () -> new ToolSwapperUpgradeItem(false, false)); public static final RegistryObject ADVANCED_TOOL_SWAPPER_UPGRADE = ITEMS.register("advanced_tool_swapper_upgrade", @@ -320,7 +321,8 @@ private static void onResourceReload(AddReloadListenerEvent event) { private static final UpgradeContainerType CRAFTING_TYPE = new UpgradeContainerType<>(CraftingUpgradeContainer::new); private static final UpgradeContainerType INCEPTION_TYPE = new UpgradeContainerType<>(InceptionUpgradeContainer::new); private static final UpgradeContainerType STONECUTTER_TYPE = new UpgradeContainerType<>(StonecutterUpgradeContainer::new); - private static final UpgradeContainerType JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new); + private static final UpgradeContainerType JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new); + private static final UpgradeContainerType ADVANCED_JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new); private static final UpgradeContainerType TOOL_SWAPPER_TYPE = new UpgradeContainerType<>(ToolSwapperUpgradeContainer::new); private static final UpgradeContainerType TANK_TYPE = new UpgradeContainerType<>(TankUpgradeContainer::new); private static final UpgradeContainerType BATTERY_TYPE = new UpgradeContainerType<>(BatteryUpgradeContainer::new); @@ -363,6 +365,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); @@ -424,7 +427,8 @@ public static void registerContainers(RegisterEvent event) { UpgradeGuiManager.registerTab(INCEPTION_TYPE, InceptionUpgradeTab::new); UpgradeGuiManager.registerTab(STONECUTTER_TYPE, (StonecutterUpgradeContainer upgradeContainer, Position position, StorageScreenBase screen) -> new StonecutterUpgradeTab(upgradeContainer, position, screen, SBPButtonDefinitions.SHIFT_CLICK_TARGET)); - UpgradeGuiManager.registerTab(JUKEBOX_TYPE, JukeboxUpgradeTab::new); + UpgradeGuiManager.registerTab(JUKEBOX_TYPE, JukeboxUpgradeTab.Basic::new); + UpgradeGuiManager.registerTab(ADVANCED_JUKEBOX_TYPE, (JukeboxUpgradeContainer uc, Position p, StorageScreenBase s) -> new JukeboxUpgradeTab.Advanced(uc, p, s, Config.SERVER.advancedJukeboxUpgrade.slotsInRow.get())); UpgradeGuiManager.registerTab(TOOL_SWAPPER_TYPE, ToolSwapperUpgradeTab::new); UpgradeGuiManager.registerTab(TANK_TYPE, TankUpgradeTab::new); UpgradeGuiManager.registerTab(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 e71a5988..414b4253 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