mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
parent
a2e10dbd0c
commit
f8433cdbcc
@ -1,4 +1,5 @@
|
|||||||
Version 2.1.202
|
Version 2.1.202
|
||||||
|
Fixed a bug where mcMMO didn't reward XP for Kelp
|
||||||
Fixed a bug where mcMMO marked bonemealed Azalea trees as unnatural (and thus did not give XP or get affected by Tree Feller)
|
Fixed a bug where mcMMO marked bonemealed Azalea trees as unnatural (and thus did not give XP or get affected by Tree Feller)
|
||||||
Added Amethyst_Block to experience.yml for Mining
|
Added Amethyst_Block to experience.yml for Mining
|
||||||
Added Flowering Azalea Leaves to Tree Feller's white list
|
Added Flowering Azalea Leaves to Tree Feller's white list
|
||||||
|
@ -251,6 +251,9 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @param brokenPlants plant blocks to process
|
* @param brokenPlants plant blocks to process
|
||||||
*/
|
*/
|
||||||
private void processHerbalismOnBlocksBroken(BlockBreakEvent blockBreakEvent, HashSet<Block> brokenPlants) {
|
private void processHerbalismOnBlocksBroken(BlockBreakEvent blockBreakEvent, HashSet<Block> brokenPlants) {
|
||||||
|
if(blockBreakEvent.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
BlockState originalBreak = blockBreakEvent.getBlock().getState();
|
BlockState originalBreak = blockBreakEvent.getBlock().getState();
|
||||||
boolean greenThumbActivated = false;
|
boolean greenThumbActivated = false;
|
||||||
|
|
||||||
@ -263,16 +266,6 @@ public class HerbalismManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//When replanting a immature crop we cancel the block break event and back out
|
|
||||||
if(greenThumbActivated) {
|
|
||||||
if(originalBreak.getBlock().getBlockData() instanceof Ageable) {
|
|
||||||
Ageable ageableCrop = (Ageable) originalBreak.getBlock().getBlockData();
|
|
||||||
if(!isAgeableMature(ageableCrop)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mark blocks for double drops
|
* Mark blocks for double drops
|
||||||
* Be aware of the hacky interactions we are doing with Chorus Plants
|
* Be aware of the hacky interactions we are doing with Chorus Plants
|
||||||
@ -394,6 +387,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
//Catcus and Sugar Canes cannot be trusted
|
//Catcus and Sugar Canes cannot be trusted
|
||||||
switch(blockData.getMaterial()) {
|
switch(blockData.getMaterial()) {
|
||||||
case CACTUS:
|
case CACTUS:
|
||||||
|
case KELP:
|
||||||
case SUGAR_CANE:
|
case SUGAR_CANE:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
@ -530,21 +524,18 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @param blockBreakEvent target event
|
* @param blockBreakEvent target event
|
||||||
* @return a set of plant-blocks that were broken as a result of this event
|
* @return a set of plant-blocks that were broken as a result of this event
|
||||||
*/
|
*/
|
||||||
private HashSet<Block> getBrokenHerbalismBlocks(BlockBreakEvent blockBreakEvent) {
|
private HashSet<Block> getBrokenHerbalismBlocks(@NotNull BlockBreakEvent blockBreakEvent) {
|
||||||
//Get an updated capture of this block
|
//Get an updated capture of this block
|
||||||
BlockState originalBlockBlockState = blockBreakEvent.getBlock().getState();
|
BlockState originBlockState = blockBreakEvent.getBlock().getState();
|
||||||
Material originalBlockMaterial = originalBlockBlockState.getType();
|
Material originBlockMaterial = originBlockState.getType();
|
||||||
HashSet<Block> blocksBroken = new HashSet<>(); //Blocks broken
|
HashSet<Block> blocksBroken = new HashSet<>(); //Blocks broken
|
||||||
|
|
||||||
//Check if this block is a one block plant or not
|
//Add the initial block
|
||||||
boolean oneBlockPlant = isOneBlockPlant(originalBlockMaterial);
|
blocksBroken.add(originBlockState.getBlock());
|
||||||
|
|
||||||
if(oneBlockPlant) {
|
if(!isOneBlockPlant(originBlockMaterial)) {
|
||||||
//If the block is a one-block plant return only that
|
|
||||||
blocksBroken.add(originalBlockBlockState.getBlock());
|
|
||||||
} else {
|
|
||||||
//If the block is a multi-block structure, capture a set of all blocks broken and return that
|
//If the block is a multi-block structure, capture a set of all blocks broken and return that
|
||||||
blocksBroken = getBrokenBlocksMultiBlockPlants(originalBlockBlockState, blockBreakEvent);
|
blocksBroken = getBrokenBlocksMultiBlockPlants(originBlockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return all broken plant-blocks
|
//Return all broken plant-blocks
|
||||||
@ -580,17 +571,16 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* The method to grab these blocks is a bit hacky and does not hook into the API
|
* The method to grab these blocks is a bit hacky and does not hook into the API
|
||||||
* Basically we expect the blocks to be broken if this event is not cancelled and we determine which block are broken on our end rather than any event state captures
|
* Basically we expect the blocks to be broken if this event is not cancelled and we determine which block are broken on our end rather than any event state captures
|
||||||
*
|
*
|
||||||
* @param blockBreakEvent target event
|
|
||||||
* @return a set of plant-blocks broken from this event
|
* @return a set of plant-blocks broken from this event
|
||||||
*/
|
*/
|
||||||
protected HashSet<Block> getBrokenBlocksMultiBlockPlants(BlockState originalBlockBroken, BlockBreakEvent blockBreakEvent) {
|
protected HashSet<Block> getBrokenBlocksMultiBlockPlants(BlockState brokenBlock) {
|
||||||
//Track the broken blocks
|
//Track the broken blocks
|
||||||
HashSet<Block> brokenBlocks;
|
HashSet<Block> brokenBlocks;
|
||||||
|
|
||||||
if (isChorusBranch(originalBlockBroken.getType())) {
|
if (isChorusBranch(brokenBlock.getType())) {
|
||||||
brokenBlocks = getBrokenChorusBlocks(originalBlockBroken);
|
brokenBlocks = getBrokenChorusBlocks(brokenBlock);
|
||||||
} else {
|
} else {
|
||||||
brokenBlocks = getBlocksBrokenAbove(originalBlockBroken);
|
brokenBlocks = getBlocksBrokenAbove(brokenBlock, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return brokenBlocks;
|
return brokenBlocks;
|
||||||
@ -610,21 +600,22 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* The vertical search returns early if it runs into anything that is not a multi-block plant
|
* The vertical search returns early if it runs into anything that is not a multi-block plant
|
||||||
* Multi-block plants are hard-coded and kept in {@link MaterialMapStore}
|
* Multi-block plants are hard-coded and kept in {@link MaterialMapStore}
|
||||||
*
|
*
|
||||||
* @param breakPointBlockState The point of the "break"
|
* @param originBlock The point of the "break"
|
||||||
* @return A set of blocks above the target block which can be assumed to be broken
|
* @return A set of blocks above the target block which can be assumed to be broken
|
||||||
*/
|
*/
|
||||||
private HashSet<Block> getBlocksBrokenAbove(BlockState breakPointBlockState) {
|
private HashSet<Block> getBlocksBrokenAbove(BlockState originBlock, boolean inclusive) {
|
||||||
HashSet<Block> brokenBlocks = new HashSet<>();
|
HashSet<Block> brokenBlocks = new HashSet<>();
|
||||||
Block block = breakPointBlockState.getBlock();
|
Block block = originBlock.getBlock();
|
||||||
|
|
||||||
//Add the initial block to the set
|
//Add the initial block to the set
|
||||||
brokenBlocks.add(block);
|
if(inclusive)
|
||||||
|
brokenBlocks.add(block);
|
||||||
|
|
||||||
//Limit our search
|
//Limit our search
|
||||||
int maxHeight = 255;
|
int maxHeight = 512;
|
||||||
|
|
||||||
// Search vertically for multi-block plants, exit early if any non-multi block plants
|
// Search vertically for multi-block plants, exit early if any non-multi block plants
|
||||||
for (int y = 1; y < maxHeight; y++) {
|
for (int y = 0; y < maxHeight; y++) {
|
||||||
//TODO: Should this grab state? It would be more expensive..
|
//TODO: Should this grab state? It would be more expensive..
|
||||||
Block relativeUpBlock = block.getRelative(BlockFace.UP, y);
|
Block relativeUpBlock = block.getRelative(BlockFace.UP, y);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user