import crafttweaker.block.IBlock; import crafttweaker.player.IPlayer; import crafttweaker.block.IBlockPattern; import crafttweaker.event.PlayerInteractBlockEvent; .add(, , , ); .addAll(); static wrenchables as IBlockPattern = as IBlock | as IBlock | as IBlock | as IBlock | as IBlock | as IBlock | as IBlock; function isNotWrenchable(block as IBlock) as bool { return isNull(block) || // no block !(wrenchables has block); // not wrenchable } function isNotWrenching(player as IPlayer) as bool { return isNull(player) || // no player !player.isSneaking || // not sneaking isNull(player.currentItem) || // no item is held !( has player.currentItem); // not a wrench } function playerIsNotWrenchingWrenchable(evt as PlayerInteractBlockEvent) as bool { // gracefully handle unusual circumstances if (isNull(evt) || isNull(evt.world) || evt.canceled || evt.useItem == "DENY") return true; return isNotWrenching(evt.player) || isNotWrenchable(evt.block); } function dropItem(evt as PlayerInteractBlockEvent) as bool { if (evt.world.remote) return true; val stack = evt.world.getPickedBlock(evt.position, evt.player.getRayTrace(4, 0), evt.player); if (isNull(stack) || !evt.world.setBlockState(, evt.position)) return false; // dummy entity to drop the item with val dummy = .createEntity(evt.world); dummy.posX = evt.x as double + 0.5; dummy.posY = evt.y as double + 0.5; dummy.posZ = evt.z as double + 0.5; dummy.dropItem(stack); } events.onPlayerInteractBlock(function(evt as PlayerInteractBlockEvent) as void { if (playerIsNotWrenchingWrenchable(evt)) return; if (dropItem(evt)) { evt.cancellationResult = "SUCCESS"; evt.cancel(); } });