From a644856981d8ed23b518ecfdeb72f6a88482384e Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Wed, 11 Sep 2024 00:47:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=97=A0=E4=BA=BA?= =?UTF-8?q?=E6=9C=BA=E7=9A=84=E5=B1=8F=E5=B9=95shader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/ClientEventHandler.java | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java b/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java index c0d6e2418..f7f1d2e78 100644 --- a/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java @@ -11,6 +11,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.player.LocalPlayer; import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; @@ -65,6 +66,8 @@ public class ClientEventHandler { && living.getMainHandItem().getOrCreateTag().getBoolean("Using") && living.getMainHandItem().getOrCreateTag().getBoolean("Linked")) { handleDroneCamera(event, living); + } else { + Minecraft.getInstance().gameRenderer.shutdownEffect(); } if (level != null && entity instanceof LivingEntity living && living.getMainHandItem().is(ModTags.Items.GUN)) { handleWeaponCrossHair(living); @@ -105,6 +108,30 @@ public class ClientEventHandler { event.setPitch((float) (pitch + data.getDouble("droneCameraRotX") - 0.15f * Mth.RAD_TO_DEG * data.getDouble("droneRotZ"))); event.setRoll((float) (roll + data.getDouble("droneCameraRotY") - 0.5f * Mth.RAD_TO_DEG * data.getDouble("droneRotX"))); } + + if (drone != null && stack.getOrCreateTag().getBoolean("Using")) { + if (Minecraft.getInstance().gameRenderer.currentEffect() == null) { + Minecraft.getInstance().gameRenderer.loadEffect(new ResourceLocation("minecraft:shaders/post/scan_pincushion.json")); + } + } + } + + + private static void handleCannonScreen(LivingEntity entity) { + if (entity.level().isClientSide() && entity instanceof Player player) { + ItemStack stack = player.getMainHandItem(); + DroneEntity drone = entity.level().getEntitiesOfClass(DroneEntity.class, entity.getBoundingBox().inflate(512)) + .stream().filter(e -> e.getStringUUID().equals(stack.getOrCreateTag().getString("LinkedDrone"))).findFirst().orElse(null); + + if ((drone != null && player.getMainHandItem().is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using")) + || (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS && !stack.is(ModTags.Items.GUN))) { + if (Minecraft.getInstance().gameRenderer.currentEffect() == null) { + Minecraft.getInstance().gameRenderer.loadEffect(new ResourceLocation("minecraft:shaders/post/scan_pincushion.json")); + } + } else { + Minecraft.getInstance().gameRenderer.shutdownEffect(); + } + } } private static void handleCannonCamera(ViewportEvent.ComputeCameraAngles event, LivingEntity entity) { @@ -475,10 +502,8 @@ public class ClientEventHandler { player.getPersistentData().putDouble("fov", event.getFOV()); return; } - if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity) { - if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { - event.setFOV(event.getFOV() / 5); - } + if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS && !stack.is(ModTags.Items.GUN)) { + event.setFOV(event.getFOV() / 5); } }