优化NBT#RPM
This commit is contained in:
parent
46f9428889
commit
2668a19e72
25 changed files with 48 additions and 47 deletions
|
@ -4,6 +4,7 @@ import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.item.gun.machinegun.MinigunItem;
|
import com.atsuishio.superbwarfare.item.gun.machinegun.MinigunItem;
|
||||||
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -56,7 +57,7 @@ public class MinigunItemModel extends GeoModel<MinigunItem> {
|
||||||
double fp = ClientEventHandler.firePos;
|
double fp = ClientEventHandler.firePos;
|
||||||
double fr = ClientEventHandler.fireRot;
|
double fr = ClientEventHandler.fireRot;
|
||||||
|
|
||||||
int rpm = stack.getOrCreateTag().getInt("rpm");
|
int rpm = GunsTool.getGunIntTag(stack, "RPM", 0);
|
||||||
|
|
||||||
gun.setRotZ(gun.getRotZ() + times * -0.07f * ((float) rpm / 1200) * ClientEventHandler.miniGunRot);
|
gun.setRotZ(gun.getRotZ() + times * -0.07f * ((float) rpm / 1200) * ClientEventHandler.miniGunRot);
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package com.atsuishio.superbwarfare.client.screens;
|
package com.atsuishio.superbwarfare.client.screens;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.init.ModKeyMappings;
|
|
||||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModKeyMappings;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
|
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||||
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -95,7 +95,7 @@ public class AmmoBarOverlay {
|
||||||
// 渲染加特林射速
|
// 渲染加特林射速
|
||||||
event.getGuiGraphics().drawString(
|
event.getGuiGraphics().drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
stack.getOrCreateTag().getInt("rpm") + " RPM",
|
GunsTool.getGunIntTag(stack, "RPM", 0) + " RPM",
|
||||||
w - 111f,
|
w - 111f,
|
||||||
h - 20,
|
h - 20,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
|
@ -125,7 +125,7 @@ public class AmmoBarOverlay {
|
||||||
} else {
|
} else {
|
||||||
event.getGuiGraphics().drawString(
|
event.getGuiGraphics().drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
stack.getOrCreateTag().getBoolean("DA") ? Component.translatable("des.superbwarfare.revolver.sa").withStyle(ChatFormatting.BOLD) : Component.translatable("des.superbwarfare.revolver.da").withStyle(ChatFormatting.BOLD),
|
stack.getOrCreateTag().getBoolean("DA") ? Component.translatable("des.superbwarfare.revolver.sa").withStyle(ChatFormatting.BOLD) : Component.translatable("des.superbwarfare.revolver.da").withStyle(ChatFormatting.BOLD),
|
||||||
w - 96,
|
w - 96,
|
||||||
h - 20,
|
h - 20,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
|
||||||
} else {
|
} else {
|
||||||
return Component.translatable("des.superbwarfare.tips.rpm").withStyle(ChatFormatting.GRAY)
|
return Component.translatable("des.superbwarfare.tips.rpm").withStyle(ChatFormatting.GRAY)
|
||||||
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
.append(Component.literal("").withStyle(ChatFormatting.RESET))
|
||||||
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getDouble(stack, "rpm", 0) + ItemNBTTool.getDouble(stack, "customRpm", 0)))
|
.append(Component.literal(new DecimalFormat("##").format(GunsTool.getGunIntTag(stack, "RPM", 0) + ItemNBTTool.getDouble(stack, "customRpm", 0)))
|
||||||
.withStyle(ChatFormatting.GREEN));
|
.withStyle(ChatFormatting.GREEN));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,14 +192,10 @@ public class ClientEventHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (stack.getItem() == ModItems.MINIGUN.get()) {
|
if (stack.is(ModItems.MINIGUN.get())) {
|
||||||
if (holdFire || zoom) {
|
if (holdFire || zoom) {
|
||||||
miniGunRot = Math.min(miniGunRot + 5, 21);
|
miniGunRot = Math.min(miniGunRot + 5, 21);
|
||||||
float rpm = 1;
|
float rpm = (float) GunsTool.getGunIntTag(stack, "RPM", 0) / 3600;
|
||||||
|
|
||||||
if (player.getMainHandItem().is(ModItems.MINIGUN.get())) {
|
|
||||||
rpm = (float) player.getMainHandItem().getOrCreateTag().getInt("rpm") / 3600;
|
|
||||||
}
|
|
||||||
player.playSound(ModSounds.MINIGUN_ROT.get(), 1, 0.7f + rpm);
|
player.playSound(ModSounds.MINIGUN_ROT.get(), 1, 0.7f + rpm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +265,7 @@ public class ClientEventHandler {
|
||||||
cantFireTime = Mth.clamp(cantFireTime - 6 * speed * times, 0, 40);
|
cantFireTime = Mth.clamp(cantFireTime - 6 * speed * times, 0, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rpm = (int) (stack.getOrCreateTag().getDouble("rpm") + customRpm);
|
int rpm = GunsTool.getGunIntTag(stack, "RPM", 0) + customRpm;
|
||||||
if (rpm == 0) {
|
if (rpm == 0) {
|
||||||
rpm = 600;
|
rpm = 600;
|
||||||
}
|
}
|
||||||
|
@ -900,8 +896,8 @@ public class ClientEventHandler {
|
||||||
|
|
||||||
double rpm = 1;
|
double rpm = 1;
|
||||||
|
|
||||||
if (entity.getMainHandItem().is(ModItems.MINIGUN.get())) {
|
if (stack.is(ModItems.MINIGUN.get())) {
|
||||||
rpm = (double) entity.getMainHandItem().getOrCreateTag().getInt("rpm") / 1800;
|
rpm = (double) GunsTool.getGunIntTag(stack, "RPM", 0) / 1800;
|
||||||
}
|
}
|
||||||
|
|
||||||
float[] shake = {0, 0};
|
float[] shake = {0, 0};
|
||||||
|
@ -991,7 +987,7 @@ public class ClientEventHandler {
|
||||||
double rpm = 1;
|
double rpm = 1;
|
||||||
|
|
||||||
if (stack.is(ModItems.MINIGUN.get())) {
|
if (stack.is(ModItems.MINIGUN.get())) {
|
||||||
rpm = (double) stack.getOrCreateTag().getInt("rpm") / 1800;
|
rpm = (double) GunsTool.getGunIntTag(stack, "RPM", 0) / 1800;
|
||||||
}
|
}
|
||||||
|
|
||||||
float gunRecoilX = (float) GunsTool.getGunDoubleTag(stack, "RecoilX", 0) * 60;
|
float gunRecoilX = (float) GunsTool.getGunDoubleTag(stack, "RecoilX", 0) * 60;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.network.message;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -11,6 +12,7 @@ import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class AdjustZoomFovMessage {
|
public class AdjustZoomFovMessage {
|
||||||
|
@ -45,20 +47,21 @@ public class AdjustZoomFovMessage {
|
||||||
double minRpm = 300;
|
double minRpm = 300;
|
||||||
double maxRpm = 2400;
|
double maxRpm = 2400;
|
||||||
|
|
||||||
tag.putInt("rpm", (int) Mth.clamp(tag.getInt("rpm") + 50 * message.scroll, minRpm, maxRpm));
|
GunsTool.setGunIntTag(stack, "RPM", (int) Mth.clamp(GunsTool.getGunIntTag(stack, "RPM", 0) + 50 * message.scroll, minRpm, maxRpm));
|
||||||
if (tag.getInt("rpm") == 1150) {
|
if (GunsTool.getGunIntTag(stack, "RPM", 0) == 1150) {
|
||||||
tag.putInt("rpm", 1145);
|
GunsTool.setGunIntTag(stack, "RPM", 1145);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getInt("rpm") == 1195) {
|
if (GunsTool.getGunIntTag(stack, "RPM", 0) == 1195) {
|
||||||
tag.putInt("rpm", 1200);
|
GunsTool.setGunIntTag(stack, "RPM", 1200);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getInt("rpm") == 1095) {
|
if (GunsTool.getGunIntTag(stack, "RPM", 0) == 1095) {
|
||||||
tag.putInt("rpm", 1100);
|
GunsTool.setGunIntTag(stack, "RPM", 1100);
|
||||||
}
|
}
|
||||||
player.displayClientMessage(Component.literal("Rpm:" + new java.text.DecimalFormat("##").format(tag.getInt("rpm"))), true);
|
player.displayClientMessage(Component.literal("RPM: " + new DecimalFormat("##").format(GunsTool.getGunIntTag(stack, "RPM", 0))), true);
|
||||||
if (tag.getInt("rpm") > minRpm && tag.getInt("rpm") < maxRpm) {
|
int rpm = GunsTool.getGunIntTag(stack, "RPM", 0);
|
||||||
|
if (rpm > minRpm && rpm < maxRpm) {
|
||||||
SoundTool.playLocalSound(player, ModSounds.ADJUST_FOV.get(), 1f, 0.7f);
|
SoundTool.playLocalSound(player, ModSounds.ADJUST_FOV.get(), 1f, 0.7f);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -55,7 +55,8 @@ public class GunsTool {
|
||||||
|
|
||||||
// TODO 临时使用,移植完毕后删除
|
// TODO 临时使用,移植完毕后删除
|
||||||
private static final Set<String> STRING_SET = Set.of("EmptyReloadTime", "FireMode", "Weight", "SoundRadius", "BurstSize", "ProjectileAmount",
|
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");
|
"Spread", "NormalReloadTime", "Headshot", "Semi", "Burst", "Auto", "RecoilX", "RecoilY", "Velocity", "Damage", "BypassesArmor",
|
||||||
|
"RPM");
|
||||||
|
|
||||||
public static void initGun(Level level, ItemStack stack, String location) {
|
public static void initGun(Level level, ItemStack stack, String location) {
|
||||||
if (level.getServer() == null) return;
|
if (level.getServer() == null) return;
|
||||||
|
|
|
@ -15,5 +15,5 @@
|
||||||
"EmptyReloadTime": 85,
|
"EmptyReloadTime": 85,
|
||||||
"BypassesArmor": 0.05,
|
"BypassesArmor": 0.05,
|
||||||
"SoundRadius": 18,
|
"SoundRadius": 18,
|
||||||
"rpm": 360
|
"RPM": 360
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,5 +14,5 @@
|
||||||
"EmptyReloadTime": 83,
|
"EmptyReloadTime": 83,
|
||||||
"BypassesArmor": 0.01,
|
"BypassesArmor": 0.01,
|
||||||
"SoundRadius": 16,
|
"SoundRadius": 16,
|
||||||
"rpm": 600
|
"RPM": 600
|
||||||
}
|
}
|
|
@ -16,5 +16,5 @@
|
||||||
"EmptyReloadTime": 58,
|
"EmptyReloadTime": 58,
|
||||||
"BypassesArmor": 0.23,
|
"BypassesArmor": 0.23,
|
||||||
"SoundRadius": 12,
|
"SoundRadius": 12,
|
||||||
"rpm": 700
|
"RPM": 700
|
||||||
}
|
}
|
|
@ -16,5 +16,5 @@
|
||||||
"EmptyReloadTime": 65,
|
"EmptyReloadTime": 65,
|
||||||
"BypassesArmor": 0.2,
|
"BypassesArmor": 0.2,
|
||||||
"SoundRadius": 14,
|
"SoundRadius": 14,
|
||||||
"rpm": 600
|
"RPM": 600
|
||||||
}
|
}
|
|
@ -14,5 +14,5 @@
|
||||||
"EmptyReloadTime": 95,
|
"EmptyReloadTime": 95,
|
||||||
"BypassesArmor": 0.25,
|
"BypassesArmor": 0.25,
|
||||||
"SoundRadius": 13,
|
"SoundRadius": 13,
|
||||||
"rpm": 400
|
"RPM": 400
|
||||||
}
|
}
|
|
@ -13,5 +13,5 @@
|
||||||
"EmptyReloadTime": 35,
|
"EmptyReloadTime": 35,
|
||||||
"BypassesArmor": 0.15,
|
"BypassesArmor": 0.15,
|
||||||
"SoundRadius": 8,
|
"SoundRadius": 8,
|
||||||
"rpm": 400
|
"RPM": 400
|
||||||
}
|
}
|
|
@ -14,5 +14,5 @@
|
||||||
"EmptyReloadTime": 35,
|
"EmptyReloadTime": 35,
|
||||||
"BypassesArmor": 0.15,
|
"BypassesArmor": 0.15,
|
||||||
"SoundRadius": 8,
|
"SoundRadius": 8,
|
||||||
"rpm": 1300
|
"RPM": 1300
|
||||||
}
|
}
|
|
@ -16,5 +16,5 @@
|
||||||
"EmptyReloadTime": 64,
|
"EmptyReloadTime": 64,
|
||||||
"BypassesArmor": 0.25,
|
"BypassesArmor": 0.25,
|
||||||
"SoundRadius": 14,
|
"SoundRadius": 14,
|
||||||
"rpm": 900
|
"RPM": 900
|
||||||
}
|
}
|
|
@ -13,5 +13,5 @@
|
||||||
"EmptyReloadTime": 35,
|
"EmptyReloadTime": 35,
|
||||||
"BypassesArmor": 0.2,
|
"BypassesArmor": 0.2,
|
||||||
"SoundRadius": 10,
|
"SoundRadius": 10,
|
||||||
"rpm": 400
|
"RPM": 400
|
||||||
}
|
}
|
|
@ -16,5 +16,5 @@
|
||||||
"EmptyReloadTime": 64,
|
"EmptyReloadTime": 64,
|
||||||
"BypassesArmor": 0.25,
|
"BypassesArmor": 0.25,
|
||||||
"SoundRadius": 14,
|
"SoundRadius": 14,
|
||||||
"rpm": 850
|
"RPM": 850
|
||||||
}
|
}
|
|
@ -13,5 +13,5 @@
|
||||||
"EmptyReloadTime": 133,
|
"EmptyReloadTime": 133,
|
||||||
"BypassesArmor": 0.25,
|
"BypassesArmor": 0.25,
|
||||||
"SoundRadius": 15,
|
"SoundRadius": 15,
|
||||||
"rpm": 600
|
"RPM": 600
|
||||||
}
|
}
|
|
@ -9,5 +9,5 @@
|
||||||
"FireMode": 2,
|
"FireMode": 2,
|
||||||
"BypassesArmor": 0.3,
|
"BypassesArmor": 0.3,
|
||||||
"SoundRadius": 14,
|
"SoundRadius": 14,
|
||||||
"rpm": 1200
|
"RPM": 1200
|
||||||
}
|
}
|
|
@ -16,5 +16,5 @@
|
||||||
"EmptyReloadTime": 71,
|
"EmptyReloadTime": 71,
|
||||||
"BypassesArmor": 0.4,
|
"BypassesArmor": 0.4,
|
||||||
"SoundRadius": 16,
|
"SoundRadius": 16,
|
||||||
"rpm": 700
|
"RPM": 700
|
||||||
}
|
}
|
|
@ -16,5 +16,5 @@
|
||||||
"EmptyReloadTime": 74,
|
"EmptyReloadTime": 74,
|
||||||
"BypassesArmor": 0.28,
|
"BypassesArmor": 0.28,
|
||||||
"SoundRadius": 13,
|
"SoundRadius": 13,
|
||||||
"rpm": 650
|
"RPM": 650
|
||||||
}
|
}
|
|
@ -14,5 +14,5 @@
|
||||||
"EmptyReloadTime": 95,
|
"EmptyReloadTime": 95,
|
||||||
"BypassesArmor": 0.23,
|
"BypassesArmor": 0.23,
|
||||||
"SoundRadius": 14,
|
"SoundRadius": 14,
|
||||||
"rpm": 600
|
"RPM": 600
|
||||||
}
|
}
|
|
@ -13,5 +13,5 @@
|
||||||
"EmptyReloadTime": 75,
|
"EmptyReloadTime": 75,
|
||||||
"BypassesArmor": 0.23,
|
"BypassesArmor": 0.23,
|
||||||
"SoundRadius": 16,
|
"SoundRadius": 16,
|
||||||
"rpm": 400
|
"RPM": 400
|
||||||
}
|
}
|
|
@ -14,5 +14,5 @@
|
||||||
"EmptyReloadTime": 70,
|
"EmptyReloadTime": 70,
|
||||||
"BypassesArmor": 0.45,
|
"BypassesArmor": 0.45,
|
||||||
"SoundRadius": 17,
|
"SoundRadius": 17,
|
||||||
"rpm": 300
|
"RPM": 300
|
||||||
}
|
}
|
|
@ -12,5 +12,5 @@
|
||||||
"EmptyReloadTime": 65,
|
"EmptyReloadTime": 65,
|
||||||
"BypassesArmor": 0.3,
|
"BypassesArmor": 0.3,
|
||||||
"SoundRadius": 10,
|
"SoundRadius": 10,
|
||||||
"rpm": 240
|
"RPM": 240
|
||||||
}
|
}
|
|
@ -16,5 +16,5 @@
|
||||||
"EmptyReloadTime": 64,
|
"EmptyReloadTime": 64,
|
||||||
"BypassesArmor": 0.15,
|
"BypassesArmor": 0.15,
|
||||||
"SoundRadius": 11,
|
"SoundRadius": 11,
|
||||||
"rpm": 1200
|
"RPM": 1200
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue