Java Code Examples for net.minecraft.init.Blocks#air()

The following examples show how to use net.minecraft.init.Blocks#air() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private BlockPos getClosestBlockAll() {
    final Minecraft mc = Minecraft.getMinecraft();
    float maxDist = this.distance.getValue();

    BlockPos ret = null;

    for (float x = maxDist; x >= -maxDist; x--) {
        for (float y = maxDist; y >= -maxDist; y--) {
            for (float z = maxDist; z >= -maxDist; z--) {
                final BlockPos pos = new BlockPos(mc.player.posX + x, mc.player.posY + y, mc.player.posZ + z);
                final double dist = mc.player.getDistance(pos.getX(), pos.getY(), pos.getZ());
                if (dist <= maxDist && (mc.world.getBlockState(pos).getBlock() != Blocks.AIR && !(mc.world.getBlockState(pos).getBlock() instanceof BlockLiquid)) && canBreak(pos)) {
                    if (pos.getY() >= mc.player.posY) {
                        maxDist = (float) dist;
                        ret = pos;
                    }
                }
            }
        }
    }

    return ret;
}
 
Example 2
private BlockPos getClosestBlockSelection() {
    final Minecraft mc = Minecraft.getMinecraft();
    float maxDist = this.distance.getValue();

    BlockPos ret = null;

    for (float x = maxDist; x >= -maxDist; x--) {
        for (float y = maxDist; y >= -maxDist; y--) {
            for (float z = maxDist; z >= -maxDist; z--) {
                final BlockPos pos = new BlockPos(mc.player.posX + x, mc.player.posY + y, mc.player.posZ + z);
                final double dist = mc.player.getDistance(pos.getX(), pos.getY(), pos.getZ());
                if (dist <= maxDist && (mc.world.getBlockState(pos).getBlock() != Blocks.AIR && !(mc.world.getBlockState(pos).getBlock() instanceof BlockLiquid)) && mc.world.getBlockState(pos).getBlock() == this.selected && canBreak(pos)) {
                    if (pos.getY() >= mc.player.posY) {
                        maxDist = (float) dist;
                        ret = pos;
                    }
                }
            }
        }
    }

    return ret;
}
 
Example 3
private void registerNOVAToMinecraft() {
	BlockManager blockManager = Game.blocks();

	//Register air block
	BlockFactory airBlock = new BlockFactory("air", () -> new BWBlock(Blocks.AIR) {
		@Override
		public boolean canReplace() {
			return true;
		}
	}, evt -> {
	});

	blockManager.register(airBlock);

	//NOTE: There should NEVER be blocks already registered in preInit() stage of a NativeConverter.
	Game.events().on(BlockEvent.Register.class).bind(evt -> registerNovaBlock(evt.blockFactory));
}
 
Example 4
@Override
public boolean Load()
{
	if(super.Load())
	{
		ArrayList<SchemBlock> map = new ArrayList<SchemBlock>();
		for(SchemBlock b : blockMap)
		{
			if(b.state.getBlock() != Blocks.AIR)
				map.add(b);
		}
		blockMap = map;
		return true;
	}
	return false;
}
 
Example 5
private void placeBlock(BlockPos pos) {
    final Minecraft mc = Minecraft.getMinecraft();
    
    BlockPos[][] posit = {{pos.add(0, 0, 1), pos.add(0, 0, -1)}, {pos.add(0, 1, 0), pos.add(0, -1, 0)}, {pos.add(1, 0, 0),pos.add(-1, 0, 0)}};
    EnumFacing[][] facing = {{EnumFacing.NORTH, EnumFacing.SOUTH}, {EnumFacing.DOWN, EnumFacing.UP}, {EnumFacing.WEST, EnumFacing.EAST}}; // Facing reversed as blocks are placed while facing in the opposite direction

    for (int i=0; i<6; i++) {
        final Block block = mc.world.getBlockState(posit[i/2][i%2]).getBlock();
        final boolean activated = block.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
        if (block != null && block != Blocks.AIR && !(block instanceof BlockLiquid)) {
            if (activated)
                mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
            if (mc.playerController.processRightClickBlock(mc.player, mc.world, posit[i/2][i%2], facing[i/2][i%2], new Vec3d(0d, 0d, 0d), EnumHand.MAIN_HAND) != EnumActionResult.FAIL)
                mc.player.swingArm(EnumHand.MAIN_HAND);
            if (activated)
                mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
        }
    }
}
 
Example 6
public int getTotalGrowthFromAdjacentLight() {

        for (int i = 1; i < EmergingTechnologyConfig.HYDROPONICS_MODULE.GROWLIGHT.lightBlockRange; i++) {

            BlockPos pos = this.pos.add(0, i + 1, 0);

            Block aboveBlock = this.world.getBlockState(pos).getBlock();

            if (aboveBlock instanceof Light) {
                TileEntity tileEntity = this.world.getTileEntity(pos);
                if (tileEntity instanceof LightTileEntity) {
                    LightTileEntity lightTileEntity = (LightTileEntity) tileEntity;
                    int lightGrowthModifier = lightTileEntity.getGrowthProbabilityForBulb();
                    int lightBoostModifier = lightTileEntity.getSpecificPlantGrowthBoostForBulb();
                    return lightGrowthModifier + lightBoostModifier;
                }
            } else if (aboveBlock == Blocks.AIR || PlantHelper.isPlantBlock(aboveBlock)) {
                continue;
            } else {
                return 0;
            }
        }

        return 0;
    }
 
Example 7
@Override
public Optional<Block> getBlock(Vector3D position) {
	IBlockState blockState = access.getBlockState(new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ()));
	net.minecraft.block.Block block = blockState == null ? null : blockState.getBlock();
	if (blockState == null || block == null || block == Blocks.AIR) {
		Block airBlock = Game.blocks().getAirBlock().build();
		airBlock.components.add(new FWBlockTransform(airBlock, this, position));
		return Optional.of(airBlock);
	}
	if (block instanceof FWBlock) {
		return Optional.of(((FWBlock) block).getBlockInstance(access, position));
	} else {
		BWBlock wrappedBlock = new BWBlock(blockState, this, position);
		Game.blocks().get(Objects.toString(net.minecraft.block.Block.REGISTRY.getNameForObject(block)))
			.ifPresent(blockFactory -> wrappedBlock.components.getOrAdd(new FactoryProvider(blockFactory)));
		return Optional.of(wrappedBlock);
	}
}
 
Example 8
@Override
synchronized public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
{
    // Item model
    if (state == null)
    {
        return this.itemQuads;
    }

    IExtendedBlockState extendedState = (IExtendedBlockState) state;
    IBlockState actualState = extendedState.getClean();
    IBlockState camoState = extendedState.getValue(BlockEnderUtilitiesTileEntity.CAMOBLOCKSTATE);
    boolean validCamo = camoState != null && camoState.getBlock() != Blocks.AIR;

    Optional<IBlockState> key = Optional.of(actualState);
    Map<Optional<IBlockState>, ImmutableMap<Optional<EnumFacing>, ImmutableList<BakedQuad>>> cache = validCamo ? QUAD_CACHE_CAMO : QUAD_CACHE_NORMAL;
    ImmutableMap<Optional<EnumFacing>, ImmutableList<BakedQuad>> map = cache.get(key);

    if (map == null)
    {
        IBakedModel bakedModel = validCamo ? this.getBakedOverlayModel(actualState) : this.getBakedBaseModel(actualState);
        map = this.getQuadsForState(bakedModel, extendedState, rand, validCamo);
        cache.put(key, map);
    }

    return map.get(Optional.ofNullable(side));
}
 
Example 9
Source Project: AdvancedRocketry   File: MapGenLargeCrystal.java    License: MIT License 5 votes vote down vote up
private int getHeightValue(int x, int z, ChunkPrimer blocks) {
	int y;
	if(x > 15 || x < 0 || z > 15 || z < 0)
		return 0;
	for(y = 255; blocks.getBlockState(x, y, z).getBlock() == Blocks.AIR && y > 0; y--)
	{
		//System.out.println(y);
	}
	return y;
}
 
Example 10
private Vec3d getFirstBlock(double[] dir) {
    final Minecraft mc = Minecraft.getMinecraft();
    Vec3d pos = new Vec3d(mc.player.posX, mc.player.posY - 1, mc.player.posZ);
    Vec3d dirpos = new Vec3d(mc.player.posX + dir[0], mc.player.posY - 1, mc.player.posZ + dir[1]);
    if (mc.world.getBlockState(new BlockPos(pos.x, pos.y, pos.z)).getBlock() == Blocks.AIR)
        return pos;
    if (mc.world.getBlockState(new BlockPos(dirpos.x, dirpos.y, dirpos.z)).getBlock() == Blocks.AIR)
        if (mc.world.getBlockState(new BlockPos(pos.x, dirpos.y, dirpos.z)).getBlock() == Blocks.AIR && mc.world.getBlockState(new BlockPos(dirpos.x, dirpos.y, pos.z)).getBlock() == Blocks.AIR) {
            return new Vec3d(dirpos.x, pos.y, pos.z);
        } else {
            return dirpos;
        }
    return null;
}
 
Example 11
@Nullable
private IBlockState getPlacementStateForPosition(int position, World world, BlockPos pos, FakePlayer player, ItemStack stack)
{
    if (this.blockInfoTaken[position] != null)
    {
        return this.blockInfoTaken[position].getState();
    }

    // The Normal variant shouldn't place blocks into positions it didn't take them from,
    // unless it hasn't taken any blocks but was instead extended with inserted-only items.
    if ((this.isAdvanced() || this.numTaken == 0) &&
         stack.isEmpty() == false && stack.getItem() instanceof ItemBlock)
    {
        ItemBlock itemBlock = (ItemBlock) stack.getItem();
        Block block = itemBlock.getBlock();

        if (block != null && block != Blocks.AIR)
        {
            int meta = itemBlock.getMetadata(stack.getMetadata());
            player.rotationYaw = this.getFacing().getHorizontalAngle();

            return block.getStateForPlacement(world, pos, EnumFacing.UP, 0.5f, 1f, 0.5f, meta, player, EnumHand.MAIN_HAND);
        }
    }

    return null;
}
 
Example 12
Source Project: Kettle   File: CraftBlock.java    License: GNU General Public License v3.0 5 votes vote down vote up
public boolean breakNaturally() {
    // Order matters here, need to drop before setting to air so skulls can get their data
    net.minecraft.block.Block block = this.getNMSBlock();
    byte data = getData();
    boolean result = false;

    if (block != null && block != Blocks.AIR) {
        block.dropBlockAsItemWithChance(chunk.getHandle().getWorld(), new BlockPos(x, y, z), block.getStateFromMeta(data), 1.0F, 0);
        result = true;
    }

    setTypeId(Material.AIR.getId());
    return result;
}
 
Example 13
public boolean generate(World world, Random rand, BlockPos position)
{
	while (world.isAirBlock(position) && position.getY() > 2)
	{
		position = position.down();
	}

	int i = rand.nextInt(1 +(this.width - 2)) + 2;
	int offset = -2 + rand.nextInt(4);
	if(world.getBlockState(position.down()).getBlock() == Blocks.LAVA)
		position = position.down();

	for (int x = position.getX() - i; x <= position.getX() + i; ++x)
	{
		for (int z = position.getZ() - i; z <= position.getZ() + i; ++z)
		{
			int xx = x - position.getX();
			int zz = z - position.getZ();

			boolean doPlace = xx * xx + zz * zz <= i * i || rand.nextInt(3) == 0;

			if (doPlace)
			{
				for (int yy = position.getY() - 1; yy <= position.getY() + offset; ++yy)
				{
					BlockPos blockpos = new BlockPos(x, yy, z);
					Block block = world.getBlockState(blockpos).getBlock();

					if (block == Blocks.LAVA || block == Blocks.NETHERRACK || block == Blocks.AIR || block == Blocks.SOUL_SAND)
					{
						world.setBlockState(blockpos, this.block.getDefaultState(), 2);
					}
				}
			}
		}
	}

	return true;
}
 
Example 14
protected void genRoom(ChunkPrimer primer, Dungeon dungeon, DungeonRoom room)
{
	RoomSchematic schem = room.getSchematic();

	for(SchemBlock b : schem.getProcessedBlockList(dungeon))
	{
		DungeonDirection borderFacing = isOnBorder(b);
		if(borderFacing != null && b.state.getBlock() == Blocks.OAK_DOOR)
		{
			if(!room.hasConnection(borderFacing))
			{
				primer.setBlockState(8+b.pos.getX(), room.getPosition().getY() + b.pos.getY(), 8+b.pos.getZ(), dungeon.blockMap.get("dungeon_wall"));
				continue;
			}
			else if(room.hasConnection(borderFacing) && !room.getConnection(borderFacing).placeDoor)
			{
				primer.setBlockState(8+b.pos.getX(), room.getPosition().getY() + b.pos.getY(), 8+b.pos.getZ(), Blocks.AIR.getDefaultState());
				continue;
			}
		}
		else if(borderFacing != null && b.state.getBlock() == Blocks.AIR)
		{
			if(!room.hasConnection(borderFacing) && b.pos.getY() < 10)//the <10 check here makes sure that the surface sections of entrances
			{
				primer.setBlockState(8+b.pos.getX(), room.getPosition().getY() + b.pos.getY(), 8+b.pos.getZ(), dungeon.blockMap.get("dungeon_wall"));
				continue;
			}
		}
		primer.setBlockState(8+b.pos.getX(), room.getPosition().getY() + b.pos.getY(), 8+b.pos.getZ(), b.state);
	}
}
 
Example 15
Source Project: EmergingTechnology   File: HarvesterTileEntity.java    License: MIT License 4 votes vote down vote up
private void tryPlant(EnumFacing facing) {

        if (facing == EnumFacing.UP || facing == EnumFacing.DOWN) {
            return;
        }

        // If non-break-harvest plant, return
        if (HarvesterHelper.isInteractableCrop(getTargetBlockState(facing).getBlock())) {
            return;
        }

        ItemStack inputStack = getInputStack();

        // If no seeds to plant, return
        if (StackHelper.isItemStackEmpty(inputStack)) {
            return;
        }

        // Probably not neccessary
        if (getTargetBlockState(facing) == null) {
            return;
        }

        // If crop space is occupied, return
        if (getTargetBlockState(facing).getBlock() != Blocks.AIR) {
            return;
        }

        BlockPos soilTarget = getTarget(facing).add(0, -1, 0);

        if (!PlantHelper.isValidSoil(getWorld(), soilTarget)) {
            return;
        }
    
        IBlockState blockStateToPlace = PlantHelper.getBlockStateFromItemStackForPlanting(inputStack, getWorld(),
                getTarget(facing));

        // No crop block associated with this item, return
        if (blockStateToPlace == null) {
            return;
        }

        world.setBlockState(getTarget(facing), blockStateToPlace, 3);

        this.itemHandler.extractItem(0, 1, false);
    }
 
Example 16
Source Project: Sakura_mod   File: WorldGenMapleTree.java    License: MIT License 4 votes vote down vote up
/**
 * Fill the given area with the selected blocks
 */
private void fallenLeaves(World worldIn,BlockPos pos, int xADD, int yADD, int zADD, IBlockState insideBlockState){
	int xx = pos.getX();
    int yy = pos.getY();
    int zz = pos.getZ();
    
    boolean setFlg = false;
    int YEND = 4;
    for (int xx1 = xx - xADD; xx1 <= xx + xADD; xx1++) {
      for (int zz1 = zz - zADD; zz1 <= zz + zADD; zz1++) {
        if (((xx1 != xx - xADD) || (zz1 != zz - zADD)) && ((xx1 != xx + xADD) || (zz1 != zz - zADD)) && ((xx1 != xx - xADD) || (zz1 != zz + zADD)) && ((xx1 != xx + xADD) || (zz1 != zz + zADD)) && (((xx1 >= xx - xADD + 1) && (xx1 <= xx + xADD - 1) && (zz1 >= zz - zADD + 1) && (zz1 <= zz + zADD - 1)) || (worldIn.rand.nextInt(2) != 0)))
        {
          setFlg = false;
          int yy1 = yy + yADD;
          Block cBl = worldIn.getBlockState(new BlockPos(xx1, yy + yADD, zz1)).getBlock();
          
          if ((cBl == Blocks.AIR) || (cBl instanceof BlockLeaves) || (cBl == BlockLoader.CHESTNUTBURR)) {
            for (yy1 = yy + yADD; yy1 >= yy - YEND; yy1--)
            {
              boolean cAir = worldIn.isAirBlock(new BlockPos(xx1, yy1, zz1));
              cBl = worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).getBlock();
              if ((cBl == Blocks.AIR) || ((cBl != Blocks.GRASS) && !(cBl instanceof BlockLeaves) && (!worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).isOpaqueCube())))
              {
                if (cBl != Blocks.AIR) {
                  break;
                }
              }
              else if (cAir)
              {
                setFlg = true;
                break;
              }
            }
          }
          if (setFlg) {
            setBlockAndNotifyAdequately(worldIn, new BlockPos(xx1, yy1, zz1), insideBlockState);
          }
        }
      }
    }
}
 
Example 17
Source Project: Sakura_mod   File: WorldGenBigMaple.java    License: MIT License 4 votes vote down vote up
/**
 * Fill the given area with the selected blocks
 */
private void fallenLeaves(World worldIn,BlockPos pos, int xADD, int yADD, int zADD, IBlockState insideBlockState){
	int xx = pos.getX();
    int yy = pos.getY();
    int zz = pos.getZ();
    
    boolean setFlg = false;
    int YEND = 4;
    for (int xx1 = xx - xADD; xx1 <= xx + xADD; xx1++) {
      for (int zz1 = zz - zADD; zz1 <= zz + zADD; zz1++) {
        if (((xx1 != xx - xADD) || (zz1 != zz - zADD)) && ((xx1 != xx + xADD) || (zz1 != zz - zADD)) && ((xx1 != xx - xADD) || (zz1 != zz + zADD)) && ((xx1 != xx + xADD) || (zz1 != zz + zADD)) && (((xx1 >= xx - xADD + 1) && (xx1 <= xx + xADD - 1) && (zz1 >= zz - zADD + 1) && (zz1 <= zz + zADD - 1)) || (worldIn.rand.nextInt(2) != 0)))
        {
          setFlg = false;
          int yy1 = yy + yADD;
          Block cBl = worldIn.getBlockState(new BlockPos(xx1, yy + yADD, zz1)).getBlock();
          
          if ((cBl == Blocks.AIR) || (cBl instanceof BlockLeaves) || (cBl == BlockLoader.CHESTNUTBURR)) {
            for (yy1 = yy + yADD; yy1 >= yy - YEND; yy1--)
            {
              boolean cAir = worldIn.isAirBlock(new BlockPos(xx1, yy1, zz1));
              cBl = worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).getBlock();
              if ((cBl == Blocks.AIR) || ((cBl != Blocks.GRASS) && !(cBl instanceof BlockLeaves) && (!worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).isOpaqueCube())))
              {
                if (cBl != Blocks.AIR) {
                  break;
                }
              }
              else if (cAir)
              {
                setFlg = true;
                break;
              }
            }
          }
          if (setFlg) {
            setBlockAndNotifyAdequately(worldIn, new BlockPos(xx1, yy1, zz1), insideBlockState);
          }
        }
      }
    }
}
 
Example 18
@Override
public void handleUpdateTag(NBTTagCompound tag)
{
    if (tag.hasKey("r"))
    {
        this.setFacing(EnumFacing.byIndex((byte)(tag.getByte("r") & 0x07)));
    }

    if (tag.hasKey("o", Constants.NBT.TAG_STRING))
    {
        this.ownerData = new OwnerData(tag.getString("o"), tag.getBoolean("pu"));
    }

    if (tag.hasKey("Camo", Constants.NBT.TAG_INT))
    {
        this.camoState = Block.getStateById(tag.getInteger("Camo"));

        World world = this.getWorld();
        BlockPos pos = this.getPos();
        IBlockState stateSelf = world.getBlockState(pos);

        // Temporarily place the target block to be able to grab its data
        if (this.camoState != null && this.camoState.getBlock() != Blocks.AIR)
        {
            try
            {
                BlockUtils.setBlockToAirWithoutSpillingContents(world, pos, 16);

                if (world.setBlockState(pos, this.camoState, 16))
                {
                    if (tag.hasKey("CD", Constants.NBT.TAG_COMPOUND))
                    {
                        this.camoData = tag.getCompoundTag("CD");
                        TileEntity te = world.getTileEntity(pos);

                        if (te != null)
                        {
                            te.handleUpdateTag(this.camoData);
                        }
                    }

                    this.camoState = this.camoState.getActualState(world, pos);
                    this.camoStateExtended = this.camoState.getBlock().getExtendedState(this.camoState, world, pos);

                    BlockUtils.setBlockToAirWithoutSpillingContents(world, pos, 16);
                    world.setBlockState(pos, stateSelf, 16);
                    this.validate(); // re-validate after being removed by the setBlockState() to air
                    world.setTileEntity(pos, this);
                }
            }
            catch (Exception e)
            {
                EnderUtilities.logger.warn("Exception while trying to grab the Extended state for a camo block: {}", this.camoState, e);
            }
        }
    }
    else
    {
        this.camoState = null;
        this.camoStateExtended = null;
    }

    this.getWorld().checkLightFor(EnumSkyBlock.BLOCK, this.getPos());
    this.notifyBlockUpdate(this.getPos());
}
 
Example 19
private static boolean setSchematicBlockStates(BlockPos posStart, BlockPos posEnd, IBlockState state)
{
    if (posStart != null && posEnd != null)
    {
        SubChunkPos cpos = new SubChunkPos(posStart);
        List<PlacementPart> list = DataManager.getSchematicPlacementManager().getAllPlacementsTouchingSubChunk(cpos);

        if (list.isEmpty() == false)
        {
            for (PlacementPart part : list)
            {
                if (part.getBox().containsPos(posStart))
                {
                    String regionName = part.getSubRegionName();
                    SchematicPlacement schematicPlacement = part.getPlacement();
                    SubRegionPlacement placement = schematicPlacement.getRelativeSubRegionPlacement(regionName);
                    ISchematic schematic = schematicPlacement.getSchematic();
                    ISchematicRegion region = schematic.getSchematicRegion(regionName);

                    if (region == null)
                    {
                        continue;
                    }

                    ILitematicaBlockStateContainer container = region.getBlockStateContainer();
                    BlockPos posStartSchematic = SchematicUtils.getSchematicContainerPositionFromWorldPosition(posStart, schematic,
                            regionName, schematicPlacement, placement, container);
                    BlockPos posEndSchematic = SchematicUtils.getSchematicContainerPositionFromWorldPosition(posEnd, schematic,
                            regionName, schematicPlacement, placement, container);

                    if (posStartSchematic != null && posEndSchematic != null)
                    {
                        BlockPos posMin = PositionUtils.getMinCorner(posStartSchematic, posEndSchematic);
                        BlockPos posMax = PositionUtils.getMaxCorner(posStartSchematic, posEndSchematic);
                        final int minX = Math.max(posMin.getX(), 0);
                        final int minY = Math.max(posMin.getY(), 0);
                        final int minZ = Math.max(posMin.getZ(), 0);
                        final int maxX = Math.min(posMax.getX(), container.getSize().getX() - 1);
                        final int maxY = Math.min(posMax.getY(), container.getSize().getY() - 1);
                        final int maxZ = Math.min(posMax.getZ(), container.getSize().getZ() - 1);
                        long totalBlocks = schematic.getMetadata().getTotalBlocks();
                        long increment = 0;

                        state = SchematicUtils.getUntransformedBlockState(state, schematicPlacement, regionName);

                        for (int y = minY; y <= maxY; ++y)
                        {
                            for (int z = minZ; z <= maxZ; ++z)
                            {
                                for (int x = minX; x <= maxX; ++x)
                                {
                                    IBlockState stateOriginal = container.getBlockState(x, y, z);

                                    if (stateOriginal.getBlock() != Blocks.AIR)
                                    {
                                        increment = state.getBlock() != Blocks.AIR ? 0 : -1;
                                    }
                                    else
                                    {
                                        increment = state.getBlock() != Blocks.AIR ? 1 : 0;
                                    }

                                    totalBlocks += increment;

                                    container.setBlockState(x, y, z, state);
                                }
                            }
                        }

                        SchematicMetadata metadata = schematic.getMetadata();
                        metadata.setTotalBlocks(totalBlocks);
                        metadata.setTimeModifiedToNow();
                        metadata.setModifiedSinceSaved();

                        DataManager.getSchematicPlacementManager().markAllPlacementsOfSchematicForRebuild(schematic);

                        return true;
                    }

                    return false;
                }
            }
        }
    }

    return false;
}
 
Example 20
public static boolean isAnyAir(IBlockState state) {
	return state.getBlock() == Blocks.AIR || state.getBlock() == ModBlocks.FAKE_AIR;
}