给更多载具添加obb
This commit is contained in:
parent
a1b062504d
commit
e8a0fc2840
8 changed files with 160 additions and 22 deletions
|
@ -160,7 +160,7 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
|
||||||
this,
|
this,
|
||||||
this.getBoundingBox()
|
this.getBoundingBox()
|
||||||
.expandTowards(this.getDeltaMovement())
|
.expandTowards(this.getDeltaMovement())
|
||||||
.inflate(this.beast ? 3 : 1),
|
.inflate(1),
|
||||||
PROJECTILE_TARGETS
|
PROJECTILE_TARGETS
|
||||||
);
|
);
|
||||||
for (Entity entity : entities) {
|
for (Entity entity : entities) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.entity.vehicle;
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
||||||
|
import com.atsuishio.superbwarfare.entity.OBBEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.*;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.*;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
|
import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.*;
|
import com.atsuishio.superbwarfare.entity.vehicle.weapon.*;
|
||||||
|
@ -51,9 +52,7 @@ import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.joml.Math;
|
import org.joml.Math;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.*;
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector4f;
|
|
||||||
import software.bernie.geckolib.animatable.GeoEntity;
|
import software.bernie.geckolib.animatable.GeoEntity;
|
||||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||||
import software.bernie.geckolib.animation.AnimatableManager;
|
import software.bernie.geckolib.animation.AnimatableManager;
|
||||||
|
@ -67,7 +66,7 @@ import static com.atsuishio.superbwarfare.event.ClientMouseHandler.freeCameraPit
|
||||||
import static com.atsuishio.superbwarfare.event.ClientMouseHandler.freeCameraYaw;
|
import static com.atsuishio.superbwarfare.event.ClientMouseHandler.freeCameraYaw;
|
||||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||||
|
|
||||||
public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity, WeaponVehicleEntity, AircraftEntity {
|
public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity, WeaponVehicleEntity, AircraftEntity, OBBEntity {
|
||||||
|
|
||||||
public static Consumer<MobileVehicleEntity> fireSound = vehicle -> {
|
public static Consumer<MobileVehicleEntity> fireSound = vehicle -> {
|
||||||
};
|
};
|
||||||
|
@ -89,9 +88,31 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
private boolean wasFiring = false;
|
private boolean wasFiring = false;
|
||||||
public float delta_x;
|
public float delta_x;
|
||||||
public float delta_y;
|
public float delta_y;
|
||||||
|
public OBB obb;
|
||||||
|
public OBB obb2;
|
||||||
|
public OBB obb3;
|
||||||
|
public OBB obb4;
|
||||||
|
public OBB obb5;
|
||||||
|
public OBB obb6;
|
||||||
|
public OBB obb7;
|
||||||
|
public OBB obb8;
|
||||||
|
public OBB obb9;
|
||||||
|
public OBB obb10;
|
||||||
|
public OBB obb11;
|
||||||
|
|
||||||
public A10Entity(EntityType<A10Entity> type, Level world) {
|
public A10Entity(EntityType<A10Entity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
|
this.obb = new OBB(this.position().toVector3f(), new Vector3f(0.6875f, 1.09375f, 3.65625f), new Quaternionf(), false);
|
||||||
|
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(8.8125f, 0.3125f, 1.40625f), new Quaternionf(), false);
|
||||||
|
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(3.1875f, 0.125f, 0.96875f), new Quaternionf(), false);
|
||||||
|
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.09375f, 0.84375f), new Quaternionf(), false);
|
||||||
|
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.09375f, 0.84375f), new Quaternionf(), false);
|
||||||
|
this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.78125f, 1.09375f), new Quaternionf(), false);
|
||||||
|
this.obb7 = new OBB(this.position().toVector3f(), new Vector3f(0.6875f, 0.75f, 2.9375f), new Quaternionf(), false);
|
||||||
|
this.obb8 = new OBB(this.position().toVector3f(), new Vector3f(0.75f, 0.75f, 1.5625f), new Quaternionf(), false);
|
||||||
|
this.obb9 = new OBB(this.position().toVector3f(), new Vector3f(0.75f, 0.75f, 1.5625f), new Quaternionf(), false);
|
||||||
|
this.obb10 = new OBB(this.position().toVector3f(), new Vector3f(0.34375f, 0.359375f, 1.78125f), new Quaternionf(), false);
|
||||||
|
this.obb11 = new OBB(this.position().toVector3f(), new Vector3f(0.34375f, 0.359375f, 1.78125f), new Quaternionf(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -207,6 +228,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
this.lockingTargetO = getTargetUuid();
|
this.lockingTargetO = getTargetUuid();
|
||||||
|
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
this.updateOBB();
|
||||||
float f = (float) Mth.clamp(Math.max((onGround() ? 0.819f : 0.82f) - 0.0035 * getDeltaMovement().length(), 0.5) + 0.001f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99);
|
float f = (float) Mth.clamp(Math.max((onGround() ? 0.819f : 0.82f) - 0.0035 * getDeltaMovement().length(), 0.5) + 0.001f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99);
|
||||||
|
|
||||||
boolean forward = getDeltaMovement().dot(getViewVector(1)) > 0;
|
boolean forward = getDeltaMovement().dot(getViewVector(1)) > 0;
|
||||||
|
@ -1088,4 +1110,58 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
public @Nullable ResourceLocation getVehicleItemIcon() {
|
public @Nullable ResourceLocation getVehicleItemIcon() {
|
||||||
return Mod.loc("textures/gui/vehicle/type/aircraft.png");
|
return Mod.loc("textures/gui/vehicle/type/aircraft.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OBB> getOBBs() {
|
||||||
|
return List.of(this.obb, this.obb2, this.obb3, this.obb4, this.obb5, this.obb6, this.obb7, this.obb8, this.obb9, this.obb10, this.obb11);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateOBB() {
|
||||||
|
Matrix4f transform = getVehicleTransform(1);
|
||||||
|
|
||||||
|
Vector4f worldPosition = transformPosition(transform, 0, 2.65625f - 2.375f, 1.71875f);
|
||||||
|
this.obb.center().set(new Vector3f(worldPosition.x, worldPosition.y, worldPosition.z));
|
||||||
|
this.obb.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition2 = transformPosition(transform, 0, 0, -0.46875f);
|
||||||
|
this.obb2.center().set(new Vector3f(worldPosition2.x, worldPosition2.y, worldPosition2.z));
|
||||||
|
this.obb2.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition3 = transformPosition(transform, 0, 2.4375f - 2.375f, -6.71875f);
|
||||||
|
this.obb3.center().set(new Vector3f(worldPosition3.x, worldPosition3.y, worldPosition3.z));
|
||||||
|
this.obb3.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition4 = transformPosition(transform, -3.125f, 3.65625f - 2.375f, -6.71875f);
|
||||||
|
this.obb4.center().set(new Vector3f(worldPosition4.x, worldPosition4.y, worldPosition4.z));
|
||||||
|
this.obb4.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition5 = transformPosition(transform, 3.125f, 3.65625f - 2.375f, -6.71875f);
|
||||||
|
this.obb5.center().set(new Vector3f(worldPosition5.x, worldPosition5.y, worldPosition5.z));
|
||||||
|
this.obb5.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition6 = transformPosition(transform, 0f, 2.34375f - 2.375f, 6.46875f);
|
||||||
|
this.obb6.center().set(new Vector3f(worldPosition6.x, worldPosition6.y, worldPosition6.z));
|
||||||
|
this.obb6.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition7 = transformPosition(transform, 0f, 2.5625f - 2.375f, -4.875f);
|
||||||
|
this.obb7.center().set(new Vector3f(worldPosition7.x, worldPosition7.y, worldPosition7.z));
|
||||||
|
this.obb7.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition8 = transformPosition(transform, -1.625f, 3.375f - 2.375f, -3.5f);
|
||||||
|
this.obb8.center().set(new Vector3f(worldPosition8.x, worldPosition8.y, worldPosition8.z));
|
||||||
|
this.obb8.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition9 = transformPosition(transform, 1.625f, 3.375f - 2.375f, -3.5f);
|
||||||
|
this.obb9.center().set(new Vector3f(worldPosition9.x, worldPosition9.y, worldPosition9.z));
|
||||||
|
this.obb9.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition10 = transformPosition(transform, -2.703125f, 1.921875f - 2.375f, 0.03125f);
|
||||||
|
this.obb10.center().set(new Vector3f(worldPosition10.x, worldPosition10.y, worldPosition10.z));
|
||||||
|
this.obb10.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition11 = transformPosition(transform, 2.703125f, 1.921875f - 2.375f, 0.03125f);
|
||||||
|
this.obb11.center().set(new Vector3f(worldPosition11.x, worldPosition11.y, worldPosition11.z));
|
||||||
|
this.obb11.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.entity.vehicle;
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
||||||
|
import com.atsuishio.superbwarfare.entity.OBBEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.HelicopterEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.HelicopterEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition;
|
||||||
|
@ -44,19 +45,19 @@ import net.neoforged.neoforge.event.EventHooks;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.joml.Math;
|
import org.joml.Math;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.*;
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector4f;
|
|
||||||
import software.bernie.geckolib.animatable.GeoEntity;
|
import software.bernie.geckolib.animatable.GeoEntity;
|
||||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||||
import software.bernie.geckolib.animation.AnimatableManager;
|
import software.bernie.geckolib.animation.AnimatableManager;
|
||||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.atsuishio.superbwarfare.event.ClientMouseHandler.freeCameraPitch;
|
import static com.atsuishio.superbwarfare.event.ClientMouseHandler.freeCameraPitch;
|
||||||
import static com.atsuishio.superbwarfare.event.ClientMouseHandler.freeCameraYaw;
|
import static com.atsuishio.superbwarfare.event.ClientMouseHandler.freeCameraYaw;
|
||||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||||
|
|
||||||
public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity, HelicopterEntity, WeaponVehicleEntity {
|
public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity, HelicopterEntity, WeaponVehicleEntity, OBBEntity {
|
||||||
|
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
public static final EntityDataAccessor<Float> PROPELLER_ROT = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> PROPELLER_ROT = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.FLOAT);
|
||||||
|
@ -72,9 +73,19 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
|
|
||||||
public float delta_x;
|
public float delta_x;
|
||||||
public float delta_y;
|
public float delta_y;
|
||||||
|
public OBB obb;
|
||||||
|
public OBB obb2;
|
||||||
|
public OBB obb3;
|
||||||
|
public OBB obb4;
|
||||||
|
public OBB obb5;
|
||||||
|
|
||||||
public Ah6Entity(EntityType<Ah6Entity> type, Level world) {
|
public Ah6Entity(EntityType<Ah6Entity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
|
this.obb = new OBB(this.position().toVector3f(), new Vector3f(1.0625f, 1.28125f, 1.625f), new Quaternionf(), false);
|
||||||
|
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(0.875f, 0.6875f, 0.59375f), new Quaternionf(), false);
|
||||||
|
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.3125f, 2.25f), new Quaternionf(), false);
|
||||||
|
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.15625f, 0.40625f), new Quaternionf(), false);
|
||||||
|
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1f, 0.25f, 0.21875f), new Quaternionf(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -160,6 +171,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
@Override
|
@Override
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
updateOBB();
|
||||||
|
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
if (reloadCoolDown > 0) {
|
if (reloadCoolDown > 0) {
|
||||||
|
@ -754,4 +766,34 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
public @Nullable ResourceLocation getVehicleItemIcon() {
|
public @Nullable ResourceLocation getVehicleItemIcon() {
|
||||||
return Mod.loc("textures/gui/vehicle/type/aircraft.png");
|
return Mod.loc("textures/gui/vehicle/type/aircraft.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OBB> getOBBs() {
|
||||||
|
return List.of(this.obb, this.obb2, this.obb3, this.obb4, this.obb5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateOBB() {
|
||||||
|
Matrix4f transform = getVehicleTransform(1);
|
||||||
|
|
||||||
|
Vector4f worldPosition = transformPosition(transform, 0, 1.96875f - 1.45f, -0.15625f);
|
||||||
|
this.obb.center().set(new Vector3f(worldPosition.x, worldPosition.y, worldPosition.z));
|
||||||
|
this.obb.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition2 = transformPosition(transform, 0, 1.5f - 1.45f, 1.90625f);
|
||||||
|
this.obb2.center().set(new Vector3f(worldPosition2.x, worldPosition2.y, worldPosition2.z));
|
||||||
|
this.obb2.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition3 = transformPosition(transform, 0, 2.3125f - 1.45f, -4.1875f);
|
||||||
|
this.obb3.center().set(new Vector3f(worldPosition3.x, worldPosition3.y, worldPosition3.z));
|
||||||
|
this.obb3.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition4 = transformPosition(transform, -0.125f, 2.34375f - 1.45f, -6.34375f);
|
||||||
|
this.obb4.center().set(new Vector3f(worldPosition4.x, worldPosition4.y, worldPosition4.z));
|
||||||
|
this.obb4.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition5 = transformPosition(transform, -0.125f, 3.5625f - 1.45f, -6.65625f);
|
||||||
|
this.obb5.center().set(new Vector3f(worldPosition5.x, worldPosition5.y, worldPosition5.z));
|
||||||
|
this.obb5.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.entity.vehicle;
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
||||||
|
import com.atsuishio.superbwarfare.entity.OBBEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.*;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.*;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.ProjectileWeapon;
|
import com.atsuishio.superbwarfare.entity.vehicle.weapon.ProjectileWeapon;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon;
|
import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon;
|
||||||
|
@ -11,10 +12,7 @@ import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.network.message.receive.ShakeClientMessage;
|
import com.atsuishio.superbwarfare.network.message.receive.ShakeClientMessage;
|
||||||
import com.atsuishio.superbwarfare.tools.Ammo;
|
import com.atsuishio.superbwarfare.tools.*;
|
||||||
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
|
||||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
|
||||||
import com.mojang.math.Axis;
|
import com.mojang.math.Axis;
|
||||||
import it.unimi.dsi.fastutil.Pair;
|
import it.unimi.dsi.fastutil.Pair;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
|
@ -40,9 +38,7 @@ import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.joml.Math;
|
import org.joml.Math;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.*;
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector4f;
|
|
||||||
import software.bernie.geckolib.animatable.GeoEntity;
|
import software.bernie.geckolib.animatable.GeoEntity;
|
||||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||||
import software.bernie.geckolib.animation.*;
|
import software.bernie.geckolib.animation.*;
|
||||||
|
@ -50,14 +46,20 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||||
|
|
||||||
public class SpeedboatEntity extends ContainerMobileVehicleEntity implements GeoEntity, ArmedVehicleEntity, WeaponVehicleEntity, LandArmorEntity {
|
public class SpeedboatEntity extends ContainerMobileVehicleEntity implements GeoEntity, ArmedVehicleEntity, WeaponVehicleEntity, LandArmorEntity, OBBEntity {
|
||||||
|
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
public OBB obb;
|
||||||
|
public OBB obb2;
|
||||||
|
|
||||||
public SpeedboatEntity(EntityType<SpeedboatEntity> type, Level world) {
|
public SpeedboatEntity(EntityType<SpeedboatEntity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
|
this.obb = new OBB(this.position().toVector3f(), new Vector3f(1.5625f, 0.75f, 3.1875f), new Quaternionf(), false);
|
||||||
|
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(1.0625f, 0.5f, 1.90625f), new Quaternionf(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,6 +102,7 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
@Override
|
@Override
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
updateOBB();
|
||||||
|
|
||||||
double fluidFloat;
|
double fluidFloat;
|
||||||
fluidFloat = 0.12 * getSubmergedHeight(this);
|
fluidFloat = 0.12 * getSubmergedHeight(this);
|
||||||
|
@ -560,4 +563,22 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
public @Nullable ResourceLocation getVehicleItemIcon() {
|
public @Nullable ResourceLocation getVehicleItemIcon() {
|
||||||
return Mod.loc("textures/gui/vehicle/type/water.png");
|
return Mod.loc("textures/gui/vehicle/type/water.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OBB> getOBBs() {
|
||||||
|
return List.of(this.obb, this.obb2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateOBB() {
|
||||||
|
Matrix4f transform = getVehicleTransform(1);
|
||||||
|
|
||||||
|
Vector4f worldPosition = transformPosition(transform, 0, 0.875f - 0.9f, 0.375f);
|
||||||
|
this.obb.center().set(new Vector3f(worldPosition.x, worldPosition.y, worldPosition.z));
|
||||||
|
this.obb.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition2 = transformPosition(transform, 0, 2.0625f - 0.9f, -0.71875f);
|
||||||
|
this.obb2.center().set(new Vector3f(worldPosition2.x, worldPosition2.y, worldPosition2.z));
|
||||||
|
this.obb2.setRotation(VectorTool.combineRotations(1, this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,7 +231,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
@Override
|
@Override
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
|
||||||
this.updateOBB();
|
this.updateOBB();
|
||||||
|
|
||||||
if (getLeftTrack() < 0) {
|
if (getLeftTrack() < 0) {
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class ModEntities {
|
||||||
public static final DeferredHolder<EntityType<?>, EntityType<WheelChairEntity>> WHEEL_CHAIR = register("wheel_chair",
|
public static final DeferredHolder<EntityType<?>, EntityType<WheelChairEntity>> WHEEL_CHAIR = register("wheel_chair",
|
||||||
EntityType.Builder.of(WheelChairEntity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(1.0f, 1.0f));
|
EntityType.Builder.of(WheelChairEntity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(1.0f, 1.0f));
|
||||||
public static final DeferredHolder<EntityType<?>, EntityType<Ah6Entity>> AH_6 = register("ah_6",
|
public static final DeferredHolder<EntityType<?>, EntityType<Ah6Entity>> AH_6 = register("ah_6",
|
||||||
EntityType.Builder.of(Ah6Entity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(2.8f, 2.9f));
|
EntityType.Builder.of(Ah6Entity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(3.6f, 2.9f));
|
||||||
public static final DeferredHolder<EntityType<?>, EntityType<Lav150Entity>> LAV_150 = register("lav_150",
|
public static final DeferredHolder<EntityType<?>, EntityType<Lav150Entity>> LAV_150 = register("lav_150",
|
||||||
EntityType.Builder.of(Lav150Entity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(2.8f, 3.1f));
|
EntityType.Builder.of(Lav150Entity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(2.8f, 3.1f));
|
||||||
public static final DeferredHolder<EntityType<?>, EntityType<Tom6Entity>> TOM_6 = register("tom_6",
|
public static final DeferredHolder<EntityType<?>, EntityType<Tom6Entity>> TOM_6 = register("tom_6",
|
||||||
|
@ -123,7 +123,7 @@ public class ModEntities {
|
||||||
public static final DeferredHolder<EntityType<?>, EntityType<PrismTankEntity>> PRISM_TANK = register("prism_tank",
|
public static final DeferredHolder<EntityType<?>, EntityType<PrismTankEntity>> PRISM_TANK = register("prism_tank",
|
||||||
EntityType.Builder.of(PrismTankEntity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(5f, 2.6f));
|
EntityType.Builder.of(PrismTankEntity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(5f, 2.6f));
|
||||||
public static final DeferredHolder<EntityType<?>, EntityType<A10Entity>> A_10A = register("a_10a",
|
public static final DeferredHolder<EntityType<?>, EntityType<A10Entity>> A_10A = register("a_10a",
|
||||||
EntityType.Builder.of(A10Entity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(6, 3.5f));
|
EntityType.Builder.of(A10Entity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(9f, 3.5f));
|
||||||
|
|
||||||
private static <T extends Entity> DeferredHolder<EntityType<?>, EntityType<T>> register(String name, EntityType.Builder<T> entityTypeBuilder) {
|
private static <T extends Entity> DeferredHolder<EntityType<?>, EntityType<T>> register(String name, EntityType.Builder<T> entityTypeBuilder) {
|
||||||
return REGISTRY.register(name, () -> entityTypeBuilder.build(name));
|
return REGISTRY.register(name, () -> entityTypeBuilder.build(name));
|
||||||
|
|
|
@ -26,7 +26,7 @@ public abstract class LevelMixin {
|
||||||
at = @At("RETURN"))
|
at = @At("RETURN"))
|
||||||
public void getEntities(Entity pEntity, AABB pBoundingBox, Predicate<? super Entity> pPredicate, CallbackInfoReturnable<List<Entity>> cir) {
|
public void getEntities(Entity pEntity, AABB pBoundingBox, Predicate<? super Entity> pPredicate, CallbackInfoReturnable<List<Entity>> cir) {
|
||||||
if (pEntity instanceof ProjectileEntity) {
|
if (pEntity instanceof ProjectileEntity) {
|
||||||
this.getEntities().get(pBoundingBox.inflate(2), entity -> {
|
this.getEntities().get(pBoundingBox.inflate(3), entity -> {
|
||||||
if (entity instanceof OBBEntity obbEntity) {
|
if (entity instanceof OBBEntity obbEntity) {
|
||||||
for (OBB obb : obbEntity.getOBBs()) {
|
for (OBB obb : obbEntity.getOBBs()) {
|
||||||
if (OBB.isColliding(obb, pBoundingBox)) {
|
if (OBB.isColliding(obb, pBoundingBox)) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class ProjectileUtilMixin {
|
||||||
private static void getEntityHitResult(Entity pShooter, Vec3 pStartVec, Vec3 pEndVec, AABB pBoundingBox, Predicate<Entity> pFilter, double pDistance, CallbackInfoReturnable<EntityHitResult> cir) {
|
private static void getEntityHitResult(Entity pShooter, Vec3 pStartVec, Vec3 pEndVec, AABB pBoundingBox, Predicate<Entity> pFilter, double pDistance, CallbackInfoReturnable<EntityHitResult> cir) {
|
||||||
Level level = pShooter.level();
|
Level level = pShooter.level();
|
||||||
|
|
||||||
for (Entity entity : level.getEntities(pShooter, pBoundingBox, pFilter)) {
|
for (Entity entity : level.getEntities(pShooter, pBoundingBox.inflate(2), pFilter)) {
|
||||||
if (entity instanceof OBBEntity obbEntity) {
|
if (entity instanceof OBBEntity obbEntity) {
|
||||||
if (entity.getPassengers().contains(pShooter)) {
|
if (entity.getPassengers().contains(pShooter)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue