优化NBT#Charging
This commit is contained in:
parent
4830dc1366
commit
e987542772
7 changed files with 13 additions and 17 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.client;
|
package com.atsuishio.superbwarfare.client;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import net.minecraft.client.model.HumanoidModel;
|
import net.minecraft.client.model.HumanoidModel;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
@ -14,7 +15,7 @@ public class PoseTool {
|
||||||
if (stack.getOrCreateTag().getBoolean("is_empty_reloading")
|
if (stack.getOrCreateTag().getBoolean("is_empty_reloading")
|
||||||
|| stack.getOrCreateTag().getBoolean("is_normal_reloading")
|
|| stack.getOrCreateTag().getBoolean("is_normal_reloading")
|
||||||
|| stack.getOrCreateTag().getBoolean("reloading")
|
|| stack.getOrCreateTag().getBoolean("reloading")
|
||||||
|| stack.getOrCreateTag().getBoolean("sentinel_is_charging")) {
|
|| GunsTool.getGunBooleanTag(stack, "Charging")) {
|
||||||
return HumanoidModel.ArmPose.CROSSBOW_CHARGE;
|
return HumanoidModel.ArmPose.CROSSBOW_CHARGE;
|
||||||
} else if (entityLiving.isSprinting() && entityLiving.onGround() && entityLiving.getPersistentData().getDouble("noRun") == 0) {
|
} else if (entityLiving.isSprinting() && entityLiving.onGround() && entityLiving.getPersistentData().getDouble("noRun") == 0) {
|
||||||
return HumanoidModel.ArmPose.CROSSBOW_CHARGE;
|
return HumanoidModel.ArmPose.CROSSBOW_CHARGE;
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
|
||||||
float numR = (float) (1 - 0.9 * zt);
|
float numR = (float) (1 - 0.9 * zt);
|
||||||
float numP = (float) (1 - 0.98 * 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.setRotX(numR * main.getRotX());
|
||||||
main.setRotY(numR * main.getRotY());
|
main.setRotY(numR * main.getRotY());
|
||||||
main.setRotZ(numR * main.getRotZ());
|
main.setRotZ(numR * main.getRotZ());
|
||||||
|
|
|
@ -824,7 +824,7 @@ public class GunEventHandler {
|
||||||
// 启动换弹
|
// 启动换弹
|
||||||
if (tag.getBoolean("start_sentinel_charge")) {
|
if (tag.getBoolean("start_sentinel_charge")) {
|
||||||
tag.putInt("sentinel_charge_time", 127);
|
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"));
|
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge"));
|
||||||
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
|
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
|
||||||
|
@ -866,7 +866,7 @@ public class GunEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getInt("sentinel_charge_time") == 1) {
|
if (tag.getInt("sentinel_charge_time") == 1) {
|
||||||
tag.putBoolean("sentinel_is_charging", false);
|
GunsTool.setGunBooleanTag(stack, "Charging", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,7 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldStack.is(ModItems.SENTINEL.get())) {
|
if (oldStack.is(ModItems.SENTINEL.get())) {
|
||||||
oldTags.putBoolean("sentinel_is_charging", false);
|
data.putBoolean("Charging", false);
|
||||||
oldTags.putInt("sentinel_charge_time", 0);
|
oldTags.putInt("sentinel_charge_time", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.is(ModItems.SENTINEL.get())) {
|
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);
|
newStack.getOrCreateTag().putInt("sentinel_charge_time", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.reload_normal"));
|
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"));
|
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()
|
if (player.isSprinting() && player.onGround()
|
||||||
&& player.getPersistentData().getDouble("noRun") == 0
|
&& player.getPersistentData().getDouble("noRun") == 0
|
||||||
&& !(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
|
&& !(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) {
|
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && stack.getOrCreateTag().getInt("bolt_action_anim") == 0) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sentinel.run_fast"));
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sentinel.run_fast"));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class FireModeMessage {
|
||||||
&& !player.isSpectator()
|
&& !player.isSpectator()
|
||||||
&& !(player.getCooldowns().isOnCooldown(stack.getItem()))
|
&& !(player.getCooldowns().isOnCooldown(stack.getItem()))
|
||||||
&& GunsTool.getGunIntTag(stack, "ReloadTime") == 0
|
&& GunsTool.getGunIntTag(stack, "ReloadTime") == 0
|
||||||
&& !stack.getOrCreateTag().getBoolean("sentinel_is_charging")) {
|
&& !GunsTool.getGunBooleanTag(stack, "Charging")) {
|
||||||
|
|
||||||
for (var cell : player.getInventory().items) {
|
for (var cell : player.getInventory().items) {
|
||||||
if (cell.is(ModItems.CELL.get())) {
|
if (cell.is(ModItems.CELL.get())) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class ReloadMessage {
|
||||||
|
|
||||||
if (!player.isSpectator()
|
if (!player.isSpectator()
|
||||||
&& stack.getItem() instanceof GunItem gunItem
|
&& stack.getItem() instanceof GunItem gunItem
|
||||||
&& !stack.getOrCreateTag().getBoolean("sentinel_is_charging")
|
&& !GunsTool.getGunBooleanTag(stack, "Charging")
|
||||||
&& GunsTool.getGunIntTag(stack, "ReloadTime") == 0
|
&& GunsTool.getGunIntTag(stack, "ReloadTime") == 0
|
||||||
&& stack.getOrCreateTag().getInt("bolt_action_anim") == 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);
|
boolean clipLoad = GunsTool.getGunIntTag(stack, "Ammo", 0) == 0 && gunItem.isClipReload(stack);
|
||||||
|
|
||||||
// 检查备弹
|
// 检查备弹
|
||||||
int count = 0;
|
boolean hasCreativeAmmoBox = player.getInventory().hasAnyMatching(item -> item.is(ModItems.CREATIVE_AMMO_BOX.get()));
|
||||||
for (var inv : player.getInventory().items) {
|
|
||||||
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count == 0) {
|
if (!hasCreativeAmmoBox) {
|
||||||
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) {
|
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) {
|
||||||
return;
|
return;
|
||||||
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) {
|
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue