优化NBT#Reloading Charging
This commit is contained in:
parent
ef1cedbf0a
commit
8c7b576699
14 changed files with 25 additions and 26 deletions
|
@ -320,8 +320,8 @@ public class ClickHandler {
|
|||
|
||||
if (stack.getItem() instanceof GunItem gunItem && !(player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity)) {
|
||||
if ((!(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
|
||||
&& !stack.getOrCreateTag().getBoolean("reloading")
|
||||
&& !stack.getOrCreateTag().getBoolean("charging")
|
||||
&& !GunsTool.getGunBooleanTag(stack, "Reloading")
|
||||
&& !GunsTool.getGunBooleanTag(stack, "Charging")
|
||||
&& !GunsTool.getGunBooleanTag(stack, "NeedBoltAction", false))
|
||||
&& cantFireTime == 0
|
||||
&& drawTime < 0.01
|
||||
|
|
|
@ -14,7 +14,7 @@ public class PoseTool {
|
|||
public static HumanoidModel.ArmPose pose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
|
||||
if (stack.getOrCreateTag().getBoolean("is_empty_reloading")
|
||||
|| stack.getOrCreateTag().getBoolean("is_normal_reloading")
|
||||
|| stack.getOrCreateTag().getBoolean("reloading")
|
||||
|| GunsTool.getGunBooleanTag(stack, "Reloading")
|
||||
|| GunsTool.getGunBooleanTag(stack, "Charging")) {
|
||||
return HumanoidModel.ArmPose.CROSSBOW_CHARGE;
|
||||
} else if (entityLiving.isSprinting() && entityLiving.onGround() && entityLiving.getPersistentData().getDouble("noRun") == 0) {
|
||||
|
|
|
@ -107,7 +107,7 @@ public class K98ItemModel extends GeoModel<K98Item> {
|
|||
float numR = (float) (1 - 0.52 * zt);
|
||||
float numP = (float) (1 - 0.58 * zt);
|
||||
|
||||
if (GunsTool.getGunIntTag(stack, "ReloadTime") > 0 || stack.getOrCreateTag().getBoolean("reloading")) {
|
||||
if (GunsTool.getGunIntTag(stack, "ReloadTime") > 0 || GunsTool.getGunBooleanTag(stack, "Reloading")) {
|
||||
main.setRotX(numR * main.getRotX());
|
||||
main.setRotY(numR * main.getRotY());
|
||||
main.setRotZ(numR * main.getRotZ());
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
|||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.shotgun.M870Item;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -98,8 +99,7 @@ public class M870ItemModel extends GeoModel<M870Item> {
|
|||
float numR = (float) (1 - 0.72 * zt);
|
||||
float numP = (float) (1 - 0.82 * zt);
|
||||
|
||||
// TODO 修改本nbt
|
||||
if (stack.getOrCreateTag().getBoolean("reloading")) {
|
||||
if (GunsTool.getGunBooleanTag(stack, "Reloading")) {
|
||||
main.setRotX(numR * main.getRotX());
|
||||
main.setRotY(numR * main.getRotY());
|
||||
main.setRotZ(numR * main.getRotZ());
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
|||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.rifle.MarlinItem;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -99,8 +100,7 @@ public class MarlinItemModel extends GeoModel<MarlinItem> {
|
|||
float numR = (float) (1 - 0.55 * zt);
|
||||
float numP = (float) (1 - 0.88 * zt);
|
||||
|
||||
// TODO 修改本nbt
|
||||
if (stack.getOrCreateTag().getBoolean("reloading")) {
|
||||
if (GunsTool.getGunBooleanTag(stack, "Reloading")) {
|
||||
main.setRotX(numR * main.getRotX());
|
||||
main.setRotY(numR * main.getRotY());
|
||||
main.setRotZ(numR * main.getRotZ());
|
||||
|
|
|
@ -121,8 +121,7 @@ public class MosinNagantItemModel extends GeoModel<MosinNagantItem> {
|
|||
float numR = (float) (1 - 0.97 * zt);
|
||||
float numP = (float) (1 - 0.81 * zt);
|
||||
|
||||
// TODO 修改本nbt
|
||||
if (stack.getOrCreateTag().getBoolean("reloading") || GunsTool.getGunIntTag(stack, "BoltActionTick") > 0) {
|
||||
if (GunsTool.getGunBooleanTag(stack, "Reloading") || GunsTool.getGunIntTag(stack, "BoltActionTick") > 0) {
|
||||
main.setRotX(numR * main.getRotX());
|
||||
main.setRotY(numR * main.getRotY());
|
||||
main.setRotZ(numR * main.getRotZ());
|
||||
|
|
|
@ -348,8 +348,8 @@ public class ClientEventHandler {
|
|||
&& !notInGame()
|
||||
&& !player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit
|
||||
&& (!(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
|
||||
&& !stack.getOrCreateTag().getBoolean("reloading")
|
||||
&& !stack.getOrCreateTag().getBoolean("charging")
|
||||
&& !GunsTool.getGunBooleanTag(stack, "Reloading")
|
||||
&& !GunsTool.getGunBooleanTag(stack, "Charging")
|
||||
&& GunsTool.getGunIntTag(stack, "Ammo", 0) > 0
|
||||
&& !player.getCooldowns().isOnCooldown(stack.getItem())
|
||||
&& !GunsTool.getGunBooleanTag(stack, "NeedBoltAction", false)
|
||||
|
|
|
@ -542,7 +542,7 @@ public class GunEventHandler {
|
|||
tag.putBoolean("force_stop", false);
|
||||
tag.putBoolean("stop", false);
|
||||
tag.putInt("reload_stage", 1);
|
||||
tag.putBoolean("reloading", true);
|
||||
GunsTool.setGunBooleanTag(stack, "Reloading", true);
|
||||
tag.putBoolean("start_single_reload", false);
|
||||
}
|
||||
|
||||
|
@ -661,7 +661,7 @@ public class GunEventHandler {
|
|||
if (GunsTool.getGunIntTag(stack, "BoltActionTime", 0) > 0) {
|
||||
GunsTool.setGunBooleanTag(stack, "NeedBoltAction", false);
|
||||
}
|
||||
tag.putBoolean("reloading", false);
|
||||
GunsTool.setGunBooleanTag(stack, "Reloading", false);
|
||||
tag.putBoolean("start_single_reload", false);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack));
|
||||
|
|
|
@ -343,7 +343,7 @@ public class LivingEventHandler {
|
|||
oldTags.putBoolean("force_stop", false);
|
||||
oldTags.putBoolean("stop", false);
|
||||
oldTags.putInt("reload_stage", 0);
|
||||
oldTags.putBoolean("reloading", false);
|
||||
data.putBoolean("Reloading", false);
|
||||
oldTags.putDouble("prepare", 0);
|
||||
oldTags.putDouble("prepare_load", 0);
|
||||
oldTags.putDouble("iterative", 0);
|
||||
|
@ -378,7 +378,7 @@ public class LivingEventHandler {
|
|||
newStack.getOrCreateTag().putBoolean("force_stop", false);
|
||||
newStack.getOrCreateTag().putBoolean("stop", false);
|
||||
newStack.getOrCreateTag().putInt("reload_stage", 0);
|
||||
newStack.getOrCreateTag().putBoolean("reloading", false);
|
||||
GunsTool.setGunBooleanTag(newStack, "Reloading", false);
|
||||
newStack.getOrCreateTag().putDouble("prepare", 0);
|
||||
newStack.getOrCreateTag().putDouble("prepare_load", 0);
|
||||
newStack.getOrCreateTag().putDouble("iterative", 0);
|
||||
|
|
|
@ -111,7 +111,7 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
&& player.onGround()
|
||||
&& player.getPersistentData().getDouble("noRun") == 0
|
||||
&& ClientEventHandler.drawTime < 0.01
|
||||
&& !stack.getOrCreateTag().getBoolean("reloading")) {
|
||||
&& !GunsTool.getGunBooleanTag(stack, "Reloading")) {
|
||||
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.marlin.run_fast"));
|
||||
} else {
|
||||
|
|
|
@ -116,7 +116,7 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
&& player.onGround()
|
||||
&& player.getPersistentData().getDouble("noRun") == 0
|
||||
&& ClientEventHandler.drawTime < 0.01
|
||||
&& !stack.getOrCreateTag().getBoolean("reloading")) {
|
||||
&& !GunsTool.getGunBooleanTag(stack, "Reloading")) {
|
||||
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m870.run_fast"));
|
||||
} else {
|
||||
|
|
|
@ -113,7 +113,7 @@ public class K98Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
&& stack.getOrCreateTag().getInt("reload_stage") != 2
|
||||
&& stack.getOrCreateTag().getInt("reload_stage") != 3
|
||||
&& ClientEventHandler.drawTime < 0.01
|
||||
&& !stack.getOrCreateTag().getBoolean("reloading")) {
|
||||
&& !GunsTool.getGunBooleanTag(stack, "Reloading")) {
|
||||
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(stack, "BoltActionTick") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.k98.run_fast"));
|
||||
} else {
|
||||
|
|
|
@ -113,7 +113,7 @@ public class MosinNagantItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
&& stack.getOrCreateTag().getInt("reload_stage") != 2
|
||||
&& stack.getOrCreateTag().getInt("reload_stage") != 3
|
||||
&& ClientEventHandler.drawTime < 0.01
|
||||
&& !stack.getOrCreateTag().getBoolean("reloading")) {
|
||||
&& !GunsTool.getGunBooleanTag(stack, "Reloading")) {
|
||||
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(stack, "BoltActionTick") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mosin.run_fast"));
|
||||
} else {
|
||||
|
|
|
@ -130,7 +130,7 @@ public class FireMessage {
|
|||
}
|
||||
}
|
||||
|
||||
if (tag.getDouble("prepare") == 0 && tag.getBoolean("reloading") && GunsTool.getGunIntTag(stack, "Ammo", 0) > 0) {
|
||||
if (tag.getDouble("prepare") == 0 && GunsTool.getGunBooleanTag(stack, "Reloading") && GunsTool.getGunIntTag(stack, "Ammo", 0) > 0) {
|
||||
tag.putDouble("force_stop", 1);
|
||||
}
|
||||
|
||||
|
@ -146,8 +146,8 @@ public class FireMessage {
|
|||
if (GunsTool.getGunIntTag(stack, "BoltActionTime", 0) > 0 && GunsTool.getGunIntTag(stack, "Ammo", 0) > (stack.is(ModTags.Items.REVOLVER) ? -1 : 0)
|
||||
&& GunsTool.getGunIntTag(stack, "BoltActionTick") == 0
|
||||
&& !(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
|
||||
&& !stack.getOrCreateTag().getBoolean("reloading")
|
||||
&& !stack.getOrCreateTag().getBoolean("charging")) {
|
||||
&& !GunsTool.getGunBooleanTag(stack, "Reloading")
|
||||
&& !GunsTool.getGunBooleanTag(stack, "Charging")) {
|
||||
if (!player.getCooldowns().isOnCooldown(stack.getItem()) && GunsTool.getGunBooleanTag(stack, "NeedBoltAction", false)) {
|
||||
GunsTool.setGunIntTag(stack, "BoltActionTick", GunsTool.getGunIntTag(stack, "BoltActionTime", 0) + 1);
|
||||
GunEventHandler.playGunBoltSounds(player);
|
||||
|
@ -307,7 +307,7 @@ public class FireMessage {
|
|||
if (player.isSpectator()) return;
|
||||
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!stack.getOrCreateTag().getBoolean("reloading")) {
|
||||
if (!GunsTool.getGunBooleanTag(stack, "Reloading")) {
|
||||
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.VOLT_OVERLOAD.get(), stack);
|
||||
AtomicBoolean flag = new AtomicBoolean(false);
|
||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||
|
@ -357,7 +357,7 @@ public class FireMessage {
|
|||
if (player.isSpectator()) return;
|
||||
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!stack.getOrCreateTag().getBoolean("reloading")) {
|
||||
if (!GunsTool.getGunBooleanTag(stack, "Reloading")) {
|
||||
if (!player.getCooldowns().isOnCooldown(stack.getItem()) && GunsTool.getGunIntTag(stack, "Ammo", 0) > 0) {
|
||||
boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom;
|
||||
double spread = GunsTool.getGunDoubleTag(stack, "Spread");
|
||||
|
@ -412,7 +412,7 @@ public class FireMessage {
|
|||
ItemStack stack = player.getMainHandItem();
|
||||
CompoundTag tag = stack.getOrCreateTag();
|
||||
|
||||
if (!tag.getBoolean("reloading") && !player.getCooldowns().isOnCooldown(stack.getItem()) && GunsTool.getGunIntTag(stack, "Ammo", 0) > 0) {
|
||||
if (!GunsTool.getGunBooleanTag(stack, "Reloading") && !player.getCooldowns().isOnCooldown(stack.getItem()) && GunsTool.getGunIntTag(stack, "Ammo", 0) > 0) {
|
||||
boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom;
|
||||
double spread = GunsTool.getGunDoubleTag(stack, "Spread");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue