通过神秘的办法让载具抵消大部分爆炸击退,修复快艇吃水深度bug
This commit is contained in:
parent
8c6ae814c9
commit
2f2052e331
6 changed files with 62 additions and 2 deletions
|
@ -611,6 +611,16 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
||||||
return super.getDismountLocationForPassenger(passenger);
|
return super.getDismountLocationForPassenger(passenger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float ignoreExplosionHorizontalKnockBack() {
|
||||||
|
return -0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float ignoreExplosionVerticalKnockBack() {
|
||||||
|
return -0.9f;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDriver(Player player) {
|
public boolean isDriver(Player player) {
|
||||||
return player == this.getFirstPassenger();
|
return player == this.getFirstPassenger();
|
||||||
|
|
|
@ -181,7 +181,7 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity,
|
||||||
}
|
}
|
||||||
|
|
||||||
double fluidFloat;
|
double fluidFloat;
|
||||||
fluidFloat = -0.06 + 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()) {
|
||||||
|
@ -452,6 +452,16 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity,
|
||||||
return this.cache;
|
return this.cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float ignoreExplosionHorizontalKnockBack() {
|
||||||
|
return -0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float ignoreExplosionVerticalKnockBack() {
|
||||||
|
return -0.9f;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxPassengers() {
|
public int getMaxPassengers() {
|
||||||
return 5;
|
return 5;
|
||||||
|
|
|
@ -310,6 +310,14 @@ public class VehicleEntity extends Entity {
|
||||||
public void travel() {
|
public void travel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float ignoreExplosionHorizontalKnockBack() {
|
||||||
|
return -1f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float ignoreExplosionVerticalKnockBack() {
|
||||||
|
return -1f;
|
||||||
|
}
|
||||||
|
|
||||||
// From Immersive_Aircraft
|
// From Immersive_Aircraft
|
||||||
public Matrix4f getVehicleTransform() {
|
public Matrix4f getVehicleTransform() {
|
||||||
Matrix4f transform = new Matrix4f();
|
Matrix4f transform = new Matrix4f();
|
||||||
|
|
|
@ -277,6 +277,16 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float ignoreExplosionHorizontalKnockBack() {
|
||||||
|
return -0.2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float ignoreExplosionVerticalKnockBack() {
|
||||||
|
return -0.3f;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.tools;
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
|
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -11,8 +12,10 @@ import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.item.PrimedTnt;
|
import net.minecraft.world.entity.item.PrimedTnt;
|
||||||
import net.minecraft.world.entity.monster.Monster;
|
import net.minecraft.world.entity.monster.Monster;
|
||||||
|
import net.minecraft.world.item.enchantment.ProtectionEnchantment;
|
||||||
import net.minecraft.world.level.Explosion;
|
import net.minecraft.world.level.Explosion;
|
||||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
@ -167,6 +170,9 @@ public class CustomExplosion extends Explosion {
|
||||||
double zDistance = entity.getZ() - this.z;
|
double zDistance = entity.getZ() - this.z;
|
||||||
double distance = Math.sqrt(xDistance * xDistance + yDistance * yDistance + zDistance * zDistance);
|
double distance = Math.sqrt(xDistance * xDistance + yDistance * yDistance + zDistance * zDistance);
|
||||||
if (distance != 0.0D) {
|
if (distance != 0.0D) {
|
||||||
|
xDistance /= distance;
|
||||||
|
yDistance /= distance;
|
||||||
|
zDistance /= distance;
|
||||||
double seenPercent = Mth.clamp(getSeenPercent(position, entity), 0.01 * ExplosionConfig.EXPLOSION_PENETRATION_RATIO.get(), Double.POSITIVE_INFINITY);
|
double seenPercent = Mth.clamp(getSeenPercent(position, entity), 0.01 * ExplosionConfig.EXPLOSION_PENETRATION_RATIO.get(), Double.POSITIVE_INFINITY);
|
||||||
double damagePercent = (1.0D - distanceRate) * seenPercent;
|
double damagePercent = (1.0D - distanceRate) * seenPercent;
|
||||||
|
|
||||||
|
@ -180,6 +186,22 @@ public class CustomExplosion extends Explosion {
|
||||||
if (fireTime > 0) {
|
if (fireTime > 0) {
|
||||||
entity.setSecondsOnFire(fireTime);
|
entity.setSecondsOnFire(fireTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double d11;
|
||||||
|
if (entity instanceof LivingEntity livingentity) {
|
||||||
|
d11 = ProtectionEnchantment.getExplosionKnockbackAfterDampener(livingentity, damagePercent);
|
||||||
|
} else {
|
||||||
|
d11 = damagePercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
xDistance *= d11;
|
||||||
|
yDistance *= d11;
|
||||||
|
zDistance *= d11;
|
||||||
|
|
||||||
|
if (entity instanceof VehicleEntity vehicle) {
|
||||||
|
Vec3 knockbackVec = new Vec3(vehicle.ignoreExplosionHorizontalKnockBack() * xDistance, vehicle.ignoreExplosionVerticalKnockBack() * yDistance, vehicle.ignoreExplosionHorizontalKnockBack() * zDistance);
|
||||||
|
vehicle.setDeltaMovement(vehicle.getDeltaMovement().add(knockbackVec));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class ProjectileTool {
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion);
|
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion);
|
||||||
explosion.finalizeExplosion(false);
|
explosion.finalizeExplosion(false);
|
||||||
ParticleTool.spawnMediumExplosionParticles(projectile.level(), target.position());
|
ParticleTool.spawnMediumExplosionParticles(projectile.level(), projectile.position());
|
||||||
projectile.discard();
|
projectile.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue