Skip to content

Commit

Permalink
Book pile improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdAurora committed Aug 13, 2023
1 parent 72b399e commit 9c84bb3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,9 @@
- Fixed render rules model injection issues.
- Fixed shelves not respecting locks (NBT property `Lock`).

### 1.0.0-beta.21

- Fixed multiplayer synchronization issues with book piles.
- Made book pile unmodifiable for players in adventure game mode.

[EMI]: https://modrinth.com/mod/emi "EMI Modrinth page"
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx1G

# Mod properties
mod_version=1.0.0-beta.20
mod_version=1.0.0-beta.21
maven_group=dev.lambdaurora
archives_base_name=aurorasdecorations
modrinth_id=GOqAnOfW
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
BlockHitResult hit) {
var stack = player.getStackInHand(hand);

if (!player.getAbilities().allowModifyWorld) {
return ActionResult.PASS;
}

if (stack.isOf(Items.BOOK) || stack.isOf(Items.ENCHANTED_BOOK)) {
var bookPile = AurorasDecoRegistry.BOOK_PILE_BLOCK_ENTITY_TYPE.get(world, pos);
if (bookPile != null && !bookPile.isFull()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void insertBook(ItemStack stack) {
copy.setCount(1);
this.books.set(i, copy);

this.markDirty();
this.attemptToSync();
return;
}
}
Expand All @@ -65,11 +65,20 @@ public ItemStack removeBook(int slot) {
var copy = stack.copy();
if (!stack.isEmpty()) {
stack.setCount(0);
this.markDirty();
this.attemptToSync();
}
return copy;
}

/* Sync */

private void attemptToSync() {
if (this.world != null && !this.world.isClient()) {
this.markDirty();
this.sync();
}
}

/* Serialization */

@Override
Expand Down

0 comments on commit 9c84bb3

Please sign in to comment.