Exemplo n.º 1
0
    protected void transferEnergy(BlockFacing side, float dt)
    {
        BlockPos    outPos     = Pos.Copy().Offset(side);
        BlockEntity tileEntity = Api.World.BlockAccessor.GetBlockEntity(outPos);

        if (tileEntity == null)
        {
            return;
        }
        if (!(tileEntity is IFluxStorage))
        {
            return;
        }
        float eout = Math.Min(energyStorage.getLimitExtract() * dt, energyStorage.getEnergyStored() * dt);

        energyStorage.modifyEnergyStored(-((IFluxStorage)tileEntity).receiveEnergy(side.Opposite, eout, false, dt));
    }
Exemplo n.º 2
0
 private void OnTick(float dt)
 {
     if (inventory[0]?.Itemstack?.Item is IFluxStorageItem)
     {
         energyStorage.modifyEnergyStored(-((IFluxStorageItem)inventory[0].Itemstack.Item).receiveEnergy(inventory[0].Itemstack, (int)Math.Min(energyStorage.getLimitExtract() * dt, energyStorage.getEnergyStored())));
     }
     else if (inventory[0]?.Itemstack?.Block is IFluxStorageItem)
     {
         energyStorage.modifyEnergyStored(-((IFluxStorageItem)inventory[0].Itemstack.Block).receiveEnergy(inventory[0].Itemstack, (int)Math.Min(energyStorage.getLimitExtract() * dt, energyStorage.getEnergyStored())));
     }
     MarkDirty();
 }