use of net.minecraft.world.level.block.CocoaBlock 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.CocoaBlock in project Create by Creators-of-Create.
the class ContraptionCollider method isCollidingWithWorld.
public static boolean isCollidingWithWorld(Level world, TranslatingContraption contraption, BlockPos anchor, Direction movementDirection) {
for (BlockPos pos : contraption.getColliders(world, movementDirection)) {
BlockPos colliderPos = pos.offset(anchor);
if (!world.isLoaded(colliderPos))
return true;
BlockState collidedState = world.getBlockState(colliderPos);
StructureBlockInfo blockInfo = contraption.getBlocks().get(pos);
boolean emptyCollider = collidedState.getCollisionShape(world, pos).isEmpty();
if (collidedState.getBlock() instanceof CocoaBlock)
continue;
if (AllMovementBehaviours.contains(blockInfo.state.getBlock())) {
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state.getBlock());
if (movementBehaviour instanceof BlockBreakingMovementBehaviour) {
BlockBreakingMovementBehaviour behaviour = (BlockBreakingMovementBehaviour) movementBehaviour;
if (!behaviour.canBreak(world, colliderPos, collidedState) && !emptyCollider)
return true;
continue;
}
if (movementBehaviour instanceof HarvesterMovementBehaviour) {
HarvesterMovementBehaviour harvesterMovementBehaviour = (HarvesterMovementBehaviour) movementBehaviour;
if (!harvesterMovementBehaviour.isValidCrop(world, colliderPos, collidedState) && !harvesterMovementBehaviour.isValidOther(world, colliderPos, collidedState) && !emptyCollider)
return true;
continue;
}
}
if (AllBlocks.PULLEY_MAGNET.has(collidedState) && pos.equals(BlockPos.ZERO) && movementDirection == Direction.UP)
continue;
if (!collidedState.getMaterial().isReplaceable() && !emptyCollider) {
return true;
}
}
return false;
}
Aggregations