diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java index 1a7fe28d3..20a397a06 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/C4Entity.java @@ -279,7 +279,7 @@ public class C4Entity extends Projectile implements GeoEntity { protected void onHitEntity(EntityHitResult pResult) { super.onHitEntity(pResult); Entity entity = pResult.getEntity(); - if (entity == this.getOwner() || entity == this.getVehicle()) return; + if (entity == this.getVehicle()) return; this.entityData.set(TARGET_UUID, entity.getStringUUID()); this.onEntity = true; this.setDeltaMovement(this.getDeltaMovement().multiply(0, 0, 0)); diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java index 9b60321dc..f97b8a0bf 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java @@ -425,5 +425,7 @@ public class ModSounds { public static final RegistryObject TURRET_TURN = REGISTRY.register("turret_turn", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("turret_turn"))); public static final RegistryObject C4_BEEP = REGISTRY.register("c4_beep", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("c4_beep"))); public static final RegistryObject C4_FINAL = REGISTRY.register("c4_final", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("c4_final"))); + public static final RegistryObject C4_THROW = REGISTRY.register("c4_throw", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("c4_throw"))); + public static final RegistryObject C4_DETONATOR_CLICK = REGISTRY.register("c4_detonator_click", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("c4_detonator_click"))); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/C4Bomb.java b/src/main/java/com/atsuishio/superbwarfare/item/C4Bomb.java index 6146aeecf..9c8603a23 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/C4Bomb.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/C4Bomb.java @@ -2,8 +2,10 @@ package com.atsuishio.superbwarfare.item; import com.atsuishio.superbwarfare.client.TooltipTool; import com.atsuishio.superbwarfare.entity.C4Entity; -import com.atsuishio.superbwarfare.tools.EntityFindUtil; +import com.atsuishio.superbwarfare.init.ModSounds; import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; @@ -25,11 +27,6 @@ public class C4Bomb extends Item { public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); - if (player.serializeNBT().contains("C4UUID") && player.serializeNBT().hasUUID("C4UUID")) { - if (EntityFindUtil.findEntity(player.level(), player.serializeNBT().getUUID("C4UUID").toString()) != null) { - return InteractionResultHolder.pass(stack); - } - } if (!level.isClientSide) { C4Entity entity = new C4Entity(player, level); entity.setPos(player.getX() + 0.25 * player.getLookAngle().x, player.getEyeY() - 0.2f + 0.25 * player.getLookAngle().y, player.getZ() + 0.25 * player.getLookAngle().z); @@ -39,6 +36,10 @@ public class C4Bomb extends Item { level.addFreshEntity(entity); } + if (player instanceof ServerPlayer serverPlayer) { + serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.C4_THROW.get(), SoundSource.PLAYERS, 1, 1); + } + player.getCooldowns().addCooldown(this, 20); if (!player.getAbilities().instabuild) { diff --git a/src/main/java/com/atsuishio/superbwarfare/item/Detonator.java b/src/main/java/com/atsuishio/superbwarfare/item/Detonator.java index cd01657f1..612e1e911 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/Detonator.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/Detonator.java @@ -1,7 +1,10 @@ package com.atsuishio.superbwarfare.item; import com.atsuishio.superbwarfare.entity.C4Entity; +import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.tools.EntityFindUtil; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.Entity; @@ -28,16 +31,19 @@ public Detonator() { ItemStack stack = player.getItemInHand(hand); player.getCooldowns().addCooldown(stack.getItem(), 10); + if (player instanceof ServerPlayer serverPlayer) { + serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.C4_DETONATOR_CLICK.get(), SoundSource.PLAYERS, 1, 1); + } + 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); + return InteractionResultHolder.consume(stack); } } diff --git a/src/main/resources/assets/superbwarfare/sounds.json b/src/main/resources/assets/superbwarfare/sounds.json index fe7cbbddc..4bab1a45c 100644 --- a/src/main/resources/assets/superbwarfare/sounds.json +++ b/src/main/resources/assets/superbwarfare/sounds.json @@ -2931,5 +2931,21 @@ "stream": false } ] + }, + "c4_throw": { + "sounds": [ + { + "name": "superbwarfare:c4/c4_throw", + "stream": false + } + ] + }, + "c4_detonator_click": { + "sounds": [ + { + "name": "superbwarfare:c4/c4_detonator_click", + "stream": false + } + ] } } \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/sounds/c4/c4_detonator_click.ogg b/src/main/resources/assets/superbwarfare/sounds/c4/c4_detonator_click.ogg new file mode 100644 index 000000000..95593df01 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/c4/c4_detonator_click.ogg differ diff --git a/src/main/resources/assets/superbwarfare/sounds/c4/c4_throw.ogg b/src/main/resources/assets/superbwarfare/sounds/c4/c4_throw.ogg new file mode 100644 index 000000000..a990ba038 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/c4/c4_throw.ogg differ