优化NBT#StartReload HoldOpen
This commit is contained in:
parent
d35bcb3092
commit
7a8f24ac18
12 changed files with 27 additions and 25 deletions
|
@ -127,7 +127,7 @@ public class Glock17ItemModel extends GeoModel<Glock17Item> {
|
|||
AnimationHelper.handleShellsAnimation(getAnimationProcessor(), 0.7f, 1f);
|
||||
|
||||
CoreGeoBone shell = getAnimationProcessor().getBone("shell");
|
||||
if (stack.getOrCreateTag().getBoolean("HoldOpen")) {
|
||||
if (GunsTool.getGunBooleanTag(stack, "HoldOpen")) {
|
||||
slide.setPosZ(1.5f);
|
||||
bullet.setScaleX(0);
|
||||
bullet.setScaleY(0);
|
||||
|
|
|
@ -136,7 +136,7 @@ public class Glock18ItemModel extends GeoModel<Glock18Item> {
|
|||
AnimationHelper.handleShellsAnimation(getAnimationProcessor(), 0.7f, 1f);
|
||||
|
||||
CoreGeoBone shell = getAnimationProcessor().getBone("shell");
|
||||
if (stack.getOrCreateTag().getBoolean("HoldOpen")) {
|
||||
if (GunsTool.getGunBooleanTag(stack, "HoldOpen")) {
|
||||
slide.setPosZ(1.5f);
|
||||
bullet.setScaleX(0);
|
||||
bullet.setScaleY(0);
|
||||
|
|
|
@ -127,7 +127,7 @@ public class M1911ItemModel extends GeoModel<M1911Item> {
|
|||
AnimationHelper.handleShellsAnimation(getAnimationProcessor(), 0.7f, 1f);
|
||||
CoreGeoBone shell = getAnimationProcessor().getBone("shell");
|
||||
|
||||
if (stack.getOrCreateTag().getBoolean("HoldOpen")) {
|
||||
if (GunsTool.getGunBooleanTag(stack, "HoldOpen")) {
|
||||
slide.setPosZ(1.5f);
|
||||
bullet.setScaleX(0);
|
||||
bullet.setScaleY(0);
|
||||
|
|
|
@ -164,7 +164,7 @@ public class Mk14ItemModel extends GeoModel<Mk14Item> {
|
|||
|
||||
CoreGeoBone shell = getAnimationProcessor().getBone("shell");
|
||||
|
||||
if (stack.getOrCreateTag().getBoolean("HoldOpen")) {
|
||||
if (GunsTool.getGunBooleanTag(stack, "HoldOpen")) {
|
||||
action.setPosZ(2.5f);
|
||||
shell.setScaleX(0);
|
||||
shell.setScaleY(0);
|
||||
|
|
|
@ -165,7 +165,7 @@ public class Qbz95ItemModel extends GeoModel<Qbz95Item> {
|
|||
l.setRotX(rotXBipod * Mth.DEG_TO_RAD);
|
||||
r.setRotX(rotXBipod * Mth.DEG_TO_RAD);
|
||||
|
||||
if (stack.getOrCreateTag().getBoolean("HoldOpen")) {
|
||||
if (GunsTool.getGunBooleanTag(stack, "HoldOpen")) {
|
||||
bolt.setPosZ(5f);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
|||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.rifle.SksItem;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -106,7 +107,7 @@ public class SksItemModel extends GeoModel<SksItem> {
|
|||
AnimationHelper.handleShellsAnimation(getAnimationProcessor(), 0.7f, 1.2f);
|
||||
CoreGeoBone shell = getAnimationProcessor().getBone("shell");
|
||||
|
||||
if (stack.getOrCreateTag().getBoolean("HoldOpen")) {
|
||||
if (GunsTool.getGunBooleanTag(stack, "HoldOpen")) {
|
||||
shell.setScaleX(0);
|
||||
shell.setScaleY(0);
|
||||
shell.setScaleZ(0);
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
|||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.sniper.SvdItem;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -48,7 +49,7 @@ public class SvdItemModel extends GeoModel<SvdItem> {
|
|||
ItemStack stack = player.getMainHandItem();
|
||||
if (!stack.is(ModTags.Items.GUN)) return;
|
||||
|
||||
if (stack.getOrCreateTag().getBoolean("HoldOpen")) {
|
||||
if (GunsTool.getGunBooleanTag(stack, "HoldOpen")) {
|
||||
bolt.setPosZ(3.25f);
|
||||
}
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ public class GunEventHandler {
|
|||
CompoundTag tag = stack.getOrCreateTag();
|
||||
CompoundTag data = stack.getOrCreateTag().getCompound("GunData");
|
||||
// 启动换弹
|
||||
if (tag.getBoolean("start_reload")) {
|
||||
if (GunsTool.getGunBooleanTag(stack, "StartReload")) {
|
||||
MinecraftForge.EVENT_BUS.post(new ReloadEvent.Pre(player, stack));
|
||||
if (gunItem.isOpenBolt(stack)) {
|
||||
if (GunsTool.getGunIntTag(stack, "Ammo", 0) == 0) {
|
||||
|
@ -334,7 +334,7 @@ public class GunEventHandler {
|
|||
stack.getOrCreateTag().putBoolean("is_empty_reloading", true);
|
||||
playGunEmptyReloadSounds(player);
|
||||
}
|
||||
tag.putBoolean("start_reload", false);
|
||||
GunsTool.setGunBooleanTag(stack, "StartReload", false);
|
||||
}
|
||||
|
||||
if (data.getInt("ReloadTime") > 0) {
|
||||
|
@ -352,13 +352,13 @@ public class GunEventHandler {
|
|||
|
||||
if (stack.getItem() == ModItems.MK_14.get()) {
|
||||
if (data.getInt("ReloadTime") == 18) {
|
||||
tag.putBoolean("HoldOpen", false);
|
||||
GunsTool.setGunBooleanTag(stack, "HoldOpen", false);
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.getItem() == ModItems.SKS.get()) {
|
||||
if (data.getInt("ReloadTime") == 14) {
|
||||
tag.putBoolean("HoldOpen", false);
|
||||
GunsTool.setGunBooleanTag(stack, "HoldOpen", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,13 +370,13 @@ public class GunEventHandler {
|
|||
|
||||
if (stack.getItem() == ModItems.GLOCK_17.get() || stack.getItem() == ModItems.GLOCK_18.get() || stack.getItem() == ModItems.M_1911.get()) {
|
||||
if (data.getInt("ReloadTime") == 5) {
|
||||
tag.putBoolean("HoldOpen", false);
|
||||
GunsTool.setGunBooleanTag(stack, "HoldOpen", false);
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.getItem() == ModItems.QBZ_95.get()) {
|
||||
if (data.getInt("ReloadTime") == 14) {
|
||||
tag.putBoolean("HoldOpen", false);
|
||||
GunsTool.setGunBooleanTag(stack, "HoldOpen", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,7 +390,7 @@ public class GunEventHandler {
|
|||
} else {
|
||||
playGunEmptyReload(player);
|
||||
}
|
||||
tag.putBoolean("start_reload", false);
|
||||
GunsTool.setGunBooleanTag(stack, "StartReload", false);
|
||||
}
|
||||
|
||||
stack.addTagElement("GunData", data);
|
||||
|
|
|
@ -334,7 +334,7 @@ public class PlayerEventHandler {
|
|||
} else {
|
||||
GunsTool.setGunIntTag(stack, "Ammo", GunsTool.getGunIntTag(stack, "Magazine", 0) + stack.getOrCreateTag().getInt("customMag"));
|
||||
}
|
||||
stack.getOrCreateTag().putBoolean("HoldOpen", false);
|
||||
GunsTool.setGunBooleanTag(stack, "HoldOpen", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,15 +119,15 @@ public class SksItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack itemstack, Level level, Entity entity, int slot, boolean selected) {
|
||||
if (itemstack.getOrCreateTag().getBoolean("draw")) {
|
||||
itemstack.getOrCreateTag().putBoolean("draw", false);
|
||||
public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, boolean selected) {
|
||||
if (stack.getOrCreateTag().getBoolean("draw")) {
|
||||
stack.getOrCreateTag().putBoolean("draw", false);
|
||||
|
||||
if (GunsTool.getGunIntTag(itemstack, "Ammo", 0) == 0) {
|
||||
itemstack.getOrCreateTag().putBoolean("HoldOpen", true);
|
||||
if (GunsTool.getGunIntTag(stack, "Ammo", 0) == 0) {
|
||||
GunsTool.setGunBooleanTag(stack, "HoldOpen", true);
|
||||
}
|
||||
}
|
||||
super.inventoryTick(itemstack, level, entity, slot, selected);
|
||||
super.inventoryTick(stack, level, entity, slot, selected);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -95,15 +95,15 @@ public class ReloadMessage {
|
|||
if (gunItem.isOpenBolt(stack)) {
|
||||
if (gunItem.bulletInBarrel(stack)) {
|
||||
if (GunsTool.getGunIntTag(stack, "Ammo", 0) < magazine + tag.getInt("customMag") + 1) {
|
||||
tag.putBoolean("start_reload", true);
|
||||
GunsTool.setGunBooleanTag(stack, "StartReload", true);
|
||||
}
|
||||
} else {
|
||||
if (GunsTool.getGunIntTag(stack, "Ammo", 0) < magazine + tag.getInt("customMag")) {
|
||||
tag.putBoolean("start_reload", true);
|
||||
GunsTool.setGunBooleanTag(stack, "StartReload", true);
|
||||
}
|
||||
}
|
||||
} else if (GunsTool.getGunIntTag(stack, "Ammo", 0) < magazine + tag.getInt("customMag")) {
|
||||
tag.putBoolean("start_reload", true);
|
||||
GunsTool.setGunBooleanTag(stack, "StartReload", true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ShootMessage {
|
|||
if (GunsTool.getGunIntTag(stack, "Ammo", 0) > 0) {
|
||||
// 空仓挂机
|
||||
if (GunsTool.getGunIntTag(stack, "Ammo", 0) == 1) {
|
||||
stack.getOrCreateTag().putBoolean("HoldOpen", true);
|
||||
GunsTool.setGunBooleanTag(stack, "HoldOpen", true);
|
||||
}
|
||||
|
||||
if (stack.is(ModTags.Items.REVOLVER)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue