Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 1x2 and 2x2 storage drawers #51

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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