警棍、大锤、子弹添加命中音效
This commit is contained in:
parent
7726b67db1
commit
6d8f59659f
4 changed files with 44 additions and 4 deletions
|
@ -482,6 +482,10 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
|
||||||
entity = part.getParent();
|
entity = part.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entity instanceof LivingEntity living) {
|
||||||
|
living.level().playSound(null, living.getOnPos(), ModSounds.MELEE_HIT.get(), SoundSource.PLAYERS, 1, (float) ((2 * org.joml.Math.random() - 1) * 0.1f + 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
if (beast && entity instanceof LivingEntity living) {
|
if (beast && entity instanceof LivingEntity living) {
|
||||||
Beast.beastKill(this.shooter, living);
|
Beast.beastKill(this.shooter, living);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -147,10 +147,7 @@ public class ModItems {
|
||||||
.durability(1200)
|
.durability(1200)
|
||||||
));
|
));
|
||||||
public static final DeferredHolder<Item, Hammer> HAMMER = ITEMS.register("hammer", Hammer::new);
|
public static final DeferredHolder<Item, Hammer> HAMMER = ITEMS.register("hammer", Hammer::new);
|
||||||
public static final DeferredHolder<Item, SwordItem> T_BATON = ITEMS.register("t_baton", () -> new SwordItem(ModItemTier.STEEL, new Item.Properties()
|
public static final DeferredHolder<Item, TBaton> T_BATON = ITEMS.register("t_baton", TBaton::new);
|
||||||
.attributes(SwordItem.createAttributes(ModItemTier.STEEL, 3, -2))
|
|
||||||
.durability(1115)
|
|
||||||
));
|
|
||||||
public static final DeferredHolder<Item, ElectricBaton> ELECTRIC_BATON = ITEMS.register("electric_baton", ElectricBaton::new);
|
public static final DeferredHolder<Item, ElectricBaton> ELECTRIC_BATON = ITEMS.register("electric_baton", ElectricBaton::new);
|
||||||
public static final DeferredHolder<Item, Crowbar> CROWBAR = ITEMS.register("crowbar", Crowbar::new);
|
public static final DeferredHolder<Item, Crowbar> CROWBAR = ITEMS.register("crowbar", Crowbar::new);
|
||||||
public static final DeferredHolder<Item, Defuser> DEFUSER = ITEMS.register("defuser", Defuser::new);
|
public static final DeferredHolder<Item, Defuser> DEFUSER = ITEMS.register("defuser", Defuser::new);
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item;
|
package com.atsuishio.superbwarfare.item;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.SwordItem;
|
import net.minecraft.world.item.SwordItem;
|
||||||
|
@ -10,6 +13,8 @@ import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
@EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME)
|
@EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME)
|
||||||
public class Hammer extends SwordItem {
|
public class Hammer extends SwordItem {
|
||||||
|
|
||||||
|
@ -40,6 +45,13 @@ public class Hammer extends SwordItem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
|
||||||
|
attacker.level().playSound(null, target.getOnPos(), ModSounds.MELEE_HIT.get(), SoundSource.PLAYERS, 1, (float) ((2 * org.joml.Math.random() - 1) * 0.1f + 1.0f));
|
||||||
|
return super.hurtEnemy(stack, target, attacker);
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onItemCrafted(PlayerEvent.ItemCraftedEvent event) {
|
public static void onItemCrafted(PlayerEvent.ItemCraftedEvent event) {
|
||||||
var item = event.getCrafting();
|
var item = event.getCrafting();
|
||||||
|
|
27
src/main/java/com/atsuishio/superbwarfare/item/TBaton.java
Normal file
27
src/main/java/com/atsuishio/superbwarfare/item/TBaton.java
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package com.atsuishio.superbwarfare.item;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
import com.atsuishio.superbwarfare.tiers.ModItemTier;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.SwordItem;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
public class TBaton extends SwordItem {
|
||||||
|
public TBaton() {
|
||||||
|
super(ModItemTier.STEEL, new Properties()
|
||||||
|
.durability(1115)
|
||||||
|
.attributes(SwordItem.createAttributes(ModItemTier.STEEL, 3, -2))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
|
||||||
|
attacker.level().playSound(null, target.getOnPos(), ModSounds.MELEE_HIT.get(), SoundSource.PLAYERS, 1, (float) ((2 * org.joml.Math.random() - 1) * 0.1f + 1));
|
||||||
|
return super.hurtEnemy(stack, target, attacker);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue