提取HoldOpen、HideBulletChain、Draw属性
This commit is contained in:
parent
7e5b24617d
commit
fc59522ac6
30 changed files with 40 additions and 71 deletions
|
@ -74,7 +74,6 @@ public class AK12ItemModel extends GeoModel<AK12Item> {
|
|||
double fr = ClientEventHandler.fireRot;
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
int type = data.attachment.get(AttachmentType.SCOPE);
|
||||
|
||||
float posY = switch (type) {
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.Glock17Item;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -104,7 +103,6 @@ public class Glock17ItemModel extends GeoModel<Glock17Item> {
|
|||
float numP = (float) (1 - 0.68 * zt);
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
|
||||
if (data.reload.time() > 0) {
|
||||
main.setRotX(numR * main.getRotX());
|
||||
|
@ -123,7 +121,7 @@ public class Glock17ItemModel extends GeoModel<Glock17Item> {
|
|||
|
||||
GeoBone shell = getAnimationProcessor().getBone("shell");
|
||||
GeoBone barrel = getAnimationProcessor().getBone("guan");
|
||||
if (GunsTool.getGunBooleanTag(tag, "HoldOpen")) {
|
||||
if (data.holdOpen.get()) {
|
||||
slide.setPosZ(1.5f);
|
||||
barrel.setRotX(4 * Mth.DEG_TO_RAD);
|
||||
bullet.setScaleX(0);
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.Glock18Item;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -48,7 +47,6 @@ public class Glock18ItemModel extends GeoModel<Glock18Item> {
|
|||
if (!stack.is(ModTags.Items.GUN)) return;
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
int mode = data.fireMode.get();
|
||||
if (mode == 0) {
|
||||
switch_.setRotX(35 * Mth.DEG_TO_RAD);
|
||||
|
@ -132,7 +130,7 @@ public class Glock18ItemModel extends GeoModel<Glock18Item> {
|
|||
|
||||
GeoBone shell = getAnimationProcessor().getBone("shell");
|
||||
GeoBone barrel = getAnimationProcessor().getBone("guan");
|
||||
if (GunsTool.getGunBooleanTag(tag, "HoldOpen")) {
|
||||
if (data.holdOpen.get()) {
|
||||
slide.setPosZ(1.5f);
|
||||
barrel.setRotX(4 * Mth.DEG_TO_RAD);
|
||||
bullet.setScaleX(0);
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.M1911Item;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -106,7 +105,6 @@ public class M1911ItemModel extends GeoModel<M1911Item> {
|
|||
float numP = (float) (1 - 0.68 * zt);
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
if (data.reload.time() > 0) {
|
||||
main.setRotX(numR * main.getRotX());
|
||||
main.setRotY(numR * main.getRotY());
|
||||
|
@ -123,7 +121,7 @@ public class M1911ItemModel extends GeoModel<M1911Item> {
|
|||
AnimationHelper.handleShellsAnimation(getAnimationProcessor(), 0.7f, 1f);
|
||||
GeoBone shell = getAnimationProcessor().getBone("shell");
|
||||
|
||||
if (GunsTool.getGunBooleanTag(tag, "HoldOpen")) {
|
||||
if (data.holdOpen.get()) {
|
||||
slide.setPosZ(1.5f);
|
||||
bullet.setScaleX(0);
|
||||
bullet.setScaleY(0);
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.item.gun.machinegun.M60Item;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -60,9 +59,8 @@ public class M60ItemModel extends GeoModel<M60Item> {
|
|||
}
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
int ammo = data.ammo.get();
|
||||
boolean flag = GunsTool.getGunBooleanTag(tag, "HideBulletChain");
|
||||
boolean flag = data.hideBulletChain.get();
|
||||
|
||||
if (ammo < 5 && flag) {
|
||||
b5.setScaleX(0);
|
||||
|
|
|
@ -166,7 +166,7 @@ public class Mk14ItemModel extends GeoModel<Mk14Item> {
|
|||
|
||||
GeoBone shell = getAnimationProcessor().getBone("shell");
|
||||
|
||||
if (data.data().getBoolean("HoldOpen")) {
|
||||
if (data.holdOpen.get()) {
|
||||
action.setPosZ(2.5f);
|
||||
shell.setScaleX(0);
|
||||
shell.setScaleY(0);
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.Mp443Item;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -103,7 +102,6 @@ public class Mp443ItemModel extends GeoModel<Mp443Item> {
|
|||
float numP = (float) (1 - 0.68 * zt);
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
if (data.reload.time() > 0) {
|
||||
main.setRotX(numR * main.getRotX());
|
||||
main.setRotY(numR * main.getRotY());
|
||||
|
@ -121,7 +119,7 @@ public class Mp443ItemModel extends GeoModel<Mp443Item> {
|
|||
|
||||
GeoBone shell = getAnimationProcessor().getBone("shell");
|
||||
|
||||
if (GunsTool.getGunBooleanTag(tag, "HoldOpen")) {
|
||||
if (data.holdOpen.get()) {
|
||||
slide.setPosZ(1.5f);
|
||||
bullet.setScaleX(0);
|
||||
bullet.setScaleY(0);
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.atsuishio.superbwarfare.init.ModTags;
|
|||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType;
|
||||
import com.atsuishio.superbwarfare.item.gun.rifle.Qbz95Item;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -85,7 +84,6 @@ public class Qbz95ItemModel extends GeoModel<Qbz95Item> {
|
|||
double fr = ClientEventHandler.fireRot;
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
int type = data.attachment.get(AttachmentType.SCOPE);
|
||||
|
||||
float posYAlt = switch (type) {
|
||||
|
@ -169,7 +167,7 @@ public class Qbz95ItemModel extends GeoModel<Qbz95Item> {
|
|||
l.setRotX(rotXBipod * Mth.DEG_TO_RAD);
|
||||
r.setRotX(rotXBipod * Mth.DEG_TO_RAD);
|
||||
|
||||
if (GunsTool.getGunBooleanTag(tag, "HoldOpen")) {
|
||||
if (data.holdOpen.get()) {
|
||||
bolt.setPosZ(5f);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,8 +71,6 @@ public class RpkItemModel extends GeoModel<RpkItem> {
|
|||
double fp = ClientEventHandler.firePos;
|
||||
double fr = ClientEventHandler.fireRot;
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
int type = GunData.from(stack).attachment.get(AttachmentType.SCOPE);
|
||||
|
||||
float posYAlt = switch (type) {
|
||||
|
|
|
@ -100,7 +100,6 @@ public class SecondaryCataclysmModel extends GeoModel<SecondaryCataclysm> {
|
|||
float numP = (float) (1 - 0.68 * zt);
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
if (data.reload.time() > 0) {
|
||||
main.setRotX(numR * main.getRotX());
|
||||
main.setRotY(numR * main.getRotY());
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.item.gun.rifle.SksItem;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -69,7 +68,6 @@ public class SksItemModel extends GeoModel<SksItem> {
|
|||
gun.setRotZ((float) (0.05f * zpz));
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
|
||||
GeoBone shen = getAnimationProcessor().getBone("shen");
|
||||
|
||||
|
@ -110,7 +108,7 @@ public class SksItemModel extends GeoModel<SksItem> {
|
|||
AnimationHelper.handleShellsAnimation(getAnimationProcessor(), 0.7f, 1.2f);
|
||||
GeoBone shell = getAnimationProcessor().getBone("shell");
|
||||
|
||||
if (GunsTool.getGunBooleanTag(tag, "HoldOpen")) {
|
||||
if (data.holdOpen.get()) {
|
||||
shell.setScaleX(0);
|
||||
shell.setScaleY(0);
|
||||
shell.setScaleZ(0);
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.atsuishio.superbwarfare.init.ModTags;
|
|||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType;
|
||||
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;
|
||||
|
@ -112,7 +111,6 @@ public class SvdItemModel extends GeoModel<SvdItem> {
|
|||
cross3.setScaleY((float) (1f + (0.1 * zp)));
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
|
||||
GeoBone shen;
|
||||
if (zt < 0.5) {
|
||||
|
@ -148,7 +146,7 @@ public class SvdItemModel extends GeoModel<SvdItem> {
|
|||
|
||||
bolt.setPosZ(4.5f * (float) fp);
|
||||
|
||||
if (GunsTool.getGunBooleanTag(tag, "HoldOpen")) {
|
||||
if (data.holdOpen.get()) {
|
||||
bolt.setPosZ(3.5f);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ public class VectorItemModel extends GeoModel<VectorItem> {
|
|||
if (!stack.is(ModTags.Items.GUN)) return;
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
int mode = data.fireMode.get();
|
||||
if (mode == 0) {
|
||||
kmj.setRotX(-120 * Mth.DEG_TO_RAD);
|
||||
|
|
|
@ -81,7 +81,6 @@ public class RpkItemRenderer extends GeoItemRenderer<RpkItem> {
|
|||
ItemStack itemStack = player.getMainHandItem();
|
||||
if (!itemStack.is(ModTags.Items.GUN)) return;
|
||||
var data = GunData.from(itemStack);
|
||||
var tag = GunData.from(itemStack).tag();
|
||||
|
||||
if (name.equals("Cross1")) {
|
||||
bone.setHidden(ClientEventHandler.zoomPos < 0.7 || data.attachment.get(AttachmentType.SCOPE) != 1);
|
||||
|
|
|
@ -390,9 +390,9 @@ public class LivingEventHandler {
|
|||
|
||||
if (newStack.getItem() instanceof GunItem) {
|
||||
var newData = GunData.from(newStack);
|
||||
newData.draw.set(true);
|
||||
newTag = newData.tag();
|
||||
|
||||
newTag.putBoolean("draw", true);
|
||||
if (newData.defaultActionTime() > 0) {
|
||||
newData.bolt.actionTimer.reset();
|
||||
}
|
||||
|
|
|
@ -39,10 +39,7 @@ public class PlayerEventHandler {
|
|||
for (ItemStack stack : player.getInventory().items) {
|
||||
if (stack.getItem() instanceof GunItem) {
|
||||
var data = GunData.from(stack);
|
||||
tag = data.tag();
|
||||
|
||||
tag.putBoolean("draw", true);
|
||||
|
||||
data.draw.set(true);
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
|
@ -60,10 +57,7 @@ public class PlayerEventHandler {
|
|||
for (ItemStack stack : player.getInventory().items) {
|
||||
if (stack.is(ModTags.Items.GUN)) {
|
||||
var data = GunData.from(stack);
|
||||
final var tag = data.tag();
|
||||
|
||||
tag.putBoolean("draw", true);
|
||||
|
||||
data.draw.set(true);
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +96,6 @@ public class PlayerEventHandler {
|
|||
for (ItemStack stack : player.getInventory().items) {
|
||||
if (stack.is(ModTags.Items.GUN)) {
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
|
||||
if (!InventoryTool.hasCreativeAmmoBox(player)) {
|
||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE);
|
||||
|
@ -142,7 +135,7 @@ public class PlayerEventHandler {
|
|||
} else {
|
||||
data.ammo.set(data.magazine());
|
||||
}
|
||||
GunsTool.setGunBooleanTag(tag, "HoldOpen", false);
|
||||
data.holdOpen.set(false);
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,7 @@ public class GunEvents {
|
|||
var stack = event.getItemEntity().getItem();
|
||||
if (stack.is(ModTags.Items.GUN)) {
|
||||
var data = GunData.from(stack);
|
||||
final var tag = data.tag();
|
||||
tag.putBoolean("draw", true);
|
||||
data.draw.set(true);
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,6 @@ public abstract class GunItem extends Item implements CustomRendererItem {
|
|||
) return;
|
||||
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
|
||||
if (!data.initialized()) {
|
||||
data.initialize();
|
||||
|
@ -73,7 +72,7 @@ public abstract class GunItem extends Item implements CustomRendererItem {
|
|||
data.ammo.set(data.magazine());
|
||||
}
|
||||
}
|
||||
tag.putBoolean("draw", false);
|
||||
data.draw.set(false);
|
||||
handleGunPerks(data);
|
||||
|
||||
var hasBulletInBarrel = gunItem.hasBulletInBarrel(stack);
|
||||
|
|
|
@ -64,6 +64,9 @@ public class GunData {
|
|||
forceStop = new BooleanValue(data, "ForceStop");
|
||||
loadIndex = new IntValue(data, "LoadIndex");
|
||||
maxAmmo = new IntValue(data, "MaxAmmo");
|
||||
holdOpen = new BooleanValue(data, "HoldOpen");
|
||||
hideBulletChain = new BooleanValue(data, "HideBulletChain");
|
||||
draw = new BooleanValue(data, "Draw");
|
||||
}
|
||||
|
||||
private CompoundTag getOrPut(String name) {
|
||||
|
@ -301,6 +304,9 @@ public class GunData {
|
|||
public final IntValue loadIndex;
|
||||
public final IntValue maxAmmo;
|
||||
|
||||
public final BooleanValue holdOpen;
|
||||
public final BooleanValue hideBulletChain;
|
||||
public final BooleanValue draw;
|
||||
|
||||
// 其他子级属性
|
||||
|
||||
|
|
|
@ -144,6 +144,6 @@ public class Glock17Item extends GunItem implements GeoItem {
|
|||
public void addReloadTimeBehavior(Map<Integer, Consumer<GunData>> behaviors) {
|
||||
super.addReloadTimeBehavior(behaviors);
|
||||
|
||||
behaviors.put(9, data -> data.data().remove("HoldOpen"));
|
||||
behaviors.put(9, data -> data.holdOpen.set(false));
|
||||
}
|
||||
}
|
|
@ -152,6 +152,6 @@ public class Glock18Item extends GunItem implements GeoItem {
|
|||
public void addReloadTimeBehavior(Map<Integer, Consumer<GunData>> behaviors) {
|
||||
super.addReloadTimeBehavior(behaviors);
|
||||
|
||||
behaviors.put(9, data -> data.data().remove("HoldOpen"));
|
||||
behaviors.put(9, data -> data.holdOpen.set(false));
|
||||
}
|
||||
}
|
|
@ -147,6 +147,6 @@ public class M1911Item extends GunItem implements GeoItem {
|
|||
public void addReloadTimeBehavior(Map<Integer, Consumer<GunData>> behaviors) {
|
||||
super.addReloadTimeBehavior(behaviors);
|
||||
|
||||
behaviors.put(9, data -> data.data().remove("HoldOpen"));
|
||||
behaviors.put(9, data -> data.holdOpen.set(false));
|
||||
}
|
||||
}
|
|
@ -144,6 +144,6 @@ public class Mp443Item extends GunItem implements GeoItem {
|
|||
public void addReloadTimeBehavior(Map<Integer, Consumer<GunData>> behaviors) {
|
||||
super.addReloadTimeBehavior(behaviors);
|
||||
|
||||
behaviors.put(9, data -> data.data().remove("HoldOpen"));
|
||||
behaviors.put(9, data -> data.holdOpen.set(false));
|
||||
}
|
||||
}
|
|
@ -133,9 +133,8 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
@ParametersAreNonnullByDefault
|
||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||
var data = GunData.from(stack);
|
||||
final var tag = data.tag();
|
||||
if (tag.getBoolean("draw")) {
|
||||
tag.putBoolean("draw", false);
|
||||
if (data.draw.get()) {
|
||||
data.draw.set(false);
|
||||
|
||||
if (data.ammo.get() == 0) {
|
||||
data.isEmpty.set(true);
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.atsuishio.superbwarfare.item.gun.GunItem;
|
|||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -109,12 +108,11 @@ public class M60Item extends GunItem implements GeoItem {
|
|||
@ParametersAreNonnullByDefault
|
||||
public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, boolean selected) {
|
||||
var data = GunData.from(stack);
|
||||
final var tag = data.tag();
|
||||
if (tag.getBoolean("draw")) {
|
||||
tag.putBoolean("draw", false);
|
||||
if (data.draw.get()) {
|
||||
data.draw.set(false);
|
||||
|
||||
if (data.ammo.get() <= 5) {
|
||||
GunsTool.setGunBooleanTag(tag, "HideBulletChain", true);
|
||||
data.hideBulletChain.set(true);
|
||||
}
|
||||
data.save();
|
||||
}
|
||||
|
@ -165,6 +163,6 @@ public class M60Item extends GunItem implements GeoItem {
|
|||
public void addReloadTimeBehavior(Map<Integer, Consumer<GunData>> behaviors) {
|
||||
super.addReloadTimeBehavior(behaviors);
|
||||
|
||||
behaviors.put(55, data -> data.data().remove("HideBulletChain"));
|
||||
behaviors.put(55, data -> data.hideBulletChain.reset());
|
||||
}
|
||||
}
|
|
@ -244,6 +244,6 @@ public class Mk14Item extends GunItem implements GeoItem {
|
|||
public void addReloadTimeBehavior(Map<Integer, Consumer<GunData>> behaviors) {
|
||||
super.addReloadTimeBehavior(behaviors);
|
||||
|
||||
behaviors.put(18, data -> data.data().remove("HoldOpen"));
|
||||
behaviors.put(18, data -> data.holdOpen.set(false));
|
||||
}
|
||||
}
|
|
@ -252,6 +252,6 @@ public class Qbz95Item extends GunItem implements GeoItem {
|
|||
public void addReloadTimeBehavior(Map<Integer, Consumer<GunData>> behaviors) {
|
||||
super.addReloadTimeBehavior(behaviors);
|
||||
|
||||
behaviors.put(14, data -> data.data().remove("HoldOpen"));
|
||||
behaviors.put(14, data -> data.holdOpen.set(false));
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@ import com.atsuishio.superbwarfare.item.gun.GunItem;
|
|||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -93,12 +92,11 @@ public class SksItem extends GunItem implements GeoItem {
|
|||
@ParametersAreNonnullByDefault
|
||||
public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, boolean selected) {
|
||||
var data = GunData.from(stack);
|
||||
final var tag = data.tag();
|
||||
if (tag.getBoolean("draw")) {
|
||||
tag.putBoolean("draw", false);
|
||||
if (data.draw.get()) {
|
||||
data.draw.set(false);
|
||||
|
||||
if (data.ammo.get() == 0) {
|
||||
GunsTool.setGunBooleanTag(tag, "HoldOpen", true);
|
||||
data.holdOpen.set(true);
|
||||
}
|
||||
data.save();
|
||||
}
|
||||
|
@ -149,6 +147,6 @@ public class SksItem extends GunItem implements GeoItem {
|
|||
public void addReloadTimeBehavior(Map<Integer, Consumer<GunData>> behaviors) {
|
||||
super.addReloadTimeBehavior(behaviors);
|
||||
|
||||
behaviors.put(14, data -> data.data().remove("HoldOpen"));
|
||||
behaviors.put(14, data -> data.holdOpen.set(false));
|
||||
}
|
||||
}
|
|
@ -198,6 +198,6 @@ public class SvdItem extends GunItem implements GeoItem {
|
|||
public void addReloadTimeBehavior(Map<Integer, Consumer<GunData>> behaviors) {
|
||||
super.addReloadTimeBehavior(behaviors);
|
||||
|
||||
behaviors.put(17, data -> data.data().remove("HoldOpen"));
|
||||
behaviors.put(17, data -> data.holdOpen.set(false));
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import com.atsuishio.superbwarfare.init.*;
|
|||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||
|
@ -50,7 +49,7 @@ public record ShootMessage(double spread, boolean zoom) implements CustomPacketP
|
|||
if (data.ammo.get() > 0) {
|
||||
// 空仓挂机
|
||||
if (data.ammo.get() == 1) {
|
||||
GunsTool.setGunBooleanTag(tag, "HoldOpen", true);
|
||||
data.holdOpen.set(true);
|
||||
}
|
||||
|
||||
if (stack.is(ModTags.Items.REVOLVER)) {
|
||||
|
@ -66,7 +65,7 @@ public record ShootMessage(double spread, boolean zoom) implements CustomPacketP
|
|||
data.isEmpty.set(true);
|
||||
|
||||
if (stack.getItem() == ModItems.M_60.get() && data.ammo.get() <= 5) {
|
||||
GunsTool.setGunBooleanTag(tag, "HideBulletChain", true);
|
||||
data.hideBulletChain.set(true);
|
||||
}
|
||||
|
||||
if (stack.getItem() == ModItems.HOMEMADE_SHOTGUN.get()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue