优化NBT#NeedBoltAction
This commit is contained in:
parent
b8432ab5ea
commit
b8f20eb2a0
8 changed files with 10 additions and 20 deletions
|
@ -311,7 +311,7 @@ public class ClickHandler {
|
||||||
if ((!(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
|
if ((!(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
|
||||||
&& !stack.getOrCreateTag().getBoolean("reloading")
|
&& !stack.getOrCreateTag().getBoolean("reloading")
|
||||||
&& !stack.getOrCreateTag().getBoolean("charging")
|
&& !stack.getOrCreateTag().getBoolean("charging")
|
||||||
&& !stack.getOrCreateTag().getBoolean("need_bolt_action"))
|
&& !GunsTool.getGunBooleanTag(stack, "NeedBoltAction", false))
|
||||||
&& cantFireTime == 0
|
&& cantFireTime == 0
|
||||||
&& drawTime < 0.01
|
&& drawTime < 0.01
|
||||||
&& !notInGame()) {
|
&& !notInGame()) {
|
||||||
|
|
|
@ -122,16 +122,6 @@ public class CrossHairOverlay {
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
RenderSystem.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||||
|
|
||||||
// if (!stack.is(ModTags.Items.GUN)) return;
|
|
||||||
|
|
||||||
// if (stack.getOrCreateTag().getBoolean("need_bolt_action")) {
|
|
||||||
// Font font = Minecraft.getInstance().font;
|
|
||||||
// Component component = Component.translatable("des.superbwarfare.need_bolt_action");
|
|
||||||
//
|
|
||||||
// guiGraphics.drawString(font, component, w / 2 - font.width(component) / 2, h / 2 + 50, 0xFF6969);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void normalCrossHair(GuiGraphics guiGraphics, int w, int h, double spread, float moveX, float moveY) {
|
private static void normalCrossHair(GuiGraphics guiGraphics, int w, int h, double spread, float moveX, float moveY) {
|
||||||
|
|
|
@ -299,7 +299,7 @@ public class ClientEventHandler {
|
||||||
&& !stack.getOrCreateTag().getBoolean("charging")
|
&& !stack.getOrCreateTag().getBoolean("charging")
|
||||||
&& stack.getOrCreateTag().getInt("ammo") > 0
|
&& stack.getOrCreateTag().getInt("ammo") > 0
|
||||||
&& !player.getCooldowns().isOnCooldown(stack.getItem())
|
&& !player.getCooldowns().isOnCooldown(stack.getItem())
|
||||||
&& !stack.getOrCreateTag().getBoolean("need_bolt_action")
|
&& !GunsTool.getGunBooleanTag(stack, "NeedBoltAction", false)
|
||||||
&& revolverPre()
|
&& revolverPre()
|
||||||
)
|
)
|
||||||
|| (stack.is(ModItems.MINIGUN.get())
|
|| (stack.is(ModItems.MINIGUN.get())
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class GunEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getOrCreateTag().getInt("bolt_action_anim") == 1) {
|
if (stack.getOrCreateTag().getInt("bolt_action_anim") == 1) {
|
||||||
stack.getOrCreateTag().putBoolean("need_bolt_action", false);
|
GunsTool.setGunBooleanTag(stack, "NeedBoltAction", false);
|
||||||
if (stack.is(ModTags.Items.REVOLVER)) {
|
if (stack.is(ModTags.Items.REVOLVER)) {
|
||||||
stack.getOrCreateTag().putBoolean("canImmediatelyShoot", true);
|
stack.getOrCreateTag().putBoolean("canImmediatelyShoot", true);
|
||||||
}
|
}
|
||||||
|
@ -693,7 +693,7 @@ public class GunEventHandler {
|
||||||
if (tag.getInt("finish") == 1) {
|
if (tag.getInt("finish") == 1) {
|
||||||
tag.putInt("reload_stage", 0);
|
tag.putInt("reload_stage", 0);
|
||||||
if (GunsTool.getGunIntTag(stack, "BoltActionTime", 0) > 0) {
|
if (GunsTool.getGunIntTag(stack, "BoltActionTime", 0) > 0) {
|
||||||
stack.getOrCreateTag().putBoolean("need_bolt_action", false);
|
GunsTool.setGunBooleanTag(stack, "NeedBoltAction", false);
|
||||||
}
|
}
|
||||||
tag.putBoolean("reloading", false);
|
tag.putBoolean("reloading", false);
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class FireMessage {
|
||||||
&& !(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
|
&& !(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
|
||||||
&& !stack.getOrCreateTag().getBoolean("reloading")
|
&& !stack.getOrCreateTag().getBoolean("reloading")
|
||||||
&& !stack.getOrCreateTag().getBoolean("charging")) {
|
&& !stack.getOrCreateTag().getBoolean("charging")) {
|
||||||
if (!player.getCooldowns().isOnCooldown(stack.getItem()) && stack.getOrCreateTag().getBoolean("need_bolt_action")) {
|
if (!player.getCooldowns().isOnCooldown(stack.getItem()) && GunsTool.getGunBooleanTag(stack, "NeedBoltAction", false)) {
|
||||||
stack.getOrCreateTag().putInt("bolt_action_anim", GunsTool.getGunIntTag(stack, "BoltActionTime", 0) + 1);
|
stack.getOrCreateTag().putInt("bolt_action_anim", GunsTool.getGunIntTag(stack, "BoltActionTime", 0) + 1);
|
||||||
GunEventHandler.playGunBoltSounds(player);
|
GunEventHandler.playGunBoltSounds(player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class FireModeMessage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getItem() == ModItems.TRACHELIUM.get() && !tag.getBoolean("need_bolt_action")) {
|
if (stack.getItem() == ModItems.TRACHELIUM.get() && !GunsTool.getGunBooleanTag(stack, "NeedBoltAction", false)) {
|
||||||
if (!tag.getBoolean("DA")) {
|
if (!tag.getBoolean("DA")) {
|
||||||
tag.putBoolean("DA", true);
|
tag.putBoolean("DA", true);
|
||||||
player.displayClientMessage(Component.translatable("des.superbwarfare.revolver.sa").withStyle(ChatFormatting.BOLD), true);
|
player.displayClientMessage(Component.translatable("des.superbwarfare.revolver.sa").withStyle(ChatFormatting.BOLD), true);
|
||||||
|
@ -137,7 +137,7 @@ public class FireModeMessage {
|
||||||
player.displayClientMessage(Component.translatable("des.superbwarfare.revolver.da").withStyle(ChatFormatting.BOLD), true);
|
player.displayClientMessage(Component.translatable("des.superbwarfare.revolver.da").withStyle(ChatFormatting.BOLD), true);
|
||||||
}
|
}
|
||||||
if (!tag.getBoolean("canImmediatelyShoot")) {
|
if (!tag.getBoolean("canImmediatelyShoot")) {
|
||||||
tag.putBoolean("need_bolt_action", true);
|
GunsTool.setGunBooleanTag(stack, "NeedBoltAction", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class ShootMessage {
|
||||||
|
|
||||||
// 判断是否为栓动武器(BoltActionTime > 0),并在开火后给一个需要上膛的状态
|
// 判断是否为栓动武器(BoltActionTime > 0),并在开火后给一个需要上膛的状态
|
||||||
if (GunsTool.getGunIntTag(stack, "BoltActionTime", 0) > 0 && stack.getOrCreateTag().getInt("ammo") > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) {
|
if (GunsTool.getGunIntTag(stack, "BoltActionTime", 0) > 0 && stack.getOrCreateTag().getInt("ammo") > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) {
|
||||||
stack.getOrCreateTag().putBoolean("need_bolt_action", true);
|
GunsTool.setGunBooleanTag(stack, "NeedBoltAction", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.getOrCreateTag().putInt("ammo", (stack.getOrCreateTag().getInt("ammo") - 1));
|
stack.getOrCreateTag().putInt("ammo", (stack.getOrCreateTag().getInt("ammo") - 1));
|
||||||
|
|
|
@ -105,9 +105,9 @@ public class GunsTool {
|
||||||
int ammo = tag.getInt("ammo");
|
int ammo = tag.getInt("ammo");
|
||||||
int ammoToAdd = mag - ammo + (extraOne ? 1 : 0);
|
int ammoToAdd = mag - ammo + (extraOne ? 1 : 0);
|
||||||
|
|
||||||
// 空仓换弹的栓动武器应该在换单后取消待上膛标记
|
// 空仓换弹的栓动武器应该在换弹后取消待上膛标记
|
||||||
if (ammo == 0 && GunsTool.getGunIntTag(stack, "BoltActionTime", 0) > 0 && !stack.is(ModTags.Items.REVOLVER)) {
|
if (ammo == 0 && GunsTool.getGunIntTag(stack, "BoltActionTime", 0) > 0 && !stack.is(ModTags.Items.REVOLVER)) {
|
||||||
tag.putBoolean("need_bolt_action", false);
|
GunsTool.setGunBooleanTag(stack, "NeedBoltAction", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerAmmo = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> switch (type) {
|
int playerAmmo = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> switch (type) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue