优化武器数据读取、同步和初始化方式
This commit is contained in:
parent
60f79e9f62
commit
1da96065fc
67 changed files with 285 additions and 565 deletions
|
@ -164,7 +164,7 @@ public class ClickHandler {
|
|||
var tag = NBTTool.getTag(stack);
|
||||
|
||||
if (stack.is(ModTags.Items.GUN) && ClientEventHandler.zoom) {
|
||||
if (GunsTool.getGunBooleanTag(tag, "CanSwitchScope", false)) {
|
||||
if (GunsTool.getGunBooleanTag(tag, "CanSwitchScope")) {
|
||||
PacketDistributor.sendToServer(new SwitchScopeMessage(scroll));
|
||||
} else if (tag.getBoolean("CanAdjustZoomFov") || stack.is(ModItems.MINIGUN.get())) {
|
||||
PacketDistributor.sendToServer(new AdjustZoomFovMessage(scroll));
|
||||
|
@ -323,7 +323,7 @@ public class ClickHandler {
|
|||
&& (!(tag.getBoolean("is_normal_reloading") || tag.getBoolean("is_empty_reloading"))
|
||||
&& !GunsTool.getGunBooleanTag(tag, "Reloading")
|
||||
&& !GunsTool.getGunBooleanTag(tag, "Charging")
|
||||
&& !GunsTool.getGunBooleanTag(tag, "NeedBoltAction", false))
|
||||
&& !GunsTool.getGunBooleanTag(tag, "NeedBoltAction"))
|
||||
&& cantFireTime == 0
|
||||
&& drawTime < 0.01
|
||||
&& !notInGame()
|
||||
|
@ -331,14 +331,14 @@ public class ClickHandler {
|
|||
if ((!(tag.getBoolean("is_normal_reloading") || tag.getBoolean("is_empty_reloading"))
|
||||
&& !GunsTool.getGunBooleanTag(tag, "Reloading")
|
||||
&& !GunsTool.getGunBooleanTag(tag, "Charging")
|
||||
&& !GunsTool.getGunBooleanTag(tag, "NeedBoltAction", false))
|
||||
&& !GunsTool.getGunBooleanTag(tag, "NeedBoltAction"))
|
||||
&& cantFireTime == 0
|
||||
&& drawTime < 0.01
|
||||
&& !notInGame()) {
|
||||
player.playSound(ModSounds.TRIGGER_CLICK.get(), 1, 1);
|
||||
}
|
||||
|
||||
if (!gunItem.useBackpackAmmo(stack) && GunsTool.getGunIntTag(tag, "Ammo", 0) <= 0 && GunsTool.getGunIntTag(tag, "ReloadTime") == 0) {
|
||||
if (!gunItem.useBackpackAmmo(stack) && GunsTool.getGunIntTag(tag, "Ammo") <= 0 && GunsTool.getGunIntTag(tag, "ReloadTime") == 0) {
|
||||
if (ReloadConfig.LEFT_CLICK_RELOAD.get()) {
|
||||
PacketDistributor.sendToServer(new ReloadMessage(0));
|
||||
ClientEventHandler.burstFireSize = 0;
|
||||
|
@ -347,7 +347,7 @@ public class ClickHandler {
|
|||
PacketDistributor.sendToServer(new FireMessage(0));
|
||||
if (GunsTool.getGunIntTag(tag, "FireMode") == 1) {
|
||||
if (ClientEventHandler.burstFireSize == 0) {
|
||||
ClientEventHandler.burstFireSize = GunsTool.getGunIntTag(tag, "BurstSize", 1);
|
||||
ClientEventHandler.burstFireSize = GunsTool.getGunIntTag(tag, "BurstSize");
|
||||
}
|
||||
} else {
|
||||
if (!stack.is(ModItems.BOCEK.get())) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class K98ItemModel extends GeoModel<K98Item> {
|
|||
if (!stack.is(ModTags.Items.GUN)) return;
|
||||
|
||||
final var tag = NBTTool.getTag(stack);
|
||||
if (NBTTool.getTag(stack).getDouble("prepare") > 11 && GunsTool.getGunIntTag(tag, "Ammo", 0) == 1) {
|
||||
if (NBTTool.getTag(stack).getDouble("prepare") > 11 && GunsTool.getGunIntTag(tag, "Ammo") == 1) {
|
||||
clip.setScaleX(0);
|
||||
clip.setScaleY(0);
|
||||
clip.setScaleZ(0);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class M60ItemModel extends GeoModel<M60Item> {
|
|||
}
|
||||
|
||||
final var tag = NBTTool.getTag(stack);
|
||||
int ammo = GunsTool.getGunIntTag(tag, "Ammo", 0);
|
||||
int ammo = GunsTool.getGunIntTag(tag, "Ammo");
|
||||
boolean flag = GunsTool.getGunBooleanTag(tag, "HideBulletChain");
|
||||
|
||||
if (ammo < 5 && flag) {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class MinigunItemModel extends GeoModel<MinigunItem> {
|
|||
double fr = ClientEventHandler.fireRot;
|
||||
|
||||
final var tag = NBTTool.getTag(stack);
|
||||
int rpm = GunsTool.getGunIntTag(tag, "RPM", 0);
|
||||
int rpm = GunsTool.getGunIntTag(tag, "RPM");
|
||||
|
||||
gun.setRotZ(gun.getRotZ() + times * -0.07f * ((float) rpm / 1200) * ClientEventHandler.miniGunRot);
|
||||
|
||||
|
|
|
@ -107,8 +107,8 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
|
|||
root.setRotY((float) (0.2f * movePosX + Mth.DEG_TO_RAD * 300 * ClientEventHandler.drawTime + Mth.DEG_TO_RAD * turnRotY));
|
||||
root.setRotZ((float) (0.2f * movePosX + moveRotZ + Mth.DEG_TO_RAD * 90 * ClientEventHandler.drawTime + 2.7f * mph + Mth.DEG_TO_RAD * turnRotZ));
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) <= 5) {
|
||||
ammo.setScaleX((float) GunsTool.getGunIntTag(tag, "Ammo", 0) / 5);
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") <= 5) {
|
||||
ammo.setScaleX((float) GunsTool.getGunIntTag(tag, "Ammo") / 5);
|
||||
}
|
||||
|
||||
GeoBone camera = getAnimationProcessor().getBone("camera");
|
||||
|
|
|
@ -100,7 +100,7 @@ public class AmmoBarOverlay {
|
|||
// 渲染加特林射速
|
||||
event.getGuiGraphics().drawString(
|
||||
Minecraft.getInstance().font,
|
||||
GunsTool.getGunIntTag(tag, "RPM", 0) + " RPM",
|
||||
GunsTool.getGunIntTag(tag, "RPM") + " RPM",
|
||||
w - 111f,
|
||||
h - 20,
|
||||
0xFFFFFF,
|
||||
|
@ -410,7 +410,7 @@ public class AmmoBarOverlay {
|
|||
return GunsTool.getGunIntTag(tag, "MaxAmmo");
|
||||
}
|
||||
|
||||
return GunsTool.getGunIntTag(tag, "Ammo", 0);
|
||||
return GunsTool.getGunIntTag(tag, "Ammo");
|
||||
}
|
||||
|
||||
private static String getPlayerAmmoCount(Player player) {
|
||||
|
|
|
@ -78,7 +78,7 @@ public class JavelinHudOverlay {
|
|||
float j1 = l + j;
|
||||
preciseBlit(event.getGuiGraphics(), Mod.loc("textures/screens/javelin/javelin_hud.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
preciseBlit(event.getGuiGraphics(), Mod.loc(tag.getBoolean("TopMode") ? "textures/screens/javelin/top.png" : "textures/screens/javelin/dir.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
preciseBlit(event.getGuiGraphics(), Mod.loc(GunsTool.getGunIntTag(tag, "Ammo", 0) > 0 ? "textures/screens/javelin/missile_green.png" : "textures/screens/javelin/missile_red.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
preciseBlit(event.getGuiGraphics(), Mod.loc(GunsTool.getGunIntTag(tag, "Ammo") > 0 ? "textures/screens/javelin/missile_green.png" : "textures/screens/javelin/missile_red.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
if (tag.getInt("SeekTime") > 1 && tag.getInt("SeekTime") < 20) {
|
||||
preciseBlit(event.getGuiGraphics(), Mod.loc("textures/screens/javelin/seek.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ClientBocekImageTooltip extends ClientGunImageTooltip {
|
|||
slug = true;
|
||||
}
|
||||
|
||||
double total = GunsTool.getGunDoubleTag(tag, "Damage", 0) * TooltipTool.perkDamage(stack);
|
||||
double total = GunsTool.getGunDoubleTag(tag, "Damage") * TooltipTool.perkDamage(stack);
|
||||
|
||||
if (slug) {
|
||||
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
|
|||
}
|
||||
|
||||
protected boolean shouldRenderBypassAndHeadshotTooltip() {
|
||||
return GunsTool.getGunDoubleTag(tag, "BypassesArmor", 0) > 0 || GunsTool.getGunDoubleTag(tag, "Headshot", 0) > 0;
|
||||
return GunsTool.getGunDoubleTag(tag, "BypassesArmor") > 0 || GunsTool.getGunDoubleTag(tag, "Headshot") > 0;
|
||||
}
|
||||
|
||||
protected boolean shouldRenderEditTooltip() {
|
||||
|
@ -92,7 +92,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
|
|||
* 获取武器伤害的文本组件
|
||||
*/
|
||||
protected Component getDamageComponent() {
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage", 0) * TooltipTool.perkDamage(stack);
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage") * TooltipTool.perkDamage(stack);
|
||||
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
.append(Component.literal(FormatTool.format1D(damage) + (TooltipTool.heBullet(stack) ? " + "
|
||||
|
@ -106,7 +106,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
|
|||
if (this.stack.getItem() instanceof GunItem gunItem && gunItem.isAutoWeapon(this.stack)) {
|
||||
return Component.translatable("des.superbwarfare.guns.rpm").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
.append(Component.literal(FormatTool.format0D(GunsTool.getGunIntTag(tag, "RPM", 0)))
|
||||
.append(Component.literal(FormatTool.format0D(GunsTool.getGunIntTag(tag, "RPM")))
|
||||
.withStyle(ChatFormatting.GREEN));
|
||||
}
|
||||
return Component.literal("");
|
||||
|
@ -125,8 +125,8 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
|
|||
* 获取武器等级文本组件
|
||||
*/
|
||||
protected Component getLevelComponent() {
|
||||
int level = GunsTool.getGunIntTag(tag, "Level", 0);
|
||||
double rate = GunsTool.getGunDoubleTag(tag, "Exp", 0) / (20 * Math.pow(level, 2) + 160 * level + 20);
|
||||
int level = GunsTool.getGunIntTag(tag, "Level");
|
||||
double rate = GunsTool.getGunDoubleTag(tag, "Exp") / (20 * Math.pow(level, 2) + 160 * level + 20);
|
||||
|
||||
ChatFormatting formatting;
|
||||
if (level < 10) {
|
||||
|
@ -152,7 +152,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
|
|||
* 获取武器强化点数文本组件
|
||||
*/
|
||||
protected Component getUpgradePointComponent() {
|
||||
int upgradePoint = Mth.floor(GunsTool.getGunDoubleTag(tag, "UpgradePoint", 0));
|
||||
int upgradePoint = Mth.floor(GunsTool.getGunDoubleTag(tag, "UpgradePoint"));
|
||||
return Component.translatable("des.superbwarfare.guns.upgrade_point").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
.append(Component.literal(String.valueOf(upgradePoint)).withStyle(ChatFormatting.WHITE).withStyle(ChatFormatting.BOLD));
|
||||
|
@ -178,7 +178,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
|
|||
int level = PerkHelper.getItemPerkLevel(perk, tag);
|
||||
perkBypassArmorRate = ammoPerk.bypassArmorRate + (perk == ModPerks.AP_BULLET.get() ? 0.05f * (level - 1) : 0);
|
||||
}
|
||||
double bypassRate = Math.max(GunsTool.getGunDoubleTag(tag, "BypassesArmor", 0) + perkBypassArmorRate, 0);
|
||||
double bypassRate = Math.max(GunsTool.getGunDoubleTag(tag, "BypassesArmor") + perkBypassArmorRate, 0);
|
||||
|
||||
return Component.translatable("des.superbwarfare.guns.bypass").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
|
@ -189,7 +189,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
|
|||
* 获取武器爆头倍率文本组件
|
||||
*/
|
||||
protected Component getHeadshotComponent() {
|
||||
double headshot = GunsTool.getGunDoubleTag(tag, "Headshot", 0);
|
||||
double headshot = GunsTool.getGunDoubleTag(tag, "Headshot");
|
||||
return Component.translatable("des.superbwarfare.guns.headshot").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
.append(Component.literal(FormatTool.format1D(headshot, "x")).withStyle(ChatFormatting.AQUA));
|
||||
|
|
|
@ -17,11 +17,11 @@ public class ClientLauncherImageTooltip extends ClientGunImageTooltip {
|
|||
|
||||
@Override
|
||||
protected Component getDamageComponent() {
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage", 0) * TooltipTool.perkDamage(stack);
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage") * TooltipTool.perkDamage(stack);
|
||||
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.MICRO_MISSILE.get(), tag);
|
||||
if (perkLevel > 0) damage *= 1.1f + perkLevel * 0.1f;
|
||||
|
||||
double explosionDamage = GunsTool.getGunDoubleTag(tag, "ExplosionDamage", 0);
|
||||
double explosionDamage = GunsTool.getGunDoubleTag(tag, "ExplosionDamage");
|
||||
|
||||
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
|
|
|
@ -17,11 +17,11 @@ public class ClientSecondaryCataclysmImageTooltip extends ClientEnergyImageToolt
|
|||
|
||||
@Override
|
||||
protected Component getDamageComponent() {
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage", 0) * TooltipTool.perkDamage(stack);
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage") * TooltipTool.perkDamage(stack);
|
||||
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.MICRO_MISSILE.get(), tag);
|
||||
if (perkLevel > 0) damage *= 1.1f + perkLevel * 0.1f;
|
||||
|
||||
double explosionDamage = GunsTool.getGunDoubleTag(tag, "ExplosionDamage", 0);
|
||||
double explosionDamage = GunsTool.getGunDoubleTag(tag, "ExplosionDamage");
|
||||
|
||||
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
|
|
|
@ -19,8 +19,8 @@ public class ClientSentinelImageTooltip extends ClientEnergyImageTooltip {
|
|||
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||
|
||||
if (cap != null && cap.getEnergyStored() > 0) {
|
||||
double damage = (GunsTool.getGunDoubleTag(tag, "Damage", 0) +
|
||||
GunsTool.getGunDoubleTag(tag, "ChargedDamage", 0))
|
||||
double damage = (GunsTool.getGunDoubleTag(tag, "Damage") +
|
||||
GunsTool.getGunDoubleTag(tag, "ChargedDamage"))
|
||||
* TooltipTool.perkDamage(stack);
|
||||
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
|
@ -28,7 +28,7 @@ public class ClientSentinelImageTooltip extends ClientEnergyImageTooltip {
|
|||
FormatTool.format1D(0.8 * damage * (1 + 0.1 * TooltipTool.heBulletLevel(stack))) : ""))
|
||||
.withStyle(ChatFormatting.AQUA).withStyle(ChatFormatting.BOLD));
|
||||
} else {
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage", 0) * TooltipTool.perkDamage(stack);
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage") * TooltipTool.perkDamage(stack);
|
||||
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
.append(Component.literal(FormatTool.format1D(damage) + (TooltipTool.heBullet(stack) ?
|
||||
|
|
|
@ -26,16 +26,16 @@ public class ClientShotgunImageTooltip extends ClientGunImageTooltip {
|
|||
}
|
||||
|
||||
if (slug) {
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage", 0) * GunsTool.getGunIntTag(tag, "ProjectileAmount", 1) * TooltipTool.perkDamage(stack);
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage") * GunsTool.getGunIntTag(tag, "ProjectileAmount") * TooltipTool.perkDamage(stack);
|
||||
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
.append(Component.literal(FormatTool.format1D(damage) + (TooltipTool.heBullet(stack) ? " + " +
|
||||
FormatTool.format1D(0.8 * damage * (1 + 0.1 * TooltipTool.heBulletLevel(stack))) : "")).withStyle(ChatFormatting.GREEN));
|
||||
} else {
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage", 0) * TooltipTool.perkDamage(stack);
|
||||
double damage = GunsTool.getGunDoubleTag(tag, "Damage") * TooltipTool.perkDamage(stack);
|
||||
return Component.translatable("des.superbwarfare.guns.damage").withStyle(ChatFormatting.GRAY)
|
||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||
.append(Component.literal(FormatTool.format1D(damage) + " * " + FormatTool.format0D(GunsTool.getGunIntTag(tag, "ProjectileAmount", 1))).withStyle(ChatFormatting.GREEN));
|
||||
.append(Component.literal(FormatTool.format1D(damage) + " * " + FormatTool.format0D(GunsTool.getGunIntTag(tag, "ProjectileAmount"))).withStyle(ChatFormatting.GREEN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ public class ClientEventHandler {
|
|||
if (stack.is(ModItems.MINIGUN.get())) {
|
||||
if (holdFire || zoom) {
|
||||
miniGunRot = Math.min(miniGunRot + 5, 21);
|
||||
float rpm = (float) GunsTool.getGunIntTag(tag, "RPM", 0) / 3600;
|
||||
float rpm = (float) GunsTool.getGunIntTag(tag, "RPM") / 3600;
|
||||
player.playSound(ModSounds.MINIGUN_ROT.get(), 1, 0.7f + rpm);
|
||||
}
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ public class ClientEventHandler {
|
|||
cantFireTime = Mth.clamp(cantFireTime - 6 * speed * times, 0, 40);
|
||||
}
|
||||
|
||||
int rpm = GunsTool.getGunIntTag(tag, "RPM", 0) + customRpm;
|
||||
int rpm = GunsTool.getGunIntTag(tag, "RPM") + customRpm;
|
||||
if (rpm == 0) {
|
||||
rpm = 600;
|
||||
}
|
||||
|
@ -474,9 +474,9 @@ public class ClientEventHandler {
|
|||
&& (!(tag.getBoolean("is_normal_reloading") || tag.getBoolean("is_empty_reloading"))
|
||||
&& !GunsTool.getGunBooleanTag(tag, "Reloading")
|
||||
&& !GunsTool.getGunBooleanTag(tag, "Charging")
|
||||
&& GunsTool.getGunIntTag(tag, "Ammo", 0) > 0
|
||||
&& GunsTool.getGunIntTag(tag, "Ammo") > 0
|
||||
&& !player.getCooldowns().isOnCooldown(stack.getItem())
|
||||
&& !GunsTool.getGunBooleanTag(tag, "NeedBoltAction", false)
|
||||
&& !GunsTool.getGunBooleanTag(tag, "NeedBoltAction")
|
||||
&& revolverPre(tag))
|
||||
|| (stack.is(ModItems.MINIGUN.get())
|
||||
&& !player.isSprinting()
|
||||
|
@ -548,14 +548,14 @@ public class ClientEventHandler {
|
|||
public static void shootClient(Player player, final CompoundTag tag) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (stack.is(ModTags.Items.NORMAL_GUN)) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) > 0) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") > 0) {
|
||||
int mode = GunsTool.getGunIntTag(tag, "FireMode");
|
||||
if (mode != 2) {
|
||||
holdFire = false;
|
||||
}
|
||||
|
||||
if (mode == 1) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) == 1) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") == 1) {
|
||||
burstFireSize = 1;
|
||||
}
|
||||
if (burstFireSize == 1) {
|
||||
|
@ -581,7 +581,7 @@ public class ClientEventHandler {
|
|||
}
|
||||
|
||||
// 判断是否为栓动武器(BoltActionTime > 0),并在开火后给一个需要上膛的状态
|
||||
if (GunsTool.getGunIntTag(tag, "BoltActionTime", 0) > 0 && GunsTool.getGunIntTag(tag, "Ammo", 0) > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) {
|
||||
if (GunsTool.getGunIntTag(tag, "BoltActionTime") > 0 && GunsTool.getGunIntTag(tag, "Ammo") > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) {
|
||||
GunsTool.setGunBooleanTag(tag, "NeedBoltAction", true);
|
||||
}
|
||||
|
||||
|
@ -627,7 +627,7 @@ public class ClientEventHandler {
|
|||
PacketDistributor.sendToServer(new ShootMessage(gunSpread));
|
||||
fireRecoilTime = 10;
|
||||
|
||||
float gunRecoilY = (float) GunsTool.getGunDoubleTag(tag, "RecoilY", 0) * 10;
|
||||
float gunRecoilY = (float) GunsTool.getGunDoubleTag(tag, "RecoilY") * 10;
|
||||
|
||||
recoilY = (float) (2 * Math.random() - 1) * gunRecoilY;
|
||||
|
||||
|
@ -1091,7 +1091,7 @@ public class ClientEventHandler {
|
|||
float roll = event.getRoll();
|
||||
ItemStack stack = entity.getMainHandItem();
|
||||
|
||||
double amplitude = 15000 * GunsTool.getGunDoubleTag(tag, "RecoilY", 0) * GunsTool.getGunDoubleTag(tag, "RecoilX", 0);
|
||||
double amplitude = 15000 * GunsTool.getGunDoubleTag(tag, "RecoilY") * GunsTool.getGunDoubleTag(tag, "RecoilX");
|
||||
|
||||
if (fireRecoilTime > 0) {
|
||||
firePosTimer = 0.001;
|
||||
|
@ -1126,7 +1126,7 @@ public class ClientEventHandler {
|
|||
double rpm = 1;
|
||||
|
||||
if (stack.is(ModItems.MINIGUN.get())) {
|
||||
rpm = (double) GunsTool.getGunIntTag(tag, "RPM", 0) / 1800;
|
||||
rpm = (double) GunsTool.getGunIntTag(tag, "RPM") / 1800;
|
||||
}
|
||||
|
||||
float[] shake = {0, 0};
|
||||
|
@ -1215,10 +1215,10 @@ public class ClientEventHandler {
|
|||
double rpm = 1;
|
||||
|
||||
if (stack.is(ModItems.MINIGUN.get())) {
|
||||
rpm = (double) GunsTool.getGunIntTag(tag, "RPM", 0) / 1800;
|
||||
rpm = (double) GunsTool.getGunIntTag(tag, "RPM") / 1800;
|
||||
}
|
||||
|
||||
float gunRecoilX = (float) GunsTool.getGunDoubleTag(tag, "RecoilX", 0) * 60;
|
||||
float gunRecoilX = (float) GunsTool.getGunDoubleTag(tag, "RecoilX") * 60;
|
||||
|
||||
recoilHorizon = Mth.lerp(0.2 * times, recoilHorizon, 0) + recoilY;
|
||||
recoilY = 0;
|
||||
|
@ -1389,7 +1389,7 @@ public class ClientEventHandler {
|
|||
p = zoomPos;
|
||||
}
|
||||
|
||||
customZoom = Mth.lerp(0.6 * times, customZoom, GunsTool.getGunDoubleTag(tag, "CustomZoom", 0));
|
||||
customZoom = Mth.lerp(0.6 * times, customZoom, GunsTool.getGunDoubleTag(tag, "CustomZoom"));
|
||||
|
||||
double zoomFov = 1.25 + customZoom;
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ public class ClientMouseHandler {
|
|||
return original;
|
||||
}
|
||||
|
||||
double zoom = 1.25 + GunsTool.getGunDoubleTag(tag, "CustomZoom", 0);
|
||||
double zoom = 1.25 + GunsTool.getGunDoubleTag(tag, "CustomZoom");
|
||||
float customSens = (float) tag.getInt("sensitivity");
|
||||
|
||||
if (!player.getMainHandItem().isEmpty() && mc.options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||
|
|
|
@ -118,7 +118,7 @@ public class GunEventHandler {
|
|||
player.playSound(ModSounds.HENG.get(), 4f, 1f);
|
||||
}
|
||||
|
||||
float soundRadius = (float) (GunsTool.getGunDoubleTag(tag, "SoundRadius") * GunsTool.getGunDoubleTag(tag, "CustomSoundRadius", 1));
|
||||
float soundRadius = (float) (GunsTool.getGunDoubleTag(tag, "SoundRadius") * GunsTool.getGunDoubleTag(tag, "CustomSoundRadius"));
|
||||
int barrelType = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.BARREL);
|
||||
|
||||
SoundEvent sound3p = BuiltInRegistries.SOUND_EVENT.get(Mod.loc(name + (barrelType == 2 ? "_fire_3p_s" : "_fire_3p")));
|
||||
|
@ -156,7 +156,7 @@ public class GunEventHandler {
|
|||
|
||||
if (stack.is(ModTags.Items.REVOLVER)) return;
|
||||
|
||||
Mod.queueServerWork((int) (GunsTool.getGunDoubleTag(tag, "BoltActionTime", 0) / 2 + 1.5 * shooterHeight), () -> {
|
||||
Mod.queueServerWork((int) (GunsTool.getGunDoubleTag(tag, "BoltActionTime") / 2 + 1.5 * shooterHeight), () -> {
|
||||
if (stack.is(ModTags.Items.SHOTGUN)) {
|
||||
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_SHOTGUN.get(), (float) Math.max(0.75 - 0.12 * shooterHeight, 0), 1);
|
||||
} else if (stack.is(ModTags.Items.SNIPER_RIFLE)) {
|
||||
|
@ -173,12 +173,12 @@ public class GunEventHandler {
|
|||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
if (!player.level().isClientSide()) {
|
||||
float headshot = (float) GunsTool.getGunDoubleTag(tag, "Headshot", 0);
|
||||
float damage = (float) (GunsTool.getGunDoubleTag(tag, "Damage", 0) +
|
||||
GunsTool.getGunDoubleTag(tag, "ChargedDamage", 0)) * (float) perkDamage(tag);
|
||||
float velocity = (float) ((GunsTool.getGunDoubleTag(tag, "Velocity", 0) + GunsTool.getGunDoubleTag(tag, "CustomVelocity", 0)) * perkSpeed(tag));
|
||||
int projectileAmount = GunsTool.getGunIntTag(tag, "ProjectileAmount", 1);
|
||||
float bypassArmorRate = (float) GunsTool.getGunDoubleTag(tag, "BypassesArmor", 0);
|
||||
float headshot = (float) GunsTool.getGunDoubleTag(tag, "Headshot");
|
||||
float damage = (float) (GunsTool.getGunDoubleTag(tag, "Damage") +
|
||||
GunsTool.getGunDoubleTag(tag, "ChargedDamage")) * (float) perkDamage(tag);
|
||||
float velocity = (float) ((GunsTool.getGunDoubleTag(tag, "Velocity") + GunsTool.getGunDoubleTag(tag, "CustomVelocity")) * perkSpeed(tag));
|
||||
int projectileAmount = GunsTool.getGunIntTag(tag, "ProjectileAmount");
|
||||
float bypassArmorRate = (float) GunsTool.getGunDoubleTag(tag, "BypassesArmor");
|
||||
|
||||
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
||||
boolean zoom = cap != null && cap.zoom;
|
||||
|
@ -319,7 +319,7 @@ public class GunEventHandler {
|
|||
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Pre(player, stack));
|
||||
if (gunItem.isOpenBolt(stack)) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) == 0) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||
data.putInt("ReloadTime", data.getInt("EmptyReloadTime") + 1);
|
||||
tag.putBoolean("is_empty_reloading", true);
|
||||
playGunEmptyReloadSounds(player);
|
||||
|
@ -387,7 +387,7 @@ public class GunEventHandler {
|
|||
|
||||
if (data.getInt("ReloadTime") == 1) {
|
||||
if (gunItem.isOpenBolt(stack)) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) == 0) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||
playGunEmptyReload(player, tag);
|
||||
} else {
|
||||
playGunNormalReload(player, tag);
|
||||
|
@ -533,24 +533,24 @@ public class GunEventHandler {
|
|||
if (tag.getBoolean("start_single_reload")) {
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Pre(player, stack));
|
||||
|
||||
if ((GunsTool.getGunIntTag(tag, "PrepareLoadTime", 0) != 0
|
||||
&& GunsTool.getGunIntTag(tag, "Ammo", 0) == 0)
|
||||
if ((GunsTool.getGunIntTag(tag, "PrepareLoadTime") != 0
|
||||
&& GunsTool.getGunIntTag(tag, "Ammo") == 0)
|
||||
|| stack.is(ModItems.SECONDARY_CATACLYSM.get())
|
||||
) {
|
||||
// 此处判断空仓换弹的时候,是否在准备阶段就需要装填一发,如M870
|
||||
playGunPrepareLoadReloadSounds(player);
|
||||
int prepareLoadTime = GunsTool.getGunIntTag(tag, "PrepareLoadTime", 0);
|
||||
int prepareLoadTime = GunsTool.getGunIntTag(tag, "PrepareLoadTime");
|
||||
tag.putInt("prepare_load", prepareLoadTime + 1);
|
||||
player.getCooldowns().addCooldown(stack.getItem(), prepareLoadTime);
|
||||
} else if (GunsTool.getGunIntTag(tag, "PrepareEmptyTime", 0) != 0 && GunsTool.getGunIntTag(tag, "Ammo", 0) == 0) {
|
||||
} else if (GunsTool.getGunIntTag(tag, "PrepareEmptyTime") != 0 && GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||
// 此处判断空仓换弹,如莫辛纳甘
|
||||
playGunEmptyPrepareSounds(player);
|
||||
int prepareEmptyTime = GunsTool.getGunIntTag(tag, "PrepareEmptyTime", 0);
|
||||
int prepareEmptyTime = GunsTool.getGunIntTag(tag, "PrepareEmptyTime");
|
||||
tag.putInt("prepare", prepareEmptyTime + 1);
|
||||
player.getCooldowns().addCooldown(stack.getItem(), prepareEmptyTime);
|
||||
} else {
|
||||
playGunPrepareReloadSounds(player);
|
||||
int prepareTime = GunsTool.getGunIntTag(tag, "PrepareTime", 0);
|
||||
int prepareTime = GunsTool.getGunIntTag(tag, "PrepareTime");
|
||||
tag.putInt("prepare", prepareTime + 1);
|
||||
player.getCooldowns().addCooldown(stack.getItem(), prepareTime);
|
||||
}
|
||||
|
@ -588,13 +588,13 @@ public class GunEventHandler {
|
|||
tag.putBoolean("force_stage3_start", true);
|
||||
} else if (stack.is(ModTags.Items.LAUNCHER) && GunsTool.getGunIntTag(tag, "MaxAmmo") == 0) {
|
||||
tag.putBoolean("force_stage3_start", true);
|
||||
} else if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && GunsTool.getGunIntTag(tag, "Ammo", 0) >= GunsTool.getGunIntTag(tag, "Magazine", 0)) {
|
||||
} else if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && GunsTool.getGunIntTag(tag, "Ammo") >= GunsTool.getGunIntTag(tag, "Magazine")) {
|
||||
tag.putBoolean("force_stage3_start", true);
|
||||
} else {
|
||||
tag.putInt("reload_stage", 2);
|
||||
}
|
||||
} else {
|
||||
if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && GunsTool.getGunIntTag(tag, "Ammo", 0) >= GunsTool.getGunIntTag(tag, "Magazine", 0)) {
|
||||
if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && GunsTool.getGunIntTag(tag, "Ammo") >= GunsTool.getGunIntTag(tag, "Magazine")) {
|
||||
tag.putBoolean("force_stage3_start", true);
|
||||
} else {
|
||||
tag.putInt("reload_stage", 2);
|
||||
|
@ -613,11 +613,11 @@ public class GunEventHandler {
|
|||
&& tag.getInt("reload_stage") == 2
|
||||
&& tag.getInt("iterative") == 0
|
||||
&& !tag.getBoolean("stop")
|
||||
&& GunsTool.getGunIntTag(tag, "Ammo", 0) < GunsTool.getGunIntTag(tag, "Magazine", 0)
|
||||
+ GunsTool.getGunIntTag(tag, "CustomMagazine", 0)) {
|
||||
&& GunsTool.getGunIntTag(tag, "Ammo") < GunsTool.getGunIntTag(tag, "Magazine")
|
||||
+ GunsTool.getGunIntTag(tag, "CustomMagazine")) {
|
||||
|
||||
playGunLoopReloadSounds(player);
|
||||
int iterativeTime = GunsTool.getGunIntTag(tag, "IterativeTime", 0);
|
||||
int iterativeTime = GunsTool.getGunIntTag(tag, "IterativeTime");
|
||||
tag.putDouble("iterative", iterativeTime);
|
||||
player.getCooldowns().addCooldown(stack.getItem(), iterativeTime);
|
||||
// 动画播放nbt
|
||||
|
@ -650,8 +650,8 @@ public class GunEventHandler {
|
|||
// 二阶段结束
|
||||
if (tag.getInt("iterative") == 1) {
|
||||
// 装满结束
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) >= GunsTool.getGunIntTag(tag, "Magazine", 0)
|
||||
+ GunsTool.getGunIntTag(tag, "CustomMagazine", 0)) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") >= GunsTool.getGunIntTag(tag, "Magazine")
|
||||
+ GunsTool.getGunIntTag(tag, "CustomMagazine")) {
|
||||
tag.putInt("reload_stage", 3);
|
||||
}
|
||||
|
||||
|
@ -685,7 +685,7 @@ public class GunEventHandler {
|
|||
if ((tag.getInt("iterative") == 1 && tag.getInt("reload_stage") == 3) || tag.getBoolean("force_stage3_start")) {
|
||||
tag.putInt("reload_stage", 3);
|
||||
tag.putBoolean("force_stage3_start", false);
|
||||
int finishTime = GunsTool.getGunIntTag(tag, "FinishTime", 0);
|
||||
int finishTime = GunsTool.getGunIntTag(tag, "FinishTime");
|
||||
tag.putInt("finish", finishTime + 2);
|
||||
player.getCooldowns().addCooldown(stack.getItem(), finishTime + 2);
|
||||
playGunEndReloadSounds(player);
|
||||
|
@ -698,7 +698,7 @@ public class GunEventHandler {
|
|||
// 三阶段结束
|
||||
if (tag.getInt("finish") == 1) {
|
||||
tag.putInt("reload_stage", 0);
|
||||
if (GunsTool.getGunIntTag(tag, "BoltActionTime", 0) > 0) {
|
||||
if (GunsTool.getGunIntTag(tag, "BoltActionTime") > 0) {
|
||||
GunsTool.setGunBooleanTag(tag, "NeedBoltAction", false);
|
||||
}
|
||||
GunsTool.setGunBooleanTag(tag, "Reloading", false);
|
||||
|
@ -766,7 +766,7 @@ public class GunEventHandler {
|
|||
double shooterHeight = player.getEyePosition().distanceTo((Vec3.atLowerCornerOf(player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(new Vec3(0, -1, 0).scale(10)),
|
||||
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos())));
|
||||
|
||||
Mod.queueServerWork((int) (GunsTool.getGunIntTag(tag, "PrepareEmptyTime", 0) / 2 + 3 + 1.5 * shooterHeight), () -> {
|
||||
Mod.queueServerWork((int) (GunsTool.getGunIntTag(tag, "PrepareEmptyTime") / 2 + 3 + 1.5 * shooterHeight), () -> {
|
||||
if (stack.is(ModTags.Items.SHOTGUN)) {
|
||||
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_SHOTGUN.get(), (float) Math.max(0.75 - 0.12 * shooterHeight, 0), 1);
|
||||
} else if (stack.is(ModTags.Items.SNIPER_RIFLE) || stack.is(ModTags.Items.HEAVY_WEAPON)) {
|
||||
|
@ -866,11 +866,11 @@ public class GunEventHandler {
|
|||
data.putBoolean("StartCharge", true);
|
||||
}
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "ChargeTime", 0) > 0) {
|
||||
if (GunsTool.getGunIntTag(tag, "ChargeTime") > 0) {
|
||||
data.putInt("ChargeTime", data.getInt("ChargeTime") - 1);
|
||||
}
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "ChargeTime", 0) == 17) {
|
||||
if (GunsTool.getGunIntTag(tag, "ChargeTime") == 17) {
|
||||
for (var cell : player.getInventory().items) {
|
||||
if (cell.is(ModItems.CELL.get())) {
|
||||
var stackStorage = cell.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||
|
@ -893,7 +893,7 @@ public class GunEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "ChargeTime", 0) == 1) {
|
||||
if (GunsTool.getGunIntTag(tag, "ChargeTime") == 1) {
|
||||
data.putBoolean("Charging", false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,14 +214,14 @@ public class LivingEventHandler {
|
|||
// 先处理发射器类武器或高爆弹的爆炸伤害
|
||||
if (source.is(ModDamageTypes.PROJECTILE_BOOM)) {
|
||||
if (stack.is(ModTags.Items.LAUNCHER) || PerkHelper.getItemPerkLevel(ModPerks.HE_BULLET.get(), tag) > 0) {
|
||||
GunsTool.setGunDoubleTag(tag, "Exp", GunsTool.getGunDoubleTag(tag, "Exp", 0) + amount);
|
||||
GunsTool.setGunDoubleTag(tag, "Exp", GunsTool.getGunDoubleTag(tag, "Exp") + amount);
|
||||
}
|
||||
}
|
||||
|
||||
// 再判断是不是枪械能造成的伤害
|
||||
if (!DamageTypeTool.isGunDamage(source)) return;
|
||||
|
||||
GunsTool.setGunDoubleTag(tag, "Exp", GunsTool.getGunDoubleTag(tag, "Exp", 0) + amount);
|
||||
GunsTool.setGunDoubleTag(tag, "Exp", GunsTool.getGunDoubleTag(tag, "Exp") + amount);
|
||||
|
||||
NBTTool.saveTag(stack, tag);
|
||||
}
|
||||
|
@ -240,27 +240,27 @@ public class LivingEventHandler {
|
|||
// 先处理发射器类武器或高爆弹的爆炸伤害
|
||||
if (source.is(ModDamageTypes.PROJECTILE_BOOM)) {
|
||||
if (stack.is(ModTags.Items.LAUNCHER) || PerkHelper.getItemPerkLevel(ModPerks.HE_BULLET.get(), tag) > 0) {
|
||||
GunsTool.setGunDoubleTag(tag, "Exp", GunsTool.getGunDoubleTag(tag, "Exp", 0) + amount);
|
||||
GunsTool.setGunDoubleTag(tag, "Exp", GunsTool.getGunDoubleTag(tag, "Exp") + amount);
|
||||
}
|
||||
}
|
||||
|
||||
// 再判断是不是枪械能造成的伤害
|
||||
if (DamageTypeTool.isGunDamage(source)) {
|
||||
GunsTool.setGunDoubleTag(tag, "Exp", GunsTool.getGunDoubleTag(tag, "Exp", 0) + amount);
|
||||
GunsTool.setGunDoubleTag(tag, "Exp", GunsTool.getGunDoubleTag(tag, "Exp") + amount);
|
||||
}
|
||||
|
||||
// 提升武器等级
|
||||
int level = GunsTool.getGunIntTag(tag, "Level", 0);
|
||||
double exp = GunsTool.getGunDoubleTag(tag, "Exp", 0);
|
||||
int level = GunsTool.getGunIntTag(tag, "Level");
|
||||
double exp = GunsTool.getGunDoubleTag(tag, "Exp");
|
||||
double upgradeExpNeeded = 20 * Math.pow(level, 2) + 160 * level + 20;
|
||||
|
||||
while (exp >= upgradeExpNeeded) {
|
||||
exp -= upgradeExpNeeded;
|
||||
level = GunsTool.getGunIntTag(tag, "Level", 0) + 1;
|
||||
level = GunsTool.getGunIntTag(tag, "Level") + 1;
|
||||
upgradeExpNeeded = 20 * Math.pow(level, 2) + 160 * level + 20;
|
||||
GunsTool.setGunDoubleTag(tag, "Exp", exp);
|
||||
GunsTool.setGunIntTag(tag, "Level", level);
|
||||
GunsTool.setGunDoubleTag(tag, "UpgradePoint", GunsTool.getGunDoubleTag(tag, "UpgradePoint", 0) + 0.5);
|
||||
GunsTool.setGunDoubleTag(tag, "UpgradePoint", GunsTool.getGunDoubleTag(tag, "UpgradePoint") + 0.5);
|
||||
}
|
||||
NBTTool.saveTag(stack, tag);
|
||||
}
|
||||
|
@ -274,17 +274,17 @@ public class LivingEventHandler {
|
|||
if (event.getEntity() instanceof TargetEntity) return;
|
||||
|
||||
final var tag = NBTTool.getTag(stack);
|
||||
int level = GunsTool.getGunIntTag(tag, "Level", 0);
|
||||
double exp = GunsTool.getGunDoubleTag(tag, "Exp", 0);
|
||||
int level = GunsTool.getGunIntTag(tag, "Level");
|
||||
double exp = GunsTool.getGunDoubleTag(tag, "Exp");
|
||||
double upgradeExpNeeded = 20 * Math.pow(level, 2) + 160 * level + 20;
|
||||
|
||||
while (exp >= upgradeExpNeeded) {
|
||||
exp -= upgradeExpNeeded;
|
||||
level = GunsTool.getGunIntTag(tag, "Level", 0) + 1;
|
||||
level = GunsTool.getGunIntTag(tag, "Level") + 1;
|
||||
upgradeExpNeeded = 20 * Math.pow(level, 2) + 160 * level + 20;
|
||||
GunsTool.setGunDoubleTag(tag, "Exp", exp);
|
||||
GunsTool.setGunIntTag(tag, "Level", level);
|
||||
GunsTool.setGunDoubleTag(tag, "UpgradePoint", GunsTool.getGunDoubleTag(tag, "UpgradePoint", 0) + 0.5);
|
||||
GunsTool.setGunDoubleTag(tag, "UpgradePoint", GunsTool.getGunDoubleTag(tag, "UpgradePoint") + 0.5);
|
||||
}
|
||||
NBTTool.saveTag(stack, tag);
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ public class LivingEventHandler {
|
|||
|
||||
CompoundTag data = oldTag.getCompound("GunData");
|
||||
|
||||
if (GunsTool.getGunDoubleTag(oldTag, "BoltActionTime", 0) > 0) {
|
||||
if (GunsTool.getGunDoubleTag(oldTag, "BoltActionTime") > 0) {
|
||||
data.putInt("BoltActionTick", 0);
|
||||
}
|
||||
|
||||
|
@ -365,7 +365,7 @@ public class LivingEventHandler {
|
|||
oldTag.putBoolean("is_normal_reloading", false);
|
||||
oldTag.putBoolean("is_empty_reloading", false);
|
||||
|
||||
if (GunsTool.getGunIntTag(oldTag, "IterativeTime", 0) != 0) {
|
||||
if (GunsTool.getGunIntTag(oldTag, "IterativeTime") != 0) {
|
||||
oldTag.putBoolean("force_stop", false);
|
||||
oldTag.putBoolean("stop", false);
|
||||
oldTag.putInt("reload_stage", 0);
|
||||
|
@ -391,7 +391,7 @@ public class LivingEventHandler {
|
|||
if (newStack.getItem() instanceof GunItem) {
|
||||
player.getPersistentData().putDouble("noRun", 40);
|
||||
newTag.putBoolean("draw", true);
|
||||
if (GunsTool.getGunIntTag(newTag, "BoltActionTime", 0) > 0) {
|
||||
if (GunsTool.getGunIntTag(newTag, "BoltActionTime") > 0) {
|
||||
GunsTool.setGunIntTag(newTag, "BoltActionTick", 0);
|
||||
}
|
||||
newTag.putBoolean("is_normal_reloading", false);
|
||||
|
@ -401,7 +401,7 @@ public class LivingEventHandler {
|
|||
data.putInt("ReloadTime", 0);
|
||||
newTag.put("GunData", data);
|
||||
|
||||
if (GunsTool.getGunIntTag(newTag, "IterativeTime", 0) != 0) {
|
||||
if (GunsTool.getGunIntTag(newTag, "IterativeTime") != 0) {
|
||||
newTag.putBoolean("force_stop", false);
|
||||
newTag.putBoolean("stop", false);
|
||||
newTag.putInt("reload_stage", 0);
|
||||
|
@ -653,8 +653,8 @@ public class LivingEventHandler {
|
|||
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
||||
if (cap == null) return;
|
||||
|
||||
int mag = GunsTool.getGunIntTag(tag, "Magazine", 0) + GunsTool.getGunIntTag(tag, "CustomMagazine", 0);
|
||||
int ammo = GunsTool.getGunIntTag(tag, "Ammo", 0);
|
||||
int mag = GunsTool.getGunIntTag(tag, "Magazine") + GunsTool.getGunIntTag(tag, "CustomMagazine");
|
||||
int ammo = GunsTool.getGunIntTag(tag, "Ammo");
|
||||
int ammoReload = (int) Math.min(mag, mag * rate);
|
||||
int ammoNeed = Math.min(mag - ammo, ammoReload);
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ public class PlayerEventHandler {
|
|||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
final var tag = NBTTool.getTag(stack);
|
||||
if ((stack.is(ModItems.RPG.get()) || stack.is(ModItems.BOCEK.get())) && GunsTool.getGunIntTag(tag, "Ammo", 0) == 1) {
|
||||
if ((stack.is(ModItems.RPG.get()) || stack.is(ModItems.BOCEK.get())) && GunsTool.getGunIntTag(tag, "Ammo") == 1) {
|
||||
tag.putDouble("empty", 0);
|
||||
NBTTool.saveTag(stack, tag);
|
||||
}
|
||||
|
@ -284,25 +284,25 @@ public class PlayerEventHandler {
|
|||
GunsTool.reload(player, stack, tag, AmmoType.HEAVY);
|
||||
}
|
||||
|
||||
if (stack.getItem() == ModItems.TASER.get() && GunsTool.getGunIntTag(tag, "MaxAmmo") > 0 && GunsTool.getGunIntTag(tag, "Ammo", 0) == 0) {
|
||||
if (stack.getItem() == ModItems.TASER.get() && GunsTool.getGunIntTag(tag, "MaxAmmo") > 0 && GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||
GunsTool.setGunIntTag(tag, "Ammo", 1);
|
||||
player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.TASER_ELECTRODE.get(), 1, player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
if (stack.getItem() == ModItems.M_79.get() && GunsTool.getGunIntTag(tag, "MaxAmmo") > 0 && GunsTool.getGunIntTag(tag, "Ammo", 0) == 0) {
|
||||
if (stack.getItem() == ModItems.M_79.get() && GunsTool.getGunIntTag(tag, "MaxAmmo") > 0 && GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||
GunsTool.setGunIntTag(tag, "Ammo", 1);
|
||||
player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.GRENADE_40MM.get(), 1, player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
if (stack.getItem() == ModItems.RPG.get() && GunsTool.getGunIntTag(tag, "MaxAmmo") > 0 && GunsTool.getGunIntTag(tag, "Ammo", 0) == 0) {
|
||||
if (stack.getItem() == ModItems.RPG.get() && GunsTool.getGunIntTag(tag, "MaxAmmo") > 0 && GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||
GunsTool.setGunIntTag(tag, "Ammo", 1);
|
||||
player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.ROCKET.get(), 1, player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
if (stack.getItem() == ModItems.JAVELIN.get() && GunsTool.getGunIntTag(tag, "MaxAmmo") > 0 && GunsTool.getGunIntTag(tag, "Ammo", 0) == 0) {
|
||||
if (stack.getItem() == ModItems.JAVELIN.get() && GunsTool.getGunIntTag(tag, "MaxAmmo") > 0 && GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||
GunsTool.setGunIntTag(tag, "Ammo", 1);
|
||||
player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.JAVELIN_MISSILE.get(), 1, player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
} else {
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Magazine", 0)
|
||||
+ GunsTool.getGunIntTag(tag, "CustomMagazine", 0));
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Magazine")
|
||||
+ GunsTool.getGunIntTag(tag, "CustomMagazine"));
|
||||
}
|
||||
GunsTool.setGunBooleanTag(tag, "HoldOpen", false);
|
||||
NBTTool.saveTag(stack, tag);
|
||||
|
@ -354,7 +354,7 @@ public class PlayerEventHandler {
|
|||
ItemStack output = left.copy();
|
||||
|
||||
final var outputTag = NBTTool.getTag(output);
|
||||
GunsTool.setGunDoubleTag(outputTag, "UpgradePoint", GunsTool.getGunDoubleTag(outputTag, "UpgradePoint", 0) + 1);
|
||||
GunsTool.setGunDoubleTag(outputTag, "UpgradePoint", GunsTool.getGunDoubleTag(outputTag, "UpgradePoint") + 1);
|
||||
NBTTool.saveTag(output, outputTag);
|
||||
|
||||
event.setOutput(output);
|
||||
|
|
|
@ -2,24 +2,7 @@ package com.atsuishio.superbwarfare.init;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.item.*;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.*;
|
||||
import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item;
|
||||
import com.atsuishio.superbwarfare.item.gun.launcher.JavelinItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.launcher.M79Item;
|
||||
import com.atsuishio.superbwarfare.item.gun.launcher.RpgItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.launcher.SecondaryCataclysm;
|
||||
import com.atsuishio.superbwarfare.item.gun.machinegun.DevotionItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.machinegun.M60Item;
|
||||
import com.atsuishio.superbwarfare.item.gun.machinegun.MinigunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.machinegun.RpkItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.rifle.*;
|
||||
import com.atsuishio.superbwarfare.item.gun.shotgun.Aa12Item;
|
||||
import com.atsuishio.superbwarfare.item.gun.shotgun.HomemadeShotgunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.shotgun.M870Item;
|
||||
import com.atsuishio.superbwarfare.item.gun.smg.VectorItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.sniper.*;
|
||||
import com.atsuishio.superbwarfare.item.gun.special.BocekItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.special.TaserItem;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -32,6 +15,7 @@ import net.minecraft.world.item.alchemy.Potion;
|
|||
import net.minecraft.world.item.alchemy.PotionContents;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
|
@ -48,43 +32,25 @@ public class ModTabs {
|
|||
() -> CreativeModeTab.builder()
|
||||
.title(Component.translatable("item_group.superbwarfare.guns"))
|
||||
.icon(() -> new ItemStack(ModItems.TASER.get()))
|
||||
.displayItems((param, output) -> {
|
||||
output.accept(TaserItem.getGunInstance());
|
||||
output.accept(Glock17Item.getGunInstance());
|
||||
output.accept(Glock18Item.getGunInstance());
|
||||
output.accept(M1911Item.getGunInstance());
|
||||
output.accept(Mp443Item.getGunInstance());
|
||||
output.accept(HomemadeShotgunItem.getGunInstance());
|
||||
output.accept(Trachelium.getGunInstance());
|
||||
output.accept(VectorItem.getGunInstance());
|
||||
output.accept(SksItem.getGunInstance());
|
||||
output.accept(AK47Item.getGunInstance());
|
||||
output.accept(AK12Item.getGunInstance());
|
||||
output.accept(M4Item.getGunInstance());
|
||||
output.accept(Hk416Item.getGunInstance());
|
||||
output.accept(Qbz95Item.getGunInstance());
|
||||
output.accept(InsidiousItem.getGunInstance());
|
||||
output.accept(Mk14Item.getGunInstance());
|
||||
output.accept(MarlinItem.getGunInstance());
|
||||
output.accept(K98Item.getGunInstance());
|
||||
output.accept(MosinNagantItem.getGunInstance());
|
||||
output.accept(SvdItem.getGunInstance());
|
||||
output.accept(HuntingRifleItem.getGunInstance());
|
||||
output.accept(M98bItem.getGunInstance());
|
||||
output.accept(SentinelItem.getGunInstance());
|
||||
output.accept(Ntw20Item.getGunInstance());
|
||||
output.accept(M870Item.getGunInstance());
|
||||
output.accept(Aa12Item.getGunInstance());
|
||||
output.accept(DevotionItem.getGunInstance());
|
||||
output.accept(RpkItem.getGunInstance());
|
||||
output.accept(M60Item.getGunInstance());
|
||||
output.accept(MinigunItem.getGunInstance());
|
||||
output.accept(BocekItem.getGunInstance());
|
||||
output.accept(M79Item.getGunInstance());
|
||||
output.accept(SecondaryCataclysm.getGunInstance());
|
||||
output.accept(RpgItem.getGunInstance());
|
||||
output.accept(JavelinItem.getGunInstance());
|
||||
})
|
||||
.displayItems((param, output) -> ModItems.GUNS.getEntries().forEach(registryObject -> {
|
||||
// 普通枪械
|
||||
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);
|
||||
|
||||
// 充电后枪械
|
||||
var newStack = stack.copy();
|
||||
var cap = newStack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||
|
||||
if (cap != null) {
|
||||
cap.receiveEnergy(Integer.MAX_VALUE, false);
|
||||
output.accept(newStack);
|
||||
}
|
||||
}))
|
||||
.build());
|
||||
|
||||
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> PERK_TAB = TABS.register("perk",
|
||||
|
|
|
@ -15,7 +15,7 @@ public class GunEvents {
|
|||
if (stack.is(ModTags.Items.GUN)) {
|
||||
final var tag = NBTTool.getTag(stack);
|
||||
tag.putBoolean("draw", true);
|
||||
tag.putBoolean("init", true);
|
||||
tag.putBoolean("init", false);
|
||||
NBTTool.saveTag(stack, tag);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,8 +62,21 @@ public abstract class GunItem extends Item implements CustomRendererItem {
|
|||
) return;
|
||||
|
||||
var tag = NBTTool.getTag(stack);
|
||||
|
||||
if (tag.getString("id").isEmpty()) {
|
||||
var id = stack.getDescriptionId();
|
||||
tag.putString("id", id.substring(id.lastIndexOf(".") + 1));
|
||||
}
|
||||
|
||||
if (!tag.getBoolean("init")) {
|
||||
GunsTool.initGun(level, tag, this.getDescriptionId().substring(this.getDescriptionId().lastIndexOf('.') + 1));
|
||||
var name = this.getDescriptionId().substring(this.getDescriptionId().lastIndexOf('.') + 1);
|
||||
|
||||
if (level.getServer() != null && entity instanceof Player player && player.isCreative()) {
|
||||
GunsTool.initCreativeGun(tag, name);
|
||||
} else {
|
||||
GunsTool.initGun(tag, name);
|
||||
}
|
||||
|
||||
GunsTool.generateAndSetUUID(tag);
|
||||
tag.putBoolean("init", true);
|
||||
}
|
||||
|
@ -73,9 +86,9 @@ public abstract class GunItem extends Item implements CustomRendererItem {
|
|||
handleGunAttachment(tag);
|
||||
|
||||
var hasBulletInBarrel = gunItem.hasBulletInBarrel(stack);
|
||||
var ammoCount = GunsTool.getGunIntTag(tag, "Ammo", 0);
|
||||
var magazine = GunsTool.getGunIntTag(tag, "Magazine", 0);
|
||||
var customMagazine = GunsTool.getGunIntTag(tag, "CustomMagazine", 0);
|
||||
var ammoCount = GunsTool.getGunIntTag(tag, "Ammo");
|
||||
var magazine = GunsTool.getGunIntTag(tag, "Magazine");
|
||||
var customMagazine = GunsTool.getGunIntTag(tag, "CustomMagazine");
|
||||
|
||||
if ((hasBulletInBarrel && ammoCount > magazine + customMagazine + 1)
|
||||
|| (!hasBulletInBarrel && ammoCount > magazine + customMagazine)
|
||||
|
@ -184,8 +197,8 @@ public abstract class GunItem extends Item implements CustomRendererItem {
|
|||
GunsTool.setPerkIntTag(tag, "FourthTimesCharmTick", 0);
|
||||
GunsTool.setPerkIntTag(tag, "FourthTimesCharmCount", 0);
|
||||
|
||||
int mag = GunsTool.getGunIntTag(tag, "Magazine", 0) + GunsTool.getGunIntTag(tag, "CustomMagazine", 0);
|
||||
GunsTool.setGunIntTag(tag, "Ammo", Math.min(mag, GunsTool.getGunIntTag(tag, "Ammo", 0) + 2));
|
||||
int mag = GunsTool.getGunIntTag(tag, "Magazine") + GunsTool.getGunIntTag(tag, "CustomMagazine");
|
||||
GunsTool.setGunIntTag(tag, "Ammo", Math.min(mag, GunsTool.getGunIntTag(tag, "Ammo") + 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,11 @@ package com.atsuishio.superbwarfare.item.gun.handgun;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.Glock17ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -101,12 +99,6 @@ public class Glock17Item extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.GLOCK_17_RELOAD_EMPTY.get(), ModSounds.GLOCK_17_RELOAD_NORMAL.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.GLOCK_17.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.GLOCK_17.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/glock_icon.png");
|
||||
|
|
|
@ -3,14 +3,12 @@ package com.atsuishio.superbwarfare.item.gun.handgun;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.Glock18ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -104,12 +102,6 @@ public class Glock18Item extends GunItem implements GeoItem {
|
|||
);
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.GLOCK_18.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.GLOCK_18.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/glock_icon.png");
|
||||
|
|
|
@ -3,13 +3,11 @@ package com.atsuishio.superbwarfare.item.gun.handgun;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.M1911ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -104,12 +102,6 @@ public class M1911Item extends GunItem implements GeoItem {
|
|||
);
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.M_1911.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.M_1911.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/m1911_icon.png");
|
||||
|
|
|
@ -3,13 +3,11 @@ package com.atsuishio.superbwarfare.item.gun.handgun;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.Mp443ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -101,12 +99,6 @@ public class Mp443Item extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.MP_443_RELOAD_EMPTY.get(), ModSounds.MP_443_RELOAD_NORMAL.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.MP_443.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.MP_443.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/mp443_icon.png");
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
|||
import com.atsuishio.superbwarfare.client.TooltipTool;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.TracheliumItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -235,12 +234,6 @@ public class Trachelium extends GunItem implements GeoItem {
|
|||
}
|
||||
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.TRACHELIUM.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.TRACHELIUM.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.Ntw20Renderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModRarity;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
|
@ -144,7 +143,7 @@ public class Ntw20Item extends GunItem implements GeoItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 2.25;
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom", 0);
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom");
|
||||
};
|
||||
|
||||
tag.putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
@ -153,12 +152,6 @@ public class Ntw20Item extends GunItem implements GeoItem {
|
|||
NBTTool.saveTag(stack, tag);
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.NTW_20.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.NTW_20.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/ntw_20_icon.png");
|
||||
|
|
|
@ -206,12 +206,6 @@ public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
return stack.getItem() == ModItems.JAVELIN_MISSILE.get();
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.JAVELIN.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.JAVELIN.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/javelin_icon.png");
|
||||
|
@ -253,9 +247,9 @@ public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
|
||||
if (player.level() instanceof ServerLevel serverLevel) {
|
||||
JavelinMissileEntity missileEntity = new JavelinMissileEntity(player, level,
|
||||
(float) GunsTool.getGunDoubleTag(tag, "Damage", 0),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionDamage", 0),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius", 0),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "Damage"),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionDamage"),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius"),
|
||||
tag.getInt("GuideType"),
|
||||
new Vec3(tag.getDouble("TargetPosX"), tag.getDouble("TargetPosY"), tag.getDouble("TargetPosZ")));
|
||||
|
||||
|
@ -286,7 +280,7 @@ public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
}
|
||||
|
||||
player.getCooldowns().addCooldown(stack.getItem(), 10);
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo", 0) - 1);
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo") - 1);
|
||||
NBTTool.saveTag(stack, tag);
|
||||
}
|
||||
|
||||
|
@ -305,7 +299,7 @@ public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
@Override
|
||||
public void fireOnPress(Player player, final CompoundTag tag) {
|
||||
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
||||
if (cap != null && !cap.zoom || GunsTool.getGunIntTag(tag, "Ammo", 0) <= 0) return;
|
||||
if (cap != null && !cap.zoom || GunsTool.getGunIntTag(tag, "Ammo") <= 0) return;
|
||||
|
||||
Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 512, 8);
|
||||
|
||||
|
|
|
@ -139,12 +139,6 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
return stack.getItem() == ModItems.GRENADE_40MM.get();
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.M_79.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.M_79.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/m79_icon.png");
|
||||
|
@ -175,7 +169,7 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
if (GunsTool.getGunBooleanTag(tag, "Reloading")) return;
|
||||
if (player.getCooldowns().isOnCooldown(stack.getItem()) || GunsTool.getGunIntTag(tag, "Ammo", 0) <= 0) return;
|
||||
if (player.getCooldowns().isOnCooldown(stack.getItem()) || GunsTool.getGunIntTag(tag, "Ammo") <= 0) return;
|
||||
|
||||
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
||||
boolean zooming = cap != null && cap.zoom;
|
||||
|
@ -183,9 +177,9 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
|
||||
if (player.level() instanceof ServerLevel serverLevel) {
|
||||
GunGrenadeEntity gunGrenadeEntity = new GunGrenadeEntity(player, serverLevel,
|
||||
(float) GunsTool.getGunDoubleTag(tag, "Damage", 0),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionDamage", 0),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius", 0));
|
||||
(float) GunsTool.getGunDoubleTag(tag, "Damage"),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionDamage"),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius"));
|
||||
|
||||
var dmgPerk = PerkHelper.getPerkByType(tag, Perk.Type.DAMAGE);
|
||||
if (dmgPerk == ModPerks.MONSTER_HUNTER.get()) {
|
||||
|
@ -195,11 +189,11 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
|
||||
gunGrenadeEntity.setNoGravity(PerkHelper.getPerkByType(tag, Perk.Type.AMMO) == ModPerks.MICRO_MISSILE.get());
|
||||
|
||||
float velocity = (float) GunsTool.getGunDoubleTag(tag, "Velocity", 0);
|
||||
float velocity = (float) GunsTool.getGunDoubleTag(tag, "Velocity");
|
||||
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.MICRO_MISSILE.get(), tag);
|
||||
if (perkLevel > 0) {
|
||||
gunGrenadeEntity.setExplosionRadius((float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius", 0) * 0.5f);
|
||||
gunGrenadeEntity.setDamage((float) GunsTool.getGunDoubleTag(tag, "Damage", 0) * (1.1f + perkLevel * 0.1f));
|
||||
gunGrenadeEntity.setExplosionRadius((float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius") * 0.5f);
|
||||
gunGrenadeEntity.setDamage((float) GunsTool.getGunDoubleTag(tag, "Damage") * (1.1f + perkLevel * 0.1f));
|
||||
velocity *= 1.2f;
|
||||
}
|
||||
|
||||
|
@ -224,6 +218,6 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
}
|
||||
|
||||
player.getCooldowns().addCooldown(stack.getItem(), 2);
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo", 0) - 1);
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo") - 1);
|
||||
}
|
||||
}
|
|
@ -132,7 +132,7 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
if (tag.getBoolean("draw")) {
|
||||
tag.putBoolean("draw", false);
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) == 0) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||
tag.putDouble("empty", 1);
|
||||
}
|
||||
}
|
||||
|
@ -149,12 +149,6 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
return stack.getItem() == ModItems.ROCKET.get();
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.RPG.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.RPG.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/rpg_icon.png");
|
||||
|
@ -187,7 +181,7 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
|
||||
if (GunsTool.getGunBooleanTag(tag, "Reloading")
|
||||
|| player.getCooldowns().isOnCooldown(stack.getItem())
|
||||
|| GunsTool.getGunIntTag(tag, "Ammo", 0) <= 0
|
||||
|| GunsTool.getGunIntTag(tag, "Ammo") <= 0
|
||||
) return;
|
||||
|
||||
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
||||
|
@ -196,9 +190,9 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
|
||||
if (player.level() instanceof ServerLevel serverLevel) {
|
||||
RpgRocketEntity rocket = new RpgRocketEntity(player, level,
|
||||
(float) GunsTool.getGunDoubleTag(tag, "Damage", 0),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionDamage", 0),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius", 0));
|
||||
(float) GunsTool.getGunDoubleTag(tag, "Damage"),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionDamage"),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius"));
|
||||
|
||||
var dmgPerk = PerkHelper.getPerkByType(tag, Perk.Type.DAMAGE);
|
||||
if (dmgPerk == ModPerks.MONSTER_HUNTER.get()) {
|
||||
|
@ -206,7 +200,7 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
rocket.setMonsterMultiplier(0.1f + 0.1f * perkLevel);
|
||||
}
|
||||
|
||||
float velocity = (float) GunsTool.getGunDoubleTag(tag, "Velocity", 0);
|
||||
float velocity = (float) GunsTool.getGunDoubleTag(tag, "Velocity");
|
||||
|
||||
if (PerkHelper.getPerkByType(tag, Perk.Type.AMMO) == ModPerks.MICRO_MISSILE.get()) {
|
||||
rocket.setNoGravity(true);
|
||||
|
@ -214,7 +208,7 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.MICRO_MISSILE.get(), tag);
|
||||
if (perkLevel > 0) {
|
||||
rocket.setExplosionRadius(0.5f);
|
||||
rocket.setDamage((float) GunsTool.getGunDoubleTag(tag, "Damage", 0) * (1.1f + perkLevel * 0.1f));
|
||||
rocket.setDamage((float) GunsTool.getGunDoubleTag(tag, "Damage") * (1.1f + perkLevel * 0.1f));
|
||||
velocity *= 1.2f;
|
||||
}
|
||||
}
|
||||
|
@ -239,12 +233,12 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
PacketDistributor.sendToPlayer(serverPlayer, new ShootClientMessage(10));
|
||||
}
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) == 1) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") == 1) {
|
||||
tag.putBoolean("empty", true);
|
||||
GunsTool.setGunBooleanTag(tag, "CloseHammer", true);
|
||||
}
|
||||
|
||||
player.getCooldowns().addCooldown(stack.getItem(), 10);
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo", 0) - 1);
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo") - 1);
|
||||
}
|
||||
}
|
|
@ -206,12 +206,6 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
|
|||
return stack.getItem() == ModItems.GRENADE_40MM.get();
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.SECONDARY_CATACLYSM.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.SECONDARY_CATACLYSM.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/secondary_cataclysm_icon.png");
|
||||
|
@ -264,7 +258,7 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
|
|||
public void fireOnPress(Player player, final CompoundTag tag) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (GunsTool.getGunBooleanTag(tag, "Reloading")) return;
|
||||
if (player.getCooldowns().isOnCooldown(stack.getItem()) || GunsTool.getGunIntTag(tag, "Ammo", 0) <= 0) return;
|
||||
if (player.getCooldowns().isOnCooldown(stack.getItem()) || GunsTool.getGunIntTag(tag, "Ammo") <= 0) return;
|
||||
|
||||
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
||||
boolean zooming = cap != null && cap.zoom;
|
||||
|
@ -277,9 +271,9 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
|
|||
|
||||
if (player.level() instanceof ServerLevel serverLevel) {
|
||||
GunGrenadeEntity gunGrenadeEntity = new GunGrenadeEntity(player, serverLevel,
|
||||
(float) GunsTool.getGunDoubleTag(tag, "Damage", 0),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionDamage", 0),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius", 0));
|
||||
(float) GunsTool.getGunDoubleTag(tag, "Damage"),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionDamage"),
|
||||
(float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius"));
|
||||
|
||||
var dmgPerk = PerkHelper.getPerkByType(tag, Perk.Type.DAMAGE);
|
||||
if (dmgPerk == ModPerks.MONSTER_HUNTER.get()) {
|
||||
|
@ -290,11 +284,11 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
|
|||
gunGrenadeEntity.setNoGravity(PerkHelper.getPerkByType(tag, Perk.Type.AMMO) == ModPerks.MICRO_MISSILE.get());
|
||||
gunGrenadeEntity.charged(isChargedFire);
|
||||
|
||||
float velocity = (float) GunsTool.getGunDoubleTag(tag, "Velocity", 0);
|
||||
float velocity = (float) GunsTool.getGunDoubleTag(tag, "Velocity");
|
||||
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.MICRO_MISSILE.get(), tag);
|
||||
if (perkLevel > 0) {
|
||||
gunGrenadeEntity.setExplosionRadius((float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius", 0) * 0.5f);
|
||||
gunGrenadeEntity.setDamage((float) GunsTool.getGunDoubleTag(tag, "Damage", 0) * (1.1f + perkLevel * 0.1f));
|
||||
gunGrenadeEntity.setExplosionRadius((float) GunsTool.getGunDoubleTag(tag, "ExplosionRadius") * 0.5f);
|
||||
gunGrenadeEntity.setDamage((float) GunsTool.getGunDoubleTag(tag, "Damage") * (1.1f + perkLevel * 0.1f));
|
||||
velocity *= 1.2f;
|
||||
}
|
||||
|
||||
|
@ -331,7 +325,7 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
|
|||
PacketDistributor.sendToPlayer(serverPlayer, new ShootClientMessage(10));
|
||||
}
|
||||
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo", 0) - 1);
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo") - 1);
|
||||
player.getCooldowns().addCooldown(stack.getItem(), 6);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,14 +3,12 @@ package com.atsuishio.superbwarfare.item.gun.machinegun;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.DevotionItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -87,12 +85,6 @@ public class DevotionItem extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.DEVOTION_RELOAD_EMPTY.get(), ModSounds.DEVOTION_RELOAD_NORMAL.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.DEVOTION.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.DEVOTION.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/devotion_icon.png");
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.atsuishio.superbwarfare.item.gun.machinegun;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.M60ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
|
@ -105,12 +104,6 @@ public class M60Item extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.M_60_RELOAD_EMPTY.get(), ModSounds.M_60_RELOAD_NORMAL.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.M_60.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.M_60.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, boolean selected) {
|
||||
|
@ -118,7 +111,7 @@ public class M60Item extends GunItem implements GeoItem {
|
|||
if (tag.getBoolean("draw")) {
|
||||
tag.putBoolean("draw", false);
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) <= 5) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") <= 5) {
|
||||
GunsTool.setGunBooleanTag(tag, "HideBulletChain", true);
|
||||
}
|
||||
NBTTool.saveTag(stack, tag);
|
||||
|
|
|
@ -3,10 +3,12 @@ package com.atsuishio.superbwarfare.item.gun.machinegun;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.MinigunItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.*;
|
||||
import com.atsuishio.superbwarfare.init.ModParticleTypes;
|
||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModRarity;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -145,12 +147,6 @@ public class MinigunItem extends GunItem implements GeoItem {
|
|||
NBTTool.saveTag(stack, tag);
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.MINIGUN.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.MINIGUN.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/minigun_icon.png");
|
||||
|
|
|
@ -3,14 +3,12 @@ package com.atsuishio.superbwarfare.item.gun.machinegun;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.RpkItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -87,12 +85,6 @@ public class RpkItem extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.RPK_RELOAD_EMPTY.get(), ModSounds.RPK_RELOAD_NORMAL.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.RPK.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.RPK.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/rpk_icon.png");
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.AK12ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -134,12 +133,6 @@ public class AK12Item extends GunItem implements GeoItem {
|
|||
return this.cache;
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.AK_12.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.AK_12.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||
|
@ -160,7 +153,7 @@ public class AK12Item extends GunItem implements GeoItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 2.15;
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom", 0);
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom");
|
||||
};
|
||||
|
||||
tag.putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.AK47ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -142,12 +141,6 @@ public class AK47Item extends GunItem implements GeoItem {
|
|||
return this.cache;
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.AK_47.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.AK_47.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||
|
@ -168,7 +161,7 @@ public class AK47Item extends GunItem implements GeoItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 2.75;
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom", 0);
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom");
|
||||
};
|
||||
|
||||
tag.putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.Hk416ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -150,7 +149,7 @@ public class Hk416Item extends GunItem implements GeoItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 2.25;
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom", 0);
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom");
|
||||
};
|
||||
|
||||
tag.putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
@ -169,12 +168,6 @@ public class Hk416Item extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.HK_416_RELOAD_EMPTY.get(), ModSounds.HK_416_RELOAD_NORMAL.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.HK_416.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.HK_416.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/hk416_icon.png");
|
||||
|
|
|
@ -3,13 +3,11 @@ package com.atsuishio.superbwarfare.item.gun.rifle;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.InsidiousItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -78,12 +76,6 @@ public class InsidiousItem extends GunItem implements GeoItem {
|
|||
return this.cache;
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.INSIDIOUS.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.INSIDIOUS.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SoundEvent> getReloadSound() {
|
||||
return Set.of(ModSounds.VECTOR_RELOAD_NORMAL.get(), ModSounds.VECTOR_RELOAD_EMPTY.get());
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.M4ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -142,12 +141,6 @@ public class M4Item extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.M_4_RELOAD_EMPTY.get(), ModSounds.M_4_RELOAD_NORMAL.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.M_4.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.M_4.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||
|
@ -168,7 +161,7 @@ public class M4Item extends GunItem implements GeoItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> NBTTool.getTag(stack).getBoolean("ScopeAlt") ? 0 : 2.75;
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom", 0);
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom");
|
||||
};
|
||||
|
||||
GunsTool.setGunBooleanTag(tag, "CanSwitchScope", scopeType == 2);
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.atsuishio.superbwarfare.item.gun.rifle;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.MarlinItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -122,12 +121,6 @@ public class MarlinItem extends GunItem implements GeoItem {
|
|||
ModSounds.MARLIN_BOLT.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.MARLIN.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.MARLIN.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/marlin_icon.png");
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.Mk14ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -155,7 +154,7 @@ public class Mk14Item extends GunItem implements GeoItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 2.25;
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom", 0);
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom");
|
||||
};
|
||||
|
||||
tag.putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
@ -169,12 +168,6 @@ public class Mk14Item extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.MK_14_RELOAD_EMPTY.get(), ModSounds.MK_14_RELOAD_NORMAL.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.MK_14.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.MK_14.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/mk14ebr_icon.png");
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.Qbz95ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -157,7 +156,7 @@ public class Qbz95Item extends GunItem implements GeoItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 2.15;
|
||||
default -> GunsTool.getGunDoubleTag(rootTag, "CustomZoom", 0);
|
||||
default -> GunsTool.getGunDoubleTag(rootTag, "CustomZoom");
|
||||
};
|
||||
|
||||
rootTag.putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
@ -171,12 +170,6 @@ public class Qbz95Item extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.QBZ_95_RELOAD_EMPTY.get(), ModSounds.QBZ_95_RELOAD_NORMAL.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.QBZ_95.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.QBZ_95.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/qbz95_icon.png");
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.atsuishio.superbwarfare.item.gun.rifle;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.SksItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -89,12 +88,6 @@ public class SksItem extends GunItem implements GeoItem {
|
|||
return this.cache;
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.SKS.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.SKS.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, boolean selected) {
|
||||
|
@ -102,7 +95,7 @@ public class SksItem extends GunItem implements GeoItem {
|
|||
final var tag = NBTTool.getTag(stack);
|
||||
tag.putBoolean("draw", false);
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) == 0) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||
GunsTool.setGunBooleanTag(tag, "HoldOpen", true);
|
||||
}
|
||||
NBTTool.saveTag(stack, tag);
|
||||
|
|
|
@ -4,11 +4,13 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.client.renderer.item.Aa12ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.client.tooltip.component.ShotgunImageComponent;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.*;
|
||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModRarity;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -109,12 +111,6 @@ public class Aa12Item extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.AA_12_RELOAD_EMPTY.get(), ModSounds.AA_12_RELOAD_NORMAL.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.AA_12.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.AA_12.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/aa_12_icon.png");
|
||||
|
|
|
@ -4,13 +4,11 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.client.renderer.item.HomemadeShotgunItemRenderer;
|
||||
import com.atsuishio.superbwarfare.client.tooltip.component.ShotgunImageComponent;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -90,12 +88,6 @@ public class HomemadeShotgunItem extends GunItem implements GeoItem {
|
|||
return this.cache;
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.HOMEMADE_SHOTGUN.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.HOMEMADE_SHOTGUN.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/homemade_shotgun_icon.png");
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.client.renderer.item.M870ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.client.tooltip.component.ShotgunImageComponent;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -126,12 +125,6 @@ public class M870Item extends GunItem implements GeoItem {
|
|||
ModSounds.M_870_BOLT.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.M_870.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.M_870.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/m870_icon.png");
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.VectorItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -137,7 +136,7 @@ public class VectorItem extends GunItem implements GeoItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 0.75;
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom", 0);
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom");
|
||||
};
|
||||
|
||||
GunsTool.setGunDoubleTag(tag, "CustomZoom", customZoom);
|
||||
|
@ -145,12 +144,6 @@ public class VectorItem extends GunItem implements GeoItem {
|
|||
NBTTool.saveTag(stack, tag);
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.VECTOR.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.VECTOR.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SoundEvent> getReloadSound() {
|
||||
return Set.of(ModSounds.VECTOR_RELOAD_NORMAL.get(), ModSounds.VECTOR_RELOAD_EMPTY.get());
|
||||
|
|
|
@ -3,13 +3,11 @@ package com.atsuishio.superbwarfare.item.gun.sniper;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.HuntingRifleItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -81,12 +79,6 @@ public class HuntingRifleItem extends GunItem implements GeoItem {
|
|||
return this.cache;
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.HUNTING_RIFLE.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.HUNTING_RIFLE.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/hunting_rifle_icon.png");
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.atsuishio.superbwarfare.item.gun.sniper;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.K98ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -128,12 +127,6 @@ public class K98Item extends GunItem implements GeoItem {
|
|||
);
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.K_98.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.K_98.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/k98_icon.png");
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.atsuishio.superbwarfare.item.gun.sniper;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.M98bItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -105,12 +104,6 @@ public class M98bItem extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.M_98B_RELOAD_EMPTY.get(), ModSounds.M_98B_RELOAD_NORMAL.get(), ModSounds.M_98B_BOLT.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.M_98B.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.M_98B.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/m98b_icon.png");
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.atsuishio.superbwarfare.item.gun.sniper;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.MosinNagantItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -56,11 +55,11 @@ public class MosinNagantItem extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.shift"));
|
||||
}
|
||||
|
||||
if (NBTTool.getTag(stack).getInt("reload_stage") == 1 && GunsTool.getGunIntTag(tag, "Ammo", 0) == 0) {
|
||||
if (NBTTool.getTag(stack).getInt("reload_stage") == 1 && GunsTool.getGunIntTag(tag, "Ammo") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare_empty"));
|
||||
}
|
||||
|
||||
if (NBTTool.getTag(stack).getInt("reload_stage") == 1 && GunsTool.getGunIntTag(tag, "Ammo", 0) > 0) {
|
||||
if (NBTTool.getTag(stack).getInt("reload_stage") == 1 && GunsTool.getGunIntTag(tag, "Ammo") > 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare"));
|
||||
}
|
||||
|
||||
|
@ -128,12 +127,6 @@ public class MosinNagantItem extends GunItem implements GeoItem {
|
|||
);
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.MOSIN_NAGANT.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.MOSIN_NAGANT.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/mosin_nagant_icon.png");
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.client.renderer.item.SentinelItemRenderer;
|
||||
import com.atsuishio.superbwarfare.client.tooltip.component.SentinelImageComponent;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModRarity;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
|
@ -142,7 +141,7 @@ public class SentinelItem extends GunItem implements GeoItem, EnergyStorageItem
|
|||
if (cap != null && cap.getEnergyStored() > 0) {
|
||||
cap.extractEnergy(1, false);
|
||||
GunsTool.setGunDoubleTag(tag, "ChargedDamage", 0.2857142857142857
|
||||
* GunsTool.getGunDoubleTag(tag, "Damage", 0));
|
||||
* GunsTool.getGunDoubleTag(tag, "Damage"));
|
||||
} else {
|
||||
GunsTool.setGunDoubleTag(tag, "ChargedDamage", 0);
|
||||
}
|
||||
|
@ -159,12 +158,6 @@ public class SentinelItem extends GunItem implements GeoItem, EnergyStorageItem
|
|||
);
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.SENTINEL.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.SENTINEL.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/sentinel_icon.png");
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.SvdItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
@ -107,12 +106,6 @@ public class SvdItem extends GunItem implements GeoItem {
|
|||
return Set.of(ModSounds.SVD_RELOAD_EMPTY.get(), ModSounds.SVD_RELOAD_NORMAL.get());
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.SVD.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.SVD.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||
|
@ -131,7 +124,7 @@ public class SvdItem extends GunItem implements GeoItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 3.75;
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom", 0);
|
||||
default -> GunsTool.getGunDoubleTag(tag, "CustomZoom");
|
||||
};
|
||||
|
||||
tag.putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
|
|
@ -134,12 +134,6 @@ public class BocekItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
return stack.getItem() == Items.ARROW;
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.BOCEK.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.BOCEK.getId().getPath());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/bocek_icon.png");
|
||||
|
|
|
@ -193,16 +193,6 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En
|
|||
return stack.getItem() == ModItems.TASER_ELECTRODE.get();
|
||||
}
|
||||
|
||||
public static ItemStack getGunInstance() {
|
||||
ItemStack stack = new ItemStack(ModItems.TASER.get());
|
||||
GunsTool.initCreativeGun(stack, ModItems.TASER.getId().getPath());
|
||||
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||
if (cap != null) {
|
||||
cap.receiveEnergy(MAX_ENERGY, false);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getGunIcon() {
|
||||
return Mod.loc("textures/gun_icon/taser_icon.png");
|
||||
|
@ -243,7 +233,7 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En
|
|||
var hasEnoughEnergy = energyStorage != null && energyStorage.getEnergyStored() >= 400 + 100 * perkLevel;
|
||||
|
||||
if (player.getCooldowns().isOnCooldown(stack.getItem())
|
||||
|| GunsTool.getGunIntTag(tag, "Ammo", 0) <= 0
|
||||
|| GunsTool.getGunIntTag(tag, "Ammo") <= 0
|
||||
|| !hasEnoughEnergy
|
||||
) return;
|
||||
|
||||
|
@ -263,17 +253,17 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En
|
|||
var level = serverPlayer.level();
|
||||
|
||||
TaserBulletEntity taserBulletProjectile = new TaserBulletEntity(player, level,
|
||||
(float) GunsTool.getGunDoubleTag(tag, "Damage", 0), volt, wireLength);
|
||||
(float) GunsTool.getGunDoubleTag(tag, "Damage"), volt, wireLength);
|
||||
|
||||
taserBulletProjectile.setPos(player.getX(), player.getEyeY() - 0.1, player.getZ());
|
||||
taserBulletProjectile.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, (float) GunsTool.getGunDoubleTag(tag, "Velocity", 0),
|
||||
taserBulletProjectile.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, (float) GunsTool.getGunDoubleTag(tag, "Velocity"),
|
||||
(float) (zoom ? 0.1 : spread));
|
||||
level.addFreshEntity(taserBulletProjectile);
|
||||
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShootClientMessage(10));
|
||||
}
|
||||
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo", 0) - 1);
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo") - 1);
|
||||
energyStorage.extractEnergy(400 + 100 * perkLevel, false);
|
||||
tag.putBoolean("shoot", true);
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class ReforgingTableMenu extends AbstractContainerMenu {
|
|||
if (!this.moveItemStackTo(stack, INPUT_SLOT, INPUT_SLOT + 1, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (stack.getItem() instanceof PerkItem perkItem) {
|
||||
} else if (stack.getItem() instanceof PerkItem<?> perkItem) {
|
||||
Perk.Type type = perkItem.getPerk().type;
|
||||
if (type == Perk.Type.AMMO) {
|
||||
if (!this.moveItemStackTo(stack, AMMO_PERK_SLOT, AMMO_PERK_SLOT + 1, false)) {
|
||||
|
@ -209,7 +209,7 @@ public class ReforgingTableMenu extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
final var tag = NBTTool.getTag(stack);
|
||||
double oldPoint = GunsTool.getGunDoubleTag(tag, "UpgradePoint", 0);
|
||||
double oldPoint = GunsTool.getGunDoubleTag(tag, "UpgradePoint");
|
||||
int point = (int) oldPoint;
|
||||
int newPoint = this.upgradePoint.get();
|
||||
int delta = newPoint - point;
|
||||
|
@ -295,15 +295,15 @@ public class ReforgingTableMenu extends AbstractContainerMenu {
|
|||
int level = PerkHelper.getItemPerkLevel(perkItem.getPerk(), tag);
|
||||
|
||||
if (level <= 0) {
|
||||
this.upgradePoint.set((int) GunsTool.getGunDoubleTag(tag, "UpgradePoint", 0));
|
||||
this.upgradePoint.set((int) GunsTool.getGunDoubleTag(tag, "UpgradePoint"));
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack output = gun.copy();
|
||||
final var outputTag = NBTTool.getTag(output);
|
||||
PerkHelper.removePerkByType(outputTag, perkItem.getPerk().type);
|
||||
GunsTool.setGunDoubleTag(outputTag, "UpgradePoint", Math.min(MAX_UPGRADE_POINT, level - 1 + GunsTool.getGunDoubleTag(outputTag, "UpgradePoint", 0)));
|
||||
this.upgradePoint.set((int) GunsTool.getGunDoubleTag(outputTag, "UpgradePoint", 0));
|
||||
GunsTool.setGunDoubleTag(outputTag, "UpgradePoint", Math.min(MAX_UPGRADE_POINT, level - 1 + GunsTool.getGunDoubleTag(outputTag, "UpgradePoint")));
|
||||
this.upgradePoint.set((int) GunsTool.getGunDoubleTag(outputTag, "UpgradePoint"));
|
||||
|
||||
NBTTool.saveTag(output, outputTag);
|
||||
this.container.setItem(INPUT_SLOT, output);
|
||||
|
@ -338,7 +338,7 @@ public class ReforgingTableMenu extends AbstractContainerMenu {
|
|||
return;
|
||||
}
|
||||
final var tag = NBTTool.getTag(stack);
|
||||
int point = (int) GunsTool.getGunDoubleTag(tag, "UpgradePoint", 0);
|
||||
int point = (int) GunsTool.getGunDoubleTag(tag, "UpgradePoint");
|
||||
this.upgradePoint.set(Mth.clamp(point, 0, MAX_UPGRADE_POINT));
|
||||
|
||||
var ammoPerk = PerkHelper.getPerkByType(tag, Perk.Type.AMMO);
|
||||
|
|
|
@ -39,30 +39,30 @@ public record AdjustZoomFovMessage(double scroll) implements CustomPacketPayload
|
|||
double minRpm = 300;
|
||||
double maxRpm = 2400;
|
||||
|
||||
GunsTool.setGunIntTag(tag, "RPM", (int) Mth.clamp(GunsTool.getGunIntTag(tag, "RPM", 0) + 50 * message.scroll, minRpm, maxRpm));
|
||||
if (GunsTool.getGunIntTag(tag, "RPM", 0) == 1150) {
|
||||
GunsTool.setGunIntTag(tag, "RPM", (int) Mth.clamp(GunsTool.getGunIntTag(tag, "RPM") + 50 * message.scroll, minRpm, maxRpm));
|
||||
if (GunsTool.getGunIntTag(tag, "RPM") == 1150) {
|
||||
GunsTool.setGunIntTag(tag, "RPM", 1145);
|
||||
}
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "RPM", 0) == 1195) {
|
||||
if (GunsTool.getGunIntTag(tag, "RPM") == 1195) {
|
||||
GunsTool.setGunIntTag(tag, "RPM", 1200);
|
||||
}
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "RPM", 0) == 1095) {
|
||||
if (GunsTool.getGunIntTag(tag, "RPM") == 1095) {
|
||||
GunsTool.setGunIntTag(tag, "RPM", 1100);
|
||||
}
|
||||
player.displayClientMessage(Component.literal("RPM: " + FormatTool.format0D(GunsTool.getGunIntTag(tag, "RPM", 0))), true);
|
||||
int rpm = GunsTool.getGunIntTag(tag, "RPM", 0);
|
||||
player.displayClientMessage(Component.literal("RPM: " + FormatTool.format0D(GunsTool.getGunIntTag(tag, "RPM"))), true);
|
||||
int rpm = GunsTool.getGunIntTag(tag, "RPM");
|
||||
if (rpm > minRpm && rpm < maxRpm) {
|
||||
SoundTool.playLocalSound(player, ModSounds.ADJUST_FOV.get(), 1f, 0.7f);
|
||||
}
|
||||
} else {
|
||||
double minZoom = GunsTool.getGunDoubleTag(tag, "MinZoom", 0) - 1.25;
|
||||
double maxZoom = GunsTool.getGunDoubleTag(tag, "MaxZoom", 0) - 1.25;
|
||||
double customZoom = GunsTool.getGunDoubleTag(tag, "CustomZoom", 0);
|
||||
double minZoom = GunsTool.getGunDoubleTag(tag, "MinZoom") - 1.25;
|
||||
double maxZoom = GunsTool.getGunDoubleTag(tag, "MaxZoom") - 1.25;
|
||||
double customZoom = GunsTool.getGunDoubleTag(tag, "CustomZoom");
|
||||
GunsTool.setGunDoubleTag(tag, "CustomZoom", Mth.clamp(customZoom + 0.5 * message.scroll, minZoom, maxZoom));
|
||||
if (GunsTool.getGunDoubleTag(tag, "CustomZoom", 0) > minZoom &&
|
||||
GunsTool.getGunDoubleTag(tag, "CustomZoom", 0) < maxZoom) {
|
||||
if (GunsTool.getGunDoubleTag(tag, "CustomZoom") > minZoom &&
|
||||
GunsTool.getGunDoubleTag(tag, "CustomZoom") < maxZoom) {
|
||||
SoundTool.playLocalSound(player, ModSounds.ADJUST_FOV.get(), 1f, 0.7f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public record FireMessage(int msgType) implements CustomPacketPayload {
|
|||
|
||||
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
||||
if (type == 0) {
|
||||
if (tag.getDouble("prepare") == 0 && GunsTool.getGunBooleanTag(tag, "Reloading") && GunsTool.getGunIntTag(tag, "Ammo", 0) > 0) {
|
||||
if (tag.getDouble("prepare") == 0 && GunsTool.getGunBooleanTag(tag, "Reloading") && GunsTool.getGunIntTag(tag, "Ammo") > 0) {
|
||||
tag.putDouble("force_stop", 1);
|
||||
NBTTool.saveTag(stack, tag);
|
||||
}
|
||||
|
@ -90,15 +90,15 @@ public record FireMessage(int msgType) implements CustomPacketPayload {
|
|||
private static void handleGunBolt(Player player, ItemStack stack, final CompoundTag tag) {
|
||||
if (!stack.is(ModTags.Items.GUN)) return;
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "BoltActionTime", 0) > 0
|
||||
&& GunsTool.getGunIntTag(tag, "Ammo", 0) > (stack.is(ModTags.Items.REVOLVER) ? -1 : 0)
|
||||
if (GunsTool.getGunIntTag(tag, "BoltActionTime") > 0
|
||||
&& GunsTool.getGunIntTag(tag, "Ammo") > (stack.is(ModTags.Items.REVOLVER) ? -1 : 0)
|
||||
&& GunsTool.getGunIntTag(tag, "BoltActionTick") == 0
|
||||
&& !(tag.getBoolean("is_normal_reloading")
|
||||
|| tag.getBoolean("is_empty_reloading"))
|
||||
&& !GunsTool.getGunBooleanTag(tag, "Reloading")
|
||||
&& !GunsTool.getGunBooleanTag(tag, "Charging")) {
|
||||
if (!player.getCooldowns().isOnCooldown(stack.getItem()) && GunsTool.getGunBooleanTag(tag, "NeedBoltAction", false)) {
|
||||
GunsTool.setGunIntTag(tag, "BoltActionTick", GunsTool.getGunIntTag(tag, "BoltActionTime", 0) + 1);
|
||||
if (!player.getCooldowns().isOnCooldown(stack.getItem()) && GunsTool.getGunBooleanTag(tag, "NeedBoltAction")) {
|
||||
GunsTool.setGunIntTag(tag, "BoltActionTick", GunsTool.getGunIntTag(tag, "BoltActionTime") + 1);
|
||||
GunEventHandler.playGunBoltSounds(player);
|
||||
}
|
||||
}
|
||||
|
@ -126,9 +126,9 @@ public record FireMessage(int msgType) implements CustomPacketPayload {
|
|||
if (player.level().isClientSide()) return;
|
||||
|
||||
var perk = PerkHelper.getPerkByType(tag, Perk.Type.AMMO);
|
||||
float headshot = (float) GunsTool.getGunDoubleTag(tag, "Headshot", 0);
|
||||
float headshot = (float) GunsTool.getGunDoubleTag(tag, "Headshot");
|
||||
float velocity = 2 * (float) GunsTool.getGunDoubleTag(tag, "Power", 6) * (float) perkSpeed(tag);
|
||||
float bypassArmorRate = (float) GunsTool.getGunDoubleTag(tag, "BypassesArmor", 0);
|
||||
float bypassArmorRate = (float) GunsTool.getGunDoubleTag(tag, "BypassesArmor");
|
||||
double damage;
|
||||
|
||||
var cap = player.getCapability(ModCapabilities.PLAYER_VARIABLE);
|
||||
|
@ -137,12 +137,12 @@ public record FireMessage(int msgType) implements CustomPacketPayload {
|
|||
float spread;
|
||||
if (zoom) {
|
||||
spread = 0.01f;
|
||||
damage = 0.08333333 * GunsTool.getGunDoubleTag(tag, "Damage", 0) *
|
||||
damage = 0.08333333 * GunsTool.getGunDoubleTag(tag, "Damage") *
|
||||
GunsTool.getGunDoubleTag(tag, "Power", 6) * perkDamage(stack);
|
||||
} else {
|
||||
spread = perk instanceof AmmoPerk ammoPerk && ammoPerk.slug ? 0.5f : 2.5f;
|
||||
damage = (perk instanceof AmmoPerk ammoPerk && ammoPerk.slug ? 0.08333333 : 0.008333333) *
|
||||
GunsTool.getGunDoubleTag(tag, "Damage", 0) *
|
||||
GunsTool.getGunDoubleTag(tag, "Damage") *
|
||||
GunsTool.getGunDoubleTag(tag, "Power", 6) * perkDamage(stack);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public record FireModeMessage(int msgType) implements CustomPacketPayload {
|
|||
}
|
||||
}
|
||||
|
||||
if (stack.getItem() == ModItems.TRACHELIUM.get() && !GunsTool.getGunBooleanTag(tag, "NeedBoltAction", false)) {
|
||||
if (stack.getItem() == ModItems.TRACHELIUM.get() && !GunsTool.getGunBooleanTag(tag, "NeedBoltAction")) {
|
||||
tag.putBoolean("DA", !tag.getBoolean("DA"));
|
||||
NBTTool.saveTag(stack, tag);
|
||||
if (!tag.getBoolean("canImmediatelyShoot")) {
|
||||
|
|
|
@ -50,7 +50,7 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload {
|
|||
) {
|
||||
boolean canSingleReload = gunItem.isIterativeReload(stack);
|
||||
boolean canReload = gunItem.isMagazineReload(stack) && !gunItem.isClipReload(stack);
|
||||
boolean clipLoad = GunsTool.getGunIntTag(tag, "Ammo", 0) == 0 && gunItem.isClipReload(stack);
|
||||
boolean clipLoad = GunsTool.getGunIntTag(tag, "Ammo") == 0 && gunItem.isClipReload(stack);
|
||||
|
||||
// 检查备弹
|
||||
boolean hasCreativeAmmoBox = player.getInventory().hasAnyMatching(item -> item.is(ModItems.CREATIVE_AMMO_BOX.get()));
|
||||
|
@ -74,9 +74,9 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload {
|
|||
}
|
||||
|
||||
if (canReload || clipLoad) {
|
||||
int magazine = GunsTool.getGunIntTag(tag, "Magazine", 0);
|
||||
int ammo = GunsTool.getGunIntTag(tag, "Ammo", 0);
|
||||
int customMagazine = GunsTool.getGunIntTag(tag, "CustomMagazine", 0);
|
||||
int magazine = GunsTool.getGunIntTag(tag, "Magazine");
|
||||
int ammo = GunsTool.getGunIntTag(tag, "Ammo");
|
||||
int customMagazine = GunsTool.getGunIntTag(tag, "CustomMagazine");
|
||||
|
||||
if (gunItem.isOpenBolt(stack)) {
|
||||
if (gunItem.hasBulletInBarrel(stack)) {
|
||||
|
@ -94,9 +94,9 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload {
|
|||
}
|
||||
|
||||
if (canSingleReload
|
||||
&& GunsTool.getGunIntTag(tag, "Ammo", 0)
|
||||
< GunsTool.getGunIntTag(tag, "Magazine", 0)
|
||||
+ GunsTool.getGunIntTag(tag, "CustomMagazine", 0)) {
|
||||
&& GunsTool.getGunIntTag(tag, "Ammo")
|
||||
< GunsTool.getGunIntTag(tag, "Magazine")
|
||||
+ GunsTool.getGunIntTag(tag, "CustomMagazine")) {
|
||||
|
||||
tag.putBoolean("start_single_reload", true);
|
||||
}
|
||||
|
|
|
@ -45,9 +45,9 @@ public record ShootMessage(double spread) implements CustomPacketPayload {
|
|||
if (stack.is(ModTags.Items.NORMAL_GUN)) {
|
||||
int projectileAmount = GunsTool.getGunIntTag(tag, "ProjectileAmount", 1);
|
||||
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) > 0) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") > 0) {
|
||||
// 空仓挂机
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo", 0) == 1) {
|
||||
if (GunsTool.getGunIntTag(tag, "Ammo") == 1) {
|
||||
GunsTool.setGunBooleanTag(tag, "HoldOpen", true);
|
||||
}
|
||||
|
||||
|
@ -56,14 +56,14 @@ public record ShootMessage(double spread) implements CustomPacketPayload {
|
|||
}
|
||||
|
||||
// 判断是否为栓动武器(BoltActionTime > 0),并在开火后给一个需要上膛的状态
|
||||
if (GunsTool.getGunIntTag(tag, "BoltActionTime", 0) > 0 && GunsTool.getGunIntTag(tag, "Ammo", 0) > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) {
|
||||
if (GunsTool.getGunIntTag(tag, "BoltActionTime") > 0 && GunsTool.getGunIntTag(tag, "Ammo") > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) {
|
||||
GunsTool.setGunBooleanTag(tag, "NeedBoltAction", true);
|
||||
}
|
||||
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo", 0) - 1);
|
||||
GunsTool.setGunIntTag(tag, "Ammo", GunsTool.getGunIntTag(tag, "Ammo") - 1);
|
||||
tag.putDouble("empty", 1);
|
||||
|
||||
if (stack.getItem() == ModItems.M_60.get() && GunsTool.getGunIntTag(tag, "Ammo", 0) <= 5) {
|
||||
if (stack.getItem() == ModItems.M_60.get() && GunsTool.getGunIntTag(tag, "Ammo") <= 5) {
|
||||
GunsTool.setGunBooleanTag(tag, "HideBulletChain", true);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ import net.minecraft.server.level.ServerPlayer;
|
|||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.event.OnDatapackSyncEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
|
@ -21,6 +21,7 @@ import javax.annotation.Nullable;
|
|||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@EventBusSubscriber(modid = Mod.MODID)
|
||||
public class GunsTool {
|
||||
|
@ -53,26 +54,26 @@ public class GunsTool {
|
|||
}
|
||||
}
|
||||
|
||||
public static void initGun(Level level, final CompoundTag tag, String location) {
|
||||
if (level.getServer() == null) return;
|
||||
gunsData.get(location).forEach((k, v) -> {
|
||||
public static void initGun(final CompoundTag tag, String location) {
|
||||
if (gunsData != null && gunsData.get(location) != null) {
|
||||
CompoundTag data = tag.getCompound("GunData");
|
||||
data.putDouble(k, v);
|
||||
|
||||
gunsData.get(location).forEach(data::putDouble);
|
||||
data.putBoolean("Init", true);
|
||||
tag.put("GunData", data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void initCreativeGun(ItemStack stack, String location) {
|
||||
if (gunsData != null && gunsData.get(location) != null) {
|
||||
final var tag = NBTTool.getTag(stack);
|
||||
gunsData.get(location).forEach((k, v) -> {
|
||||
CompoundTag data = tag.getCompound("GunData");
|
||||
data.putDouble(k, v);
|
||||
tag.put("GunData", data);
|
||||
});
|
||||
public static void initCreativeGun(final CompoundTag tag, String location) {
|
||||
var fillAmmo = !tag.getCompound("GunData").getBoolean("Init");
|
||||
|
||||
initGun(tag, location);
|
||||
|
||||
if (fillAmmo) {
|
||||
var data = tag.getCompound("GunData");
|
||||
data.putInt("Ammo", data.getInt("Magazine") + data.getInt("CustomMagazine"));
|
||||
NBTTool.saveTag(stack, tag);
|
||||
data.putInt("Ammo", GunsTool.getGunIntTag(tag, "Magazine")
|
||||
+ GunsTool.getGunIntTag(tag, "CustomMagazine")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +84,17 @@ public class GunsTool {
|
|||
tag.put("GunData", data);
|
||||
}
|
||||
|
||||
public static double getGunDefaultData(final CompoundTag tag, String name) {
|
||||
var id = tag.getString("id");
|
||||
|
||||
if (!tag.getBoolean("init")) {
|
||||
return GunsTool.gunsData
|
||||
.getOrDefault(id, new HashMap<>())
|
||||
.getOrDefault(name, 0.0);
|
||||
}
|
||||
return getGunDoubleTag(tag, name);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (event.getEntity() instanceof ServerPlayer player) {
|
||||
|
@ -95,6 +107,19 @@ public class GunsTool {
|
|||
initJsonData(event.getServer().getResourceManager());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void datapackSync(OnDatapackSyncEvent event) {
|
||||
AtomicInteger count = new AtomicInteger();
|
||||
event.getRelevantPlayers().forEach(player -> {
|
||||
if (count.get() == 0 && player.getServer() != null) {
|
||||
initJsonData(player.getServer().getResourceManager());
|
||||
}
|
||||
count.getAndIncrement();
|
||||
|
||||
PacketDistributor.sendToPlayer(player, new GunsDataMessage(GunsTool.gunsData));
|
||||
});
|
||||
}
|
||||
|
||||
public static void reload(Player player, ItemStack stack, final CompoundTag tag, AmmoType type) {
|
||||
reload(player, stack, tag, type, false);
|
||||
}
|
||||
|
@ -202,7 +227,9 @@ public class GunsTool {
|
|||
}
|
||||
|
||||
public static int getGunIntTag(final CompoundTag tag, String name) {
|
||||
return getGunIntTag(tag, name, 0);
|
||||
var data = tag.getCompound("GunData");
|
||||
if (!data.contains(name)) return (int) getGunDefaultData(tag, name);
|
||||
return data.getInt(name);
|
||||
}
|
||||
|
||||
public static int getGunIntTag(final CompoundTag tag, String name, int defaultValue) {
|
||||
|
@ -218,7 +245,9 @@ public class GunsTool {
|
|||
}
|
||||
|
||||
public static double getGunDoubleTag(final CompoundTag tag, String name) {
|
||||
return getGunDoubleTag(tag, name, 0);
|
||||
var data = tag.getCompound("GunData");
|
||||
if (!data.contains(name) && !tag.getBoolean("init")) return getGunDefaultData(tag, name);
|
||||
return data.getDouble(name);
|
||||
}
|
||||
|
||||
public static double getGunDoubleTag(final CompoundTag tag, String name, double defaultValue) {
|
||||
|
@ -234,12 +263,8 @@ public class GunsTool {
|
|||
}
|
||||
|
||||
public static boolean getGunBooleanTag(final CompoundTag tag, String name) {
|
||||
return getGunBooleanTag(tag, name, false);
|
||||
}
|
||||
|
||||
public static boolean getGunBooleanTag(final CompoundTag tag, String name, boolean defaultValue) {
|
||||
var data = tag.getCompound("GunData");
|
||||
if (!data.contains(name)) return defaultValue;
|
||||
if (!data.contains(name)) return getGunDefaultData(tag, name) != 0;
|
||||
return data.getBoolean(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"type": "minecraft:blasting",
|
||||
"cookingtime": 100,
|
||||
"experience": 0.3,
|
||||
"ingredient": {
|
||||
"tag": "c:dusts/silver"
|
||||
},
|
||||
"result": "superbwarfare:silver_ingot"
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"type": "minecraft:blasting",
|
||||
"category": "misc",
|
||||
"experience": 4,
|
||||
"cookingtime": 400,
|
||||
"ingredient": {
|
||||
"item": "superbwarfare:scheelite"
|
||||
},
|
||||
"result": "superbwarfare:tungsten_ingot"
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"type": "minecraft:blasting",
|
||||
"category": "misc",
|
||||
"experience": 4,
|
||||
"cookingtime": 200,
|
||||
"ingredient": {
|
||||
"item": "superbwarfare:tungsten_powder"
|
||||
},
|
||||
"result": "superbwarfare:tungsten_ingot"
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"type": "minecraft:blasting",
|
||||
"cookingtime": 100,
|
||||
"experience": 0.3,
|
||||
"ingredient": {
|
||||
"tag": "c:dusts/tungsten"
|
||||
},
|
||||
"result": "superbwarfare:tungsten_ingot"
|
||||
}
|
Loading…
Add table
Reference in a new issue