优化A10瞄准,蝴蝶雷不再破坏方块
This commit is contained in:
parent
ee91c581f1
commit
0fcfdee2ee
6 changed files with 42 additions and 30 deletions
|
@ -7,7 +7,6 @@ import com.atsuishio.superbwarfare.entity.vehicle.A10Entity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.AircraftEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.AircraftEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|
||||||
import com.atsuishio.superbwarfare.event.ClientMouseHandler;
|
import com.atsuishio.superbwarfare.event.ClientMouseHandler;
|
||||||
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||||
|
@ -39,6 +38,7 @@ import java.util.List;
|
||||||
|
|
||||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||||
import static com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity.HEAT;
|
import static com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity.HEAT;
|
||||||
|
import static com.atsuishio.superbwarfare.event.ClientEventHandler.zoomVehicle;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class AircraftOverlay implements LayeredDraw.Layer {
|
public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
|
@ -64,6 +64,7 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
Camera camera = mc.gameRenderer.getMainCamera();
|
Camera camera = mc.gameRenderer.getMainCamera();
|
||||||
Vec3 cameraPos = camera.getPosition();
|
Vec3 cameraPos = camera.getPosition();
|
||||||
PoseStack poseStack = guiGraphics.pose();
|
PoseStack poseStack = guiGraphics.pose();
|
||||||
|
Vec3 lookVec = new Vec3(camera.getLookVector());
|
||||||
|
|
||||||
var partialTick = deltaTracker.getGameTimeDeltaPartialTick(true);
|
var partialTick = deltaTracker.getGameTimeDeltaPartialTick(true);
|
||||||
|
|
||||||
|
@ -89,17 +90,17 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
|
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
|
||||||
double zoom = 3 + 0.06 * fovAdjust2;
|
double zoom = 3 + 0.06 * fovAdjust2;
|
||||||
|
|
||||||
Vec3 pos = aircraftEntity.shootPos(partialTick).add(mobileVehicle.getViewVector(partialTick).scale(192));
|
Vec3 pos = cameraPos.add(mobileVehicle.getViewVector(partialTick).scale(192));
|
||||||
Vec3 lookAngle = mobileVehicle.getViewVector(partialTick).normalize().scale(pos.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
Vec3 lookAngle = lookVec.normalize().scale(pos.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
||||||
|
|
||||||
Vec3 posCross = aircraftEntity.shootPos(partialTick).add(aircraftEntity.shootVec(partialTick).scale(192));
|
Vec3 posCross = cameraPos.add(aircraftEntity.shootVec(partialTick).scale(192));
|
||||||
Vec3 lookAngle2 = aircraftEntity.shootVec(partialTick).normalize().scale(posCross.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
Vec3 lookAngle2 = lookVec.normalize().scale(posCross.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
||||||
|
|
||||||
var cPos = cameraPos.add(lookAngle);
|
var cPos = cameraPos.add(lookAngle);
|
||||||
var cPos2 = cameraPos.add(lookAngle2);
|
var cPos2 = cameraPos.add(lookAngle2);
|
||||||
|
|
||||||
Vec3 p = RenderHelper.worldToScreen(pos, ClientEventHandler.zoomVehicle ? cPos : cameraPos);
|
Vec3 p = RenderHelper.worldToScreen(pos, zoomVehicle ? cPos : cameraPos);
|
||||||
Vec3 pCross = RenderHelper.worldToScreen(posCross, ClientEventHandler.zoomVehicle ? cPos2 : cameraPos);
|
Vec3 pCross = RenderHelper.worldToScreen(posCross, zoomVehicle ? cPos2 : cameraPos);
|
||||||
|
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
|
@ -220,8 +221,8 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
// 准星
|
// 准星
|
||||||
if (pCross != null) {
|
if (pCross != null) {
|
||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
float x = (float) pCross.x;
|
float x = (float) pCross.x + (zoomVehicle ? 6 : 2);
|
||||||
float y = (float) pCross.y;
|
float y = (float) pCross.y + (zoomVehicle ? 15 : 5);
|
||||||
|
|
||||||
if (mc.options.getCameraType() == CameraType.FIRST_PERSON && !(mobileVehicle instanceof A10Entity a10Entity && a10Entity.getWeaponIndex(0) == 3)) {
|
if (mc.options.getCameraType() == CameraType.FIRST_PERSON && !(mobileVehicle instanceof A10Entity a10Entity && a10Entity.getWeaponIndex(0) == 3)) {
|
||||||
RenderSystem.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
|
@ -273,9 +274,9 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
|
|
||||||
for (var e : entities) {
|
for (var e : entities) {
|
||||||
Vec3 pos3 = new Vec3(Mth.lerp(partialTick, e.xo, e.getX()), Mth.lerp(partialTick, e.yo + e.getEyeHeight(), e.getEyeY()), Mth.lerp(partialTick, e.zo, e.getZ()));
|
Vec3 pos3 = new Vec3(Mth.lerp(partialTick, e.xo, e.getX()), Mth.lerp(partialTick, e.yo + e.getEyeHeight(), e.getEyeY()), Mth.lerp(partialTick, e.zo, e.getZ()));
|
||||||
Vec3 lookAngle3 = player.getViewVector(partialTick).normalize().scale(pos3.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
Vec3 lookAngle3 = lookVec.normalize().scale(pos3.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
||||||
var cPos3 = cameraPos.add(lookAngle3);
|
var cPos3 = cameraPos.add(lookAngle3);
|
||||||
Vec3 point = RenderHelper.worldToScreen(pos3, ClientEventHandler.zoomVehicle ? cPos3 : cameraPos);
|
Vec3 point = RenderHelper.worldToScreen(pos3, zoomVehicle ? cPos3 : cameraPos);
|
||||||
if (point != null) {
|
if (point != null) {
|
||||||
boolean nearest = e == targetEntity;
|
boolean nearest = e == targetEntity;
|
||||||
boolean lockOn = a10Entity.locked && nearest;
|
boolean lockOn = a10Entity.locked && nearest;
|
||||||
|
|
|
@ -242,11 +242,11 @@ public class Blu43Entity extends Entity implements GeoEntity, OwnableEntity {
|
||||||
private void triggerExplode() {
|
private void triggerExplode() {
|
||||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||||
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, this.getOwner()), 10f,
|
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, this.getOwner()), 10f,
|
||||||
this.getX(), this.getEyeY(), this.getZ(), 2f, Explosion.BlockInteraction.KEEP, true);
|
this.getX(), this.getEyeY(), this.getZ(), 2f, Explosion.BlockInteraction.KEEP, false);
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
EventHooks.onExplosionStart(this.level(), explosion);
|
EventHooks.onExplosionStart(this.level(), explosion);
|
||||||
explosion.finalizeExplosion(false);
|
explosion.finalizeExplosion(false);
|
||||||
ParticleTool.spawnMiniExplosionParticles(this.level(), this.position());
|
ParticleTool.spawnSmallExplosionParticles(this.level(), this.position());
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -768,11 +768,17 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vec3 shootVec(float tickDelta) {
|
public Vec3 shootVec(float tickDelta) {
|
||||||
|
Matrix4f transform = getVehicleTransform(tickDelta);
|
||||||
|
Vector4f worldPosition;
|
||||||
|
Vector4f worldPosition2;
|
||||||
if (getWeaponIndex(0) == 3) {
|
if (getWeaponIndex(0) == 3) {
|
||||||
return getViewVector(tickDelta);
|
worldPosition = transformPosition(transform, 0, 0, 0);
|
||||||
|
worldPosition2 = transformPosition(transform, 0, 0f, 1);
|
||||||
} else {
|
} else {
|
||||||
return new Vec3(getViewVector(tickDelta).x, getViewVector(tickDelta).y - 0.08, getViewVector(tickDelta).z);
|
worldPosition = transformPosition(transform, 0, 0, 0);
|
||||||
|
worldPosition2 = transformPosition(transform, 0.007f, -0.03f, 1);
|
||||||
}
|
}
|
||||||
|
return new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).vectorTo(new Vec3(worldPosition2.x, worldPosition2.y, worldPosition2.z)).normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -797,7 +803,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
var entityToSpawn = ((SmallCannonShellWeapon) getWeapon(0)).create(player);
|
var entityToSpawn = ((SmallCannonShellWeapon) getWeapon(0)).create(player);
|
||||||
|
|
||||||
entityToSpawn.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
entityToSpawn.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||||
entityToSpawn.shoot(getLookAngle().x, getLookAngle().y - 0.07, getLookAngle().z, 30, 0.5f);
|
entityToSpawn.shoot(shootVec(1).x, shootVec(1).y, shootVec(1).z, 30, 0.5f);
|
||||||
level().addFreshEntity(entityToSpawn);
|
level().addFreshEntity(entityToSpawn);
|
||||||
|
|
||||||
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPosition.x, worldPosition.y, worldPosition.z, 1, 0.2, 0.2, 0.2, 0.001, true);
|
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPosition.x, worldPosition.y, worldPosition.z, 1, 0.2, 0.2, 0.2, 0.001, true);
|
||||||
|
@ -844,10 +850,8 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
fireIndex = 0;
|
fireIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
shootAngle = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).vectorTo(new Vec3(worldPosition2.x, worldPosition2.y, worldPosition2.z)).normalize();
|
|
||||||
|
|
||||||
heliRocketEntity.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
heliRocketEntity.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||||
heliRocketEntity.shoot(shootAngle.x, shootAngle.y - 0.075, shootAngle.z, 8, 0.5f);
|
heliRocketEntity.shoot(shootVec(1).x, shootVec(1).y, shootVec(1).z, 8, 0.5f);
|
||||||
player.level().addFreshEntity(heliRocketEntity);
|
player.level().addFreshEntity(heliRocketEntity);
|
||||||
|
|
||||||
BlockPos pos = BlockPos.containing(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z));
|
BlockPos pos = BlockPos.containing(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z));
|
||||||
|
@ -910,7 +914,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
Agm65Entity.setTargetUuid(getTargetUuid());
|
Agm65Entity.setTargetUuid(getTargetUuid());
|
||||||
}
|
}
|
||||||
Agm65Entity.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
Agm65Entity.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||||
Agm65Entity.shoot(getLookAngle().x, getLookAngle().y, getLookAngle().z, (float) getDeltaMovement().length() + 1, 1);
|
Agm65Entity.shoot(shootVec(1).x, shootVec(1).y, shootVec(1).z, (float) getDeltaMovement().length() + 1, 1);
|
||||||
player.level().addFreshEntity(Agm65Entity);
|
player.level().addFreshEntity(Agm65Entity);
|
||||||
|
|
||||||
BlockPos pos = BlockPos.containing(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z));
|
BlockPos pos = BlockPos.containing(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z));
|
||||||
|
@ -1045,7 +1049,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Vec2 getCameraRotation(float partialTicks, Player player, boolean zoom, boolean isFirstPerson) {
|
public @Nullable Vec2 getCameraRotation(float partialTicks, Player player, boolean zoom, boolean isFirstPerson) {
|
||||||
if (this.getSeatIndex(player) == 0) {
|
if (this.getSeatIndex(player) == 0) {
|
||||||
return new Vec2((float) (getRotY(partialTicks) - 0.5f * Mth.lerp(partialTicks, delta_yo, delta_y) - freeCameraYaw), (float) (getRotX(partialTicks) + (isFirstPerson ? 0 : 4) - 0.5f * Mth.lerp(partialTicks, delta_xo, delta_x) + freeCameraPitch));
|
return new Vec2((float) (getRotY(partialTicks) - 0.5f * Mth.lerp(partialTicks, delta_yo, delta_y) - freeCameraYaw), (float) (getRotX(partialTicks) - 0.5f * Mth.lerp(partialTicks, delta_xo, delta_x) + freeCameraPitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getCameraRotation(partialTicks, player, false, false);
|
return super.getCameraRotation(partialTicks, player, false, false);
|
||||||
|
@ -1058,7 +1062,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
Matrix4f transform = getClientVehicleTransform(partialTicks);
|
Matrix4f transform = getClientVehicleTransform(partialTicks);
|
||||||
|
|
||||||
|
|
||||||
Vector4f worldPosition = transformPosition(transform, 0f, 5, -14);
|
Vector4f worldPosition = transformPosition(transform, 0f, 4, -14);
|
||||||
|
|
||||||
if (isFirstPerson) {
|
if (isFirstPerson) {
|
||||||
return new Vec3(Mth.lerp(partialTicks, player.xo, player.getX()), Mth.lerp(partialTicks, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTicks, player.zo, player.getZ()));
|
return new Vec3(Mth.lerp(partialTicks, player.xo, player.getX()), Mth.lerp(partialTicks, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTicks, player.zo, player.getZ()));
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ClientMouseHandler {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
var tag = NBTTool.getTag(stack);
|
var tag = NBTTool.getTag(stack);
|
||||||
|
|
||||||
if (stack.is(ModItems.MONITOR.get()) && tag.getBoolean("Using") && tag.getBoolean("Linked")) {
|
if (!notInGame() && stack.is(ModItems.MONITOR.get()) && tag.getBoolean("Using") && tag.getBoolean("Linked")) {
|
||||||
DroneEntity drone = EntityFindUtil.findDrone(player.level(), tag.getString("LinkedDrone"));
|
DroneEntity drone = EntityFindUtil.findDrone(player.level(), tag.getString("LinkedDrone"));
|
||||||
if (drone != null) {
|
if (drone != null) {
|
||||||
speedX = drone.getMouseSensitivity() * (posN.x - posO.x);
|
speedX = drone.getMouseSensitivity() * (posN.x - posO.x);
|
||||||
|
@ -138,6 +138,11 @@ public class ClientMouseHandler {
|
||||||
while (freeCameraPitch <= -180F) {
|
while (freeCameraPitch <= -180F) {
|
||||||
freeCameraPitch += 360;
|
freeCameraPitch += 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.getVehicle() instanceof AirEntity) {
|
||||||
|
player.setYRot(player.getVehicle().getYRot());
|
||||||
|
player.setYHeadRot(player.getYRot());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class Tm62 extends Item implements GeoItem {
|
||||||
|
|
||||||
if (!level.isClientSide) {
|
if (!level.isClientSide) {
|
||||||
float randomRot = (float) Mth.clamp((2 * Math.random() - 1) * 180, -180, 180);
|
float randomRot = (float) Mth.clamp((2 * Math.random() - 1) * 180, -180, 180);
|
||||||
Tm62Entity entity = new Tm62Entity(player, level, player.isCrouching());
|
Tm62Entity entity = new Tm62Entity(player, level, player.isShiftKeyDown());
|
||||||
entity.moveTo(player.getX(), player.getY() + 1.1, player.getZ(), randomRot, 0);
|
entity.moveTo(player.getX(), player.getY() + 1.1, player.getZ(), randomRot, 0);
|
||||||
entity.setYBodyRot(randomRot);
|
entity.setYBodyRot(randomRot);
|
||||||
entity.setYHeadRot(randomRot);
|
entity.setYHeadRot(randomRot);
|
||||||
|
|
|
@ -3,11 +3,13 @@ package com.atsuishio.superbwarfare.mixins;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.Pose;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(value = Player.class, priority = 1145)
|
@Mixin(value = Player.class, priority = 1145)
|
||||||
|
@ -27,10 +29,10 @@ public abstract class PlayerMixin extends Entity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Inject(method = "updatePlayerPose()V", at = @At("TAIL"))
|
@Inject(method = "updatePlayerPose()V", at = @At("TAIL"))
|
||||||
// public void updatePostInjection(CallbackInfo ci) {
|
public void updatePostInjection(CallbackInfo ci) {
|
||||||
// if (getRootVehicle() instanceof VehicleEntity) {
|
if (getRootVehicle() instanceof VehicleEntity) {
|
||||||
// this.setPose(Pose.STANDING);
|
this.setPose(Pose.STANDING);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue