Skip to content

Commit 40ebae0

Browse files
committed
feat: add buckets to use block listener
1 parent d8a2dc0 commit 40ebae0

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

fabric/src/main/java/net/william278/cloplib/listener/FabricUseBlockListener.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import net.minecraft.entity.projectile.ProjectileEntity;
3131
import net.minecraft.inventory.Inventory;
3232
import net.minecraft.item.BlockItem;
33+
import net.minecraft.item.BucketItem;
3334
import net.minecraft.item.ItemStack;
3435
import net.minecraft.registry.Registries;
3536
import net.minecraft.server.network.ServerPlayerEntity;
@@ -113,11 +114,12 @@ default ActionResult onPlayerUseBlock(PlayerEntity playerEntity, World world, Ha
113114
hand == Hand.OFF_HAND
114115
))) {
115116
return ActionResult.FAIL;
116-
} else if (held != null && held.getItem() instanceof BlockItem && getHandler().cancelOperation(Operation.of(
117-
getUser(player),
118-
getPrecalculatedItemMap().getOrDefault(held.toString(), OperationType.BLOCK_PLACE),
119-
getPosition(BlockPos.ofFloored(blockHit.getPos().offset(blockHit.getSide(), 1.0d)), world)
120-
))){
117+
} else if (held != null && (held.getItem() instanceof BlockItem || held.getItem() instanceof BucketItem) &&
118+
getHandler().cancelOperation(Operation.of(
119+
getUser(player),
120+
getPrecalculatedItemMap().getOrDefault(held.toString(), OperationType.BLOCK_PLACE),
121+
getPosition(BlockPos.ofFloored(blockHit.getPos().offset(blockHit.getSide(), 1.0d)), world)
122+
))) {
121123
return ActionResult.FAIL;
122124
}
123125
return ActionResult.PASS;

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ org.gradle.daemon=true
66
# Ignore loom version errors - Essential gradle multi-version doesn't work with Loom 1.10 yet (needed for 1.21.5) :-(
77
loom.ignoreDependencyLoomVersionValidation=true
88

9-
library_version=2.0.6
9+
library_version=2.0.7
1010
library_archive=cloplib
1111
library_description=Common library for handling operations on Minecraft blocks within regions

0 commit comments

Comments
 (0)