修复超高无法开火的问题

This commit is contained in:
17146 2025-01-01 20:37:45 +08:00
parent aedb3fe209
commit a8db1dd5e4
27 changed files with 29 additions and 73 deletions

View file

@ -17,6 +17,7 @@ import java.util.function.Supplier;
import static com.atsuishio.superbwarfare.entity.MortarEntity.PITCH;
public class AdjustMortarAngleMessage {
private final double scroll;
public AdjustMortarAngleMessage(double scroll) {

View file

@ -16,6 +16,7 @@ import java.text.DecimalFormat;
import java.util.function.Supplier;
public class AdjustZoomFovMessage {
private final double scroll;
public AdjustZoomFovMessage(double scroll) {

View file

@ -3,12 +3,12 @@ package com.atsuishio.superbwarfare.network.message;
import com.atsuishio.superbwarfare.network.ModVariables;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level;
import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class BreathMessage {
private final boolean type;
public BreathMessage(boolean type) {
@ -29,12 +29,6 @@ public class BreathMessage {
ServerPlayer player = context.getSender();
if (player != null) {
Level level = player.level();
if (!level.isLoaded(player.blockPosition())) {
return;
}
var cap = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
if (message.type && !cap.orElse(new ModVariables.PlayerVariables()).breathExhaustion && cap.orElse(new ModVariables.PlayerVariables()).zoom &&

View file

@ -9,6 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class ClientIndicatorMessage {
public final int type;
public final int value;

View file

@ -12,6 +12,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class DoubleJumpMessage {
private final boolean canDoubleJump;
public DoubleJumpMessage(boolean canDoubleJump) {
@ -37,10 +38,6 @@ public class DoubleJumpMessage {
double y = player.getY();
double z = player.getZ();
if (!level.isLoaded(player.blockPosition())) {
return;
}
level.playSound(null, BlockPos.containing(x, y, z), ModSounds.DOUBLE_JUMP.get(), SoundSource.BLOCKS, 1, 1);
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {

View file

@ -9,6 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class DrawClientMessage {
public boolean draw;
public DrawClientMessage(boolean draw) {

View file

@ -71,10 +71,8 @@ public class DroneFireMessage {
+ "," + offStack.getOrCreateTag().getInt("TargetY")
+ "," + offStack.getOrCreateTag().getInt("TargetZ") + "]")), true);
}
}
}
}
});
context.setPacketHandled(true);

View file

@ -10,6 +10,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class DroneMovementMessage {
private final int direction;
private final boolean clicked;

View file

@ -1,7 +1,7 @@
package com.atsuishio.superbwarfare.network.message;
import com.atsuishio.superbwarfare.tools.SoundTool;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.tools.SoundTool;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Player;
@ -11,6 +11,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class EditMessage {
private final int type;
public EditMessage(int type) {
@ -33,8 +34,6 @@ public class EditMessage {
public static void pressAction(Player player, int type) {
if (player == null) return;
if (!player.level().isLoaded(player.blockPosition()))
return;
ItemStack stack = player.getMainHandItem();

View file

@ -12,6 +12,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class EditModeMessage {
private final int type;
public EditModeMessage(int type) {
@ -35,8 +36,6 @@ public class EditModeMessage {
public static void pressAction(Player player, int type) {
if (player == null) return;
if (!player.level().isLoaded(player.blockPosition())) return;
if (type == 0) {
ItemStack mainHandItem = player.getMainHandItem();
if (!(mainHandItem.getItem() instanceof GunItem gunItem)) return;

View file

@ -64,12 +64,6 @@ public class FireMessage {
}
public static void pressAction(Player player, int type) {
Level world = player.level();
if (!world.isLoaded(player.blockPosition())) {
return;
}
handleGunBolt(player, player.getMainHandItem());
if (type == 0) {

View file

@ -42,9 +42,7 @@ public class FireModeMessage {
public static void pressAction(Player player, int type) {
if (player == null) return;
// security measure to prevent arbitrary chunk generation
if (!player.level().isLoaded(player.blockPosition()))
return;
if (type == 0) {
changeFireMode(player);
}

View file

@ -9,7 +9,8 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class GunReforgeMessage {
int type;
public int type;
public GunReforgeMessage(int type) {
this.type = type;

View file

@ -10,6 +10,7 @@ import java.util.HashMap;
import java.util.function.Supplier;
public class GunsDataMessage {
public final HashMap<String, HashMap<String, Double>> gunsData;
public GunsDataMessage(HashMap<String, HashMap<String, Double>> gunsData) {
@ -32,5 +33,4 @@ public class GunsDataMessage {
ctx.get().enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> ClientPacketHandler.handleGunsDataMessage(message, ctx)));
ctx.get().setPacketHandled(true);
}
}

View file

@ -22,6 +22,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class InteractMessage {
private final int type;
public InteractMessage(int type) {
@ -49,8 +50,6 @@ public class InteractMessage {
public static void pressAction(Player player, int type) {
Level level = player.level();
if (!level.isLoaded(player.blockPosition()))
return;
if (type == 0) {
ItemStack stack = player.getMainHandItem();
if (player.getMainHandItem().is(ModTags.Items.GUN)) {
@ -69,9 +68,7 @@ public class InteractMessage {
if (lookingEntity == null)
return;
player.interactOn(lookingEntity, InteractionHand.MAIN_HAND);
} else if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked") && !player.getCooldowns().isOnCooldown(stack.getItem())) {
DroneEntity drone = EntityFindUtil.findDrone(player.level(), stack.getOrCreateTag().getString("LinkedDrone"));
if (drone != null) {

View file

@ -16,6 +16,7 @@ import java.util.UUID;
import java.util.function.Supplier;
public class LaserShootMessage {
private final double damage;
private final UUID uuid;
private final boolean headshot;
@ -49,10 +50,6 @@ public class LaserShootMessage {
public static void pressAction(ServerPlayer player, double damage, UUID uuid, boolean headshot) {
Level level = player.level();
if (!level.isLoaded(player.blockPosition())) {
return;
}
Entity entity = EntityFindUtil.findEntity(level, String.valueOf(uuid));
if (entity != null) {

View file

@ -16,6 +16,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class PlayerGunKillMessage {
public final int attackerId;
public final int targetId;
public final boolean headshot;

View file

@ -9,12 +9,12 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class ReloadMessage {
private final int type;
public ReloadMessage(int type) {
@ -40,12 +40,6 @@ public class ReloadMessage {
}
public static void pressAction(Player player, int type) {
Level level = player.level();
if (!level.isLoaded(player.blockPosition())) {
return;
}
if (type == 0) {
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.edit = false;

View file

@ -10,6 +10,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class SensitivityMessage {
private final boolean add;
public SensitivityMessage(boolean add) {

View file

@ -10,6 +10,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class SetPerkLevelMessage {
int type;
boolean add;

View file

@ -9,14 +9,12 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class ShakeClientMessage {
public double time;
public double radius;
public double amplitude;
public double x;
public double y;
public double z;
public ShakeClientMessage(double time, double radius, double amplitude, double x, double y, double z) {

View file

@ -9,6 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class ShootClientMessage {
public double time;
public ShootClientMessage(double time) {

View file

@ -19,7 +19,6 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.network.NetworkEvent;
@ -52,12 +51,6 @@ public class ShootMessage {
}
public static void pressAction(Player player, double spared) {
Level level = player.level();
if (!level.isLoaded(player.blockPosition())) {
return;
}
ItemStack stack = player.getMainHandItem();
if (stack.is(ModTags.Items.NORMAL_GUN)) {
int projectileAmount = GunsTool.getGunIntTag(stack, "ProjectileAmount", 1);

View file

@ -9,6 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class SwitchScopeMessage {
private final double scroll;
public SwitchScopeMessage(double scroll) {

View file

@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.network.message;
import com.atsuishio.superbwarfare.entity.IArmedVehicleEntity;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.Level;
import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
@ -28,11 +27,6 @@ public class VehicleFireMessage {
context.enqueueWork(() -> {
if (context.getSender() != null) {
var player = context.getSender();
Level level = player.level();
if (!level.isLoaded(player.blockPosition())) {
return;
}
if (player.getVehicle() instanceof IArmedVehicleEntity iVehicle) {
iVehicle.vehicleShoot(player);

View file

@ -9,6 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class VehicleMovementMessage {
private final int direction;
private final boolean clicked;
@ -54,6 +55,7 @@ public class VehicleMovementMessage {
mobileVehicleEntity.downInputDown = message.clicked;
break;
}
if (player.getMainHandItem().is(ModItems.MONITOR.get())) {
if (player.getMainHandItem().getOrCreateTag().getBoolean("Using") && player.getMainHandItem().getOrCreateTag().getBoolean("Linked")) {
mobileVehicleEntity.leftInputDown = false;
@ -64,7 +66,6 @@ public class VehicleMovementMessage {
mobileVehicleEntity.downInputDown = false;
}
}
}
}
});

View file

@ -12,13 +12,12 @@ import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class ZoomMessage {
private final int type;
public ZoomMessage(int type) {
@ -39,13 +38,6 @@ public class ZoomMessage {
ServerPlayer player = context.getSender();
if (player != null) {
ItemStack stack = player.getMainHandItem();
Level level = player.level();
if (!level.isLoaded(player.blockPosition())) {
return;
}
if (message.type == 0) {
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.zoom = true;
@ -72,9 +64,9 @@ public class ZoomMessage {
if (player.getMainHandItem().getItem() == ModItems.JAVELIN.get()) {
var handItem = player.getMainHandItem();
var tag = handItem.getOrCreateTag();
tag.putBoolean("Seeking",false);
tag.putInt("SeekTime",0);
tag.putString("TargetEntity","none");
tag.putBoolean("Seeking", false);
tag.putInt("SeekTime", 0);
tag.putString("TargetEntity", "none");
var clientboundstopsoundpacket = new ClientboundStopSoundPacket(new ResourceLocation(ModUtils.MODID, "javelin_lock"), SoundSource.PLAYERS);
player.connection.send(clientboundstopsoundpacket);
}