use of net.minecraft.world.level.block.SweetBerryBushBlock in project Create by Creators-of-Create.
the class HarvesterMovementBehaviour method isValidCrop.
public boolean isValidCrop(Level world, BlockPos pos, BlockState state) {
boolean harvestPartial = AllConfigs.SERVER.kinetics.harvestPartiallyGrown.get();
boolean replant = AllConfigs.SERVER.kinetics.harvesterReplants.get();
if (state.getBlock() instanceof CropBlock) {
CropBlock crop = (CropBlock) state.getBlock();
if (harvestPartial)
return state.getValue(crop.getAgeProperty()) != 0 || !replant;
return crop.isMaxAge(state);
}
if (state.getCollisionShape(world, pos).isEmpty() || state.getBlock() instanceof CocoaBlock) {
for (Property<?> property : state.getProperties()) {
if (!(property instanceof IntegerProperty))
continue;
IntegerProperty ageProperty = (IntegerProperty) property;
if (!property.getName().equals(BlockStateProperties.AGE_1.getName()))
continue;
int age = state.getValue(ageProperty).intValue();
if (state.getBlock() instanceof SweetBerryBushBlock && age <= 1 && replant)
continue;
if (age == 0 && replant || !harvestPartial && (ageProperty.getPossibleValues().size() - 1 != age))
continue;
return true;
}
}
return false;
}
use of net.minecraft.world.level.block.SweetBerryBushBlock in project Shelve by Mssstream.
the class HarvesterBlock method harvest.
public void harvest(Level lev, BlockState state, BlockPos pos) {
if (state.getBlock() instanceof CropBlock) {
if (state.getValue(CropBlock.AGE) == 7) {
lev.destroyBlock(pos, true);
lev.playSound(null, pos, SoundEvents.CROP_BREAK, SoundSource.BLOCKS, 0.8f, 1.0f);
lev.setBlockAndUpdate(pos, state.setValue(CropBlock.AGE, 1));
}
} else if (state.getBlock() instanceof NetherWartBlock) {
if (state.getValue(NetherWartBlock.AGE) == 3) {
lev.destroyBlock(pos, true);
lev.playSound(null, pos, SoundEvents.NETHER_WART_BREAK, SoundSource.BLOCKS, 0.8f, 1.0f);
lev.setBlockAndUpdate(pos, state.setValue(NetherWartBlock.AGE, 0));
}
} else if (state.getBlock() instanceof SweetBerryBushBlock) {
if (state.getValue(SweetBerryBushBlock.AGE) == 3) {
int j = 1 + lev.random.nextInt(2);
popResource(lev, pos, new ItemStack(Items.SWEET_BERRIES, j + 1));
lev.playSound((Player) null, pos, SoundEvents.SWEET_BERRY_BUSH_PICK_BERRIES, SoundSource.BLOCKS, 1.0F, 0.8F + lev.random.nextFloat() * 0.4F);
lev.setBlock(pos, state.setValue(SweetBerryBushBlock.AGE, Integer.valueOf(1)), 2);
}
} else {
}
}
Aggregations