use of com.minecolonies.coremod.blocks.BlockWaypoint in project minecolonies by Minecolonies.
the class StructureWrapper method isStructureBlockEqualWorldBlock.
/**
* Checks if the block in the world is the same as what is in the structure.
*
* @return true if the structure block equals the world block.
*/
public boolean isStructureBlockEqualWorldBlock() {
final IBlockState structureBlockState = structure.getBlockState(this.getLocalPosition());
final Block structureBlock = structureBlockState.getBlock();
// All worldBlocks are equal the substitution block
if (structureBlock == ModBlocks.blockSubstitution) {
return true;
}
final BlockPos worldPos = this.getBlockPosition();
final IBlockState worldBlockState = world.getBlockState(worldPos);
if (structureBlock == ModBlocks.blockSolidSubstitution && worldBlockState.getMaterial().isSolid()) {
return true;
}
final Block worldBlock = worldBlockState.getBlock();
// For the time being any flower pot is equal to each other.
if (structureBlock instanceof BlockDoor || structureBlock == Blocks.FLOWER_POT) {
return structureBlock == worldBlock;
} else if (worldBlock == ModBlocks.blockRack) {
return BlockMinecoloniesRack.shouldBlockBeReplacedWithRack(structureBlock);
} else if ((structureBlock instanceof BlockStairs && structureBlockState == worldBlockState) || BlockUtils.isGrassOrDirt(structureBlock, worldBlock, structureBlockState, worldBlockState) || structureBlock instanceof BlockWaypoint) {
return true;
}
final Template.EntityInfo entityInfo = structure.getEntityinfo(this.getLocalPosition());
if (entityInfo != null) {
return false;
// todo get entity at position.
}
// had this problem in a super flat world, causes builder to sit doing nothing because placement failed
return worldPos.getY() <= 0 || structureBlockState == worldBlockState;
}
Aggregations