调整汤姆F6F跳机后不回正角度,载具会记录上一个驾驶员的UUID
This commit is contained in:
parent
c534eeebdb
commit
21d3f10637
3 changed files with 21 additions and 9 deletions
|
@ -8,6 +8,7 @@ import com.atsuishio.superbwarfare.entity.projectile.LaserEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -129,13 +130,14 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
super.move(movementType, movement);
|
super.move(movementType, movement);
|
||||||
if (level() instanceof ServerLevel) {
|
if (level() instanceof ServerLevel) {
|
||||||
if (lastTickSpeed < 0.3 || collisionCoolDown > 0) return;
|
if (lastTickSpeed < 0.3 || collisionCoolDown > 0) return;
|
||||||
|
Entity driver = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_DRIVER_UUID));
|
||||||
|
|
||||||
if ((verticalCollision)) {
|
if ((verticalCollision)) {
|
||||||
if (this instanceof IHelicopterEntity) {
|
if (this instanceof IHelicopterEntity) {
|
||||||
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (20 * ((lastTickSpeed - 0.3) * (lastTickSpeed - 0.3))));
|
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, driver == null ? this : driver), (float) (20 * ((lastTickSpeed - 0.3) * (lastTickSpeed - 0.3))));
|
||||||
this.bounceVertical(Direction.getNearest(this.getDeltaMovement().x(), this.getDeltaMovement().y(), this.getDeltaMovement().z()).getOpposite());
|
this.bounceVertical(Direction.getNearest(this.getDeltaMovement().x(), this.getDeltaMovement().y(), this.getDeltaMovement().z()).getOpposite());
|
||||||
} else if (Mth.abs((float) lastTickVerticalSpeed) > 0.6) {
|
} else if (Mth.abs((float) lastTickVerticalSpeed) > 0.6) {
|
||||||
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (48 * ((Mth.abs((float) lastTickVerticalSpeed) - 0.6) * (lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
|
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, driver == null ? this : driver), (float) (48 * ((Mth.abs((float) lastTickVerticalSpeed) - 0.6) * (lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
|
||||||
if (!this.level().isClientSide) {
|
if (!this.level().isClientSide) {
|
||||||
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
|
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
|
||||||
}
|
}
|
||||||
|
@ -144,7 +146,7 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.horizontalCollision) {
|
if (this.horizontalCollision) {
|
||||||
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (36 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
|
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, driver == null ? this : driver), (float) (36 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
|
||||||
this.bounceHorizontal(Direction.getNearest(this.getDeltaMovement().x(), this.getDeltaMovement().y(), this.getDeltaMovement().z()).getOpposite());
|
this.bounceHorizontal(Direction.getNearest(this.getDeltaMovement().x(), this.getDeltaMovement().y(), this.getDeltaMovement().z()).getOpposite());
|
||||||
if (!this.level().isClientSide) {
|
if (!this.level().isClientSide) {
|
||||||
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
|
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
|
||||||
|
|
|
@ -121,7 +121,9 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
|
|
||||||
f = (float) Mth.clamp(0.759f + 0.041f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99);
|
f = (float) Mth.clamp(0.759f + 0.041f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99);
|
||||||
|
|
||||||
this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).scale((0.24) * this.getDeltaMovement().length())));
|
boolean forward = Mth.abs((float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) < 90;
|
||||||
|
|
||||||
|
this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).scale((forward ? 0.24 : -0.24) * this.getDeltaMovement().length())));
|
||||||
this.setDeltaMovement(this.getDeltaMovement().multiply(f, f, f));
|
this.setDeltaMovement(this.getDeltaMovement().multiply(f, f, f));
|
||||||
|
|
||||||
if (onGround()) {
|
if (onGround()) {
|
||||||
|
@ -146,11 +148,11 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
this.rightInputDown = false;
|
this.rightInputDown = false;
|
||||||
this.forwardInputDown = false;
|
this.forwardInputDown = false;
|
||||||
this.backInputDown = false;
|
this.backInputDown = false;
|
||||||
this.setZRot(this.roll * 0.8f);
|
this.entityData.set(POWER, this.entityData.get(POWER) * 0.95f);
|
||||||
this.setXRot(this.getXRot() * 0.7f);
|
|
||||||
this.entityData.set(POWER, this.entityData.get(POWER) * 0.98f);
|
|
||||||
if (onGround()) {
|
if (onGround()) {
|
||||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.8, 1, 0.8));
|
this.setDeltaMovement(this.getDeltaMovement().multiply(0.96, 1, 0.96));
|
||||||
|
} else {
|
||||||
|
this.setXRot(Mth.clamp(this.getXRot() + 0.1f, -89, 89));
|
||||||
}
|
}
|
||||||
} else if (passenger instanceof Player player) {
|
} else if (passenger instanceof Player player) {
|
||||||
if (level().isClientSide && this.getEnergy() > 0) {
|
if (level().isClientSide && this.getEnergy() > 0) {
|
||||||
|
@ -163,7 +165,7 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backInputDown || downInputDown) {
|
if (backInputDown || downInputDown) {
|
||||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.006f, onGround() ? -0.12f : 0.04f));
|
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - (this.entityData.get(POWER) > 0 ? 0.006f : 0.001f), onGround() ? -0.12f : 0.04f));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!onGround()) {
|
if (!onGround()) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class VehicleEntity extends Entity {
|
||||||
|
|
||||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT);
|
||||||
protected static final EntityDataAccessor<String> LAST_ATTACKER_UUID = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.STRING);
|
protected static final EntityDataAccessor<String> LAST_ATTACKER_UUID = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.STRING);
|
||||||
|
protected static final EntityDataAccessor<String> LAST_DRIVER_UUID = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.STRING);
|
||||||
|
|
||||||
protected int interpolationSteps;
|
protected int interpolationSteps;
|
||||||
protected double x;
|
protected double x;
|
||||||
|
@ -84,11 +85,13 @@ public class VehicleEntity extends Entity {
|
||||||
protected void defineSynchedData() {
|
protected void defineSynchedData() {
|
||||||
this.entityData.define(HEALTH, this.getMaxHealth());
|
this.entityData.define(HEALTH, this.getMaxHealth());
|
||||||
this.entityData.define(LAST_ATTACKER_UUID, "undefined");
|
this.entityData.define(LAST_ATTACKER_UUID, "undefined");
|
||||||
|
this.entityData.define(LAST_DRIVER_UUID, "undefined");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readAdditionalSaveData(CompoundTag compound) {
|
protected void readAdditionalSaveData(CompoundTag compound) {
|
||||||
this.entityData.set(LAST_ATTACKER_UUID, compound.getString("LastAttacker"));
|
this.entityData.set(LAST_ATTACKER_UUID, compound.getString("LastAttacker"));
|
||||||
|
this.entityData.set(LAST_DRIVER_UUID, compound.getString("LastDriver"));
|
||||||
this.entityData.set(HEALTH, compound.getFloat("Health"));
|
this.entityData.set(HEALTH, compound.getFloat("Health"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +99,7 @@ public class VehicleEntity extends Entity {
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
compound.putFloat("Health", this.entityData.get(HEALTH));
|
compound.putFloat("Health", this.entityData.get(HEALTH));
|
||||||
compound.putString("LastAttacker", this.entityData.get(LAST_ATTACKER_UUID));
|
compound.putString("LastAttacker", this.entityData.get(LAST_ATTACKER_UUID));
|
||||||
|
compound.putString("LastDriver", this.entityData.get(LAST_DRIVER_UUID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -264,6 +268,10 @@ public class VehicleEntity extends Entity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getFirstPassenger() != null) {
|
||||||
|
this.entityData.set(LAST_DRIVER_UUID, getFirstPassenger().getStringUUID());
|
||||||
|
}
|
||||||
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue