在重载数据包时正确清空对应缓存
This commit is contained in:
parent
8ffada46d8
commit
97bab5e46d
5 changed files with 10 additions and 1 deletions
|
@ -39,7 +39,7 @@ public class GunData {
|
|||
public final CompoundTag attachmentTag;
|
||||
public final String id;
|
||||
|
||||
private static final LoadingCache<ItemStack, GunData> dataCache = CacheBuilder.newBuilder()
|
||||
public static final LoadingCache<ItemStack, GunData> dataCache = CacheBuilder.newBuilder()
|
||||
.weakKeys()
|
||||
.build(new CacheLoader<>() {
|
||||
public @NotNull GunData load(@NotNull ItemStack stack) {
|
||||
|
|
|
@ -25,6 +25,7 @@ public class LaunchableEntityTool {
|
|||
*/
|
||||
public static void initJsonData(ResourceManager manager) {
|
||||
launchableEntitiesData.clear();
|
||||
|
||||
for (var entry : manager.listResources("launchable", file -> file.getPath().endsWith(".json")).entrySet()) {
|
||||
var attribute = entry.getValue();
|
||||
try {
|
||||
|
|
|
@ -19,6 +19,8 @@ public class VehicleDataTool {
|
|||
|
||||
public static void initJsonData(ResourceManager manager) {
|
||||
vehicleData.clear();
|
||||
VehicleData.dataCache.invalidateAll();
|
||||
|
||||
for (var entry : manager.listResources(VEHICLE_DATA_FOLDER, file -> file.getPath().endsWith(".json")).entrySet()) {
|
||||
var attribute = entry.getValue();
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ public abstract class EnergyVehicleEntity extends VehicleEntity {
|
|||
|
||||
public static final EntityDataAccessor<Integer> ENERGY = SynchedEntityData.defineId(EnergyVehicleEntity.class, EntityDataSerializers.INT);
|
||||
|
||||
// TODO 在数据更新时修改能量相关属性
|
||||
protected final IEnergyStorage energyStorage = new SyncedEntityEnergyStorage(this.getMaxEnergy(), this.entityData, ENERGY);
|
||||
|
||||
public EnergyVehicleEntity(EntityType<?> pEntityType, Level pLevel) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.tools;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.data.gun.DefaultGunData;
|
||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.network.message.receive.GunsDataMessage;
|
||||
import com.google.gson.Gson;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -28,6 +29,10 @@ public class GunsTool {
|
|||
* 初始化数据,从data中读取数据json文件
|
||||
*/
|
||||
public static void initJsonData(ResourceManager manager) {
|
||||
gunsData.clear();
|
||||
GunData.dataCache.invalidateAll();
|
||||
|
||||
// TODO 将枪械ID挪至JSON数据内
|
||||
for (var entry : manager.listResources("guns", file -> file.getPath().endsWith(".json")).entrySet()) {
|
||||
var id = entry.getKey();
|
||||
var attribute = entry.getValue();
|
||||
|
|
Loading…
Add table
Reference in a new issue