Example usage for net.minecraftforge.common.util BlockSnapshot getPos

List of usage examples for net.minecraftforge.common.util BlockSnapshot getPos

Introduction

In this page you can find the example usage for net.minecraftforge.common.util BlockSnapshot getPos.

Prototype

public BlockPos getPos() 

Source Link

Usage

From source file:hellfirepvp.astralsorcery.common.tile.TileTreeBeacon.java

License:Open Source License

private boolean updatePositionsFromSnapshots(World world, WorldBlockPos saplingPos, BlockPos origin) {
    boolean ret = false;
    if (!TreeCaptureHelper.oneTimeCatches.remove(saplingPos) && !world.capturedBlockSnapshots.isEmpty()
            && world.capturedBlockSnapshots.size() > 2) { //I guess then something grew after all?
        if (treePositions.getSize() + world.capturedBlockSnapshots.size() <= ConfigEntryTreeBeacon.maxCount) {
            for (BlockSnapshot snapshot : world.capturedBlockSnapshots) {
                IBlockState setBlock = snapshot.getCurrentBlock();
                if (!setBlock.getBlock().equals(BlocksAS.blockFakeTree)
                        && !setBlock.getBlock().equals(Blocks.DIRT)
                        && !setBlock.getBlock().equals(Blocks.GRASS)) {
                    world.setBlockState(snapshot.getPos(), BlocksAS.blockFakeTree.getDefaultState());
                    TileFakeTree tft = MiscUtils.getTileAt(world, snapshot.getPos(), TileFakeTree.class, true);
                    if (tft != null) {
                        tft.setupTile(origin, setBlock);
                    }//  w  w  w.  j a va  2  s . c o  m
                    if (treePositions.offerElement(snapshot.getPos()))
                        ret = true;
                }
            }
        } else {
            for (BlockSnapshot snapshot : world.capturedBlockSnapshots) {
                IBlockState current = world.getBlockState(snapshot.getPos());
                world.notifyBlockUpdate(snapshot.getPos(), current, current, 3);
            }
        }
    }
    world.capturedBlockSnapshots.clear();
    return ret;
}