Public Access
This commit is contained in:
1 parent
b8215f1336
commit
2da52f2658
9 files changed
+65
-7
No files matched your search
@@ -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");
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<SoundEvent> SOUNDS =
|
||||
DeferredRegister.create(Registries.SOUND_EVENT, Rivencraft.MOD_ID);
|
||||
|
||||
public static final DeferredHolder<SoundEvent, SoundEvent> LINK = register("linking.link");
|
||||
|
||||
private ModSounds() {
|
||||
}
|
||||
|
||||
private static DeferredHolder<SoundEvent, SoundEvent> 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"linking.link": {
|
||||
"category": "player",
|
||||
"sounds": [
|
||||
{
|
||||
"name": "rivencraft:linking/link"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in new issue
Block a user