Bukkit Help with stopping trampling

Status
This thread has been locked.

Shattered

old-timer
Supreme
Feedback score
5
Posts
3,486
Reactions
2,059
Resources
0
I am trying to find a nice little piece of code which will disable crop trampling I tried almost everything, and I just cant find anything.

If someone can comment with a simple piece of code which can disable it, that will be awesome :)
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

TheNewTao

Java Developer
Premium
Feedback score
0
Posts
654
Reactions
274
Resources
0
Java:
if ((e.getAction() == Action.PHYSICAL) && (e.getClickedBlock().getType() == Material.SOIL)) {
      event.e(true);
    }

// And for other entities, besides players
if ((e.getEntityType() != EntityType.PLAYER) && (e.getBlock().getType() == Material.SOIL)) {
      e.setCancelled(true);
    }

Hope it helps, sorry my brackets are off, copying and pasting didn't go well...
 

Shattered

old-timer
Supreme
Feedback score
5
Posts
3,486
Reactions
2,059
Resources
0
Code:
      @EventHandler
      public void PlayerInteractEvent (PlayerInteractEvent  event)
      {
          if ((event.getAction() == Action.PHYSICAL) && (event.getClickedBlock().getType() == Material.SOIL)) {
              event.setCancelled(true);
            }
      }
I have gotten it using this, RockinMC I have tried visiting that bukkit page but that was for like 1.2 or something when it didn't have to be a physical action. And thanks TheNewTao :)
 
Status
This thread has been locked.
Top