mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Immature plants will be replanted if weilding a hoe
This commit is contained in:
parent
4e21f1a200
commit
8f26544188
@ -1,4 +1,5 @@
|
|||||||
Version 2.1.115
|
Version 2.1.115
|
||||||
|
Using a hoe on non-fully grown crops will replant them as a convenience feature for those who can't bother to wait for all of their plants to grow (put away the hoe to break non-fully grown crops)
|
||||||
Fixed a bug where Salvage always gave the best results
|
Fixed a bug where Salvage always gave the best results
|
||||||
Fixed an issue with arrows causing exceptions with players not yet having data loaded
|
Fixed an issue with arrows causing exceptions with players not yet having data loaded
|
||||||
Spectral arrows are now tracked by mcMMO
|
Spectral arrows are now tracked by mcMMO
|
||||||
|
@ -143,6 +143,9 @@ public class HerbalismManager extends SkillManager {
|
|||||||
//Grab all broken blocks
|
//Grab all broken blocks
|
||||||
HashSet<Block> brokenBlocks = getBrokenHerbalismBlocks(blockBreakEvent);
|
HashSet<Block> brokenBlocks = getBrokenHerbalismBlocks(blockBreakEvent);
|
||||||
|
|
||||||
|
if(brokenBlocks.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
//Handle rewards, xp, ability interactions, etc
|
//Handle rewards, xp, ability interactions, etc
|
||||||
processHerbalismOnBlocksBroken(blockBreakEvent, brokenBlocks);
|
processHerbalismOnBlocksBroken(blockBreakEvent, brokenBlocks);
|
||||||
}
|
}
|
||||||
@ -157,7 +160,12 @@ public class HerbalismManager extends SkillManager {
|
|||||||
|
|
||||||
//TODO: The design of Green Terra needs to change, this is a mess
|
//TODO: The design of Green Terra needs to change, this is a mess
|
||||||
if(Permissions.greenThumbPlant(getPlayer(), originalBreak.getType())) {
|
if(Permissions.greenThumbPlant(getPlayer(), originalBreak.getType())) {
|
||||||
processGreenThumbPlants(originalBreak, isGreenTerraActive());
|
processGreenThumbPlants(originalBreak, blockBreakEvent, isGreenTerraActive());
|
||||||
|
}
|
||||||
|
|
||||||
|
//When replanting a immature crop we cancel the block break event and back out
|
||||||
|
if(blockBreakEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -339,9 +347,11 @@ public class HerbalismManager extends SkillManager {
|
|||||||
//Calculate XP
|
//Calculate XP
|
||||||
if(plantData instanceof Ageable) {
|
if(plantData instanceof Ageable) {
|
||||||
Ageable plantAgeable = (Ageable) plantData;
|
Ageable plantAgeable = (Ageable) plantData;
|
||||||
|
|
||||||
if(isAgeableMature(plantAgeable) || isBizarreAgeable(plantData)) {
|
if(isAgeableMature(plantAgeable) || isBizarreAgeable(plantData)) {
|
||||||
xpToReward += ExperienceConfig.getInstance().getXp(PrimarySkillType.HERBALISM, brokenBlockNewState.getType());
|
xpToReward += ExperienceConfig.getInstance().getXp(PrimarySkillType.HERBALISM, brokenBlockNewState.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
xpToReward += ExperienceConfig.getInstance().getXp(PrimarySkillType.HERBALISM, brokenPlantBlock.getType());
|
xpToReward += ExperienceConfig.getInstance().getXp(PrimarySkillType.HERBALISM, brokenPlantBlock.getType());
|
||||||
}
|
}
|
||||||
@ -635,10 +645,18 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
* @param greenTerra boolean to determine if greenTerra is active or not
|
* @param greenTerra boolean to determine if greenTerra is active or not
|
||||||
*/
|
*/
|
||||||
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
|
private void processGreenThumbPlants(BlockState blockState, BlockBreakEvent blockBreakEvent, boolean greenTerra) {
|
||||||
if (!BlockUtils.isFullyGrown(blockState))
|
BlockData blockData = blockState.getBlockData();
|
||||||
|
|
||||||
|
if (!(blockData instanceof Ageable))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//If the ageable is NOT mature and the player is NOT using a hoe, abort
|
||||||
|
if(!isAgeableMature((Ageable) blockData) && !ItemUtils.isHoe(getPlayer().getItemInHand())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
PlayerInventory playerInventory = player.getInventory();
|
PlayerInventory playerInventory = player.getInventory();
|
||||||
Material seed = null;
|
Material seed = null;
|
||||||
@ -678,7 +696,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!processGrowingPlants(blockState, greenTerra)) {
|
if (!processGrowingPlants(blockState, blockBreakEvent, greenTerra)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,11 +713,18 @@ public class HerbalismManager extends SkillManager {
|
|||||||
new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0);
|
new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean processGrowingPlants(BlockState blockState, boolean greenTerra) {
|
private boolean processGrowingPlants(BlockState blockState, BlockBreakEvent blockBreakEvent, boolean greenTerra) {
|
||||||
|
Ageable crops = (Ageable) blockState.getBlockData();
|
||||||
int greenThumbStage = getGreenThumbStage();
|
int greenThumbStage = getGreenThumbStage();
|
||||||
|
|
||||||
|
//Immature plants will start over at 0
|
||||||
|
if(!isAgeableMature(crops)) {
|
||||||
|
crops.setAge(0);
|
||||||
|
blockBreakEvent.setCancelled(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
blockState.setMetadata(mcMMO.greenThumbDataKey, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
blockState.setMetadata(mcMMO.greenThumbDataKey, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
||||||
Ageable crops = (Ageable) blockState.getBlockData();
|
|
||||||
|
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user