Search in sources :

Example 1 with TileTransitRequest

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--;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TransitResponse(mekanism.common.lib.inventory.TransitRequest.TransitResponse) TileTransitRequest(mekanism.common.lib.inventory.TileTransitRequest) TileEntityLogisticalTransporterBase(mekanism.common.tile.transmitter.TileEntityLogisticalTransporterBase)

Aggregations

TileTransitRequest (mekanism.common.lib.inventory.TileTransitRequest)1 TransitResponse (mekanism.common.lib.inventory.TransitRequest.TransitResponse)1 TileEntityLogisticalTransporterBase (mekanism.common.tile.transmitter.TileEntityLogisticalTransporterBase)1 TileEntity (net.minecraft.tileentity.TileEntity)1