将触发抛壳移动到客户端
This commit is contained in:
parent
ca73dacbb9
commit
97e9c2a05f
3 changed files with 12 additions and 30 deletions
|
@ -106,7 +106,7 @@ public class ClientEventHandler {
|
|||
public static double drawTime = 1;
|
||||
|
||||
public static int shellIndex = 0;
|
||||
public static double[] shellIndexTime = {0, 0, 0, 0, 0};
|
||||
public static double[] shellIndexTime = {0, 0, 0, 0, 0, 0};
|
||||
public static double[] randomShell = {0, 0, 0};
|
||||
|
||||
public static double customZoom = 0;
|
||||
|
@ -316,6 +316,16 @@ public class ClientEventHandler {
|
|||
float gunRecoilY = (float) tag.getDouble("recoil_y") * 10;
|
||||
recoilY = (float) (2 * Math.random() - 1) * gunRecoilY;
|
||||
|
||||
if (shellIndex < 5) {
|
||||
shellIndex++;
|
||||
}
|
||||
|
||||
shellIndexTime[shellIndex] = 0.001;
|
||||
|
||||
randomShell[0] = (1 + 0.2 * (Math.random() - 0.5));
|
||||
randomShell[1] = (0.2 + (Math.random() - 0.5));
|
||||
randomShell[2] = (0.7 + (Math.random() - 0.5));
|
||||
|
||||
}
|
||||
|
||||
public static void playGunClientSounds(Player player) {
|
||||
|
@ -358,23 +368,6 @@ public class ClientEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public static void handleFireRecoilTimeMessage(double time, Supplier<NetworkEvent.Context> ctx) {
|
||||
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
if (player == null) return;
|
||||
if (!player.getMainHandItem().is(ModTags.Items.GUN)) return;
|
||||
|
||||
|
||||
// fireRecoilTime = time;
|
||||
shellIndex++;
|
||||
shellIndexTime[shellIndex] = 0.001;
|
||||
|
||||
randomShell[0] = (1 + 0.2 * (Math.random() - 0.5));
|
||||
randomShell[1] = (0.2 + (Math.random() - 0.5));
|
||||
randomShell[2] = (0.7 + (Math.random() - 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void handleWeaponBreathSway(TickEvent.RenderTickEvent event) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ShootClientMessage {
|
|||
|
||||
public static void handle(ShootClientMessage message, Supplier<NetworkEvent.Context> context) {
|
||||
context.get().enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT,
|
||||
() -> () -> ClientEventHandler.handleFireRecoilTimeMessage(message.time, context)));
|
||||
() -> ClientEventHandler::handleClientShoot));
|
||||
context.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.mcreator.superbwarfare.network.message;
|
||||
|
||||
import net.mcreator.superbwarfare.ModUtils;
|
||||
import net.mcreator.superbwarfare.init.ModItems;
|
||||
import net.mcreator.superbwarfare.init.ModPerks;
|
||||
import net.mcreator.superbwarfare.init.ModSounds;
|
||||
|
@ -22,7 +21,6 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -148,11 +146,6 @@ public class ShootMessage {
|
|||
}
|
||||
|
||||
playGunSounds(player);
|
||||
|
||||
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
|
||||
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
|
||||
}
|
||||
|
||||
}
|
||||
} else if (stack.is(ModItems.MINIGUN.get())) {
|
||||
var tag = stack.getOrCreateTag();
|
||||
|
@ -194,10 +187,6 @@ public class ShootMessage {
|
|||
}
|
||||
|
||||
tag.putInt("fire_animation", 2);
|
||||
|
||||
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
|
||||
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue