优化NBT#Charging

This commit is contained in:
17146 2025-01-04 01:24:42 +08:00
parent 4830dc1366
commit e987542772
7 changed files with 13 additions and 17 deletions

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.client;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
@ -14,7 +15,7 @@ public class PoseTool {
if (stack.getOrCreateTag().getBoolean("is_empty_reloading")
|| stack.getOrCreateTag().getBoolean("is_normal_reloading")
|| stack.getOrCreateTag().getBoolean("reloading")
|| stack.getOrCreateTag().getBoolean("sentinel_is_charging")) {
|| GunsTool.getGunBooleanTag(stack, "Charging")) {
return HumanoidModel.ArmPose.CROSSBOW_CHARGE;
} else if (entityLiving.isSprinting() && entityLiving.onGround() && entityLiving.getPersistentData().getDouble("noRun") == 0) {
return HumanoidModel.ArmPose.CROSSBOW_CHARGE;

View file

@ -113,7 +113,7 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
float numR = (float) (1 - 0.9 * zt);
float numP = (float) (1 - 0.98 * zt);
if (GunsTool.getGunIntTag(stack, "ReloadTime") > 0 || stack.getOrCreateTag().getBoolean("sentinel_is_charging")) {
if (GunsTool.getGunIntTag(stack, "ReloadTime") > 0 || GunsTool.getGunBooleanTag(stack, "Charging")) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -824,7 +824,7 @@ public class GunEventHandler {
// 启动换弹
if (tag.getBoolean("start_sentinel_charge")) {
tag.putInt("sentinel_charge_time", 127);
stack.getOrCreateTag().putBoolean("sentinel_is_charging", true);
GunsTool.setGunBooleanTag(stack, "Charging", true);
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge"));
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
@ -866,7 +866,7 @@ public class GunEventHandler {
}
if (tag.getInt("sentinel_charge_time") == 1) {
tag.putBoolean("sentinel_is_charging", false);
GunsTool.setGunBooleanTag(stack, "Charging", false);
}
}

View file

@ -353,7 +353,7 @@ public class LivingEventHandler {
}
if (oldStack.is(ModItems.SENTINEL.get())) {
oldTags.putBoolean("sentinel_is_charging", false);
data.putBoolean("Charging", false);
oldTags.putInt("sentinel_charge_time", 0);
}
@ -388,7 +388,7 @@ public class LivingEventHandler {
}
if (newStack.is(ModItems.SENTINEL.get())) {
newStack.getOrCreateTag().putBoolean("sentinel_is_charging", false);
GunsTool.setGunBooleanTag(newStack, "Charging", false);
newStack.getOrCreateTag().putInt("sentinel_charge_time", 0);
}

View file

@ -136,7 +136,7 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.reload_normal"));
}
if (stack.getOrCreateTag().getBoolean("sentinel_is_charging")) {
if (GunsTool.getGunBooleanTag(stack, "Charging")) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.charge"));
}
@ -152,7 +152,7 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
if (player.isSprinting() && player.onGround()
&& player.getPersistentData().getDouble("noRun") == 0
&& !(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
&& !stack.getOrCreateTag().getBoolean("sentinel_is_charging") && ClientEventHandler.drawTime < 0.01) {
&& !GunsTool.getGunBooleanTag(stack, "Charging") && ClientEventHandler.drawTime < 0.01) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && stack.getOrCreateTag().getInt("bolt_action_anim") == 0) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sentinel.run_fast"));
} else {

View file

@ -98,7 +98,7 @@ public class FireModeMessage {
&& !player.isSpectator()
&& !(player.getCooldowns().isOnCooldown(stack.getItem()))
&& GunsTool.getGunIntTag(stack, "ReloadTime") == 0
&& !stack.getOrCreateTag().getBoolean("sentinel_is_charging")) {
&& !GunsTool.getGunBooleanTag(stack, "Charging")) {
for (var cell : player.getInventory().items) {
if (cell.is(ModItems.CELL.get())) {

View file

@ -51,7 +51,7 @@ public class ReloadMessage {
if (!player.isSpectator()
&& stack.getItem() instanceof GunItem gunItem
&& !stack.getOrCreateTag().getBoolean("sentinel_is_charging")
&& !GunsTool.getGunBooleanTag(stack, "Charging")
&& GunsTool.getGunIntTag(stack, "ReloadTime") == 0
&& stack.getOrCreateTag().getInt("bolt_action_anim") == 0
) {
@ -62,14 +62,9 @@ public class ReloadMessage {
boolean clipLoad = GunsTool.getGunIntTag(stack, "Ammo", 0) == 0 && gunItem.isClipReload(stack);
// 检查备弹
int count = 0;
for (var inv : player.getInventory().items) {
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
count++;
}
}
boolean hasCreativeAmmoBox = player.getInventory().hasAnyMatching(item -> item.is(ModItems.CREATIVE_AMMO_BOX.get()));
if (count == 0) {
if (!hasCreativeAmmoBox) {
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) {
return;
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) {