实验载具部件破坏
This commit is contained in:
parent
2677e77780
commit
869687d58a
3 changed files with 36 additions and 4 deletions
|
@ -16,6 +16,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.weapon.WgMissileWeapon;
|
|||
import com.atsuishio.superbwarfare.event.ClientMouseHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModParticleTypes;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.network.message.receive.ShakeClientMessage;
|
||||
import com.atsuishio.superbwarfare.tools.*;
|
||||
|
@ -32,6 +33,7 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
|||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
@ -67,7 +69,10 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
public static final EntityDataAccessor<Integer> CANNON_FIRE_TIME = SynchedEntityData.defineId(Bmp2Entity.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Integer> LOADED_MISSILE = SynchedEntityData.defineId(Bmp2Entity.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Integer> MISSILE_COUNT = SynchedEntityData.defineId(Bmp2Entity.class, EntityDataSerializers.INT);
|
||||
|
||||
public static final EntityDataAccessor<Boolean> TURRET_DAMAGED = SynchedEntityData.defineId(Bmp2Entity.class, EntityDataSerializers.BOOLEAN);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
|
||||
public int reloadCoolDown;
|
||||
|
||||
public OBB obb;
|
||||
|
@ -82,7 +87,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.1875f, 0.5f, 0.65625f), new Quaternionf(), OBB.Part.BODY);
|
||||
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), OBB.Part.BODY);
|
||||
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), OBB.Part.BODY);
|
||||
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(1.5f, 0.34375f, 1.5f), new Quaternionf(), OBB.Part.BODY);
|
||||
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(1.5f, 0.34375f, 1.5f), new Quaternionf(), OBB.Part.TURRET);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -130,7 +135,8 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
super.defineSynchedData(builder);
|
||||
builder.define(CANNON_FIRE_TIME, 0)
|
||||
.define(LOADED_MISSILE, 0)
|
||||
.define(MISSILE_COUNT, 0);
|
||||
.define(MISSILE_COUNT, 0)
|
||||
.define(TURRET_DAMAGED, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -211,7 +217,22 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
sendParticle(serverLevel, ParticleTypes.BUBBLE_COLUMN_UP, this.getX() + 0.5 * this.getDeltaMovement().x, this.getY() + getSubmergedHeight(this) - 0.2, this.getZ() + 0.5 * this.getDeltaMovement().z, (int) (2 + 10 * this.getDeltaMovement().length()), 0.65, 0, 0.65, 0, true);
|
||||
}
|
||||
|
||||
turretAngle(10, 12.5f);
|
||||
if (entityData.get(TURRET_DAMAGED)) {
|
||||
List<Entity> entities = getPlayer(level());
|
||||
for (var e : entities) {
|
||||
if (e instanceof ServerPlayer player) {
|
||||
if (player.level() instanceof ServerLevel serverLevel) {
|
||||
Matrix4f transformT = getTurretTransform(1);
|
||||
Vector4f worldPositionT = transformPosition(transformT, 0, 0.56875f, 0f);
|
||||
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), worldPositionT.x, worldPositionT.y, worldPositionT.z, 5, 0.25, 0.25, 0.25, 0.2, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
turretAngle(1, 1.25f);
|
||||
} else {
|
||||
turretAngle(10, 12.5f);
|
||||
}
|
||||
|
||||
this.terrainCompact(4f, 5f);
|
||||
inertiaRotate(1);
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.atsuishio.superbwarfare.mixins;
|
||||
|
||||
import com.atsuishio.superbwarfare.entity.OBBEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity;
|
||||
import com.atsuishio.superbwarfare.init.ModParticleTypes;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.tools.OBB;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
@ -23,6 +25,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity.TURRET_DAMAGED;
|
||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||
|
||||
@Mixin(ProjectileUtil.class)
|
||||
|
@ -52,6 +55,9 @@ public class ProjectileUtilMixin {
|
|||
sendParticle(serverLevel, ParticleTypes.SMOKE, hitPos.x, hitPos.y, hitPos.z, 2, 0, 0, 0, 0.01, false);
|
||||
}
|
||||
}
|
||||
if (obbEntity instanceof Bmp2Entity bmp2 && obb.part() == OBB.Part.TURRET) {
|
||||
bmp2.getEntityData().set(TURRET_DAMAGED, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -227,6 +227,10 @@ public record OBB(Vector3f center, Vector3f extents, Quaternionf rotation, Part
|
|||
return new OBB(newCenter, extents, rotation, part);
|
||||
}
|
||||
|
||||
public Part getPart(OBB obb) {
|
||||
return obb.part;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查点是否在OBB内部
|
||||
*
|
||||
|
@ -253,7 +257,8 @@ public record OBB(Vector3f center, Vector3f extents, Quaternionf rotation, Part
|
|||
}
|
||||
|
||||
public enum Part {
|
||||
WHEEL(),
|
||||
WHEEL_LEFT(),
|
||||
WHEEL_RIGHT(),
|
||||
TURRET(),
|
||||
ENGINE(),
|
||||
BODY();
|
||||
|
|
Loading…
Add table
Reference in a new issue