HomeJavaModsFarm Protection for MC 1.16 - 1.21
FarmProtection for MC 1.16
This is a simple plugin to prevent players and mobs from destroying farm / farmland by walking or jumping on it.

Tested on 1.16.4 and 1.16.5, should work for lower 1.16 versions too.

Spoiler: Event Source Code
If you just want to know how it's working to use it in your own plugins, here's the code.
Code (Java):
import org.bukkit.Material ;

import org.bukkit.block.Block ;
import org.bukkit.event.EventHandler ;
import org.bukkit.event.Listener ;
import org.bukkit.event.block.Action ;
import org.bukkit.event.entity.EntityInteractEvent ;
import org.bukkit.event.player.PlayerInteractEvent ;

public class FarmProtectionListener implements Listener {

    @EventHandler
    public void onEntityInteract (EntityInteractEvent event ) {
        Block block = event. getBlock ( ) ;
        if (block != null && block. getType ( ) == Material. FARMLAND ) {
            event. setCancelled ( true ) ;
        }
    }

    @EventHandler
    public void onPlayerInteract (PlayerInteractEvent event ) {
        if (event. getAction ( ) == Action. PHYSICAL ) {
            if (event. getClickedBlock ( ). getType ( ) == Material. FARMLAND ) {
                event. setCancelled ( true ) ;
            }
        }
    }

}

Plugin details

Read from the plugin's own plugin.yml.

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

Farm Protection for MC 1.16 - 1.21 is a free Minecraft Java mod. Compatible with Minecraft 1.16. Downloaded 24,490 times (via Spigot). Download it and open it directly in the game.

Explore more