Skip to content

Commit

Permalink
Merge pull request #164 from InsightsPlugin/fix/tripwire-count
Browse files Browse the repository at this point in the history
Fix tripwire hooks counting all attached strings
  • Loading branch information
FrankHeijden authored Mar 4, 2022
2 parents 6e49ced + 779d7dc commit 24abc8f
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ public void onBlockPlace(BlockPlaceEvent event) {
var player = event.getPlayer();

// In case of BlockMultiPlaceEvent, we may need to take a different delta.
// A closing tripwire hook triggers a BlockMultiPlaceEvent for all attached strings,
// but since they already exist in the world we do not need to count them.
var delta = 0;
if (event instanceof BlockMultiPlaceEvent) {
if (event instanceof BlockMultiPlaceEvent && material != Material.TRIPWIRE_HOOK) {
List<BlockState> replacedBlockStates = ((BlockMultiPlaceEvent) event).getReplacedBlockStates();
for (BlockState state : replacedBlockStates) {
if (BlockUtils.isSameChunk(location.getBlockX(), location.getBlockZ(), state.getX(), state.getZ())) {
Expand Down Expand Up @@ -87,7 +89,9 @@ public void onBlockPlaceMonitor(BlockPlaceEvent event) {
var player = event.getPlayer();

// In case of BlockMultiPlaceEvent, we need to update the cache differently.
if (event instanceof BlockMultiPlaceEvent) {
// A closing tripwire hook triggers a BlockMultiPlaceEvent for all attached strings,
// but since they already exist in the world we do not need to count them.
if (event instanceof BlockMultiPlaceEvent && material != Material.TRIPWIRE_HOOK) {
List<BlockState> replacedBlockStates = ((BlockMultiPlaceEvent) event).getReplacedBlockStates();
for (BlockState state : replacedBlockStates) {
var loc = state.getLocation();
Expand Down

0 comments on commit 24abc8f

Please sign in to comment.