Skip to content

Commit

Permalink
fix 1x2 and 2x2 storage drawers (#51)
Browse files Browse the repository at this point in the history
Co-authored-by: Abdulaziz <[email protected]>
  • Loading branch information
Caedis and 0hwx authored Jan 17, 2025
1 parent 8fa6668 commit 79fc1e0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
5 changes: 3 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ dependencies {
compileOnly("com.github.GTNewHorizons:NotEnoughItems:2.7.22-GTNH:dev")
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.79:dev")
compileOnly("com.github.GTNewHorizons:Botania:1.12.5-GTNH:dev")


devOnlyNonPublishable("com.github.GTNewHorizons:StorageDrawers:2.1.0-GTNH:dev")

runtimeOnlyNonPublishable("com.github.GTNewHorizons:waila:1.8.2:dev")

compileOnly rfg.deobf('curse.maven:projecte-226410:2340786')
compileOnly rfg.deobf('curse.maven:rftools-224641:2287287')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;

import com.cleanroommc.bogosorter.compat.loader.Mods;
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;

public class DropOffHandler {

private final InventoryManager inventoryManager;
Expand Down Expand Up @@ -107,6 +110,27 @@ private void movePlayerStack(int playerStackIndex, IInventory toInventory) {
if (inventoryManager.isStacksEqual(toCurrentStack, playerStacks[playerStackIndex])) {
hasSameStack = true;
int toCurrentStackMaxSize = inventoryManager.getMaxAllowedStackSize(toInventory, toCurrentStack);
if (Mods.StorageDrawers.isLoaded() && toInventory instanceof TileEntityDrawers drawer) {
int drawerSlot = drawer.getDrawerInventory()
.getDrawerSlot(i);
// side is ignored
if (drawer.canInsertItem(drawerSlot, playerStacks[playerStackIndex], 0)) {
// handles reducing the player stack size
int countAdded = drawer.putItemsIntoSlot(
drawerSlot,
playerStacks[playerStackIndex],
playerStacks[playerStackIndex].stackSize);

if (countAdded == 0) {
continue;
}

if (playerStacks[playerStackIndex].stackSize <= 0) {
playerStacks[playerStackIndex] = null;
}
}
return;
}

if (toCurrentStack.stackSize + playerStacks[playerStackIndex].stackSize <= toCurrentStackMaxSize) {
toCurrentStack.stackSize += playerStacks[playerStackIndex].stackSize;
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/com/cleanroommc/bogosorter/compat/loader/Mods.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,34 @@

public enum Mods {

EnderStorage("EnderStorage"),
DraconicEvolution("DraconicEvolution"),
AdventureBackpack2("adventurebackpack"),
Ae2("appliedenergistics2"),
AvaritiaAddons("avaritiaddons"),
Backpack("Backpack"),
Bibliocraft("BiblioCraft"),
CookingForBlockheads("cookingforblockheads"),
Ae2("appliedenergistics2"),
DraconicEvolution("DraconicEvolution"),
EnderStorage("EnderStorage"),
Energycontrol("energycontrol"),
Etfuturum("etfuturum"),
ExtraUtilities("ExtraUtilities"),
Forestry("Forestry"),
GT5u(() -> Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")),
GT6(() -> Loader.isModLoaded("gregtech") && Loader.isModLoaded("gregapi")),
Backpack("Backpack"),
GalacticraftCore("galacticraftcore"),
AdventureBackpack2("adventurebackpack"),
ProjectE("ProjectE"),
Tconstruct("TConstruct"),
ServerUtilities("serverutilities"),
Nutrition("nutrition"),
Bibliocraft("BiblioCraft"),
HBM("hbm"),
IC2("IC2"),
ImmersiveEngineering("ImmersiveEngineering"),
IronChest("IronChest"),
Mekanism("Mekanism"),
Nutrition("nutrition"),
ProjectE("ProjectE"),
ProjectRed("ProjRed|Expansion"),
ImmersiveEngineering("ImmersiveEngineering"),
Thebetweenlands("thebetweenlands"),
ServerUtilities("serverutilities"),
StorageDrawers("StorageDrawers"),
Tconstruct("TConstruct"),
Terrafirmacraft("terrafirmacraft"),
Energycontrol("energycontrol"),
Etfuturum("etfuturum"),
IronChest("IronChest"),
IC2("IC2"),
ExtraUtilities("ExtraUtilities"),
HBM("hbm");
Thebetweenlands("thebetweenlands"),;

public final String modid;
private final Supplier<Boolean> supplier;
Expand All @@ -46,7 +47,6 @@ public enum Mods {
Mods(Supplier<Boolean> supplier) {
this.supplier = supplier;
this.modid = null;

}

public boolean isLoaded() {
Expand Down

0 comments on commit 79fc1e0

Please sign in to comment.