use of mekanism.common.lib.inventory.TileTransitRequest in project Mekanism by mekanism.
the class TileEntityBin method onUpdateServer.
@Override
protected void onUpdateServer() {
super.onUpdateServer();
addTicks = Math.max(0, addTicks - 1);
removeTicks = Math.max(0, removeTicks - 1);
delayTicks = Math.max(0, delayTicks - 1);
if (delayTicks == 0) {
if (getActive()) {
TileEntity tile = WorldUtils.getTileEntity(getLevel(), getBlockPos().below());
TileTransitRequest request = new TileTransitRequest(this, Direction.DOWN);
request.addItem(binSlot.getBottomStack(), 0);
TransitResponse response;
if (tile instanceof TileEntityLogisticalTransporterBase) {
response = ((TileEntityLogisticalTransporterBase) tile).getTransmitter().insert(this, request, null, true, 0);
} else {
response = request.addToInventory(tile, Direction.DOWN, 0, false);
}
if (!response.isEmpty() && tier != BinTier.CREATIVE) {
int sendingAmount = response.getSendingAmount();
MekanismUtils.logMismatchedStackSize(binSlot.shrinkStack(sendingAmount, Action.EXECUTE), sendingAmount);
}
delayTicks = 10;
}
} else {
delayTicks--;
}
}
Aggregations