正确检查载具EnergyStorage
This commit is contained in:
parent
8bbeff2e7a
commit
c39cb62469
4 changed files with 36 additions and 28 deletions
|
@ -232,6 +232,7 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
poseStack.popPose();
|
||||
|
||||
// 能量警告
|
||||
if (mobileVehicle.hasEnergyStorage()) {
|
||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("NO POWER!"),
|
||||
(int) x - 144, (int) y + 14, -65536, false);
|
||||
|
@ -241,6 +242,7 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 准星
|
||||
{
|
||||
|
|
|
@ -138,6 +138,7 @@ public class HelicopterHudOverlay implements LayeredDraw.Layer {
|
|||
w / 2 - 42, h / 2 + 24, -65536, false);
|
||||
}
|
||||
|
||||
if (mobileVehicle.hasEnergyStorage()) {
|
||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("NO POWER!"),
|
||||
w / 2 - 144, h / 2 + 14, -65536, false);
|
||||
|
@ -145,6 +146,7 @@ public class HelicopterHudOverlay implements LayeredDraw.Layer {
|
|||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("LOW POWER"),
|
||||
w / 2 - 144, h / 2 + 14, 0xFF6B00, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -251,6 +251,7 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
w / 2 + 160, h / 2 - 48, 0x66FF00, false);
|
||||
|
||||
// 低电量警告
|
||||
if (mobileVehicle.hasEnergyStorage()) {
|
||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(mc.font, Component.literal("NO POWER!"),
|
||||
w / 2 - 144, h / 2 + 14, -65536, false);
|
||||
|
@ -258,6 +259,7 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
guiGraphics.drawString(mc.font, Component.literal("LOW POWER"),
|
||||
w / 2 - 144, h / 2 + 14, 0xFF6B00, false);
|
||||
}
|
||||
}
|
||||
|
||||
// 测距
|
||||
boolean lookAtEntity = false;
|
||||
|
|
|
@ -74,6 +74,7 @@ public abstract class ContainerMobileVehicleEntity extends MobileVehicleEntity i
|
|||
public void baseTick() {
|
||||
super.baseTick();
|
||||
|
||||
if (this.hasEnergyStorage() && this.tickCount % 20 == 0) {
|
||||
for (var stack : this.getItemStacks()) {
|
||||
int neededEnergy = this.getMaxEnergy() - this.getEnergy();
|
||||
if (neededEnergy <= 0) break;
|
||||
|
@ -88,6 +89,7 @@ public abstract class ContainerMobileVehicleEntity extends MobileVehicleEntity i
|
|||
energyCap.extractEnergy(energyToExtract, false);
|
||||
this.setEnergy(this.getEnergy() + energyToExtract);
|
||||
}
|
||||
}
|
||||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue