Search in sources :

Example 1 with BlockWorldScale

use of betterwithaddons.block.BlockWorldScale in project BetterWithAddons by DaedalusGame.

the class TileEntityWorldScaleActive method update.

@Override
public void update() {
    //if (!this.worldObj.isRemote)
    //{
    BlockPos pos = this.getPos();
    if (!oldPos.equals(pos)) {
        unclaimAllChunks();
        claimAllChunks();
        setOldPos();
    }
    if (updateTick++ > UPDATE_TICKRATE) {
        ChunkPos chunkpos = new ChunkPos(pos);
        claimChunk(chunkpos);
        for (int z = -MAX_RANGE; z <= MAX_RANGE; z++) for (int x = -MAX_RANGE; x <= MAX_RANGE; x++) {
            if (z == x && x == 0)
                continue;
            BlockPos newpos = pos.add(x, 0, z);
            if (!world.isBlockLoaded(newpos))
                continue;
            IBlockState blockstate = world.getBlockState(newpos);
            ChunkPos newchunk = new ChunkPos(chunkpos.chunkXPos + x, chunkpos.chunkZPos + z);
            Block block = blockstate.getBlock();
            if (block instanceof BlockWorldScale) {
                boolean claimed = claimChunk(newchunk);
                if (!world.isRemote)
                    ((BlockWorldScale) block).setCracked(world, newpos, blockstate, !claimed);
            } else {
                unclaimChunk(newchunk);
            }
        }
        updateTick = 0;
    }
//}
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) ChunkPos(net.minecraft.util.math.ChunkPos) BlockWorldScale(betterwithaddons.block.BlockWorldScale)

Aggregations

BlockWorldScale (betterwithaddons.block.BlockWorldScale)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1 ChunkPos (net.minecraft.util.math.ChunkPos)1