提取载具固定视角方法
This commit is contained in:
parent
e3b3dcf87d
commit
9ea44d7b8d
11 changed files with 53 additions and 14 deletions
|
@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||||
* 玩家击杀生物后,用于判断是否发送击杀播报/显示击杀指示
|
* 玩家击杀生物后,用于判断是否发送击杀播报/显示击杀指示
|
||||||
*/
|
*/
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
@ApiStatus.AvailableSince("0.7.7")
|
@ApiStatus.AvailableSince("0.8.0")
|
||||||
public class PreKillEvent extends Event implements ICancellableEvent {
|
public class PreKillEvent extends Event implements ICancellableEvent {
|
||||||
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* Register Entities as a container
|
* Register Entities as a container
|
||||||
*/
|
*/
|
||||||
@ApiStatus.AvailableSince("0.7.7")
|
@ApiStatus.AvailableSince("0.8.0")
|
||||||
public class RegisterContainersEvent extends Event implements IModBusEvent {
|
public class RegisterContainersEvent extends Event implements IModBusEvent {
|
||||||
public static final List<ItemStack> containers = new ArrayList<>();
|
public static final List<ItemStack> containers = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import net.neoforged.bus.api.Event;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
@ApiStatus.AvailableSince("0.7.7")
|
@ApiStatus.AvailableSince("0.8.0")
|
||||||
public class ReloadEvent extends Event {
|
public class ReloadEvent extends Event {
|
||||||
|
|
||||||
public final Player player;
|
public final Player player;
|
||||||
|
|
|
@ -1094,4 +1094,9 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
}
|
}
|
||||||
return super.getCameraPosition(partialTicks, player, false, false);
|
return super.getCameraPosition(partialTicks, player, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public boolean useFixedCameraPos(Entity entity) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -631,4 +631,9 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
|
||||||
}
|
}
|
||||||
return super.getCameraPosition(partialTicks, player, false, false);
|
return super.getCameraPosition(partialTicks, player, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public boolean useFixedCameraPos(Entity entity) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,4 +483,9 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
||||||
}
|
}
|
||||||
return super.getCameraPosition(partialTicks, player, false, false);
|
return super.getCameraPosition(partialTicks, player, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public boolean useFixedCameraPos(Entity entity) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -552,4 +552,9 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
||||||
}
|
}
|
||||||
return super.getCameraPosition(partialTicks, player, false, false);
|
return super.getCameraPosition(partialTicks, player, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public boolean useFixedCameraPos(Entity entity) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -844,4 +844,9 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
}
|
}
|
||||||
return super.getCameraPosition(partialTicks, player, false, false);
|
return super.getCameraPosition(partialTicks, player, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public boolean useFixedCameraPos(Entity entity) {
|
||||||
|
return this.getSeatIndex(entity) == 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -598,4 +598,9 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
}
|
}
|
||||||
return super.getCameraPosition(partialTicks, player, zoom, isFirstPerson);
|
return super.getCameraPosition(partialTicks, player, zoom, isFirstPerson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public boolean useFixedCameraPos(Entity entity) {
|
||||||
|
return this.getSeatIndex(entity) == 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1026,14 +1026,33 @@ public abstract class VehicleEntity extends Entity {
|
||||||
public void renderThirdPersonOverlay(GuiGraphics guiGraphics, Font font, Player player, int screenWidth, int screenHeight, float scale) {
|
public void renderThirdPersonOverlay(GuiGraphics guiGraphics, Font font, Player player, int screenWidth, int screenHeight, float scale) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取视角旋转
|
||||||
|
*
|
||||||
|
* @param zoom 是否在载具上瞄准
|
||||||
|
* @param isFirstPerson 是否是第一人称视角
|
||||||
|
*/
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Nullable
|
@Nullable
|
||||||
public Vec2 getCameraRotation(float partialTicks, Player player, boolean zoom, boolean isFirstPerson) {
|
public Vec2 getCameraRotation(float partialTicks, Player player, boolean zoom, boolean isFirstPerson) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取视角位置
|
||||||
|
* @param zoom 是否在载具上瞄准
|
||||||
|
* @param isFirstPerson 是否是第一人称视角
|
||||||
|
*/
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public Vec3 getCameraPosition(float partialTicks, Player player, boolean zoom, boolean isFirstPerson) {
|
public Vec3 getCameraPosition(float partialTicks, Player player, boolean zoom, boolean isFirstPerson) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否使用载具固定视角
|
||||||
|
*/
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public boolean useFixedCameraPos(Entity entity) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package com.atsuishio.superbwarfare.mixins;
|
package com.atsuishio.superbwarfare.mixins;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.A10Entity;
|
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.PrismTankEntity;
|
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity;
|
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
|
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
@ -52,11 +48,8 @@ public class GameRendererMixin {
|
||||||
if (entity != null && !mainCamera.isDetached() && entity.getRootVehicle() instanceof VehicleEntity vehicle) {
|
if (entity != null && !mainCamera.isDetached() && entity.getRootVehicle() instanceof VehicleEntity vehicle) {
|
||||||
// rotate camera
|
// rotate camera
|
||||||
float a = vehicle.getTurretYaw(partialTicks);
|
float a = vehicle.getTurretYaw(partialTicks);
|
||||||
|
|
||||||
float r = (Mth.abs(a) - 90f) / 90f;
|
float r = (Mth.abs(a) - 90f) / 90f;
|
||||||
|
|
||||||
float r2;
|
float r2;
|
||||||
|
|
||||||
if (Mth.abs(a) <= 90f) {
|
if (Mth.abs(a) <= 90f) {
|
||||||
r2 = a / 90f;
|
r2 = a / 90f;
|
||||||
} else {
|
} else {
|
||||||
|
@ -69,10 +62,7 @@ public class GameRendererMixin {
|
||||||
|
|
||||||
poseStack.mulPose(Axis.ZP.rotationDegrees(-r * vehicle.getRoll(partialTicks) + r2 * vehicle.getViewXRot(partialTicks)));
|
poseStack.mulPose(Axis.ZP.rotationDegrees(-r * vehicle.getRoll(partialTicks) + r2 * vehicle.getViewXRot(partialTicks)));
|
||||||
|
|
||||||
if (!(vehicle instanceof SpeedboatEntity speedboat && entity == speedboat.getFirstPassenger()) &&
|
if (!vehicle.useFixedCameraPos(entity)) {
|
||||||
!(vehicle instanceof PrismTankEntity prismTank && entity == prismTank.getFirstPassenger()) &&
|
|
||||||
!(vehicle instanceof CannonEntity) && !(vehicle instanceof A10Entity)
|
|
||||||
) {
|
|
||||||
// fetch eye offset
|
// fetch eye offset
|
||||||
float eye = entity.getEyeHeight();
|
float eye = entity.getEyeHeight();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue