mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Fix hanging plants searching up instead of down. (#4766)
This commit is contained in:
parent
c41d2d1f39
commit
4a8630262e
@ -578,7 +578,7 @@ public class HerbalismManager extends SkillManager {
|
||||
if (isChorusBranch(brokenBlock.getType())) {
|
||||
brokenBlocks = getBrokenChorusBlocks(brokenBlock);
|
||||
} else {
|
||||
brokenBlocks = getBlocksBrokenAbove(brokenBlock, false);
|
||||
brokenBlocks = getBlocksBrokenAboveOrBelow(brokenBlock, false, mcMMO.getMaterialMapStore().isMultiBlockHangingPlant(brokenBlock.getType()));
|
||||
}
|
||||
|
||||
return brokenBlocks;
|
||||
@ -599,9 +599,11 @@ public class HerbalismManager extends SkillManager {
|
||||
* Multi-block plants are hard-coded and kept in {@link MaterialMapStore}
|
||||
*
|
||||
* @param originBlock The point of the "break"
|
||||
* @param inclusive Whether to include the origin block
|
||||
* @param below Whether to search down instead of up.
|
||||
* @return A set of blocks above the target block which can be assumed to be broken
|
||||
*/
|
||||
private HashSet<Block> getBlocksBrokenAbove(BlockState originBlock, boolean inclusive) {
|
||||
private HashSet<Block> getBlocksBrokenAboveOrBelow(BlockState originBlock, boolean inclusive, boolean below) {
|
||||
HashSet<Block> brokenBlocks = new HashSet<>();
|
||||
Block block = originBlock.getBlock();
|
||||
|
||||
@ -612,16 +614,18 @@ public class HerbalismManager extends SkillManager {
|
||||
//Limit our search
|
||||
int maxHeight = 512;
|
||||
|
||||
final BlockFace relativeFace = below ? BlockFace.DOWN : BlockFace.UP;
|
||||
|
||||
// Search vertically for multi-block plants, exit early if any non-multi block plants
|
||||
for (int y = 0; y < maxHeight; y++) {
|
||||
//TODO: Should this grab state? It would be more expensive..
|
||||
Block relativeUpBlock = block.getRelative(BlockFace.UP, y);
|
||||
Block relativeBlock = block.getRelative(relativeFace, y);
|
||||
|
||||
//Abandon our search if the block isn't multi
|
||||
if(!mcMMO.getMaterialMapStore().isMultiBlockPlant(relativeUpBlock.getType()))
|
||||
if (isOneBlockPlant(relativeBlock.getType()))
|
||||
break;
|
||||
|
||||
brokenBlocks.add(relativeUpBlock);
|
||||
brokenBlocks.add(relativeBlock);
|
||||
}
|
||||
|
||||
return brokenBlocks;
|
||||
@ -634,7 +638,7 @@ public class HerbalismManager extends SkillManager {
|
||||
* @return true if the block is not contained in the collection of multi-block plants
|
||||
*/
|
||||
private boolean isOneBlockPlant(Material material) {
|
||||
return !mcMMO.getMaterialMapStore().isMultiBlockPlant(material);
|
||||
return !mcMMO.getMaterialMapStore().isMultiBlockPlant(material) && !mcMMO.getMaterialMapStore().isMultiBlockHangingPlant(material);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,7 @@ public class MaterialMapStore {
|
||||
private final @NotNull HashSet<String> blockCrackerWhiteList;
|
||||
private final @NotNull HashSet<String> canMakeShroomyWhiteList;
|
||||
private final @NotNull HashSet<String> multiBlockPlant;
|
||||
private final @NotNull HashSet<String> multiBlockHangingPlant;
|
||||
private final @NotNull HashSet<String> foodItemWhiteList;
|
||||
private final @NotNull HashSet<String> glassBlocks;
|
||||
|
||||
@ -71,6 +72,7 @@ public class MaterialMapStore {
|
||||
blockCrackerWhiteList = new HashSet<>();
|
||||
canMakeShroomyWhiteList = new HashSet<>();
|
||||
multiBlockPlant = new HashSet<>();
|
||||
multiBlockHangingPlant = new HashSet<>();
|
||||
foodItemWhiteList = new HashSet<>();
|
||||
glassBlocks = new HashSet<>();
|
||||
|
||||
@ -121,6 +123,7 @@ public class MaterialMapStore {
|
||||
fillBlockCrackerWhiteList();
|
||||
fillShroomyWhiteList();
|
||||
fillMultiBlockPlantSet();
|
||||
fillMultiBlockHangingPlantSet();
|
||||
fillFoodWhiteList();
|
||||
fillGlassBlockWhiteList();
|
||||
fillArmors();
|
||||
@ -137,6 +140,10 @@ public class MaterialMapStore {
|
||||
return multiBlockPlant.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
public boolean isMultiBlockHangingPlant(@NotNull Material material) {
|
||||
return multiBlockHangingPlant.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
public boolean isAbilityActivationBlackListed(@NotNull Material material)
|
||||
{
|
||||
return abilityBlackList.contains(material.getKey().getKey());
|
||||
@ -974,8 +981,12 @@ public class MaterialMapStore {
|
||||
multiBlockPlant.add("large_fern");
|
||||
multiBlockPlant.add("tall_grass");
|
||||
multiBlockPlant.add("bamboo");
|
||||
multiBlockPlant.add("weeping_vines_plant");
|
||||
multiBlockPlant.add("twisted_vines_plant");
|
||||
}
|
||||
|
||||
private void fillMultiBlockHangingPlantSet() {
|
||||
multiBlockHangingPlant.add("weeping_vines_plant");
|
||||
multiBlockHangingPlant.add("twisted_vines_plant");
|
||||
multiBlockHangingPlant.add("cave_vines_plant");
|
||||
}
|
||||
|
||||
private void fillShroomyWhiteList()
|
||||
|
Loading…
Reference in New Issue
Block a user