diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RgoGrenadeEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RgoGrenadeEntity.java index d5823f6a0..b51e25a31 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RgoGrenadeEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RgoGrenadeEntity.java @@ -91,7 +91,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5)); } } - if (entity instanceof DroneEntity) { + if (!(entity instanceof DroneEntity)) { ProjectileTool.causeCustomExplode(this, 100f, 4f, 1.2f); } break; diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index d8e02edbf..0eb0aee81 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java @@ -354,7 +354,7 @@ public class ClientEventHandler { Entity lookingEntity = TraceTool.laserfindLookingEntity(player, 512); if (player.isCrouching()) { - Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 64, 32); + Entity seekingEntity = SeekTool.seekLivingEntity(player, player.level(), 64, 32); if (seekingEntity != null && seekingEntity.isAlive()) { player.lookAt(EntityAnchorArgument.Anchor.EYES, seekingEntity.getEyePosition()); } @@ -1123,7 +1123,7 @@ public class ClientEventHandler { && !player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) { int level = PerkHelper.getItemPerkLevel(ModPerks.INTELLIGENT_CHIP.get(), stack); if (level > 0) { - Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 32 + 8 * (level - 1), 25 / zoomFov); + Entity seekingEntity = SeekTool.seekLivingEntity(player, player.level(), 32 + 8 * (level - 1), 25 / zoomFov); if (seekingEntity != null && seekingEntity.isAlive()) { player.lookAt(EntityAnchorArgument.Anchor.EYES, seekingEntity.getEyePosition()); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/MinigunItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/MinigunItem.java index 01caf0d4d..eee8ec2b3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/MinigunItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/MinigunItem.java @@ -3,17 +3,17 @@ package com.atsuishio.superbwarfare.item.gun.machinegun; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.client.renderer.item.MinigunItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; -import com.atsuishio.superbwarfare.perk.Perk; -import com.atsuishio.superbwarfare.tools.GunsTool; -import com.atsuishio.superbwarfare.tools.ItemNBTTool; -import com.atsuishio.superbwarfare.tools.ParticleTool; -import com.atsuishio.superbwarfare.tools.RarityTool; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModParticleTypes; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.AnimatedItem; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.perk.Perk; +import com.atsuishio.superbwarfare.tools.GunsTool; +import com.atsuishio.superbwarfare.tools.ItemNBTTool; +import com.atsuishio.superbwarfare.tools.ParticleTool; +import com.atsuishio.superbwarfare.tools.RarityTool; import net.minecraft.client.Minecraft; import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.player.LocalPlayer; @@ -208,7 +208,7 @@ public class MinigunItem extends GunItem implements GeoItem, AnimatedItem { public boolean canApplyPerk(Perk perk) { return switch (perk.type) { case AMMO -> true; - case FUNCTIONAL -> perk == ModPerks.FIELD_DOCTOR.get(); + case FUNCTIONAL -> perk == ModPerks.FIELD_DOCTOR.get() || perk == ModPerks.INTELLIGENT_CHIP.get(); case DAMAGE -> perk == ModPerks.MONSTER_HUNTER.get() || perk == ModPerks.KILLING_TALLY.get(); }; } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/special/BocekItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/special/BocekItem.java index 611062b5c..c08ca5859 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/special/BocekItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/special/BocekItem.java @@ -160,7 +160,7 @@ public class BocekItem extends GunItem implements GeoItem, AnimatedItem { public boolean canApplyPerk(Perk perk) { return switch (perk.type) { case AMMO -> !perk.descriptionId.equals("butterfly_bullet"); - case FUNCTIONAL -> perk == ModPerks.FIELD_DOCTOR.get(); + case FUNCTIONAL -> perk == ModPerks.FIELD_DOCTOR.get() || perk == ModPerks.INTELLIGENT_CHIP.get(); case DAMAGE -> perk == ModPerks.MONSTER_HUNTER.get() || perk == ModPerks.KILLING_TALLY.get(); }; } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/special/TaserItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/special/TaserItem.java index bef0988c9..7375b2de7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/special/TaserItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/special/TaserItem.java @@ -1,20 +1,20 @@ package com.atsuishio.superbwarfare.item.gun.special; import com.atsuishio.superbwarfare.ModUtils; +import com.atsuishio.superbwarfare.client.PoseTool; import com.atsuishio.superbwarfare.client.renderer.item.TaserItemRenderer; +import com.atsuishio.superbwarfare.client.tooltip.component.EnergyImageComponent; import com.atsuishio.superbwarfare.energy.ItemEnergyProvider; import com.atsuishio.superbwarfare.event.ClientEventHandler; -import com.atsuishio.superbwarfare.perk.Perk; -import com.atsuishio.superbwarfare.perk.PerkHelper; -import com.atsuishio.superbwarfare.tools.GunsTool; -import com.atsuishio.superbwarfare.client.PoseTool; -import com.atsuishio.superbwarfare.client.tooltip.component.EnergyImageComponent; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.AnimatedItem; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.perk.Perk; +import com.atsuishio.superbwarfare.perk.PerkHelper; +import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.player.LocalPlayer; @@ -223,7 +223,7 @@ public class TaserItem extends GunItem implements GeoItem, AnimatedItem { public boolean canApplyPerk(Perk perk) { return switch (perk.type) { case AMMO -> perk == ModPerks.LONGER_WIRE.get(); - case FUNCTIONAL -> perk == ModPerks.SUPER_RECHARGE.get() || perk == ModPerks.POWERFUL_ATTRACTION.get(); + case FUNCTIONAL -> perk == ModPerks.SUPER_RECHARGE.get() || perk == ModPerks.POWERFUL_ATTRACTION.get() || perk == ModPerks.INTELLIGENT_CHIP.get(); case DAMAGE -> perk == ModPerks.VOLT_OVERLOAD.get(); }; } diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java index a190cdabe..0df31388b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java @@ -1,6 +1,8 @@ package com.atsuishio.superbwarfare.tools; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.phys.HitResult; @@ -22,6 +24,22 @@ public class SeekTool { }).min(Comparator.comparingDouble(e -> calculateAngle(e, entity))).orElse(null); } + public static Entity seekLivingEntity(Entity entity, Level level, double seekRange, double seekAngle) { + return StreamSupport.stream(EntityFindUtil.getEntities(level).getAll().spliterator(), false) + .filter(e -> { + if (e.distanceTo(entity) <= seekRange && calculateAngle(e, entity) < seekAngle + && e != entity + && e.isAlive() + && e instanceof LivingEntity + && !(e instanceof Player player && (player.isCreative() || player.isSpectator())) + && (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) { + return level.clip(new ClipContext(entity.getEyePosition(), e.getEyePosition(), + ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() != HitResult.Type.BLOCK; + } + return false; + }).min(Comparator.comparingDouble(e -> calculateAngle(e, entity))).orElse(null); + } + private static double calculateAngle(Entity entityA, Entity entityB) { Vec3 start = new Vec3(entityA.getX() - entityB.getX(), entityA.getY() - entityB.getY(), entityA.getZ() - entityB.getZ()); Vec3 end = entityB.getLookAngle(); diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index 29ea42fbf..a4e4bd705 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -273,6 +273,8 @@ "des.superbwarfare.turbo_charger": "Reduces auto fire spin-up time for compatible weapons", "item.superbwarfare.powerful_attraction": "Powerful Attraction", "des.superbwarfare.powerful_attraction": "Transfer items and experience dropped by killed targets to your inventory", + "item.superbwarfare.intelligent_chip": "Intelligent Chip", + "des.superbwarfare.intelligent_chip": "自动瞄准敌人(请勿在PVP环境下使用此模组)", "item.superbwarfare.kill_clip": "Kill Clip", "des.superbwarfare.kill_clip": "Increases the damage of weapon after dealing a final blow", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index 52a363fcc..c926accbe 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -273,6 +273,8 @@ "des.superbwarfare.turbo_charger": "装配后减少武器自动射击所需的缓冲时间", "item.superbwarfare.powerful_attraction": "强力吸引", "des.superbwarfare.powerful_attraction": "击杀目标后掉落的物品和经验会直接转移到自身", + "item.superbwarfare.intelligent_chip": "智慧芯片", + "des.superbwarfare.intelligent_chip": "自动瞄准敌人(请勿在PVP环境下使用此模组)", "item.superbwarfare.kill_clip": "杀戮弹匣", "des.superbwarfare.kill_clip": "完成击杀后填装可提升武器伤害", diff --git a/src/main/resources/assets/superbwarfare/models/item/intelligent_chip.json b/src/main/resources/assets/superbwarfare/models/item/intelligent_chip.json new file mode 100644 index 000000000..78cf776b8 --- /dev/null +++ b/src/main/resources/assets/superbwarfare/models/item/intelligent_chip.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "superbwarfare:item/perk/intelligent_chip" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/textures/item/perk/intelligent_chip.png b/src/main/resources/assets/superbwarfare/textures/item/perk/intelligent_chip.png new file mode 100644 index 000000000..3e38cf3fa Binary files /dev/null and b/src/main/resources/assets/superbwarfare/textures/item/perk/intelligent_chip.png differ