use of com.minecolonies.coremod.blocks.BlockSolidSubstitution in project minecolonies by Minecolonies.
the class EntityAIStructureBuilder method requestMaterials.
/**
* Iterates through all the required resources and stores them in the building.
* Suppressing Sonar Rule Squid:S135
* The rule thinks we should have less continue and breaks.
* But in this case the rule does not apply because code would become unreadable and uneffective without.
*/
@SuppressWarnings(LOOPS_SHOULD_NOT_CONTAIN_MORE_THAN_A_SINGLE_BREAK_OR_CONTINUE_STATEMENT)
private void requestMaterials() {
if (job.getWorkOrder().isRequested()) {
return;
}
final AbstractBuildingWorker buildingWorker = getOwnBuilding();
if (buildingWorker instanceof BuildingBuilder) {
((BuildingBuilder) buildingWorker).resetNeededResources();
}
while (job.getStructure().findNextBlock()) {
@Nullable final Template.BlockInfo blockInfo = job.getStructure().getBlockInfo();
@Nullable final Template.EntityInfo entityInfo = job.getStructure().getEntityinfo();
if (entityInfo != null) {
requestEntityToBuildingIfRequired(entityInfo);
}
if (blockInfo == null) {
continue;
}
@Nullable IBlockState blockState = blockInfo.blockState;
@Nullable Block block = blockState.getBlock();
if (job.getStructure().isStructureBlockEqualWorldBlock() || (blockState.getBlock() instanceof BlockBed && blockState.getValue(BlockBed.PART).equals(BlockBed.EnumPartType.FOOT)) || (blockState.getBlock() instanceof BlockDoor && blockState.getValue(BlockDoor.HALF).equals(BlockDoor.EnumDoorHalf.UPPER))) {
continue;
}
if (block instanceof BlockSolidSubstitution) {
blockState = getSolidSubstitution(job.getStructure().getBlockPosition());
block = blockState.getBlock();
}
final Block worldBlock = BlockPosUtil.getBlock(world, job.getStructure().getBlockPosition());
if (block != null && block != Blocks.AIR && worldBlock != Blocks.BEDROCK && !(worldBlock instanceof AbstractBlockHut) && !isBlockFree(block, 0)) {
requestBlockToBuildingIfRequired((BuildingBuilder) getOwnBuilding(), blockState);
}
}
job.getWorkOrder().setRequested(true);
}
Aggregations