调整载具撞击实体的类型
This commit is contained in:
parent
4611d7168e
commit
9525d019c3
1 changed files with 20 additions and 15 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.entity;
|
package com.atsuishio.superbwarfare.entity;
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -65,15 +66,20 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
if (velocity.horizontalDistance() < 0.1) return;
|
if (velocity.horizontalDistance() < 0.1) return;
|
||||||
var frontBox = getBoundingBox().move(velocity.scale(0.5));
|
var frontBox = getBoundingBox().move(velocity.scale(0.5));
|
||||||
var velAdd = velocity.add(0, 0, 0).scale(0.9);
|
var velAdd = velocity.add(0, 0, 0).scale(0.9);
|
||||||
for (var entity : level().getEntities(EntityTypeTest.forClass(Entity.class), frontBox, entity -> entity != this && entity != getFirstPassenger() && entity.getVehicle() == null)) {
|
|
||||||
|
var entities = level().getEntities(EntityTypeTest.forClass(Entity.class), frontBox,
|
||||||
|
entity -> entity != this && entity != getFirstPassenger() && entity.getVehicle() == null)
|
||||||
|
.stream().filter(entity -> entity.isAlive()
|
||||||
|
&& !(entity instanceof ItemEntity || entity instanceof Projectile || entity instanceof ProjectileEntity || entity instanceof LaserEntity)
|
||||||
|
&& !(entity instanceof Player player && (player.isSpectator() || player.isCreative())))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
for (var entity : entities) {
|
||||||
double entitySize = entity.getBbWidth() * entity.getBbHeight();
|
double entitySize = entity.getBbWidth() * entity.getBbHeight();
|
||||||
double thisSize = this.getBbWidth() * this.getBbHeight();
|
double thisSize = this.getBbWidth() * this.getBbHeight();
|
||||||
double f = Math.min(entitySize / thisSize, 2);
|
double f = Math.min(entitySize / thisSize, 2);
|
||||||
double f1 = Math.min(thisSize / entitySize, 4);
|
double f1 = Math.min(thisSize / entitySize, 4);
|
||||||
|
|
||||||
if (entity.isAlive()
|
|
||||||
&& !(entity instanceof ItemEntity || entity instanceof Projectile || entity instanceof ProjectileEntity)
|
|
||||||
&& !(entity instanceof Player player && (player.isSpectator() || player.isCreative()))) {
|
|
||||||
if (velocity.horizontalDistance() > 0.4) {
|
if (velocity.horizontalDistance() > 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);
|
||||||
|
@ -88,7 +94,6 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3f getForwardDirection() {
|
public Vector3f getForwardDirection() {
|
||||||
return new Vector3f(
|
return new Vector3f(
|
||||||
|
|
Loading…
Add table
Reference in a new issue