mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-29 08:27:03 +01:00
Chute extraction refactor
This commit is contained in:
parent
9ab5c74929
commit
d1c8ad38fc
2 changed files with 24 additions and 31 deletions
|
@ -72,7 +72,6 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
ChuteItemHandler itemHandler;
|
ChuteItemHandler itemHandler;
|
||||||
LazyOptional<IItemHandler> lazyHandler;
|
LazyOptional<IItemHandler> lazyHandler;
|
||||||
boolean canPickUpItems;
|
boolean canPickUpItems;
|
||||||
boolean canFilterItems;
|
|
||||||
|
|
||||||
float bottomPullDistance;
|
float bottomPullDistance;
|
||||||
float beltBelowOffset;
|
float beltBelowOffset;
|
||||||
|
@ -91,7 +90,6 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
itemHandler = new ChuteItemHandler(this);
|
itemHandler = new ChuteItemHandler(this);
|
||||||
lazyHandler = LazyOptional.of(() -> itemHandler);
|
lazyHandler = LazyOptional.of(() -> itemHandler);
|
||||||
canPickUpItems = false;
|
canPickUpItems = false;
|
||||||
canFilterItems = false;
|
|
||||||
capAbove = LazyOptional.empty();
|
capAbove = LazyOptional.empty();
|
||||||
capBelow = LazyOptional.empty();
|
capBelow = LazyOptional.empty();
|
||||||
bottomPullDistance = 0;
|
bottomPullDistance = 0;
|
||||||
|
@ -326,40 +324,25 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
private void handleInputFromAbove() {
|
private void handleInputFromAbove() {
|
||||||
if (!capAbove.isPresent())
|
if (!capAbove.isPresent())
|
||||||
capAbove = grabCapability(Direction.UP);
|
capAbove = grabCapability(Direction.UP);
|
||||||
if (!capAbove.isPresent())
|
handleInput(capAbove.orElse(null));
|
||||||
return;
|
|
||||||
|
|
||||||
int count = getExtractionAmount();
|
|
||||||
IItemHandler inv = capAbove.orElse(null);
|
|
||||||
Predicate<ItemStack> canAccept = this::canAcceptItem;
|
|
||||||
if (count == 0) {
|
|
||||||
item = ItemHelper.extract(inv, canAccept, ExtractionCountMode.UPTO, canFilterItems ? 64 : 16, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ItemHelper.extract(inv, canAccept, ExtractionCountMode.EXACTLY, count, true)
|
|
||||||
.isEmpty())
|
|
||||||
item = ItemHelper.extract(inv, canAccept, ExtractionCountMode.EXACTLY, count, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleInputFromBelow() {
|
private void handleInputFromBelow() {
|
||||||
if (!capBelow.isPresent())
|
if (!capBelow.isPresent())
|
||||||
capBelow = grabCapability(Direction.DOWN);
|
capBelow = grabCapability(Direction.DOWN);
|
||||||
if (!capBelow.isPresent())
|
handleInput(capBelow.orElse(null));
|
||||||
return;
|
|
||||||
|
|
||||||
int count = getExtractionAmount();
|
|
||||||
IItemHandler inv = capBelow.orElse(null);
|
|
||||||
Predicate<ItemStack> canAccept = this::canAcceptItem;
|
|
||||||
|
|
||||||
if (count == 0) {
|
|
||||||
item = ItemHelper.extract(inv, canAccept, ExtractionCountMode.UPTO, canFilterItems ? 64 : 16, false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ItemHelper.extract(inv, canAccept, ExtractionCountMode.EXACTLY, count, true)
|
private void handleInput(IItemHandler inv) {
|
||||||
|
if (inv == null)
|
||||||
|
return;
|
||||||
|
Predicate<ItemStack> canAccept = this::canAcceptItem;
|
||||||
|
int count = getExtractionAmount();
|
||||||
|
ExtractionCountMode mode = getExtractionMode();
|
||||||
|
if (mode == ExtractionCountMode.UPTO || !ItemHelper.extract(inv, canAccept, mode, count, true)
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
item = ItemHelper.extract(inv, canAccept, ExtractionCountMode.EXACTLY, count, false);
|
item = ItemHelper.extract(inv, canAccept, mode, count, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleDownwardOutput(boolean simulate) {
|
private boolean handleDownwardOutput(boolean simulate) {
|
||||||
|
@ -477,7 +460,11 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getExtractionAmount() {
|
protected int getExtractionAmount() {
|
||||||
return 0;
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ExtractionCountMode getExtractionMode() {
|
||||||
|
return ExtractionCountMode.UPTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canCollectItemsFromBelow() {
|
protected boolean canCollectItemsFromBelow() {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.content.logistics.block.chute;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode;
|
||||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
|
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
|
||||||
|
|
||||||
|
@ -17,7 +18,6 @@ public class SmartChuteTileEntity extends ChuteTileEntity {
|
||||||
|
|
||||||
public SmartChuteTileEntity(TileEntityType<?> tileEntityTypeIn) {
|
public SmartChuteTileEntity(TileEntityType<?> tileEntityTypeIn) {
|
||||||
super(tileEntityTypeIn);
|
super(tileEntityTypeIn);
|
||||||
canFilterItems = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,7 +27,13 @@ public class SmartChuteTileEntity extends ChuteTileEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getExtractionAmount() {
|
protected int getExtractionAmount() {
|
||||||
return filtering.isCountVisible() ? filtering.getAmount() : 0;
|
return filtering.isCountVisible() && !filtering.anyAmount() ? filtering.getAmount() : 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ExtractionCountMode getExtractionMode() {
|
||||||
|
return filtering.isCountVisible() && !filtering.anyAmount() ? ExtractionCountMode.EXACTLY
|
||||||
|
: ExtractionCountMode.UPTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue