本文整理汇总了Java中org.bukkit.material.Crops类的典型用法代码示例。如果您正苦于以下问题:Java Crops类的具体用法?Java Crops怎么用?Java Crops使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Crops类属于org.bukkit.material包,在下文中一共展示了Crops类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCropState
import org.bukkit.material.Crops; //导入依赖的package包/类
public String getCropState(BlockState blockState) {
switch (blockState.getType()) { // .getBlock().getType()) {
case COCOA:
return ((CocoaPlant) blockState.getData()).getSize().toString();
case NETHER_WARTS:
return ((NetherWarts) blockState.getData()).getState().toString();
case MELON_STEM:
return (int) blockState.getBlock().getData() + "";
case PUMPKIN_STEM:
return (int) blockState.getBlock().getData() + "";
case CACTUS:
return null;
case BROWN_MUSHROOM:
return null;
case RED_MUSHROOM:
return null;
case SUGAR_CANE_BLOCK:
return null;
default:
//CropControl.getPlugin().debug("Unable to find CropState match for {0}", blockState);
return ((Crops) blockState.getData()).getState().toString();
}
}
示例2: isApplicable
import org.bukkit.material.Crops; //导入依赖的package包/类
private boolean isApplicable(Block block)
{
BlockState state = block.getState();
switch (state.getType())
{
case CACTUS:
case MELON_BLOCK:
case PUMPKIN:
return true;
case CROPS:
return ((Crops) state.getData()).getState() == CropState.RIPE;
case NETHER_WARTS:
return ((NetherWarts) state.getData()).getState() == NetherWartsState.RIPE;
case COCOA:
return ((CocoaPlant) state.getData()).getSize() == CocoaPlantSize.LARGE;
default:
return false;
}
}
示例3: affectedByGreenTerra
import org.bukkit.material.Crops; //导入依赖的package包/类
/**
* Determine if a given block should be affected by Green Terra
*
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should affected by Green Terra, false otherwise
*/
public static boolean affectedByGreenTerra(BlockState blockState) {
switch (blockState.getType()) {
case BROWN_MUSHROOM:
case CACTUS:
case DOUBLE_PLANT:
case MELON_BLOCK:
case LONG_GRASS:
case PUMPKIN:
case RED_MUSHROOM:
case RED_ROSE:
case SUGAR_CANE_BLOCK:
case VINE:
case WATER_LILY:
case YELLOW_FLOWER:
return true;
case CARROT:
case POTATO:
return blockState.getRawData() == CropState.RIPE.getData();
case CROPS:
return ((Crops) blockState.getData()).getState() == CropState.RIPE;
case NETHER_WARTS:
return ((NetherWarts) blockState.getData()).getState() == NetherWartsState.RIPE;
case COCOA:
return ((CocoaPlant) blockState.getData()).getSize() == CocoaPlantSize.LARGE;
default:
return mcMMO.getModManager().isCustomHerbalismBlock(blockState);
}
}
示例4: isGrowable
import org.bukkit.material.Crops; //导入依赖的package包/类
private boolean isGrowable(Block block)
{
BlockState state = block.getState();
Material material = block.getType();
MaterialData data = state.getData();
return data instanceof NetherWarts || data instanceof Crops || data instanceof CocoaPlant
|| material == Material.SAPLING || material == Material.RED_MUSHROOM || material == Material.BROWN_MUSHROOM;
}
示例5: canCrops
import org.bukkit.material.Crops; //导入依赖的package包/类
public boolean canCrops(Block b) {
return flagExists("cropsfarm") && (b instanceof Crops || b.getType().equals(Material.PUMPKIN_STEM) || b.getType().equals(Material.MELON_STEM) || b.getType().toString().contains("CROPS") || b.getType().toString().contains("SOIL") || b.getType().toString().contains("CHORUS_") || b.getType().toString().contains("BEETROOT_") || b.getType().toString().contains("SUGAR_CANE")) && getFlagBool("cropsfarm");
}
示例6: onPlayerInteract
import org.bukkit.material.Crops; //导入依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e){
RedProtect.get().logger.debug("BlockListener - Is PlayerInteractEvent event! Cancelled? " + e.isCancelled());
if (e.isCancelled()) {
return;
}
Player p = e.getPlayer();
Location l = e.getClickedBlock().getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
Block b = p.getLocation().getBlock();
if (r != null &&
(b instanceof Crops
|| b.getType().equals(Material.PUMPKIN_STEM)
|| b.getType().equals(Material.MELON_STEM)
|| b.getType().toString().contains("CROPS")
|| b.getType().toString().contains("SOIL")
|| b.getType().toString().contains("CHORUS_")
|| b.getType().toString().contains("BEETROOT_")
|| b.getType().toString().contains("SUGAR_CANE")) && !r.canCrops(b) && !r.canBuild(p)){
RPLang.sendMessage(p, "blocklistener.region.cantbreak");
e.setCancelled(true);
return;
}
try {
for (Block block:p.getLineOfSight(null, 8)){
if (block == null){
continue;
}
if (r != null && block.getType().equals(Material.FIRE) && !r.canBuild(p)){
RPLang.sendMessage(p, "blocklistener.region.cantbreak");
e.setCancelled(true);
return;
}
}
} catch (Exception ignored){
}
}
示例7: handleBlockState
import org.bukkit.material.Crops; //导入依赖的package包/类
private boolean handleBlockState(BlockState blockState, boolean greenTerra) {
byte greenThumbStage = getGreenThumbStage();
blockState.setMetadata(mcMMO.greenThumbDataKey, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
switch (blockState.getType()) {
case CROPS:
Crops crops = (Crops) blockState.getData();
if (greenTerra) {
crops.setState(CropState.MEDIUM);
}
else {
switch (greenThumbStage) {
case 4:
crops.setState(CropState.SMALL);
break;
case 3:
crops.setState(CropState.VERY_SMALL);
break;
case 2:
crops.setState(CropState.GERMINATED);
break;
default:
crops.setState(CropState.SEEDED);
break;
}
}
return true;
case CARROT:
case POTATO:
if (greenTerra) {
blockState.setRawData(CropState.MEDIUM.getData());
}
else {
blockState.setRawData(greenThumbStage);
}
return true;
case NETHER_WARTS:
NetherWarts warts = (NetherWarts) blockState.getData();
if (greenTerra || greenThumbStage > 2) {
warts.setState(NetherWartsState.STAGE_TWO);
}
else if (greenThumbStage == 2) {
warts.setState(NetherWartsState.STAGE_ONE);
}
else {
warts.setState(NetherWartsState.SEEDED);
}
return true;
case COCOA:
CocoaPlant plant = (CocoaPlant) blockState.getData();
if (greenTerra || getGreenThumbStage() > 1) {
plant.setSize(CocoaPlantSize.MEDIUM);
}
else {
plant.setSize(CocoaPlantSize.SMALL);
}
return true;
default:
return false;
}
}
示例8: Crops
import org.bukkit.material.Crops; //导入依赖的package包/类
public Crops() {
}
示例9: clone
import org.bukkit.material.Crops; //导入依赖的package包/类
public Crops clone() {
return null;
}
示例10: runInstaGrow
import org.bukkit.material.Crops; //导入依赖的package包/类
public static void runInstaGrow(UUID id, Block block){
Material b = block.getType();
BlockState bs = block.getState();
Location loc = block.getLocation();
Location down = loc.clone().subtract(0, 1, 0);
Location down2 = loc.clone().subtract(0, 2, 0);
Location up = loc.clone().add(0, 1, 0);
Location up2 = loc.clone().add(0, 2, 0);
Player player = Bukkit.getPlayer(id);
if(canRunAbility(id, AbilityType.INSTAGROW)){
if(b == Material.PUMPKIN_STEM){
block.setType(Material.PUMPKIN);
runAbility(id, AbilityType.INSTAGROW);
}else if(b == Material.MELON_STEM){
block.setType(Material.MELON_BLOCK);
runAbility(id, AbilityType.INSTAGROW);
}else if(b == Material.SUGAR_CANE_BLOCK){
if(down.getBlock().getType() == Material.SUGAR_CANE_BLOCK){
if(up.getBlock().getType() == Material.SUGAR_CANE_BLOCK || down2.getBlock().getType() == Material.SUGAR_CANE_BLOCK){
player.sendMessage("You cannot use InstaGrow on sugar cane taller than 2 blocks");
return;
}
if(up.getBlock().getType() == Material.AIR){
up.getBlock().setType(Material.SUGAR_CANE_BLOCK);
runAbility(id, AbilityType.INSTAGROW);
}
}else{
if(up.getBlock().getType() == Material.AIR){
if(up2.getBlock().getType() == Material.AIR){
up.getBlock().setType(Material.SUGAR_CANE_BLOCK);
up2.getBlock().setType(Material.SUGAR_CANE_BLOCK);
runAbility(id, AbilityType.INSTAGROW);
}else{
up.getBlock().setType(Material.SUGAR_CANE_BLOCK);
runAbility(id, AbilityType.INSTAGROW);
}
}
}
}else if(b == Material.CACTUS){
if(down.getBlock().getType() == Material.CACTUS){
if(up.getBlock().getType() == Material.CACTUS || down2.getBlock().getType() == Material.CACTUS){
player.sendMessage("You cannot use InstaGrow on sugar cane taller than 2 blocks");
return;
}
if(up.getBlock().getType() == Material.AIR){
runAbility(id, AbilityType.INSTAGROW);
}
}else{
if(up.getBlock().getType() == Material.AIR){
if(up2.getBlock().getType() == Material.AIR){
up.getBlock().setType(Material.CACTUS);
up2.getBlock().setType(Material.CACTUS);
runAbility(id, AbilityType.INSTAGROW);
}else{
up.getBlock().setType(Material.CACTUS);
runAbility(id, AbilityType.INSTAGROW);
}
}
}
}else if(b == Material.CROPS){
Crops c = new Crops(b);
c.setState(CropState.RIPE);
bs.setData(c);
bs.update();
runAbility(id, AbilityType.INSTAGROW);
}
}
}
示例11: smelt
import org.bukkit.material.Crops; //导入依赖的package包/类
private static void smelt(Block block, Crops crops, Material material) {
Location location = block.getLocation();
switch (material) {
case IRON_ORE:
drop(Material.IRON_INGOT, 1, location);
break;
case GOLD_ORE:
drop(Material.GOLD_INGOT, 1, location);
break;
case POTATO:
if (crops.getState().equals(CropState.RIPE)) {
drop(Material.BAKED_POTATO, random(), location);
drop(Material.POTATO_ITEM, 1, location);
} else {
drop(Material.POTATO_ITEM, 1, location);
}
break;
}
}