Fix sig sounds

This commit is contained in:
Andrew-71 2023-08-25 14:31:53 +03:00
parent d7e3ee995d
commit 547fa0aee8
2 changed files with 8 additions and 60 deletions

View file

@ -25,7 +25,7 @@ import net.minecraft.util.TypedActionResult;
import org.jetbrains.annotations.Nullable;
import su.a71.new_soviet.NewSoviet;
import su.a71.new_soviet.registration.NSE_Items;
import su.a71.new_soviet.sounds.Sounds;
import su.a71.new_soviet.registration.NSE_Sounds;
import java.util.List;
import java.util.Objects;
@ -57,16 +57,16 @@ public class CigaretteItem
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
ItemStack itemStack = user.getStackInHand(hand);
if (user.getInventory().getStack(40).getItem() == Items.FLINT_AND_STEEL && user.getInventory().getMainHandStack().getDamage() == 0) {
world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_START, SoundCategory.PLAYERS, 1.0f, 1.0f);
world.playSound(user, BlockPos.ofFloored(user.getPos()), NSE_Sounds.CIGARETTE_START, SoundCategory.PLAYERS, 1.0f, 1.0f);
user.incrementStat(Stats.USED.getOrCreateStat(this));
itemStack.damage(1, user, e -> e.sendEquipmentBreakStatus(EquipmentSlot.OFFHAND));
return ItemUsage.consumeHeldItem(world, user, hand);
} else if (user.getInventory().getMainHandStack().getDamage() != 0) {
world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_RESTART, SoundCategory.PLAYERS, 1.0f, 1.0f);
world.playSound(user, BlockPos.ofFloored(user.getPos()), NSE_Sounds.CIGARETTE_RESTART, SoundCategory.PLAYERS, 1.0f, 1.0f);
user.incrementStat(Stats.USED.getOrCreateStat(this));
return ItemUsage.consumeHeldItem(world, user, hand);
} else if (user.isCreative()) {
world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_RESTART, SoundCategory.PLAYERS, 1.0f, 1.0f);
world.playSound(user, BlockPos.ofFloored(user.getPos()), NSE_Sounds.CIGARETTE_RESTART, SoundCategory.PLAYERS, 1.0f, 1.0f);
user.incrementStat(Stats.USED.getOrCreateStat(this));
return ItemUsage.consumeHeldItem(world, user, hand);
}
@ -90,7 +90,7 @@ public class CigaretteItem
double e = user.getY() + 1.5;
double f = user.getZ();
world.addParticle(ParticleTypes.SMOKE, d, e, f, 0, 0, 0);
world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.SMOKING, SoundCategory.PLAYERS, 1.0f, pitch);
world.playSound(user, BlockPos.ofFloored(user.getPos()), NSE_Sounds.SMOKING, SoundCategory.PLAYERS, 1.0f, pitch);
}
if (NewSoviet.RANDOM.nextBetween(1, 6) == 1) {
double d = user.getX();
@ -98,7 +98,7 @@ public class CigaretteItem
double f = user.getZ();
world.addParticle(ParticleTypes.LARGE_SMOKE, d, e, f, 0, 0, 0);
float pitch = NewSoviet.RANDOM.nextBetween(9, 10) * 0.1f;
world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_RANDOM, SoundCategory.PLAYERS, 1.0f, pitch);
world.playSound(user, BlockPos.ofFloored(user.getPos()), NSE_Sounds.CIGARETTE_RANDOM, SoundCategory.PLAYERS, 1.0f, pitch);
}
}
@ -106,10 +106,10 @@ public class CigaretteItem
public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
if (stack.getDamage() < (durationInTicks - 1)) {
stack.damage(1, user, e -> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));
world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_PAUSE, SoundCategory.PLAYERS, 1.0f, 1.0f);
world.playSound(user, BlockPos.ofFloored(user.getPos()), NSE_Sounds.CIGARETTE_PAUSE, SoundCategory.PLAYERS, 1.0f, 1.0f);
} else if (stack.getDamage() >= (durationInTicks - 2)) {
user.equipStack(EquipmentSlot.MAINHAND, new ItemStack(returnedItem));
world.playSound(user, BlockPos.ofFloored(user.getPos()), Sounds.CIGARETTE_STOPPED, SoundCategory.PLAYERS, 1.0f, 1.0f);
world.playSound(user, BlockPos.ofFloored(user.getPos()), NSE_Sounds.CIGARETTE_STOPPED, SoundCategory.PLAYERS, 1.0f, 1.0f);
}
double d = user.getX();
double e = user.getY() + 1.5;

View file

@ -1,52 +0,0 @@
package su.a71.new_soviet.sounds;
import net.minecraft.block.Blocks;
import net.minecraft.sound.SoundEvents;
import su.a71.new_soviet.NewSoviet;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
public class Sounds {
//dice sound
public static SoundEvent DICE_SOUND = registerSoundEvent("dice_sound");
//parquet sounds
public static SoundEvent PARQUET_WALK = registerSoundEvent("parquet_walk");
public static final BlockSoundGroup PARQUET_SOUNDS = new BlockSoundGroup(1f, 1f,
BlockSoundGroup.CHERRY_WOOD.getBreakSound(), Sounds.PARQUET_WALK, BlockSoundGroup.CHERRY_WOOD.getPlaceSound(),
BlockSoundGroup.CHERRY_WOOD.getHitSound(), Sounds.PARQUET_WALK);
//meat sounds
public static final BlockSoundGroup MEAT_SOUNDS = new BlockSoundGroup(1f, 1f,
BlockSoundGroup.MUD.getBreakSound(), BlockSoundGroup.HONEY.getStepSound(), BlockSoundGroup.MUD.getPlaceSound(),
BlockSoundGroup.MUD.getHitSound(), BlockSoundGroup.HONEY.getStepSound());
//switch sound
public static SoundEvent SWITCH_PRESS = registerSoundEvent("switch_press");
//sand tiles sounds
public static final BlockSoundGroup SAND_TILES_SOUNDS = new BlockSoundGroup(1f, 0.8f,
BlockSoundGroup.MUD_BRICKS.getBreakSound(), BlockSoundGroup.DECORATED_POT.getStepSound(), BlockSoundGroup.MUD_BRICKS.getPlaceSound(),
BlockSoundGroup.MUD_BRICKS.getHitSound(), BlockSoundGroup.DECORATED_POT.getStepSound());
//wallpaper block sounds
public static final BlockSoundGroup WALLPAPER_BLOCK_SOUNDS = new BlockSoundGroup(1f, 0.7f,
BlockSoundGroup.BAMBOO_WOOD.getBreakSound(), BlockSoundGroup.WOOL.getStepSound(), BlockSoundGroup.BAMBOO_WOOD.getPlaceSound(),
BlockSoundGroup.WOOL.getHitSound(), BlockSoundGroup.WOOL.getStepSound());
//rake sound
public static SoundEvent ITEM_RAKE_TILL = registerSoundEvent("item_rake_till");
//cigarette sounds
public static SoundEvent SMOKING = registerSoundEvent("smoking");
public static SoundEvent CIGARETTE_RESTART = registerSoundEvent("cigarette_restart");
public static SoundEvent CIGARETTE_RANDOM = registerSoundEvent("cigarette_random");
public static SoundEvent CIGARETTE_STOPPED = registerSoundEvent("cigarette_stopped");
public static SoundEvent CIGARETTE_START = registerSoundEvent("cigarette_start");
public static SoundEvent CIGARETTE_PAUSE = registerSoundEvent("cigarette_pause");
private static SoundEvent registerSoundEvent(String name) {
Identifier id = new Identifier(NewSoviet.MOD_ID, name);
return Registry.register(Registries.SOUND_EVENT, id, SoundEvent.of(id));
}
}