mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-26 05:28:33 +01:00
Compare commits
No commits in common. "3d65dc34db05a9841757e353a7faf99d53e44274" and "78012cf0192828f0f56f937264726c5e48924290" have entirely different histories.
3d65dc34db
...
78012cf019
2 changed files with 3 additions and 23 deletions
|
@ -111,9 +111,6 @@ dependencies {
|
||||||
compileOnly fg.deobf("mezz.jei:jei-1.19.2-common-api:11.3.0.260")
|
compileOnly fg.deobf("mezz.jei:jei-1.19.2-common-api:11.3.0.260")
|
||||||
runtimeOnly fg.deobf("mezz.jei:jei-1.19.2-forge:11.3.0.260")
|
runtimeOnly fg.deobf("mezz.jei:jei-1.19.2-forge:11.3.0.260")
|
||||||
|
|
||||||
// test storage drawers
|
|
||||||
runtimeOnly fg.deobf("curse.maven:storage-drawers-223852:3884263")
|
|
||||||
|
|
||||||
// to test the rf requiring and crafting stuff
|
// to test the rf requiring and crafting stuff
|
||||||
/* runtimeOnly fg.deobf("curse.maven:powah-352656:3057732")
|
/* runtimeOnly fg.deobf("curse.maven:powah-352656:3057732")
|
||||||
runtimeOnly fg.deobf("curse.maven:lollipop-347954:3057731")
|
runtimeOnly fg.deobf("curse.maven:lollipop-347954:3057731")
|
||||||
|
|
|
@ -39,6 +39,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.common.util.Lazy;
|
import net.minecraftforge.common.util.Lazy;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
@ -197,27 +198,10 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
continue;
|
continue;
|
||||||
if (!force && this.streamModules().anyMatch(m -> !m.getRight().canAcceptItem(m.getLeft(), this, stack, dir, handler)))
|
if (!force && this.streamModules().anyMatch(m -> !m.getRight().canAcceptItem(m.getLeft(), this, stack, dir, handler)))
|
||||||
continue;
|
continue;
|
||||||
|
var remain = ItemHandlerHelper.insertItem(handler, stack, true);
|
||||||
var startSlot = 0;
|
|
||||||
var slotAmount = handler.getSlots();
|
|
||||||
// the 0th slot of a storage drawer is a "catch-all" for any items that can be inserted into the drawer, and all
|
|
||||||
// subsequent slots are the actual slots for the items. this causes a problem because the drawer will seem to have
|
|
||||||
// space for more items that it actually does, so we restrict to only inspecting the 0th slot here.
|
|
||||||
// see https://github.com/Ellpeck/PrettyPipes/issues/131#issuecomment-1288653623 and Discord convo with Quinteger
|
|
||||||
if (handler.getClass().getName().equals("com.jaquadro.minecraft.storagedrawers.capabilities.DrawerItemHandler"))
|
|
||||||
slotAmount = 1;
|
|
||||||
|
|
||||||
// check how many items from the stack we can insert into this destination in total
|
|
||||||
var remain = stack;
|
|
||||||
for (var i = startSlot; i < slotAmount; i++) {
|
|
||||||
remain = handler.insertItem(i, remain, true);
|
|
||||||
if (remain.isEmpty())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// did we insert anything?
|
// did we insert anything?
|
||||||
if (remain.getCount() == stack.getCount())
|
if (remain.getCount() == stack.getCount())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var toInsert = stack.copy();
|
var toInsert = stack.copy();
|
||||||
toInsert.shrink(remain.getCount());
|
toInsert.shrink(remain.getCount());
|
||||||
// limit to the max amount that modules allow us to insert
|
// limit to the max amount that modules allow us to insert
|
||||||
|
@ -239,7 +223,7 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
}
|
}
|
||||||
// totalSpace will be the amount of items that fit into the attached container
|
// totalSpace will be the amount of items that fit into the attached container
|
||||||
var totalSpace = 0;
|
var totalSpace = 0;
|
||||||
for (var i = startSlot; i < slotAmount; i++) {
|
for (var i = 0; i < handler.getSlots(); i++) {
|
||||||
var copy = stack.copy();
|
var copy = stack.copy();
|
||||||
var maxStackSize = copy.getMaxStackSize();
|
var maxStackSize = copy.getMaxStackSize();
|
||||||
// if the container can store more than 64 items in this slot, then it's likely
|
// if the container can store more than 64 items in this slot, then it's likely
|
||||||
|
@ -258,7 +242,6 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
toInsert.setCount(totalSpace - onTheWay);
|
toInsert.setCount(totalSpace - onTheWay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we return the item that can actually be inserted, NOT the remainder!
|
// we return the item that can actually be inserted, NOT the remainder!
|
||||||
if (!toInsert.isEmpty())
|
if (!toInsert.isEmpty())
|
||||||
return Pair.of(offset, toInsert);
|
return Pair.of(offset, toInsert);
|
||||||
|
|
Loading…
Reference in a new issue