private void updateChargeIn() { ItemStack stack = this.getStackInSlot(0); if (stack != null && itemManager.isSupported(stack)) { // Charge into the node. double req = Math.min(getBandwidth(), getMaxEnergy() - energy); double pull = itemManager.pull(stack, req, false); chargingIn = pull != 0; this.setEnergy(energy + pull); } else { chargingIn = false; } }
private void updateChargeOut() { ItemStack stack = this.getStackInSlot(1); if (stack != null && itemManager.isSupported(stack)) { double cur = getEnergy(); if (cur > 0) { cur = Math.min(getBandwidth(), cur); double left = itemManager.charge(stack, cur); chargingOut = left != cur; this.setEnergy(getEnergy() - (cur - left)); } } else { chargingOut = false; } }