优化NBT#CanSwitchScope

This commit is contained in:
17146 2024-12-24 17:28:07 +08:00
parent 49789548b8
commit c442d25d1d
3 changed files with 3 additions and 5 deletions

View file

@ -157,7 +157,7 @@ public class ClickHandler {
if (stack.is(ModTags.Items.GUN) && ClientEventHandler.zoom) { if (stack.is(ModTags.Items.GUN) && ClientEventHandler.zoom) {
var tag = stack.getOrCreateTag(); var tag = stack.getOrCreateTag();
if (tag.getBoolean("CanSwitchScope")) { if (GunsTool.getGunBooleanTag(stack, "CanSwitchScope", false)) {
ModUtils.PACKET_HANDLER.sendToServer(new SwitchScopeMessage(scroll)); ModUtils.PACKET_HANDLER.sendToServer(new SwitchScopeMessage(scroll));
} else if (tag.getBoolean("CanAdjustZoomFov") || stack.is(ModItems.MINIGUN.get())) { } else if (tag.getBoolean("CanAdjustZoomFov") || stack.is(ModItems.MINIGUN.get())) {
ModUtils.PACKET_HANDLER.sendToServer(new AdjustZoomFovMessage(scroll)); ModUtils.PACKET_HANDLER.sendToServer(new AdjustZoomFovMessage(scroll));

View file

@ -265,7 +265,6 @@ public class Trachelium extends GunItem implements GeoItem, AnimatedItem {
int stockType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.STOCK); int stockType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.STOCK);
CompoundTag tags = stack.getOrCreateTag().getCompound("Attachments"); CompoundTag tags = stack.getOrCreateTag().getCompound("Attachments");
if (stockType == 1) { if (stockType == 1) {
tags.putInt("Stock", 2); tags.putInt("Stock", 2);
} }
@ -292,8 +291,7 @@ public class Trachelium extends GunItem implements GeoItem, AnimatedItem {
default -> 1; default -> 1;
}; };
stack.getOrCreateTag().putBoolean("CanSwitchScope", scopeType == 2); GunsTool.setGunBooleanTag(stack, "CanSwitchScope", scopeType == 2);
GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom); GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom);
} }

View file

@ -194,7 +194,7 @@ public class M4Item extends GunItem implements GeoItem, AnimatedItem {
default -> GunsTool.getGunDoubleTag(stack, "CustomZoom", 0); default -> GunsTool.getGunDoubleTag(stack, "CustomZoom", 0);
}; };
stack.getOrCreateTag().putBoolean("CanSwitchScope", scopeType == 2); GunsTool.setGunBooleanTag(stack, "CanSwitchScope", scopeType == 2);
stack.getOrCreateTag().putBoolean("CanAdjustZoomFov", scopeType == 3); stack.getOrCreateTag().putBoolean("CanAdjustZoomFov", scopeType == 3);
GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom); GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom);
stack.getOrCreateTag().putInt("customMag", customMag); stack.getOrCreateTag().putInt("customMag", customMag);