As I understand it, your ability to use violence to defend your property under the criminal law is generally limited to castle or stand your ground laws.
under tort law, you are generally liable for harms that occur to people (even trespassers) on your property due to traps or hazards.