This commit is contained in:
Thiago Gebrim 2024-04-14 14:42:08 +00:00 committed by GitHub
commit e410adf829
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -704,7 +704,7 @@ public class HerbalismManager extends SkillManager {
public boolean processShroomThumb(BlockState blockState) { public boolean processShroomThumb(BlockState blockState) {
Player player = getPlayer(); Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory(); PlayerInventory playerInventory = player.getInventory();
if (!playerInventory.contains(Material.BROWN_MUSHROOM, 1)) { if (!playerInventory.contains(Material.BROWN_MUSHROOM, 1)) {
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)); NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM));
return false; return false;
@ -747,7 +747,7 @@ public class HerbalismManager extends SkillManager {
*/ */
private boolean processGreenThumbPlants(BlockState blockState, BlockBreakEvent blockBreakEvent, boolean greenTerra) { private boolean processGreenThumbPlants(BlockState blockState, BlockBreakEvent blockBreakEvent, boolean greenTerra) {
if (!ItemUtils.isHoe(blockBreakEvent.getPlayer().getInventory().getItemInMainHand()) if (!ItemUtils.isHoe(blockBreakEvent.getPlayer().getInventory().getItemInMainHand())
&& !ItemUtils.isAxe(blockBreakEvent.getPlayer().getInventory().getItemInMainHand())) { && !ItemUtils.isAxe(blockBreakEvent.getPlayer().getInventory().getItemInMainHand())) {
return false; return false;
} }
@ -757,8 +757,6 @@ public class HerbalismManager extends SkillManager {
return false; return false;
} }
//If the ageable is NOT mature and the player is NOT using a hoe, abort
Player player = getPlayer(); Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory(); PlayerInventory playerInventory = player.getInventory();
Material seed; Material seed;
@ -767,27 +765,21 @@ public class HerbalismManager extends SkillManager {
case "carrots": case "carrots":
seed = Material.matchMaterial("CARROT"); seed = Material.matchMaterial("CARROT");
break; break;
case "wheat": case "wheat":
seed = Material.matchMaterial("WHEAT_SEEDS"); seed = Material.matchMaterial("WHEAT_SEEDS");
break; break;
case "nether_wart": case "nether_wart":
seed = Material.getMaterial("NETHER_WART"); seed = Material.matchMaterial("NETHER_WART");
break; break;
case "potatoes": case "potatoes":
seed = Material.matchMaterial("POTATO"); seed = Material.matchMaterial("POTATO");
break; break;
case "beetroots": case "beetroots":
seed = Material.matchMaterial("BEETROOT_SEEDS"); seed = Material.matchMaterial("BEETROOT_SEEDS");
break; break;
case "cocoa": case "cocoa":
seed = Material.matchMaterial("COCOA_BEANS"); seed = Material.matchMaterial("COCOA_BEANS");
break; break;
case "torchflower": case "torchflower":
seed = Material.matchMaterial("TORCHFLOWER_SEEDS"); seed = Material.matchMaterial("TORCHFLOWER_SEEDS");
break; break;
@ -795,11 +787,10 @@ public class HerbalismManager extends SkillManager {
return false; return false;
} }
ItemStack seedStack = new ItemStack(seed); ItemStack seedStack = new ItemStack(seed);
if (ItemUtils.isAxe(blockBreakEvent.getPlayer().getInventory().getItemInMainHand()) if (ItemUtils.isAxe(blockBreakEvent.getPlayer().getInventory().getItemInMainHand())
&& blockState.getType() != Material.COCOA) { && blockState.getType() != Material.COCOA) {
return false; return false;
} }
@ -807,7 +798,8 @@ public class HerbalismManager extends SkillManager {
return false; return false;
} }
if (!playerInventory.containsAtLeast(seedStack, 1)) { if (!playerInventory.contains(seedStack)) {
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Skills.NeedMore", StringUtils.getPrettyItemString(seed));
return false; return false;
} }
@ -815,12 +807,13 @@ public class HerbalismManager extends SkillManager {
return false; return false;
} }
if(EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, blockState.getBlock()).isCancelled()) { if (EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, blockState.getBlock()).isCancelled()) {
return false; return false;
} else { } else {
playerInventory.removeItem(seedStack); playerInventory.removeItem(new ItemStack(seed, 1));
player.updateInventory(); // Needed until replacement available
//Play sound player.updateInventory();
SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_CONSUMED); SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_CONSUMED);
return true; return true;
} }
@ -852,7 +845,7 @@ public class HerbalismManager extends SkillManager {
case "carrots": case "carrots":
case "wheat": case "wheat":
finalAge = getGreenThumbStage(greenTerra); finalAge = getGreenThumbStage(greenTerra);
break; break;
case "beetroots": case "beetroots":