提取sensitivity属性
This commit is contained in:
parent
70dc4c5bb0
commit
532f380612
3 changed files with 6 additions and 6 deletions
|
@ -123,7 +123,7 @@ public class ClientMouseHandler {
|
|||
ItemStack stack = mc.player.getMainHandItem();
|
||||
if (stack.getItem() instanceof GunItem) {
|
||||
var data = GunData.from(stack);
|
||||
float customSens = (float) data.tag.getInt("sensitivity");
|
||||
float customSens = data.sensitivity.get();
|
||||
|
||||
if (!player.getMainHandItem().isEmpty() && mc.options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||
return original / Math.max((1 + (0.2 * (data.zoom() - (0.3 * customSens)) * ClientEventHandler.zoomTime)), 0.1);
|
||||
|
|
|
@ -76,6 +76,7 @@ public class GunData {
|
|||
holdOpen = new BooleanValue(data, "HoldOpen");
|
||||
hideBulletChain = new BooleanValue(data, "HideBulletChain");
|
||||
draw = new BooleanValue(data, "Draw");
|
||||
sensitivity = new IntValue(data, "Sensitivity");
|
||||
}
|
||||
|
||||
private CompoundTag getOrPut(String name) {
|
||||
|
@ -458,6 +459,7 @@ public class GunData {
|
|||
public final BooleanValue holdOpen;
|
||||
public final BooleanValue hideBulletChain;
|
||||
public final BooleanValue draw;
|
||||
public final IntValue sensitivity;
|
||||
|
||||
// 其他子级属性
|
||||
|
||||
|
|
|
@ -28,15 +28,13 @@ public record SensitivityMessage(boolean isAdd) implements CustomPacketPayload {
|
|||
if (!(stack.getItem() instanceof GunItem)) return;
|
||||
|
||||
var data = GunData.from(stack);
|
||||
final var tag = data.tag();
|
||||
if (message.isAdd) {
|
||||
tag.putInt("sensitivity", Math.min(10, tag.getInt("sensitivity") + 1));
|
||||
data.sensitivity.set(Math.min(10, data.sensitivity.get() + 1));
|
||||
} else {
|
||||
tag.putInt("sensitivity", Math.max(-10, tag.getInt("sensitivity") - 1));
|
||||
data.sensitivity.set(Math.max(-10, data.sensitivity.get() - 1));
|
||||
}
|
||||
data.save();
|
||||
player.displayClientMessage(Component.translatable("tips.superbwarfare.sensitivity", tag.getInt("sensitivity")), true);
|
||||
|
||||
player.displayClientMessage(Component.translatable("tips.superbwarfare.sensitivity", data.sensitivity.get()), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue