提取更多属性,优化GunData调用方法

This commit is contained in:
Light_Quanta 2025-04-06 05:52:15 +08:00
parent 1b614de660
commit c7a15bb859
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
98 changed files with 491 additions and 420 deletions

View file

@ -1,8 +1,7 @@
package com.atsuishio.superbwarfare.client;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.NBTTool;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Minecraft;
@ -83,7 +82,8 @@ public class AnimationHelper {
}
public static void handleReloadShakeAnimation(ItemStack stack, GeoBone main, GeoBone camera, float roll, float pitch) {
if (GunsTool.getGunIntTag(NBTTool.getTag(stack), "ReloadTime") > 0) {
var data = GunData.from(stack);
if (data.reload.time() > 0) {
main.setRotX(roll * main.getRotX());
main.setRotY(roll * main.getRotY());
main.setRotZ(roll * main.getRotZ());

View file

@ -9,11 +9,10 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.network.message.send.*;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.NBTTool;
import com.atsuishio.superbwarfare.tools.SeekTool;
import com.atsuishio.superbwarfare.tools.TraceTool;
@ -337,16 +336,14 @@ public class ClickHandler {
var tag = data.tag();
player.playSound(ModSounds.TRIGGER_CLICK.get(), 1, 1);
if (!gunItem.useBackpackAmmo(stack) && data.ammo() <= 0 && GunsTool.getGunIntTag(tag, "ReloadTime") == 0) {
if (!gunItem.useBackpackAmmo(stack) && data.ammo() <= 0 && data.reload.time() == 0) {
if (ReloadConfig.LEFT_CLICK_RELOAD.get()) {
PacketDistributor.sendToServer(new ReloadMessage(0));
ClientEventHandler.burstFireAmount = 0;
}
} else {
PacketDistributor.sendToServer(new FireMessage(0));
if ((!data.reloading() && !data.charging()
&& !GunsTool.getGunBooleanTag(tag, "NeedBoltAction")
) && drawTime < 0.01) {
if ((!data.reloading() && !data.charging() && !data.bolt.needed()) && drawTime < 0.01) {
if (data.fireMode() == 1) {
if (ClientEventHandler.burstFireAmount == 0) {
ClientEventHandler.burstFireAmount = data.burstAmount();

View file

@ -1,7 +1,7 @@
package com.atsuishio.superbwarfare.client;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.rifle.AK12Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.rifle.AK47Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;

View file

@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.special.BocekItem;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.machinegun.DevotionItem;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.handgun.Glock17Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
@ -106,7 +106,7 @@ public class Glock17ItemModel extends GeoModel<Glock17Item> {
var data = GunData.from(stack);
var tag = data.tag();
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
if (data.reload.time() > 0) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.handgun.Glock18Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
@ -115,7 +115,7 @@ public class Glock18ItemModel extends GeoModel<Glock18Item> {
float numR = (float) (1 - 0.12 * zt);
float numP = (float) (1 - 0.68 * zt);
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
if (data.reload.time() > 0) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.rifle.Hk416Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.rifle.InsidiousItem;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;

View file

@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.launcher.JavelinItem;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;

View file

@ -4,9 +4,8 @@ import com.atsuishio.superbwarfare.Mod;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.sniper.K98Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
@ -109,7 +108,7 @@ public class K98ItemModel extends GeoModel<K98Item> {
float numR = (float) (1 - 0.52 * zt);
float numP = (float) (1 - 0.58 * zt);
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0 || data.reloading()) {
if (data.reload.time() > 0 || data.reloading()) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.handgun.M1911Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
@ -107,7 +107,7 @@ public class M1911ItemModel extends GeoModel<M1911Item> {
var data = GunData.from(stack);
var tag = data.tag();
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
if (data.reload.time() > 0) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.rifle.M4Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.NBTTool;

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.machinegun.M60Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
@ -154,7 +154,7 @@ public class M60ItemModel extends GeoModel<M60Item> {
AnimationHelper.handleShellsAnimation(getAnimationProcessor(), 1f, 0.45f);
GeoBone shell = getAnimationProcessor().getBone("shell");
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
if (data.reload.time() > 0) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.shotgun.M870Item;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;

View file

@ -4,9 +4,8 @@ import com.atsuishio.superbwarfare.Mod;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.sniper.M98bItem;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
@ -108,7 +107,7 @@ public class M98bItemModel extends GeoModel<M98bItem> {
float numR = (float) (1 - 0.88 * zt);
float numP = (float) (1 - 0.68 * zt);
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
if (data.reload.time() > 0) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.rifle.MarlinItem;
import com.atsuishio.superbwarfare.tools.NBTTool;
import net.minecraft.client.Minecraft;

View file

@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.machinegun.MinigunItem;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.rifle.Mk14Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;

View file

@ -4,9 +4,8 @@ import com.atsuishio.superbwarfare.Mod;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.sniper.MosinNagantItem;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
@ -125,7 +124,7 @@ public class MosinNagantItemModel extends GeoModel<MosinNagantItem> {
float numR = (float) (1 - 0.97 * zt);
float numP = (float) (1 - 0.81 * zt);
if (data.reloading() || GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
if (data.reloading() || data.bolt.actionTime() > 0) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.handgun.Mp443Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
@ -104,7 +104,7 @@ public class Mp443ItemModel extends GeoModel<Mp443Item> {
var data = GunData.from(stack);
var tag = data.tag();
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
if (data.reload.time() > 0) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
@ -164,7 +164,7 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
float numR = (float) (1 - 0.92 * zt);
float numP = (float) (1 - 0.88 * zt);
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0 || GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
if (data.reload.time() > 0 || data.bolt.actionTime() > 0) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.rifle.Qbz95Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.NBTTool;
@ -204,7 +204,7 @@ public class Qbz95ItemModel extends GeoModel<Qbz95Item> {
lHandRotZ = Mth.lerp(1.5f * times, lHandRotZ, isZooming ? 2.9228f : leftHand.getRotZ());
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
leftHand.setPosX(lHandPosX);
leftHand.setPosY(lHandPosY);
leftHand.setPosZ(lHandPosZ);

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.launcher.RpgItem;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.machinegun.RpkItem;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;

View file

@ -4,9 +4,8 @@ import com.atsuishio.superbwarfare.Mod;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.launcher.SecondaryCataclysm;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
@ -102,7 +101,7 @@ public class SecondaryCataclysmModel extends GeoModel<SecondaryCataclysm> {
var data = GunData.from(stack);
var tag = data.tag();
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
if (data.reload.time() > 0) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -4,9 +4,8 @@ import com.atsuishio.superbwarfare.Mod;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.sniper.SentinelItem;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
@ -118,7 +117,7 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
float numR = (float) (1 - 0.9 * zt);
float numP = (float) (1 - 0.98 * zt);
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0 || data.charging()) {
if (data.reload.time() > 0 || data.charging()) {
main.setRotX(numR * main.getRotX());
main.setRotY(numR * main.getRotY());
main.setRotZ(numR * main.getRotZ());

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.rifle.SksItem;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.sniper.SvdItem;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.handgun.Trachelium;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.NBTTool;
@ -165,7 +165,7 @@ public class TracheliumItemModel extends GeoModel<Trachelium> {
ammo.setRotZ(60 * Mth.DEG_TO_RAD * (float) ClientEventHandler.revolverWheelPreTime);
ammohole.setRotZ(-60 * Mth.DEG_TO_RAD * (float) ClientEventHandler.revolverWheelPreTime);
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
lun.setRotZ(0);
ammo.setRotZ(0);
ammohole.setRotZ(0);

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
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.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.smg.VectorItem;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;

View file

@ -9,8 +9,8 @@ import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModKeyMappings;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.common.ammo.AmmoSupplierItem;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.tools.AmmoType;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.InventoryTool;

View file

@ -6,7 +6,7 @@ import com.atsuishio.superbwarfare.client.RenderHelper;
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
import com.atsuishio.superbwarfare.tools.NBTTool;
import com.atsuishio.superbwarfare.tools.SeekTool;

View file

@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper;
import com.atsuishio.superbwarfare.client.model.item.RpkItemModel;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.machinegun.RpkItem;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.mojang.blaze3d.vertex.PoseStack;

View file

@ -4,8 +4,8 @@ import com.atsuishio.superbwarfare.client.TooltipTool;
import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent;
import com.atsuishio.superbwarfare.init.ModKeyMappings;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;

View file

@ -10,8 +10,8 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.network.message.send.*;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk;
@ -311,7 +311,7 @@ public class ClientEventHandler {
&& !holdFireVehicle
&& !notInGame()
&& cap != null && !cap.edit
&& !(data.normalReloading() || data.emptyReloading())
&& !(data.reload.normal() || data.reload.empty())
&& !data.reloading()
&& !data.charging()
&& !player.getCooldowns().isOnCooldown(stack.getItem())
@ -456,7 +456,7 @@ public class ClientEventHandler {
//左轮类
if (clientTimer.getProgress() == 0 && stack.is(ModTags.Items.REVOLVER) && ((holdFire && !tag.getBoolean("DA"))
|| (GunsTool.getGunIntTag(tag, "BoltActionTick") < 7 && GunsTool.getGunIntTag(tag, "BoltActionTick") > 2) || tag.getBoolean("canImmediatelyShoot"))) {
|| (data.bolt.actionTime() < 7 && data.bolt.actionTime() > 2) || tag.getBoolean("canImmediatelyShoot"))) {
revolverPreTime = Mth.clamp(revolverPreTime + 0.3 * times, 0, 1);
revolverWheelPreTime = Mth.clamp(revolverWheelPreTime + 0.32 * times, 0, revolverPreTime > 0.7 ? 1 : 0.55);
} else if (!tag.getBoolean("DA") && !tag.getBoolean("canImmediatelyShoot")) {
@ -473,12 +473,12 @@ public class ClientEventHandler {
&& drawTime < 0.01
&& cap != null && !cap.edit
&& !notInGame()
&& (!(data.normalReloading() || data.emptyReloading())
&& (!(data.reload.normal() || data.reload.empty())
&& !data.reloading()
&& !data.charging()
&& data.ammo() > 0
&& !player.getCooldowns().isOnCooldown(stack.getItem())
&& !GunsTool.getGunBooleanTag(tag, "NeedBoltAction")
&& !data.bolt.needed()
&& revolverPre(tag))
|| (stack.is(ModItems.MINIGUN.get())
&& !player.isSprinting()
@ -521,7 +521,7 @@ public class ClientEventHandler {
clientTimer.stop();
}
if (stack.getItem() == ModItems.DEVOTION.get() && (data.normalReloading() || data.emptyReloading())) {
if (stack.getItem() == ModItems.DEVOTION.get() && (data.reload.normal() || data.reload.empty())) {
customRpm = 0;
}
@ -586,8 +586,8 @@ public class ClientEventHandler {
}
// 判断是否为栓动武器BoltActionTime > 0并在开火后给一个需要上膛的状态
if (data.boltActionTime() > 0 && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) {
GunsTool.setGunBooleanTag(tag, "NeedBoltAction", true);
if (data.bolt.defaultActionTime() > 0 && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) {
data.bolt.markNeeded();
}
revolverPreTime = 0;

View file

@ -7,7 +7,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModMobEffects;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.tools.NBTTool;
import net.minecraft.client.CameraType;
import net.minecraft.client.Minecraft;

View file

@ -9,8 +9,9 @@ import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.data.ReloadState;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
@ -61,23 +62,22 @@ public class GunEventHandler {
/**
* 拉大栓
*/
private static void handleGunBolt(Player player, GunData gunData) {
private static void handleGunBolt(Player player, GunData data) {
ItemStack stack = player.getMainHandItem();
if (stack.is(ModTags.Items.NORMAL_GUN)) {
var tag = gunData.tag();
var data = gunData.data();
var tag = data.tag();
if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
data.putInt("BoltActionTick", GunsTool.getGunIntTag(tag, "BoltActionTick") - 1);
if (data.bolt.actionTime() > 0) {
data.bolt.reduceActionTime();
}
if (stack.getItem() == ModItems.MARLIN.get() && GunsTool.getGunIntTag(tag, "BoltActionTick") == 9) {
if (stack.getItem() == ModItems.MARLIN.get() && data.bolt.actionTime() == 9) {
tag.remove("IsEmpty");
}
if (GunsTool.getGunIntTag(tag, "BoltActionTick") == 1) {
GunsTool.setGunBooleanTag(tag, "NeedBoltAction", false);
if (data.bolt.actionTime() == 1) {
data.bolt.markNeedless();
if (stack.is(ModTags.Items.REVOLVER)) {
tag.putBoolean("canImmediatelyShoot", true);
}
@ -165,7 +165,7 @@ public class GunEventHandler {
if (stack.is(ModTags.Items.REVOLVER)) return;
Mod.queueServerWork((int) (data.boltActionTime() / 2 + 1.5 * shooterHeight), () -> {
Mod.queueServerWork((int) (data.bolt.defaultActionTime() / 2 + 1.5 * shooterHeight), () -> {
if (stack.is(ModTags.Items.SHOTGUN)) {
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_SHOTGUN.get(), (float) Math.max(0.75 - 0.12 * shooterHeight, 0), 1);
} else if (stack.is(ModTags.Items.SNIPER_RIFLE)) {
@ -316,53 +316,51 @@ public class GunEventHandler {
var data = gunData.data();
// 启动换弹
if (GunsTool.getGunBooleanTag(tag, "StartReload")) {
if (gunData.reload.shouldStart()) {
NeoForge.EVENT_BUS.post(new ReloadEvent.Pre(player, stack));
if (gunItem.isOpenBolt(stack)) {
if (gunData.ammo() == 0) {
data.putInt("ReloadTime", gunData.emptyReloadTime() + 1);
gunData.setReloadState(GunData.ReloadState.EMPTY_RELOADING);
gunData.reload.setTime(gunData.emptyReloadTime() + 1);
gunData.reload.setState(ReloadState.EMPTY_RELOADING);
playGunEmptyReloadSounds(player);
} else {
data.putInt("ReloadTime", gunData.normalReloadTime() + 1);
gunData.setReloadState(GunData.ReloadState.NORMAL_RELOADING);
gunData.reload.setTime(gunData.normalReloadTime() + 1);
gunData.reload.setState(ReloadState.NORMAL_RELOADING);
playGunNormalReloadSounds(player);
}
} else {
data.putInt("ReloadTime", gunData.emptyReloadTime() + 2);
gunData.setReloadState(GunData.ReloadState.EMPTY_RELOADING);
gunData.reload.setTime(gunData.emptyReloadTime() + 2);
gunData.reload.setState(ReloadState.EMPTY_RELOADING);
playGunEmptyReloadSounds(player);
}
data.remove("StartReload");
gunData.reload.markStarted();
}
if (data.getInt("ReloadTime") > 0) {
data.putInt("ReloadTime", data.getInt("ReloadTime") - 1);
}
gunData.reload.reduce();
if (stack.getItem() == ModItems.RPG.get()) {
if (data.getInt("ReloadTime") == 84) {
if (gunData.reload.time() == 84) {
tag.remove("IsEmpty");
}
if (data.getInt("ReloadTime") == 9) {
if (gunData.reload.time() == 9) {
data.remove("CloseHammer");
}
}
if (stack.getItem() == ModItems.MK_14.get() && data.getInt("ReloadTime") == 18) {
if (stack.getItem() == ModItems.MK_14.get() && gunData.reload.time() == 18) {
data.remove("HoldOpen");
}
if (stack.getItem() == ModItems.SVD.get() && data.getInt("ReloadTime") == 17) {
if (stack.getItem() == ModItems.SVD.get() && gunData.reload.time() == 17) {
data.remove("HoldOpen");
}
if (stack.getItem() == ModItems.SKS.get() && data.getInt("ReloadTime") == 14) {
if (stack.getItem() == ModItems.SKS.get() && gunData.reload.time() == 14) {
data.remove("HoldOpen");
}
if (stack.getItem() == ModItems.M_60.get() && data.getInt("ReloadTime") == 55) {
if (stack.getItem() == ModItems.M_60.get() && gunData.reload.time() == 55) {
data.remove("HideBulletChain");
}
@ -371,16 +369,16 @@ public class GunEventHandler {
|| stack.getItem() == ModItems.M_1911.get()
|| stack.getItem() == ModItems.MP_443.get()
) {
if (data.getInt("ReloadTime") == 9) {
if (gunData.reload.time() == 9) {
data.remove("HoldOpen");
}
}
if (stack.getItem() == ModItems.QBZ_95.get() && data.getInt("ReloadTime") == 14) {
if (stack.getItem() == ModItems.QBZ_95.get() && gunData.reload.time() == 14) {
data.remove("HoldOpen");
}
if (data.getInt("ReloadTime") == 1) {
if (gunData.reload.time() == 1) {
if (gunItem.isOpenBolt(stack)) {
if (gunData.ammo() == 0) {
playGunEmptyReload(player, gunData);
@ -390,7 +388,7 @@ public class GunEventHandler {
} else {
playGunEmptyReload(player, gunData);
}
data.remove("StartReload");
gunData.reload.markStarted();
}
}
@ -413,7 +411,7 @@ public class GunEventHandler {
GunsTool.reload(player, stack, gunData, AmmoType.HEAVY, gunItem.hasBulletInBarrel(stack));
}
}
gunData.setReloadState(GunData.ReloadState.NOT_RELOADING);
gunData.reload.setState(ReloadState.NOT_RELOADING);
NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack));
}
@ -447,7 +445,7 @@ public class GunEventHandler {
player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.JAVELIN_MISSILE.get(), 1, player.inventoryMenu.getCraftSlots());
}
}
gunData.setReloadState(GunData.ReloadState.NOT_RELOADING);
gunData.reload.setState(ReloadState.NOT_RELOADING);
NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack));
}
@ -541,8 +539,8 @@ public class GunEventHandler {
tag.remove("ForceStop");
tag.remove("Stopped");
gunData.setReloadStage(1);
gunData.setReloadState(GunData.ReloadState.NORMAL_RELOADING);
gunData.reload.setStage(1);
gunData.reload.setState(ReloadState.NORMAL_RELOADING);
tag.remove("StartSingleReload");
}
@ -575,26 +573,26 @@ public class GunEventHandler {
} else if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && gunData.ammo() >= gunData.magazine()) {
tag.putBoolean("ForceStartStage3", true);
} else {
gunData.setReloadStage(2);
gunData.reload.setStage(2);
}
} else {
if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && gunData.ammo() >= gunData.magazine()) {
tag.putBoolean("ForceStartStage3", true);
} else {
gunData.setReloadStage(2);
gunData.reload.setStage(2);
}
}
// 检查备弹
}
// 强制停止换弹进入三阶段
if (tag.getBoolean("ForceStop") && gunData.getReloadStage() == 2 && tag.getInt("IterativeLoadTime") > 0) {
if (tag.getBoolean("ForceStop") && gunData.reload.stage() == 2 && tag.getInt("IterativeLoadTime") > 0) {
tag.putBoolean("Stopped", true);
}
// 二阶段
if ((tag.getDouble("PrepareTime") == 0 || tag.getDouble("PrepareLoadTime") == 0)
&& gunData.getReloadStage() == 2
&& gunData.reload.stage() == 2
&& tag.getInt("IterativeLoadTime") == 0
&& !tag.getBoolean("Stopped")
&& gunData.ammo() < gunData.magazine()
@ -635,7 +633,7 @@ public class GunEventHandler {
if (tag.getInt("IterativeLoadTime") == 1) {
// 装满结束
if (gunData.ammo() >= gunData.magazine()) {
gunData.setReloadStage(3);
gunData.reload.setStage(3);
}
// 备弹耗尽结束
@ -644,29 +642,29 @@ public class GunEventHandler {
if (capability == null) capability = new PlayerVariable();
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) {
gunData.setReloadStage(3);
gunData.reload.setStage(3);
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) {
gunData.setReloadStage(3);
gunData.reload.setStage(3);
} else if ((stack.is(ModTags.Items.USE_HANDGUN_AMMO) || stack.is(ModTags.Items.SMG)) && capability.handgunAmmo == 0) {
gunData.setReloadStage(3);
gunData.reload.setStage(3);
} else if (stack.is(ModTags.Items.USE_RIFLE_AMMO) && capability.rifleAmmo == 0) {
gunData.setReloadStage(3);
gunData.reload.setStage(3);
} else if (stack.is(ModTags.Items.USE_HEAVY_AMMO) && capability.heavyAmmo == 0) {
gunData.setReloadStage(3);
gunData.reload.setStage(3);
}
}
// 强制结束
if (tag.getBoolean("Stopped")) {
gunData.setReloadStage(3);
gunData.reload.setStage(3);
tag.remove("ForceStop");
tag.remove("Stopped");
}
}
// 三阶段
if ((tag.getInt("IterativeLoadTime") == 1 && gunData.getReloadStage() == 3) || tag.getBoolean("ForceStartStage3")) {
gunData.setReloadStage(3);
if ((tag.getInt("IterativeLoadTime") == 1 && gunData.reload.stage() == 3) || tag.getBoolean("ForceStartStage3")) {
gunData.reload.setStage(3);
tag.remove("ForceStartStage3");
int finishTime = gunData.finishTime();
tag.putInt("FinishTime", finishTime + 2);
@ -680,11 +678,11 @@ public class GunEventHandler {
// 三阶段结束
if (tag.getInt("FinishTime") == 1) {
gunData.setReloadStage(0);
if (gunData.boltActionTime() > 0) {
GunsTool.setGunBooleanTag(tag, "NeedBoltAction", false);
gunData.reload.setStage(0);
if (gunData.bolt.defaultActionTime() > 0) {
gunData.bolt.markNeedless();
}
gunData.setReloadState(GunData.ReloadState.NOT_RELOADING);
gunData.reload.setState(ReloadState.NOT_RELOADING);
tag.remove("StartSingleReload");
NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack));

View file

@ -14,8 +14,9 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEnt
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.event.events.PreKillEvent;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.data.ReloadState;
import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage;
import com.atsuishio.superbwarfare.network.message.receive.DrawClientMessage;
import com.atsuishio.superbwarfare.network.message.receive.PlayerGunKillMessage;
@ -360,19 +361,19 @@ public class LivingEventHandler {
oldTag = oldData.tag();
var data = oldData.data();
if (oldData.boltActionTime() > 0) {
data.putInt("BoltActionTick", 0);
if (oldData.bolt.defaultActionTime() > 0) {
oldData.bolt.setActionTime(0);
}
data.putInt("ReloadTime", 0);
oldData.reload.setTime(0);
oldTag.put("GunData", data);
oldData.setReloadState(GunData.ReloadState.NOT_RELOADING);
oldData.reload.setState(ReloadState.NOT_RELOADING);
if (oldData.iterativeTime() != 0) {
oldTag.remove("ForceStop");
oldTag.remove("Stopped");
oldData.setReloadStage(0);
oldData.reload.setStage(0);
oldTag.remove("PrepareTime");
oldTag.remove("PrepareLoadTime");
oldTag.remove("IterativeLoadTime");
@ -398,20 +399,20 @@ public class LivingEventHandler {
player.getPersistentData().putDouble("noRun", 40);
newTag.putBoolean("draw", true);
if (newData.boltActionTime() > 0) {
GunsTool.setGunIntTag(newTag, "BoltActionTick", 0);
if (newData.bolt.defaultActionTime() > 0) {
newData.bolt.setActionTime(0);
}
newData.setReloadState(GunData.ReloadState.NOT_RELOADING);
newData.reload.setState(ReloadState.NOT_RELOADING);
var data = newTag.getCompound("GunData");
data.remove("ReloadTime");
var data = newData.data();
newData.reload.setTime(0);
newTag.put("GunData", data);
if (newData.iterativeTime() != 0) {
newTag.remove("ForceStop");
newTag.remove("Stopped");
newData.setReloadStage(0);
newData.reload.setStage(0);
newTag.remove("PrepareTime");
newTag.remove("PrepareLoadTime");
newTag.remove("IterativeLoadTime");

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.config.server.MiscConfig;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.tools.*;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;

View file

@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.event;
import com.atsuishio.superbwarfare.event.events.ReloadEvent;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.world.entity.player.Player;

View file

@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.item.gun;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent;

View file

@ -8,6 +8,7 @@ import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.CustomRendererItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.AmmoType;

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.item.gun;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import net.minecraft.world.entity.player.Player;

View file

@ -0,0 +1,47 @@
package com.atsuishio.superbwarfare.item.gun.data;
import net.minecraft.nbt.CompoundTag;
public final class Bolt {
private final CompoundTag data;
private final GunData gunData;
Bolt(GunData data) {
this.gunData = data;
this.data = data.data();
}
public boolean needed() {
return data.getBoolean("NeedBoltAction");
}
public void markNeeded() {
data.putBoolean("NeedBoltAction", true);
}
public void markNeedless() {
data.remove("NeedBoltAction");
}
public int defaultActionTime() {
return (int) gunData.getGunData("BoltActionTime") + gunData.item().getCustomBoltActionTime(gunData.stack());
}
public int actionTime() {
return data.getInt("BoltActionTime");
}
public void setActionTime(int tick) {
if (tick <= 0) {
data.remove("BoltActionTime");
} else {
data.putInt("BoltActionTime", tick);
}
}
public void reduceActionTime() {
setActionTime(actionTime() - 1);
}
}

View file

@ -0,0 +1,43 @@
package com.atsuishio.superbwarfare.item.gun.data;
import net.minecraft.nbt.CompoundTag;
public final class Charge {
private final CompoundTag data;
Charge(GunData data) {
this.data = data.data();
}
public void markStart() {
data.putBoolean("StartCharge", true);
}
public boolean shouldStartCharge() {
return data.getBoolean("StartCharge");
}
public void markStarted() {
data.remove("StartCharge");
}
public int time() {
return data.getInt("ChargeTime");
}
public void reduce() {
setTime(time() - 1);
}
public void setTime(int chargeTime) {
if (chargeTime <= 0) {
data.remove("ChargeTime");
} else {
data.putInt("ChargeTime", chargeTime);
}
}
public void reset() {
setTime(0);
}
}

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.item.gun;
package com.atsuishio.superbwarfare.item.gun.data;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
@ -49,6 +50,10 @@ public class GunData {
} else {
perk = tag.getCompound("PerkData");
}
reload = new Reload(this);
charge = new Charge(this);
bolt = new Bolt(this);
}
public boolean initialized() {
@ -91,7 +96,7 @@ public class GunData {
return perk;
}
private double getGunData(String key) {
double getGunData(String key) {
return getGunData(key, 0);
}
@ -103,7 +108,7 @@ public class GunData {
return getGunData("Damage");
}
public double perkDamage() {
public double perkDamageRate() {
var perk = PerkHelper.getPerkByType(tag, Perk.Type.AMMO);
if (perk instanceof AmmoPerk ammoPerk) {
return ammoPerk.damageRate;
@ -112,7 +117,7 @@ public class GunData {
}
public double damage() {
return (rawDamage() + item.getCustomDamage(stack)) + perkDamage();
return (rawDamage() + item.getCustomDamage(stack)) * perkDamageRate();
}
public double explosionDamage() {
@ -167,24 +172,10 @@ public class GunData {
return (int) getGunData("PrepareEmptyTime");
}
public int boltActionTime() {
return (int) getGunData("BoltActionTime") + item.getCustomBoltActionTime(stack);
}
public int finishTime() {
return (int) getGunData("FinishTime");
}
public int reloadTime() {
var normalReload = normalReloadTime();
var emptyReload = emptyReloadTime();
if (normalReload == 0) return emptyReload;
if (emptyReload == 0) return normalReload;
return ammo() < magazine() ? normalReload : emptyReload;
}
public double soundRadius() {
return getGunData("SoundRadius", 15) + item.getCustomSoundRadius(stack);
}
@ -217,9 +208,6 @@ public class GunData {
data.putInt("Ammo", ammo);
}
public boolean reloading() {
return getReloadState() != ReloadState.NOT_RELOADING;
}
public double defaultZoom() {
return getGunData("DefaultZoom", 1.25);
@ -292,88 +280,21 @@ public class GunData {
return item.canSwitchScope(stack);
}
public enum ReloadState {
NOT_RELOADING,
NORMAL_RELOADING,
EMPTY_RELOADING,
public final Reload reload;
public boolean reloading() {
return reload.state() != ReloadState.NOT_RELOADING;
}
public ReloadState getReloadState() {
return switch (data.getInt("ReloadState")) {
case 1 -> ReloadState.NORMAL_RELOADING;
case 2 -> ReloadState.EMPTY_RELOADING;
default -> ReloadState.NOT_RELOADING;
};
}
public boolean normalReloading() {
return getReloadState() == ReloadState.NORMAL_RELOADING;
}
public boolean emptyReloading() {
return getReloadState() == ReloadState.EMPTY_RELOADING;
}
public void setReloadState(ReloadState state) {
if (state == ReloadState.NOT_RELOADING) {
data.remove("ReloadState");
} else {
data.putInt("ReloadState", state.ordinal());
}
}
public int getReloadStage() {
return data.getInt("ReloadStage");
}
public void setReloadStage(int stage) {
if (stage == 0) {
data.remove("ReloadStage");
} else {
data.putInt("ReloadStage", stage);
}
}
public final Charge charge = new Charge();
public class Charge {
public void markStart() {
data.putBoolean("StartCharge", true);
}
public boolean shouldStartCharge() {
return data.getBoolean("StartCharge");
}
public void markStarted() {
data.remove("StartCharge");
}
public int time() {
return data.getInt("ChargeTime");
}
public void reduce() {
setTime(time() - 1);
}
public void setTime(int chargeTime) {
if (chargeTime <= 0) {
data.remove("ChargeTime");
} else {
data.putInt("ChargeTime", chargeTime);
}
}
public void reset() {
setTime(0);
}
}
public final Charge charge;
public boolean charging() {
return charge.time() > 0;
}
public final Bolt bolt;
public void save() {
stack.set(DataComponents.CUSTOM_DATA, CustomData.of(tag));
}

View file

@ -0,0 +1,75 @@
package com.atsuishio.superbwarfare.item.gun.data;
import net.minecraft.nbt.CompoundTag;
public final class Reload {
private final CompoundTag data;
Reload(GunData data) {
this.data = data.data();
}
public ReloadState state() {
return switch (data.getInt("ReloadState")) {
case 1 -> ReloadState.NORMAL_RELOADING;
case 2 -> ReloadState.EMPTY_RELOADING;
default -> ReloadState.NOT_RELOADING;
};
}
public boolean normal() {
return state() == ReloadState.NORMAL_RELOADING;
}
public boolean empty() {
return state() == ReloadState.EMPTY_RELOADING;
}
public void setState(ReloadState state) {
if (state == ReloadState.NOT_RELOADING) {
data.remove("ReloadState");
} else {
data.putInt("ReloadState", state.ordinal());
}
}
public int stage() {
return data.getInt("ReloadStage");
}
public void setStage(int stage) {
if (stage <= 0) {
data.remove("ReloadStage");
} else {
data.putInt("ReloadStage", stage);
}
}
public void markStart() {
data.putBoolean("StartReload", true);
}
public void markStarted() {
data.remove("StartReload");
}
public boolean shouldStart() {
return data.getBoolean("StartReload");
}
public int time() {
return data.getInt("ReloadTime");
}
public void setTime(int time) {
if (time <= 0) {
data.remove("ReloadTime");
} else {
data.putInt("ReloadTime", time);
}
}
public void reduce() {
setTime(time() - 1);
}
}

View file

@ -0,0 +1,7 @@
package com.atsuishio.superbwarfare.item.gun.data;
public enum ReloadState {
NOT_RELOADING,
NORMAL_RELOADING,
EMPTY_RELOADING,
}

View file

@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.Glock17ItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import net.minecraft.client.Minecraft;
@ -49,11 +49,11 @@ public class Glock17Item extends GunItem implements GeoItem {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_empty"));
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_normal"));
}
@ -69,7 +69,7 @@ public class Glock17Item extends GunItem implements GeoItem {
if (player.isSprinting() && player.onGround()
&& player.getPersistentData().getDouble("noRun") == 0
&& !(GunData.from(stack).normalReloading() || GunData.from(stack).emptyReloading()) && ClientEventHandler.drawTime < 0.01) {
&& !(GunData.from(stack).reload.normal() || GunData.from(stack).reload.empty()) && ClientEventHandler.drawTime < 0.01) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.glock.run_fast"));
} else {

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import net.minecraft.client.Minecraft;
@ -50,11 +50,11 @@ public class Glock18Item extends GunItem implements GeoItem {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_empty"));
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_normal"));
}
@ -69,7 +69,7 @@ public class Glock18Item extends GunItem implements GeoItem {
if (player.isSprinting() && player.onGround()
&& player.getPersistentData().getDouble("noRun") == 0
&& !(GunData.from(stack).normalReloading() || GunData.from(stack).emptyReloading()) && ClientEventHandler.drawTime < 0.01) {
&& !(GunData.from(stack).reload.normal() || GunData.from(stack).reload.empty()) && ClientEventHandler.drawTime < 0.01) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.glock.run_fast"));
} else {

View file

@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.M1911ItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import net.minecraft.client.Minecraft;
@ -49,11 +49,11 @@ public class M1911Item extends GunItem implements GeoItem {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_empty"));
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_normal"));
}
@ -69,7 +69,7 @@ public class M1911Item extends GunItem implements GeoItem {
if (player.isSprinting() && player.onGround()
&& player.getPersistentData().getDouble("noRun") == 0
&& !(GunData.from(stack).normalReloading() || GunData.from(stack).emptyReloading()) && ClientEventHandler.drawTime < 0.01) {
&& !(GunData.from(stack).reload.normal() || GunData.from(stack).reload.empty()) && ClientEventHandler.drawTime < 0.01) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.glock.run_fast"));
} else {

View file

@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.Mp443ItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import net.minecraft.client.Minecraft;
@ -49,11 +49,11 @@ public class Mp443Item extends GunItem implements GeoItem {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_empty"));
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_normal"));
}
@ -69,7 +69,7 @@ public class Mp443Item extends GunItem implements GeoItem {
if (player.isSprinting() && player.onGround()
&& player.getPersistentData().getDouble("noRun") == 0
&& !(GunData.from(stack).normalReloading() || GunData.from(stack).emptyReloading()) && ClientEventHandler.drawTime < 0.01) {
&& !(GunData.from(stack).reload.normal() || GunData.from(stack).reload.empty()) && ClientEventHandler.drawTime < 0.01) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.glock.run_fast"));
} else {

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.TracheliumItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -111,7 +111,7 @@ public class Trachelium extends GunItem implements GeoItem {
boolean stock = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.STOCK) == 2;
boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) > 0 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.SCOPE) > 0;
if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
if (data.bolt.actionTime() > 0) {
if (stock) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.trachelium.action_stock_grip"));
@ -127,7 +127,7 @@ public class Trachelium extends GunItem implements GeoItem {
}
}
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
if (stock) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.trachelium.reload_stock_grip"));

View file

@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModRarity;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -59,15 +59,15 @@ public class Ntw20Item extends GunItem implements GeoItem {
var data = GunData.from(stack);
final var tag = data.tag();
if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
if (data.bolt.actionTime() > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.shift"));
}
if (data.emptyReloading()) {
if (data.reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.reload_empty"));
}
if (data.normalReloading()) {
if (data.reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.reload_normal"));
}
@ -84,9 +84,9 @@ public class Ntw20Item extends GunItem implements GeoItem {
if (player.isSprinting() && player.onGround()
&& player.getPersistentData().getDouble("noRun") == 0
&& !(data.normalReloading() || data.emptyReloading())
&& !(data.reload.normal() || data.reload.empty())
&& ClientEventHandler.drawTime < 0.01) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && data.bolt.actionTime() == 0) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ntw_20.run_fast"));
} else {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ntw_20.run"));

View file

@ -9,9 +9,9 @@ import com.atsuishio.superbwarfare.entity.projectile.JavelinMissileEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
@ -77,7 +77,7 @@ public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.javelin.reload"));
}

View file

@ -10,9 +10,9 @@ import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
@ -76,7 +76,7 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m79.reload"));
}

View file

@ -10,9 +10,9 @@ import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
@ -77,7 +77,7 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
var data = GunData.from(stack);
if (data.emptyReloading()) {
if (data.reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.rpg.reload"));
}

View file

@ -8,9 +8,9 @@ import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.item.EnergyStorageItem;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
@ -90,15 +90,15 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
var data = GunData.from(stack);
final var tag = data.tag();
if (data.getReloadStage() == 1 && tag.getDouble("PrepareLoadTime") > 0) {
if (data.reload.stage() == 1 && tag.getDouble("PrepareLoadTime") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.prepare"));
}
if (tag.getDouble("LoadIndex") == 0 && data.getReloadStage() == 2) {
if (tag.getDouble("LoadIndex") == 0 && data.reload.stage() == 2) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.iterativeload"));
}
if (tag.getDouble("LoadIndex") == 1 && data.getReloadStage() == 2) {
if (tag.getDouble("LoadIndex") == 1 && data.reload.stage() == 2) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.iterativeload2"));
}
@ -106,7 +106,7 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.hit"));
}
if (data.getReloadStage() == 3) {
if (data.reload.stage() == 3) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.finish"));
}
@ -122,10 +122,10 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
if (player.isSprinting() && player.onGround()
&& player.getPersistentData().getDouble("noRun") == 0
&& !data.emptyReloading()
&& data.getReloadStage() != 1
&& data.getReloadStage() != 2
&& data.getReloadStage() != 3
&& !data.reload.empty()
&& data.reload.stage() != 1
&& data.reload.stage() != 2
&& data.reload.stage() != 3
&& ClientEventHandler.drawTime < 0.01
&& ClientEventHandler.gunMelee == 0
&& !data.reloading()

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import net.minecraft.client.Minecraft;
@ -50,11 +50,11 @@ public class DevotionItem extends GunItem implements GeoItem {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.devotion.reload_empty"));
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.devotion.reload_normal"));
}

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -67,11 +67,11 @@ public class M60Item extends GunItem implements GeoItem {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m60.reload"));
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m60.reload2"));
}

View file

@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.init.ModParticleTypes;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModRarity;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.tools.NBTTool;
import com.atsuishio.superbwarfare.tools.ParticleTool;

View file

@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -62,7 +62,7 @@ public class RpkItem extends GunItem implements GeoItem {
boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2;
boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.GRIP) == 2;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.reload_empty_drum_grip"));
@ -78,7 +78,7 @@ public class RpkItem extends GunItem implements GeoItem {
}
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.reload_normal_drum_grip"));

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.AK12ItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -62,7 +62,7 @@ public class AK12Item extends GunItem implements GeoItem {
boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2;
boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak12.reload_empty_grip"));
} else {
@ -70,7 +70,7 @@ public class AK12Item extends GunItem implements GeoItem {
}
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak12.reload_normal_drum_grip"));

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.AK47ItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -62,7 +62,7 @@ public class AK47Item extends GunItem implements GeoItem {
boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2;
boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.reload_empty_drum_grip"));
@ -78,7 +78,7 @@ public class AK47Item extends GunItem implements GeoItem {
}
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.reload_normal_drum_grip"));

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.Hk416ItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -57,7 +57,7 @@ public class Hk416Item extends GunItem implements GeoItem {
boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2;
boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_empty_drum_grip"));
@ -73,7 +73,7 @@ public class Hk416Item extends GunItem implements GeoItem {
}
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_normal_drum_grip"));

View file

@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.InsidiousItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import net.minecraft.client.Minecraft;
@ -51,7 +51,7 @@ public class InsidiousItem extends GunItem implements GeoItem {
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
var data = GunData.from(stack);
if (data.emptyReloading()) {
if (data.reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.insidious.reload"));
}

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.M4ItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -58,7 +58,7 @@ public class M4Item extends GunItem implements GeoItem {
boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2;
boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2;
if (data.emptyReloading()) {
if (data.reload.empty()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_empty_drum_grip"));
@ -74,7 +74,7 @@ public class M4Item extends GunItem implements GeoItem {
}
}
if (data.normalReloading()) {
if (data.reload.normal()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_normal_drum_grip"));

View file

@ -5,11 +5,10 @@ import com.atsuishio.superbwarfare.client.renderer.item.MarlinItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.resources.ResourceLocation;
@ -52,23 +51,23 @@ public class MarlinItem extends GunItem implements GeoItem {
var data = GunData.from(stack);
final var tag = data.tag();
if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
if (data.bolt.actionTime() > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.shift"));
}
if (data.getReloadStage() == 1 && tag.getDouble("PrepareTime") > 0) {
if (data.reload.stage() == 1 && tag.getDouble("PrepareTime") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.prepare"));
}
if (tag.getDouble("LoadIndex") == 0 && data.getReloadStage() == 2) {
if (tag.getDouble("LoadIndex") == 0 && data.reload.stage() == 2) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload"));
}
if (tag.getDouble("LoadIndex") == 1 && data.getReloadStage() == 2) {
if (tag.getDouble("LoadIndex") == 1 && data.reload.stage() == 2) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload2"));
}
if (data.getReloadStage() == 3) {
if (data.reload.stage() == 3) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.finish"));
}

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.Mk14ItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -57,7 +57,7 @@ public class Mk14Item extends GunItem implements GeoItem {
boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2;
boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2;
if (data.emptyReloading()) {
if (data.reload.empty()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m14.reload_empty_drum_grip"));
@ -73,7 +73,7 @@ public class Mk14Item extends GunItem implements GeoItem {
}
}
if (data.normalReloading()) {
if (data.reload.normal()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m14.reload_normal_drum_grip"));

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.Qbz95ItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -61,7 +61,7 @@ public class Qbz95Item extends GunItem implements GeoItem {
boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2;
boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2;
if (data.emptyReloading()) {
if (data.reload.empty()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.qbz95.reload_empty_drum_grip"));
@ -77,7 +77,7 @@ public class Qbz95Item extends GunItem implements GeoItem {
}
}
if (data.normalReloading()) {
if (data.reload.normal()) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.qbz95.reload_normal_drum_grip"));

View file

@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.SksItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -58,11 +58,11 @@ public class SksItem extends GunItem implements GeoItem {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sks.reload_empty"));
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sks.reload_normal"));
}

View file

@ -8,8 +8,8 @@ import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModRarity;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import net.minecraft.client.Minecraft;
@ -57,11 +57,11 @@ public class Aa12Item extends GunItem implements GeoItem {
if (this.animationProcedure.equals("empty")) {
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa12.reload_empty"));
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa12.reload_normal"));
}

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.tooltip.component.ShotgunImageComponen
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import net.minecraft.client.Minecraft;
@ -58,11 +58,11 @@ public class HomemadeShotgunItem extends GunItem implements GeoItem {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ab.reload_empty"));
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ab.reload_normal"));
}

View file

@ -6,11 +6,10 @@ import com.atsuishio.superbwarfare.client.tooltip.component.ShotgunImageComponen
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.NBTTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
@ -57,27 +56,27 @@ public class M870Item extends GunItem implements GeoItem {
var data = GunData.from(stack);
final var tag = NBTTool.getTag(stack);
if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
if (data.bolt.actionTime() > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.shift"));
}
if (data.getReloadStage() == 1 && tag.getDouble("PrepareLoadTime") > 0) {
if (data.reload.stage() == 1 && tag.getDouble("PrepareLoadTime") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.preparealt"));
}
if (data.getReloadStage() == 1 && tag.getDouble("PrepareTime") > 0) {
if (data.reload.stage() == 1 && tag.getDouble("PrepareTime") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.prepare"));
}
if (tag.getDouble("LoadIndex") == 0 && data.getReloadStage() == 2) {
if (tag.getDouble("LoadIndex") == 0 && data.reload.stage() == 2) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.iterativeload"));
}
if (tag.getDouble("LoadIndex") == 1 && data.getReloadStage() == 2) {
if (tag.getDouble("LoadIndex") == 1 && data.reload.stage() == 2) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.iterativeload2"));
}
if (data.getReloadStage() == 3) {
if (data.reload.stage() == 3) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.finish"));
}

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.VectorItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -56,7 +56,7 @@ public class VectorItem extends GunItem implements GeoItem {
boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2;
if (data.emptyReloading()) {
if (data.reload.empty()) {
if (drum) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vec.reload_empty_drum"));
} else {
@ -64,7 +64,7 @@ public class VectorItem extends GunItem implements GeoItem {
}
}
if (data.normalReloading()) {
if (data.reload.normal()) {
if (drum) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vec.reload_normal_drum"));
} else {

View file

@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.HuntingRifleItemRenderer
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import net.minecraft.client.Minecraft;
@ -54,7 +54,7 @@ public class HuntingRifleItem extends GunItem implements GeoItem {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.hunting_rifle.reload"));
}

View file

@ -5,11 +5,10 @@ import com.atsuishio.superbwarfare.client.renderer.item.K98ItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.resources.ResourceLocation;
@ -53,27 +52,27 @@ public class K98Item extends GunItem implements GeoItem {
var data = GunData.from(stack);
final var tag = data.tag();
if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
if (data.bolt.actionTime() > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.shift"));
}
if (data.getReloadState() == GunData.ReloadState.EMPTY_RELOADING) {
if (data.reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.reload_empty"));
}
if (data.getReloadStage() == 1 && tag.getDouble("PrepareTime") > 0) {
if (data.reload.stage() == 1 && tag.getDouble("PrepareTime") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.prepare"));
}
if (tag.getDouble("LoadIndex") == 0 && data.getReloadStage() == 2) {
if (tag.getDouble("LoadIndex") == 0 && data.reload.stage() == 2) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.iterativeload"));
}
if (tag.getDouble("LoadIndex") == 1 && data.getReloadStage() == 2) {
if (tag.getDouble("LoadIndex") == 1 && data.reload.stage() == 2) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.iterativeload2"));
}
if (data.getReloadStage() == 3) {
if (data.reload.stage() == 3) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.finish"));
}
@ -91,14 +90,14 @@ public class K98Item extends GunItem implements GeoItem {
if (player.isSprinting() && player.onGround()
&& player.getPersistentData().getDouble("noRun") == 0
&& !(data.getReloadState() == GunData.ReloadState.EMPTY_RELOADING)
&& data.getReloadStage() != 1
&& data.getReloadStage() != 2
&& data.getReloadStage() != 3
&& !data.reload.empty()
&& data.reload.stage() != 1
&& data.reload.stage() != 2
&& data.reload.stage() != 3
&& ClientEventHandler.drawTime < 0.01
&& !data.reloading()
) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && data.bolt.actionTime() == 0) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.k98.run_fast"));
} else {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.k98.run"));

View file

@ -5,11 +5,10 @@ import com.atsuishio.superbwarfare.client.renderer.item.M98bItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.resources.ResourceLocation;
@ -52,15 +51,15 @@ public class M98bItem extends GunItem implements GeoItem {
var data = GunData.from(stack);
final var tag = data.tag();
if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
if (data.bolt.actionTime() > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m98b.shift"));
}
if (data.emptyReloading()) {
if (data.reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m98b.reload_empty"));
}
if (data.normalReloading()) {
if (data.reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m98b.reload_normal"));
}
@ -77,8 +76,8 @@ public class M98bItem extends GunItem implements GeoItem {
if (player.isSprinting() && player.onGround()
&& player.getPersistentData().getDouble("noRun") == 0
&& !(data.normalReloading() || data.emptyReloading()) && ClientEventHandler.drawTime < 0.01) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0) {
&& !(data.reload.normal() || data.reload.empty()) && ClientEventHandler.drawTime < 0.01) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && data.bolt.actionTime() == 0) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m98b.run_fast"));
} else {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m98b.run"));

View file

@ -5,11 +5,10 @@ import com.atsuishio.superbwarfare.client.renderer.item.MosinNagantItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.NBTTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
@ -53,27 +52,27 @@ public class MosinNagantItem extends GunItem implements GeoItem {
var data = GunData.from(stack);
final var tag = data.tag();
if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
if (data.bolt.actionTime() > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.shift"));
}
if (data.getReloadStage() == 1 && data.ammo() == 0) {
if (data.reload.stage() == 1 && data.ammo() == 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare_empty"));
}
if (data.getReloadStage() == 1 && data.ammo() > 0) {
if (data.reload.stage() == 1 && data.ammo() > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare"));
}
if (NBTTool.getTag(stack).getDouble("LoadIndex") == 0 && data.getReloadStage() == 2) {
if (NBTTool.getTag(stack).getDouble("LoadIndex") == 0 && data.reload.stage() == 2) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.iterativeload"));
}
if (NBTTool.getTag(stack).getDouble("LoadIndex") == 1 && data.getReloadStage() == 2) {
if (NBTTool.getTag(stack).getDouble("LoadIndex") == 1 && data.reload.stage() == 2) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.iterativeload2"));
}
if (data.getReloadStage() == 3) {
if (data.reload.stage() == 3) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.finish"));
}
@ -90,14 +89,14 @@ public class MosinNagantItem extends GunItem implements GeoItem {
if (player.isSprinting() && player.onGround()
&& player.getPersistentData().getDouble("noRun") == 0
&& !(GunData.from(stack).emptyReloading())
&& data.getReloadStage() != 1
&& data.getReloadStage() != 2
&& data.getReloadStage() != 3
&& !(GunData.from(stack).reload.empty())
&& data.reload.stage() != 1
&& data.reload.stage() != 2
&& data.reload.stage() != 3
&& ClientEventHandler.drawTime < 0.01
&& !data.reloading()
) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && data.bolt.actionTime() == 0) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mosin.run_fast"));
} else {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mosin.run"));

View file

@ -8,11 +8,10 @@ import com.atsuishio.superbwarfare.init.ModRarity;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.EnergyStorageItem;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.resources.ResourceLocation;
@ -76,15 +75,15 @@ public class SentinelItem extends GunItem implements GeoItem, EnergyStorageItem
var data = GunData.from(stack);
final var tag = data.tag();
if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
if (data.bolt.actionTime() > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.shift"));
}
if (data.emptyReloading()) {
if (data.reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.reload_empty"));
}
if (data.normalReloading()) {
if (data.reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.reload_normal"));
}
@ -109,7 +108,7 @@ public class SentinelItem extends GunItem implements GeoItem, EnergyStorageItem
&& !data.charging()
&& ClientEventHandler.drawTime < 0.01
) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && data.bolt.actionTime() == 0) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sentinel.run_fast"));
} else {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sentinel.run"));

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.SvdItemRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -52,11 +52,11 @@ public class SvdItem extends GunItem implements GeoItem {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.svd.reload_empty"));
}
if (GunData.from(stack).normalReloading()) {
if (GunData.from(stack).reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.svd.reload_normal"));
}

View file

@ -9,9 +9,9 @@ import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk;

View file

@ -11,9 +11,9 @@ import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.EnergyStorageItem;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
@ -95,7 +95,7 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (GunData.from(stack).emptyReloading()) {
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.taser.reload"));
}

View file

@ -4,8 +4,8 @@ import com.atsuishio.superbwarfare.init.ModBlocks;
import com.atsuishio.superbwarfare.init.ModMenuTypes;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.PerkItem;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.NBTTool;

View file

@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.tools.FormatTool;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.SoundTool;

View file

@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.network.message.send;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.tools.SoundTool;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.CompoundTag;

View file

@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
import com.atsuishio.superbwarfare.event.GunEventHandler;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
@ -89,18 +89,17 @@ public record FireMessage(int msgType) implements CustomPacketPayload {
private static void handleGunBolt(Player player, ItemStack stack) {
if (!stack.is(ModTags.Items.GUN)) return;
var data = GunData.from(stack);
CompoundTag tag = data.tag();
if (data.boltActionTime() > 0
if (data.bolt.defaultActionTime() > 0
&& data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? -1 : 0)
&& GunsTool.getGunIntTag(tag, "BoltActionTick") == 0
&& !(data.normalReloading()
|| data.emptyReloading())
&& data.bolt.actionTime() == 0
&& !(data.reload.normal()
|| data.reload.empty())
&& !data.reloading()
&& !data.charging()
) {
if (!player.getCooldowns().isOnCooldown(stack.getItem()) && GunsTool.getGunBooleanTag(tag, "NeedBoltAction")) {
GunsTool.setGunIntTag(tag, "BoltActionTick", data.boltActionTime() + 1);
if (!player.getCooldowns().isOnCooldown(stack.getItem()) && data.bolt.needed()) {
data.bolt.setActionTime(data.bolt.defaultActionTime() + 1);
GunEventHandler.playGunBoltSounds(player);
}
}

View file

@ -3,9 +3,8 @@ package com.atsuishio.superbwarfare.network.message.send;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.tools.SoundTool;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
@ -89,7 +88,7 @@ public record FireModeMessage(int msgType) implements CustomPacketPayload {
if (stack.getItem() == ModItems.SENTINEL.get()
&& !player.isSpectator()
&& !(player.getCooldowns().isOnCooldown(stack.getItem()))
&& GunsTool.getGunIntTag(tag, "ReloadTime") == 0
&& data.reload.time() == 0
&& !data.charging()
) {
for (var cell : player.getInventory().items) {
@ -110,11 +109,10 @@ public record FireModeMessage(int msgType) implements CustomPacketPayload {
}
}
if (stack.getItem() == ModItems.TRACHELIUM.get() && !GunsTool.getGunBooleanTag(tag, "NeedBoltAction")) {
if (stack.getItem() == ModItems.TRACHELIUM.get() && !data.bolt.needed()) {
tag.putBoolean("DA", !tag.getBoolean("DA"));
data.save();
if (!tag.getBoolean("canImmediatelyShoot")) {
GunsTool.setGunBooleanTag(tag, "NeedBoltAction", true);
data.bolt.markNeeded();
}
}

View file

@ -4,8 +4,8 @@ import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.capability.ModCapabilities;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.tools.GunsTool;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
@ -46,8 +46,8 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload {
if (!player.isSpectator()
&& !data.charging()
&& !data.reloading()
&& GunsTool.getGunIntTag(tag, "ReloadTime") == 0
&& GunsTool.getGunIntTag(tag, "BoltActionTick") == 0
&& data.reload.time() == 0
&& data.bolt.actionTime() == 0
) {
boolean canSingleReload = gunItem.isIterativeReload(stack);
boolean canReload = gunItem.isMagazineReload(stack) && !gunItem.isClipReload(stack);
@ -76,19 +76,11 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload {
if (canReload || clipLoad) {
int magazine = data.magazine();
var extra = (gunItem.isOpenBolt(stack) && gunItem.hasBulletInBarrel(stack)) ? 1 : 0;
var maxAmmo = magazine + extra;
if (gunItem.isOpenBolt(stack)) {
if (gunItem.hasBulletInBarrel(stack)) {
if (data.ammo() < magazine + 1) {
GunsTool.setGunBooleanTag(tag, "StartReload", true);
}
} else {
if (data.ammo() < magazine) {
GunsTool.setGunBooleanTag(tag, "StartReload", true);
}
}
} else if (data.ammo() < magazine) {
GunsTool.setGunBooleanTag(tag, "StartReload", true);
if (data.ammo() < maxAmmo) {
data.reload.markStart();
}
return;
}

View file

@ -2,7 +2,7 @@ package com.atsuishio.superbwarfare.network.message.send;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.network.codec.ByteBufCodecs;

View file

@ -7,7 +7,7 @@ import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
@ -61,8 +61,8 @@ public record ShootMessage(double spread) implements CustomPacketPayload {
}
// 判断是否为栓动武器BoltActionTime > 0并在开火后给一个需要上膛的状态
if (data.boltActionTime() > 0 && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) {
GunsTool.setGunBooleanTag(tag, "NeedBoltAction", true);
if (data.bolt.defaultActionTime() > 0 && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) {
data.bolt.markNeeded();
}
data.setAmmo(data.ammo() - 1);

View file

@ -2,7 +2,7 @@ package com.atsuishio.superbwarfare.network.message.send;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;

View file

@ -6,7 +6,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.tools.SoundTool;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;

View file

@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.perk;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModPerks;
import com.atsuishio.superbwarfare.item.PerkItem;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;

View file

@ -3,7 +3,8 @@ package com.atsuishio.superbwarfare.tools;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.capability.ModCapabilities;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunData;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.item.gun.data.ReloadState;
import com.atsuishio.superbwarfare.network.message.receive.GunsDataMessage;
import com.google.gson.stream.JsonReader;
import net.minecraft.nbt.CompoundTag;
@ -92,8 +93,8 @@ public class GunsTool {
int ammoToAdd = mag - ammo + (extraOne ? 1 : 0);
// 空仓换弹的栓动武器应该在换弹后取消待上膛标记
if (ammo == 0 && gunData.boltActionTime() > 0 && !stack.is(ModTags.Items.REVOLVER)) {
data.putBoolean("NeedBoltAction", false);
if (ammo == 0 && gunData.bolt.defaultActionTime() > 0 && !stack.is(ModTags.Items.REVOLVER)) {
gunData.bolt.markNeedless();
}
var capability = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
@ -109,7 +110,7 @@ public class GunsTool {
int needToAdd = ammo + Math.min(ammoToAdd, playerAmmo);
gunData.setAmmo(needToAdd);
gunData.setReloadState(GunData.ReloadState.NOT_RELOADING);
gunData.reload.setState(ReloadState.NOT_RELOADING);
}
/* PerkData */