Rework siren

This commit is contained in:
Andrew-71 2024-03-07 11:59:43 +03:00
parent d40dcc4cc2
commit 27eac23401
5 changed files with 45 additions and 18 deletions

View file

@ -53,8 +53,9 @@ This version focuses on QOL and bug fixes
### Changelog 0.3 -> 0.4 ### Changelog 0.3 -> 0.4
Due to sheer amount of changes, some may be undocumented. We hope you enjoy this update! :D Due to sheer amount of changes, some may be undocumented. We hope you enjoy this update! :D
* Texture improvements for various blocks * Added dozens of new blocks
* Reworked wallpaper blocks, added new ones * Texture improvements for existing blocks
* Reworked wallpapers, added new ones
* Concrete improvements * Concrete improvements
* 3 new colours - basic, dark green and orange * 3 new colours - basic, dark green and orange
* Concrete with bars can now be placed horizontally. Or vertically. It's a matter of perspective! * Concrete with bars can now be placed horizontally. Or vertically. It's a matter of perspective!
@ -67,9 +68,14 @@ Due to sheer amount of changes, some may be undocumented. We hope you enjoy this
* Added a new antenna item to improve radio electronics recipes * Added a new antenna item to improve radio electronics recipes
* Parquet improvements * Parquet improvements
* Separated oak and dark oak parquet in naming * Separated oak and dark oak parquet in naming
* Added spruce parquet (TODO) * Added a few new types
* Siren improvements
* Now uses screwdriver to change sound
* Sound names now translated
* Added a questionable sound option
* Bug fixes * Bug fixes
* Stone-cutting recipe for slabs now gives 2 blocks * Stone-cutting recipe for slabs now gives 2 blocks
* Fixed typos in Russian translation
* Fixed a few missing drops/tags/recipes related to concrete * Fixed a few missing drops/tags/recipes related to concrete
* Concrete with bars is now pickaxe mine-able * Concrete with bars is now pickaxe mine-able
* Fixed some concrete blocks missing drops * Fixed some concrete blocks missing drops

View file

@ -19,6 +19,7 @@ import net.minecraft.state.property.IntProperty;
import net.minecraft.state.property.Properties; import net.minecraft.state.property.Properties;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -32,6 +33,8 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView; import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import su.a71.new_soviet.NewSoviet;
import su.a71.new_soviet.registration.NSE_Items;
import su.a71.new_soviet.registration.NSE_Sounds; import su.a71.new_soviet.registration.NSE_Sounds;
import java.util.ArrayList; import java.util.ArrayList;
@ -48,11 +51,11 @@ public class SirenBlock extends HorizontalFacingBlock implements Waterloggable {
super(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).notSolid().pistonBehavior(PistonBehavior.DESTROY).strength(1f, 2f)); super(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).notSolid().pistonBehavior(PistonBehavior.DESTROY).strength(1f, 2f));
setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH).with(ON, false).with(WATERLOGGED, false).with(SOUND_INDEX, 0)); setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH).with(ON, false).with(WATERLOGGED, false).with(SOUND_INDEX, 0));
SIREN_SOUNDS.add(new SirenSound("Air raid", NSE_Sounds.SIREN_SOUND, 140)); SIREN_SOUNDS.add(new SirenSound("Air raid", NSE_Sounds.SIREN_SOUND, 140, "air_raid"));
SIREN_SOUNDS.add(new SirenSound("Bell", NSE_Sounds.BELL_SIREN_SOUND, 100)); SIREN_SOUNDS.add(new SirenSound("Bell", NSE_Sounds.BELL_SIREN_SOUND, 100, "bell"));
SIREN_SOUNDS.add(new SirenSound("Woop", NSE_Sounds.WOOP_SIREN_SOUND, 40)); SIREN_SOUNDS.add(new SirenSound("Woop", NSE_Sounds.WOOP_SIREN_SOUND, 40, "woop"));
SIREN_SOUNDS.add(new SirenSound("Cloister Bell", NSE_Sounds.CLOISTER_SIREN_SOUND, 60)); SIREN_SOUNDS.add(new SirenSound("Cloister Bell", NSE_Sounds.CLOISTER_SIREN_SOUND, 60, "cloister"));
SIREN_SOUNDS.add(new SirenSound("Kuplinov siren", NSE_Sounds.KUPLINOV_SIREN_SOUND, 120)); SIREN_SOUNDS.add(new SirenSound("Kuplinov siren", NSE_Sounds.KUPLINOV_SIREN_SOUND, 120, "kuplinov"));
} }
@Override @Override
@ -77,11 +80,14 @@ public class SirenBlock extends HorizontalFacingBlock implements Waterloggable {
@Override @Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (player.isSneaking()) { if (player.getInventory().getMainHandStack().getItem() == NSE_Items.SCREWDRIVER && !player.getItemCooldownManager().isCoolingDown(NSE_Items.SCREWDRIVER)) {
if (!world.isClient) { if (!world.isClient) {
incrementSoundIndex(world, pos); incrementSoundIndex(world, pos);
} }
player.sendMessage(Text.translatable("block.new_soviet.siren.set", SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).name()), true); player.getItemCooldownManager().set(NSE_Items.SCREWDRIVER, 10);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), NSE_Sounds.SCREWDRIVER_SOUND, SoundCategory.BLOCKS, 1.0f, (float) NewSoviet.RANDOM.nextBetween(8, 11) / 10);
player.sendMessage(Text.translatable("block.new_soviet.siren.set").append(Text.translatable("block.new_soviet.siren.sound." + SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).translation_key()).formatted(Formatting.YELLOW)), true);
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
return super.onUse(state, world, pos, player, hand, hit); return super.onUse(state, world, pos, player, hand, hit);
@ -157,7 +163,7 @@ public class SirenBlock extends HorizontalFacingBlock implements Waterloggable {
@Override @Override
public void appendTooltip(ItemStack stack, @Nullable BlockView world, List<Text> tooltip, TooltipContext options) { public void appendTooltip(ItemStack stack, @Nullable BlockView world, List<Text> tooltip, TooltipContext options) {
tooltip.add(Text.translatable("block.new_soviet.siren.instruction")); // TODO: Pull keybindings in case user changed RMB to whatever tooltip.add(Text.translatable("block.new_soviet.siren.instruction"));
super.appendTooltip(stack, world, tooltip, options); super.appendTooltip(stack, world, tooltip, options);
} }
@ -166,6 +172,6 @@ public class SirenBlock extends HorizontalFacingBlock implements Waterloggable {
WATERLOGGED = Properties.WATERLOGGED; WATERLOGGED = Properties.WATERLOGGED;
} }
public record SirenSound(String name, SoundEvent sound, int duration) { public record SirenSound(String name, SoundEvent sound, int duration, String translation_key) {
} }
} }

View file

@ -153,8 +153,13 @@
"block.new_soviet.table_lamp": "Table Lamp", "block.new_soviet.table_lamp": "Table Lamp",
"block.new_soviet.ceiling_fan": "Ceiling Fan", "block.new_soviet.ceiling_fan": "Ceiling Fan",
"block.new_soviet.siren": "Siren", "block.new_soviet.siren": "Siren",
"block.new_soviet.siren.set": "Siren sound set to: %s", "block.new_soviet.siren.set": "Siren sound set to: ",
"block.new_soviet.siren.instruction": "Right click while sneaking to change sound", "block.new_soviet.siren.sound.air_raid": "Air Raid",
"block.new_soviet.siren.sound.bell": "Bell",
"block.new_soviet.siren.sound.woop": "Woop",
"block.new_soviet.siren.sound.cloister": "Cloister Bell",
"block.new_soviet.siren.sound.kuplinov": "Kuplinov Alert",
"block.new_soviet.siren.instruction": "Use a screwdriver to change sound",
"item.new_soviet.dice_d6": "Die", "item.new_soviet.dice_d6": "Die",
"item.new_soviet.dice_d4": "Die", "item.new_soviet.dice_d4": "Die",
"item.new_soviet.dice_d20": "Die", "item.new_soviet.dice_d20": "Die",

View file

@ -153,8 +153,13 @@
"block.new_soviet.table_lamp": "Настольныя лампа", "block.new_soviet.table_lamp": "Настольныя лампа",
"block.new_soviet.ceiling_fan": "Потолочный вѣнтилятор", "block.new_soviet.ceiling_fan": "Потолочный вѣнтилятор",
"block.new_soviet.siren": "Сирѣна", "block.new_soviet.siren": "Сирѣна",
"block.new_soviet.siren.set": "Звукъ сирѣнъ: %s", "block.new_soviet.siren.set": "Звукъ сирѣнъ: ",
"block.new_soviet.siren.instruction": "Нажми ПКМ въ прiсядѣ для смѣнъ звука", "block.new_soviet.siren.sound.air_raid": "Воздушная тревога",
"block.new_soviet.siren.sound.bell": "Колоколъ",
"block.new_soviet.siren.sound.woop": "Вупъ",
"block.new_soviet.siren.sound.cloister": "Врачѣбный колоколъ",
"block.new_soviet.siren.sound.kuplinov": "Сирѣна Куплинова",
"block.new_soviet.siren.instruction": "Нажми отвѣрткой для смѣнъ звука",
"item.new_soviet.dice_d6": "Игральныя кость", "item.new_soviet.dice_d6": "Игральныя кость",
"item.new_soviet.dice_d4": "Игральныя кость", "item.new_soviet.dice_d4": "Игральныя кость",
"item.new_soviet.dice_d20": "Игральныя кость", "item.new_soviet.dice_d20": "Игральныя кость",

View file

@ -153,8 +153,13 @@
"block.new_soviet.table_lamp": "Настольная лампа", "block.new_soviet.table_lamp": "Настольная лампа",
"block.new_soviet.ceiling_fan": "Потолочный вентилятор", "block.new_soviet.ceiling_fan": "Потолочный вентилятор",
"block.new_soviet.siren": "Сирена", "block.new_soviet.siren": "Сирена",
"block.new_soviet.siren.set": "Звук сирены: %s", "block.new_soviet.siren.set": "Звук сирены: ",
"block.new_soviet.siren.instruction": "Нажми ПКМ в присяде для смены звука", "block.new_soviet.siren.sound.air_raid": "Воздушная тревога",
"block.new_soviet.siren.sound.bell": "Колокол",
"block.new_soviet.siren.sound.woop": "Вуп",
"block.new_soviet.siren.sound.cloister": "Врачебный колокол",
"block.new_soviet.siren.sound.kuplinov": "Сирена Куплинова",
"block.new_soviet.siren.instruction": "Используй отвертку для смены звука",
"item.new_soviet.dice_d6": "Игральная кость", "item.new_soviet.dice_d6": "Игральная кость",
"item.new_soviet.dice_d4": "Игральная кость", "item.new_soviet.dice_d4": "Игральная кость",
"item.new_soviet.dice_d20": "Игральная кость", "item.new_soviet.dice_d20": "Игральная кость",