diff --git a/README.md b/README.md index 246832f..8def5ee 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ survives inventory and world saves. Travel only succeeds if the target dimension is loaded and a non-fluid, passable landing position can be found nearby. +Successful book travel plays Mystcraft Legacy's original linking sound at both +the departure and arrival locations. + Right-click an empty vanilla lectern with a Rivencraft book to convert it into a Book Stand and place the book on it. Use a Linking Book on the stand by right-clicking with an empty hand. Sneak-right-click with an empty hand to take diff --git a/docs/PORTING.md b/docs/PORTING.md index 2c0e5f6..b560677 100644 --- a/docs/PORTING.md +++ b/docs/PORTING.md @@ -206,6 +206,10 @@ Version 0.2.10.3 scans each candidate column downward from the dimension's top before choosing footing, preventing cave floors from being selected as the Age arrival surface. Columns covered by fluid remain ineligible. +Version 0.2.10.4 restores Mystcraft Legacy's standard linking sound for both +Linking and Descriptive Books. Successful travel plays the sound at its source +and destination with the legacy volume and pitch variation. + The preview code is separated behind a renderer interface and uses an isolated Ponder level populated from server-authoritative destination snapshots. diff --git a/gradle.properties b/gradle.properties index aa70f67..c75391c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -35,7 +35,7 @@ mod_name=Rivencraft # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=LGPL-3.0-or-later # The mod version. Rivencraft uses the x.y.z.b policy documented in README.md. -mod_version=0.2.10.3 +mod_version=0.2.10.4 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/net/dnorberg/rivencraft/Rivencraft.java b/src/main/java/net/dnorberg/rivencraft/Rivencraft.java index 4102701..a445fe1 100644 --- a/src/main/java/net/dnorberg/rivencraft/Rivencraft.java +++ b/src/main/java/net/dnorberg/rivencraft/Rivencraft.java @@ -4,6 +4,7 @@ import com.mojang.logging.LogUtils; import net.dnorberg.rivencraft.registry.ModCreativeTabs; import net.dnorberg.rivencraft.registry.ModDataComponents; import net.dnorberg.rivencraft.registry.ModItems; +import net.dnorberg.rivencraft.registry.ModSounds; import net.dnorberg.rivencraft.registry.ModBlocks; import net.dnorberg.rivencraft.registry.ModBlockEntities; import net.dnorberg.rivencraft.event.BookStandConversionHandler; @@ -30,6 +31,7 @@ public final class Rivencraft { ModBlocks.register(modEventBus); ModBlockEntities.register(modEventBus); ModItems.register(modEventBus); + ModSounds.register(modEventBus); ModCreativeTabs.register(modEventBus); NeoForge.EVENT_BUS.addListener(BookStandConversionHandler::onRightClickBlock); LOGGER.info("Initializing Rivencraft"); diff --git a/src/main/java/net/dnorberg/rivencraft/item/DescriptiveBookItem.java b/src/main/java/net/dnorberg/rivencraft/item/DescriptiveBookItem.java index a124e38..43f6d73 100644 --- a/src/main/java/net/dnorberg/rivencraft/item/DescriptiveBookItem.java +++ b/src/main/java/net/dnorberg/rivencraft/item/DescriptiveBookItem.java @@ -9,13 +9,14 @@ import net.dnorberg.rivencraft.book.AgeDimensionService; import net.dnorberg.rivencraft.config.RivencraftConfig; import net.dnorberg.rivencraft.registry.ModDataComponents; import net.dnorberg.rivencraft.registry.ModItems; +import net.dnorberg.rivencraft.registry.ModSounds; import net.minecraft.ChatFormatting; import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; @@ -51,6 +52,8 @@ public final class DescriptiveBookItem extends Item { return false; } + ServerLevel sourceLevel = player.serverLevel(); + var sourcePosition = player.blockPosition(); LinkingService.LinkResult result = LinkingService.travelWithFooting(player, ageTarget); if (result != LinkingService.LinkResult.SUCCESS) { player.displayClientMessage(Component.translatable("message.rivencraft.descriptive_book.unsafe"), true); @@ -69,7 +72,10 @@ public final class DescriptiveBookItem extends Item { player.drop(returnBook, false); } } - player.level().playSound(null, player.blockPosition(), SoundEvents.PORTAL_TRAVEL, SoundSource.PLAYERS, 0.35F, 1.0F); + sourceLevel.playSound(null, sourcePosition, ModSounds.LINK.get(), SoundSource.PLAYERS, + 0.8F, sourceLevel.random.nextFloat() * 0.2F + 0.9F); + player.level().playSound(null, player.blockPosition(), ModSounds.LINK.get(), SoundSource.PLAYERS, + 0.8F, player.level().random.nextFloat() * 0.2F + 0.9F); player.displayClientMessage(Component.translatable( createReturnLink ? "message.rivencraft.descriptive_book.linked_first" : "message.rivencraft.descriptive_book.linked", age.name() diff --git a/src/main/java/net/dnorberg/rivencraft/item/LinkingBookItem.java b/src/main/java/net/dnorberg/rivencraft/item/LinkingBookItem.java index cf601d7..2662b60 100644 --- a/src/main/java/net/dnorberg/rivencraft/item/LinkingBookItem.java +++ b/src/main/java/net/dnorberg/rivencraft/item/LinkingBookItem.java @@ -4,12 +4,12 @@ import java.util.List; import net.dnorberg.rivencraft.book.LinkTarget; import net.dnorberg.rivencraft.book.LinkingService; import net.dnorberg.rivencraft.registry.ModDataComponents; +import net.dnorberg.rivencraft.registry.ModSounds; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; @@ -45,15 +45,19 @@ public final class LinkingBookItem extends Item { return InteractionResultHolder.fail(stack); } + Level sourceLevel = player.level(); + BlockPos sourcePosition = player.blockPosition(); LinkingService.LinkResult result = LinkingService.travel(player, target); if (result == LinkingService.LinkResult.SUCCESS) { + sourceLevel.playSound(null, sourcePosition, ModSounds.LINK.get(), SoundSource.PLAYERS, + 0.8F, sourceLevel.random.nextFloat() * 0.2F + 0.9F); player.level().playSound( null, player.blockPosition(), - SoundEvents.PORTAL_TRAVEL, + ModSounds.LINK.get(), SoundSource.PLAYERS, - 0.35F, - 1.0F + 0.8F, + player.level().random.nextFloat() * 0.2F + 0.9F ); player.displayClientMessage(Component.translatable("message.rivencraft.linking_book.linked"), true); return InteractionResultHolder.success(stack); diff --git a/src/main/java/net/dnorberg/rivencraft/registry/ModSounds.java b/src/main/java/net/dnorberg/rivencraft/registry/ModSounds.java new file mode 100644 index 0000000..05798ff --- /dev/null +++ b/src/main/java/net/dnorberg/rivencraft/registry/ModSounds.java @@ -0,0 +1,29 @@ +package net.dnorberg.rivencraft.registry; + +import net.dnorberg.rivencraft.Rivencraft; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredRegister; + +/** Sound events retained from Mystcraft Legacy's linking behavior. */ +public final class ModSounds { + private static final DeferredRegister SOUNDS = + DeferredRegister.create(Registries.SOUND_EVENT, Rivencraft.MOD_ID); + + public static final DeferredHolder LINK = register("linking.link"); + + private ModSounds() { + } + + private static DeferredHolder register(String name) { + ResourceLocation id = ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, name); + return SOUNDS.register(name, () -> SoundEvent.createVariableRangeEvent(id)); + } + + public static void register(IEventBus modEventBus) { + SOUNDS.register(modEventBus); + } +} diff --git a/src/main/resources/assets/rivencraft/sounds.json b/src/main/resources/assets/rivencraft/sounds.json new file mode 100644 index 0000000..2929317 --- /dev/null +++ b/src/main/resources/assets/rivencraft/sounds.json @@ -0,0 +1,10 @@ +{ + "linking.link": { + "category": "player", + "sounds": [ + { + "name": "rivencraft:linking/link" + } + ] + } +} diff --git a/src/main/resources/assets/rivencraft/sounds/linking/link.ogg b/src/main/resources/assets/rivencraft/sounds/linking/link.ogg new file mode 100644 index 0000000..7f2a771 Binary files /dev/null and b/src/main/resources/assets/rivencraft/sounds/linking/link.ogg differ