Add unique sounds for tv

This commit is contained in:
Andrew-71 2023-10-31 12:02:59 +03:00
parent 7204a7bfd8
commit b2fb521395
11 changed files with 53 additions and 5 deletions

View file

@ -32,6 +32,7 @@ This version focuses on QOL and bug fixes
* Added Russian (ru_ru) and pre-reform Russian (ru_rpr) translations * Added Russian (ru_ru) and pre-reform Russian (ru_rpr) translations
* Added missing warped, cherry and bamboo planks * Added missing warped, cherry and bamboo planks
* Added unique sounds for TV being turned on/off and broken.
* Added many of the missing recipes * Added many of the missing recipes
* Removed ability to cut blocks back into original form on stone-cutter * Removed ability to cut blocks back into original form on stone-cutter
* Added button to open config file when using Mod Menu * Added button to open config file when using Mod Menu
@ -39,9 +40,11 @@ This version focuses on QOL and bug fixes
* Minor bug fixes * Minor bug fixes
* Added some dedicated particle textures * Added some dedicated particle textures
* Fixed issue with some blocks being non opaque * Fixed issue with some blocks being non opaque
* Fixed TV's hit-box * Fixed TVs' hit-boxes
* Switches no longer emit redstone particle * Switches no longer emit redstone particle
* Slightly improved cigarette's GUI model * Slightly improved cigarette's GUI model
* Light bulb lamp now makes a sound when repaired
* TV can now be repaired with a glass pane (breaking and re-placing still works for now)
* Technical changes * Technical changes
* Simplified recipe data generation * Simplified recipe data generation
* Deleted various unused files - code, textures and models * Deleted various unused files - code, textures and models

View file

@ -11,6 +11,7 @@ import net.minecraft.item.ItemPlacementContext;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager; import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties; import net.minecraft.state.property.Properties;
@ -26,7 +27,9 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import su.a71.new_soviet.NewSoviet;
import su.a71.new_soviet.entities.TVBlockEntity; import su.a71.new_soviet.entities.TVBlockEntity;
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 su.a71.new_soviet.util.Shapes; import su.a71.new_soviet.util.Shapes;
@ -87,18 +90,29 @@ public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvide
@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 (state.get(BROKEN) && player.getInventory().getMainHandStack().getItem() == Blocks.GLASS_PANE.asItem()) {
if (!player.isCreative())
player.getInventory().getMainHandStack().decrement(1);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.BLOCK_GLASS_PLACE, SoundCategory.BLOCKS, 0.8f, 1f);
world.setBlockState(pos, state.with(BROKEN, false));
return ActionResult.SUCCESS;
}
if (!world.isClient) { if (!world.isClient) {
world.setBlockState(pos, state.cycle(INVERTED), 2); world.setBlockState(pos, state.cycle(INVERTED), 2);
} }
float f = state.get(ON) ? 1f : 0.9f; BlockState newState = world.getBlockState(pos);
world.playSound(null, pos, NSE_Sounds.SWITCH_PRESS, SoundCategory.BLOCKS, 0.6f, f); if (newState.get(ON) != newState.get(INVERTED)) {
world.playSound(null, pos, NSE_Sounds.TV_ON_SOUND, SoundCategory.BLOCKS, 0.6f, 1f);
} else {
world.playSound(null, pos, NSE_Sounds.TV_OFF_SOUND, SoundCategory.BLOCKS, 0.6f, 1f);
}
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
@Override @Override
public void onProjectileHit(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile) { public void onProjectileHit(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile) {
if (!state.get(BROKEN)) { if (!state.get(BROKEN)) {
world.playSound(null, hit.getBlockPos().getX(), hit.getBlockPos().getY(), hit.getBlockPos().getZ(), NSE_Sounds.LIGHT_BULB_BROKEN_SOUND, SoundCategory.BLOCKS, 0.8f, 1f); world.playSound(null, hit.getBlockPos().getX(), hit.getBlockPos().getY(), hit.getBlockPos().getZ(), NSE_Sounds.TV_BREAK_SOUND, SoundCategory.BLOCKS, 0.8f, 1f);
} }
world.setBlockState(hit.getBlockPos(), state.with(BROKEN, true), 2); world.setBlockState(hit.getBlockPos(), state.with(BROKEN, true), 2);
super.onProjectileHit(world, state, hit, projectile); super.onProjectileHit(world, state, hit, projectile);

View file

@ -1,6 +1,7 @@
package su.a71.new_soviet.blocks.lamps; package su.a71.new_soviet.blocks.lamps;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.entity.projectile.ProjectileEntity;
@ -55,6 +56,7 @@ public class LightBulbLampBlock extends LampBlock {
if (world.isReceivingRedstonePower(pos) == state.get(INVERTED) || (NewSoviet.RANDOM.nextBetween(1, 32) == 1)) { if (world.isReceivingRedstonePower(pos) == state.get(INVERTED) || (NewSoviet.RANDOM.nextBetween(1, 32) == 1)) {
if (!player.isCreative()) if (!player.isCreative())
player.getInventory().getMainHandStack().decrement(1); player.getInventory().getMainHandStack().decrement(1);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.BLOCK_GLASS_PLACE, SoundCategory.BLOCKS, 0.8f, 1f);
world.setBlockState(pos, state.with(BROKEN, false)); world.setBlockState(pos, state.with(BROKEN, false));
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} else { } else {

View file

@ -41,9 +41,11 @@ public class NSE_Sounds extends NSE_BaseRegistration {
public static final SoundEvent WOOP_SIREN_SOUND = registerSoundEvent("woop_siren_sound"); public static final SoundEvent WOOP_SIREN_SOUND = registerSoundEvent("woop_siren_sound");
public static final SoundEvent CLOISTER_SIREN_SOUND = registerSoundEvent("cloister_siren_sound"); public static final SoundEvent CLOISTER_SIREN_SOUND = registerSoundEvent("cloister_siren_sound");
public static final SoundEvent ELECTRIC_HIT = SoundEvent.of(new Identifier(NewSoviet.MOD_ID, "electric_hit")); public static final SoundEvent ELECTRIC_HIT = SoundEvent.of(new Identifier(NewSoviet.MOD_ID, "electric_hit"));
public static final SoundEvent LIGHT_BULB_BROKEN_SOUND = registerSoundEvent("light_bulb_broken_sound"); public static final SoundEvent LIGHT_BULB_BROKEN_SOUND = registerSoundEvent("light_bulb_broken_sound");
public static final SoundEvent TV_ON_SOUND = registerSoundEvent("tv_on_sound");
public static final SoundEvent TV_OFF_SOUND = registerSoundEvent("tv_off_sound");
public static final SoundEvent TV_BREAK_SOUND = registerSoundEvent("tv_break_sound");
} }

View file

@ -484,6 +484,9 @@
"block.new_soviet.herringbone_bamboo_planks": "Herringbone Bamboo Planks", "block.new_soviet.herringbone_bamboo_planks": "Herringbone Bamboo Planks",
"block.new_soviet.herringbone_bamboo_planks_stairs": "Herringbone Bamboo Planks Stairs", "block.new_soviet.herringbone_bamboo_planks_stairs": "Herringbone Bamboo Planks Stairs",
"block.new_soviet.herringbone_bamboo_planks_slab": "Herringbone Bamboo Planks Slab", "block.new_soviet.herringbone_bamboo_planks_slab": "Herringbone Bamboo Planks Slab",
"subtitles.new_soviet.tv_on": "TV turned on",
"subtitles.new_soviet.tv_off": "TV turned off",
"subtitles.new_soviet.tv_break": "TV screen shattered",
"advancement.new_soviet.root.name": "A New Era", "advancement.new_soviet.root.name": "A New Era",
"advancement.new_soviet.root.desc": "Time to create something great", "advancement.new_soviet.root.desc": "Time to create something great",

View file

@ -484,6 +484,9 @@
"block.new_soviet.herringbone_bamboo_planks": "Бамбуковый паркѣт «ёлочкой»", "block.new_soviet.herringbone_bamboo_planks": "Бамбуковый паркѣт «ёлочкой»",
"block.new_soviet.herringbone_bamboo_planks_stairs": "Ступѣнi из бамбукового паркѣта «ёлочкой»", "block.new_soviet.herringbone_bamboo_planks_stairs": "Ступѣнi из бамбукового паркѣта «ёлочкой»",
"block.new_soviet.herringbone_bamboo_planks_slab": "Плита из бамбукового паркѣта «ёлочкой»", "block.new_soviet.herringbone_bamboo_planks_slab": "Плита из бамбукового паркѣта «ёлочкой»",
"subtitles.new_soviet.tv_on": "Включается тѣлѣвизоръ",
"subtitles.new_soviet.tv_off": "Выключается тѣлѣвизоръ",
"subtitles.new_soviet.tv_break": "Разбитъ экранъ тѣлѣвизора",
"advancement.new_soviet.root.name": "Новыя эра!", "advancement.new_soviet.root.name": "Новыя эра!",
"advancement.new_soviet.root.desc": "Врѣмя совѣршать вѣликое!", "advancement.new_soviet.root.desc": "Врѣмя совѣршать вѣликое!",

View file

@ -484,6 +484,9 @@
"block.new_soviet.herringbone_bamboo_planks": "Бамбуковый паркет «ёлочкой»", "block.new_soviet.herringbone_bamboo_planks": "Бамбуковый паркет «ёлочкой»",
"block.new_soviet.herringbone_bamboo_planks_stairs": "Ступени из бамбукового паркета «ёлочкой»", "block.new_soviet.herringbone_bamboo_planks_stairs": "Ступени из бамбукового паркета «ёлочкой»",
"block.new_soviet.herringbone_bamboo_planks_slab": "Плита из бамбукового паркета «ёлочкой»", "block.new_soviet.herringbone_bamboo_planks_slab": "Плита из бамбукового паркета «ёлочкой»",
"subtitles.new_soviet.tv_on": "Включается телевизор",
"subtitles.new_soviet.tv_off": "Выключается телевизор",
"subtitles.new_soviet.tv_break": "Разбит экран телевизора",
"advancement.new_soviet.root.name": "Новая эра!", "advancement.new_soviet.root.name": "Новая эра!",
"advancement.new_soviet.root.desc": "Время совершать великое!", "advancement.new_soviet.root.desc": "Время совершать великое!",

View file

@ -93,6 +93,24 @@
"sounds": [ "sounds": [
"new_soviet:cigarette_pause" "new_soviet:cigarette_pause"
] ]
},
"tv_on_sound": {
"subtitle": "subtitles.new_soviet.tv_on",
"sounds": [
"new_soviet:tv_on"
]
},
"tv_off_sound": {
"subtitle": "subtitles.new_soviet.tv_off",
"sounds": [
"new_soviet:tv_off"
]
},
"tv_break_sound": {
"subtitle": "subtitles.new_soviet.tv_break",
"sounds": [
"new_soviet:tv_break"
]
} }
} }

Binary file not shown.

Binary file not shown.