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 ce53eca commit 10009d0
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 31 deletions.
13 changes: 3 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
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;
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 @@ -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;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -155,21 +150,25 @@ 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);
}
}
}));
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();
List<RecordItem> 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);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,17 @@ protected void buildRecipes(Consumer<FinishedRecipe> 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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -233,8 +234,8 @@ private ModItems() {
new StackUpgradeItem(8, Config.SERVER.maxUpgradesPerStorage));
public static final RegistryObject<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 RegistryObject<JukeboxUpgradeItem> JUKEBOX_UPGRADE = ITEMS.register(JUKEBOX_UPGRADE_NAME, () -> new JukeboxUpgradeItem(Config.SERVER.maxUpgradesPerStorage));
public static final RegistryObject<JukeboxUpgradeItem> JUKEBOX_UPGRADE = ITEMS.register("jukebox_upgrade", () -> new JukeboxUpgradeItem(Config.SERVER.maxUpgradesPerStorage, () -> 1, () -> 1));
public static final RegistryObject<JukeboxUpgradeItem> 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<ToolSwapperUpgradeItem> TOOL_SWAPPER_UPGRADE = ITEMS.register("tool_swapper_upgrade",
() -> new ToolSwapperUpgradeItem(false, false));
public static final RegistryObject<ToolSwapperUpgradeItem> ADVANCED_TOOL_SWAPPER_UPGRADE = ITEMS.register("advanced_tool_swapper_upgrade",
Expand Down Expand Up @@ -320,7 +321,8 @@ private static void onResourceReload(AddReloadListenerEvent event) {
private static final UpgradeContainerType<CraftingUpgradeWrapper, CraftingUpgradeContainer> CRAFTING_TYPE = new UpgradeContainerType<>(CraftingUpgradeContainer::new);
private static final UpgradeContainerType<InceptionUpgradeWrapper, InceptionUpgradeContainer> INCEPTION_TYPE = new UpgradeContainerType<>(InceptionUpgradeContainer::new);
private static final UpgradeContainerType<StonecutterUpgradeWrapper, StonecutterUpgradeContainer> STONECUTTER_TYPE = new UpgradeContainerType<>(StonecutterUpgradeContainer::new);
private static final UpgradeContainerType<JukeboxUpgradeItem.Wrapper, JukeboxUpgradeContainer> JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new);
private static final UpgradeContainerType<JukeboxUpgradeWrapper, JukeboxUpgradeContainer> JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new);
private static final UpgradeContainerType<JukeboxUpgradeWrapper, JukeboxUpgradeContainer> ADVANCED_JUKEBOX_TYPE = new UpgradeContainerType<>(JukeboxUpgradeContainer::new);
private static final UpgradeContainerType<ToolSwapperUpgradeWrapper, ToolSwapperUpgradeContainer> TOOL_SWAPPER_TYPE = new UpgradeContainerType<>(ToolSwapperUpgradeContainer::new);
private static final UpgradeContainerType<TankUpgradeWrapper, TankUpgradeContainer> TANK_TYPE = new UpgradeContainerType<>(TankUpgradeContainer::new);
private static final UpgradeContainerType<BatteryUpgradeWrapper, BatteryUpgradeContainer> BATTERY_TYPE = new UpgradeContainerType<>(BatteryUpgradeContainer::new);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
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 10009d0

Please sign in to comment.