From a5332a6cac455003611674351af2fc22539fb8ae Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Fri, 21 Mar 2025 14:54:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0C4=E8=B5=B7=E7=88=86=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/entity/C4Entity.java | 2 +- .../superbwarfare/init/ModItems.java | 2 + .../superbwarfare/item/Detonator.java | 43 +++ .../assets/superbwarfare/lang/en_us.json | 1 + .../assets/superbwarfare/lang/zh_cn.json | 1 + .../superbwarfare/models/item/detonator.json | 304 ++++++++++++++++++ .../superbwarfare/textures/item/detonator.png | Bin 0 -> 1697 bytes 7 files changed, 352 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/atsuishio/superbwarfare/item/Detonator.java create mode 100644 src/main/resources/assets/superbwarfare/models/item/detonator.json create mode 100644 src/main/resources/assets/superbwarfare/textures/item/detonator.png diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java index 04cec468c..1a7fe28d3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java @@ -309,7 +309,7 @@ public class C4Entity extends Projectile implements GeoEntity { this.inGround = true; } - private void explode() { + public void explode() { Vec3 pos = position(); if (onEntity) { diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java index 179cb2810..f0d7a2b60 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java @@ -132,6 +132,8 @@ public class ModItems { public static final RegistryObject DRONE = ITEMS.register("drone", Drone::new); public static final RegistryObject MONITOR = ITEMS.register("monitor", Monitor::new); + + public static final RegistryObject DETONATOR = ITEMS.register("detonator", Detonator::new); public static final RegistryObject TARGET_DEPLOYER = ITEMS.register("target_deployer", TargetDeployer::new); public static final RegistryObject KNIFE = ITEMS.register("knife", Knife::new); public static final RegistryObject HAMMER = ITEMS.register("hammer", Hammer::new); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/Detonator.java b/src/main/java/com/atsuishio/superbwarfare/item/Detonator.java new file mode 100644 index 000000000..cd01657f1 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/Detonator.java @@ -0,0 +1,43 @@ +package com.atsuishio.superbwarfare.item; + +import com.atsuishio.superbwarfare.entity.C4Entity; +import com.atsuishio.superbwarfare.tools.EntityFindUtil; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; + +import java.util.List; +import java.util.stream.StreamSupport; + +public class Detonator extends Item { +public Detonator() { + super(new Properties().stacksTo(1)); + } + + public static List getC4(Player player, Level level) { + return StreamSupport.stream(EntityFindUtil.getEntities(level).getAll().spliterator(), false) + .filter(e -> e instanceof C4Entity c4 && c4.getOwner() == player) + .toList(); + } + @Override + public InteractionResultHolder use(Level world, Player player, InteractionHand hand) { + ItemStack stack = player.getItemInHand(hand); + player.getCooldowns().addCooldown(stack.getItem(), 10); + + releaseUsing(stack, player.level(), player, 1); + + List entities = getC4(player, player.level()); + + for (var e : entities) { + if (e instanceof C4Entity c4) { + c4.explode(); + } + } + + return super.use(world, player, hand); + } +} diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index 73d12e810..26e8c3330 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -197,6 +197,7 @@ "item.superbwarfare.large_battery_pack": "Large Battery Pack", "item.superbwarfare.drone": "Drone", "item.superbwarfare.monitor": "Monitor", + "item.superbwarfare.detonator": "Detonator", "des.superbwarfare.monitor": "Drone Distance: %1$s", "item.superbwarfare.propeller": "Propeller", "item.superbwarfare.large_propeller": "Large Propeller", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index 2d3190cfb..c004ce8a4 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -197,6 +197,7 @@ "item.superbwarfare.large_battery_pack": "大型电池组", "item.superbwarfare.drone": "无人机", "item.superbwarfare.monitor": "遥控器", + "item.superbwarfare.detonator": "起爆器", "des.superbwarfare.monitor": "无人机距离你: %1$s", "item.superbwarfare.propeller": "螺旋桨", "item.superbwarfare.large_propeller": "大型螺旋桨", diff --git a/src/main/resources/assets/superbwarfare/models/item/detonator.json b/src/main/resources/assets/superbwarfare/models/item/detonator.json new file mode 100644 index 000000000..e1b049853 --- /dev/null +++ b/src/main/resources/assets/superbwarfare/models/item/detonator.json @@ -0,0 +1,304 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "1": "superbwarfare:item/detonator" + }, + "elements": [ + { + "name": "zhu", + "from": [7.5, 2.8345, 8.81392], + "to": [8.5, 3.74231, 9.56392], + "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 3.11732, 9.18892]}, + "faces": { + "east": {"uv": [6, 7, 6.75, 8], "texture": "#1"}, + "south": {"uv": [6, 6, 7, 7], "texture": "#1"}, + "west": {"uv": [7, 6, 7.75, 7], "texture": "#1"}, + "down": {"uv": [8, 7, 7, 7.75], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [7.5, 0, 7.9], + "to": [8.5, 0.25, 9.66563], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 10, 1, 10.25], "texture": "#1"}, + "east": {"uv": [9, 4, 10.75, 4.25], "texture": "#1"}, + "south": {"uv": [10, 0, 11, 0.25], "texture": "#1"}, + "west": {"uv": [9, 5, 10.75, 5.25], "texture": "#1"}, + "up": {"uv": [5, 5.75, 4, 4], "texture": "#1"}, + "down": {"uv": [6, 0, 5, 1.75], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [8.5, -0.46875, 7.15], + "to": [8.6, -0.36875, 8.16563], + "rotation": {"angle": -45, "axis": "x", "origin": [8.55, -0.3, 7.38281]}, + "faces": { + "north": {"uv": [11, 8, 11.25, 8.25], "texture": "#1"}, + "east": {"uv": [1, 10, 2, 10.25], "texture": "#1"}, + "south": {"uv": [9, 11, 9.25, 11.25], "texture": "#1"}, + "west": {"uv": [10, 1, 11, 1.25], "texture": "#1"}, + "up": {"uv": [2.25, 11, 2, 10], "texture": "#1"}, + "down": {"uv": [10.25, 2, 10, 3], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [7.5, -0.46875, 7.15], + "to": [8.5, -0.36875, 7.25], + "rotation": {"angle": -45, "axis": "x", "origin": [8.55, -0.3, 7.38281]}, + "faces": { + "north": {"uv": [3, 10, 4, 10.25], "texture": "#1"}, + "east": {"uv": [11, 9, 11.25, 9.25], "texture": "#1"}, + "south": {"uv": [10, 3, 11, 3.25], "texture": "#1"}, + "west": {"uv": [10, 11, 10.25, 11.25], "texture": "#1"}, + "up": {"uv": [5, 10.25, 4, 10], "texture": "#1"}, + "down": {"uv": [6, 10, 5, 10.25], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [7.4, -0.46875, 7.15], + "to": [7.5, -0.36875, 8.16563], + "rotation": {"angle": -45, "axis": "x", "origin": [7.45, -0.3, 7.38281]}, + "faces": { + "north": {"uv": [11, 10, 11.25, 10.25], "texture": "#1"}, + "east": {"uv": [6, 10, 7, 10.25], "texture": "#1"}, + "south": {"uv": [11, 11, 11.25, 11.25], "texture": "#1"}, + "west": {"uv": [10, 6, 11, 6.25], "texture": "#1"}, + "up": {"uv": [7.25, 11, 7, 10], "texture": "#1"}, + "down": {"uv": [10.25, 7, 10, 8], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [7.5, 0.25, 7.75], + "to": [8.5, 3, 9.64219], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [0, 3, 1, 5.75], "texture": "#1"}, + "east": {"uv": [0, 0, 2, 2.75], "texture": "#1"}, + "south": {"uv": [1, 3, 2, 5.75], "texture": "#1"}, + "west": {"uv": [2, 0, 4, 2.75], "texture": "#1"}, + "down": {"uv": [5, 0, 4, 2], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [7.5, 3.23824, 7.3462], + "to": [8.5, 3.83824, 9.2962], + "rotation": {"angle": 0, "axis": "y", "origin": [8, -0.00001, 8.00001]}, + "faces": { + "north": {"uv": [8, 7, 9, 7.5], "texture": "#1"}, + "east": {"uv": [7, 0, 9, 0.5], "texture": "#1"}, + "west": {"uv": [7, 1, 9, 1.5], "texture": "#1"}, + "up": {"uv": [5, 4, 4, 2], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [7.5, 2.99606, 7.74619], + "to": [8.5, 3.23825, 8.94619], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [8, 10, 9, 10.25], "texture": "#1"}, + "east": {"uv": [9, 8, 10.25, 8.25], "texture": "#1"}, + "south": {"uv": [9, 10, 10, 10.25], "texture": "#1"}, + "west": {"uv": [9, 9, 10.25, 9.25], "texture": "#1"}, + "down": {"uv": [6, 6, 5, 7.25], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [7.5, 3.12379, 7.3716], + "to": [8.5, 3.36598, 7.9216], + "rotation": {"angle": 22.5, "axis": "x", "origin": [8, 3.24489, 7.6466]}, + "faces": { + "east": {"uv": [11, 6, 11.5, 6.25], "texture": "#1"}, + "west": {"uv": [7, 11, 7.5, 11.25], "texture": "#1"}, + "down": {"uv": [9, 8, 8, 8.5], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [7.7, 3.75, 8.4], + "to": [8.3, 6.5, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [6, 0, 6.5, 2.75], "texture": "#1"}, + "east": {"uv": [1, 6, 1.5, 8.75], "texture": "#1"}, + "south": {"uv": [6, 3, 6.5, 5.75], "texture": "#1"}, + "west": {"uv": [4, 6, 4.5, 8.75], "texture": "#1"}, + "up": {"uv": [10.5, 10.5, 10, 10], "texture": "#1"}, + "down": {"uv": [0.5, 11, 0, 11.5], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [7.75, 0.24428, 7.4373], + "to": [8.25, 1.74428, 7.8873], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8.1]}, + "faces": { + "north": {"uv": [8, 2, 8.5, 3.5], "texture": "#1"}, + "east": {"uv": [8, 4, 8.5, 5.5], "texture": "#1"}, + "south": {"uv": [5, 8, 5.5, 9.5], "texture": "#1"}, + "west": {"uv": [6, 8, 6.5, 9.5], "texture": "#1"}, + "up": {"uv": [11.5, 0.5, 11, 0], "texture": "#1"}, + "down": {"uv": [1.5, 11, 1, 11.5], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [7.55, 2.93166, 7.09493], + "to": [8.45, 3.63166, 7.64493], + "rotation": {"angle": 45, "axis": "x", "origin": [8, 3.43166, 7.46993]}, + "faces": { + "north": {"uv": [8, 6, 9, 6.75], "texture": "#1"}, + "east": {"uv": [9, 6, 9.5, 6.75], "texture": "#1"}, + "south": {"uv": [7, 8, 8, 8.75], "texture": "#1"}, + "west": {"uv": [7, 9, 7.5, 9.75], "texture": "#1"}, + "up": {"uv": [10, 0.5, 9, 0], "texture": "#1"}, + "down": {"uv": [2, 9, 1, 9.5], "texture": "#1"} + } + }, + { + "name": "zhu", + "from": [7.5, 3.27155, 7.01494], + "to": [8.5, 3.47155, 7.21494], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [11, 1, 12, 1.25], "texture": "#1"}, + "east": {"uv": [0, 12, 0.25, 12.25], "texture": "#1"}, + "south": {"uv": [2, 11, 3, 11.25], "texture": "#1"}, + "west": {"uv": [12, 0, 12.25, 0.25], "texture": "#1"}, + "up": {"uv": [12, 2.25, 11, 2], "texture": "#1"}, + "down": {"uv": [4, 11, 3, 11.25], "texture": "#1"} + } + }, + { + "name": "ba", + "from": [7.8, 0.12709, 6.61152], + "to": [8.2, 1.87709, 7.06152], + "rotation": {"angle": 45, "axis": "x", "origin": [8, 1.36928, 6.8373]}, + "faces": { + "north": {"uv": [2, 7, 2.5, 8.75], "texture": "#1"}, + "east": {"uv": [7, 2, 7.5, 3.75], "texture": "#1"}, + "south": {"uv": [3, 7, 3.5, 8.75], "texture": "#1"}, + "west": {"uv": [7, 4, 7.5, 5.75], "texture": "#1"}, + "up": {"uv": [11.5, 3.5, 11, 3], "texture": "#1"}, + "down": {"uv": [4.5, 11, 4, 11.5], "texture": "#1"} + } + }, + { + "name": "ba", + "from": [7.8, 0.84173, 6.39688], + "to": [8.2, 1.84173, 6.59688], + "rotation": {"angle": 45, "axis": "x", "origin": [8, 1.33392, 6.87266]}, + "faces": { + "north": {"uv": [9, 1, 9.5, 2], "texture": "#1"}, + "east": {"uv": [11, 4, 11.25, 5], "texture": "#1"}, + "south": {"uv": [2, 9, 2.5, 10], "texture": "#1"}, + "west": {"uv": [5, 11, 5.25, 12], "texture": "#1"}, + "up": {"uv": [11.5, 7.25, 11, 7], "texture": "#1"}, + "down": {"uv": [8.5, 11, 8, 11.25], "texture": "#1"} + } + }, + { + "name": "ba", + "from": [7.65, 0.09818, 6.1459], + "to": [8.35, 3.29818, 6.6459], + "rotation": {"angle": 22.5, "axis": "x", "origin": [8, 1.36928, 6.8373]}, + "faces": { + "north": {"uv": [2, 3, 2.75, 6.25], "texture": "#1"}, + "east": {"uv": [5, 2, 5.5, 5.25], "texture": "#1"}, + "south": {"uv": [3, 3, 3.75, 6.25], "texture": "#1"}, + "west": {"uv": [0, 6, 0.5, 9.25], "texture": "#1"}, + "up": {"uv": [9.75, 7.5, 9, 7], "texture": "#1"}, + "down": {"uv": [8.75, 9, 8, 9.5], "texture": "#1"} + } + }, + { + "name": "tanhuang", + "from": [7.75, 2.2, 6.7], + "to": [8.25, 2.7, 7.81563], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]}, + "faces": { + "north": {"uv": [11, 5, 11.5, 5.5], "texture": "#1"}, + "east": {"uv": [9, 2, 10, 2.5], "texture": "#1"}, + "south": {"uv": [6, 11, 6.5, 11.5], "texture": "#1"}, + "west": {"uv": [3, 9, 4, 9.5], "texture": "#1"}, + "up": {"uv": [9.5, 4, 9, 3], "texture": "#1"}, + "down": {"uv": [4.5, 9, 4, 10], "texture": "#1"} + } + } + ], + "gui_light": "front", + "display": { + "thirdperson_righthand": { + "translation": [-1, 4.5, 0] + }, + "thirdperson_lefthand": { + "translation": [-1, 4.5, 0] + }, + "firstperson_righthand": { + "rotation": [0, 0, -17], + "translation": [-1.5, 10.5, 4.25] + }, + "firstperson_lefthand": { + "rotation": [0, 0, -17], + "translation": [-1.5, 10.5, 4.25] + }, + "ground": { + "translation": [0, 5, 0] + }, + "gui": { + "rotation": [90, 45, -90], + "translation": [8, 8.75, 0.5], + "scale": [2.2, 2.2, 2.2] + }, + "head": { + "translation": [0, 14.75, 0] + }, + "fixed": { + "rotation": [90, -45, 90], + "translation": [-9, 9.75, 0.5], + "scale": [2.5, 2.5, 2.5] + } + }, + "groups": [ + { + "name": "bone", + "origin": [8, 10, 8], + "color": 0, + "children": [ + { + "name": "0", + "origin": [8, 0, 8], + "color": 1, + "children": [ + { + "name": "zhu", + "origin": [8, 3.41452, 7.379], + "color": 3, + "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] + }, + { + "name": "ba", + "origin": [8, 3.35, 7.07], + "color": 4, + "children": [13, 14, 15] + }, + { + "name": "tanhuang", + "origin": [8, 2.45, 7.25781], + "color": 5, + "children": [16] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/textures/item/detonator.png b/src/main/resources/assets/superbwarfare/textures/item/detonator.png new file mode 100644 index 0000000000000000000000000000000000000000..429895789ee5f3ccbbe90226c2523c07a9bc6074 GIT binary patch literal 1697 zcmV;S244AzP)Px*TS-JgRCt{2nonpQMI6V!zuA57r73MeL0ZYddTG-`Xj2JkReTMtf=cn?ErP`u zq<9byUOWheg0@gR6p>oBU=D)dq0oagwy9!ksl*z=)GB(ghpJG)+B9!>XMP^`&A!=r ze>R)l_Y!nJm+b8P**CxW{eJWN&4h;c4l*-CDTW||QVakPf?#64SIiKCKooBS0KOMQ zbxJbU`u9R9h0B*O695eF8{}5~G&>)7Bv$_V#~HXK2LKTG5~EwH0Du!GP7nZ8t5u$v znQ1>@0xs7l7I-o?X(d~CP%;!ox#EJEL88^SDf*+7iuVr~!U1HUKmeE-%s@Mt%w4!1 zs~O!=WwV@R@&G_P#$H%*>J~07kPp{FcYp$SD9QnBR zFxoZx&T?utyARyoLBI0HB|%`7?wi_NTI~SefALf7<(u;2ms3EGAfly)b-$jF@|B|larGSV_(1io5046 z8&R!>+ug*(M9d8IdrfXWKsW-zA+WKkS~JX*CIVnBsCU<2n)9rqg5_&@)(P9he1KP5 zo~n9_ey9n3CEWVs4(_>cZKKZfI`&;yScsLUr>A2RoS2yCs!wodr{^#Q<>W(xpfc!fnW;zrR1$e*gac3;?H3pN<-tvB1U8KL89Ll9j|bKxXvdQnpDd z+OU58`dHbH1GE#(i)I0k^-P2y2;jQ8$4r3X{WUjk-00Xoua(!doK==DwDJRHMws^m zveGO7bIW3e?|YCz5G6J?-l7jI`cYZ-Tj{Tr4kyI{f4jc}0Bqj`0JGEc^wM*C_}!1r z=O)A^0kDzlbYuTf0mq!6P1ap0Ex8-EQ|g>9+t_hH5}ky%9C8$Wr+WWk{f_8l?+tCmA=vGzI=)S6+R2_8Fj7_1oIp1al^A0UK?1uut>eH#0aPJlG_ zp{I=u0tEG)K?VU>F_hs9rIZMQFkf)pW+C_FOz_s9cVaK|uzihE3@K%JQ=}BgvA4;^ zXy@=ezs)G!Bh&z6zIN!EL~?t>p|+6g(W7szs86V$2{v9Rr65G(g&n)wiKIF`3P>k=kMM6VDxQK>-A*we9Kx|vhhz1&PsmDdOdthU69SyP;{q2}4xd(~)1Ld=th7ml zKETM~lVW$foc7#5ZSvD?LJcsSplzeB|1)4rT;I(N3=H7r&6`m^Z=U0u*!jNgBVKv& ziRgQ8zxP=bCn(vtg*MG1cORgWpygtpmgWQB#t%i#izlzQWdTIuF zOgPJUyLUg#)#{$EnarvSglzQ6cZ+nl82>>cAE39N@$qp+sH(Ajza85)hceW0f_-d5;a7`n~>-UlSw rctJryK|w)5K|w)5K|w*me~y0v!Hy9JGpn!o00000NkvXXu0mjfxbQaC literal 0 HcmV?d00001