优化部分代码
This commit is contained in:
parent
0720a96dce
commit
570cd27027
3 changed files with 8 additions and 28 deletions
|
@ -118,7 +118,6 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/hud_base.png"), x - 160, y - 160, 0, 0, 320, 320, 320, 320);
|
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/hud_base.png"), x - 160, y - 160, 0, 0, 320, 320, 320, 320);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//指南针
|
//指南针
|
||||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/compass.png"), x - 128, y - 122, 128 + ((float) 64 / 45 * mobileVehicle.getYRot()), 0, 256, 16, 512, 16);
|
preciseBlit(guiGraphics, Mod.loc("textures/screens/compass.png"), x - 128, y - 122, 128 + ((float) 64 / 45 * mobileVehicle.getYRot()), 0, 256, 16, 512, 16);
|
||||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/compass_ind.png"), x - 4, y - 123, 0, 0, 8, 8, 8, 8);
|
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/compass_ind.png"), x - 4, y - 123, 0, 0, 8, 8, 8, 8);
|
||||||
|
@ -129,7 +128,6 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/roll_ind.png"), x - 4, y + 144, 0, 0, 8, 8, 8, 8);
|
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/roll_ind.png"), x - 4, y + 144, 0, 0, 8, 8, 8, 8);
|
||||||
poseStack.popPose();
|
poseStack.popPose();
|
||||||
|
|
||||||
|
|
||||||
//时速
|
//时速
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(mobileVehicle.getDeltaMovement().dot(mobileVehicle.getViewVector(1)) * 72)),
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(mobileVehicle.getDeltaMovement().dot(mobileVehicle.getViewVector(1)) * 72)),
|
||||||
(int) x - 105, (int) y - 61, 0x66FF00, false);
|
(int) x - 105, (int) y - 61, 0x66FF00, false);
|
||||||
|
@ -153,7 +151,6 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
|
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("TGT"), (int) x + 76, (int) y + 78, 0x66FF00, false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("TGT"), (int) x + 76, (int) y + 78, 0x66FF00, false);
|
||||||
|
|
||||||
|
|
||||||
if (mobileVehicle instanceof A10Entity a10Entity) {
|
if (mobileVehicle instanceof A10Entity a10Entity) {
|
||||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
double heat = 1 - a10Entity.getEntityData().get(HEAT) / 100.0F;
|
double heat = 1 - a10Entity.getEntityData().get(HEAT) / 100.0F;
|
||||||
|
@ -207,8 +204,7 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/hud_ind.png"), x - 18 + diffY, y - 12, 0, 0, 36, 24, 36, 24);
|
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/hud_ind.png"), x - 18 + diffY, y - 12, 0, 0, 36, 24, 36, 24);
|
||||||
poseStack.popPose();
|
poseStack.popPose();
|
||||||
|
|
||||||
//能量警告
|
// 能量警告
|
||||||
|
|
||||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("NO POWER!"),
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("NO POWER!"),
|
||||||
(int) x - 144, (int) y + 14, -65536, false);
|
(int) x - 144, (int) y + 14, -65536, false);
|
||||||
|
@ -221,13 +217,11 @@ 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;
|
||||||
float y = (float) pCross.y;
|
float y = (float) pCross.y;
|
||||||
|
|
||||||
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();
|
||||||
RenderSystem.depthMask(false);
|
RenderSystem.depthMask(false);
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
|
@ -239,7 +233,6 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
|
|
||||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/crosshair_ind.png"), x - 16, y - 16, 0, 0, 32, 32, 32, 32);
|
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/crosshair_ind.png"), x - 16, y - 16, 0, 0, 32, 32, 32, 32);
|
||||||
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||||
|
|
||||||
} else if (mc.options.getCameraType() == CameraType.THIRD_PERSON_BACK) {
|
} else if (mc.options.getCameraType() == CameraType.THIRD_PERSON_BACK) {
|
||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(aircraftEntity.getRotZ(partialTick)), x, y, 0);
|
poseStack.rotateAround(Axis.ZP.rotationDegrees(aircraftEntity.getRotZ(partialTick)), x, y, 0);
|
||||||
|
@ -271,8 +264,7 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
poseStack.popPose();
|
poseStack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
//A-10的导弹锁定
|
// A-10的导弹锁定
|
||||||
|
|
||||||
if (mobileVehicle instanceof A10Entity a10Entity && a10Entity.getWeaponIndex(0) == 3) {
|
if (mobileVehicle instanceof A10Entity a10Entity && a10Entity.getWeaponIndex(0) == 3) {
|
||||||
Entity targetEntity = EntityFindUtil.findEntity(player.level(), a10Entity.getTargetUuid());
|
Entity targetEntity = EntityFindUtil.findEntity(player.level(), a10Entity.getTargetUuid());
|
||||||
List<Entity> entities = SeekTool.seekCustomSizeEntities(a10Entity, player.level(), 384, 20, 0.9, true);
|
List<Entity> entities = SeekTool.seekCustomSizeEntities(a10Entity, player.level(), 384, 20, 0.9, true);
|
||||||
|
@ -308,7 +300,6 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
poseStack.popPose();
|
poseStack.popPose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,8 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
|
||||||
|
|
||||||
public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity, WeaponVehicleEntity, AircraftEntity {
|
public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity, WeaponVehicleEntity, AircraftEntity {
|
||||||
|
|
||||||
public static final EntityDataAccessor<Integer> LOADED_ROCKET = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> LOADED_ROCKET = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Integer> LOADED_BOMB = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> LOADED_BOMB = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Integer> LOADED_MISSILE = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> LOADED_MISSILE = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
|
||||||
|
@ -71,9 +70,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
public String lockingTargetO = "none";
|
public String lockingTargetO = "none";
|
||||||
public String lockingTarget = "none";
|
public String lockingTarget = "none";
|
||||||
|
|
||||||
public String test;
|
|
||||||
public int lockTime;
|
public int lockTime;
|
||||||
public boolean locking;
|
|
||||||
public boolean locked;
|
public boolean locked;
|
||||||
|
|
||||||
public A10Entity(EntityType<A10Entity> type, Level world) {
|
public A10Entity(EntityType<A10Entity> type, Level world) {
|
||||||
|
@ -183,13 +180,10 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
|
|
||||||
lockingTargetO = getTargetUuid();
|
lockingTargetO = getTargetUuid();
|
||||||
|
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
float f;
|
float f = (float) Mth.clamp(Math.max((onGround() ? 0.88f : 0.885f) - 0.01 * getDeltaMovement().length(), 0.5) + 0.001f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99);
|
||||||
|
|
||||||
f = (float) Mth.clamp(Math.max((onGround() ? 0.88f : 0.885f) - 0.01 * getDeltaMovement().length(), 0.5) + 0.001f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99);
|
|
||||||
|
|
||||||
boolean forward = Mth.abs((float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) < 90;
|
boolean forward = Mth.abs((float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) < 90;
|
||||||
|
|
||||||
|
@ -358,8 +352,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
} else {
|
} else {
|
||||||
this.setXRot(Mth.clamp(this.getXRot() + 0.1f, -89, 89));
|
this.setXRot(Mth.clamp(this.getXRot() + 0.1f, -89, 89));
|
||||||
}
|
}
|
||||||
} else if (passenger instanceof Player player) {
|
} else if (passenger instanceof Player) {
|
||||||
|
|
||||||
if (getEnergy() > 0) {
|
if (getEnergy() > 0) {
|
||||||
if (forwardInputDown) {
|
if (forwardInputDown) {
|
||||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.002f, 1f));
|
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.002f, 1f));
|
||||||
|
@ -438,7 +431,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.95f);
|
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.95f);
|
||||||
|
|
||||||
if (getEnergy() > 0) {
|
if (getEnergy() > 0) {
|
||||||
this.consumeEnergy((int) Mth.abs(this.entityData.get(POWER)) * VehicleConfig.A_10_MAX_ENERGY_COST.get());
|
this.consumeEnergy((int) (Mth.abs(this.entityData.get(POWER)) * VehicleConfig.A_10_MAX_ENERGY_COST.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale(Math.max((90 + this.getXRot()) / 90, 0.8) * 0.4 * this.entityData.get(POWER))));
|
this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale(Math.max((90 + this.getXRot()) / 90, 0.8) * 0.4 * this.entityData.get(POWER))));
|
||||||
|
@ -673,7 +666,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
Vector4f worldPosition = transformPosition(transform, 0.1321625f, -0.56446875f, 7.85210625f);
|
Vector4f worldPosition = transformPosition(transform, 0.1321625f, -0.56446875f, 7.85210625f);
|
||||||
|
|
||||||
if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) {
|
if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) {
|
||||||
|
|
||||||
entityData.set(FIRE_TIME, Math.min(entityData.get(FIRE_TIME) + 6, 6));
|
entityData.set(FIRE_TIME, Math.min(entityData.get(FIRE_TIME) + 6, 6));
|
||||||
|
|
||||||
var entityToSpawn = ((SmallCannonShellWeapon) getWeapon(0)).create(player);
|
var entityToSpawn = ((SmallCannonShellWeapon) getWeapon(0)).create(player);
|
||||||
|
@ -682,7 +674,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
entityToSpawn.shoot(getLookAngle().x, getLookAngle().y - 0.07, getLookAngle().z, 30, 0.5f);
|
entityToSpawn.shoot(getLookAngle().x, getLookAngle().y - 0.07, getLookAngle().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, 0, 0, 0, false);
|
ParticleTool.sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPosition.x, worldPosition.y, worldPosition.z, 1, 0, 0, 0, 0, false);
|
||||||
|
|
||||||
if (!hasCreativeAmmo) {
|
if (!hasCreativeAmmo) {
|
||||||
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||||
|
@ -700,8 +692,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entityData.set(HEAT, this.entityData.get(HEAT) + 2);
|
this.entityData.set(HEAT, this.entityData.get(HEAT) + 2);
|
||||||
|
|
||||||
|
|
||||||
} else if (getWeaponIndex(0) == 1 && this.getEntityData().get(LOADED_ROCKET) > 0) {
|
} else if (getWeaponIndex(0) == 1 && this.getEntityData().get(LOADED_ROCKET) > 0) {
|
||||||
var heliRocketEntity = ((HeliRocketWeapon) getWeapon(0)).create(player);
|
var heliRocketEntity = ((HeliRocketWeapon) getWeapon(0)).create(player);
|
||||||
|
|
||||||
|
@ -749,7 +739,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadCoolDown = 15;
|
reloadCoolDown = 15;
|
||||||
|
|
||||||
} else if (getWeaponIndex(0) == 2 && this.getEntityData().get(LOADED_BOMB) > 0) {
|
} else if (getWeaponIndex(0) == 2 && this.getEntityData().get(LOADED_BOMB) > 0) {
|
||||||
var Mk82Entity = ((Mk82Weapon) getWeapon(0)).create(player);
|
var Mk82Entity = ((Mk82Weapon) getWeapon(0)).create(player);
|
||||||
|
|
||||||
|
@ -775,7 +764,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
reloadCoolDownBomb = 300;
|
reloadCoolDownBomb = 300;
|
||||||
}
|
}
|
||||||
this.entityData.set(LOADED_BOMB, this.getEntityData().get(LOADED_BOMB) - 1);
|
this.entityData.set(LOADED_BOMB, this.getEntityData().get(LOADED_BOMB) - 1);
|
||||||
|
|
||||||
} else if (getWeaponIndex(0) == 3 && this.getEntityData().get(LOADED_MISSILE) > 0) {
|
} else if (getWeaponIndex(0) == 3 && this.getEntityData().get(LOADED_MISSILE) > 0) {
|
||||||
var Agm65Entity = ((Agm65Weapon) getWeapon(0)).create(player);
|
var Agm65Entity = ((Agm65Weapon) getWeapon(0)).create(player);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.entity.vehicle.base;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
public interface AircraftEntity extends AirEntity {
|
public interface AircraftEntity extends AirEntity {
|
||||||
|
|
||||||
Vec3 shootPos(float tickDelta);
|
Vec3 shootPos(float tickDelta);
|
||||||
|
|
||||||
Vec3 shootVec(float tickDelta);
|
Vec3 shootVec(float tickDelta);
|
||||||
|
|
Loading…
Add table
Reference in a new issue