实体加速卡修改默认为2x,避免出现1x卡
This commit is contained in:
parent
e223b9fae6
commit
618992aa7c
|
|
@ -33,11 +33,20 @@ public class EntitySpeedCardItem extends UpgradeCardItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int readMultiplier(ItemStack stack) {
|
public static int readMultiplier(ItemStack stack) {
|
||||||
if (stack == null || stack.isEmpty()) return 1;
|
if (stack == null || stack.isEmpty()) return 2;
|
||||||
CompoundTag t = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
if (t == null) return 1;
|
if (tag == null || !tag.contains(NBT_MULTIPLIER)) {
|
||||||
int v = t.getInt(NBT_MULTIPLIER);
|
// 关键:检测到没有 NBT,直接强制写一个默认合法值
|
||||||
return v <= 0 ? 1 : v;
|
CompoundTag newTag = stack.getOrCreateTag();
|
||||||
|
newTag.putInt(NBT_MULTIPLIER, 2);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
int v = tag.getInt(NBT_MULTIPLIER);
|
||||||
|
// 合法性检查
|
||||||
|
return switch (v) {
|
||||||
|
case 2, 4, 8, 16 -> v;
|
||||||
|
default -> 2; // 非法值一律纠正为 x2
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -54,8 +63,7 @@ public class EntitySpeedCardItem extends UpgradeCardItem {
|
||||||
return Component.translatable(key);
|
return Component.translatable(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Component> getTooltipLines(ItemStack stack) {
|
||||||
public List<Component> getTooltipLines(ItemStack stack) {
|
|
||||||
int mult = readMultiplier(stack);
|
int mult = readMultiplier(stack);
|
||||||
long cap = 1L;
|
long cap = 1L;
|
||||||
switch (mult) {
|
switch (mult) {
|
||||||
|
|
@ -76,6 +84,4 @@ public class EntitySpeedCardItem extends UpgradeCardItem {
|
||||||
// add our custom tooltip lines (multiplier and max)
|
// add our custom tooltip lines (multiplier and max)
|
||||||
lines.addAll(this.getTooltipLines(stack));
|
lines.addAll(this.getTooltipLines(stack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user