调整部分载具碰水伤害
This commit is contained in:
parent
d2369660d3
commit
6a18cac8a9
4 changed files with 27 additions and 14 deletions
|
@ -253,9 +253,9 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
|||
this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.95, f));
|
||||
}
|
||||
|
||||
if (this.isInWater() && this.tickCount % 4 == 0) {
|
||||
if (this.isInWater() && this.tickCount % 4 == 0 && getSubmergedHeight(this) > 0.5 * getBbHeight()) {
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 0.6, 0.6));
|
||||
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), 26 + (float) (60 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
|
||||
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), 1 + (float) (20 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
|
||||
}
|
||||
|
||||
releaseDecoy();
|
||||
|
|
|
@ -35,11 +35,9 @@ import net.minecraft.world.level.Explosion;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.minecraftforge.network.PlayMessages;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.joml.Math;
|
||||
import software.bernie.geckolib.animatable.GeoEntity;
|
||||
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
||||
|
@ -179,14 +177,6 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity,
|
|||
return true;
|
||||
}
|
||||
|
||||
public double getSubmergedHeight(Entity entity) {
|
||||
for (FluidType fluidType : ForgeRegistries.FLUID_TYPES.get().getValues()) {
|
||||
if (entity.level().getFluidState(entity.blockPosition()).getFluidType() == fluidType)
|
||||
return entity.getFluidTypeHeight(fluidType);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
turretYRotO = this.getTurretYRot();
|
||||
|
|
|
@ -133,6 +133,13 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
|||
setZRot(getRoll() * 0.7f);
|
||||
}
|
||||
|
||||
if (this.isInWater() && this.tickCount % 4 == 0) {
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 0.6, 0.6));
|
||||
if (lastTickSpeed > 0.4) {
|
||||
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (20 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
|
||||
}
|
||||
}
|
||||
|
||||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
|
@ -145,7 +152,7 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
|||
float diffX;
|
||||
float diffY;
|
||||
|
||||
if (passenger == null) {
|
||||
if (passenger == null || isInWater()) {
|
||||
this.leftInputDown = false;
|
||||
this.rightInputDown = false;
|
||||
this.forwardInputDown = false;
|
||||
|
|
|
@ -38,7 +38,9 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Math;
|
||||
import org.joml.Matrix4f;
|
||||
|
@ -63,6 +65,7 @@ public class VehicleEntity extends Entity {
|
|||
public float roll;
|
||||
public float prevRoll;
|
||||
public int lastHurtTick;
|
||||
public int repairCoolDown;
|
||||
public boolean crash;
|
||||
|
||||
public float getRoll() {
|
||||
|
@ -175,6 +178,7 @@ public class VehicleEntity extends Entity {
|
|||
this.entityData.set(LAST_ATTACKER_UUID, source.getEntity().getStringUUID());
|
||||
}
|
||||
lastHurtTick = 0;
|
||||
repairCoolDown = 200;
|
||||
|
||||
return super.hurt(source, amount);
|
||||
}
|
||||
|
@ -249,12 +253,24 @@ public class VehicleEntity extends Entity {
|
|||
return 1;
|
||||
}
|
||||
|
||||
public double getSubmergedHeight(Entity entity) {
|
||||
for (FluidType fluidType : ForgeRegistries.FLUID_TYPES.get().getValues()) {
|
||||
if (entity.level().getFluidState(entity.blockPosition()).getFluidType() == fluidType)
|
||||
return entity.getFluidTypeHeight(fluidType);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
|
||||
this.lastHurtTick++;
|
||||
|
||||
if (repairCoolDown > 0) {
|
||||
repairCoolDown--;
|
||||
}
|
||||
|
||||
this.prevRoll = this.getRoll();
|
||||
|
||||
float delta = Math.abs(getYRot() - yRotO);
|
||||
|
@ -290,7 +306,7 @@ public class VehicleEntity extends Entity {
|
|||
if (this.getHealth() <= 0.1 * this.getMaxHealth()) {
|
||||
this.hurt(0.1f, attacker, false);
|
||||
} else {
|
||||
if (!(this instanceof DroneEntity)) {
|
||||
if (!(this instanceof DroneEntity) && repairCoolDown == 0) {
|
||||
this.heal(0.05f);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue