优化部分代码
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);
|
||||
}
|
||||
|
||||
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()) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new ReloadMessage(0));
|
||||
}
|
||||
|
|
|
@ -103,8 +103,6 @@ public abstract class CameraMixin {
|
|||
return transform.transform(new Vector4f(x, y, z, 1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Inject(method = "setup", at = @At("TAIL"))
|
||||
public void ia$setup(BlockGetter area, Entity entity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
|
||||
if (thirdPerson && entity.getVehicle() instanceof Mk42Entity) {
|
||||
|
|
|
@ -33,9 +33,7 @@ public class MouseHandlerMixin {
|
|||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
||||
if (player == null) {
|
||||
return original;
|
||||
}
|
||||
if (player == null) return original;
|
||||
|
||||
if (player.hasEffect(ModMobEffects.SHOCK.get()) && !player.isSpectator()) {
|
||||
return 0;
|
||||
|
@ -44,11 +42,7 @@ public class MouseHandlerMixin {
|
|||
ItemStack stack = mc.player.getMainHandItem();
|
||||
|
||||
if (player.getVehicle() instanceof ICannonEntity) {
|
||||
if (ClientEventHandler.zoom) {
|
||||
return 0.15;
|
||||
} else {
|
||||
return 0.3;
|
||||
}
|
||||
return ClientEventHandler.zoom ? 0.15 : 0.3;
|
||||
}
|
||||
|
||||
if (player.getVehicle() instanceof Ah6Entity ah6Entity && !ah6Entity.onGround() && ah6Entity.getFirstPassenger() == player) {
|
||||
|
@ -56,11 +50,7 @@ public class MouseHandlerMixin {
|
|||
}
|
||||
|
||||
if (player.getVehicle() instanceof Lav150Entity) {
|
||||
if (ClientEventHandler.zoom) {
|
||||
return 0.23;
|
||||
} else {
|
||||
return 0.28;
|
||||
}
|
||||
return ClientEventHandler.zoom ? 0.23 : 0.28;
|
||||
}
|
||||
|
||||
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.atsuishio.superbwarfare.network.message;
|
||||
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
@ -36,6 +37,7 @@ public class EditMessage {
|
|||
if (player == null) return;
|
||||
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!stack.is(ModTags.Items.GUN)) return;
|
||||
|
||||
CompoundTag tag = stack.getOrCreateTag().getCompound("Attachments");
|
||||
switch (type) {
|
||||
|
|
|
@ -83,13 +83,12 @@ public class FireMessage {
|
|||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
|
||||
if (player.getMainHandItem().getItem() == ModItems.BOCEK.get()) {
|
||||
if (stack.getItem() == ModItems.BOCEK.get()) {
|
||||
handleBowShoot(player);
|
||||
}
|
||||
|
||||
if (player.getMainHandItem().getItem() == ModItems.JAVELIN.get()) {
|
||||
var handItem = player.getMainHandItem();
|
||||
var tag = handItem.getOrCreateTag();
|
||||
if (stack.getItem() == ModItems.JAVELIN.get()) {
|
||||
var tag = stack.getOrCreateTag();
|
||||
handleJavelinFire(player);
|
||||
tag.putBoolean("Seeking", false);
|
||||
tag.putInt("SeekTime", 0);
|
||||
|
|
|
@ -55,7 +55,6 @@ public class ReloadMessage {
|
|||
&& GunsTool.getGunIntTag(stack, "ReloadTime") == 0
|
||||
&& GunsTool.getGunIntTag(stack, "BoltActionTick") == 0
|
||||
&& !GunsTool.getGunBooleanTag(stack, "Reloading")
|
||||
|
||||
) {
|
||||
CompoundTag tag = stack.getOrCreateTag();
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ public class ZoomMessage {
|
|||
NetworkEvent.Context context = contextSupplier.get();
|
||||
context.enqueueWork(() -> {
|
||||
ServerPlayer player = context.getSender();
|
||||
if (player == null) return;
|
||||
|
||||
if (player != null) {
|
||||
if (message.type == 0) {
|
||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.zoom = true;
|
||||
|
@ -71,7 +71,6 @@ public class ZoomMessage {
|
|||
player.connection.send(clientboundstopsoundpacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
context.setPacketHandled(true);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue