添加XY100乘客武器开火火焰和HUD
This commit is contained in:
parent
077d97eb91
commit
6398671f16
15 changed files with 344 additions and 93 deletions
|
@ -358,10 +358,8 @@ public class ClickHandler {
|
||||||
public static void handleWeaponZoomPress(Player player, ItemStack stack) {
|
public static void handleWeaponZoomPress(Player player, ItemStack stack) {
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new ZoomMessage(0));
|
ModUtils.PACKET_HANDLER.sendToServer(new ZoomMessage(0));
|
||||||
|
|
||||||
if (player.getVehicle() instanceof ArmedVehicleEntity iVehicle && iVehicle.banHand(player)) {
|
if (player.getVehicle() instanceof VehicleEntity pVehicle && player.getVehicle() instanceof WeaponVehicleEntity iVehicle && iVehicle.hasWeapon(pVehicle.getSeatIndex(player))) {
|
||||||
if (iVehicle.isDriver(player)) {
|
|
||||||
ClientEventHandler.zoomVehicle = true;
|
ClientEventHandler.zoomVehicle = true;
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.client.overlay;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModKeyMappings;
|
import com.atsuishio.superbwarfare.init.ModKeyMappings;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
@ -50,7 +51,7 @@ public class AmmoBarOverlay {
|
||||||
if (player.isSpectator()) return;
|
if (player.isSpectator()) return;
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (stack.getItem() instanceof GunItem gunItem) {
|
if (stack.getItem() instanceof GunItem gunItem &&!(player.getVehicle() instanceof ArmedVehicleEntity vehicle && vehicle.banHand(player))) {
|
||||||
PoseStack poseStack = event.getGuiGraphics().pose();
|
PoseStack poseStack = event.getGuiGraphics().pose();
|
||||||
|
|
||||||
// 渲染图标
|
// 渲染图标
|
||||||
|
|
|
@ -178,7 +178,7 @@ public class KillMessageOverlay {
|
||||||
|
|
||||||
if (player != null && player.getVehicle() instanceof VehicleEntity vehicleEntity) {
|
if (player != null && player.getVehicle() instanceof VehicleEntity vehicleEntity) {
|
||||||
// 载具图标
|
// 载具图标
|
||||||
if ((vehicleEntity instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand(player)) || record.damageType == ModDamageTypes.VEHICLE_STRIKE) {
|
if ((vehicleEntity instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player)) || record.damageType == ModDamageTypes.VEHICLE_STRIKE) {
|
||||||
renderItem = true;
|
renderItem = true;
|
||||||
|
|
||||||
ResourceLocation resourceLocation = vehicleEntity.getVehicleIcon();
|
ResourceLocation resourceLocation = vehicleEntity.getVehicleIcon();
|
||||||
|
|
|
@ -96,50 +96,50 @@ public class VehicleHudOverlay {
|
||||||
}
|
}
|
||||||
poseStack.popPose();
|
poseStack.popPose();
|
||||||
|
|
||||||
if (vehicle instanceof ArmedVehicleEntity iVehicle && iVehicle.getAmmoCount(player) != -1 && iVehicle.isDriver(player)) {
|
// if (vehicle instanceof ArmedVehicleEntity iVehicle && iVehicle.getAmmoCount(player) != -1 && iVehicle.isDriver(player)) {
|
||||||
boolean iCharge = iVehicle instanceof EnergyVehicleEntity;
|
// boolean iCharge = iVehicle instanceof EnergyVehicleEntity;
|
||||||
|
//
|
||||||
// 渲染当前弹药量
|
// // 渲染当前弹药量
|
||||||
poseStack.pushPose();
|
// poseStack.pushPose();
|
||||||
poseStack.scale(1.5f, 1.5f, 1f);
|
// poseStack.scale(1.5f, 1.5f, 1f);
|
||||||
float v = h / 1.5f - (iCharge ? 42 : 29) / 1.5f;
|
// float v = h / 1.5f - (iCharge ? 42 : 29) / 1.5f;
|
||||||
|
//
|
||||||
if (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))
|
// if (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))
|
||||||
&& !(iVehicle instanceof CannonEntity
|
// && !(iVehicle instanceof CannonEntity
|
||||||
|| (iVehicle instanceof Ah6Entity ah6Entity && ah6Entity.getWeaponType(0) == 1))
|
// || (iVehicle instanceof Ah6Entity ah6Entity && ah6Entity.getWeaponType(0) == 1))
|
||||||
) {
|
// ) {
|
||||||
event.getGuiGraphics().drawString(
|
// event.getGuiGraphics().drawString(
|
||||||
Minecraft.getInstance().font,
|
// Minecraft.getInstance().font,
|
||||||
"∞",
|
// "∞",
|
||||||
w / 1.5f - 41 / 1.5f,
|
// w / 1.5f - 41 / 1.5f,
|
||||||
v,
|
// v,
|
||||||
0xFFFFFF,
|
// 0xFFFFFF,
|
||||||
true
|
// true
|
||||||
);
|
// );
|
||||||
} else {
|
// } else {
|
||||||
event.getGuiGraphics().drawString(
|
// event.getGuiGraphics().drawString(
|
||||||
Minecraft.getInstance().font,
|
// Minecraft.getInstance().font,
|
||||||
iVehicle.getAmmoCount(player) + "",
|
// iVehicle.getAmmoCount(player) + "",
|
||||||
w / 1.5f - 41 / 1.5f,
|
// w / 1.5f - 41 / 1.5f,
|
||||||
v,
|
// v,
|
||||||
0xFFFFFF,
|
// 0xFFFFFF,
|
||||||
true
|
// true
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
poseStack.popPose();
|
// poseStack.popPose();
|
||||||
ItemStack stack = player.getMainHandItem();
|
// ItemStack stack = player.getMainHandItem();
|
||||||
|
//
|
||||||
// 渲染弹药类型
|
// // 渲染弹药类型
|
||||||
event.getGuiGraphics().drawString(
|
// event.getGuiGraphics().drawString(
|
||||||
Minecraft.getInstance().font,
|
// Minecraft.getInstance().font,
|
||||||
getVehicleAmmoType(stack, iVehicle),
|
// getVehicleAmmoType(stack, iVehicle),
|
||||||
w - 90,
|
// w - 90,
|
||||||
h - (iCharge ? 38 : 26),
|
// h - (iCharge ? 38 : 26),
|
||||||
0xFFFFFF,
|
// 0xFFFFFF,
|
||||||
true
|
// true
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldRenderHud(Player player) {
|
private static boolean shouldRenderHud(Player player) {
|
||||||
|
@ -420,7 +420,7 @@ public class VehicleHudOverlay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renderKillIndicator3P(GuiGraphics guiGraphics, float posX, float posY) {
|
public static void renderKillIndicator3P(GuiGraphics guiGraphics, float posX, float posY) {
|
||||||
float rate = (40 - KILL_INDICATOR * 5) / 5.5f;
|
float rate = (40 - KILL_INDICATOR * 5) / 5.5f;
|
||||||
|
|
||||||
if (HIT_INDICATOR > 0) {
|
if (HIT_INDICATOR > 0) {
|
||||||
|
|
|
@ -3,20 +3,37 @@ package com.atsuishio.superbwarfare.client.overlay;
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
|
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.Camera;
|
||||||
|
import net.minecraft.client.CameraType;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.RenderGuiEvent;
|
import net.minecraftforge.client.event.RenderGuiEvent;
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import org.joml.Math;
|
||||||
|
|
||||||
|
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||||
|
import static com.atsuishio.superbwarfare.client.overlay.VehicleHudOverlay.renderKillIndicator3P;
|
||||||
|
import static com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity.MACHINE_GUN_HEAT;
|
||||||
|
import static com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity.MG_AMMO;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||||
public class VehicleMgHudOverlay {
|
public class VehicleMgHudOverlay {
|
||||||
|
@ -25,7 +42,12 @@ public class VehicleMgHudOverlay {
|
||||||
public static void eventHandler(RenderGuiEvent.Pre event) {
|
public static void eventHandler(RenderGuiEvent.Pre event) {
|
||||||
int w = event.getWindow().getGuiScaledWidth();
|
int w = event.getWindow().getGuiScaledWidth();
|
||||||
int h = event.getWindow().getGuiScaledHeight();
|
int h = event.getWindow().getGuiScaledHeight();
|
||||||
Player player = Minecraft.getInstance().player;
|
Minecraft mc = Minecraft.getInstance();
|
||||||
|
Player player = mc.player;
|
||||||
|
GuiGraphics guiGraphics = event.getGuiGraphics();
|
||||||
|
PoseStack poseStack = guiGraphics.pose();
|
||||||
|
Camera camera = mc.gameRenderer.getMainCamera();
|
||||||
|
Vec3 cameraPos = camera.getPosition();
|
||||||
|
|
||||||
if (!shouldRenderCrossHair(player)) return;
|
if (!shouldRenderCrossHair(player)) return;
|
||||||
|
|
||||||
|
@ -39,6 +61,8 @@ public class VehicleMgHudOverlay {
|
||||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||||
|
|
||||||
|
if (player.getVehicle() instanceof LandArmorEntity iLand && iLand instanceof WeaponVehicleEntity && iLand instanceof MobileVehicleEntity mobileVehicle) {
|
||||||
|
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || ClientEventHandler.zoomVehicle) {
|
||||||
float fovAdjust = (float) 70 / Minecraft.getInstance().options.fov().get();
|
float fovAdjust = (float) 70 / Minecraft.getInstance().options.fov().get();
|
||||||
|
|
||||||
float f = (float) Math.min(w, h);
|
float f = (float) Math.min(w, h);
|
||||||
|
@ -47,12 +71,51 @@ public class VehicleMgHudOverlay {
|
||||||
int j = Mth.floor(f * f1);
|
int j = Mth.floor(f * f1);
|
||||||
int k = (w - i) / 2;
|
int k = (w - i) / 2;
|
||||||
int l = (h - j) / 2;
|
int l = (h - j) / 2;
|
||||||
RenderHelper.preciseBlit(event.getGuiGraphics(), ModUtils.loc("textures/screens/cannon/cannon_crosshair_notzoom.png"), k, l, 0, 0.0F, i, j, i, j);
|
RenderHelper.preciseBlit(guiGraphics, ModUtils.loc("textures/screens/cannon/cannon_crosshair_notzoom.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||||
|
VehicleHudOverlay.renderKillIndicator(guiGraphics, w, h);
|
||||||
|
|
||||||
|
} else if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && !ClientEventHandler.zoomVehicle) {
|
||||||
|
Vec3 p = RenderHelper.worldToScreen(new Vec3(Mth.lerp(event.getPartialTick(), player.xo, player.getX()), Mth.lerp(event.getPartialTick(), player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(event.getPartialTick(), player.zo, player.getZ())).add(iLand.getGunVec(event.getPartialTick()).scale(192)), cameraPos);
|
||||||
|
// 第三人称准星
|
||||||
|
if (p != null) {
|
||||||
|
poseStack.pushPose();
|
||||||
|
float x = (float) p.x;
|
||||||
|
float y = (float) p.y;
|
||||||
|
|
||||||
|
poseStack.pushPose();
|
||||||
|
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/drone.png"), x - 12, y - 12, 0, 0, 24, 24, 24, 24);
|
||||||
|
renderKillIndicator3P(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||||
|
|
||||||
|
poseStack.pushPose();
|
||||||
|
|
||||||
|
poseStack.translate(x, y, 0);
|
||||||
|
poseStack.scale(0.75f, 0.75f, 1);
|
||||||
|
|
||||||
|
|
||||||
|
//YX-100
|
||||||
|
if (player.getVehicle() instanceof Yx100Entity yx100) {
|
||||||
|
double heat = yx100.getEntityData().get(MACHINE_GUN_HEAT) / 100.0F;
|
||||||
|
guiGraphics.drawString(mc.font, Component.literal(".50 HMG " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "∞" : yx100.getEntityData().get(MG_AMMO))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
double heal = 1 - mobileVehicle.getHealth() / mobileVehicle.getMaxHealth();
|
||||||
|
|
||||||
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HP " +
|
||||||
|
FormatTool.format0D(100 * mobileVehicle.getHealth() / mobileVehicle.getMaxHealth())), 30, 1, Mth.hsvToRgb(0F, (float) heal, 1.0F), false);
|
||||||
|
|
||||||
|
poseStack.popPose();
|
||||||
|
poseStack.popPose();
|
||||||
|
poseStack.popPose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldRenderCrossHair(Player player) {
|
private static boolean shouldRenderCrossHair(Player player) {
|
||||||
if (player == null) return false;
|
if (player == null) return false;
|
||||||
return !player.isSpectator()
|
return !player.isSpectator()
|
||||||
&& player.getVehicle() instanceof SpeedboatEntity && ClientEventHandler.zoomVehicle && !player.getMainHandItem().is(ModTags.Items.GUN);
|
&& (player.getVehicle() instanceof SpeedboatEntity
|
||||||
|
|| player.getVehicle() instanceof Yx100Entity yx100 && yx100.getNthEntity(1) == player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -539,6 +539,11 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
return getBarrelVector(ticks);
|
return getBarrelVector(ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vec3 getGunVec(float ticks) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public float getTurretYRot() {
|
public float getTurretYRot() {
|
||||||
return this.turretYRot;
|
return this.turretYRot;
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,6 +483,11 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
return getBarrelVector(ticks);
|
return getBarrelVector(ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vec3 getGunVec(float ticks) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public float getTurretYRot() {
|
public float getTurretYRot() {
|
||||||
return this.turretYRot;
|
return this.turretYRot;
|
||||||
}
|
}
|
||||||
|
|
|
@ -438,7 +438,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
if (this.cannotFire) return;
|
if (this.cannotFire) return;
|
||||||
|
|
||||||
Matrix4f transform = getGunTransform();
|
Matrix4f transform = getGunTransform();
|
||||||
Vector4f worldPosition = transformPosition(transform, 0, -0.2f, 0);
|
Vector4f worldPosition = transformPosition(transform, 0, -0.25f, 0);
|
||||||
|
|
||||||
ProjectileEntity projectile = new ProjectileEntity(player.level())
|
ProjectileEntity projectile = new ProjectileEntity(player.level())
|
||||||
.shooter(player)
|
.shooter(player)
|
||||||
|
@ -448,7 +448,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
projectile.bypassArmorRate(0.4f);
|
projectile.bypassArmorRate(0.4f);
|
||||||
projectile.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z);
|
projectile.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z);
|
||||||
projectile.shoot(getGunVector(1).x, getGunVector(1).y + 0.005f, getGunVector(1).z, 20, 0.02f);
|
projectile.shoot(getGunVector(1).x, getGunVector(1).y + 0.005f, getGunVector(1).z, 20, 0.3f);
|
||||||
this.level().addFreshEntity(projectile);
|
this.level().addFreshEntity(projectile);
|
||||||
|
|
||||||
float pitch = this.entityData.get(MACHINE_GUN_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - this.entityData.get(MACHINE_GUN_HEAT)));
|
float pitch = this.entityData.get(MACHINE_GUN_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - this.entityData.get(MACHINE_GUN_HEAT)));
|
||||||
|
@ -469,7 +469,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||||
if (target instanceof ServerPlayer serverPlayer) {
|
if (target instanceof ServerPlayer serverPlayer) {
|
||||||
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(6, 5, 5, this.getX(), this.getEyeY(), this.getZ()));
|
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(6, 4, 8, this.getX(), this.getEyeY(), this.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,8 +608,8 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
diffY = Mth.wrapDegrees(gunAngle - getGunYRot());
|
diffY = Mth.wrapDegrees(gunAngle - getGunYRot());
|
||||||
diffX = Mth.wrapDegrees(gunner.getXRot() - this.getGunXRot());
|
diffX = Mth.wrapDegrees(gunner.getXRot() - this.getGunXRot());
|
||||||
|
|
||||||
this.setGunXRot(Mth.clamp(this.getGunXRot() + Mth.clamp(0.95f * diffX, -10, 10), -50f, 10f));
|
this.setGunXRot(Mth.clamp(this.getGunXRot() + Mth.clamp(0.95f * diffX, -10, 10), -60f, 12.5f));
|
||||||
this.setGunYRot(this.getGunYRot() + Mth.clamp(0.9f * diffY, -18, 18));
|
this.setGunYRot(this.getGunYRot() + Mth.clamp(0.9f * diffY, -15, 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -653,6 +653,11 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
return getBarrelVector(ticks);
|
return getBarrelVector(ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vec3 getGunVec(float ticks) {
|
||||||
|
return getGunVector(ticks);
|
||||||
|
}
|
||||||
|
|
||||||
public float getTurretYRot() {
|
public float getTurretYRot() {
|
||||||
return this.turretYRot;
|
return this.turretYRot;
|
||||||
}
|
}
|
||||||
|
@ -814,13 +819,13 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void clampRotation(Entity entity) {
|
protected void clampRotation(Entity entity) {
|
||||||
|
Minecraft mc = Minecraft.getInstance();
|
||||||
if (entity.level().isClientSide && entity == getFirstPassenger()) {
|
if (entity.level().isClientSide && entity == getFirstPassenger()) {
|
||||||
float f = Mth.wrapDegrees(entity.getXRot());
|
float f = Mth.wrapDegrees(entity.getXRot());
|
||||||
float f1 = Mth.clamp(f, -30F, 4F);
|
float f1 = Mth.clamp(f, -30F, 4F);
|
||||||
entity.xRotO += f1 - f;
|
entity.xRotO += f1 - f;
|
||||||
entity.setXRot(entity.getXRot() + f1 - f);
|
entity.setXRot(entity.getXRot() + f1 - f);
|
||||||
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
if (mc.options.getCameraType() == CameraType.FIRST_PERSON) {
|
if (mc.options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||||
entity.setYBodyRot(this.getYRot());
|
entity.setYBodyRot(this.getYRot());
|
||||||
float f2 = Mth.wrapDegrees(entity.getYRot() - this.getBarrelYRot(1));
|
float f2 = Mth.wrapDegrees(entity.getYRot() - this.getBarrelYRot(1));
|
||||||
|
@ -831,9 +836,18 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
}
|
}
|
||||||
} else if (entity == getNthEntity(1)) {
|
} else if (entity == getNthEntity(1)) {
|
||||||
float f = Mth.wrapDegrees(entity.getXRot());
|
float f = Mth.wrapDegrees(entity.getXRot());
|
||||||
float f1 = Mth.clamp(f, -50F, 10F);
|
float f1 = Mth.clamp(f, -60F, 12.5F);
|
||||||
entity.xRotO += f1 - f;
|
entity.xRotO += f1 - f;
|
||||||
entity.setXRot(entity.getXRot() + f1 - f);
|
entity.setXRot(entity.getXRot() + f1 - f);
|
||||||
|
|
||||||
|
if (mc.options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||||
|
entity.setYBodyRot(this.getYRot());
|
||||||
|
float f2 = Mth.wrapDegrees(entity.getYRot() - this.getGunYRot(1));
|
||||||
|
float f3 = Mth.clamp(f2, -150.0F, 150.0F);
|
||||||
|
entity.yRotO += f3 - f2;
|
||||||
|
entity.setYRot(entity.getYRot() + f3 - f2);
|
||||||
|
entity.setYBodyRot(this.getYRot());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,9 +863,17 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.yx100.idle"));
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.yx100.idle"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PlayState gunFirePredicate(AnimationState<Yx100Entity> event) {
|
||||||
|
if (this.entityData.get(FIRE_TIME) > 0) {
|
||||||
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.yx100.fire2"));
|
||||||
|
}
|
||||||
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.yx100.idle"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
||||||
data.add(new AnimationController<>(this, "movement", 0, this::firePredicate));
|
data.add(new AnimationController<>(this, "movement", 0, this::firePredicate));
|
||||||
|
data.add(new AnimationController<>(this, "shoot", 0, this::gunFirePredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,4 +13,6 @@ public interface LandArmorEntity extends ArmedVehicleEntity {
|
||||||
float turretXRot();
|
float turretXRot();
|
||||||
|
|
||||||
Vec3 getBarrelVec(float ticks);
|
Vec3 getBarrelVec(float ticks);
|
||||||
|
|
||||||
|
Vec3 getGunVec(float ticks);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1335,8 +1335,8 @@ public class ClientEventHandler {
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
if (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && iArmedVehicle.banHand(player) && zoomVehicle) {
|
if (player.getVehicle() instanceof WeaponVehicleEntity iVehicle && zoomVehicle) {
|
||||||
event.setFOV(event.getFOV() / iArmedVehicle.zoomFov());
|
event.setFOV(event.getFOV() / iVehicle.zoomFov());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1435,7 +1435,7 @@ public class ClientEventHandler {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player)) {
|
if (player.getVehicle() instanceof VehicleEntity pVehicle && player.getVehicle() instanceof WeaponVehicleEntity iVehicle && iVehicle.hasWeapon(pVehicle.getSeatIndex(player))) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,8 +178,12 @@ public abstract class CameraMixin {
|
||||||
move(-getMaxZoom(3), 1, 0.0);
|
move(-getMaxZoom(3), 1, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thirdPerson && entity.getVehicle() instanceof Yx100Entity && !ClientEventHandler.zoomVehicle) {
|
if (thirdPerson && entity.getVehicle() instanceof Yx100Entity yx100 && !ClientEventHandler.zoomVehicle) {
|
||||||
move(-getMaxZoom(5), 1.5, 0.0);
|
if (yx100.getFirstPassenger() == entity) {
|
||||||
|
move(-getMaxZoom(5), 1.5, -0.8669625f);
|
||||||
|
} else if (yx100.getNthEntity(1) == entity) {
|
||||||
|
move(-getMaxZoom(-0.5), 2, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class MouseHandlerMixin {
|
||||||
if (player == yx100.getFirstPassenger()) {
|
if (player == yx100.getFirstPassenger()) {
|
||||||
return ClientEventHandler.zoomVehicle ? 0.17 : 0.22;
|
return ClientEventHandler.zoomVehicle ? 0.17 : 0.22;
|
||||||
} else if (player ==yx100.getNthEntity(1)){
|
} else if (player ==yx100.getNthEntity(1)){
|
||||||
return ClientEventHandler.zoomVehicle ? 0.27 : 0.35;
|
return ClientEventHandler.zoomVehicle ? 0.25 : 0.35;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
"bones": {
|
"bones": {
|
||||||
"glow": {
|
"glow": {
|
||||||
"scale": 0
|
"scale": 0
|
||||||
|
},
|
||||||
|
"flare": {
|
||||||
|
"scale": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -122,6 +125,39 @@
|
||||||
"0.9917": [0, 0, 0],
|
"0.9917": [0, 0, 0],
|
||||||
"2.0": [0, 0, 0]
|
"2.0": [0, 0, 0]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"flare": {
|
||||||
|
"scale": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"animation.yx100.fire2": {
|
||||||
|
"loop": "hold_on_last_frame",
|
||||||
|
"animation_length": 0.5,
|
||||||
|
"bones": {
|
||||||
|
"glow": {
|
||||||
|
"scale": 0
|
||||||
|
},
|
||||||
|
"flare": {
|
||||||
|
"scale": {
|
||||||
|
"0.0": [0, 0, 0],
|
||||||
|
"0.0083": [8, 8, 8],
|
||||||
|
"0.05": [11, 11, 11],
|
||||||
|
"0.075": [1, 1, 1],
|
||||||
|
"0.0917": [0, 0, 0],
|
||||||
|
"0.15": [0, 0, 0]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"action": {
|
||||||
|
"position": {
|
||||||
|
"0.0": [0, 0, 0],
|
||||||
|
"0.0417": {
|
||||||
|
"pre": [0, 0, 4.1],
|
||||||
|
"post": [0, 0, 6.1],
|
||||||
|
"lerp_mode": "catmullrom"
|
||||||
|
},
|
||||||
|
"0.1167": [0, 0, 0]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
"texture_width": 1024,
|
"texture_width": 1024,
|
||||||
"texture_height": 1024,
|
"texture_height": 1024,
|
||||||
"visible_bounds_width": 81,
|
"visible_bounds_width": 81,
|
||||||
"visible_bounds_height": 15,
|
"visible_bounds_height": 16,
|
||||||
"visible_bounds_offset": [0, 0.5, 0]
|
"visible_bounds_offset": [0, 1, 0]
|
||||||
},
|
},
|
||||||
"bones": [
|
"bones": [
|
||||||
{
|
{
|
||||||
|
@ -1405,9 +1405,9 @@
|
||||||
"pivot": [22.01115, 53.85625, 54.84162],
|
"pivot": [22.01115, 53.85625, 54.84162],
|
||||||
"cubes": [
|
"cubes": [
|
||||||
{
|
{
|
||||||
"origin": [22.14844, 49.35625, 54.70433],
|
"origin": [22.4799, 49.35625, 54.84162],
|
||||||
"size": [0.9375, 60, 0],
|
"size": [0.9375, 60, 0],
|
||||||
"pivot": [22.61719, 56.3875, 55.17308],
|
"pivot": [22.94865, 79.35625, 54.84162],
|
||||||
"rotation": [0, -45, 0],
|
"rotation": [0, -45, 0],
|
||||||
"uv": {
|
"uv": {
|
||||||
"north": {"uv": [422, 566], "uv_size": [1, 64]}
|
"north": {"uv": [422, 566], "uv_size": [1, 64]}
|
||||||
|
@ -7513,28 +7513,143 @@
|
||||||
"up": {"uv": [344, 602], "uv_size": [4, 14]},
|
"up": {"uv": [344, 602], "uv_size": [4, 14]},
|
||||||
"down": {"uv": [348, 616], "uv_size": [4, -14]}
|
"down": {"uv": [348, 616], "uv_size": [4, -14]}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"origin": [-15.8914, 60.01786, -20.3125],
|
"name": "flare",
|
||||||
"size": [1.875, 1.875, 5.625],
|
"parent": "qiangguan",
|
||||||
"pivot": [-14.42656, 61.00808, -20.78125],
|
"pivot": [-14.13, 61.41482, -30.27799],
|
||||||
"rotation": [0, 0, 135],
|
"cubes": [
|
||||||
|
{
|
||||||
|
"origin": [-14.85751, 60.68732, -30.33986],
|
||||||
|
"size": [1.455, 1.455, 0],
|
||||||
"uv": {
|
"uv": {
|
||||||
"east": {"uv": [639, 44], "uv_size": [6, 2]},
|
"north": {"uv": [900, 548], "uv_size": [114, 114]},
|
||||||
"south": {"uv": [538, 652], "uv_size": [1, 2]},
|
"south": {"uv": [1014, 548], "uv_size": [-114, 114]}
|
||||||
"west": {"uv": [639, 46], "uv_size": [6, 2]},
|
|
||||||
"up": {"uv": [103, 643], "uv_size": [1, 6]},
|
|
||||||
"down": {"uv": [104, 649], "uv_size": [1, -6]}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"origin": [-15.53984, 60.03798, -26.875],
|
"origin": [-15.96001, 60.80731, -31.12738],
|
||||||
"size": [2.8125, 2.8125, 6.5625],
|
"size": [3.66, 1.215, 0],
|
||||||
|
"pivot": [-14.13001, 61.41482, -31.12736],
|
||||||
|
"rotation": [0, -90, 0],
|
||||||
|
"uv": {
|
||||||
|
"north": {"uv": [1014, 548], "uv_size": [-106.125, 114]},
|
||||||
|
"south": {"uv": [907.875, 548], "uv_size": [106.125, 114]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"origin": [-15.96001, 60.80731, -31.12738],
|
||||||
|
"size": [3.66, 1.215, 0],
|
||||||
|
"pivot": [-14.13001, 61.41482, -31.12736],
|
||||||
|
"rotation": [0, -90, 60],
|
||||||
|
"uv": {
|
||||||
|
"north": {"uv": [1014, 548], "uv_size": [-106.125, 114]},
|
||||||
|
"south": {"uv": [907.875, 548], "uv_size": [106.125, 114]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"origin": [-15.96001, 60.80731, -31.12738],
|
||||||
|
"size": [3.66, 1.215, 0],
|
||||||
|
"pivot": [-14.13001, 61.41482, -31.12736],
|
||||||
|
"rotation": [0, -90, 120],
|
||||||
|
"uv": {
|
||||||
|
"north": {"uv": [1014, 548], "uv_size": [-106.125, 114]},
|
||||||
|
"south": {"uv": [907.875, 548], "uv_size": [106.125, 114]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "action",
|
||||||
|
"parent": "qiangguan",
|
||||||
|
"pivot": [-14.13359, 61.44423, -23.10156],
|
||||||
|
"cubes": [
|
||||||
|
{
|
||||||
|
"origin": [-15.02845, 61.03074, -20.3125],
|
||||||
|
"size": [1.875, 0.775, 5.625],
|
||||||
|
"pivot": [-14.09095, 61.41824, -17.5],
|
||||||
|
"rotation": [0, 0, 112.5],
|
||||||
|
"uv": {
|
||||||
|
"east": {"uv": [639, 44], "uv_size": [6, 2]},
|
||||||
|
"west": {"uv": [639, 46], "uv_size": [6, 2]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"origin": [-14.62765, 60.24892, -25.3125],
|
||||||
|
"size": [0.98812, 2.39063, 5],
|
||||||
|
"pivot": [-14.13359, 61.44423, -23.10156],
|
||||||
|
"rotation": [0, 0, 22.5],
|
||||||
|
"uv": {
|
||||||
|
"north": {"uv": [133, 650], "uv_size": [1, 3]},
|
||||||
|
"south": {"uv": [170, 650], "uv_size": [1, 3]},
|
||||||
|
"up": {"uv": [69, 642], "uv_size": [1, 7]},
|
||||||
|
"down": {"uv": [70, 649], "uv_size": [1, -7]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"origin": [-15.02845, 61.03074, -20.3125],
|
||||||
|
"size": [1.875, 0.775, 5.625],
|
||||||
|
"pivot": [-14.09095, 61.41824, -17.5],
|
||||||
|
"rotation": [0, 0, 67.5],
|
||||||
|
"uv": {
|
||||||
|
"east": {"uv": [639, 44], "uv_size": [6, 2]},
|
||||||
|
"west": {"uv": [639, 46], "uv_size": [6, 2]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"origin": [-15.02845, 61.03074, -20.3125],
|
||||||
|
"size": [1.875, 0.775, 5.625],
|
||||||
|
"pivot": [-14.09095, 61.41824, -17.5],
|
||||||
|
"rotation": [0, 0, 157.5],
|
||||||
|
"uv": {
|
||||||
|
"east": {"uv": [639, 44], "uv_size": [6, 2]},
|
||||||
|
"west": {"uv": [639, 46], "uv_size": [6, 2]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"origin": [-15.02845, 61.03074, -20.3125],
|
||||||
|
"size": [1.875, 0.775, 5.625],
|
||||||
|
"pivot": [-14.09095, 61.41824, -17.5],
|
||||||
|
"rotation": [0, 0, 22.5],
|
||||||
|
"uv": {
|
||||||
|
"east": {"uv": [639, 44], "uv_size": [6, 2]},
|
||||||
|
"west": {"uv": [639, 46], "uv_size": [6, 2]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"origin": [-14.62765, 60.24892, -25.3125],
|
||||||
|
"size": [0.98812, 2.39063, 5],
|
||||||
|
"pivot": [-14.13359, 61.44423, -23.10156],
|
||||||
|
"rotation": [0, 0, -22.5],
|
||||||
|
"uv": {
|
||||||
|
"north": {"uv": [133, 650], "uv_size": [1, 3]},
|
||||||
|
"south": {"uv": [170, 650], "uv_size": [1, 3]},
|
||||||
|
"up": {"uv": [69, 642], "uv_size": [1, 7]},
|
||||||
|
"down": {"uv": [70, 649], "uv_size": [1, -7]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"origin": [-14.62765, 60.24892, -25.3125],
|
||||||
|
"size": [0.98812, 2.39063, 5],
|
||||||
|
"pivot": [-14.13359, 61.44423, -23.10156],
|
||||||
|
"rotation": [0, 0, 67.5],
|
||||||
|
"uv": {
|
||||||
|
"north": {"uv": [133, 650], "uv_size": [1, 3]},
|
||||||
|
"south": {"uv": [170, 650], "uv_size": [1, 3]},
|
||||||
|
"up": {"uv": [69, 642], "uv_size": [1, 7]},
|
||||||
|
"down": {"uv": [70, 649], "uv_size": [1, -7]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"origin": [-14.62765, 60.24892, -25.3125],
|
||||||
|
"size": [0.98812, 2.39063, 5],
|
||||||
|
"pivot": [-14.13359, 61.44423, -23.10156],
|
||||||
|
"rotation": [0, 0, -67.5],
|
||||||
"uv": {
|
"uv": {
|
||||||
"north": {"uv": [133, 650], "uv_size": [1, 3]},
|
"north": {"uv": [133, 650], "uv_size": [1, 3]},
|
||||||
"east": {"uv": [192, 631], "uv_size": [7, 3]},
|
|
||||||
"south": {"uv": [170, 650], "uv_size": [1, 3]},
|
"south": {"uv": [170, 650], "uv_size": [1, 3]},
|
||||||
"west": {"uv": [631, 194], "uv_size": [7, 3]},
|
|
||||||
"up": {"uv": [69, 642], "uv_size": [1, 7]},
|
"up": {"uv": [69, 642], "uv_size": [1, 7]},
|
||||||
"down": {"uv": [70, 649], "uv_size": [1, -7]}
|
"down": {"uv": [70, 649], "uv_size": [1, -7]}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 88 KiB |
Loading…
Add table
Reference in a new issue