2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.util;
|
|
|
|
|
2019-03-24 00:21:25 +01:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2017-06-10 19:47:20 +02:00
|
|
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
2019-01-13 08:54:53 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
2019-03-24 00:21:25 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
2018-07-24 04:13:57 +02:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2013-05-21 17:11:55 +02:00
|
|
|
import com.gmail.nossr50.skills.repair.Repair;
|
2013-03-06 18:31:48 +01:00
|
|
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
2019-03-24 00:21:25 +01:00
|
|
|
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
|
|
|
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
2018-07-24 04:13:57 +02:00
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.block.BlockState;
|
2018-10-10 03:48:47 +02:00
|
|
|
import org.bukkit.block.data.Ageable;
|
|
|
|
import org.bukkit.block.data.BlockData;
|
2019-03-24 00:21:25 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2019-03-29 19:27:49 +01:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
2018-07-24 04:13:57 +02:00
|
|
|
|
|
|
|
import java.util.HashSet;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
public final class BlockUtils {
|
2017-06-10 19:47:20 +02:00
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
private BlockUtils() {}
|
|
|
|
|
2019-03-24 00:21:25 +01:00
|
|
|
/**
|
|
|
|
* Mark a block for giving bonus drops, double drops are used if triple is false
|
|
|
|
* @param blockState target blockstate
|
|
|
|
* @param triple marks the block to give triple drops
|
|
|
|
*/
|
2019-03-29 19:27:49 +01:00
|
|
|
public static void spawnBonusDrops(BlockState blockState, boolean triple)
|
2019-03-24 00:21:25 +01:00
|
|
|
{
|
2019-03-29 19:27:49 +01:00
|
|
|
for(ItemStack spawnItem : blockState.getBlock().getDrops())
|
|
|
|
{
|
|
|
|
if(triple)
|
|
|
|
blockState.getWorld().dropItemNaturally(blockState.getLocation(), spawnItem);
|
|
|
|
|
|
|
|
blockState.getWorld().dropItemNaturally(blockState.getLocation(), spawnItem);
|
|
|
|
}
|
2019-03-24 00:21:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if a player successfully passed the double drop check
|
|
|
|
* @param blockState the blockstate
|
|
|
|
* @return true if the player succeeded in the check
|
|
|
|
*/
|
|
|
|
public static boolean checkDoubleDrops(Player player, BlockState blockState, PrimarySkillType skillType, SubSkillType subSkillType)
|
|
|
|
{
|
|
|
|
if(Config.getInstance().getDoubleDropsEnabled(skillType, blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType))
|
|
|
|
{
|
|
|
|
return RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType, true));
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
/**
|
|
|
|
* Checks to see if a given block awards XP.
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the block awards XP, false otherwise
|
|
|
|
*/
|
|
|
|
public static boolean shouldBeWatched(BlockState blockState) {
|
2013-05-16 14:41:57 +02:00
|
|
|
return affectedByGigaDrillBreaker(blockState) || affectedByGreenTerra(blockState) || affectedBySuperBreaker(blockState) || isLog(blockState);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a given block should allow for the activation of abilities
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
|
|
|
* @return true if the block should allow ability activation, false
|
|
|
|
* otherwise
|
2013-03-01 06:52:01 +01:00
|
|
|
*/
|
|
|
|
public static boolean canActivateAbilities(BlockState blockState) {
|
|
|
|
switch (blockState.getType()) {
|
2018-07-24 04:13:57 +02:00
|
|
|
case BLACK_BED:
|
|
|
|
case BLUE_BED:
|
|
|
|
case BROWN_BED:
|
|
|
|
case CYAN_BED:
|
|
|
|
case GRAY_BED:
|
|
|
|
case GREEN_BED:
|
|
|
|
case LIGHT_BLUE_BED:
|
|
|
|
case LIGHT_GRAY_BED:
|
|
|
|
case LIME_BED:
|
|
|
|
case MAGENTA_BED:
|
|
|
|
case ORANGE_BED:
|
|
|
|
case PINK_BED:
|
|
|
|
case PURPLE_BED:
|
|
|
|
case RED_BED:
|
|
|
|
case WHITE_BED:
|
|
|
|
case YELLOW_BED:
|
2017-06-10 19:47:20 +02:00
|
|
|
case BREWING_STAND :
|
|
|
|
case BOOKSHELF :
|
2018-07-24 04:13:57 +02:00
|
|
|
case CAKE:
|
2017-06-10 19:47:20 +02:00
|
|
|
case CHEST :
|
|
|
|
case DISPENSER :
|
2018-07-24 04:13:57 +02:00
|
|
|
case ENCHANTING_TABLE:
|
2017-06-10 19:47:20 +02:00
|
|
|
case ENDER_CHEST :
|
2018-07-24 04:13:57 +02:00
|
|
|
case OAK_FENCE_GATE:
|
2017-06-10 19:47:20 +02:00
|
|
|
case ACACIA_FENCE_GATE :
|
|
|
|
case DARK_OAK_FENCE_GATE :
|
|
|
|
case SPRUCE_FENCE_GATE :
|
|
|
|
case BIRCH_FENCE_GATE :
|
|
|
|
case JUNGLE_FENCE_GATE :
|
|
|
|
case FURNACE :
|
|
|
|
case JUKEBOX :
|
|
|
|
case LEVER :
|
|
|
|
case NOTE_BLOCK :
|
|
|
|
case STONE_BUTTON :
|
2018-07-24 04:13:57 +02:00
|
|
|
case OAK_BUTTON:
|
|
|
|
case BIRCH_BUTTON:
|
|
|
|
case ACACIA_BUTTON:
|
|
|
|
case DARK_OAK_BUTTON:
|
|
|
|
case JUNGLE_BUTTON:
|
|
|
|
case SPRUCE_BUTTON:
|
|
|
|
case ACACIA_TRAPDOOR:
|
|
|
|
case BIRCH_TRAPDOOR:
|
|
|
|
case DARK_OAK_TRAPDOOR:
|
|
|
|
case JUNGLE_TRAPDOOR:
|
|
|
|
case OAK_TRAPDOOR:
|
|
|
|
case SPRUCE_TRAPDOOR:
|
2017-06-10 19:47:20 +02:00
|
|
|
case WALL_SIGN :
|
2018-07-24 04:13:57 +02:00
|
|
|
case CRAFTING_TABLE:
|
2017-06-10 19:47:20 +02:00
|
|
|
case BEACON :
|
|
|
|
case ANVIL :
|
|
|
|
case DROPPER :
|
|
|
|
case HOPPER :
|
|
|
|
case TRAPPED_CHEST :
|
|
|
|
case IRON_DOOR :
|
|
|
|
case IRON_TRAPDOOR :
|
2018-07-24 04:13:57 +02:00
|
|
|
case OAK_DOOR:
|
2017-06-10 19:47:20 +02:00
|
|
|
case ACACIA_DOOR :
|
|
|
|
case SPRUCE_DOOR :
|
|
|
|
case BIRCH_DOOR :
|
|
|
|
case JUNGLE_DOOR :
|
|
|
|
case DARK_OAK_DOOR :
|
2018-07-24 04:13:57 +02:00
|
|
|
case OAK_FENCE:
|
2017-06-10 19:47:20 +02:00
|
|
|
case ACACIA_FENCE :
|
|
|
|
case DARK_OAK_FENCE :
|
|
|
|
case BIRCH_FENCE :
|
|
|
|
case JUNGLE_FENCE :
|
|
|
|
case SPRUCE_FENCE :
|
|
|
|
case ARMOR_STAND :
|
2018-04-30 08:09:52 +02:00
|
|
|
case BLACK_SHULKER_BOX :
|
|
|
|
case BLUE_SHULKER_BOX :
|
|
|
|
case BROWN_SHULKER_BOX :
|
|
|
|
case CYAN_SHULKER_BOX :
|
|
|
|
case GRAY_SHULKER_BOX :
|
|
|
|
case GREEN_SHULKER_BOX :
|
|
|
|
case LIGHT_BLUE_SHULKER_BOX :
|
|
|
|
case LIME_SHULKER_BOX :
|
|
|
|
case MAGENTA_SHULKER_BOX :
|
|
|
|
case ORANGE_SHULKER_BOX :
|
|
|
|
case PINK_SHULKER_BOX :
|
|
|
|
case PURPLE_SHULKER_BOX :
|
|
|
|
case RED_SHULKER_BOX :
|
2018-07-24 04:13:57 +02:00
|
|
|
case LIGHT_GRAY_SHULKER_BOX:
|
2018-04-30 08:09:52 +02:00
|
|
|
case WHITE_SHULKER_BOX :
|
|
|
|
case YELLOW_SHULKER_BOX :
|
2013-03-01 06:52:01 +01:00
|
|
|
return false;
|
|
|
|
|
2017-06-10 19:47:20 +02:00
|
|
|
default :
|
2015-07-26 04:29:19 +02:00
|
|
|
return !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-20 12:17:01 +01:00
|
|
|
/**
|
|
|
|
* Check if a given block should allow for the activation of tools
|
|
|
|
* Activating a tool is step 1 of a 2 step process for super ability activation
|
|
|
|
*
|
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
|
|
|
* @return true if the block should allow ability activation, false
|
|
|
|
* otherwise
|
|
|
|
*/
|
|
|
|
public static boolean canActivateTools(BlockState blockState) {
|
|
|
|
switch (blockState.getType()) {
|
|
|
|
case BLACK_BED:
|
|
|
|
case BLUE_BED:
|
|
|
|
case BROWN_BED:
|
|
|
|
case CYAN_BED:
|
|
|
|
case GRAY_BED:
|
|
|
|
case GREEN_BED:
|
|
|
|
case LIGHT_BLUE_BED:
|
|
|
|
case LIGHT_GRAY_BED:
|
|
|
|
case LIME_BED:
|
|
|
|
case MAGENTA_BED:
|
|
|
|
case ORANGE_BED:
|
|
|
|
case PINK_BED:
|
|
|
|
case PURPLE_BED:
|
|
|
|
case RED_BED:
|
|
|
|
case WHITE_BED:
|
|
|
|
case YELLOW_BED:
|
|
|
|
case BREWING_STAND :
|
|
|
|
case BOOKSHELF :
|
|
|
|
case CAKE:
|
|
|
|
case CHEST :
|
|
|
|
case DISPENSER :
|
|
|
|
case ENCHANTING_TABLE:
|
|
|
|
case ENDER_CHEST :
|
|
|
|
case OAK_FENCE_GATE:
|
|
|
|
case ACACIA_FENCE_GATE :
|
|
|
|
case DARK_OAK_FENCE_GATE :
|
|
|
|
case SPRUCE_FENCE_GATE :
|
|
|
|
case BIRCH_FENCE_GATE :
|
|
|
|
case JUNGLE_FENCE_GATE :
|
|
|
|
case FURNACE :
|
|
|
|
case JUKEBOX :
|
|
|
|
case LEVER :
|
|
|
|
case NOTE_BLOCK :
|
|
|
|
case STONE_BUTTON :
|
|
|
|
case OAK_BUTTON:
|
|
|
|
case BIRCH_BUTTON:
|
|
|
|
case ACACIA_BUTTON:
|
|
|
|
case DARK_OAK_BUTTON:
|
|
|
|
case JUNGLE_BUTTON:
|
|
|
|
case SPRUCE_BUTTON:
|
|
|
|
case ACACIA_TRAPDOOR:
|
|
|
|
case BIRCH_TRAPDOOR:
|
|
|
|
case DARK_OAK_TRAPDOOR:
|
|
|
|
case JUNGLE_TRAPDOOR:
|
|
|
|
case OAK_TRAPDOOR:
|
|
|
|
case SPRUCE_TRAPDOOR:
|
|
|
|
case WALL_SIGN :
|
|
|
|
case CRAFTING_TABLE:
|
|
|
|
case BEACON :
|
|
|
|
case ANVIL :
|
|
|
|
case DROPPER :
|
|
|
|
case HOPPER :
|
|
|
|
case TRAPPED_CHEST :
|
|
|
|
case IRON_DOOR :
|
|
|
|
case IRON_TRAPDOOR :
|
|
|
|
case OAK_DOOR:
|
|
|
|
case ACACIA_DOOR :
|
|
|
|
case SPRUCE_DOOR :
|
|
|
|
case BIRCH_DOOR :
|
|
|
|
case JUNGLE_DOOR :
|
|
|
|
case DARK_OAK_DOOR :
|
|
|
|
case OAK_FENCE:
|
|
|
|
case ACACIA_FENCE :
|
|
|
|
case DARK_OAK_FENCE :
|
|
|
|
case BIRCH_FENCE :
|
|
|
|
case JUNGLE_FENCE :
|
|
|
|
case SPRUCE_FENCE :
|
|
|
|
case ARMOR_STAND :
|
|
|
|
case BLACK_SHULKER_BOX :
|
|
|
|
case BLUE_SHULKER_BOX :
|
|
|
|
case BROWN_SHULKER_BOX :
|
|
|
|
case CYAN_SHULKER_BOX :
|
|
|
|
case GRAY_SHULKER_BOX :
|
|
|
|
case GREEN_SHULKER_BOX :
|
|
|
|
case LIGHT_BLUE_SHULKER_BOX :
|
|
|
|
case LIME_SHULKER_BOX :
|
|
|
|
case MAGENTA_SHULKER_BOX :
|
|
|
|
case ORANGE_SHULKER_BOX :
|
|
|
|
case PINK_SHULKER_BOX :
|
|
|
|
case PURPLE_SHULKER_BOX :
|
|
|
|
case RED_SHULKER_BOX :
|
|
|
|
case LIGHT_GRAY_SHULKER_BOX:
|
|
|
|
case WHITE_SHULKER_BOX :
|
|
|
|
case YELLOW_SHULKER_BOX :
|
|
|
|
case STRIPPED_ACACIA_LOG:
|
|
|
|
case STRIPPED_ACACIA_WOOD:
|
|
|
|
case STRIPPED_BIRCH_LOG:
|
|
|
|
case STRIPPED_BIRCH_WOOD:
|
|
|
|
case STRIPPED_DARK_OAK_LOG:
|
|
|
|
case STRIPPED_DARK_OAK_WOOD:
|
|
|
|
case STRIPPED_JUNGLE_LOG:
|
|
|
|
case STRIPPED_JUNGLE_WOOD:
|
|
|
|
case STRIPPED_OAK_LOG:
|
|
|
|
case STRIPPED_OAK_WOOD:
|
|
|
|
case STRIPPED_SPRUCE_LOG:
|
|
|
|
case STRIPPED_SPRUCE_WOOD:
|
|
|
|
case ACACIA_LOG:
|
|
|
|
case ACACIA_WOOD:
|
|
|
|
case BIRCH_LOG:
|
|
|
|
case BIRCH_WOOD:
|
|
|
|
case DARK_OAK_LOG:
|
|
|
|
case DARK_OAK_WOOD:
|
|
|
|
case JUNGLE_LOG:
|
|
|
|
case JUNGLE_WOOD:
|
|
|
|
case OAK_LOG:
|
|
|
|
case OAK_WOOD:
|
|
|
|
case SPRUCE_LOG:
|
|
|
|
case SPRUCE_WOOD:
|
|
|
|
return false;
|
|
|
|
|
|
|
|
default :
|
|
|
|
return !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
/**
|
|
|
|
* Check if a given block is an ore
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the block is an ore, false otherwise
|
|
|
|
*/
|
|
|
|
public static boolean isOre(BlockState blockState) {
|
2018-10-10 03:48:47 +02:00
|
|
|
return MaterialUtils.isOre(blockState.getType());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a given block can be made mossy
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the block can be made mossy, false otherwise
|
|
|
|
*/
|
|
|
|
public static boolean canMakeMossy(BlockState blockState) {
|
|
|
|
switch (blockState.getType()) {
|
2017-06-10 19:47:20 +02:00
|
|
|
case COBBLESTONE :
|
|
|
|
case DIRT :
|
|
|
|
case GRASS_PATH :
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
2018-07-24 04:13:57 +02:00
|
|
|
case STONE_BRICKS:
|
|
|
|
return true;
|
2013-09-05 22:36:02 +02:00
|
|
|
|
2018-07-24 04:13:57 +02:00
|
|
|
case COBBLESTONE_WALL:
|
|
|
|
return true;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2017-06-10 19:47:20 +02:00
|
|
|
default :
|
2013-03-01 06:52:01 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a given block should be affected by Green Terra
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the block should affected by Green Terra, false otherwise
|
|
|
|
*/
|
|
|
|
public static boolean affectedByGreenTerra(BlockState blockState) {
|
2019-01-15 13:36:35 +01:00
|
|
|
if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.HERBALISM, blockState.getBlockData())) {
|
2017-06-10 19:47:20 +02:00
|
|
|
return true;
|
2018-07-27 01:53:29 +02:00
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2017-06-10 19:47:20 +02:00
|
|
|
return mcMMO.getModManager().isCustomHerbalismBlock(blockState);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a given block should be affected by Super Breaker
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
|
|
|
* @return true if the block should affected by Super Breaker, false
|
|
|
|
* otherwise
|
2013-03-01 06:52:01 +01:00
|
|
|
*/
|
|
|
|
public static Boolean affectedBySuperBreaker(BlockState blockState) {
|
2019-01-15 13:36:35 +01:00
|
|
|
if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.MINING, blockState.getBlockData()))
|
2017-06-10 19:47:20 +02:00
|
|
|
return true;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2017-06-10 19:47:20 +02:00
|
|
|
return isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a given block should be affected by Giga Drill Breaker
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
|
|
|
* @return true if the block should affected by Giga Drill Breaker, false
|
|
|
|
* otherwise
|
2013-03-01 06:52:01 +01:00
|
|
|
*/
|
|
|
|
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
|
2019-01-15 13:36:35 +01:00
|
|
|
if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.EXCAVATION, blockState.getBlockData()))
|
2017-06-10 19:47:20 +02:00
|
|
|
return true;
|
|
|
|
return mcMMO.getModManager().isCustomExcavationBlock(blockState);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a given block is a log
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the block is a log, false otherwise
|
|
|
|
*/
|
|
|
|
public static boolean isLog(BlockState blockState) {
|
2019-01-15 13:36:35 +01:00
|
|
|
if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.WOODCUTTING, blockState.getBlockData()))
|
2017-06-10 19:47:20 +02:00
|
|
|
return true;
|
|
|
|
return mcMMO.getModManager().isCustomLog(blockState);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a given block is a leaf
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the block is a leaf, false otherwise
|
|
|
|
*/
|
|
|
|
public static boolean isLeaves(BlockState blockState) {
|
|
|
|
switch (blockState.getType()) {
|
2018-07-24 04:13:57 +02:00
|
|
|
case OAK_LEAVES:
|
|
|
|
case ACACIA_LEAVES:
|
|
|
|
case BIRCH_LEAVES:
|
|
|
|
case DARK_OAK_LEAVES:
|
|
|
|
case JUNGLE_LEAVES:
|
|
|
|
case SPRUCE_LEAVES:
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
2017-06-10 19:47:20 +02:00
|
|
|
default :
|
2014-02-03 20:48:43 +01:00
|
|
|
return mcMMO.getModManager().isCustomLeaf(blockState);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a given block should be affected by Flux Mining
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
2013-03-01 06:52:01 +01:00
|
|
|
* @return true if the block should affected by Flux Mining, false otherwise
|
|
|
|
*/
|
|
|
|
public static boolean affectedByFluxMining(BlockState blockState) {
|
|
|
|
switch (blockState.getType()) {
|
2017-06-10 19:47:20 +02:00
|
|
|
case IRON_ORE :
|
|
|
|
case GOLD_ORE :
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
2017-06-10 19:47:20 +02:00
|
|
|
default :
|
2013-03-01 06:52:01 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a given block can activate Herbalism abilities
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
|
|
|
* @return true if the block can be activate Herbalism abilities, false
|
|
|
|
* otherwise
|
2013-03-01 06:52:01 +01:00
|
|
|
*/
|
|
|
|
public static boolean canActivateHerbalism(BlockState blockState) {
|
|
|
|
switch (blockState.getType()) {
|
2017-06-10 19:47:20 +02:00
|
|
|
case DIRT :
|
|
|
|
case GRASS :
|
|
|
|
case GRASS_PATH :
|
2018-07-24 04:13:57 +02:00
|
|
|
case FARMLAND:
|
2013-03-01 06:52:01 +01:00
|
|
|
return false;
|
|
|
|
|
2017-06-10 19:47:20 +02:00
|
|
|
default :
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a given block should be affected by Block Cracker
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
|
|
|
* @return true if the block should affected by Block Cracker, false
|
|
|
|
* otherwise
|
2013-03-01 06:52:01 +01:00
|
|
|
*/
|
|
|
|
public static boolean affectedByBlockCracker(BlockState blockState) {
|
|
|
|
switch (blockState.getType()) {
|
2018-07-24 04:13:57 +02:00
|
|
|
case STONE_BRICKS:
|
|
|
|
return true;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2017-06-10 19:47:20 +02:00
|
|
|
default :
|
2013-03-01 06:52:01 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a given block can be made into Mycelium
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
2013-12-02 18:08:12 +01:00
|
|
|
* @return true if the block can be made into Mycelium, false otherwise
|
2013-03-01 06:52:01 +01:00
|
|
|
*/
|
|
|
|
public static boolean canMakeShroomy(BlockState blockState) {
|
|
|
|
switch (blockState.getType()) {
|
2017-06-10 19:47:20 +02:00
|
|
|
case DIRT :
|
|
|
|
case GRASS :
|
|
|
|
case GRASS_PATH :
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
|
2017-06-10 19:47:20 +02:00
|
|
|
default :
|
2013-03-01 06:52:01 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2013-05-16 14:41:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a given block is an mcMMO anvil
|
|
|
|
*
|
2017-06-10 19:47:20 +02:00
|
|
|
* @param blockState
|
|
|
|
* The {@link BlockState} of the block to check
|
2013-05-16 14:41:57 +02:00
|
|
|
* @return true if the block is an mcMMO anvil, false otherwise
|
|
|
|
*/
|
2013-05-21 17:11:55 +02:00
|
|
|
public static boolean isMcMMOAnvil(BlockState blockState) {
|
2013-09-13 15:12:21 +02:00
|
|
|
Material type = blockState.getType();
|
2013-05-16 14:41:57 +02:00
|
|
|
|
2013-03-06 18:31:48 +01:00
|
|
|
return type == Repair.anvilMaterial || type == Salvage.anvilMaterial;
|
2013-05-16 14:41:57 +02:00
|
|
|
}
|
2013-08-17 10:11:46 +02:00
|
|
|
|
2014-06-15 14:22:32 +02:00
|
|
|
public static boolean isPistonPiece(BlockState blockState) {
|
|
|
|
Material type = blockState.getType();
|
|
|
|
|
2018-07-24 04:13:57 +02:00
|
|
|
return type == Material.MOVING_PISTON || type == Material.AIR;
|
2014-06-15 14:22:32 +02:00
|
|
|
}
|
|
|
|
|
2013-08-17 10:11:46 +02:00
|
|
|
/**
|
|
|
|
* Get a HashSet containing every transparent block
|
|
|
|
*
|
|
|
|
* @return HashSet with the IDs of every transparent block
|
|
|
|
*/
|
2017-08-05 20:50:24 +02:00
|
|
|
public static HashSet<Material> getTransparentBlocks() {
|
|
|
|
HashSet<Material> transparentBlocks = new HashSet<Material>();
|
2013-08-19 21:12:08 +02:00
|
|
|
|
|
|
|
for (Material material : Material.values()) {
|
|
|
|
if (material.isTransparent()) {
|
2017-08-05 20:53:38 +02:00
|
|
|
transparentBlocks.add(material);
|
2013-08-19 21:12:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return transparentBlocks;
|
2013-08-17 10:11:46 +02:00
|
|
|
}
|
2018-10-10 03:48:47 +02:00
|
|
|
|
2018-10-13 23:09:08 +02:00
|
|
|
public static boolean isFullyGrown(BlockState blockState) {
|
2018-10-10 03:48:47 +02:00
|
|
|
BlockData data = blockState.getBlockData();
|
|
|
|
if (data.getMaterial() == Material.CACTUS || data.getMaterial() == Material.SUGAR_CANE)
|
|
|
|
return true;
|
|
|
|
if (data instanceof Ageable)
|
|
|
|
{
|
|
|
|
Ageable ageable = (Ageable) data;
|
|
|
|
return ageable.getAge() == ageable.getMaximumAge();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|