修复电击屏幕倾斜不恢复的问题
This commit is contained in:
parent
f60d19e112
commit
014708a31e
2 changed files with 16 additions and 3 deletions
|
@ -1357,12 +1357,10 @@ public class ClientEventHandler {
|
|||
if (entity.hasEffect(ModMobEffects.SHOCK) && Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||
float shakeStrength = (float) DisplayConfig.SHOCK_SCREEN_SHAKE.get() / 100.0f;
|
||||
if (shakeStrength <= 0.0f) return;
|
||||
|
||||
event.setYaw(Minecraft.getInstance().gameRenderer.getMainCamera().getYRot() +
|
||||
(float) Mth.nextDouble(RandomSource.create(), -3, 3) * shakeStrength);
|
||||
event.setPitch(Minecraft.getInstance().gameRenderer.getMainCamera().getXRot() +
|
||||
(float) Mth.nextDouble(RandomSource.create(), -3, 3) * shakeStrength);
|
||||
event.setRoll((float) Mth.nextDouble(RandomSource.create(), 8, 12) * shakeStrength);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package com.atsuishio.superbwarfare.mixins;
|
||||
|
||||
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModMobEffects;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
|
@ -9,6 +13,7 @@ import net.minecraft.client.CameraType;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -45,7 +50,17 @@ public class GameRendererMixin {
|
|||
@Inject(method = "bobHurt(Lcom/mojang/blaze3d/vertex/PoseStack;F)V", at = @At("HEAD"))
|
||||
public void superbWarfare$renderWorld(PoseStack poseStack, float partialTicks, CallbackInfo ci) {
|
||||
Entity entity = mainCamera.getEntity();
|
||||
if (entity != null && !mainCamera.isDetached() && entity.getRootVehicle() instanceof VehicleEntity vehicle) {
|
||||
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(ClientEventHandler.cameraRoll));
|
||||
|
||||
|
||||
if (entity instanceof Player player && !player.isSpectator() && player.hasEffect(ModMobEffects.SHOCK)) {
|
||||
float shakeStrength = (float) DisplayConfig.SHOCK_SCREEN_SHAKE.get() / 100.0f;
|
||||
if (shakeStrength <= 0.0f) return;
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees((float) Mth.nextDouble(RandomSource.create(), 8, 12) * shakeStrength));
|
||||
}
|
||||
|
||||
if (entity != null && entity.getRootVehicle() instanceof VehicleEntity vehicle && (!mainCamera.isDetached() || (vehicle instanceof LandArmorEntity && ClientEventHandler.zoomVehicle))) {
|
||||
// rotate camera
|
||||
float a = vehicle.getTurretYaw(partialTicks);
|
||||
float r = (Mth.abs(a) - 90f) / 90f;
|
||||
|
|
Loading…
Add table
Reference in a new issue