优化智慧芯片锁定
This commit is contained in:
parent
0e2cbdd728
commit
dffd294fa6
2 changed files with 21 additions and 9 deletions
|
@ -10,7 +10,9 @@ import com.atsuishio.superbwarfare.init.*;
|
|||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||
import com.atsuishio.superbwarfare.network.message.*;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||
import com.atsuishio.superbwarfare.tools.SeekTool;
|
||||
import com.atsuishio.superbwarfare.tools.TraceTool;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
@ -124,13 +126,13 @@ public class ClickHandler {
|
|||
}
|
||||
|
||||
if (button == ModKeyMappings.HOLD_ZOOM.getKey().getValue()) {
|
||||
handleWeaponZoomPress();
|
||||
handleWeaponZoomPress(player, stack);
|
||||
switchZoom = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (button == ModKeyMappings.SWITCH_ZOOM.getKey().getValue()) {
|
||||
handleWeaponZoomPress();
|
||||
handleWeaponZoomPress(player, stack);
|
||||
switchZoom = !switchZoom;
|
||||
}
|
||||
}
|
||||
|
@ -252,13 +254,13 @@ public class ClickHandler {
|
|||
}
|
||||
|
||||
if (key == ModKeyMappings.HOLD_ZOOM.getKey().getValue()) {
|
||||
handleWeaponZoomPress();
|
||||
handleWeaponZoomPress(player, stack);
|
||||
switchZoom = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (key == ModKeyMappings.SWITCH_ZOOM.getKey().getValue()) {
|
||||
handleWeaponZoomPress();
|
||||
handleWeaponZoomPress(player, stack);
|
||||
switchZoom = !switchZoom;
|
||||
}
|
||||
}
|
||||
|
@ -340,14 +342,21 @@ public class ClickHandler {
|
|||
ClientEventHandler.customRpm = 0;
|
||||
}
|
||||
|
||||
public static void handleWeaponZoomPress() {
|
||||
public static void handleWeaponZoomPress(Player player, ItemStack stack) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new ZoomMessage(0));
|
||||
ClientEventHandler.zoom = true;
|
||||
int level = PerkHelper.getItemPerkLevel(ModPerks.INTELLIGENT_CHIP.get(), stack);
|
||||
if (level > 0) {
|
||||
if (ClientEventHandler.entity == null) {
|
||||
ClientEventHandler.entity = SeekTool.seekLivingEntity(player, player.level(), 32 + 8 * (level - 1), 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleWeaponZoomRelease() {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new ZoomMessage(1));
|
||||
ClientEventHandler.zoom = false;
|
||||
ClientEventHandler.entity = null;
|
||||
}
|
||||
|
||||
private static void editModelShake() {
|
||||
|
|
|
@ -143,6 +143,7 @@ public class ClientEventHandler {
|
|||
public static double vehicleFov = 1;
|
||||
public static double vehicleFovLerp = 1;
|
||||
public static int lungeAttack;
|
||||
public static Entity entity;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void handleWeaponTurn(RenderHandEvent event) {
|
||||
|
@ -1223,10 +1224,12 @@ public class ClientEventHandler {
|
|||
&& !player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) {
|
||||
int level = PerkHelper.getItemPerkLevel(ModPerks.INTELLIGENT_CHIP.get(), stack);
|
||||
if (level > 0) {
|
||||
Entity seekingEntity = SeekTool.seekLivingEntity(player, player.level(), 32 + 8 * (level - 1), 25 / zoomFov);
|
||||
if (seekingEntity != null && seekingEntity.isAlive()) {
|
||||
Vec3 targetVec = new Vec3(seekingEntity.getX() - player.getX(), seekingEntity.getEyeY() - player.getEyeY(), seekingEntity.getZ() - player.getZ()).normalize();
|
||||
Vec3 toVec = new Vec3(player.getViewVector(1).add(targetVec.scale(times)).toVector3f());
|
||||
if (ClientEventHandler.entity == null || !entity.isAlive()) {
|
||||
ClientEventHandler.entity = SeekTool.seekLivingEntity(player, player.level(), 32 + 8 * (level - 1), 16 / zoomFov);
|
||||
}
|
||||
if (entity != null && entity.isAlive()) {
|
||||
Vec3 targetVec = player.getEyePosition().vectorTo(entity.getEyePosition());
|
||||
Vec3 toVec = player.getViewVector(1).add(targetVec.scale(1.1f * times));
|
||||
look(player, toVec);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue