优化载具代码
This commit is contained in:
parent
4ab475195d
commit
f5d013a45a
10 changed files with 80 additions and 123 deletions
|
@ -594,7 +594,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
float flapY = (1 - (Mth.abs(getRoll())) / 90) * Mth.clamp(entityData.get(MOUSE_SPEED_X), -22.5f, 22.5f) + VectorTool.calculateY(getRoll()) * Mth.clamp(entityData.get(MOUSE_SPEED_Y), -22.5f, 22.5f);
|
float flapY = (1 - (Mth.abs(getRoll())) / 90) * Mth.clamp(entityData.get(MOUSE_SPEED_X), -22.5f, 22.5f) + VectorTool.calculateY(getRoll()) * Mth.clamp(entityData.get(MOUSE_SPEED_Y), -22.5f, 22.5f);
|
||||||
|
|
||||||
setFlap3Rot(flapY * 5);
|
setFlap3Rot(flapY * 5);
|
||||||
|
|
||||||
} else if (!onGround()) {
|
} else if (!onGround()) {
|
||||||
float diffX;
|
float diffX;
|
||||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0003f, 0.02f));
|
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0003f, 0.02f));
|
||||||
|
@ -695,10 +694,9 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
Matrix4f transform = getVehicleTransform(1);
|
Matrix4f transform = getVehicleTransform(1);
|
||||||
|
|
||||||
float x = 0f;
|
float x = 0f;
|
||||||
float y = -0.2f;
|
float y = 0.1f + (float) passenger.getVehicleAttachmentPoint(this).y;
|
||||||
float z = 3.95f;
|
float z = 3.95f;
|
||||||
|
|
||||||
|
|
||||||
Vector4f worldPosition = transformPosition(transform, x, y, z);
|
Vector4f worldPosition = transformPosition(transform, x, y, z);
|
||||||
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||||
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
|
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
|
||||||
|
@ -706,12 +704,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
copyEntityData(passenger);
|
copyEntityData(passenger);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 driverPos(float ticks) {
|
|
||||||
Matrix4f transform = getVehicleTransform(ticks);
|
|
||||||
Vector4f worldPosition = transformPosition(transform, 0, 1.35f, 4f);
|
|
||||||
return new Vec3(worldPosition.x, worldPosition.y, worldPosition.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vec3 driverZoomPos(float ticks) {
|
public Vec3 driverZoomPos(float ticks) {
|
||||||
Matrix4f transform = getVehicleTransform(ticks);
|
Matrix4f transform = getVehicleTransform(ticks);
|
||||||
|
@ -812,7 +804,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
|
|
||||||
boolean hasCreativeAmmo = getFirstPassenger() instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer);
|
boolean hasCreativeAmmo = getFirstPassenger() instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer);
|
||||||
|
|
||||||
|
|
||||||
Vector4f worldPosition = transformPosition(transform, 0.1321625f, -0.56446875f, 7.85210625f);
|
Vector4f worldPosition = transformPosition(transform, 0.1321625f, -0.56446875f, 7.85210625f);
|
||||||
Vector4f worldPosition2 = transformPosition(transform, 0.1321625f + 0.01f, -0.56446875f - 0.03f, 8.85210625f);
|
Vector4f worldPosition2 = transformPosition(transform, 0.1321625f + 0.01f, -0.56446875f - 0.03f, 8.85210625f);
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,6 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
setRightTrack(0);
|
setRightTrack(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
if (reloadCoolDown > 0) {
|
if (reloadCoolDown > 0) {
|
||||||
reloadCoolDown--;
|
reloadCoolDown--;
|
||||||
|
|
|
@ -24,7 +24,6 @@ import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
@ -117,16 +116,6 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
return new ThirdPersonCameraPosition(2.75 + ClientMouseHandler.custom3pDistanceLerp, 1, 0);
|
return new ThirdPersonCameraPosition(2.75 + ClientMouseHandler.custom3pDistanceLerp, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
|
||||||
super.addAdditionalSaveData(compound);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readAdditionalSaveData(CompoundTag compound) {
|
|
||||||
super.readAdditionalSaveData(compound);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
protected void playStepSound(BlockPos pPos, BlockState pState) {
|
protected void playStepSound(BlockPos pPos, BlockState pState) {
|
||||||
|
@ -154,8 +143,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
this.handleAmmo();
|
this.handleAmmo();
|
||||||
}
|
}
|
||||||
|
|
||||||
double fluidFloat;
|
double fluidFloat = 0.052 * getSubmergedHeight(this);
|
||||||
fluidFloat = 0.052 * getSubmergedHeight(this);
|
|
||||||
this.setDeltaMovement(this.getDeltaMovement().add(0.0, fluidFloat, 0.0));
|
this.setDeltaMovement(this.getDeltaMovement().add(0.0, fluidFloat, 0.0));
|
||||||
|
|
||||||
if (this.onGround()) {
|
if (this.onGround()) {
|
||||||
|
@ -396,6 +384,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getMaxPassengers() {
|
public int getMaxPassengers() {
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,6 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
||||||
return 2.16F;
|
return 2.16F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void positionRider(@NotNull Entity passenger, @NotNull MoveFunction callback) {
|
public void positionRider(@NotNull Entity passenger, @NotNull MoveFunction callback) {
|
||||||
if (!this.hasPassenger(passenger)) {
|
if (!this.hasPassenger(passenger)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -102,10 +102,9 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
@Override
|
@Override
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
updateOBB();
|
this.updateOBB();
|
||||||
|
|
||||||
double fluidFloat;
|
double fluidFloat = 0.12 * getSubmergedHeight(this);
|
||||||
fluidFloat = 0.12 * getSubmergedHeight(this);
|
|
||||||
this.setDeltaMovement(this.getDeltaMovement().add(0.0, fluidFloat, 0.0));
|
this.setDeltaMovement(this.getDeltaMovement().add(0.0, fluidFloat, 0.0));
|
||||||
|
|
||||||
if (this.onGround()) {
|
if (this.onGround()) {
|
||||||
|
@ -128,9 +127,9 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
this.handleAmmo();
|
this.handleAmmo();
|
||||||
}
|
}
|
||||||
|
|
||||||
turretAngle(40, 40);
|
this.turretAngle(40, 40);
|
||||||
lowHealthWarning();
|
this.lowHealthWarning();
|
||||||
inertiaRotate(2);
|
this.inertiaRotate(2);
|
||||||
this.terrainCompact(2f, 3f);
|
this.terrainCompact(2f, 3f);
|
||||||
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
|
@ -151,14 +150,12 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
return false;
|
return false;
|
||||||
}).mapToInt(Ammo.HEAVY::get).sum() + countItem(ModItems.HEAVY_AMMO.get());
|
}).mapToInt(Ammo.HEAVY::get).sum() + countItem(ModItems.HEAVY_AMMO.get());
|
||||||
|
|
||||||
|
|
||||||
this.entityData.set(AMMO, ammoCount);
|
this.entityData.set(AMMO, ammoCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机枪塔开火
|
* 机枪塔开火
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void vehicleShoot(Player player, int type) {
|
public void vehicleShoot(Player player, int type) {
|
||||||
if (this.cannotFire) return;
|
if (this.cannotFire) return;
|
||||||
|
@ -179,8 +176,6 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
(float) 0.4);
|
(float) 0.4);
|
||||||
this.level().addFreshEntity(projectile);
|
this.level().addFreshEntity(projectile);
|
||||||
|
|
||||||
float pitch = this.entityData.get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - this.entityData.get(HEAT)));
|
|
||||||
|
|
||||||
if (!player.level().isClientSide) {
|
if (!player.level().isClientSide) {
|
||||||
playShootSound3p(player, 0, 4, 12, 24);
|
playShootSound3p(player, 0, 4, 12, 24);
|
||||||
}
|
}
|
||||||
|
@ -302,24 +297,16 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
|
|
||||||
float y = -0.65f;
|
float y = -0.65f;
|
||||||
|
|
||||||
if (i == 0) {
|
Vector4f worldPosition = switch (i) {
|
||||||
Vector4f worldPosition = transformPosition(transform, 0, y + 0.25f, -0.2f);
|
case 0 -> transformPosition(transform, 0, y + 0.25f, -0.2f);
|
||||||
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
case 1 -> transformPosition(transform, -0.8f, y, -1.2f);
|
||||||
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
|
case 2 -> transformPosition(transform, 0.8f, y, -1.2f);
|
||||||
} else if (i == 1) {
|
case 3 -> transformPosition(transform, -0.8f, y, -2.2f);
|
||||||
Vector4f worldPosition = transformPosition(transform, -0.8f, y, -1.2f);
|
case 4 -> transformPosition(transform, 0.8f, y, -2.2f);
|
||||||
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
default -> null;
|
||||||
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
|
};
|
||||||
} else if (i == 2) {
|
|
||||||
Vector4f worldPosition = transformPosition(transform, 0.8f, y, -1.2f);
|
if (worldPosition != null) {
|
||||||
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
|
||||||
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
|
|
||||||
} else if (i == 3) {
|
|
||||||
Vector4f worldPosition = transformPosition(transform, -0.8f, y, -2.2f);
|
|
||||||
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
|
||||||
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
|
|
||||||
} else if (i == 4) {
|
|
||||||
Vector4f worldPosition = transformPosition(transform, 0.8f, y, -2.2f);
|
|
||||||
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||||
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
|
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,11 +61,11 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
private float yRotSync;
|
private float yRotSync;
|
||||||
|
|
||||||
public float delta_xo;
|
public float deltaXo;
|
||||||
public float delta_yo;
|
public float deltaYo;
|
||||||
|
|
||||||
public float delta_x;
|
public float deltaX;
|
||||||
public float delta_y;
|
public float deltaY;
|
||||||
|
|
||||||
public Tom6Entity(EntityType<Tom6Entity> type, Level world) {
|
public Tom6Entity(EntityType<Tom6Entity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
|
@ -113,16 +113,14 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
delta_xo = delta_x;
|
deltaXo = deltaX;
|
||||||
delta_yo = delta_y;
|
deltaYo = deltaY;
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
|
||||||
delta_x = entityData.get(MOUSE_SPEED_Y);
|
deltaX = entityData.get(MOUSE_SPEED_Y);
|
||||||
delta_y = entityData.get(MOUSE_SPEED_X);
|
deltaY = entityData.get(MOUSE_SPEED_X);
|
||||||
|
|
||||||
float f;
|
float f = (float) Mth.clamp(0.69f + 0.101f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99);
|
||||||
|
|
||||||
f = (float) Mth.clamp(0.69f + 0.101f * 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;
|
||||||
|
|
||||||
|
@ -144,11 +142,6 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
public void travel() {
|
public void travel() {
|
||||||
Entity passenger = this.getFirstPassenger();
|
Entity passenger = this.getFirstPassenger();
|
||||||
|
|
||||||
// if (this.getEnergy() <= 0) return;
|
|
||||||
|
|
||||||
float diffX;
|
|
||||||
float diffY;
|
|
||||||
|
|
||||||
if (passenger == null || isInWater()) {
|
if (passenger == null || isInWater()) {
|
||||||
this.leftInputDown = false;
|
this.leftInputDown = false;
|
||||||
this.rightInputDown = false;
|
this.rightInputDown = false;
|
||||||
|
@ -182,8 +175,8 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(passenger.getYHeadRot() - this.getYRot()));
|
float diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(passenger.getYHeadRot() - this.getYRot()));
|
||||||
diffX = Math.clamp(-60f, 60f, Mth.wrapDegrees(passenger.getXRot() - this.getXRot()));
|
float diffX = Math.clamp(-60f, 60f, Mth.wrapDegrees(passenger.getXRot() - this.getXRot()));
|
||||||
|
|
||||||
float roll = Mth.abs(Mth.clamp(getRoll() / 60, -1.5f, 1.5f));
|
float roll = Mth.abs(Mth.clamp(getRoll() / 60, -1.5f, 1.5f));
|
||||||
|
|
||||||
|
@ -280,7 +273,7 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
Matrix4f transform = getVehicleTransform(1);
|
Matrix4f transform = getVehicleTransform(1);
|
||||||
|
|
||||||
float x = 0f;
|
float x = 0f;
|
||||||
float y = 0.05f;
|
float y = 0.45f + (float) passenger.getVehicleAttachmentPoint(this).y;
|
||||||
float z = -0.4f;
|
float z = -0.4f;
|
||||||
|
|
||||||
int i = this.getSeatIndex(passenger);
|
int i = this.getSeatIndex(passenger);
|
||||||
|
@ -300,9 +293,9 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
|
|
||||||
public void copyEntityData(Entity entity) {
|
public void copyEntityData(Entity entity) {
|
||||||
float i = getXRot() / 90;
|
float i = getXRot() / 90;
|
||||||
|
|
||||||
float f = Mth.wrapDegrees(entity.getYRot() - getYRot());
|
float f = Mth.wrapDegrees(entity.getYRot() - getYRot());
|
||||||
float g = Mth.clamp(f, -105.0f, 105.0f);
|
float g = Mth.clamp(f, -105.0f, 105.0f);
|
||||||
|
|
||||||
entity.yRotO += g - f;
|
entity.yRotO += g - f;
|
||||||
entity.setYRot(entity.getYRot() + g - f + yRotSync * Mth.abs(i));
|
entity.setYRot(entity.getYRot() + g - f + yRotSync * Mth.abs(i));
|
||||||
entity.setYHeadRot(entity.getYRot());
|
entity.setYHeadRot(entity.getYRot());
|
||||||
|
@ -393,7 +386,7 @@ public class Tom6Entity extends MobileVehicleEntity 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 (isFreeCam(player) && this.getSeatIndex(player) == 0 && Mth.abs((float) (freeCameraYaw * freeCameraPitch)) > 0.01) {
|
if (isFreeCam(player) && this.getSeatIndex(player) == 0 && Mth.abs((float) (freeCameraYaw * freeCameraPitch)) > 0.01) {
|
||||||
return new Vec2((float) (getYaw(partialTicks) - 0.5f * Mth.lerp(partialTicks, delta_yo, delta_y) - freeCameraYaw), (float) (getPitch(partialTicks) - 0.5f * Mth.lerp(partialTicks, delta_xo, delta_x) + freeCameraPitch));
|
return new Vec2((float) (getYaw(partialTicks) - 0.5f * Mth.lerp(partialTicks, deltaYo, deltaY) - freeCameraYaw), (float) (getPitch(partialTicks) - 0.5f * Mth.lerp(partialTicks, deltaXo, deltaX) + freeCameraPitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getCameraRotation(partialTicks, player, false, false);
|
return super.getCameraRotation(partialTicks, player, false, false);
|
||||||
|
|
|
@ -903,7 +903,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
return transformG;
|
return transformG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
if (level() instanceof ServerLevel) {
|
if (level() instanceof ServerLevel) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue