From 76cd1543cbb89e41294f98e223a58c317320cf77 Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Tue, 4 Mar 2025 02:27:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=E5=85=85=E7=94=B5=E7=AB=99?= =?UTF-8?q?=E5=86=85=E4=BD=BF=E7=94=A8=E7=89=A9=E5=93=81=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=BE=9B=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../block/entity/ChargingStationBlockEntity.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/block/entity/ChargingStationBlockEntity.java b/src/main/java/com/atsuishio/superbwarfare/block/entity/ChargingStationBlockEntity.java index a8c8789d0..5fecc2ca4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/entity/ChargingStationBlockEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/entity/ChargingStationBlockEntity.java @@ -142,7 +142,19 @@ public class ChargingStationBlockEntity extends BlockEntity implements WorldlyCo ItemStack fuel = blockEntity.getItem(SLOT_FUEL); int burnTime = ForgeHooks.getBurnTime(fuel, RecipeType.SMELTING); - if (burnTime > 0) { + + if (fuel.getCapability(ForgeCapabilities.ENERGY).isPresent()) { + // 优先当作电池处理 + fuel.getCapability(ForgeCapabilities.ENERGY).ifPresent(itemEnergy -> blockEntity.energyHandler.ifPresent(energy -> { + var energyToExtract = Math.min(CHARGE_OTHER_SPEED, energy.getMaxEnergyStored() - energy.getEnergyStored()); + if (itemEnergy.canExtract() && energy.canReceive()) { + energy.receiveEnergy(itemEnergy.extractEnergy(energyToExtract, false), false); + } + })); + + blockEntity.setChanged(); + } else if (burnTime > 0) { + // 其次尝试作为燃料处理 blockEntity.fuelTick = burnTime; blockEntity.maxFuelTick = burnTime; @@ -168,6 +180,7 @@ public class ChargingStationBlockEntity extends BlockEntity implements WorldlyCo blockEntity.setChanged(); } else if (fuel.getItem().isEdible()) { + // 最后作为食物处理 var properties = fuel.getFoodProperties(null); if (properties == null) return;