优化NBT#ChargeTime
This commit is contained in:
parent
8c7b576699
commit
9447216b54
2 changed files with 7 additions and 9 deletions
|
@ -824,7 +824,7 @@ public class GunEventHandler {
|
||||||
CompoundTag tag = stack.getOrCreateTag();
|
CompoundTag tag = stack.getOrCreateTag();
|
||||||
// 启动换弹
|
// 启动换弹
|
||||||
if (tag.getBoolean("start_sentinel_charge")) {
|
if (tag.getBoolean("start_sentinel_charge")) {
|
||||||
tag.putInt("sentinel_charge_time", 127);
|
GunsTool.setGunIntTag(stack, "ChargeTime", 127);
|
||||||
GunsTool.setGunBooleanTag(stack, "Charging", true);
|
GunsTool.setGunBooleanTag(stack, "Charging", true);
|
||||||
|
|
||||||
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge"));
|
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);
|
tag.putBoolean("start_sentinel_charge", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getInt("sentinel_charge_time") > 0) {
|
if (GunsTool.getGunIntTag(stack, "ChargeTime", 0) > 0) {
|
||||||
tag.putInt("sentinel_charge_time", tag.getInt("sentinel_charge_time") - 1);
|
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) {
|
for (var cell : player.getInventory().items) {
|
||||||
if (cell.is(ModItems.CELL.get())) {
|
if (cell.is(ModItems.CELL.get())) {
|
||||||
assert stack.getCapability(ForgeCapabilities.ENERGY).resolve().isPresent();
|
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);
|
GunsTool.setGunBooleanTag(stack, "Charging", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,7 +352,7 @@ public class LivingEventHandler {
|
||||||
|
|
||||||
if (oldStack.is(ModItems.SENTINEL.get())) {
|
if (oldStack.is(ModItems.SENTINEL.get())) {
|
||||||
data.putBoolean("Charging", false);
|
data.putBoolean("Charging", false);
|
||||||
oldTags.putInt("sentinel_charge_time", 0);
|
data.putInt("ChargeTime", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
|
@ -387,7 +387,7 @@ public class LivingEventHandler {
|
||||||
|
|
||||||
if (newStack.is(ModItems.SENTINEL.get())) {
|
if (newStack.is(ModItems.SENTINEL.get())) {
|
||||||
GunsTool.setGunBooleanTag(newStack, "Charging", false);
|
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);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.KILLING_TALLY.get(), newStack);
|
||||||
|
|
Loading…
Add table
Reference in a new issue