diff --git a/src/generated/resources/.cache/b6658e94d9c7ecb8e7f48d7838aba9405dd47577 b/src/generated/resources/.cache/b6658e94d9c7ecb8e7f48d7838aba9405dd47577 index 0a7a6b4cd..acf484510 100644 --- a/src/generated/resources/.cache/b6658e94d9c7ecb8e7f48d7838aba9405dd47577 +++ b/src/generated/resources/.cache/b6658e94d9c7ecb8e7f48d7838aba9405dd47577 @@ -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 +831bbb12a31a9fd9a731e812b690d09d70ade7e9 data/superbwarfare/tags/entity_type/decoy.json dab439adf745fde8ee3ecf56a40c617dfedc9c47 data/superbwarfare/tags/entity_type/destroyable_projectile.json diff --git a/src/generated/resources/data/superbwarfare/tags/entity_type/decoy.json b/src/generated/resources/data/superbwarfare/tags/entity_type/decoy.json new file mode 100644 index 000000000..ed2ccb454 --- /dev/null +++ b/src/generated/resources/data/superbwarfare/tags/entity_type/decoy.json @@ -0,0 +1,6 @@ +{ + "values": [ + "superbwarfare:smoke_decoy", + "superbwarfare:flare_decoy" + ] +} \ No newline at end of file diff --git a/src/main/java/com/atsuishio/superbwarfare/datagen/ModEntityTypeTagProvider.java b/src/main/java/com/atsuishio/superbwarfare/datagen/ModEntityTypeTagProvider.java index a5c45dfce..10b41401b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/datagen/ModEntityTypeTagProvider.java +++ b/src/main/java/com/atsuishio/superbwarfare/datagen/ModEntityTypeTagProvider.java @@ -37,6 +37,11 @@ public class ModEntityTypeTagProvider extends EntityTypeTagsProvider { ModEntities.SWARM_DRONE.get(), ModEntities.WG_MISSILE.get() ); + + this.tag(ModTags.EntityTypes.DECOY).add( + ModEntities.SMOKE_DECOY.get(), + ModEntities.FLARE_DECOY.get() + ); } public static TagKey> cTag(String name) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Agm65Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Agm65Entity.java index 2365a20bb..67189f7ad 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Agm65Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Agm65Entity.java @@ -2,10 +2,7 @@ package com.atsuishio.superbwarfare.entity.projectile; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; -import com.atsuishio.superbwarfare.init.ModDamageTypes; -import com.atsuishio.superbwarfare.init.ModEntities; -import com.atsuishio.superbwarfare.init.ModItems; -import com.atsuishio.superbwarfare.init.ModSounds; +import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage; import com.atsuishio.superbwarfare.tools.*; 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 explosionRadius = ExplosionConfig.AGM_65_EXPLOSION_RADIUS.get().floatValue(); private boolean distracted = false; - private int durability = 100; public Agm65Entity(EntityType type, Level world) { @@ -244,9 +240,10 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E List decoy = SeekTool.seekLivingEntities(this, this.level(), 32, 90); for (var e : decoy) { - if (e instanceof DecoyEntity decoyEntity && !distracted) { - this.entityData.set(TARGET_UUID, decoyEntity.getDecoyUUID()); - distracted = true; + if (e.getType().is(ModTags.EntityTypes.DECOY) && !this.distracted) { + this.entityData.set(TARGET_UUID, e.getStringUUID()); + this.distracted = true; + break; } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/DecoyEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/DecoyEntity.java deleted file mode 100644 index 27690c75f..000000000 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/DecoyEntity.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.atsuishio.superbwarfare.entity.projectile; - -import net.minecraft.world.phys.Vec3; - -public interface DecoyEntity { - - String getDecoyUUID(); - - Vec3 getPosition(); -} diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FlareDecoyEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FlareDecoyEntity.java index 0bca9700c..e3a2ffef8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FlareDecoyEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FlareDecoyEntity.java @@ -14,7 +14,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; -public class FlareDecoyEntity extends Entity implements DecoyEntity { +public class FlareDecoyEntity extends Entity { public FlareDecoyEntity(EntityType type, Level world) { super(type, world); @@ -61,14 +61,4 @@ public class FlareDecoyEntity extends Entity implements DecoyEntity { this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); } - - @Override - public String getDecoyUUID() { - return this.getStringUUID(); - } - - @Override - public Vec3 getPosition() { - return position(); - } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java index f7b6acfa2..16beb6f3e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java @@ -2,10 +2,7 @@ package com.atsuishio.superbwarfare.entity.projectile; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; -import com.atsuishio.superbwarfare.init.ModDamageTypes; -import com.atsuishio.superbwarfare.init.ModEntities; -import com.atsuishio.superbwarfare.init.ModItems; -import com.atsuishio.superbwarfare.init.ModSounds; +import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage; import com.atsuishio.superbwarfare.tools.*; import net.minecraft.core.BlockPos; @@ -292,9 +289,10 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo List decoy = SeekTool.seekLivingEntities(this, this.level(), 32, 90); for (var e : decoy) { - if (e instanceof DecoyEntity decoyEntity && !distracted) { - this.entityData.set(TARGET_UUID, decoyEntity.getDecoyUUID()); - distracted = true; + if (e.getType().is(ModTags.EntityTypes.DECOY) && !this.distracted) { + this.entityData.set(TARGET_UUID, e.getStringUUID()); + this.distracted = true; + break; } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmokeDecoyEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmokeDecoyEntity.java index 52b7fb2ab..de856e5c8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmokeDecoyEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmokeDecoyEntity.java @@ -16,7 +16,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; -public class SmokeDecoyEntity extends Entity implements DecoyEntity { +public class SmokeDecoyEntity extends Entity { public SmokeDecoyEntity(EntityType type, Level world) { super(type, world); @@ -78,14 +78,4 @@ public class SmokeDecoyEntity extends Entity implements DecoyEntity { this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); } - - @Override - public Vec3 getPosition() { - return position(); - } - - @Override - public String getDecoyUUID() { - return this.getStringUUID(); - } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SwarmDroneEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SwarmDroneEntity.java index 97f3190f9..6361a2e0c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SwarmDroneEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SwarmDroneEntity.java @@ -1,10 +1,7 @@ package com.atsuishio.superbwarfare.entity.projectile; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; -import com.atsuishio.superbwarfare.init.ModDamageTypes; -import com.atsuishio.superbwarfare.init.ModEntities; -import com.atsuishio.superbwarfare.init.ModItems; -import com.atsuishio.superbwarfare.init.ModSounds; +import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage; import com.atsuishio.superbwarfare.tools.CustomExplosion; import com.atsuishio.superbwarfare.tools.EntityFindUtil; @@ -212,9 +209,10 @@ public class SwarmDroneEntity extends FastThrowableProjectile implements GeoEnti List decoy = SeekTool.seekLivingEntities(this, this.level(), 32, 90); for (var e : decoy) { - if (e instanceof DecoyEntity decoyEntity && !distracted) { - this.entityData.set(TARGET_UUID, decoyEntity.getDecoyUUID()); - distracted = true; + if (e.getType().is(ModTags.EntityTypes.DECOY) && !this.distracted) { + this.entityData.set(TARGET_UUID, e.getStringUUID()); + this.distracted = true; + break; } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java index 4330d1072..c4e06c24a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java @@ -6,6 +6,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity; import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; +import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.Monitor; import com.atsuishio.superbwarfare.item.common.ammo.MortarShell; 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()); } - public DroneEntity(EntityType type, Level world, float moveX, float moveY, float moveZ) { - super(type, world); - } - @Override protected void defineSynchedData(SynchedEntityData.Builder 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()); for (Entity target : level.getEntitiesOfClass(Entity.class, aabb, e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) { 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); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModTags.java b/src/main/java/com/atsuishio/superbwarfare/init/ModTags.java index ef8429866..592d9f033 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModTags.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModTags.java @@ -68,6 +68,7 @@ public class ModTags { public static class EntityTypes { public static final TagKey> AERIAL_BOMB = tag("aerial_bomb"); public static final TagKey> DESTROYABLE_PROJECTILE = tag("destroyable_projectile"); + public static final TagKey> DECOY = tag("decoy"); private static TagKey> tag(String name) { return TagKey.create(Registries.ENTITY_TYPE, Mod.loc(name)); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java index 532bd12dd..7b2b32259 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java @@ -4,12 +4,12 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.renderer.gun.JavelinItemRenderer; import com.atsuishio.superbwarfare.client.tooltip.component.LauncherImageComponent; 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.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModEnumExtensions; import com.atsuishio.superbwarfare.init.ModSounds; +import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage; import com.atsuishio.superbwarfare.perk.Perk; @@ -104,14 +104,13 @@ public class JavelinItem extends GunItem { if (entity instanceof Player player && selected) { if (tag.getBoolean("Seeking")) { - List decoy = SeekTool.seekLivingEntities(player, player.level(), 512, 8); for (var e : decoy) { - if (e instanceof DecoyEntity decoyEntity) { - tag.putString("TargetEntity", decoyEntity.getDecoyUUID()); - tag.putDouble("TargetPosX", decoyEntity.getPosition().x); - tag.putDouble("TargetPosY", decoyEntity.getPosition().y); - tag.putDouble("TargetPosZ", decoyEntity.getPosition().z); + if (e.getType().is(ModTags.EntityTypes.DECOY)) { + tag.putString("TargetEntity", e.getStringUUID()); + tag.putDouble("TargetPosX", e.position().x); + tag.putDouble("TargetPosY", e.position().y); + 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); } } - } else if (tag.getInt("GuideType") == 1) { - 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) { 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); - if (seekingEntity instanceof DecoyEntity) { + if (seekingEntity.getType().is(ModTags.EntityTypes.DECOY)) { tag.putInt("SeekTime", 0); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java index d9b2162bf..d75a1b0b8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java @@ -1,7 +1,6 @@ package com.atsuishio.superbwarfare.tools; 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.SwarmDroneEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity; @@ -178,7 +177,7 @@ public class SeekTool { public static List getEntitiesWithinRange(BlockPos pos, Level level, double range) { return StreamSupport.stream(EntityFindUtil.getEntities(level).getAll().spliterator(), false) .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(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java index 60c8c0e3e..35df1d0b7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java @@ -1,7 +1,7 @@ package com.atsuishio.superbwarfare.tools; -import com.atsuishio.superbwarfare.entity.projectile.DecoyEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; +import com.atsuishio.superbwarfare.init.ModTags; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.entity.Entity; @@ -108,7 +108,8 @@ public class TraceTool { Vec3 viewVec = vehicle.getBarrelVector(1); 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); - 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) { hitResult = entityhitresult; @@ -130,7 +131,8 @@ public class TraceTool { && p.isAlive() && !(p instanceof Projectile) && SeekTool.baseFilter(p) - && !(p instanceof DecoyEntity) && smokeFilter(p) + && !p.getType().is(ModTags.EntityTypes.DECOY) + && smokeFilter(p) && p != entity && p != entity.getVehicle(), distance); if (entityhitresult != null) { @@ -154,7 +156,8 @@ public class TraceTool { && p.isAlive() && !(p instanceof Projectile) && SeekTool.baseFilter(p) - && !(p instanceof DecoyEntity) && smokeFilter(p) + && !p.getType().is(ModTags.EntityTypes.DECOY) + && smokeFilter(p) && p != player && p != player.getVehicle(), distance); if (entityhitresult != null) {