修复GunData的更多相关问题
This commit is contained in:
parent
1153af4061
commit
b7083324b0
55 changed files with 291 additions and 249 deletions
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.rifle.AK12Item;
|
import com.atsuishio.superbwarfare.item.gun.rifle.AK12Item;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -73,7 +73,8 @@ public class AK12ItemModel extends GeoModel<AK12Item> {
|
||||||
double fp = ClientEventHandler.firePos;
|
double fp = ClientEventHandler.firePos;
|
||||||
double fr = ClientEventHandler.fireRot;
|
double fr = ClientEventHandler.fireRot;
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
int type = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.SCOPE);
|
int type = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.SCOPE);
|
||||||
|
|
||||||
float posY = switch (type) {
|
float posY = switch (type) {
|
||||||
|
@ -173,6 +174,6 @@ public class AK12ItemModel extends GeoModel<AK12Item> {
|
||||||
AnimationHelper.handleReloadShakeAnimation(stack, main, camera, numR, numP);
|
AnimationHelper.handleReloadShakeAnimation(stack, main, camera, numR, numP);
|
||||||
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(), Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
|
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(), Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
|
||||||
AnimationHelper.handleShellsAnimation(getAnimationProcessor(), 1f, 0.35f);
|
AnimationHelper.handleShellsAnimation(getAnimationProcessor(), 1f, 0.35f);
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.rifle.AK47Item;
|
import com.atsuishio.superbwarfare.item.gun.rifle.AK47Item;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -114,9 +114,10 @@ public class AK47ItemModel extends GeoModel<AK47Item> {
|
||||||
scope2.setScaleZ(1f - (0.3f * (float) zp));
|
scope2.setScaleZ(1f - (0.3f * (float) zp));
|
||||||
scope3.setScaleZ(1f - (0.7f * (float) zp));
|
scope3.setScaleZ(1f - (0.7f * (float) zp));
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosX() > 1.8));
|
tag.putBoolean("HoloHidden", !(gun.getPosX() > 1.8));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
GeoBone shen;
|
GeoBone shen;
|
||||||
if (zt < 0.5) {
|
if (zt < 0.5) {
|
||||||
|
|
|
@ -4,8 +4,8 @@ import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.special.BocekItem;
|
import com.atsuishio.superbwarfare.item.gun.special.BocekItem;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -105,9 +105,10 @@ public class BocekItemModel extends GeoModel<BocekItem> {
|
||||||
r.setScaleZ(1f - (0.31f * (float) zp));
|
r.setScaleZ(1f - (0.31f * (float) zp));
|
||||||
shen.setRotZ(60 * Mth.DEG_TO_RAD * (float) zp + (float) (0.05f * zpz) - 0.2f);
|
shen.setRotZ(60 * Mth.DEG_TO_RAD * (float) zp + (float) (0.05f * zpz) - 0.2f);
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !((shen_pos.getPosX() < -0.6 && gun.getPosZ() < -2)));
|
tag.putBoolean("HoloHidden", !((shen_pos.getPosX() < -0.6 && gun.getPosZ() < -2)));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
fire.setPosX((float) (0.75f * ClientEventHandler.recoilHorizon * fpz * fp));
|
fire.setPosX((float) (0.75f * ClientEventHandler.recoilHorizon * fpz * fp));
|
||||||
fire.setPosY((float) (-0.03f * fp - 0.06f * fr));
|
fire.setPosY((float) (-0.03f * fp - 0.06f * fr));
|
||||||
|
|
|
@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.machinegun.DevotionItem;
|
import com.atsuishio.superbwarfare.item.gun.machinegun.DevotionItem;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -74,9 +74,10 @@ public class DevotionItemModel extends GeoModel<DevotionItem> {
|
||||||
GeoBone shen = getAnimationProcessor().getBone("shen");
|
GeoBone shen = getAnimationProcessor().getBone("shen");
|
||||||
GeoBone holo = getAnimationProcessor().getBone("holo");
|
GeoBone holo = getAnimationProcessor().getBone("holo");
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosX() > 1.8));
|
tag.putBoolean("HoloHidden", !(gun.getPosX() > 1.8));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
shen.setPosX((float) (0.95f * ClientEventHandler.recoilHorizon * fpz * fp));
|
shen.setPosX((float) (0.95f * ClientEventHandler.recoilHorizon * fpz * fp));
|
||||||
shen.setPosY((float) (0.15f * fp + 0.18f * fr));
|
shen.setPosY((float) (0.15f * fp + 0.18f * fr));
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.handgun.Glock17Item;
|
import com.atsuishio.superbwarfare.item.gun.handgun.Glock17Item;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -103,7 +103,8 @@ public class Glock17ItemModel extends GeoModel<Glock17Item> {
|
||||||
float numR = (float) (1 - 0.12 * zt);
|
float numR = (float) (1 - 0.12 * zt);
|
||||||
float numP = (float) (1 - 0.68 * zt);
|
float numP = (float) (1 - 0.68 * zt);
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
|
|
||||||
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
|
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
|
||||||
main.setRotX(numR * main.getRotX());
|
main.setRotX(numR * main.getRotX());
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.handgun.Glock18Item;
|
import com.atsuishio.superbwarfare.item.gun.handgun.Glock18Item;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -47,7 +47,8 @@ public class Glock18ItemModel extends GeoModel<Glock18Item> {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.is(ModTags.Items.GUN)) return;
|
if (!stack.is(ModTags.Items.GUN)) return;
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
int mode = GunsTool.getGunIntTag(tag, "FireMode");
|
int mode = GunsTool.getGunIntTag(tag, "FireMode");
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
switch_.setRotX(35 * Mth.DEG_TO_RAD);
|
switch_.setRotX(35 * Mth.DEG_TO_RAD);
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.rifle.Hk416Item;
|
import com.atsuishio.superbwarfare.item.gun.rifle.Hk416Item;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -108,9 +108,10 @@ public class Hk416ItemModel extends GeoModel<Hk416Item> {
|
||||||
scope2.setScaleZ(1f - (0.8f * (float) zp));
|
scope2.setScaleZ(1f - (0.8f * (float) zp));
|
||||||
scope3.setScaleZ(1f - (0.5f * (float) zp));
|
scope3.setScaleZ(1f - (0.5f * (float) zp));
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosX() > 3.1));
|
tag.putBoolean("HoloHidden", !(gun.getPosX() > 3.1));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
GeoBone shen;
|
GeoBone shen;
|
||||||
if (zt < 0.5) {
|
if (zt < 0.5) {
|
||||||
|
|
|
@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.rifle.InsidiousItem;
|
import com.atsuishio.superbwarfare.item.gun.rifle.InsidiousItem;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -68,9 +68,10 @@ public class InsidiousItemModel extends GeoModel<InsidiousItem> {
|
||||||
gun.setPosZ(6.2f * (float) zp + (float) (0.5f * zpz));
|
gun.setPosZ(6.2f * (float) zp + (float) (0.5f * zpz));
|
||||||
gun.setScaleZ(1f - (0.82f * (float) zp));
|
gun.setScaleZ(1f - (0.82f * (float) zp));
|
||||||
|
|
||||||
var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosX() > 3));
|
tag.putBoolean("HoloHidden", !(gun.getPosX() > 3));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
GeoBone shen = getAnimationProcessor().getBone("fireRootNormal");
|
GeoBone shen = getAnimationProcessor().getBone("fireRootNormal");
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.launcher.JavelinItem;
|
import com.atsuishio.superbwarfare.item.gun.launcher.JavelinItem;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -68,9 +68,10 @@ public class JavelinItemModel extends GeoModel<JavelinItem> {
|
||||||
|
|
||||||
javelin.setHidden(gun.getPosZ() > 15.85);
|
javelin.setHidden(gun.getPosZ() > 15.85);
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosZ() > 15.85));
|
tag.putBoolean("HoloHidden", !(gun.getPosZ() > 15.85));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
shen.setPosX((float) (0.75f * ClientEventHandler.recoilHorizon * fpz * fp));
|
shen.setPosX((float) (0.75f * ClientEventHandler.recoilHorizon * fpz * fp));
|
||||||
shen.setPosY((float) (-0.03f * fp - 0.06f * fr));
|
shen.setPosY((float) (-0.03f * fp - 0.06f * fr));
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.handgun.M1911Item;
|
import com.atsuishio.superbwarfare.item.gun.handgun.M1911Item;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -105,7 +105,8 @@ public class M1911ItemModel extends GeoModel<M1911Item> {
|
||||||
float numR = (float) (1 - 0.12 * zt);
|
float numR = (float) (1 - 0.12 * zt);
|
||||||
float numP = (float) (1 - 0.68 * zt);
|
float numP = (float) (1 - 0.68 * zt);
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
|
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
|
||||||
main.setRotX(numR * main.getRotX());
|
main.setRotX(numR * main.getRotX());
|
||||||
main.setRotY(numR * main.getRotY());
|
main.setRotY(numR * main.getRotY());
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.rifle.M4Item;
|
import com.atsuishio.superbwarfare.item.gun.rifle.M4Item;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||||
|
@ -129,9 +130,10 @@ public class M4ItemModel extends GeoModel<M4Item> {
|
||||||
button6.setScaleX(1f - (0.5f * (float) zp));
|
button6.setScaleX(1f - (0.5f * (float) zp));
|
||||||
button7.setScaleX(1f - (0.5f * (float) zp));
|
button7.setScaleX(1f - (0.5f * (float) zp));
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosX() > 2.385));
|
tag.putBoolean("HoloHidden", !(gun.getPosX() > 2.385));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
if (type == 3 && zt > 0.5) {
|
if (type == 3 && zt > 0.5) {
|
||||||
lh.setPosY((float) (-zt * 4));
|
lh.setPosY((float) (-zt * 4));
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.machinegun.M60Item;
|
import com.atsuishio.superbwarfare.item.gun.machinegun.M60Item;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -59,7 +59,8 @@ public class M60ItemModel extends GeoModel<M60Item> {
|
||||||
r.setRotX(1.5f);
|
r.setRotX(1.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
int ammo = GunsTool.getGunIntTag(tag, "Ammo");
|
int ammo = GunsTool.getGunIntTag(tag, "Ammo");
|
||||||
boolean flag = GunsTool.getGunBooleanTag(tag, "HideBulletChain");
|
boolean flag = GunsTool.getGunBooleanTag(tag, "HideBulletChain");
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.sniper.M98bItem;
|
import com.atsuishio.superbwarfare.item.gun.sniper.M98bItem;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -88,9 +88,10 @@ public class M98bItemModel extends GeoModel<M98bItem> {
|
||||||
gun.setPosZ(4.2f * (float) zp + (float) (0.3f * zpz));
|
gun.setPosZ(4.2f * (float) zp + (float) (0.3f * zpz));
|
||||||
gun.setRotZ((float) (0.02f * zpz));
|
gun.setRotZ((float) (0.02f * zpz));
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosX() > 1.8));
|
tag.putBoolean("HoloHidden", !(gun.getPosX() > 1.8));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
GeoBone root = getAnimationProcessor().getBone("root");
|
GeoBone root = getAnimationProcessor().getBone("root");
|
||||||
GeoBone zhunxing = getAnimationProcessor().getBone("shi");
|
GeoBone zhunxing = getAnimationProcessor().getBone("shi");
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.rifle.Mk14Item;
|
import com.atsuishio.superbwarfare.item.gun.rifle.Mk14Item;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -139,9 +139,10 @@ public class Mk14ItemModel extends GeoModel<Mk14Item> {
|
||||||
|
|
||||||
action.setPosZ(2.5f * (float) fp);
|
action.setPosZ(2.5f * (float) fp);
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosX() > 2.5));
|
tag.putBoolean("HoloHidden", !(gun.getPosX() > 2.5));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
GeoBone root = getAnimationProcessor().getBone("root");
|
GeoBone root = getAnimationProcessor().getBone("root");
|
||||||
root.setPosX((float) (movePosX + 20 * ClientEventHandler.drawTime + 9.3f * mph));
|
root.setPosX((float) (movePosX + 20 * ClientEventHandler.drawTime + 9.3f * mph));
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunData;
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.sniper.MosinNagantItem;
|
import com.atsuishio.superbwarfare.item.gun.sniper.MosinNagantItem;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -90,7 +89,7 @@ public class MosinNagantItemModel extends GeoModel<MosinNagantItem> {
|
||||||
var data = GunData.from(stack);
|
var data = GunData.from(stack);
|
||||||
final var tag = data.getTag();
|
final var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosX() > 1.4));
|
tag.putBoolean("HoloHidden", !(gun.getPosX() > 1.4));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
shen.setPosX((float) (0.95f * ClientEventHandler.recoilHorizon * fpz * fp));
|
shen.setPosX((float) (0.95f * ClientEventHandler.recoilHorizon * fpz * fp));
|
||||||
shen.setPosY((float) (0.4f * fp + 0.44f * fr));
|
shen.setPosY((float) (0.4f * fp + 0.44f * fr));
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.handgun.Mp443Item;
|
import com.atsuishio.superbwarfare.item.gun.handgun.Mp443Item;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -102,7 +102,8 @@ public class Mp443ItemModel extends GeoModel<Mp443Item> {
|
||||||
float numR = (float) (1 - 0.12 * zt);
|
float numR = (float) (1 - 0.12 * zt);
|
||||||
float numP = (float) (1 - 0.68 * zt);
|
float numP = (float) (1 - 0.68 * zt);
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
|
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
|
||||||
main.setRotX(numR * main.getRotX());
|
main.setRotX(numR * main.getRotX());
|
||||||
main.setRotY(numR * main.getRotY());
|
main.setRotY(numR * main.getRotY());
|
||||||
|
|
|
@ -4,9 +4,9 @@ import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item;
|
import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -137,9 +137,10 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
|
||||||
|
|
||||||
CrossHairOverlay.gunRot = shen.getRotZ();
|
CrossHairOverlay.gunRot = shen.getRotZ();
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosX() > 4.3));
|
tag.putBoolean("HoloHidden", !(gun.getPosX() > 4.3));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
action.setPosZ(3f * (float) ClientEventHandler.actionMove);
|
action.setPosZ(3f * (float) ClientEventHandler.actionMove);
|
||||||
lh.setPosZ(-3f * (float) ClientEventHandler.actionMove);
|
lh.setPosZ(-3f * (float) ClientEventHandler.actionMove);
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.launcher.RpgItem;
|
import com.atsuishio.superbwarfare.item.gun.launcher.RpgItem;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -45,7 +45,8 @@ public class RpgItemModel extends GeoModel<RpgItem> {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.is(ModTags.Items.GUN)) return;
|
if (!stack.is(ModTags.Items.GUN)) return;
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
if (GunsTool.getGunBooleanTag(tag, "CloseHammer")) {
|
if (GunsTool.getGunBooleanTag(tag, "CloseHammer")) {
|
||||||
hammer.setRotX(-90 * Mth.DEG_TO_RAD);
|
hammer.setRotX(-90 * Mth.DEG_TO_RAD);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.machinegun.RpkItem;
|
import com.atsuishio.superbwarfare.item.gun.machinegun.RpkItem;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -75,9 +75,10 @@ public class RpkItemModel extends GeoModel<RpkItem> {
|
||||||
button.setScaleZ(1f - (0.3f * (float) zp));
|
button.setScaleZ(1f - (0.3f * (float) zp));
|
||||||
|
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosX() > 1.65));
|
tag.putBoolean("HoloHidden", !(gun.getPosX() > 1.65));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
shen.setPosX((float) (0.95f * ClientEventHandler.recoilHorizon * fpz * fp));
|
shen.setPosX((float) (0.95f * ClientEventHandler.recoilHorizon * fpz * fp));
|
||||||
shen.setPosY((float) (0.15f * fp + 0.18f * fr));
|
shen.setPosY((float) (0.15f * fp + 0.18f * fr));
|
||||||
|
|
|
@ -4,9 +4,9 @@ import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.launcher.SecondaryCataclysm;
|
import com.atsuishio.superbwarfare.item.gun.launcher.SecondaryCataclysm;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -100,7 +100,8 @@ public class SecondaryCataclysmModel extends GeoModel<SecondaryCataclysm> {
|
||||||
float numR = (float) (1 - 0.12 * zt);
|
float numR = (float) (1 - 0.12 * zt);
|
||||||
float numP = (float) (1 - 0.68 * zt);
|
float numP = (float) (1 - 0.68 * zt);
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
|
if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) {
|
||||||
main.setRotX(numR * main.getRotX());
|
main.setRotX(numR * main.getRotX());
|
||||||
main.setRotY(numR * main.getRotY());
|
main.setRotY(numR * main.getRotY());
|
||||||
|
|
|
@ -4,9 +4,9 @@ import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.sniper.SentinelItem;
|
import com.atsuishio.superbwarfare.item.gun.sniper.SentinelItem;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -76,9 +76,10 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
|
||||||
GeoBone holo = getAnimationProcessor().getBone("holo");
|
GeoBone holo = getAnimationProcessor().getBone("holo");
|
||||||
holo.setPosY(0.09f);
|
holo.setPosY(0.09f);
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", !(gun.getPosX() > 2.4));
|
tag.putBoolean("HoloHidden", !(gun.getPosX() > 2.4));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
shen.setPosX((float) (0.95f * ClientEventHandler.recoilHorizon * fpz * fp));
|
shen.setPosX((float) (0.95f * ClientEventHandler.recoilHorizon * fpz * fp));
|
||||||
shen.setPosY((float) (0.4f * fp + 0.44f * fr));
|
shen.setPosY((float) (0.4f * fp + 0.44f * fr));
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.rifle.SksItem;
|
import com.atsuishio.superbwarfare.item.gun.rifle.SksItem;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -68,9 +68,10 @@ public class SksItemModel extends GeoModel<SksItem> {
|
||||||
gun.setPosZ(2.5f * (float) zp + (float) (0.5f * zpz));
|
gun.setPosZ(2.5f * (float) zp + (float) (0.5f * zpz));
|
||||||
gun.setRotZ((float) (0.05f * zpz));
|
gun.setRotZ((float) (0.05f * zpz));
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", gun.getPosX() <= 1.2);
|
tag.putBoolean("HoloHidden", gun.getPosX() <= 1.2);
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
GeoBone shen = getAnimationProcessor().getBone("shen");
|
GeoBone shen = getAnimationProcessor().getBone("shen");
|
||||||
|
|
||||||
shen.setPosX((float) (0.95f * ClientEventHandler.recoilHorizon * fpz * fp));
|
shen.setPosX((float) (0.95f * ClientEventHandler.recoilHorizon * fpz * fp));
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.sniper.SvdItem;
|
import com.atsuishio.superbwarfare.item.gun.sniper.SvdItem;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -110,9 +110,10 @@ public class SvdItemModel extends GeoModel<SvdItem> {
|
||||||
cross3.setScaleX((float) (1f + (0.1 * zp)));
|
cross3.setScaleX((float) (1f + (0.1 * zp)));
|
||||||
cross3.setScaleY((float) (1f + (0.1 * zp)));
|
cross3.setScaleY((float) (1f + (0.1 * zp)));
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", gun.getPosX() <= 1.4);
|
tag.putBoolean("HoloHidden", gun.getPosX() <= 1.4);
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
GeoBone shen;
|
GeoBone shen;
|
||||||
if (zt < 0.5) {
|
if (zt < 0.5) {
|
||||||
|
|
|
@ -153,9 +153,10 @@ public class TracheliumItemModel extends GeoModel<Trachelium> {
|
||||||
|
|
||||||
CrossHairOverlay.gunRot = shen.getRotZ();
|
CrossHairOverlay.gunRot = shen.getRotZ();
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
tag.putBoolean("HoloHidden", (gun.getPosX() <= 3 || Mth.abs(shen.getRotX()) > (scopeType == 2 ? 3 : 1) * Mth.DEG_TO_RAD || Mth.abs(main.getRotX()) > (scopeType == 2 ? 5.7 : 1) * Mth.DEG_TO_RAD || Mth.abs(main.getRotY()) > 3 * Mth.DEG_TO_RAD));
|
tag.putBoolean("HoloHidden", (gun.getPosX() <= 3 || Mth.abs(shen.getRotX()) > (scopeType == 2 ? 3 : 1) * Mth.DEG_TO_RAD || Mth.abs(main.getRotX()) > (scopeType == 2 ? 5.7 : 1) * Mth.DEG_TO_RAD || Mth.abs(main.getRotY()) > 3 * Mth.DEG_TO_RAD));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
hammer.setRotX(50 * Mth.DEG_TO_RAD * (float) ClientEventHandler.revolverPreTime);
|
hammer.setRotX(50 * Mth.DEG_TO_RAD * (float) ClientEventHandler.revolverPreTime);
|
||||||
lun.setRotZ(-60 * Mth.DEG_TO_RAD * (float) ClientEventHandler.revolverWheelPreTime);
|
lun.setRotZ(-60 * Mth.DEG_TO_RAD * (float) ClientEventHandler.revolverWheelPreTime);
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.item.gun.smg.VectorItem;
|
import com.atsuishio.superbwarfare.item.gun.smg.VectorItem;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -55,7 +55,8 @@ public class VectorItemModel extends GeoModel<VectorItem> {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.is(ModTags.Items.GUN)) return;
|
if (!stack.is(ModTags.Items.GUN)) return;
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
int mode = GunsTool.getGunIntTag(tag, "FireMode");
|
int mode = GunsTool.getGunIntTag(tag, "FireMode");
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
kmj.setRotX(-120 * Mth.DEG_TO_RAD);
|
kmj.setRotX(-120 * Mth.DEG_TO_RAD);
|
||||||
|
@ -100,7 +101,7 @@ public class VectorItemModel extends GeoModel<VectorItem> {
|
||||||
scope.setScaleZ(1f - (0.2f * (float) zp));
|
scope.setScaleZ(1f - (0.2f * (float) zp));
|
||||||
|
|
||||||
tag.putBoolean("HoloHidden", gun.getPosX() <= 2);
|
tag.putBoolean("HoloHidden", gun.getPosX() <= 2);
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
GeoBone shen;
|
GeoBone shen;
|
||||||
if (zt < 0.5) {
|
if (zt < 0.5) {
|
||||||
|
|
|
@ -378,9 +378,7 @@ public class ClientEventHandler {
|
||||||
public static void handleWeaponFire(RenderFrameEvent.Pre event) {
|
public static void handleWeaponFire(RenderFrameEvent.Pre event) {
|
||||||
ClientLevel level = Minecraft.getInstance().level;
|
ClientLevel level = Minecraft.getInstance().level;
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
|
if (player == null || level == null) return;
|
||||||
if (player == null) return;
|
|
||||||
if (level == null) return;
|
|
||||||
|
|
||||||
if (notInGame()) {
|
if (notInGame()) {
|
||||||
holdFire = false;
|
holdFire = false;
|
||||||
|
@ -525,6 +523,8 @@ public class ClientEventHandler {
|
||||||
if (stack.getItem() == ModItems.DEVOTION.get() && (data.normalReloading() || data.emptyReloading())) {
|
if (stack.getItem() == ModItems.DEVOTION.get() && (data.normalReloading() || data.emptyReloading())) {
|
||||||
customRpm = 0;
|
customRpm = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void beamShoot(Player player, ItemStack stack) {
|
public static void beamShoot(Player player, ItemStack stack) {
|
||||||
|
@ -593,7 +593,7 @@ public class ClientEventHandler {
|
||||||
revolverWheelPreTime = 0;
|
revolverWheelPreTime = 0;
|
||||||
|
|
||||||
playGunClientSounds(player, tag);
|
playGunClientSounds(player, tag);
|
||||||
handleClientShoot(tag);
|
handleClientShoot();
|
||||||
}
|
}
|
||||||
} else if (stack.is(ModItems.MINIGUN.get())) {
|
} else if (stack.is(ModItems.MINIGUN.get())) {
|
||||||
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
||||||
|
@ -613,7 +613,7 @@ public class ClientEventHandler {
|
||||||
Mod.queueClientWork((int) (1 + 1.5 * shooterHeight), () -> player.playSound(ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1));
|
Mod.queueClientWork((int) (1 + 1.5 * shooterHeight), () -> player.playSound(ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClientShoot(tag);
|
handleClientShoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,7 +622,7 @@ public class ClientEventHandler {
|
||||||
actionMove = Mth.lerp(0.125 * times, actionMove, 0);
|
actionMove = Mth.lerp(0.125 * times, actionMove, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleClientShoot(final CompoundTag tag) {
|
public static void handleClientShoot() {
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
|
@ -48,10 +48,12 @@ public class GunEventHandler {
|
||||||
|
|
||||||
if (stack.is(ModTags.Items.GUN)) {
|
if (stack.is(ModTags.Items.GUN)) {
|
||||||
var data = GunData.from(stack);
|
var data = GunData.from(stack);
|
||||||
handleGunBolt(player, data.reload());
|
|
||||||
handleGunReload(player, data.reload());
|
handleGunBolt(player, data);
|
||||||
handleGunSingleReload(player, data.reload());
|
handleGunReload(player, data);
|
||||||
handleSentinelCharge(player, data.reload());
|
handleGunSingleReload(player, data);
|
||||||
|
handleSentinelCharge(player, data);
|
||||||
|
|
||||||
data.save();
|
data.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +66,7 @@ public class GunEventHandler {
|
||||||
|
|
||||||
if (stack.is(ModTags.Items.NORMAL_GUN)) {
|
if (stack.is(ModTags.Items.NORMAL_GUN)) {
|
||||||
var tag = gunData.getTag();
|
var tag = gunData.getTag();
|
||||||
var data = tag.getCompound("GunData");
|
var data = gunData.getData();
|
||||||
|
|
||||||
if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
|
if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) {
|
||||||
data.putInt("BoltActionTick", GunsTool.getGunIntTag(tag, "BoltActionTick") - 1);
|
data.putInt("BoltActionTick", GunsTool.getGunIntTag(tag, "BoltActionTick") - 1);
|
||||||
|
@ -81,7 +83,6 @@ public class GunEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gunData.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -400,7 +401,6 @@ public class GunEventHandler {
|
||||||
}
|
}
|
||||||
data.putBoolean("StartReload", false);
|
data.putBoolean("StartReload", false);
|
||||||
}
|
}
|
||||||
gunData.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void playGunNormalReload(Player player, GunData gunData) {
|
public static void playGunNormalReload(Player player, GunData gunData) {
|
||||||
|
@ -411,15 +411,15 @@ public class GunEventHandler {
|
||||||
gunData.setAmmo(gunData.magazine() + (gunItem.hasBulletInBarrel(stack) ? 1 : 0));
|
gunData.setAmmo(gunData.magazine() + (gunItem.hasBulletInBarrel(stack) ? 1 : 0));
|
||||||
} else {
|
} else {
|
||||||
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
||||||
GunsTool.reload(player, stack, gunData.reload(), AmmoType.SHOTGUN, gunItem.hasBulletInBarrel(stack));
|
GunsTool.reload(player, stack, gunData, AmmoType.SHOTGUN, gunItem.hasBulletInBarrel(stack));
|
||||||
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) {
|
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) {
|
||||||
GunsTool.reload(player, stack, gunData.reload(), AmmoType.SNIPER, true);
|
GunsTool.reload(player, stack, gunData, AmmoType.SNIPER, true);
|
||||||
} else if (stack.is(ModTags.Items.USE_HANDGUN_AMMO)) {
|
} else if (stack.is(ModTags.Items.USE_HANDGUN_AMMO)) {
|
||||||
GunsTool.reload(player, stack, gunData.reload(), AmmoType.HANDGUN, true);
|
GunsTool.reload(player, stack, gunData, AmmoType.HANDGUN, true);
|
||||||
} else if (stack.is(ModTags.Items.USE_RIFLE_AMMO)) {
|
} else if (stack.is(ModTags.Items.USE_RIFLE_AMMO)) {
|
||||||
GunsTool.reload(player, stack, gunData.reload(), AmmoType.RIFLE, gunItem.hasBulletInBarrel(stack));
|
GunsTool.reload(player, stack, gunData, AmmoType.RIFLE, gunItem.hasBulletInBarrel(stack));
|
||||||
} else if (stack.is(ModTags.Items.USE_HEAVY_AMMO)) {
|
} else if (stack.is(ModTags.Items.USE_HEAVY_AMMO)) {
|
||||||
GunsTool.reload(player, stack, gunData.reload(), AmmoType.HEAVY, gunItem.hasBulletInBarrel(stack));
|
GunsTool.reload(player, stack, gunData, AmmoType.HEAVY, gunItem.hasBulletInBarrel(stack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gunData.setReloadState(GunData.ReloadState.NOT_RELOADING);
|
gunData.setReloadState(GunData.ReloadState.NOT_RELOADING);
|
||||||
|
@ -433,15 +433,15 @@ public class GunEventHandler {
|
||||||
gunData.setAmmo(gunData.magazine());
|
gunData.setAmmo(gunData.magazine());
|
||||||
} else {
|
} else {
|
||||||
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
||||||
GunsTool.reload(player, stack, gunData.reload(), AmmoType.SHOTGUN);
|
GunsTool.reload(player, stack, gunData, AmmoType.SHOTGUN);
|
||||||
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) {
|
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) {
|
||||||
GunsTool.reload(player, stack, gunData.reload(), AmmoType.SNIPER);
|
GunsTool.reload(player, stack, gunData, AmmoType.SNIPER);
|
||||||
} else if (stack.is(ModTags.Items.USE_HANDGUN_AMMO)) {
|
} else if (stack.is(ModTags.Items.USE_HANDGUN_AMMO)) {
|
||||||
GunsTool.reload(player, stack, gunData.reload(), AmmoType.HANDGUN);
|
GunsTool.reload(player, stack, gunData, AmmoType.HANDGUN);
|
||||||
} else if (stack.is(ModTags.Items.USE_RIFLE_AMMO)) {
|
} else if (stack.is(ModTags.Items.USE_RIFLE_AMMO)) {
|
||||||
GunsTool.reload(player, stack, gunData.reload(), AmmoType.RIFLE);
|
GunsTool.reload(player, stack, gunData, AmmoType.RIFLE);
|
||||||
} else if (stack.is(ModTags.Items.USE_HEAVY_AMMO)) {
|
} else if (stack.is(ModTags.Items.USE_HEAVY_AMMO)) {
|
||||||
GunsTool.reload(player, stack, gunData.reload(), AmmoType.HEAVY);
|
GunsTool.reload(player, stack, gunData, AmmoType.HEAVY);
|
||||||
} else if (stack.getItem() == ModItems.TASER.get()) {
|
} else if (stack.getItem() == ModItems.TASER.get()) {
|
||||||
gunData.setAmmo(1);
|
gunData.setAmmo(1);
|
||||||
player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.TASER_ELECTRODE.get(), 1, player.inventoryMenu.getCraftSlots());
|
player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.TASER_ELECTRODE.get(), 1, player.inventoryMenu.getCraftSlots());
|
||||||
|
@ -584,26 +584,26 @@ public class GunEventHandler {
|
||||||
} else if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && gunData.getAmmo() >= gunData.magazine()) {
|
} else if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && gunData.getAmmo() >= gunData.magazine()) {
|
||||||
tag.putBoolean("force_stage3_start", true);
|
tag.putBoolean("force_stage3_start", true);
|
||||||
} else {
|
} else {
|
||||||
tag.putInt("reload_stage", 2);
|
gunData.setReloadStage(2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && gunData.getAmmo() >= gunData.magazine()) {
|
if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && gunData.getAmmo() >= gunData.magazine()) {
|
||||||
tag.putBoolean("force_stage3_start", true);
|
tag.putBoolean("force_stage3_start", true);
|
||||||
} else {
|
} else {
|
||||||
tag.putInt("reload_stage", 2);
|
gunData.setReloadStage(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 检查备弹
|
// 检查备弹
|
||||||
}
|
}
|
||||||
|
|
||||||
// 强制停止换弹,进入三阶段
|
// 强制停止换弹,进入三阶段
|
||||||
if (tag.getBoolean("force_stop") && tag.getInt("reload_stage") == 2 && tag.getInt("iterative") > 0) {
|
if (tag.getBoolean("force_stop") && gunData.getReloadStage() == 2 && tag.getInt("iterative") > 0) {
|
||||||
tag.putBoolean("stop", true);
|
tag.putBoolean("stop", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 二阶段
|
// 二阶段
|
||||||
if ((tag.getDouble("prepare") == 0 || tag.getDouble("prepare_load") == 0)
|
if ((tag.getDouble("prepare") == 0 || tag.getDouble("prepare_load") == 0)
|
||||||
&& tag.getInt("reload_stage") == 2
|
&& gunData.getReloadStage() == 2
|
||||||
&& tag.getInt("iterative") == 0
|
&& tag.getInt("iterative") == 0
|
||||||
&& !tag.getBoolean("stop")
|
&& !tag.getBoolean("stop")
|
||||||
&& gunData.getAmmo() < gunData.magazine()
|
&& gunData.getAmmo() < gunData.magazine()
|
||||||
|
@ -644,7 +644,7 @@ public class GunEventHandler {
|
||||||
if (tag.getInt("iterative") == 1) {
|
if (tag.getInt("iterative") == 1) {
|
||||||
// 装满结束
|
// 装满结束
|
||||||
if (gunData.getAmmo() >= gunData.magazine()) {
|
if (gunData.getAmmo() >= gunData.magazine()) {
|
||||||
tag.putInt("reload_stage", 3);
|
gunData.setReloadStage(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 备弹耗尽结束
|
// 备弹耗尽结束
|
||||||
|
@ -653,29 +653,29 @@ public class GunEventHandler {
|
||||||
if (capability == null) capability = new PlayerVariable();
|
if (capability == null) capability = new PlayerVariable();
|
||||||
|
|
||||||
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) {
|
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) {
|
||||||
tag.putInt("reload_stage", 3);
|
gunData.setReloadStage(3);
|
||||||
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) {
|
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) {
|
||||||
tag.putInt("reload_stage", 3);
|
gunData.setReloadStage(3);
|
||||||
} else if ((stack.is(ModTags.Items.USE_HANDGUN_AMMO) || stack.is(ModTags.Items.SMG)) && capability.handgunAmmo == 0) {
|
} else if ((stack.is(ModTags.Items.USE_HANDGUN_AMMO) || stack.is(ModTags.Items.SMG)) && capability.handgunAmmo == 0) {
|
||||||
tag.putInt("reload_stage", 3);
|
gunData.setReloadStage(3);
|
||||||
} else if (stack.is(ModTags.Items.USE_RIFLE_AMMO) && capability.rifleAmmo == 0) {
|
} else if (stack.is(ModTags.Items.USE_RIFLE_AMMO) && capability.rifleAmmo == 0) {
|
||||||
tag.putInt("reload_stage", 3);
|
gunData.setReloadStage(3);
|
||||||
} else if (stack.is(ModTags.Items.USE_HEAVY_AMMO) && capability.heavyAmmo == 0) {
|
} else if (stack.is(ModTags.Items.USE_HEAVY_AMMO) && capability.heavyAmmo == 0) {
|
||||||
tag.putInt("reload_stage", 3);
|
gunData.setReloadStage(3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 强制结束
|
// 强制结束
|
||||||
if (tag.getBoolean("stop")) {
|
if (tag.getBoolean("stop")) {
|
||||||
tag.putInt("reload_stage", 3);
|
gunData.setReloadStage(3);
|
||||||
tag.putBoolean("force_stop", false);
|
tag.putBoolean("force_stop", false);
|
||||||
tag.putBoolean("stop", false);
|
tag.putBoolean("stop", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 三阶段
|
// 三阶段
|
||||||
if ((tag.getInt("iterative") == 1 && tag.getInt("reload_stage") == 3) || tag.getBoolean("force_stage3_start")) {
|
if ((tag.getInt("iterative") == 1 && gunData.getReloadStage() == 3) || tag.getBoolean("force_stage3_start")) {
|
||||||
tag.putInt("reload_stage", 3);
|
gunData.setReloadStage(3);
|
||||||
tag.putBoolean("force_stage3_start", false);
|
tag.putBoolean("force_stage3_start", false);
|
||||||
int finishTime = gunData.finishTime();
|
int finishTime = gunData.finishTime();
|
||||||
tag.putInt("finish", finishTime + 2);
|
tag.putInt("finish", finishTime + 2);
|
||||||
|
@ -689,7 +689,7 @@ public class GunEventHandler {
|
||||||
|
|
||||||
// 三阶段结束
|
// 三阶段结束
|
||||||
if (tag.getInt("finish") == 1) {
|
if (tag.getInt("finish") == 1) {
|
||||||
tag.putInt("reload_stage", 0);
|
gunData.setReloadStage(0);
|
||||||
if (gunData.boltActionTime() > 0) {
|
if (gunData.boltActionTime() > 0) {
|
||||||
GunsTool.setGunBooleanTag(tag, "NeedBoltAction", false);
|
GunsTool.setGunBooleanTag(tag, "NeedBoltAction", false);
|
||||||
}
|
}
|
||||||
|
@ -698,8 +698,6 @@ public class GunEventHandler {
|
||||||
|
|
||||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack));
|
NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
gunData.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void singleLoad(Player player, GunData data) {
|
public static void singleLoad(Player player, GunData data) {
|
||||||
|
@ -890,7 +888,5 @@ public class GunEventHandler {
|
||||||
if (GunsTool.getGunIntTag(tag, "ChargeTime") == 1) {
|
if (GunsTool.getGunIntTag(tag, "ChargeTime") == 1) {
|
||||||
data.putBoolean("Charging", false);
|
data.putBoolean("Charging", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
gunData.save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,7 @@ public class LivingEventHandler {
|
||||||
if (!stack.is(ModTags.Items.GUN)) return;
|
if (!stack.is(ModTags.Items.GUN)) return;
|
||||||
if (event.getEntity() instanceof TargetEntity) return;
|
if (event.getEntity() instanceof TargetEntity) return;
|
||||||
|
|
||||||
var data = GunData.from(stack).reload();
|
var data = GunData.from(stack);
|
||||||
double amount = Math.min(0.125 * event.getAmount(), event.getEntity().getMaxHealth());
|
double amount = Math.min(0.125 * event.getAmount(), event.getEntity().getMaxHealth());
|
||||||
final var tag = NBTTool.getTag(stack);
|
final var tag = NBTTool.getTag(stack);
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ public class LivingEventHandler {
|
||||||
if (!stack.is(ModTags.Items.GUN)) return;
|
if (!stack.is(ModTags.Items.GUN)) return;
|
||||||
if (event.getEntity() instanceof TargetEntity) return;
|
if (event.getEntity() instanceof TargetEntity) return;
|
||||||
|
|
||||||
var data = GunData.from(stack).reload();
|
var data = GunData.from(stack);
|
||||||
double amount = 20 + 2 * event.getEntity().getMaxHealth();
|
double amount = 20 + 2 * event.getEntity().getMaxHealth();
|
||||||
final var tag = NBTTool.getTag(stack);
|
final var tag = NBTTool.getTag(stack);
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ public class LivingEventHandler {
|
||||||
if (!stack.is(ModTags.Items.GUN)) return;
|
if (!stack.is(ModTags.Items.GUN)) return;
|
||||||
if (event.getEntity() instanceof TargetEntity) return;
|
if (event.getEntity() instanceof TargetEntity) return;
|
||||||
|
|
||||||
var data = GunData.from(stack).reload();
|
var data = GunData.from(stack);
|
||||||
int level = data.getLevel();
|
int level = data.getLevel();
|
||||||
double exp = data.getExp();
|
double exp = data.getExp();
|
||||||
double upgradeExpNeeded = 20 * Math.pow(level, 2) + 160 * level + 20;
|
double upgradeExpNeeded = 20 * Math.pow(level, 2) + 160 * level + 20;
|
||||||
|
@ -356,8 +356,9 @@ public class LivingEventHandler {
|
||||||
if (oldStack.getItem() instanceof GunItem oldGun) {
|
if (oldStack.getItem() instanceof GunItem oldGun) {
|
||||||
stopGunReloadSound(serverPlayer, oldGun);
|
stopGunReloadSound(serverPlayer, oldGun);
|
||||||
|
|
||||||
var oldData = GunData.from(oldStack).reload();
|
var oldData = GunData.from(oldStack);
|
||||||
CompoundTag data = oldData.getData();
|
oldTag = oldData.getTag();
|
||||||
|
var data = oldData.getData();
|
||||||
|
|
||||||
if (oldData.boltActionTime() > 0) {
|
if (oldData.boltActionTime() > 0) {
|
||||||
data.putInt("BoltActionTick", 0);
|
data.putInt("BoltActionTick", 0);
|
||||||
|
@ -371,7 +372,7 @@ public class LivingEventHandler {
|
||||||
if (oldData.iterativeTime() != 0) {
|
if (oldData.iterativeTime() != 0) {
|
||||||
oldTag.putBoolean("force_stop", false);
|
oldTag.putBoolean("force_stop", false);
|
||||||
oldTag.putBoolean("stop", false);
|
oldTag.putBoolean("stop", false);
|
||||||
oldTag.putInt("reload_stage", 0);
|
oldData.setReloadStage(0);
|
||||||
oldTag.putDouble("prepare", 0);
|
oldTag.putDouble("prepare", 0);
|
||||||
oldTag.putDouble("prepare_load", 0);
|
oldTag.putDouble("prepare_load", 0);
|
||||||
oldTag.putDouble("iterative", 0);
|
oldTag.putDouble("iterative", 0);
|
||||||
|
@ -388,10 +389,13 @@ public class LivingEventHandler {
|
||||||
cap.edit = false;
|
cap.edit = false;
|
||||||
cap.syncPlayerVariables(player);
|
cap.syncPlayerVariables(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oldData.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.getItem() instanceof GunItem) {
|
if (newStack.getItem() instanceof GunItem) {
|
||||||
var newData = GunData.from(newStack);
|
var newData = GunData.from(newStack);
|
||||||
|
newTag = newData.getTag();
|
||||||
|
|
||||||
player.getPersistentData().putDouble("noRun", 40);
|
player.getPersistentData().putDouble("noRun", 40);
|
||||||
newTag.putBoolean("draw", true);
|
newTag.putBoolean("draw", true);
|
||||||
|
@ -401,14 +405,14 @@ public class LivingEventHandler {
|
||||||
|
|
||||||
newData.setReloadState(GunData.ReloadState.NOT_RELOADING);
|
newData.setReloadState(GunData.ReloadState.NOT_RELOADING);
|
||||||
|
|
||||||
CompoundTag data = newTag.getCompound("GunData");
|
var data = newTag.getCompound("GunData");
|
||||||
data.putInt("ReloadTime", 0);
|
data.putInt("ReloadTime", 0);
|
||||||
newTag.put("GunData", data);
|
newTag.put("GunData", data);
|
||||||
|
|
||||||
if (newData.iterativeTime() != 0) {
|
if (newData.iterativeTime() != 0) {
|
||||||
newTag.putBoolean("force_stop", false);
|
newTag.putBoolean("force_stop", false);
|
||||||
newTag.putBoolean("stop", false);
|
newTag.putBoolean("stop", false);
|
||||||
newTag.putInt("reload_stage", 0);
|
newData.setReloadStage(0);
|
||||||
newTag.putDouble("prepare", 0);
|
newTag.putDouble("prepare", 0);
|
||||||
newTag.putDouble("prepare_load", 0);
|
newTag.putDouble("prepare_load", 0);
|
||||||
newTag.putDouble("iterative", 0);
|
newTag.putDouble("iterative", 0);
|
||||||
|
@ -419,7 +423,6 @@ public class LivingEventHandler {
|
||||||
GunsTool.setGunBooleanTag(newTag, "Charging", false);
|
GunsTool.setGunBooleanTag(newTag, "Charging", false);
|
||||||
GunsTool.setGunIntTag(newTag, "ChargeTime", 0);
|
GunsTool.setGunIntTag(newTag, "ChargeTime", 0);
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(newStack, newTag);
|
|
||||||
|
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.KILLING_TALLY.get(), newTag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.KILLING_TALLY.get(), newTag);
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
|
@ -435,9 +438,9 @@ public class LivingEventHandler {
|
||||||
cap.tacticalSprint = false;
|
cap.tacticalSprint = false;
|
||||||
cap.syncPlayerVariables(player);
|
cap.syncPlayerVariables(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newData.save();
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(oldStack, oldTag);
|
|
||||||
NBTTool.saveTag(newStack, newTag);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -573,7 +576,8 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleClipPerks(ItemStack stack) {
|
private static void handleClipPerks(ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int healClipLevel = PerkHelper.getItemPerkLevel(ModPerks.HEAL_CLIP.get(), tag);
|
int healClipLevel = PerkHelper.getItemPerkLevel(ModPerks.HEAL_CLIP.get(), tag);
|
||||||
if (healClipLevel != 0) {
|
if (healClipLevel != 0) {
|
||||||
GunsTool.setPerkIntTag(tag, "HealClipTime", 80 + healClipLevel * 20);
|
GunsTool.setPerkIntTag(tag, "HealClipTime", 80 + healClipLevel * 20);
|
||||||
|
@ -583,11 +587,12 @@ public class LivingEventHandler {
|
||||||
if (killClipLevel != 0) {
|
if (killClipLevel != 0) {
|
||||||
GunsTool.setPerkIntTag(tag, "KillClipReloadTime", 80);
|
GunsTool.setPerkIntTag(tag, "KillClipReloadTime", 80);
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleKillClipDamage(ItemStack stack, LivingIncomingDamageEvent event) {
|
private static void handleKillClipDamage(ItemStack stack, LivingIncomingDamageEvent event) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
if (GunsTool.getPerkIntTag(tag, "KillClipTime") > 0) {
|
if (GunsTool.getPerkIntTag(tag, "KillClipTime") > 0) {
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.KILL_CLIP.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.KILL_CLIP.get(), tag);
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
|
@ -599,7 +604,8 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleGutshotStraightDamage(ItemStack stack, LivingIncomingDamageEvent event) {
|
private static void handleGutshotStraightDamage(ItemStack stack, LivingIncomingDamageEvent event) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.GUTSHOT_STRAIGHT.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.GUTSHOT_STRAIGHT.get(), tag);
|
||||||
if (level == 0) return;
|
if (level == 0) return;
|
||||||
|
|
||||||
|
@ -607,7 +613,8 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleKillingTallyDamage(ItemStack stack, LivingIncomingDamageEvent event) {
|
private static void handleKillingTallyDamage(ItemStack stack, LivingIncomingDamageEvent event) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.KILLING_TALLY.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.KILLING_TALLY.get(), tag);
|
||||||
if (level == 0) return;
|
if (level == 0) return;
|
||||||
|
|
||||||
|
@ -620,16 +627,18 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleKillingTallyAddCount(ItemStack stack) {
|
private static void handleKillingTallyAddCount(ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.KILLING_TALLY.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.KILLING_TALLY.get(), tag);
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
GunsTool.setPerkIntTag(tag, "KillingTally", Math.min(3, GunsTool.getPerkIntTag(tag, "KillingTally") + 1));
|
GunsTool.setPerkIntTag(tag, "KillingTally", Math.min(3, GunsTool.getPerkIntTag(tag, "KillingTally") + 1));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleFourthTimesCharm(ItemStack stack) {
|
private static void handleFourthTimesCharm(ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.FOURTH_TIMES_CHARM.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.FOURTH_TIMES_CHARM.get(), tag);
|
||||||
if (level == 0) return;
|
if (level == 0) return;
|
||||||
|
|
||||||
|
@ -643,11 +652,12 @@ public class LivingEventHandler {
|
||||||
GunsTool.setPerkIntTag(tag, "FourthTimesCharmCount", Math.min(4, count + 1));
|
GunsTool.setPerkIntTag(tag, "FourthTimesCharmCount", Math.min(4, count + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleSubsistence(ItemStack stack, Player player) {
|
private static void handleSubsistence(ItemStack stack, Player player) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.SUBSISTENCE.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.SUBSISTENCE.get(), tag);
|
||||||
if (level == 0) return;
|
if (level == 0) return;
|
||||||
|
|
||||||
|
@ -656,7 +666,6 @@ public class LivingEventHandler {
|
||||||
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
||||||
if (cap == null) return;
|
if (cap == null) return;
|
||||||
|
|
||||||
var data = GunData.from(stack);
|
|
||||||
int mag = data.magazine();
|
int mag = data.magazine();
|
||||||
int ammo = data.getAmmo();
|
int ammo = data.getAmmo();
|
||||||
int ammoReload = (int) Math.min(mag, mag * rate);
|
int ammoReload = (int) Math.min(mag, mag * rate);
|
||||||
|
@ -687,7 +696,8 @@ public class LivingEventHandler {
|
||||||
|
|
||||||
|
|
||||||
private static void handleFieldDoctor(ItemStack stack, LivingIncomingDamageEvent event, Player player) {
|
private static void handleFieldDoctor(ItemStack stack, LivingIncomingDamageEvent event, Player player) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.FIELD_DOCTOR.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.FIELD_DOCTOR.get(), tag);
|
||||||
if (level == 0) return;
|
if (level == 0) return;
|
||||||
|
|
||||||
|
@ -698,16 +708,18 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleHeadSeekerTime(ItemStack stack) {
|
private static void handleHeadSeekerTime(ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.HEAD_SEEKER.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.HEAD_SEEKER.get(), tag);
|
||||||
if (level == 0) return;
|
if (level == 0) return;
|
||||||
|
|
||||||
GunsTool.setPerkIntTag(tag, "HeadSeeker", 11 + level * 2);
|
GunsTool.setPerkIntTag(tag, "HeadSeeker", 11 + level * 2);
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleHeadSeekerDamage(ItemStack stack, LivingIncomingDamageEvent event) {
|
private static void handleHeadSeekerDamage(ItemStack stack, LivingIncomingDamageEvent event) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.HEAD_SEEKER.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.HEAD_SEEKER.get(), tag);
|
||||||
if (level == 0) return;
|
if (level == 0) return;
|
||||||
|
|
||||||
|
@ -717,12 +729,13 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleDesperado(ItemStack stack) {
|
private static void handleDesperado(ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.DESPERADO.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.DESPERADO.get(), tag);
|
||||||
if (level == 0) return;
|
if (level == 0) return;
|
||||||
|
|
||||||
GunsTool.setPerkIntTag(tag, "DesperadoTime", 90 + level * 10);
|
GunsTool.setPerkIntTag(tag, "DesperadoTime", 90 + level * 10);
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,10 +37,12 @@ public class PlayerEventHandler {
|
||||||
}
|
}
|
||||||
for (ItemStack pStack : player.getInventory().items) {
|
for (ItemStack pStack : player.getInventory().items) {
|
||||||
if (pStack.is(ModTags.Items.GUN)) {
|
if (pStack.is(ModTags.Items.GUN)) {
|
||||||
tag = NBTTool.getTag(pStack);
|
var data = GunData.from(stack);
|
||||||
|
tag = data.getTag();
|
||||||
|
|
||||||
tag.putBoolean("draw", true);
|
tag.putBoolean("draw", true);
|
||||||
tag.putBoolean("init", false);
|
|
||||||
NBTTool.saveTag(pStack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,11 +62,14 @@ public class PlayerEventHandler {
|
||||||
handleRespawnReload(player);
|
handleRespawnReload(player);
|
||||||
handleRespawnAutoArmor(player);
|
handleRespawnAutoArmor(player);
|
||||||
|
|
||||||
for (ItemStack pStack : player.getInventory().items) {
|
for (ItemStack stack : player.getInventory().items) {
|
||||||
if (pStack.is(ModTags.Items.GUN)) {
|
if (stack.is(ModTags.Items.GUN)) {
|
||||||
var tag = NBTTool.getTag(pStack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
|
|
||||||
tag.putBoolean("draw", true);
|
tag.putBoolean("draw", true);
|
||||||
NBTTool.saveTag(pStack, tag);
|
|
||||||
|
data.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +217,9 @@ public class PlayerEventHandler {
|
||||||
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
||||||
if (cap == null) return;
|
if (cap == null) return;
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
|
|
||||||
if (cap.bowPullHold) {
|
if (cap.bowPullHold) {
|
||||||
if (stack.getItem() == ModItems.BOCEK.get()
|
if (stack.getItem() == ModItems.BOCEK.get()
|
||||||
&& GunsTool.getGunIntTag(tag, "MaxAmmo") > 0
|
&& GunsTool.getGunIntTag(tag, "MaxAmmo") > 0
|
||||||
|
@ -246,7 +253,7 @@ public class PlayerEventHandler {
|
||||||
player.setSprinting(false);
|
player.setSprinting(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleSimulationDistance(Player player) {
|
private static void handleSimulationDistance(Player player) {
|
||||||
|
@ -265,7 +272,7 @@ public class PlayerEventHandler {
|
||||||
|
|
||||||
for (ItemStack stack : player.getInventory().items) {
|
for (ItemStack stack : player.getInventory().items) {
|
||||||
if (stack.is(ModTags.Items.GUN)) {
|
if (stack.is(ModTags.Items.GUN)) {
|
||||||
var data = GunData.from(stack).reload();
|
var data = GunData.from(stack);
|
||||||
var tag = data.getTag();
|
var tag = data.getTag();
|
||||||
|
|
||||||
if (!InventoryTool.hasCreativeAmmoBox(player)) {
|
if (!InventoryTool.hasCreativeAmmoBox(player)) {
|
||||||
|
@ -356,7 +363,7 @@ public class PlayerEventHandler {
|
||||||
if (left.is(ModTags.Items.GUN) && right.getItem() == ModItems.SHORTCUT_PACK.get()) {
|
if (left.is(ModTags.Items.GUN) && right.getItem() == ModItems.SHORTCUT_PACK.get()) {
|
||||||
ItemStack output = left.copy();
|
ItemStack output = left.copy();
|
||||||
|
|
||||||
var data = GunData.from(output).reload();
|
var data = GunData.from(output);
|
||||||
data.setUpgradePoint(data.getUpgradePoint() + 1);
|
data.setUpgradePoint(data.getUpgradePoint() + 1);
|
||||||
data.save();
|
data.save();
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ package com.atsuishio.superbwarfare.event;
|
||||||
import com.atsuishio.superbwarfare.event.events.ReloadEvent;
|
import com.atsuishio.superbwarfare.event.events.ReloadEvent;
|
||||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
@ -49,7 +49,8 @@ public class ReloadEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleHealClipPre(ItemStack stack) {
|
private static void handleHealClipPre(ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int time = GunsTool.getPerkIntTag(tag, "HealClipTime");
|
int time = GunsTool.getPerkIntTag(tag, "HealClipTime");
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
GunsTool.setPerkIntTag(tag, "HealClipTime", 0);
|
GunsTool.setPerkIntTag(tag, "HealClipTime", 0);
|
||||||
|
@ -57,11 +58,12 @@ public class ReloadEventHandler {
|
||||||
} else {
|
} else {
|
||||||
GunsTool.setPerkBooleanTag(tag, "HealClip", false);
|
GunsTool.setPerkBooleanTag(tag, "HealClip", false);
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleHealClipPost(Player player, ItemStack stack) {
|
private static void handleHealClipPost(Player player, ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
if (!GunsTool.getPerkBooleanTag(tag, "HealClip")) return;
|
if (!GunsTool.getPerkBooleanTag(tag, "HealClip")) return;
|
||||||
|
|
||||||
int healClipLevel = PerkHelper.getItemPerkLevel(ModPerks.HEAL_CLIP.get(), tag);
|
int healClipLevel = PerkHelper.getItemPerkLevel(ModPerks.HEAL_CLIP.get(), tag);
|
||||||
|
@ -77,7 +79,8 @@ public class ReloadEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleKillClipPre(ItemStack stack) {
|
private static void handleKillClipPre(ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int time = GunsTool.getPerkIntTag(tag, "KillClipReloadTime");
|
int time = GunsTool.getPerkIntTag(tag, "KillClipReloadTime");
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
GunsTool.setPerkIntTag(tag, "KillClipReloadTime", 0);
|
GunsTool.setPerkIntTag(tag, "KillClipReloadTime", 0);
|
||||||
|
@ -85,29 +88,32 @@ public class ReloadEventHandler {
|
||||||
} else {
|
} else {
|
||||||
GunsTool.setPerkBooleanTag(tag, "KillClip", false);
|
GunsTool.setPerkBooleanTag(tag, "KillClip", false);
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleKillClipPost(ItemStack stack) {
|
private static void handleKillClipPost(ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
if (!GunsTool.getPerkBooleanTag(tag, "KillClip")) return;
|
if (!GunsTool.getPerkBooleanTag(tag, "KillClip")) return;
|
||||||
|
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.KILL_CLIP.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.KILL_CLIP.get(), tag);
|
||||||
GunsTool.setPerkIntTag(tag, "KillClipTime", 90 + 10 * level);
|
GunsTool.setPerkIntTag(tag, "KillClipTime", 90 + 10 * level);
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleKillingTallyPre(ItemStack stack) {
|
private static void handleKillingTallyPre(ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.KILLING_TALLY.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.KILLING_TALLY.get(), tag);
|
||||||
if (level == 0) return;
|
if (level == 0) return;
|
||||||
|
|
||||||
GunsTool.setPerkIntTag(tag, "KillingTally", 0);
|
GunsTool.setPerkIntTag(tag, "KillingTally", 0);
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleDesperadoPre(ItemStack stack) {
|
private static void handleDesperadoPre(ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
int time = GunsTool.getPerkIntTag(tag, "DesperadoTime");
|
int time = GunsTool.getPerkIntTag(tag, "DesperadoTime");
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
GunsTool.setPerkIntTag(tag, "DesperadoTime", 0);
|
GunsTool.setPerkIntTag(tag, "DesperadoTime", 0);
|
||||||
|
@ -115,15 +121,16 @@ public class ReloadEventHandler {
|
||||||
} else {
|
} else {
|
||||||
GunsTool.setPerkBooleanTag(tag, "Desperado", false);
|
GunsTool.setPerkBooleanTag(tag, "Desperado", false);
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleDesperadoPost(ItemStack stack) {
|
private static void handleDesperadoPost(ItemStack stack) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
if (!GunsTool.getPerkBooleanTag(tag, "Desperado")) return;
|
if (!GunsTool.getPerkBooleanTag(tag, "Desperado")) return;
|
||||||
|
|
||||||
int level = PerkHelper.getItemPerkLevel(ModPerks.DESPERADO.get(), tag);
|
int level = PerkHelper.getItemPerkLevel(ModPerks.DESPERADO.get(), tag);
|
||||||
GunsTool.setPerkIntTag(tag, "DesperadoTimePost", 110 + level * 10);
|
GunsTool.setPerkIntTag(tag, "DesperadoTimePost", 110 + level * 10);
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.init;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.item.*;
|
import com.atsuishio.superbwarfare.item.*;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -35,11 +34,6 @@ public class ModTabs {
|
||||||
.displayItems((param, output) -> ModItems.GUNS.getEntries().forEach(registryObject -> {
|
.displayItems((param, output) -> ModItems.GUNS.getEntries().forEach(registryObject -> {
|
||||||
// 普通枪械
|
// 普通枪械
|
||||||
var stack = new ItemStack(registryObject.get());
|
var stack = new ItemStack(registryObject.get());
|
||||||
var id = stack.getDescriptionId();
|
|
||||||
var tag = NBTTool.getTag(stack);
|
|
||||||
tag.putString("id", id.substring(id.lastIndexOf(".") + 1));
|
|
||||||
NBTTool.saveTag(stack, tag);
|
|
||||||
|
|
||||||
output.accept(stack);
|
output.accept(stack);
|
||||||
|
|
||||||
// 充电后枪械
|
// 充电后枪械
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class GunData {
|
||||||
|
|
||||||
private static final WeakHashMap<ItemStack, GunData> dataCache = new WeakHashMap<>();
|
private static final WeakHashMap<ItemStack, GunData> dataCache = new WeakHashMap<>();
|
||||||
|
|
||||||
public GunData reload() {
|
private void loadTags() {
|
||||||
var customData = stack.get(DataComponents.CUSTOM_DATA);
|
var customData = stack.get(DataComponents.CUSTOM_DATA);
|
||||||
this.tag = customData != null ? customData.copyTag() : new CompoundTag();
|
this.tag = customData != null ? customData.copyTag() : new CompoundTag();
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ public class GunData {
|
||||||
} else {
|
} else {
|
||||||
data = tag.getCompound("GunData");
|
data = tag.getCompound("GunData");
|
||||||
}
|
}
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private GunData(ItemStack stack) {
|
private GunData(ItemStack stack) {
|
||||||
|
@ -40,7 +39,7 @@ public class GunData {
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
var id = stack.getDescriptionId();
|
var id = stack.getDescriptionId();
|
||||||
this.id = id.substring(id.lastIndexOf(".") + 1);
|
this.id = id.substring(id.lastIndexOf(".") + 1);
|
||||||
reload();
|
loadTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GunData from(ItemStack stack) {
|
public static GunData from(ItemStack stack) {
|
||||||
|
@ -289,6 +288,5 @@ public class GunData {
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
stack.set(DataComponents.CUSTOM_DATA, CustomData.of(tag));
|
stack.set(DataComponents.CUSTOM_DATA, CustomData.of(tag));
|
||||||
reload();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.item.gun;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent;
|
import net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent;
|
||||||
|
@ -13,10 +12,10 @@ public class GunEvents {
|
||||||
public static void onPickup(ItemEntityPickupEvent.Pre event) {
|
public static void onPickup(ItemEntityPickupEvent.Pre event) {
|
||||||
var stack = event.getItemEntity().getItem();
|
var stack = event.getItemEntity().getItem();
|
||||||
if (stack.is(ModTags.Items.GUN)) {
|
if (stack.is(ModTags.Items.GUN)) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
tag.putBoolean("draw", true);
|
tag.putBoolean("draw", true);
|
||||||
tag.putBoolean("init", false);
|
data.save();
|
||||||
NBTTool.saveTag(stack, tag);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,17 +81,11 @@ public abstract class GunItem extends Item implements CustomRendererItem {
|
||||||
} else {
|
} else {
|
||||||
GunsTool.initGun(tag, name);
|
GunsTool.initGun(tag, name);
|
||||||
}
|
}
|
||||||
data.reload();
|
|
||||||
tag = data.getTag();
|
|
||||||
|
|
||||||
GunsTool.generateAndSetUUID(tag);
|
GunsTool.generateAndSetUUID(tag);
|
||||||
tag.putBoolean("init", true);
|
tag.putBoolean("init", true);
|
||||||
}
|
}
|
||||||
tag.putBoolean("draw", false);
|
tag.putBoolean("draw", false);
|
||||||
|
|
||||||
data.save();
|
|
||||||
handleGunPerks(data);
|
handleGunPerks(data);
|
||||||
data.reload();
|
|
||||||
|
|
||||||
var hasBulletInBarrel = gunItem.hasBulletInBarrel(stack);
|
var hasBulletInBarrel = gunItem.hasBulletInBarrel(stack);
|
||||||
var ammoCount = data.getAmmo();
|
var ammoCount = data.getAmmo();
|
||||||
|
@ -193,7 +187,6 @@ public abstract class GunItem extends Item implements CustomRendererItem {
|
||||||
|
|
||||||
int mag = data.magazine();
|
int mag = data.magazine();
|
||||||
GunsTool.setGunIntTag(tag, "Ammo", Math.min(mag, GunsTool.getGunIntTag(tag, "Ammo") + 2));
|
GunsTool.setGunIntTag(tag, "Ammo", Math.min(mag, GunsTool.getGunIntTag(tag, "Ammo") + 2));
|
||||||
data.save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,8 @@ public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
super.inventoryTick(stack, world, entity, slot, selected);
|
super.inventoryTick(stack, world, entity, slot, selected);
|
||||||
var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
|
|
||||||
if (entity instanceof Player player && selected) {
|
if (entity instanceof Player player && selected) {
|
||||||
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
||||||
|
@ -200,7 +201,7 @@ public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
||||||
} else {
|
} else {
|
||||||
tag.putInt("SeekTime", 0);
|
tag.putInt("SeekTime", 0);
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean check(ItemStack stack) {
|
protected static boolean check(ItemStack stack) {
|
||||||
|
|
|
@ -17,7 +17,6 @@ import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -129,9 +128,10 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon {
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
super.inventoryTick(stack, world, entity, slot, selected);
|
super.inventoryTick(stack, world, entity, slot, selected);
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -133,7 +132,8 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
||||||
@Override
|
@Override
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
if (tag.getBoolean("draw")) {
|
if (tag.getBoolean("draw")) {
|
||||||
tag.putBoolean("draw", false);
|
tag.putBoolean("draw", false);
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
|
|
||||||
super.inventoryTick(stack, world, entity, slot, selected);
|
super.inventoryTick(stack, world, entity, slot, selected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -91,15 +90,15 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
|
||||||
var data = GunData.from(stack);
|
var data = GunData.from(stack);
|
||||||
final var tag = data.getTag();
|
final var tag = data.getTag();
|
||||||
|
|
||||||
if (tag.getInt("reload_stage") == 1 && tag.getDouble("prepare_load") > 0) {
|
if (data.getReloadStage() == 1 && tag.getDouble("prepare_load") > 0) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.prepare"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.prepare"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getDouble("load_index") == 0 && tag.getInt("reload_stage") == 2) {
|
if (tag.getDouble("load_index") == 0 && data.getReloadStage() == 2) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.iterativeload"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.iterativeload"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getDouble("load_index") == 1 && tag.getInt("reload_stage") == 2) {
|
if (tag.getDouble("load_index") == 1 && data.getReloadStage() == 2) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.iterativeload2"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.iterativeload2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +106,7 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.hit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.hit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getInt("reload_stage") == 3) {
|
if (data.getReloadStage() == 3) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.finish"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.finish"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,9 +123,9 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
|
||||||
if (player.isSprinting() && player.onGround()
|
if (player.isSprinting() && player.onGround()
|
||||||
&& player.getPersistentData().getDouble("noRun") == 0
|
&& player.getPersistentData().getDouble("noRun") == 0
|
||||||
&& !data.emptyReloading()
|
&& !data.emptyReloading()
|
||||||
&& data.getTag().getInt("reload_stage") != 1
|
&& data.getReloadStage() != 1
|
||||||
&& data.getTag().getInt("reload_stage") != 2
|
&& data.getReloadStage() != 2
|
||||||
&& data.getTag().getInt("reload_stage") != 3
|
&& data.getReloadStage() != 3
|
||||||
&& ClientEventHandler.drawTime < 0.01
|
&& ClientEventHandler.drawTime < 0.01
|
||||||
&& ClientEventHandler.gunMelee == 0
|
&& ClientEventHandler.gunMelee == 0
|
||||||
&& !data.isReloading()
|
&& !data.isReloading()
|
||||||
|
@ -181,9 +180,10 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
|
||||||
super.inventoryTick(stack, world, entity, slot, selected);
|
super.inventoryTick(stack, world, entity, slot, selected);
|
||||||
|
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -108,14 +107,15 @@ public class M60Item extends GunItem implements GeoItem {
|
||||||
@Override
|
@Override
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, boolean selected) {
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
if (tag.getBoolean("draw")) {
|
if (tag.getBoolean("draw")) {
|
||||||
tag.putBoolean("draw", false);
|
tag.putBoolean("draw", false);
|
||||||
|
|
||||||
if (GunsTool.getGunIntTag(tag, "Ammo") <= 5) {
|
if (GunsTool.getGunIntTag(tag, "Ammo") <= 5) {
|
||||||
GunsTool.setGunBooleanTag(tag, "HideBulletChain", true);
|
GunsTool.setGunBooleanTag(tag, "HideBulletChain", true);
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
super.inventoryTick(stack, level, entity, slot, selected);
|
super.inventoryTick(stack, level, entity, slot, selected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,8 @@ public class MinigunItem extends GunItem implements GeoItem {
|
||||||
cooldown = -0.1;
|
cooldown = -0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var tag = data.getTag();
|
||||||
if (entity instanceof ServerPlayer serverPlayer && entity.level() instanceof ServerLevel serverLevel && tag.getDouble("heat") > 4 && entity.isInWaterOrRain()) {
|
if (entity instanceof ServerPlayer serverPlayer && entity.level() instanceof ServerLevel serverLevel && tag.getDouble("heat") > 4 && entity.isInWaterOrRain()) {
|
||||||
if (entity.isInWater()) {
|
if (entity.isInWater()) {
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.BUBBLE_COLUMN_UP,
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.BUBBLE_COLUMN_UP,
|
||||||
|
@ -149,7 +150,7 @@ public class MinigunItem extends GunItem implements GeoItem {
|
||||||
tag.putDouble("overheat", (tag.getDouble("overheat") - 1));
|
tag.putDouble("overheat", (tag.getDouble("overheat") - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -56,19 +56,19 @@ public class MarlinItem extends GunItem implements GeoItem {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.shift"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.shift"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getInt("reload_stage") == 1 && tag.getDouble("prepare") > 0) {
|
if (data.getReloadStage() == 1 && tag.getDouble("prepare") > 0) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.prepare"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.prepare"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getDouble("load_index") == 0 && tag.getInt("reload_stage") == 2) {
|
if (tag.getDouble("load_index") == 0 && data.getReloadStage() == 2) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getDouble("load_index") == 1 && tag.getInt("reload_stage") == 2) {
|
if (tag.getDouble("load_index") == 1 && data.getReloadStage() == 2) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload2"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getInt("reload_stage") == 3) {
|
if (data.getReloadStage() == 3) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.finish"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.finish"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -92,14 +91,15 @@ public class SksItem extends GunItem implements GeoItem {
|
||||||
@Override
|
@Override
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, boolean selected) {
|
||||||
if (NBTTool.getTag(stack).getBoolean("draw")) {
|
var data = GunData.from(stack);
|
||||||
final var tag = NBTTool.getTag(stack);
|
final var tag = data.getTag();
|
||||||
|
if (tag.getBoolean("draw")) {
|
||||||
tag.putBoolean("draw", false);
|
tag.putBoolean("draw", false);
|
||||||
|
|
||||||
if (GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
if (GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||||
GunsTool.setGunBooleanTag(tag, "HoldOpen", true);
|
GunsTool.setGunBooleanTag(tag, "HoldOpen", true);
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
super.inventoryTick(stack, level, entity, slot, selected);
|
super.inventoryTick(stack, level, entity, slot, selected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,23 +57,23 @@ public class MosinNagantItem extends GunItem implements GeoItem {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.shift"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.shift"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NBTTool.getTag(stack).getInt("reload_stage") == 1 && GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
if (data.getReloadStage() == 1 && GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare_empty"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare_empty"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NBTTool.getTag(stack).getInt("reload_stage") == 1 && GunsTool.getGunIntTag(tag, "Ammo") > 0) {
|
if (data.getReloadStage() == 1 && GunsTool.getGunIntTag(tag, "Ammo") > 0) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NBTTool.getTag(stack).getDouble("load_index") == 0 && NBTTool.getTag(stack).getInt("reload_stage") == 2) {
|
if (NBTTool.getTag(stack).getDouble("load_index") == 0 && data.getReloadStage() == 2) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.iterativeload"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.iterativeload"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NBTTool.getTag(stack).getDouble("load_index") == 1 && NBTTool.getTag(stack).getInt("reload_stage") == 2) {
|
if (NBTTool.getTag(stack).getDouble("load_index") == 1 && data.getReloadStage() == 2) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.iterativeload2"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.iterativeload2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NBTTool.getTag(stack).getInt("reload_stage") == 3) {
|
if (data.getReloadStage() == 3) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.finish"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.finish"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,9 +91,9 @@ public class MosinNagantItem extends GunItem implements GeoItem {
|
||||||
if (player.isSprinting() && player.onGround()
|
if (player.isSprinting() && player.onGround()
|
||||||
&& player.getPersistentData().getDouble("noRun") == 0
|
&& player.getPersistentData().getDouble("noRun") == 0
|
||||||
&& !(GunData.from(stack).emptyReloading())
|
&& !(GunData.from(stack).emptyReloading())
|
||||||
&& NBTTool.getTag(stack).getInt("reload_stage") != 1
|
&& data.getReloadStage() != 1
|
||||||
&& NBTTool.getTag(stack).getInt("reload_stage") != 2
|
&& data.getReloadStage() != 2
|
||||||
&& NBTTool.getTag(stack).getInt("reload_stage") != 3
|
&& data.getReloadStage() != 3
|
||||||
&& ClientEventHandler.drawTime < 0.01
|
&& ClientEventHandler.drawTime < 0.01
|
||||||
&& !data.isReloading()
|
&& !data.isReloading()
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -13,7 +13,6 @@ import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -138,7 +137,8 @@ public class SentinelItem extends GunItem implements GeoItem, EnergyStorageItem
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
super.inventoryTick(stack, world, entity, slot, selected);
|
super.inventoryTick(stack, world, entity, slot, selected);
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
|
|
||||||
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||||
if (cap != null && cap.getEnergyStored() > 0) {
|
if (cap != null && cap.getEnergyStored() > 0) {
|
||||||
|
@ -148,7 +148,7 @@ public class SentinelItem extends GunItem implements GeoItem, EnergyStorageItem
|
||||||
} else {
|
} else {
|
||||||
GunsTool.setGunDoubleTag(tag, "ChargedDamage", 0);
|
GunsTool.setGunDoubleTag(tag, "ChargedDamage", 0);
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,7 +18,6 @@ import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
@ -118,15 +117,16 @@ public class BocekItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
super.inventoryTick(stack, world, entity, slot, selected);
|
super.inventoryTick(stack, world, entity, slot, selected);
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GunsTool.getGunIntTag(tag, "ArrowEmpty") > 0) {
|
if (GunsTool.getGunIntTag(tag, "ArrowEmpty") > 0) {
|
||||||
GunsTool.setGunIntTag(tag, "ArrowEmpty", GunsTool.getGunIntTag(tag, "ArrowEmpty") - 1);
|
GunsTool.setGunIntTag(tag, "ArrowEmpty", GunsTool.getGunIntTag(tag, "ArrowEmpty") - 1);
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
@ -147,11 +146,12 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
super.inventoryTick(stack, world, entity, slot, selected);
|
super.inventoryTick(stack, world, entity, slot, selected);
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
|
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
GunsTool.setGunIntTag(tag, "MaxAmmo", getAmmoCount(player));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.REGENERATION.get(), tag);
|
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.REGENERATION.get(), tag);
|
||||||
|
|
|
@ -239,7 +239,8 @@ public class ReforgingTableMenu extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack result = gun.copy();
|
ItemStack result = gun.copy();
|
||||||
final var tag = NBTTool.getTag(result);
|
var data = GunData.from(result);
|
||||||
|
final var tag = data.getTag();
|
||||||
|
|
||||||
if (!ammo.isEmpty() && ammo.getItem() instanceof PerkItem<?> perkItem) {
|
if (!ammo.isEmpty() && ammo.getItem() instanceof PerkItem<?> perkItem) {
|
||||||
if (gunItem.canApplyPerk(perkItem.getPerk())) {
|
if (gunItem.canApplyPerk(perkItem.getPerk())) {
|
||||||
|
@ -262,7 +263,7 @@ public class ReforgingTableMenu extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTool.saveTag(result, tag);
|
data.save();
|
||||||
handleUpgradePoint(result);
|
handleUpgradePoint(result);
|
||||||
|
|
||||||
this.ammoPerkLevel.set(0);
|
this.ammoPerkLevel.set(0);
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.atsuishio.superbwarfare.network.message.receive;
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
|
@ -20,7 +19,7 @@ public record ShootClientMessage(double time) implements CustomPacketPayload {
|
||||||
);
|
);
|
||||||
|
|
||||||
public static void handler(ShootClientMessage message, final IPayloadContext context) {
|
public static void handler(ShootClientMessage message, final IPayloadContext context) {
|
||||||
ClientEventHandler.handleClientShoot(new CompoundTag());
|
ClientEventHandler.handleClientShoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,10 +37,10 @@ public record AdjustZoomFovMessage(double scroll) implements CustomPacketPayload
|
||||||
var tag = data.getTag();
|
var tag = data.getTag();
|
||||||
|
|
||||||
if (stack.is(ModItems.MINIGUN.get())) {
|
if (stack.is(ModItems.MINIGUN.get())) {
|
||||||
double minRpm = 300;
|
double minRpm = 300 - 1200;
|
||||||
double maxRpm = 2400;
|
double maxRpm = 2400 - 1200;
|
||||||
|
|
||||||
GunsTool.setGunIntTag(tag, "CustomRPM", (int) Mth.clamp(GunsTool.getGunIntTag(tag, "CustomRPM") - 1200 + 50 * message.scroll, minRpm, maxRpm));
|
GunsTool.setGunIntTag(tag, "CustomRPM", (int) Mth.clamp(GunsTool.getGunIntTag(tag, "CustomRPM") + 50 * message.scroll, minRpm, maxRpm));
|
||||||
if (GunsTool.getGunIntTag(tag, "CustomRPM") == 1150 - 1200) {
|
if (GunsTool.getGunIntTag(tag, "CustomRPM") == 1150 - 1200) {
|
||||||
GunsTool.setGunIntTag(tag, "CustomRPM", 1145 - 1200);
|
GunsTool.setGunIntTag(tag, "CustomRPM", 1145 - 1200);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.network.message.send;
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -34,7 +34,8 @@ public record EditMessage(int msgType) implements CustomPacketPayload {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.is(ModTags.Items.GUN)) return;
|
if (!stack.is(ModTags.Items.GUN)) return;
|
||||||
|
|
||||||
var rootTag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
var rootTag = data.getTag();
|
||||||
CompoundTag tag = rootTag.getCompound("Attachments");
|
CompoundTag tag = rootTag.getCompound("Attachments");
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0 -> {
|
case 0 -> {
|
||||||
|
@ -69,7 +70,7 @@ public record EditMessage(int msgType) implements CustomPacketPayload {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rootTag.put("Attachments", tag);
|
rootTag.put("Attachments", tag);
|
||||||
NBTTool.saveTag(stack, rootTag);
|
data.save();
|
||||||
SoundTool.playLocalSound(player, ModSounds.EDIT.get(), 1f, 1f);
|
SoundTool.playLocalSound(player, ModSounds.EDIT.get(), 1f, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.atsuishio.superbwarfare.network.message.send;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
|
@ -27,13 +27,14 @@ public record SensitivityMessage(boolean isAdd) implements CustomPacketPayload {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.is(ModTags.Items.GUN)) return;
|
if (!stack.is(ModTags.Items.GUN)) return;
|
||||||
|
|
||||||
var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
if (message.isAdd) {
|
if (message.isAdd) {
|
||||||
tag.putInt("sensitivity", Math.min(10, tag.getInt("sensitivity") + 1));
|
tag.putInt("sensitivity", Math.min(10, tag.getInt("sensitivity") + 1));
|
||||||
} else {
|
} else {
|
||||||
tag.putInt("sensitivity", Math.max(-10, tag.getInt("sensitivity") - 1));
|
tag.putInt("sensitivity", Math.max(-10, tag.getInt("sensitivity") - 1));
|
||||||
}
|
}
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
player.displayClientMessage(Component.translatable("tips.superbwarfare.sensitivity", tag.getInt("sensitivity")), true);
|
player.displayClientMessage(Component.translatable("tips.superbwarfare.sensitivity", tag.getInt("sensitivity")), true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.atsuishio.superbwarfare.network.message.send;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
|
@ -27,9 +27,10 @@ public record SwitchScopeMessage(double scroll) implements CustomPacketPayload {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.is(ModTags.Items.GUN)) return;
|
if (!stack.is(ModTags.Items.GUN)) return;
|
||||||
|
|
||||||
final var tag = NBTTool.getTag(stack);
|
var data = GunData.from(stack);
|
||||||
|
final var tag = data.getTag();
|
||||||
tag.putBoolean("ScopeAlt", tag.getBoolean("ScopeAlt"));
|
tag.putBoolean("ScopeAlt", tag.getBoolean("ScopeAlt"));
|
||||||
NBTTool.saveTag(stack, tag);
|
data.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
import com.atsuishio.superbwarfare.item.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
|
@ -63,11 +63,14 @@ public record ZoomMessage(int msgType) implements CustomPacketPayload {
|
||||||
|
|
||||||
if (player.getMainHandItem().getItem() == ModItems.JAVELIN.get()) {
|
if (player.getMainHandItem().getItem() == ModItems.JAVELIN.get()) {
|
||||||
var handItem = player.getMainHandItem();
|
var handItem = player.getMainHandItem();
|
||||||
var tag = NBTTool.getTag(handItem);
|
var data = GunData.from(handItem);
|
||||||
|
var tag = data.getTag();
|
||||||
|
|
||||||
tag.putBoolean("Seeking", false);
|
tag.putBoolean("Seeking", false);
|
||||||
tag.putInt("SeekTime", 0);
|
tag.putInt("SeekTime", 0);
|
||||||
tag.putString("TargetEntity", "none");
|
tag.putString("TargetEntity", "none");
|
||||||
NBTTool.saveTag(handItem, tag);
|
|
||||||
|
data.save();
|
||||||
|
|
||||||
var clientboundstopsoundpacket = new ClientboundStopSoundPacket(Mod.loc("javelin_lock"), SoundSource.PLAYERS);
|
var clientboundstopsoundpacket = new ClientboundStopSoundPacket(Mod.loc("javelin_lock"), SoundSource.PLAYERS);
|
||||||
player.connection.send(clientboundstopsoundpacket);
|
player.connection.send(clientboundstopsoundpacket);
|
||||||
|
|
|
@ -152,7 +152,6 @@ public class GunsTool {
|
||||||
|
|
||||||
gunData.setAmmo(needToAdd);
|
gunData.setAmmo(needToAdd);
|
||||||
gunData.setReloadState(GunData.ReloadState.NOT_RELOADING);
|
gunData.setReloadState(GunData.ReloadState.NOT_RELOADING);
|
||||||
gunData.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PerkData */
|
/* PerkData */
|
||||||
|
|
|
@ -13,6 +13,10 @@ public final class NBTTool {
|
||||||
|
|
||||||
return new CompoundTag();
|
return new CompoundTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 警告:请勿使用该方法保存任何枪械NBT数据!请统一使用GunData.save()保存枪械数据
|
||||||
|
*/
|
||||||
public static void saveTag(ItemStack stack, CompoundTag tag) {
|
public static void saveTag(ItemStack stack, CompoundTag tag) {
|
||||||
var data = stack.get(DataComponents.CUSTOM_DATA);
|
var data = stack.get(DataComponents.CUSTOM_DATA);
|
||||||
var oldTag = data != null ? data.copyTag() : new CompoundTag();
|
var oldTag = data != null ? data.copyTag() : new CompoundTag();
|
||||||
|
|
Loading…
Add table
Reference in a new issue