Public Access
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
972aeaaed6 | ||
|
|
5066e71897 | ||
|
|
02901c9cbc | ||
|
|
d6fd32994f | ||
|
|
143da0a940 | ||
|
|
dc5157f973 | ||
|
|
956b91c462 |
No files matched your search
@@ -6,6 +6,12 @@ It is not an official release of Mystcraft.
|
|||||||
Mystcraft Legacy source: https://github.com/Mystcraft/Mystcraft-Legacy
|
Mystcraft Legacy source: https://github.com/Mystcraft/Mystcraft-Legacy
|
||||||
Mystcraft Legacy copyright: XCompWiz and contributors
|
Mystcraft Legacy copyright: XCompWiz and contributors
|
||||||
Mystcraft Legacy license: GNU Lesser General Public License version 3
|
Mystcraft Legacy license: GNU Lesser General Public License version 3
|
||||||
|
The animated ink-vial item texture in this project is copied from Mystcraft
|
||||||
|
Legacy's assets/mystcraft/textures/items/ink_vial.png under that license.
|
||||||
|
The Notebook page atlas is copied from Legacy's assets/mystcraft/gui/bookui_pagel.png
|
||||||
|
under the same license.
|
||||||
|
The Writing Desk item texture is copied from Legacy's
|
||||||
|
assets/mystcraft/textures/items/writingdesk.png under the same license.
|
||||||
|
|
||||||
The initial build layout is derived from the official NeoForge 1.21.1
|
The initial build layout is derived from the official NeoForge 1.21.1
|
||||||
ModDevGradle MDK: https://github.com/NeoForgeMDKs/MDK-1.21.1-ModDevGradle
|
ModDevGradle MDK: https://github.com/NeoForgeMDKs/MDK-1.21.1-ModDevGradle
|
||||||
@@ -13,8 +13,18 @@ have not been ported yet.
|
|||||||
|
|
||||||
Milestone 4 now includes stackable blank Pages plus server-created symbol,
|
Milestone 4 now includes stackable blank Pages plus server-created symbol,
|
||||||
unresolved-symbol, and baseline link-panel states. Page visuals follow the
|
unresolved-symbol, and baseline link-panel states. Page visuals follow the
|
||||||
legacy runtime-composition rules; written-page creation will become available
|
legacy runtime-composition rules. Craft an Ink Vial from two black dye, a glass
|
||||||
through the Writing Desk work that follows.
|
bottle, and a water bucket; the bucket is returned. Hold a blank Page in one
|
||||||
|
hand and use the Ink Vial in the other to prepare a baseline Link Panel Page.
|
||||||
|
Each vial holds 16 ink units, and the default link-panel cost is two units.
|
||||||
|
The spent vial returns a glass bottle. Server owners can adjust the symbol-copy
|
||||||
|
and link-panel costs in the `writing` section of `rivencraft-server.toml`.
|
||||||
|
Symbol-page transcription will become available through the Writing Desk.
|
||||||
|
The Writing Desk is now craftable from planks, a glass bottle, and a feather.
|
||||||
|
Its four collection tabs, ink/source/page work slots, and inventory persist
|
||||||
|
through world saves; breaking it drops stored contents. The desk screen is a
|
||||||
|
functional foundation styled after Legacy's left tabs, central writing surface,
|
||||||
|
and right inventory. Transcription controls are not implemented yet.
|
||||||
|
|
||||||
## Linking Book
|
## Linking Book
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ project's GNU LGPL v3 license. Rivencraft itself uses the same license.
|
|||||||
| Rivencraft asset | Upstream asset | Upstream revision | Changes |
|
| Rivencraft asset | Upstream asset | Upstream revision | Changes |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| `assets/rivencraft/textures/item/page.png` | `assets/mystcraft/textures/items/page_background.png` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Namespace/path rename only |
|
| `assets/rivencraft/textures/item/page.png` | `assets/mystcraft/textures/items/page_background.png` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Namespace/path rename only |
|
||||||
|
| `assets/rivencraft/textures/gui/notebook_pages.png` | `assets/mystcraft/gui/bookui_pagel.png` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Namespace/path rename only; Notebook draws the native 30×40 page at atlas coordinates `(156, 0)` |
|
||||||
|
| `assets/rivencraft/textures/item/writing_desk.png` | `assets/mystcraft/textures/items/writingdesk.png` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Namespace/path rename only |
|
||||||
| `assets/rivencraft/textures/item/linking_book_unwritten.png` | `assets/mystcraft/textures/items/unlinked.png` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Namespace/path rename only |
|
| `assets/rivencraft/textures/item/linking_book_unwritten.png` | `assets/mystcraft/textures/items/unlinked.png` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Namespace/path rename only |
|
||||||
| `assets/rivencraft/textures/item/page_link_panel.png` | `page_background.png` and `PageBuilder.BasicPageSprite` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Reproduces the legacy 160 px scale, black panel at `(25,30)`–`(135,75)`, and 128 px resample |
|
| `assets/rivencraft/textures/item/page_link_panel.png` | `page_background.png` and `PageBuilder.BasicPageSprite` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Reproduces the legacy 160 px scale, black panel at `(25,30)`–`(135,75)`, and 128 px resample |
|
||||||
| `assets/rivencraft/textures/item/page_symbol*.png` and `page_unresolved.png` | `page_background.png`, `textures/symbolcomponents.png`, `WordData`, `ModSymbols`, and `PageBuilder.PageSprite` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Static 1.21.1 renditions of the legacy runtime-composed four-word symbol pages; `normal_time` uses the legacy Full Length poem |
|
| `assets/rivencraft/textures/item/page_symbol*.png` and `page_unresolved.png` | `page_background.png`, `textures/symbolcomponents.png`, `WordData`, `ModSymbols`, and `PageBuilder.PageSprite` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Static 1.21.1 renditions of the legacy runtime-composed four-word symbol pages; `normal_time` uses the legacy Full Length poem |
|
||||||
|
|||||||
@@ -64,3 +64,27 @@ identifier. Built-in pages reproduce Mystcraft Legacy's four-word poem
|
|||||||
composition from its page background and symbol-component sheet. Data-pack
|
composition from its page background and symbol-component sheet. Data-pack
|
||||||
symbols without a bundled resource-pack model use the legacy question-mark
|
symbols without a bundled resource-pack model use the legacy question-mark
|
||||||
fallback while keeping their real identifier and display metadata.
|
fallback while keeping their real identifier and display metadata.
|
||||||
|
|
||||||
|
The Notebook surface displays pages by their persistent slot index instead of
|
||||||
|
packing occupied pages together. Empty positions through the last placed page
|
||||||
|
appear darkened. While carrying a Page, all available positions are shown for
|
||||||
|
placement. The surface draws the native 30×40 portrait page region from
|
||||||
|
Legacy's book UI atlas; symbols are layered at a uniform scale, while the
|
||||||
|
square item models remain unchanged in inventories.
|
||||||
|
|
||||||
|
## Ink and baseline link panels
|
||||||
|
|
||||||
|
An Ink Vial is crafted from two black dye, a glass bottle, and a water bucket.
|
||||||
|
The bucket remains after crafting. Each vial holds 16 ink units, stored in a
|
||||||
|
persistent, network-synchronized component; only vials with identical remaining
|
||||||
|
ink stack together. When depleted, a vial returns a glass bottle that can be
|
||||||
|
used to craft another. The animated item texture comes from Mystcraft Legacy.
|
||||||
|
|
||||||
|
The server config sets ink costs independently for symbol copying (default one
|
||||||
|
unit) and baseline link-panel preparation (default two units). To prepare a
|
||||||
|
panel, hold a blank Page in one hand and use an Ink Vial in the other. The
|
||||||
|
server checks the held items, blank state, and sufficient ink before consuming
|
||||||
|
anything. A stack of blank Pages yields exactly one Link Panel Page per use;
|
||||||
|
if the inventory is full, the result is dropped instead of deleted. Symbol
|
||||||
|
copying will be implemented by the Writing Desk. Link-property modifiers are
|
||||||
|
deferred beyond this baseline flow.
|
||||||
+1
-1
@@ -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.
|
# 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
|
mod_license=LGPL-3.0-or-later
|
||||||
# The mod version. Rivencraft uses the x.y.z.b policy documented in README.md.
|
# The mod version. Rivencraft uses the x.y.z.b policy documented in README.md.
|
||||||
mod_version=0.3.3.1
|
mod_version=0.3.5.0
|
||||||
immersive_portals_version=6.0.7
|
immersive_portals_version=6.0.7
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# 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.
|
# This should match the base package used for the mod sources.
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package net.dnorberg.rivencraft.block;
|
||||||
|
|
||||||
|
import com.mojang.serialization.MapCodec;
|
||||||
|
import net.dnorberg.rivencraft.block.entity.WritingDeskBlockEntity;
|
||||||
|
import net.dnorberg.rivencraft.menu.WritingDeskMenu;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.Containers;
|
||||||
|
import net.minecraft.world.InteractionResult;
|
||||||
|
import net.minecraft.world.SimpleMenuProvider;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||||
|
import net.minecraft.world.level.block.RenderShape;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
|
||||||
|
public final class WritingDeskBlock extends BaseEntityBlock {
|
||||||
|
public static final MapCodec<WritingDeskBlock> CODEC = simpleCodec(WritingDeskBlock::new);
|
||||||
|
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
||||||
|
|
||||||
|
public WritingDeskBlock(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
registerDefaultState(stateDefinition.any().setValue(FACING, net.minecraft.core.Direction.NORTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public MapCodec<? extends BaseEntityBlock> codec() { return CODEC; }
|
||||||
|
@Override protected void createBlockStateDefinition(StateDefinition.Builder<net.minecraft.world.level.block.Block, BlockState> builder) {
|
||||||
|
builder.add(FACING);
|
||||||
|
}
|
||||||
|
@Override public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||||
|
return defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite());
|
||||||
|
}
|
||||||
|
@Override protected RenderShape getRenderShape(BlockState state) { return RenderShape.MODEL; }
|
||||||
|
@Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
return new WritingDeskBlockEntity(pos, state);
|
||||||
|
}
|
||||||
|
@Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos,
|
||||||
|
Player player, BlockHitResult hit) {
|
||||||
|
if (!level.isClientSide && player instanceof ServerPlayer serverPlayer
|
||||||
|
&& level.getBlockEntity(pos) instanceof WritingDeskBlockEntity desk) {
|
||||||
|
serverPlayer.openMenu(new SimpleMenuProvider(
|
||||||
|
(id, inventory, ignored) -> new WritingDeskMenu(id, inventory, desk),
|
||||||
|
Component.translatable("container.rivencraft.writing_desk")),
|
||||||
|
buffer -> buffer.writeBlockPos(pos));
|
||||||
|
}
|
||||||
|
return InteractionResult.sidedSuccess(level.isClientSide);
|
||||||
|
}
|
||||||
|
@Override protected void onRemove(BlockState state, Level level, BlockPos pos, BlockState replacement, boolean moving) {
|
||||||
|
if (!state.is(replacement.getBlock()) && !level.isClientSide
|
||||||
|
&& level.getBlockEntity(pos) instanceof WritingDeskBlockEntity desk) {
|
||||||
|
Containers.dropContents(level, pos, desk);
|
||||||
|
level.updateNeighbourForOutputSignal(pos, this);
|
||||||
|
}
|
||||||
|
super.onRemove(state, level, pos, replacement, moving);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package net.dnorberg.rivencraft.block.entity;
|
||||||
|
|
||||||
|
import net.dnorberg.rivencraft.registry.ModBlockEntities;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.world.Container;
|
||||||
|
import net.minecraft.world.ContainerHelper;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
/** The four Legacy-like collection tabs and four work slots are owned by the block, not its viewers. */
|
||||||
|
public final class WritingDeskBlockEntity extends BlockEntity implements Container {
|
||||||
|
public static final int COLLECTIONS = 4;
|
||||||
|
public static final int INK = 4;
|
||||||
|
public static final int SOURCE = 5;
|
||||||
|
public static final int PAPER = 6;
|
||||||
|
public static final int OUTPUT = 7;
|
||||||
|
public static final int SIZE = 8;
|
||||||
|
private NonNullList<ItemStack> items = NonNullList.withSize(SIZE, ItemStack.EMPTY);
|
||||||
|
private int activeCollection;
|
||||||
|
|
||||||
|
public WritingDeskBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
super(ModBlockEntities.WRITING_DESK.get(), pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int activeCollection() { return activeCollection; }
|
||||||
|
public void setActiveCollection(int index) {
|
||||||
|
if (index >= 0 && index < COLLECTIONS && activeCollection != index) {
|
||||||
|
activeCollection = index;
|
||||||
|
setChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getContainerSize() { return SIZE; }
|
||||||
|
@Override public boolean isEmpty() { return items.stream().allMatch(ItemStack::isEmpty); }
|
||||||
|
@Override public ItemStack getItem(int slot) { return items.get(slot); }
|
||||||
|
@Override public ItemStack removeItem(int slot, int amount) {
|
||||||
|
ItemStack removed = ContainerHelper.removeItem(items, slot, amount);
|
||||||
|
if (!removed.isEmpty()) setChanged();
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
@Override public ItemStack removeItemNoUpdate(int slot) { return ContainerHelper.takeItem(items, slot); }
|
||||||
|
@Override public void setItem(int slot, ItemStack stack) {
|
||||||
|
items.set(slot, stack);
|
||||||
|
if (stack.getCount() > getMaxStackSize()) stack.setCount(getMaxStackSize());
|
||||||
|
setChanged();
|
||||||
|
}
|
||||||
|
@Override public boolean stillValid(Player player) {
|
||||||
|
return level != null && level.isLoaded(worldPosition)
|
||||||
|
&& level.getBlockEntity(worldPosition) == this
|
||||||
|
&& player.distanceToSqr(worldPosition.getX() + 0.5, worldPosition.getY() + 0.5,
|
||||||
|
worldPosition.getZ() + 0.5) <= 64.0;
|
||||||
|
}
|
||||||
|
@Override public boolean canPlaceItem(int slot, ItemStack stack) {
|
||||||
|
if (slot < COLLECTIONS) return stack.is(ModItems.NOTEBOOK.get()) || stack.is(ModItems.PAGE.get());
|
||||||
|
return switch (slot) {
|
||||||
|
case INK -> stack.is(ModItems.INK_VIAL.get());
|
||||||
|
case SOURCE -> stack.is(ModItems.PAGE.get()) || stack.is(ModItems.NOTEBOOK.get());
|
||||||
|
case PAPER -> stack.is(ModItems.PAGE.get());
|
||||||
|
case OUTPUT -> false;
|
||||||
|
default -> false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@Override public void clearContent() {
|
||||||
|
items.clear();
|
||||||
|
items = NonNullList.withSize(SIZE, ItemStack.EMPTY);
|
||||||
|
setChanged();
|
||||||
|
}
|
||||||
|
@Override protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
|
super.loadAdditional(tag, registries);
|
||||||
|
items = NonNullList.withSize(SIZE, ItemStack.EMPTY);
|
||||||
|
ContainerHelper.loadAllItems(tag, items, registries);
|
||||||
|
activeCollection = Math.clamp(tag.getInt("ActiveCollection"), 0, COLLECTIONS - 1);
|
||||||
|
}
|
||||||
|
@Override protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
|
super.saveAdditional(tag, registries);
|
||||||
|
ContainerHelper.saveAllItems(tag, items, registries);
|
||||||
|
tag.putInt("ActiveCollection", activeCollection);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ import net.neoforged.neoforge.common.NeoForge;
|
|||||||
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
|
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
|
||||||
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
|
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
|
||||||
import net.dnorberg.rivencraft.client.screen.NotebookScreen;
|
import net.dnorberg.rivencraft.client.screen.NotebookScreen;
|
||||||
|
import net.dnorberg.rivencraft.client.screen.WritingDeskScreen;
|
||||||
import net.dnorberg.rivencraft.registry.ModMenus;
|
import net.dnorberg.rivencraft.registry.ModMenus;
|
||||||
|
|
||||||
@EventBusSubscriber(modid = Rivencraft.MOD_ID, value = Dist.CLIENT)
|
@EventBusSubscriber(modid = Rivencraft.MOD_ID, value = Dist.CLIENT)
|
||||||
@@ -29,6 +30,7 @@ public final class ClientEvents {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void registerScreens(RegisterMenuScreensEvent event) {
|
public static void registerScreens(RegisterMenuScreensEvent event) {
|
||||||
event.register(ModMenus.NOTEBOOK.get(), NotebookScreen::new);
|
event.register(ModMenus.NOTEBOOK.get(), NotebookScreen::new);
|
||||||
|
event.register(ModMenus.WRITING_DESK.get(), WritingDeskScreen::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -1,177 +1,304 @@
|
|||||||
package net.dnorberg.rivencraft.client.screen;
|
package net.dnorberg.rivencraft.client.screen;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
||||||
import net.dnorberg.rivencraft.network.RenameNotebookPagePayload;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
import net.minecraft.client.gui.components.Tooltip;
|
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.inventory.ClickType;
|
import net.minecraft.world.inventory.ClickType;
|
||||||
import net.minecraft.world.inventory.Slot;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
|
||||||
|
|
||||||
|
/** A page surface modelled on Legacy's folder GUI, backed by the Notebook menu. */
|
||||||
public final class NotebookScreen extends AbstractContainerScreen<NotebookMenu> {
|
public final class NotebookScreen extends AbstractContainerScreen<NotebookMenu> {
|
||||||
private static final int SURFACE_TOP = 20;
|
private static final int SURFACE_TOP = 20;
|
||||||
private static final int SURFACE_BOTTOM = 132;
|
private static final int SURFACE_BOTTOM = 132;
|
||||||
private static final int PAGE_WIDTH = 17;
|
private static final int SURFACE_RIGHT = 156;
|
||||||
private static final int PAGE_HEIGHT = 31;
|
private static final int PAGE_WIDTH = 30;
|
||||||
private static final int PAGE_ROW_HEIGHT = 34;
|
private static final int PAGE_HEIGHT = 40;
|
||||||
private EditBox nameInput;
|
private static final int PAGE_STEP_X = 31;
|
||||||
private Button previousButton;
|
private static final int PAGE_STEP_Y = 41;
|
||||||
private Button nextButton;
|
private static final int PAGE_COLUMNS = 5;
|
||||||
|
private static final ResourceLocation PAGE_ATLAS = texture("gui/notebook_pages");
|
||||||
|
private static final ResourceLocation GENERIC_SYMBOL = texture("item/page_symbol");
|
||||||
|
private static final ResourceLocation UNRESOLVED_SYMBOL = texture("item/page_unresolved");
|
||||||
|
private static final ResourceLocation STANDARD_TERRAIN = texture("item/page_symbol_terrain_standard");
|
||||||
|
private static final ResourceLocation NATIVE_BIOMES = texture("item/page_symbol_biome_native");
|
||||||
|
private static final ResourceLocation NORMAL_LIGHTING = texture("item/page_symbol_lighting_normal");
|
||||||
|
private static final ResourceLocation NORMAL_WEATHER = texture("item/page_symbol_weather_normal");
|
||||||
|
private static final ResourceLocation NORMAL_TIME = texture("item/page_symbol_celestial_normal_time");
|
||||||
|
private static final ResourceLocation CAVES = texture("item/page_symbol_feature_caves");
|
||||||
|
private EditBox textInput;
|
||||||
|
private boolean draggingScrollbar;
|
||||||
|
private boolean surfaceClickPendingRelease;
|
||||||
private int selectedSlot = -1;
|
private int selectedSlot = -1;
|
||||||
|
private int scroll;
|
||||||
|
|
||||||
public NotebookScreen(NotebookMenu menu, Inventory inventory, Component title) {
|
public NotebookScreen(NotebookMenu menu, Inventory inventory, Component title) {
|
||||||
super(menu, inventory, title);
|
super(menu, inventory, title);
|
||||||
imageWidth = 176;
|
imageWidth = 176;
|
||||||
imageHeight = 213;
|
imageHeight = 213;
|
||||||
inventoryLabelY = 123;
|
inventoryLabelY = 123;
|
||||||
titleLabelY = 7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
super.init();
|
super.init();
|
||||||
nameInput = new EditBox(font, leftPos + 47, topPos + 7, 86, 18,
|
Button sortButton = Button.builder(Component.literal("AZ"), button -> {})
|
||||||
Component.translatable("screen.rivencraft.notebook.rename"));
|
.bounds(leftPos, topPos, 18, 18).build();
|
||||||
nameInput.setMaxLength(32);
|
Button allButton = Button.builder(Component.literal("ALL"), button -> {})
|
||||||
nameInput.setResponder(ignored -> updateButtons());
|
.bounds(leftPos + 20, topPos, 26, 18).build();
|
||||||
addRenderableWidget(nameInput);
|
sortButton.active = false;
|
||||||
|
allButton.active = false;
|
||||||
previousButton = Button.builder(Component.literal("←"), ignored -> moveSelected(false))
|
addRenderableWidget(sortButton);
|
||||||
.bounds(leftPos + 136, topPos + 7, 16, 18)
|
addRenderableWidget(allButton);
|
||||||
.tooltip(Tooltip.create(Component.translatable("screen.rivencraft.notebook.move_previous")))
|
textInput = new EditBox(font, leftPos + 48, topPos, 128, 18,
|
||||||
.build();
|
Component.translatable("screen.rivencraft.notebook.search"));
|
||||||
nextButton = Button.builder(Component.literal("→"), ignored -> moveSelected(true))
|
textInput.setMaxLength(32);
|
||||||
.bounds(leftPos + 153, topPos + 7, 16, 18)
|
textInput.setHint(Component.translatable("screen.rivencraft.notebook.search"));
|
||||||
.tooltip(Tooltip.create(Component.translatable("screen.rivencraft.notebook.move_next")))
|
textInput.setResponder(value -> scroll = 0);
|
||||||
.build();
|
addRenderableWidget(textInput);
|
||||||
addRenderableWidget(previousButton);
|
|
||||||
addRenderableWidget(nextButton);
|
|
||||||
updateButtons();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
|
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
|
||||||
super.render(graphics, mouseX, mouseY, partialTick);
|
super.render(graphics, mouseX, mouseY, partialTick);
|
||||||
if (selectedSlot >= 0) {
|
int pageSlots = displayedPageSlots();
|
||||||
Slot slot = menu.slots.get(selectedSlot);
|
scroll = Math.min(scroll, maxScroll(pageSlots));
|
||||||
graphics.renderOutline(leftPos + slot.x - 1, topPos + slot.y - 1, 18, 18, 0xFFE0C36A);
|
graphics.enableScissor(leftPos, topPos + SURFACE_TOP, leftPos + SURFACE_RIGHT,
|
||||||
|
topPos + SURFACE_BOTTOM);
|
||||||
|
for (int index = 0; index < pageSlots; index++) {
|
||||||
|
int x = leftPos + (index % PAGE_COLUMNS) * PAGE_STEP_X;
|
||||||
|
int y = topPos + SURFACE_TOP + (index / PAGE_COLUMNS) * PAGE_STEP_Y - scroll;
|
||||||
|
if (y + PAGE_HEIGHT > topPos + SURFACE_TOP && y < topPos + SURFACE_BOTTOM) {
|
||||||
|
drawPage(graphics, index, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
graphics.disableScissor();
|
||||||
|
drawScrollbar(graphics, pageSlots);
|
||||||
|
int hovered = pageAt(mouseX, mouseY);
|
||||||
|
if (!menu.getCarried().isEmpty() && inSurface(mouseX, mouseY)) {
|
||||||
|
graphics.renderItem(menu.getCarried(), mouseX - 8, mouseY - 8);
|
||||||
|
} else if (hovered >= 0 && !menu.getSlot(hovered).getItem().isEmpty()) {
|
||||||
|
ItemStack page = menu.getSlot(hovered).getItem();
|
||||||
|
if (matchesSearch(page)) graphics.renderTooltip(font, page, mouseX, mouseY);
|
||||||
|
} else {
|
||||||
|
renderTooltip(graphics, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
renderTooltip(graphics, mouseX, mouseY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderBg(GuiGraphics graphics, float partialTick, int mouseX, int mouseY) {
|
protected void renderBg(GuiGraphics graphics, float partialTick, int mouseX, int mouseY) {
|
||||||
drawBeveledPanel(graphics, leftPos, topPos, imageWidth, SURFACE_BOTTOM);
|
graphics.fill(leftPos, topPos + SURFACE_TOP, leftPos + SURFACE_RIGHT,
|
||||||
graphics.fill(leftPos, topPos + SURFACE_TOP, leftPos + imageWidth - 1, topPos + SURFACE_BOTTOM - 1,
|
topPos + SURFACE_BOTTOM, 0xB0000000);
|
||||||
0xFF1D2633);
|
|
||||||
drawPageCards(graphics);
|
|
||||||
|
|
||||||
drawBeveledPanel(graphics, leftPos, topPos + 132, imageWidth, 81);
|
drawBeveledPanel(graphics, leftPos, topPos + 132, imageWidth, 81);
|
||||||
for (int row = 0; row < 3; row++) {
|
for (int row = 0; row < 3; row++) {
|
||||||
for (int column = 0; column < 9; column++) {
|
for (int column = 0; column < 9; column++) drawSlot(graphics, 7 + column * 18, 134 + row * 18);
|
||||||
drawSlot(graphics, 7 + column * 18, 134 + row * 18);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int column = 0; column < 9; column++) {
|
|
||||||
drawSlot(graphics, 7 + column * 18, 192);
|
|
||||||
}
|
}
|
||||||
|
for (int column = 0; column < 9; column++) drawSlot(graphics, 7 + column * 18, 192);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||||
graphics.drawString(font, title, titleLabelX, titleLabelY, 0x3F2A18, false);
|
|
||||||
graphics.drawString(font, playerInventoryTitle, inventoryLabelX, inventoryLabelY, 0x404040, false);
|
graphics.drawString(font, playerInventoryTitle, inventoryLabelX, inventoryLabelY, 0x404040, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void slotClicked(Slot slot, int slotId, int mouseButton, ClickType type) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
if (slotId >= 0 && slotId < NotebookMenu.NOTEBOOK_SLOTS) {
|
if (inScrollbar(mouseX, mouseY) && button == 0) {
|
||||||
selectedSlot = slotId;
|
draggingScrollbar = true;
|
||||||
|
setScrollFromMouse(mouseY, displayedPageSlots());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
super.slotClicked(slot, slotId, mouseButton, type);
|
int index = pageAt(mouseX, mouseY);
|
||||||
refreshName();
|
if (index >= 0 && (button == 0 || button == 1)) {
|
||||||
|
ItemStack page = menu.getSlot(index).getItem();
|
||||||
|
if ((!page.isEmpty() && !matchesSearch(page))
|
||||||
|
|| (page.isEmpty() && !menu.getCarried().is(ModItems.PAGE.get()))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
setFocused(null);
|
||||||
|
textInput.setFocused(false);
|
||||||
|
selectedSlot = index;
|
||||||
|
slotClicked(menu.getSlot(index), index, button, ClickType.PICKUP);
|
||||||
|
surfaceClickPendingRelease = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.mouseClicked(mouseX, mouseY, button);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) {
|
||||||
|
if (draggingScrollbar && button == 0) {
|
||||||
|
setScrollFromMouse(mouseY, displayedPageSlots());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.mouseDragged(mouseX, mouseY, button, dragX, dragY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||||
|
if (draggingScrollbar || surfaceClickPendingRelease) {
|
||||||
|
draggingScrollbar = false;
|
||||||
|
surfaceClickPendingRelease = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
draggingScrollbar = false;
|
||||||
|
return super.mouseReleased(mouseX, mouseY, button);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) {
|
||||||
|
if (inSurface(mouseX, mouseY) || inScrollbar(mouseX, mouseY)) {
|
||||||
|
scroll = Math.clamp(scroll - (int)Math.signum(scrollY) * 20,
|
||||||
|
0, maxScroll(displayedPageSlots()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.mouseScrolled(mouseX, mouseY, scrollX, scrollY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||||
if (nameInput.isFocused() && (keyCode == 257 || keyCode == 335)) {
|
if (textInput.isFocused()) {
|
||||||
renameSelected();
|
if (keyCode == 256) {
|
||||||
|
setFocused(null);
|
||||||
|
textInput.setFocused(false);
|
||||||
|
} else {
|
||||||
|
textInput.keyPressed(keyCode, scanCode, modifiers);
|
||||||
|
}
|
||||||
|
// EditBox does not consume ordinary letter key presses; the matching charTyped
|
||||||
|
// event handles text input. Do not pass them to the container's inventory keys.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!nameInput.isFocused() && keyCode == 263) {
|
if (!textInput.isFocused() && selectedSlot >= 0 && (keyCode == 263 || keyCode == 262)) {
|
||||||
moveSelected(false);
|
moveSelected(keyCode == 262);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!nameInput.isFocused() && keyCode == 262) {
|
|
||||||
moveSelected(true);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.keyPressed(keyCode, scanCode, modifiers);
|
return super.keyPressed(keyCode, scanCode, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private int displayedPageSlots() {
|
||||||
public void onClose() {
|
if (menu.getCarried().is(ModItems.PAGE.get())) {
|
||||||
renameSelected();
|
return NotebookMenu.NOTEBOOK_SLOTS;
|
||||||
super.onClose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshName() {
|
|
||||||
ItemStack selected = selectedPage();
|
|
||||||
nameInput.setValue(selected.isEmpty() ? "" : selected.getHoverName().getString());
|
|
||||||
updateButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renameSelected() {
|
|
||||||
if (selectedSlot < 0 || selectedPage().isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
PacketDistributor.sendToServer(new RenameNotebookPagePayload(
|
for (int index = NotebookMenu.NOTEBOOK_SLOTS - 1; index >= 0; index--) {
|
||||||
menu.containerId, selectedSlot, nameInput.getValue()));
|
if (!menu.getSlot(index).getItem().isEmpty()) {
|
||||||
|
return index + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean matchesSearch(ItemStack page) {
|
||||||
|
return textInput.getValue().isBlank()
|
||||||
|
|| page.getHoverName().getString().toLowerCase(Locale.ROOT)
|
||||||
|
.contains(textInput.getValue().toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
|
||||||
|
private int pageAt(double mouseX, double mouseY) {
|
||||||
|
if (!inSurface(mouseX, mouseY)) return -1;
|
||||||
|
int localX = (int)mouseX - leftPos;
|
||||||
|
int localY = (int)mouseY - topPos - SURFACE_TOP + scroll;
|
||||||
|
int column = localX / PAGE_STEP_X;
|
||||||
|
int index = (localY / PAGE_STEP_Y) * PAGE_COLUMNS + column;
|
||||||
|
return column < PAGE_COLUMNS && localX % PAGE_STEP_X < PAGE_WIDTH
|
||||||
|
&& localY % PAGE_STEP_Y < PAGE_HEIGHT && index < displayedPageSlots()
|
||||||
|
? index : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean inSurface(double mouseX, double mouseY) {
|
||||||
|
return mouseX >= leftPos && mouseX < leftPos + SURFACE_RIGHT
|
||||||
|
&& mouseY >= topPos + SURFACE_TOP && mouseY < topPos + SURFACE_BOTTOM;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean inScrollbar(double mouseX, double mouseY) {
|
||||||
|
return mouseX >= leftPos + SURFACE_RIGHT && mouseX < leftPos + imageWidth
|
||||||
|
&& mouseY >= topPos + SURFACE_TOP && mouseY < topPos + SURFACE_BOTTOM;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int maxScroll(int pageCount) {
|
||||||
|
int rows = (pageCount + PAGE_COLUMNS - 1) / PAGE_COLUMNS;
|
||||||
|
return Math.max(0, rows * PAGE_STEP_Y - (SURFACE_BOTTOM - SURFACE_TOP));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setScrollFromMouse(double mouseY, int pageCount) {
|
||||||
|
int maximum = maxScroll(pageCount);
|
||||||
|
double fraction = (mouseY - topPos - SURFACE_TOP - 10.0)
|
||||||
|
/ (SURFACE_BOTTOM - SURFACE_TOP - 20.0);
|
||||||
|
scroll = Math.clamp((int)(Math.clamp(fraction, 0.0, 1.0) * maximum), 0, maximum);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawScrollbar(GuiGraphics graphics, int pageCount) {
|
||||||
|
int x = leftPos + SURFACE_RIGHT;
|
||||||
|
int y = topPos + SURFACE_TOP;
|
||||||
|
int height = SURFACE_BOTTOM - SURFACE_TOP;
|
||||||
|
graphics.fill(x, y, x + 20, y + height, 0xFF858585);
|
||||||
|
graphics.renderOutline(x, y, 20, height, 0xFF262626);
|
||||||
|
for (int line = y + 5; line < y + height - 4; line += 5) {
|
||||||
|
graphics.fill(x + 4, line, x + 16, line + 1, 0xFFB7B7B7);
|
||||||
|
}
|
||||||
|
int maximum = maxScroll(pageCount);
|
||||||
|
int thumbY = y + 4 + (maximum == 0 ? 0 : scroll * (height - 23) / maximum);
|
||||||
|
graphics.fill(x + 4, thumbY, x + 16, thumbY + 15, 0xFFC9C9C9);
|
||||||
|
graphics.renderOutline(x + 4, thumbY, 12, 15, 0xFF414141);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawPage(GuiGraphics graphics, int index, int x, int y) {
|
||||||
|
ItemStack page = menu.getSlot(index).getItem();
|
||||||
|
boolean dimmed = page.isEmpty() || !matchesSearch(page);
|
||||||
|
// Legacy's Notebook draws the atlas' native 30x40 page, not a stretched item icon.
|
||||||
|
graphics.blit(PAGE_ATLAS, x, y, PAGE_WIDTH, PAGE_HEIGHT,
|
||||||
|
156, 0, PAGE_WIDTH, PAGE_HEIGHT, 256, 256);
|
||||||
|
if (!page.isEmpty()) {
|
||||||
|
switch (PageItem.content(page).kind()) {
|
||||||
|
case BLANK -> { }
|
||||||
|
case LINK_PANEL -> graphics.fill(x + 5, y + 6, x + 25, y + 20, 0xFF000000);
|
||||||
|
case SYMBOL, UNRESOLVED_SYMBOL -> graphics.blit(symbolTexture(page), x + 1, y + 6,
|
||||||
|
28, 28, 16, 16, 96, 96, 128, 128);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dimmed) {
|
||||||
|
graphics.fill(x, y, x + PAGE_WIDTH, y + PAGE_HEIGHT, 0xB8000000);
|
||||||
|
}
|
||||||
|
if (index == selectedSlot && !page.isEmpty()) {
|
||||||
|
graphics.renderOutline(x, y, PAGE_WIDTH, PAGE_HEIGHT, 0xFFFFD061);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ResourceLocation symbolTexture(ItemStack page) {
|
||||||
|
var content = PageItem.content(page);
|
||||||
|
if (content.kind() == net.dnorberg.rivencraft.writing.PageContent.Kind.UNRESOLVED_SYMBOL) {
|
||||||
|
return UNRESOLVED_SYMBOL;
|
||||||
|
}
|
||||||
|
return switch (content.symbol().orElseThrow().id().toString()) {
|
||||||
|
case "rivencraft:terrain/standard" -> STANDARD_TERRAIN;
|
||||||
|
case "rivencraft:biome/native" -> NATIVE_BIOMES;
|
||||||
|
case "rivencraft:lighting/normal" -> NORMAL_LIGHTING;
|
||||||
|
case "rivencraft:weather/normal" -> NORMAL_WEATHER;
|
||||||
|
case "rivencraft:celestial/normal_time" -> NORMAL_TIME;
|
||||||
|
case "rivencraft:feature/caves" -> CAVES;
|
||||||
|
default -> GENERIC_SYMBOL;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ResourceLocation texture(String path) {
|
||||||
|
return ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "textures/" + path + ".png");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveSelected(boolean next) {
|
private void moveSelected(boolean next) {
|
||||||
int target = selectedSlot + (next ? 1 : -1);
|
int target = selectedSlot + (next ? 1 : -1);
|
||||||
if (selectedSlot < 0 || selectedPage().isEmpty()
|
if (selectedSlot < 0 || target < 0 || target >= NotebookMenu.NOTEBOOK_SLOTS
|
||||||
|| target < 0 || target >= NotebookMenu.NOTEBOOK_SLOTS) {
|
|| menu.getSlot(selectedSlot).getItem().isEmpty()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
renameSelected();
|
|
||||||
int buttonId = (next ? NotebookMenu.MOVE_NEXT_BASE : NotebookMenu.MOVE_PREVIOUS_BASE) + selectedSlot;
|
int buttonId = (next ? NotebookMenu.MOVE_NEXT_BASE : NotebookMenu.MOVE_PREVIOUS_BASE) + selectedSlot;
|
||||||
if (menu.clickMenuButton(minecraft.player, buttonId)) {
|
if (menu.clickMenuButton(minecraft.player, buttonId)) {
|
||||||
minecraft.gameMode.handleInventoryButtonClick(menu.containerId, buttonId);
|
minecraft.gameMode.handleInventoryButtonClick(menu.containerId, buttonId);
|
||||||
selectedSlot = target;
|
selectedSlot = target;
|
||||||
refreshName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ItemStack selectedPage() {
|
|
||||||
return selectedSlot >= 0 && selectedSlot < NotebookMenu.NOTEBOOK_SLOTS
|
|
||||||
? menu.getSlot(selectedSlot).getItem()
|
|
||||||
: ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateButtons() {
|
|
||||||
if (previousButton == null || nextButton == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
boolean hasPage = !selectedPage().isEmpty();
|
|
||||||
previousButton.active = hasPage && selectedSlot > 0;
|
|
||||||
nextButton.active = hasPage && selectedSlot >= 0 && selectedSlot < NotebookMenu.NOTEBOOK_SLOTS - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawPageCards(GuiGraphics graphics) {
|
|
||||||
for (int index = 0; index < NotebookMenu.NOTEBOOK_SLOTS; index++) {
|
|
||||||
int row = index / NotebookMenu.PAGE_COLUMNS;
|
|
||||||
int x = leftPos + 7 + (index % NotebookMenu.PAGE_COLUMNS) * 18;
|
|
||||||
int y = topPos + 21 + row * PAGE_ROW_HEIGHT;
|
|
||||||
graphics.fill(x, y, x + PAGE_WIDTH, y + PAGE_HEIGHT, 0xFFB8AD8D);
|
|
||||||
graphics.renderOutline(x, y, PAGE_WIDTH, PAGE_HEIGHT, 0xFF594D39);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package net.dnorberg.rivencraft.client.screen;
|
||||||
|
|
||||||
|
import net.dnorberg.rivencraft.menu.WritingDeskMenu;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
|
||||||
|
/** Functional storage surface; full Legacy transcription controls are a later Milestone 4 slice. */
|
||||||
|
public final class WritingDeskScreen extends AbstractContainerScreen<WritingDeskMenu> {
|
||||||
|
public WritingDeskScreen(WritingDeskMenu menu, Inventory inventory, Component title) {
|
||||||
|
super(menu, inventory, title);
|
||||||
|
imageWidth = 398;
|
||||||
|
imageHeight = 176;
|
||||||
|
titleLabelX = 222;
|
||||||
|
inventoryLabelX = 224;
|
||||||
|
inventoryLabelY = 79;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected void renderBg(GuiGraphics graphics, float partialTick, int mouseX, int mouseY) {
|
||||||
|
int x = leftPos;
|
||||||
|
int y = topPos;
|
||||||
|
graphics.fill(x + 4, y + 8, x + 216, y + 174, 0xFF383230);
|
||||||
|
graphics.fill(x + 44, y + 14, x + 210, y + 170, 0xFF221B1A);
|
||||||
|
graphics.fill(x + 218, y + 4, x + 396, y + 174, 0xFF555454);
|
||||||
|
graphics.fill(x + 220, y + 6, x + 394, y + 172, 0xFFB7B7B7);
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
graphics.fill(x + 6, y + 16 + i * 37, x + 40, y + 48 + i * 37,
|
||||||
|
i == menu.activeCollection() ? 0xFF7777B6 : 0xFF999999);
|
||||||
|
slotFrame(graphics, 12, 20 + i * 37);
|
||||||
|
}
|
||||||
|
slotFrame(graphics, 228, 20);
|
||||||
|
slotFrame(graphics, 266, 20);
|
||||||
|
slotFrame(graphics, 304, 20);
|
||||||
|
slotFrame(graphics, 342, 20);
|
||||||
|
for (int row = 0; row < 3; row++) {
|
||||||
|
for (int column = 0; column < 9; column++) slotFrame(graphics, 224 + column * 18, 91 + row * 18);
|
||||||
|
}
|
||||||
|
for (int column = 0; column < 9; column++) slotFrame(graphics, 224 + column * 18, 149);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void slotFrame(GuiGraphics graphics, int x, int y) {
|
||||||
|
graphics.fill(leftPos + x - 1, topPos + y - 1,
|
||||||
|
leftPos + x + 17, topPos + y + 17, 0xFF4D4D4D);
|
||||||
|
graphics.fill(leftPos + x, topPos + y,
|
||||||
|
leftPos + x + 16, topPos + y + 16, 0xFF858585);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
|
||||||
|
super.render(graphics, mouseX, mouseY, partialTick);
|
||||||
|
renderTooltip(graphics, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
|
if (button == 0 && mouseX >= leftPos + 29 && mouseX < leftPos + 40) {
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
int top = topPos + 16 + i * 37;
|
||||||
|
if (mouseY >= top && mouseY < top + 32) {
|
||||||
|
if (minecraft != null && minecraft.gameMode != null) {
|
||||||
|
minecraft.gameMode.handleInventoryButtonClick(menu.containerId, i);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.mouseClicked(mouseX, mouseY, button);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,8 @@ public final class RivencraftConfig {
|
|||||||
|
|
||||||
public static final ModConfigSpec SPEC;
|
public static final ModConfigSpec SPEC;
|
||||||
private static final ModConfigSpec.EnumValue<ReturnLinkMode> RETURN_LINK_MODE;
|
private static final ModConfigSpec.EnumValue<ReturnLinkMode> RETURN_LINK_MODE;
|
||||||
|
private static final ModConfigSpec.IntValue SYMBOL_INK_COST;
|
||||||
|
private static final ModConfigSpec.IntValue LINK_PANEL_INK_COST;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
|
ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
|
||||||
@@ -25,6 +27,12 @@ public final class RivencraftConfig {
|
|||||||
)
|
)
|
||||||
.defineEnum("return_link_mode", ReturnLinkMode.ON_CREATION);
|
.defineEnum("return_link_mode", ReturnLinkMode.ON_CREATION);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
builder.push("writing");
|
||||||
|
SYMBOL_INK_COST = builder.comment("Ink units consumed when the Writing Desk copies one symbol page.")
|
||||||
|
.defineInRange("symbol_ink_cost", 1, 1, 16);
|
||||||
|
LINK_PANEL_INK_COST = builder.comment("Ink units consumed when preparing one baseline link-panel page.")
|
||||||
|
.defineInRange("link_panel_ink_cost", 2, 1, 16);
|
||||||
|
builder.pop();
|
||||||
SPEC = builder.build();
|
SPEC = builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,4 +42,12 @@ public final class RivencraftConfig {
|
|||||||
public static ReturnLinkMode returnLinkMode() {
|
public static ReturnLinkMode returnLinkMode() {
|
||||||
return RETURN_LINK_MODE.get();
|
return RETURN_LINK_MODE.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int symbolInkCost() {
|
||||||
|
return SYMBOL_INK_COST.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int linkPanelInkCost() {
|
||||||
|
return LINK_PANEL_INK_COST.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,8 @@ import net.dnorberg.rivencraft.writing.SymbolReference;
|
|||||||
import net.dnorberg.rivencraft.writing.WritingEntry;
|
import net.dnorberg.rivencraft.writing.WritingEntry;
|
||||||
import net.dnorberg.rivencraft.writing.NotebookContents;
|
import net.dnorberg.rivencraft.writing.NotebookContents;
|
||||||
import net.dnorberg.rivencraft.item.PageItem;
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
|
import net.dnorberg.rivencraft.item.InkVialItem;
|
||||||
|
import net.dnorberg.rivencraft.writing.WritingInkService;
|
||||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
||||||
@@ -22,6 +24,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.inventory.ClickType;
|
||||||
import net.neoforged.neoforge.gametest.GameTestHolder;
|
import net.neoforged.neoforge.gametest.GameTestHolder;
|
||||||
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
|
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
|
||||||
|
|
||||||
@@ -150,32 +153,168 @@ public final class WritingDataGameTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GameTest(template = "empty")
|
@GameTest(template = "empty")
|
||||||
public static void notebookMenuValidatesInsertionAndPersistsReorderAndRename(GameTestHelper helper) {
|
public static void notebookMenuValidatesInsertionAndPersistsReorder(GameTestHelper helper) {
|
||||||
var player = helper.makeMockServerPlayerInLevel();
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
ItemStack notebook = new ItemStack(ModItems.NOTEBOOK.get());
|
ItemStack notebook = new ItemStack(ModItems.NOTEBOOK.get());
|
||||||
player.setItemInHand(InteractionHand.MAIN_HAND, notebook);
|
player.setItemInHand(InteractionHand.MAIN_HAND, notebook);
|
||||||
NotebookMenu menu = new NotebookMenu(7, player.getInventory(), InteractionHand.MAIN_HAND);
|
NotebookMenu menu = new NotebookMenu(7, player.getInventory(), InteractionHand.MAIN_HAND);
|
||||||
ItemStack first = PageItem.createSymbolPage(reference("rivencraft:terrain/standard"));
|
ItemStack first = PageItem.createSymbolPage(reference("rivencraft:terrain/standard"));
|
||||||
|
first.set(net.minecraft.core.component.DataComponents.CUSTOM_NAME,
|
||||||
|
net.minecraft.network.chat.Component.literal("Terrain Base"));
|
||||||
ItemStack second = PageItem.createRecoveredPage(reference("example:removed_symbol"));
|
ItemStack second = PageItem.createRecoveredPage(reference("example:removed_symbol"));
|
||||||
|
|
||||||
helper.assertFalse(menu.getSlot(0).mayPlace(new ItemStack(Items.DIRT)),
|
helper.assertFalse(menu.getSlot(0).mayPlace(new ItemStack(Items.DIRT)),
|
||||||
"Notebook slots must reject non-Page items");
|
"Notebook slots must reject non-Page items");
|
||||||
menu.getSlot(0).set(first);
|
menu.getSlot(0).set(first);
|
||||||
menu.getSlot(1).set(second);
|
menu.getSlot(1).set(second);
|
||||||
menu.renamePage(0, "Terrain Base");
|
|
||||||
helper.assertTrue(menu.clickMenuButton(player, NotebookMenu.MOVE_NEXT_BASE),
|
helper.assertTrue(menu.clickMenuButton(player, NotebookMenu.MOVE_NEXT_BASE),
|
||||||
"The server menu must accept a valid adjacent reorder");
|
"The server menu must accept a valid adjacent reorder");
|
||||||
|
|
||||||
NotebookContents saved = notebook.get(ModDataComponents.NOTEBOOK_CONTENTS.get());
|
NotebookContents saved = notebook.get(ModDataComponents.NOTEBOOK_CONTENTS.get());
|
||||||
helper.assertTrue(saved != null, "Menu changes must persist immediately to the Notebook item");
|
helper.assertTrue(saved != null, "Menu changes must persist immediately to the Notebook item");
|
||||||
helper.assertValueEqual(saved.pages().get(1).getHoverName().getString(), "Terrain Base",
|
helper.assertValueEqual(saved.pages().get(1).getHoverName().getString(), "Terrain Base",
|
||||||
"Reordering must preserve the renamed Page stack");
|
"Reordering must preserve existing Page item data");
|
||||||
helper.assertValueEqual(PageItem.content(saved.pages().get(0)).kind(),
|
helper.assertValueEqual(PageItem.content(saved.pages().get(0)).kind(),
|
||||||
PageContent.Kind.UNRESOLVED_SYMBOL,
|
PageContent.Kind.UNRESOLVED_SYMBOL,
|
||||||
"Reordering must preserve unresolved pages");
|
"Reordering must preserve unresolved pages");
|
||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void notebookMenuSurvivesInventoryStackReplacementAndClicks(GameTestHelper helper) {
|
||||||
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
|
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(ModItems.NOTEBOOK.get()));
|
||||||
|
NotebookMenu menu = new NotebookMenu(8, player.getInventory(), InteractionHand.MAIN_HAND);
|
||||||
|
|
||||||
|
// Slot synchronization may replace the ItemStack object while the Notebook remains held.
|
||||||
|
player.setItemInHand(InteractionHand.MAIN_HAND, player.getMainHandItem().copy());
|
||||||
|
helper.assertTrue(menu.stillValid(player),
|
||||||
|
"Replacing the held stack object must not close an open Notebook menu");
|
||||||
|
menu.getSlot(0).set(PageItem.createSymbolPage(reference("rivencraft:terrain/standard")));
|
||||||
|
helper.assertTrue(player.getMainHandItem().has(ModDataComponents.NOTEBOOK_CONTENTS.get()),
|
||||||
|
"Page edits must persist to the current held Notebook stack");
|
||||||
|
|
||||||
|
player.getInventory().setItem(9, new ItemStack(Items.DIRT));
|
||||||
|
menu.clicked(NotebookMenu.NOTEBOOK_SLOTS, 0, ClickType.PICKUP, player);
|
||||||
|
helper.assertTrue(menu.getCarried().is(Items.DIRT),
|
||||||
|
"Clicking a player inventory item must pick it up without closing the Notebook");
|
||||||
|
helper.assertTrue(menu.stillValid(player),
|
||||||
|
"Normal inventory clicks must leave the Notebook menu valid");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void notebookMenuPreservesSparsePagePositions(GameTestHelper helper) {
|
||||||
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
|
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(ModItems.NOTEBOOK.get()));
|
||||||
|
NotebookMenu menu = new NotebookMenu(9, player.getInventory(), InteractionHand.MAIN_HAND);
|
||||||
|
ItemStack page = PageItem.createSymbolPage(reference("rivencraft:terrain/standard"));
|
||||||
|
menu.setCarried(page);
|
||||||
|
|
||||||
|
menu.clicked(9, 0, ClickType.PICKUP, player);
|
||||||
|
helper.assertTrue(menu.getCarried().isEmpty(),
|
||||||
|
"Clicking a distant empty Notebook slot must place the carried Page");
|
||||||
|
NotebookContents saved = player.getMainHandItem().get(ModDataComponents.NOTEBOOK_CONTENTS.get());
|
||||||
|
helper.assertTrue(saved != null && saved.pages().size() > 9,
|
||||||
|
"Notebook persistence must extend through the highest occupied position");
|
||||||
|
for (int index = 0; index < 9; index++) {
|
||||||
|
helper.assertTrue(saved.pages().get(index).isEmpty(),
|
||||||
|
"Earlier empty page positions must remain empty rather than being packed together");
|
||||||
|
}
|
||||||
|
helper.assertValueEqual(PageItem.content(saved.pages().get(9)).kind(), PageContent.Kind.SYMBOL,
|
||||||
|
"The Page must remain in the selected distant position");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void inkVialsPersistAndOnlyStackWithMatchingContents(GameTestHelper helper) {
|
||||||
|
ItemStack vial = new ItemStack(ModItems.INK_VIAL.get());
|
||||||
|
vial.set(ModDataComponents.INK_REMAINING.get(), 7);
|
||||||
|
CompoundTag serialized = (CompoundTag) vial.saveOptional(helper.getLevel().registryAccess());
|
||||||
|
ItemStack restored = ItemStack.parseOptional(helper.getLevel().registryAccess(), serialized);
|
||||||
|
helper.assertValueEqual(InkVialItem.remaining(restored), 7,
|
||||||
|
"Remaining ink must survive ItemStack persistence");
|
||||||
|
helper.assertTrue(ItemStack.isSameItemSameComponents(vial, restored),
|
||||||
|
"Vials with equal ink contents must be eligible to stack");
|
||||||
|
helper.assertFalse(ItemStack.isSameItemSameComponents(vial, new ItemStack(ModItems.INK_VIAL.get())),
|
||||||
|
"Vials with different ink contents must not stack");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void linkPanelPreparationConsumesOnePageAndConfiguredInkOnlyOnSuccess(GameTestHelper helper) {
|
||||||
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
|
ItemStack pages = new ItemStack(ModItems.PAGE.get(), 2);
|
||||||
|
ItemStack vial = new ItemStack(ModItems.INK_VIAL.get());
|
||||||
|
player.setItemInHand(InteractionHand.MAIN_HAND, vial);
|
||||||
|
player.setItemInHand(InteractionHand.OFF_HAND, pages);
|
||||||
|
|
||||||
|
helper.assertTrue(WritingInkService.prepareLinkPanel(player, InteractionHand.MAIN_HAND),
|
||||||
|
"A blank Page and sufficient ink must prepare one link panel");
|
||||||
|
helper.assertValueEqual(pages.getCount(), 1, "Preparation must consume exactly one blank Page");
|
||||||
|
helper.assertValueEqual(InkVialItem.remaining(player.getMainHandItem()),
|
||||||
|
InkVialItem.CAPACITY - WritingInkService.linkPanelCost(),
|
||||||
|
"Preparation must consume exactly the server-configured ink cost");
|
||||||
|
long panels = player.getInventory().items.stream()
|
||||||
|
.filter(stack -> stack.is(ModItems.PAGE.get())
|
||||||
|
&& PageItem.content(stack).kind() == PageContent.Kind.LINK_PANEL)
|
||||||
|
.mapToInt(ItemStack::getCount).sum();
|
||||||
|
helper.assertValueEqual(panels, 1L, "Preparation must output exactly one link panel");
|
||||||
|
|
||||||
|
ItemStack written = PageItem.createSymbolPage(reference("rivencraft:terrain/standard"));
|
||||||
|
player.setItemInHand(InteractionHand.OFF_HAND, written);
|
||||||
|
int inkBefore = InkVialItem.remaining(player.getMainHandItem());
|
||||||
|
helper.assertFalse(WritingInkService.prepareLinkPanel(player, InteractionHand.MAIN_HAND),
|
||||||
|
"A written Page must not be overwritten as a link panel");
|
||||||
|
helper.assertValueEqual(InkVialItem.remaining(player.getMainHandItem()), inkBefore,
|
||||||
|
"Rejected writing must not consume ink");
|
||||||
|
helper.assertValueEqual(PageItem.content(written).kind(), PageContent.Kind.SYMBOL,
|
||||||
|
"Rejected writing must not modify the input Page");
|
||||||
|
|
||||||
|
ItemStack lowInk = new ItemStack(ModItems.INK_VIAL.get());
|
||||||
|
lowInk.set(ModDataComponents.INK_REMAINING.get(), WritingInkService.linkPanelCost() - 1);
|
||||||
|
player.setItemInHand(InteractionHand.MAIN_HAND, lowInk);
|
||||||
|
player.setItemInHand(InteractionHand.OFF_HAND, new ItemStack(ModItems.PAGE.get()));
|
||||||
|
helper.assertFalse(WritingInkService.prepareLinkPanel(player, InteractionHand.MAIN_HAND),
|
||||||
|
"Insufficient ink must reject link-panel preparation");
|
||||||
|
helper.assertValueEqual(InkVialItem.remaining(player.getMainHandItem()),
|
||||||
|
WritingInkService.linkPanelCost() - 1,
|
||||||
|
"Insufficient ink must remain untouched");
|
||||||
|
helper.assertValueEqual(PageItem.content(player.getOffhandItem()).kind(), PageContent.Kind.BLANK,
|
||||||
|
"Insufficient ink must leave the Page blank");
|
||||||
|
|
||||||
|
lowInk.set(ModDataComponents.INK_REMAINING.get(), WritingInkService.linkPanelCost());
|
||||||
|
helper.assertTrue(WritingInkService.prepareLinkPanel(player, InteractionHand.MAIN_HAND),
|
||||||
|
"Exact remaining ink must be usable");
|
||||||
|
helper.assertTrue(player.getMainHandItem().is(Items.GLASS_BOTTLE),
|
||||||
|
"A depleted Ink Vial must return a reusable glass bottle");
|
||||||
|
helper.assertValueEqual(PageItem.content(player.getOffhandItem()).kind(),
|
||||||
|
PageContent.Kind.LINK_PANEL,
|
||||||
|
"A single blank Page must be replaced by one Link Panel Page");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void stackedInkVialsSplitWithoutChangingTheOtherVials(GameTestHelper helper) {
|
||||||
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
|
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(ModItems.INK_VIAL.get(), 2));
|
||||||
|
player.setItemInHand(InteractionHand.OFF_HAND, new ItemStack(ModItems.PAGE.get()));
|
||||||
|
|
||||||
|
helper.assertTrue(WritingInkService.prepareLinkPanel(player, InteractionHand.MAIN_HAND),
|
||||||
|
"A stack of full vials must support preparing one panel");
|
||||||
|
helper.assertValueEqual(player.getMainHandItem().getCount(), 1,
|
||||||
|
"Using one vial must leave the other full vial in hand");
|
||||||
|
helper.assertValueEqual(InkVialItem.remaining(player.getMainHandItem()), InkVialItem.CAPACITY,
|
||||||
|
"The unconsumed vial must remain full");
|
||||||
|
long partialVials = player.getInventory().items.stream()
|
||||||
|
.filter(stack -> stack.is(ModItems.INK_VIAL.get())
|
||||||
|
&& InkVialItem.remaining(stack) == InkVialItem.CAPACITY - WritingInkService.linkPanelCost())
|
||||||
|
.mapToInt(ItemStack::getCount).sum();
|
||||||
|
helper.assertValueEqual(partialVials, 1L,
|
||||||
|
"The used vial must reappear with only its own ink reduced");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
private static SymbolReference reference(String id) {
|
private static SymbolReference reference(String id) {
|
||||||
return new SymbolReference(ResourceLocation.parse(id));
|
return new SymbolReference(ResourceLocation.parse(id));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package net.dnorberg.rivencraft.gametest;
|
||||||
|
|
||||||
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
|
import net.dnorberg.rivencraft.block.entity.WritingDeskBlockEntity;
|
||||||
|
import net.dnorberg.rivencraft.menu.WritingDeskMenu;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModBlocks;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.gametest.framework.GameTest;
|
||||||
|
import net.minecraft.gametest.framework.GameTestHelper;
|
||||||
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraft.world.phys.AABB;
|
||||||
|
import net.neoforged.neoforge.gametest.GameTestHolder;
|
||||||
|
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
|
||||||
|
|
||||||
|
@GameTestHolder(Rivencraft.MOD_ID)
|
||||||
|
@PrefixGameTestTemplate(false)
|
||||||
|
public final class WritingDeskGameTests {
|
||||||
|
private WritingDeskGameTests() {}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void inventoryAndActiveCollectionPersist(GameTestHelper helper) {
|
||||||
|
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||||
|
var original = new WritingDeskBlockEntity(pos, ModBlocks.WRITING_DESK.get().defaultBlockState());
|
||||||
|
original.setItem(0, new ItemStack(ModItems.NOTEBOOK.get()));
|
||||||
|
original.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
|
original.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(ModItems.PAGE.get(), 12));
|
||||||
|
original.setActiveCollection(2);
|
||||||
|
var saved = original.saveWithoutMetadata(helper.getLevel().registryAccess());
|
||||||
|
var restored = new WritingDeskBlockEntity(pos, ModBlocks.WRITING_DESK.get().defaultBlockState());
|
||||||
|
restored.loadWithComponents(saved, helper.getLevel().registryAccess());
|
||||||
|
helper.assertTrue(restored.getItem(0).is(ModItems.NOTEBOOK.get()), "Notebook lost on save/load");
|
||||||
|
helper.assertTrue(restored.getItem(WritingDeskBlockEntity.INK).is(ModItems.INK_VIAL.get()), "Ink lost on save/load");
|
||||||
|
helper.assertValueEqual(restored.getItem(WritingDeskBlockEntity.PAPER).getCount(), 12, "Pages lost on save/load");
|
||||||
|
helper.assertValueEqual(restored.activeCollection(), 2, "Active collection lost on save/load");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void breakingDeskDropsItsStoredItemsOnce(GameTestHelper helper) {
|
||||||
|
BlockPos relative = new BlockPos(1, 1, 1);
|
||||||
|
BlockPos pos = helper.absolutePos(relative);
|
||||||
|
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
||||||
|
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
|
desk.setItem(0, new ItemStack(ModItems.NOTEBOOK.get()));
|
||||||
|
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
|
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(ModItems.PAGE.get(), 12));
|
||||||
|
helper.getLevel().setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
||||||
|
var drops = helper.getLevel().getEntitiesOfClass(ItemEntity.class, new AABB(pos).inflate(2));
|
||||||
|
int notebooks = drops.stream().filter(e -> e.getItem().is(ModItems.NOTEBOOK.get())).mapToInt(e -> e.getItem().getCount()).sum();
|
||||||
|
int ink = drops.stream().filter(e -> e.getItem().is(ModItems.INK_VIAL.get())).mapToInt(e -> e.getItem().getCount()).sum();
|
||||||
|
int pages = drops.stream().filter(e -> e.getItem().is(ModItems.PAGE.get())).mapToInt(e -> e.getItem().getCount()).sum();
|
||||||
|
helper.assertValueEqual(notebooks, 1, "Notebook must drop exactly once");
|
||||||
|
helper.assertValueEqual(ink, 1, "Ink must drop exactly once");
|
||||||
|
helper.assertValueEqual(pages, 12, "Pages must drop without loss");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void menuTransfersWithoutDuplicationAndClosesWhenReplaced(GameTestHelper helper) {
|
||||||
|
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||||
|
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
||||||
|
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
|
player.moveTo(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||||
|
player.getInventory().setItem(9, new ItemStack(ModItems.PAGE.get(), 12));
|
||||||
|
WritingDeskMenu menu = new WritingDeskMenu(1, player.getInventory(), desk);
|
||||||
|
helper.assertTrue(menu.stillValid(player), "Placed desk must keep its menu valid");
|
||||||
|
helper.assertTrue(menu.clickMenuButton(player, 3), "Active collection control must accept a valid tab");
|
||||||
|
helper.assertValueEqual(desk.activeCollection(), 3, "Selected tab must be stored on the desk");
|
||||||
|
menu.quickMoveStack(player, 8);
|
||||||
|
helper.assertValueEqual(desk.getItem(WritingDeskBlockEntity.PAPER).getCount(), 12, "Shift-click must deposit all pages");
|
||||||
|
helper.assertTrue(player.getInventory().getItem(9).isEmpty(), "Shift-click must consume player source stack");
|
||||||
|
menu.quickMoveStack(player, WritingDeskBlockEntity.PAPER);
|
||||||
|
helper.assertTrue(desk.getItem(WritingDeskBlockEntity.PAPER).isEmpty(), "Shift-click must empty desk source slot");
|
||||||
|
int total = player.getInventory().items.stream().filter(stack -> stack.is(ModItems.PAGE.get()))
|
||||||
|
.mapToInt(ItemStack::getCount).sum();
|
||||||
|
helper.assertValueEqual(total, 12, "Round-trip must not lose or duplicate pages");
|
||||||
|
helper.getLevel().setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
||||||
|
helper.assertFalse(menu.stillValid(player), "Removed desk must invalidate menu");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package net.dnorberg.rivencraft.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
|
import net.dnorberg.rivencraft.writing.WritingInkService;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.TooltipFlag;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
|
/** A stackable vial; the ink component is per vial, not shared across a stack. */
|
||||||
|
public final class InkVialItem extends Item {
|
||||||
|
public static final int CAPACITY = 16;
|
||||||
|
|
||||||
|
public InkVialItem(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int remaining(ItemStack vial) {
|
||||||
|
return vial.getOrDefault(ModDataComponents.INK_REMAINING.get(), CAPACITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
|
||||||
|
if (!WritingInkService.canPrepareLinkPanel(player, hand)) {
|
||||||
|
return InteractionResultHolder.pass(player.getItemInHand(hand));
|
||||||
|
}
|
||||||
|
if (!level.isClientSide) {
|
||||||
|
WritingInkService.prepareLinkPanel(player, hand);
|
||||||
|
}
|
||||||
|
return InteractionResultHolder.sidedSuccess(player.getItemInHand(hand), level.isClientSide);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void appendHoverText(ItemStack stack, TooltipContext context,
|
||||||
|
List<Component> tooltip, TooltipFlag flag) {
|
||||||
|
tooltip.add(Component.translatable("item.rivencraft.ink_vial.remaining",
|
||||||
|
remaining(stack), CAPACITY).withStyle(ChatFormatting.GRAY));
|
||||||
|
tooltip.add(Component.translatable("item.rivencraft.ink_vial.usage")
|
||||||
|
.withStyle(ChatFormatting.GRAY));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,7 @@ import net.dnorberg.rivencraft.registry.ModItems;
|
|||||||
import net.dnorberg.rivencraft.registry.ModMenus;
|
import net.dnorberg.rivencraft.registry.ModMenus;
|
||||||
import net.dnorberg.rivencraft.writing.NotebookContents;
|
import net.dnorberg.rivencraft.writing.NotebookContents;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.core.component.DataComponents;
|
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.world.Container;
|
import net.minecraft.world.Container;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.SimpleContainer;
|
import net.minecraft.world.SimpleContainer;
|
||||||
@@ -21,14 +19,12 @@ import net.minecraft.world.item.ItemStack;
|
|||||||
|
|
||||||
public final class NotebookMenu extends AbstractContainerMenu {
|
public final class NotebookMenu extends AbstractContainerMenu {
|
||||||
public static final int NOTEBOOK_SLOTS = NotebookContents.MAX_PAGES;
|
public static final int NOTEBOOK_SLOTS = NotebookContents.MAX_PAGES;
|
||||||
public static final int PAGE_COLUMNS = 9;
|
|
||||||
public static final int PAGE_ROWS = 3;
|
|
||||||
public static final int MOVE_PREVIOUS_BASE = 0;
|
public static final int MOVE_PREVIOUS_BASE = 0;
|
||||||
public static final int MOVE_NEXT_BASE = NOTEBOOK_SLOTS;
|
public static final int MOVE_NEXT_BASE = NOTEBOOK_SLOTS;
|
||||||
private static final int PLAYER_INVENTORY_START = NOTEBOOK_SLOTS;
|
private static final int PLAYER_INVENTORY_START = NOTEBOOK_SLOTS;
|
||||||
private final Inventory playerInventory;
|
private final Inventory playerInventory;
|
||||||
private final InteractionHand hand;
|
private final InteractionHand hand;
|
||||||
private final ItemStack notebook;
|
private final int openedHotbarSlot;
|
||||||
private final NotebookContainer contents;
|
private final NotebookContainer contents;
|
||||||
|
|
||||||
public NotebookMenu(int containerId, Inventory inventory, RegistryFriendlyByteBuf data) {
|
public NotebookMenu(int containerId, Inventory inventory, RegistryFriendlyByteBuf data) {
|
||||||
@@ -39,12 +35,13 @@ public final class NotebookMenu extends AbstractContainerMenu {
|
|||||||
super(ModMenus.NOTEBOOK.get(), containerId);
|
super(ModMenus.NOTEBOOK.get(), containerId);
|
||||||
this.playerInventory = inventory;
|
this.playerInventory = inventory;
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
this.notebook = inventory.player.getItemInHand(hand);
|
this.openedHotbarSlot = inventory.selected;
|
||||||
this.contents = new NotebookContainer(notebook);
|
this.contents = new NotebookContainer(inventory, hand);
|
||||||
|
|
||||||
for (int row = 0; row < 3; row++) {
|
for (int row = 0; row < 3; row++) {
|
||||||
for (int column = 0; column < 9; column++) {
|
for (int column = 0; column < 9; column++) {
|
||||||
addSlot(new PageSlot(contents, column + row * 9, 8 + column * 18, 28 + row * 34));
|
// The client draws these pages on a filtered, scrollable surface instead.
|
||||||
|
addSlot(new PageSlot(contents, column + row * 9, -1000, -1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int row = 0; row < 3; row++) {
|
for (int row = 0; row < 3; row++) {
|
||||||
@@ -59,14 +56,16 @@ public final class NotebookMenu extends AbstractContainerMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Slot playerSlot(int inventoryIndex, int x, int y) {
|
private Slot playerSlot(int inventoryIndex, int x, int y) {
|
||||||
boolean locked = hand == InteractionHand.MAIN_HAND && inventoryIndex == playerInventory.selected;
|
boolean locked = hand == InteractionHand.MAIN_HAND && inventoryIndex == openedHotbarSlot;
|
||||||
return locked ? new LockedSlot(playerInventory, inventoryIndex, x, y)
|
return locked ? new LockedSlot(playerInventory, inventoryIndex, x, y)
|
||||||
: new Slot(playerInventory, inventoryIndex, x, y);
|
: new Slot(playerInventory, inventoryIndex, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return player.isAlive() && player.getItemInHand(hand) == notebook && notebook.is(ModItems.NOTEBOOK.get());
|
return player.isAlive()
|
||||||
|
&& (hand == InteractionHand.OFF_HAND || player.getInventory().selected == openedHotbarSlot)
|
||||||
|
&& player.getItemInHand(hand).is(ModItems.NOTEBOOK.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -117,29 +116,18 @@ public final class NotebookMenu extends AbstractContainerMenu {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renamePage(int slot, String name) {
|
|
||||||
if (slot < 0 || slot >= NOTEBOOK_SLOTS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ItemStack page = contents.getItem(slot);
|
|
||||||
if (page.isEmpty() || !page.is(ModItems.PAGE.get())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (name.isBlank()) {
|
|
||||||
page.remove(DataComponents.CUSTOM_NAME);
|
|
||||||
} else {
|
|
||||||
page.set(DataComponents.CUSTOM_NAME, Component.literal(name));
|
|
||||||
}
|
|
||||||
contents.setChanged();
|
|
||||||
broadcastChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clicked(int slotId, int button, ClickType clickType, Player player) {
|
public void clicked(int slotId, int button, ClickType clickType, Player player) {
|
||||||
super.clicked(slotId, button, clickType, player);
|
|
||||||
if (!stillValid(player)) {
|
if (!stillValid(player)) {
|
||||||
player.closeContainer();
|
player.closeContainer();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if (clickType == ClickType.SWAP
|
||||||
|
&& (button == openedHotbarSlot && hand == InteractionHand.MAIN_HAND
|
||||||
|
|| button == 40 && hand == InteractionHand.OFF_HAND)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.clicked(slotId, button, clickType, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class PageSlot extends Slot {
|
private static final class PageSlot extends Slot {
|
||||||
@@ -161,12 +149,15 @@ public final class NotebookMenu extends AbstractContainerMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final class NotebookContainer extends SimpleContainer {
|
private static final class NotebookContainer extends SimpleContainer {
|
||||||
private final ItemStack notebook;
|
private final Inventory inventory;
|
||||||
|
private final InteractionHand hand;
|
||||||
private boolean loading;
|
private boolean loading;
|
||||||
|
|
||||||
private NotebookContainer(ItemStack notebook) {
|
private NotebookContainer(Inventory inventory, InteractionHand hand) {
|
||||||
super(NOTEBOOK_SLOTS);
|
super(NOTEBOOK_SLOTS);
|
||||||
this.notebook = notebook;
|
this.inventory = inventory;
|
||||||
|
this.hand = hand;
|
||||||
|
ItemStack notebook = inventory.player.getItemInHand(hand);
|
||||||
loading = true;
|
loading = true;
|
||||||
List<ItemStack> saved = notebook.getOrDefault(
|
List<ItemStack> saved = notebook.getOrDefault(
|
||||||
ModDataComponents.NOTEBOOK_CONTENTS.get(), NotebookContents.EMPTY).pages();
|
ModDataComponents.NOTEBOOK_CONTENTS.get(), NotebookContents.EMPTY).pages();
|
||||||
@@ -188,7 +179,8 @@ public final class NotebookMenu extends AbstractContainerMenu {
|
|||||||
@Override
|
@Override
|
||||||
public void setChanged() {
|
public void setChanged() {
|
||||||
super.setChanged();
|
super.setChanged();
|
||||||
if (loading || notebook.isEmpty()) {
|
ItemStack notebook = inventory.player.getItemInHand(hand);
|
||||||
|
if (loading || !notebook.is(ModItems.NOTEBOOK.get())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NonNullList<ItemStack> saved = NonNullList.withSize(NOTEBOOK_SLOTS, ItemStack.EMPTY);
|
NonNullList<ItemStack> saved = NonNullList.withSize(NOTEBOOK_SLOTS, ItemStack.EMPTY);
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package net.dnorberg.rivencraft.menu;
|
||||||
|
|
||||||
|
import net.dnorberg.rivencraft.block.entity.WritingDeskBlockEntity;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModMenus;
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
|
import net.minecraft.world.Container;
|
||||||
|
import net.minecraft.world.SimpleContainer;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
|
import net.minecraft.world.inventory.DataSlot;
|
||||||
|
import net.minecraft.world.inventory.Slot;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
|
public final class WritingDeskMenu extends AbstractContainerMenu {
|
||||||
|
private static final int PLAYER_START = WritingDeskBlockEntity.SIZE;
|
||||||
|
private final Container desk;
|
||||||
|
private final WritingDeskBlockEntity blockEntity;
|
||||||
|
private int syncedActiveCollection;
|
||||||
|
|
||||||
|
public WritingDeskMenu(int id, Inventory inventory, RegistryFriendlyByteBuf data) {
|
||||||
|
this(id, inventory, inventory.player.level().getBlockEntity(data.readBlockPos())
|
||||||
|
instanceof WritingDeskBlockEntity found ? found : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WritingDeskMenu(int id, Inventory inventory, WritingDeskBlockEntity blockEntity) {
|
||||||
|
super(ModMenus.WRITING_DESK.get(), id);
|
||||||
|
this.blockEntity = blockEntity;
|
||||||
|
this.desk = blockEntity == null ? new SimpleContainer(WritingDeskBlockEntity.SIZE) : blockEntity;
|
||||||
|
addDataSlot(new DataSlot() {
|
||||||
|
@Override public int get() { return WritingDeskMenu.this.blockEntity == null
|
||||||
|
? syncedActiveCollection : WritingDeskMenu.this.blockEntity.activeCollection(); }
|
||||||
|
@Override public void set(int value) { syncedActiveCollection = value; }
|
||||||
|
});
|
||||||
|
for (int i = 0; i < WritingDeskBlockEntity.COLLECTIONS; i++) {
|
||||||
|
addSlot(new DeskSlot(desk, i, 12, 20 + i * 37, 1));
|
||||||
|
}
|
||||||
|
addSlot(new DeskSlot(desk, WritingDeskBlockEntity.INK, 228, 20, 1));
|
||||||
|
addSlot(new DeskSlot(desk, WritingDeskBlockEntity.SOURCE, 266, 20, 1));
|
||||||
|
addSlot(new DeskSlot(desk, WritingDeskBlockEntity.PAPER, 304, 20, 64));
|
||||||
|
addSlot(new DeskSlot(desk, WritingDeskBlockEntity.OUTPUT, 342, 20, 64));
|
||||||
|
for (int row = 0; row < 3; row++) {
|
||||||
|
for (int column = 0; column < 9; column++) {
|
||||||
|
addSlot(new Slot(inventory, column + row * 9 + 9, 224 + column * 18, 91 + row * 18));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int column = 0; column < 9; column++) {
|
||||||
|
addSlot(new Slot(inventory, column, 224 + column * 18, 149));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int activeCollection() { return syncedActiveCollection; }
|
||||||
|
|
||||||
|
@Override public boolean clickMenuButton(Player player, int id) {
|
||||||
|
if (blockEntity == null || !stillValid(player) || id < 0 || id >= WritingDeskBlockEntity.COLLECTIONS) return false;
|
||||||
|
blockEntity.setActiveCollection(id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean stillValid(Player player) {
|
||||||
|
return blockEntity != null && blockEntity.stillValid(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public ItemStack quickMoveStack(Player player, int index) {
|
||||||
|
if (!stillValid(player) || index < 0 || index >= slots.size()) return ItemStack.EMPTY;
|
||||||
|
Slot slot = slots.get(index);
|
||||||
|
if (!slot.hasItem()) return ItemStack.EMPTY;
|
||||||
|
ItemStack moving = slot.getItem();
|
||||||
|
ItemStack original = moving.copy();
|
||||||
|
if (index < PLAYER_START) {
|
||||||
|
if (!moveItemStackTo(moving, PLAYER_START, slots.size(), true)) return ItemStack.EMPTY;
|
||||||
|
} else if (!moveIntoDesk(moving)) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
if (moving.isEmpty()) slot.setByPlayer(ItemStack.EMPTY);
|
||||||
|
else slot.setChanged();
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean moveIntoDesk(ItemStack moving) {
|
||||||
|
if (moving.is(ModItems.INK_VIAL.get())) return moveItemStackTo(moving, 4, 5, false);
|
||||||
|
if (moving.is(ModItems.NOTEBOOK.get())) return moveItemStackTo(moving, 0, 4, false);
|
||||||
|
if (moving.is(ModItems.PAGE.get())) {
|
||||||
|
return moveItemStackTo(moving, 6, 7, false)
|
||||||
|
|| moveItemStackTo(moving, 0, 4, false)
|
||||||
|
|| moveItemStackTo(moving, 5, 6, false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class DeskSlot extends Slot {
|
||||||
|
private final int limit;
|
||||||
|
private DeskSlot(Container container, int index, int x, int y, int limit) {
|
||||||
|
super(container, index, x, y);
|
||||||
|
this.limit = limit;
|
||||||
|
}
|
||||||
|
@Override public boolean mayPlace(ItemStack stack) { return container.canPlaceItem(getContainerSlot(), stack); }
|
||||||
|
@Override public int getMaxStackSize() { return limit; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ import net.dnorberg.rivencraft.client.ClientAgeCelestialAngles;
|
|||||||
import net.dnorberg.rivencraft.event.AgeCelestialAngleSync;
|
import net.dnorberg.rivencraft.event.AgeCelestialAngleSync;
|
||||||
import net.dnorberg.rivencraft.item.DescriptiveBookItem;
|
import net.dnorberg.rivencraft.item.DescriptiveBookItem;
|
||||||
import net.dnorberg.rivencraft.item.LinkingBookItem;
|
import net.dnorberg.rivencraft.item.LinkingBookItem;
|
||||||
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
|
||||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
import net.minecraft.core.component.DataComponents;
|
import net.minecraft.core.component.DataComponents;
|
||||||
@@ -50,8 +49,6 @@ public final class ModNetworking {
|
|||||||
|
|
||||||
public static void register(RegisterPayloadHandlersEvent event) {
|
public static void register(RegisterPayloadHandlersEvent event) {
|
||||||
PayloadRegistrar registrar = event.registrar("10");
|
PayloadRegistrar registrar = event.registrar("10");
|
||||||
registrar.playToServer(RenameNotebookPagePayload.TYPE, RenameNotebookPagePayload.STREAM_CODEC,
|
|
||||||
ModNetworking::renameNotebookPage);
|
|
||||||
registrar.playToServer(RequestDescriptiveBookScreenPayload.TYPE, RequestDescriptiveBookScreenPayload.STREAM_CODEC,
|
registrar.playToServer(RequestDescriptiveBookScreenPayload.TYPE, RequestDescriptiveBookScreenPayload.STREAM_CODEC,
|
||||||
ModNetworking::requestDescriptiveBookScreen);
|
ModNetworking::requestDescriptiveBookScreen);
|
||||||
registrar.playToClient(OpenDescriptiveBookScreenPayload.TYPE, OpenDescriptiveBookScreenPayload.STREAM_CODEC,
|
registrar.playToClient(OpenDescriptiveBookScreenPayload.TYPE, OpenDescriptiveBookScreenPayload.STREAM_CODEC,
|
||||||
@@ -73,16 +70,6 @@ public final class ModNetworking {
|
|||||||
ClientAgeCelestialAngles::handle);
|
ClientAgeCelestialAngles::handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renameNotebookPage(RenameNotebookPagePayload payload, IPayloadContext context) {
|
|
||||||
if (!(context.player() instanceof ServerPlayer player)
|
|
||||||
|| !(player.containerMenu instanceof NotebookMenu menu)
|
|
||||||
|| menu.containerId != payload.containerId()
|
|
||||||
|| payload.name().length() > MAX_BOOK_TITLE_LENGTH) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
menu.renamePage(payload.slot(), normalizeTitle(payload.name()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void requestDescriptiveBookScreen(RequestDescriptiveBookScreenPayload payload, IPayloadContext context) {
|
private static void requestDescriptiveBookScreen(RequestDescriptiveBookScreenPayload payload, IPayloadContext context) {
|
||||||
if (!(context.player() instanceof ServerPlayer player)) {
|
if (!(context.player() instanceof ServerPlayer player)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package net.dnorberg.rivencraft.network;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
public record RenameNotebookPagePayload(int containerId, int slot, String name) implements CustomPacketPayload {
|
|
||||||
public static final Type<RenameNotebookPagePayload> TYPE = new Type<>(
|
|
||||||
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "rename_notebook_page"));
|
|
||||||
public static final StreamCodec<ByteBuf, RenameNotebookPagePayload> STREAM_CODEC = StreamCodec.composite(
|
|
||||||
ByteBufCodecs.VAR_INT, RenameNotebookPagePayload::containerId,
|
|
||||||
ByteBufCodecs.VAR_INT, RenameNotebookPagePayload::slot,
|
|
||||||
ByteBufCodecs.STRING_UTF8, RenameNotebookPagePayload::name,
|
|
||||||
RenameNotebookPagePayload::new);
|
|
||||||
|
|
||||||
@Override public Type<? extends CustomPacketPayload> type() { return TYPE; }
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,7 @@ package net.dnorberg.rivencraft.registry;
|
|||||||
|
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
import net.dnorberg.rivencraft.block.entity.BookStandBlockEntity;
|
import net.dnorberg.rivencraft.block.entity.BookStandBlockEntity;
|
||||||
|
import net.dnorberg.rivencraft.block.entity.WritingDeskBlockEntity;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.neoforged.bus.api.IEventBus;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
@@ -16,6 +17,9 @@ public final class ModBlockEntities {
|
|||||||
BLOCK_ENTITIES.register("book_stand", () -> BlockEntityType.Builder
|
BLOCK_ENTITIES.register("book_stand", () -> BlockEntityType.Builder
|
||||||
.of(BookStandBlockEntity::new, ModBlocks.BOOK_STAND.get())
|
.of(BookStandBlockEntity::new, ModBlocks.BOOK_STAND.get())
|
||||||
.build(null));
|
.build(null));
|
||||||
|
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<WritingDeskBlockEntity>> WRITING_DESK =
|
||||||
|
BLOCK_ENTITIES.register("writing_desk", () -> BlockEntityType.Builder
|
||||||
|
.of(WritingDeskBlockEntity::new, ModBlocks.WRITING_DESK.get()).build(null));
|
||||||
|
|
||||||
private ModBlockEntities() {
|
private ModBlockEntities() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.dnorberg.rivencraft.registry;
|
|||||||
|
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
import net.dnorberg.rivencraft.block.BookStandBlock;
|
import net.dnorberg.rivencraft.block.BookStandBlock;
|
||||||
|
import net.dnorberg.rivencraft.block.WritingDeskBlock;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
import net.neoforged.bus.api.IEventBus;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
@@ -16,6 +17,10 @@ public final class ModBlocks {
|
|||||||
BookStandBlock::new,
|
BookStandBlock::new,
|
||||||
BlockBehaviour.Properties.ofFullCopy(Blocks.LECTERN)
|
BlockBehaviour.Properties.ofFullCopy(Blocks.LECTERN)
|
||||||
);
|
);
|
||||||
|
public static final DeferredBlock<WritingDeskBlock> WRITING_DESK = BLOCKS.registerBlock(
|
||||||
|
"writing_desk", WritingDeskBlock::new,
|
||||||
|
BlockBehaviour.Properties.ofFullCopy(Blocks.CRAFTING_TABLE)
|
||||||
|
);
|
||||||
|
|
||||||
private ModBlocks() {
|
private ModBlocks() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.dnorberg.rivencraft.registry;
|
package net.dnorberg.rivencraft.registry;
|
||||||
|
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
@@ -19,8 +20,19 @@ public final class ModCreativeTabs {
|
|||||||
.displayItems((parameters, output) -> {
|
.displayItems((parameters, output) -> {
|
||||||
output.accept(ModItems.DESCRIPTIVE_BOOK.get());
|
output.accept(ModItems.DESCRIPTIVE_BOOK.get());
|
||||||
output.accept(ModItems.LINKING_BOOK.get());
|
output.accept(ModItems.LINKING_BOOK.get());
|
||||||
output.accept(ModItems.PAGE.get());
|
|
||||||
output.accept(ModItems.NOTEBOOK.get());
|
output.accept(ModItems.NOTEBOOK.get());
|
||||||
|
output.accept(ModItems.INK_VIAL.get());
|
||||||
|
output.accept(ModItems.WRITING_DESK.get());
|
||||||
|
})
|
||||||
|
.build());
|
||||||
|
|
||||||
|
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> PAGES =
|
||||||
|
CREATIVE_TABS.register("rivencraft_pages", () -> CreativeModeTab.builder()
|
||||||
|
.title(Component.translatable("itemGroup.rivencraft.pages"))
|
||||||
|
.icon(PageItem::createLinkPanelPage)
|
||||||
|
.displayItems((parameters, output) -> {
|
||||||
|
output.accept(ModItems.PAGE.get());
|
||||||
|
output.accept(PageItem.createLinkPanelPage());
|
||||||
})
|
})
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import net.dnorberg.rivencraft.book.AgeReference;
|
|||||||
import net.dnorberg.rivencraft.writing.PageContent;
|
import net.dnorberg.rivencraft.writing.PageContent;
|
||||||
import net.dnorberg.rivencraft.writing.NotebookContents;
|
import net.dnorberg.rivencraft.writing.NotebookContents;
|
||||||
import net.dnorberg.rivencraft.writing.SymbolDisplayMetadata;
|
import net.dnorberg.rivencraft.writing.SymbolDisplayMetadata;
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
import net.minecraft.core.component.DataComponentType;
|
import net.minecraft.core.component.DataComponentType;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -60,6 +61,12 @@ public final class ModDataComponents {
|
|||||||
.networkSynchronized(NotebookContents.STREAM_CODEC)
|
.networkSynchronized(NotebookContents.STREAM_CODEC)
|
||||||
.cacheEncoding()
|
.cacheEncoding()
|
||||||
.build());
|
.build());
|
||||||
|
public static final DeferredHolder<DataComponentType<?>, DataComponentType<Integer>> INK_REMAINING =
|
||||||
|
DATA_COMPONENTS.register("ink_remaining", () -> DataComponentType.<Integer>builder()
|
||||||
|
.persistent(Codec.intRange(0, 16))
|
||||||
|
.networkSynchronized(ByteBufCodecs.VAR_INT)
|
||||||
|
.cacheEncoding()
|
||||||
|
.build());
|
||||||
|
|
||||||
private ModDataComponents() {
|
private ModDataComponents() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import net.dnorberg.rivencraft.item.DescriptiveBookItem;
|
|||||||
import net.dnorberg.rivencraft.item.LinkingBookItem;
|
import net.dnorberg.rivencraft.item.LinkingBookItem;
|
||||||
import net.dnorberg.rivencraft.item.PageItem;
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
import net.dnorberg.rivencraft.item.NotebookItem;
|
import net.dnorberg.rivencraft.item.NotebookItem;
|
||||||
|
import net.dnorberg.rivencraft.item.InkVialItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.neoforged.bus.api.IEventBus;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.neoforged.neoforge.registries.DeferredItem;
|
import net.neoforged.neoforge.registries.DeferredItem;
|
||||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||||
@@ -33,6 +35,12 @@ public final class ModItems {
|
|||||||
NotebookItem::new,
|
NotebookItem::new,
|
||||||
new Item.Properties().stacksTo(1)
|
new Item.Properties().stacksTo(1)
|
||||||
);
|
);
|
||||||
|
public static final DeferredItem<InkVialItem> INK_VIAL = ITEMS.registerItem(
|
||||||
|
"ink_vial",
|
||||||
|
InkVialItem::new,
|
||||||
|
new Item.Properties().stacksTo(16)
|
||||||
|
);
|
||||||
|
public static final DeferredItem<BlockItem> WRITING_DESK = ITEMS.registerSimpleBlockItem(ModBlocks.WRITING_DESK);
|
||||||
|
|
||||||
private ModItems() {
|
private ModItems() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.dnorberg.rivencraft.registry;
|
|||||||
|
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
||||||
|
import net.dnorberg.rivencraft.menu.WritingDeskMenu;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.neoforged.bus.api.IEventBus;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
@@ -15,6 +16,8 @@ public final class ModMenus {
|
|||||||
|
|
||||||
public static final DeferredHolder<MenuType<?>, MenuType<NotebookMenu>> NOTEBOOK =
|
public static final DeferredHolder<MenuType<?>, MenuType<NotebookMenu>> NOTEBOOK =
|
||||||
MENUS.register("notebook", () -> IMenuTypeExtension.create(NotebookMenu::new));
|
MENUS.register("notebook", () -> IMenuTypeExtension.create(NotebookMenu::new));
|
||||||
|
public static final DeferredHolder<MenuType<?>, MenuType<WritingDeskMenu>> WRITING_DESK =
|
||||||
|
MENUS.register("writing_desk", () -> IMenuTypeExtension.create(WritingDeskMenu::new));
|
||||||
|
|
||||||
private ModMenus() {
|
private ModMenus() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package net.dnorberg.rivencraft.writing;
|
||||||
|
|
||||||
|
import net.dnorberg.rivencraft.config.RivencraftConfig;
|
||||||
|
import net.dnorberg.rivencraft.item.InkVialItem;
|
||||||
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
|
||||||
|
/** Server-owned costs and the baseline blank-page-to-link-panel transaction. */
|
||||||
|
public final class WritingInkService {
|
||||||
|
private WritingInkService() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int symbolCopyCost() {
|
||||||
|
return RivencraftConfig.symbolInkCost();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int linkPanelCost() {
|
||||||
|
return RivencraftConfig.linkPanelInkCost();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canPrepareLinkPanel(Player player, InteractionHand vialHand) {
|
||||||
|
ItemStack vial = player.getItemInHand(vialHand);
|
||||||
|
ItemStack page = player.getItemInHand(other(vialHand));
|
||||||
|
int remaining = InkVialItem.remaining(vial);
|
||||||
|
return vial.is(ModItems.INK_VIAL.get()) && remaining >= linkPanelCost()
|
||||||
|
&& remaining <= InkVialItem.CAPACITY
|
||||||
|
&& page.is(ModItems.PAGE.get()) && PageItem.content(page).kind() == PageContent.Kind.BLANK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean prepareLinkPanel(Player player, InteractionHand vialHand) {
|
||||||
|
if (player.level().isClientSide || !canPrepareLinkPanel(player, vialHand)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
InteractionHand pageHand = other(vialHand);
|
||||||
|
ItemStack page = player.getItemInHand(pageHand);
|
||||||
|
ItemStack vial = player.getItemInHand(vialHand);
|
||||||
|
int newInk = InkVialItem.remaining(vial) - linkPanelCost();
|
||||||
|
ItemStack panel = PageItem.createLinkPanelPage();
|
||||||
|
ItemStack spentVial = newInk == 0
|
||||||
|
? new ItemStack(Items.GLASS_BOTTLE)
|
||||||
|
: new ItemStack(ModItems.INK_VIAL.get());
|
||||||
|
if (newInk > 0) {
|
||||||
|
spentVial.set(ModDataComponents.INK_REMAINING.get(), newInk);
|
||||||
|
}
|
||||||
|
|
||||||
|
// All validation and output construction is complete before changing either input.
|
||||||
|
if (page.getCount() == 1) {
|
||||||
|
player.setItemInHand(pageHand, panel);
|
||||||
|
} else {
|
||||||
|
page.shrink(1);
|
||||||
|
giveOrDrop(player, panel);
|
||||||
|
}
|
||||||
|
if (vial.getCount() == 1) {
|
||||||
|
player.setItemInHand(vialHand, spentVial);
|
||||||
|
} else {
|
||||||
|
vial.shrink(1);
|
||||||
|
giveOrDrop(player, spentVial);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static InteractionHand other(InteractionHand hand) {
|
||||||
|
return hand == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void giveOrDrop(Player player, ItemStack stack) {
|
||||||
|
if (!player.getInventory().add(stack)) {
|
||||||
|
player.drop(stack, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"facing=north": { "model": "rivencraft:block/writing_desk" },
|
||||||
|
"facing=east": { "model": "rivencraft:block/writing_desk", "y": 90 },
|
||||||
|
"facing=south": { "model": "rivencraft:block/writing_desk", "y": 180 },
|
||||||
|
"facing=west": { "model": "rivencraft:block/writing_desk", "y": 270 }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,12 @@
|
|||||||
"item.rivencraft.notebook": "Notebook",
|
"item.rivencraft.notebook": "Notebook",
|
||||||
"item.rivencraft.notebook.pages": "Pages: %s/%s",
|
"item.rivencraft.notebook.pages": "Pages: %s/%s",
|
||||||
"item.rivencraft.notebook.unresolved": "Unresolved pages: %s",
|
"item.rivencraft.notebook.unresolved": "Unresolved pages: %s",
|
||||||
"screen.rivencraft.notebook.rename": "Rename selected page",
|
"item.rivencraft.ink_vial": "Ink Vial",
|
||||||
|
"block.rivencraft.writing_desk": "Writing Desk",
|
||||||
|
"container.rivencraft.writing_desk": "Writing Desk",
|
||||||
|
"item.rivencraft.ink_vial.remaining": "Ink: %s/%s",
|
||||||
|
"item.rivencraft.ink_vial.usage": "Use with a blank Page in the other hand to prepare a Link Panel.",
|
||||||
|
"screen.rivencraft.notebook.search": "Search pages",
|
||||||
"screen.rivencraft.notebook.move_previous": "Move selected page left",
|
"screen.rivencraft.notebook.move_previous": "Move selected page left",
|
||||||
"screen.rivencraft.notebook.move_next": "Move selected page right",
|
"screen.rivencraft.notebook.move_next": "Move selected page right",
|
||||||
"message.rivencraft.linking_book.bind_hint": "Sneak-use to bind this book to your current location",
|
"message.rivencraft.linking_book.bind_hint": "Sneak-use to bind this book to your current location",
|
||||||
@@ -95,5 +100,6 @@
|
|||||||
"screen.rivencraft.book.explore": "Explore",
|
"screen.rivencraft.book.explore": "Explore",
|
||||||
"screen.rivencraft.book.exploring": "Exploring",
|
"screen.rivencraft.book.exploring": "Exploring",
|
||||||
"screen.rivencraft.book.return_from_explore": "Right-click to return",
|
"screen.rivencraft.book.return_from_explore": "Right-click to return",
|
||||||
"itemGroup.rivencraft": "Rivencraft"
|
"itemGroup.rivencraft": "Rivencraft",
|
||||||
|
"itemGroup.rivencraft.pages": "Rivencraft Pages"
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:block/cube_bottom_top",
|
||||||
|
"textures": {
|
||||||
|
"top": "rivencraft:item/writing_desk",
|
||||||
|
"side": "minecraft:block/oak_planks",
|
||||||
|
"bottom": "minecraft:block/oak_planks"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "rivencraft:item/ink_vial"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/generated",
|
||||||
|
"textures": { "layer0": "rivencraft:item/writing_desk" }
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"animation": {}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 208 B |
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"pools": [{ "rolls": 1, "entries": [{ "type": "minecraft:item", "name": "rivencraft:writing_desk" }] }]
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shapeless",
|
||||||
|
"category": "misc",
|
||||||
|
"ingredients": [
|
||||||
|
{ "item": "minecraft:black_dye" },
|
||||||
|
{ "item": "minecraft:black_dye" },
|
||||||
|
{ "item": "minecraft:glass_bottle" },
|
||||||
|
{ "item": "minecraft:water_bucket" }
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"count": 1,
|
||||||
|
"id": "rivencraft:ink_vial"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"category": "misc",
|
||||||
|
"pattern": ["V F", "PPP", "P P"],
|
||||||
|
"key": {
|
||||||
|
"V": { "item": "minecraft:glass_bottle" },
|
||||||
|
"F": { "item": "minecraft:feather" },
|
||||||
|
"P": { "tag": "minecraft:planks" }
|
||||||
|
},
|
||||||
|
"result": { "id": "rivencraft:writing_desk", "count": 1 }
|
||||||
|
}
|
||||||
Reference in new issue
Block a user