@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); } } } }
@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); } }
@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); } }
if (!growEvent.isCancelled()) { blockState.update(true);
@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(block, state); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { state.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); } } }
BlockGrowEvent growEvent = new BlockGrowEvent(blockAbove, state); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { state.update(true);
BlockGrowEvent growEvent = new BlockGrowEvent(blockAbove, state); EventFactory.getInstance().callEvent(growEvent); if (!growEvent.isCancelled()) { state.update(true);