mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Herbalism compatibility with PlayerAnimationEvent
This change in theory should make McMMO herbalism compatible with plugins that utilise PlayerAnimationEvent. The main reason that I want to add this is to fix `no swing` false positives in `AAC` (though didn't get to test this).
I would appreciate if someone could test this PR and verify that its working without any issues. (I am busy for the next few days so I haven't been able to test it. In theory it looks like it should work. I could have checked if the event `isCancelled()` however, this doesn't seem necessary quite yet. Though, if it is needed I can add it 👍
Please don't merge this unless it's confirmed completely working. I will find some time to test it out within the next few days.
This commit is contained in:
parent
c0a3d63213
commit
93fefa031b
@ -656,16 +656,17 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer()); //PlayerAnimationEvent compat
|
||||||
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
||||||
|
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||||
player.getInventory().setItemInMainHand(new ItemStack(Material.WHEAT_SEEDS, heldItem.getAmount() - 1));
|
player.getInventory().setItemInMainHand(new ItemStack(Material.WHEAT_SEEDS, heldItem.getAmount() - 1));
|
||||||
|
|
||||||
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||||
blockState.update(true);
|
blockState.update(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SHROOM THUMB CHECK */
|
/* SHROOM THUMB CHECK */
|
||||||
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
||||||
|
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||||
blockState.update(true);
|
blockState.update(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user