修复超高无法开火的问题
This commit is contained in:
parent
aedb3fe209
commit
a8db1dd5e4
27 changed files with 29 additions and 73 deletions
|
@ -17,6 +17,7 @@ import java.util.function.Supplier;
|
||||||
import static com.atsuishio.superbwarfare.entity.MortarEntity.PITCH;
|
import static com.atsuishio.superbwarfare.entity.MortarEntity.PITCH;
|
||||||
|
|
||||||
public class AdjustMortarAngleMessage {
|
public class AdjustMortarAngleMessage {
|
||||||
|
|
||||||
private final double scroll;
|
private final double scroll;
|
||||||
|
|
||||||
public AdjustMortarAngleMessage(double scroll) {
|
public AdjustMortarAngleMessage(double scroll) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.text.DecimalFormat;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class AdjustZoomFovMessage {
|
public class AdjustZoomFovMessage {
|
||||||
|
|
||||||
private final double scroll;
|
private final double scroll;
|
||||||
|
|
||||||
public AdjustZoomFovMessage(double scroll) {
|
public AdjustZoomFovMessage(double scroll) {
|
||||||
|
|
|
@ -3,12 +3,12 @@ package com.atsuishio.superbwarfare.network.message;
|
||||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class BreathMessage {
|
public class BreathMessage {
|
||||||
|
|
||||||
private final boolean type;
|
private final boolean type;
|
||||||
|
|
||||||
public BreathMessage(boolean type) {
|
public BreathMessage(boolean type) {
|
||||||
|
@ -29,12 +29,6 @@ public class BreathMessage {
|
||||||
ServerPlayer player = context.getSender();
|
ServerPlayer player = context.getSender();
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
Level level = player.level();
|
|
||||||
|
|
||||||
if (!level.isLoaded(player.blockPosition())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var cap = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
|
var cap = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
|
||||||
|
|
||||||
if (message.type && !cap.orElse(new ModVariables.PlayerVariables()).breathExhaustion && cap.orElse(new ModVariables.PlayerVariables()).zoom &&
|
if (message.type && !cap.orElse(new ModVariables.PlayerVariables()).breathExhaustion && cap.orElse(new ModVariables.PlayerVariables()).zoom &&
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ClientIndicatorMessage {
|
public class ClientIndicatorMessage {
|
||||||
|
|
||||||
public final int type;
|
public final int type;
|
||||||
public final int value;
|
public final int value;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class DoubleJumpMessage {
|
public class DoubleJumpMessage {
|
||||||
|
|
||||||
private final boolean canDoubleJump;
|
private final boolean canDoubleJump;
|
||||||
|
|
||||||
public DoubleJumpMessage(boolean canDoubleJump) {
|
public DoubleJumpMessage(boolean canDoubleJump) {
|
||||||
|
@ -37,10 +38,6 @@ public class DoubleJumpMessage {
|
||||||
double y = player.getY();
|
double y = player.getY();
|
||||||
double z = player.getZ();
|
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);
|
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 -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class DrawClientMessage {
|
public class DrawClientMessage {
|
||||||
|
|
||||||
public boolean draw;
|
public boolean draw;
|
||||||
|
|
||||||
public DrawClientMessage(boolean draw) {
|
public DrawClientMessage(boolean draw) {
|
||||||
|
|
|
@ -71,10 +71,8 @@ public class DroneFireMessage {
|
||||||
+ "," + offStack.getOrCreateTag().getInt("TargetY")
|
+ "," + offStack.getOrCreateTag().getInt("TargetY")
|
||||||
+ "," + offStack.getOrCreateTag().getInt("TargetZ") + "]")), true);
|
+ "," + offStack.getOrCreateTag().getInt("TargetZ") + "]")), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
context.setPacketHandled(true);
|
context.setPacketHandled(true);
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class DroneMovementMessage {
|
public class DroneMovementMessage {
|
||||||
|
|
||||||
private final int direction;
|
private final int direction;
|
||||||
private final boolean clicked;
|
private final boolean clicked;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.atsuishio.superbwarfare.network.message;
|
package com.atsuishio.superbwarfare.network.message;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -11,6 +11,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class EditMessage {
|
public class EditMessage {
|
||||||
|
|
||||||
private final int type;
|
private final int type;
|
||||||
|
|
||||||
public EditMessage(int type) {
|
public EditMessage(int type) {
|
||||||
|
@ -33,8 +34,6 @@ public class EditMessage {
|
||||||
|
|
||||||
public static void pressAction(Player player, int type) {
|
public static void pressAction(Player player, int type) {
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
if (!player.level().isLoaded(player.blockPosition()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class EditModeMessage {
|
public class EditModeMessage {
|
||||||
|
|
||||||
private final int type;
|
private final int type;
|
||||||
|
|
||||||
public EditModeMessage(int type) {
|
public EditModeMessage(int type) {
|
||||||
|
@ -35,8 +36,6 @@ public class EditModeMessage {
|
||||||
public static void pressAction(Player player, int type) {
|
public static void pressAction(Player player, int type) {
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
if (!player.level().isLoaded(player.blockPosition())) return;
|
|
||||||
|
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
ItemStack mainHandItem = player.getMainHandItem();
|
ItemStack mainHandItem = player.getMainHandItem();
|
||||||
if (!(mainHandItem.getItem() instanceof GunItem gunItem)) return;
|
if (!(mainHandItem.getItem() instanceof GunItem gunItem)) return;
|
||||||
|
|
|
@ -64,12 +64,6 @@ public class FireMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pressAction(Player player, int type) {
|
public static void pressAction(Player player, int type) {
|
||||||
Level world = player.level();
|
|
||||||
|
|
||||||
if (!world.isLoaded(player.blockPosition())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
handleGunBolt(player, player.getMainHandItem());
|
handleGunBolt(player, player.getMainHandItem());
|
||||||
|
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
|
|
|
@ -42,9 +42,7 @@ public class FireModeMessage {
|
||||||
|
|
||||||
public static void pressAction(Player player, int type) {
|
public static void pressAction(Player player, int type) {
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
// security measure to prevent arbitrary chunk generation
|
|
||||||
if (!player.level().isLoaded(player.blockPosition()))
|
|
||||||
return;
|
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
changeFireMode(player);
|
changeFireMode(player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class GunReforgeMessage {
|
public class GunReforgeMessage {
|
||||||
int type;
|
|
||||||
|
public int type;
|
||||||
|
|
||||||
public GunReforgeMessage(int type) {
|
public GunReforgeMessage(int type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.util.HashMap;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class GunsDataMessage {
|
public class GunsDataMessage {
|
||||||
|
|
||||||
public final HashMap<String, HashMap<String, Double>> gunsData;
|
public final HashMap<String, HashMap<String, Double>> gunsData;
|
||||||
|
|
||||||
public GunsDataMessage(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().enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> ClientPacketHandler.handleGunsDataMessage(message, ctx)));
|
||||||
ctx.get().setPacketHandled(true);
|
ctx.get().setPacketHandled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class InteractMessage {
|
public class InteractMessage {
|
||||||
|
|
||||||
private final int type;
|
private final int type;
|
||||||
|
|
||||||
public InteractMessage(int type) {
|
public InteractMessage(int type) {
|
||||||
|
@ -49,8 +50,6 @@ public class InteractMessage {
|
||||||
public static void pressAction(Player player, int type) {
|
public static void pressAction(Player player, int type) {
|
||||||
Level level = player.level();
|
Level level = player.level();
|
||||||
|
|
||||||
if (!level.isLoaded(player.blockPosition()))
|
|
||||||
return;
|
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (player.getMainHandItem().is(ModTags.Items.GUN)) {
|
if (player.getMainHandItem().is(ModTags.Items.GUN)) {
|
||||||
|
@ -69,9 +68,7 @@ public class InteractMessage {
|
||||||
if (lookingEntity == null)
|
if (lookingEntity == null)
|
||||||
return;
|
return;
|
||||||
player.interactOn(lookingEntity, InteractionHand.MAIN_HAND);
|
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())) {
|
} 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"));
|
DroneEntity drone = EntityFindUtil.findDrone(player.level(), stack.getOrCreateTag().getString("LinkedDrone"));
|
||||||
|
|
||||||
if (drone != null) {
|
if (drone != null) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.UUID;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class LaserShootMessage {
|
public class LaserShootMessage {
|
||||||
|
|
||||||
private final double damage;
|
private final double damage;
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private final boolean headshot;
|
private final boolean headshot;
|
||||||
|
@ -49,10 +50,6 @@ public class LaserShootMessage {
|
||||||
public static void pressAction(ServerPlayer player, double damage, UUID uuid, boolean headshot) {
|
public static void pressAction(ServerPlayer player, double damage, UUID uuid, boolean headshot) {
|
||||||
Level level = player.level();
|
Level level = player.level();
|
||||||
|
|
||||||
if (!level.isLoaded(player.blockPosition())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity entity = EntityFindUtil.findEntity(level, String.valueOf(uuid));
|
Entity entity = EntityFindUtil.findEntity(level, String.valueOf(uuid));
|
||||||
|
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class PlayerGunKillMessage {
|
public class PlayerGunKillMessage {
|
||||||
|
|
||||||
public final int attackerId;
|
public final int attackerId;
|
||||||
public final int targetId;
|
public final int targetId;
|
||||||
public final boolean headshot;
|
public final boolean headshot;
|
||||||
|
|
|
@ -9,12 +9,12 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ReloadMessage {
|
public class ReloadMessage {
|
||||||
|
|
||||||
private final int type;
|
private final int type;
|
||||||
|
|
||||||
public ReloadMessage(int type) {
|
public ReloadMessage(int type) {
|
||||||
|
@ -40,12 +40,6 @@ public class ReloadMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pressAction(Player player, int type) {
|
public static void pressAction(Player player, int type) {
|
||||||
Level level = player.level();
|
|
||||||
|
|
||||||
if (!level.isLoaded(player.blockPosition())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
capability.edit = false;
|
capability.edit = false;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class SensitivityMessage {
|
public class SensitivityMessage {
|
||||||
|
|
||||||
private final boolean add;
|
private final boolean add;
|
||||||
|
|
||||||
public SensitivityMessage(boolean add) {
|
public SensitivityMessage(boolean add) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class SetPerkLevelMessage {
|
public class SetPerkLevelMessage {
|
||||||
|
|
||||||
int type;
|
int type;
|
||||||
boolean add;
|
boolean add;
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,12 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ShakeClientMessage {
|
public class ShakeClientMessage {
|
||||||
|
|
||||||
public double time;
|
public double time;
|
||||||
public double radius;
|
public double radius;
|
||||||
public double amplitude;
|
public double amplitude;
|
||||||
|
|
||||||
public double x;
|
public double x;
|
||||||
|
|
||||||
public double y;
|
public double y;
|
||||||
|
|
||||||
public double z;
|
public double z;
|
||||||
|
|
||||||
public ShakeClientMessage(double time, double radius, double amplitude, double x, double y, double z) {
|
public ShakeClientMessage(double time, double radius, double amplitude, double x, double y, double z) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ShootClientMessage {
|
public class ShootClientMessage {
|
||||||
|
|
||||||
public double time;
|
public double time;
|
||||||
|
|
||||||
public ShootClientMessage(double time) {
|
public ShootClientMessage(double time) {
|
||||||
|
|
|
@ -19,7 +19,6 @@ import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
|
@ -52,12 +51,6 @@ public class ShootMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pressAction(Player player, double spared) {
|
public static void pressAction(Player player, double spared) {
|
||||||
Level level = player.level();
|
|
||||||
|
|
||||||
if (!level.isLoaded(player.blockPosition())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (stack.is(ModTags.Items.NORMAL_GUN)) {
|
if (stack.is(ModTags.Items.NORMAL_GUN)) {
|
||||||
int projectileAmount = GunsTool.getGunIntTag(stack, "ProjectileAmount", 1);
|
int projectileAmount = GunsTool.getGunIntTag(stack, "ProjectileAmount", 1);
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class SwitchScopeMessage {
|
public class SwitchScopeMessage {
|
||||||
|
|
||||||
private final double scroll;
|
private final double scroll;
|
||||||
|
|
||||||
public SwitchScopeMessage(double scroll) {
|
public SwitchScopeMessage(double scroll) {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.network.message;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.entity.IArmedVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.IArmedVehicleEntity;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
@ -28,11 +27,6 @@ public class VehicleFireMessage {
|
||||||
context.enqueueWork(() -> {
|
context.enqueueWork(() -> {
|
||||||
if (context.getSender() != null) {
|
if (context.getSender() != null) {
|
||||||
var player = context.getSender();
|
var player = context.getSender();
|
||||||
Level level = player.level();
|
|
||||||
|
|
||||||
if (!level.isLoaded(player.blockPosition())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player.getVehicle() instanceof IArmedVehicleEntity iVehicle) {
|
if (player.getVehicle() instanceof IArmedVehicleEntity iVehicle) {
|
||||||
iVehicle.vehicleShoot(player);
|
iVehicle.vehicleShoot(player);
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class VehicleMovementMessage {
|
public class VehicleMovementMessage {
|
||||||
|
|
||||||
private final int direction;
|
private final int direction;
|
||||||
private final boolean clicked;
|
private final boolean clicked;
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ public class VehicleMovementMessage {
|
||||||
mobileVehicleEntity.downInputDown = message.clicked;
|
mobileVehicleEntity.downInputDown = message.clicked;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getMainHandItem().is(ModItems.MONITOR.get())) {
|
if (player.getMainHandItem().is(ModItems.MONITOR.get())) {
|
||||||
if (player.getMainHandItem().getOrCreateTag().getBoolean("Using") && player.getMainHandItem().getOrCreateTag().getBoolean("Linked")) {
|
if (player.getMainHandItem().getOrCreateTag().getBoolean("Using") && player.getMainHandItem().getOrCreateTag().getBoolean("Linked")) {
|
||||||
mobileVehicleEntity.leftInputDown = false;
|
mobileVehicleEntity.leftInputDown = false;
|
||||||
|
@ -64,7 +66,6 @@ public class VehicleMovementMessage {
|
||||||
mobileVehicleEntity.downInputDown = false;
|
mobileVehicleEntity.downInputDown = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,13 +12,12 @@ import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ZoomMessage {
|
public class ZoomMessage {
|
||||||
|
|
||||||
private final int type;
|
private final int type;
|
||||||
|
|
||||||
public ZoomMessage(int type) {
|
public ZoomMessage(int type) {
|
||||||
|
@ -39,13 +38,6 @@ public class ZoomMessage {
|
||||||
ServerPlayer player = context.getSender();
|
ServerPlayer player = context.getSender();
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
|
||||||
Level level = player.level();
|
|
||||||
|
|
||||||
if (!level.isLoaded(player.blockPosition())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.type == 0) {
|
if (message.type == 0) {
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
capability.zoom = true;
|
capability.zoom = true;
|
||||||
|
@ -72,9 +64,9 @@ public class ZoomMessage {
|
||||||
if (player.getMainHandItem().getItem() == ModItems.JAVELIN.get()) {
|
if (player.getMainHandItem().getItem() == ModItems.JAVELIN.get()) {
|
||||||
var handItem = player.getMainHandItem();
|
var handItem = player.getMainHandItem();
|
||||||
var tag = handItem.getOrCreateTag();
|
var tag = handItem.getOrCreateTag();
|
||||||
tag.putBoolean("Seeking",false);
|
tag.putBoolean("Seeking", false);
|
||||||
tag.putInt("SeekTime",0);
|
tag.putInt("SeekTime", 0);
|
||||||
tag.putString("TargetEntity","none");
|
tag.putString("TargetEntity", "none");
|
||||||
var clientboundstopsoundpacket = new ClientboundStopSoundPacket(new ResourceLocation(ModUtils.MODID, "javelin_lock"), SoundSource.PLAYERS);
|
var clientboundstopsoundpacket = new ClientboundStopSoundPacket(new ResourceLocation(ModUtils.MODID, "javelin_lock"), SoundSource.PLAYERS);
|
||||||
player.connection.send(clientboundstopsoundpacket);
|
player.connection.send(clientboundstopsoundpacket);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue