Skip to content

Commit

Permalink
feat: ✨ Added advanced jukebox upgrade
Browse files Browse the repository at this point in the history
- Has multiple slots that can hold music discs and plays them one by one
- Has controls to go skip between discs played
- Allows playing discs in random order by using Shuffle toggle
- Allows repeating all or the current disc played
- Mobs that spawn with jukebox in their backpack will now sometimes have an advanced one with possibly more than one disc in them
  • Loading branch information
P3pp3rF1y committed Jan 8, 2025
1 parent 2d3ccc0 commit 07932d0
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 14 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
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;
import net.p3pp3rf1y.sophisticatedcore.upgrades.battery.BatteryUpgradeConfig;
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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -159,20 +160,24 @@ 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);
}
}
});
monster.setItemSlot(EquipmentSlot.CHEST, backpack);
monster.setDropChance(EquipmentSlot.CHEST, 0);
}

private static void addJukeboxUpgradeAndRandomDisc(IStorageWrapper w, RandomSource rnd) {
w.getUpgradeHandler().setStackInSlot(0, new ItemStack(ModItems.JUKEBOX_UPGRADE.get()));
Iterator<JukeboxUpgradeItem.Wrapper> 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<JukeboxUpgradeWrapper> 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);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -214,8 +215,8 @@ private ModItems() {
new StackUpgradeItem(8, Config.SERVER.maxUpgradesPerStorage));
public static final DeferredHolder<Item, StackUpgradeItem> 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<Item, JukeboxUpgradeItem> JUKEBOX_UPGRADE = ITEMS.register(JUKEBOX_UPGRADE_NAME, () -> new JukeboxUpgradeItem(Config.SERVER.maxUpgradesPerStorage));
public static final DeferredHolder<Item, JukeboxUpgradeItem> JUKEBOX_UPGRADE = ITEMS.register("jukebox_upgrade", () -> new JukeboxUpgradeItem(Config.SERVER.maxUpgradesPerStorage, () -> 1, () -> 1));
public static final DeferredHolder<Item, JukeboxUpgradeItem> 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<Item, ToolSwapperUpgradeItem> TOOL_SWAPPER_UPGRADE = ITEMS.register("tool_swapper_upgrade",
() -> new ToolSwapperUpgradeItem(false, false));
public static final DeferredHolder<Item, ToolSwapperUpgradeItem> ADVANCED_TOOL_SWAPPER_UPGRADE = ITEMS.register("advanced_tool_swapper_upgrade",
Expand Down Expand Up @@ -303,7 +304,8 @@ public static void registerHandlers(IEventBus modBus) {
public static final UpgradeContainerType<CraftingUpgradeWrapper, CraftingUpgradeContainer> CRAFTING_TYPE = new UpgradeContainerType<>(CraftingUpgradeContainer::new);
public static final UpgradeContainerType<InceptionUpgradeWrapper, InceptionUpgradeContainer> INCEPTION_TYPE = new UpgradeContainerType<>(InceptionUpgradeContainer::new);
public static final UpgradeContainerType<StonecutterUpgradeWrapper, StonecutterUpgradeContainer> STONECUTTER_TYPE = new UpgradeContainerType<>(StonecutterUpgradeContainer::new);
public static final UpgradeContainerType<JukeboxUpgradeItem.Wrapper, JukeboxUpgradeContainer> JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new);
public static final UpgradeContainerType<JukeboxUpgradeWrapper, JukeboxUpgradeContainer> JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new);
public static final UpgradeContainerType<JukeboxUpgradeWrapper, JukeboxUpgradeContainer> ADVANCED_JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new);
public static final UpgradeContainerType<ToolSwapperUpgradeWrapper, ToolSwapperUpgradeContainer> TOOL_SWAPPER_TYPE = new UpgradeContainerType<>(ToolSwapperUpgradeContainer::new);
public static final UpgradeContainerType<TankUpgradeWrapper, TankUpgradeContainer> TANK_TYPE = new UpgradeContainerType<>(TankUpgradeContainer::new);
public static final UpgradeContainerType<BatteryUpgradeWrapper, BatteryUpgradeContainer> BATTERY_TYPE = new UpgradeContainerType<>(BatteryUpgradeContainer::new);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "sophisticatedbackpacks:item/advanced_jukebox_upgrade"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 07932d0

Please sign in to comment.