修改充电站充能频率
This commit is contained in:
parent
4c6cd9be3b
commit
303e3c39ab
2 changed files with 3 additions and 1 deletions
|
@ -190,11 +190,12 @@ public class ChargingStationBlockEntity extends BlockEntity implements WorldlyCo
|
|||
|
||||
private void chargeEntity(EnergyStorage handler) {
|
||||
if (this.level == null) return;
|
||||
if (this.level.getGameTime() % 20 != 0) return;
|
||||
|
||||
List<Entity> entities = this.level.getEntitiesOfClass(Entity.class, new AABB(this.getBlockPos()).inflate(CHARGE_RADIUS));
|
||||
entities.forEach(entity -> entity.getCapability(ForgeCapabilities.ENERGY).ifPresent(cap -> {
|
||||
if (cap.canReceive()) {
|
||||
int charged = cap.receiveEnergy(Math.min(handler.getEnergyStored(), CHARGE_OTHER_SPEED), false);
|
||||
int charged = cap.receiveEnergy(Math.min(handler.getEnergyStored(), CHARGE_OTHER_SPEED * 20), false);
|
||||
handler.extractEnergy(charged, false);
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -42,6 +42,7 @@ public class CreativeChargingStationBlockEntity extends BlockEntity {
|
|||
|
||||
private void chargeEntity() {
|
||||
if (this.level == null) return;
|
||||
if (this.level.getGameTime() % 20 != 0) return;
|
||||
|
||||
List<Entity> entities = this.level.getEntitiesOfClass(Entity.class, new AABB(this.getBlockPos()).inflate(CHARGE_RADIUS));
|
||||
entities.forEach(entity -> entity.getCapability(ForgeCapabilities.ENERGY).ifPresent(cap -> {
|
||||
|
|
Loading…
Add table
Reference in a new issue