Workbench Factory

Workbench Factory

574k Downloads

Pipelines

ArturilloD opened this issue · 35 comments

commented

Is there any chance of becoming a tileentity?

commented

It is a title-entity already:

public class FactoryEntity extends LockableLootTileEntity implements ITickableTileEntity, IRecipeHolder, IRecipeHelperPopulator, ISidedInventory {

commented

Is there a specific mod you want me to test it with, searched for "Pipelines" but didn't found one.

commented
commented
commented
commented

Ah, my code that prevent hoppers to mess with the inventory, stops the pippeps from using the inventory.

Senario:

  1. The hopper wants to send an item
  2. Hopper checks if its pointing to a tile-entity, if not abort.
  3. Hopper checks if its an inventory with CapabilityItemHandler.ITEM_HANDLER_CAPABILITY
  4. if so, try to put the item in each slot in the inventory, done
  5. if not, check if the inventory is a ISidedInventory
  6. if so, ask what slots are avaible from the connected side
  7. try to put the item in each avaible slot.

To prevent the hopper from puting/pulling item from the wrong slots, I answered that it dosn't have ITEM_HANDLER_CAPABILITY.

Pipes check for ITEM_HANDLER_CAPABILITY when it checks if it can connect.

commented

AbstractFurnaceTileEntity using a SidedInvWrapper to solve the same problem,
but by answering that it has ITEM_HANDLER_CAPABILITY, and then act as a filter,
if a tile entity have 3 slots (nr 0, 1 & 2), and only nr 2 is avaible from the bottom,
when accessing the tile entity throght SidedInvWrapper, getSlots() returns 1 insted of 3, and insertItem(0, ...) converts to insertItem(2, ...) and so on.

commented

See row 177-182 in PipeBlock.java
https://github.com/Ellpeck/PrettyPipes/blob/294559ca614fdf2851d0277d6fbb130859f9684a/src/main/java/de/ellpeck/prettypipes/pipe/PipeBlock.java#L177-L182

And see row 334-339 in FactoryEntity.java

public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return LazyOptional.empty();
}
return super.getCapability(cap, side);
}

commented

v1.2.0
2020-08-26_15 59 20

commented

I'll play around with 2 mods you sugested, this weekend, and see if I can figure out whats happening.

As you seams to be intrested, Il try to decribing my findings in more details then usal :-)

commented

v1.2.0 solves the connection issue,

It fills the stacks up in a odd way, the chosen receipt was a stone pickaxes, so it has 3 slots for stone.
When it started to fill it up I saw the following step of stones slots: [64, 0, 0] -> [64, 1, 0] -> [64, 64, 0] -> [64, 64, 1].
I'l see what I can do with that for version 1.2.1, but first I want to release the v1.2.0 version for all mc-versions i support.
But I keep this Issue open as it's not completely solved yet.

commented
commented

Oh, now I see 3 part of the problem:

  1. The pipes didn't connect
  2. An uneven fill, can make it produce less items, as there can be enough materials, but in the wrong slots.
  3. For extracting items, it would be nice if the direction is ignored.
commented
commented
commented
commented
commented

The soulotion for "1. The pipes didn't connect"
was replace this code I found somewhare:

public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return LazyOptional.empty();
}
return super.getCapability(cap, side);
}

with the code at row 487-501 in AbstractFurnaceTileEntity.java

LazyOptional<? extends IItemHandler>[] handlers = SidedInvWrapper.create(this, Direction.UP, Direction.DOWN, Direction.NORTH);
@Override
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
if (!this.removed && facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
if (facing == Direction.UP)
return handlers[0].cast();
else if (facing == Direction.DOWN)
return handlers[1].cast();
else
return handlers[2].cast();
}
return super.getCapability(capability, facing);
}

commented
commented

Had some time to test the current version, and some ides how to improve it, but not enough time to write the code yet.

On my mind right now:

  • For an item that just use one type of material like 9 coal -> 1 coal block, the hoppers fill up the item-slots in a way that is efficient, but pipes send more then one at the time, so it fills them up in the same order, but with larger amount, therefor unbalanced.

  • For an item that have more then one material like 1 stone + 2 stick -> 1 shovel, the hopper can't add sticks if there is no stone, I think that it checks the first slot, notice it's empty, ask if it can put the stick there, when the answer is no, it gives up.

  • When trying to make the next item, If any of the required slot is empty, insted of aborting, I could add "balance material"-step, that spread out the material. This whould also solve the problem that accure when manual loading the slots. For exemple if you have the shovel recipt acitve, and put one stack of stone and one stack of sticks, instead of just aborting, it automaticly moves half the stack of stick to the last slot.

  • When an hopper (or pipe) ask what slots that it can insert items in, maybe I should lie, and maybe just say that it has one empty slot, and when it ask if it could add stone or stick to that slot (in the case of the shovel) I can answer yes on both, on when the item is inserted, I move it to the right slot.

commented
commented

v1.2.1 Connected side now ignored, can excrat items at the top, and insert item in the bottom.
2020-08-29_16 24 18

commented
commented

Built a Loop with dimonds and dimond blocks, but in 9 stack of dimond blocks (9x64=576).
After AFK-ing for a bit, I stoped the loop by disabeling one extractor, and now there is less then 1½ stack left (92 blocks).
2020-08-29_22 47 20

commented
commented

That was a bug on my side.

  1. The pipes didn't connect
  2. An uneven fill, can make it produce less items, as there can be enough materials, but in the wrong slots.
  3. For extracting items, it would be nice if the direction is ignored.

I think all 3 issues above, now is solved in v.1.3.1, Please test it:
https://www.curseforge.com/minecraft/mc-mods/workbench-factory/files/3045386

commented
commented
commented

v1.3.0 implement the auto-rebalance, but now there is a new bug with the pipelines, items get lost :-(.

commented
commented
commented
commented
commented
commented