优化NBT#CustomZoom
This commit is contained in:
parent
cb78664676
commit
6323be3dc6
12 changed files with 49 additions and 61 deletions
|
@ -1160,7 +1160,7 @@ public class ClientEventHandler {
|
|||
p = zoomPos;
|
||||
}
|
||||
|
||||
customZoom = Mth.lerp(0.6 * times, customZoom, stack.getOrCreateTag().getDouble("CustomZoom"));
|
||||
customZoom = Mth.lerp(0.6 * times, customZoom, GunsTool.getGunDoubleTag(stack, "CustomZoom", 0));
|
||||
|
||||
double zoomFov = 1.25 + customZoom;
|
||||
|
||||
|
|
|
@ -293,8 +293,8 @@ public class Trachelium extends GunItem implements GeoItem, AnimatedItem {
|
|||
};
|
||||
|
||||
stack.getOrCreateTag().putBoolean("CanSwitchScope", scopeType == 2);
|
||||
stack.getOrCreateTag().putDouble("CustomZoom", customZoom);
|
||||
|
||||
GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.atsuishio.superbwarfare.item.gun.rifle;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.AK12ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
|
@ -12,7 +13,6 @@ import com.atsuishio.superbwarfare.network.ModVariables;
|
|||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -182,13 +182,11 @@ public class AK12Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 2.15;
|
||||
default -> stack.getOrCreateTag().getDouble("CustomZoom");
|
||||
default -> GunsTool.getGunDoubleTag(stack, "CustomZoom", 0);
|
||||
};
|
||||
|
||||
stack.getOrCreateTag().putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
||||
stack.getOrCreateTag().putDouble("CustomZoom", customZoom);
|
||||
|
||||
GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom);
|
||||
stack.getOrCreateTag().putInt("customMag", customMag);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package com.atsuishio.superbwarfare.item.gun.rifle;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.AK47ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.AnimatedItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||
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.model.HumanoidModel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -191,13 +191,11 @@ public class AK47Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 2.75;
|
||||
default -> stack.getOrCreateTag().getDouble("CustomZoom");
|
||||
default -> GunsTool.getGunDoubleTag(stack, "CustomZoom", 0);
|
||||
};
|
||||
|
||||
stack.getOrCreateTag().putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
||||
stack.getOrCreateTag().putDouble("CustomZoom", customZoom);
|
||||
|
||||
GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom);
|
||||
stack.getOrCreateTag().putInt("customMag", customMag);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package com.atsuishio.superbwarfare.item.gun.rifle;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
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.AnimatedItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.AnimatedItem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -173,13 +173,11 @@ public class Hk416Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 2.25;
|
||||
default -> stack.getOrCreateTag().getDouble("CustomZoom");
|
||||
default -> GunsTool.getGunDoubleTag(stack, "CustomZoom", 0);
|
||||
};
|
||||
|
||||
stack.getOrCreateTag().putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
||||
stack.getOrCreateTag().putDouble("CustomZoom", customZoom);
|
||||
|
||||
GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom);
|
||||
stack.getOrCreateTag().putInt("customMag", customMag);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package com.atsuishio.superbwarfare.item.gun.rifle;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
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.AnimatedItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.AnimatedItem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -191,15 +191,12 @@ public class M4Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> stack.getOrCreateTag().getBoolean("ScopeAlt") ? 0 : 2.75;
|
||||
default -> stack.getOrCreateTag().getDouble("CustomZoom");
|
||||
default -> GunsTool.getGunDoubleTag(stack, "CustomZoom", 0);
|
||||
};
|
||||
|
||||
stack.getOrCreateTag().putBoolean("CanSwitchScope", scopeType == 2);
|
||||
|
||||
stack.getOrCreateTag().putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
||||
stack.getOrCreateTag().putDouble("CustomZoom", customZoom);
|
||||
|
||||
GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom);
|
||||
stack.getOrCreateTag().putInt("customMag", customMag);
|
||||
}
|
||||
|
||||
|
|
|
@ -176,13 +176,11 @@ public class Mk14Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 2.25;
|
||||
default -> stack.getOrCreateTag().getDouble("CustomZoom");
|
||||
default -> GunsTool.getGunDoubleTag(stack, "CustomZoom", 0);
|
||||
};
|
||||
|
||||
stack.getOrCreateTag().putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
||||
stack.getOrCreateTag().putDouble("CustomZoom", customZoom);
|
||||
|
||||
GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom);
|
||||
stack.getOrCreateTag().putInt("customMag", customMag);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package com.atsuishio.superbwarfare.item.gun.rifle;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.Qbz95ItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.AnimatedItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||
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.model.HumanoidModel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -179,13 +179,11 @@ public class Qbz95Item extends GunItem implements GeoItem, AnimatedItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 2.15;
|
||||
default -> stack.getOrCreateTag().getDouble("CustomZoom");
|
||||
default -> GunsTool.getGunDoubleTag(stack, "CustomZoom", 0);
|
||||
};
|
||||
|
||||
stack.getOrCreateTag().putBoolean("CanAdjustZoomFov", scopeType == 3);
|
||||
|
||||
stack.getOrCreateTag().putDouble("CustomZoom", customZoom);
|
||||
|
||||
GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom);
|
||||
stack.getOrCreateTag().putInt("customMag", customMag);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package com.atsuishio.superbwarfare.item.gun.smg;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
import com.atsuishio.superbwarfare.client.renderer.item.VectorItemRenderer;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.AnimatedItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||
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.model.HumanoidModel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -153,11 +153,10 @@ public class VectorItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
double customZoom = switch (scopeType) {
|
||||
case 0, 1 -> 0;
|
||||
case 2 -> 0.75;
|
||||
default -> stack.getOrCreateTag().getDouble("CustomZoom");
|
||||
default -> GunsTool.getGunDoubleTag(stack, "CustomZoom", 0);
|
||||
};
|
||||
|
||||
|
||||
stack.getOrCreateTag().putDouble("CustomZoom", customZoom);
|
||||
GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom);
|
||||
stack.getOrCreateTag().putInt("customMag", customMag);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModMobEffects;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import net.minecraft.client.CameraType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
|
@ -60,7 +61,7 @@ public class MouseHandlerMixin {
|
|||
return original;
|
||||
}
|
||||
|
||||
double zoom = 1.25 + stack.getOrCreateTag().getDouble("CustomZoom");
|
||||
double zoom = 1.25 + GunsTool.getGunDoubleTag(stack, "CustomZoom", 0);
|
||||
float customSens = (float) stack.getOrCreateTag().getInt("sensitivity");
|
||||
|
||||
if (!player.getMainHandItem().isEmpty() && mc.options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||
|
|
|
@ -41,7 +41,6 @@ public class AdjustZoomFovMessage {
|
|||
if (!stack.is(ModTags.Items.GUN)) {
|
||||
return;
|
||||
}
|
||||
var tag = stack.getOrCreateTag();
|
||||
|
||||
if (stack.is(ModItems.MINIGUN.get())) {
|
||||
double minRpm = 300;
|
||||
|
@ -67,8 +66,10 @@ public class AdjustZoomFovMessage {
|
|||
} else {
|
||||
double minZoom = GunsTool.getGunDoubleTag(stack, "MinZoom", 0) - 1.25;
|
||||
double maxZoom = GunsTool.getGunDoubleTag(stack, "MaxZoom", 0) - 1.25;
|
||||
tag.putDouble("CustomZoom", Mth.clamp(tag.getDouble("CustomZoom") + 0.5 * message.scroll, minZoom, maxZoom));
|
||||
if (tag.getDouble("CustomZoom") > minZoom && tag.getDouble("CustomZoom") < maxZoom) {
|
||||
double customZoom = GunsTool.getGunDoubleTag(stack, "CustomZoom", 0);
|
||||
GunsTool.setGunDoubleTag(stack, "CustomZoom", Mth.clamp(customZoom + 0.5 * message.scroll, minZoom, maxZoom));
|
||||
if (GunsTool.getGunDoubleTag(stack, "CustomZoom", 0) > minZoom &&
|
||||
GunsTool.getGunDoubleTag(stack, "CustomZoom", 0) < maxZoom) {
|
||||
SoundTool.playLocalSound(player, ModSounds.ADJUST_FOV.get(), 1f, 0.7f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class GunsTool {
|
|||
// TODO 临时使用,移植完毕后删除
|
||||
private static final Set<String> STRING_SET = Set.of("EmptyReloadTime", "FireMode", "Weight", "SoundRadius", "BurstSize", "ProjectileAmount",
|
||||
"Spread", "NormalReloadTime", "Headshot", "Semi", "Burst", "Auto", "RecoilX", "RecoilY", "Velocity", "Damage", "BypassesArmor",
|
||||
"RPM", "Magazine", "MinZoom", "MaxZoom");
|
||||
"RPM", "Magazine", "MinZoom", "MaxZoom", "CustomZoom");
|
||||
|
||||
public static void initGun(Level level, ItemStack stack, String location) {
|
||||
if (level.getServer() == null) return;
|
||||
|
|
Loading…
Add table
Reference in a new issue