添加载具血量Jade显示

This commit is contained in:
Light_Quanta 2025-02-13 06:09:36 +08:00
parent 52b9888543
commit 9e924a0602
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
4 changed files with 41 additions and 2 deletions

View file

@ -2,7 +2,9 @@ package com.atsuishio.superbwarfare.compat.jade;
import com.atsuishio.superbwarfare.compat.jade.providers.EnergyVehicleProvider;
import com.atsuishio.superbwarfare.compat.jade.providers.VehicleHealthProvider;
import com.atsuishio.superbwarfare.entity.vehicle.EnergyVehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity;
import snownee.jade.api.IWailaClientRegistration;
import snownee.jade.api.IWailaCommonRegistration;
import snownee.jade.api.IWailaPlugin;
@ -18,6 +20,7 @@ public class SbwJadePlugin implements IWailaPlugin {
@Override
public void registerClient(IWailaClientRegistration registration) {
registration.registerEntityComponent(VehicleHealthProvider.INSTANCE, VehicleEntity.class);
registration.registerEntityComponent(EnergyVehicleProvider.INSTANCE, EnergyVehicleEntity.class);
}
}

View file

@ -0,0 +1,34 @@
package com.atsuishio.superbwarfare.compat.jade.providers;
import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity;
import net.minecraft.resources.ResourceLocation;
import snownee.jade.api.EntityAccessor;
import snownee.jade.api.IEntityComponentProvider;
import snownee.jade.api.ITooltip;
import snownee.jade.api.config.IPluginConfig;
import snownee.jade.impl.ui.HealthElement;
public enum VehicleHealthProvider implements IEntityComponentProvider {
INSTANCE;
private static final ResourceLocation ID = new ResourceLocation(ModUtils.MODID, "vehicle_health");
public void appendTooltip(ITooltip tooltip, EntityAccessor accessor, IPluginConfig config) {
// 对EntityHealthProvider的拙劣模仿
var vehicle = (VehicleEntity) accessor.getEntity();
float health = vehicle.getHealth();
float maxHealth = vehicle.getMaxHealth();
tooltip.add(new HealthElement(maxHealth, health));
}
public ResourceLocation getUid() {
return ID;
}
public int getDefaultPriority() {
return -4501;
}
}

View file

@ -522,5 +522,6 @@
"jei.superbwarfare.ancient_cpu": "Mysterious ancient technology, can be found at ancient cities.",
"jei.superbwarfare.charging_station": "Generates power by consuming fuel or food, and can also accept FE energy input. This block supplies FE energy to adjacent blocks, and can also charge rechargeable vehicles within range.",
"config.jade.plugin_superbwarfare.energy_vehicle": "Energy Vehicle"
"config.jade.plugin_superbwarfare.energy_vehicle": "Energy Vehicle",
"config.jade.plugin_superbwarfare.vehicle_health": "Vehicle Health"
}

View file

@ -522,5 +522,6 @@
"jei.superbwarfare.ancient_cpu": "神秘的古代科技,可以在古城找到。",
"jei.superbwarfare.charging_station": "使用燃料或食物进行发电也可以接收主动输入的FE能量。能够为相邻的方块提供FE能量为周围一定范围内的可充能载具充能。",
"config.jade.plugin_superbwarfare.energy_vehicle": "能量载具"
"config.jade.plugin_superbwarfare.energy_vehicle": "能量载具",
"config.jade.plugin_superbwarfare.vehicle_health": "载具血量"
}