From 38cd812f4fff1419497b3074f49f5fbe8527e19b Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Sun, 1 Dec 2024 20:06:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=99=BA=E6=85=A7=E8=8A=AF?= =?UTF-8?q?=E7=89=87=E7=9A=84=E7=BF=BB=E8=AF=91/=E8=B4=B4=E5=9B=BE/?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=EF=BC=8C=E6=89=A9=E5=A4=A7=E6=99=BA=E6=85=A7?= =?UTF-8?q?=E8=8A=AF=E7=89=87=E8=83=BD=E5=BA=94=E7=94=A8=E7=9A=84=E6=AD=A6?= =?UTF-8?q?=E5=99=A8=E7=A7=8D=E7=B1=BB=EF=BC=8C=E4=BC=98=E5=8C=96=E6=99=BA?= =?UTF-8?q?=E6=85=A7=E8=8A=AF=E7=89=87=E7=9A=84=E9=94=81=E5=AE=9A=E7=9B=AE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/projectile/RgoGrenadeEntity.java | 2 +- .../event/ClientEventHandler.java | 4 ++-- .../item/gun/machinegun/MinigunItem.java | 12 ++++++------ .../item/gun/special/BocekItem.java | 2 +- .../item/gun/special/TaserItem.java | 12 ++++++------ .../superbwarfare/tools/SeekTool.java | 18 ++++++++++++++++++ .../assets/superbwarfare/lang/en_us.json | 2 ++ .../assets/superbwarfare/lang/zh_cn.json | 2 ++ .../models/item/intelligent_chip.json | 6 ++++++ .../textures/item/perk/intelligent_chip.png | Bin 0 -> 729 bytes 10 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 src/main/resources/assets/superbwarfare/models/item/intelligent_chip.json create mode 100644 src/main/resources/assets/superbwarfare/textures/item/perk/intelligent_chip.png 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 0000000000000000000000000000000000000000..3e38cf3fa0311e58d1ed496b1350bdf7148e136a GIT binary patch literal 729 zcmV;~0w(>5P)5_@&IU^pyPlq2#i?sj&GM|+QRzo15?R6rYm1m+4E3yEgg5U3!0D#T* zm_^MX2|x(m#n!#wX$j=oZXa5)2Wvp7)t-t`fLjk9FbI$;`2B9#*q(#l8ekE;fa6*s z7doA{%)BssRs_v?Kvh*&9}sOn0U$Un{5M++(Zuoj{?yDYbzO^I`&x|o;vLYb0X_wf zn2jKWa$Uy(w>Z_A@H!9B5wj+Qc3BhwbZoXq>~~A&AYuqh6~KE~p#xngF?HUg9(hP%<_YeEZ--?g(AP>g$V5J5e1_0!|K4gDYS& zq=jWKublfezd3|-UJ0h`EM+F?gW`@NPIF?`6K4msJ7wbr)&A}F)Y(8@n;cMN4WQDl z5wV6G*#V(DU}{gz{Lr%!7dIr`4(sf%gDQd#WC19vI$v~|_pS6MlGOl;Na~nRv6@UK zz-D`FepJ*XXYi*W&vst+=n7j1Sn-I3}jLRI0@