添加拉环和投掷音效

This commit is contained in:
Atsuihsio 2024-07-30 03:21:05 +08:00
parent e02410ee84
commit 151fbc2446
7 changed files with 36 additions and 8 deletions

View file

@ -127,7 +127,7 @@ public class HandGrenadeEntity extends ThrowableItemProjectile {
private void causeExplode() { private void causeExplode() {
CustomExplosion explosion = new CustomExplosion(this.level(), this, CustomExplosion explosion = new CustomExplosion(this.level(), this,
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), 90, ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), 90,
this.getX(), this.getY(), this.getZ(), 10f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(2); this.getX(), this.getY(), this.getZ(), 6.5f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(2);
explosion.explode(); explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false); explosion.finalizeExplosion(false);

View file

@ -192,4 +192,6 @@ public class ModSounds {
public static final RegistryObject<SoundEvent> BULLET_SUPPLY = REGISTRY.register("bullet_supply", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("superbwarfare", "bullet_supply"))); public static final RegistryObject<SoundEvent> BULLET_SUPPLY = REGISTRY.register("bullet_supply", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("superbwarfare", "bullet_supply")));
public static final RegistryObject<SoundEvent> ADJUST_FOV = REGISTRY.register("adjust_fov", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("superbwarfare", "adjust_fov"))); public static final RegistryObject<SoundEvent> ADJUST_FOV = REGISTRY.register("adjust_fov", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("superbwarfare", "adjust_fov")));
public static final RegistryObject<SoundEvent> DRONE_SOUND = REGISTRY.register("drone_sound", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("superbwarfare", "drone_sound"))); public static final RegistryObject<SoundEvent> DRONE_SOUND = REGISTRY.register("drone_sound", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("superbwarfare", "drone_sound")));
public static final RegistryObject<SoundEvent> GRENADE_PULL = REGISTRY.register("grenade_pull", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("superbwarfare", "grenade_pull")));
public static final RegistryObject<SoundEvent> GRENADE_THROW = REGISTRY.register("grenade_throw", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("superbwarfare", "grenade_throw")));
} }

View file

@ -2,8 +2,11 @@ package net.mcreator.superbwarfare.item;
import net.mcreator.superbwarfare.entity.HandGrenadeEntity; import net.mcreator.superbwarfare.entity.HandGrenadeEntity;
import net.mcreator.superbwarfare.init.ModDamageTypes; import net.mcreator.superbwarfare.init.ModDamageTypes;
import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.tools.CustomExplosion; import net.mcreator.superbwarfare.tools.CustomExplosion;
import net.mcreator.superbwarfare.tools.ParticleTool; import net.mcreator.superbwarfare.tools.ParticleTool;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
@ -25,6 +28,9 @@ public class HandGrenade extends Item {
public @NotNull InteractionResultHolder<ItemStack> use(Level worldIn, Player playerIn, InteractionHand handIn) { public @NotNull InteractionResultHolder<ItemStack> use(Level worldIn, Player playerIn, InteractionHand handIn) {
ItemStack stack = playerIn.getItemInHand(handIn); ItemStack stack = playerIn.getItemInHand(handIn);
playerIn.startUsingItem(handIn); playerIn.startUsingItem(handIn);
if (playerIn instanceof ServerPlayer serverPlayer) {
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.GRENADE_PULL.get(), SoundSource.PLAYERS, 1, 1);
}
return InteractionResultHolder.consume(stack); return InteractionResultHolder.consume(stack);
} }
@ -45,6 +51,10 @@ public class HandGrenade extends Item {
handGrenade.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0f, power, 0.0f); handGrenade.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0f, power, 0.0f);
worldIn.addFreshEntity(handGrenade); worldIn.addFreshEntity(handGrenade);
if (player instanceof ServerPlayer serverPlayer) {
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.GRENADE_THROW.get(), SoundSource.PLAYERS, 1, 1);
}
if (!player.isCreative()) { if (!player.isCreative()) {
stack.shrink(1); stack.shrink(1);
} }
@ -59,7 +69,7 @@ public class HandGrenade extends Item {
if (!pLevel.isClientSide) { if (!pLevel.isClientSide) {
CustomExplosion explosion = new CustomExplosion(pLevel, null, CustomExplosion explosion = new CustomExplosion(pLevel, null,
ModDamageTypes.causeProjectileBoomDamage(pLevel.registryAccess(), pLivingEntity, pLivingEntity), 90, ModDamageTypes.causeProjectileBoomDamage(pLevel.registryAccess(), pLivingEntity, pLivingEntity), 90,
pLivingEntity.getX(), pLivingEntity.getY(), pLivingEntity.getZ(), 10f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(2); pLivingEntity.getX(), pLivingEntity.getY(), pLivingEntity.getZ(), 6.5f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(2);
explosion.explode(); explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(pLevel, explosion); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(pLevel, explosion);
explosion.finalizeExplosion(false); explosion.finalizeExplosion(false);

View file

@ -285,14 +285,14 @@
], ],
"display": { "display": {
"firstperson_righthand": { "firstperson_righthand": {
"rotation": [0, -9, -7.25], "rotation": [-3, -19, -7.25],
"translation": [-2, 2.25, 3.25], "translation": [5.5, -0.75, -3.5],
"scale": [1.5, 1.5, 1] "scale": [2, 2, 2]
}, },
"firstperson_lefthand": { "firstperson_lefthand": {
"rotation": [0, -9, -7.25], "rotation": [-3, -19, -7.25],
"translation": [-2, 2.25, 3.25], "translation": [5.5, -0.75, -3.5],
"scale": [1.5, 1.5, 1] "scale": [2, 2, 2]
}, },
"ground": { "ground": {
"translation": [0, -2, 0] "translation": [0, -2, 0]

View file

@ -1582,5 +1582,21 @@
"stream": false "stream": false
} }
] ]
},
"grenade_throw": {
"sounds": [
{
"name": "superbwarfare:grenade_throw",
"stream": false
}
]
},
"grenade_pull": {
"sounds": [
{
"name": "superbwarfare:grenade_pull",
"stream": false
}
]
} }
} }