Search in sources :

Example 1 with BlockWaypoint

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;
}
Also used : BlockDoor(net.minecraft.block.BlockDoor) BlockWaypoint(com.minecolonies.coremod.blocks.BlockWaypoint) IBlockState(net.minecraft.block.state.IBlockState) BlockStairs(net.minecraft.block.BlockStairs) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) Template(net.minecraft.world.gen.structure.template.Template)

Aggregations

BlockWaypoint (com.minecolonies.coremod.blocks.BlockWaypoint)1 Block (net.minecraft.block.Block)1 BlockDoor (net.minecraft.block.BlockDoor)1 BlockStairs (net.minecraft.block.BlockStairs)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1 Template (net.minecraft.world.gen.structure.template.Template)1