Skip to content

Commit

Permalink
Fix: Item display block cannot rotate.
Browse files Browse the repository at this point in the history
Took 15 minutes
  • Loading branch information
xkball committed Oct 15, 2024
1 parent 5664944 commit 634f6db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod_name=Power Tool
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPL-3.0
# The mod version. See https://semver.org/
mod_version=1.4.17
mod_version=1.4.18
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down
20 changes: 6 additions & 14 deletions src/main/java/org/teacon/powertool/block/ItemDisplayBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,16 @@ public void attack(BlockState state, Level level, BlockPos pos, Player player) {
}
}

@Override
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
if (level.getBlockEntity(pos) instanceof ItemDisplayBlockEntity theBE) {
if (player.getAbilities().instabuild || state.getValue(SURVIVAL_AVAILABLE)) {
theBE.rotation = (theBE.rotation + 45) % 360;
theBE.setChanged();
level.sendBlockUpdated(pos, state, state, Block.UPDATE_CLIENTS);
return InteractionResult.SUCCESS;
}
}
return InteractionResult.PASS;
}

@Override
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
if (level.getBlockEntity(pos) instanceof ItemDisplayBlockEntity theBE) {
if (player.getAbilities().instabuild || state.getValue(SURVIVAL_AVAILABLE)){
theBE.itemToDisplay = stack.copy();
if(stack.isEmpty()){
theBE.rotation = (theBE.rotation + 45) % 360;
}
else{
theBE.itemToDisplay = stack.copy();
}
if (!level.isClientSide) {
theBE.setChanged();
level.sendBlockUpdated(pos, state, state, Block.UPDATE_CLIENTS);
Expand Down

0 comments on commit 634f6db

Please sign in to comment.