优化加特林的预热
This commit is contained in:
parent
ba0e12075d
commit
830714878c
3 changed files with 24 additions and 26 deletions
|
@ -61,7 +61,7 @@ public class MinigunItemModel extends GeoModel<MinigunItem> {
|
|||
|
||||
heat_barrels.setScaleZ(4 * heat);
|
||||
|
||||
gun.setRotZ((float) (gun.getRotZ() + times * -0.18f * stack.getOrCreateTag().getDouble("minigun_rotation")));
|
||||
gun.setRotZ(gun.getRotZ() + times * -0.18f * ClientEventHandler.miniGunRot);
|
||||
|
||||
shen.setPosX((float) (0.75f * ClientEventHandler.recoilHorizon * fpz * fp));
|
||||
shen.setPosY((float) (-0.03f * fp - 0.06f * fr));
|
||||
|
|
|
@ -121,6 +121,9 @@ public class ClientEventHandler {
|
|||
public static double chamberRot = 0;
|
||||
public static double actionMove = 0;
|
||||
|
||||
public static int miniGunRot = 0;
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public static void handleWeaponTurn(RenderHandEvent event) {
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
|
@ -157,6 +160,25 @@ public class ClientEventHandler {
|
|||
|| (player != null && player.isSprinting());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void handleClientTick(TickEvent.ClientTickEvent event) {
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (miniGunRot > 0) {
|
||||
miniGunRot -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void handleWeaponFire(TickEvent.RenderTickEvent event) {
|
||||
ClientLevel level = Minecraft.getInstance().level;
|
||||
|
@ -238,7 +260,7 @@ 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()) && stack.getOrCreateTag().getDouble("minigun_rotation") >= 10
|
||||
|| (stack.is(ModItems.MINIGUN.get()) && !player.isSprinting() && stack.getOrCreateTag().getDouble("overheat") == 0 && !player.getCooldowns().isOnCooldown(stack.getItem()) && miniGunRot >= 20
|
||||
))) {
|
||||
|
||||
if (mode == 0) {
|
||||
|
|
|
@ -46,7 +46,6 @@ public class GunEventHandler {
|
|||
|
||||
if (event.phase == TickEvent.Phase.END && stack.is(ModTags.Items.GUN)) {
|
||||
handleGunBolt(player);
|
||||
handleMiniGunFire(player);
|
||||
handleGunReload(player);
|
||||
handleGunSingleReload(player);
|
||||
handleSentinelCharge(player);
|
||||
|
@ -73,29 +72,6 @@ public class GunEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加特林开火流程
|
||||
*/
|
||||
private static void handleMiniGunFire(Player player) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (stack.getItem() != ModItems.MINIGUN.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var tag = stack.getOrCreateTag();
|
||||
|
||||
if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).holdFire || (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom) {
|
||||
if (tag.getDouble("minigun_rotation") < 10) {
|
||||
tag.putDouble("minigun_rotation", (tag.getDouble("minigun_rotation") + 1));
|
||||
}
|
||||
if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) {
|
||||
SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_ROT.get(), 2f, 1f);
|
||||
}
|
||||
} else if (tag.getDouble("minigun_rotation") > 0) {
|
||||
tag.putDouble("minigun_rotation", (tag.getDouble("minigun_rotation") - 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据武器的注册名来寻找音效并播放
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue