允许充电站内使用物品进行供能
This commit is contained in:
parent
512cddf520
commit
76cd1543cb
1 changed files with 14 additions and 1 deletions
|
@ -142,7 +142,19 @@ public class ChargingStationBlockEntity extends BlockEntity implements WorldlyCo
|
||||||
|
|
||||||
ItemStack fuel = blockEntity.getItem(SLOT_FUEL);
|
ItemStack fuel = blockEntity.getItem(SLOT_FUEL);
|
||||||
int burnTime = ForgeHooks.getBurnTime(fuel, RecipeType.SMELTING);
|
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.fuelTick = burnTime;
|
||||||
blockEntity.maxFuelTick = burnTime;
|
blockEntity.maxFuelTick = burnTime;
|
||||||
|
|
||||||
|
@ -168,6 +180,7 @@ public class ChargingStationBlockEntity extends BlockEntity implements WorldlyCo
|
||||||
|
|
||||||
blockEntity.setChanged();
|
blockEntity.setChanged();
|
||||||
} else if (fuel.getItem().isEdible()) {
|
} else if (fuel.getItem().isEdible()) {
|
||||||
|
// 最后作为食物处理
|
||||||
var properties = fuel.getFoodProperties(null);
|
var properties = fuel.getFoodProperties(null);
|
||||||
if (properties == null) return;
|
if (properties == null) return;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue