mcMMO/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java

109 lines
4.0 KiB
Java
Raw Normal View History

package com.gmail.nossr50.skills.herbalism;
2012-01-09 20:00:13 +01:00
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
2012-02-24 07:02:23 +01:00
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
2012-01-09 20:00:13 +01:00
2012-03-10 19:03:31 +01:00
public class Herbalism {
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
public static int farmersDietRankLevel2 = farmersDietRankLevel1 * 2;
public static int farmersDietMaxLevel = farmersDietRankLevel1 * 5;
public static int greenThumbStageChangeLevel = AdvancedConfig.getInstance().getGreenThumbStageChange();
public static int greenThumbStageMaxLevel = greenThumbStageChangeLevel * 4;
public static double greenThumbMaxChance = AdvancedConfig.getInstance().getGreenThumbChanceMax();
public static int greenThumbMaxLevel = AdvancedConfig.getInstance().getGreenThumbMaxLevel();
public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getHerbalismDoubleDropsChanceMax();
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getHerbalismDoubleDropsMaxLevel();
public static double hylianLuckMaxChance = AdvancedConfig.getInstance().getHylianLuckChanceMax();
2013-02-21 00:20:34 +01:00
public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLuckMaxLevel();
2012-03-26 17:04:17 +02:00
public static double shroomThumbMaxChance = AdvancedConfig.getInstance().getShroomThumbChanceMax();
public static int shroomThumbMaxLevel = AdvancedConfig.getInstance().getShroomThumbMaxLevel();
/**
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
switch (blockState.getType()) {
case COBBLE_WALL:
case SMOOTH_BRICK:
blockState.setRawData((byte) 0x1);
return true;
2013-01-26 01:21:33 +01:00
case DIRT:
blockState.setType(Material.GRASS);
return true;
2013-01-26 01:21:33 +01:00
case COBBLESTONE:
blockState.setType(Material.MOSSY_COBBLESTONE);
return true;
2013-01-26 01:21:33 +01:00
default:
return false;
2012-03-10 19:03:31 +01:00
}
}
/**
* Calculate the drop amounts for cacti & sugar cane based on the blocks above them.
*
* @param blockState The {@link BlockState} of the bottom block of the plant
* @return the number of bonus drops to award from the blocks in this plant
*/
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
Block block = blockState.getBlock();
Material blockType = blockState.getType();
int dropAmount = 0;
// Handle the original block
if (!mcMMO.placeStore.isTrue(blockState)) {
dropAmount++;
}
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
for (int y = 1; y < 3; y++) {
Block relativeBlock = block.getRelative(BlockFace.UP, y);
Material relativeBlockType = relativeBlock.getType();
// If the first one is air, so is the next one
if (relativeBlockType == Material.AIR) {
break;
}
if (relativeBlockType == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) {
dropAmount++;
}
}
return dropAmount;
}
/**
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertShroomThumb(BlockState blockState) {
switch (blockState.getType()){
case DIRT:
case GRASS:
blockState.setType(Material.MYCEL);
return true;
default:
return false;
}
}
}