Skip to content

Commit

Permalink
Merge pull request #1023 from P3pp3rF1y/1.20.x-dev
Browse files Browse the repository at this point in the history
Release merge
  • Loading branch information
P3pp3rF1y authored Apr 6, 2024
2 parents 6158652 + 81ca958 commit a44ec24
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 27 deletions.
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.20.3
mod_version=3.20.5
sonar_project_key=sophisticatedbackpacks:SophisticatedBackpacks
github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedBackpacks

Expand All @@ -25,5 +25,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-0.6.0,1.21)
sc_version=[1.20.1-0.6.17,1.20.4)
parchment_version=1.19.3-2023.03.12-1.20
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ private Comparator<Map.Entry<ItemStackKey, Integer>> getComparator() {
case COUNT -> InventorySorter.BY_COUNT;
case TAGS -> InventorySorter.BY_TAGS;
case NAME -> InventorySorter.BY_NAME;
case MOD -> InventorySorter.BY_MOD;
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.anvil;

import net.minecraft.world.item.CreativeModeTab;
import net.p3pp3rf1y.sophisticatedbackpacks.Config;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeType;

import java.util.List;

public class AnvilUpgradeItem extends UpgradeItemBase<AnvilUpgradeWrapper> {
private static final UpgradeType<AnvilUpgradeWrapper> TYPE = new UpgradeType<>(AnvilUpgradeWrapper::new);
public AnvilUpgradeItem() {
Expand All @@ -15,4 +16,9 @@ public AnvilUpgradeItem() {
public UpgradeType<AnvilUpgradeWrapper> getType() {
return TYPE;
}

@Override
public List<UpgradeConflictDefinition> getUpgradeConflicts() {
return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeType;

import java.util.List;
import java.util.function.IntSupplier;

public class DepositUpgradeItem extends UpgradeItemBase<DepositUpgradeWrapper> {
Expand All @@ -20,6 +21,11 @@ public UpgradeType<DepositUpgradeWrapper> getType() {
return TYPE;
}

@Override
public List<UpgradeConflictDefinition> getUpgradeConflicts() {
return List.of();
}

public int getFilterSlotCount() {
return filterSlotCount.getAsInt();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

import net.minecraft.world.item.ItemStack;
import net.p3pp3rf1y.sophisticatedbackpacks.Config;
import net.p3pp3rf1y.sophisticatedbackpacks.client.gui.SBPTranslationHelper;
import net.p3pp3rf1y.sophisticatedcore.api.IStorageWrapper;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeType;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeWrapperBase;

import java.util.List;
import java.util.function.Consumer;

public class EverlastingUpgradeItem extends UpgradeItemBase<EverlastingUpgradeItem.Wrapper> {
public static final UpgradeType<Wrapper> TYPE = new UpgradeType<>(Wrapper::new);
public static final List<UpgradeConflictDefinition> UPGRADE_CONFLICT_DEFINITIONS = List.of(new UpgradeConflictDefinition(EverlastingUpgradeItem.class::isInstance, 0, SBPTranslationHelper.INSTANCE.translError("add.everlasting_exists")));

public EverlastingUpgradeItem() {
super(Config.SERVER.maxUpgradesPerStorage);
Expand All @@ -21,6 +24,11 @@ public UpgradeType<Wrapper> getType() {
return TYPE;
}

@Override
public List<UpgradeConflictDefinition> getUpgradeConflicts() {
return UPGRADE_CONFLICT_DEFINITIONS;
}

public static class Wrapper extends UpgradeWrapperBase<Wrapper, EverlastingUpgradeItem> {
public Wrapper(IStorageWrapper backpackWrapper, ItemStack upgrade, Consumer<ItemStack> upgradeSaveHandler) {
super(backpackWrapper, upgrade, upgradeSaveHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class InceptionUpgradeItem extends UpgradeItemBase<InceptionUpgradeWrapper> {
public static final UpgradeType<InceptionUpgradeWrapper> TYPE = new UpgradeType<>(InceptionUpgradeWrapper::new);
public static final List<UpgradeConflictDefinition> UPGRADE_CONFLICT_DEFINITIONS = List.of(new UpgradeConflictDefinition(InceptionUpgradeItem.class::isInstance, 0, SBPTranslationHelper.INSTANCE.translError("add.inception_exists")));

public InceptionUpgradeItem() {
super(Config.SERVER.maxUpgradesPerStorage);
}
super(Config.SERVER.maxUpgradesPerStorage);
}

@Override
public UpgradeType<InceptionUpgradeWrapper> getType() {
Expand Down Expand Up @@ -51,6 +53,11 @@ public UpgradeSlotChangeResult canAddUpgradeTo(IStorageWrapper storageWrapper, I
return new UpgradeSlotChangeResult.Success();
}

@Override
public List<UpgradeConflictDefinition> getUpgradeConflicts() {
return UPGRADE_CONFLICT_DEFINITIONS;
}

@Override
public UpgradeSlotChangeResult canRemoveUpgradeFrom(IStorageWrapper storageWrapper, boolean isClientSide) {
Set<Integer> slots = InventoryHelper.getItemSlots(storageWrapper.getInventoryHandler(), stack -> stack.getItem() instanceof BackpackItem);
Expand All @@ -59,4 +66,13 @@ public UpgradeSlotChangeResult canRemoveUpgradeFrom(IStorageWrapper storageWrapp
}
return new UpgradeSlotChangeResult.Success();
}

@Override
public UpgradeSlotChangeResult canSwapUpgradeFor(ItemStack upgradeStackToPut, int upgradeSlot, IStorageWrapper storageWrapper, boolean isClientSide) {
if (upgradeStackToPut.getItem() == this) {
return new UpgradeSlotChangeResult.Success();
}

return canRemoveUpgradeFrom(storageWrapper, isClientSide);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeType;

import java.util.List;
import java.util.function.IntSupplier;

public class RefillUpgradeItem extends UpgradeItemBase<RefillUpgradeWrapper> {
Expand All @@ -28,6 +29,11 @@ public UpgradeType<RefillUpgradeWrapper> getType() {
return TYPE;
}

@Override
public List<UpgradeConflictDefinition> getUpgradeConflicts() {
return List.of();
}

public int getFilterSlotCount() {
return filterSlotCount.getAsInt();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeType;

import java.util.List;
import java.util.function.IntSupplier;

public class RestockUpgradeItem extends UpgradeItemBase<RestockUpgradeWrapper> {
Expand All @@ -20,6 +21,11 @@ public UpgradeType<RestockUpgradeWrapper> getType() {
return TYPE;
}

@Override
public List<UpgradeConflictDefinition> getUpgradeConflicts() {
return List.of();
}

public int getFilterSlotCount() {
return filterSlotCount.getAsInt();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.toolswapper;

import net.minecraft.world.item.ItemStack;
import net.p3pp3rf1y.sophisticatedbackpacks.Config;
import net.p3pp3rf1y.sophisticatedbackpacks.client.gui.SBPTranslationHelper;
import net.p3pp3rf1y.sophisticatedcore.api.IStorageWrapper;
import net.p3pp3rf1y.sophisticatedcore.common.gui.UpgradeSlotChangeResult;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase;
import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeType;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.List;

public class ToolSwapperUpgradeItem extends UpgradeItemBase<ToolSwapperUpgradeWrapper> {
private static final UpgradeType<ToolSwapperUpgradeWrapper> TYPE = new UpgradeType<>(ToolSwapperUpgradeWrapper::new);
public static final List<UpgradeConflictDefinition> UPGRADE_CONFLICT_DEFINITIONS = List.of(new UpgradeConflictDefinition(ToolSwapperUpgradeItem.class::isInstance, 0, SBPTranslationHelper.INSTANCE.translError("add.tool_swapper_exists")));
private final boolean hasSettingsTab;
private final boolean swapToolOnKeyPress;

Expand All @@ -37,21 +33,7 @@ public boolean shouldSwapToolOnKeyPress() {
}

@Override
public UpgradeSlotChangeResult canAddUpgradeTo(IStorageWrapper storageWrapper, ItemStack upgradeStack, boolean firstLevelStorage, boolean isClientSide) {
UpgradeSlotChangeResult result = super.canAddUpgradeTo(storageWrapper, upgradeStack, firstLevelStorage, isClientSide);
if (!result.isSuccessful()) {
return result;
}

Set<Integer> errorUpgradeSlots = new HashSet<>();
storageWrapper.getUpgradeHandler().getSlotWrappers().forEach((slot, wrapper) -> {
if (wrapper instanceof ToolSwapperUpgradeWrapper) {
errorUpgradeSlots.add(slot);
}
});
if (!errorUpgradeSlots.isEmpty()) {
return new UpgradeSlotChangeResult.Fail(SBPTranslationHelper.INSTANCE.translError("add.tool_swapper_exists"), errorUpgradeSlots, Collections.emptySet(), Collections.emptySet());
}
return new UpgradeSlotChangeResult.Success();
public List<UpgradeConflictDefinition> getUpgradeConflicts() {
return UPGRADE_CONFLICT_DEFINITIONS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
"gui.sophisticatedbackpacks.error.add.inception_exists": "There's already Inception Upgrade in another upgrade slot",
"gui.sophisticatedbackpacks.error.remove.inception_sub_backpack": "There's one or more backpacks in the backpack",
"gui.sophisticatedbackpacks.error.add.tool_swapper_exists": "There's already Tool Swapper Upgrade in another upgrade slot",
"gui.sophisticatedbackpacks.error.add.everlasting_exists": "There's already Everlasting Upgrade in another upgrade slot",
"gui.sophisticatedbackpacks.settings.buttons.another_player_can_open.on": "Another player can open",
"gui.sophisticatedbackpacks.settings.buttons.another_player_can_open.on.tooltip": "When this backpack is worn and visible another player can open it when right clicking on this player's back",
"gui.sophisticatedbackpacks.settings.buttons.another_player_can_open.off": "Another player can NOT open",
Expand Down

0 comments on commit a44ec24

Please sign in to comment.