Skip to content

Commit 9d117a6

Browse files
committed
fix: 🐛 Fixed dupe bug with bundles in upgrade slots
1 parent 2109cd9 commit 9d117a6

2 files changed

Lines changed: 35 additions & 31 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ loader_version_range=[4,)
1313
mod_id=sophisticatedcore
1414
mod_name=Sophisticated Core
1515
mod_license=All Rights Reserved
16-
mod_version=1.3.57
16+
mod_version=1.3.58
1717
mod_group_id=sophisticatedcore
1818
mod_authors=P3pp3rF1y
1919
mod_description=A library / shared functionality mod for Sophisticated Storage and Backpacks

src/main/java/net/p3pp3rf1y/sophisticatedcore/common/gui/StorageContainerMenuBase.java

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,39 +1172,43 @@ protected void doClick(int slotId, int dragType, ClickType clickType, Player pla
11721172
ItemStack slotStack = slot7.getItem();
11731173
ItemStack carriedStack = getCarried();
11741174
player.updateTutorialInventoryAction(carriedStack, slot7.getItem(), clickaction);
1175-
if (!carriedStack.overrideStackedOnOther(slot7, clickaction, player) && !slotStack.overrideOtherStackedOnMe(carriedStack, slot7, clickaction, player, createCarriedSlotAccess())) {
1176-
if (slotStack.isEmpty()) {
1177-
if (!carriedStack.isEmpty()) {
1178-
int l2 = clickaction == ClickAction.PRIMARY ? carriedStack.getCount() : 1;
1179-
setCarried(slot7.safeInsert(carriedStack, l2));
1180-
}
1181-
} else if (slot7.mayPickup(player)) {
1182-
if (carriedStack.isEmpty()) {
1183-
int countToRemove;
1184-
countToRemove = Math.min(slotStack.getCount(), slotStack.getMaxStackSize());
1185-
if (clickaction == ClickAction.SECONDARY) {
1186-
countToRemove = countToRemove / 2 + countToRemove % 2;
1175+
if (!carriedStack.overrideStackedOnOther(slot7, clickaction, player)) {
1176+
if (!slotStack.overrideOtherStackedOnMe(carriedStack, slot7, clickaction, player, createCarriedSlotAccess())) {
1177+
if (slotStack.isEmpty()) {
1178+
if (!carriedStack.isEmpty()) {
1179+
int l2 = clickaction == ClickAction.PRIMARY ? carriedStack.getCount() : 1;
1180+
setCarried(slot7.safeInsert(carriedStack, l2));
11871181
}
1188-
Optional<ItemStack> optional1 = slot7.tryRemove(countToRemove, Integer.MAX_VALUE, player);
1189-
optional1.ifPresent((p_150421_) -> {
1190-
setCarried(p_150421_);
1191-
slot7.onTake(player, p_150421_);
1192-
});
1193-
} else if (slot7.mayPlace(carriedStack)) {
1194-
if (ItemStack.isSameItemSameComponents(slotStack, carriedStack)) {
1195-
int j3 = clickaction == ClickAction.PRIMARY ? carriedStack.getCount() : 1;
1196-
setCarried(slot7.safeInsert(carriedStack, j3));
1197-
} else if (carriedStack.getCount() <= slot7.getMaxStackSize(carriedStack) && slotStack.getCount() <= slotStack.getMaxStackSize()) {
1198-
slot7.set(carriedStack);
1199-
setCarried(slotStack);
1182+
} else if (slot7.mayPickup(player)) {
1183+
if (carriedStack.isEmpty()) {
1184+
int countToRemove;
1185+
countToRemove = Math.min(slotStack.getCount(), slotStack.getMaxStackSize());
1186+
if (clickaction == ClickAction.SECONDARY) {
1187+
countToRemove = countToRemove / 2 + countToRemove % 2;
1188+
}
1189+
Optional<ItemStack> optional1 = slot7.tryRemove(countToRemove, Integer.MAX_VALUE, player);
1190+
optional1.ifPresent((p_150421_) -> {
1191+
setCarried(p_150421_);
1192+
slot7.onTake(player, p_150421_);
1193+
});
1194+
} else if (slot7.mayPlace(carriedStack)) {
1195+
if (ItemStack.isSameItemSameComponents(slotStack, carriedStack)) {
1196+
int j3 = clickaction == ClickAction.PRIMARY ? carriedStack.getCount() : 1;
1197+
setCarried(slot7.safeInsert(carriedStack, j3));
1198+
} else if (carriedStack.getCount() <= slot7.getMaxStackSize(carriedStack) && slotStack.getCount() <= slotStack.getMaxStackSize()) {
1199+
slot7.set(carriedStack);
1200+
setCarried(slotStack);
1201+
}
1202+
} else if (ItemStack.isSameItemSameComponents(slotStack, carriedStack)) {
1203+
Optional<ItemStack> optional = slot7.tryRemove(slotStack.getCount(), carriedStack.getMaxStackSize() - carriedStack.getCount(), player);
1204+
optional.ifPresent((p_150428_) -> {
1205+
carriedStack.grow(p_150428_.getCount());
1206+
slot7.onTake(player, p_150428_);
1207+
});
12001208
}
1201-
} else if (ItemStack.isSameItemSameComponents(slotStack, carriedStack)) {
1202-
Optional<ItemStack> optional = slot7.tryRemove(slotStack.getCount(), carriedStack.getMaxStackSize() - carriedStack.getCount(), player);
1203-
optional.ifPresent((p_150428_) -> {
1204-
carriedStack.grow(p_150428_.getCount());
1205-
slot7.onTake(player, p_150428_);
1206-
});
12071209
}
1210+
} else {
1211+
slot7.set(slotStack);
12081212
}
12091213
}
12101214

0 commit comments

Comments
 (0)