@Override public void updateBlock(GlowBlock block) { int cropState = block.getData(); if (cropState < NetherWartsState.RIPE.ordinal() && ThreadLocalRandom.current().nextInt(10) == 0) { cropState++; GlowBlockState state = block.getState(); state.setRawData((byte) cropState); BlockGrowEvent growEvent = new BlockGrowEvent(block, state); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { state.update(true); } } } }
/** * @param event */ @EventHandler(priority = EventPriority.HIGH) public void onBlockGrow(BlockGrowEvent event) { if (event.getBlock() == null) { return; } Field field = plugin.getForceFieldManager().getEnabledSourceField(event.getBlock().getLocation(), FieldFlag.NO_GROWTH); if (field != null) { event.setCancelled(true); } }
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true) public void onBlockGrow(BlockGrowEvent event) { Location loc = event.getBlock().getLocation(); String wn = getWorld(loc.getWorld()).getName(); sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockgrow"); } };
@EventHandler(priority = EventPriority.HIGH) public void onBlockGrow(BlockGrowEvent e) { Block newBlock = e.getNewState().getBlock(); if (shopUtils.isShop(newBlock.getLocation()) || shopUtils.isShop(newBlock.getRelative(BlockFace.DOWN).getLocation())) { e.setCancelled(true); } }
@Override public MCBlockState getNewState() { return new BukkitMCBlockState(bge.getNewState()); } }
@EventHandler(ignoreCancelled = true) public void onBlockGrow(BlockGrowEvent grow) { Game game = BedwarsRel.getInstance().getGameManager().getGameByLocation(grow.getBlock().getLocation()); if (game == null) { return; } grow.setCancelled(true); }
@Override public MCBlock getBlock() { return new BukkitMCBlock(bge.getBlock()); }
@EventHandler(ignoreCancelled = true) public void onBlockGrow(BlockGrowEvent grow) { Game game = BedwarsRel.getInstance().getGameManager().getGameByLocation(grow.getBlock().getLocation()); if (game == null) { return; } grow.setCancelled(true); }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockGrow(BlockGrowEvent event) { /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) return; BlockState blockState = event.getBlock().getState(); if (!BlockUtils.shouldBeWatched(blockState)) { return; } mcMMO.getPlaceStore().setFalse(blockState); }
@Override public void grow(GlowPlayer player, GlowBlock block) { GlowBlockState state = block.getState(); int cropState = block.getData() + ThreadLocalRandom.current().nextInt(CropState.MEDIUM.ordinal()) + CropState.VERY_SMALL.ordinal(); if (cropState > CropState.RIPE.ordinal()) { cropState = CropState.RIPE.ordinal(); } state.setRawData((byte) cropState); BlockGrowEvent growEvent = new BlockGrowEvent(block, state); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { state.update(true); } }
@EventHandler public void onCropGrow(BlockGrowEvent event) { WorldClimateEngine worldEngine = ClimateEngine.getInstance().getClimateEngine(event.getBlock().getWorld().getUID()); if (worldEngine != null && worldEngine.isEffectEnabled(ClimateEffectType.FARM_YIELD)) { Distribution distribution = cropDistribution.get(event.getBlock().getType()); if (distribution != null) { double random = GlobalWarming.getInstance().getRandom().nextDouble(); double chance = distribution.getValue(worldEngine.getTemperature()); if (chance / 100.f <= random) { event.setCancelled(true); } } } }
@EventHandler public void onCropGrow(BlockGrowEvent e) { FLocation floc = new FLocation(e.getBlock().getLocation()); Faction factionAtLoc = Board.getInstance().getFactionAt(floc); if (!factionAtLoc.isWilderness()) { int level = factionAtLoc.getUpgrade(Upgrade.CROP); if (level != 0) { int chance = -1; switch (level) { case 1: chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-1"); break; case 2: chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-2"); break; case 3: chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-3"); break; } if (chance >= 0) { int randomNum = ThreadLocalRandom.current().nextInt(1, 100 + 1); if (randomNum <= chance) growCrop(e); } } } }
@Override public void grow(GlowPlayer player, GlowBlock block) { GlowBlockState state = block.getState(); int cropState = block.getData() + ThreadLocalRandom.current().nextInt(CropState.MEDIUM.ordinal()) + CropState.VERY_SMALL.ordinal(); if (cropState > CropState.RIPE.ordinal()) { cropState = CropState.RIPE.ordinal(); } state.setRawData((byte) cropState); BlockGrowEvent growEvent = new BlockGrowEvent(block, state); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { state.update(true); } }
private void growCrop(BlockGrowEvent e) { if (e.getBlock().getType().equals(SavageFactions.plugin.CROPS)) { e.setCancelled(true); Crops c = new Crops(CropState.RIPE); BlockState bs = e.getBlock().getState(); bs.setData(c); bs.update(); } Block below = e.getBlock().getLocation().subtract(0, 1, 0).getBlock(); if (below.getType() == SavageFactions.plugin.SUGAR_CANE_BLOCK) { Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock(); if (above.getType() == Material.AIR && above.getLocation().add(0, - 2, 0).getBlock().getType() != Material.AIR) { above.setType(SavageFactions.plugin.SUGAR_CANE_BLOCK); } } else if (below.getType() == Material.CACTUS) { Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock(); if (above.getType() == Material.AIR && above.getLocation().add(0, - 2, 0).getBlock().getType() != Material.AIR) { above.setType(Material.CACTUS); } } } }
@EventHandler(ignoreCancelled = true) public void onPlantGrowth(BlockGrowEvent event) { Block plant = event.getBlock(); Material species = plant.getType(); if (!plants.contains(species)) {
@Override public void updateBlock(GlowBlock block) { MaterialData data = block.getState().getData(); if (data instanceof CocoaPlant) { CocoaPlant cocoa = (CocoaPlant) data; CocoaPlantSize size = cocoa.getSize(); if (size != CocoaPlantSize.LARGE && ThreadLocalRandom.current().nextInt(5) == 0) { if (size == CocoaPlantSize.SMALL) { cocoa.setSize(CocoaPlantSize.MEDIUM); } else if (size == CocoaPlantSize.MEDIUM) { cocoa.setSize(CocoaPlantSize.LARGE); } else { return; } GlowBlockState state = block.getState(); state.setData(cocoa); BlockGrowEvent growEvent = new BlockGrowEvent(block, state); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { state.update(true); } } } else { warnMaterialData(CocoaPlant.class, data); } } }
@Override public void updateBlock(GlowBlock block) { GlowBlockState state = block.getState(); int cropState = block.getData(); // we check light level on the above block, meaning the crops need at least one free block // above them in order to grow naturally (vanilla behavior) if (cropState < CropState.RIPE.ordinal() && block.getRelative(BlockFace.UP).getLightLevel() >= 9 && ThreadLocalRandom.current() .nextInt((int) (25.0F / getGrowthRateModifier(block)) + 1) == 0) { cropState++; if (cropState > CropState.RIPE.ordinal()) { cropState = CropState.RIPE.ordinal(); } state.setRawData((byte) cropState); BlockGrowEvent growEvent = new BlockGrowEvent(block, state); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { state.update(true); } } // we check for insufficient light on the block itself, then drop if (block.getLightLevel() < 8) { block.breakNaturally(); } }
@Override public void grow(GlowPlayer player, GlowBlock block) { MaterialData data = block.getState().getData(); if (data instanceof CocoaPlant) { CocoaPlant cocoa = (CocoaPlant) data; CocoaPlantSize size = cocoa.getSize(); if (size == CocoaPlantSize.SMALL) { cocoa.setSize(CocoaPlantSize.MEDIUM); } else if (size == CocoaPlantSize.MEDIUM) { cocoa.setSize(CocoaPlantSize.LARGE); } else { return; } GlowBlockState state = block.getState(); state.setData(cocoa); BlockGrowEvent growEvent = new BlockGrowEvent(block, state); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { state.update(true); } } else { warnMaterialData(CocoaPlant.class, data); } }
BlockGrowEvent growEvent = new BlockGrowEvent(b, blockState); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { blockState.update(true);
@Override public void grow(GlowPlayer player, GlowBlock block) { MaterialData data = block.getState().getData(); if (data instanceof LongGrass) { GrassSpecies species = ((LongGrass) data).getSpecies(); if (species == GrassSpecies.NORMAL || species == GrassSpecies.FERN_LIKE) { GlowBlockState headBlockState = block.getRelative(BlockFace.UP).getState(); if (headBlockState.getType() == Material.AIR) { DoublePlantSpecies doublePlantSpecies = species == GrassSpecies.FERN_LIKE ? DoublePlantSpecies.LARGE_FERN : DoublePlantSpecies.DOUBLE_TALLGRASS; GlowBlockState blockState = block.getState(); blockState.setType(Material.DOUBLE_PLANT); blockState.setData(new DoublePlant(doublePlantSpecies)); headBlockState.setType(Material.DOUBLE_PLANT); headBlockState.setData(new DoublePlant(DoublePlantSpecies.PLANT_APEX)); BlockGrowEvent growEvent = new BlockGrowEvent(block, blockState); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { blockState.update(true); headBlockState.update(true); } } } } else { warnMaterialData(LongGrass.class, data); } } }