Public Access
Release machine acceleration, dropped books and baseline defaults for both tracks
This commit is contained in:
1 parent
d199ac253e
commit
6630ed7ab1
72 files changed
+2390
-108
No files matched your search
@@ -1,6 +1,6 @@
|
||||
# Minecraft 26.3
|
||||
|
||||
The current **Minecraft 26.3 release is 26.3.0.10**, for NeoForge 26.3.0.99 and
|
||||
The current **Minecraft 26.3 release is 26.3.0.15**, for NeoForge 26.3.0.99 and
|
||||
Java 25. It uses Rivencraft's first-party Age backend, with no Dynamic Dimensions
|
||||
or Bad Packets dependency. The writing loop, authored/seeded Ages, generation
|
||||
features, weather/skies/celestials, libraries, crystal portals, live instability,
|
||||
@@ -29,7 +29,12 @@ The port feature and acceptance review is recorded in
|
||||
movement is disabled. The final dedicated-server restart/return check passed.
|
||||
Create/Ponder scenes are not ported to this target. Use matching client/server
|
||||
builds, keep saves separate from 1.21.1 and back up before updating.
|
||||
See [release notes](RELEASE_NOTES_26.3.0.10.md).
|
||||
See [release notes](RELEASE_NOTES_26.3.0.15.md).
|
||||
|
||||
This release adds [Accelerated machine ticking](../../docs/ACCELERATED_MACHINES.md),
|
||||
corrects [Writing Desk displays](../../docs/WRITING_DESK_MODEL.md), restores
|
||||
[dropped-book interaction](../../docs/DROPPED_BOOKS.md), and adds
|
||||
[void/skyblock block baselines](../../docs/BLOCK_BASELINE.md). Player in-game checks passed.
|
||||
|
||||
Flooded Environment Pages now fill Cave and other terrain to Y=63 by default,
|
||||
or the absolute base-25 Number Pages immediately before Flooded. Both-version
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# Rivencraft 26.3.0.11
|
||||
|
||||
Intermediate development candidate; accepted changes are included in the subsequent 1.21.1.0.12 / 26.3.0.15 releases.
|
||||
|
||||
- Accelerated Pages now give ticking server machines extra registered ticker calls.
|
||||
- Repeated Pages stack within separate configurable machine and candidate budgets.
|
||||
- Fair allocation, loaded/ticking chunk checks, world-border/removal checks and tick freeze remain in effect.
|
||||
- No force-loading or entity acceleration; normal Ages and the Overworld are unchanged.
|
||||
- Existing Accelerated Ages gain the behavior without rebinding; saved Page counts are unchanged.
|
||||
- Random-block acceleration retains its own independent budget.
|
||||
- Machine fuel, energy and input costs remain normal; global-time-gated machines may not scale linearly.
|
||||
@@ -0,0 +1,8 @@
|
||||
# Rivencraft 26.3.0.12
|
||||
|
||||
Intermediate development candidate; accepted changes are included in the subsequent 1.21.1.0.12 / 26.3.0.15 releases.
|
||||
|
||||
- Corrects Writing Desk selected-page height and centers it on the red writing mat.
|
||||
- Adds shared white paper-stack geometry on the right shelf, slightly forward, using Legacy's existing desk texture.
|
||||
- Paper count controls up to four staggered layers; attachments follow all desk facings.
|
||||
- Includes the player-validated Accelerated machine support from issue #112.
|
||||
@@ -0,0 +1,11 @@
|
||||
# Rivencraft 26.3.0.13
|
||||
|
||||
Intermediate development candidate; accepted changes are included in the subsequent 1.21.1.0.12 / 26.3.0.15 releases.
|
||||
|
||||
- Dropped Linking/Descriptive Books no longer auto-pick up on contact.
|
||||
- Right-click opens the existing book GUI; its panel links while leaving the book on the ground.
|
||||
- Shift-right-click picks up using normal ownership, pickup-delay and inventory checks.
|
||||
- Ground-book previews follow lectern behavior: rotating views remain available, interactive exploration is disabled.
|
||||
- Server validates the actual nearby entity, UUID and expected book for actions and previews.
|
||||
- Clients and servers must use matching updated builds.
|
||||
- Includes the prior local Writing Desk and machine-acceleration changes; 1.21.1 also includes universal open-book drop conversion.
|
||||
@@ -0,0 +1,18 @@
|
||||
# Rivencraft 26.3.0.15
|
||||
|
||||
Release for Minecraft 26.3 / NeoForge 26.3.0.99 / Java 25.
|
||||
Uses Rivencraft's first-party Age backend; no Dynamic Dimensions or Bad Packets required. Update clients and servers together.
|
||||
|
||||
- Accelerated Pages now also speed up registered server-side machine tickers. Repeated Pages stack within independent configurable machine/candidate budgets. Normal fuel, energy and input costs apply; machines gated by global time may remain limited.
|
||||
- Corrects Writing Desk selected-page placement on the red mat and adds white paper-stack geometry on the right shelf, with up to four layers matching the stored paper count.
|
||||
- Dropped Linking and Descriptive Books do not auto-pick up. Right-click opens the book; shift-right-click collects it with normal ownership, delay and inventory checks. Destination-panel travel leaves the ground book in place.
|
||||
- Ground-book previews follow lectern behavior: rotating previews remain available, interactive exploration is disabled. Server validation rejects stale or remote book actions.
|
||||
- Zero-count Overworld materials use version-specific bundled averages, balancing valuable-block instability with void/skyblock Overworlds. Positive measured counts retain precedence.
|
||||
- Missing modded ores use combined iron/deepslate iron measurements, falling back to bundled iron averages when measured iron is also absent. No extra profiling dimension is generated.
|
||||
- Existing 401 Age / 500 Overworld sampling thresholds, 5% excess allowance, material weights and difficulty controls remain unchanged.
|
||||
|
||||
Player in-game checks passed for both supported versions. Focused machine probes passed 25 checks (1.21.1) / 26 (26.3), dropped-book interaction probes passed 21 / 23, and baseline policy checks passed 14 per version with source-average audits. The 1.21.1 universal-drop probe passed 62 checks. Writing Desk geometry audit passed 126 face checks. These do not claim a separate automated full client/restart matrix.
|
||||
|
||||
The abandoned reference-world generation probes stalled and were stopped without retry. They are superseded by bundled defaults; no generation pass is claimed for them.
|
||||
|
||||
Known issue: [#118](https://git.paddedcell.org/dnorberg/rivencraft/issues/118) continues to track optional Reborn/Seamless crashes and travel disconnects. This release does not fix those failures.
|
||||
@@ -7,7 +7,7 @@ neo_version=26.3.0.99
|
||||
mod_id=rivencraft
|
||||
mod_name=Rivencraft
|
||||
mod_license=LGPL-3.0-or-later
|
||||
mod_version=26.3.0.10
|
||||
mod_version=26.3.0.15
|
||||
|
||||
jei_version=31.17.0.109
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
"symbol.rivencraft.feature.dungeons.description": "Add monster-room dungeon attempts throughout surface noise or Cave terrain, including Nether cave biomes. Not Flat or Void.",
|
||||
"symbol.rivencraft.biome.single.description": "Use one biome across the Age. If omitted, choose an eligible biome from the Age seed.",
|
||||
"symbol.rivencraft.terrain.flat.description": "A level, biome-decorated landscape with its foundation at Y=0.",
|
||||
"symbol.rivencraft.environment.accelerated.description": "Adds extra random block ticks near players in this Age. Repeated pages stack within server tick budgets; does not speed up entities or machines.",
|
||||
"symbol.rivencraft.environment.accelerated.description": "Adds extra random block ticks and server machine ticks in this Age. Repeated pages stack within separate budgets; entities are not accelerated.",
|
||||
"symbol.rivencraft.feature.floating_islands.description": "Add high floating islands alongside noise, Flat, or Void terrain; not Cave terrain.",
|
||||
"symbol.rivencraft.feature.caves.description": "Add extra cave carving to noise terrain, including Cave; not Flat or Void.",
|
||||
"symbol.rivencraft.feature.ravines.description": "Add canyon carving to noise terrain; not Flat or Void. Skips Nether biomes.",
|
||||
|
||||
@@ -20,6 +20,8 @@ public final class PortConfig {
|
||||
public static final ModConfigSpec.EnumValue<ReturnLinkMode> RETURN_LINK_MODE;
|
||||
public static final ModConfigSpec.IntValue ACCELERATED_MAX_CHUNKS;
|
||||
public static final ModConfigSpec.IntValue ACCELERATED_MAX_ATTEMPTS;
|
||||
public static final ModConfigSpec.IntValue ACCELERATED_MACHINE_CANDIDATES;
|
||||
public static final ModConfigSpec.IntValue ACCELERATED_MACHINE_TICKS;
|
||||
|
||||
static {
|
||||
var builder = new ModConfigSpec.Builder();
|
||||
@@ -74,8 +76,12 @@ public final class PortConfig {
|
||||
builder.push("accelerated_age");
|
||||
ACCELERATED_MAX_CHUNKS = builder.comment("Maximum already-loaded player-nearby chunks given extra random ticks per Age tick.")
|
||||
.defineInRange("max_loaded_chunks", 8, 1, 64);
|
||||
ACCELERATED_MAX_ATTEMPTS = builder.comment("Maximum extra random-tick positions sampled per Age tick, shared fairly across loaded sections; zero disables Accelerated.")
|
||||
ACCELERATED_MAX_ATTEMPTS = builder.comment("Maximum extra random-tick positions sampled per Age tick, shared fairly across loaded sections; zero disables extra random ticks.")
|
||||
.defineInRange("max_random_tick_attempts_per_tick", 16384, 0, 65536);
|
||||
ACCELERATED_MACHINE_CANDIDATES = builder.comment("Maximum registered server machine tickers inspected per Age tick; rotates fairly without loading chunks.")
|
||||
.defineInRange("max_machine_candidates_per_tick", 1024, 1, 65536);
|
||||
ACCELERATED_MACHINE_TICKS = builder.comment("Maximum extra machine ticker calls per Age tick, shared round-robin. Each Accelerated page requests one extra tick per machine; zero disables machine acceleration independently of random ticks.")
|
||||
.defineInRange("max_machine_ticks_per_tick", 4096, 0, 65536);
|
||||
builder.pop();
|
||||
net.dnorberg.rivencraft.age.PortInstabilityConfig.define(builder);
|
||||
SPEC = builder.build();
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
||||
/** Extra random block ticks from authored Accelerated pages, bounded to loaded player chunks. */
|
||||
/** Independent bounded random-block and server-machine acceleration in authored Ages. */
|
||||
public final class PortAcceleratedTicks {
|
||||
public static final Identifier PAGE = Identifier.fromNamespaceAndPath("rivencraft", "environment/accelerated");
|
||||
|
||||
@@ -42,9 +42,10 @@ public final class PortAcceleratedTicks {
|
||||
|
||||
static void tick(ServerLevel level) {
|
||||
int maximumAttempts = PortConfig.ACCELERATED_MAX_ATTEMPTS.get();
|
||||
if (maximumAttempts == 0) return;
|
||||
int pages = pages(level);
|
||||
if (pages == 0) return;
|
||||
if (pages == 0 || !level.tickRateManager().runsNormally() || level.tickRateManager().isFrozen()) return;
|
||||
PortMachineTicks.tick(level, pages);
|
||||
if (maximumAttempts == 0) return;
|
||||
|
||||
List<ChunkPos> chunks = loadedPlayerChunks(level);
|
||||
if (chunks.isEmpty()) return;
|
||||
|
||||
@@ -54,6 +54,32 @@ public final class PortBlockInstability {
|
||||
|
||||
private PortBlockInstability() {}
|
||||
|
||||
private static final net.dnorberg.rivencraft.shared.MaterialBaselinePolicy DEFAULT_BASELINE =
|
||||
net.dnorberg.rivencraft.shared.MaterialBaselinePolicy.load(
|
||||
"/assets/rivencraft/instability/default_block_baseline.json");
|
||||
|
||||
public static int baselineSamples(MinecraftServer server) {
|
||||
return PortBlockProfileSavedData.get(server.overworld()).count();
|
||||
}
|
||||
|
||||
public static String baselineStatus(MinecraftServer server) {
|
||||
return "minecraft:overworld; zero counts use bundled defaults, modded ores use iron";
|
||||
}
|
||||
|
||||
private static boolean moddedOre(Identifier id) {
|
||||
if (id.getNamespace().equals("minecraft") || id.getNamespace().equals("rivencraft")
|
||||
|| !BuiltInRegistries.BLOCK.containsKey(id)) return false;
|
||||
var state = BuiltInRegistries.BLOCK.getValue(id).defaultBlockState();
|
||||
return state.is(Tags.BlockItems.ORES.block()) || id.getPath().endsWith("_ore") || id.getPath().contains("_ore_");
|
||||
}
|
||||
|
||||
static double baselineAverage(Identifier id, Map<Identifier, Long> baseline, int chunks) {
|
||||
long iron = baseline.getOrDefault(Identifier.withDefaultNamespace("iron_ore"), 0L)
|
||||
+ baseline.getOrDefault(Identifier.withDefaultNamespace("deepslate_iron_ore"), 0L);
|
||||
return DEFAULT_BASELINE.average(id.toString(), baseline.getOrDefault(id, 0L),
|
||||
chunks, moddedOre(id), iron);
|
||||
}
|
||||
|
||||
/** Track recognized materials from installed mods without requiring any mod-specific API. */
|
||||
static boolean tracked(Identifier id) {
|
||||
if (VANILLA_WEIGHTS.containsKey(id)) return true;
|
||||
@@ -164,7 +190,7 @@ public final class PortBlockInstability {
|
||||
GENERATION_IN_FLIGHT.remove(event.getServer());
|
||||
}
|
||||
|
||||
/** Generate at most one chunk per second across the active Age and its Overworld baseline. */
|
||||
/** Generate at most one chunk per second across active Ages and the Overworld baseline. */
|
||||
private static void generateNextSpawnSample(MinecraftServer server) {
|
||||
if (GENERATION_IN_FLIGHT.containsKey(server)) return;
|
||||
List<SampleTarget> targets = new ArrayList<>();
|
||||
@@ -178,8 +204,8 @@ public final class PortBlockInstability {
|
||||
PortBlockProfileSavedData.MIN_AGE_SAMPLES));
|
||||
}
|
||||
if (targets.isEmpty()) return;
|
||||
ServerLevel overworld = server.overworld();
|
||||
targets.add(0, new SampleTarget(overworld, overworld.getRespawnData().pos(),
|
||||
ServerLevel baseline = server.overworld();
|
||||
targets.add(0, new SampleTarget(baseline, baseline.getRespawnData().pos(),
|
||||
PortBlockProfileSavedData.MIN_BASELINE_SAMPLES));
|
||||
int first = Math.floorMod(NEXT_TARGET.getOrDefault(server, 0), targets.size());
|
||||
for (int offset = 0; offset < targets.size(); offset++) {
|
||||
@@ -261,7 +287,7 @@ public final class PortBlockInstability {
|
||||
double weight = weight(id);
|
||||
if (weight <= 0) continue;
|
||||
double excess = age.getOrDefault(id, 0L) / (double) ageChunks
|
||||
- 1.05 * baseline.getOrDefault(id, 0L) / (double) baselineChunks;
|
||||
- 1.05 * baselineAverage(id, baseline, baselineChunks);
|
||||
if (excess > 0) result += excess * weight;
|
||||
}
|
||||
return (int) Math.min(100_000, Math.round(result));
|
||||
|
||||
@@ -32,7 +32,8 @@ public final class PortInstabilityCommands {
|
||||
+ "; effective score=" + PortInstabilityRuntime.effectiveScore(level)
|
||||
+ "; difficulty=" + PortInstabilityConfig.instabilityDifficulty()
|
||||
+ "; samples Age=" + PortBlockInstability.sampledChunks(level) + "/" + PortBlockProfileSavedData.MIN_AGE_SAMPLES
|
||||
+ ", Overworld=" + PortBlockInstability.sampledChunks(source.getServer().overworld()) + "/" + PortBlockProfileSavedData.MIN_BASELINE_SAMPLES
|
||||
+ ", baseline=" + PortBlockInstability.baselineSamples(source.getServer()) + "/" + PortBlockProfileSavedData.MIN_BASELINE_SAMPLES
|
||||
+ " [" + PortBlockInstability.baselineStatus(source.getServer()) + "]"
|
||||
+ "; profiling=" + PortInstabilityData.get(source.getServer()).supportsProfiling(level)), false);
|
||||
for (var cost : age.contributions()) source.sendSuccess(() -> Component.literal(
|
||||
" " + cost.reason() + " page=" + cost.page() + " +" + cost.points()), false);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.dnorberg.rivencraft.age;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import net.dnorberg.rivencraft.PortConfig;
|
||||
import net.dnorberg.rivencraft.mixin.LevelBlockEntityTickersAccessor;
|
||||
import net.dnorberg.rivencraft.shared.AcceleratedMachineWork;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
|
||||
/** Reuses vanilla/NeoForge bound tickers, including modded server machines. */
|
||||
public final class PortMachineTicks {
|
||||
private static final Map<ServerLevel, AcceleratedMachineWork> WORK = new WeakHashMap<>();
|
||||
private PortMachineTicks() {}
|
||||
|
||||
public static void tick(ServerLevel level, int pages) {
|
||||
if (pages <= 0 || !level.tickRateManager().runsNormally() || level.tickRateManager().isFrozen()) return;
|
||||
WORK.computeIfAbsent(level, ignored -> new AcceleratedMachineWork()).run(
|
||||
((LevelBlockEntityTickersAccessor) level).rivencraft$blockEntityTickers(),
|
||||
pages, PortConfig.ACCELERATED_MACHINE_CANDIDATES.get(), PortConfig.ACCELERATED_MACHINE_TICKS.get(),
|
||||
ticker -> eligible(level, ticker), TickingBlockEntity::tick);
|
||||
}
|
||||
|
||||
private static boolean eligible(ServerLevel level, TickingBlockEntity ticker) {
|
||||
var pos = ticker.getPos();
|
||||
return level.tickRateManager().runsNormally() && !level.tickRateManager().isFrozen() && !ticker.isRemoved()
|
||||
&& level.getWorldBorder().isWithinBounds(pos)
|
||||
&& level.hasChunkAt(pos) && level.shouldTickBlocksAt(pos);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public final class AgeCatalogClient {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(RegisterClientPayloadHandlersEvent event) {
|
||||
event.register(net.dnorberg.rivencraft.network.OpenDroppedBookScreenPayload.TYPE, ClientDroppedBooks::open);
|
||||
event.register(net.dnorberg.rivencraft.network.BookPreviewPayload.TYPE, (payload, context) -> PortBookPreview.accept(payload));
|
||||
event.register(net.dnorberg.rivencraft.network.WritingDeskCatalogPayload.TYPE, ClientWritingDeskCatalog::handle);
|
||||
event.register(net.dnorberg.rivencraft.network.SereneAgeWhitelistPayload.TYPE, (payload, context) ->
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.dnorberg.rivencraft.client;
|
||||
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.dnorberg.rivencraft.network.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.neoforged.neoforge.client.network.ClientPacketDistributor;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
|
||||
public final class ClientDroppedBooks {
|
||||
private ClientDroppedBooks() {}
|
||||
public static boolean present(DroppedBookActionPayload source) {
|
||||
var mc = Minecraft.getInstance();
|
||||
var entity = mc.level == null ? null : mc.level.getEntity(source.entityId());
|
||||
return mc.player != null && entity instanceof net.dnorberg.rivencraft.entity.DroppedBookEntity
|
||||
&& !entity.isRemoved() && entity.getUUID().equals(source.entityUuid())
|
||||
&& mc.player.distanceToSqr(entity) <= 64;
|
||||
}
|
||||
public static void send(DroppedBookActionPayload source, DroppedBookActionPayload.Action action, String title) {
|
||||
ClientPacketDistributor.sendToServer(source.action(action, title, false));
|
||||
}
|
||||
public static void open(OpenDroppedBookScreenPayload payload, IPayloadContext context) {
|
||||
context.enqueueWork(() -> {
|
||||
var source = payload.source();
|
||||
if (!present(source)) return;
|
||||
if (source.book().is(Rivencraft.LINKING_BOOK.get()))
|
||||
Minecraft.getInstance().gui.setScreen(new PortLinkingBookScreen(source));
|
||||
else if (source.book().is(Rivencraft.DESCRIPTIVE_BOOK.get()))
|
||||
Minecraft.getInstance().gui.setScreen(new PortDescriptiveBookScreen(source));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -30,10 +30,15 @@ public final class PortBookPreview {
|
||||
private net.minecraft.resources.Identifier destination;
|
||||
|
||||
PortBookPreview(InteractionHand hand, ItemStack book, UseBookStandPayload stand) {
|
||||
this(hand, book, stand, null);
|
||||
}
|
||||
|
||||
PortBookPreview(InteractionHand hand, ItemStack book, UseBookStandPayload stand, DroppedBookActionPayload dropped) {
|
||||
var minecraft = Minecraft.getInstance();
|
||||
request = minecraft.level == null ? null : new RequestBookPreviewPayload(session,
|
||||
hand == InteractionHand.OFF_HAND, stand != null, minecraft.level.dimension().identifier(),
|
||||
stand == null ? BlockPos.ZERO : stand.pos(), book.copy());
|
||||
stand == null ? BlockPos.ZERO : stand.pos(), book.copy(),
|
||||
dropped == null ? null : dropped.entityUuid());
|
||||
boolean enabled = ImmersiveBookPreviews.bookViewsEnabled();
|
||||
live = enabled ? new ImmersiveLiveBookPanel() : null;
|
||||
if (active != null) active.close();
|
||||
|
||||
+17
-4
@@ -31,6 +31,7 @@ public final class PortDescriptiveBookScreen extends Screen {
|
||||
private final net.dnorberg.rivencraft.writing.DescriptiveBookPages pages;
|
||||
private int pageIndex;
|
||||
private net.dnorberg.rivencraft.network.UseBookStandPayload standSource;
|
||||
private net.dnorberg.rivencraft.network.DroppedBookActionPayload droppedSource;
|
||||
private EditBox titleInput;
|
||||
|
||||
public PortDescriptiveBookScreen(InteractionHand hand, ItemStack book) {
|
||||
@@ -47,11 +48,16 @@ public final class PortDescriptiveBookScreen extends Screen {
|
||||
standSource = source;
|
||||
}
|
||||
|
||||
public PortDescriptiveBookScreen(net.dnorberg.rivencraft.network.DroppedBookActionPayload source) {
|
||||
this(InteractionHand.MAIN_HAND, source.book());
|
||||
droppedSource = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
if (bound) {
|
||||
linkPanel.open(hand, book, standSource);
|
||||
exploration.attach(this, this::addRenderableWidget, (width - WIDTH) / 2, (height - HEIGHT) / 2, standSource != null);
|
||||
linkPanel.open(hand, book, standSource, droppedSource);
|
||||
exploration.attach(this, this::addRenderableWidget, (width - WIDTH) / 2, (height - HEIGHT) / 2, standSource != null || droppedSource != null);
|
||||
return;
|
||||
}
|
||||
if (standSource != null) return;
|
||||
@@ -151,7 +157,9 @@ public final class PortDescriptiveBookScreen extends Screen {
|
||||
int direction = PortLegacyBookArtwork.turnDirection(event.x() - left, event.y() - top, pageIndex, pages.lastPage());
|
||||
if (direction != 0) { turnPage(direction); return true; }
|
||||
if (bound && pageIndex == 0 && PortLegacyLinkPanel.contains(event.x() - left, event.y() - top)) {
|
||||
if (standSource != null) ClientPacketDistributor.sendToServer(standSource);
|
||||
if (droppedSource != null) ClientDroppedBooks.send(droppedSource,
|
||||
net.dnorberg.rivencraft.network.DroppedBookActionPayload.Action.USE, "");
|
||||
else if (standSource != null) ClientPacketDistributor.sendToServer(standSource);
|
||||
else ClientPacketDistributor.sendToServer(new UseDescriptiveBookPayload(hand == InteractionHand.OFF_HAND));
|
||||
onClose();
|
||||
return true;
|
||||
@@ -187,6 +195,9 @@ public final class PortDescriptiveBookScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override public void tick() {
|
||||
if (droppedSource != null && !ClientDroppedBooks.present(droppedSource)) {
|
||||
onClose(); return;
|
||||
}
|
||||
if (bound) linkPanel.tick();
|
||||
exploration.tick(pageIndex == 0);
|
||||
}
|
||||
@@ -202,7 +213,9 @@ public final class PortDescriptiveBookScreen extends Screen {
|
||||
if (titleInput == null) return;
|
||||
String name = titleInput.getValue().strip();
|
||||
if (name.isEmpty()) return;
|
||||
ClientPacketDistributor.sendToServer(new BindDescriptiveBookPayload(hand == InteractionHand.OFF_HAND, name));
|
||||
if (droppedSource != null) ClientDroppedBooks.send(droppedSource,
|
||||
net.dnorberg.rivencraft.network.DroppedBookActionPayload.Action.BIND, name);
|
||||
else ClientPacketDistributor.sendToServer(new BindDescriptiveBookPayload(hand == InteractionHand.OFF_HAND, name));
|
||||
onClose();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,12 @@ final class PortLegacyLinkPanel {
|
||||
private PortBookPreview preview;
|
||||
void open(net.minecraft.world.InteractionHand hand, net.minecraft.world.item.ItemStack book,
|
||||
net.dnorberg.rivencraft.network.UseBookStandPayload stand) {
|
||||
if (preview == null) preview = new PortBookPreview(hand, book, stand);
|
||||
open(hand, book, stand, null);
|
||||
}
|
||||
void open(net.minecraft.world.InteractionHand hand, net.minecraft.world.item.ItemStack book,
|
||||
net.dnorberg.rivencraft.network.UseBookStandPayload stand,
|
||||
net.dnorberg.rivencraft.network.DroppedBookActionPayload dropped) {
|
||||
if (preview == null) preview = new PortBookPreview(hand, book, stand, dropped);
|
||||
}
|
||||
void close() { if (preview != null) { preview.close(); preview = null; } }
|
||||
boolean canExplore() { return preview != null && preview.canExplore(); }
|
||||
|
||||
+17
-4
@@ -32,6 +32,7 @@ public final class PortLinkingBookScreen extends Screen {
|
||||
private final PortLegacyLinkPanel linkPanel = new PortLegacyLinkPanel();
|
||||
private final PortBookExploration exploration = new PortBookExploration(linkPanel);
|
||||
private net.dnorberg.rivencraft.network.UseBookStandPayload standSource;
|
||||
private net.dnorberg.rivencraft.network.DroppedBookActionPayload droppedSource;
|
||||
private EditBox titleInput;
|
||||
|
||||
public PortLinkingBookScreen(InteractionHand hand, ItemStack book) {
|
||||
@@ -52,11 +53,16 @@ public final class PortLinkingBookScreen extends Screen {
|
||||
standSource = source;
|
||||
}
|
||||
|
||||
public PortLinkingBookScreen(net.dnorberg.rivencraft.network.DroppedBookActionPayload source) {
|
||||
this(InteractionHand.MAIN_HAND, source.book());
|
||||
droppedSource = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
if (bound) {
|
||||
linkPanel.open(hand, book, standSource);
|
||||
exploration.attach(this, this::addRenderableWidget, (width - WIDTH) / 2, (height - HEIGHT) / 2, standSource != null);
|
||||
linkPanel.open(hand, book, standSource, droppedSource);
|
||||
exploration.attach(this, this::addRenderableWidget, (width - WIDTH) / 2, (height - HEIGHT) / 2, standSource != null || droppedSource != null);
|
||||
return;
|
||||
}
|
||||
if (standSource != null) return;
|
||||
@@ -119,7 +125,9 @@ public final class PortLinkingBookScreen extends Screen {
|
||||
int direction = PortLegacyBookArtwork.turnDirection(event.x() - left, event.y() - top, pageIndex, 1);
|
||||
if (direction != 0) { turnPage(direction); return true; }
|
||||
if (bound && pageIndex == 0 && PortLegacyLinkPanel.contains(event.x() - left, event.y() - top)) {
|
||||
if (standSource != null) ClientPacketDistributor.sendToServer(standSource);
|
||||
if (droppedSource != null) ClientDroppedBooks.send(droppedSource,
|
||||
net.dnorberg.rivencraft.network.DroppedBookActionPayload.Action.USE, "");
|
||||
else if (standSource != null) ClientPacketDistributor.sendToServer(standSource);
|
||||
else ClientPacketDistributor.sendToServer(new UseLinkingBookPayload(hand == InteractionHand.OFF_HAND));
|
||||
onClose();
|
||||
return true;
|
||||
@@ -152,6 +160,9 @@ public final class PortLinkingBookScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override public void tick() {
|
||||
if (droppedSource != null && !ClientDroppedBooks.present(droppedSource)) {
|
||||
onClose(); return;
|
||||
}
|
||||
if (bound) linkPanel.tick();
|
||||
exploration.tick(pageIndex == 0);
|
||||
}
|
||||
@@ -167,7 +178,9 @@ public final class PortLinkingBookScreen extends Screen {
|
||||
if (titleInput == null) return;
|
||||
String name = titleInput.getValue().strip();
|
||||
if (name.isEmpty()) return;
|
||||
ClientPacketDistributor.sendToServer(new BindLinkingBookPayload(hand == InteractionHand.OFF_HAND, name));
|
||||
if (droppedSource != null) ClientDroppedBooks.send(droppedSource,
|
||||
net.dnorberg.rivencraft.network.DroppedBookActionPayload.Action.BIND, name);
|
||||
else ClientPacketDistributor.sendToServer(new BindLinkingBookPayload(hand == InteractionHand.OFF_HAND, name));
|
||||
onClose();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,18 +14,20 @@ import net.minecraft.client.renderer.item.ItemStackRenderState;
|
||||
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.dnorberg.rivencraft.shared.WritingDeskDisplayModel;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.client.renderer.rendertype.RenderTypes;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/** The existing selected-page and white-paper display, extracted for 26.3. */
|
||||
public final class WritingDeskRenderer implements BlockEntityRenderer<WritingDeskBlockEntity, WritingDeskRenderer.State> {
|
||||
private static final Identifier TEXTURE = Identifier.fromNamespaceAndPath(
|
||||
"rivencraft", "textures/block/writing_desk.png");
|
||||
private final ItemModelResolver resolver;
|
||||
public WritingDeskRenderer(BlockEntityRendererProvider.Context context) { resolver = context.itemModelResolver(); }
|
||||
public static final class State extends BlockEntityRenderState {
|
||||
final ItemStackRenderState paper = new ItemStackRenderState();
|
||||
final ItemStackRenderState page = new ItemStackRenderState();
|
||||
int layers;
|
||||
int paperCount;
|
||||
float rotation;
|
||||
}
|
||||
@Override public State createRenderState() { return new State(); }
|
||||
@@ -33,18 +35,31 @@ public final class WritingDeskRenderer implements BlockEntityRenderer<WritingDes
|
||||
Vec3 camera, ModelFeatureRenderer.CrumblingOverlay overlay) {
|
||||
BlockEntityRenderer.super.extractRenderState(desk, state, partialTick, camera, overlay);
|
||||
int count = desk.getItem(WritingDeskBlockEntity.PAPER).getCount();
|
||||
state.layers = count == 0 ? 0 : Math.min(4, 1 + count / 16);
|
||||
state.paperCount = count;
|
||||
state.rotation = 180 - desk.getBlockState().getValue(WritingDeskBlock.FACING).toYRot();
|
||||
resolver.updateForTopItem(state.paper, new ItemStack(Items.PAPER), ItemDisplayContext.FIXED, desk.getLevel(), null, 0);
|
||||
resolver.updateForTopItem(state.page, desk.displayPage(), ItemDisplayContext.FIXED, desk.getLevel(), null, 0);
|
||||
}
|
||||
@Override public void submit(State state, PoseStack pose, SubmitNodeCollector collector, CameraRenderState camera) {
|
||||
pose.pushPose();
|
||||
pose.translate(0.5, 0, 0.5);
|
||||
pose.rotateDegrees(Axis.YP, state.rotation);
|
||||
for (int i = 0; i < state.layers; i++) draw(state.paper, pose, collector, state.lightCoords,
|
||||
1.22, 0.27 + i * 0.008, -0.14, 0.55F);
|
||||
if (!state.page.isEmpty()) draw(state.page, pose, collector, state.lightCoords, 1.0, 0.572, 0, 0.8F);
|
||||
var faces = WritingDeskDisplayModel.paper(state.paperCount);
|
||||
if (!faces.isEmpty()) {
|
||||
int light = state.lightCoords;
|
||||
collector.submitCustomGeometry(pose, RenderTypes.entitySolid(TEXTURE), (matrix, vertices) -> {
|
||||
for (var face : faces) {
|
||||
for (var vertex : face.vertices()) {
|
||||
vertices.addVertex(matrix, vertex.x(), vertex.y(), vertex.z())
|
||||
.setColor(face.color()).setUv(vertex.u(), vertex.v())
|
||||
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(light)
|
||||
.setNormal(matrix, face.nx(), face.ny(), face.nz());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!state.page.isEmpty()) draw(state.page, pose, collector, state.lightCoords,
|
||||
WritingDeskDisplayModel.PAGE_X, WritingDeskDisplayModel.PAGE_Y,
|
||||
WritingDeskDisplayModel.PAGE_Z, WritingDeskDisplayModel.PAGE_SCALE);
|
||||
pose.popPose();
|
||||
}
|
||||
private static void draw(ItemStackRenderState item, PoseStack pose, SubmitNodeCollector collector,
|
||||
|
||||
@@ -40,6 +40,7 @@ final class ImmersivePreviewChunks {
|
||||
if (previous != null && previous.session().equals(request.session())
|
||||
&& previous.source().offhand() == request.offhand()
|
||||
&& previous.source().fromStand() == request.fromStand()
|
||||
&& java.util.Objects.equals(previous.source().droppedBook(), request.droppedBook())
|
||||
&& previous.source().sourceDimension().equals(request.sourceDimension())
|
||||
&& previous.source().standPos().equals(request.standPos())
|
||||
&& ItemStack.matches(previous.source().book(), request.book())) {
|
||||
@@ -80,6 +81,13 @@ final class ImmersivePreviewChunks {
|
||||
|
||||
private static ItemStack validated(ServerPlayer player, RequestBookPreviewPayload request) {
|
||||
if (!player.level().dimension().identifier().equals(request.sourceDimension()) || !player.isAlive()) return ItemStack.EMPTY;
|
||||
if (request.droppedBook() != null) {
|
||||
var entity = player.level().getEntity(request.droppedBook());
|
||||
if (!(entity instanceof net.dnorberg.rivencraft.entity.DroppedBookEntity dropped)) return ItemStack.EMPTY;
|
||||
var validated = net.dnorberg.rivencraft.entity.DroppedBookEntity.validated(
|
||||
player, dropped.getId(), request.droppedBook(), request.book());
|
||||
return validated == null ? ItemStack.EMPTY : validated.getItem();
|
||||
}
|
||||
if (request.fromStand()) return PortBookNetworking.validatedStandBook(player,
|
||||
new net.dnorberg.rivencraft.network.UseBookStandPayload(request.sourceDimension(), request.standPos(), request.book()));
|
||||
ItemStack held = player.getItemInHand(request.offhand() ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND);
|
||||
|
||||
@@ -37,6 +37,37 @@ public final class DroppedBookEntity extends ItemEntity {
|
||||
return book;
|
||||
}
|
||||
|
||||
/** Contact must never take a book away from its world GUI. */
|
||||
@Override public void playerTouch(net.minecraft.world.entity.player.Player player) {}
|
||||
|
||||
@Override public boolean isPickable() { return !isRemoved() && !getItem().isEmpty(); }
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.InteractionResult interact(net.minecraft.world.entity.player.Player player,
|
||||
net.minecraft.world.InteractionHand hand, Vec3 hit) {
|
||||
if (level().isClientSide()) return net.minecraft.world.InteractionResult.SUCCESS;
|
||||
if (!(player instanceof net.minecraft.server.level.ServerPlayer serverPlayer)
|
||||
|| !player.isAlive() || player.isSpectator() || player.distanceToSqr(this) > 64
|
||||
|| isRemoved() || getItem().isEmpty()) return net.minecraft.world.InteractionResult.PASS;
|
||||
if (player.isShiftKeyDown()) {
|
||||
// Explicit interaction uses normal ownership, delay, inventory and NeoForge pickup hooks.
|
||||
super.playerTouch(player);
|
||||
} else {
|
||||
net.dnorberg.rivencraft.network.PortBookNetworking.openDroppedBook(serverPlayer, this);
|
||||
}
|
||||
return net.minecraft.world.InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
/** Only the nearby, still-present world book can authorize an action or preview. */
|
||||
public static DroppedBookEntity validated(net.minecraft.server.level.ServerPlayer player,
|
||||
int id, java.util.UUID uuid, ItemStack expected) {
|
||||
var entity = player.level().getEntity(id);
|
||||
return player.isAlive() && !player.isSpectator()
|
||||
&& entity instanceof DroppedBookEntity book && !book.isRemoved() && !book.getItem().isEmpty() && book.isAddedToLevel()
|
||||
&& book.getUUID().equals(uuid) && player.distanceToSqr(book) <= 64
|
||||
&& ItemStack.matches(book.getItem(), expected) ? book : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package net.dnorberg.rivencraft.mixin;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(Level.class)
|
||||
public interface LevelBlockEntityTickersAccessor {
|
||||
@Accessor("blockEntityTickers")
|
||||
List<TickingBlockEntity> rivencraft$blockEntityTickers();
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package net.dnorberg.rivencraft.network;
|
||||
|
||||
import java.util.UUID;
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
/** The stack is an expected identity, never an authoritative destination. */
|
||||
public record DroppedBookActionPayload(int entityId, UUID entityUuid, ItemStack book,
|
||||
Action action, String title, boolean immersive) implements CustomPacketPayload {
|
||||
public enum Action { USE, BIND, PREVIEW }
|
||||
public static final Type<DroppedBookActionPayload> TYPE = new Type<>(
|
||||
Identifier.fromNamespaceAndPath(Rivencraft.MOD_ID, "dropped_book_action"));
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, DroppedBookActionPayload> STREAM_CODEC =
|
||||
StreamCodec.of((buf, value) -> {
|
||||
buf.writeVarInt(value.entityId()); buf.writeUUID(value.entityUuid());
|
||||
ItemStack.STREAM_CODEC.encode(buf, value.book()); buf.writeEnum(value.action());
|
||||
buf.writeUtf(value.title(), 32); buf.writeBoolean(value.immersive());
|
||||
}, buf -> new DroppedBookActionPayload(buf.readVarInt(), buf.readUUID(),
|
||||
ItemStack.STREAM_CODEC.decode(buf), buf.readEnum(Action.class),
|
||||
buf.readUtf(32), buf.readBoolean()));
|
||||
public DroppedBookActionPayload action(Action action, String title, boolean immersive) {
|
||||
return new DroppedBookActionPayload(entityId, entityUuid, book.copy(), action, title, immersive);
|
||||
}
|
||||
@Override public Type<? extends CustomPacketPayload> type() { return TYPE; }
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package net.dnorberg.rivencraft.network;
|
||||
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.Identifier;
|
||||
|
||||
public record OpenDroppedBookScreenPayload(DroppedBookActionPayload source) implements CustomPacketPayload {
|
||||
public static final Type<OpenDroppedBookScreenPayload> TYPE = new Type<>(
|
||||
Identifier.fromNamespaceAndPath(Rivencraft.MOD_ID,"open_dropped_book"));
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, OpenDroppedBookScreenPayload> STREAM_CODEC =
|
||||
StreamCodec.of((buf,value)->{ DroppedBookActionPayload.STREAM_CODEC.encode(buf,value.source()); },
|
||||
buf->new OpenDroppedBookScreenPayload(DroppedBookActionPayload.STREAM_CODEC.decode(buf)));
|
||||
@Override public Type<? extends CustomPacketPayload> type() { return TYPE; }
|
||||
}
|
||||
@@ -32,7 +32,12 @@ public final class PortBookNetworking {
|
||||
}
|
||||
|
||||
public static void registerPayloads(RegisterPayloadHandlersEvent event) {
|
||||
var registrar = event.registrar("1");
|
||||
var registrar = event.registrar("2");
|
||||
registrar.playToClient(OpenDroppedBookScreenPayload.TYPE, OpenDroppedBookScreenPayload.STREAM_CODEC);
|
||||
registrar.playToServer(DroppedBookActionPayload.TYPE, DroppedBookActionPayload.STREAM_CODEC,
|
||||
(payload, context) -> {
|
||||
if (context.player() instanceof ServerPlayer player) droppedBookAction(player, payload);
|
||||
});
|
||||
registrar.playToClient(BookPreviewPayload.TYPE, BookPreviewPayload.STREAM_CODEC);
|
||||
registrar.playToServer(RequestBookPreviewPayload.TYPE, RequestBookPreviewPayload.STREAM_CODEC,
|
||||
(payload, context) -> {
|
||||
@@ -96,9 +101,12 @@ public final class PortBookNetworking {
|
||||
}
|
||||
|
||||
private static void bind(ServerPlayer player, BindLinkingBookPayload payload) {
|
||||
ItemStack stack = player.getItemInHand(hand(payload.offhand()));
|
||||
bindLinking(player, player.getItemInHand(hand(payload.offhand())), payload.title());
|
||||
}
|
||||
|
||||
private static void bindLinking(ServerPlayer player, ItemStack stack, String requestedTitle) {
|
||||
if (!stack.is(Rivencraft.LINKING_BOOK.get()) || stack.has(Rivencraft.LINK_BOOK_TARGET.get())) return;
|
||||
String title = payload.title().strip();
|
||||
String title = requestedTitle.strip();
|
||||
if (title.isEmpty() || title.length() > MAX_BOOK_TITLE_LENGTH) return;
|
||||
stack.set(Rivencraft.LINK_BOOK_TARGET.get(), LinkBookTarget.at(player));
|
||||
stack.set(Rivencraft.LINK_DESTINATION_NAME.get(), LinkingBookItem.destinationName(player.level()));
|
||||
@@ -118,9 +126,12 @@ public final class PortBookNetworking {
|
||||
}
|
||||
|
||||
private static void bindAge(ServerPlayer player, BindDescriptiveBookPayload payload) {
|
||||
ItemStack stack = player.getItemInHand(hand(payload.offhand()));
|
||||
bindDescriptive(player, player.getItemInHand(hand(payload.offhand())), payload.title());
|
||||
}
|
||||
|
||||
private static void bindDescriptive(ServerPlayer player, ItemStack stack, String requestedTitle) {
|
||||
if (!stack.is(Rivencraft.DESCRIPTIVE_BOOK.get()) || stack.has(Rivencraft.AGE_BOOK_ID.get())) return;
|
||||
String title = payload.title().strip();
|
||||
String title = requestedTitle.strip();
|
||||
if (title.isEmpty() || title.length() > MAX_BOOK_TITLE_LENGTH) return;
|
||||
Identifier id = createAge(player, title);
|
||||
if (id == null) return;
|
||||
@@ -253,6 +264,34 @@ public final class PortBookNetworking {
|
||||
}
|
||||
}
|
||||
|
||||
public static void openDroppedBook(ServerPlayer player, net.dnorberg.rivencraft.entity.DroppedBookEntity entity) {
|
||||
var source = new DroppedBookActionPayload(entity.getId(), entity.getUUID(), entity.getItem().copy(),
|
||||
DroppedBookActionPayload.Action.USE, "", false);
|
||||
net.neoforged.neoforge.network.PacketDistributor.sendToPlayer(player, new OpenDroppedBookScreenPayload(source));
|
||||
}
|
||||
|
||||
public static void droppedBookAction(ServerPlayer player, DroppedBookActionPayload payload) {
|
||||
var entity = net.dnorberg.rivencraft.entity.DroppedBookEntity.validated(
|
||||
player, payload.entityId(), payload.entityUuid(), payload.book());
|
||||
if (entity == null) return;
|
||||
var stack = entity.getItem();
|
||||
switch (payload.action()) {
|
||||
case USE -> {
|
||||
if (stack.is(Rivencraft.LINKING_BOOK.get())) {
|
||||
String failure = LinkingBookItem.travel(player, stack);
|
||||
if (failure != null) player.sendOverlayMessage(Component.literal(failure));
|
||||
else net.dnorberg.rivencraft.advancement.ProgressionAdvancements.awardAgeTravel(player);
|
||||
} else if (stack.is(Rivencraft.DESCRIPTIVE_BOOK.get())) travelDescriptive(player, stack, null);
|
||||
}
|
||||
case BIND -> {
|
||||
if (stack.is(Rivencraft.LINKING_BOOK.get())) bindLinking(player, stack, payload.title());
|
||||
else if (stack.is(Rivencraft.DESCRIPTIVE_BOOK.get())) bindDescriptive(player, stack, payload.title());
|
||||
entity.setItem(stack.copy());
|
||||
}
|
||||
case PREVIEW -> { /* Live views use the existing session-bound preview request. */ }
|
||||
}
|
||||
}
|
||||
|
||||
private static InteractionHand hand(boolean offhand) {
|
||||
return offhand ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
|
||||
}
|
||||
|
||||
+10
-3
@@ -9,16 +9,23 @@ import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
/** The server verifies the actual held/stand book, never a client-supplied destination. */
|
||||
/** The server verifies the actual held, stand or dropped book, never a client-supplied destination. */
|
||||
public record RequestBookPreviewPayload(UUID session, boolean offhand, boolean fromStand,
|
||||
Identifier sourceDimension, BlockPos standPos, ItemStack book) implements CustomPacketPayload {
|
||||
Identifier sourceDimension, BlockPos standPos, ItemStack book, UUID droppedBook) implements CustomPacketPayload {
|
||||
public RequestBookPreviewPayload(UUID session, boolean offhand, boolean fromStand,
|
||||
Identifier dimension, BlockPos pos, ItemStack book) {
|
||||
this(session, offhand, fromStand, dimension, pos, book, null);
|
||||
}
|
||||
public static final Type<RequestBookPreviewPayload> TYPE = new Type<>(Identifier.fromNamespaceAndPath(Rivencraft.MOD_ID, "request_book_preview"));
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, RequestBookPreviewPayload> STREAM_CODEC = StreamCodec.of(
|
||||
(buf, value) -> {
|
||||
buf.writeUUID(value.session()); buf.writeBoolean(value.offhand()); buf.writeBoolean(value.fromStand());
|
||||
Identifier.STREAM_CODEC.encode(buf, value.sourceDimension());
|
||||
BlockPos.STREAM_CODEC.encode(buf, value.standPos()); ItemStack.STREAM_CODEC.encode(buf, value.book());
|
||||
buf.writeBoolean(value.droppedBook() != null);
|
||||
if (value.droppedBook() != null) buf.writeUUID(value.droppedBook());
|
||||
}, buf -> new RequestBookPreviewPayload(buf.readUUID(), buf.readBoolean(), buf.readBoolean(),
|
||||
Identifier.STREAM_CODEC.decode(buf), BlockPos.STREAM_CODEC.decode(buf), ItemStack.STREAM_CODEC.decode(buf)));
|
||||
Identifier.STREAM_CODEC.decode(buf), BlockPos.STREAM_CODEC.decode(buf), ItemStack.STREAM_CODEC.decode(buf),
|
||||
buf.readBoolean() ? buf.readUUID() : null));
|
||||
@Override public Type<RequestBookPreviewPayload> type() { return TYPE; }
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"minecraft_version": "26.3",
|
||||
"source_sample_count": 1024,
|
||||
"source_sha256": "07a9989118b5079f75e9c03d04126b82509555082829a8f610481add9740a162",
|
||||
"blocks_per_chunk": {
|
||||
"minecraft:coal_ore": 95.7587890625,
|
||||
"minecraft:deepslate_coal_ore": 0.642578125,
|
||||
"minecraft:deepslate_diamond_ore": 24.1845703125,
|
||||
"minecraft:deepslate_emerald_ore": 0.03125,
|
||||
"minecraft:deepslate_gold_ore": 21.470703125,
|
||||
"minecraft:deepslate_iron_ore": 24.6806640625,
|
||||
"minecraft:deepslate_lapis_ore": 13.30078125,
|
||||
"minecraft:deepslate_redstone_ore": 32.9697265625,
|
||||
"minecraft:diamond_ore": 0.4580078125,
|
||||
"minecraft:emerald_ore": 0.6337890625,
|
||||
"minecraft:gold_ore": 4.158203125,
|
||||
"minecraft:iron_ore": 51.85546875,
|
||||
"minecraft:lapis_ore": 11.046875,
|
||||
"minecraft:raw_iron_block": 0.0390625,
|
||||
"minecraft:redstone_ore": 3.0068359375,
|
||||
"rivencraft:crystal_block": 0.015625
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@
|
||||
"AgeDayTimelineMixin",
|
||||
"RuinsDimensionMixin",
|
||||
"RuinsTemplateDimensionMixin",
|
||||
"RuinsAttemptMixin"
|
||||
"RuinsAttemptMixin",
|
||||
"LevelBlockEntityTickersAccessor"
|
||||
],
|
||||
"client": [
|
||||
"StaticSkyStateMixin",
|
||||
|
||||
Reference in new issue
Block a user