删除诱饵实体接口

This commit is contained in:
17146 2025-06-17 17:41:04 +08:00 committed by Light_Quanta
parent d94a53c963
commit 4ab475195d
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
14 changed files with 49 additions and 76 deletions

View file

@ -1,3 +1,4 @@
// 1.21.1 2025-06-12T21:56:29.8001208 Tags for minecraft:entity_type mod id superbwarfare // 1.21.1 2025-06-17T18:58:56.229726 Tags for minecraft:entity_type mod id superbwarfare
4b66f399cf351dc05891ad11d0e94889962a4327 data/superbwarfare/tags/entity_type/aerial_bomb.json 4b66f399cf351dc05891ad11d0e94889962a4327 data/superbwarfare/tags/entity_type/aerial_bomb.json
831bbb12a31a9fd9a731e812b690d09d70ade7e9 data/superbwarfare/tags/entity_type/decoy.json
dab439adf745fde8ee3ecf56a40c617dfedc9c47 data/superbwarfare/tags/entity_type/destroyable_projectile.json dab439adf745fde8ee3ecf56a40c617dfedc9c47 data/superbwarfare/tags/entity_type/destroyable_projectile.json

View file

@ -0,0 +1,6 @@
{
"values": [
"superbwarfare:smoke_decoy",
"superbwarfare:flare_decoy"
]
}

View file

@ -37,6 +37,11 @@ public class ModEntityTypeTagProvider extends EntityTypeTagsProvider {
ModEntities.SWARM_DRONE.get(), ModEntities.SWARM_DRONE.get(),
ModEntities.WG_MISSILE.get() ModEntities.WG_MISSILE.get()
); );
this.tag(ModTags.EntityTypes.DECOY).add(
ModEntities.SMOKE_DECOY.get(),
ModEntities.FLARE_DECOY.get()
);
} }
public static TagKey<EntityType<?>> cTag(String name) { public static TagKey<EntityType<?>> cTag(String name) {

View file

@ -2,10 +2,7 @@ package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.init.ModEntities;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage; import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage;
import com.atsuishio.superbwarfare.tools.*; import com.atsuishio.superbwarfare.tools.*;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -57,7 +54,6 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
private float explosionDamage = ExplosionConfig.AGM_65_EXPLOSION_DAMAGE.get(); private float explosionDamage = ExplosionConfig.AGM_65_EXPLOSION_DAMAGE.get();
private float explosionRadius = ExplosionConfig.AGM_65_EXPLOSION_RADIUS.get().floatValue(); private float explosionRadius = ExplosionConfig.AGM_65_EXPLOSION_RADIUS.get().floatValue();
private boolean distracted = false; private boolean distracted = false;
private int durability = 100; private int durability = 100;
public Agm65Entity(EntityType<? extends Agm65Entity> type, Level world) { public Agm65Entity(EntityType<? extends Agm65Entity> type, Level world) {
@ -244,9 +240,10 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E
List<Entity> decoy = SeekTool.seekLivingEntities(this, this.level(), 32, 90); List<Entity> decoy = SeekTool.seekLivingEntities(this, this.level(), 32, 90);
for (var e : decoy) { for (var e : decoy) {
if (e instanceof DecoyEntity decoyEntity && !distracted) { if (e.getType().is(ModTags.EntityTypes.DECOY) && !this.distracted) {
this.entityData.set(TARGET_UUID, decoyEntity.getDecoyUUID()); this.entityData.set(TARGET_UUID, e.getStringUUID());
distracted = true; this.distracted = true;
break;
} }
} }

View file

@ -1,10 +0,0 @@
package com.atsuishio.superbwarfare.entity.projectile;
import net.minecraft.world.phys.Vec3;
public interface DecoyEntity {
String getDecoyUUID();
Vec3 getPosition();
}

View file

@ -14,7 +14,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class FlareDecoyEntity extends Entity implements DecoyEntity { public class FlareDecoyEntity extends Entity {
public FlareDecoyEntity(EntityType<? extends FlareDecoyEntity> type, Level world) { public FlareDecoyEntity(EntityType<? extends FlareDecoyEntity> type, Level world) {
super(type, world); super(type, world);
@ -61,14 +61,4 @@ public class FlareDecoyEntity extends Entity implements DecoyEntity {
this.yRotO = this.getYRot(); this.yRotO = this.getYRot();
this.xRotO = this.getXRot(); this.xRotO = this.getXRot();
} }
@Override
public String getDecoyUUID() {
return this.getStringUUID();
}
@Override
public Vec3 getPosition() {
return position();
}
} }

View file

@ -2,10 +2,7 @@ package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.init.ModEntities;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage; import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage;
import com.atsuishio.superbwarfare.tools.*; import com.atsuishio.superbwarfare.tools.*;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -292,9 +289,10 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo
List<Entity> decoy = SeekTool.seekLivingEntities(this, this.level(), 32, 90); List<Entity> decoy = SeekTool.seekLivingEntities(this, this.level(), 32, 90);
for (var e : decoy) { for (var e : decoy) {
if (e instanceof DecoyEntity decoyEntity && !distracted) { if (e.getType().is(ModTags.EntityTypes.DECOY) && !this.distracted) {
this.entityData.set(TARGET_UUID, decoyEntity.getDecoyUUID()); this.entityData.set(TARGET_UUID, e.getStringUUID());
distracted = true; this.distracted = true;
break;
} }
} }

View file

@ -16,7 +16,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class SmokeDecoyEntity extends Entity implements DecoyEntity { public class SmokeDecoyEntity extends Entity {
public SmokeDecoyEntity(EntityType<? extends SmokeDecoyEntity> type, Level world) { public SmokeDecoyEntity(EntityType<? extends SmokeDecoyEntity> type, Level world) {
super(type, world); super(type, world);
@ -78,14 +78,4 @@ public class SmokeDecoyEntity extends Entity implements DecoyEntity {
this.yRotO = this.getYRot(); this.yRotO = this.getYRot();
this.xRotO = this.getXRot(); this.xRotO = this.getXRot();
} }
@Override
public Vec3 getPosition() {
return position();
}
@Override
public String getDecoyUUID() {
return this.getStringUUID();
}
} }

View file

@ -1,10 +1,7 @@
package com.atsuishio.superbwarfare.entity.projectile; package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.init.ModEntities;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage; import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage;
import com.atsuishio.superbwarfare.tools.CustomExplosion; import com.atsuishio.superbwarfare.tools.CustomExplosion;
import com.atsuishio.superbwarfare.tools.EntityFindUtil; import com.atsuishio.superbwarfare.tools.EntityFindUtil;
@ -212,9 +209,10 @@ public class SwarmDroneEntity extends FastThrowableProjectile implements GeoEnti
List<Entity> decoy = SeekTool.seekLivingEntities(this, this.level(), 32, 90); List<Entity> decoy = SeekTool.seekLivingEntities(this, this.level(), 32, 90);
for (var e : decoy) { for (var e : decoy) {
if (e instanceof DecoyEntity decoyEntity && !distracted) { if (e.getType().is(ModTags.EntityTypes.DECOY) && !this.distracted) {
this.entityData.set(TARGET_UUID, decoyEntity.getDecoyUUID()); this.entityData.set(TARGET_UUID, e.getStringUUID());
distracted = true; this.distracted = true;
break;
} }
} }

View file

@ -6,6 +6,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
import com.atsuishio.superbwarfare.init.ModDamageTypes; 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.init.ModTags;
import com.atsuishio.superbwarfare.item.Monitor; import com.atsuishio.superbwarfare.item.Monitor;
import com.atsuishio.superbwarfare.item.common.ammo.MortarShell; import com.atsuishio.superbwarfare.item.common.ammo.MortarShell;
import com.atsuishio.superbwarfare.tools.CustomExplosion; import com.atsuishio.superbwarfare.tools.CustomExplosion;
@ -98,10 +99,6 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
return Mth.lerp(0.6f * tickDelta, pitchO, getBodyPitch()); return Mth.lerp(0.6f * tickDelta, pitchO, getBodyPitch());
} }
public DroneEntity(EntityType<? extends DroneEntity> type, Level world, float moveX, float moveY, float moveZ) {
super(type, world);
}
@Override @Override
protected void defineSynchedData(SynchedEntityData.Builder builder) { protected void defineSynchedData(SynchedEntityData.Builder builder) {
super.defineSynchedData(builder); super.defineSynchedData(builder);
@ -443,7 +440,8 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
final Vec3 center = new Vec3(this.getX(), this.getY(), this.getZ()); final Vec3 center = new Vec3(this.getX(), this.getY(), this.getZ());
for (Entity target : level.getEntitiesOfClass(Entity.class, aabb, e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) { for (Entity target : level.getEntitiesOfClass(Entity.class, aabb, e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
if (this != target && target != null if (this != target && target != null
&& !(target instanceof ItemEntity || target instanceof Projectile || target instanceof ProjectileEntity || target instanceof LaserEntity || target instanceof DecoyEntity || target instanceof AreaEffectCloud || target instanceof C4Entity)) { && !(target instanceof ItemEntity || target instanceof Projectile || target instanceof ProjectileEntity || target instanceof LaserEntity
|| target.getType().is(ModTags.EntityTypes.DECOY) || target instanceof AreaEffectCloud || target instanceof C4Entity)) {
hitEntityCrash(controller, target); hitEntityCrash(controller, target);
} }
} }

View file

@ -68,6 +68,7 @@ public class ModTags {
public static class EntityTypes { public static class EntityTypes {
public static final TagKey<EntityType<?>> AERIAL_BOMB = tag("aerial_bomb"); public static final TagKey<EntityType<?>> AERIAL_BOMB = tag("aerial_bomb");
public static final TagKey<EntityType<?>> DESTROYABLE_PROJECTILE = tag("destroyable_projectile"); public static final TagKey<EntityType<?>> DESTROYABLE_PROJECTILE = tag("destroyable_projectile");
public static final TagKey<EntityType<?>> DECOY = tag("decoy");
private static TagKey<EntityType<?>> tag(String name) { private static TagKey<EntityType<?>> tag(String name) {
return TagKey.create(Registries.ENTITY_TYPE, Mod.loc(name)); return TagKey.create(Registries.ENTITY_TYPE, Mod.loc(name));

View file

@ -4,12 +4,12 @@ import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.client.renderer.gun.JavelinItemRenderer; import com.atsuishio.superbwarfare.client.renderer.gun.JavelinItemRenderer;
import com.atsuishio.superbwarfare.client.tooltip.component.LauncherImageComponent; import com.atsuishio.superbwarfare.client.tooltip.component.LauncherImageComponent;
import com.atsuishio.superbwarfare.data.gun.GunData; import com.atsuishio.superbwarfare.data.gun.GunData;
import com.atsuishio.superbwarfare.entity.projectile.DecoyEntity;
import com.atsuishio.superbwarfare.entity.projectile.JavelinMissileEntity; import com.atsuishio.superbwarfare.entity.projectile.JavelinMissileEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModEnumExtensions; import com.atsuishio.superbwarfare.init.ModEnumExtensions;
import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage; import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.Perk;
@ -104,14 +104,13 @@ public class JavelinItem extends GunItem {
if (entity instanceof Player player && selected) { if (entity instanceof Player player && selected) {
if (tag.getBoolean("Seeking")) { if (tag.getBoolean("Seeking")) {
List<Entity> decoy = SeekTool.seekLivingEntities(player, player.level(), 512, 8); List<Entity> decoy = SeekTool.seekLivingEntities(player, player.level(), 512, 8);
for (var e : decoy) { for (var e : decoy) {
if (e instanceof DecoyEntity decoyEntity) { if (e.getType().is(ModTags.EntityTypes.DECOY)) {
tag.putString("TargetEntity", decoyEntity.getDecoyUUID()); tag.putString("TargetEntity", e.getStringUUID());
tag.putDouble("TargetPosX", decoyEntity.getPosition().x); tag.putDouble("TargetPosX", e.position().x);
tag.putDouble("TargetPosY", decoyEntity.getPosition().y); tag.putDouble("TargetPosY", e.position().y);
tag.putDouble("TargetPosZ", decoyEntity.getPosition().z); tag.putDouble("TargetPosZ", e.position().z);
} }
} }
@ -139,9 +138,7 @@ public class JavelinItem extends GunItem {
targetEntity.level().playSound(null, targetEntity.getOnPos(), targetEntity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.LOCKED_WARNING.get(), SoundSource.PLAYERS, 1, 0.95f); targetEntity.level().playSound(null, targetEntity.getOnPos(), targetEntity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.LOCKED_WARNING.get(), SoundSource.PLAYERS, 1, 0.95f);
} }
} }
} else if (tag.getInt("GuideType") == 1) { } else if (tag.getInt("GuideType") == 1) {
Vec3 toVec = player.getEyePosition().vectorTo(new Vec3(tag.getDouble("TargetPosX"), tag.getDouble("TargetPosY"), tag.getDouble("TargetPosZ"))).normalize(); Vec3 toVec = player.getEyePosition().vectorTo(new Vec3(tag.getDouble("TargetPosX"), tag.getDouble("TargetPosY"), tag.getDouble("TargetPosZ"))).normalize();
if (VectorTool.calculateAngle(player.getViewVector(1), toVec) < 8) { if (VectorTool.calculateAngle(player.getViewVector(1), toVec) < 8) {
tag.putInt("SeekTime", tag.getInt("SeekTime") + 1); tag.putInt("SeekTime", tag.getInt("SeekTime") + 1);
@ -162,7 +159,7 @@ public class JavelinItem extends GunItem {
Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 512, 8); Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 512, 8);
if (seekingEntity instanceof DecoyEntity) { if (seekingEntity.getType().is(ModTags.EntityTypes.DECOY)) {
tag.putInt("SeekTime", 0); tag.putInt("SeekTime", 0);
} }
} }

View file

@ -1,7 +1,6 @@
package com.atsuishio.superbwarfare.tools; package com.atsuishio.superbwarfare.tools;
import com.atsuishio.superbwarfare.config.server.SeekConfig; import com.atsuishio.superbwarfare.config.server.SeekConfig;
import com.atsuishio.superbwarfare.entity.projectile.DecoyEntity;
import com.atsuishio.superbwarfare.entity.projectile.SmokeDecoyEntity; import com.atsuishio.superbwarfare.entity.projectile.SmokeDecoyEntity;
import com.atsuishio.superbwarfare.entity.projectile.SwarmDroneEntity; import com.atsuishio.superbwarfare.entity.projectile.SwarmDroneEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
@ -178,7 +177,7 @@ public class SeekTool {
public static List<Entity> getEntitiesWithinRange(BlockPos pos, Level level, double range) { public static List<Entity> getEntitiesWithinRange(BlockPos pos, Level level, double range) {
return StreamSupport.stream(EntityFindUtil.getEntities(level).getAll().spliterator(), false) return StreamSupport.stream(EntityFindUtil.getEntities(level).getAll().spliterator(), false)
.filter(e -> e.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) <= range * range .filter(e -> e.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) <= range * range
&& baseFilter(e) && smokeFilter(e) && !(e instanceof DecoyEntity)) && baseFilter(e) && smokeFilter(e) && !e.getType().is(ModTags.EntityTypes.DECOY))
.toList(); .toList();
} }

View file

@ -1,7 +1,7 @@
package com.atsuishio.superbwarfare.tools; package com.atsuishio.superbwarfare.tools;
import com.atsuishio.superbwarfare.entity.projectile.DecoyEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import com.atsuishio.superbwarfare.init.ModTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -108,7 +108,8 @@ public class TraceTool {
Vec3 viewVec = vehicle.getBarrelVector(1); Vec3 viewVec = vehicle.getBarrelVector(1);
Vec3 toVec = eye.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach); Vec3 toVec = eye.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
AABB aabb = vehicle.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D); AABB aabb = vehicle.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(vehicle, eye, toVec, aabb, p -> !p.isSpectator() && p.isAlive() && SeekTool.baseFilter(p) && !(p instanceof DecoyEntity) && smokeFilter(p), distance); EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(vehicle, eye, toVec, aabb,
p -> !p.isSpectator() && p.isAlive() && SeekTool.baseFilter(p) && !p.getType().is(ModTags.EntityTypes.DECOY) && smokeFilter(p), distance);
if (entityhitresult != null) { if (entityhitresult != null) {
hitResult = entityhitresult; hitResult = entityhitresult;
@ -130,7 +131,8 @@ public class TraceTool {
&& p.isAlive() && p.isAlive()
&& !(p instanceof Projectile) && !(p instanceof Projectile)
&& SeekTool.baseFilter(p) && SeekTool.baseFilter(p)
&& !(p instanceof DecoyEntity) && smokeFilter(p) && !p.getType().is(ModTags.EntityTypes.DECOY)
&& smokeFilter(p)
&& p != entity && p != entity
&& p != entity.getVehicle(), distance); && p != entity.getVehicle(), distance);
if (entityhitresult != null) { if (entityhitresult != null) {
@ -154,7 +156,8 @@ public class TraceTool {
&& p.isAlive() && p.isAlive()
&& !(p instanceof Projectile) && !(p instanceof Projectile)
&& SeekTool.baseFilter(p) && SeekTool.baseFilter(p)
&& !(p instanceof DecoyEntity) && smokeFilter(p) && !p.getType().is(ModTags.EntityTypes.DECOY)
&& smokeFilter(p)
&& p != player && p != player
&& p != player.getVehicle(), distance); && p != player.getVehicle(), distance);
if (entityhitresult != null) { if (entityhitresult != null) {