修复波塞克手部动画和无效发射bug
This commit is contained in:
parent
fede5d2a4c
commit
3c13f0753a
3 changed files with 22 additions and 18 deletions
|
@ -334,6 +334,7 @@ public class ClickHandler {
|
|||
player.playSound(ModSounds.TRIGGER_CLICK.get(), 1, 1);
|
||||
} else {
|
||||
player.playSound(ModSounds.BOCEK_PULL_1P.get(), 1, 1);
|
||||
handTimer = 0;
|
||||
}
|
||||
|
||||
if (!gunItem.useBackpackAmmo(stack) && data.ammo() <= 0 && data.reload.time() == 0) {
|
||||
|
@ -342,8 +343,12 @@ public class ClickHandler {
|
|||
ClientEventHandler.burstFireAmount = 0;
|
||||
}
|
||||
} else {
|
||||
PacketDistributor.sendToServer(new FireMessage(0));
|
||||
if ((!data.reloading() && !data.charging() && !data.bolt.needed()) && drawTime < 0.01) {
|
||||
PacketDistributor.sendToServer(new FireMessage(0, handTimer, zoom));
|
||||
if ((!data.reloading()
|
||||
&& !data.charging()
|
||||
&& !data.bolt.needed())
|
||||
&& drawTime < 0.01
|
||||
) {
|
||||
if (data.fireMode() == 1) {
|
||||
if (ClientEventHandler.burstFireAmount == 0) {
|
||||
ClientEventHandler.burstFireAmount = data.burstAmount();
|
||||
|
@ -358,7 +363,7 @@ public class ClickHandler {
|
|||
}
|
||||
|
||||
public static void handleWeaponFireRelease() {
|
||||
PacketDistributor.sendToServer(new FireMessage(1));
|
||||
PacketDistributor.sendToServer(new FireMessage(1, handTimer, zoom));
|
||||
ClientEventHandler.holdFire = false;
|
||||
ClientEventHandler.holdFireVehicle = false;
|
||||
ClientEventHandler.customRpm = 0;
|
||||
|
|
|
@ -1009,7 +1009,7 @@ public class ClientEventHandler {
|
|||
handleWeaponFire(event, living);
|
||||
handleWeaponShell();
|
||||
handleGunRecoil();
|
||||
handleBowPullAnimation(living);
|
||||
handleBowPullAnimation(living, stack);
|
||||
handleWeaponDraw(living);
|
||||
handlePlayerCamera(event);
|
||||
}
|
||||
|
@ -1420,10 +1420,10 @@ public class ClientEventHandler {
|
|||
event.setRoll((float) (roll + cameraRot[2] + (DisplayConfig.CAMERA_ROTATE.get() ? 0.35 : 0) * turnRot[2]));
|
||||
}
|
||||
|
||||
private static void handleBowPullAnimation(LivingEntity entity) {
|
||||
private static void handleBowPullAnimation(LivingEntity entity, ItemStack stack) {
|
||||
float times = 4 * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
|
||||
|
||||
if (holdFire) {
|
||||
if (holdFire && entity instanceof Player player && !player.getCooldowns().isOnCooldown(stack.getItem())) {
|
||||
pullTimer = Math.min(pullTimer + 0.024 * times, 1.4);
|
||||
bowTimer = Math.min(bowTimer + 0.018 * times, 1);
|
||||
handTimer = Math.min(handTimer + 0.018 * times, 1);
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.network.message.send;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.event.GunEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
|
@ -27,21 +26,25 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public record FireMessage(int msgType) implements CustomPacketPayload {
|
||||
public record FireMessage(int msgType, double power, boolean zoom) implements CustomPacketPayload {
|
||||
public static final Type<FireMessage> TYPE = new Type<>(Mod.loc("fire"));
|
||||
|
||||
public static final StreamCodec<ByteBuf, FireMessage> STREAM_CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.INT,
|
||||
FireMessage::msgType,
|
||||
ByteBufCodecs.DOUBLE,
|
||||
FireMessage::power,
|
||||
ByteBufCodecs.BOOL,
|
||||
FireMessage::zoom,
|
||||
FireMessage::new
|
||||
);
|
||||
|
||||
|
||||
public static void handler(FireMessage message, final IPayloadContext context) {
|
||||
pressAction(context.player(), message.msgType);
|
||||
pressAction(context.player(), message.msgType, message.power, message.zoom);
|
||||
}
|
||||
|
||||
public static void pressAction(Player player, int type) {
|
||||
public static void pressAction(Player player, int type, double power, boolean zoom) {
|
||||
if (player.isSpectator()) return;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!stack.is(ModTags.Items.GUN)) return;
|
||||
|
@ -59,19 +62,15 @@ public record FireMessage(int msgType) implements CustomPacketPayload {
|
|||
cap.edit = false;
|
||||
|
||||
// 按下开火
|
||||
if (!(stack.getItem() instanceof SpecialFireWeapon specialFireWeapon)) {
|
||||
player.setData(ModAttachments.PLAYER_VARIABLE, cap);
|
||||
cap.sync(player);
|
||||
return;
|
||||
}
|
||||
specialFireWeapon.fireOnPress(player, data, ClientEventHandler.zoom);
|
||||
if (!(stack.getItem() instanceof SpecialFireWeapon specialFireWeapon)) return;
|
||||
specialFireWeapon.fireOnPress(player, data, zoom);
|
||||
} else if (type == 1) {
|
||||
// 松开开火
|
||||
if (stack.getItem() instanceof SpecialFireWeapon specialFireWeapon) {
|
||||
if (specialFireWeapon instanceof BocekItem) {
|
||||
specialFireWeapon.fireOnRelease(player, data, ClientEventHandler.bowTimer, ClientEventHandler.zoom);
|
||||
specialFireWeapon.fireOnRelease(player, data, power, zoom);
|
||||
} else {
|
||||
specialFireWeapon.fireOnRelease(player, data, 0, ClientEventHandler.zoom);
|
||||
specialFireWeapon.fireOnRelease(player, data, 0, zoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue