public override void OnHeldAttackStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, ref EnumHandHandling handling) { if (byEntity.World.Side == EnumAppSide.Client) { handling = EnumHandHandling.PreventDefaultAction; return; } if (blockSel == null) { return; } ModSystemBlockReinforcement modBre = byEntity.Api.ModLoader.GetModSystem <ModSystemBlockReinforcement>(); IServerPlayer player = (byEntity as EntityPlayer).Player as IServerPlayer; if (player == null) { return; } BlockReinforcement bre = modBre.GetReinforcment(blockSel.Position); string errorCode = ""; if (!modBre.TryRemoveReinforcement(blockSel.Position, player, ref errorCode)) { if (errorCode == "notownblock") { (player as IServerPlayer).SendIngameError("cantremove", "Cannot remove reinforcement. This block does not belong to you"); } else { (player as IServerPlayer).SendIngameError("cantremove", "Cannot remove reinforcement. It's not reinforced"); } return; } else { if (bre.Locked) { ItemStack stack = new ItemStack(byEntity.World.GetItem(new AssetLocation(bre.LockedByItemCode))); if (!player.InventoryManager.TryGiveItemstack(stack, true)) { byEntity.World.SpawnItemEntity(stack, byEntity.ServerPos.XYZ); } } } BlockPos pos = blockSel.Position; byEntity.World.PlaySoundAt(new AssetLocation("sounds/tool/reinforce"), pos.X, pos.Y, pos.Z, null); handling = EnumHandHandling.PreventDefaultAction; }