优化部分代码
This commit is contained in:
parent
edd15e6a1d
commit
fedf2734e5
7 changed files with 38 additions and 51 deletions
|
@ -331,7 +331,7 @@ public class ClickHandler {
|
||||||
player.playSound(ModSounds.TRIGGER_CLICK.get(), 1, 1);
|
player.playSound(ModSounds.TRIGGER_CLICK.get(), 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gunItem.useBackpackAmmo(stack) && GunsTool.getGunIntTag(stack, "Ammo", 0) <= 0 && stack.getOrCreateTag().getInt("ReloadTime") == 0) {
|
if (!gunItem.useBackpackAmmo(stack) && GunsTool.getGunIntTag(stack, "Ammo", 0) <= 0 && GunsTool.getGunIntTag(stack, "ReloadTime") == 0) {
|
||||||
if (ReloadConfig.LEFT_CLICK_RELOAD.get()) {
|
if (ReloadConfig.LEFT_CLICK_RELOAD.get()) {
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new ReloadMessage(0));
|
ModUtils.PACKET_HANDLER.sendToServer(new ReloadMessage(0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,8 +103,6 @@ public abstract class CameraMixin {
|
||||||
return transform.transform(new Vector4f(x, y, z, 1));
|
return transform.transform(new Vector4f(x, y, z, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Inject(method = "setup", at = @At("TAIL"))
|
@Inject(method = "setup", at = @At("TAIL"))
|
||||||
public void ia$setup(BlockGetter area, Entity entity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
|
public void ia$setup(BlockGetter area, Entity entity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
|
||||||
if (thirdPerson && entity.getVehicle() instanceof Mk42Entity) {
|
if (thirdPerson && entity.getVehicle() instanceof Mk42Entity) {
|
||||||
|
|
|
@ -33,9 +33,7 @@ public class MouseHandlerMixin {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) return original;
|
||||||
return original;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player.hasEffect(ModMobEffects.SHOCK.get()) && !player.isSpectator()) {
|
if (player.hasEffect(ModMobEffects.SHOCK.get()) && !player.isSpectator()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -44,11 +42,7 @@ public class MouseHandlerMixin {
|
||||||
ItemStack stack = mc.player.getMainHandItem();
|
ItemStack stack = mc.player.getMainHandItem();
|
||||||
|
|
||||||
if (player.getVehicle() instanceof ICannonEntity) {
|
if (player.getVehicle() instanceof ICannonEntity) {
|
||||||
if (ClientEventHandler.zoom) {
|
return ClientEventHandler.zoom ? 0.15 : 0.3;
|
||||||
return 0.15;
|
|
||||||
} else {
|
|
||||||
return 0.3;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getVehicle() instanceof Ah6Entity ah6Entity && !ah6Entity.onGround() && ah6Entity.getFirstPassenger() == player) {
|
if (player.getVehicle() instanceof Ah6Entity ah6Entity && !ah6Entity.onGround() && ah6Entity.getFirstPassenger() == player) {
|
||||||
|
@ -56,11 +50,7 @@ public class MouseHandlerMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getVehicle() instanceof Lav150Entity) {
|
if (player.getVehicle() instanceof Lav150Entity) {
|
||||||
if (ClientEventHandler.zoom) {
|
return ClientEventHandler.zoom ? 0.23 : 0.28;
|
||||||
return 0.23;
|
|
||||||
} else {
|
|
||||||
return 0.28;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.atsuishio.superbwarfare.network.message;
|
package com.atsuishio.superbwarfare.network.message;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
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;
|
||||||
|
@ -36,6 +37,7 @@ public class EditMessage {
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
if (!stack.is(ModTags.Items.GUN)) return;
|
||||||
|
|
||||||
CompoundTag tag = stack.getOrCreateTag().getCompound("Attachments");
|
CompoundTag tag = stack.getOrCreateTag().getCompound("Attachments");
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
|
@ -83,13 +83,12 @@ public class FireMessage {
|
||||||
capability.syncPlayerVariables(player);
|
capability.syncPlayerVariables(player);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (player.getMainHandItem().getItem() == ModItems.BOCEK.get()) {
|
if (stack.getItem() == ModItems.BOCEK.get()) {
|
||||||
handleBowShoot(player);
|
handleBowShoot(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getMainHandItem().getItem() == ModItems.JAVELIN.get()) {
|
if (stack.getItem() == ModItems.JAVELIN.get()) {
|
||||||
var handItem = player.getMainHandItem();
|
var tag = stack.getOrCreateTag();
|
||||||
var tag = handItem.getOrCreateTag();
|
|
||||||
handleJavelinFire(player);
|
handleJavelinFire(player);
|
||||||
tag.putBoolean("Seeking", false);
|
tag.putBoolean("Seeking", false);
|
||||||
tag.putInt("SeekTime", 0);
|
tag.putInt("SeekTime", 0);
|
||||||
|
|
|
@ -55,7 +55,6 @@ public class ReloadMessage {
|
||||||
&& GunsTool.getGunIntTag(stack, "ReloadTime") == 0
|
&& GunsTool.getGunIntTag(stack, "ReloadTime") == 0
|
||||||
&& GunsTool.getGunIntTag(stack, "BoltActionTick") == 0
|
&& GunsTool.getGunIntTag(stack, "BoltActionTick") == 0
|
||||||
&& !GunsTool.getGunBooleanTag(stack, "Reloading")
|
&& !GunsTool.getGunBooleanTag(stack, "Reloading")
|
||||||
|
|
||||||
) {
|
) {
|
||||||
CompoundTag tag = stack.getOrCreateTag();
|
CompoundTag tag = stack.getOrCreateTag();
|
||||||
|
|
||||||
|
|
|
@ -36,40 +36,39 @@ public class ZoomMessage {
|
||||||
NetworkEvent.Context context = contextSupplier.get();
|
NetworkEvent.Context context = contextSupplier.get();
|
||||||
context.enqueueWork(() -> {
|
context.enqueueWork(() -> {
|
||||||
ServerPlayer player = context.getSender();
|
ServerPlayer player = context.getSender();
|
||||||
|
if (player == null) return;
|
||||||
|
|
||||||
if (player != null) {
|
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;
|
capability.edit = false;
|
||||||
capability.edit = false;
|
capability.syncPlayerVariables(player);
|
||||||
capability.syncPlayerVariables(player);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (player.isPassenger() && player.getVehicle() instanceof IArmedVehicleEntity && !(player.getVehicle() instanceof WheelChairEntity)) {
|
if (player.isPassenger() && player.getVehicle() instanceof IArmedVehicleEntity && !(player.getVehicle() instanceof WheelChairEntity)) {
|
||||||
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
|
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.type == 1) {
|
||||||
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
|
capability.zoom = false;
|
||||||
|
capability.breath = false;
|
||||||
|
capability.syncPlayerVariables(player);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (player.isPassenger() && player.getVehicle() instanceof IArmedVehicleEntity && !(player.getVehicle() instanceof WheelChairEntity)) {
|
||||||
|
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_OUT.get(), 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.type == 1) {
|
if (player.getMainHandItem().getItem() == ModItems.JAVELIN.get()) {
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
var handItem = player.getMainHandItem();
|
||||||
capability.zoom = false;
|
var tag = handItem.getOrCreateTag();
|
||||||
capability.breath = false;
|
tag.putBoolean("Seeking", false);
|
||||||
capability.syncPlayerVariables(player);
|
tag.putInt("SeekTime", 0);
|
||||||
});
|
tag.putString("TargetEntity", "none");
|
||||||
|
var clientboundstopsoundpacket = new ClientboundStopSoundPacket(new ResourceLocation(ModUtils.MODID, "javelin_lock"), SoundSource.PLAYERS);
|
||||||
if (player.isPassenger() && player.getVehicle() instanceof IArmedVehicleEntity && !(player.getVehicle() instanceof WheelChairEntity)) {
|
player.connection.send(clientboundstopsoundpacket);
|
||||||
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_OUT.get(), 2, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
var clientboundstopsoundpacket = new ClientboundStopSoundPacket(new ResourceLocation(ModUtils.MODID, "javelin_lock"), SoundSource.PLAYERS);
|
|
||||||
player.connection.send(clientboundstopsoundpacket);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue