From 42952dc420c97e8a311a957b9b6b3dfd3c89f2a1 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 18 Mar 2020 19:44:27 -0700 Subject: [PATCH] repair/salvage anvils will override vanilla functions of a block --- Changelog.txt | 1 + .../gmail/nossr50/listeners/PlayerListener.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index e6d4bceaf..35aa6030e 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,5 @@ Version 2.1.124 + if Repair's anvil or Salvage's anvil are set to a vanilla block, that block will no longer provide its right-click vanilla function. You can use this to set the vanilla minecraft Anvil as the Anvil used for Repair. Added Gold_Nugget to Mining's Bonus_Drops in config.yml (edit your config) Added Piglin to experience.yml combat XP tables with a value of 2.0 (edit your config) Added Hoglin to experience.yml combat XP tables with a value of 4.0 (edit your config) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 0313655c9..a026bf790 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -41,6 +41,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.*; import org.bukkit.entity.minecart.PoweredMinecart; +import org.bukkit.event.Event; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -596,6 +597,18 @@ public class PlayerListener implements Listener { return; } + //Cancel the event to prevent vanilla functionality + if(event.getClickedBlock() != null) { + if(event.getAction() == Action.RIGHT_CLICK_BLOCK) { + if(event.getClickedBlock().getType() == Repair.anvilMaterial || event.getClickedBlock().getType() == Salvage.anvilMaterial) { + if(event.useInteractedBlock() == Event.Result.ALLOW) { + event.setUseInteractedBlock(Event.Result.DENY); + } + } + } + } + + if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { return; } @@ -646,6 +659,7 @@ public class PlayerListener implements Listener { player.updateInventory(); } } + } /* BLAST MINING CHECK */ else if (miningManager.canDetonate()) {