添加加特林调整射速的功能
This commit is contained in:
parent
ecbca1a2ed
commit
e118632e3c
10 changed files with 130 additions and 50 deletions
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2024-11-08T20:06:16.3248238 Tags for minecraft:item mod id superbwarfare
|
||||
// 1.20.1 2024-11-08T20:57:48.1853892 Tags for minecraft:item mod id superbwarfare
|
||||
cf8d49a8d2872286d1a9c3d4a7e1c2b7690db0b8 data/forge/tags/items/dusts.json
|
||||
0fa06c2ff83bf09797e3ddff90f62d1124e645b4 data/forge/tags/items/dusts/coal_coke.json
|
||||
295ddf906b7133a0558d03e9a60eea18281fe430 data/forge/tags/items/dusts/iron.json
|
||||
|
@ -36,7 +36,7 @@ af6fd64b4a685c353f243763db268f7b2304c009 data/forge/tags/items/storage_blocks/le
|
|||
dff9ff6d6637951191906cb55a210ae5a3ad5cd6 data/superbwarfare/tags/items/extra_one_ammo.json
|
||||
52598e22974c8da0d2852defe4c9005e1d67744b data/superbwarfare/tags/items/gun.json
|
||||
62eb408544731ce4cfcd119d8a6cc74731189ac0 data/superbwarfare/tags/items/handgun.json
|
||||
835c071e873ee7061e36e1361026897b39487bd6 data/superbwarfare/tags/items/has_shell_effect.json
|
||||
49fbb8c030fdfafec1f291acc1cdff406c777c7e data/superbwarfare/tags/items/has_shell_effect.json
|
||||
dae3f86663e841d336efff9d23d8910aa7247be5 data/superbwarfare/tags/items/is_auto_weapon.json
|
||||
68ec25b0ccd68abbbe2f33ab7097572c2140c9da data/superbwarfare/tags/items/launcher.json
|
||||
b404c6fd99d2ca68c6738f225cb7d68ee443c10a data/superbwarfare/tags/items/machine_gun.json
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
"superbwarfare:glock_17",
|
||||
"superbwarfare:glock_18",
|
||||
"superbwarfare:m_1911",
|
||||
"superbwarfare:qbz_95",
|
||||
"superbwarfare:minigun"
|
||||
"superbwarfare:qbz_95"
|
||||
]
|
||||
}
|
|
@ -143,7 +143,7 @@ public class ClickHandler {
|
|||
if (tag.getBoolean("CanSwitchScope")) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new SwitchScopeMessage(scroll));
|
||||
}
|
||||
else if (tag.getBoolean("CanAdjustZoomFov")) {
|
||||
else if (tag.getBoolean("CanAdjustZoomFov") || stack.is(ModItems.MINIGUN.get())) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new AdjustZoomFovMessage(scroll));
|
||||
}
|
||||
event.setCanceled(true);
|
||||
|
|
|
@ -61,7 +61,9 @@ public class MinigunItemModel extends GeoModel<MinigunItem> {
|
|||
|
||||
heat_barrels.setScaleZ(4 * heat);
|
||||
|
||||
gun.setRotZ(gun.getRotZ() + times * -0.18f * ClientEventHandler.miniGunRot);
|
||||
int rpm = stack.getOrCreateTag().getInt("rpm");
|
||||
|
||||
gun.setRotZ(gun.getRotZ() + times * -0.07f * ((float) rpm / 1200) * ClientEventHandler.miniGunRot);
|
||||
|
||||
shen.setPosX((float) (0.75f * ClientEventHandler.recoilHorizon * fpz * fp));
|
||||
shen.setPosY((float) (-0.03f * fp - 0.06f * fr));
|
||||
|
|
|
@ -27,6 +27,7 @@ public class AmmoBarOverlay {
|
|||
private static final ResourceLocation AUTO = ModUtils.loc("textures/gun_icon/fire_mode/auto.png");
|
||||
private static final ResourceLocation TOP = ModUtils.loc("textures/gun_icon/fire_mode/top.png");
|
||||
private static final ResourceLocation DIR = ModUtils.loc("textures/gun_icon/fire_mode/dir.png");
|
||||
private static final ResourceLocation MOUSE = ModUtils.loc("textures/gun_icon/fire_mode/mouse.png");
|
||||
|
||||
private static boolean creativeAmmo() {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
@ -69,14 +70,16 @@ public class AmmoBarOverlay {
|
|||
16);
|
||||
|
||||
// 渲染开火模式切换按键
|
||||
event.getGuiGraphics().drawString(
|
||||
Minecraft.getInstance().font,
|
||||
"[" + ModKeyMappings.FIRE_MODE.getKey().getDisplayName().getString() + "]",
|
||||
w - 111.5f,
|
||||
h - 20,
|
||||
0xFFFFFF,
|
||||
false
|
||||
);
|
||||
if (stack.getItem() != ModItems.MINIGUN.get()) {
|
||||
event.getGuiGraphics().drawString(
|
||||
Minecraft.getInstance().font,
|
||||
"[" + ModKeyMappings.FIRE_MODE.getKey().getDisplayName().getString() + "]",
|
||||
w - 111.5f,
|
||||
h - 20,
|
||||
0xFFFFFF,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
// 渲染开火模式
|
||||
ResourceLocation fireMode = getFireMode(stack);
|
||||
|
@ -85,25 +88,50 @@ public class AmmoBarOverlay {
|
|||
fireMode = stack.getOrCreateTag().getBoolean("TopMode") ? TOP : DIR;
|
||||
}
|
||||
|
||||
event.getGuiGraphics().blit(fireMode,
|
||||
w - 95,
|
||||
h - 21,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8);
|
||||
if (stack.getItem() == ModItems.MINIGUN.get()) {
|
||||
fireMode = MOUSE;
|
||||
// 渲染加特林射速
|
||||
event.getGuiGraphics().drawString(
|
||||
Minecraft.getInstance().font,
|
||||
stack.getOrCreateTag().getInt("rpm") + " RPM",
|
||||
w - 111f,
|
||||
h - 20,
|
||||
0xFFFFFF,
|
||||
false
|
||||
);
|
||||
|
||||
event.getGuiGraphics().blit(LINE,
|
||||
w - 95,
|
||||
h - 16,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8);
|
||||
event.getGuiGraphics().blit(fireMode,
|
||||
w - 126,
|
||||
h - 22,
|
||||
0,
|
||||
0,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12);
|
||||
} else {
|
||||
event.getGuiGraphics().blit(fireMode,
|
||||
w - 95,
|
||||
h - 21,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8);
|
||||
}
|
||||
|
||||
if (stack.getItem() != ModItems.MINIGUN.get()) {
|
||||
event.getGuiGraphics().blit(LINE,
|
||||
w - 95,
|
||||
h - 16,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8);
|
||||
}
|
||||
|
||||
// 渲染当前弹药量
|
||||
poseStack.pushPose();
|
||||
|
|
|
@ -112,7 +112,7 @@ public class ModItemTagProvider extends ItemTagsProvider {
|
|||
|
||||
this.tag(ModTags.Items.HAS_SHELL_EFFECT).add(ModItems.AK_47.get(), ModItems.AK_12.get(), ModItems.SVD.get(), ModItems.M_60.get(), ModItems.MK_14.get(), ModItems.VECTOR.get(),
|
||||
ModItems.SKS.get(), ModItems.RPK.get(), ModItems.HK_416.get(), ModItems.AA_12.get(), ModItems.M_4.get(), ModItems.DEVOTION.get(), ModItems.GLOCK_17.get(),
|
||||
ModItems.GLOCK_18.get(), ModItems.M_1911.get(), ModItems.QBZ_95.get(), ModItems.MINIGUN.get());
|
||||
ModItems.GLOCK_18.get(), ModItems.M_1911.get(), ModItems.QBZ_95.get());
|
||||
|
||||
this.tag(ModTags.Items.MILITARY_ARMOR).add(ModItems.RU_CHEST_6B43.get(), ModItems.US_CHEST_IOTV.get());
|
||||
|
||||
|
|
|
@ -170,7 +170,12 @@ public class ClientEventHandler {
|
|||
if (stack.getItem() == ModItems.MINIGUN.get()) {
|
||||
if (holdFire || GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
|
||||
miniGunRot = Math.min(miniGunRot + 5, 21);
|
||||
player.playSound(ModSounds.MINIGUN_ROT.get(), 1, 1);
|
||||
float rpm = 1;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,7 +265,11 @@ public class ClientEventHandler {
|
|||
&& stack.getOrCreateTag().getInt("ammo") > 0
|
||||
&& !player.getCooldowns().isOnCooldown(stack.getItem())
|
||||
&& !stack.getOrCreateTag().getBoolean("need_bolt_action"))
|
||||
|| (stack.is(ModItems.MINIGUN.get()) && !player.isSprinting() && stack.getOrCreateTag().getDouble("overheat") == 0 && !player.getCooldowns().isOnCooldown(stack.getItem()) && miniGunRot >= 20
|
||||
|| (stack.is(ModItems.MINIGUN.get())
|
||||
&& !player.isSprinting()
|
||||
&& stack.getOrCreateTag().getDouble("overheat") == 0
|
||||
&& !player.getCooldowns().isOnCooldown(stack.getItem()) && miniGunRot >= 20
|
||||
&& ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).rifleAmmo > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())))
|
||||
))) {
|
||||
|
||||
if (mode == 0) {
|
||||
|
@ -352,6 +361,13 @@ public class ClientEventHandler {
|
|||
if (perk == ModPerks.BEAST_BULLET.get()) {
|
||||
player.playSound(ModSounds.HENG.get(), 1f, 1f);
|
||||
}
|
||||
|
||||
double shooterHeight = player.getEyePosition().distanceTo((Vec3.atLowerCornerOf(player.level().clip( new ClipContext(player.getEyePosition(), player.getEyePosition().add(new Vec3(0, -1 , 0).scale(10)),
|
||||
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos())));
|
||||
|
||||
ModUtils.queueClientWork((int) (1 + 1.5 * shooterHeight), () -> {
|
||||
player.playSound(ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
|
||||
});
|
||||
}
|
||||
|
||||
handleClientShoot();
|
||||
|
@ -709,6 +725,12 @@ public class ClientEventHandler {
|
|||
fireRotTimer += 0.18 * (1.9 - fireRotTimer) * times;
|
||||
}
|
||||
|
||||
double rpm = 1;
|
||||
|
||||
if (entity.getMainHandItem().is(ModItems.MINIGUN.get())) {
|
||||
rpm = (double) entity.getMainHandItem().getOrCreateTag().getInt("rpm") / 1800;
|
||||
}
|
||||
|
||||
float[] shake = {0, 0};
|
||||
shake[0] = (float) (1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 0, 1) * (2 * Math.random() - 1));
|
||||
shake[1] = (float) (4.2 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 3 * Mth.clamp(0.5 - fireRotTimer, 0, 0.5) * (2 * Math.random() - 1));
|
||||
|
@ -716,13 +738,13 @@ public class ClientEventHandler {
|
|||
if (0 < fireRotTimer && fireRotTimer < 1.732) {
|
||||
fireRot = 1 / 6.3 * (fireRotTimer - 0.5) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2));
|
||||
if (recoilY > 0) {
|
||||
event.setYaw(yaw - shake[0]);
|
||||
event.setPitch(pitch + shake[0]);
|
||||
event.setRoll(roll + shake[1]);
|
||||
event.setYaw((float) (yaw - shake[0] * rpm));
|
||||
event.setPitch((float) (pitch + shake[0] * rpm));
|
||||
event.setRoll((float) (roll + shake[1] * rpm));
|
||||
} else if (recoilY <= 0) {
|
||||
event.setYaw(yaw + shake[0]);
|
||||
event.setPitch(pitch - shake[0]);
|
||||
event.setRoll(roll - shake[1]);
|
||||
event.setYaw((float) (yaw + shake[0] * rpm));
|
||||
event.setPitch((float) (pitch - shake[0] * rpm));
|
||||
event.setRoll((float) (roll - shake[1] * rpm));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -786,6 +808,12 @@ public class ClientEventHandler {
|
|||
|
||||
double cusWeight = player.getMainHandItem().getOrCreateTag().getDouble("CustomWeight");
|
||||
|
||||
double rpm = 1;
|
||||
|
||||
if (player.getMainHandItem().is(ModItems.MINIGUN.get())) {
|
||||
rpm = (double) player.getMainHandItem().getOrCreateTag().getInt("rpm") / 1800;
|
||||
}
|
||||
|
||||
float gunRecoilX = (float) tag.getDouble("recoil_x") * 60;
|
||||
|
||||
recoilHorizon = Mth.lerp(0.2 * times, recoilHorizon, 0) + recoilY;
|
||||
|
@ -806,7 +834,7 @@ public class ClientEventHandler {
|
|||
|
||||
// 水平后座
|
||||
|
||||
float newYaw = player.getYRot() - (float) (0.6 * recoilHorizon * pose * times * (0.5 + fireSpread) * recoil * (1 - 0.06 * cusWeight) * gripRecoilX);
|
||||
float newYaw = player.getYRot() - (float) (0.6 * recoilHorizon * pose * times * (0.5 + fireSpread) * recoil * (1 - 0.06 * cusWeight) * gripRecoilX * rpm);
|
||||
player.setYRot(newYaw);
|
||||
player.yRotO = player.getYRot();
|
||||
|
||||
|
@ -814,7 +842,7 @@ public class ClientEventHandler {
|
|||
|
||||
// 竖直后座
|
||||
if (0 < recoilTime && recoilTime < 0.5) {
|
||||
float newPitch = (float) (player.getXRot() - 0.02f * gunRecoilX * times * recoil * (1 - 0.06 * cusWeight) * gripRecoilY);
|
||||
float newPitch = (float) (player.getXRot() - 0.02f * gunRecoilX * times * recoil * (1 - 0.06 * cusWeight) * gripRecoilY * rpm);
|
||||
player.setXRot(newPitch);
|
||||
player.xRotO = player.getXRot();
|
||||
}
|
||||
|
@ -830,7 +858,7 @@ public class ClientEventHandler {
|
|||
}
|
||||
|
||||
if (0 < recoilTime && recoilTime < 2.5) {
|
||||
float newPitch = player.getXRot() - (float) (1.5 * pose * gunRecoilX * (sinRes + Mth.clamp(0.5 - recoilTime, 0, 0.5)) * times * (0.5 + fireSpread) * recoil * (1 - 0.06 * cusWeight) * gripRecoilY);
|
||||
float newPitch = player.getXRot() - (float) (1.5 * pose * gunRecoilX * (sinRes + Mth.clamp(0.5 - recoilTime, 0, 0.5)) * times * (0.5 + fireSpread) * recoil * (1 - 0.06 * cusWeight) * gripRecoilY * rpm);
|
||||
player.setXRot(newPitch);
|
||||
player.xRotO = player.getXRot();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package net.mcreator.superbwarfare.network.message;
|
||||
|
||||
import net.mcreator.superbwarfare.init.ModItems;
|
||||
import net.mcreator.superbwarfare.init.ModSounds;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.tools.SoundTool;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -39,12 +41,33 @@ public class AdjustZoomFovMessage {
|
|||
}
|
||||
var tag = stack.getOrCreateTag();
|
||||
|
||||
if (stack.is(ModItems.MINIGUN.get())) {
|
||||
double minRpm = 300;
|
||||
double maxRpm = 2400;
|
||||
|
||||
double min_zoom = tag.getDouble("MinZoom") - 1.25;
|
||||
double max_zoom = tag.getDouble("MaxZoom") - 1.25;
|
||||
tag.putDouble("CustomZoom", Mth.clamp(tag.getDouble("CustomZoom") + 0.5 * message.scroll, min_zoom, max_zoom));
|
||||
if (tag.getDouble("CustomZoom") > min_zoom && tag.getDouble("CustomZoom") < max_zoom) {
|
||||
SoundTool.playLocalSound(player, ModSounds.ADJUST_FOV.get(), 1f, 0.7f);
|
||||
tag.putInt("rpm", (int) Mth.clamp(tag.getInt("rpm") + 50 * message.scroll, minRpm, maxRpm));
|
||||
if (tag.getInt("rpm") == 1150) {
|
||||
tag.putInt("rpm", 1145);
|
||||
}
|
||||
|
||||
if (tag.getInt("rpm") == 1195) {
|
||||
tag.putInt("rpm", 1200);
|
||||
}
|
||||
|
||||
if (tag.getInt("rpm") == 1095) {
|
||||
tag.putInt("rpm", 1100);
|
||||
}
|
||||
player.displayClientMessage(Component.literal("Rpm:" + new java.text.DecimalFormat("##").format(tag.getInt("rpm"))), true);
|
||||
if (tag.getInt("rpm") > minRpm && tag.getInt("rpm") < maxRpm) {
|
||||
SoundTool.playLocalSound(player, ModSounds.ADJUST_FOV.get(), 1f, 0.7f);
|
||||
}
|
||||
} else {
|
||||
double min_zoom = tag.getDouble("MinZoom") - 1.25;
|
||||
double max_zoom = tag.getDouble("MaxZoom") - 1.25;
|
||||
tag.putDouble("CustomZoom", Mth.clamp(tag.getDouble("CustomZoom") + 0.5 * message.scroll, min_zoom, max_zoom));
|
||||
if (tag.getDouble("CustomZoom") > min_zoom && tag.getDouble("CustomZoom") < max_zoom) {
|
||||
SoundTool.playLocalSound(player, ModSounds.ADJUST_FOV.get(), 1f, 0.7f);
|
||||
}
|
||||
}
|
||||
});
|
||||
context.get().setPacketHandled(true);
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 270 B |
|
@ -10,5 +10,5 @@
|
|||
"projectile_amount": 1,
|
||||
"BypassesArmor": 0.3,
|
||||
"SoundRadius": 14,
|
||||
"rpm": 2400
|
||||
"rpm": 1200
|
||||
}
|
Loading…
Add table
Reference in a new issue