mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
add off hand to replant in herbalims
This commit is contained in:
parent
4d98d25215
commit
e50e984c65
@ -757,37 +757,29 @@ 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;
|
||||||
|
|
||||||
switch (blockState.getType().getKey().getKey().toLowerCase(Locale.ROOT)) {
|
switch (blockState.getType().getKey().getKey().toLowerCase(Locale.ROOT)) {
|
||||||
case "carrots":
|
case "carrots":
|
||||||
seed = Material.matchMaterial("CARROT");
|
seed = Material.CARROT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "wheat":
|
case "wheat":
|
||||||
seed = Material.matchMaterial("WHEAT_SEEDS");
|
seed = Material.WHEAT_SEEDS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "nether_wart":
|
case "nether_wart":
|
||||||
seed = Material.getMaterial("NETHER_WART");
|
seed = Material.NETHER_WART;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "potatoes":
|
case "potatoes":
|
||||||
seed = Material.matchMaterial("POTATO");
|
seed = Material.POTATO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "beetroots":
|
case "beetroots":
|
||||||
seed = Material.matchMaterial("BEETROOT_SEEDS");
|
seed = Material.BEETROOT_SEEDS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "cocoa":
|
case "cocoa":
|
||||||
seed = Material.matchMaterial("COCOA_BEANS");
|
seed = Material.COCOA_BEANS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "torchflower":
|
case "torchflower":
|
||||||
seed = Material.matchMaterial("TORCHFLOWER_SEEDS");
|
seed = Material.matchMaterial("TORCHFLOWER_SEEDS");
|
||||||
break;
|
break;
|
||||||
@ -795,7 +787,6 @@ 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())
|
||||||
@ -807,10 +798,21 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!playerInventory.containsAtLeast(seedStack, 1)) {
|
// Check for seeds in both the main hand and off-hand
|
||||||
|
if (!(playerInventory.containsAtLeast(seedStack, 1) || playerInventory.getItemInOffHand().getType() == seed)) {
|
||||||
|
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Skills.NeedMore", StringUtils.getPrettyItemString(seed));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove seed from the appropriate inventory slot (main hand or off-hand)
|
||||||
|
if (playerInventory.getItemInMainHand().getType() == seed) {
|
||||||
|
playerInventory.removeItem(new ItemStack(seed, 1));
|
||||||
|
} else if (playerInventory.getItemInOffHand().getType() == seed) {
|
||||||
|
playerInventory.getItemInOffHand().setAmount(playerInventory.getItemInOffHand().getAmount() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.updateInventory(); // Needed until replacement available
|
||||||
|
|
||||||
if (!processGrowingPlants(blockState, ageable, blockBreakEvent, greenTerra)) {
|
if (!processGrowingPlants(blockState, ageable, blockBreakEvent, greenTerra)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -818,8 +820,6 @@ public class HerbalismManager extends SkillManager {
|
|||||||
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);
|
|
||||||
player.updateInventory(); // Needed until replacement available
|
|
||||||
//Play sound
|
//Play sound
|
||||||
SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_CONSUMED);
|
SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_CONSUMED);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user