优化NBT#ChargeTime

This commit is contained in:
17146 2025-01-04 02:12:59 +08:00
parent 8c7b576699
commit 9447216b54
2 changed files with 7 additions and 9 deletions

View file

@ -824,7 +824,7 @@ public class GunEventHandler {
CompoundTag tag = stack.getOrCreateTag();
// 启动换弹
if (tag.getBoolean("start_sentinel_charge")) {
tag.putInt("sentinel_charge_time", 127);
GunsTool.setGunIntTag(stack, "ChargeTime", 127);
GunsTool.setGunBooleanTag(stack, "Charging", true);
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge"));
@ -835,12 +835,11 @@ public class GunEventHandler {
tag.putBoolean("start_sentinel_charge", false);
}
if (tag.getInt("sentinel_charge_time") > 0) {
tag.putInt("sentinel_charge_time", tag.getInt("sentinel_charge_time") - 1);
if (GunsTool.getGunIntTag(stack, "ChargeTime", 0) > 0) {
GunsTool.setGunIntTag(stack, "ChargeTime", GunsTool.getGunIntTag(stack, "ChargeTime", 0) - 1);
}
if (tag.getInt("sentinel_charge_time") == 17) {
if (GunsTool.getGunIntTag(stack, "ChargeTime", 0) == 17) {
for (var cell : player.getInventory().items) {
if (cell.is(ModItems.CELL.get())) {
assert stack.getCapability(ForgeCapabilities.ENERGY).resolve().isPresent();
@ -866,9 +865,8 @@ public class GunEventHandler {
}
}
if (tag.getInt("sentinel_charge_time") == 1) {
if (GunsTool.getGunIntTag(stack, "ChargeTime", 0) == 1) {
GunsTool.setGunBooleanTag(stack, "Charging", false);
}
}
}

View file

@ -352,7 +352,7 @@ public class LivingEventHandler {
if (oldStack.is(ModItems.SENTINEL.get())) {
data.putBoolean("Charging", false);
oldTags.putInt("sentinel_charge_time", 0);
data.putInt("ChargeTime", 0);
}
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
@ -387,7 +387,7 @@ public class LivingEventHandler {
if (newStack.is(ModItems.SENTINEL.get())) {
GunsTool.setGunBooleanTag(newStack, "Charging", false);
newStack.getOrCreateTag().putInt("sentinel_charge_time", 0);
GunsTool.setGunIntTag(newStack, "ChargeTime", 0);
}
int level = PerkHelper.getItemPerkLevel(ModPerks.KILLING_TALLY.get(), newStack);