private void handleStackSizeChanged( int slot, IAEFluidStack oldAeFS, FluidStack newFS, List<IAEFluidStack> changes ) { // Still the same fluid, but amount might have changed final long diff = newFS.amount - oldAeFS.getStackSize(); if( diff != 0 ) { final IAEFluidStack stack = oldAeFS.copy(); stack.setStackSize( newFS.amount ); this.cachedAeStacks[slot] = stack; final IAEFluidStack a = stack.copy(); a.setStackSize( diff ); changes.add( a ); } }
private void handleFluidChanged( int slot, IAEFluidStack oldAeFS, FluidStack newFS, List<IAEFluidStack> changes ) { // Completely different fluid this.cachedAeStacks[slot] = AEFluidStack.fromFluidStack( newFS ); // If we had a stack previously in this slot, notify the network about its disappearance if( oldAeFS != null ) { oldAeFS.setStackSize( -oldAeFS.getStackSize() ); changes.add( oldAeFS ); } // Notify the network about the new stack. Note that this is null if newFS was null if( this.cachedAeStacks[slot] != null ) { changes.add( this.cachedAeStacks[slot] ); } } }
a.setStackSize( -a.getStackSize() ); changes.add( a );
@Override public void setFluidInSlot( final int slot, final IAEFluidStack fluid ) { if( slot >= 0 && slot < this.getSlots() ) { if( Objects.equals( this.fluids[slot], fluid ) ) { if( fluid != null && fluid.getStackSize() != this.fluids[slot].getStackSize() ) { this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) ); this.onContentChanged( slot ); } } else { if( fluid == null ) { this.fluids[slot] = null; } else { this.fluids[slot] = fluid.copy(); this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) ); } this.onContentChanged( slot ); } } }
this.requireWork[slot] = work.setStackSize( -work.getStackSize() ); return; this.requireWork[slot].setStackSize( TANK_CAPACITY ); return; this.requireWork[slot].setStackSize( TANK_CAPACITY - stored.getStackSize() ); return; this.requireWork[slot] = work.setStackSize( -work.getStackSize() ); return;
@Override public IAEFluidStack extractItems( final IAEFluidStack request, final Actionable type, final IActionSource src ) { final FluidStack removed = this.handler.drain( request.getFluidStack(), type == Actionable.MODULATE ); if( removed == null || removed.amount == 0 ) { return null; } if( type == Actionable.MODULATE ) { this.onTick(); } final IAEFluidStack o = request.copy(); o.setStackSize( removed.amount ); return o; }
fluid.setStackSize( fluid.getStackSize() + amountToStore ); this.onContentChanged( slot );
@Override public void addCrafting( final IAEFluidStack option ) { if( option == null ) { return; } final IAEFluidStack st = this.getFluidRecord( option ); if( st != null ) { st.setCraftable( true ); return; } final IAEFluidStack opt = option.copy(); opt.setStackSize( 0 ); opt.setCraftable( true ); this.putFluidRecord( opt ); }
old.aeStack.setStackSize( -old.aeStack.getStackSize() ); changes.add( old.aeStack ); stack.setStackSize( newSize ); this.list.add( stack ); a.setStackSize( diff ); changes.add( a ); changed = true; a.setStackSize( -a.getStackSize() ); changes.add( a ); changed = true;
@Override public IAEFluidStack injectItems( final IAEFluidStack input, final Actionable type, final IActionSource src ) { final int filled = this.handler.fill( input.getFluidStack(), type == Actionable.MODULATE ); if( filled == 0 ) { return input.copy(); } if( type == Actionable.MODULATE ) { this.onTick(); } if( filled == input.getStackSize() ) { return null; } final IAEFluidStack o = input.copy(); o.setStackSize( input.getStackSize() - filled ); return o; }
public FluidStack drain( final int slot, final int maxDrain, boolean doDrain ) { final IAEFluidStack fluid = this.fluids[slot]; if( fluid == null || maxDrain <= 0 ) { return null; } int drained = maxDrain; if( fluid.getStackSize() < drained ) { drained = (int) fluid.getStackSize(); } FluidStack stack = new FluidStack( fluid.getFluid(), drained ); if( doDrain ) { fluid.setStackSize( fluid.getStackSize() - drained ); if( fluid.getStackSize() <= 0 ) { this.fluids[slot] = null; } this.onContentChanged( slot ); } return stack; }
@Override public void addRequestable( final IAEFluidStack option ) { if( option == null ) { return; } final IAEFluidStack st = this.getFluidRecord( option ); if( st != null ) { st.setCountRequestable( st.getCountRequestable() + option.getCountRequestable() ); return; } final IAEFluidStack opt = option.copy(); opt.setStackSize( 0 ); opt.setCraftable( false ); opt.setCountRequestable( option.getCountRequestable() ); this.putFluidRecord( opt ); }
toStore.setStackSize( -toStore.getStackSize() ); toStore.setStackSize( toStore.getStackSize() - ( notStored == null ? 0 : notStored.getStackSize() ) );
toExtract.setStackSize( this.calculateAmountToSend() ); toExtract.setStackSize( wasInserted ); inv.extractItems( toExtract, Actionable.MODULATE, this.source );
ret.setStackSize( input.getStackSize() - Fluid.BUCKET_VOLUME ); return ret.getStackSize() == 0 ? null : ret;
stack.setStackSize( Integer.MAX_VALUE ); int amountAllowed = fh.fill( stack.getFluidStack(), false ); stack.setStackSize( amountAllowed ); stack.setStackSize( canFill ); final IAEFluidStack pulled = Platform.poweredExtraction( this.getPowerSource(), this.monitor, stack, this.getActionSource() ); if( pulled == null || pulled.getStackSize() < 1 )
if( send == null ) is.setStackSize( 0 ); piu.appendFluid( is );
public static IAEFluidStack createAEFluidStack(Gas gas, long amount) { return createAEFluidStack(new FluidStack(MekanismGas.getFluidGasMap().get(gas), 1)).setStackSize( amount); }
public static IAEFluidStack createAEFluidStack(IAEGasStack gasStack){ if (gasStack == null || gasStack.getGas() == null) return null; return createAEFluidStack((Gas)gasStack.getGas()).setStackSize(gasStack.getStackSize()); }